-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa959a0
commit 90001cf
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/me/markeh/ffw/integrations/kingdoms/KingdomsEngine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
33
src/me/markeh/ffw/integrations/kingdoms/KingdomsIgnition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} | ||
|