Skip to content

Commit

Permalink
Adding Kingdoms support
Browse files Browse the repository at this point in the history
  • Loading branch information
markhughes committed Nov 29, 2016
1 parent fa959a0 commit 90001cf
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/me/markeh/ffw/FreshWilderness.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import me.markeh.ffw.integrations.Ignition;
import me.markeh.ffw.integrations.Integrations;
import me.markeh.ffw.integrations.factions.FactionsIgnition;
import me.markeh.ffw.integrations.kingdoms.KingdomsIgnition;
import me.markeh.ffw.integrations.townships.TownshipsIgnition;
import me.markeh.ffw.integrations.towny.TownyIgnition;
import me.markeh.ffw.regentask.RegenTask;
Expand Down Expand Up @@ -59,6 +60,7 @@ public void onEnable() {
Integrations.get().addIntegration(FactionsIgnition.get(), true);
Integrations.get().addIntegration(TownyIgnition.get(), true);
Integrations.get().addIntegration(TownshipsIgnition.get(), true);
Integrations.get().addIntegration(KingdomsIgnition.get(), true);

this.getServer().getPluginManager().registerEvents(this, this);

Expand Down
55 changes: 55 additions & 0 deletions src/me/markeh/ffw/integrations/kingdoms/KingdomsEngine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package me.markeh.ffw.integrations.kingdoms;

import org.bukkit.Chunk;
import org.kingdoms.constants.land.Land;
import org.kingdoms.constants.land.SimpleChunkLocation;
import org.kingdoms.manager.game.GameManagement;

import me.markeh.ffw.integrations.Engine;
import me.markeh.ffw.store.Config;

public class KingdomsEngine extends Engine {

@Override
public Boolean shouldReset(Chunk chunk) {
return ( ! this.isKingdomAt(chunk));
}

@Override
public Boolean runReset(Chunk chunk) {
return true;
}

@Override
public Boolean shouldLogAt(Chunk chunk) {
if (this.isKingdomAt(chunk)) return false;

if (Config.get().dontLogIfClaimNearby) {
for (int x = chunk.getX() - 1 ; x < 1 ; x = x + 15) {
for (int z = chunk.getZ() - 1 ; z < 1 ; z = z + 15) {
if (Math.sqrt(x * x + z * z) < (double) 1) {
Chunk nextChunk = chunk.getWorld().getChunkAt(x, z);
if ( ! this.isKingdomAt(nextChunk)) continue;

return false;
}
}
}
}

return true;
}

public Boolean isKingdomAt(Chunk chunk) {
SimpleChunkLocation schunk = new SimpleChunkLocation(chunk);

Land land = GameManagement.getLandManager().getOrLoadLand(schunk);

if (land == null || land.getOwner() == null) {
return false;
}

return true;
}

}
33 changes: 33 additions & 0 deletions src/me/markeh/ffw/integrations/kingdoms/KingdomsIgnition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package me.markeh.ffw.integrations.kingdoms;

import org.bukkit.Bukkit;

import me.markeh.ffw.integrations.Engine;
import me.markeh.ffw.integrations.Ignition;
public class KingdomsIgnition extends Ignition {

private static KingdomsIgnition i = new KingdomsIgnition();
public static KingdomsIgnition get() { return i; }

public KingdomsIgnition() {
this.setPluginName("Kingdoms");
}

private KingdomsEngine engine = null;

@Override
public Boolean isEnabled() {
return Bukkit.getPluginManager().isPluginEnabled("Kingdoms");
}

@Override
public Engine getEngine() {
if (this.engine == null) {
this.engine = new KingdomsEngine();
}

return this.engine;
}

}

0 comments on commit 90001cf

Please sign in to comment.