This commit is contained in:
boy0001 2015-02-22 17:06:45 +11:00
parent e572428e45
commit 029fbd7f00

View File

@ -27,9 +27,12 @@ import org.apache.commons.lang.StringUtils;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions;
public class Comment extends SubCommand {
@ -39,10 +42,11 @@ public class Comment extends SubCommand {
@Override
public boolean execute(final PlotPlayer plr, final String... args) {
if (!BukkitPlayerFunctions.isInPlot(plr)) {
Location loc = plr.getLocation();
Plot plot = MainUtil.getPlot(loc);
if (plot == null) {
return sendMessage(plr, C.NOT_IN_PLOT);
}
final Plot plot = MainUtil.getPlot(loc);
if (!plot.hasOwner()) {
return sendMessage(plr, C.NOT_IN_PLOT);
}
@ -52,7 +56,7 @@ public class Comment extends SubCommand {
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);
DBFunc.setComment(loc.getWorld(), plot, comment);
return sendMessage(plr, C.COMMENT_ADDED);
} else {
return sendMessage(plr, C.NO_PERMISSION, "plots.comment." + args[0].toLowerCase());