mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +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
4602e2246b
commit
cec506f148
@ -3,6 +3,8 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
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.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -35,10 +37,10 @@ public class AntiNuke extends FreedomService
|
|||||||
|
|
||||||
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
server.broadcast(Component.text(player.getName()).append(Component.text(" is breaking blocks too fast!"))
|
||||||
//plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
.color(NamedTextColor.RED));
|
||||||
player.kickPlayer(ChatColor.RED + "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
player.kick(Component.text("You are breaking blocks too fast. Nukers are not permitted on this server.",
|
||||||
|
NamedTextColor.RED));
|
||||||
fPlayer.resetBlockDestroyCount();
|
fPlayer.resetBlockDestroyCount();
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -58,10 +60,9 @@ public class AntiNuke extends FreedomService
|
|||||||
|
|
||||||
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
server.broadcast(Component.text(player.getName()).append(Component.text(" is placing blocks too fast!"))
|
||||||
//plugin.ae.autoEject(player, "You are placing blocks too fast.");
|
.color(NamedTextColor.RED));
|
||||||
player.kickPlayer(ChatColor.RED + "You are placing blocks too fast.");
|
player.kick(Component.text("You are placing blocks too fast.", NamedTextColor.RED));
|
||||||
|
|
||||||
fPlayer.resetBlockPlaceCount();
|
fPlayer.resetBlockPlaceCount();
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -10,52 +10,41 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class AntiSpam extends FreedomService
|
public class AntiSpam extends FreedomService
|
||||||
{
|
{
|
||||||
|
private ScheduledThreadPoolExecutor cycle;
|
||||||
public static final int MSG_PER_CYCLE = 8;
|
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<>();
|
private Map<Player, Integer> muteCounts = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
new BukkitRunnable()
|
cycle = new ScheduledThreadPoolExecutor(1);
|
||||||
{
|
cycle.scheduleAtFixedRate(this::cycle, 0, 1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
cycle();
|
|
||||||
}
|
|
||||||
}.runTaskTimer(plugin, TICKS_PER_CYCLE, TICKS_PER_CYCLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
FUtil.cancel(cycleTask);
|
cycle.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cycle()
|
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
|
// TODO: Move each to their own section
|
||||||
playerdata.resetMsgCount();
|
fPlayer.resetMsgCount();
|
||||||
playerdata.resetBlockDestroyCount();
|
fPlayer.resetBlockDestroyCount();
|
||||||
playerdata.resetBlockPlaceCount();
|
fPlayer.resetBlockPlaceCount();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
@ -91,7 +91,7 @@ public class AutoEject extends FreedomService
|
|||||||
}
|
}
|
||||||
case STRIKE_THREE:
|
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.");
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
@ -21,15 +21,9 @@ public class CommandSpy extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)
|
||||||
{
|
&& plugin.al.getAdmin(player).getCommandSpy() && player != event.getPlayer()).forEach(player ->
|
||||||
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
|
player.sendMessage(Component.text(event.getPlayer().getName()).append(Component.text(": "))
|
||||||
{
|
.append(Component.text(event.getMessage()))));
|
||||||
if (player != event.getPlayer())
|
|
||||||
{
|
|
||||||
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + 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 WorldRestrictions wr;
|
||||||
public EntityWiper ew;
|
public EntityWiper ew;
|
||||||
public VanishHandler vh;
|
public VanishHandler vh;
|
||||||
public Pterodactyl ptero;
|
|
||||||
//
|
//
|
||||||
// Bridges
|
// Bridges
|
||||||
public BukkitTelnetBridge btb;
|
public BukkitTelnetBridge btb;
|
||||||
@ -312,7 +311,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
gr = new GameRuleHandler();
|
gr = new GameRuleHandler();
|
||||||
ew = new EntityWiper();
|
ew = new EntityWiper();
|
||||||
vh = new VanishHandler();
|
vh = new VanishHandler();
|
||||||
ptero = new Pterodactyl();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initAdminUtils()
|
private void initAdminUtils()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
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.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -13,7 +15,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
public class VanishHandler extends FreedomService
|
public class VanishHandler extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
@ -29,40 +30,32 @@ public class VanishHandler extends FreedomService
|
|||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
server.getOnlinePlayers().stream().filter(pl -> !plugin.al.isAdmin(player)
|
||||||
{
|
&& plugin.al.isVanished(pl.getUniqueId())).forEach(pl -> player.hidePlayer(plugin, pl));
|
||||||
if (!plugin.al.isAdmin(player) && plugin.al.isVanished(p.getName()))
|
|
||||||
{
|
|
||||||
player.hidePlayer(plugin, p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
server.getOnlinePlayers().stream().filter(pl -> !plugin.al.isAdmin(pl)
|
||||||
{
|
&& plugin.al.isVanished(player.getUniqueId())).forEach(pl -> pl.hidePlayer(plugin, player));
|
||||||
if (!plugin.al.isAdmin(p) && plugin.al.isVanished(player.getName()))
|
|
||||||
{
|
|
||||||
p.hidePlayer(plugin, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.al.isVanished(player.getName()))
|
if (plugin.al.isVanished(player.getUniqueId()))
|
||||||
{
|
{
|
||||||
plugin.esb.setVanished(player.getName(), true);
|
plugin.esb.setVanished(player.getName(), true);
|
||||||
FLog.info(player.getName() + " joined while still vanished.");
|
FLog.info(player.getName() + " joined while still vanished.");
|
||||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
||||||
event.setJoinMessage(null);
|
event.joinMessage(null);
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
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();
|
this.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.GOLD + "You are hidden from other players."));
|
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 0L, 4L);
|
}.runTaskTimer(plugin, 0L, 4L);
|
||||||
}
|
}
|
||||||
@ -73,9 +66,9 @@ public class VanishHandler extends FreedomService
|
|||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
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.");
|
FLog.info(player.getName() + " left while still vanished.");
|
||||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has left silently.");
|
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has left silently.");
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ public class Admin
|
|||||||
private Boolean commandSpy = false;
|
private Boolean commandSpy = false;
|
||||||
private Boolean potionSpy = false;
|
private Boolean potionSpy = false;
|
||||||
private String acFormat = null;
|
private String acFormat = null;
|
||||||
private String pteroID = null;
|
|
||||||
|
|
||||||
public Admin(Player player)
|
public Admin(Player player)
|
||||||
{
|
{
|
||||||
@ -46,7 +45,6 @@ public class Admin
|
|||||||
this.commandSpy = resultSet.getBoolean("command_spy");
|
this.commandSpy = resultSet.getBoolean("command_spy");
|
||||||
this.potionSpy = resultSet.getBoolean("potion_spy");
|
this.potionSpy = resultSet.getBoolean("potion_spy");
|
||||||
this.acFormat = resultSet.getString("ac_format");
|
this.acFormat = resultSet.getString("ac_format");
|
||||||
this.pteroID = resultSet.getString("ptero_id");
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
@ -65,8 +63,7 @@ public class Admin
|
|||||||
.append("- Rank: ").append(rank.getName()).append("\n")
|
.append("- Rank: ").append(rank.getName()).append("\n")
|
||||||
.append("- Is Active: ").append(active).append("\n")
|
.append("- Is Active: ").append(active).append("\n")
|
||||||
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
||||||
.append("- Admin Chat Format: ").append(acFormat).append("\n")
|
.append("- Admin Chat Format: ").append(acFormat).append("\n");
|
||||||
.append("- Pterodactyl ID: ").append(pteroID).append("\n");
|
|
||||||
|
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
@ -83,7 +80,6 @@ public class Admin
|
|||||||
put("command_spy", commandSpy);
|
put("command_spy", commandSpy);
|
||||||
put("potion_spy", potionSpy);
|
put("potion_spy", potionSpy);
|
||||||
put("ac_format", acFormat);
|
put("ac_format", acFormat);
|
||||||
put("ptero_id", pteroID);
|
|
||||||
}};
|
}};
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -247,14 +243,4 @@ public class Admin
|
|||||||
{
|
{
|
||||||
this.acFormat = acFormat;
|
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 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
|
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
||||||
// Only active admins below
|
// Only active admins below
|
||||||
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
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> nameTable = Maps.newHashMap();
|
||||||
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
||||||
|
|
||||||
public static List<String> getVanished()
|
|
||||||
{
|
|
||||||
return vanished;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
@ -99,16 +94,6 @@ public class AdminList extends FreedomService
|
|||||||
return isAdmin(sender);
|
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)
|
public boolean isAdmin(CommandSender sender)
|
||||||
{
|
{
|
||||||
if (!(sender instanceof Player))
|
if (!(sender instanceof Player))
|
||||||
@ -321,9 +306,9 @@ public class AdminList extends FreedomService
|
|||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVanished(String player)
|
public boolean isVanished(UUID uuid)
|
||||||
{
|
{
|
||||||
return vanished.contains(player);
|
return vanished.contains(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Admin> getAllAdmins()
|
public Set<Admin> getAllAdmins()
|
||||||
|
@ -121,17 +121,6 @@ public class Ban
|
|||||||
reason);
|
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()
|
public static SimpleDateFormat getDateFormat()
|
||||||
{
|
{
|
||||||
return DATE_FORMAT;
|
return DATE_FORMAT;
|
||||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -33,13 +34,8 @@ public class Command_adminmode extends FreedomCommand
|
|||||||
{
|
{
|
||||||
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
||||||
FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true);
|
FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
server.getOnlinePlayers().stream().filter(player -> !isAdmin(player)).forEach(player ->
|
||||||
{
|
player.kick(Component.text("The server is now closed to non-admins.")));
|
||||||
if (!isAdmin(player))
|
|
||||||
{
|
|
||||||
player.kickPlayer("Server is now closed to non-admins.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Lists all possible attributes.", usage = "/<command>")
|
@CommandParameters(description = "Lists all possible attributes.", usage = "/<command>")
|
||||||
public class Command_attributelist extends FreedomCommand
|
public class Command_attributelist extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
StringBuilder list = new StringBuilder("All possible attributes: ");
|
msg("All possible attributes: " + FUtil.listToString(Arrays.stream(Attribute.values()).map(Enum::name).toList()));
|
||||||
|
|
||||||
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());
|
|
||||||
return true;
|
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]")
|
@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
|
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)
|
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)
|
if (args.length == 0)
|
||||||
@ -33,11 +33,8 @@ public class Command_cage extends FreedomCommand
|
|||||||
if (args[0].equalsIgnoreCase("purge"))
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
server.getOnlinePlayers().stream().map(player -> plugin.pl.getPlayer(player)).forEach(fPlayer ->
|
||||||
{
|
fPlayer.getCageData().setCaged(false));
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
|
||||||
fPlayer.getCageData().setCaged(false);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +59,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
final String s = args[1];
|
final String s = args[1];
|
||||||
switch (s)
|
switch (s)
|
||||||
{
|
{
|
||||||
case "head":
|
case "head" ->
|
||||||
{
|
{
|
||||||
outerMaterial = Material.PLAYER_HEAD;
|
outerMaterial = Material.PLAYER_HEAD;
|
||||||
if (args.length >= 3)
|
if (args.length >= 3)
|
||||||
@ -73,9 +70,8 @@ public class Command_cage extends FreedomCommand
|
|||||||
{
|
{
|
||||||
outerMaterial = Material.SKELETON_SKULL;
|
outerMaterial = Material.SKELETON_SKULL;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "block":
|
case "block" ->
|
||||||
{
|
{
|
||||||
if (args.length >= 3)
|
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())
|
if (Material.matchMaterial(args[2]) != null && Material.matchMaterial(args[2]).isBlock())
|
||||||
{
|
{
|
||||||
outerMaterial = Material.matchMaterial(args[2]);
|
outerMaterial = Material.matchMaterial(args[2]);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -98,7 +93,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default ->
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -156,7 +151,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args[1].equals("block"))
|
if (args[1].equals("block"))
|
||||||
{
|
{
|
||||||
return FUtil.getAllMaterialNames();
|
return Arrays.stream(Material.values()).map(Enum::name).toList();
|
||||||
}
|
}
|
||||||
else if (args[1].equals("head"))
|
else if (args[1].equals("head"))
|
||||||
{
|
{
|
||||||
|
@ -10,20 +10,17 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Clears the chat.", usage = "/<command>", aliases = "cc")
|
@CommandParameters(description = "Clears the chat.", usage = "/<command>", aliases = "cc")
|
||||||
public class Command_cleanchat extends FreedomCommand
|
public class Command_cleanchat extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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);
|
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
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.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -15,20 +18,19 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
@CommandParameters(description = "Get a stick of happiness.", usage = "/<command>")
|
@CommandParameters(description = "Get a stick of happiness.", usage = "/<command>")
|
||||||
public class Command_debugstick extends FreedomCommand
|
public class Command_debugstick extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
ItemStack itemStack = new ItemStack(Material.DEBUG_STICK);
|
ItemStack itemStack = new ItemStack(Material.DEBUG_STICK);
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
assert itemMeta != null;
|
assert itemMeta != null;
|
||||||
itemMeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD.toString() + "Stick of Happiness");
|
itemMeta.displayName(Component.text("Stick of Happiness", NamedTextColor.GOLD).decorate(TextDecoration.BOLD));
|
||||||
List<String> lore = Arrays.asList(
|
itemMeta.lore(Arrays.asList(
|
||||||
ChatColor.RED + "This is the most powerful stick in the game.",
|
Component.text("This is the most powerful stick in the game.", NamedTextColor.RED),
|
||||||
ChatColor.DARK_BLUE + "You can left click to select what you want to change.",
|
Component.text("You can left click to select what you want to change.", NamedTextColor.DARK_BLUE),
|
||||||
ChatColor.DARK_GREEN + "And then you can right click to change it!",
|
Component.text("And then you can right click to change it!", NamedTextColor.DARK_GREEN),
|
||||||
ChatColor.DARK_PURPLE + "Isn't technology amazing?");
|
Component.text("Isn't technology amazing?", NamedTextColor.DARK_PURPLE)
|
||||||
itemMeta.setLore(lore);
|
));
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
playerSender.getInventory().addItem(itemStack);
|
playerSender.getInventory().addItem(itemStack);
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,12 +21,7 @@ public class Command_denick extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Removing all nicknames", false);
|
FUtil.adminAction(sender.getName(), "Removing all nicknames", false);
|
||||||
|
server.getOnlinePlayers().forEach(player -> plugin.esb.setNickname(player.getName(), null));
|
||||||
for (Player player : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
plugin.esb.setNickname(player.getName(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class Command_deop extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if ((player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
if ((player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
||||||
|| player.getName().contains(targetName) || player.getDisplayName().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());
|
matchedPlayerNames.add(player.getName());
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
|
@ -52,7 +52,6 @@ public class Command_doom extends FreedomCommand
|
|||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
plugin.al.save(admin);
|
plugin.al.save(admin);
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
plugin.ptero.updateAccountStatus(admin);
|
|
||||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||||
{
|
{
|
||||||
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||||
|
@ -5,6 +5,8 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.ChatColor;
|
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>>")
|
@CommandParameters(description = "Enchant items.", usage = "/<command> <list | addall | reset | add <name> [level] | remove <name>>")
|
||||||
public class Command_enchant extends FreedomCommand
|
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")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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"))
|
else if (args[0].equalsIgnoreCase("addall"))
|
||||||
{
|
{
|
||||||
for (Enchantment ench : Enchantment.values())
|
Arrays.stream(Enchantment.values()).filter(enchantment -> enchantment.canEnchantItem(item)).forEach(ench ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (ench.canEnchantItem(item))
|
item.addEnchantment(ench, ench.getMaxLevel());
|
||||||
{
|
|
||||||
item.addEnchantment(ench, ench.getMaxLevel());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
msg("Could not add enchantment: " + ench.getName());
|
msg("Could not add enchantment: " + ench.getName());
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
msg("Added all possible enchantments for this item.");
|
msg("Added all possible enchantments for this item.");
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("reset"))
|
else if (args[0].equalsIgnoreCase("reset"))
|
||||||
{
|
{
|
||||||
for (Enchantment ench : item.getEnchantments().keySet())
|
item.getEnchantments().keySet().forEach(item::removeEnchantment);
|
||||||
{
|
|
||||||
item.removeEnchantment(ench);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Removed all enchantments.");
|
msg("Removed all enchantments.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -258,7 +241,7 @@ public class Command_enchant extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!unsafe)
|
if (!unsafe)
|
||||||
{
|
{
|
||||||
return stringNumberRange(1, enchantment.getMaxLevel());
|
return IntStream.rangeClosed(1, enchantment.getMaxLevel()).mapToObj(String::valueOf).toList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ public class Command_invis extends FreedomCommand
|
|||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
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());
|
players.add(player.getName());
|
||||||
if (clear && !plugin.al.isAdmin(player))
|
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.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
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.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
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")
|
@CommandParameters(description = "Kick all non-admins on server.", usage = "/<command>", aliases = "kickall")
|
||||||
public class Command_kicknoob extends FreedomCommand
|
public class Command_kicknoob extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Disconnecting all non-admins", true);
|
FUtil.adminAction(sender.getName(), "Disconnecting all non-admins", true);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
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)));
|
||||||
if (!plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
player.kickPlayer(ChatColor.RED + "All non-admins were kicked by " + sender.getName() + ".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -65,9 +65,9 @@ public class Command_list extends FreedomCommand
|
|||||||
+ " out of a maximum " + ChatColor.RED + server.getMaxPlayers() + ChatColor.BLUE + " players online.";
|
+ " out of a maximum " + ChatColor.RED + server.getMaxPlayers() + ChatColor.BLUE + " players online.";
|
||||||
|
|
||||||
players = server.getOnlinePlayers().stream().filter(pl ->
|
players = server.getOnlinePlayers().stream().filter(pl ->
|
||||||
(listFilter == ListFilter.ADMINS && plugin.al.isAdmin(pl) && !plugin.al.isVanished(pl.getName()))
|
(listFilter == ListFilter.ADMINS && plugin.al.isAdmin(pl) && !plugin.al.isVanished(pl.getUniqueId()))
|
||||||
|| (listFilter == ListFilter.VANISHED_ADMINS && plugin.al.isVanished(pl.getName()))
|
|| (listFilter == ListFilter.VANISHED_ADMINS && plugin.al.isVanished(pl.getUniqueId()))
|
||||||
|| (listFilter == ListFilter.PLAYERS && !plugin.al.isVanished(pl.getName()))).map(player ->
|
|| (listFilter == ListFilter.PLAYERS && !plugin.al.isVanished(pl.getUniqueId()))).map(player ->
|
||||||
plugin.rm.getDisplay(player).getColoredTag() + player.getName()).toList();
|
plugin.rm.getDisplay(player).getColoredTag() + player.getName()).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
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")
|
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command> [name]", aliases = "mp")
|
||||||
public class Command_mobpurge extends FreedomCommand
|
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
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
return getAllMobNames();
|
return Groups.MOB_TYPES.stream().map(Enum::name).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -74,11 +74,11 @@ public class Command_nickfilter extends FreedomCommand
|
|||||||
|
|
||||||
player = getPlayerByDisplayName(displayName);
|
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);
|
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);
|
msg("Can't find player by nickname: " + displayName);
|
||||||
return true;
|
return true;
|
||||||
|
@ -35,7 +35,7 @@ public class Command_op extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if ((player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
if ((player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
||||||
|| player.getName().contains(targetName) || player.getDisplayName().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());
|
matchedPlayerNames.add(player.getName());
|
||||||
player.setOp(true);
|
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]);
|
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);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
|
@ -112,8 +112,6 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.ptero.updateAccountStatus(admin);
|
|
||||||
|
|
||||||
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -210,7 +208,6 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
Discord.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
Discord.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugin.ptero.updateAccountStatus(admin);
|
|
||||||
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
if (fPlayer.getFreezeData().isFrozen())
|
if (fPlayer.getFreezeData().isFrozen())
|
||||||
@ -265,8 +262,6 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
Discord.syncRoles(admin, plugin.pl.getData(adminName).getDiscordID());
|
Discord.syncRoles(admin, plugin.pl.getData(adminName).getDiscordID());
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.ptero.updateAccountStatus(admin);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
|
||||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.generator.WorldInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
@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
|
sender.sendMessage(Component.translatable("commands.seed.success",
|
||||||
if (senderIsConsole)
|
Component.text("[", NamedTextColor.WHITE).append(Component.text(world.getSeed(), NamedTextColor.GREEN)
|
||||||
{
|
.clickEvent(ClickEvent.copyToClipboard(String.valueOf(world.getSeed())))
|
||||||
msg("Seed: [" + ChatColor.GREEN + world.getSeed() + ChatColor.WHITE + "]", ChatColor.WHITE);
|
.hoverEvent(HoverEvent.showText(Component.translatable("chat.copy"))))
|
||||||
}
|
.append(Component.text("]"))));
|
||||||
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);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,13 +58,7 @@ public class Command_seed extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
// Returns a list of worlds on the server and returns it
|
return server.getWorlds().stream().map(WorldInfo::getName).toList();
|
||||||
List<String> worlds = new ArrayList<>();
|
|
||||||
for (World world : server.getWorlds())
|
|
||||||
{
|
|
||||||
worlds.add(world.getName());
|
|
||||||
}
|
|
||||||
return worlds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -24,7 +24,7 @@ public class Command_spawnmob extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args.length > 0 && args[0].equalsIgnoreCase("list"))
|
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();
|
String typeList = StringUtils.join(types, ", ").toLowerCase();
|
||||||
msg(typeList);
|
msg(typeList);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
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>")
|
@CommandParameters(description = "Shows Minecraft server info, such as authentication status.", usage = "/<command>")
|
||||||
public class Command_status extends FreedomCommand
|
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
|
@Override
|
||||||
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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())
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
@ -21,17 +19,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
usage = "/<command> <mobtype [speed] | off | list>")
|
usage = "/<command> <mobtype [speed] | off | list>")
|
||||||
public class Command_tossmob extends FreedomCommand
|
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
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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"))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import me.totalfreedom.totalfreedommod.rank.Displayable;
|
|||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
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")
|
@CommandParameters(description = "Vanish/unvanish yourself.", usage = "/<command> [-s[ilent]]", aliases = "v")
|
||||||
public class Command_vanish extends FreedomCommand
|
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)
|
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);
|
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)
|
if (silent)
|
||||||
{
|
{
|
||||||
@ -44,7 +44,8 @@ public class Command_vanish extends FreedomCommand
|
|||||||
{
|
{
|
||||||
msg("You have unvanished.", ChatColor.GOLD);
|
msg("You have unvanished.", ChatColor.GOLD);
|
||||||
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
|
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);
|
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);
|
plugin.esb.setVanished(playerSender.getName(), false);
|
||||||
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
||||||
AdminList.vanished.remove(playerSender.getName());
|
AdminList.vanished.remove(playerSender.getUniqueId());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -76,9 +77,13 @@ public class Command_vanish extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
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);
|
}.runTaskTimer(plugin, 0L, 4L);
|
||||||
@ -90,23 +95,19 @@ public class Command_vanish extends FreedomCommand
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("You have vanished.", ChatColor.GOLD);
|
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);
|
plugin.dc.messageChatChannel("**" + playerSender.getName() + " left the server" + "**", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLog.info(playerSender.getName() + " is now vanished.");
|
FLog.info(playerSender.getName() + " is now vanished.");
|
||||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins.");
|
plugin.al.messageAllAdmins(ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins.");
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
||||||
{
|
player.hidePlayer(plugin,playerSender));
|
||||||
if (!plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
player.hidePlayer(plugin, playerSender);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.esb.setVanished(playerSender.getName(), true);
|
plugin.esb.setVanished(playerSender.getName(), true);
|
||||||
AdminList.vanished.add(playerSender.getName());
|
AdminList.vanished.add(playerSender.getUniqueId());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -31,7 +30,8 @@ public class Command_whitelist extends FreedomCommand
|
|||||||
msg("There are no whitelisted players.");
|
msg("There are no whitelisted players.");
|
||||||
return true;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,23 +187,13 @@ public class Command_whitelist extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else if (args[0].equals("remove"))
|
else if (args[0].equals("remove"))
|
||||||
{
|
{
|
||||||
return getWhitelistedNames();
|
return server.getWhitelistedPlayers().stream().map(OfflinePlayer::getName).filter(Objects::nonNull).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
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()
|
public int purge()
|
||||||
{
|
{
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
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")
|
@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 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
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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())
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
@ -80,7 +70,7 @@ public class Command_whohas extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
return getAllMaterials();
|
return Arrays.stream(Material.values()).map(Enum::name).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 2 && plugin.al.isAdmin(sender))
|
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)
|
protected Player getPlayer(String name, Boolean nullVanished)
|
||||||
{
|
{
|
||||||
Player player = Bukkit.getPlayer(name);
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -91,12 +91,6 @@ public enum ConfigEntry
|
|||||||
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
|
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
|
||||||
DISCORD_INVITE_LINK(String.class, "discord.invite_link"),
|
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_ENABLED(Boolean.class, "shop.enabled"),
|
||||||
SHOP_TITLE(String.class, "shop.title"),
|
SHOP_TITLE(String.class, "shop.title"),
|
||||||
SHOP_PREFIX(String.class, "shop.prefix"),
|
SHOP_PREFIX(String.class, "shop.prefix"),
|
||||||
|
@ -231,32 +231,6 @@ public class Discord extends FreedomService
|
|||||||
messageChatChannel("**Message queue cleared**", true);
|
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)
|
public String generateCode(int size)
|
||||||
{
|
{
|
||||||
return RandomStringUtils.randomNumeric(size);
|
return RandomStringUtils.randomNumeric(size);
|
||||||
@ -289,7 +263,7 @@ public class Discord extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
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);
|
messageChatChannel("**" + deformat(event.getPlayer().getName()) + " joined the server" + "**", true);
|
||||||
}
|
}
|
||||||
@ -298,7 +272,7 @@ public class Discord extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerLeave(PlayerQuitEvent event)
|
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);
|
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<>();
|
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()))
|
final Displayable displayable = rankManager.getDisplay(player);
|
||||||
{
|
final String name = Discord.deformat(player.getName());
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Displayable displayable = rankManager.getDisplay(onlinePlayer);
|
|
||||||
|
|
||||||
final String name = Discord.deformat(onlinePlayer.getName());
|
|
||||||
|
|
||||||
if (displayables.containsKey(displayable))
|
if (displayables.containsKey(displayable))
|
||||||
{
|
{
|
||||||
displayables.get(displayable).add(name);
|
displayables.get(displayable).add(name);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
displayables.put(displayable, new ArrayList<>(List.of(name)));
|
displayables.put(displayable, new ArrayList<>(List.of(name)));
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
for (Map.Entry<Displayable, List<String>> entry : displayables.entrySet())
|
for (Map.Entry<Displayable, List<String>> entry : displayables.entrySet())
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ public class Module_list extends HTTPDModule
|
|||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isVanished(player.getName()))
|
if (plugin.al.isVanished(player.getUniqueId()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ public class Module_list extends HTTPDModule
|
|||||||
operators.add(player.getName());
|
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);
|
Admin admin = plugin.al.getAdmin(player);
|
||||||
switch (admin.getRank())
|
switch (admin.getRank())
|
||||||
@ -112,21 +112,13 @@ public class Module_list extends HTTPDModule
|
|||||||
|
|
||||||
final Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
final Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||||
|
|
||||||
int count = onlinePlayers.size() - AdminList.vanished.size();
|
body.append("<p>There are ").append(FUtil.getFakePlayerCount()).append("/")
|
||||||
body.append("<p>There are ").append(count < 0 ? 0 : count).append("/")
|
|
||||||
.append(Bukkit.getMaxPlayers()).append(" players online:</p>\r\n");
|
.append(Bukkit.getMaxPlayers()).append(" players online:</p>\r\n");
|
||||||
|
|
||||||
body.append("<ul>\r\n");
|
body.append("<ul>\r\n");
|
||||||
|
|
||||||
for (Player player : onlinePlayers)
|
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"));
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
body.append("</ul>\r\n");
|
body.append("</ul>\r\n");
|
||||||
|
|
||||||
|
@ -1,16 +1,21 @@
|
|||||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
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.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Module_players extends HTTPDModule
|
public class Module_players extends HTTPDModule
|
||||||
{
|
{
|
||||||
|
private static final Gson gson = new Gson();
|
||||||
|
|
||||||
public Module_players(NanoHTTPD.HTTPSession session)
|
public Module_players(NanoHTTPD.HTTPSession session)
|
||||||
{
|
{
|
||||||
@ -18,72 +23,37 @@ public class Module_players extends HTTPDModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public NanoHTTPD.Response getResponse()
|
public NanoHTTPD.Response getResponse()
|
||||||
{
|
{
|
||||||
final JSONObject responseObject = new JSONObject();
|
final Map<String, List<String>> responseMap = new HashMap<>();
|
||||||
|
|
||||||
final JSONArray players = new JSONArray();
|
final List<String> admins = new ArrayList<>();
|
||||||
final JSONArray onlineadmins = new JSONArray(); // updated, never queried.
|
final List<String> senioradmins = new ArrayList<>();
|
||||||
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();
|
|
||||||
|
|
||||||
// All online players
|
plugin.al.getActiveAdmins().stream().filter(admin -> admin.getName() != null).forEach(admin ->
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
{
|
||||||
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())
|
switch (admin.getRank())
|
||||||
{
|
{
|
||||||
case ADMIN:
|
case ADMIN -> admins.add(admin.getName());
|
||||||
|
case SENIOR_ADMIN -> senioradmins.add(admin.getName());
|
||||||
|
default ->
|
||||||
{
|
{
|
||||||
admins.add(username);
|
// Do nothing, keeps Codacy quiet
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SENIOR_ADMIN:
|
|
||||||
{
|
|
||||||
senioradmins.add(username);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
// Do nothing
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
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
|
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON,
|
||||||
developers.addAll(FUtil.DEVELOPER_NAMES);
|
gson.toJson(responseMap));
|
||||||
|
|
||||||
// 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());
|
|
||||||
response.addHeader("Access-Control-Allow-Origin", "*");
|
response.addHeader("Access-Control-Allow-Origin", "*");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -193,12 +193,10 @@ public class RankManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast login message
|
// 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
|
// Set display
|
||||||
|
@ -84,7 +84,7 @@ public class SQLite extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
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)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
@ -219,7 +219,7 @@ public class SQLite extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
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(1, admin.getUuid().toString());
|
||||||
statement.setString(2, FUtil.listToString(admin.getIps()));
|
statement.setString(2, FUtil.listToString(admin.getIps()));
|
||||||
statement.setString(3, admin.getRank().toString());
|
statement.setString(3, admin.getRank().toString());
|
||||||
@ -228,7 +228,6 @@ public class SQLite extends FreedomService
|
|||||||
statement.setBoolean(6, admin.getCommandSpy());
|
statement.setBoolean(6, admin.getCommandSpy());
|
||||||
statement.setBoolean(7, admin.getPotionSpy());
|
statement.setBoolean(7, admin.getPotionSpy());
|
||||||
statement.setString(8, admin.getAcFormat());
|
statement.setString(8, admin.getAcFormat());
|
||||||
statement.setString(9, admin.getPteroID());
|
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
|
@ -69,21 +69,6 @@ public class FSync
|
|||||||
}.runTask(plugin);
|
}.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)
|
public static void bcastMsg(final String message, final ChatColor color)
|
||||||
{
|
{
|
||||||
final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
||||||
|
@ -4,22 +4,17 @@ import com.earth2me.essentials.utils.DateUtil;
|
|||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.commons.lang.WordUtils;
|
import org.apache.commons.lang.WordUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
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.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@ -91,34 +86,12 @@ public class FUtil
|
|||||||
ChatColor.DARK_PURPLE,
|
ChatColor.DARK_PURPLE,
|
||||||
ChatColor.LIGHT_PURPLE);
|
ChatColor.LIGHT_PURPLE);
|
||||||
private static final SplittableRandom RANDOM = new SplittableRandom();
|
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";
|
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
|
static
|
||||||
{
|
{
|
||||||
for (ChatColor chatColor : CHAT_COLOR_POOL)
|
CHAT_COLOR_POOL.forEach(color -> CHAT_COLOR_NAMES.put(color.name().toLowerCase().replace("_", ""), color));
|
||||||
{
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void cancel(BukkitTask task)
|
public static void cancel(BukkitTask task)
|
||||||
@ -139,7 +112,9 @@ public class FUtil
|
|||||||
|
|
||||||
public static boolean isExecutive(String name)
|
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)
|
public static boolean isDeveloper(Player player)
|
||||||
@ -171,15 +146,8 @@ public class FUtil
|
|||||||
|
|
||||||
public static List<String> getPlayerList()
|
public static List<String> getPlayerList()
|
||||||
{
|
{
|
||||||
List<String> names = new ArrayList<>();
|
return getServer().getOnlinePlayers().stream().filter(player ->
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
!TotalFreedomMod.getPlugin().al.isVanished(player.getUniqueId())).map(HumanEntity::getName).toList();
|
||||||
{
|
|
||||||
if (!TotalFreedomMod.getPlugin().al.isVanished(player.getName()))
|
|
||||||
{
|
|
||||||
names.add(player.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String listToString(List<String> list)
|
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)
|
public static void bcastMsg(String message, ChatColor color)
|
||||||
{
|
{
|
||||||
bcastMsg(message, color, true);
|
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)
|
private static long a(String parse)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@ -447,16 +352,6 @@ public class FUtil
|
|||||||
return FUtil.getUnixTime(Date.from(instant));
|
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)
|
public static String dateToString(Date date)
|
||||||
{
|
{
|
||||||
return new SimpleDateFormat(DATE_STORAGE_FORMAT, Locale.ENGLISH).format(date);
|
return new SimpleDateFormat(DATE_STORAGE_FORMAT, Locale.ENGLISH).format(date);
|
||||||
@ -517,17 +412,6 @@ public class FUtil
|
|||||||
return match;
|
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()
|
public static ChatColor randomChatColor()
|
||||||
{
|
{
|
||||||
return CHAT_COLOR_POOL.get(RANDOM.nextInt(CHAT_COLOR_POOL.size()));
|
return CHAT_COLOR_POOL.get(RANDOM.nextInt(CHAT_COLOR_POOL.size()));
|
||||||
@ -593,33 +477,12 @@ public class FUtil
|
|||||||
return date.getTime();
|
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)
|
public static int randomInteger(int min, int max)
|
||||||
{
|
{
|
||||||
int range = max - min + 1;
|
int range = max - min + 1;
|
||||||
return (int) (Math.random() * range) + min;
|
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)
|
public static String randomAlphanumericString(int length)
|
||||||
{
|
{
|
||||||
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz0123456789";
|
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz0123456789";
|
||||||
@ -650,76 +513,8 @@ public class FUtil
|
|||||||
|
|
||||||
public static void fixCommandVoid(Player player)
|
public static void fixCommandVoid(Player player)
|
||||||
{
|
{
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
Bukkit.getOnlinePlayers().forEach(pl ->
|
||||||
{
|
pl.getPassengers().stream().filter(entity -> entity == player).forEach(player::removePassenger));
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getIp(Player player)
|
public static String getIp(Player player)
|
||||||
@ -805,17 +600,10 @@ public class FUtil
|
|||||||
}.runTaskLater(TotalFreedomMod.getPlugin(), delay);
|
}.runTaskLater(TotalFreedomMod.getPlugin(), delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getFakePlayerCount()
|
public static long getFakePlayerCount()
|
||||||
{
|
{
|
||||||
int i = TotalFreedomMod.getPlugin().al.vanished.size();
|
return getServer().getOnlinePlayers().stream().filter(player ->
|
||||||
for (String name : TotalFreedomMod.getPlugin().al.vanished)
|
!TotalFreedomMod.getPlugin().al.isVanished(player.getUniqueId())).count();
|
||||||
{
|
|
||||||
if (Bukkit.getPlayer(name) == null)
|
|
||||||
{
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getServer().getOnlinePlayers().size() - i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getMeanAverageDouble(double[] doubles)
|
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 for your Discord server
|
||||||
invite_link: 'https://discord.com/invite/PW4savJR9a'
|
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
|
# The shop
|
||||||
shop:
|
shop:
|
||||||
# Enable the shop
|
# Enable the shop
|
||||||
|
Loading…
Reference in New Issue
Block a user