2015-05-08 22:58:21 +02:00
|
|
|
package com.intellectualcrafters.plot.commands;
|
|
|
|
|
2015-07-03 14:15:20 +02:00
|
|
|
import com.intellectualcrafters.plot.PS;
|
2015-05-08 22:58:21 +02:00
|
|
|
import com.intellectualcrafters.plot.config.C;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
2015-07-27 19:50:04 +02:00
|
|
|
import com.plotsquared.general.commands.CommandDeclaration;
|
2015-05-08 22:58:21 +02:00
|
|
|
|
2015-07-26 21:33:54 +02:00
|
|
|
@CommandDeclaration(
|
|
|
|
command = "chat",
|
|
|
|
description = "Toggle plto chant on or off",
|
|
|
|
usage = "/plot chat [on|off]",
|
|
|
|
permission = "plots.chat",
|
|
|
|
category = CommandCategory.ACTIONS,
|
2015-07-27 15:10:14 +02:00
|
|
|
requiredType = RequiredType.PLAYER
|
2015-07-26 21:33:54 +02:00
|
|
|
)
|
2015-05-08 22:58:21 +02:00
|
|
|
public class Chat extends SubCommand {
|
|
|
|
|
|
|
|
@Override
|
2015-07-27 15:10:14 +02:00
|
|
|
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
|
|
|
|
2015-05-08 22:58:21 +02:00
|
|
|
final String world = plr.getLocation().getWorld();
|
2015-07-03 14:15:20 +02:00
|
|
|
if (!PS.get().isPlotWorld(world)) {
|
2015-05-08 22:58:21 +02:00
|
|
|
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
|
|
|
}
|
|
|
|
boolean enable = !(plr.getMeta("chat") != null && (Boolean) plr.getMeta("chat"));
|
|
|
|
if (args.length > 0) {
|
|
|
|
if (args[0].equalsIgnoreCase("on")) {
|
|
|
|
enable = true;
|
|
|
|
} else if (args[0].equalsIgnoreCase("off")) {
|
|
|
|
enable = false;
|
|
|
|
}
|
|
|
|
}
|
2015-07-03 14:15:20 +02:00
|
|
|
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
2015-05-08 22:58:21 +02:00
|
|
|
if (!enable && plotworld.PLOT_CHAT) {
|
|
|
|
return !sendMessage(plr, C.PLOT_CHAT_FORCED);
|
|
|
|
}
|
|
|
|
plr.setMeta("chat", enable);
|
|
|
|
return sendMessage(plr, enable ? C.PLOT_CHAT_ON : C.PLOT_CHAT_OFF);
|
|
|
|
}
|
|
|
|
}
|