From 2b62daeed4943c81280914e4e8f8b630dade0a32 Mon Sep 17 00:00:00 2001 From: CJ Burkey Date: Tue, 25 Jul 2017 14:08:51 -0400 Subject: [PATCH] Dynmap support, cross world screw up. --- README.md | 4 +- pom.xml | 14 ++++ .../com/cjburkey/claimchunk/ClaimChunk.java | 74 +++++++++++-------- .../java/com/cjburkey/claimchunk/Econ.java | 63 ++++++++++++++++ .../java/com/cjburkey/claimchunk/Utils.java | 2 +- .../claimchunk/chunk/ChunkHandler.java | 34 +++++---- .../cjburkey/claimchunk/chunk/ChunkPos.java | 30 ++++---- .../claimchunk/cmd/CmdAccessChunks.java | 1 + .../claimchunk/cmd/CmdClaimChunk.java | 15 +++- .../claimchunk/cmd/CmdUnclaimChunk.java | 15 +++- .../claimchunk/dynmap/ChunkMarkerHandler.java | 7 ++ .../claimchunk/dynmap/ClaimChunkDynmap.java | 24 ++++++ .../event/PlayerMovementHandler.java | 10 +-- src/main/java/config.yml | 8 ++ src/main/java/plugin.yml | 3 +- src/main/java/writing.txt | 5 -- 16 files changed, 229 insertions(+), 80 deletions(-) create mode 100644 src/main/java/com/cjburkey/claimchunk/dynmap/ChunkMarkerHandler.java create mode 100644 src/main/java/com/cjburkey/claimchunk/dynmap/ClaimChunkDynmap.java delete mode 100644 src/main/java/writing.txt diff --git a/README.md b/README.md index 441701ed..6f75f2f8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Spigot plugin for 1.12+ allowing the claiming of chunks. +*(Should work with Spigot 1.11+ with titles enabled, if they're disabled, should work back a few versions)* + Page on SpigotMC can be found [HERE](https://www.spigotmc.org/resources/claimchunk.44458/). -Current version: **0.0.1** for Minecraft **1.12**. Requires [Vault](https://www.spigotmc.org/resources/vault.41918/). \ No newline at end of file +Current version: **0.0.2** for Minecraft **1.12**. Requires [Vault](https://www.spigotmc.org/resources/vault.41918/). \ No newline at end of file diff --git a/pom.xml b/pom.xml index 55013207..30f18d95 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,10 @@ natrolite-repo https://repo.natrolite.org/repository/maven-public/ + + dynmap-rep + http://repo.mikeprimm.com/ + @@ -19,5 +23,15 @@ 1.6.1 provided + + us.dynmap + dynmap + 2.6-SNAPSHOT + + + org.bukkit + bukkit + 1.12-R0.1-SNAPSHOT + \ No newline at end of file diff --git a/src/main/java/com/cjburkey/claimchunk/ClaimChunk.java b/src/main/java/com/cjburkey/claimchunk/ClaimChunk.java index 6c538431..4d09634e 100644 --- a/src/main/java/com/cjburkey/claimchunk/ClaimChunk.java +++ b/src/main/java/com/cjburkey/claimchunk/ClaimChunk.java @@ -4,30 +4,33 @@ import java.io.IOException; import java.util.UUID; import org.bukkit.Chunk; +import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; -import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; import com.cjburkey.claimchunk.chunk.AccessHandler; import com.cjburkey.claimchunk.chunk.ChunkHandler; import com.cjburkey.claimchunk.cmd.CmdAccessChunks; import com.cjburkey.claimchunk.cmd.CmdClaimChunk; import com.cjburkey.claimchunk.cmd.CmdUnclaimChunk; +import com.cjburkey.claimchunk.dynmap.ClaimChunkDynmap; import com.cjburkey.claimchunk.event.CancellableChunkEvents; import com.cjburkey.claimchunk.event.PlayerJoinHandler; import com.cjburkey.claimchunk.event.PlayerMovementHandler; -import net.milkbowl.vault.permission.Permission; public final class ClaimChunk extends JavaPlugin { private static ClaimChunk instance; + private boolean useEcon = false; + private boolean useDynmap = false; + private File dataFile; private File plyFile; private File accessFile; private Econ economy; - private Permission perms; + private ClaimChunkDynmap map; private Cacher cacher; private ChunkHandler chunkHandler; private AccessHandler accessHandler; @@ -38,26 +41,39 @@ public void onEnable() { plyFile = new File(getDataFolder(), "/data/playerCache.dat"); accessFile = new File(getDataFolder(), "/data/grantedAccess.dat"); economy = new Econ(); + map = new ClaimChunkDynmap(); cacher = new Cacher(); chunkHandler = new ChunkHandler(); accessHandler = new AccessHandler(); - if (!economy.setupEconomy(this)) { - Utils.err("Economy could not be setup. Make sure that you have an economy plugin (like Essentials) installed. ClaimChunk has been disabled."); - disable(); - return; - } - Utils.log("Economy set up."); - setupConfig(); Utils.log("Config set up."); - if (!setupPermissions()) { - Utils.err("Permissions could not be initialized. ClaimChunk has been disabled."); - disable(); - return; + useEcon = ((getServer().getPluginManager().getPlugin("Vault") != null) && getConfig().getBoolean("useEconomy")); + useDynmap = ((getServer().getPluginManager().getPlugin("dynmap") != null) && getConfig().getBoolean("useDynmap")); + if (useEcon) { + if (!economy.setupEconomy(this)) { + Utils.err("Economy could not be setup. Make sure that you have an economy plugin (like Essentials) installed. ClaimChunk has been disabled."); + disable(); + return; + } + Utils.log("Economy set up."); + getServer().getScheduler().scheduleSyncDelayedTask(this, () -> Utils.log("Money Format: " + economy.format(99132.76)), 0l); // Once everything is loaded. + } else { + Utils.log("Economy not enabled. Either it was disabled with config or Vault was not found."); + } + + if (useDynmap) { + if (!map.registerAndSuch()) { + Utils.log("There was an error while enabling Dynmap support."); + disable(); + return; + } else { + Utils.log("Dynmap support enabled."); + } + } else { + Utils.log("Dynmap support not enabled. Either it was disabled with config or Dynmap was not found."); } - Utils.log("Permissions set up."); setupCommands(); Utils.log("Commands set up."); @@ -77,14 +93,14 @@ public void onEnable() { Utils.log("Initialization complete."); } - public boolean canEdit(int x, int z, UUID player) { - if (!chunkHandler.isClaimed(x, z)) { + public boolean canEdit(World world, int x, int z, UUID player) { + if (!chunkHandler.isClaimed(world, x, z)) { return true; } - if (chunkHandler.isOwner(x, z, player)) { + if (chunkHandler.isOwner(world, x, z, player)) { return true; } - if (accessHandler.hasAccess(chunkHandler.getOwner(x, z), player)) { + if (accessHandler.hasAccess(chunkHandler.getOwner(world, x, z), player)) { return true; } return false; @@ -93,7 +109,7 @@ public boolean canEdit(int x, int z, UUID player) { public void cancelEventIfNotOwned(Player ply, Chunk chunk, Cancellable e) { if (getConfig().getBoolean("blockInteractionInOtherPlayersChunks")) { if (!e.isCancelled()) { - if (!canEdit(chunk.getX(), chunk.getZ(), ply.getUniqueId())) { + if (!canEdit(chunk.getWorld(), chunk.getX(), chunk.getZ(), ply.getUniqueId())) { e.setCancelled(true); Utils.toPlayer(ply, Utils.getConfigColor("errorColor"), Utils.getLang("CannotEditThisChunk")); } @@ -118,12 +134,6 @@ private void setupCommands() { getCommand("accesschunks").setExecutor(new CmdAccessChunks()); } - private boolean setupPermissions() { - RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Permission.class); - perms = rsp.getProvider(); - return perms != null; - } - public void onDisable() { try { cacher.write(plyFile); @@ -143,10 +153,6 @@ public Econ getEconomy() { return economy; } - public Permission getPermission() { - return perms; - } - public Cacher getPlayers() { return cacher; } @@ -171,6 +177,14 @@ public File getAccessFile() { return accessFile; } + public boolean useEconomy() { + return useEcon; + } + + public boolean useDynmap() { + return useDynmap; + } + public static ClaimChunk getInstance() { return instance; } diff --git a/src/main/java/com/cjburkey/claimchunk/Econ.java b/src/main/java/com/cjburkey/claimchunk/Econ.java index 3f9426bb..2fc3f60a 100644 --- a/src/main/java/com/cjburkey/claimchunk/Econ.java +++ b/src/main/java/com/cjburkey/claimchunk/Econ.java @@ -1,7 +1,12 @@ package com.cjburkey.claimchunk; +import java.text.NumberFormat; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; import org.bukkit.plugin.RegisteredServiceProvider; import net.milkbowl.vault.economy.Economy; +import net.milkbowl.vault.economy.EconomyResponse; public final class Econ { @@ -19,6 +24,64 @@ public boolean setupEconomy(ClaimChunk instance) { return econ != null; } + public double getMoney(UUID ply) { + OfflinePlayer op = getOfflinePlayer(ply); + if (op != null && op.hasPlayedBefore()) { + return econ.getBalance(op); + } + return -1.0d; + } + + /** + * Take money from the player. + * @param ply Player purchasing. + * @param cost The cost of the purchase. + * @return Whether or not the transaction was successful. + */ + public boolean buy(UUID ply, double cost) { + if (getMoney(ply) >= cost) { + EconomyResponse r = takeMoney(ply, cost); + if (r.type.equals(EconomyResponse.ResponseType.SUCCESS)) { + return true; + } + } + return false; + } + + public void setMoney(UUID ply, double amt) { + double current = getMoney(ply); + double toAdd = amt - current; + if (toAdd < 0) { + takeMoney(ply, Math.abs(toAdd)); + return; + } + addMoney(ply, toAdd); + } + + public EconomyResponse addMoney(UUID ply, double amt) { + OfflinePlayer op = getOfflinePlayer(ply); + if (op != null) { + return econ.depositPlayer(op, Math.abs(amt)); + } + return null; + } + + public EconomyResponse takeMoney(UUID ply, double amt) { + OfflinePlayer op = getOfflinePlayer(ply); + if (op != null) { + return econ.withdrawPlayer(op, Math.abs(amt)); + } + return null; + } + + public String format(double amt) { + return NumberFormat.getCurrencyInstance().format(amt); + } + + private OfflinePlayer getOfflinePlayer(UUID id) { + return Bukkit.getOfflinePlayer(id); + } + public Economy getEconomy() { return econ; } diff --git a/src/main/java/com/cjburkey/claimchunk/Utils.java b/src/main/java/com/cjburkey/claimchunk/Utils.java index e5622620..f603db17 100644 --- a/src/main/java/com/cjburkey/claimchunk/Utils.java +++ b/src/main/java/com/cjburkey/claimchunk/Utils.java @@ -55,7 +55,7 @@ public static void toPlayer(Player ply, ChatColor color, String msg) { } public static boolean hasPerm(CommandSender sender, String perm) { - return ClaimChunk.getInstance().getPermission().has(sender, perm); + return sender.hasPermission(perm); } private static String prepMsg(Object msg) { diff --git a/src/main/java/com/cjburkey/claimchunk/chunk/ChunkHandler.java b/src/main/java/com/cjburkey/claimchunk/chunk/ChunkHandler.java index e17fa736..fec3d964 100644 --- a/src/main/java/com/cjburkey/claimchunk/chunk/ChunkHandler.java +++ b/src/main/java/com/cjburkey/claimchunk/chunk/ChunkHandler.java @@ -14,6 +14,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; +import org.bukkit.World; import org.bukkit.entity.Player; import com.cjburkey.claimchunk.ClaimChunk; import com.cjburkey.claimchunk.Utils; @@ -24,49 +25,51 @@ public final class ChunkHandler { /** * Claims a specific chunk for a player if that chunk is not already owned. + * @param world The current world. * @param x The chunk x-coord. * @param z The chunk z-coord. * @param player The player for whom to claim the chunk. * @return Whether or not the chunk was claimed. */ - public boolean claimChunk(int x, int z, Player player) { - if (isClaimed(x, z)) { + public boolean claimChunk(World world, int x, int z, Player player) { + if (isClaimed(world, x, z)) { return false; } - claimed.put(new ChunkPos(x, z), player.getUniqueId()); + claimed.put(new ChunkPos(world.getName(), x, z), player.getUniqueId()); reload(); return true; } /** * Unclaims a specific chunk if that chunk is currently owned. + * @param world The current world. * @param x The chunk x-coord. * @param z The chunk z-coord. * @return Whether or not the chunk was unclaimed. */ - public boolean unclaimChunk(int x, int z) { - if (!isClaimed(x, z)) { + public boolean unclaimChunk(World world, int x, int z) { + if (!isClaimed(world, x, z)) { return false; } - claimed.remove(new ChunkPos(x, z)); + claimed.remove(new ChunkPos(world.getName(), x, z)); reload(); return true; } - public boolean isClaimed(int x, int z) { - return claimed.containsKey(new ChunkPos(x, z)); + public boolean isClaimed(World world, int x, int z) { + return claimed.containsKey(new ChunkPos(world.getName(), x, z)); } - public boolean isOwner(int x, int z, UUID uuid) { - return claimed.get(new ChunkPos(x, z)).equals(uuid); + public boolean isOwner(World world, int x, int z, UUID uuid) { + return claimed.get(new ChunkPos(world.getName(), x, z)).equals(uuid); } - public boolean isOwner(int x, int z, Player ply) { - return isOwner(x, z, ply.getUniqueId()); + public boolean isOwner(World world, int x, int z, Player ply) { + return isOwner(world, x, z, ply.getUniqueId()); } - public UUID getOwner(int x, int z) { - return claimed.get(new ChunkPos(x, z)); + public UUID getOwner(World world, int x, int z) { + return claimed.get(new ChunkPos(world.getName(), x, z)); } public void reload() { @@ -87,7 +90,7 @@ public void writeToDisk(File file) throws IOException { } FileWriter writer = null; StringBuilder out = new StringBuilder(); - out.append(";;-cab91ae58cc9464e1fbeda05024bed39"); // MD5 + out.append(";;-This is a comment, it is not read. It doesn't matter, though, this file is reset every time."); out.append("\n"); for (Entry entry : claimed.entrySet()) { out.append(entry.getKey().toString()); @@ -95,7 +98,6 @@ public void writeToDisk(File file) throws IOException { out.append(entry.getValue().toString()); out.append('\n'); } - out.append(";;-f957097d7a22775f6bea41b46cae4d14274dac9f"); // SHA-1 try { writer = new FileWriter(file, false); writer.write(out.toString()); diff --git a/src/main/java/com/cjburkey/claimchunk/chunk/ChunkPos.java b/src/main/java/com/cjburkey/claimchunk/chunk/ChunkPos.java index 4ec41a3b..8e3ea8a2 100644 --- a/src/main/java/com/cjburkey/claimchunk/chunk/ChunkPos.java +++ b/src/main/java/com/cjburkey/claimchunk/chunk/ChunkPos.java @@ -4,29 +4,24 @@ public final class ChunkPos { + private final String world; private final int x; private final int z; - public ChunkPos(int x, int z) { + public ChunkPos(String world, int x, int z) { + this.world = world; this.x = x; this.z = z; } - public int getX() { - return x; - } - - public int getZ() { - return z; - } - public String toString() { - return x + "," + z; + return world + "," + x + "," + z; } public int hashCode() { final int prime = 31; int result = 1; + result = prime * result + ((world == null) ? 0 : world.hashCode()); result = prime * result + x; result = prime * result + z; return result; @@ -40,20 +35,25 @@ public boolean equals(Object obj) { if (getClass() != obj.getClass()) return false; ChunkPos other = (ChunkPos) obj; + if (world == null) { + if (other.world != null) + return false; + } else if (!world.equals(other.world)) + return false; if (x != other.x) return false; if (z != other.z) return false; return true; } - + public static ChunkPos fromString(String in) { String[] split = in.split(Pattern.quote(",")); - if(split.length == 2) { + if(split.length == 3) { try { - int x = Integer.parseInt(split[0].trim()); - int z = Integer.parseInt(split[1].trim()); - return new ChunkPos(x, z); + int x = Integer.parseInt(split[1].trim()); + int z = Integer.parseInt(split[2].trim()); + return new ChunkPos(split[0], x, z); } catch(Exception e) { } } diff --git a/src/main/java/com/cjburkey/claimchunk/cmd/CmdAccessChunks.java b/src/main/java/com/cjburkey/claimchunk/cmd/CmdAccessChunks.java index a330d6ee..f047ea13 100644 --- a/src/main/java/com/cjburkey/claimchunk/cmd/CmdAccessChunks.java +++ b/src/main/java/com/cjburkey/claimchunk/cmd/CmdAccessChunks.java @@ -25,6 +25,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St Utils.msg(sender, Utils.getConfigColor("errorColor") + " " + Utils.getLang("AccessHelp")); return true; } + @SuppressWarnings("deprecation") Player other = ClaimChunk.getInstance().getServer().getPlayer(args[0]); if (other != null) { toggle(p, other.getUniqueId(), other.getName()); diff --git a/src/main/java/com/cjburkey/claimchunk/cmd/CmdClaimChunk.java b/src/main/java/com/cjburkey/claimchunk/cmd/CmdClaimChunk.java index bb46de54..161fb250 100644 --- a/src/main/java/com/cjburkey/claimchunk/cmd/CmdClaimChunk.java +++ b/src/main/java/com/cjburkey/claimchunk/cmd/CmdClaimChunk.java @@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.cjburkey.claimchunk.ClaimChunk; +import com.cjburkey.claimchunk.Econ; import com.cjburkey.claimchunk.Utils; import com.cjburkey.claimchunk.chunk.ChunkHandler; @@ -23,11 +24,21 @@ public boolean onCommand(CommandSender sender, Command command, String label, St } ChunkHandler ch = ClaimChunk.getInstance().getChunks(); Chunk loc = p.getLocation().getChunk(); - if(ch.isClaimed(loc.getX(), loc.getZ())) { + if (ch.isClaimed(loc.getWorld(), loc.getX(), loc.getZ())) { Utils.toPlayer(p, Utils.getConfigColor("errorColor"), Utils.getLang("ChunkAlreadyOwned")); return true; } - ch.claimChunk(loc.getX(), loc.getZ(), p); + if (ClaimChunk.getInstance().useEconomy()) { + Econ e = ClaimChunk.getInstance().getEconomy(); + double cost = ClaimChunk.getInstance().getConfig().getDouble("claimPrice"); + if (cost > 0) { + if (!e.buy(p.getUniqueId(), cost)) { + Utils.toPlayer(p, Utils.getConfigColor("errorColor"), Utils.getLang("NotEnoughMoney")); + return true; + } + } + } + ch.claimChunk(loc.getWorld(), loc.getX(), loc.getZ(), p); Utils.toPlayer(p, Utils.getConfigColor("successColor"), Utils.getLang("ChunkClaimed")); return true; } diff --git a/src/main/java/com/cjburkey/claimchunk/cmd/CmdUnclaimChunk.java b/src/main/java/com/cjburkey/claimchunk/cmd/CmdUnclaimChunk.java index bfc634f8..26dae4ff 100644 --- a/src/main/java/com/cjburkey/claimchunk/cmd/CmdUnclaimChunk.java +++ b/src/main/java/com/cjburkey/claimchunk/cmd/CmdUnclaimChunk.java @@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.cjburkey.claimchunk.ClaimChunk; +import com.cjburkey.claimchunk.Econ; import com.cjburkey.claimchunk.Utils; import com.cjburkey.claimchunk.chunk.ChunkHandler; @@ -23,15 +24,23 @@ public boolean onCommand(CommandSender sender, Command command, String label, St } ChunkHandler ch = ClaimChunk.getInstance().getChunks(); Chunk loc = p.getLocation().getChunk(); - if(!ch.isClaimed(loc.getX(), loc.getZ())) { + if(!ch.isClaimed(loc.getWorld(), loc.getX(), loc.getZ())) { Utils.toPlayer(p, Utils.getConfigColor("errorColor"), Utils.getLang("ChunkAlreadyNotClaimed")); return true; } - if(!ch.isOwner(loc.getX(), loc.getZ(), p)) { + if(!ch.isOwner(loc.getWorld(), loc.getX(), loc.getZ(), p)) { Utils.toPlayer(p, Utils.getConfigColor("errorColor"), Utils.getLang("NotYourChunk")); return true; } - ch.unclaimChunk(loc.getX(), loc.getZ()); + if (ClaimChunk.getInstance().useEconomy()) { + Econ e = ClaimChunk.getInstance().getEconomy(); + double reward = ClaimChunk.getInstance().getConfig().getDouble("unclaimReward"); + if (reward > 0) { + e.addMoney(p.getUniqueId(), reward); + Utils.toPlayer(p, Utils.getConfigColor("errorColor"), Utils.getLang("UnclaimReward").replaceAll("%%AMT%%", e.format(reward))); + } + } + ch.unclaimChunk(loc.getWorld(), loc.getX(), loc.getZ()); Utils.toPlayer(p, Utils.getConfigColor("successColor"), Utils.getLang("ChunkUnclaimed")); return true; } diff --git a/src/main/java/com/cjburkey/claimchunk/dynmap/ChunkMarkerHandler.java b/src/main/java/com/cjburkey/claimchunk/dynmap/ChunkMarkerHandler.java new file mode 100644 index 00000000..781c7ae2 --- /dev/null +++ b/src/main/java/com/cjburkey/claimchunk/dynmap/ChunkMarkerHandler.java @@ -0,0 +1,7 @@ +package com.cjburkey.claimchunk.dynmap; + +public class ChunkMarkerHandler { + + + +} \ No newline at end of file diff --git a/src/main/java/com/cjburkey/claimchunk/dynmap/ClaimChunkDynmap.java b/src/main/java/com/cjburkey/claimchunk/dynmap/ClaimChunkDynmap.java new file mode 100644 index 00000000..3d94280c --- /dev/null +++ b/src/main/java/com/cjburkey/claimchunk/dynmap/ClaimChunkDynmap.java @@ -0,0 +1,24 @@ +package com.cjburkey.claimchunk.dynmap; + +import org.bukkit.plugin.Plugin; +import org.dynmap.DynmapAPI; +import com.cjburkey.claimchunk.ClaimChunk; + +public class ClaimChunkDynmap { + + private DynmapAPI dynmap; + + public boolean registerAndSuch() { + Plugin plugin = ClaimChunk.getInstance().getServer().getPluginManager().getPlugin("dynmap"); + if (plugin != null && plugin instanceof DynmapAPI) { + dynmap = (DynmapAPI) plugin; + return true; + } + return false; + } + + public DynmapAPI getApi() { + return dynmap; + } + +} \ No newline at end of file diff --git a/src/main/java/com/cjburkey/claimchunk/event/PlayerMovementHandler.java b/src/main/java/com/cjburkey/claimchunk/event/PlayerMovementHandler.java index db84668b..71fd68fe 100644 --- a/src/main/java/com/cjburkey/claimchunk/event/PlayerMovementHandler.java +++ b/src/main/java/com/cjburkey/claimchunk/event/PlayerMovementHandler.java @@ -19,10 +19,10 @@ public void onPlayerMove(PlayerMoveEvent e) { Chunk prev = e.getFrom().getChunk(); Chunk to = e.getTo().getChunk(); ChunkHandler ch = ClaimChunk.getInstance().getChunks(); - if (ch.isClaimed(to.getX(), to.getZ())) { - if (ch.isClaimed(prev.getX(), prev.getZ())) { - UUID prevOwner = ch.getOwner(prev.getX(), prev.getZ()); - UUID newOwner = ch.getOwner(to.getX(), to.getZ()); + if (ch.isClaimed(to.getWorld(), to.getX(), to.getZ())) { + if (ch.isClaimed(prev.getWorld(), prev.getX(), prev.getZ())) { + UUID prevOwner = ch.getOwner(prev.getWorld(), prev.getX(), prev.getZ()); + UUID newOwner = ch.getOwner(to.getWorld(), to.getX(), to.getZ()); if (!prevOwner.equals(newOwner)) { showTitle(e.getPlayer(), to); } @@ -34,7 +34,7 @@ public void onPlayerMove(PlayerMoveEvent e) { } private void showTitle(Player player, Chunk newChunk) { - UUID newOwner = ClaimChunk.getInstance().getChunks().getOwner(newChunk.getX(), newChunk.getZ()); + UUID newOwner = ClaimChunk.getInstance().getChunks().getOwner(newChunk.getWorld(), newChunk.getX(), newChunk.getZ()); if (!newOwner.equals(player.getUniqueId())) { String newName = ClaimChunk.getInstance().getPlayers().getName(newOwner); if (newName != null) { diff --git a/src/main/java/config.yml b/src/main/java/config.yml index a20a20a7..bd1b8cba 100644 --- a/src/main/java/config.yml +++ b/src/main/java/config.yml @@ -9,15 +9,23 @@ infoColor: DARK_GREEN blockInteractionInOtherPlayersChunks: true +useEconomy: true +claimPrice: 100.0 +unclaimReward: 0.0 + +useDynmap: true + langNoPermToClaim: 'You do not have permission to claim chunks.' langChunkAlreadyOwned: 'This chunk is already claimed.' langTooManyChunks: 'You own the maximum number of chunks.' langChunkClaimed: 'Chunk claimed!' +langNotEnoughMoney: 'You do not have enough money.' langNoPermToUnclaim: 'You do not have permission to unclaim chunks.' langChunkAlreadyNotClaimed: 'This chunk is not owned.' langNotYourChunk: 'You do not own this chunk.' langChunkUnclaimed: 'Chunk unclaimed!' +langUnlclaimReward: 'You have been refunded %%AMT%%.' landNoPermToAccess: 'You do not have permission to give access to chunks.' langAccessArgUsage: 'Usage: /accesschunks ' diff --git a/src/main/java/plugin.yml b/src/main/java/plugin.yml index 5248bf74..5fb6b012 100644 --- a/src/main/java/plugin.yml +++ b/src/main/java/plugin.yml @@ -3,9 +3,8 @@ main: com.cjburkey.claimchunk.ClaimChunk author: CJ Burkey database: false prefix: ClaimChunk -version: 0.0.1 +version: 0.0.2 website: https://www.spigotmc.org/resources/claimchunk.44458/ -depend: [ "Vault" ] permission: claimchunk.claim: diff --git a/src/main/java/writing.txt b/src/main/java/writing.txt deleted file mode 100644 index eca0c845..00000000 --- a/src/main/java/writing.txt +++ /dev/null @@ -1,5 +0,0 @@ -Starting: - 0.0.1: cab91ae58cc9464e1fbeda05024bed39 - -Finishing: - 0.0.1: f957097d7a22775f6bea41b46cae4d14274dac9f \ No newline at end of file