diff --git a/PlotSquared/src/com/intellectualcrafters/plot/C.java b/PlotSquared/src/com/intellectualcrafters/plot/C.java index 8183487c1..8527c71a2 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/C.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/C.java @@ -16,6 +16,10 @@ import org.bukkit.ChatColor; * @author Citymonstret */ public enum C { + /* + * Comment + */ + COMMENT_SYNTAX("&cUse /plot comment "), /* * Console */ diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotComment.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotComment.java new file mode 100644 index 000000000..6812738b1 --- /dev/null +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotComment.java @@ -0,0 +1,13 @@ +package com.intellectualcrafters.plot; + +public class PlotComment { + public final String comment; + public final int tier; + public final String senderName; + + public PlotComment(String comment, String senderName, int tier) { + this.comment = comment; + this.tier = tier; + this.senderName = senderName; + } +} diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index d61891b45..8385ee672 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -105,7 +105,7 @@ public class PlotMain extends JavaPlugin { public static WorldGuardListener worldGuardListener = null; public static Economy economy; - public static boolean useEconomy; + public static boolean useEconomy = false; /** * !!WorldGeneration!! @@ -705,7 +705,7 @@ public class PlotMain extends JavaPlugin { checkExpired(PlotMain.getMain(), true); checkForExpiredPlots(); } - if (getServer().getPluginManager().getPlugin("Vault") != null) { + if (getServer().getPluginManager().getPlugin("Vault") != null && getServer().getPluginManager().getPlugin("Vault").isEnabled()) { RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); if (economyProvider != null) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java index 16d594243..6fdd88f9d 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java @@ -10,6 +10,7 @@ package com.intellectualcrafters.plot; import org.bukkit.block.Biome; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -33,6 +34,7 @@ public class PlotSettings { */ private Biome biome; + private ArrayList comments; /** * */ @@ -165,4 +167,17 @@ public class PlotSettings { public String getLeaveMessage() { return ""; } + public ArrayList getComments() { + if (this.comments == null) { + return new ArrayList(); + } + return this.comments; + } + + public void addComment(PlotComment comment) { + if (this.comments == null) { + this.comments = new ArrayList(); + } + this.comments.add(comment); + } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java index 5f5f1a0ce..c3f33c6d2 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java @@ -24,6 +24,14 @@ public enum Command { // - /plot rate // - /plot list + INBOX("inbox"), + /** + * + */ + COMMENT("comment", "msg"), + /** + * + */ TRUSTED("trusted", "trust"), /** * diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Comment.java new file mode 100644 index 000000000..e63120720 --- /dev/null +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Comment.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41 + */ + +package com.intellectualcrafters.plot.commands; + +import java.util.Arrays; +import java.util.List; + +import com.intellectualcrafters.plot.*; + +import org.apache.commons.lang.StringUtils; +import org.bukkit.entity.Player; + +/** + * Created by Citymonstret on 2014-08-01. + */ +public class Comment extends SubCommand { + + public Comment() { + super(Command.COMMENT, "Comment on a plot", "comment", CommandCategory.ACTIONS, true); + } + + @Override + public boolean execute(Player plr, String... args) { + if (!PlayerFunctions.isInPlot(plr)) { + PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + return false; + } + Plot plot = PlayerFunctions.getCurrentPlot(plr); + if (!plot.hasOwner()) { + PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + return false; + } + + List recipients = Arrays.asList(new String[] {"admin", "owner", "helper", "trusted", "everyone" }); + + if (args.length==2 && recipients.contains(args[0].toLowerCase())) { + + if (PlotMain.hasPermission(plr, "plots.comment."+args[0].toLowerCase())) { + String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " "); + PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase())); + plot.settings.addComment(comment); + + DBFunc.addComment(...) // Can you do this? + + + return true; + } + else { + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.comment."+args[0].toLowerCase()); + return false; + } + } + PlayerFunctions.sendMessage(plr, C.COMMENT_SYNTAX); + return false; + } +} diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java index 12d15a629..32c8ad4b2 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java @@ -24,7 +24,7 @@ public class Copy extends SubCommand { @Override public boolean execute(Player plr, String... args) { if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, "You're not in a plot."); + PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } Plot plot = PlayerFunctions.getCurrentPlot(plr); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Inbox.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Inbox.java new file mode 100644 index 000000000..95e2c2f5a --- /dev/null +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Inbox.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41 + */ + +package com.intellectualcrafters.plot.commands; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +import com.intellectualcrafters.plot.*; + +import org.apache.commons.lang.StringUtils; +import org.bukkit.entity.Player; + +/** + * Created by Citymonstret on 2014-08-01. + */ +public class Inbox extends SubCommand { + + public Inbox() { + super(Command.INBOX, "Comment on a plot", "comment", CommandCategory.ACTIONS, true); + } + + @Override + public boolean execute(Player plr, String... args) { + if (!PlayerFunctions.isInPlot(plr)) { + PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + return false; + } + Plot plot = PlayerFunctions.getCurrentPlot(plr); + if (!plot.hasOwner()) { + PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + return false; + } + + Integer tier = null; + UUID uuid = plr.getUniqueId(); + if (PlotMain.hasPermission(plr, "plots.admin")) { + tier = 0; + } + else if (plot.owner == uuid) { + tier = 1; + } + else if (plot.helpers.contains(uuid)) { + tier = 2; + } + else if (plot.trusted.contains(uuid)) { + tier = 3; + } + else { + tier = 4; + } + ArrayList comments = plot.settings.getComments(); + List recipients = Arrays.asList(new String[] {"admin", "owner", "helper", "trusted", "everyone" }); + + int counter = 0; + StringBuilder message = new StringBuilder(); + String prefix = ""; + for (PlotComment comment : comments) { + if (comment.tier>=tier) { + message.append(prefix + "&6[&c" + recipients.get(tier) + "&6] &7"+comment.senderName+"&f: "+comment.comment); + prefix = "\n"; + } + } + if (counter==0) { + PlayerFunctions.sendMessage(plr, "&cNo messages."); + return false; + } + PlayerFunctions.sendMessage(plr, message.toString()); + return true; + } +} diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Paste.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Paste.java index 9ca2f64df..f01b2673b 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Paste.java @@ -16,7 +16,7 @@ public class Paste extends SubCommand { @Override public boolean execute(Player plr, String... args) { if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, "You're not in a plot."); + PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } Plot plot = PlayerFunctions.getCurrentPlot(plr);