diff --git a/plugin.yml b/plugin.yml index bd4c33f..9b02274 100644 --- a/plugin.yml +++ b/plugin.yml @@ -32,6 +32,7 @@ permissions: plotme.use.bid: true plotme.use.dispose: true plotme.use.done: true + plotme.use.chat: true plotme.admin: description: Gives default administrator commands children: @@ -92,6 +93,8 @@ permissions: description: Gives the remove command for plots owned plotme.use.protect: description: Gives the protect command + plotme.use.chat: + description: Gives the chat command plotme.limit.*: description: Gives unlimited plots plotme.admin.claim.other: diff --git a/src/com/worldcretornica/plotme/PMCommand.java b/src/com/worldcretornica/plotme/PMCommand.java index 78b923a..46eaff6 100644 --- a/src/com/worldcretornica/plotme/PMCommand.java +++ b/src/com/worldcretornica/plotme/PMCommand.java @@ -139,6 +139,7 @@ public boolean onCommand(CommandSender s, Command c, String l, String[] args) if (a0.equalsIgnoreCase(C("CommandAddtime"))) { return addtime(p, args);} if (a0.equalsIgnoreCase(C("CommandDone"))) { return done(p, args);} if (a0.equalsIgnoreCase(C("CommandDoneList"))) { return donelist(p, args);} + if (a0.equalsIgnoreCase(C("CommandChat"))) { return chat(p, args);} if (a0.equalsIgnoreCase(C("CommandProtect"))) { return protect(p, args);} if (a0.equalsIgnoreCase(C("CommandSell"))) { return sell(p, args);} @@ -156,6 +157,31 @@ public boolean onCommand(CommandSender s, Command c, String l, String[] args) return false; } + private boolean chat(CommandSender s, String[] args) + { + if(PlotMe.cPerms(s, "PlotMe.use.chat")) + { + if(args.length <= 1) + { + Send(s, C("WordUsage") + ": " + RED + "/plotme " + C("CommandChat") + " <" + C("WordMessage") + "> " + RESET + "Example: " + RED + "/plotme " + C("CommandChat") + " Hello everyone on my plot! "); + } + else + { + String str = ""; + boolean firstLoop=true; + for (String currentArg : args) { + if (!firstLoop) { + str = str + currentArg + " "; + } else { + firstLoop = false; + } + } + PlotManager.sendMessageToPlot(PlotManager.getPlotId((Player)s), str.trim()); + } + } + return true; + } + private boolean resetexpired(CommandSender s, String[] args) { if(PlotMe.cPerms(s, "PlotMe.admin.resetexpired")) diff --git a/src/com/worldcretornica/plotme/PlotManager.java b/src/com/worldcretornica/plotme/PlotManager.java index 672b976..456d300 100644 --- a/src/com/worldcretornica/plotme/PlotManager.java +++ b/src/com/worldcretornica/plotme/PlotManager.java @@ -127,6 +127,17 @@ public static List getPlayersInPlot(String id) } return playersInPlot; } + public static void sendMessageToPlot(String id, String msg)//TODO move this to the Plot class? + { + for (Player p : getPlayersInPlot(id)) + { + if (p.hasPermission("plotme.use.chat")) + { + p.sendMessage(msg); + } + } + } + public static void adjustLinkedPlots(String id, World world) { @@ -590,6 +601,7 @@ public static void clear(Location bottom, Location top) { block = new Location(bottom.getWorld(), x, y, z).getBlock(); + if(y == 0) block.setTypeId(pmi.BottomBlockId); else if(y < pmi.RoadHeight) diff --git a/src/com/worldcretornica/plotme/PlotMe.java b/src/com/worldcretornica/plotme/PlotMe.java index b5eb341..b670d03 100644 --- a/src/com/worldcretornica/plotme/PlotMe.java +++ b/src/com/worldcretornica/plotme/PlotMe.java @@ -15,9 +15,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.TreeMap; import java.util.Map.Entry; +import java.util.TreeMap; import java.util.logging.Logger; + import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; @@ -812,6 +813,7 @@ public void loadCaptions() properties.put("WordBottom", "Bottom"); properties.put("WordTop", "Top"); properties.put("WordPossessive", "'s"); + properties.put("WordMessage", "Message"); properties.put("SignOwner", "Owner:"); properties.put("SignId", "ID:"); @@ -860,6 +862,7 @@ public void loadCaptions() properties.put("CommandAddtime", "addtime"); properties.put("CommandDone", "done"); properties.put("CommandDoneList", "donelist"); + properties.put("CommandChat", "chat"); properties.put("CommandProtect", "protect"); properties.put("CommandSell", "sell"); properties.put("CommandSellBank", "sell bank");