> entry : displayables.entrySet())
{
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java
index 177df52a..83b750c2 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java
@@ -20,7 +20,6 @@ import me.totalfreedom.totalfreedommod.httpd.module.Module_indefbans;
import me.totalfreedom.totalfreedommod.httpd.module.Module_index;
import me.totalfreedom.totalfreedommod.httpd.module.Module_list;
import me.totalfreedom.totalfreedommod.httpd.module.Module_logfile;
-import me.totalfreedom.totalfreedommod.httpd.module.Module_logs;
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
import me.totalfreedom.totalfreedommod.httpd.module.Module_punishments;
import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
@@ -96,7 +95,6 @@ public class HTTPDaemon extends FreedomService
module("help", Module_help.class, false);
module("list", Module_list.class, false);
module("logfile", Module_logfile.class, true);
- module("logs", Module_logs.class, true);
module("indefbans", Module_indefbans.class, true);
module("players", Module_players.class, false);
module("punishments", Module_punishments.class, true);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java
index fa2f5f6d..1b523721 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java
@@ -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("There are ").append(count < 0 ? 0 : count).append("/")
+ body.append("
There are ").append(FUtil.getFakePlayerCount()).append("/")
.append(Bukkit.getMaxPlayers()).append(" players online:
\r\n");
body.append("\r\n");
- for (Player player : onlinePlayers)
- {
- if (plugin.al.isVanished(player.getName()))
- {
- continue;
- }
- String tag = plugin.rm.getDisplay(player).getTag();
- body.append("- ").append(tag).append(player.getName()).append("
\r\n");
- }
+ onlinePlayers.stream().filter(player -> !plugin.al.isVanished(player.getUniqueId())).forEach(player ->
+ body.append("- ").append(plugin.rm.getDisplay(player).getTag()).append(player.getName()).append("
\r\n"));
body.append("
\r\n");
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logs.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logs.java
deleted file mode 100644
index d9925ca3..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logs.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package me.totalfreedom.totalfreedommod.httpd.module;
-
-import java.io.File;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
-import me.totalfreedom.totalfreedommod.util.FLog;
-
-public class Module_logs extends Module_file
-{
-
- public Module_logs(NanoHTTPD.HTTPSession session)
- {
- super(session);
- }
-
- @Override
- public NanoHTTPD.Response getResponse()
- {
- if (ConfigEntry.LOGS_SECRET.getString().equals(params.get("password")) && !ConfigEntry.LOGS_SECRET.getString().isEmpty())
- {
- FLog.info(session.getSocket().getInetAddress() + " is downloading latest.log.");
- return serveFile("latest.log", params, new File("./logs"));
- }
- else
- {
- return new NanoHTTPD.Response(NanoHTTPD.Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "Incorrect password.");
- }
- }
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java
index 059b4009..3633514d 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java
@@ -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> 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 admins = new ArrayList<>();
+ final List 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;
}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java
index ced5a67a..d1f74e10 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java
@@ -20,10 +20,8 @@ import java.util.UUID;
public class FPlayer
{
-
public static final long AUTO_PURGE_TICKS = 5L * 60L * 20L;
-
private final TotalFreedomMod plugin;
private final String name;
@@ -40,8 +38,6 @@ public class FPlayer
private int messageCount = 0;
private int totalBlockDestroy = 0;
private int totalBlockPlace = 0;
- private int freecamDestroyCount = 0;
- private int freecamPlaceCount = 0;
private boolean isOrbiting = false;
private double orbitStrength = 10.0;
private boolean mobThrowerEnabled = false;
@@ -52,11 +48,9 @@ public class FPlayer
private boolean mp44Firing = false;
private BukkitTask lockupScheduleTask = null;
private boolean lockedUp = false;
- private String lastMessage = "";
private boolean inAdminchat = false;
private boolean allCommandsBlocked = false;
private String lastCommand = "";
- private boolean cmdspyEnabled = false;
private String tag = null;
private int warningCount = 0;
@@ -82,11 +76,6 @@ public class FPlayer
this.ip = ip;
}
- public static long getAutoPurgeTicks()
- {
- return AUTO_PURGE_TICKS;
- }
-
public Player getPlayer()
{
if (player != null && !player.isOnline())
@@ -110,7 +99,6 @@ public class FPlayer
// Ensure admins don't have admin functionality when removed (FS-222)
public void removeAdminFunctionality()
{
- this.setCommandSpy(false);
this.setAdminChat(false);
this.setFuckoffRadius(0);
}
@@ -120,11 +108,6 @@ public class FPlayer
return isOrbiting;
}
- public void setOrbiting(boolean orbiting)
- {
- isOrbiting = orbiting;
- }
-
public void startOrbiting(double strength)
{
this.isOrbiting = true;
@@ -186,26 +169,6 @@ public class FPlayer
this.totalBlockPlace = 0;
}
- public int incrementAndGetFreecamDestroyCount()
- {
- return this.freecamDestroyCount++;
- }
-
- public void resetFreecamDestroyCount()
- {
- this.freecamDestroyCount = 0;
- }
-
- public int incrementAndGetFreecamPlaceCount()
- {
- return this.freecamPlaceCount++;
- }
-
- public void resetFreecamPlaceCount()
- {
- this.freecamPlaceCount = 0;
- }
-
public void enableMobThrower(EntityType mobThrowerCreature, double mobThrowerSpeed)
{
this.mobThrowerEnabled = true;
@@ -294,7 +257,6 @@ public class FPlayer
public void setMuted(boolean muted, int minutes)
{
FUtil.cancel(unmuteTask);
- plugin.mu.MUTED_PLAYERS.remove(getPlayer().getName());
unmuteTask = null;
if (!muted)
@@ -307,8 +269,6 @@ public class FPlayer
return;
}
- plugin.mu.MUTED_PLAYERS.add(getPlayer().getName());
-
// TODO: Simplify this into a Consumer lambda?
unmuteTask = new BukkitRunnable()
{
@@ -323,7 +283,6 @@ public class FPlayer
else
{
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Unmuting " + getName(), false);
- plugin.mu.MUTED_PLAYERS.remove(getName());
}
}
}.runTaskLater(plugin, minutes * (60L * 20L));
@@ -354,16 +313,6 @@ public class FPlayer
this.lockedUp = lockedUp;
}
- public String getLastMessage()
- {
- return lastMessage;
- }
-
- public void setLastMessage(String message)
- {
- this.lastMessage = message;
- }
-
public void setAdminChat(boolean inAdminchat)
{
this.inAdminchat = inAdminchat;
@@ -394,16 +343,6 @@ public class FPlayer
this.lastCommand = lastCommand;
}
- public void setCommandSpy(boolean enabled)
- {
- this.cmdspyEnabled = enabled;
- }
-
- public boolean cmdspyEnabled()
- {
- return cmdspyEnabled;
- }
-
public String getTag()
{
return this.tag;
@@ -421,16 +360,6 @@ public class FPlayer
}
}
- public int getWarningCount()
- {
- return this.warningCount;
- }
-
- public void setWarningCount(int warningCount)
- {
- this.warningCount = warningCount;
- }
-
public void incrementWarnings(boolean quiet)
{
this.warningCount++;
@@ -463,16 +392,6 @@ public class FPlayer
return ip;
}
- public BukkitTask getUnmuteTask()
- {
- return unmuteTask;
- }
-
- public void setUnmuteTask(BukkitTask unmuteTask)
- {
- this.unmuteTask = unmuteTask;
- }
-
public FreezeData getFreezeData()
{
return freezeData;
@@ -488,176 +407,11 @@ public class FPlayer
this.fuckoffRadius = fuckoffRadius;
}
- public int getMessageCount()
- {
- return messageCount;
- }
-
- public void setMessageCount(int messageCount)
- {
- this.messageCount = messageCount;
- }
-
- public int getTotalBlockDestroy()
- {
- return totalBlockDestroy;
- }
-
- public void setTotalBlockDestroy(int totalBlockDestroy)
- {
- this.totalBlockDestroy = totalBlockDestroy;
- }
-
- public int getTotalBlockPlace()
- {
- return totalBlockPlace;
- }
-
- public void setTotalBlockPlace(int totalBlockPlace)
- {
- this.totalBlockPlace = totalBlockPlace;
- }
-
- public int getFreecamDestroyCount()
- {
- return freecamDestroyCount;
- }
-
- public void setFreecamDestroyCount(int freecamDestroyCount)
- {
- this.freecamDestroyCount = freecamDestroyCount;
- }
-
- public int getFreecamPlaceCount()
- {
- return freecamPlaceCount;
- }
-
- public void setFreecamPlaceCount(int freecamPlaceCount)
- {
- this.freecamPlaceCount = freecamPlaceCount;
- }
-
public CageData getCageData()
{
return cageData;
}
- public double getOrbitStrength()
- {
- return orbitStrength;
- }
-
- public void setOrbitStrength(double orbitStrength)
- {
- this.orbitStrength = orbitStrength;
- }
-
- public boolean isMobThrowerEnabled()
- {
- return mobThrowerEnabled;
- }
-
- public void setMobThrowerEnabled(boolean mobThrowerEnabled)
- {
- this.mobThrowerEnabled = mobThrowerEnabled;
- }
-
- public EntityType getMobThrowerEntity()
- {
- return mobThrowerEntity;
- }
-
- public void setMobThrowerEntity(EntityType mobThrowerEntity)
- {
- this.mobThrowerEntity = mobThrowerEntity;
- }
-
- public double getMobThrowerSpeed()
- {
- return mobThrowerSpeed;
- }
-
- public void setMobThrowerSpeed(double mobThrowerSpeed)
- {
- this.mobThrowerSpeed = mobThrowerSpeed;
- }
-
- public List getMobThrowerQueue()
- {
- return mobThrowerQueue;
- }
-
- public BukkitTask getMp44ScheduleTask()
- {
- return mp44ScheduleTask;
- }
-
- public void setMp44ScheduleTask(BukkitTask mp44ScheduleTask)
- {
- this.mp44ScheduleTask = mp44ScheduleTask;
- }
-
- public boolean isMp44Armed()
- {
- return mp44Armed;
- }
-
- public void setMp44Armed(boolean mp44Armed)
- {
- this.mp44Armed = mp44Armed;
- }
-
- public boolean isMp44Firing()
- {
- return mp44Firing;
- }
-
- public void setMp44Firing(boolean mp44Firing)
- {
- this.mp44Firing = mp44Firing;
- }
-
- public BukkitTask getLockupScheduleTask()
- {
- return lockupScheduleTask;
- }
-
- public void setLockupScheduleTask(BukkitTask lockupScheduleTask)
- {
- this.lockupScheduleTask = lockupScheduleTask;
- }
-
- public boolean isInAdminchat()
- {
- return inAdminchat;
- }
-
- public void setInAdminchat(boolean inAdminchat)
- {
- this.inAdminchat = inAdminchat;
- }
-
- public boolean isAllCommandsBlocked()
- {
- return allCommandsBlocked;
- }
-
- public void setAllCommandsBlocked(boolean allCommandsBlocked)
- {
- this.allCommandsBlocked = allCommandsBlocked;
- }
-
- public boolean isCmdspyEnabled()
- {
- return cmdspyEnabled;
- }
-
- public void setCmdspyEnabled(boolean cmdspyEnabled)
- {
- this.cmdspyEnabled = cmdspyEnabled;
- }
-
public boolean isEditBlocked()
{
return editBlocked;
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java b/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java
index 680bc98d..bd15bf1e 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java
@@ -23,7 +23,7 @@ public class PlayerData
private Boolean masterBuilder = false;
- private String rideMode = "ask";
+ private RideMode rideMode = RideMode.ASK;
private int coins;
@@ -51,7 +51,7 @@ public class PlayerData
tag = resultSet.getString("tag");
discordID = resultSet.getString("discord_id");
masterBuilder = resultSet.getBoolean("master_builder");
- rideMode = resultSet.getString("ride_mode");
+ rideMode = RideMode.valueOf(resultSet.getString("ride_mode").toUpperCase());
coins = resultSet.getInt("coins");
items.clear();
items.addAll(FUtil.stringToList(resultSet.getString("items")));
@@ -82,7 +82,7 @@ public class PlayerData
"- Total Votes: " + totalVotes + "\n" +
"- Display Discord: " + displayDiscord + "\n" +
"- Tag: " + FUtil.colorize(tag) + ChatColor.GRAY + "\n" +
- "- Ride Mode: " + rideMode + "\n" +
+ "- Ride Mode: " + rideMode.name() + "\n" +
"- Login Message: " + loginMessage;
}
@@ -194,7 +194,7 @@ public class PlayerData
put("tag", tag);
put("discord_id", discordID);
put("master_builder", masterBuilder);
- put("ride_mode", rideMode);
+ put("ride_mode", rideMode.name());
put("coins", coins);
put("items", FUtil.listToString(items));
put("total_votes", totalVotes);
@@ -249,12 +249,12 @@ public class PlayerData
this.masterBuilder = masterBuilder;
}
- public String getRideMode()
+ public RideMode getRideMode()
{
return rideMode;
}
- public void setRideMode(String rideMode)
+ public void setRideMode(RideMode rideMode)
{
this.rideMode = rideMode;
}
@@ -308,4 +308,11 @@ public class PlayerData
{
this.inspect = inspect;
}
+
+ public enum RideMode
+ {
+ ASK,
+ NORMAL,
+ OFF
+ }
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java b/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java
index e1d07e1e..df39351c 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java
@@ -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
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/shop/Shop.java b/src/main/java/me/totalfreedom/totalfreedommod/shop/Shop.java
index 5eebbb2d..f12fb04d 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/shop/Shop.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/shop/Shop.java
@@ -21,6 +21,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@@ -411,6 +412,25 @@ public class Shop extends FreedomService
}
+ @EventHandler
+ public void onPlayerChat(AsyncPlayerChatEvent event)
+ {
+ String message = event.getMessage();
+ Player player = event.getPlayer();
+
+ if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean()
+ && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
+ {
+ event.setCancelled(true);
+ PlayerData data = plugin.pl.getData(player);
+ data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
+ plugin.pl.save(data);
+ plugin.sh.endReaction(player.getName());
+ player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD
+ + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
+ }
+ }
+
public ShopItem getShopItem(int slot)
{
for (ShopItem shopItem : ShopItem.values())
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java b/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java
index 336c7934..d435537e 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java
@@ -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)
@@ -249,7 +248,7 @@ public class SQLite extends FreedomService
statement.setString(4, player.getTag());
statement.setString(5, player.getDiscordID());
statement.setBoolean(6, player.isMasterBuilder());
- statement.setString(7, player.getRideMode());
+ statement.setString(7, player.getRideMode().name());
statement.setInt(8, player.getCoins());
statement.setString(9, FUtil.listToString(player.getItems()));
statement.setInt(10, player.getTotalVotes());
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FSync.java b/src/main/java/me/totalfreedom/totalfreedommod/util/FSync.java
index 191e0feb..15fde2b9 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/util/FSync.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/util/FSync.java
@@ -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();
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java
index 3fc1bb7a..512c69ea 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java
@@ -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 TIMEZONE_LOOKUP = new HashMap<>();
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
+ private static final List 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 getPlayerList()
{
- List 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 list)
@@ -233,58 +201,6 @@ public class FUtil
}
}
- public static List getAllMaterialNames()
- {
- List names = new ArrayList<>();
- for (Material material : Material.values())
- {
- names.add(material.name());
- }
- return names;
- }
-
- public static Response sendRequest(String endpoint, String method, List 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 regxList = new ArrayList()
- {{
- 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 players)
- {
- List 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 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 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)
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/Response.java b/src/main/java/me/totalfreedom/totalfreedommod/util/Response.java
deleted file mode 100644
index 867b3f7f..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/util/Response.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 2aa7a488..dea8a9f3 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -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
@@ -606,160 +593,10 @@ first_join_info:
- "&eThe server's name doesn't mean we have no rules. Do &6/rules &efor a list of them."
- "&aNeed help getting started? Do &2/help &aor a list of commands!"
-# Famous players - cannot be banned by username
-famous_players:
- - honeydew
- - xephos
- - captainsparklez
- - truemu
- - kiershar
- - fvdisco
- - sethbling
- - gamechap
- - bertiechap
- - vechs
- - antvenom
- - chimneyswift
- - deadmau5
- - etho
- - ethoslab
- - skydoesminecraft
- - skythekidrs
- - tobyturner
- - xxslyfoxhoundxx
- - paulsoaresjr
- - sips_
- - deadlox
- - xxslyxx
- - jeromeasf
- - grum
- - evilseph
- - cavemanfilms
- - herobrine
- - whiteboy7thst
- - stampylonghead
- - stampylongnose
- - dantdm
- - gizzy14gazza
- - furiousdestroyer
- - pewdie
- - thecampingrusher
- - logdotzip
- - ssundee
- - mrcrainer
- - achileis
- - donibobes
- - itsjerry
- - itsharry
- - bebopvox
- - clankstar
- - jollyajax
- - b0xx3r
- - vareide
- - defek7
- - strutt20
- - appleg
- - sterling_
- - hypixel
- - huskymudkipz
- - setosorcerer
- - slamacow
- - mrcrayfish
- - zexyzek
- - synhd
- - syndicate
- - bajancanadian
- - actennisac
- - bodil40
- - trumu
- - huskymudkipz
- - dantdm
- - skeppy
- - badboyhalo
- # Mojang staff below this line
- - aeplh
- - amir343
- - angryem
- - ashrafi
- - binni
- - blurpi
- - bopogamel
- - boq
- - c418
- - carlmanneh
- - carnalizer
- - carramel
- - darngeek
- - dinnerbone
- - eldrone
- - elevenen
- - el_hefe_
- - engst
- - excitedze
- - frukthamster
- - fry_
- - grumm
- - hampus
- - helloiammarsh
- - hey
- - hoodad
- - ianna_na_na
- - jeb_
- - jonkagstrom
- - kappe
- - klumpig
- - krisjelbring
- - ladyagnes
- - lisa
- - mahuldur
- - mansolson
- - marc
- - marc_irl
- - masseffect
- - midnightenforcer
- - minecraftchick
- - modhelius
- - moesh
- - mojangjonas
- - mojangsta
- - mollstam
- - neonmaster
- - olle
- - olofcarlson
- - phreakholm
- - poipoichen
- - pretto
- - profmobius
- - razzleberryfox
- - searge
- - searge_dp
- - shoghicp
- - slicedlime
- - sockerpappan
- - themogminer
- - theopard
- - theputtman
- - tom__m
- - vaktis
- - volgar
- - vubui
- - xlson
- - xsson
- - yoloswag4lyfe
- - zeeraw
- - _alcatras
- - _tommo_
- - ____fox____
-
# Pet Protect - Prevent tamed pets from being killed.
petprotect:
enabled: true
-# Logviewer
-logs:
- url: ''
- secret: ''
-
# Mojang service checker
service_checker_url: http://status.mojang.com/check
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 308beb03..24ea4a9e 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -10,8 +10,12 @@ softdepend:
- WorldEdit
- WorldGuard
- WorldGuardExtraFlags
- - TFGuilds
- JDA
- Votifier
authors: [Madgeek1450, Prozza]
-api-version: "1.17"
\ No newline at end of file
+api-version: "1.17"
+libraries:
+ - org.apache.commons:commons-lang3:3.12.0
+ - commons-io:commons-io:2.11.0
+ - org.jetbrains:annotations:23.0.0
+ - org.javassist:javassist:3.29.1-GA
\ No newline at end of file