mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 20:47:37 +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:
parent
d3b4feaec9
commit
2698cbf46d
@ -3,6 +3,8 @@ package me.totalfreedom.totalfreedommod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -35,10 +37,10 @@ public class AntiNuke extends FreedomService
|
||||
|
||||
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
||||
{
|
||||
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||
//plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||
player.kickPlayer(ChatColor.RED + "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||
|
||||
server.broadcast(Component.text(player.getName()).append(Component.text(" is breaking blocks too fast!"))
|
||||
.color(NamedTextColor.RED));
|
||||
player.kick(Component.text("You are breaking blocks too fast. Nukers are not permitted on this server.",
|
||||
NamedTextColor.RED));
|
||||
fPlayer.resetBlockDestroyCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -58,10 +60,9 @@ public class AntiNuke extends FreedomService
|
||||
|
||||
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
||||
{
|
||||
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||
//plugin.ae.autoEject(player, "You are placing blocks too fast.");
|
||||
player.kickPlayer(ChatColor.RED + "You are placing blocks too fast.");
|
||||
|
||||
server.broadcast(Component.text(player.getName()).append(Component.text(" is placing blocks too fast!"))
|
||||
.color(NamedTextColor.RED));
|
||||
player.kick(Component.text("You are placing blocks too fast.", NamedTextColor.RED));
|
||||
fPlayer.resetBlockPlaceCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -10,52 +10,41 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AntiSpam extends FreedomService
|
||||
{
|
||||
|
||||
private ScheduledThreadPoolExecutor cycle;
|
||||
public static final int MSG_PER_CYCLE = 8;
|
||||
public static final int TICKS_PER_CYCLE = 2 * 10;
|
||||
//
|
||||
public BukkitTask cycleTask = null;
|
||||
private Map<Player, Integer> muteCounts = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
cycle();
|
||||
}
|
||||
}.runTaskTimer(plugin, TICKS_PER_CYCLE, TICKS_PER_CYCLE);
|
||||
cycle = new ScheduledThreadPoolExecutor(1);
|
||||
cycle.scheduleAtFixedRate(this::cycle, 0, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
FUtil.cancel(cycleTask);
|
||||
cycle.shutdownNow();
|
||||
}
|
||||
|
||||
private void cycle()
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
server.getOnlinePlayers().stream().map(player -> plugin.pl.getPlayer(player)).forEach(fPlayer ->
|
||||
{
|
||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
|
||||
// TODO: Move each to their own section
|
||||
playerdata.resetMsgCount();
|
||||
playerdata.resetBlockDestroyCount();
|
||||
playerdata.resetBlockPlaceCount();
|
||||
}
|
||||
fPlayer.resetMsgCount();
|
||||
fPlayer.resetBlockDestroyCount();
|
||||
fPlayer.resetBlockPlaceCount();
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
|
@ -91,7 +91,7 @@ public class AutoEject extends FreedomService
|
||||
}
|
||||
case STRIKE_THREE:
|
||||
{
|
||||
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
|
||||
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), null, kickMessage));
|
||||
|
||||
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
@ -21,15 +21,9 @@ public class CommandSpy extends FreedomService
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
|
||||
{
|
||||
if (player != event.getPlayer())
|
||||
{
|
||||
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)
|
||||
&& plugin.al.getAdmin(player).getCommandSpy() && player != event.getPlayer()).forEach(player ->
|
||||
player.sendMessage(Component.text(event.getPlayer().getName()).append(Component.text(": "))
|
||||
.append(Component.text(event.getMessage()))));
|
||||
}
|
||||
}
|
@ -1,214 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import com.google.common.base.Strings;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.util.Response;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
public class Pterodactyl extends FreedomService
|
||||
{
|
||||
|
||||
public final String URL = ConfigEntry.PTERO_URL.getString();
|
||||
private final String SERVER_KEY = ConfigEntry.PTERO_SERVER_KEY.getString();
|
||||
private final String ADMIN_KEY = ConfigEntry.PTERO_ADMIN_KEY.getString();
|
||||
private final List<String> SERVER_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + SERVER_KEY);
|
||||
private final List<String> ADMIN_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + ADMIN_KEY);
|
||||
|
||||
private boolean enabled = !Strings.isNullOrEmpty(URL);
|
||||
|
||||
public void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public void updateAccountStatus(Admin admin)
|
||||
{
|
||||
String id = admin.getPteroID();
|
||||
|
||||
if (Strings.isNullOrEmpty(id) || !enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!admin.isActive() || admin.getRank() != Rank.SENIOR_ADMIN)
|
||||
{
|
||||
FLog.debug("Disabling ptero acc");
|
||||
removeAccountFromServer(id);
|
||||
return;
|
||||
}
|
||||
|
||||
FLog.debug("Enabling ptero acc");
|
||||
addAccountToServer(id);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public String createAccount(String username, String password)
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("username", username);
|
||||
json.put("password", password);
|
||||
json.put("email", username.toLowerCase() + "@" + ConfigEntry.PTERO_DEFAULT_EMAIL_DOMAIN.getString());
|
||||
json.put("first_name", username);
|
||||
json.put("last_name", "\u200E"); // required, so I made it appear empty
|
||||
|
||||
Response response;
|
||||
JSONObject jsonResponse;
|
||||
try
|
||||
{
|
||||
response = FUtil.sendRequest(URL + "/api/application/users", "POST", ADMIN_HEADERS, json.toJSONString());
|
||||
jsonResponse = response.getJSONMessage();
|
||||
}
|
||||
catch (IOException | ParseException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return ((JSONObject)jsonResponse.get("attributes")).get("id").toString();
|
||||
|
||||
}
|
||||
|
||||
public boolean deleteAccount(String id)
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
try
|
||||
{
|
||||
return FUtil.sendRequest(URL + "/api/application/users/" + id, "DELETE", ADMIN_HEADERS, json.toJSONString()).getCode() == 204;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addAccountToServer(String id)
|
||||
{
|
||||
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users";
|
||||
|
||||
JSONObject userData = getUserData(id);
|
||||
if (userData == null)
|
||||
{
|
||||
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("email", userData.get("email").toString());
|
||||
json.put("permissions", Arrays.asList("control.console", "control.start", "control.restart", "control.stop", "control.kill"));
|
||||
|
||||
try
|
||||
{
|
||||
FUtil.sendRequest(url, "POST", SERVER_HEADERS, json.toJSONString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAccountFromServer(String id)
|
||||
{
|
||||
JSONObject userData = getUserData(id);
|
||||
if (userData == null)
|
||||
{
|
||||
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
|
||||
return;
|
||||
}
|
||||
|
||||
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users/" + userData.get("uuid");
|
||||
|
||||
try
|
||||
{
|
||||
FUtil.sendRequest(url, "DELETE", SERVER_HEADERS, null);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject getUserData(String id)
|
||||
{
|
||||
Response response;
|
||||
JSONObject jsonResponse;
|
||||
try
|
||||
{
|
||||
response = FUtil.sendRequest(URL + "/api/application/users/" + id, "GET", ADMIN_HEADERS, null);
|
||||
jsonResponse = response.getJSONMessage();
|
||||
|
||||
}
|
||||
catch (IOException | ParseException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return (JSONObject)jsonResponse.get("attributes");
|
||||
|
||||
}
|
||||
|
||||
// API patch function on users doesnt work rn, it throws 500 errors, so it's probably not written yet
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setPassword(String id, String password)
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("password", password);
|
||||
|
||||
try
|
||||
{
|
||||
FUtil.sendRequest(URL + "/api/application/users/" + id, "PATCH", ADMIN_HEADERS, json.toJSONString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getURL()
|
||||
{
|
||||
return URL;
|
||||
}
|
||||
|
||||
public String getServerKey()
|
||||
{
|
||||
return SERVER_KEY;
|
||||
}
|
||||
|
||||
public String getAdminKey()
|
||||
{
|
||||
return ADMIN_KEY;
|
||||
}
|
||||
|
||||
public List<String> getServerHeaders()
|
||||
{
|
||||
return SERVER_HEADERS;
|
||||
}
|
||||
|
||||
public List<String> getAdminHeaders()
|
||||
{
|
||||
return ADMIN_HEADERS;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
@ -119,7 +119,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public WorldRestrictions wr;
|
||||
public EntityWiper ew;
|
||||
public VanishHandler vh;
|
||||
public Pterodactyl ptero;
|
||||
//
|
||||
// Bridges
|
||||
public BukkitTelnetBridge btb;
|
||||
@ -312,7 +311,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
gr = new GameRuleHandler();
|
||||
ew = new EntityWiper();
|
||||
vh = new VanishHandler();
|
||||
ptero = new Pterodactyl();
|
||||
}
|
||||
|
||||
private void initAdminUtils()
|
||||
|
@ -1,6 +1,8 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -13,7 +15,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class VanishHandler extends FreedomService
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
@ -29,40 +30,32 @@ public class VanishHandler extends FreedomService
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(player) && plugin.al.isVanished(p.getName()))
|
||||
{
|
||||
player.hidePlayer(plugin, p);
|
||||
}
|
||||
}
|
||||
server.getOnlinePlayers().stream().filter(pl -> !plugin.al.isAdmin(player)
|
||||
&& plugin.al.isVanished(pl.getUniqueId())).forEach(pl -> player.hidePlayer(plugin, pl));
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(p) && plugin.al.isVanished(player.getName()))
|
||||
{
|
||||
p.hidePlayer(plugin, player);
|
||||
}
|
||||
}
|
||||
server.getOnlinePlayers().stream().filter(pl -> !plugin.al.isAdmin(pl)
|
||||
&& plugin.al.isVanished(player.getUniqueId())).forEach(pl -> pl.hidePlayer(plugin, player));
|
||||
|
||||
if (plugin.al.isVanished(player.getName()))
|
||||
if (plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
plugin.esb.setVanished(player.getName(), true);
|
||||
FLog.info(player.getName() + " joined while still vanished.");
|
||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
||||
event.setJoinMessage(null);
|
||||
event.joinMessage(null);
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!plugin.al.isVanished(player.getName()))
|
||||
if (plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
player.sendActionBar(Component.text("You are hidden from other players.").color(NamedTextColor.GOLD));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.GOLD + "You are hidden from other players."));
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 4L);
|
||||
}
|
||||
@ -73,9 +66,9 @@ public class VanishHandler extends FreedomService
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (plugin.al.isVanished(player.getName()))
|
||||
if (plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
event.setQuitMessage(null);
|
||||
event.quitMessage(null);
|
||||
FLog.info(player.getName() + " left while still vanished.");
|
||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has left silently.");
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ public class Admin
|
||||
private Boolean commandSpy = false;
|
||||
private Boolean potionSpy = false;
|
||||
private String acFormat = null;
|
||||
private String pteroID = null;
|
||||
|
||||
public Admin(Player player)
|
||||
{
|
||||
@ -46,7 +45,6 @@ public class Admin
|
||||
this.commandSpy = resultSet.getBoolean("command_spy");
|
||||
this.potionSpy = resultSet.getBoolean("potion_spy");
|
||||
this.acFormat = resultSet.getString("ac_format");
|
||||
this.pteroID = resultSet.getString("ptero_id");
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -65,8 +63,7 @@ public class Admin
|
||||
.append("- Rank: ").append(rank.getName()).append("\n")
|
||||
.append("- Is Active: ").append(active).append("\n")
|
||||
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
||||
.append("- Admin Chat Format: ").append(acFormat).append("\n")
|
||||
.append("- Pterodactyl ID: ").append(pteroID).append("\n");
|
||||
.append("- Admin Chat Format: ").append(acFormat).append("\n");
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
@ -83,7 +80,6 @@ public class Admin
|
||||
put("command_spy", commandSpy);
|
||||
put("potion_spy", potionSpy);
|
||||
put("ac_format", acFormat);
|
||||
put("ptero_id", pteroID);
|
||||
}};
|
||||
return map;
|
||||
}
|
||||
@ -247,14 +243,4 @@ public class Admin
|
||||
{
|
||||
this.acFormat = acFormat;
|
||||
}
|
||||
|
||||
public String getPteroID()
|
||||
{
|
||||
return pteroID;
|
||||
}
|
||||
|
||||
public void setPteroID(String pteroID)
|
||||
{
|
||||
this.pteroID = pteroID;
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class AdminList extends FreedomService
|
||||
{
|
||||
public static final List<String> vanished = new ArrayList<>();
|
||||
public static final List<UUID> vanished = new ArrayList<>();
|
||||
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
||||
// Only active admins below
|
||||
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
||||
@ -25,11 +25,6 @@ public class AdminList extends FreedomService
|
||||
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
||||
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
||||
|
||||
public static List<String> getVanished()
|
||||
{
|
||||
return vanished;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
@ -99,16 +94,6 @@ public class AdminList extends FreedomService
|
||||
return isAdmin(sender);
|
||||
}
|
||||
|
||||
public List<String> getActiveAdminNames()
|
||||
{
|
||||
List<String> names = new ArrayList();
|
||||
for (Admin admin : activeAdmins)
|
||||
{
|
||||
names.add(admin.getName());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public boolean isAdmin(CommandSender sender)
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
@ -321,9 +306,9 @@ public class AdminList extends FreedomService
|
||||
updateTables();
|
||||
}
|
||||
|
||||
public boolean isVanished(String player)
|
||||
public boolean isVanished(UUID uuid)
|
||||
{
|
||||
return vanished.contains(player);
|
||||
return vanished.contains(uuid);
|
||||
}
|
||||
|
||||
public Set<Admin> getAllAdmins()
|
||||
|
@ -121,17 +121,6 @@ public class Ban
|
||||
reason);
|
||||
}
|
||||
|
||||
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
|
||||
{
|
||||
return new Ban(player.getName(),
|
||||
player.getUniqueId(),
|
||||
FUtil.getFuzzyIp(FUtil.getIp(player)),
|
||||
by.getName(),
|
||||
Date.from(Instant.now()),
|
||||
expiry,
|
||||
reason);
|
||||
}
|
||||
|
||||
public static SimpleDateFormat getDateFormat()
|
||||
{
|
||||
return DATE_FORMAT;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -90,12 +90,6 @@ public enum ConfigEntry
|
||||
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
|
||||
DISCORD_INVITE_LINK(String.class, "discord.invite_link"),
|
||||
//
|
||||
PTERO_URL(String.class, "ptero.url"),
|
||||
PTERO_DEFAULT_EMAIL_DOMAIN(String.class, "ptero.default_email_domain"),
|
||||
PTERO_SERVER_UUID(String.class, "ptero.server_uuid"),
|
||||
PTERO_ADMIN_KEY(String.class, "ptero.admin_key"),
|
||||
PTERO_SERVER_KEY(String.class, "ptero.server_key"),
|
||||
//
|
||||
SHOP_ENABLED(Boolean.class, "shop.enabled"),
|
||||
SHOP_TITLE(String.class, "shop.title"),
|
||||
SHOP_PREFIX(String.class, "shop.prefix"),
|
||||
|
@ -231,32 +231,6 @@ public class Discord extends FreedomService
|
||||
messageChatChannel("**Message queue cleared**", true);
|
||||
}
|
||||
|
||||
public void sendPteroInfo(PlayerData playerData, String username, String password)
|
||||
{
|
||||
User user = getUser(playerData.getDiscordID());
|
||||
String message = "The following are your Pterodactyl details:\n\nUsername: " + username + "\nPassword: " + password + "\n\nYou can connect to the panel at " + plugin.ptero.URL;
|
||||
PrivateChannel privateChannel = user.openPrivateChannel().complete();
|
||||
privateChannel.sendMessage(message).complete();
|
||||
}
|
||||
|
||||
public User getUser(String id)
|
||||
{
|
||||
Guild guild = bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString());
|
||||
if (guild == null)
|
||||
{
|
||||
FLog.severe("Either the bot is not in the Discord server or it doesn't exist. Check the server ID.");
|
||||
return null;
|
||||
}
|
||||
|
||||
Member member = guild.getMemberById(id);
|
||||
if (member == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return member.getUser();
|
||||
}
|
||||
|
||||
public String generateCode(int size)
|
||||
{
|
||||
return RandomStringUtils.randomNumeric(size);
|
||||
@ -289,7 +263,7 @@ public class Discord extends FreedomService
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (!plugin.al.isVanished(event.getPlayer().getName()))
|
||||
if (!plugin.al.isVanished(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
messageChatChannel("**" + deformat(event.getPlayer().getName()) + " joined the server" + "**", true);
|
||||
}
|
||||
@ -298,7 +272,7 @@ public class Discord extends FreedomService
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLeave(PlayerQuitEvent event)
|
||||
{
|
||||
if (!plugin.al.isVanished(event.getPlayer().getName()))
|
||||
if (!plugin.al.isVanished(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
messageChatChannel("**" + deformat(event.getPlayer().getName()) + " left the server" + "**", true);
|
||||
}
|
||||
|
@ -70,26 +70,20 @@ public class ListCommand extends DiscordCommandImpl
|
||||
|
||||
Map<Displayable, List<String>> displayables = new HashMap<>();
|
||||
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers())
|
||||
Bukkit.getOnlinePlayers().stream().filter(player -> !adminList.isVanished(player.getUniqueId())).forEach(player ->
|
||||
{
|
||||
if (adminList.isVanished(onlinePlayer.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Displayable displayable = rankManager.getDisplay(onlinePlayer);
|
||||
|
||||
final String name = Discord.deformat(onlinePlayer.getName());
|
||||
final Displayable displayable = rankManager.getDisplay(player);
|
||||
final String name = Discord.deformat(player.getName());
|
||||
|
||||
if (displayables.containsKey(displayable))
|
||||
{
|
||||
displayables.get(displayable).add(name);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
displayables.put(displayable, new ArrayList<>(List.of(name)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (Map.Entry<Displayable, List<String>> entry : displayables.entrySet())
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ public class Module_list extends HTTPDModule
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.al.isVanished(player.getName()))
|
||||
if (plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -67,7 +67,7 @@ public class Module_list extends HTTPDModule
|
||||
operators.add(player.getName());
|
||||
}
|
||||
|
||||
if (hasSpecialTitle(player) && plugin.al.isAdmin(player) && !plugin.al.isVanished(player.getName()))
|
||||
if (hasSpecialTitle(player) && plugin.al.isAdmin(player) && !plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
switch (admin.getRank())
|
||||
@ -112,21 +112,13 @@ public class Module_list extends HTTPDModule
|
||||
|
||||
final Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
|
||||
int count = onlinePlayers.size() - AdminList.vanished.size();
|
||||
body.append("<p>There are ").append(count < 0 ? 0 : count).append("/")
|
||||
body.append("<p>There are ").append(FUtil.getFakePlayerCount()).append("/")
|
||||
.append(Bukkit.getMaxPlayers()).append(" players online:</p>\r\n");
|
||||
|
||||
body.append("<ul>\r\n");
|
||||
|
||||
for (Player player : onlinePlayers)
|
||||
{
|
||||
if (plugin.al.isVanished(player.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String tag = plugin.rm.getDisplay(player).getTag();
|
||||
body.append("<li>").append(tag).append(player.getName()).append("</li>\r\n");
|
||||
}
|
||||
onlinePlayers.stream().filter(player -> !plugin.al.isVanished(player.getUniqueId())).forEach(player ->
|
||||
body.append("<li>").append(plugin.rm.getDisplay(player).getTag()).append(player.getName()).append("</li>\r\n"));
|
||||
|
||||
body.append("</ul>\r\n");
|
||||
|
||||
|
@ -1,89 +1,59 @@
|
||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import com.google.gson.Gson;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class Module_players extends HTTPDModule
|
||||
{
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Module_players extends HTTPDModule
|
||||
{
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
public Module_players(NanoHTTPD.HTTPSession session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public NanoHTTPD.Response getResponse()
|
||||
{
|
||||
final JSONObject responseObject = new JSONObject();
|
||||
final Map<String, List<String>> responseMap = new HashMap<>();
|
||||
|
||||
final JSONArray players = new JSONArray();
|
||||
final JSONArray onlineadmins = new JSONArray(); // updated, never queried.
|
||||
final JSONArray masterbuilders = new JSONArray();
|
||||
final JSONArray admins = new JSONArray();
|
||||
final JSONArray senioradmins = new JSONArray();
|
||||
final JSONArray developers = new JSONArray();
|
||||
final JSONArray executives = new JSONArray();
|
||||
final List<String> admins = new ArrayList<>();
|
||||
final List<String> senioradmins = new ArrayList<>();
|
||||
|
||||
// All online players
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
plugin.al.getActiveAdmins().stream().filter(admin -> admin.getName() != null).forEach(admin ->
|
||||
{
|
||||
if (!plugin.al.isVanished(player.getName()))
|
||||
{
|
||||
players.add(player.getName());
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
onlineadmins.add(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Admins
|
||||
for (Admin admin : plugin.al.getActiveAdmins())
|
||||
{
|
||||
final String username = admin.getName();
|
||||
switch (admin.getRank())
|
||||
{
|
||||
case ADMIN:
|
||||
case ADMIN -> admins.add(admin.getName());
|
||||
case SENIOR_ADMIN -> senioradmins.add(admin.getName());
|
||||
default ->
|
||||
{
|
||||
admins.add(username);
|
||||
break;
|
||||
}
|
||||
case SENIOR_ADMIN:
|
||||
{
|
||||
senioradmins.add(username);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Do nothing
|
||||
break;
|
||||
// Do nothing, keeps Codacy quiet
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
masterbuilders.addAll(plugin.pl.getMasterBuilderNames());
|
||||
responseMap.put("players", server.getOnlinePlayers().stream().filter(player ->
|
||||
!plugin.al.isVanished(player.getUniqueId())).map(HumanEntity::getName).toList());
|
||||
responseMap.put("masterbuilders", plugin.pl.getMasterBuilderNames());
|
||||
responseMap.put("admins", admins);
|
||||
responseMap.put("senioradmins", senioradmins);
|
||||
responseMap.put("developers", FUtil.DEVELOPER_NAMES);
|
||||
responseMap.put("assistantexecutives", ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getStringList());
|
||||
responseMap.put("executives", ConfigEntry.SERVER_EXECUTIVES.getStringList());
|
||||
|
||||
// Developers
|
||||
developers.addAll(FUtil.DEVELOPER_NAMES);
|
||||
|
||||
// Executives
|
||||
executives.addAll(ConfigEntry.SERVER_EXECUTIVES.getList());
|
||||
|
||||
responseObject.put("players", players);
|
||||
responseObject.put("masterbuilders", masterbuilders);
|
||||
responseObject.put("admins", admins);
|
||||
responseObject.put("senioradmins", senioradmins);
|
||||
responseObject.put("developers", developers);
|
||||
responseObject.put("executives", executives);
|
||||
|
||||
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString());
|
||||
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON,
|
||||
gson.toJson(responseMap));
|
||||
response.addHeader("Access-Control-Allow-Origin", "*");
|
||||
return response;
|
||||
}
|
||||
|
@ -193,12 +193,10 @@ public class RankManager extends FreedomService
|
||||
}
|
||||
|
||||
// Broadcast login message
|
||||
if (isAdmin || FUtil.isDeveloper(player) || plugin.pl.getData(player).isMasterBuilder() || plugin.pl.getData(player).hasLoginMessage())
|
||||
if ((isAdmin || FUtil.isDeveloper(player) || plugin.pl.getData(player).isMasterBuilder()
|
||||
|| plugin.pl.getData(player).hasLoginMessage()) && !plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
if (!plugin.al.isVanished(player.getName()))
|
||||
{
|
||||
FUtil.bcastMsg(craftLoginMessage(player, null));
|
||||
}
|
||||
FUtil.bcastMsg(craftLoginMessage(player, null));
|
||||
}
|
||||
|
||||
// Set display
|
||||
|
@ -84,7 +84,7 @@ public class SQLite extends FreedomService
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.createStatement().execute("CREATE TABLE `admins` (`uuid` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `rank` VARCHAR NOT NULL, `active` BOOLEAN NOT NULL, `last_login` LONG NOT NULL, `command_spy` BOOLEAN NOT NULL, `potion_spy` BOOLEAN NOT NULL, `ac_format` VARCHAR, `ptero_id` VARCHAR);");
|
||||
connection.createStatement().execute("CREATE TABLE `admins` (`uuid` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `rank` VARCHAR NOT NULL, `active` BOOLEAN NOT NULL, `last_login` LONG NOT NULL, `command_spy` BOOLEAN NOT NULL, `potion_spy` BOOLEAN NOT NULL, `ac_format` VARCHAR);");
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -219,7 +219,7 @@ public class SQLite extends FreedomService
|
||||
{
|
||||
try
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO admins VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO admins VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
statement.setString(1, admin.getUuid().toString());
|
||||
statement.setString(2, FUtil.listToString(admin.getIps()));
|
||||
statement.setString(3, admin.getRank().toString());
|
||||
@ -228,7 +228,6 @@ public class SQLite extends FreedomService
|
||||
statement.setBoolean(6, admin.getCommandSpy());
|
||||
statement.setBoolean(7, admin.getPotionSpy());
|
||||
statement.setString(8, admin.getAcFormat());
|
||||
statement.setString(9, admin.getPteroID());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
catch (SQLException e)
|
||||
|
@ -69,21 +69,6 @@ public class FSync
|
||||
}.runTask(plugin);
|
||||
}
|
||||
|
||||
public static void autoEject(final Player player, final String kickMessage)
|
||||
{
|
||||
final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
||||
new BukkitRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
plugin.ae.autoEject(player, kickMessage);
|
||||
}
|
||||
|
||||
}.runTask(plugin);
|
||||
}
|
||||
|
||||
public static void bcastMsg(final String message, final ChatColor color)
|
||||
{
|
||||
final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
||||
|
@ -4,22 +4,17 @@ import com.earth2me.essentials.utils.DateUtil;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
@ -91,34 +86,12 @@ public class FUtil
|
||||
ChatColor.DARK_PURPLE,
|
||||
ChatColor.LIGHT_PURPLE);
|
||||
private static final SplittableRandom RANDOM = new SplittableRandom();
|
||||
private static final String CHARACTER_STRING = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
private static final Map<Integer, String> TIMEZONE_LOOKUP = new HashMap<>();
|
||||
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
||||
private static final List<String> regxList = Arrays.asList("y", "mo", "w", "d", "h", "m", "s");
|
||||
|
||||
static
|
||||
{
|
||||
for (ChatColor chatColor : CHAT_COLOR_POOL)
|
||||
{
|
||||
CHAT_COLOR_NAMES.put(chatColor.name().toLowerCase().replace("_", ""), chatColor);
|
||||
}
|
||||
|
||||
for (int i = -12; i <= 12; i++)
|
||||
{
|
||||
String sec = String.valueOf(i).replace("-", "");
|
||||
if (i > -10 && i < 10)
|
||||
{
|
||||
sec = "0" + sec;
|
||||
}
|
||||
if (i >= 0)
|
||||
{
|
||||
sec = "+" + sec;
|
||||
}
|
||||
else
|
||||
{
|
||||
sec = "-" + sec;
|
||||
}
|
||||
TIMEZONE_LOOKUP.put(i, "GMT" + sec + ":00");
|
||||
}
|
||||
CHAT_COLOR_POOL.forEach(color -> CHAT_COLOR_NAMES.put(color.name().toLowerCase().replace("_", ""), color));
|
||||
}
|
||||
|
||||
public static void cancel(BukkitTask task)
|
||||
@ -139,7 +112,9 @@ public class FUtil
|
||||
|
||||
public static boolean isExecutive(String name)
|
||||
{
|
||||
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getStringList().contains(name);
|
||||
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name)
|
||||
|| ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name)
|
||||
|| ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getStringList().contains(name);
|
||||
}
|
||||
|
||||
public static boolean isDeveloper(Player player)
|
||||
@ -171,15 +146,8 @@ public class FUtil
|
||||
|
||||
public static List<String> getPlayerList()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (!TotalFreedomMod.getPlugin().al.isVanished(player.getName()))
|
||||
{
|
||||
names.add(player.getName());
|
||||
}
|
||||
}
|
||||
return names;
|
||||
return getServer().getOnlinePlayers().stream().filter(player ->
|
||||
!TotalFreedomMod.getPlugin().al.isVanished(player.getUniqueId())).map(HumanEntity::getName).toList();
|
||||
}
|
||||
|
||||
public static String listToString(List<String> list)
|
||||
@ -233,58 +201,6 @@ public class FUtil
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getAllMaterialNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Material material : Material.values())
|
||||
{
|
||||
names.add(material.name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static Response sendRequest(String endpoint, String method, List<String> headers, String body) throws IOException
|
||||
{
|
||||
URL url = new URL(endpoint);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
connection.setRequestMethod(method);
|
||||
|
||||
if (headers != null)
|
||||
{
|
||||
|
||||
for (String header : headers)
|
||||
{
|
||||
String[] kv = header.split(":");
|
||||
connection.setRequestProperty(kv[0], kv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
FLog.info(connection.getRequestMethod());
|
||||
|
||||
if (body != null)
|
||||
{
|
||||
connection.setDoOutput(true);
|
||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.writeBytes(body);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuilder response = new StringBuilder();
|
||||
|
||||
while ((inputLine = in.readLine()) != null)
|
||||
{
|
||||
response.append(inputLine);
|
||||
}
|
||||
|
||||
in.close();
|
||||
|
||||
return new Response(connection.getResponseCode(), response.toString());
|
||||
}
|
||||
|
||||
public static void bcastMsg(String message, ChatColor color)
|
||||
{
|
||||
bcastMsg(message, color, true);
|
||||
@ -365,17 +281,6 @@ public class FUtil
|
||||
}
|
||||
}
|
||||
|
||||
private static final List<String> regxList = new ArrayList<String>()
|
||||
{{
|
||||
add("y");
|
||||
add("mo");
|
||||
add("w");
|
||||
add("d");
|
||||
add("h");
|
||||
add("m");
|
||||
add("s");
|
||||
}};
|
||||
|
||||
private static long a(String parse)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@ -447,16 +352,6 @@ public class FUtil
|
||||
return FUtil.getUnixTime(Date.from(instant));
|
||||
}
|
||||
|
||||
public static String playerListToNames(Set<OfflinePlayer> players)
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (OfflinePlayer player : players)
|
||||
{
|
||||
names.add(player.getName());
|
||||
}
|
||||
return StringUtils.join(names, ", ");
|
||||
}
|
||||
|
||||
public static String dateToString(Date date)
|
||||
{
|
||||
return new SimpleDateFormat(DATE_STORAGE_FORMAT, Locale.ENGLISH).format(date);
|
||||
@ -517,17 +412,6 @@ public class FUtil
|
||||
return match;
|
||||
}
|
||||
|
||||
public static String getFuzzyIp(String ip)
|
||||
{
|
||||
final String[] ipParts = ip.split("\\.");
|
||||
if (ipParts.length == 4)
|
||||
{
|
||||
return String.format("%s.%s.*.*", ipParts[0], ipParts[1]);
|
||||
}
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
public static ChatColor randomChatColor()
|
||||
{
|
||||
return CHAT_COLOR_POOL.get(RANDOM.nextInt(CHAT_COLOR_POOL.size()));
|
||||
@ -593,33 +477,12 @@ public class FUtil
|
||||
return date.getTime();
|
||||
}
|
||||
|
||||
public static String getNMSVersion()
|
||||
{
|
||||
String packageName = getServer().getClass().getPackage().getName();
|
||||
return packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||
}
|
||||
|
||||
public static int randomInteger(int min, int max)
|
||||
{
|
||||
int range = max - min + 1;
|
||||
return (int) (Math.random() * range) + min;
|
||||
}
|
||||
|
||||
public static String randomString(int length)
|
||||
{
|
||||
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz0123456789-_=+[]{};:,.<>~";
|
||||
StringBuilder randomString = new StringBuilder();
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
int selectedCharacter = randomInteger(1, characters.length()) - 1;
|
||||
|
||||
randomString.append(characters.charAt(selectedCharacter));
|
||||
}
|
||||
|
||||
return randomString.toString();
|
||||
|
||||
}
|
||||
|
||||
public static String randomAlphanumericString(int length)
|
||||
{
|
||||
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz0123456789";
|
||||
@ -650,76 +513,8 @@ public class FUtil
|
||||
|
||||
public static void fixCommandVoid(Player player)
|
||||
{
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
for (Entity passengerEntity : p.getPassengers())
|
||||
{
|
||||
if (passengerEntity == player)
|
||||
{
|
||||
p.removePassenger(passengerEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static char getRandomCharacter()
|
||||
{
|
||||
return CHARACTER_STRING.charAt(new SplittableRandom().nextInt(CHARACTER_STRING.length()));
|
||||
}
|
||||
|
||||
public static void give(Player player, Material material, String coloredName, int amount, String... lore)
|
||||
{
|
||||
ItemStack stack = new ItemStack(material, amount);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
assert meta != null;
|
||||
meta.setDisplayName(FUtil.colorize(coloredName));
|
||||
List<String> loreList = new ArrayList<>();
|
||||
for (String entry : lore)
|
||||
{
|
||||
loreList.add(FUtil.colorize(entry));
|
||||
}
|
||||
meta.setLore(loreList);
|
||||
stack.setItemMeta(meta);
|
||||
player.getInventory().setItem(player.getInventory().firstEmpty(), stack);
|
||||
}
|
||||
|
||||
public static Player getRandomPlayer()
|
||||
{
|
||||
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
|
||||
return players.get(randomInteger(0, players.size() - 1));
|
||||
}
|
||||
|
||||
// convert the current time
|
||||
public static int getTimeInTicks(int tz)
|
||||
{
|
||||
if (timeZoneOutOfBounds(tz))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
Calendar date = Calendar.getInstance(TimeZone.getTimeZone(TIMEZONE_LOOKUP.get(tz)));
|
||||
int res = 0;
|
||||
for (int i = 0; i < date.get(Calendar.HOUR_OF_DAY) - 6; i++) // oh yeah i don't know why this is 6 hours ahead
|
||||
{
|
||||
res += 1000;
|
||||
}
|
||||
int addExtra = 0; // we're adding extra to account for repeating decimals
|
||||
for (int i = 0; i < date.get(Calendar.MINUTE); i++)
|
||||
{
|
||||
res += 16;
|
||||
addExtra++;
|
||||
if (addExtra == 3)
|
||||
{
|
||||
res += 1;
|
||||
addExtra = 0;
|
||||
}
|
||||
}
|
||||
// this is the best it can be. trust me.
|
||||
return res;
|
||||
}
|
||||
|
||||
public static boolean timeZoneOutOfBounds(int tz)
|
||||
{
|
||||
return tz < -12 || tz > 12;
|
||||
Bukkit.getOnlinePlayers().forEach(pl ->
|
||||
pl.getPassengers().stream().filter(entity -> entity == player).forEach(player::removePassenger));
|
||||
}
|
||||
|
||||
public static String getIp(Player player)
|
||||
@ -805,17 +600,10 @@ public class FUtil
|
||||
}.runTaskLater(TotalFreedomMod.getPlugin(), delay);
|
||||
}
|
||||
|
||||
public static int getFakePlayerCount()
|
||||
public static long getFakePlayerCount()
|
||||
{
|
||||
int i = TotalFreedomMod.getPlugin().al.vanished.size();
|
||||
for (String name : TotalFreedomMod.getPlugin().al.vanished)
|
||||
{
|
||||
if (Bukkit.getPlayer(name) == null)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
}
|
||||
return getServer().getOnlinePlayers().size() - i;
|
||||
return getServer().getOnlinePlayers().stream().filter(player ->
|
||||
!TotalFreedomMod.getPlugin().al.isVanished(player.getUniqueId())).count();
|
||||
}
|
||||
|
||||
public static double getMeanAverageDouble(double[] doubles)
|
||||
|
@ -1,32 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.util;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
public class Response
|
||||
{
|
||||
private final int code;
|
||||
private final String message;
|
||||
|
||||
public Response(int code, String message)
|
||||
{
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public JSONObject getJSONMessage() throws ParseException
|
||||
{
|
||||
return (JSONObject)new JSONParser().parse(message);
|
||||
}
|
||||
|
||||
public int getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
}
|
@ -89,19 +89,6 @@ discord:
|
||||
# Invite link for your Discord server
|
||||
invite_link: 'https://discord.com/invite/PW4savJR9a'
|
||||
|
||||
# Pterodactyl
|
||||
ptero:
|
||||
# URL - do not leave a trailing forward slash
|
||||
url: ''
|
||||
# The default email domain used to set email addresses for new users - do not include the @
|
||||
default_email_domain: 'example.com'
|
||||
# Server UUID
|
||||
server_uuid: ''
|
||||
# Admin panel API key
|
||||
admin_key: ''
|
||||
# Server API key
|
||||
server_key: ''
|
||||
|
||||
# The shop
|
||||
shop:
|
||||
# Enable the shop
|
||||
|
Loading…
Reference in New Issue
Block a user