/* * 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 org.apache.commons.lang.StringUtils; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.PlotComment; import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.database.DBFunc; /** * 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(final Player plr, final String... args) { if (!PlayerFunctions.isInPlot(plr)) { PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } final Plot plot = PlayerFunctions.getCurrentPlot(plr); if (!plot.hasOwner()) { PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } final 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())) { final String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " "); final PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase())); plot.settings.addComment(comment); DBFunc.setComment(plr.getWorld().getName(), plot, comment); return true; } else { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.comment." + args[0].toLowerCase()); return false; } } PlayerFunctions.sendMessage(plr, C.COMMENT_SYNTAX); return false; } }