mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-12 13:53:54 +00:00
Removal of Lombok
Lombok implementation removal. I have also gone through and replaced things with inline methods and variables, lambdas, and simplified loops down, removed unnecessary guard clauses, and overall cleaned up every single class. This took a long time, please do remember to follow proper naming conventions, don't include unnecessary guard clauses, follow exception rules and comment rules, and please PLEASE remember to use the DIAMOND OPERATOR rather than just inferring RAW TYPES!!! Thank you!!
This commit is contained in:
@ -19,11 +19,6 @@ import org.bukkit.entity.Player;
|
||||
public class Command_adminworld extends FreedomCommand
|
||||
{
|
||||
|
||||
private enum CommandMode
|
||||
{
|
||||
TELEPORT, TIME, WEATHER
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -66,7 +61,7 @@ public class Command_adminworld extends FreedomCommand
|
||||
{
|
||||
adminWorld = plugin.wm.adminworld.getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
|
||||
@ -158,22 +153,6 @@ public class Command_adminworld extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionDeniedException extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PermissionDeniedException()
|
||||
{
|
||||
super("");
|
||||
}
|
||||
|
||||
private PermissionDeniedException(String string)
|
||||
{
|
||||
super(string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
@ -198,4 +177,25 @@ public class Command_adminworld extends FreedomCommand
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private enum CommandMode
|
||||
{
|
||||
TELEPORT, TIME, WEATHER
|
||||
}
|
||||
|
||||
private static class PermissionDeniedException extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PermissionDeniedException()
|
||||
{
|
||||
super("");
|
||||
}
|
||||
|
||||
private PermissionDeniedException(String string)
|
||||
{
|
||||
super(string);
|
||||
}
|
||||
}
|
||||
}
|
@ -14,17 +14,17 @@ public class Command_attributelist extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
String list = "All possible attributes: ";
|
||||
StringBuilder list = new StringBuilder("All possible attributes: ");
|
||||
|
||||
for (Attribute attribute : Attribute.values())
|
||||
{
|
||||
list += attribute.name() + ", ";
|
||||
list.append(attribute.name()).append(", ");
|
||||
}
|
||||
|
||||
// Remove extra comma at the end of the list
|
||||
list = list.substring(0, list.length() - 2);
|
||||
list = new StringBuilder(list.substring(0, list.length() - 2));
|
||||
|
||||
msg(list);
|
||||
msg(list.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
@ -31,8 +32,8 @@ public class Command_ban extends FreedomCommand
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
Boolean silent = false;
|
||||
Boolean cancelRollback = false;
|
||||
boolean silent = false;
|
||||
boolean cancelRollback = false;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
@ -100,7 +101,7 @@ public class Command_ban extends FreedomCommand
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
targetPos.getWorld().strikeLightning(strike_pos);
|
||||
Objects.requireNonNull(targetPos.getWorld()).strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,7 +155,7 @@ public class Command_ban extends FreedomCommand
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||
}
|
||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||
FUtil.adminAction(sender.getName(), String.format(bcast.toString()), true);
|
||||
FUtil.adminAction(sender.getName(), bcast.toString(), true);
|
||||
}
|
||||
|
||||
// Kick player and handle others on IP
|
||||
|
@ -30,7 +30,7 @@ public class Command_banip extends FreedomCommand
|
||||
|
||||
String ip = args[0];
|
||||
|
||||
if (!FUtil.isValidIPv4(ip))
|
||||
if (FUtil.isValidIPv4(ip))
|
||||
{
|
||||
msg(ip + " is not a valid IP address", ChatColor.RED);
|
||||
return true;
|
||||
|
@ -29,6 +29,7 @@ public class Command_cake extends FreedomCommand
|
||||
|
||||
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||
assert heldItemMeta != null;
|
||||
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
||||
heldItem.setItemMeta(heldItemMeta);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -38,7 +39,7 @@ public class Command_cartsit extends FreedomCommand
|
||||
|
||||
if (targetPlayer.isInsideVehicle())
|
||||
{
|
||||
targetPlayer.getVehicle().eject();
|
||||
Objects.requireNonNull(targetPlayer.getVehicle()).eject();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -30,16 +30,13 @@ public class Command_commandlist extends FreedomCommand
|
||||
PluginDescriptionFile desc = targetPlugin.getDescription();
|
||||
Map<String, Map<String, Object>> map = desc.getCommands();
|
||||
|
||||
if (map != null)
|
||||
for (Entry<String, Map<String, Object>> entry : map.entrySet())
|
||||
{
|
||||
for (Entry<String, Map<String, Object>> entry : map.entrySet())
|
||||
{
|
||||
String command_name = entry.getKey();
|
||||
commands.add(command_name);
|
||||
}
|
||||
String command_name = entry.getKey();
|
||||
commands.add(command_name);
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
catch (Throwable ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -28,15 +28,6 @@ public class Command_cookie extends FreedomCommand
|
||||
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||
}
|
||||
|
||||
final StringBuilder name = new StringBuilder();
|
||||
|
||||
name.append(ChatColor.DARK_RED).append("C")
|
||||
.append(ChatColor.GOLD).append("o")
|
||||
.append(ChatColor.YELLOW).append("o")
|
||||
.append(ChatColor.DARK_GREEN).append("k")
|
||||
.append(ChatColor.DARK_BLUE).append("i")
|
||||
.append(ChatColor.DARK_PURPLE).append("e");
|
||||
|
||||
final StringBuilder lore = new StringBuilder();
|
||||
|
||||
for (final String word : LORE.split(" "))
|
||||
@ -46,7 +37,14 @@ public class Command_cookie extends FreedomCommand
|
||||
|
||||
final ItemStack heldItem = new ItemStack(Material.COOKIE);
|
||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||
heldItemMeta.setDisplayName(name.toString());
|
||||
String name = ChatColor.DARK_RED + "C" +
|
||||
ChatColor.GOLD + "o" +
|
||||
ChatColor.YELLOW + "o" +
|
||||
ChatColor.DARK_GREEN + "k" +
|
||||
ChatColor.DARK_BLUE + "i" +
|
||||
ChatColor.DARK_PURPLE + "e";
|
||||
assert heldItemMeta != null;
|
||||
heldItemMeta.setDisplayName(name);
|
||||
heldItemMeta.setLore(Arrays.asList(lore.toString().split("\n")));
|
||||
heldItem.setItemMeta(heldItemMeta);
|
||||
|
||||
|
@ -14,8 +14,18 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
public class Command_deafen extends FreedomCommand
|
||||
{
|
||||
|
||||
private static final Random random = new Random();
|
||||
public static final double STEPS = 10.0;
|
||||
private static final Random random = new Random();
|
||||
|
||||
private static Location randomOffset(Location a)
|
||||
{
|
||||
return a.clone().add(randomDoubleRange() * 5.0, randomDoubleRange() * 5.0, randomDoubleRange() * 5.0);
|
||||
}
|
||||
|
||||
private static Double randomDoubleRange()
|
||||
{
|
||||
return -1.0 + (random.nextDouble() * ((1.0 - -1.0) + 1.0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
@ -30,7 +40,7 @@ public class Command_deafen extends FreedomCommand
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
playerSender.playSound(randomOffset(playerSender.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
||||
playerSender.playSound(randomOffset(playerSender.getLocation()), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
||||
}
|
||||
}.runTaskLater(plugin, Math.round(20.0 * percent * 2.0));
|
||||
}
|
||||
@ -38,14 +48,4 @@ public class Command_deafen extends FreedomCommand
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Location randomOffset(Location a, double magnitude)
|
||||
{
|
||||
return a.clone().add(randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude);
|
||||
}
|
||||
|
||||
private static Double randomDoubleRange(double min, double max)
|
||||
{
|
||||
return min + (random.nextDouble() * ((max - min) + 1.0));
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ public class Command_debugstick extends FreedomCommand
|
||||
{
|
||||
ItemStack itemStack = new ItemStack(Material.DEBUG_STICK);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
assert itemMeta != null;
|
||||
itemMeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD.toString() + "Stick of Happiness");
|
||||
List<String> lore = Arrays.asList(
|
||||
ChatColor.RED + "This is the most powerful stick in the game.",
|
||||
|
@ -20,6 +20,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class Command_dispfill extends FreedomCommand
|
||||
{
|
||||
|
||||
private static void setDispenserContents(final Block targetBlock, final ItemStack[] items)
|
||||
{
|
||||
if (targetBlock.getType() == Material.DISPENSER)
|
||||
{
|
||||
final Inventory dispenserInv = ((Dispenser)targetBlock.getState()).getInventory();
|
||||
dispenserInv.clear();
|
||||
dispenserInv.addItem(items);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -54,7 +64,7 @@ public class Command_dispfill extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
final ItemStack[] itemsArray = items.toArray(new ItemStack[items.size()]);
|
||||
final ItemStack[] itemsArray = items.toArray(new ItemStack[0]);
|
||||
|
||||
int affected = 0;
|
||||
final Location centerLocation = playerSender.getLocation();
|
||||
@ -88,14 +98,4 @@ public class Command_dispfill extends FreedomCommand
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void setDispenserContents(final Block targetBlock, final ItemStack[] items)
|
||||
{
|
||||
if (targetBlock.getType() == Material.DISPENSER)
|
||||
{
|
||||
final Inventory dispenserInv = ((Dispenser)targetBlock.getState()).getInventory();
|
||||
dispenserInv.clear();
|
||||
dispenserInv.addItem(items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -41,7 +43,7 @@ public class Command_doom extends FreedomCommand
|
||||
FUtil.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
|
||||
FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
|
||||
|
||||
final String ip = player.getAddress().getAddress().getHostAddress().trim();
|
||||
final String ip = Objects.requireNonNull(player.getAddress()).getAddress().getHostAddress().trim();
|
||||
|
||||
// Remove from admin
|
||||
Admin admin = getAdmin(player);
|
||||
@ -54,7 +56,7 @@ public class Command_doom extends FreedomCommand
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +127,6 @@ public class Command_doom extends FreedomCommand
|
||||
|
||||
// generate explosion
|
||||
player.getWorld().createExplosion(player.getLocation(), 0F, false);
|
||||
;
|
||||
|
||||
// kick player
|
||||
player.kickPlayer(ChatColor.RED + kickReason);
|
||||
|
@ -19,7 +19,7 @@ public class Command_eject extends FreedomCommand
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
List<String> names = new ArrayList();
|
||||
List<String> names = new ArrayList<>();
|
||||
|
||||
for (Entity entity : playerSender.getPassengers())
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -19,6 +20,18 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class Command_enchant extends FreedomCommand
|
||||
{
|
||||
|
||||
public static List<String> stringNumberRange(int min, int max)
|
||||
{
|
||||
List<String> range = new ArrayList<>();
|
||||
for (int i = min; i <= max; i++)
|
||||
{
|
||||
range.add(String.valueOf(i));
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -27,9 +40,9 @@ public class Command_enchant extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack item = playerSender.getEquipment().getItemInMainHand();
|
||||
ItemStack item = Objects.requireNonNull(playerSender.getEquipment()).getItemInMainHand();
|
||||
|
||||
if (item == null || item.getType() == Material.AIR)
|
||||
if (item.getType() == Material.AIR)
|
||||
{
|
||||
msg("You have to hold an item to enchant it");
|
||||
return true;
|
||||
@ -99,7 +112,7 @@ public class Command_enchant extends FreedomCommand
|
||||
{
|
||||
ench = Enchantment.getByName(args[1].toUpperCase());
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
|
||||
@ -123,7 +136,7 @@ public class Command_enchant extends FreedomCommand
|
||||
{
|
||||
if (ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean())
|
||||
{
|
||||
level = Integer.valueOf(args[2]);
|
||||
level = Integer.parseInt(args[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -158,9 +171,10 @@ public class Command_enchant extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<String> getAllEnchantments()
|
||||
{
|
||||
List<String> enchantments = new ArrayList();
|
||||
List<String> enchantments = new ArrayList<>();
|
||||
for (Enchantment enchantment : Enchantment.values())
|
||||
{
|
||||
enchantments.add(enchantment.getName());
|
||||
@ -168,9 +182,10 @@ public class Command_enchant extends FreedomCommand
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<String> getAllEnchantments(ItemStack item)
|
||||
{
|
||||
List<String> enchantments = new ArrayList();
|
||||
List<String> enchantments = new ArrayList<>();
|
||||
for (Enchantment enchantment : Enchantment.values())
|
||||
{
|
||||
if (enchantment.canEnchantItem(item))
|
||||
@ -181,9 +196,10 @@ public class Command_enchant extends FreedomCommand
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<String> getEnchantments(ItemStack item)
|
||||
{
|
||||
List<String> enchantments = new ArrayList();
|
||||
List<String> enchantments = new ArrayList<>();
|
||||
for (Enchantment enchantment : item.getEnchantments().keySet())
|
||||
{
|
||||
enchantments.add(enchantment.getName());
|
||||
@ -191,17 +207,7 @@ public class Command_enchant extends FreedomCommand
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
public static List<String> stringNumberRange(int min, int max)
|
||||
{
|
||||
List<String> range = new ArrayList();
|
||||
for (int i = min; i <= max; i++)
|
||||
{
|
||||
range.add(String.valueOf(i));
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
@ -214,9 +220,9 @@ public class Command_enchant extends FreedomCommand
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ItemStack item = player.getEquipment().getItemInMainHand();
|
||||
ItemStack item = Objects.requireNonNull(player.getEquipment()).getItemInMainHand();
|
||||
|
||||
if (item == null || item.getType() == Material.AIR)
|
||||
if (item.getType() == Material.AIR)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@ -258,7 +264,7 @@ public class Command_enchant extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
return Arrays.asList("[level]");
|
||||
return Collections.singletonList("[level]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,29 @@ import org.bukkit.entity.Player;
|
||||
public class Command_entitywipe extends FreedomCommand
|
||||
{
|
||||
|
||||
public static List<EntityType> getAllEntities()
|
||||
{
|
||||
List<EntityType> entityTypes = new ArrayList<>();
|
||||
for (EntityType entityType : EntityType.values())
|
||||
{
|
||||
if (!Groups.MOB_TYPES.contains(entityType))
|
||||
{
|
||||
entityTypes.add(entityType);
|
||||
}
|
||||
}
|
||||
return entityTypes;
|
||||
}
|
||||
|
||||
public static List<String> getAllEntityNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (EntityType entityType : getAllEntities())
|
||||
{
|
||||
names.add(entityType.name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -75,29 +98,6 @@ public class Command_entitywipe extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
public static List<EntityType> getAllEntities()
|
||||
{
|
||||
List<EntityType> entityTypes = new ArrayList<>();
|
||||
for (EntityType entityType : EntityType.values())
|
||||
{
|
||||
if (!Groups.MOB_TYPES.contains(entityType))
|
||||
{
|
||||
entityTypes.add(entityType);
|
||||
}
|
||||
}
|
||||
return entityTypes;
|
||||
}
|
||||
|
||||
public static List<String> getAllEntityNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (EntityType entityType : getAllEntities())
|
||||
{
|
||||
names.add(entityType.name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ public class Command_expel extends FreedomCommand
|
||||
{
|
||||
radius = Math.max(1.0, Math.min(100.0, Double.parseDouble(args[0])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
catch (NumberFormatException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ public class Command_expel extends FreedomCommand
|
||||
{
|
||||
strength = Math.max(0.0, Math.min(50.0, Double.parseDouble(args[1])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
catch (NumberFormatException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class Command_expel extends FreedomCommand
|
||||
{
|
||||
inRange = targetPosVec.distanceSquared(senderPos) < (radius * radius);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
catch (IllegalArgumentException ignored)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class Command_health extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
private class TFM_TickMeter
|
||||
private static class TFM_TickMeter
|
||||
{
|
||||
|
||||
private final AtomicInteger ticks = new AtomicInteger();
|
||||
|
@ -19,11 +19,6 @@ import org.bukkit.entity.Player;
|
||||
public class Command_hubworld extends FreedomCommand
|
||||
{
|
||||
|
||||
private enum CommandMode
|
||||
{
|
||||
TELEPORT, TIME, WEATHER
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -66,7 +61,7 @@ public class Command_hubworld extends FreedomCommand
|
||||
{
|
||||
hubWorld = plugin.wm.hubworld.getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
|
||||
@ -184,7 +179,12 @@ public class Command_hubworld extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionDeniedException extends Exception
|
||||
private enum CommandMode
|
||||
{
|
||||
TELEPORT, TIME, WEATHER
|
||||
}
|
||||
|
||||
private static class PermissionDeniedException extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -42,7 +41,7 @@ public class Command_invis extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
List<String> players = new ArrayList<String>();
|
||||
List<String> players = new ArrayList<>();
|
||||
int clears = 0;
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
@ -81,7 +80,7 @@ public class Command_invis extends FreedomCommand
|
||||
{
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||
{
|
||||
return Arrays.asList("clear");
|
||||
return Collections.singletonList("clear");
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
@ -47,11 +47,6 @@ public class Command_invsee extends FreedomCommand
|
||||
if (args[1].equals("offhand"))
|
||||
{
|
||||
ItemStack offhand = player.getInventory().getItemInOffHand();
|
||||
if (offhand == null)
|
||||
{
|
||||
msg("That player has nothing in their offhand.");
|
||||
return true;
|
||||
}
|
||||
Inventory inventory = server.createInventory(null, 9, player.getName() + "'s offhand");
|
||||
inventory.setItem(1, offhand);
|
||||
playerSender.openInventory(inventory);
|
||||
|
@ -50,7 +50,7 @@ public class Command_landmine extends FreedomCommand
|
||||
{
|
||||
radius = Math.max(2.0, Math.min(6.0, Double.parseDouble(args[0])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
catch (NumberFormatException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class Command_linkdiscord extends FreedomCommand
|
||||
|
||||
if (Discord.LINK_CODES.containsValue(data))
|
||||
{
|
||||
code = plugin.dc.getCode(data);
|
||||
code = Discord.getCode(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2,11 +2,11 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -17,7 +17,7 @@ public class Command_lockup extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
Boolean silent = (args[args.length - 1].equalsIgnoreCase("-q"));
|
||||
boolean silent = (args[args.length - 1].equalsIgnoreCase("-q"));
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("all"))
|
||||
|
@ -81,7 +81,7 @@ public class Command_makeopregion extends FreedomCommand
|
||||
region.setOwners(owners);
|
||||
region.setFlags(flags);
|
||||
|
||||
for (Flag flag : flags.keySet())
|
||||
for (Flag<?> flag : flags.keySet())
|
||||
{
|
||||
region.setFlag(flag.getRegionGroupFlag(), RegionGroup.MEMBERS);
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ public class Command_manageshop extends FreedomCommand
|
||||
{
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -68,8 +67,8 @@ public class Command_manageshop extends FreedomCommand
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||
}
|
||||
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
@ -100,7 +99,6 @@ public class Command_manageshop extends FreedomCommand
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -116,8 +114,8 @@ public class Command_manageshop extends FreedomCommand
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||
}
|
||||
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -19,11 +19,6 @@ import org.bukkit.entity.Player;
|
||||
public class Command_masterbuilderworld extends FreedomCommand
|
||||
{
|
||||
|
||||
private enum CommandMode
|
||||
{
|
||||
TELEPORT, TIME, WEATHER
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -66,7 +61,7 @@ public class Command_masterbuilderworld extends FreedomCommand
|
||||
{
|
||||
masterBuilderWorld = plugin.wm.masterBuilderWorld.getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
|
||||
@ -184,7 +179,12 @@ public class Command_masterbuilderworld extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionDeniedException extends Exception
|
||||
private enum CommandMode
|
||||
{
|
||||
TELEPORT, TIME, WEATHER
|
||||
}
|
||||
|
||||
private static class PermissionDeniedException extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -101,7 +101,7 @@ public class Command_mbconfig extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!plugin.pl.canManageMasterBuilders(sender.getName()))
|
||||
if (plugin.pl.canManageMasterBuilders(sender.getName()))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
@ -157,7 +157,7 @@ public class Command_mbconfig extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!plugin.pl.canManageMasterBuilders(sender.getName()))
|
||||
if (plugin.pl.canManageMasterBuilders(sender.getName()))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class Command_moblimiter extends FreedomCommand
|
||||
{
|
||||
ConfigEntry.MOB_LIMITER_MAX.setInteger(Math.max(0, Math.min(2000, Integer.parseInt(args[1]))));
|
||||
}
|
||||
catch (NumberFormatException nfex)
|
||||
catch (NumberFormatException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,16 @@ import org.bukkit.entity.Player;
|
||||
public class Command_mobpurge extends FreedomCommand
|
||||
{
|
||||
|
||||
public static List<String> getAllMobNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (EntityType entityType : Groups.MOB_TYPES)
|
||||
{
|
||||
names.add(entityType.name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -52,16 +62,6 @@ public class Command_mobpurge extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
public static List<String> getAllMobNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (EntityType entityType : Groups.MOB_TYPES)
|
||||
{
|
||||
names.add(entityType.name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
public class Command_modifyitem extends FreedomCommand
|
||||
{
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -52,6 +53,7 @@ public class Command_modifyitem extends FreedomCommand
|
||||
}
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
assert meta != null;
|
||||
switch (args[0])
|
||||
{
|
||||
case "name":
|
||||
@ -188,6 +190,7 @@ public class Command_modifyitem extends FreedomCommand
|
||||
});
|
||||
cmpnd.setString("Slot", "mainhand");
|
||||
modifiers.add(cmpnd);
|
||||
assert compound != null;
|
||||
compound.set("AttributeModifiers", modifiers);
|
||||
nmsStack.setTag(compound);
|
||||
item = CraftItemStack.asBukkitCopy(nmsStack);
|
||||
@ -237,17 +240,6 @@ public class Command_modifyitem extends FreedomCommand
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
public String getAttribute()
|
||||
{
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public static Attribute getByName(String name)
|
||||
{
|
||||
for (Attribute attr : Attribute.values())
|
||||
@ -259,5 +251,16 @@ public class Command_modifyitem extends FreedomCommand
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getAttribute()
|
||||
{
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -38,7 +39,7 @@ public class Command_mp44 extends FreedomCommand
|
||||
msg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN);
|
||||
msg("Type /mp44 sling to disable. -by Madgeek1450", ChatColor.GREEN);
|
||||
|
||||
playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.GUNPOWDER, 1));
|
||||
Objects.requireNonNull(playerSender.getEquipment()).setItemInMainHand(new ItemStack(Material.GUNPOWDER, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4,11 +4,11 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -20,7 +20,7 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Essentials Interface Command - Remove illegal chatcodes from nicknames of one or all players on server.", usage = "/<command> [player]", aliases = "nc")
|
||||
public class Command_nickclean extends FreedomCommand
|
||||
{
|
||||
private Map<String, Color> colorCodes = new HashMap<String, Color>()
|
||||
private final Map<String, Color> colorCodes = new HashMap<String, Color>()
|
||||
{{
|
||||
put("&0", Color.BLACK);
|
||||
put("&1", Color.BLUE);
|
||||
@ -81,7 +81,7 @@ public class Command_nickclean extends FreedomCommand
|
||||
for (String split : nickName.split("§x"))
|
||||
{
|
||||
List<Color> colors = new ArrayList<>();
|
||||
String hexColorSub = null;
|
||||
String hexColorSub;
|
||||
if (split.length() >= 12 && split.contains("§"))
|
||||
{
|
||||
hexColorSub = split.substring(0, 12);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -20,6 +19,42 @@ import org.bukkit.entity.Player;
|
||||
public class Command_nickfilter extends FreedomCommand
|
||||
{
|
||||
|
||||
private static Player getPlayerByDisplayName(String needle)
|
||||
{
|
||||
needle = needle.toLowerCase().trim();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (player.getDisplayName().toLowerCase().trim().contains(needle))
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Player getPlayerByDisplayNameAlt(String needle)
|
||||
{
|
||||
needle = needle.toLowerCase().trim();
|
||||
|
||||
Integer minEditDistance = null;
|
||||
Player minEditMatch = null;
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
String haystack = player.getDisplayName().toLowerCase().trim();
|
||||
int editDistance = StringUtils.getLevenshteinDistance(needle, haystack.toLowerCase());
|
||||
if (minEditDistance == null || minEditDistance > editDistance)
|
||||
{
|
||||
minEditDistance = editDistance;
|
||||
minEditMatch = player;
|
||||
}
|
||||
}
|
||||
|
||||
return minEditMatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -29,8 +64,7 @@ public class Command_nickfilter extends FreedomCommand
|
||||
|
||||
if (args.length >= 1)
|
||||
{
|
||||
final List<String> argsList = Arrays.asList(args);
|
||||
for (String arg : argsList)
|
||||
for (String arg : args)
|
||||
{
|
||||
Player player = null;
|
||||
|
||||
@ -84,40 +118,4 @@ public class Command_nickfilter extends FreedomCommand
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Player getPlayerByDisplayName(String needle)
|
||||
{
|
||||
needle = needle.toLowerCase().trim();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (player.getDisplayName().toLowerCase().trim().contains(needle))
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Player getPlayerByDisplayNameAlt(String needle)
|
||||
{
|
||||
needle = needle.toLowerCase().trim();
|
||||
|
||||
Integer minEditDistance = null;
|
||||
Player minEditMatch = null;
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
String haystack = player.getDisplayName().toLowerCase().trim();
|
||||
int editDistance = StringUtils.getLevenshteinDistance(needle, haystack.toLowerCase());
|
||||
if (minEditDistance == null || minEditDistance.intValue() > editDistance)
|
||||
{
|
||||
minEditDistance = editDistance;
|
||||
minEditMatch = player;
|
||||
}
|
||||
}
|
||||
|
||||
return minEditMatch;
|
||||
}
|
||||
}
|
@ -51,12 +51,12 @@ public class Command_notes extends FreedomCommand
|
||||
case "list":
|
||||
{
|
||||
final StringBuilder noteList = new StringBuilder();
|
||||
noteList.append(ChatColor.GREEN + "Player notes for " + playerData.getName() + ":");
|
||||
noteList.append(ChatColor.GREEN).append("Player notes for ").append(playerData.getName()).append(":");
|
||||
int id = 1;
|
||||
for (String note : playerData.getNotes())
|
||||
{
|
||||
String noteLine = id + ". " + note;
|
||||
noteList.append("\n" + ChatColor.GOLD + noteLine);
|
||||
noteList.append("\n").append(ChatColor.GOLD).append(noteLine);
|
||||
id++;
|
||||
}
|
||||
msg(noteList.toString());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -54,7 +55,7 @@ public class Command_ops extends FreedomCommand
|
||||
player.setOp(false);
|
||||
if (player.isOnline())
|
||||
{
|
||||
msg(player.getPlayer(), FreedomCommand.YOU_ARE_NOT_OP);
|
||||
msg(Objects.requireNonNull(player.getPlayer()), FreedomCommand.YOU_ARE_NOT_OP);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -4,9 +4,9 @@ import com.google.common.base.Strings;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -98,27 +98,6 @@ public class Command_panel extends FreedomCommand
|
||||
msg("Successfully deleted your Pterodactyl account.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
/*else if (args[0].equals("resetpassword"))
|
||||
{
|
||||
Admin admin = getAdmin(playerSender);
|
||||
|
||||
if (admin.getAmpUsername() == null)
|
||||
{
|
||||
msg("You do not have a Pterodactyl account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Resetting your password...", ChatColor.GREEN);
|
||||
|
||||
String id = admin.getPteroID();
|
||||
String password = FUtil.randomString(30);
|
||||
plugin.ptero.setPassword(id, password);
|
||||
plugin.dc.sendPteroInfo(playerData, null, password);
|
||||
|
||||
msg("Successfully reset your AMP account password. Check your DMs from " + plugin.dc.formatBotTag() + " on discord to get your credentials.", ChatColor.GREEN);
|
||||
return true;
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,7 @@ public class Command_playerverification extends FreedomCommand
|
||||
{
|
||||
PlayerData target = plugin.pl.getData(playerSender);
|
||||
boolean verificationEnabled = ConfigEntry.DISCORD_VERIFICATION.getBoolean();
|
||||
List<String> ips = new ArrayList<>();
|
||||
ips.addAll(target.getIps());
|
||||
List<String> ips = new ArrayList<>(target.getIps());
|
||||
|
||||
if (verificationEnabled)
|
||||
{
|
||||
@ -49,15 +48,7 @@ public class Command_playerverification extends FreedomCommand
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("clearip"))
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
target.removeIp(args[1]);
|
||||
msg("Removed" + args[1] + " from your list of IPs");
|
||||
plugin.pl.save(target);
|
||||
plugin.pl.syncIps(target);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,8 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.admin.ActivityLogEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -45,16 +45,32 @@ public class Command_playtime extends FreedomCommand
|
||||
long cminutes = duration / (60 * 1000) % 60;
|
||||
long chours = duration / (60 * 60 * 1000);
|
||||
StringBuilder sb = new StringBuilder()
|
||||
.append("Playtime - " + sender.getName() + "\n")
|
||||
.append("Current Session: " + chours + " hours, " + cminutes + " minutes, and " + cseconds + " seconds" + "\n")
|
||||
.append("Overall: " + hours + " hours, " + minutes + " minutes, and " + seconds + " seconds" + "\n");
|
||||
.append("Playtime - ")
|
||||
.append(sender.getName())
|
||||
.append("\n")
|
||||
.append("Current Session: ")
|
||||
.append(chours)
|
||||
.append(" hours, ")
|
||||
.append(cminutes)
|
||||
.append(" minutes, and ")
|
||||
.append(cseconds)
|
||||
.append(" seconds")
|
||||
.append("\n")
|
||||
.append("Overall: ")
|
||||
.append(hours)
|
||||
.append(" hours, ")
|
||||
.append(minutes)
|
||||
.append(" minutes, and ")
|
||||
.append(seconds)
|
||||
.append(" seconds")
|
||||
.append("\n");
|
||||
List<String> durations = entry.getDurations();
|
||||
if (durations.size() >= 3)
|
||||
{
|
||||
sb.append("Recent Sessions:");
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
sb.append("\n" + " - " + durations.get((durations.size() - 1) - i));
|
||||
sb.append("\n" + " - ").append(durations.get((durations.size() - 1) - i));
|
||||
}
|
||||
}
|
||||
msg(sb.toString());
|
||||
|
@ -38,7 +38,7 @@ public class Command_plugincontrol extends FreedomCommand
|
||||
{
|
||||
final String version = serverPlugin.getDescription().getVersion();
|
||||
msg(ChatColor.GRAY + "- " + (serverPlugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + serverPlugin.getName()
|
||||
+ ChatColor.GOLD + (version != null && !version.isEmpty() ? " v" + version : "") + " by "
|
||||
+ ChatColor.GOLD + (!version.isEmpty() ? " v" + version : "") + " by "
|
||||
+ StringUtils.join(serverPlugin.getDescription().getAuthors(), ", "));
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
public class Command_potion extends FreedomCommand
|
||||
{
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -178,8 +179,7 @@ public class Command_potion extends FreedomCommand
|
||||
switch (args.length)
|
||||
{
|
||||
case 1:
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.addAll(Arrays.asList("list", "clear", "add"));
|
||||
List<String> arguments = new ArrayList<>(Arrays.asList("list", "clear", "add"));
|
||||
if (plugin.al.isAdmin(sender))
|
||||
{
|
||||
arguments.add("clearall");
|
||||
@ -203,14 +203,14 @@ public class Command_potion extends FreedomCommand
|
||||
case 3:
|
||||
if (args[0].equals("add"))
|
||||
{
|
||||
return Arrays.asList("<duration>");
|
||||
return Collections.singletonList("<duration>");
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (args[0].equals("add"))
|
||||
{
|
||||
return Arrays.asList("<amplifier>");
|
||||
return Collections.singletonList("<amplifier>");
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -19,11 +19,6 @@ import org.bukkit.entity.ThrownPotion;
|
||||
@CommandParameters(description = "Allows admins to see potions that are thrown.", usage = "/<command> <enable | on | disable | off> | history [player] <page>", aliases = "potspy")
|
||||
public class Command_potionspy extends FreedomCommand
|
||||
{
|
||||
private String titleText = "&8&m------------------&r &ePotionSpy &8&m------------------&r";
|
||||
private String validPageText = "Please specify a valid page number between 1 and %s.";
|
||||
private String noPlayerRecord = "That player has not thrown any potions yet.";
|
||||
private String splashedText = "&r%s splashed a potion at &eX: %s Y: %s Z: %s&r\nin the world '&e%s&r' about &e%s &rago%s.";
|
||||
private String bottomText = "&8&m--------------------&r &e%s / %s &8&m--------------------&r";
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
@ -37,6 +32,11 @@ public class Command_potionspy extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
String titleText = "&8&m------------------&r &ePotionSpy &8&m------------------&r";
|
||||
String validPageText = "Please specify a valid page number between 1 and %s.";
|
||||
String noPlayerRecord = "That player has not thrown any potions yet.";
|
||||
String splashedText = "&r%s splashed a potion at &eX: %s Y: %s Z: %s&r\nin the world '&e%s&r' about &e%s &rago%s.";
|
||||
String bottomText = "&8&m--------------------&r &e%s / %s &8&m--------------------&r";
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
case "enable":
|
||||
@ -59,8 +59,7 @@ public class Command_potionspy extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
List<Map.Entry<ThrownPotion, Long>> thrownPotions = new ArrayList<>();
|
||||
thrownPotions.addAll(plugin.mo.getPlayerThrownPotions(player)); // Make a copy of the list to avoid modifying the original.
|
||||
List<Map.Entry<ThrownPotion, Long>> thrownPotions = new ArrayList<>(plugin.mo.getPlayerThrownPotions(player)); // Make a copy of the list to avoid modifying the original.
|
||||
|
||||
List<String> potionThrowNotifications = new ArrayList<>();
|
||||
int lastPage = (int)Math.ceil(thrownPotions.size() / 5.0);
|
||||
|
@ -47,7 +47,7 @@ public class Command_premium extends FreedomCommand
|
||||
final URL getUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + name);
|
||||
final HttpURLConnection urlConnection = (HttpURLConnection)getUrl.openConnection();
|
||||
urlConnection.setRequestProperty("User-Agent", "");
|
||||
String message = "";
|
||||
String message;
|
||||
/*old code
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())))
|
||||
//message = (!"PREMIUM".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
|
||||
public class Command_releaseparrots extends FreedomCommand
|
||||
{
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
@ -22,6 +22,46 @@ import org.bukkit.entity.Player;
|
||||
public class Command_ro extends FreedomCommand
|
||||
{
|
||||
|
||||
public static int replaceBlocks(Location center, Material fromMaterial, Material toMaterial, int radius)
|
||||
{
|
||||
int affected = 0;
|
||||
|
||||
Block centerBlock = center.getBlock();
|
||||
for (int xOffset = -radius; xOffset <= radius; xOffset++)
|
||||
{
|
||||
for (int yOffset = -radius; yOffset <= radius; yOffset++)
|
||||
{
|
||||
for (int zOffset = -radius; zOffset <= radius; zOffset++)
|
||||
{
|
||||
Block block = centerBlock.getRelative(xOffset, yOffset, zOffset);
|
||||
BlockData data = block.getBlockData();
|
||||
if (block.getLocation().distanceSquared(center) < (radius * radius))
|
||||
{
|
||||
if (fromMaterial.equals(Material.WATER) && data instanceof Waterlogged)
|
||||
{
|
||||
Waterlogged waterloggedData = (Waterlogged)data;
|
||||
if (waterloggedData.isWaterlogged())
|
||||
{
|
||||
waterloggedData.setWaterlogged(false);
|
||||
block.setBlockData(waterloggedData);
|
||||
affected++;
|
||||
continue;
|
||||
}
|
||||
block.setType(toMaterial);
|
||||
affected++;
|
||||
}
|
||||
else if (block.getType().equals(fromMaterial))
|
||||
{
|
||||
block.setType(toMaterial);
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -97,7 +137,7 @@ public class Command_ro extends FreedomCommand
|
||||
{
|
||||
adminWorld = plugin.wm.adminworld.getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
|
||||
@ -134,47 +174,4 @@ public class Command_ro extends FreedomCommand
|
||||
FUtil.adminAction(sender.getName(), "Remove complete! " + affected + " blocks removed.", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int replaceBlocks(Location center, Material fromMaterial, Material toMaterial, int radius)
|
||||
{
|
||||
int affected = 0;
|
||||
|
||||
Block centerBlock = center.getBlock();
|
||||
for (int xOffset = -radius; xOffset <= radius; xOffset++)
|
||||
{
|
||||
for (int yOffset = -radius; yOffset <= radius; yOffset++)
|
||||
{
|
||||
for (int zOffset = -radius; zOffset <= radius; zOffset++)
|
||||
{
|
||||
Block block = centerBlock.getRelative(xOffset, yOffset, zOffset);
|
||||
BlockData data = block.getBlockData();
|
||||
if (block.getLocation().distanceSquared(center) < (radius * radius))
|
||||
{
|
||||
if (fromMaterial.equals(Material.WATER) && data instanceof Waterlogged)
|
||||
{
|
||||
if (data instanceof Waterlogged)
|
||||
{
|
||||
Waterlogged waterloggedData = (Waterlogged)data;
|
||||
if (waterloggedData.isWaterlogged())
|
||||
{
|
||||
waterloggedData.setWaterlogged(false);
|
||||
block.setBlockData(waterloggedData);
|
||||
affected++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
block.setType(toMaterial);
|
||||
affected++;
|
||||
}
|
||||
else if (block.getType().equals(fromMaterial))
|
||||
{
|
||||
block.setType(toMaterial);
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return affected;
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ public class Command_rock extends FreedomCommand
|
||||
{
|
||||
final ItemStack heldItem = new ItemStack(Material.STONE);
|
||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||
assert heldItemMeta != null;
|
||||
heldItemMeta.setDisplayName(ChatColor.BLUE + "Rock");
|
||||
heldItem.setItemMeta(heldItemMeta);
|
||||
|
||||
|
@ -5,11 +5,11 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -176,7 +176,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
}
|
||||
|
||||
// Find the old admin entry
|
||||
String name = player != null ? player.getName() : args[1];
|
||||
String name = player.getName();
|
||||
Admin admin = null;
|
||||
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
||||
{
|
||||
@ -195,33 +195,24 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
if (admin == null) // New admin
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
||||
admin = new Admin(player);
|
||||
|
||||
plugin.al.addAdmin(admin);
|
||||
plugin.rm.updateDisplay(player);
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
}
|
||||
else // Existing admin
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the admin list", true);
|
||||
|
||||
if (player != null)
|
||||
String oldName = admin.getName();
|
||||
if (!oldName.equals(player.getName()))
|
||||
{
|
||||
String oldName = admin.getName();
|
||||
if (oldName != player.getName())
|
||||
{
|
||||
admin.setName(player.getName());
|
||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||
}
|
||||
admin.addIp(FUtil.getIp(player));
|
||||
admin.setName(player.getName());
|
||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||
}
|
||||
admin.addIp(FUtil.getIp(player));
|
||||
|
||||
admin.setActive(true);
|
||||
admin.setLastLogin(new Date());
|
||||
@ -234,32 +225,26 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
if (player != null)
|
||||
{
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
plugin.rm.updateDisplay(player);
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
plugin.dc.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||
Discord.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||
}
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
}
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
{
|
||||
fPlayer.getFreezeData().setFrozen(false);
|
||||
msg(player, "You have been unfrozen.");
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
if (!player.isOp())
|
||||
{
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
{
|
||||
fPlayer.getFreezeData().setFrozen(false);
|
||||
msg(player, "You have been unfrozen.");
|
||||
}
|
||||
|
||||
if (!player.isOp())
|
||||
{
|
||||
player.setOp(true);
|
||||
player.sendMessage(YOU_ARE_OP);
|
||||
}
|
||||
player.setOp(true);
|
||||
player.sendMessage(YOU_ARE_OP);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -7,10 +7,11 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Switch;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.material.Lever;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/<command> <x> <y> <z> <worldname> <on|off>")
|
||||
@ -65,9 +66,11 @@ public class Command_setlever extends FreedomCommand
|
||||
if (targetBlock.getType() == Material.LEVER)
|
||||
{
|
||||
BlockState state = targetBlock.getState();
|
||||
Lever lever = (Lever)state.getData();
|
||||
lever.setPowered(leverOn);
|
||||
state.setData(lever);
|
||||
BlockData data = state.getBlockData();
|
||||
Switch caster = (Switch)data;
|
||||
|
||||
caster.setPowered(leverOn);
|
||||
state.setBlockData(data);
|
||||
state.update();
|
||||
}
|
||||
else
|
||||
|
@ -59,6 +59,7 @@ public class Command_setplayerlimit extends FreedomCommand
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
assert player != null;
|
||||
FUtil.adminAction(sender.getName(), "Setting " + player.getName() + "'s WorldEdit block modification limit to " + amount + ".", true);
|
||||
}
|
||||
return true;
|
||||
|
@ -19,51 +19,6 @@ import org.bukkit.entity.Player;
|
||||
public class Command_smite extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
boolean silent = false;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
silent = true;
|
||||
}
|
||||
|
||||
if (args.length >= 3)
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
}
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
smite(sender, player, reason, silent);
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void smite(CommandSender sender, Player player)
|
||||
{
|
||||
smite(sender, player, null, false);
|
||||
@ -122,4 +77,49 @@ public class Command_smite extends FreedomCommand
|
||||
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Reason: " + reason, 20, 100, 60);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
boolean silent = false;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
silent = true;
|
||||
}
|
||||
|
||||
if (args.length >= 3)
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
}
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
smite(sender, player, reason, silent);
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
@ -40,12 +41,12 @@ public class Command_tban extends FreedomCommand
|
||||
}
|
||||
|
||||
final String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
final PlayerData entry;
|
||||
if (player == null)
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
entry = plugin.pl.getData(args[0]);
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
@ -54,14 +55,13 @@ public class Command_tban extends FreedomCommand
|
||||
}
|
||||
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
else
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(player);
|
||||
entry = plugin.pl.getData(player);
|
||||
username = player.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
final List<String> ips = new ArrayList<>(entry.getIps());
|
||||
|
||||
String reason = null;
|
||||
if (args.length > 1)
|
||||
@ -84,7 +84,7 @@ public class Command_tban extends FreedomCommand
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
targetPos.getWorld().strikeLightning(strike_pos);
|
||||
Objects.requireNonNull(targetPos.getWorld()).strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
@ -22,7 +23,7 @@ import org.bukkit.entity.Player;
|
||||
public class Command_tempban extends FreedomCommand
|
||||
{
|
||||
|
||||
private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||
private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
@ -44,12 +45,12 @@ public class Command_tempban extends FreedomCommand
|
||||
}
|
||||
|
||||
final String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
final PlayerData entry;
|
||||
if (player == null)
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
entry = plugin.pl.getData(args[0]);
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
@ -58,15 +59,15 @@ public class Command_tempban extends FreedomCommand
|
||||
}
|
||||
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
else
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(player);
|
||||
entry = plugin.pl.getData(player);
|
||||
username = player.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
final List<String> ips = new ArrayList<>(entry.getIps());
|
||||
|
||||
assert player != null;
|
||||
final StringBuilder message = new StringBuilder("Temporarily banned " + player.getName());
|
||||
|
||||
Date expires = FUtil.parseDateOffset("30m");
|
||||
@ -93,7 +94,7 @@ public class Command_tempban extends FreedomCommand
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
targetPos.getWorld().strikeLightningEffect(strike_pos);
|
||||
Objects.requireNonNull(targetPos.getWorld()).strikeLightningEffect(strike_pos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,14 +108,7 @@ public class Command_tempban extends FreedomCommand
|
||||
|
||||
Ban ban;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
ban = Ban.forPlayer(player, sender, null, reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
ban = Ban.forPlayerName(username, sender, null, reason);
|
||||
}
|
||||
ban = Ban.forPlayer(player, sender, null, reason);
|
||||
|
||||
for (String ip : ips)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.GameRuleHandler;
|
||||
import me.totalfreedom.totalfreedommod.LoginProcess;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -109,8 +110,8 @@ public class Command_toggle extends FreedomCommand
|
||||
|
||||
case "lockdown":
|
||||
{
|
||||
boolean active = !plugin.lp.isLockdownEnabled();
|
||||
plugin.lp.setLockdownEnabled(active);
|
||||
boolean active = !LoginProcess.isLockdownEnabled();
|
||||
LoginProcess.setLockdownEnabled(active);
|
||||
FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true);
|
||||
break;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -21,6 +22,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class Command_tossmob extends FreedomCommand
|
||||
{
|
||||
|
||||
public static List<String> getAllMobNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (EntityType entityType : Groups.MOB_TYPES)
|
||||
{
|
||||
names.add(entityType.name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -38,41 +49,38 @@ public class Command_tossmob extends FreedomCommand
|
||||
FPlayer playerData = plugin.pl.getPlayer(playerSender);
|
||||
|
||||
EntityType type = null;
|
||||
if (args.length >= 1)
|
||||
if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
playerData.disableMobThrower();
|
||||
msg("Turned off.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
playerData.disableMobThrower();
|
||||
msg("Turned off.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
msg("Supported mobs: " + getAllMobNames(), ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
msg("Supported mobs: " + getAllMobNames(), ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (EntityType loop : EntityType.values())
|
||||
for (EntityType loop : EntityType.values())
|
||||
{
|
||||
if (loop != null && loop.name().equalsIgnoreCase(args[0]))
|
||||
{
|
||||
if (loop != null && loop.name().equalsIgnoreCase(args[0]))
|
||||
{
|
||||
type = loop;
|
||||
break;
|
||||
}
|
||||
type = loop;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
msg("Unknown entity type: " + args[0], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
if (type == null)
|
||||
{
|
||||
msg("Unknown entity type: " + args[0], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Groups.MOB_TYPES.contains(type))
|
||||
{
|
||||
msg(FUtil.formatName(type.name()) + " is an entity, however it is not a mob.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
if (!Groups.MOB_TYPES.contains(type))
|
||||
{
|
||||
msg(FUtil.formatName(type.name()) + " is an entity, however it is not a mob.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
double speed = 1.0;
|
||||
@ -103,17 +111,7 @@ public class Command_tossmob extends FreedomCommand
|
||||
msg("Right click while holding a " + Material.BONE.toString() + " to throw mobs!", ChatColor.GREEN);
|
||||
msg("Type '/tossmob off' to disable. -By Madgeek1450", ChatColor.GREEN);
|
||||
|
||||
playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.BONE, 1));
|
||||
Objects.requireNonNull(playerSender.getEquipment()).setItemInMainHand(new ItemStack(Material.BONE, 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
public static List<String> getAllMobNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (EntityType entityType : Groups.MOB_TYPES)
|
||||
{
|
||||
names.add(entityType.name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@ public class Command_unban extends FreedomCommand
|
||||
if (args.length > 0)
|
||||
{
|
||||
String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
|
||||
if (entry == null)
|
||||
@ -32,7 +31,7 @@ public class Command_unban extends FreedomCommand
|
||||
}
|
||||
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
final List<String> ips = new ArrayList<>(entry.getIps());
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
||||
msg(username + " has been unbanned along with the following IPs: " + StringUtils.join(ips, ", "));
|
||||
|
@ -25,7 +25,7 @@ public class Command_unbanip extends FreedomCommand
|
||||
|
||||
String ip = args[0];
|
||||
|
||||
if (!FUtil.isValidIPv4(ip))
|
||||
if (FUtil.isValidIPv4(ip))
|
||||
{
|
||||
msg(ip + " is not a valid IP address", ChatColor.RED);
|
||||
return true;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -66,7 +67,7 @@ public class Command_vanish extends FreedomCommand
|
||||
}
|
||||
plugin.esb.setVanished(playerSender.getName(), false);
|
||||
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
||||
plugin.al.vanished.remove(playerSender.getName());
|
||||
AdminList.vanished.remove(playerSender.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -105,7 +106,7 @@ public class Command_vanish extends FreedomCommand
|
||||
}
|
||||
|
||||
plugin.esb.setVanished(playerSender.getName(), true);
|
||||
plugin.al.vanished.add(playerSender.getName());
|
||||
AdminList.vanished.add(playerSender.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -69,14 +70,14 @@ public class Command_verify extends FreedomCommand
|
||||
PlayerData mapPlayer = plugin.dc.getVerificationCodes().get(code);
|
||||
if (mapPlayer == null)
|
||||
{
|
||||
if (!playerData.getBackupCodes().contains(plugin.dc.getMD5(code)))
|
||||
if (!playerData.getBackupCodes().contains(Discord.getMD5(code)))
|
||||
{
|
||||
msg("You have entered an invalid verification code", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
backupCode = plugin.dc.getMD5(code);
|
||||
backupCode = Discord.getMD5(code);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -169,8 +169,7 @@ public class Command_whitelist extends FreedomCommand
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.addAll(Arrays.asList("list", "count"));
|
||||
List<String> arguments = new ArrayList<>(Arrays.asList("list", "count"));
|
||||
if (plugin.al.isAdmin(sender))
|
||||
{
|
||||
arguments.addAll(Arrays.asList("on", "off", "add", "remove", "addall"));
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -17,6 +16,16 @@ import org.bukkit.entity.Player;
|
||||
public class Command_whohas extends FreedomCommand
|
||||
{
|
||||
|
||||
public static List<String> getAllMaterials()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Material material : Material.values())
|
||||
{
|
||||
names.add(material.name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -69,16 +78,6 @@ public class Command_whohas extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
public static List<String> getAllMaterials()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Material material : Material.values())
|
||||
{
|
||||
names.add(material.name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
@ -89,7 +88,7 @@ public class Command_whohas extends FreedomCommand
|
||||
|
||||
if (args.length == 2 && plugin.al.isAdmin(sender))
|
||||
{
|
||||
return Arrays.asList("clear");
|
||||
return Collections.singletonList("clear");
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -32,11 +33,11 @@ public class Command_wipeuserdata extends FreedomCommand
|
||||
continue;
|
||||
}
|
||||
|
||||
FUtil.deleteFolder(new File(server.getPluginManager().getPlugin("Essentials").getDataFolder(), "userdata"));
|
||||
FUtil.deleteFolder(new File(Objects.requireNonNull(server.getPluginManager().getPlugin("Essentials")).getDataFolder(), "userdata"));
|
||||
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "playerdata"));
|
||||
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "stats"));
|
||||
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(w.getName()).getWorldFolder().getName() + "stats"));
|
||||
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(w.getName()).getWorldFolder().getName() + "playerdata"));
|
||||
FUtil.deleteFolder(new File(Objects.requireNonNull(Bukkit.getServer().getWorld(w.getName())).getWorldFolder().getName() + "stats"));
|
||||
FUtil.deleteFolder(new File(Objects.requireNonNull(Bukkit.getServer().getWorld(w.getName())).getWorldFolder().getName() + "playerdata"));
|
||||
msg("Deleted all player data.");
|
||||
return true;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ public class Command_wipewarps extends FreedomCommand
|
||||
File warps = new File(essentials.getDataFolder(), "warps");
|
||||
FUtil.adminAction(sender.getName(), "Wiping Essentials warps", true);
|
||||
FUtil.deleteFolder(warps);
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
warps.mkdir();
|
||||
essentials.reload();
|
||||
msg("All warps deleted.");
|
||||
|
@ -8,11 +8,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -27,43 +26,33 @@ import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.spigotmc.SpigotConfig;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
{
|
||||
public static final String COMMAND_PREFIX = "Command_";
|
||||
|
||||
@Getter
|
||||
private static CommandMap commandMap;
|
||||
@Getter
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String usage;
|
||||
@Getter
|
||||
private final String aliases;
|
||||
private final Rank level;
|
||||
private final SourceType source;
|
||||
private final boolean blockHostConsole;
|
||||
private final int cooldown;
|
||||
private final CommandParameters params;
|
||||
@Getter
|
||||
private final CommandPermissions perms;
|
||||
|
||||
protected CommandSender sender;
|
||||
|
||||
protected final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
||||
protected final Server server = plugin.getServer();
|
||||
|
||||
public static final String UNKNOWN_COMMAND = ChatColor.WHITE + SpigotConfig.unknownCommandMessage;
|
||||
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
||||
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
||||
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
|
||||
public static final String ONLY_CONSOLE = ChatColor.RED + "Only console senders may execute this command!";
|
||||
public static final String ONLY_IN_GAME = ChatColor.RED + "Only in-game players may execute this command!";
|
||||
public static final String NO_PERMISSION = ChatColor.RED + "You do not have permission to execute this command.";
|
||||
|
||||
public static final Timer timer = new Timer();
|
||||
public static final Map<CommandSender, FreedomCommand> COOLDOWN_TIMERS = new HashMap<>();
|
||||
private static CommandMap commandMap;
|
||||
protected final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
||||
protected final Server server = plugin.getServer();
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String usage;
|
||||
private final String aliases;
|
||||
private final Rank level;
|
||||
private final SourceType source;
|
||||
private final boolean blockHostConsole;
|
||||
private final int cooldown;
|
||||
private final CommandParameters params;
|
||||
private final CommandPermissions perms;
|
||||
protected CommandSender sender;
|
||||
|
||||
FreedomCommand()
|
||||
{
|
||||
@ -79,25 +68,6 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
this.cooldown = perms.cooldown();
|
||||
}
|
||||
|
||||
public void register()
|
||||
{
|
||||
FCommand cmd = new FCommand(this.name);
|
||||
if (this.aliases != null)
|
||||
{
|
||||
cmd.setAliases(Arrays.asList(StringUtils.split(this.aliases, ",")));
|
||||
}
|
||||
if (this.description != null)
|
||||
{
|
||||
cmd.setDescription(this.description);
|
||||
}
|
||||
if (this.usage != null)
|
||||
{
|
||||
cmd.setUsage(this.usage);
|
||||
}
|
||||
getCommandMap().register("totalfreedommod", cmd);
|
||||
cmd.setExecutor(this);
|
||||
}
|
||||
|
||||
public static CommandMap getCommandMap()
|
||||
{
|
||||
if (commandMap == null)
|
||||
@ -116,84 +86,42 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
return commandMap;
|
||||
}
|
||||
|
||||
private final class FCommand extends Command
|
||||
public static FreedomCommand getFrom(Command command)
|
||||
{
|
||||
private FreedomCommand cmd = null;
|
||||
|
||||
private FCommand(String command)
|
||||
try
|
||||
{
|
||||
super(command);
|
||||
return (FreedomCommand)(((PluginCommand)command).getExecutor());
|
||||
}
|
||||
|
||||
public void setExecutor(FreedomCommand cmd)
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
public boolean execute(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
if (cmd != null)
|
||||
{
|
||||
cmd.sender = sender;
|
||||
|
||||
if (COOLDOWN_TIMERS.containsKey(sender) && COOLDOWN_TIMERS.containsValue(cmd))
|
||||
{
|
||||
msg(ChatColor.RED + "You are on cooldown for this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()) && !FUtil.inDeveloperMode())
|
||||
{
|
||||
msg(ChatColor.RED + "Host console is not allowed to use this command!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.rm.getRank(sender).isAtLeast(perms.level()))
|
||||
{
|
||||
msg(NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.source() == SourceType.ONLY_CONSOLE && sender instanceof Player)
|
||||
{
|
||||
msg(ONLY_CONSOLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.source() == SourceType.ONLY_IN_GAME && sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
msg(ONLY_IN_GAME);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.cooldown() != 0 && !isAdmin(sender))
|
||||
{
|
||||
COOLDOWN_TIMERS.put(sender, cmd);
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
COOLDOWN_TIMERS.remove(sender);
|
||||
}
|
||||
}, perms.cooldown() * 1000);
|
||||
}
|
||||
return cmd.onCommand(sender, this, commandLabel, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args)
|
||||
{
|
||||
if (cmd != null)
|
||||
{
|
||||
return cmd.onTabComplete(sender, this, alias, args);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getCommandPrefix()
|
||||
{
|
||||
return COMMAND_PREFIX;
|
||||
}
|
||||
|
||||
public void register()
|
||||
{
|
||||
FCommand cmd = new FCommand(this.name);
|
||||
if (this.aliases != null)
|
||||
{
|
||||
cmd.setAliases(Arrays.asList(StringUtils.split(this.aliases, ",")));
|
||||
}
|
||||
if (this.description != null)
|
||||
{
|
||||
cmd.setDescription(this.description);
|
||||
}
|
||||
if (this.usage != null)
|
||||
{
|
||||
cmd.setUsage(this.usage);
|
||||
}
|
||||
getCommandMap().register("totalfreedommod", cmd);
|
||||
cmd.setExecutor(this);
|
||||
}
|
||||
|
||||
protected void msg(CommandSender sender, String message)
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + message);
|
||||
@ -258,15 +186,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkNotHostConsole()
|
||||
{
|
||||
if (isConsole() && FUtil.isFromHostConsole(sender.getName()))
|
||||
{
|
||||
throw new CommandFailException("This command can not be used from the host console.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String commandLabel, @NotNull String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -284,7 +204,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args)
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args)
|
||||
{
|
||||
List<String> options = getTabCompleteOptions(sender, command, alias, args);
|
||||
if (options == null)
|
||||
@ -344,14 +264,130 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
throw new CommandFailException(NO_PERMISSION);
|
||||
}
|
||||
|
||||
public static FreedomCommand getFrom(Command command)
|
||||
public String getName()
|
||||
{
|
||||
try
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getUsage()
|
||||
{
|
||||
return usage;
|
||||
}
|
||||
|
||||
public String getAliases()
|
||||
{
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public Rank getLevel()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
public SourceType getSource()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
public boolean isBlockHostConsole()
|
||||
{
|
||||
return blockHostConsole;
|
||||
}
|
||||
|
||||
public int getCooldown()
|
||||
{
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
public CommandParameters getParams()
|
||||
{
|
||||
return params;
|
||||
}
|
||||
|
||||
public CommandPermissions getPerms()
|
||||
{
|
||||
return perms;
|
||||
}
|
||||
|
||||
private final class FCommand extends Command
|
||||
{
|
||||
private FreedomCommand cmd = null;
|
||||
|
||||
private FCommand(String command)
|
||||
{
|
||||
return (FreedomCommand)(((PluginCommand)command).getExecutor());
|
||||
super(command);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
public void setExecutor(FreedomCommand cmd)
|
||||
{
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, String[] args)
|
||||
{
|
||||
if (cmd != null)
|
||||
{
|
||||
cmd.sender = sender;
|
||||
|
||||
if (COOLDOWN_TIMERS.containsKey(sender) && COOLDOWN_TIMERS.containsValue(cmd))
|
||||
{
|
||||
msg(ChatColor.RED + "You are on cooldown for this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()) && !FUtil.inDeveloperMode())
|
||||
{
|
||||
msg(ChatColor.RED + "Host console is not allowed to use this command!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.rm.getRank(sender).isAtLeast(perms.level()))
|
||||
{
|
||||
msg(NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.source() == SourceType.ONLY_CONSOLE && sender instanceof Player)
|
||||
{
|
||||
msg(ONLY_CONSOLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.source() == SourceType.ONLY_IN_GAME && sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
msg(ONLY_IN_GAME);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.cooldown() != 0 && !isAdmin(sender))
|
||||
{
|
||||
COOLDOWN_TIMERS.put(sender, cmd);
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
COOLDOWN_TIMERS.remove(sender);
|
||||
}
|
||||
}, perms.cooldown() * 1000L);
|
||||
}
|
||||
return cmd.onCommand(sender, this, commandLabel, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, String[] args)
|
||||
{
|
||||
if (cmd != null)
|
||||
{
|
||||
return cmd.onTabComplete(sender, this, alias, args);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,5 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
public enum SourceType
|
||||
{
|
||||
|
||||
ONLY_IN_GAME, ONLY_CONSOLE, BOTH;
|
||||
ONLY_IN_GAME, ONLY_CONSOLE, BOTH
|
||||
}
|
||||
|
Reference in New Issue
Block a user