mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Merge pull request #285 from AtlasMediaGroup/fs24
Resolves many issues in FS-24 and cleans up code
This commit is contained in:
commit
67b0656e61
4
pom.xml
4
pom.xml
@ -410,14 +410,10 @@
|
|||||||
</relocations>
|
</relocations>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
<include>commons-io:commons-io</include>
|
|
||||||
<include>org.apache.commons:commons-lang3</include>
|
|
||||||
<include>org.reflections:reflections</include>
|
<include>org.reflections:reflections</include>
|
||||||
<include>org.javassist:javassist</include>
|
|
||||||
<include>io.papermc:paperlib</include>
|
<include>io.papermc:paperlib</include>
|
||||||
<include>org.bstats:bstats-bukkit</include>
|
<include>org.bstats:bstats-bukkit</include>
|
||||||
<include>org.bstats:bstats-base</include>
|
<include>org.bstats:bstats-base</include>
|
||||||
<include>org.jetbrains:annotations</include>
|
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -2,8 +2,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 net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.ChatColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -35,10 +35,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 +58,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);
|
||||||
|
@ -2,60 +2,48 @@ 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.FSync;
|
import net.kyori.adventure.text.Component;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
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.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)
|
||||||
@ -81,17 +69,16 @@ public class AntiSpam extends FreedomService
|
|||||||
int time = count * minutes;
|
int time = count * minutes;
|
||||||
playerdata.setMuted(true, time);
|
playerdata.setMuted(true, time);
|
||||||
|
|
||||||
FSync.bcastMsg(String.format("%s has automatically been muted for %d minutes for spamming chat.",
|
server.broadcast(Component.text(player.getName()).append(Component.text(" has been automatically muted for "))
|
||||||
player.getName(),
|
.append(Component.text(time)).append(Component.text(" minutes for spamming chat."))
|
||||||
time),
|
.color(NamedTextColor.RED));
|
||||||
ChatColor.RED);
|
|
||||||
|
|
||||||
playerdata.resetMsgCount();
|
playerdata.resetMsgCount();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
|
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(player, "Please refrain from spamming chat.", ChatColor.GRAY);
|
player.sendMessage(Component.text("Please refrain from spamming chat.", NamedTextColor.GRAY));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +94,7 @@ public class AntiSpam extends FreedomService
|
|||||||
|
|
||||||
if (fPlayer.allCommandsBlocked())
|
if (fPlayer.allCommandsBlocked())
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
player.sendMessage(Component.text("Your commands have been blocked by an admin.", NamedTextColor.RED));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -119,7 +106,9 @@ public class AntiSpam extends FreedomService
|
|||||||
|
|
||||||
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
server.broadcast(Component.text(player.getName())
|
||||||
|
.append(Component.text(" was automatically kicked for spamming commands."))
|
||||||
|
.color(NamedTextColor.RED));
|
||||||
plugin.ae.autoEject(player, "Kicked for spamming commands.");
|
plugin.ae.autoEject(player, "Kicked for spamming commands.");
|
||||||
|
|
||||||
fPlayer.resetMsgCount();
|
fPlayer.resetMsgCount();
|
||||||
|
@ -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.");
|
||||||
|
|
||||||
|
@ -4,13 +4,11 @@ import com.google.common.base.Strings;
|
|||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
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.player.PlayerData;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.SoundCategory;
|
import org.bukkit.SoundCategory;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -54,17 +52,6 @@ public class ChatManager extends FreedomService
|
|||||||
message = FUtil.colorize(message);
|
message = FUtil.colorize(message);
|
||||||
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
||||||
|
|
||||||
if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
PlayerData data = plugin.pl.getData(player);
|
|
||||||
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
|
||||||
plugin.pl.save(data);
|
|
||||||
plugin.sh.endReaction(player.getName());
|
|
||||||
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -96,10 +83,11 @@ public class ChatManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for 4chan trigger
|
// Check for 4chan trigger
|
||||||
boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
|
|
||||||
boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
|
|
||||||
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
|
boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
|
||||||
|
boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
|
||||||
|
|
||||||
if (green)
|
if (green)
|
||||||
{
|
{
|
||||||
message = ChatColor.GREEN + message;
|
message = ChatColor.GREEN + message;
|
||||||
@ -123,23 +111,27 @@ public class ChatManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for mentions
|
// Check for mentions
|
||||||
boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player);
|
String stripped = ChatColor.stripColor(message).toLowerCase();
|
||||||
for (Player p : server.getOnlinePlayers())
|
|
||||||
|
/* There is an issue would have allowed muted players to ping players. The issue is caused by the order in which
|
||||||
|
* these event handlers are registered when the plugin starts up. Muter is registered after the ChatManager,
|
||||||
|
* which results in latter being called first (before the former can cancel it). EventPriority does not seem to
|
||||||
|
* make a difference. As a short-term solution I've added this mute check alongside the usual isCancelled check
|
||||||
|
* so that the issue is mitigated, but a long-term solution should be to change the order in which things like
|
||||||
|
* ChatManager and Muter are registered. */
|
||||||
|
if (!event.isCancelled() && !plugin.pl.getPlayer(player).isMuted())
|
||||||
{
|
{
|
||||||
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
|
server.getOnlinePlayers().forEach(pl ->
|
||||||
{
|
{
|
||||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, SoundCategory.MASTER, 1337F, 0.9F);
|
if (stripped.contains("@" + pl.getName()) || (plugin.al.isAdmin(player) && stripped.contains("@everyone")))
|
||||||
}
|
{
|
||||||
|
pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, SoundCategory.MASTER, 1337F, 0.9F);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set format
|
// Set format
|
||||||
event.setFormat(format);
|
event.setFormat(format);
|
||||||
|
|
||||||
// Send to discord
|
|
||||||
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted())
|
|
||||||
{
|
|
||||||
plugin.dc.messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getColor(Displayable display)
|
public ChatColor getColor(Displayable display)
|
||||||
@ -162,7 +154,8 @@ public class ChatManager extends FreedomService
|
|||||||
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
|
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getAdmin(player);
|
Admin admin = plugin.al.getAdmin(player);
|
||||||
if (!Strings.isNullOrEmpty(admin.getAcFormat())) {
|
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
|
||||||
|
{
|
||||||
String format = admin.getAcFormat();
|
String format = admin.getAcFormat();
|
||||||
ChatColor color = getColor(display);
|
ChatColor color = getColor(display);
|
||||||
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
|
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
|
||||||
|
@ -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,201 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.NoSuchProviderException;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
public class LogViewer extends FreedomService
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onStart()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
|
||||||
{
|
|
||||||
updateLogsRegistration(sender, target.getName(), mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateLogsRegistration(final CommandSender sender, final String targetName, final LogsRegistrationMode mode)
|
|
||||||
{
|
|
||||||
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
|
||||||
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
|
||||||
|
|
||||||
if (logsRegisterUrl == null || logsRegisterPassword == null || logsRegisterUrl.isEmpty() || logsRegisterPassword.isEmpty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (sender != null)
|
|
||||||
{
|
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
|
||||||
}
|
|
||||||
|
|
||||||
final String key = SecureCodeGenerator.generateCode(20);
|
|
||||||
|
|
||||||
final URL urlAdd = new URLBuilder(logsRegisterUrl)
|
|
||||||
.addQueryParameter("mode", mode.name())
|
|
||||||
.addQueryParameter("password", logsRegisterPassword)
|
|
||||||
.addQueryParameter("name", targetName)
|
|
||||||
.addQueryParameter("key", key)
|
|
||||||
.getURL();
|
|
||||||
|
|
||||||
final HttpURLConnection connection = (HttpURLConnection)urlAdd.openConnection();
|
|
||||||
connection.setConnectTimeout(1000 * 5);
|
|
||||||
connection.setReadTimeout(1000 * 5);
|
|
||||||
connection.setUseCaches(false);
|
|
||||||
connection.setRequestMethod("HEAD");
|
|
||||||
|
|
||||||
final int responseCode = connection.getResponseCode();
|
|
||||||
|
|
||||||
if (sender != null)
|
|
||||||
{
|
|
||||||
if (!plugin.isEnabled())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if (responseCode == 200)
|
|
||||||
{
|
|
||||||
if (mode == LogsRegistrationMode.ADD)
|
|
||||||
{
|
|
||||||
String link = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final URL urlVerify = new URLBuilder(logsRegisterUrl)
|
|
||||||
.addQueryParameter("mode", LogsRegistrationMode.VERIFY.name())
|
|
||||||
.addQueryParameter("name", targetName)
|
|
||||||
.addQueryParameter("key", key)
|
|
||||||
.getURL();
|
|
||||||
link = urlVerify.toString();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GREEN + "Open this link to verify your logviewer registration:\n" + ChatColor.DARK_GREEN + link);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage(ChatColor.GREEN + "Logviewer access revoked successfully.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage(ChatColor.RED + "Error contacting logs registration server.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTask(plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskAsynchronously(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum LogsRegistrationMode
|
|
||||||
{
|
|
||||||
|
|
||||||
ADD, DELETE, VERIFY
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class URLBuilder
|
|
||||||
{
|
|
||||||
|
|
||||||
private final String requestPath;
|
|
||||||
private final Map<String, String> queryStringMap = new HashMap<>();
|
|
||||||
|
|
||||||
private URLBuilder(String requestPath)
|
|
||||||
{
|
|
||||||
this.requestPath = requestPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public URLBuilder addQueryParameter(String key, String value)
|
|
||||||
{
|
|
||||||
queryStringMap.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public URL getURL() throws MalformedURLException
|
|
||||||
{
|
|
||||||
List<String> pairs = new ArrayList<>();
|
|
||||||
for (Map.Entry<String, String> pair : queryStringMap.entrySet())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"));
|
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SecureCodeGenerator
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final String CHARACTER_SET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
||||||
|
|
||||||
public static String generateCode(final int length)
|
|
||||||
{
|
|
||||||
SecureRandom random;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
random = SecureRandom.getInstance("SHA1PRNG", "SUN");
|
|
||||||
}
|
|
||||||
catch (NoSuchAlgorithmException | NoSuchProviderException ex)
|
|
||||||
{
|
|
||||||
random = new SecureRandom();
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
|
||||||
for (int i = 0; i < length; i++)
|
|
||||||
{
|
|
||||||
sb.append(CHARACTER_SET.charAt(random.nextInt(CHARACTER_SET.length())));
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,11 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
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.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -13,13 +13,9 @@ 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.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class Muter extends FreedomService
|
public class Muter extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public final List<String> MUTED_PLAYERS = new ArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
@ -45,11 +41,10 @@ public class Muter extends FreedomService
|
|||||||
if (plugin.al.isAdminSync(player))
|
if (plugin.al.isAdminSync(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
MUTED_PLAYERS.remove(player.getName());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted.");
|
player.sendMessage(Component.text("You are muted.", NamedTextColor.RED));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +82,7 @@ public class Muter extends FreedomService
|
|||||||
|
|
||||||
if (ConfigEntry.MUTED_BLOCKED_COMMANDS.getStringList().contains(cmdName))
|
if (ConfigEntry.MUTED_BLOCKED_COMMANDS.getStringList().contains(cmdName))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
player.sendMessage(Component.text("That command is blocked while you are muted.", NamedTextColor.RED));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -98,16 +93,4 @@ public class Muter extends FreedomService
|
|||||||
FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), message), true);
|
FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), message), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
|
||||||
|
|
||||||
if (MUTED_PLAYERS.contains(player.getName()))
|
|
||||||
{
|
|
||||||
playerdata.setMuted(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -72,7 +72,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public CommandLoader cl;
|
public CommandLoader cl;
|
||||||
// Services
|
// Services
|
||||||
public WorldManager wm;
|
public WorldManager wm;
|
||||||
public LogViewer lv;
|
|
||||||
public AdminList al;
|
public AdminList al;
|
||||||
public ActivityLog acl;
|
public ActivityLog acl;
|
||||||
public RankManager rm;
|
public RankManager rm;
|
||||||
@ -119,7 +118,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;
|
||||||
@ -284,7 +282,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
{
|
{
|
||||||
// Start services
|
// Start services
|
||||||
wm = new WorldManager();
|
wm = new WorldManager();
|
||||||
lv = new LogViewer();
|
|
||||||
sql = new SQLite();
|
sql = new SQLite();
|
||||||
al = new AdminList();
|
al = new AdminList();
|
||||||
acl = new ActivityLog();
|
acl = new ActivityLog();
|
||||||
@ -312,7 +309,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.");
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
@ -25,7 +24,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 +44,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 +62,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 +79,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;
|
||||||
}
|
}
|
||||||
@ -188,8 +183,6 @@ public class Admin
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.lv.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,14 +240,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;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.totalfreedom.totalfreedommod.banning;
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@ -14,7 +13,6 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
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 org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -30,8 +28,6 @@ public class BanManager extends FreedomService
|
|||||||
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
||||||
private final Map<UUID, Ban> uuidBans = Maps.newHashMap();
|
private final Map<UUID, Ban> uuidBans = Maps.newHashMap();
|
||||||
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||||
private final List<String> unbannableUsernames = Lists.newArrayList();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,11 +66,6 @@ public class BanManager extends FreedomService
|
|||||||
updateViews();
|
updateViews();
|
||||||
|
|
||||||
FLog.info("Loaded " + ipBans.size() + " IP bans and " + nameBans.size() + " username bans.");
|
FLog.info("Loaded " + ipBans.size() + " IP bans and " + nameBans.size() + " username bans.");
|
||||||
|
|
||||||
// Load unbannable usernames
|
|
||||||
unbannableUsernames.clear();
|
|
||||||
unbannableUsernames.addAll(ConfigEntry.FAMOUS_PLAYERS.getStringList());
|
|
||||||
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Banner;
|
|
||||||
import org.bukkit.block.Skull;
|
import org.bukkit.block.Skull;
|
||||||
import org.bukkit.block.banner.Pattern;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -187,17 +183,5 @@ public class BlockBlocker extends FreedomService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
|
|
||||||
{
|
|
||||||
Banner banner = (Banner)event.getBlockPlaced().getState();
|
|
||||||
List<Pattern> patterns = banner.getPatterns();
|
|
||||||
|
|
||||||
if (patterns.size() >= 2)
|
|
||||||
{
|
|
||||||
banner.setPatterns(patterns.subList(0, 2));
|
|
||||||
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -163,12 +163,9 @@ public class EventBlocker extends FreedomService
|
|||||||
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
|
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
|
||||||
{
|
{
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity instanceof Tameable)
|
if (entity instanceof Tameable tameable && tameable.isTamed())
|
||||||
{
|
{
|
||||||
if (((Tameable) entity).isTamed())
|
event.setCancelled(true);
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,12 +203,9 @@ public class CommandBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate sub command
|
// Validate sub command
|
||||||
if (entry.getSubCommand() != null)
|
if (entry.getSubCommand() != null && (subCommand == null || !subCommand.startsWith(entry.getSubCommand())))
|
||||||
{
|
{
|
||||||
if (subCommand == null || !subCommand.startsWith(entry.getSubCommand()))
|
return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getRank().hasPermission(sender))
|
if (entry.getRank().hasPermission(sender))
|
||||||
|
@ -90,7 +90,10 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
|
|
||||||
playerTags.put("tfm.playerdata.getTag", plugin.pl.getPlayer(player).getTag());
|
playerTags.put("tfm.playerdata.getTag", plugin.pl.getPlayer(player).getTag());
|
||||||
|
|
||||||
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
if (server.getPluginManager().isPluginEnabled("Essentials"))
|
||||||
|
{
|
||||||
|
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,12 +104,9 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Plugin bukkitTelnet = server.getPluginManager().getPlugin("BukkitTelnet");
|
final Plugin bukkitTelnet = server.getPluginManager().getPlugin("BukkitTelnet");
|
||||||
if (bukkitTelnet != null)
|
if (bukkitTelnet instanceof BukkitTelnet)
|
||||||
{
|
{
|
||||||
if (bukkitTelnet instanceof BukkitTelnet)
|
bukkitTelnetPlugin = (BukkitTelnet)bukkitTelnet;
|
||||||
{
|
|
||||||
bukkitTelnetPlugin = (BukkitTelnet)bukkitTelnet;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1,81 +1,58 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.*;
|
||||||
import java.sql.*;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
|
||||||
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.coreprotect.CoreProtect;
|
import net.coreprotect.CoreProtect;
|
||||||
import net.coreprotect.CoreProtectAPI;
|
import net.coreprotect.CoreProtectAPI;
|
||||||
import org.bukkit.Bukkit;
|
import net.coreprotect.utility.Util;
|
||||||
import org.bukkit.ChatColor;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.World;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
public class CoreProtectBridge extends FreedomService
|
public class CoreProtectBridge extends FreedomService
|
||||||
{
|
{
|
||||||
public static Map<Player, FUtil.PaginationList<String>> HISTORY_MAP = new HashMap<>();
|
//-- Block Inspector --//
|
||||||
private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block");
|
private static final Component name = Component.text("Block Inspector").color(TextColor.color(0x30ade4));
|
||||||
|
private static final Component header = Component.text("---- ").append(name)
|
||||||
|
.append(Component.text(" ---- ")).colorIfAbsent(NamedTextColor.WHITE);
|
||||||
|
private static final Component prefix = name.append(Component.text(" - ").color(NamedTextColor.WHITE))
|
||||||
|
.colorIfAbsent(NamedTextColor.WHITE);
|
||||||
|
//--
|
||||||
|
private final HashMap<UUID, Long> cooldownMap = new HashMap<>();
|
||||||
|
private HashMap<UUID, FUtil.PaginationList<CoreProtectAPI.ParseResult>> historyMap;
|
||||||
|
|
||||||
private final HashMap<String, Long> cooldown = new HashMap<>();
|
//---------------------//
|
||||||
private CoreProtectAPI coreProtectAPI = null;
|
private CoreProtectAPI coreProtectAPI = null;
|
||||||
private BukkitTask wiper;
|
|
||||||
|
|
||||||
public static Long getSecondsLeft(long prevTime, int timeAdd)
|
public static Long getSecondsLeft(long prevTime, int timeAdd)
|
||||||
{
|
{
|
||||||
return prevTime / 1000L + timeAdd - System.currentTimeMillis() / 1000L;
|
return prevTime / 1000L + timeAdd - System.currentTimeMillis() / 1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unix timestamp converter taken from Functions class in CoreProtect, not my code
|
|
||||||
public static String getTimeAgo(int logTime, int currentTime)
|
|
||||||
{
|
|
||||||
StringBuilder message = new StringBuilder();
|
|
||||||
double timeSince = (double)currentTime - ((double)logTime + 0.0D);
|
|
||||||
timeSince /= 60.0D;
|
|
||||||
if (timeSince < 60.0D)
|
|
||||||
{
|
|
||||||
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/m ago");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.length() == 0)
|
|
||||||
{
|
|
||||||
timeSince /= 60.0D;
|
|
||||||
if (timeSince < 24.0D)
|
|
||||||
{
|
|
||||||
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/h ago");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.length() == 0)
|
|
||||||
{
|
|
||||||
timeSince /= 24.0D;
|
|
||||||
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/d ago");
|
|
||||||
}
|
|
||||||
|
|
||||||
return message.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
|
if (isEnabled())
|
||||||
|
{
|
||||||
|
historyMap = new HashMap<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -88,7 +65,7 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
CoreProtect coreProtect = null;
|
CoreProtect coreProtect = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Plugin coreProtectPlugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
|
final Plugin coreProtectPlugin = server.getPluginManager().getPlugin("CoreProtect");
|
||||||
assert coreProtectPlugin != null;
|
assert coreProtectPlugin != null;
|
||||||
if (coreProtectPlugin instanceof CoreProtect)
|
if (coreProtectPlugin instanceof CoreProtect)
|
||||||
{
|
{
|
||||||
@ -129,6 +106,11 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
|
|
||||||
public boolean isEnabled()
|
public boolean isEnabled()
|
||||||
{
|
{
|
||||||
|
if (!server.getPluginManager().isPluginEnabled("CoreProtect"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final CoreProtect coreProtect = getCoreProtect();
|
final CoreProtect coreProtect = getCoreProtect();
|
||||||
|
|
||||||
return coreProtect != null && coreProtect.isEnabled();
|
return coreProtect != null && coreProtect.isEnabled();
|
||||||
@ -137,13 +119,13 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
// Rollback the specified player's edits that were in the last 24 hours.
|
// Rollback the specified player's edits that were in the last 24 hours.
|
||||||
public void rollback(final String name)
|
public void rollback(final String name)
|
||||||
{
|
{
|
||||||
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
|
||||||
|
|
||||||
if (!isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -157,13 +139,13 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
// Reverts a rollback for the specified player's edits that were in the last 24 hours.
|
// Reverts a rollback for the specified player's edits that were in the last 24 hours.
|
||||||
public void restore(final String name)
|
public void restore(final String name)
|
||||||
{
|
{
|
||||||
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
|
||||||
|
|
||||||
if (!isEnabled())
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -174,264 +156,182 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
}.runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getDatabase()
|
public boolean hasHistory(Player player)
|
||||||
{
|
{
|
||||||
if (!isEnabled())
|
return historyMap.containsKey(player.getUniqueId());
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (new File(getCoreProtect().getDataFolder(), "database.db"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDBSize()
|
public FUtil.PaginationList<CoreProtectAPI.ParseResult> getHistoryForPlayer(Player player)
|
||||||
{
|
{
|
||||||
double bytes = getDatabase().length();
|
return historyMap.get(player.getUniqueId());
|
||||||
double kilobytes = (bytes / 1024);
|
|
||||||
double megabytes = (kilobytes / 1024);
|
|
||||||
return (megabytes / 1024);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearDatabase(World world)
|
public void showPageToPlayer(Player player, FUtil.PaginationList<CoreProtectAPI.ParseResult> results, int pageNum)
|
||||||
{
|
{
|
||||||
clearDatabase(world, false);
|
if (player == null || !player.isOnline())
|
||||||
}
|
|
||||||
|
|
||||||
// Wipes DB for the specified world
|
|
||||||
public void clearDatabase(World world, Boolean shutdown)
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.COREPROTECT_MYSQL_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final CoreProtect coreProtect = getCoreProtect();
|
|
||||||
|
|
||||||
if (coreProtect == null)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* As CoreProtect doesn't have an API method for deleting all of the data for a specific world
|
List<CoreProtectAPI.ParseResult> page = results.getPage(pageNum);
|
||||||
we have to do this manually via SQL */
|
|
||||||
Connection connection;
|
if (page == null || page.isEmpty())
|
||||||
try
|
|
||||||
{
|
{
|
||||||
String host = ConfigEntry.COREPROTECT_MYSQL_HOST.getString();
|
player.sendMessage(prefix.append(Component.text("No results were found.", NamedTextColor.WHITE)));
|
||||||
String port = ConfigEntry.COREPROTECT_MYSQL_PORT.getString();
|
|
||||||
String username = ConfigEntry.COREPROTECT_MYSQL_USERNAME.getString();
|
|
||||||
String password = ConfigEntry.COREPROTECT_MYSQL_PASSWORD.getString();
|
|
||||||
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
|
||||||
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
|
||||||
connection = DriverManager.getConnection("jdbc:sql://" + url);
|
|
||||||
final PreparedStatement statement = connection.prepareStatement("SELECT id FROM co_world WHERE world = ?");
|
|
||||||
statement.setQueryTimeout(30);
|
|
||||||
|
|
||||||
// Obtain world ID from CoreProtect database
|
|
||||||
statement.setString(1, world.getName());
|
|
||||||
ResultSet resultSet = statement.executeQuery();
|
|
||||||
String worldID = null;
|
|
||||||
while (resultSet.next())
|
|
||||||
{
|
|
||||||
worldID = String.valueOf(resultSet.getInt("id"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure the world ID is not null
|
|
||||||
|
|
||||||
if (worldID == null)
|
|
||||||
{
|
|
||||||
FLog.warning("Failed to obtain the world ID for the " + world.getName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate through each table and delete their data if the world ID matches
|
|
||||||
for (String table : tables)
|
|
||||||
{
|
|
||||||
final PreparedStatement statement1 = connection.prepareStatement("DELETE FROM ? WHERE wid = ?");
|
|
||||||
statement1.setString(1, table);
|
|
||||||
statement1.setString(2, worldID);
|
|
||||||
statement1.executeQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.close();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
else
|
||||||
{
|
{
|
||||||
FLog.warning("Failed to delete the CoreProtect data for the " + world.getName());
|
// This shouldn't change at all in any of the other entries, so this should be safe
|
||||||
|
Component location = Component.text(String.format("(%s, %s, %s)", results.get(0).getX(),
|
||||||
|
results.get(0).getY(), results.get(0).getZ()));
|
||||||
|
final long time = System.currentTimeMillis() / 1000;
|
||||||
|
|
||||||
|
player.sendMessage(header.append(location.color(NamedTextColor.GRAY).decorate(TextDecoration.ITALIC)));
|
||||||
|
page.forEach(entry ->
|
||||||
|
{
|
||||||
|
TextComponent.Builder line = Component.text();
|
||||||
|
|
||||||
|
// Time
|
||||||
|
line.append(Component.text(Util.getTimeSince(entry.getTime(), time, false))
|
||||||
|
.color(NamedTextColor.GRAY));
|
||||||
|
|
||||||
|
// Action
|
||||||
|
Component action = Component.text(" interacted with ");
|
||||||
|
Component symbol = Component.text(" - ", NamedTextColor.WHITE);
|
||||||
|
switch (entry.getActionId())
|
||||||
|
{
|
||||||
|
case 0 ->
|
||||||
|
{
|
||||||
|
action = Component.text(" broke ");
|
||||||
|
symbol = Component.text(" - ", NamedTextColor.RED);
|
||||||
|
}
|
||||||
|
case 1 ->
|
||||||
|
{
|
||||||
|
action = Component.text(" placed ");
|
||||||
|
symbol = Component.text(" + ", NamedTextColor.GREEN);
|
||||||
|
}
|
||||||
|
case 2 -> action = Component.text(" clicked ");
|
||||||
|
default ->
|
||||||
|
{
|
||||||
|
// Do nothing (shuts Codacy up)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Symbol, player, action, block
|
||||||
|
line.append(symbol).append(Component.text(entry.getPlayer()).color(TextColor.color(0x30ade4)))
|
||||||
|
.append(action.color(NamedTextColor.WHITE)).append(
|
||||||
|
Component.text(entry.getBlockData().getMaterial().name().toLowerCase())
|
||||||
|
.color(TextColor.color(0x30ade4)));
|
||||||
|
|
||||||
|
// Rolled back?
|
||||||
|
if (entry.isRolledBack())
|
||||||
|
{
|
||||||
|
line.decorate(TextDecoration.STRIKETHROUGH);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(line.append(Component.text(".", NamedTextColor.WHITE)).build());
|
||||||
|
});
|
||||||
|
|
||||||
|
if (results.getPageCount() > 1)
|
||||||
|
{
|
||||||
|
player.sendMessage(Component.text("-----", NamedTextColor.WHITE));
|
||||||
|
|
||||||
|
// Page indicator
|
||||||
|
TextComponent.Builder indicator = Component.text();
|
||||||
|
|
||||||
|
// <-
|
||||||
|
if (pageNum > 1)
|
||||||
|
{
|
||||||
|
indicator.append(Component.text("◀ ", NamedTextColor.WHITE).clickEvent(
|
||||||
|
ClickEvent.runCommand("/ins history " + (pageNum - 1))));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Page <current>/<total>
|
||||||
|
indicator.append(Component.text("Page ", TextColor.color(0x30ade4)).append(Component.text(pageNum + "/"
|
||||||
|
+ results.getPageCount(), NamedTextColor.WHITE)));
|
||||||
|
|
||||||
|
// ->
|
||||||
|
if (pageNum < results.getPageCount())
|
||||||
|
{
|
||||||
|
indicator.append(Component.text(" ▶", NamedTextColor.WHITE).clickEvent(
|
||||||
|
ClickEvent.runCommand("/ins history " + (pageNum + 1))));
|
||||||
|
}
|
||||||
|
|
||||||
|
// | Use /ins history <page> for advanced navigation
|
||||||
|
indicator.append(Component.text(" | ", NamedTextColor.GRAY).append(Component.text("Use ", NamedTextColor.WHITE)
|
||||||
|
.append(Component.text("/ins history <page>", TextColor.color(0x30ade4))
|
||||||
|
.clickEvent(ClickEvent.suggestCommand("/ins history ")))
|
||||||
|
.append(Component.text(" for advanced navigation", NamedTextColor.WHITE))));
|
||||||
|
|
||||||
|
player.sendMessage(indicator.build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CompletableFuture<FUtil.PaginationList<CoreProtectAPI.ParseResult>> lookupForPlayer(Block block, Player player)
|
||||||
|
{
|
||||||
|
cooldownMap.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
CoreProtectAPI api = getCoreProtectAPI();
|
||||||
|
|
||||||
|
return CompletableFuture.supplyAsync(() ->
|
||||||
|
{
|
||||||
|
historyMap.remove(player.getUniqueId());
|
||||||
|
FUtil.PaginationList<CoreProtectAPI.ParseResult> pages = new FUtil.PaginationList<>(10);
|
||||||
|
api.blockLookup(block, -1).forEach(stringArray -> pages.add(api.parseResult(stringArray)));
|
||||||
|
historyMap.put(player.getUniqueId(), pages);
|
||||||
|
return pages;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
// The inspector only works if we have CoreProtect installed
|
||||||
PlayerData data = plugin.pl.getData(player);
|
if (!isEnabled())
|
||||||
Block block = event.getClickedBlock();
|
|
||||||
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
|
||||||
|
|
||||||
// TODO: Rewrite this
|
|
||||||
if (data.hasInspection())
|
|
||||||
{
|
{
|
||||||
int cooldownTime = 3;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Cooldown check
|
Player player = event.getPlayer();
|
||||||
if ((event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
|
||||||
&& cooldown.containsKey(player.getName()))
|
if ((event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||||
|
&& plugin.pl.getData(player.getUniqueId()).hasInspection())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
Optional<Long> cooldown = Optional.ofNullable(cooldownMap.get(player.getUniqueId()));
|
||||||
|
|
||||||
|
if (cooldown.isPresent() && getSecondsLeft(cooldown.get(), 3) > 0L)
|
||||||
{
|
{
|
||||||
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
|
player.sendMessage(prefix.append(Component.text("You need to wait ")
|
||||||
if (secondsLeft > 0L)
|
.append(Component.text(getSecondsLeft(cooldown.get(), 3)))
|
||||||
{
|
.append(Component.text(" seconds before you can make another query."))
|
||||||
event.setCancelled(true);
|
.color(NamedTextColor.WHITE)));
|
||||||
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actual lookup time
|
// Time to do a look-up.
|
||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
|
if (block != null)
|
||||||
{
|
{
|
||||||
if (block != null)
|
/* This is a hack to make it so that when you right-click, the coordinates that get used depend on
|
||||||
|
* what's in your hand. Non-blocks use the block you clicked directly, but blocks use wherever the
|
||||||
|
* block was supposed to be placed. */
|
||||||
|
ItemStack hand = player.getInventory().getItemInMainHand();
|
||||||
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && hand.getType().isBlock() && hand.getType() != Material.AIR)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
block = block.getRelative(event.getBlockFace()).getState().getBlock();
|
||||||
List<String[]> lookup = coreProtect.blockLookup(block, -1);
|
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
cooldown.put(player.getName(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lookup != null)
|
|
||||||
{
|
|
||||||
if (lookup.isEmpty())
|
|
||||||
{
|
|
||||||
player.sendMessage(net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector " + ChatColor.WHITE + "- " + "No block data found for this location");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HISTORY_MAP.remove(event.getPlayer());
|
|
||||||
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
|
|
||||||
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
|
|
||||||
|
|
||||||
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- " +
|
|
||||||
ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
|
|
||||||
|
|
||||||
for (String[] value : lookup)
|
|
||||||
{
|
|
||||||
CoreProtectAPI.ParseResult result = coreProtect.parseResult(value);
|
|
||||||
BlockData bl = result.getBlockData();
|
|
||||||
|
|
||||||
String s;
|
|
||||||
String st = "";
|
|
||||||
|
|
||||||
if (result.getActionString().equals("Placement"))
|
|
||||||
{
|
|
||||||
s = " placed ";
|
|
||||||
}
|
|
||||||
else if (result.getActionString().equals("Removal"))
|
|
||||||
{
|
|
||||||
s = " broke ";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
s = " interacted with ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.isRolledBack())
|
|
||||||
{
|
|
||||||
st += "§m";
|
|
||||||
}
|
|
||||||
|
|
||||||
int time = (int)(System.currentTimeMillis() / 1000L);
|
|
||||||
|
|
||||||
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4") +
|
|
||||||
st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> page = paged.getPage(1);
|
|
||||||
for (String entries : page)
|
|
||||||
{
|
|
||||||
player.sendMessage(entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage("Page 1/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
lookupForPlayer(block, player).thenAccept(results ->
|
||||||
{
|
|
||||||
if (block != null)
|
|
||||||
{
|
{
|
||||||
BlockState blockState = block.getRelative(event.getBlockFace()).getState();
|
if (results.isEmpty())
|
||||||
Block placedBlock = blockState.getBlock();
|
|
||||||
event.setCancelled(true);
|
|
||||||
List<String[]> lookup = coreProtect.blockLookup(placedBlock, -1);
|
|
||||||
|
|
||||||
if (lookup.isEmpty())
|
|
||||||
{
|
{
|
||||||
lookup = coreProtect.blockLookup(block, -1);
|
player.sendMessage(prefix.append(Component.text("No results were found.").color(NamedTextColor.WHITE)));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!plugin.al.isAdmin(player))
|
|
||||||
{
|
{
|
||||||
cooldown.put(player.getName(), System.currentTimeMillis());
|
showPageToPlayer(player, results, 1);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
if (lookup != null)
|
|
||||||
{
|
|
||||||
if (lookup.isEmpty())
|
|
||||||
{
|
|
||||||
player.sendMessage(net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector " + ChatColor.WHITE + "- " + "No block data found for this location");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HISTORY_MAP.remove(event.getPlayer());
|
|
||||||
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
|
|
||||||
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
|
|
||||||
|
|
||||||
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- " +
|
|
||||||
ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
|
|
||||||
|
|
||||||
for (String[] value : lookup)
|
|
||||||
{
|
|
||||||
CoreProtectAPI.ParseResult result = coreProtect.parseResult(value);
|
|
||||||
BlockData bl = result.getBlockData();
|
|
||||||
|
|
||||||
String s;
|
|
||||||
String st = "";
|
|
||||||
|
|
||||||
if (result.getActionString().equals("Placement"))
|
|
||||||
{
|
|
||||||
s = " placed ";
|
|
||||||
}
|
|
||||||
else if (result.getActionString().equals("Removal"))
|
|
||||||
{
|
|
||||||
s = " broke ";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
s = " interacted with ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.isRolledBack())
|
|
||||||
{
|
|
||||||
st += "§m";
|
|
||||||
}
|
|
||||||
|
|
||||||
int time = (int)(System.currentTimeMillis() / 1000L);
|
|
||||||
|
|
||||||
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4") +
|
|
||||||
st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> page = paged.getPage(1);
|
|
||||||
for (String entries : page)
|
|
||||||
{
|
|
||||||
player.sendMessage(entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage("Page 1/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,13 +204,6 @@ public class EssentialsBridge extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Actually use this for something or remove it.
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
public boolean isEnabled()
|
||||||
{
|
{
|
||||||
final Essentials ess = getEssentialsPlugin();
|
final Essentials ess = getEssentialsPlugin();
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,134 +5,106 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
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.lang.ArrayUtils;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
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.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Restricts/unrestricts block modification abilities for everyone on the server or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]")
|
@CommandParameters(description = "Restricts/restores block modification abilities for everyone on the server or a certain player.", usage = "/<command> [<player> [reason] | list | purge | all]")
|
||||||
public class Command_blockedit extends FreedomCommand
|
public class Command_blockedit extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length > 0)
|
||||||
{
|
{
|
||||||
return false;
|
switch (args[0].toLowerCase())
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equals("list"))
|
|
||||||
{
|
|
||||||
msg("The following have block modification abilities restricted:");
|
|
||||||
int count = 0;
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
|
||||||
{
|
{
|
||||||
final FPlayer info = plugin.pl.getPlayer(player);
|
case "list" ->
|
||||||
if (info.isEditBlocked())
|
|
||||||
{
|
{
|
||||||
msg("- " + player.getName());
|
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||||
++count;
|
plugin.pl.getPlayer(player).isEditBlocked()).sorted().toList();
|
||||||
|
|
||||||
|
// Oh dear god, why do I have to do it like this?
|
||||||
|
msg("There " + (list.size() != 1 ? "are " : "is ") + list.size() + " player"
|
||||||
|
+ (list.size() != 1 ? "s" : "") + " online with restricted block modification abilities"
|
||||||
|
+ (list.size() > 0 ? ":" : "."));
|
||||||
|
|
||||||
|
list.forEach(player -> msg("- " + player.getName()));
|
||||||
}
|
}
|
||||||
}
|
case "purge" ->
|
||||||
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
msg("- none");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equals("purge"))
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for all players", true);
|
|
||||||
int count = 0;
|
|
||||||
for (final Player player : this.server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
final FPlayer info = plugin.pl.getPlayer(player);
|
|
||||||
if (info.isEditBlocked())
|
|
||||||
{
|
{
|
||||||
info.setEditBlocked(false);
|
FUtil.adminAction(sender.getName(), "Restoring block modification abilities for all players", true);
|
||||||
++count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg("Unblocked all block modification abilities for " + count + " players.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equals("all"))
|
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||||
{
|
plugin.pl.getPlayer(player).isEditBlocked()).toList();
|
||||||
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for all non-admins", true);
|
|
||||||
int counter = 0;
|
list.forEach(player ->
|
||||||
for (final Player player : this.server.getOnlinePlayers())
|
{
|
||||||
{
|
plugin.pl.getPlayer(player).setEditBlocked(false);
|
||||||
if (!plugin.al.isAdmin(player))
|
msg(player, "Your block modification abilities have been restored.", ChatColor.GREEN);
|
||||||
|
});
|
||||||
|
|
||||||
|
msg("Restored block modification abilities for " + list.size() + " player"
|
||||||
|
+ (list.size() != 1 ? "s" : "") + ".");
|
||||||
|
}
|
||||||
|
case "all", "-a" ->
|
||||||
{
|
{
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
FUtil.adminAction(sender.getName(), "Restricting block modification abilities for all non-admins", true);
|
||||||
playerdata.setEditBlocked(true);
|
|
||||||
++counter;
|
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||||
|
!plugin.al.isAdmin(player)).toList();
|
||||||
|
|
||||||
|
list.forEach(player ->
|
||||||
|
{
|
||||||
|
plugin.pl.getPlayer(player).setEditBlocked(true);
|
||||||
|
msg(player, "Your block modification abilities have been restricted.", ChatColor.RED);
|
||||||
|
});
|
||||||
|
|
||||||
|
msg("Restricted block modification abilities for " + list.size() + " player"
|
||||||
|
+ (list.size() != 1 ? "s" : "") + ".");
|
||||||
}
|
}
|
||||||
|
default -> Optional.ofNullable(getPlayer(args[0])).ifPresentOrElse(player ->
|
||||||
|
{
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (fPlayer.isEditBlocked())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Restoring block modification abilities for " + player.getName(), true);
|
||||||
|
fPlayer.setEditBlocked(false);
|
||||||
|
msg("Restored block modification abilities for " + player.getName() + ".");
|
||||||
|
msg(player, "Your block modification abilities have been restored.", ChatColor.GREEN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
msg(player.getName() + " is an admin, and as such cannot have their block modification abilities restricted.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Restricting block modification abilities for " + player.getName(), true);
|
||||||
|
fPlayer.setEditBlocked(true);
|
||||||
|
msg("Restricted block modification abilities for " + player.getName() + ".");
|
||||||
|
msg(player, "Your block modification abilities have been restricted.", ChatColor.RED);
|
||||||
|
|
||||||
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player),
|
||||||
|
sender.getName(), PunishmentType.BLOCKEDIT, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, () -> msg(PLAYER_NOT_FOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Blocked block modification abilities for " + counter + " players.");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean smite = args[0].equals("-s");
|
|
||||||
if (smite)
|
|
||||||
{
|
|
||||||
args = (String[])ArrayUtils.subarray(args, 1, args.length);
|
|
||||||
if (args.length < 1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player player2 = getPlayer(args[0]);
|
|
||||||
if (player2 == null)
|
|
||||||
{
|
|
||||||
msg(PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String reason = null;
|
|
||||||
if (args.length > 1)
|
|
||||||
{
|
|
||||||
reason = StringUtils.join(args, " ", 1, args.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
final FPlayer pd = plugin.pl.getPlayer(player2);
|
|
||||||
if (pd.isEditBlocked())
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
|
|
||||||
pd.setEditBlocked(false);
|
|
||||||
msg("Unblocking block modification abilities for " + player2.getName());
|
|
||||||
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player2))
|
return false;
|
||||||
{
|
|
||||||
msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
|
|
||||||
pd.setEditBlocked(true);
|
|
||||||
|
|
||||||
if (smite)
|
|
||||||
{
|
|
||||||
Command_smite.smite(sender, player2, reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg(player2, "Your block modification abilities have been blocked.", ChatColor.RED);
|
|
||||||
msg("Blocked all block modification abilities for " + player2.getName());
|
|
||||||
|
|
||||||
plugin.pul.logPunishment(new Punishment(player2.getName(), FUtil.getIp(player2), sender.getName(), PunishmentType.BLOCKEDIT, null));
|
|
||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,16 +32,14 @@ public class Command_deop extends FreedomCommand
|
|||||||
final List<String> matchedPlayerNames = new ArrayList<>();
|
final List<String> matchedPlayerNames = new ArrayList<>();
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
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.getUniqueId()))
|
||||||
{
|
{
|
||||||
if (player.isOp() && !plugin.al.isVanished(player.getName()))
|
matchedPlayerNames.add(player.getName());
|
||||||
{
|
player.setOp(false);
|
||||||
matchedPlayerNames.add(player.getName());
|
msg(player, YOU_ARE_NOT_OP);
|
||||||
player.setOp(false);
|
plugin.rm.updateDisplay(player);
|
||||||
msg(player, YOU_ARE_NOT_OP);
|
|
||||||
plugin.rm.updateDisplay(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
@ -251,21 +234,18 @@ public class Command_enchant extends FreedomCommand
|
|||||||
return getEnchantments(item);
|
return getEnchantments(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.length == 3)
|
else if (args.length == 3 && args[0].equals("add"))
|
||||||
{
|
{
|
||||||
if (args[0].equals("add"))
|
Enchantment enchantment = Enchantment.getByName(args[1].toUpperCase());
|
||||||
|
if (enchantment != null)
|
||||||
{
|
{
|
||||||
Enchantment enchantment = Enchantment.getByName(args[1].toUpperCase());
|
if (!unsafe)
|
||||||
if (enchantment != null)
|
|
||||||
{
|
{
|
||||||
if (!unsafe)
|
return IntStream.rangeClosed(1, enchantment.getMaxLevel()).mapToObj(String::valueOf).toList();
|
||||||
{
|
}
|
||||||
return stringNumberRange(1, enchantment.getMaxLevel());
|
else
|
||||||
}
|
{
|
||||||
else
|
return Collections.singletonList("[level]");
|
||||||
{
|
|
||||||
return Collections.singletonList("[level]");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,30 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
|
import java.util.Optional;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
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;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Block inspector tool for operators", usage = "/<command> [history] <page>", aliases = "ins")
|
@CommandParameters(description = "Block inspector tool for operators.", usage = "/<command> [history] [page]", aliases = "ins")
|
||||||
public class Command_inspect extends FreedomCommand
|
public class Command_inspect 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)
|
||||||
{
|
{
|
||||||
|
if (!plugin.cpb.isEnabled())
|
||||||
|
{
|
||||||
|
msg("CoreProtect is not enabled on this server.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
PlayerData playerData = plugin.pl.getData(playerSender);
|
PlayerData playerData = plugin.pl.getData(playerSender);
|
||||||
@ -39,31 +46,40 @@ public class Command_inspect extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
msg("Invalid number", ChatColor.RED);
|
msg("Invalid number.", ChatColor.RED);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.PaginationList<String> paged = CoreProtectBridge.HISTORY_MAP.get(playerSender);
|
|
||||||
if (paged != null)
|
|
||||||
{
|
|
||||||
if (pageIndex < 1 || pageIndex > paged.getPageCount())
|
|
||||||
{
|
|
||||||
msg("Not a valid page number", ChatColor.RED);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- ", ChatColor.WHITE);
|
|
||||||
|
|
||||||
List<String> page = paged.getPage(pageIndex);
|
|
||||||
for (String entries : page)
|
|
||||||
{
|
|
||||||
msg(entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Page " + pageIndex + "/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>", ChatColor.WHITE);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int godDammit = pageIndex;
|
||||||
|
Optional.ofNullable(plugin.cpb.getHistoryForPlayer(playerSender)).ifPresentOrElse(page ->
|
||||||
|
plugin.cpb.showPageToPlayer(playerSender, page, godDammit),
|
||||||
|
() -> msg("You haven't inspected anything yet!", ChatColor.RED));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
return Collections.singletonList("history");
|
||||||
|
}
|
||||||
|
else if (args.length == 2 && args[0].equalsIgnoreCase("history") && plugin.cpb.isEnabled()
|
||||||
|
&& sender instanceof Player player && plugin.cpb.hasHistory(player))
|
||||||
|
{
|
||||||
|
return IntStream.rangeClosed(1, plugin.cpb.getHistoryForPlayer(player).getPageCount()).limit(50)
|
||||||
|
.mapToObj(String::valueOf).toList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@ -12,63 +9,37 @@ 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.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)
|
||||||
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-s | -f | -v]", aliases = "who,lsit")
|
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a | -v]", aliases = "who,lsit")
|
||||||
public class Command_list extends FreedomCommand
|
public class Command_list 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 > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (FUtil.isFromHostConsole(sender.getName()))
|
|
||||||
{
|
|
||||||
List<String> names = new ArrayList<>();
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (!plugin.al.isVanished(player.getName()))
|
|
||||||
{
|
|
||||||
names.add(player.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg("There are " + names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(names, ", "), ChatColor.WHITE);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ListFilter listFilter;
|
ListFilter listFilter;
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
String s = args[0];
|
switch (args[0].toLowerCase())
|
||||||
switch (s)
|
|
||||||
{
|
{
|
||||||
case "-s":
|
case "-s", "-a" -> listFilter = ListFilter.ADMINS;
|
||||||
case "-a":
|
case "-v" ->
|
||||||
{
|
|
||||||
listFilter = ListFilter.ADMINS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "-v":
|
|
||||||
{
|
{
|
||||||
checkRank(Rank.ADMIN);
|
checkRank(Rank.ADMIN);
|
||||||
listFilter = ListFilter.VANISHED_ADMINS;
|
listFilter = ListFilter.VANISHED_ADMINS;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "-t":
|
case "-t" ->
|
||||||
{
|
{
|
||||||
checkRank(Rank.ADMIN);
|
checkRank(Rank.ADMIN);
|
||||||
listFilter = ListFilter.TELNET_SESSIONS;
|
listFilter = ListFilter.TELNET_SESSIONS;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "-f":
|
default ->
|
||||||
{
|
|
||||||
listFilter = ListFilter.FAMOUS_PLAYERS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -78,74 +49,42 @@ public class Command_list extends FreedomCommand
|
|||||||
{
|
{
|
||||||
listFilter = ListFilter.PLAYERS;
|
listFilter = ListFilter.PLAYERS;
|
||||||
}
|
}
|
||||||
StringBuilder onlineStats = new StringBuilder();
|
|
||||||
StringBuilder onlineUsers = new StringBuilder();
|
|
||||||
|
|
||||||
List<String> n = new ArrayList<>();
|
String onlineStats;
|
||||||
|
List<String> players;
|
||||||
|
|
||||||
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender))
|
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
List<Admin> connectedAdmins = plugin.btb.getConnectedAdmins();
|
players = plugin.btb.getConnectedAdmins().stream().map(Admin::getName).toList();
|
||||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedAdmins.size())
|
onlineStats = ChatColor.BLUE + "There are " + ChatColor.RED + players.size() + ChatColor.BLUE
|
||||||
.append(ChatColor.BLUE)
|
+ " admins connected to telnet.";
|
||||||
.append(" admins connected to telnet.");
|
|
||||||
for (Admin admin : connectedAdmins)
|
|
||||||
{
|
|
||||||
n.add(admin.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(FUtil.getFakePlayerCount())
|
onlineStats = ChatColor.BLUE + "There are " + ChatColor.RED + FUtil.getFakePlayerCount() + ChatColor.BLUE
|
||||||
.append(ChatColor.BLUE)
|
+ " out of a maximum " + ChatColor.RED + server.getMaxPlayers() + ChatColor.BLUE + " players online.";
|
||||||
.append(" out of a maximum ")
|
|
||||||
.append(ChatColor.RED)
|
|
||||||
.append(server.getMaxPlayers())
|
|
||||||
.append(ChatColor.BLUE)
|
|
||||||
.append(" players online.");
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (listFilter == ListFilter.ADMINS && !plugin.al.isAdmin(p))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (listFilter == ListFilter.ADMINS && plugin.al.isVanished(p.getName()))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (listFilter == ListFilter.VANISHED_ADMINS && !plugin.al.isVanished(p.getName()))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(p.getName().toLowerCase()))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (listFilter == ListFilter.PLAYERS && plugin.al.isVanished(p.getName()))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Displayable display = plugin.rm.getDisplay(p);
|
players = server.getOnlinePlayers().stream().filter(pl ->
|
||||||
n.add(display.getColoredTag() + p.getName());
|
(listFilter == ListFilter.ADMINS && plugin.al.isAdmin(pl) && !plugin.al.isVanished(pl.getUniqueId()))
|
||||||
}
|
|| (listFilter == ListFilter.VANISHED_ADMINS && plugin.al.isVanished(pl.getUniqueId()))
|
||||||
|
|| (listFilter == ListFilter.PLAYERS && !plugin.al.isVanished(pl.getUniqueId()))).map(player ->
|
||||||
|
plugin.rm.getDisplay(player).getColoredTag() + player.getName()).toList();
|
||||||
}
|
}
|
||||||
String playerType = listFilter.toString().toLowerCase().replace('_', ' ');
|
|
||||||
onlineUsers.append("Connected ")
|
String onlineUsers = "Connected " + listFilter.name().toLowerCase().replace('_', ' ') + ": " + ChatColor.WHITE +
|
||||||
.append(playerType)
|
StringUtils.join(players, ChatColor.WHITE + ", " + ChatColor.WHITE);
|
||||||
.append(": ")
|
|
||||||
.append(StringUtils.join(n, ChatColor.WHITE + ", "));
|
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
msg(ChatColor.stripColor(onlineStats.toString()));
|
msg(ChatColor.stripColor(onlineStats));
|
||||||
msg(ChatColor.stripColor(onlineUsers.toString()));
|
msg(ChatColor.stripColor(onlineUsers));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg(onlineStats.toString());
|
msg(onlineStats);
|
||||||
msg(onlineUsers.toString());
|
msg(onlineUsers);
|
||||||
}
|
}
|
||||||
n.clear();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +93,6 @@ public class Command_list extends FreedomCommand
|
|||||||
PLAYERS,
|
PLAYERS,
|
||||||
ADMINS,
|
ADMINS,
|
||||||
VANISHED_ADMINS,
|
VANISHED_ADMINS,
|
||||||
TELNET_SESSIONS,
|
TELNET_SESSIONS
|
||||||
FAMOUS_PLAYERS
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,26 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
|
||||||
@CommandParameters(description = "Register your connection with the TFM logviewer.", usage = "/<command> [off]")
|
|
||||||
public class Command_logs extends FreedomCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
LogsRegistrationMode mode = LogsRegistrationMode.ADD;
|
|
||||||
if (args.length == 1 && "off".equalsIgnoreCase(args[0]))
|
|
||||||
{
|
|
||||||
mode = LogsRegistrationMode.DELETE;
|
|
||||||
}
|
|
||||||
plugin.lv.updateLogsRegistration(sender, playerSender, mode);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,15 +3,15 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.GameRuleHandler;
|
import me.totalfreedom.totalfreedommod.GameRuleHandler;
|
||||||
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.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;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Control mob limiting parameters.", usage = "/<command> <on|off|setmax <count>|dragon|giant|ghast|slime>")
|
@CommandParameters(description = "Control mob limiting parameters.", usage = "/<command> <on | off | setmax <count> | dragon | giant | ghast | slime>")
|
||||||
public class Command_moblimiter extends FreedomCommand
|
public class Command_moblimiter 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)
|
||||||
{
|
{
|
||||||
@ -20,47 +20,35 @@ public class Command_moblimiter extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("on"))
|
switch (args[0].toLowerCase())
|
||||||
{
|
{
|
||||||
ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(true);
|
case "on" -> ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(true);
|
||||||
}
|
case "off" -> ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(false);
|
||||||
else if (args[0].equalsIgnoreCase("off"))
|
case "dragon" -> ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean());
|
||||||
{
|
case "giant" -> ConfigEntry.MOB_LIMITER_DISABLE_GIANT.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean());
|
||||||
ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(false);
|
case "slime" -> ConfigEntry.MOB_LIMITER_DISABLE_SLIME.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean());
|
||||||
}
|
case "ghast" -> ConfigEntry.MOB_LIMITER_DISABLE_GHAST.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean());
|
||||||
else if (args[0].equalsIgnoreCase("dragon"))
|
case "setmax" ->
|
||||||
{
|
|
||||||
ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean());
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("giant"))
|
|
||||||
{
|
|
||||||
ConfigEntry.MOB_LIMITER_DISABLE_GIANT.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean());
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("slime"))
|
|
||||||
{
|
|
||||||
ConfigEntry.MOB_LIMITER_DISABLE_SLIME.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean());
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("ghast"))
|
|
||||||
{
|
|
||||||
ConfigEntry.MOB_LIMITER_DISABLE_GHAST.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (args.length < 2)
|
|
||||||
{
|
{
|
||||||
return false;
|
if (args.length < 2)
|
||||||
}
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("setmax"))
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ConfigEntry.MOB_LIMITER_MAX.setInteger(Math.max(0, Math.min(2000, Integer.parseInt(args[1]))));
|
ConfigEntry.MOB_LIMITER_MAX.setInteger(Math.max(0, Math.min(2000, Integer.parseInt(args[1]))));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ignored)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
msg("Invalid number: " + args[1], ChatColor.RED);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
default ->
|
||||||
|
{
|
||||||
|
// Shut the fuck up Codacy!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
|
if (ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
|
||||||
@ -78,7 +66,6 @@ public class Command_moblimiter extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugin.gr.setGameRule(GameRuleHandler.GameRule.DO_MOB_SPAWNING, !ConfigEntry.MOB_LIMITER_ENABLED.getBoolean());
|
plugin.gr.setGameRule(GameRuleHandler.GameRule.DO_MOB_SPAWNING, !ConfigEntry.MOB_LIMITER_ENABLED.getBoolean());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
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.player.FPlayer;
|
|
||||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
@ -20,7 +16,6 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-s | -q] <player> [reason] | list | purge | all>", aliases = "stfu")
|
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-s | -q] <player> [reason] | list | purge | all>", aliases = "stfu")
|
||||||
public class Command_mute extends FreedomCommand
|
public class Command_mute 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)
|
||||||
{
|
{
|
||||||
@ -29,134 +24,110 @@ public class Command_mute extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
switch (args[0].toLowerCase())
|
||||||
{
|
{
|
||||||
msg("Muted players:");
|
case "list" ->
|
||||||
FPlayer info;
|
|
||||||
int count = 0;
|
|
||||||
for (Player mp : server.getOnlinePlayers())
|
|
||||||
{
|
{
|
||||||
info = plugin.pl.getPlayer(mp);
|
msg("Muted players:");
|
||||||
if (info.isMuted())
|
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||||
|
plugin.pl.getPlayer(player).isMuted()).toList();
|
||||||
|
|
||||||
|
if (list.size() > 0)
|
||||||
|
list.forEach(player -> msg("- " + player.getName()));
|
||||||
|
else
|
||||||
|
msg("- none");
|
||||||
|
}
|
||||||
|
case "purge" ->
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Unmuting all players", true);
|
||||||
|
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||||
|
plugin.pl.getPlayer(player).isMuted()).toList();
|
||||||
|
|
||||||
|
list.forEach(player ->
|
||||||
{
|
{
|
||||||
msg("- " + mp.getName());
|
plugin.pl.getPlayer(player).setMuted(false);
|
||||||
count++;
|
player.sendTitle(ChatColor.RED + "You have been unmuted.",
|
||||||
}
|
ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||||
}
|
});
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
msg("- none");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
msg("Unmuted " + list.size() + " player" + (list.size() != 1 ? "s" : "") + ".");
|
||||||
}
|
}
|
||||||
|
case "all" ->
|
||||||
if (args[0].equalsIgnoreCase("purge"))
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Unmuting all players.", true);
|
|
||||||
FPlayer info;
|
|
||||||
int count = 0;
|
|
||||||
for (Player mp : server.getOnlinePlayers())
|
|
||||||
{
|
{
|
||||||
info = plugin.pl.getPlayer(mp);
|
FUtil.adminAction(sender.getName(), "Muting all non-admins", true);
|
||||||
if (info.isMuted())
|
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||||
|
!plugin.al.isAdmin(player)).toList();
|
||||||
|
|
||||||
|
list.forEach(player ->
|
||||||
{
|
{
|
||||||
info.setMuted(false);
|
plugin.pl.getPlayer(player).setMuted(true);
|
||||||
mp.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
player.sendTitle(ChatColor.RED + "You've been muted globally.",
|
||||||
count++;
|
ChatColor.YELLOW + "Please be patient and you will be unmuted shortly.", 20, 100, 60);
|
||||||
}
|
});
|
||||||
|
|
||||||
|
msg("Muted " + list.size() + " player" + (list.size() != 1 ? "s" : "") + ".");
|
||||||
}
|
}
|
||||||
plugin.mu.MUTED_PLAYERS.clear();
|
default ->
|
||||||
msg("Unmuted " + count + " players.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("all"))
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Muting all non-admins", true);
|
|
||||||
|
|
||||||
FPlayer playerdata;
|
|
||||||
int counter = 0;
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(player))
|
boolean quiet = args[0].equalsIgnoreCase("-q");
|
||||||
|
boolean smite = args[0].equalsIgnoreCase("-s");
|
||||||
|
|
||||||
|
// Handling the -q parameter
|
||||||
|
if (quiet || smite)
|
||||||
{
|
{
|
||||||
player.sendTitle(ChatColor.RED + "You've been muted globally.", ChatColor.YELLOW + "Please be patient and you will be unmuted shortly.", 20, 100, 60);
|
if (args.length == 1) return false;
|
||||||
playerdata = plugin.pl.getPlayer(player);
|
args = ArrayUtils.subarray(args, 1, args.length);
|
||||||
playerdata.setMuted(true);
|
|
||||||
counter++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handling the (optional) reason
|
||||||
|
String reason = args.length > 1 ? StringUtils.join(args, " ", 1, args.length) : null;
|
||||||
|
|
||||||
|
// Showtime
|
||||||
|
Optional.ofNullable(getPlayer(args[0])).ifPresentOrElse(player ->
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
msg(player.getName() + " is an admin, and as such can't be muted.", ChatColor.RED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (plugin.pl.getPlayer(player).isMuted())
|
||||||
|
{
|
||||||
|
msg(player.getName() + " is already muted.", ChatColor.RED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't broadcast the mute if it was quiet
|
||||||
|
if (!quiet)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Smite the player if we're supposed to
|
||||||
|
if (smite)
|
||||||
|
{
|
||||||
|
Command_smite.smite(sender, player, reason, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutes the player
|
||||||
|
plugin.pl.getPlayer(player).setMuted(true);
|
||||||
|
|
||||||
|
// Notify the player that they have been muted
|
||||||
|
player.sendTitle(ChatColor.RED + "You've been muted.",
|
||||||
|
ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||||
|
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName()
|
||||||
|
+ ChatColor.RED + ".", ChatColor.RED);
|
||||||
|
|
||||||
|
// Give them the reason if one is present.
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
msg(player, "Reason: " + ChatColor.YELLOW + reason, ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg((quiet ? "Quietly m" : "M") + "uted " + player.getName() + ".");
|
||||||
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(),
|
||||||
|
PunishmentType.MUTE, reason));
|
||||||
|
}, () -> msg(PLAYER_NOT_FOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Muted " + counter + " players.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -s option (smite)
|
|
||||||
boolean smite = args[0].equals("-s");
|
|
||||||
// -q option (shadowmute)
|
|
||||||
boolean quiet = args[0].equals("-q");
|
|
||||||
if (smite || quiet)
|
|
||||||
{
|
|
||||||
args = ArrayUtils.subarray(args, 1, args.length);
|
|
||||||
|
|
||||||
if (args.length < 1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
msg(PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String reason = null;
|
|
||||||
if (args.length > 1)
|
|
||||||
{
|
|
||||||
reason = StringUtils.join(args, " ", 1, args.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
msg(player.getName() + " is an admin, and can't be muted.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!playerdata.isMuted())
|
|
||||||
{
|
|
||||||
playerdata.setMuted(true);
|
|
||||||
player.sendTitle(ChatColor.RED + "You've been muted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
|
||||||
|
|
||||||
if (quiet)
|
|
||||||
{
|
|
||||||
msg("Muted " + player.getName() + " quietly");
|
|
||||||
return true; // doesn't announce reason
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
|
||||||
|
|
||||||
if (reason != null)
|
|
||||||
{
|
|
||||||
msg(player, ChatColor.RED + "Reason: " + ChatColor.YELLOW + reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (smite)
|
|
||||||
{
|
|
||||||
Command_smite.smite(sender, player, reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
|
||||||
msg("Muted " + player.getName());
|
|
||||||
|
|
||||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.MUTE, reason));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg(ChatColor.RED + "That player is already muted.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -217,42 +217,33 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else if (args.length == 2)
|
else if (args.length == 2)
|
||||||
{
|
{
|
||||||
if (args[0].equals("-o"))
|
if (args[0].equalsIgnoreCase("-o"))
|
||||||
{
|
{
|
||||||
return FUtil.getPlayerList();
|
return FUtil.getPlayerList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (doubleArguments.contains(args[0]))
|
if (doubleArguments.contains(args[0]) && args[0].equalsIgnoreCase("clearip"))
|
||||||
{
|
{
|
||||||
if (args[0].equals("clearip"))
|
List<String> ips = plugin.al.getAdmin(sender).getIps();
|
||||||
{
|
ips.remove(FUtil.getIp((Player)sender));
|
||||||
List<String> ips = plugin.al.getAdmin(sender).getIps();
|
return ips;
|
||||||
ips.remove(FUtil.getIp((Player)sender));
|
|
||||||
return ips;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.length == 3)
|
else if (args.length == 3 && args[0].equalsIgnoreCase("-o"))
|
||||||
{
|
{
|
||||||
if (args[0].equals("-o"))
|
List<String> options = new ArrayList<>();
|
||||||
{
|
options.addAll(singleArguments);
|
||||||
List<String> options = new ArrayList<>();
|
options.addAll(doubleArguments);
|
||||||
options.addAll(singleArguments);
|
return options;
|
||||||
options.addAll(doubleArguments);
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (args.length == 4)
|
else if (args.length == 4 && args[0].equalsIgnoreCase("-o") && args[2].equalsIgnoreCase("clearip"))
|
||||||
{
|
{
|
||||||
if (args[0].equals("-o") && args[2].equals("clearip"))
|
Admin admin = plugin.al.getEntryByName(args[1]);
|
||||||
|
if (admin != null)
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getEntryByName(args[1]);
|
return admin.getIps();
|
||||||
if (admin != null)
|
|
||||||
{
|
|
||||||
return admin.getIps();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FUtil.getPlayerList();
|
return FUtil.getPlayerList();
|
||||||
|
@ -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;
|
||||||
|
@ -15,10 +15,15 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <hex> <hex> <nick>", aliases = "nickgr")
|
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <hex> <hex> <nick>", aliases = "nickgr")
|
||||||
public class Command_nickgradient extends FreedomCommand
|
public class Command_nickgradient 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)
|
||||||
{
|
{
|
||||||
|
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
||||||
|
{
|
||||||
|
msg("Essentials is not enabled on this server.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length != 3)
|
if (args.length != 3)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -2,20 +2,25 @@ 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.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
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.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Essentials Interface Command - Randomize the colors of your nickname.", usage = "/<command> <<nick> | off>")
|
@CommandParameters(description = "Essentials Interface Command - Randomize the colors of your nickname.", usage = "/<command> <<nick> | off>")
|
||||||
public class Command_nicknyan extends FreedomCommand
|
public class Command_nicknyan 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)
|
||||||
{
|
{
|
||||||
|
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
||||||
|
{
|
||||||
|
msg("Essentials is not enabled on this server.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -41,32 +46,24 @@ public class Command_nicknyan extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
|
||||||
|
if (server.getOnlinePlayers().stream().anyMatch(player -> player != playerSender
|
||||||
|
&& (player.getName().equalsIgnoreCase(nickPlain)
|
||||||
|
|| ChatColor.stripColor(plugin.esb.getNickname(player.getName())).trim().equalsIgnoreCase(nickPlain))))
|
||||||
{
|
{
|
||||||
if (player == playerSender)
|
msg("That nickname is already in use.");
|
||||||
{
|
return true;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (player.getName().equalsIgnoreCase(nickPlain) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain))
|
|
||||||
{
|
|
||||||
msg("That nickname is already in use.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder newNick = new StringBuilder();
|
final StringBuilder newNick = new StringBuilder();
|
||||||
|
Arrays.stream(nickPlain.chars().toArray()).forEach(character -> newNick.append(FUtil.randomChatColor())
|
||||||
final char[] chars = nickPlain.toCharArray();
|
.append(Character.toString(character)));
|
||||||
for (char c : chars)
|
|
||||||
{
|
|
||||||
newNick.append(FUtil.randomChatColor()).append(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
newNick.append(ChatColor.WHITE);
|
newNick.append(ChatColor.WHITE);
|
||||||
|
|
||||||
plugin.esb.setNickname(sender.getName(), newNick.toString());
|
plugin.esb.setNickname(sender.getName(), newNick.toString());
|
||||||
|
|
||||||
msg("Your nickname is now: " + newNick.toString());
|
msg("Your nickname is now: " + newNick);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,10 +12,15 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <nick>")
|
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <nick>")
|
||||||
public class Command_nickrainbow extends FreedomCommand
|
public class Command_nickrainbow 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)
|
||||||
{
|
{
|
||||||
|
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
||||||
|
{
|
||||||
|
msg("Essentials is not enabled on this server.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -33,16 +33,14 @@ public class Command_op extends FreedomCommand
|
|||||||
List<String> matchedPlayerNames = new ArrayList<>();
|
List<String> matchedPlayerNames = new ArrayList<>();
|
||||||
for (final Player player : server.getOnlinePlayers())
|
for (final Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
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.getUniqueId()))
|
||||||
{
|
{
|
||||||
if (!player.isOp() && !plugin.al.isVanished(player.getName()))
|
matchedPlayerNames.add(player.getName());
|
||||||
{
|
player.setOp(true);
|
||||||
matchedPlayerNames.add(player.getName());
|
msg(player, YOU_ARE_OP);
|
||||||
player.setOp(true);
|
plugin.rm.updateDisplay(player);
|
||||||
msg(player, YOU_ARE_OP);
|
|
||||||
plugin.rm.updateDisplay(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,13 +10,12 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "OP everyone on the server.", usage = "/<command>")
|
@CommandParameters(description = "OP everyone on the server.", usage = "/<command>")
|
||||||
public class Command_opall extends FreedomCommand
|
public class Command_opall 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(), "Opping all players on the server", false);
|
FUtil.adminAction(sender.getName(), "Opping all players on the server", false);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
server.getOnlinePlayers().forEach(player ->
|
||||||
{
|
{
|
||||||
if (!player.isOp())
|
if (!player.isOp())
|
||||||
{
|
{
|
||||||
@ -28,7 +27,7 @@ public class Command_opall extends FreedomCommand
|
|||||||
{
|
{
|
||||||
player.recalculatePermissions();
|
player.recalculatePermissions();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
return true;
|
return 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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,6 @@
|
|||||||
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 org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -17,116 +14,109 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
@CommandParameters(description = "Enable, disable, or reload a specified plugin, as well as list all plugins on the server.", usage = "/<command> <<enable | disable | reload> <pluginname>> | list>", aliases = "plc")
|
@CommandParameters(description = "Enable, disable, or reload a specified plugin, as well as list all plugins on the server.", usage = "/<command> <<enable | disable | reload> <pluginname>> | list>", aliases = "plc")
|
||||||
public class Command_plugincontrol extends FreedomCommand
|
public class Command_plugincontrol extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private final List<String> UNTOUCHABLE_PLUGINS = Arrays.asList(plugin.getName());
|
private final List<String> UNTOUCHABLE_PLUGINS = Arrays.asList(plugin.getName());
|
||||||
|
|
||||||
@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)
|
||||||
{
|
{
|
||||||
if (args.length == 0 || args.length > 2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final PluginManager pm = server.getPluginManager();
|
final PluginManager pm = server.getPluginManager();
|
||||||
|
|
||||||
if (args.length == 1)
|
/* This is the way it is because there was too much "if the arguments aren't enough then return false" in the
|
||||||
|
* original code in addition to the stupid amount of "if something isn't right then do some boilerplate stuff
|
||||||
|
* then return true". Codacy complained, so I aggressively optimized this to keep it quiet. */
|
||||||
|
switch (args.length)
|
||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
case 1 ->
|
||||||
{
|
{
|
||||||
for (Plugin serverPlugin : pm.getPlugins())
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
final String version = serverPlugin.getDescription().getVersion();
|
Arrays.stream(pm.getPlugins()).forEach(pl ->
|
||||||
msg(ChatColor.GRAY + "- " + (serverPlugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + serverPlugin.getName()
|
{
|
||||||
+ ChatColor.GOLD + (!version.isEmpty() ? " v" + version : "") + " by "
|
final String version = pl.getDescription().getVersion();
|
||||||
+ StringUtils.join(serverPlugin.getDescription().getAuthors(), ", "));
|
msg(ChatColor.GRAY + "- " + (pl.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + pl.getName()
|
||||||
|
+ ChatColor.GOLD + (!version.isEmpty() ? " v" + version : "") + " by "
|
||||||
|
+ StringUtils.join(pl.getDescription().getAuthors(), ", "));
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
case 2 ->
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equals("enable"))
|
|
||||||
{
|
|
||||||
final Plugin target = getPlugin(args[1]);
|
|
||||||
if (target == null)
|
|
||||||
{
|
{
|
||||||
msg("Plugin not found!");
|
Plugin pl = pm.getPlugin(args[1]);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.isEnabled())
|
if (pl != null)
|
||||||
|
{
|
||||||
|
switch (args[0].toLowerCase())
|
||||||
|
{
|
||||||
|
case "enable" ->
|
||||||
|
{
|
||||||
|
if (pl.isEnabled())
|
||||||
|
{
|
||||||
|
msg(pl.getName() + " is already enabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pm.enablePlugin(pl);
|
||||||
|
|
||||||
|
if (pl.isEnabled())
|
||||||
|
{
|
||||||
|
msg(pl.getName() + " is now enabled.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("An error occurred whilst attempting to enable " + pl.getName() + ".");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "disable" ->
|
||||||
|
{
|
||||||
|
if (!pl.isEnabled())
|
||||||
|
{
|
||||||
|
msg(pl.getName() + " is already disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (UNTOUCHABLE_PLUGINS.contains(pl.getName()))
|
||||||
|
{
|
||||||
|
msg(pl.getName() + " can't be disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pm.disablePlugin(pl);
|
||||||
|
|
||||||
|
msg(pl.getName() + " is now disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "reload" ->
|
||||||
|
{
|
||||||
|
if (UNTOUCHABLE_PLUGINS.contains(pl.getName()))
|
||||||
|
{
|
||||||
|
msg(pl.getName() + " can't be reloaded.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pm.disablePlugin(pl);
|
||||||
|
pm.enablePlugin(pl);
|
||||||
|
|
||||||
|
msg(pl.getName() + " has been reloaded.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default ->
|
||||||
|
{
|
||||||
|
// Do nothing. This is here to please Codacy.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Plugin not found!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default ->
|
||||||
{
|
{
|
||||||
msg("Plugin is already enabled.");
|
// Ditto
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pm.enablePlugin(target);
|
|
||||||
|
|
||||||
if (!pm.isPluginEnabled(target))
|
|
||||||
{
|
|
||||||
msg("Error enabling plugin " + target.getName());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg(target.getName() + " is now enabled.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equals("disable"))
|
|
||||||
{
|
|
||||||
final Plugin target = getPlugin(args[1]);
|
|
||||||
if (target == null)
|
|
||||||
{
|
|
||||||
msg("Plugin not found!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!target.isEnabled())
|
|
||||||
{
|
|
||||||
msg("Plugin is already disabled.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UNTOUCHABLE_PLUGINS.contains(target.getName()))
|
|
||||||
{
|
|
||||||
msg("You cannot disable " + target.getName());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pm.disablePlugin(target);
|
|
||||||
|
|
||||||
if (pm.isPluginEnabled(target))
|
|
||||||
{
|
|
||||||
msg("Error disabling plugin " + target.getName());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg(target.getName() + " is now disabled.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equals("reload"))
|
|
||||||
{
|
|
||||||
final Plugin target = getPlugin(args[1]);
|
|
||||||
if (target == null)
|
|
||||||
{
|
|
||||||
msg("Plugin not found!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UNTOUCHABLE_PLUGINS.contains(target.getName()))
|
|
||||||
{
|
|
||||||
msg("You cannot reload " + target.getName());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pm.disablePlugin(target);
|
|
||||||
pm.enablePlugin(target);
|
|
||||||
msg(target.getName() + " reloaded.");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -143,51 +133,12 @@ public class Command_plugincontrol extends FreedomCommand
|
|||||||
{
|
{
|
||||||
return Arrays.asList("enable", "disable", "reload", "list");
|
return Arrays.asList("enable", "disable", "reload", "list");
|
||||||
}
|
}
|
||||||
else if (args.length == 2)
|
else if (args.length == 2 && !args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
if (!args[0].equals("list"))
|
return Arrays.stream(server.getPluginManager().getPlugins()).map(Plugin::getName)
|
||||||
{
|
.filter(pl -> !UNTOUCHABLE_PLUGINS.contains(pl)).toList();
|
||||||
return getAllPluginNames();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getAllPluginNames()
|
|
||||||
{
|
|
||||||
List<String> names = new ArrayList<>();
|
|
||||||
for (Plugin plugin : server.getPluginManager().getPlugins())
|
|
||||||
{
|
|
||||||
if (!UNTOUCHABLE_PLUGINS.contains(plugin.getName()))
|
|
||||||
{
|
|
||||||
names.add(plugin.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
names.remove(plugin.getName());
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Plugin getPlugin(String name)
|
|
||||||
{
|
|
||||||
for (Plugin serverPlugin : server.getPluginManager().getPlugins())
|
|
||||||
{
|
|
||||||
if (serverPlugin.getName().equalsIgnoreCase(name))
|
|
||||||
{
|
|
||||||
return serverPlugin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name.length() >= 3)
|
|
||||||
{
|
|
||||||
for (Plugin serverPlugin : server.getPluginManager().getPlugins())
|
|
||||||
{
|
|
||||||
if (serverPlugin.getName().toLowerCase().contains(name.toLowerCase()))
|
|
||||||
{
|
|
||||||
return serverPlugin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -6,7 +6,6 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
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.lang.StringUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -21,8 +20,6 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
aliases = "effect")
|
aliases = "effect")
|
||||||
public class Command_potion extends FreedomCommand
|
public class Command_potion extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@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)
|
||||||
{
|
{
|
||||||
@ -32,15 +29,8 @@ public class Command_potion extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
List<String> potionEffectTypeNames = new ArrayList<>();
|
msg("Potion effect types: " + FUtil.listToString(Arrays.stream(PotionEffectType.values())
|
||||||
for (PotionEffectType potion_effect_type : PotionEffectType.values())
|
.map(PotionEffectType::getName).toList()), ChatColor.AQUA);
|
||||||
{
|
|
||||||
if (potion_effect_type != null)
|
|
||||||
{
|
|
||||||
potionEffectTypeNames.add(potion_effect_type.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg("Potion effect types: " + StringUtils.join(potionEffectTypeNames, ", "), ChatColor.AQUA);
|
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("clearall"))
|
else if (args[0].equalsIgnoreCase("clearall"))
|
||||||
{
|
{
|
||||||
@ -50,14 +40,9 @@ public class Command_potion extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Cleared all potion effects from all players", true);
|
FUtil.adminAction(sender.getName(), "Clearing all potion effects from all players", true);
|
||||||
for (Player target : server.getOnlinePlayers())
|
server.getOnlinePlayers().forEach(target -> target.getActivePotionEffects().forEach(effect ->
|
||||||
{
|
target.removePotionEffect(effect.getType())));
|
||||||
for (PotionEffect potion_effect : target.getActivePotionEffects())
|
|
||||||
{
|
|
||||||
target.removePotionEffect(potion_effect.getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +71,7 @@ public class Command_potion extends FreedomCommand
|
|||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
msg(PLAYER_NOT_FOUND, ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +80,8 @@ public class Command_potion extends FreedomCommand
|
|||||||
target.removePotionEffect(potion_effect.getType());
|
target.removePotionEffect(potion_effect.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Cleared all active potion effects " + (!target.equals(playerSender) ? "from player " + target.getName() + "." : "from yourself."), ChatColor.AQUA);
|
msg("Cleared all active potion effects " + (!target.equals(playerSender) ? "from player "
|
||||||
|
+ target.getName() + "." : "from yourself."), ChatColor.AQUA);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -117,7 +103,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;
|
||||||
@ -132,44 +118,41 @@ public class Command_potion extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]);
|
PotionEffectType effectType = PotionEffectType.getByName(args[1]);
|
||||||
if (potion_effect_type == null)
|
if (effectType == null)
|
||||||
{
|
{
|
||||||
msg("Invalid potion effect type.", ChatColor.AQUA);
|
msg("Invalid potion effect: " + args[1], ChatColor.AQUA);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int duration;
|
int duration;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
duration = Integer.parseInt(args[2]);
|
duration = Math.min(Integer.parseInt(args[2]), 100000);
|
||||||
duration = Math.min(duration, 100000);
|
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid potion duration.", ChatColor.RED);
|
msg("Invalid duration: " + args[2], ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int amplifier;
|
int amplifier;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
amplifier = Integer.parseInt(args[3]);
|
amplifier = Math.min(Integer.parseInt(args[3]), 100000);
|
||||||
amplifier = Math.min(amplifier, 100000);
|
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid potion amplifier.", ChatColor.RED);
|
msg("Invalid potion amplifier: " + args[3], ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PotionEffect new_effect = potion_effect_type.createEffect(duration, amplifier);
|
PotionEffect new_effect = effectType.createEffect(duration, amplifier);
|
||||||
target.addPotionEffect(new_effect, true);
|
target.addPotionEffect(new_effect);
|
||||||
msg(
|
msg("Added potion effect: " + new_effect.getType().getName()
|
||||||
"Added potion effect: " + new_effect.getType().getName()
|
+ ", Duration: " + new_effect.getDuration()
|
||||||
+ ", Duration: " + new_effect.getDuration()
|
+ ", Amplifier: " + new_effect.getAmplifier()
|
||||||
+ ", Amplifier: " + new_effect.getAmplifier()
|
+ (!target.equals(playerSender) ? " to player " + target.getName() + "." : " to yourself."), ChatColor.AQUA);
|
||||||
+ (!target.equals(playerSender) ? " to player " + target.getName() + "." : " to yourself."), ChatColor.AQUA);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -186,7 +169,7 @@ public class Command_potion extends FreedomCommand
|
|||||||
{
|
{
|
||||||
switch (args.length)
|
switch (args.length)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1 ->
|
||||||
{
|
{
|
||||||
List<String> arguments = new ArrayList<>(Arrays.asList("list", "clear", "add"));
|
List<String> arguments = new ArrayList<>(Arrays.asList("list", "clear", "add"));
|
||||||
if (plugin.al.isAdmin(sender))
|
if (plugin.al.isAdmin(sender))
|
||||||
@ -195,72 +178,46 @@ public class Command_potion extends FreedomCommand
|
|||||||
}
|
}
|
||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
case 2 ->
|
||||||
case 2:
|
|
||||||
{
|
{
|
||||||
if (args[0].equals("clear"))
|
if (args[0].equalsIgnoreCase("clear"))
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(sender))
|
if (plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
return FUtil.getPlayerList();
|
return FUtil.getPlayerList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args[0].equals("add"))
|
else if (args[0].equalsIgnoreCase("add"))
|
||||||
{
|
{
|
||||||
return getAllPotionTypes();
|
return Arrays.stream(PotionEffectType.values()).map(PotionEffectType::getName).toList();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
case 3 ->
|
||||||
case 3:
|
|
||||||
{
|
{
|
||||||
if (args[0].equals("add"))
|
if (args[0].equalsIgnoreCase("add"))
|
||||||
{
|
{
|
||||||
return Collections.singletonList("<duration>");
|
return Collections.singletonList("<duration>");
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
case 4 ->
|
||||||
case 4:
|
|
||||||
{
|
{
|
||||||
if (args[0].equals("add"))
|
if (args[0].equalsIgnoreCase("add"))
|
||||||
{
|
{
|
||||||
return Collections.singletonList("<amplifier>");
|
return Collections.singletonList("<amplifier>");
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
case 5 ->
|
||||||
case 5:
|
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(sender))
|
if (plugin.al.isAdmin(sender) && args[0].equalsIgnoreCase("add"))
|
||||||
{
|
{
|
||||||
if (args[0].equals("add"))
|
return FUtil.getPlayerList();
|
||||||
{
|
|
||||||
return FUtil.getPlayerList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
default ->
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getAllPotionTypes()
|
|
||||||
{
|
|
||||||
List<String> types = new ArrayList<>();
|
|
||||||
for (PotionEffectType potionEffectType : PotionEffectType.values())
|
|
||||||
{
|
|
||||||
if (potionEffectType != null)
|
|
||||||
{
|
|
||||||
types.add(potionEffectType.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -84,19 +84,22 @@ public class Command_ride extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 2)
|
if (args.length >= 2 && args[0].equalsIgnoreCase("mode"))
|
||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("mode"))
|
try
|
||||||
{
|
{
|
||||||
if (args[1].equalsIgnoreCase("normal") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("ask"))
|
PlayerData.RideMode mode = PlayerData.RideMode.valueOf(args[1].toUpperCase());
|
||||||
{
|
PlayerData playerDataSender = plugin.pl.getData(playerSender);
|
||||||
PlayerData playerDataSender = plugin.pl.getData(playerSender);
|
playerDataSender.setRideMode(mode);
|
||||||
playerDataSender.setRideMode(args[1].toLowerCase());
|
plugin.pl.save(playerDataSender);
|
||||||
plugin.pl.save(playerDataSender);
|
msg("Ride mode is now set to " + mode.name().toLowerCase() + ".");
|
||||||
msg("Ride mode is now set to " + args[1].toLowerCase() + ".");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
msg("Invalid mode.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = getPlayer(args[0], true);
|
final Player player = getPlayer(args[0], true);
|
||||||
@ -114,13 +117,13 @@ public class Command_ride extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerData.getRideMode().equals("off") && !isAdmin(sender))
|
if (playerData.getRideMode() == PlayerData.RideMode.OFF && !isAdmin(sender))
|
||||||
{
|
{
|
||||||
msg("That player cannot be ridden.", ChatColor.RED);
|
msg("That player cannot be ridden.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerData.getRideMode().equals("ask") && !FUtil.isExecutive(playerSender.getName()))
|
if (playerData.getRideMode() == PlayerData.RideMode.ASK && !FUtil.isExecutive(playerSender.getName()))
|
||||||
{
|
{
|
||||||
msg("Sent a request to the player.", ChatColor.GREEN);
|
msg("Sent a request to the player.", ChatColor.GREEN);
|
||||||
msg(player, sender.getName() + " has requested to ride you.", ChatColor.AQUA);
|
msg(player, sender.getName() + " has requested to ride you.", ChatColor.AQUA);
|
||||||
|
@ -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,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Optional;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -15,10 +14,9 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/<command> <x> <y> <z> <worldname> <on|off>")
|
@CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/<command> <x> <y> <z> <worldname> <on | off>")
|
||||||
public class Command_setlever extends FreedomCommand
|
public class Command_setlever 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)
|
||||||
{
|
{
|
||||||
@ -33,50 +31,38 @@ public class Command_setlever extends FreedomCommand
|
|||||||
x = Double.parseDouble(args[0]);
|
x = Double.parseDouble(args[0]);
|
||||||
y = Double.parseDouble(args[1]);
|
y = Double.parseDouble(args[1]);
|
||||||
z = Double.parseDouble(args[2]);
|
z = Double.parseDouble(args[2]);
|
||||||
|
|
||||||
|
// Shows the "Invalid coordinates" message without having to do boilerplate bullshit
|
||||||
|
if (Math.abs(x) > 29999998 || Math.abs(y) > 29999998 || Math.abs(z) > 29999998)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (IllegalArgumentException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid coordinates.");
|
msg("Invalid coordinates.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x > 29999998 || x < -29999998 || y > 29999998 || y < -29999998 || z > 29999998 || z < -29999998)
|
Optional<World> optionalWorld = server.getWorlds().stream().filter(world ->
|
||||||
|
world.getName().equalsIgnoreCase(args[3])).findAny();
|
||||||
|
|
||||||
|
if (optionalWorld.isEmpty())
|
||||||
{
|
{
|
||||||
msg("Coordinates cannot be larger than 29999998 or smaller than -29999998 blocks.");
|
msg("Invalid world: " + args[3]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
World world = null;
|
final Location leverLocation = new Location(optionalWorld.get(), x, y, z);
|
||||||
final String needleWorldName = args[3].trim();
|
|
||||||
final List<World> worlds = server.getWorlds();
|
|
||||||
for (final World testWorld : worlds)
|
|
||||||
{
|
|
||||||
if (testWorld.getName().trim().equalsIgnoreCase(needleWorldName))
|
|
||||||
{
|
|
||||||
world = testWorld;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world == null)
|
|
||||||
{
|
|
||||||
msg("Invalid world name.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Location leverLocation = new Location(world, x, y, z);
|
|
||||||
|
|
||||||
final boolean leverOn = (args[4].trim().equalsIgnoreCase("on") || args[4].trim().equalsIgnoreCase("1"));
|
|
||||||
|
|
||||||
final Block targetBlock = leverLocation.getBlock();
|
final Block targetBlock = leverLocation.getBlock();
|
||||||
|
|
||||||
if (targetBlock.getType() == Material.LEVER)
|
if (targetBlock.getType() == Material.LEVER)
|
||||||
{
|
{
|
||||||
BlockState state = targetBlock.getState();
|
BlockState state = targetBlock.getState();
|
||||||
BlockData data = state.getBlockData();
|
BlockData data = state.getBlockData();
|
||||||
Switch caster = (Switch)data;
|
Switch caster = (Switch) data;
|
||||||
|
|
||||||
caster.setPowered(leverOn);
|
caster.setPowered(args[4].trim().equalsIgnoreCase("on") || args[4].trim().equalsIgnoreCase("1"));
|
||||||
state.setBlockData(data);
|
state.setBlockData(data);
|
||||||
state.update();
|
state.update();
|
||||||
|
|
||||||
@ -84,8 +70,7 @@ public class Command_setlever extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("Target block " + targetBlock + " is not a lever.");
|
msg("That block isn't a lever.");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -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,19 +39,16 @@ 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;
|
||||||
}
|
}
|
||||||
if (player.getInventory().contains(material))
|
if (player.getInventory().contains(material))
|
||||||
{
|
{
|
||||||
players.add(player.getName());
|
players.add(player.getName());
|
||||||
if (plugin.al.isAdmin(sender))
|
if (plugin.al.isAdmin(sender) && doClear && !plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
if (doClear && !plugin.al.isAdmin(player))
|
player.getInventory().remove(material);
|
||||||
{
|
|
||||||
player.getInventory().remove(material);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,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,12 +217,9 @@ 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)
|
if (player != null && nullVanished && plugin.al.isVanished(player.getUniqueId()) && !plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
if (nullVanished && plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
|
return null;
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
@ -90,12 +90,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"),
|
||||||
@ -145,9 +139,6 @@ public enum ConfigEntry
|
|||||||
AUTOKICK_THRESHOLD(Double.class, "autokick.threshold"),
|
AUTOKICK_THRESHOLD(Double.class, "autokick.threshold"),
|
||||||
AUTOKICK_TIME(Integer.class, "autokick.time"),
|
AUTOKICK_TIME(Integer.class, "autokick.time"),
|
||||||
//
|
//
|
||||||
LOGS_SECRET(String.class, "logs.secret"),
|
|
||||||
LOGS_URL(String.class, "logs.url"),
|
|
||||||
//
|
|
||||||
FLATLANDS_GENERATE(Boolean.class, "flatlands.generate"),
|
FLATLANDS_GENERATE(Boolean.class, "flatlands.generate"),
|
||||||
FLATLANDS_GENERATE_PARAMS(String.class, "flatlands.generate_params"),
|
FLATLANDS_GENERATE_PARAMS(String.class, "flatlands.generate_params"),
|
||||||
//
|
//
|
||||||
@ -164,7 +155,6 @@ public enum ConfigEntry
|
|||||||
WILDCARD_BLOCKED_COMMANDS(List.class, "blocked_commands.wildcard"),
|
WILDCARD_BLOCKED_COMMANDS(List.class, "blocked_commands.wildcard"),
|
||||||
FORBIDDEN_WORDS(List.class, "forbidden_words"),
|
FORBIDDEN_WORDS(List.class, "forbidden_words"),
|
||||||
HOST_SENDER_NAMES(List.class, "host_sender_names"),
|
HOST_SENDER_NAMES(List.class, "host_sender_names"),
|
||||||
FAMOUS_PLAYERS(List.class, "famous_players"),
|
|
||||||
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
|
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
|
||||||
ADMIN_INFO(List.class, "admininfo"),
|
ADMIN_INFO(List.class, "admininfo"),
|
||||||
VOTING_INFO(List.class, "votinginfo"),
|
VOTING_INFO(List.class, "votinginfo"),
|
||||||
@ -185,19 +175,6 @@ public enum ConfigEntry
|
|||||||
this.configName = configName;
|
this.configName = configName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigEntry findConfigEntry(String name)
|
|
||||||
{
|
|
||||||
name = name.toLowerCase().replace("_", "");
|
|
||||||
for (ConfigEntry entry : values())
|
|
||||||
{
|
|
||||||
if (entry.toString().toLowerCase().replace("_", "").equals(name))
|
|
||||||
{
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<?> getType()
|
public Class<?> getType()
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
|
@ -39,6 +39,7 @@ import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
|||||||
import net.dv8tion.jda.internal.utils.concurrent.CountingThreadFactory;
|
import net.dv8tion.jda.internal.utils.concurrent.CountingThreadFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.apache.commons.lang.WordUtils;
|
import org.apache.commons.lang.WordUtils;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.bukkit.GameRule;
|
import org.bukkit.GameRule;
|
||||||
@ -47,6 +48,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -195,15 +197,18 @@ public class Discord extends FreedomService
|
|||||||
catch (LoginException e)
|
catch (LoginException e)
|
||||||
{
|
{
|
||||||
FLog.warning("An invalid token for Discord integration was provided, the bot will not enable.");
|
FLog.warning("An invalid token for Discord integration was provided, the bot will not enable.");
|
||||||
|
enabled = false;
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e)
|
catch (IllegalArgumentException e)
|
||||||
{
|
{
|
||||||
FLog.warning("Discord integration failed to start.");
|
FLog.warning("Discord integration failed to start.");
|
||||||
|
enabled = false;
|
||||||
}
|
}
|
||||||
catch (NoClassDefFoundError e)
|
catch (NoClassDefFoundError e)
|
||||||
{
|
{
|
||||||
FLog.warning("The JDA plugin is not installed, therefore the discord bot cannot start.");
|
FLog.warning("The JDA plugin is not installed, therefore the discord bot cannot start.");
|
||||||
FLog.warning("To resolve this error, please download the latest JDA from: https://github.com/AtlasMediaGroup/Minecraft-JDA/releases");
|
FLog.warning("To resolve this error, please download the latest JDA from: https://github.com/AtlasMediaGroup/Minecraft-JDA/releases");
|
||||||
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -226,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);
|
||||||
@ -284,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);
|
||||||
}
|
}
|
||||||
@ -293,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);
|
||||||
}
|
}
|
||||||
@ -534,4 +513,17 @@ public class Discord extends FreedomService
|
|||||||
messageChatChannel("**Server has started**", true);
|
messageChatChannel("**Server has started**", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
String message = event.getMessage();
|
||||||
|
|
||||||
|
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !server.hasWhitelist()
|
||||||
|
&& !plugin.pl.getPlayer(player).isMuted() && bot != null)
|
||||||
|
{
|
||||||
|
messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -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())
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,6 @@ import me.totalfreedom.totalfreedommod.httpd.module.Module_indefbans;
|
|||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_index;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_index;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_list;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_list;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_logfile;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_logfile;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_logs;
|
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_punishments;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_punishments;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
|
||||||
@ -96,7 +95,6 @@ public class HTTPDaemon extends FreedomService
|
|||||||
module("help", Module_help.class, false);
|
module("help", Module_help.class, false);
|
||||||
module("list", Module_list.class, false);
|
module("list", Module_list.class, false);
|
||||||
module("logfile", Module_logfile.class, true);
|
module("logfile", Module_logfile.class, true);
|
||||||
module("logs", Module_logs.class, true);
|
|
||||||
module("indefbans", Module_indefbans.class, true);
|
module("indefbans", Module_indefbans.class, true);
|
||||||
module("players", Module_players.class, false);
|
module("players", Module_players.class, false);
|
||||||
module("punishments", Module_punishments.class, true);
|
module("punishments", Module_punishments.class, true);
|
||||||
|
@ -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,29 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
|
|
||||||
public class Module_logs extends Module_file
|
|
||||||
{
|
|
||||||
|
|
||||||
public Module_logs(NanoHTTPD.HTTPSession session)
|
|
||||||
{
|
|
||||||
super(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NanoHTTPD.Response getResponse()
|
|
||||||
{
|
|
||||||
if (ConfigEntry.LOGS_SECRET.getString().equals(params.get("password")) && !ConfigEntry.LOGS_SECRET.getString().isEmpty())
|
|
||||||
{
|
|
||||||
FLog.info(session.getSocket().getInetAddress() + " is downloading latest.log.");
|
|
||||||
return serveFile("latest.log", params, new File("./logs"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "Incorrect password.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,8 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class FPlayer
|
public class FPlayer
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final long AUTO_PURGE_TICKS = 5L * 60L * 20L;
|
public static final long AUTO_PURGE_TICKS = 5L * 60L * 20L;
|
||||||
|
|
||||||
|
|
||||||
private final TotalFreedomMod plugin;
|
private final TotalFreedomMod plugin;
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
@ -40,8 +38,6 @@ public class FPlayer
|
|||||||
private int messageCount = 0;
|
private int messageCount = 0;
|
||||||
private int totalBlockDestroy = 0;
|
private int totalBlockDestroy = 0;
|
||||||
private int totalBlockPlace = 0;
|
private int totalBlockPlace = 0;
|
||||||
private int freecamDestroyCount = 0;
|
|
||||||
private int freecamPlaceCount = 0;
|
|
||||||
private boolean isOrbiting = false;
|
private boolean isOrbiting = false;
|
||||||
private double orbitStrength = 10.0;
|
private double orbitStrength = 10.0;
|
||||||
private boolean mobThrowerEnabled = false;
|
private boolean mobThrowerEnabled = false;
|
||||||
@ -52,11 +48,9 @@ public class FPlayer
|
|||||||
private boolean mp44Firing = false;
|
private boolean mp44Firing = false;
|
||||||
private BukkitTask lockupScheduleTask = null;
|
private BukkitTask lockupScheduleTask = null;
|
||||||
private boolean lockedUp = false;
|
private boolean lockedUp = false;
|
||||||
private String lastMessage = "";
|
|
||||||
private boolean inAdminchat = false;
|
private boolean inAdminchat = false;
|
||||||
private boolean allCommandsBlocked = false;
|
private boolean allCommandsBlocked = false;
|
||||||
private String lastCommand = "";
|
private String lastCommand = "";
|
||||||
private boolean cmdspyEnabled = false;
|
|
||||||
private String tag = null;
|
private String tag = null;
|
||||||
private int warningCount = 0;
|
private int warningCount = 0;
|
||||||
|
|
||||||
@ -82,11 +76,6 @@ public class FPlayer
|
|||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getAutoPurgeTicks()
|
|
||||||
{
|
|
||||||
return AUTO_PURGE_TICKS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer()
|
public Player getPlayer()
|
||||||
{
|
{
|
||||||
if (player != null && !player.isOnline())
|
if (player != null && !player.isOnline())
|
||||||
@ -110,7 +99,6 @@ public class FPlayer
|
|||||||
// Ensure admins don't have admin functionality when removed (FS-222)
|
// Ensure admins don't have admin functionality when removed (FS-222)
|
||||||
public void removeAdminFunctionality()
|
public void removeAdminFunctionality()
|
||||||
{
|
{
|
||||||
this.setCommandSpy(false);
|
|
||||||
this.setAdminChat(false);
|
this.setAdminChat(false);
|
||||||
this.setFuckoffRadius(0);
|
this.setFuckoffRadius(0);
|
||||||
}
|
}
|
||||||
@ -120,11 +108,6 @@ public class FPlayer
|
|||||||
return isOrbiting;
|
return isOrbiting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrbiting(boolean orbiting)
|
|
||||||
{
|
|
||||||
isOrbiting = orbiting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startOrbiting(double strength)
|
public void startOrbiting(double strength)
|
||||||
{
|
{
|
||||||
this.isOrbiting = true;
|
this.isOrbiting = true;
|
||||||
@ -186,26 +169,6 @@ public class FPlayer
|
|||||||
this.totalBlockPlace = 0;
|
this.totalBlockPlace = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int incrementAndGetFreecamDestroyCount()
|
|
||||||
{
|
|
||||||
return this.freecamDestroyCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetFreecamDestroyCount()
|
|
||||||
{
|
|
||||||
this.freecamDestroyCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int incrementAndGetFreecamPlaceCount()
|
|
||||||
{
|
|
||||||
return this.freecamPlaceCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetFreecamPlaceCount()
|
|
||||||
{
|
|
||||||
this.freecamPlaceCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableMobThrower(EntityType mobThrowerCreature, double mobThrowerSpeed)
|
public void enableMobThrower(EntityType mobThrowerCreature, double mobThrowerSpeed)
|
||||||
{
|
{
|
||||||
this.mobThrowerEnabled = true;
|
this.mobThrowerEnabled = true;
|
||||||
@ -294,7 +257,6 @@ public class FPlayer
|
|||||||
public void setMuted(boolean muted, int minutes)
|
public void setMuted(boolean muted, int minutes)
|
||||||
{
|
{
|
||||||
FUtil.cancel(unmuteTask);
|
FUtil.cancel(unmuteTask);
|
||||||
plugin.mu.MUTED_PLAYERS.remove(getPlayer().getName());
|
|
||||||
unmuteTask = null;
|
unmuteTask = null;
|
||||||
|
|
||||||
if (!muted)
|
if (!muted)
|
||||||
@ -307,8 +269,6 @@ public class FPlayer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.mu.MUTED_PLAYERS.add(getPlayer().getName());
|
|
||||||
|
|
||||||
// TODO: Simplify this into a Consumer<BukkitTask> lambda?
|
// TODO: Simplify this into a Consumer<BukkitTask> lambda?
|
||||||
unmuteTask = new BukkitRunnable()
|
unmuteTask = new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@ -323,7 +283,6 @@ public class FPlayer
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Unmuting " + getName(), false);
|
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Unmuting " + getName(), false);
|
||||||
plugin.mu.MUTED_PLAYERS.remove(getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, minutes * (60L * 20L));
|
}.runTaskLater(plugin, minutes * (60L * 20L));
|
||||||
@ -354,16 +313,6 @@ public class FPlayer
|
|||||||
this.lockedUp = lockedUp;
|
this.lockedUp = lockedUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLastMessage()
|
|
||||||
{
|
|
||||||
return lastMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastMessage(String message)
|
|
||||||
{
|
|
||||||
this.lastMessage = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdminChat(boolean inAdminchat)
|
public void setAdminChat(boolean inAdminchat)
|
||||||
{
|
{
|
||||||
this.inAdminchat = inAdminchat;
|
this.inAdminchat = inAdminchat;
|
||||||
@ -394,16 +343,6 @@ public class FPlayer
|
|||||||
this.lastCommand = lastCommand;
|
this.lastCommand = lastCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommandSpy(boolean enabled)
|
|
||||||
{
|
|
||||||
this.cmdspyEnabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean cmdspyEnabled()
|
|
||||||
{
|
|
||||||
return cmdspyEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTag()
|
public String getTag()
|
||||||
{
|
{
|
||||||
return this.tag;
|
return this.tag;
|
||||||
@ -421,16 +360,6 @@ public class FPlayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWarningCount()
|
|
||||||
{
|
|
||||||
return this.warningCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWarningCount(int warningCount)
|
|
||||||
{
|
|
||||||
this.warningCount = warningCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrementWarnings(boolean quiet)
|
public void incrementWarnings(boolean quiet)
|
||||||
{
|
{
|
||||||
this.warningCount++;
|
this.warningCount++;
|
||||||
@ -463,16 +392,6 @@ public class FPlayer
|
|||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitTask getUnmuteTask()
|
|
||||||
{
|
|
||||||
return unmuteTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnmuteTask(BukkitTask unmuteTask)
|
|
||||||
{
|
|
||||||
this.unmuteTask = unmuteTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FreezeData getFreezeData()
|
public FreezeData getFreezeData()
|
||||||
{
|
{
|
||||||
return freezeData;
|
return freezeData;
|
||||||
@ -488,176 +407,11 @@ public class FPlayer
|
|||||||
this.fuckoffRadius = fuckoffRadius;
|
this.fuckoffRadius = fuckoffRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMessageCount()
|
|
||||||
{
|
|
||||||
return messageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessageCount(int messageCount)
|
|
||||||
{
|
|
||||||
this.messageCount = messageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotalBlockDestroy()
|
|
||||||
{
|
|
||||||
return totalBlockDestroy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalBlockDestroy(int totalBlockDestroy)
|
|
||||||
{
|
|
||||||
this.totalBlockDestroy = totalBlockDestroy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotalBlockPlace()
|
|
||||||
{
|
|
||||||
return totalBlockPlace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalBlockPlace(int totalBlockPlace)
|
|
||||||
{
|
|
||||||
this.totalBlockPlace = totalBlockPlace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFreecamDestroyCount()
|
|
||||||
{
|
|
||||||
return freecamDestroyCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFreecamDestroyCount(int freecamDestroyCount)
|
|
||||||
{
|
|
||||||
this.freecamDestroyCount = freecamDestroyCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFreecamPlaceCount()
|
|
||||||
{
|
|
||||||
return freecamPlaceCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFreecamPlaceCount(int freecamPlaceCount)
|
|
||||||
{
|
|
||||||
this.freecamPlaceCount = freecamPlaceCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CageData getCageData()
|
public CageData getCageData()
|
||||||
{
|
{
|
||||||
return cageData;
|
return cageData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getOrbitStrength()
|
|
||||||
{
|
|
||||||
return orbitStrength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrbitStrength(double orbitStrength)
|
|
||||||
{
|
|
||||||
this.orbitStrength = orbitStrength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMobThrowerEnabled()
|
|
||||||
{
|
|
||||||
return mobThrowerEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMobThrowerEnabled(boolean mobThrowerEnabled)
|
|
||||||
{
|
|
||||||
this.mobThrowerEnabled = mobThrowerEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityType getMobThrowerEntity()
|
|
||||||
{
|
|
||||||
return mobThrowerEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMobThrowerEntity(EntityType mobThrowerEntity)
|
|
||||||
{
|
|
||||||
this.mobThrowerEntity = mobThrowerEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getMobThrowerSpeed()
|
|
||||||
{
|
|
||||||
return mobThrowerSpeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMobThrowerSpeed(double mobThrowerSpeed)
|
|
||||||
{
|
|
||||||
this.mobThrowerSpeed = mobThrowerSpeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<LivingEntity> getMobThrowerQueue()
|
|
||||||
{
|
|
||||||
return mobThrowerQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BukkitTask getMp44ScheduleTask()
|
|
||||||
{
|
|
||||||
return mp44ScheduleTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMp44ScheduleTask(BukkitTask mp44ScheduleTask)
|
|
||||||
{
|
|
||||||
this.mp44ScheduleTask = mp44ScheduleTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMp44Armed()
|
|
||||||
{
|
|
||||||
return mp44Armed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMp44Armed(boolean mp44Armed)
|
|
||||||
{
|
|
||||||
this.mp44Armed = mp44Armed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMp44Firing()
|
|
||||||
{
|
|
||||||
return mp44Firing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMp44Firing(boolean mp44Firing)
|
|
||||||
{
|
|
||||||
this.mp44Firing = mp44Firing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BukkitTask getLockupScheduleTask()
|
|
||||||
{
|
|
||||||
return lockupScheduleTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLockupScheduleTask(BukkitTask lockupScheduleTask)
|
|
||||||
{
|
|
||||||
this.lockupScheduleTask = lockupScheduleTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInAdminchat()
|
|
||||||
{
|
|
||||||
return inAdminchat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInAdminchat(boolean inAdminchat)
|
|
||||||
{
|
|
||||||
this.inAdminchat = inAdminchat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAllCommandsBlocked()
|
|
||||||
{
|
|
||||||
return allCommandsBlocked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAllCommandsBlocked(boolean allCommandsBlocked)
|
|
||||||
{
|
|
||||||
this.allCommandsBlocked = allCommandsBlocked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCmdspyEnabled()
|
|
||||||
{
|
|
||||||
return cmdspyEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCmdspyEnabled(boolean cmdspyEnabled)
|
|
||||||
{
|
|
||||||
this.cmdspyEnabled = cmdspyEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEditBlocked()
|
public boolean isEditBlocked()
|
||||||
{
|
{
|
||||||
return editBlocked;
|
return editBlocked;
|
||||||
|
@ -23,7 +23,7 @@ public class PlayerData
|
|||||||
private Boolean masterBuilder = false;
|
private Boolean masterBuilder = false;
|
||||||
|
|
||||||
|
|
||||||
private String rideMode = "ask";
|
private RideMode rideMode = RideMode.ASK;
|
||||||
|
|
||||||
|
|
||||||
private int coins;
|
private int coins;
|
||||||
@ -51,7 +51,7 @@ public class PlayerData
|
|||||||
tag = resultSet.getString("tag");
|
tag = resultSet.getString("tag");
|
||||||
discordID = resultSet.getString("discord_id");
|
discordID = resultSet.getString("discord_id");
|
||||||
masterBuilder = resultSet.getBoolean("master_builder");
|
masterBuilder = resultSet.getBoolean("master_builder");
|
||||||
rideMode = resultSet.getString("ride_mode");
|
rideMode = RideMode.valueOf(resultSet.getString("ride_mode").toUpperCase());
|
||||||
coins = resultSet.getInt("coins");
|
coins = resultSet.getInt("coins");
|
||||||
items.clear();
|
items.clear();
|
||||||
items.addAll(FUtil.stringToList(resultSet.getString("items")));
|
items.addAll(FUtil.stringToList(resultSet.getString("items")));
|
||||||
@ -82,7 +82,7 @@ public class PlayerData
|
|||||||
"- Total Votes: " + totalVotes + "\n" +
|
"- Total Votes: " + totalVotes + "\n" +
|
||||||
"- Display Discord: " + displayDiscord + "\n" +
|
"- Display Discord: " + displayDiscord + "\n" +
|
||||||
"- Tag: " + FUtil.colorize(tag) + ChatColor.GRAY + "\n" +
|
"- Tag: " + FUtil.colorize(tag) + ChatColor.GRAY + "\n" +
|
||||||
"- Ride Mode: " + rideMode + "\n" +
|
"- Ride Mode: " + rideMode.name() + "\n" +
|
||||||
"- Login Message: " + loginMessage;
|
"- Login Message: " + loginMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ public class PlayerData
|
|||||||
put("tag", tag);
|
put("tag", tag);
|
||||||
put("discord_id", discordID);
|
put("discord_id", discordID);
|
||||||
put("master_builder", masterBuilder);
|
put("master_builder", masterBuilder);
|
||||||
put("ride_mode", rideMode);
|
put("ride_mode", rideMode.name());
|
||||||
put("coins", coins);
|
put("coins", coins);
|
||||||
put("items", FUtil.listToString(items));
|
put("items", FUtil.listToString(items));
|
||||||
put("total_votes", totalVotes);
|
put("total_votes", totalVotes);
|
||||||
@ -249,12 +249,12 @@ public class PlayerData
|
|||||||
this.masterBuilder = masterBuilder;
|
this.masterBuilder = masterBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRideMode()
|
public RideMode getRideMode()
|
||||||
{
|
{
|
||||||
return rideMode;
|
return rideMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRideMode(String rideMode)
|
public void setRideMode(RideMode rideMode)
|
||||||
{
|
{
|
||||||
this.rideMode = rideMode;
|
this.rideMode = rideMode;
|
||||||
}
|
}
|
||||||
@ -308,4 +308,11 @@ public class PlayerData
|
|||||||
{
|
{
|
||||||
this.inspect = inspect;
|
this.inspect = inspect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum RideMode
|
||||||
|
{
|
||||||
|
ASK,
|
||||||
|
NORMAL,
|
||||||
|
OFF
|
||||||
|
}
|
||||||
}
|
}
|
@ -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
|
||||||
|
@ -21,6 +21,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@ -411,6 +412,25 @@ public class Shop extends FreedomService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerChat(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
String message = event.getMessage();
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean()
|
||||||
|
&& !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
PlayerData data = plugin.pl.getData(player);
|
||||||
|
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
||||||
|
plugin.pl.save(data);
|
||||||
|
plugin.sh.endReaction(player.getName());
|
||||||
|
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD
|
||||||
|
+ plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ShopItem getShopItem(int slot)
|
public ShopItem getShopItem(int slot)
|
||||||
{
|
{
|
||||||
for (ShopItem shopItem : ShopItem.values())
|
for (ShopItem shopItem : ShopItem.values())
|
||||||
|
@ -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)
|
||||||
@ -249,7 +248,7 @@ public class SQLite extends FreedomService
|
|||||||
statement.setString(4, player.getTag());
|
statement.setString(4, player.getTag());
|
||||||
statement.setString(5, player.getDiscordID());
|
statement.setString(5, player.getDiscordID());
|
||||||
statement.setBoolean(6, player.isMasterBuilder());
|
statement.setBoolean(6, player.isMasterBuilder());
|
||||||
statement.setString(7, player.getRideMode());
|
statement.setString(7, player.getRideMode().name());
|
||||||
statement.setInt(8, player.getCoins());
|
statement.setInt(8, player.getCoins());
|
||||||
statement.setString(9, FUtil.listToString(player.getItems()));
|
statement.setString(9, FUtil.listToString(player.getItems()));
|
||||||
statement.setInt(10, player.getTotalVotes());
|
statement.setInt(10, player.getTotalVotes());
|
||||||
|
@ -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
|
||||||
@ -606,160 +593,10 @@ first_join_info:
|
|||||||
- "&eThe server's name doesn't mean we have no rules. Do &6/rules &efor a list of them."
|
- "&eThe server's name doesn't mean we have no rules. Do &6/rules &efor a list of them."
|
||||||
- "&aNeed help getting started? Do &2/help &aor a list of commands!"
|
- "&aNeed help getting started? Do &2/help &aor a list of commands!"
|
||||||
|
|
||||||
# Famous players - cannot be banned by username
|
|
||||||
famous_players:
|
|
||||||
- honeydew
|
|
||||||
- xephos
|
|
||||||
- captainsparklez
|
|
||||||
- truemu
|
|
||||||
- kiershar
|
|
||||||
- fvdisco
|
|
||||||
- sethbling
|
|
||||||
- gamechap
|
|
||||||
- bertiechap
|
|
||||||
- vechs
|
|
||||||
- antvenom
|
|
||||||
- chimneyswift
|
|
||||||
- deadmau5
|
|
||||||
- etho
|
|
||||||
- ethoslab
|
|
||||||
- skydoesminecraft
|
|
||||||
- skythekidrs
|
|
||||||
- tobyturner
|
|
||||||
- xxslyfoxhoundxx
|
|
||||||
- paulsoaresjr
|
|
||||||
- sips_
|
|
||||||
- deadlox
|
|
||||||
- xxslyxx
|
|
||||||
- jeromeasf
|
|
||||||
- grum
|
|
||||||
- evilseph
|
|
||||||
- cavemanfilms
|
|
||||||
- herobrine
|
|
||||||
- whiteboy7thst
|
|
||||||
- stampylonghead
|
|
||||||
- stampylongnose
|
|
||||||
- dantdm
|
|
||||||
- gizzy14gazza
|
|
||||||
- furiousdestroyer
|
|
||||||
- pewdie
|
|
||||||
- thecampingrusher
|
|
||||||
- logdotzip
|
|
||||||
- ssundee
|
|
||||||
- mrcrainer
|
|
||||||
- achileis
|
|
||||||
- donibobes
|
|
||||||
- itsjerry
|
|
||||||
- itsharry
|
|
||||||
- bebopvox
|
|
||||||
- clankstar
|
|
||||||
- jollyajax
|
|
||||||
- b0xx3r
|
|
||||||
- vareide
|
|
||||||
- defek7
|
|
||||||
- strutt20
|
|
||||||
- appleg
|
|
||||||
- sterling_
|
|
||||||
- hypixel
|
|
||||||
- huskymudkipz
|
|
||||||
- setosorcerer
|
|
||||||
- slamacow
|
|
||||||
- mrcrayfish
|
|
||||||
- zexyzek
|
|
||||||
- synhd
|
|
||||||
- syndicate
|
|
||||||
- bajancanadian
|
|
||||||
- actennisac
|
|
||||||
- bodil40
|
|
||||||
- trumu
|
|
||||||
- huskymudkipz
|
|
||||||
- dantdm
|
|
||||||
- skeppy
|
|
||||||
- badboyhalo
|
|
||||||
# Mojang staff below this line
|
|
||||||
- aeplh
|
|
||||||
- amir343
|
|
||||||
- angryem
|
|
||||||
- ashrafi
|
|
||||||
- binni
|
|
||||||
- blurpi
|
|
||||||
- bopogamel
|
|
||||||
- boq
|
|
||||||
- c418
|
|
||||||
- carlmanneh
|
|
||||||
- carnalizer
|
|
||||||
- carramel
|
|
||||||
- darngeek
|
|
||||||
- dinnerbone
|
|
||||||
- eldrone
|
|
||||||
- elevenen
|
|
||||||
- el_hefe_
|
|
||||||
- engst
|
|
||||||
- excitedze
|
|
||||||
- frukthamster
|
|
||||||
- fry_
|
|
||||||
- grumm
|
|
||||||
- hampus
|
|
||||||
- helloiammarsh
|
|
||||||
- hey
|
|
||||||
- hoodad
|
|
||||||
- ianna_na_na
|
|
||||||
- jeb_
|
|
||||||
- jonkagstrom
|
|
||||||
- kappe
|
|
||||||
- klumpig
|
|
||||||
- krisjelbring
|
|
||||||
- ladyagnes
|
|
||||||
- lisa
|
|
||||||
- mahuldur
|
|
||||||
- mansolson
|
|
||||||
- marc
|
|
||||||
- marc_irl
|
|
||||||
- masseffect
|
|
||||||
- midnightenforcer
|
|
||||||
- minecraftchick
|
|
||||||
- modhelius
|
|
||||||
- moesh
|
|
||||||
- mojangjonas
|
|
||||||
- mojangsta
|
|
||||||
- mollstam
|
|
||||||
- neonmaster
|
|
||||||
- olle
|
|
||||||
- olofcarlson
|
|
||||||
- phreakholm
|
|
||||||
- poipoichen
|
|
||||||
- pretto
|
|
||||||
- profmobius
|
|
||||||
- razzleberryfox
|
|
||||||
- searge
|
|
||||||
- searge_dp
|
|
||||||
- shoghicp
|
|
||||||
- slicedlime
|
|
||||||
- sockerpappan
|
|
||||||
- themogminer
|
|
||||||
- theopard
|
|
||||||
- theputtman
|
|
||||||
- tom__m
|
|
||||||
- vaktis
|
|
||||||
- volgar
|
|
||||||
- vubui
|
|
||||||
- xlson
|
|
||||||
- xsson
|
|
||||||
- yoloswag4lyfe
|
|
||||||
- zeeraw
|
|
||||||
- _alcatras
|
|
||||||
- _tommo_
|
|
||||||
- ____fox____
|
|
||||||
|
|
||||||
# Pet Protect - Prevent tamed pets from being killed.
|
# Pet Protect - Prevent tamed pets from being killed.
|
||||||
petprotect:
|
petprotect:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
# Logviewer
|
|
||||||
logs:
|
|
||||||
url: ''
|
|
||||||
secret: ''
|
|
||||||
|
|
||||||
# Mojang service checker
|
# Mojang service checker
|
||||||
service_checker_url: http://status.mojang.com/check
|
service_checker_url: http://status.mojang.com/check
|
||||||
|
|
||||||
|
@ -10,8 +10,12 @@ softdepend:
|
|||||||
- WorldEdit
|
- WorldEdit
|
||||||
- WorldGuard
|
- WorldGuard
|
||||||
- WorldGuardExtraFlags
|
- WorldGuardExtraFlags
|
||||||
- TFGuilds
|
|
||||||
- JDA
|
- JDA
|
||||||
- Votifier
|
- Votifier
|
||||||
authors: [Madgeek1450, Prozza]
|
authors: [Madgeek1450, Prozza]
|
||||||
api-version: "1.17"
|
api-version: "1.17"
|
||||||
|
libraries:
|
||||||
|
- org.apache.commons:commons-lang3:3.12.0
|
||||||
|
- commons-io:commons-io:2.11.0
|
||||||
|
- org.jetbrains:annotations:23.0.0
|
||||||
|
- org.javassist:javassist:3.29.1-GA
|
Loading…
Reference in New Issue
Block a user