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;
|
2020-12-25 19:46:43 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.LoginProcess;
|
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;
|
|
|
|
|
2020-09-28 03:17:01 +00:00
|
|
|
@CommandPermissions(level = Rank.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)
|
|
|
|
{
|
2020-08-06 20:17:18 +00:00
|
|
|
msg("Available toggles: ");
|
|
|
|
msg("- waterplace");
|
|
|
|
msg("- fireplace");
|
|
|
|
msg("- lavaplace");
|
|
|
|
msg("- fluidspread");
|
|
|
|
msg("- lavadmg");
|
|
|
|
msg("- firespread");
|
|
|
|
msg("- frostwalk");
|
|
|
|
msg("- firework");
|
|
|
|
msg("- prelog");
|
|
|
|
msg("- lockdown");
|
|
|
|
msg("- petprotect");
|
|
|
|
msg("- entitywipe");
|
|
|
|
msg("- nonuke [range] [count]");
|
|
|
|
msg("- explosives [radius]");
|
|
|
|
msg("- unsafeenchs");
|
|
|
|
msg("- bells");
|
|
|
|
msg("- armorstands");
|
|
|
|
msg("- structureblocks");
|
|
|
|
msg("- jigsaws");
|
|
|
|
msg("- grindstones");
|
|
|
|
msg("- jukeboxes");
|
|
|
|
msg("- spawners");
|
|
|
|
msg("- 4chan");
|
|
|
|
msg("- beehives");
|
|
|
|
msg("- respawnanchors");
|
|
|
|
msg("- autotp");
|
|
|
|
msg("- autoclear");
|
|
|
|
msg("- minecarts");
|
|
|
|
msg("- landmines");
|
|
|
|
msg("- mp44");
|
|
|
|
msg("- tossmob");
|
2014-04-23 14:23:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-08-06 20:05:17 +00:00
|
|
|
switch (args[0].toLowerCase())
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2020-08-06 20:05:17 +00:00
|
|
|
case "waterplace":
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2020-08-06 20:05:17 +00:00
|
|
|
toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "frostwalk":
|
|
|
|
{
|
|
|
|
toggle("Frost walker enchantment is", ConfigEntry.ALLOW_FROSTWALKER);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "fireplace":
|
|
|
|
{
|
|
|
|
toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "lavaplace":
|
|
|
|
{
|
|
|
|
toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "fluidspread":
|
|
|
|
{
|
|
|
|
toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "lavadmg":
|
|
|
|
{
|
|
|
|
toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "firespread":
|
|
|
|
{
|
|
|
|
toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD);
|
|
|
|
plugin.gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "prelog":
|
|
|
|
{
|
|
|
|
toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "lockdown":
|
|
|
|
{
|
2020-12-25 19:46:43 +00:00
|
|
|
boolean active = !LoginProcess.isLockdownEnabled();
|
|
|
|
LoginProcess.setLockdownEnabled(active);
|
2020-12-04 00:28:53 +00:00
|
|
|
FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true);
|
2020-08-06 20:05:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "petprotect":
|
|
|
|
{
|
|
|
|
toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "entitywipe":
|
|
|
|
{
|
|
|
|
toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "firework":
|
|
|
|
{
|
|
|
|
toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "nonuke":
|
|
|
|
{
|
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
|
|
|
|
}
|
|
|
|
catch (NumberFormatException ex)
|
|
|
|
{
|
|
|
|
msg("The input provided is not a valid integer.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args.length >= 3)
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2020-08-06 20:05:17 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
|
|
|
|
}
|
|
|
|
catch (NumberFormatException ex)
|
|
|
|
{
|
|
|
|
msg("The input provided is not a valid integer.");
|
|
|
|
return true;
|
|
|
|
}
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2020-08-06 20:05:17 +00:00
|
|
|
|
|
|
|
toggle("Nuke monitor is", ConfigEntry.NUKE_MONITOR_ENABLED);
|
|
|
|
|
|
|
|
if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2020-08-06 20:05:17 +00:00
|
|
|
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.");
|
2018-01-01 03:43:10 +00:00
|
|
|
}
|
2020-08-06 20:05:17 +00:00
|
|
|
break;
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2020-08-06 20:05:17 +00:00
|
|
|
|
|
|
|
case "explosives":
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2020-08-06 20:05:17 +00:00
|
|
|
if (args.length == 2)
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2020-08-06 20:05:17 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
|
|
|
|
}
|
|
|
|
catch (NumberFormatException ex)
|
|
|
|
{
|
|
|
|
msg("The input provided is not a valid integer.");
|
|
|
|
return true;
|
|
|
|
}
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2020-08-06 20:05:17 +00:00
|
|
|
|
|
|
|
toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS);
|
|
|
|
|
|
|
|
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2020-08-06 20:05:17 +00:00
|
|
|
msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble());
|
2018-01-01 03:43:10 +00:00
|
|
|
}
|
2020-08-06 20:05:17 +00:00
|
|
|
break;
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2020-08-06 20:05:17 +00:00
|
|
|
|
|
|
|
case "unsafeenchs":
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2020-08-06 20:05:17 +00:00
|
|
|
toggle("Unsafe enchantments are", ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS);
|
|
|
|
break;
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2020-08-06 20:05:17 +00:00
|
|
|
|
|
|
|
case "bells":
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2020-08-06 20:05:17 +00:00
|
|
|
toggle("The ringing of bells is", ConfigEntry.ALLOW_BELLS);
|
|
|
|
break;
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2020-08-06 20:05:17 +00:00
|
|
|
|
|
|
|
case "armorstands":
|
2018-01-01 03:43:10 +00:00
|
|
|
{
|
2020-08-06 20:05:17 +00:00
|
|
|
toggle("The placement of armor stands is", ConfigEntry.ALLOW_ARMOR_STANDS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "structureblocks":
|
|
|
|
{
|
|
|
|
toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "jigsaws":
|
|
|
|
{
|
|
|
|
toggle("Jigsaws are", ConfigEntry.ALLOW_JIGSAWS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "grindstones":
|
|
|
|
{
|
|
|
|
toggle("Grindstones are", ConfigEntry.ALLOW_GRINDSTONES);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "jukeboxes":
|
|
|
|
{
|
|
|
|
toggle("Jukeboxes are", ConfigEntry.ALLOW_JUKEBOXES);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "spawners":
|
|
|
|
{
|
|
|
|
toggle("Spawners are", ConfigEntry.ALLOW_SPAWNERS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "4chan":
|
|
|
|
{
|
|
|
|
toggle("4chan mode is", ConfigEntry.FOURCHAN_ENABLED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "beehives":
|
|
|
|
{
|
|
|
|
toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "respawnanchors":
|
|
|
|
{
|
|
|
|
toggle("Respawn anchors are", ConfigEntry.ALLOW_RESPAWN_ANCHORS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "autotp":
|
|
|
|
{
|
|
|
|
toggle("Teleportation on join is", ConfigEntry.AUTO_TP);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "autoclear":
|
|
|
|
{
|
|
|
|
toggle("Clearing inventories on join is", ConfigEntry.AUTO_CLEAR);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "minecarts":
|
|
|
|
{
|
|
|
|
toggle("Minecarts are", ConfigEntry.ALLOW_MINECARTS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "landmines":
|
|
|
|
{
|
|
|
|
toggle("Landmines are", ConfigEntry.LANDMINES_ENABLED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "mp44":
|
|
|
|
{
|
|
|
|
toggle("MP44 is", ConfigEntry.MP44_ENABLED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "tossmob":
|
|
|
|
{
|
|
|
|
toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED);
|
|
|
|
break;
|
2014-04-23 14:23:50 +00:00
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
}
|
2020-08-06 20:05:17 +00:00
|
|
|
return true;
|
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)
|
|
|
|
{
|
2020-12-04 00:28:53 +00:00
|
|
|
if (!plugin.al.isAdmin(sender))
|
2020-08-06 20:05:17 +00:00
|
|
|
{
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
|
2019-01-29 04:57:41 +00:00
|
|
|
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-05-29 10:14:21 +00:00
|
|
|
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
|
2020-08-06 20:05:17 +00:00
|
|
|
"respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob");
|
2019-01-29 04:57:41 +00:00
|
|
|
}
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2020-08-06 20:05:17 +00:00
|
|
|
}
|