mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-04 13:26:41 +00:00
Too much shit to list in the commit name
- Removes ancient unused code - General code cleanup in some places - Rewrites a few components to use Adventure (testing needed) - Rewrites a few commands to use more modern Java features like Streams - Fixes oversight where vanishing still worked by names and not UUIDs - Removes unused Pterodactyl integration - Removes AutoEject's IP range banning functionality - Does some minor cleanup to HTTPD's list & players modules - Fixes ages-old bug in the AntiSpam that caused it to falsely mute players
This commit is contained in:
@ -6,6 +6,7 @@ import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -33,13 +34,8 @@ public class Command_adminmode extends FreedomCommand
|
||||
{
|
||||
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
||||
FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!isAdmin(player))
|
||||
{
|
||||
player.kickPlayer("Server is now closed to non-admins.");
|
||||
}
|
||||
}
|
||||
server.getOnlinePlayers().stream().filter(player -> !isAdmin(player)).forEach(player ->
|
||||
player.kick(Component.text("The server is now closed to non-admins.")));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,30 +1,21 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.Arrays;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Lists all possible attributes.", usage = "/<command>")
|
||||
public class Command_attributelist extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
StringBuilder list = new StringBuilder("All possible attributes: ");
|
||||
|
||||
for (Attribute attribute : Attribute.values())
|
||||
{
|
||||
list.append(attribute.name()).append(", ");
|
||||
}
|
||||
|
||||
// Remove extra comma at the end of the list
|
||||
list = new StringBuilder(list.substring(0, list.length() - 2));
|
||||
|
||||
msg(list.toString());
|
||||
msg("All possible attributes: " + FUtil.listToString(Arrays.stream(Attribute.values()).map(Enum::name).toList()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
|
||||
public class Command_cage extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
@ -33,11 +33,8 @@ public class Command_cage extends FreedomCommand
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
fPlayer.getCageData().setCaged(false);
|
||||
}
|
||||
server.getOnlinePlayers().stream().map(player -> plugin.pl.getPlayer(player)).forEach(fPlayer ->
|
||||
fPlayer.getCageData().setCaged(false));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -62,7 +59,7 @@ public class Command_cage extends FreedomCommand
|
||||
final String s = args[1];
|
||||
switch (s)
|
||||
{
|
||||
case "head":
|
||||
case "head" ->
|
||||
{
|
||||
outerMaterial = Material.PLAYER_HEAD;
|
||||
if (args.length >= 3)
|
||||
@ -73,9 +70,8 @@ public class Command_cage extends FreedomCommand
|
||||
{
|
||||
outerMaterial = Material.SKELETON_SKULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "block":
|
||||
case "block" ->
|
||||
{
|
||||
if (args.length >= 3)
|
||||
{
|
||||
@ -85,7 +81,6 @@ public class Command_cage extends FreedomCommand
|
||||
if (Material.matchMaterial(args[2]) != null && Material.matchMaterial(args[2]).isBlock())
|
||||
{
|
||||
outerMaterial = Material.matchMaterial(args[2]);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -98,7 +93,7 @@ public class Command_cage extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
}
|
||||
default:
|
||||
default ->
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -156,7 +151,7 @@ public class Command_cage extends FreedomCommand
|
||||
{
|
||||
if (args[1].equals("block"))
|
||||
{
|
||||
return FUtil.getAllMaterialNames();
|
||||
return Arrays.stream(Material.values()).map(Enum::name).toList();
|
||||
}
|
||||
else if (args[1].equals("head"))
|
||||
{
|
||||
|
@ -10,20 +10,17 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Clears the chat.", usage = "/<command>", aliases = "cc")
|
||||
public class Command_cleanchat extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
||||
{
|
||||
if (!plugin.al.isAdmin(player))
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
msg(player, "");
|
||||
}
|
||||
msg(player, "");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
||||
return true;
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@ -15,20 +18,19 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
@CommandParameters(description = "Get a stick of happiness.", usage = "/<command>")
|
||||
public class Command_debugstick extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
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.",
|
||||
ChatColor.DARK_BLUE + "You can left click to select what you want to change.",
|
||||
ChatColor.DARK_GREEN + "And then you can right click to change it!",
|
||||
ChatColor.DARK_PURPLE + "Isn't technology amazing?");
|
||||
itemMeta.setLore(lore);
|
||||
itemMeta.displayName(Component.text("Stick of Happiness", NamedTextColor.GOLD).decorate(TextDecoration.BOLD));
|
||||
itemMeta.lore(Arrays.asList(
|
||||
Component.text("This is the most powerful stick in the game.", NamedTextColor.RED),
|
||||
Component.text("You can left click to select what you want to change.", NamedTextColor.DARK_BLUE),
|
||||
Component.text("And then you can right click to change it!", NamedTextColor.DARK_GREEN),
|
||||
Component.text("Isn't technology amazing?", NamedTextColor.DARK_PURPLE)
|
||||
));
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
playerSender.getInventory().addItem(itemStack);
|
||||
return true;
|
||||
|
@ -21,12 +21,7 @@ public class Command_denick extends FreedomCommand
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Removing all nicknames", false);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
plugin.esb.setNickname(player.getName(), null);
|
||||
}
|
||||
|
||||
server.getOnlinePlayers().forEach(player -> plugin.esb.setNickname(player.getName(), null));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class Command_deop extends FreedomCommand
|
||||
{
|
||||
if ((player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
||||
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName)) &&
|
||||
player.isOp() && !plugin.al.isVanished(player.getName()))
|
||||
player.isOp() && !plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
matchedPlayerNames.add(player.getName());
|
||||
player.setOp(false);
|
||||
|
@ -52,7 +52,6 @@ public class Command_doom extends FreedomCommand
|
||||
admin.setActive(false);
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
|
@ -5,6 +5,8 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -19,18 +21,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
@CommandParameters(description = "Enchant items.", usage = "/<command> <list | addall | reset | add <name> [level] | remove <name>>")
|
||||
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)
|
||||
@ -73,30 +63,23 @@ public class Command_enchant extends FreedomCommand
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("addall"))
|
||||
{
|
||||
for (Enchantment ench : Enchantment.values())
|
||||
Arrays.stream(Enchantment.values()).filter(enchantment -> enchantment.canEnchantItem(item)).forEach(ench ->
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ench.canEnchantItem(item))
|
||||
{
|
||||
item.addEnchantment(ench, ench.getMaxLevel());
|
||||
}
|
||||
item.addEnchantment(ench, ench.getMaxLevel());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
msg("Could not add enchantment: " + ench.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
msg("Added all possible enchantments for this item.");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("reset"))
|
||||
{
|
||||
for (Enchantment ench : item.getEnchantments().keySet())
|
||||
{
|
||||
item.removeEnchantment(ench);
|
||||
}
|
||||
|
||||
item.getEnchantments().keySet().forEach(item::removeEnchantment);
|
||||
msg("Removed all enchantments.");
|
||||
}
|
||||
else
|
||||
@ -258,7 +241,7 @@ public class Command_enchant extends FreedomCommand
|
||||
{
|
||||
if (!unsafe)
|
||||
{
|
||||
return stringNumberRange(1, enchantment.getMaxLevel());
|
||||
return IntStream.rangeClosed(1, enchantment.getMaxLevel()).mapToObj(String::valueOf).toList();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ public class Command_invis extends FreedomCommand
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY) && !plugin.al.isVanished(player.getName()))
|
||||
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY) && !plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
players.add(player.getName());
|
||||
if (clear && !plugin.al.isAdmin(player))
|
||||
|
@ -2,7 +2,8 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,20 +12,13 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Kick all non-admins on server.", usage = "/<command>", aliases = "kickall")
|
||||
public class Command_kicknoob extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Disconnecting all non-admins", true);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
player.kickPlayer(ChatColor.RED + "All non-admins were kicked by " + sender.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
||||
player.kick(Component.text("All non-admins were kicked by " + sender.getName() + ".", NamedTextColor.RED)));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -65,9 +65,9 @@ public class Command_list extends FreedomCommand
|
||||
+ " out of a maximum " + ChatColor.RED + server.getMaxPlayers() + ChatColor.BLUE + " players online.";
|
||||
|
||||
players = server.getOnlinePlayers().stream().filter(pl ->
|
||||
(listFilter == ListFilter.ADMINS && plugin.al.isAdmin(pl) && !plugin.al.isVanished(pl.getName()))
|
||||
|| (listFilter == ListFilter.VANISHED_ADMINS && plugin.al.isVanished(pl.getName()))
|
||||
|| (listFilter == ListFilter.PLAYERS && !plugin.al.isVanished(pl.getName()))).map(player ->
|
||||
(listFilter == ListFilter.ADMINS && plugin.al.isAdmin(pl) && !plugin.al.isVanished(pl.getUniqueId()))
|
||||
|| (listFilter == ListFilter.VANISHED_ADMINS && plugin.al.isVanished(pl.getUniqueId()))
|
||||
|| (listFilter == ListFilter.PLAYERS && !plugin.al.isVanished(pl.getUniqueId()))).map(player ->
|
||||
plugin.rm.getDisplay(player).getColoredTag() + player.getName()).toList();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -16,17 +15,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command> [name]", aliases = "mp")
|
||||
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)
|
||||
{
|
||||
@ -67,7 +55,7 @@ public class Command_mobpurge extends FreedomCommand
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return getAllMobNames();
|
||||
return Groups.MOB_TYPES.stream().map(Enum::name).toList();
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
@ -74,11 +74,11 @@ public class Command_nickfilter extends FreedomCommand
|
||||
|
||||
player = getPlayerByDisplayName(displayName);
|
||||
|
||||
if (player == null || plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
|
||||
if (player == null || plugin.al.isVanished(player.getUniqueId()) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
player = getPlayerByDisplayNameAlt(displayName);
|
||||
|
||||
if (player == null || !plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
|
||||
if (player == null || !plugin.al.isVanished(player.getUniqueId()) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
msg("Can't find player by nickname: " + displayName);
|
||||
return true;
|
||||
|
@ -35,7 +35,7 @@ public class Command_op extends FreedomCommand
|
||||
{
|
||||
if ((player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
||||
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName)) &&
|
||||
!player.isOp() && !plugin.al.isVanished(player.getName()))
|
||||
!player.isOp() && !plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
matchedPlayerNames.add(player.getName());
|
||||
player.setOp(true);
|
||||
|
@ -1,114 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
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.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Manage your Pterodactyl panel account", usage = "/<command> <create | delete>")
|
||||
public class Command_panel extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (!plugin.ptero.isEnabled())
|
||||
{
|
||||
msg("Pterodactyl integration is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData playerData = getData(playerSender);
|
||||
|
||||
if (playerData.getDiscordID() == null)
|
||||
{
|
||||
msg("You must have a linked discord account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("create"))
|
||||
{
|
||||
msg("Creating your Pterodactyl account...", ChatColor.GREEN);
|
||||
Admin admin = getAdmin(playerSender);
|
||||
|
||||
if (admin.getPteroID() != null)
|
||||
{
|
||||
msg("You already have a Pterodactyl account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
String username = sender.getName();
|
||||
String password = FUtil.randomString(30);
|
||||
|
||||
String id = plugin.ptero.createAccount(username, password);
|
||||
if (Strings.isNullOrEmpty(id))
|
||||
{
|
||||
msg("Failed to create your Pterodactyl account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.ptero.addAccountToServer(id);
|
||||
|
||||
admin.setPteroID(id);
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
|
||||
plugin.dc.sendPteroInfo(playerData, username, password);
|
||||
msg("Successfully created your Pterodactyl account. Check your DMs from " + plugin.dc.formatBotTag() + " on discord to get your credentials.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("delete"))
|
||||
{
|
||||
msg("Deleting your Pterodactyl account...", ChatColor.GREEN);
|
||||
Admin admin = getAdmin(playerSender);
|
||||
|
||||
if (admin.getPteroID() == null)
|
||||
{
|
||||
msg("You do not have a Pterodactyl account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean deleted = plugin.ptero.deleteAccount(admin.getPteroID());
|
||||
|
||||
if (!deleted)
|
||||
{
|
||||
msg("Failed to delete your Pterodactyl account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
admin.setPteroID(null);
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
|
||||
msg("Successfully deleted your Pterodactyl account.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1 && plugin.al.isSeniorAdmin(sender))
|
||||
{
|
||||
return Arrays.asList("create", "delete");
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -117,7 +117,7 @@ public class Command_potion extends FreedomCommand
|
||||
|
||||
target = getPlayer(args[4]);
|
||||
|
||||
if (target == null || plugin.al.isVanished(target.getName()) && !plugin.al.isAdmin(sender))
|
||||
if (target == null || plugin.al.isVanished(target.getUniqueId()) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
|
@ -112,8 +112,6 @@ public class Command_saconfig extends FreedomCommand
|
||||
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
}
|
||||
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
|
||||
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
||||
return true;
|
||||
}
|
||||
@ -210,7 +208,6 @@ public class Command_saconfig extends FreedomCommand
|
||||
Discord.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||
}
|
||||
}
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
@ -265,8 +262,6 @@ public class Command_saconfig extends FreedomCommand
|
||||
Discord.syncRoles(admin, plugin.pl.getData(adminName).getDiscordID());
|
||||
}
|
||||
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,17 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@ -47,34 +45,11 @@ public class Command_seed extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
// If the sender is not a Player, use the usual msg method to
|
||||
if (senderIsConsole)
|
||||
{
|
||||
msg("Seed: [" + ChatColor.GREEN + world.getSeed() + ChatColor.WHITE + "]", ChatColor.WHITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Gets the seed for later uses
|
||||
String seed = String.valueOf(world.getSeed());
|
||||
|
||||
// This is a really stupid hack to get things to play nicely, but it works so I don't give a damn
|
||||
BaseComponent[] components = {new TranslatableComponent("chat.copy.click")};
|
||||
TextComponent seedAsComponent = new TextComponent(seed);
|
||||
|
||||
// Style the message like in vanilla Minecraft.
|
||||
seedAsComponent.setColor(ChatColor.GREEN.asBungee());
|
||||
seedAsComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, seed));
|
||||
seedAsComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(components)));
|
||||
|
||||
// Enclose the seed with brackets
|
||||
TextComponent seedString = new TextComponent("[");
|
||||
seedString.addExtra(seedAsComponent);
|
||||
seedString.addExtra("]");
|
||||
|
||||
// Send the message to the player.
|
||||
TranslatableComponent response = new TranslatableComponent("commands.seed.success", seedString);
|
||||
playerSender.spigot().sendMessage(response);
|
||||
}
|
||||
sender.sendMessage(Component.translatable("commands.seed.success",
|
||||
Component.text("[", NamedTextColor.WHITE).append(Component.text(world.getSeed(), NamedTextColor.GREEN)
|
||||
.clickEvent(ClickEvent.copyToClipboard(String.valueOf(world.getSeed())))
|
||||
.hoverEvent(HoverEvent.showText(Component.translatable("chat.copy"))))
|
||||
.append(Component.text("]"))));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -83,13 +58,7 @@ public class Command_seed extends FreedomCommand
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
// Returns a list of worlds on the server and returns it
|
||||
List<String> worlds = new ArrayList<>();
|
||||
for (World world : server.getWorlds())
|
||||
{
|
||||
worlds.add(world.getName());
|
||||
}
|
||||
return worlds;
|
||||
return server.getWorlds().stream().map(WorldInfo::getName).toList();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
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.World;
|
||||
@ -24,7 +24,7 @@ public class Command_spawnmob extends FreedomCommand
|
||||
{
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
List<EntityType> types = EnumUtils.getEnumList(EntityType.class);
|
||||
List<EntityType> types = Arrays.stream(EntityType.values()).toList();
|
||||
String typeList = StringUtils.join(types, ", ").toLowerCase();
|
||||
msg(typeList);
|
||||
return true;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
@ -13,19 +11,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Shows Minecraft server info, such as authentication status.", usage = "/<command>")
|
||||
public class Command_status extends FreedomCommand
|
||||
{
|
||||
|
||||
public static final Map<String, String> SERVICE_MAP = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
SERVICE_MAP.put("minecraft.net", "Minecraft.net");
|
||||
SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins");
|
||||
SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions");
|
||||
SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website");
|
||||
SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login");
|
||||
SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ public class Command_tag extends FreedomCommand
|
||||
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
|
||||
if (plugin.al.isVanished(player.getUniqueId()) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
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;
|
||||
@ -21,17 +19,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
usage = "/<command> <mobtype [speed] | off | list>")
|
||||
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)
|
||||
{
|
||||
@ -58,7 +45,7 @@ public class Command_tossmob extends FreedomCommand
|
||||
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
msg("Supported mobs: " + getAllMobNames(), ChatColor.GREEN);
|
||||
msg("Supported mobs: " + Groups.MOB_TYPES.stream().map(Enum::name).toList(), ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,8 @@ import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -19,7 +19,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
@CommandParameters(description = "Vanish/unvanish yourself.", usage = "/<command> [-s[ilent]]", aliases = "v")
|
||||
public class Command_vanish extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
Displayable display = plugin.rm.getDisplay(playerSender);
|
||||
@ -34,7 +34,7 @@ public class Command_vanish extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.al.isVanished(playerSender.getName()))
|
||||
if (plugin.al.isVanished(playerSender.getUniqueId()))
|
||||
{
|
||||
if (silent)
|
||||
{
|
||||
@ -44,7 +44,8 @@ public class Command_vanish extends FreedomCommand
|
||||
{
|
||||
msg("You have unvanished.", ChatColor.GOLD);
|
||||
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
|
||||
FUtil.bcastMsg(playerSender.getName() + " joined the game.", ChatColor.YELLOW);
|
||||
server.broadcast(Component.translatable("multiplayer.player.joined", Component.text(playerSender.getName()))
|
||||
.color(NamedTextColor.YELLOW));
|
||||
plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**", true);
|
||||
}
|
||||
|
||||
@ -67,7 +68,7 @@ public class Command_vanish extends FreedomCommand
|
||||
}
|
||||
plugin.esb.setVanished(playerSender.getName(), false);
|
||||
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
||||
AdminList.vanished.remove(playerSender.getName());
|
||||
AdminList.vanished.remove(playerSender.getUniqueId());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -76,9 +77,13 @@ public class Command_vanish extends FreedomCommand
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (plugin.al.isVanished(playerSender.getName()))
|
||||
if (plugin.al.isVanished(playerSender.getUniqueId()))
|
||||
{
|
||||
playerSender.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.GOLD + "You are hidden from other players."));
|
||||
sender.sendActionBar(Component.text("You are hidden from other players.").color(NamedTextColor.GOLD));
|
||||
}
|
||||
else
|
||||
{
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 4L);
|
||||
@ -90,23 +95,19 @@ public class Command_vanish extends FreedomCommand
|
||||
else
|
||||
{
|
||||
msg("You have vanished.", ChatColor.GOLD);
|
||||
FUtil.bcastMsg(playerSender.getName() + " left the game.", ChatColor.YELLOW);
|
||||
server.broadcast(Component.translatable("multiplayer.player.left", Component.text(playerSender.getName()))
|
||||
.color(NamedTextColor.YELLOW));
|
||||
plugin.dc.messageChatChannel("**" + playerSender.getName() + " left the server" + "**", true);
|
||||
}
|
||||
|
||||
FLog.info(playerSender.getName() + " is now vanished.");
|
||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins.");
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
player.hidePlayer(plugin, playerSender);
|
||||
}
|
||||
}
|
||||
server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
||||
player.hidePlayer(plugin,playerSender));
|
||||
|
||||
plugin.esb.setVanished(playerSender.getName(), true);
|
||||
AdminList.vanished.add(playerSender.getName());
|
||||
AdminList.vanished.add(playerSender.getUniqueId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -31,7 +30,8 @@ public class Command_whitelist extends FreedomCommand
|
||||
msg("There are no whitelisted players.");
|
||||
return true;
|
||||
}
|
||||
msg("Whitelisted players: " + FUtil.playerListToNames(server.getWhitelistedPlayers()));
|
||||
msg("Whitelisted players: " + FUtil.listToString(server.getWhitelistedPlayers().stream().map(player ->
|
||||
player.getName() != null ? player.getName() : player.getUniqueId().toString()).toList()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -187,23 +187,13 @@ public class Command_whitelist extends FreedomCommand
|
||||
}
|
||||
else if (args[0].equals("remove"))
|
||||
{
|
||||
return getWhitelistedNames();
|
||||
return server.getWhitelistedPlayers().stream().map(OfflinePlayer::getName).filter(Objects::nonNull).toList();
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<String> getWhitelistedNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (OfflinePlayer player : server.getWhitelistedPlayers())
|
||||
{
|
||||
names.add(player.getName());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public int purge()
|
||||
{
|
||||
int removed = 0;
|
||||
|
@ -1,6 +1,7 @@
|
||||
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;
|
||||
@ -15,17 +16,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "See who has an item and optionally clear the specified item.", usage = "/<command> <item> [clear]", aliases = "wh")
|
||||
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)
|
||||
{
|
||||
@ -49,7 +39,7 @@ public class Command_whohas extends FreedomCommand
|
||||
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender) && plugin.al.isVanished(player.getName()))
|
||||
if (!plugin.al.isAdmin(sender) && plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -80,7 +70,7 @@ public class Command_whohas extends FreedomCommand
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return getAllMaterials();
|
||||
return Arrays.stream(Material.values()).map(Enum::name).toList();
|
||||
}
|
||||
|
||||
if (args.length == 2 && plugin.al.isAdmin(sender))
|
||||
|
@ -217,7 +217,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
protected Player getPlayer(String name, Boolean nullVanished)
|
||||
{
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if (player != null && nullVanished && plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
|
||||
if (player != null && nullVanished && plugin.al.isVanished(player.getUniqueId()) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user