2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2014-04-23 14:23:50 +00:00
|
|
|
|
2019-01-29 04:57:41 +00:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2017-11-16 22:32:09 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.GameRuleHandler;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2014-04-23 14:23:50 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
2014-04-23 14:23:50 +00:00
|
|
|
@CommandParameters(description = "Toggles TotalFreedomMod settings", usage = "/<command> [option] [value] [value]")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_toggle extends FreedomCommand
|
2014-04-23 14:23:50 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2014-04-23 14:23:50 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2014-04-23 14:23:50 +00:00
|
|
|
{
|
|
|
|
if (args.length == 0)
|
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Available toggles: ");
|
|
|
|
msg("- waterplace");
|
|
|
|
msg("- fireplace");
|
|
|
|
msg("- lavaplace");
|
|
|
|
msg("- fluidspread");
|
|
|
|
msg("- lavadmg");
|
|
|
|
msg("- firespread");
|
2017-11-16 22:32:09 +00:00
|
|
|
msg("- frostwalk");
|
|
|
|
msg("- firework");
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("- prelog");
|
|
|
|
msg("- lockdown");
|
|
|
|
msg("- petprotect");
|
2016-05-12 19:40:39 +00:00
|
|
|
msg("- entitywipe");
|
|
|
|
msg("- nonuke [range] [count]");
|
|
|
|
msg("- explosives [radius]");
|
2019-02-22 23:16:08 +00:00
|
|
|
msg("- unsafeenchs");
|
2019-07-31 04:35:41 +00:00
|
|
|
msg("- bells");
|
2019-08-27 23:25:50 +00:00
|
|
|
msg("- armorstands");
|
2019-11-03 14:10:56 +00:00
|
|
|
msg("- clearonjoin");
|
2019-11-18 21:45:18 +00:00
|
|
|
msg("- tpronjoin");
|
2019-12-10 00:59:17 +00:00
|
|
|
msg("- structureblocks");
|
|
|
|
msg("- jigsaws");
|
|
|
|
msg("- grindstones");
|
|
|
|
msg("- jukeboxes");
|
|
|
|
msg("- spawners");
|
|
|
|
msg("- 4chan");
|
2020-02-09 04:52:43 +00:00
|
|
|
msg("- beehives");
|
2014-04-23 14:23:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-25 22:09:35 +00:00
|
|
|
if (args[0].equalsIgnoreCase("waterplace"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE);
|
2014-04-23 14:23:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("frostwalk"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2019-11-28 18:21:54 +00:00
|
|
|
toggle("Frost walker enchantment is", ConfigEntry.ALLOW_FROSTWALKER);
|
2014-04-23 14:23:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("fireplace"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE);
|
2014-04-23 14:23:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("lavaplace"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE);
|
2017-11-16 22:32:09 +00:00
|
|
|
return true;
|
2018-07-31 06:41:56 +00:00
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("fluidspread"))
|
2014-04-23 14:23:50 +00:00
|
|
|
{
|
2018-01-01 03:43:10 +00:00
|
|
|
toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD);
|
2014-04-23 14:23:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("lavadmg"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE);
|
2014-04-23 14:23:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("firespread"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD);
|
2018-03-18 08:32:50 +00:00
|
|
|
plugin.gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
|
2014-04-23 14:23:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("prelog"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG);
|
2014-04-23 14:23:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("lockdown"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
boolean active = !plugin.lp.isLockdownEnabled();
|
|
|
|
plugin.lp.setLockdownEnabled(active);
|
2016-03-02 19:28:01 +00:00
|
|
|
FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true);
|
2014-05-05 13:31:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("petprotect"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT);
|
2014-04-23 14:23:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("entitywipe"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE);
|
2014-04-23 14:23:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("firework"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION);
|
2017-11-16 22:32:09 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("nonuke"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
catch (NumberFormatException ex)
|
|
|
|
{
|
|
|
|
}
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
if (args.length >= 3)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
catch (NumberFormatException ex)
|
|
|
|
{
|
|
|
|
}
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
toggle("Nuke monitor is", ConfigEntry.NUKE_MONITOR_ENABLED);
|
|
|
|
if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
|
|
|
|
{
|
|
|
|
msg("Anti-freecam range is set to " + ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks.");
|
|
|
|
msg("Block throttle rate is set to " + ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds.");
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2018-07-25 22:09:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("explosives"))
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
|
|
|
if (args.length == 2)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
catch (NumberFormatException ex)
|
|
|
|
{
|
|
|
|
msg("The input provided is not a valid integer.");
|
2014-04-23 14:23:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS);
|
|
|
|
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
|
|
{
|
|
|
|
msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble());
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2019-02-22 23:16:08 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("unsafeenchs"))
|
|
|
|
{
|
|
|
|
toggle("Invalid enchantments are", ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS);
|
|
|
|
return true;
|
|
|
|
}
|
2019-07-31 04:35:41 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("bells"))
|
|
|
|
{
|
|
|
|
toggle("The ringing of bells is", ConfigEntry.ALLOW_BELLS);
|
|
|
|
return true;
|
|
|
|
}
|
2019-08-27 23:25:50 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("armorstands"))
|
|
|
|
{
|
|
|
|
toggle("The placement of armor stands is", ConfigEntry.ALLOW_ARMOR_STANDS);
|
|
|
|
return true;
|
|
|
|
}
|
2019-11-03 14:10:56 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("clearonjoin"))
|
|
|
|
{
|
|
|
|
toggle("The clearing of inventories on join is", ConfigEntry.ALLOW_CLEAR_ON_JOIN);
|
|
|
|
return true;
|
|
|
|
}
|
2019-11-18 21:45:18 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("tpronjoin"))
|
|
|
|
{
|
2019-11-28 18:21:54 +00:00
|
|
|
toggle("The random teleporting of players on join is", ConfigEntry.ALLOW_TPR_ON_JOIN);
|
2019-11-18 21:45:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-12-10 00:59:17 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("structureblocks"))
|
|
|
|
{
|
|
|
|
toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (args[0].equalsIgnoreCase("jigsaws"))
|
|
|
|
{
|
|
|
|
toggle("Jigsaws are", ConfigEntry.ALLOW_JIGSAWS);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (args[0].equalsIgnoreCase("grindstones"))
|
|
|
|
{
|
|
|
|
toggle("Grindstones are", ConfigEntry.ALLOW_GRINDSTONES);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (args[0].equalsIgnoreCase("jukeboxes"))
|
|
|
|
{
|
|
|
|
toggle("Jukeboxes are", ConfigEntry.ALLOW_JUKEBOXES);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (args[0].equalsIgnoreCase("spawners"))
|
|
|
|
{
|
|
|
|
toggle("Spawners are", ConfigEntry.ALLOW_SPAWNERS);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (args[0].equalsIgnoreCase("4chan"))
|
|
|
|
{
|
|
|
|
toggle("4chan mode is", ConfigEntry.FOURCHAN_ENABLED);
|
|
|
|
return true;
|
|
|
|
}
|
2020-02-09 04:52:43 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("beehives"))
|
|
|
|
{
|
|
|
|
toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES);
|
|
|
|
return true;
|
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2018-07-31 06:41:56 +00:00
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
private void toggle(final String name, final ConfigEntry entry)
|
|
|
|
{
|
|
|
|
msg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled."));
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2019-01-29 04:57:41 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
|
|
{
|
|
|
|
if (args.length == 1)
|
|
|
|
{
|
|
|
|
return Arrays.asList(
|
|
|
|
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
2019-12-10 00:59:17 +00:00
|
|
|
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
|
2020-02-09 04:52:43 +00:00
|
|
|
"bells", "armorstands", "clearonjoin", "tpronjoin", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives");
|
2019-01-29 04:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2017-11-16 22:32:09 +00:00
|
|
|
|