mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
LuckPerms Integration (2/2)
This commit is contained in:
parent
cc244fc4f7
commit
8a58782d99
@ -614,7 +614,7 @@ public class FrontDoor extends FreedomService
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
plugin.pl.getPlayer(player).setTag("[" + ChatColor.BLUE + "Total" + ChatColor.GOLD + "Freedom" + ChatColor.WHITE + "]");
|
||||
plugin.pl.getPlayer(player).setTag(FUtil.miniMessage("[" + ChatColor.BLUE + "Total" + ChatColor.GOLD + "Freedom" + ChatColor.WHITE + "]"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import me.totalfreedom.totalfreedommod.util.FConverter;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -245,10 +246,10 @@ public class LoginProcess extends FreedomService
|
||||
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
String tag = playerData.getTag();
|
||||
Component tag = playerData.getTag();
|
||||
if (tag != null)
|
||||
{
|
||||
fPlayer.setTag(FUtil.colorize(tag));
|
||||
fPlayer.setTag(tag);
|
||||
}
|
||||
|
||||
int noteCount = playerData.getNotes().size();
|
||||
|
@ -15,8 +15,6 @@ import me.totalfreedom.totalfreedommod.config.MainConfig;
|
||||
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
||||
import me.totalfreedom.totalfreedommod.fun.*;
|
||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||
@ -49,7 +47,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
private static TotalFreedomMod plugin;
|
||||
//
|
||||
public MainConfig config;
|
||||
public PermissionConfig permissions;
|
||||
//
|
||||
// Service Handler
|
||||
public FreedomServiceHandler fsh;
|
||||
@ -78,7 +75,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public PunishmentList pul;
|
||||
public BanManager bm;
|
||||
public IndefiniteBanList im;
|
||||
public PermissionManager pem;
|
||||
public GameRuleHandler gr;
|
||||
public CommandSpy cs;
|
||||
public Cager ca;
|
||||
@ -171,9 +167,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
BackupManager backups = new BackupManager();
|
||||
backups.createAllBackups();
|
||||
|
||||
permissions = new PermissionConfig();
|
||||
permissions.load();
|
||||
|
||||
mv = new MovementValidator();
|
||||
sp = new ServerPing();
|
||||
|
||||
@ -305,7 +298,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
pul = new PunishmentList();
|
||||
bm = new BanManager();
|
||||
im = new IndefiniteBanList();
|
||||
pem = new PermissionManager();
|
||||
gr = new GameRuleHandler();
|
||||
ew = new EntityWiper();
|
||||
vh = new VanishHandler();
|
||||
|
@ -2,20 +2,20 @@ package me.totalfreedom.totalfreedommod.admin;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AdminList extends FreedomService
|
||||
{
|
||||
@ -48,19 +48,9 @@ public class AdminList extends FreedomService
|
||||
ResultSet adminSet = plugin.sql.getAdminList();
|
||||
while (adminSet.next())
|
||||
{
|
||||
try
|
||||
{
|
||||
Admin admin = new Admin(adminSet);
|
||||
allAdmins.add(admin);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
FLog.warning("An error occurred whilst reading the admin entry at row #" + adminSet.getRow());
|
||||
FLog.warning(ex);
|
||||
}
|
||||
tryAddAdmin(adminSet);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
} catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to load admin list: " + e.getMessage());
|
||||
}
|
||||
@ -69,22 +59,24 @@ public class AdminList extends FreedomService
|
||||
FLog.info("Loaded " + allAdmins.size() + " admins (" + uuidTable.size() + " active, " + ipTable.size() + " IPs)");
|
||||
}
|
||||
|
||||
private void tryAddAdmin(ResultSet adminSet) throws SQLException
|
||||
{
|
||||
try
|
||||
{
|
||||
Admin admin = new Admin(adminSet);
|
||||
allAdmins.add(admin);
|
||||
} catch (Throwable ex)
|
||||
{
|
||||
FLog.warning("An error occurred whilst reading the admin entry at row #" + adminSet.getRow());
|
||||
FLog.warning(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void messageAllAdmins(Component message)
|
||||
{
|
||||
server.getOnlinePlayers().stream().filter(this::isAdmin).forEach(player -> player.sendMessage(message));
|
||||
}
|
||||
|
||||
public void messageAllAdmins(String message)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (isAdmin(player))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void potionSpyMessage(String message)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
@ -109,12 +101,18 @@ public class AdminList extends FreedomService
|
||||
return true;
|
||||
}
|
||||
|
||||
Admin admin = getAdmin((Player)sender);
|
||||
Admin admin = getAdmin((Player) sender);
|
||||
|
||||
return admin != null && admin.isActive();
|
||||
}
|
||||
|
||||
// Cast to OfflinePlayer
|
||||
public boolean isAdmin(Player player)
|
||||
{
|
||||
return isAdmin((OfflinePlayer) player);
|
||||
}
|
||||
|
||||
public boolean isAdmin(OfflinePlayer player)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
@ -141,25 +139,17 @@ public class AdminList extends FreedomService
|
||||
|
||||
public Admin getAdmin(CommandSender sender)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player player)
|
||||
{
|
||||
return getAdmin((Player)sender);
|
||||
return getAdmin(player);
|
||||
}
|
||||
|
||||
return getEntryByName(sender.getName());
|
||||
}
|
||||
|
||||
public Admin getAdmin(Player player)
|
||||
public Admin getAdmin(OfflinePlayer player)
|
||||
{
|
||||
final String ip = FUtil.getIp(player);
|
||||
final Admin entry = getEntryByUuid(player.getUniqueId());
|
||||
|
||||
if (entry != null && !entry.getIps().contains(ip))
|
||||
{
|
||||
entry.addIp(ip);
|
||||
}
|
||||
|
||||
return entry;
|
||||
return getEntryByUuid(player.getUniqueId());
|
||||
}
|
||||
|
||||
public Admin getEntryByUuid(UUID uuid)
|
||||
@ -177,6 +167,12 @@ public class AdminList extends FreedomService
|
||||
return ipTable.get(ip);
|
||||
}
|
||||
|
||||
// To cast against OfflinePlayer
|
||||
public Admin getAdmin(Player player)
|
||||
{
|
||||
return getAdmin((OfflinePlayer) player);
|
||||
}
|
||||
|
||||
public void updateLastLogin(Player player)
|
||||
{
|
||||
final Admin admin = getAdmin(player);
|
||||
@ -189,12 +185,12 @@ public class AdminList extends FreedomService
|
||||
save(admin);
|
||||
}
|
||||
|
||||
public boolean addAdmin(Admin admin)
|
||||
public void addAdmin(Admin admin)
|
||||
{
|
||||
if (!admin.isValid())
|
||||
{
|
||||
FLog.warning("Could not add admin: " + admin.getName() + ". Admin is missing details!");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Store admin, update views
|
||||
@ -203,18 +199,13 @@ public class AdminList extends FreedomService
|
||||
|
||||
// Save admin
|
||||
plugin.sql.addAdmin(admin);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeAdmin(Admin admin)
|
||||
{
|
||||
if (admin.getRank().isAtLeast(Rank.ADMIN))
|
||||
if (admin.getRank().isAtLeast(GroupProvider.ADMIN.getGroup()) && (plugin.btb != null))
|
||||
{
|
||||
if (plugin.btb != null)
|
||||
{
|
||||
plugin.btb.killTelnetSessions(admin.getName());
|
||||
}
|
||||
plugin.btb.killTelnetSessions(admin.getName());
|
||||
}
|
||||
|
||||
// Remove admin, update views
|
||||
@ -275,13 +266,13 @@ public class AdminList extends FreedomService
|
||||
ResultSet currentSave = plugin.sql.getAdminByUuid(admin.getUuid());
|
||||
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
|
||||
{
|
||||
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue()); if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
|
||||
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
|
||||
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
|
||||
{
|
||||
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
} catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to save admin: " + e.getMessage());
|
||||
}
|
||||
@ -292,20 +283,20 @@ public class AdminList extends FreedomService
|
||||
allAdmins.stream()
|
||||
.filter(admin -> admin.isActive() && !admin.getRank().isAtLeast(GroupProvider.SENIOR_ADMIN.getGroup()))
|
||||
.forEach(admin ->
|
||||
{
|
||||
final Date lastLogin = admin.getLastLogin();
|
||||
final long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
|
||||
if (lastLoginHours < ConfigEntry.ADMINLIST_CLEAN_THESHOLD_HOURS.getInteger())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
FUtil.adminAction("TotalFreedomMod", "Deactivating admin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
||||
}
|
||||
admin.setActive(false);
|
||||
save(admin);
|
||||
});
|
||||
{
|
||||
final Date lastLogin = admin.getLastLogin();
|
||||
final long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
|
||||
if (lastLoginHours < ConfigEntry.ADMINLIST_CLEAN_THESHOLD_HOURS.getInteger())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
FUtil.adminAction("TotalFreedomMod", "Deactivating admin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
||||
}
|
||||
admin.setActive(false);
|
||||
save(admin);
|
||||
});
|
||||
|
||||
updateTables();
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.blocking.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public enum CommandBlockerRank
|
||||
@ -25,7 +25,7 @@ public enum CommandBlockerRank
|
||||
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(sender);
|
||||
if (admin != null)
|
||||
{
|
||||
if (admin.getRank() == Rank.SENIOR_ADMIN)
|
||||
if (admin.getRank() == GroupProvider.SENIOR_ADMIN.getGroup())
|
||||
{
|
||||
return SENIOR_ADMIN;
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.bukkittelnet.BukkitTelnet;
|
||||
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
||||
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
||||
@ -10,13 +7,18 @@ import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Deprecated
|
||||
public class BukkitTelnetBridge extends FreedomService
|
||||
{
|
||||
|
||||
@ -44,7 +46,7 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
|
||||
final Admin admin = plugin.al.getEntryByIp(ip);
|
||||
|
||||
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
|
||||
if (admin == null || !admin.isActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -80,8 +82,8 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
boolean active = admin.isActive();
|
||||
|
||||
isAdmin = active;
|
||||
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
|
||||
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.ADMIN);
|
||||
isSeniorAdmin = active && admin.getRank().equals(GroupProvider.SENIOR_ADMIN.getGroup());
|
||||
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank().equals(GroupProvider.ADMIN.getGroup()));
|
||||
}
|
||||
|
||||
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
||||
@ -106,10 +108,9 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
final Plugin bukkitTelnet = server.getPluginManager().getPlugin("BukkitTelnet");
|
||||
if (bukkitTelnet instanceof BukkitTelnet)
|
||||
{
|
||||
bukkitTelnetPlugin = (BukkitTelnet)bukkitTelnet;
|
||||
bukkitTelnetPlugin = (BukkitTelnet) bukkitTelnet;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
} catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
@ -159,8 +160,7 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
{
|
||||
telnet.appender.removeSession(session);
|
||||
session.syncTerminateSession();
|
||||
}
|
||||
catch (Exception ex)
|
||||
} catch (Exception ex)
|
||||
{
|
||||
FLog.severe("Error removing single telnet session: " + ex.getMessage());
|
||||
}
|
||||
@ -168,8 +168,7 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
|
||||
FLog.info(sessionsToRemove.size() + " telnet session(s) removed.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
} catch (Exception ex)
|
||||
{
|
||||
FLog.severe("Error removing telnet sessions: " + ex.getMessage());
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.DisplayableGroup;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
@ -156,9 +156,9 @@ public class EssentialsBridge extends FreedomService
|
||||
if (inventoryHolder instanceof HumanEntity)
|
||||
{
|
||||
Player invOwner = (Player)inventoryHolder;
|
||||
Rank recieverRank = plugin.rm.getRank(player);
|
||||
Rank playerRank = plugin.rm.getRank(invOwner);
|
||||
if (playerRank.ordinal() >= recieverRank.ordinal() || !invOwner.isOnline())
|
||||
DisplayableGroup recieverRank = plugin.rm.getRank(player);
|
||||
DisplayableGroup playerRank = plugin.rm.getRank(invOwner);
|
||||
if (playerRank.getWeight() >= recieverRank.getWeight() || !invOwner.isOnline())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
refreshPlayer = player;
|
||||
|
@ -3,9 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CommandPermissions
|
||||
{
|
||||
|
@ -29,24 +29,22 @@ public class Command_deop extends FreedomCommand
|
||||
|
||||
Player player = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
if (player == null || plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
msg(sender, PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.al.isVanished(player.getUniqueId()))
|
||||
User user = GroupProvider.getUser(player);
|
||||
if (user.getPrimaryGroup().equalsIgnoreCase(GroupProvider.NON_OP.getGroup().getLuckPermsGroup().getName()))
|
||||
{
|
||||
msgNew("<red>You cannot de-op <player>, as they are vanished.", Placeholder.unparsed("player", player.getName()));
|
||||
msgNew(sender, "<red><player> is already de-opped!", Placeholder.unparsed("<player>", player.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
User user = GroupProvider.getUser(player);
|
||||
user.setPrimaryGroup(GroupProvider.NON_OP.getGroup().getLuckPermsGroup().getName());
|
||||
msg(player, YOU_ARE_NOT_OP);
|
||||
plugin.rm.updateDisplay(player);
|
||||
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "De-opping " + player.getName(), false);
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(permission = "", source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandPermissions(permission = "deop.all", source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Deop everyone on the server.", usage = "/<command>")
|
||||
public class Command_deopall extends FreedomCommand
|
||||
{
|
||||
|
@ -3,7 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.util.FConverter;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
@ -20,7 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "myadmin", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Manage your admin entry.", usage = "/<command> [-o <admin name>] <clearips | clearip <ip> | convertacformat | setacformat <format> | clearacformat> | syncroles>")
|
||||
public class Command_myadmin extends FreedomCommand
|
||||
{
|
||||
@ -39,7 +39,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
// -o switch
|
||||
if (args[0].equals("-o"))
|
||||
{
|
||||
checkPermission(Rank.SENIOR_ADMIN);
|
||||
checkPermission("tfm.myadmin.other");
|
||||
init = playerSender;
|
||||
targetPlayer = getPlayer(args[1]);
|
||||
if (targetPlayer == null)
|
||||
@ -67,7 +67,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
|
||||
switch (args[0])
|
||||
{
|
||||
case "clearips":
|
||||
case "clearips" ->
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
@ -94,8 +94,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
msgNew(targetPlayer, "<ip> is now your only IP address.", Placeholder.unparsed("ip", String.valueOf(target.getIps().get(0))));
|
||||
return true;
|
||||
}
|
||||
|
||||
case "clearip":
|
||||
case "clearip" ->
|
||||
{
|
||||
if (args.length != 2)
|
||||
{
|
||||
@ -107,8 +106,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
if (init == null)
|
||||
{
|
||||
msgNew("<red>That IP is not registered to you.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msgNew("<red>That IP does not belong to that player.");
|
||||
}
|
||||
@ -120,8 +118,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
if (init == null)
|
||||
{
|
||||
msgNew("<red>You cannot remove your current IP.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msgNew("<red>You cannot remove that admin's current IP.");
|
||||
}
|
||||
@ -140,14 +137,12 @@ public class Command_myadmin extends FreedomCommand
|
||||
msgNew("Current IPs: <ips>", Placeholder.unparsed("ip", StringUtils.join(target.getIps(), ", ")));
|
||||
return true;
|
||||
}
|
||||
|
||||
case "convertacformat":
|
||||
case "convertacformat" ->
|
||||
{
|
||||
if (!FConverter.needsConversion(target.getAcFormat()))
|
||||
{
|
||||
msgNew("<red>That format does not need to be converted.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msgNew("<yellow>Converting format...");
|
||||
target.setAcFormat(FConverter.convertAdminChatFormat(target.getAcFormat()));
|
||||
@ -158,9 +153,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case "setacformat":
|
||||
case "setscformat":
|
||||
case "setacformat", "setscformat" ->
|
||||
{
|
||||
String format = StringUtils.join(args, " ", 1, args.length);
|
||||
if (FConverter.needsConversion(format))
|
||||
@ -175,14 +168,12 @@ public class Command_myadmin extends FreedomCommand
|
||||
msgNew("Set admin chat format to \"<format>\"", Placeholder.unparsed("format", format));
|
||||
msgNew("Example:");
|
||||
msgNew(format, Placeholder.unparsed("name", "ExampleAdmin"),
|
||||
Placeholder.unparsed("rank", Rank.ADMIN.getAbbr()),
|
||||
TagResolver.resolver("rankcolor", Tag.styling(lol -> lol.color(TextColor.color(Rank.ADMIN.getColor().getColor().getRGB())))),
|
||||
Placeholder.unparsed("rank", GroupProvider.ADMIN.getGroup().getAbbr()),
|
||||
TagResolver.resolver("rankcolor", Tag.styling(styler -> styler.color(TextColor.color(GroupProvider.ADMIN.getGroup().getColor().getColor().getRGB())))),
|
||||
Placeholder.unparsed("message", "The quick brown fox jumped over the lazy dog."));
|
||||
return true;
|
||||
}
|
||||
|
||||
case "clearacformat":
|
||||
case "clearscformat":
|
||||
case "clearacformat", "clearscformat" ->
|
||||
{
|
||||
target.setAcFormat(null);
|
||||
plugin.al.save(target);
|
||||
@ -190,8 +181,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
msgNew("Cleared admin chat format.");
|
||||
return true;
|
||||
}
|
||||
|
||||
case "syncroles":
|
||||
case "syncroles" ->
|
||||
{
|
||||
if (plugin.dc != null && plugin.dc.isEnabled())
|
||||
{
|
||||
@ -210,8 +200,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
if (synced)
|
||||
{
|
||||
msgNew("<green>Successfully synced your roles.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msgNew("<red>Failed to sync your roles, please check the console.");
|
||||
}
|
||||
@ -219,8 +208,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
default ->
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "myinfo", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Check your personal data", usage = "/<command>")
|
||||
public class Command_myinfo extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
msg(plugin.pl.getData(playerSender).toString());
|
||||
msgNew(sender, plugin.pl.getData(playerSender).toString());
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "nether", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to the Nether.", usage = "/<command>", aliases = "hell")
|
||||
public class Command_nether extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
@ -1,13 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -16,29 +9,40 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@CommandPermissions(permission = "nickclean", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Essentials Interface Command - Remove illegal chatcodes from nicknames of one or all players on server.", usage = "/<command> [player]", aliases = "nc")
|
||||
public class Command_nickclean extends FreedomCommand
|
||||
{
|
||||
private final Map<String, Color> colorCodes = new HashMap<String, Color>()
|
||||
{{
|
||||
put("&0", Color.BLACK);
|
||||
put("&1", Color.BLUE);
|
||||
put("&2", Color.GREEN);
|
||||
put("&3", Color.TEAL);
|
||||
put("&4", Color.MAROON);
|
||||
put("&5", Color.FUCHSIA);
|
||||
put("&6", Color.OLIVE);
|
||||
put("&7", Color.SILVER);
|
||||
put("&8", Color.GRAY);
|
||||
put("&9", Color.NAVY);
|
||||
put("&a", Color.LIME);
|
||||
put("&b", Color.AQUA);
|
||||
put("&c", Color.RED);
|
||||
put("&d", Color.PURPLE);
|
||||
put("&e", Color.YELLOW);
|
||||
put("&f", Color.WHITE);
|
||||
}};
|
||||
private static final Map<String, Color> colorCodes = populateHashMap();
|
||||
|
||||
private static Map<String, Color> populateHashMap()
|
||||
{
|
||||
Map<String, Color> colorCodes = new HashMap<>();
|
||||
colorCodes.put("&0", Color.BLACK);
|
||||
colorCodes.put("&1", Color.BLUE);
|
||||
colorCodes.put("&2", Color.GREEN);
|
||||
colorCodes.put("&3", Color.TEAL);
|
||||
colorCodes.put("&4", Color.MAROON);
|
||||
colorCodes.put("&5", Color.FUCHSIA);
|
||||
colorCodes.put("&6", Color.OLIVE);
|
||||
colorCodes.put("&7", Color.SILVER);
|
||||
colorCodes.put("&8", Color.GRAY);
|
||||
colorCodes.put("&9", Color.NAVY);
|
||||
colorCodes.put("&a", Color.LIME);
|
||||
colorCodes.put("&b", Color.AQUA);
|
||||
colorCodes.put("&c", Color.RED);
|
||||
colorCodes.put("&d", Color.PURPLE);
|
||||
colorCodes.put("&e", Color.YELLOW);
|
||||
colorCodes.put("&f", Color.WHITE);
|
||||
return colorCodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
@ -86,7 +90,7 @@ public class Command_nickclean extends FreedomCommand
|
||||
{
|
||||
hexColorSub = split.substring(0, 12);
|
||||
split = String.valueOf(split.charAt(12));
|
||||
String hexColorString = "#" + hexColorSub.replaceAll("§", "");
|
||||
String hexColorString = "#" + hexColorSub.replace("§", "");
|
||||
java.awt.Color hexColor = java.awt.Color.decode(hexColorString);
|
||||
|
||||
// Get a range of nearby colors that are alike to the color blocked.
|
||||
@ -126,8 +130,7 @@ public class Command_nickclean extends FreedomCommand
|
||||
newNick.append("§x").append(hexColorSub).append(split);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// Falls back on old code if hex isn't used.
|
||||
final Pattern REGEX = Pattern.compile(FUtil.colorize(ChatColor.COLOR_CHAR + "[" + StringUtils.join(ConfigEntry.BLOCKED_CHATCODES.getString().split(","), "") + "]"), Pattern.CASE_INSENSITIVE);
|
||||
|
@ -1,120 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "NickFilter: Prefix any command with this command to replace nicknames in that command with real names. Nicknames should be prefixed with a !.",
|
||||
usage = "/<command> <other_command> !<playernick>",
|
||||
aliases = "nf")
|
||||
public class Command_nickfilter extends FreedomCommand
|
||||
{
|
||||
|
||||
private static Player getPlayerByDisplayName(String needle)
|
||||
{
|
||||
needle = needle.toLowerCase().trim();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (player.getDisplayName().toLowerCase().trim().contains(needle))
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Player getPlayerByDisplayNameAlt(String needle)
|
||||
{
|
||||
needle = needle.toLowerCase().trim();
|
||||
|
||||
Integer minEditDistance = null;
|
||||
Player minEditMatch = null;
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
String haystack = player.getDisplayName().toLowerCase().trim();
|
||||
int editDistance = StringUtils.getLevenshteinDistance(needle, haystack.toLowerCase());
|
||||
if (minEditDistance == null || minEditDistance > editDistance)
|
||||
{
|
||||
minEditDistance = editDistance;
|
||||
minEditMatch = player;
|
||||
}
|
||||
}
|
||||
|
||||
return minEditMatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
boolean nickMatched = false;
|
||||
|
||||
final List<String> outputCommand = new ArrayList<>();
|
||||
|
||||
if (args.length >= 1)
|
||||
{
|
||||
for (String arg : args)
|
||||
{
|
||||
Player player = null;
|
||||
|
||||
Matcher matcher = Pattern.compile("^!(.+)$").matcher(arg);
|
||||
if (matcher.find())
|
||||
{
|
||||
String displayName = matcher.group(1);
|
||||
|
||||
player = getPlayerByDisplayName(displayName);
|
||||
|
||||
if (player == null || plugin.al.isVanished(player.getUniqueId()) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
player = getPlayerByDisplayNameAlt(displayName);
|
||||
|
||||
if (player == null || !plugin.al.isVanished(player.getUniqueId()) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
msg("Can't find player by nickname: " + displayName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
outputCommand.add(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
nickMatched = true;
|
||||
outputCommand.add(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!nickMatched)
|
||||
{
|
||||
msg("No nicknames replaced in command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String newCommand = StringUtils.join(outputCommand, " ");
|
||||
|
||||
if (plugin.cb.isCommandBlocked(newCommand, sender))
|
||||
{
|
||||
// CommandBlocker handles messages and broadcasts
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Sending command: \"" + newCommand + "\".");
|
||||
server.dispatchCommand(sender, newCommand);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.api.Interpolator;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -11,7 +10,9 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "nickgradient", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <hex> <hex> <nick>", aliases = "nickgr")
|
||||
public class Command_nickgradient extends FreedomCommand
|
||||
{
|
||||
@ -59,8 +60,7 @@ public class Command_nickgradient extends FreedomCommand
|
||||
{
|
||||
awt1 = FUtil.getRandomAWTColor();
|
||||
from = " (From: " + FUtil.getHexStringOfAWTColor(awt1) + ")";
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
awt1 = java.awt.Color.decode(args[0]);
|
||||
}
|
||||
@ -69,13 +69,11 @@ public class Command_nickgradient extends FreedomCommand
|
||||
{
|
||||
awt2 = FUtil.getRandomAWTColor();
|
||||
to = " (To: " + FUtil.getHexStringOfAWTColor(awt2) + ")";
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
awt2 = java.awt.Color.decode(args[1]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid hex values.");
|
||||
return true;
|
||||
|
@ -1,70 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.Arrays;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Essentials Interface Command - Randomize the colors of your nickname.", usage = "/<command> <<nick> | off>")
|
||||
public class Command_nicknyan extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
||||
{
|
||||
msgNew("<red>Essentials is not enabled on this server.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
plugin.esb.setNickname(sender.getName(), null);
|
||||
msgNew("<green>Nickname cleared.");
|
||||
return true;
|
||||
}
|
||||
|
||||
final String nickPlain = ChatColor.stripColor(FUtil.colorize(args[0].trim()));
|
||||
|
||||
if (!nickPlain.matches("^[a-zA-Z_0-9" + ChatColor.COLOR_CHAR + "]+$"))
|
||||
{
|
||||
msgNew("<red>That nickname contains invalid characters.");
|
||||
return true;
|
||||
}
|
||||
else if (nickPlain.length() < 3 || nickPlain.length() > 30)
|
||||
{
|
||||
msgNew("<red>Your nickname must be between 3 and 30 characters long.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (server.getOnlinePlayers().stream().anyMatch(player -> player != playerSender
|
||||
&& (player.getName().equalsIgnoreCase(nickPlain)
|
||||
|| ChatColor.stripColor(plugin.esb.getNickname(player.getName())).trim().equalsIgnoreCase(nickPlain))))
|
||||
{
|
||||
msgNew("<red>That nickname is already in use.");
|
||||
return true;
|
||||
}
|
||||
|
||||
final StringBuilder newNick = new StringBuilder();
|
||||
Arrays.stream(nickPlain.chars().toArray()).forEach(character -> newNick.append(FUtil.randomChatColor())
|
||||
.append(Character.toString(character)));
|
||||
|
||||
newNick.append(ChatColor.WHITE);
|
||||
|
||||
plugin.esb.setNickname(sender.getName(), newNick.toString());
|
||||
|
||||
msgNew("Your nickname is now: <new>", Placeholder.component("new", FUtil.colorizeAsComponent(newNick.toString())));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -9,7 +8,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "nickrainbow", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <nick>")
|
||||
public class Command_nickrainbow extends FreedomCommand
|
||||
{
|
||||
|
@ -1,10 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
@ -13,6 +9,10 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "notes", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage notes for a player", usage = "/<command> <name> <list | add <note> | remove <id> | clear>")
|
||||
public class Command_notes extends FreedomCommand
|
||||
@ -39,8 +39,7 @@ public class Command_notes extends FreedomCommand
|
||||
}
|
||||
|
||||
playerData = plugin.pl.getData(entry.getName());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
playerData = plugin.pl.getData(player);
|
||||
}
|
||||
@ -125,12 +124,10 @@ public class Command_notes extends FreedomCommand
|
||||
if (args.length == 1)
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
else if (args.length == 2)
|
||||
} else if (args.length == 2)
|
||||
{
|
||||
return Arrays.asList("list", "add", "remove", "clear");
|
||||
}
|
||||
else if (args.length > 2 && (args[1].equals("add")))
|
||||
} else if (args.length > 2 && (args[1].equals("add")))
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH, cooldown = 5)
|
||||
@CommandPermissions(permission = "op", source = SourceType.BOTH, cooldown = 5)
|
||||
@CommandParameters(description = "OP a player", usage = "/<command> <partialname>")
|
||||
public class Command_op extends FreedomCommand
|
||||
{
|
||||
@ -28,32 +28,27 @@ public class Command_op extends FreedomCommand
|
||||
silent = args[1].equalsIgnoreCase("-s");
|
||||
}
|
||||
|
||||
final String targetName = args[0].toLowerCase();
|
||||
Player player = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
List<String> matchedPlayerNames = new ArrayList<>();
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
if (player == null || plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
if ((player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|
||||
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName)) &&
|
||||
!player.isOp() && !plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
matchedPlayerNames.add(player.getName());
|
||||
player.setOp(true);
|
||||
msg(player, YOU_ARE_OP);
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
msg(sender, PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!matchedPlayerNames.isEmpty())
|
||||
User user = GroupProvider.getUser(player);
|
||||
if (user.getPrimaryGroup().equalsIgnoreCase(GroupProvider.OP.getGroup().getLuckPermsGroup().getName()))
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Opping " + StringUtils.join(matchedPlayerNames, ", "), false);
|
||||
}
|
||||
msgNew(sender, "<red><player> is already OP!", Placeholder.unparsed("<player>", player.getName()));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
user.setPrimaryGroup(GroupProvider.OP.getGroup().getLuckPermsGroup().getName());
|
||||
msg(player, YOU_ARE_OP);
|
||||
plugin.rm.updateDisplay(player);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
msgNew("Either the player is already opped, or the player could not be found.");
|
||||
FUtil.adminAction(sender.getName(), "Opping " + player.getName(), false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,32 +1,27 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH, cooldown = 30)
|
||||
@CommandPermissions(permission = "op.all", source = SourceType.BOTH, cooldown = 30)
|
||||
@CommandParameters(description = "OP everyone on the server.", usage = "/<command>")
|
||||
public class Command_opall extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
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", true);
|
||||
|
||||
server.getOnlinePlayers().forEach(player ->
|
||||
{
|
||||
if (!player.isOp())
|
||||
{
|
||||
player.setOp(true);
|
||||
msg(player, YOU_ARE_OP);
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.recalculatePermissions();
|
||||
}
|
||||
User user = GroupProvider.getUser(player);
|
||||
user.setPrimaryGroup(GroupProvider.OP.getGroup().getLuckPermsGroup().getName());
|
||||
msg(player, YOU_ARE_OP);
|
||||
plugin.rm.updateDisplay(player);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -1,60 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage operators", usage = "/<command> <count | purge>")
|
||||
public class Command_ops extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("count"))
|
||||
{
|
||||
int totalOps = server.getOperators().size();
|
||||
long onlineOps = server.getOnlinePlayers().stream().filter(player -> player.isOp()).count();
|
||||
|
||||
msgNew("Online OPs: <online>", Placeholder.unparsed("online", String.valueOf(onlineOps)));
|
||||
msgNew("Offline OPs: <offline>", Placeholder.unparsed("offline", String.valueOf(totalOps - onlineOps)));
|
||||
msgNew("Total OPs: <total>", Placeholder.unparsed("total", String.valueOf(totalOps)));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
{
|
||||
noPerms();
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Purging all operators", true);
|
||||
|
||||
server.getOperators().forEach(operator ->
|
||||
{
|
||||
operator.setOp(false);
|
||||
|
||||
if (operator.isOnline())
|
||||
{
|
||||
msg(Objects.requireNonNull(operator.getPlayer()), YOU_ARE_NOT_OP);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.GameMode;
|
||||
@ -12,7 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "orbit", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "POW!!! Right in the kisser! One of these days Alice, straight to the Moon - Sends the specified player into orbit.",
|
||||
usage = "/<command> <target> [<<power> | stop>]")
|
||||
public class Command_orbit extends FreedomCommand
|
||||
@ -50,8 +49,7 @@ public class Command_orbit extends FreedomCommand
|
||||
try
|
||||
{
|
||||
strength = Math.max(1.0, Math.min(150.0, Double.parseDouble(args[1])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msgNew("<red>" + ex.getMessage());
|
||||
return true;
|
||||
|
@ -1,51 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Check your permissions", usage = "/<command> [prefix | reload]")
|
||||
public class Command_permissions extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("reload") && plugin.al.isAdmin(sender))
|
||||
{
|
||||
plugin.permissions.load();
|
||||
plugin.pem.loadPermissionNodes();
|
||||
plugin.pem.updatePlayers();
|
||||
msg("Reloaded permissions");
|
||||
}
|
||||
else
|
||||
{
|
||||
String prefix = "";
|
||||
if (args.length > 0)
|
||||
{
|
||||
prefix = args[0];
|
||||
}
|
||||
checkPlayer();
|
||||
List<String> permissions = new ArrayList<>();
|
||||
for (PermissionAttachmentInfo attachmentInfo : playerSender.getEffectivePermissions())
|
||||
{
|
||||
if (attachmentInfo.getValue())
|
||||
{
|
||||
String permission = attachmentInfo.getPermission();
|
||||
if (!prefix.isEmpty() && !permission.startsWith(prefix))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
permissions.add(permission);
|
||||
}
|
||||
}
|
||||
msg(String.join(", ", permissions));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,13 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "plotworld", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to the PlotWorld.", usage = "/<command>", aliases = "pw")
|
||||
public class Command_plotworld extends FreedomCommand
|
||||
{
|
||||
@ -18,8 +17,7 @@ public class Command_plotworld extends FreedomCommand
|
||||
if (plotworld != null)
|
||||
{
|
||||
PaperLib.teleportAsync(playerSender, plotworld.getSpawnLocation());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msg("\"plotworld\" doesn't exist.");
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.*;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "plugincontrol", source = SourceType.BOTH)
|
||||
@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
|
||||
{
|
||||
@ -26,8 +27,8 @@ public class Command_plugincontrol extends FreedomCommand
|
||||
final PluginManager pm = server.getPluginManager();
|
||||
|
||||
/* 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. */
|
||||
* 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)
|
||||
{
|
||||
case 1 ->
|
||||
@ -68,8 +69,7 @@ public class Command_plugincontrol extends FreedomCommand
|
||||
if (pl.isEnabled())
|
||||
{
|
||||
msgNew("<green><plugin> is now enabled.", Placeholder.unparsed("plugin", pl.getName()));
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msgNew("<red>An error occurred whilst attempting to enable <plugin>", Placeholder.unparsed("plugin", pl.getName()));
|
||||
}
|
||||
@ -81,8 +81,7 @@ public class Command_plugincontrol extends FreedomCommand
|
||||
{
|
||||
msgNew("<red><plugin> is already disabled.", Placeholder.unparsed("plugin", pl.getName()));
|
||||
return true;
|
||||
}
|
||||
else if (UNTOUCHABLE_PLUGINS.contains(pl.getName()))
|
||||
} else if (UNTOUCHABLE_PLUGINS.contains(pl.getName()))
|
||||
{
|
||||
msgNew("<red><plugin> can't be disabled.", Placeholder.unparsed("plugin", pl.getName()));
|
||||
return true;
|
||||
@ -104,7 +103,8 @@ public class Command_plugincontrol extends FreedomCommand
|
||||
pm.disablePlugin(pl);
|
||||
pm.enablePlugin(pl);
|
||||
|
||||
msgNew("<green><plugin> has been reloaded.", Placeholder.unparsed("plugin", pl.getName()));;
|
||||
msgNew("<green><plugin> has been reloaded.", Placeholder.unparsed("plugin", pl.getName()));
|
||||
;
|
||||
return true;
|
||||
}
|
||||
default ->
|
||||
@ -112,8 +112,7 @@ public class Command_plugincontrol extends FreedomCommand
|
||||
// Do nothing. This is here to please Codacy.
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msgNew("<red>Plugin not found!");
|
||||
return true;
|
||||
@ -138,8 +137,7 @@ public class Command_plugincontrol extends FreedomCommand
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("enable", "disable", "reload", "list");
|
||||
}
|
||||
else if (args.length == 2 && !args[0].equalsIgnoreCase("list"))
|
||||
} else if (args.length == 2 && !args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
return Arrays.stream(server.getPluginManager().getPlugins()).map(Plugin::getName)
|
||||
.filter(pl -> !UNTOUCHABLE_PLUGINS.contains(pl)).toList();
|
||||
|
@ -1,10 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -13,7 +8,12 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "potion", source = SourceType.BOTH)
|
||||
@CommandParameters(
|
||||
description = "Manipulate your potion effects. Duration is measured in server ticks (~20 ticks per second).",
|
||||
usage = "/<command> <list | clearall | clear [target name] | add <type> <duration> <amplifier> [target name]>",
|
||||
@ -25,14 +25,13 @@ public class Command_potion extends FreedomCommand
|
||||
{
|
||||
switch (args.length)
|
||||
{
|
||||
case 1:
|
||||
case 1 ->
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
msg("Potion effect types: " + FUtil.listToString(Arrays.stream(PotionEffectType.values())
|
||||
.map(PotionEffectType::getName).toList()), ChatColor.AQUA);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("clearall"))
|
||||
} else if (args[0].equalsIgnoreCase("clearall"))
|
||||
{
|
||||
if (!(plugin.al.isAdmin(sender) || senderIsConsole))
|
||||
{
|
||||
@ -46,29 +45,18 @@ public class Command_potion extends FreedomCommand
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case 2:
|
||||
case 2 ->
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("clear"))
|
||||
{
|
||||
Player target = playerSender;
|
||||
if (args.length == 2)
|
||||
|
||||
if (!plugin.al.isAdmin(sender) && !args[1].equalsIgnoreCase(sender.getName()))
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender) && !args[1].equalsIgnoreCase(sender.getName()))
|
||||
{
|
||||
msg(ChatColor.RED + "Only admins can clear potion effects from other players.");
|
||||
return true;
|
||||
}
|
||||
target = getPlayer(args[1], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (senderIsConsole)
|
||||
{
|
||||
msg("You must specify a target player when using this command from the console.");
|
||||
return true;
|
||||
}
|
||||
msg(ChatColor.RED + "Only admins can clear potion effects from other players.");
|
||||
return true;
|
||||
}
|
||||
target = getPlayer(args[1], true);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
@ -84,11 +72,8 @@ public class Command_potion extends FreedomCommand
|
||||
msg("Cleared all active potion effects " + (!target.equals(playerSender) ? "from player "
|
||||
+ target.getName() + "." : "from yourself."), ChatColor.AQUA);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
case 4, 5 ->
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("add"))
|
||||
{
|
||||
@ -109,8 +94,7 @@ public class Command_potion extends FreedomCommand
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
if (senderIsConsole)
|
||||
{
|
||||
@ -130,8 +114,7 @@ public class Command_potion extends FreedomCommand
|
||||
try
|
||||
{
|
||||
duration = Math.min(Integer.parseInt(args[2]), 100000);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid duration: " + args[2], ChatColor.RED);
|
||||
return true;
|
||||
@ -141,8 +124,7 @@ public class Command_potion extends FreedomCommand
|
||||
try
|
||||
{
|
||||
amplifier = Math.min(Integer.parseInt(args[3]), 100000);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid potion amplifier: " + args[3], ChatColor.RED);
|
||||
return true;
|
||||
@ -155,9 +137,8 @@ public class Command_potion extends FreedomCommand
|
||||
+ ", Amplifier: " + new_effect.getAmplifier()
|
||||
+ (!target.equals(playerSender) ? " to player " + target.getName() + "." : " to yourself."), ChatColor.AQUA);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
default ->
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -187,8 +168,7 @@ public class Command_potion extends FreedomCommand
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("add"))
|
||||
} else if (args[0].equalsIgnoreCase("add"))
|
||||
{
|
||||
return Arrays.stream(PotionEffectType.values()).map(PotionEffectType::getName).toList();
|
||||
}
|
||||
|
@ -1,11 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -15,7 +10,12 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@CommandPermissions(permission = "potionspy", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Allows admins to see potions that are thrown.", usage = "/<command> <enable | on | disable | off> | history [player] <page>", aliases = "potspy")
|
||||
public class Command_potionspy extends FreedomCommand
|
||||
{
|
||||
@ -29,8 +29,7 @@ public class Command_potionspy extends FreedomCommand
|
||||
{
|
||||
setPotionSpyState(admin, !admin.getPotionSpy());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
String titleText = "&8&m------------------&r &ePotionSpy &8&m------------------&r";
|
||||
String validPageText = "Please specify a valid page number between 1 and %s.";
|
||||
@ -39,17 +38,10 @@ public class Command_potionspy extends FreedomCommand
|
||||
String bottomText = "&8&m--------------------&r &e%s / %s &8&m--------------------&r";
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
case "enable":
|
||||
case "on":
|
||||
setPotionSpyState(admin, true);
|
||||
break;
|
||||
|
||||
case "disable":
|
||||
case "off":
|
||||
setPotionSpyState(admin, false);
|
||||
break;
|
||||
|
||||
case "history":
|
||||
case "enable", "on" -> setPotionSpyState(admin, true);
|
||||
case "disable", "off" -> setPotionSpyState(admin, false);
|
||||
case "history" ->
|
||||
{
|
||||
if (args.length == 3)
|
||||
{
|
||||
Player player = Bukkit.getPlayer(args[1]);
|
||||
@ -62,7 +54,7 @@ public class Command_potionspy extends FreedomCommand
|
||||
List<Map.Entry<ThrownPotion, Long>> thrownPotions = new ArrayList<>(plugin.mo.getPlayerThrownPotions(player)); // Make a copy of the list to avoid modifying the original.
|
||||
|
||||
List<String> potionThrowNotifications = new ArrayList<>();
|
||||
int lastPage = (int)Math.ceil(thrownPotions.size() / 5.0);
|
||||
int lastPage = (int) Math.ceil(thrownPotions.size() / 5.0);
|
||||
|
||||
if (thrownPotions.isEmpty())
|
||||
{
|
||||
@ -95,30 +87,27 @@ public class Command_potionspy extends FreedomCommand
|
||||
{
|
||||
msg(sender, potionThrowNotification);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msg(sender, String.format(validPageText, lastPage));
|
||||
return true;
|
||||
}
|
||||
|
||||
msg(sender, ChatColor.translateAlternateColorCodes('&', String.format(bottomText, pageIndex, lastPage)));
|
||||
}
|
||||
else if (args.length == 2)
|
||||
} else if (args.length == 2)
|
||||
{
|
||||
List<Map.Entry<ThrownPotion, Long>> thrownPotions = new ArrayList<>();
|
||||
thrownPotions.addAll(plugin.mo.getAllThrownPotions()); // Make a copy of the list to avoid modifying the original.
|
||||
|
||||
List<String> potionThrowNotifications = new ArrayList<>();
|
||||
int lastPage = (int)Math.ceil(thrownPotions.size() / 5.0);
|
||||
int lastPage = (int) Math.ceil(thrownPotions.size() / 5.0);
|
||||
|
||||
if (thrownPotions.isEmpty())
|
||||
{
|
||||
if (Bukkit.getPlayer(args[1]) != null)
|
||||
{
|
||||
msg(sender, noPlayerRecord);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msg(sender, "No potions have been thrown yet.");
|
||||
}
|
||||
@ -136,7 +125,7 @@ public class Command_potionspy extends FreedomCommand
|
||||
for (Map.Entry<ThrownPotion, Long> potionEntry : thrownPotions)
|
||||
{
|
||||
ThrownPotion potion = potionEntry.getKey();
|
||||
Player player = (Player)potion.getShooter();
|
||||
Player player = (Player) potion.getShooter();
|
||||
boolean trollPotions = plugin.mo.isTrollPotion(potion);
|
||||
|
||||
if (player != null)
|
||||
@ -154,22 +143,22 @@ public class Command_potionspy extends FreedomCommand
|
||||
{
|
||||
msg(sender, potionThrowNotification);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msg(sender, String.format(validPageText, lastPage));
|
||||
return true;
|
||||
}
|
||||
|
||||
msg(sender, ChatColor.translateAlternateColorCodes('&', String.format(bottomText, pageIndex, lastPage)));
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default ->
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -197,22 +186,19 @@ public class Command_potionspy extends FreedomCommand
|
||||
if (seconds < 60)
|
||||
{
|
||||
return seconds + "s";
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
long minutes = Math.round(seconds / 60.0);
|
||||
if (minutes < 60)
|
||||
{
|
||||
return minutes + "m";
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
long hours = Math.round(minutes / 60.0);
|
||||
if (hours < 24)
|
||||
{
|
||||
return hours + "h";
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
return Math.round(hours / 24.0) + "d";
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@ -11,7 +10,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "purgeall", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Purge current mutes, command blocks, orbits, freezes, potion effects, cages, and entities.", usage = "/<command>")
|
||||
public class Command_purgeall extends FreedomCommand
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.DisplayableGroup;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "rank", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Show the rank of the sender or a specified user.", usage = "/<command> [player]")
|
||||
public class Command_rank extends FreedomCommand
|
||||
{
|
||||
@ -51,7 +51,7 @@ public class Command_rank extends FreedomCommand
|
||||
public String message(Player player)
|
||||
{
|
||||
Displayable display = plugin.rm.getDisplay(player);
|
||||
Rank rank = plugin.rm.getRank(player);
|
||||
DisplayableGroup rank = plugin.rm.getRank(player);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(ChatColor.AQUA)
|
||||
|
@ -1,13 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "rawsay", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Broadcasts the given message. Supports colors.", usage = "/<command> <message>")
|
||||
public class Command_rawsay extends FreedomCommand
|
||||
{
|
||||
|
@ -1,15 +1,14 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME, blockHostConsole = true)
|
||||
@CommandPermissions(permission = "report", source = SourceType.ONLY_IN_GAME, blockHostConsole = true)
|
||||
@CommandParameters(description = "Report a player for all admins to see.", usage = "/<command> <player> <reason>")
|
||||
public class Command_report extends FreedomCommand
|
||||
{
|
||||
@ -22,41 +21,31 @@ public class Command_report extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[0], true);
|
||||
OfflinePlayer offlinePlayer = getOfflinePlayer(args[0]);
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null && offlinePlayer == null)
|
||||
if (sender instanceof Player && (player.equals(playerSender)))
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
msgNew("<red>Please, don't try to report yourself.");
|
||||
return true;
|
||||
}
|
||||
else if (player != null)
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
if (player.equals(playerSender))
|
||||
{
|
||||
msgNew("<red>Please, don't try to report yourself.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
msgNew("<red>You can't report admins with this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
msgNew("<red>You can't report admins with this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String report = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
plugin.cm.reportAction(playerSender, (player == null) ? offlinePlayer.getName() : player.getName(), report);
|
||||
plugin.cm.reportAction(playerSender, player.getName(), report);
|
||||
|
||||
boolean logged = false;
|
||||
|
||||
if (plugin.dc != null && plugin.dc.isEnabled())
|
||||
{
|
||||
logged = (player == null) ? plugin.dc.sendReportOffline(playerSender, offlinePlayer, report) : plugin.dc.sendReport(playerSender, player, report);
|
||||
Player online = Bukkit.getPlayer(player.getUniqueId());
|
||||
logged = (online != null)
|
||||
? plugin.dc.sendReport(playerSender, online, report)
|
||||
: plugin.dc.sendReportOffline(playerSender, player, report);
|
||||
}
|
||||
|
||||
msgNew("<green>Thank you, your report has been successfully logged.");
|
||||
|
@ -1,20 +1,19 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@CommandPermissions(permission = "ride", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Ride on the top of the specified player.", usage = "/<command> <playername | mode <normal | off | ask>>")
|
||||
public class Command_ride extends FreedomCommand
|
||||
{
|
||||
@ -94,8 +93,7 @@ public class Command_ride extends FreedomCommand
|
||||
playerDataSender.setRideMode(mode);
|
||||
plugin.pl.save(playerDataSender);
|
||||
msgNew("Ride mode is now set to <mode>.", Placeholder.unparsed("mode", mode.name().toLowerCase()));
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
} catch (IllegalArgumentException ex)
|
||||
{
|
||||
msgNew("<red>Invalid mode.");
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "rideablepearl", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a rideable ender pearl", usage = "/<command>")
|
||||
public class Command_rideablepearl extends FreedomCommand
|
||||
{
|
||||
@ -25,8 +24,7 @@ public class Command_rideablepearl extends FreedomCommand
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getRideablePearl());
|
||||
msg("You have been given a Rideable Ender Pearl", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msg("You do not own a Rideable Ender Pearl! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import net.coreprotect.CoreProtectAPI;
|
||||
@ -18,7 +15,10 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "ro", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Remove all blocks of a certain type in the radius of certain players.", usage = "/<command> <block> [radius (default=50)] [player]")
|
||||
public class Command_ro extends FreedomCommand
|
||||
{
|
||||
@ -57,8 +57,7 @@ public class Command_ro extends FreedomCommand
|
||||
|
||||
block.setType(Material.AIR);
|
||||
affected++;
|
||||
}
|
||||
else if (block.getType().equals(material))
|
||||
} else if (block.getType().equals(material))
|
||||
{
|
||||
if (cpAPI != null)
|
||||
{
|
||||
@ -89,13 +88,11 @@ public class Command_ro extends FreedomCommand
|
||||
{
|
||||
materials.addAll(Groups.SHULKER_BOXES);
|
||||
names = "shulker boxes";
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("banners") || args[0].equalsIgnoreCase("banner"))
|
||||
} else if (args[0].equalsIgnoreCase("banners") || args[0].equalsIgnoreCase("banner"))
|
||||
{
|
||||
materials.addAll(Groups.BANNERS);
|
||||
names = "banners";
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
for (String materialName : StringUtils.split(args[0], ","))
|
||||
{
|
||||
@ -117,8 +114,7 @@ public class Command_ro extends FreedomCommand
|
||||
try
|
||||
{
|
||||
radius = Math.max(1, Math.min(50, Integer.parseInt(args[1])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid radius: " + args[1], ChatColor.RED);
|
||||
return true;
|
||||
@ -134,8 +130,7 @@ public class Command_ro extends FreedomCommand
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
targetPlayer = null;
|
||||
}
|
||||
@ -149,8 +144,7 @@ public class Command_ro extends FreedomCommand
|
||||
try
|
||||
{
|
||||
adminWorld = plugin.wm.adminworld.getWorld();
|
||||
}
|
||||
catch (Exception ignored)
|
||||
} catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
|
||||
@ -171,8 +165,7 @@ public class Command_ro extends FreedomCommand
|
||||
affected += removeBlocks(player.getLocation(), material, radius, sender.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
if (targetPlayer.getWorld() != adminWorld)
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -10,7 +9,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "rock", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "You have thrown a rock, but you have also summoned a meteor!", usage = "/<command>")
|
||||
public class Command_rock extends FreedomCommand
|
||||
{
|
||||
|
@ -1,15 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "say", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Broadcasts the given message as the server, includes sender name.", usage = "/<command> <message>")
|
||||
public class Command_say extends FreedomCommand
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
@ -8,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "scare", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sends a guardian particle effect with an enderman scream to the specified player.", usage = "/<command> <player>")
|
||||
public class Command_scare extends FreedomCommand
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
@ -14,7 +13,7 @@ import org.bukkit.generator.WorldInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "seed", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Get the seed of the world you are currently in.", usage = "/seed [world]")
|
||||
public class Command_seed extends FreedomCommand
|
||||
{
|
||||
@ -31,15 +30,13 @@ public class Command_seed extends FreedomCommand
|
||||
msg("That world could not be found", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// If the sender is a Player, use that world. Otherwise, use the overworld as a fallback.
|
||||
if (!senderIsConsole)
|
||||
{
|
||||
world = playerSender.getWorld();
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
world = server.getWorlds().get(0);
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "stats", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Check the status of the server, including opped players, admins, etc.", usage = "/<command>", aliases = "ss")
|
||||
public class Command_serverstats extends FreedomCommand
|
||||
{
|
||||
|
@ -1,13 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "compass", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Set your compass to the specified position.", usage = "/<command> <x> <y> <z>")
|
||||
public class Command_setcompass extends FreedomCommand
|
||||
{
|
||||
@ -25,8 +24,7 @@ public class Command_setcompass extends FreedomCommand
|
||||
Location location = new Location(playerSender.getWorld(), Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));
|
||||
playerSender.setCompassTarget(location);
|
||||
msg("Successfully set your compass coordinates to X: " + args[0] + ", Y: " + args[1] + ", Z: " + args[2] + ".", ChatColor.GREEN);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
} catch (NumberFormatException e)
|
||||
{
|
||||
msg("One or more of your coordinates are not a valid integer.", ChatColor.RED);
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "worldedit.limit", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sets everyone's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> [limit]", aliases = "setl,swl")
|
||||
public class Command_setlimit extends FreedomCommand
|
||||
{
|
||||
@ -27,8 +25,7 @@ public class Command_setlimit extends FreedomCommand
|
||||
try
|
||||
{
|
||||
amount = Math.max(-1, Math.min(plugin.web.getMaxLimit(), Integer.parseInt(args[0])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msgNew("<red>Invalid number: <number>", Placeholder.unparsed("number", args[0]));
|
||||
return true;
|
||||
|
@ -1,15 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "worldedit.limit.other", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sets a specific player's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> <player> [limit]", aliases = "setpl,spl")
|
||||
public class Command_setplayerlimit extends FreedomCommand
|
||||
{
|
||||
@ -37,19 +35,16 @@ public class Command_setplayerlimit extends FreedomCommand
|
||||
try
|
||||
{
|
||||
amount = Math.max(-1, Math.min(plugin.web.getMaxLimit(), Integer.parseInt(args[1])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msgNew("<red>Invalid number: <amount>", Placeholder.unparsed("amount", args[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
amount = plugin.web.getDefaultLimit();
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.Location;
|
||||
@ -8,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "setspawnworld", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Set the spawn point of the world you are in.", usage = "/<command>")
|
||||
public class Command_setspawnworld extends FreedomCommand
|
||||
{
|
||||
|
@ -1,12 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "shop", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Open the shop GUI", usage = "/<command>", aliases = "sh")
|
||||
public class Command_shop extends FreedomCommand
|
||||
{
|
||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -14,7 +13,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "smite", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-ci | -q]")
|
||||
public class Command_smite extends FreedomCommand
|
||||
{
|
||||
@ -30,8 +29,7 @@ public class Command_smite extends FreedomCommand
|
||||
FUtil.bcastMsg(" Reason: " + ChatColor.YELLOW + reason, ChatColor.RED);
|
||||
}
|
||||
FUtil.bcastMsg(" Smitten by: " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
sender.sendMessage("Smitten " + player.getName() + " quietly.");
|
||||
}
|
||||
@ -94,8 +92,7 @@ public class Command_smite extends FreedomCommand
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
}
|
||||
}
|
||||
else if (args[args.length - 1].equalsIgnoreCase("-ci"))
|
||||
} else if (args[args.length - 1].equalsIgnoreCase("-ci"))
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-ci"))
|
||||
{
|
||||
@ -106,8 +103,7 @@ public class Command_smite extends FreedomCommand
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
}
|
||||
|
@ -1,10 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -14,7 +10,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "spawnmob", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Spawns the specified entity.", usage = "/<command> <entitytype> [amount]", aliases = "spawnentity")
|
||||
public class Command_spawnmob extends FreedomCommand
|
||||
{
|
||||
@ -64,8 +63,7 @@ public class Command_spawnmob extends FreedomCommand
|
||||
try
|
||||
{
|
||||
amount = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException nfex)
|
||||
} catch (NumberFormatException nfex)
|
||||
{
|
||||
msg("Invalid amount: " + args[1], ChatColor.RED);
|
||||
return true;
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "spectate", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Quickly spectate someone.", usage = "/<command> <playername>", aliases = "spec")
|
||||
public class Command_spectate extends FreedomCommand
|
||||
{
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "spectate", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Quickly change your own gamemode to spectator, or define someone's username to change theirs.", usage = "/<command> <[partialname]>", aliases = "gmsp")
|
||||
public class Command_spectator extends FreedomCommand
|
||||
{
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "stackingpotato", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a stacking potato", usage = "/<command>")
|
||||
public class Command_stackingpotato extends FreedomCommand
|
||||
{
|
||||
@ -25,8 +23,7 @@ public class Command_stackingpotato extends FreedomCommand
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getStackingPotato());
|
||||
msgNew("<green>You have been given the <item>.", Placeholder.unparsed("item", ShopItem.STACKING_POTATO.getName()));
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msgNew("<red>You don't own the <item>! Purchase it from the shop.", Placeholder.unparsed("item", ShopItem.STACKING_POTATO.getName()));
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@CommandPermissions(permission = "stop", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Kicks everyone and stops the server.", usage = "/<command> [reason]")
|
||||
public class Command_stop extends FreedomCommand
|
||||
{
|
||||
@ -27,8 +26,7 @@ public class Command_stop extends FreedomCommand
|
||||
{
|
||||
shutdown(reason);
|
||||
return true;
|
||||
}
|
||||
else if (STOP_CONFIRM.containsKey(sender))
|
||||
} else if (STOP_CONFIRM.containsKey(sender))
|
||||
{
|
||||
shutdown(STOP_CONFIRM.get(sender));
|
||||
return true;
|
||||
|
@ -1,18 +1,16 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "stopsound", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Stops all sounds or a specified sound.", usage = "/<command> [sound]")
|
||||
public class Command_stopsound extends FreedomCommand
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.GameMode;
|
||||
@ -8,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "survival", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Quickly change your own gamemode to survival, or define someone's username to change theirs.", usage = "/<command> <[partialname] | -a>", aliases = "gms")
|
||||
public class Command_survival extends FreedomCommand
|
||||
{
|
||||
@ -29,7 +28,7 @@ public class Command_survival extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
checkPermission(Rank.ADMIN);
|
||||
checkPermission("tfm.survival.other");
|
||||
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
@ -15,7 +14,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "tag", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Allows you to set your own prefix.", usage = "/<command> [-ns] <set <tag..> | list | off | clear <player> | clearall>")
|
||||
public class Command_tag extends FreedomCommand
|
||||
{
|
||||
@ -89,8 +88,7 @@ public class Command_tag extends FreedomCommand
|
||||
if (senderIsConsole)
|
||||
{
|
||||
msg("\"/tag off\" can't be used from the console. Use \"/tag clear <player>\" or \"/tag clearall\" instead.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
plugin.pl.getPlayer(playerSender).setTag(null);
|
||||
|
||||
@ -109,8 +107,7 @@ public class Command_tag extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args.length >= 2)
|
||||
} else if (args.length >= 2)
|
||||
{
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
@ -154,8 +151,7 @@ public class Command_tag extends FreedomCommand
|
||||
if (FUtil.containsChatColor(inputTag))
|
||||
{
|
||||
tag = FUtil.colorizeAsComponent(inputTag.replace("&k", ""));
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
tag = FUtil.miniMessage(inputTag);
|
||||
}
|
||||
@ -166,26 +162,22 @@ public class Command_tag extends FreedomCommand
|
||||
{
|
||||
msgNew("<red>That tag is too long (Max is <max> characters).", Placeholder.unparsed("max", String.valueOf(tagLimit)));
|
||||
return true;
|
||||
}
|
||||
else if (!plugin.al.isAdmin(sender) && ConfigEntry.FORBIDDEN_WORDS.getStringList().stream().anyMatch(word -> steamrolled.toLowerCase().contains(word)))
|
||||
} else if (!plugin.al.isAdmin(sender) && ConfigEntry.FORBIDDEN_WORDS.getStringList().stream().anyMatch(word -> steamrolled.toLowerCase().contains(word)))
|
||||
{
|
||||
msgNew("<red>That tag contains a forbidden word.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
String flattened = FUtil.miniMessage(tag);
|
||||
|
||||
plugin.pl.getPlayer(playerSender).setTag(flattened);
|
||||
plugin.pl.getPlayer(playerSender).setTag(tag);
|
||||
|
||||
if (save)
|
||||
{
|
||||
save(playerSender, flattened);
|
||||
save(playerSender, tag);
|
||||
}
|
||||
|
||||
msgNew("Tag set to '<tag>' <saved>",
|
||||
Placeholder.component("tag", tag.hoverEvent(HoverEvent.showText(Component.translatable("chat.copy")))
|
||||
.clickEvent(ClickEvent.copyToClipboard(flattened))),
|
||||
.clickEvent(ClickEvent.copyToClipboard(FUtil.miniMessage(tag)))),
|
||||
Placeholder.unparsed("saved", save ? "(Saved)" : ""));
|
||||
}
|
||||
return true;
|
||||
@ -200,7 +192,7 @@ public class Command_tag extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
public void save(Player player, String tag)
|
||||
public void save(Player player, Component tag)
|
||||
{
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setTag(tag);
|
||||
|
@ -1,63 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Give yourself a prefix with random colors", usage = "/<command> <tag>", aliases = "tn")
|
||||
public class Command_tagnyan extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final StringBuilder tag = new StringBuilder();
|
||||
|
||||
for (char c : ChatColor.stripColor(FUtil.colorize(StringUtils.join(args, " "))).toCharArray())
|
||||
{
|
||||
tag.append(FUtil.randomChatColor()).append(c);
|
||||
}
|
||||
|
||||
String tagStr = tag.toString();
|
||||
|
||||
int tagLimit = (plugin.al.isAdmin(sender) ? 30 : 20);
|
||||
|
||||
final String rawTag = ChatColor.stripColor(tagStr).toLowerCase();
|
||||
|
||||
if (rawTag.length() > tagLimit)
|
||||
{
|
||||
msg("That tag is too long (Max is " + tagLimit + " characters).");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
{
|
||||
for (String word : ConfigEntry.FORBIDDEN_WORDS.getStringList())
|
||||
{
|
||||
if (rawTag.contains(word))
|
||||
{
|
||||
msg("That tag contains a forbidden word.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final FPlayer data = plugin.pl.getPlayer(playerSender);
|
||||
data.setTag(tagStr);
|
||||
|
||||
msg("Set tag to " + tag);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,15 +1,10 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -20,7 +15,11 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@CommandPermissions(permission = "tempban", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Temporarily ban someone.", usage = "/<command> [-q] <username> [duration] [reason]", aliases = "tban,noob")
|
||||
public class Command_tempban extends FreedomCommand
|
||||
{
|
||||
@ -69,15 +68,13 @@ public class Command_tempban extends FreedomCommand
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
username = entry.getName();
|
||||
ip = entry.getIps().get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
username = player.getName();
|
||||
ip = FUtil.getIp(player);
|
||||
@ -94,8 +91,7 @@ public class Command_tempban extends FreedomCommand
|
||||
try
|
||||
{
|
||||
expires = FUtil.parseDateOffset(args[1]);
|
||||
}
|
||||
catch (NumberFormatException error)
|
||||
} catch (NumberFormatException error)
|
||||
{
|
||||
msg("Invalid duration: " + args[1], ChatColor.RED);
|
||||
return true;
|
||||
@ -116,8 +112,7 @@ public class Command_tempban extends FreedomCommand
|
||||
if (player != null)
|
||||
{
|
||||
ban = Ban.forPlayer(player, sender, expires, reason);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ban = Ban.forPlayerName(username, sender, expires, reason);
|
||||
}
|
||||
@ -144,8 +139,7 @@ public class Command_tempban extends FreedomCommand
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), message.toString(), true);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msg("Quietly temporarily banned " + username + ".");
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.GameRuleHandler;
|
||||
import me.totalfreedom.totalfreedommod.LoginProcess;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "toggle", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggles TotalFreedomMod settings", usage = "/<command> [option] [value] [value]")
|
||||
public class Command_toggle extends FreedomCommand
|
||||
{
|
||||
@ -64,8 +64,7 @@ public class Command_toggle extends FreedomCommand
|
||||
try
|
||||
{
|
||||
ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msgNew("<red>The input provided is not a valid integer.");
|
||||
return true;
|
||||
@ -77,8 +76,7 @@ public class Command_toggle extends FreedomCommand
|
||||
try
|
||||
{
|
||||
ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msgNew("<red>The input provided is not a valid integer.");
|
||||
return true;
|
||||
@ -100,8 +98,7 @@ public class Command_toggle extends FreedomCommand
|
||||
try
|
||||
{
|
||||
ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msgNew("<red>The input provided is not a valid integer.");
|
||||
return true;
|
||||
|
@ -1,13 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "clownfish.toggle", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggle whether or not a player has the ability to use clownfish", usage = "/<command> <player>", aliases = "togglecf")
|
||||
public class Command_toggleclownfish extends FreedomCommand
|
||||
{
|
||||
|
@ -1,13 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "discord.toggle", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Toggle the display of Discord messages in-game.", usage = "/<command>", aliases = "tdiscord,tdisc")
|
||||
public class Command_togglediscord extends FreedomCommand
|
||||
{
|
||||
|
@ -1,12 +1,10 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "pickup.toggle", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Toggle item pickup.", usage = "/<command>")
|
||||
public class Command_togglepickup extends FreedomCommand
|
||||
{
|
||||
|
@ -1,9 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
@ -14,7 +12,9 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
import java.util.Objects;
|
||||
|
||||
@CommandPermissions(permission = "tossmob", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Throw a mob in the direction you are facing when you right click with a bone.",
|
||||
usage = "/<command> <mobtype [speed] | off | list>")
|
||||
public class Command_tossmob extends FreedomCommand
|
||||
@ -76,8 +76,7 @@ public class Command_tossmob extends FreedomCommand
|
||||
try
|
||||
{
|
||||
speed = Double.parseDouble(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msgNew("<red>Invalid speed: <speed>", Placeholder.unparsed("speed", args[1]));
|
||||
return true;
|
||||
@ -87,8 +86,7 @@ public class Command_tossmob extends FreedomCommand
|
||||
if (speed < 1.0)
|
||||
{
|
||||
speed = 1.0;
|
||||
}
|
||||
else if (speed > 5.0)
|
||||
} else if (speed > 5.0)
|
||||
{
|
||||
speed = 5.0;
|
||||
}
|
||||
|
@ -2,10 +2,8 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -13,7 +11,7 @@ import org.bukkit.entity.Player;
|
||||
/*
|
||||
* See https://github.com/TotalFreedom/License - This file may not be edited or removed.
|
||||
*/
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows information about TotalFreedomMod or reloads it", usage = "/<command> [reload]", aliases = "tfm")
|
||||
public class Command_totalfreedommod extends FreedomCommand
|
||||
{
|
||||
|
@ -1,23 +1,23 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "tprandom", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to a random location in the current world you are in", usage = "/<command>", aliases = "tpr,rtp")
|
||||
public class Command_tprandom extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
int x = FUtil.randomInteger(-50000, 50000);
|
||||
int z = FUtil.randomInteger(-50000, 50000);
|
||||
int maximumDistance = ConfigEntry.RANDOM_TELEPORT_MAX_DISTANCE.getInteger();
|
||||
int x = FUtil.randomInteger(-(maximumDistance), maximumDistance);
|
||||
int z = FUtil.randomInteger(-(maximumDistance), maximumDistance);
|
||||
int y = playerSender.getWorld().getHighestBlockYAt(x, z) + 1;
|
||||
Location location = new Location(playerSender.getLocation().getWorld(), x, y, z);
|
||||
PaperLib.teleportAsync(playerSender, location);
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(permission = "trail", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/<command>")
|
||||
public class Command_trail extends FreedomCommand
|
||||
{
|
||||
@ -24,7 +22,7 @@ public class Command_trail extends FreedomCommand
|
||||
|
||||
if (!plugin.pl.getData(playerSender).hasItem(ShopItem.RAINBOW_TRAIL))
|
||||
{
|
||||
msgNew("<red>You didn't purchase the ability to have a <item>! Purchase it from the shop.",Placeholder.unparsed("item", ShopItem.RAINBOW_TRAIL.getName()));
|
||||
msgNew("<red>You didn't purchase the ability to have a <item>! Purchase it from the shop.", Placeholder.unparsed("item", ShopItem.RAINBOW_TRAIL.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -32,8 +30,7 @@ public class Command_trail extends FreedomCommand
|
||||
{
|
||||
plugin.tr.remove(playerSender);
|
||||
msgNew("Trail disabled.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
plugin.tr.add(playerSender);
|
||||
msgNew("Trail enabled. Run this command again to disable it.");
|
||||
|
@ -2,14 +2,13 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(permission = "unban", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unbans the specified player.", usage = "/<command> <username> [-r]")
|
||||
public class Command_unban extends FreedomCommand
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
// TODO: Merge with /unban.
|
||||
@CommandPermissions(permission = "unbanip", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unbans the specified IP.", usage = "/<command> <ip> [-q]")
|
||||
public class Command_unbanip extends FreedomCommand
|
||||
|
@ -1,15 +1,14 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
// TODO: Merge with /unban.
|
||||
@CommandPermissions(permission = "unban.name", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unbans the specified name.", usage = "/<command> <name> [-q]")
|
||||
public class Command_unbanname extends FreedomCommand
|
||||
{
|
||||
@ -32,8 +31,7 @@ public class Command_unbanname extends FreedomCommand
|
||||
{
|
||||
msgNew("<red>The name <name> is not banned.", Placeholder.unparsed("name", name));
|
||||
return true;
|
||||
}
|
||||
else if (ban.hasIps())
|
||||
} else if (ban.hasIps())
|
||||
{
|
||||
msgNew("<red>This ban is not a name-only ban.");
|
||||
return true;
|
||||
|
@ -22,15 +22,8 @@ public class Command_vanish extends FreedomCommand
|
||||
{
|
||||
Displayable display = plugin.rm.getDisplay(playerSender);
|
||||
String displayName = display.getColor() + playerSender.getName();
|
||||
String tag = display.getColoredTag();
|
||||
boolean silent = false;
|
||||
if (args.length > 0)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("-s") || args[0].equalsIgnoreCase("-silent"))
|
||||
{
|
||||
silent = true;
|
||||
}
|
||||
}
|
||||
Component tag = display.getColoredTag();
|
||||
boolean silent = args.length > 0 && (args[0].equalsIgnoreCase("-s") || args[0].equalsIgnoreCase("-silent"));
|
||||
|
||||
if (plugin.al.isVanished(playerSender.getUniqueId()))
|
||||
{
|
||||
@ -53,7 +46,7 @@ public class Command_vanish extends FreedomCommand
|
||||
PlayerData playerData = plugin.pl.getData(playerSender);
|
||||
if (playerData.getTag() != null)
|
||||
{
|
||||
tag = FUtil.colorize(playerData.getTag());
|
||||
tag = playerData.getTag();
|
||||
}
|
||||
|
||||
plugin.pl.getData(playerSender).setTag(tag);
|
||||
|
@ -1,8 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -10,7 +7,9 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
import java.util.*;
|
||||
|
||||
@CommandPermissions(permission = "whitelist", source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage the whitelist.", usage = "/<command> <on | off | list | count | add <player> | remove <player> | addall | purge>")
|
||||
public class Command_whitelist extends FreedomCommand
|
||||
{
|
||||
@ -25,13 +24,22 @@ public class Command_whitelist extends FreedomCommand
|
||||
// list
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
if (server.getWhitelistedPlayers().isEmpty())
|
||||
List<String> whitelist = server.getWhitelistedPlayers()
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(player -> player.getName() == null
|
||||
? player.getUniqueId().toString()
|
||||
: player.getName())
|
||||
.toList();
|
||||
|
||||
if (whitelist.isEmpty())
|
||||
{
|
||||
msgNew("There are no whitelisted players.");
|
||||
return true;
|
||||
}
|
||||
msgNew("Whitelisted players: <players>", Placeholder.unparsed("players", FUtil.listToString(server.getWhitelistedPlayers().stream().map(player ->
|
||||
player.getName() != null ? player.getName() : player.getUniqueId().toString()).toList())));
|
||||
|
||||
msgNew("Whitelisted players: <players>", Placeholder.unparsed("players", FUtil.listToString(whitelist)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -47,8 +55,7 @@ public class Command_whitelist extends FreedomCommand
|
||||
if (player.isOnline())
|
||||
{
|
||||
onlineWPs++;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
offlineWPs++;
|
||||
}
|
||||
@ -62,7 +69,7 @@ public class Command_whitelist extends FreedomCommand
|
||||
}
|
||||
|
||||
// Commands below are restricted to admins
|
||||
checkPermission(Rank.ADMIN);
|
||||
checkPermission("tfm.whitelist.admin");
|
||||
|
||||
// on
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
@ -123,8 +130,7 @@ public class Command_whitelist extends FreedomCommand
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the whitelist", false);
|
||||
player.setWhitelisted(false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msgNew("That player is not whitelisted");
|
||||
}
|
||||
@ -151,7 +157,7 @@ public class Command_whitelist extends FreedomCommand
|
||||
|
||||
// Telnet only
|
||||
checkConsole();
|
||||
checkPermission(Rank.ADMIN);
|
||||
checkPermission("tfm.whitelist.purge");
|
||||
|
||||
// purge
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
@ -178,14 +184,12 @@ public class Command_whitelist extends FreedomCommand
|
||||
}
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
else if (args.length == 2 && plugin.al.isAdmin(sender))
|
||||
} else if (args.length == 2 && plugin.al.isAdmin(sender))
|
||||
{
|
||||
if (args[0].equals("add"))
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
else if (args[0].equals("remove"))
|
||||
} else if (args[0].equals("remove"))
|
||||
{
|
||||
return server.getWhitelistedPlayers().stream().map(OfflinePlayer::getName).filter(Objects::nonNull).toList();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.earth2me.essentials.commands.PlayerNotFoundException;
|
||||
import com.google.common.collect.Lists;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
@ -19,6 +20,7 @@ import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -255,14 +257,15 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
return player;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected OfflinePlayer getOfflinePlayer(String name)
|
||||
@NotNull
|
||||
@Contract("null -> fail")
|
||||
protected OfflinePlayer getOfflinePlayer(String name) throws PlayerNotFoundException
|
||||
{
|
||||
return Arrays.stream(Bukkit.getOfflinePlayers())
|
||||
.filter(player -> player.getName() != null)
|
||||
.filter(player -> player.getName().equalsIgnoreCase(name))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
.orElseThrow(PlayerNotFoundException::new);
|
||||
}
|
||||
|
||||
protected Admin getAdmin(CommandSender sender)
|
||||
|
@ -1,8 +1,9 @@
|
||||
package me.totalfreedom.totalfreedommod.config;
|
||||
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public enum ConfigEntry
|
||||
{
|
||||
@ -164,7 +165,8 @@ public enum ConfigEntry
|
||||
AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"),
|
||||
TOGGLE_CHAT(Boolean.class, "toggle_chat"),
|
||||
DEVELOPER_MODE(Boolean.class, "developer_mode"),
|
||||
ANTISPAM_MINUTES(Integer.class, "antispam_minutes");
|
||||
ANTISPAM_MINUTES(Integer.class, "antispam_minutes"),
|
||||
RANDOM_TELEPORT_MAX_DISTANCE(Integer.class, "random_teleport_max_distance");
|
||||
//
|
||||
private final Class<?> type;
|
||||
private final String configName;
|
||||
@ -229,7 +231,7 @@ public enum ConfigEntry
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getStringList()
|
||||
{
|
||||
return (List<String>)getList();
|
||||
return (List<String>) getList();
|
||||
}
|
||||
|
||||
private MainConfig getConfig()
|
||||
|
@ -6,12 +6,13 @@ import java.util.*;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.DisplayableGroup;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.PluginIdentifiableCommand;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -111,21 +112,28 @@ public class Module_help extends HTTPDModule
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<Rank, List<FreedomCommand>> freedomCommands = new HashMap<>();
|
||||
Map<String, List<FreedomCommand>> freedomCommands = new HashMap<>();
|
||||
|
||||
// Filters out non-TFM commands
|
||||
commands.stream().filter((cmd) -> cmd instanceof FreedomCommand.FCommand).forEach((tfmCmd) -> {
|
||||
Rank rank = Objects.requireNonNull(FreedomCommand.getFrom(tfmCmd)).getRank();
|
||||
if (!freedomCommands.containsKey(rank))
|
||||
freedomCommands.put(rank, new ArrayList<>());
|
||||
freedomCommands.get(rank).add(FreedomCommand.getFrom(tfmCmd));
|
||||
String permission = Objects.requireNonNull(FreedomCommand.getFrom(tfmCmd)).getPermission();
|
||||
if (!freedomCommands.containsKey(permission))
|
||||
freedomCommands.put(permission, new ArrayList<>());
|
||||
freedomCommands.get(permission).add(FreedomCommand.getFrom(tfmCmd));
|
||||
});
|
||||
|
||||
List<String> permissions = Bukkit.getPluginManager()
|
||||
.getPermissions()
|
||||
.stream()
|
||||
.map(Permission::getName)
|
||||
.filter(permission -> permission.startsWith("tfm."))
|
||||
.toList();
|
||||
|
||||
// Finally dumps them to HTML
|
||||
Arrays.stream(Rank.values()).filter(freedomCommands::containsKey)
|
||||
.sorted(comparator::compare).forEach((rank -> {
|
||||
responseBody.append("</ul>\r\n").append(heading(rank.getName(), 3)).append("<ul>\r\n");
|
||||
freedomCommands.get(rank).stream().sorted(comparator::compare).forEach((command) -> responseBody.append(buildDescription(command)));
|
||||
permissions.stream().filter(freedomCommands::containsKey)
|
||||
.sorted(comparator::compare).forEach((permission -> {
|
||||
responseBody.append("</ul>\r\n").append(heading(permission, 3)).append("<ul>\r\n");
|
||||
freedomCommands.get(permission).stream().sorted(comparator::compare).forEach((command) -> responseBody.append(buildDescription(command)));
|
||||
}));
|
||||
}
|
||||
|
||||
@ -160,12 +168,9 @@ public class Module_help extends HTTPDModule
|
||||
return a.getName().compareTo(b.getName());
|
||||
}
|
||||
|
||||
public int compare(Rank a, Rank b)
|
||||
public int compare(String perm1, String perm2)
|
||||
{
|
||||
Integer levelA = a.getLevel();
|
||||
Integer levelB = b.getLevel();
|
||||
|
||||
return levelB.compareTo(levelA);
|
||||
return perm1.compareTo(perm2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,185 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.permissions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class PermissionConfig extends FreedomService
|
||||
{
|
||||
public static final String PERMISSIONS_FILENAME = "permissions.yml";
|
||||
//
|
||||
private final EnumMap<PermissionEntry, Object> entries;
|
||||
public YamlConfiguration configuration;
|
||||
|
||||
public PermissionConfig()
|
||||
{
|
||||
entries = new EnumMap<>(PermissionEntry.class);
|
||||
|
||||
PermissionDefaults tempDefaults;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
try (InputStream defaultConfig = getDefaultConfig())
|
||||
{
|
||||
tempDefaults = new PermissionDefaults(defaultConfig);
|
||||
for (PermissionEntry entry : PermissionEntry.values())
|
||||
{
|
||||
entries.put(entry, tempDefaults.get(entry.getConfigName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
|
||||
copyDefaultConfig(getConfigFile());
|
||||
|
||||
load();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
try
|
||||
{
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
config.load(getConfigFile());
|
||||
|
||||
configuration = config;
|
||||
|
||||
for (PermissionEntry entry : PermissionEntry.values())
|
||||
{
|
||||
String path = entry.getConfigName();
|
||||
if (config.contains(path))
|
||||
{
|
||||
Object value = config.get(path);
|
||||
if (value != null)
|
||||
{
|
||||
entries.put(entry, value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FLog.warning("Missing permission entry " + entry.getConfigName() + ". Using default value.");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException | InvalidConfigurationException ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private File getConfigFile()
|
||||
{
|
||||
return new File(plugin.getDataFolder(), PERMISSIONS_FILENAME);
|
||||
}
|
||||
|
||||
public List<?> getList(PermissionEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
return get(entry, List.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T> T get(PermissionEntry entry, Class<T> type) throws IllegalArgumentException
|
||||
{
|
||||
Object value = entries.get(entry);
|
||||
try
|
||||
{
|
||||
return type.cast(value);
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
throw new IllegalArgumentException(entry.name() + " is not of type " + type.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void set(PermissionEntry entry, T value)
|
||||
{
|
||||
entries.put(entry, value);
|
||||
}
|
||||
|
||||
private void copyDefaultConfig(File targetFile)
|
||||
{
|
||||
if (targetFile.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FLog.info("Installing default permission file template: " + targetFile.getPath());
|
||||
|
||||
try
|
||||
{
|
||||
try (InputStream defaultConfig = getDefaultConfig())
|
||||
{
|
||||
FileUtils.copyInputStreamToFile(defaultConfig, targetFile);
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream getDefaultConfig()
|
||||
{
|
||||
return plugin.getResource(PERMISSIONS_FILENAME);
|
||||
}
|
||||
|
||||
public static class PermissionDefaults
|
||||
{
|
||||
private YamlConfiguration defaults = null;
|
||||
|
||||
private PermissionDefaults(InputStream defaultConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
defaults = new YamlConfiguration();
|
||||
final InputStreamReader isr = new InputStreamReader(defaultConfig);
|
||||
defaults.load(isr);
|
||||
isr.close();
|
||||
}
|
||||
catch (IOException | InvalidConfigurationException ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public Object get(String path)
|
||||
{
|
||||
return defaults.get(path);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.permissions;
|
||||
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
|
||||
public enum PermissionEntry
|
||||
{
|
||||
REMOVE("remove"),
|
||||
OPERATORS("operators"),
|
||||
MASTER_BUILDERS("master_builders"),
|
||||
ADMINS("admins"),
|
||||
SENIOR_ADMINS("senior_admins");
|
||||
|
||||
private final String configName;
|
||||
|
||||
PermissionEntry(String configName)
|
||||
{
|
||||
this.configName = configName;
|
||||
}
|
||||
|
||||
public String getConfigName()
|
||||
{
|
||||
return configName;
|
||||
}
|
||||
|
||||
public List<?> getList()
|
||||
{
|
||||
return getConfig().getList(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getEntry()
|
||||
{
|
||||
return (List<String>)getList();
|
||||
}
|
||||
|
||||
private PermissionConfig getConfig()
|
||||
{
|
||||
return TotalFreedomMod.getPlugin().permissions;
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.permissions;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.Title;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
public class PermissionManager extends FreedomService
|
||||
{
|
||||
public Map<Displayable, List<String>> permissions = Maps.newHashMap();
|
||||
|
||||
public Map<Player, PermissionAttachment> attachments = Maps.newHashMap();
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
loadPermissionNodes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public void loadPermissionNodes()
|
||||
{
|
||||
FLog.info("Loading permission nodes...");
|
||||
|
||||
permissions.clear();
|
||||
|
||||
List<String> operatorPermissions;
|
||||
List<String> masterBuilderPermissions;
|
||||
List<String> adminPermissions;
|
||||
List<String> senioradminPermissions;
|
||||
|
||||
operatorPermissions = PermissionEntry.OPERATORS.getEntry();
|
||||
permissions.put(Rank.OP, operatorPermissions);
|
||||
|
||||
masterBuilderPermissions = PermissionEntry.MASTER_BUILDERS.getEntry();
|
||||
masterBuilderPermissions.addAll(operatorPermissions);
|
||||
permissions.put(Title.MASTER_BUILDER, masterBuilderPermissions);
|
||||
|
||||
adminPermissions = PermissionEntry.ADMINS.getEntry();
|
||||
adminPermissions.addAll(masterBuilderPermissions);
|
||||
permissions.put(Rank.ADMIN, adminPermissions);
|
||||
|
||||
senioradminPermissions = PermissionEntry.SENIOR_ADMINS.getEntry();
|
||||
senioradminPermissions.addAll(adminPermissions);
|
||||
permissions.put(Rank.SENIOR_ADMIN, senioradminPermissions);
|
||||
|
||||
int count = PermissionEntry.OPERATORS.getEntry().size() + PermissionEntry.MASTER_BUILDERS.getEntry().size() + PermissionEntry.ADMINS.getEntry().size() + PermissionEntry.SENIOR_ADMINS.getEntry().size();
|
||||
|
||||
FLog.info("Loaded " + count + " permission nodes");
|
||||
}
|
||||
|
||||
public void setPermissions(Player player)
|
||||
{
|
||||
PermissionAttachment attachment = attachments.get(player);
|
||||
|
||||
if (attachment != null)
|
||||
{
|
||||
player.removeAttachment(attachment);
|
||||
}
|
||||
|
||||
attachment = player.addAttachment(plugin);
|
||||
|
||||
for (PermissionAttachmentInfo attachmentInfo : player.getEffectivePermissions())
|
||||
{
|
||||
for (String rootNode : PermissionEntry.REMOVE.getEntry())
|
||||
{
|
||||
String permission = attachmentInfo.getPermission();
|
||||
if (permission.startsWith(rootNode))
|
||||
{
|
||||
attachment.setPermission(attachmentInfo.getPermission(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> nodes = permissions.get(plugin.rm.getRank(player));
|
||||
if (nodes != null)
|
||||
{
|
||||
for (String node : nodes)
|
||||
{
|
||||
attachment.setPermission(node, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.pl.getData(player).isMasterBuilder() && !plugin.al.isAdmin(player))
|
||||
{
|
||||
if (nodes != null)
|
||||
{
|
||||
for (String node : permissions.get(Title.MASTER_BUILDER))
|
||||
{
|
||||
attachment.setPermission(node, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
attachments.put(player, attachment);
|
||||
|
||||
player.recalculatePermissions();
|
||||
}
|
||||
|
||||
public void updatePlayers()
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
setPermissions(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import me.totalfreedom.totalfreedommod.caging.CageData;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Arrow;
|
||||
@ -50,7 +51,7 @@ public class FPlayer
|
||||
private boolean lockedUp = false;
|
||||
private boolean inAdminchat = false;
|
||||
private boolean allCommandsBlocked = false;
|
||||
private String tag = null;
|
||||
private Component tag = Component.empty();
|
||||
private int warningCount = 0;
|
||||
|
||||
|
||||
@ -256,6 +257,11 @@ public class FPlayer
|
||||
return unmuteTask != null;
|
||||
}
|
||||
|
||||
public void setMuted(boolean muted)
|
||||
{
|
||||
setMuted(muted, 5);
|
||||
}
|
||||
|
||||
public void setMuted(boolean muted, int minutes)
|
||||
{
|
||||
FUtil.cancel(unmuteTask);
|
||||
@ -281,8 +287,7 @@ public class FPlayer
|
||||
{
|
||||
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Unmuting " + getPlayer().getName(), false);
|
||||
setMuted(false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Unmuting " + getName(), false);
|
||||
}
|
||||
@ -290,11 +295,6 @@ public class FPlayer
|
||||
}.runTaskLater(plugin, minutes * (60L * 20L));
|
||||
}
|
||||
|
||||
public void setMuted(boolean muted)
|
||||
{
|
||||
setMuted(muted, 5);
|
||||
}
|
||||
|
||||
public BukkitTask getLockupScheduleID()
|
||||
{
|
||||
return this.lockupScheduleTask;
|
||||
@ -335,12 +335,12 @@ public class FPlayer
|
||||
this.allCommandsBlocked = commandsBlocked;
|
||||
}
|
||||
|
||||
public String getTag()
|
||||
public Component getTag()
|
||||
{
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag)
|
||||
public void setTag(Component tag)
|
||||
{
|
||||
this.tag = tag;
|
||||
}
|
||||
|
@ -1,24 +1,26 @@
|
||||
package me.totalfreedom.totalfreedommod.player;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
public class PlayerData
|
||||
{
|
||||
private UUID uuid;
|
||||
private final List<String> ips = Lists.newArrayList();
|
||||
private final List<String> notes = Lists.newArrayList();
|
||||
private String tag = null;
|
||||
private UUID uuid;
|
||||
private Component tag = Component.empty();
|
||||
private String discordID = null;
|
||||
private Boolean masterBuilder = false;
|
||||
|
||||
@ -48,7 +50,7 @@ public class PlayerData
|
||||
ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
|
||||
notes.clear();
|
||||
notes.addAll(FUtil.stringToList(resultSet.getString("notes")));
|
||||
tag = resultSet.getString("tag");
|
||||
tag = LegacyComponentSerializer.legacyAmpersand().deserialize(resultSet.getString("tag"));
|
||||
discordID = resultSet.getString("discord_id");
|
||||
masterBuilder = resultSet.getBoolean("master_builder");
|
||||
rideMode = RideMode.valueOf(resultSet.getString("ride_mode").toUpperCase());
|
||||
@ -59,8 +61,7 @@ public class PlayerData
|
||||
displayDiscord = resultSet.getBoolean("display_discord");
|
||||
loginMessage = resultSet.getString("login_message");
|
||||
inspect = resultSet.getBoolean("inspect");
|
||||
}
|
||||
catch (SQLException e)
|
||||
} catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to load player: " + e.getMessage());
|
||||
}
|
||||
@ -81,7 +82,7 @@ public class PlayerData
|
||||
"- Coins: " + coins + "\n" +
|
||||
"- Total Votes: " + totalVotes + "\n" +
|
||||
"- Display Discord: " + displayDiscord + "\n" +
|
||||
"- Tag: " + FUtil.colorize(tag) + ChatColor.GRAY + "\n" +
|
||||
"- Tag: " + tag.toString() + ChatColor.GRAY + "\n" +
|
||||
"- Ride Mode: " + rideMode.name() + "\n" +
|
||||
"- Login Message: " + loginMessage;
|
||||
}
|
||||
@ -141,8 +142,7 @@ public class PlayerData
|
||||
try
|
||||
{
|
||||
notes.remove(id);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
} catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -186,22 +186,21 @@ public class PlayerData
|
||||
|
||||
public Map<String, Object> toSQLStorable()
|
||||
{
|
||||
return new HashMap<String, Object>()
|
||||
{{
|
||||
put("uuid", uuid.toString());
|
||||
put("ips", FUtil.listToString(ips));
|
||||
put("notes", FUtil.listToString(notes));
|
||||
put("tag", tag);
|
||||
put("discord_id", discordID);
|
||||
put("master_builder", masterBuilder);
|
||||
put("ride_mode", rideMode.name());
|
||||
put("coins", coins);
|
||||
put("items", FUtil.listToString(items));
|
||||
put("total_votes", totalVotes);
|
||||
put("display_discord", displayDiscord);
|
||||
put("login_message", loginMessage);
|
||||
put("inspect", inspect);
|
||||
}};
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
objectMap.put("uuid", uuid.toString());
|
||||
objectMap.put("ips", FUtil.listToString(ips));
|
||||
objectMap.put("notes", FUtil.listToString(notes));
|
||||
objectMap.put("tag", tag.toString());
|
||||
objectMap.put("discord_id", discordID);
|
||||
objectMap.put("master_builder", masterBuilder);
|
||||
objectMap.put("ride_mode", rideMode.name());
|
||||
objectMap.put("coins", coins);
|
||||
objectMap.put("items", FUtil.listToString(items));
|
||||
objectMap.put("total_votes", totalVotes);
|
||||
objectMap.put("display_discord", displayDiscord);
|
||||
objectMap.put("login_message", loginMessage);
|
||||
objectMap.put("inspect", inspect);
|
||||
return objectMap;
|
||||
}
|
||||
|
||||
public boolean doesDisplayDiscord()
|
||||
@ -219,12 +218,12 @@ public class PlayerData
|
||||
return Bukkit.getOfflinePlayer(uuid).getName();
|
||||
}
|
||||
|
||||
public String getTag()
|
||||
public Component getTag()
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag)
|
||||
public void setTag(Component tag)
|
||||
{
|
||||
this.tag = tag;
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
package me.totalfreedom.totalfreedommod.player;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
public class PlayerList extends FreedomService
|
||||
{
|
||||
|
||||
@ -56,8 +56,7 @@ public class PlayerList extends FreedomService
|
||||
PlayerData playerData = load(resultSet);
|
||||
dataMap.put(playerData.getUuid(), playerData);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
} catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to parse master builders: " + e.getMessage());
|
||||
}
|
||||
@ -101,7 +100,7 @@ public class PlayerList extends FreedomService
|
||||
public boolean isTelnetMasterBuilder(PlayerData playerData)
|
||||
{
|
||||
Admin admin = plugin.al.getEntryByUuid(playerData.getUuid());
|
||||
return admin != null && admin.getRank().isAtLeast(Rank.ADMIN) && playerData.isMasterBuilder();
|
||||
return admin != null && admin.getRank().isAtLeast(GroupProvider.ADMIN.getGroup()) && playerData.isMasterBuilder();
|
||||
}
|
||||
|
||||
// May not return null
|
||||
@ -159,8 +158,7 @@ public class PlayerList extends FreedomService
|
||||
plugin.sql.setPlayerValue(player, entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
} catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to save player: " + e.getMessage());
|
||||
}
|
||||
|
@ -86,6 +86,11 @@ public class DisplayableGroup implements Displayable
|
||||
<= getLuckPermsGroup().getWeight().orElse(0);
|
||||
}
|
||||
|
||||
public int getWeight()
|
||||
{
|
||||
return weight;
|
||||
}
|
||||
|
||||
public Group getLuckPermsGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
@ -6,10 +6,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.node.types.PrefixNode;
|
||||
import net.luckperms.api.node.types.WeightNode;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -21,10 +18,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Objects;
|
||||
|
||||
public class RankManager extends FreedomService
|
||||
{
|
||||
@ -148,13 +142,13 @@ public class RankManager extends FreedomService
|
||||
: GroupProvider.NON_OP.getGroup();
|
||||
}
|
||||
|
||||
public String getTag(Player player, String defaultTag)
|
||||
public Component getTag(Player player, Component defaultTag)
|
||||
{
|
||||
String tag = defaultTag;
|
||||
Component tag = defaultTag;
|
||||
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
String t = playerData.getTag();
|
||||
if (t != null && !t.isEmpty())
|
||||
Component t = playerData.getTag();
|
||||
if (t != null && !(t.equals(Component.empty())))
|
||||
{
|
||||
tag = t;
|
||||
}
|
||||
@ -180,10 +174,9 @@ public class RankManager extends FreedomService
|
||||
fPlayer.setTag(null);
|
||||
player.setPlayerListName(null);
|
||||
}
|
||||
// FIXME: Adjust Rank to use MiniMessage instead of the legacy stuff
|
||||
fPlayer.setTag(getTag(player, FUtil.miniMessage(FUtil.colorizeAsComponent(display.getColoredTag()))));
|
||||
|
||||
fPlayer.setTag(getTag(player, display.getColoredTag()));
|
||||
updatePlayerTeam(player);
|
||||
plugin.pem.setPermissions(player);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@ -218,7 +211,7 @@ public class RankManager extends FreedomService
|
||||
|
||||
if (target.getTag() != null)
|
||||
{
|
||||
plugin.pl.getData(player).setTag(FUtil.colorize(target.getTag()));
|
||||
plugin.pl.getData(player).setTag(target.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,9 +167,9 @@ public class FUtil
|
||||
|
||||
public static String listToString(List<String> list)
|
||||
{
|
||||
if (list.size() == 0)
|
||||
if (list.isEmpty())
|
||||
{
|
||||
return null;
|
||||
return ""; // Don't return null here, that's stupid. Return an empty string.
|
||||
}
|
||||
|
||||
return String.join(", ", list);
|
||||
|
@ -16,7 +16,7 @@ import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.api.TFD4JCommons;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
@ -173,11 +173,11 @@ public class TFD4JCommonsImpl implements TFD4JCommons
|
||||
return true;
|
||||
}
|
||||
|
||||
if (admin.getRank().equals(Rank.ADMIN))
|
||||
if (admin.getRank().equals(GroupProvider.ADMIN.getGroup()))
|
||||
{
|
||||
syncRolesAdminAssignment(member, adminRole, senioradminRole);
|
||||
return true;
|
||||
} else if (admin.getRank().equals(Rank.SENIOR_ADMIN))
|
||||
} else if (admin.getRank().equals(GroupProvider.SENIOR_ADMIN.getGroup()))
|
||||
{
|
||||
syncRolesSeniorAssignment(member, adminRole, senioradminRole);
|
||||
return true;
|
||||
|
@ -12,7 +12,7 @@ import me.totalfreedom.discord.util.SnowflakeEntry;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.rank.Title;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -126,38 +126,32 @@ public class AdminChatListener
|
||||
{
|
||||
Guild server = tfd4j.getBot().getGuildById().block();
|
||||
// Server Owner
|
||||
assert server != null;
|
||||
if (server == null) throw new IllegalStateException();
|
||||
|
||||
return member.getRoles().map(role ->
|
||||
{
|
||||
if (role.getId().equals(SnowflakeEntry.OWNER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.OWNER;
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.DEVELOPER_ROLE_ID.getSnowflake()))
|
||||
} else if (role.getId().equals(SnowflakeEntry.DEVELOPER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.DEVELOPER;
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
} else if (role.getId().equals(SnowflakeEntry.EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.EXECUTIVE;
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.ASSISTANT_EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
} else if (role.getId().equals(SnowflakeEntry.ASSISTANT_EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.ASSTEXEC;
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake()))
|
||||
} else if (role.getId().equals(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Rank.SENIOR_ADMIN;
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake()))
|
||||
return GroupProvider.SENIOR_ADMIN.getGroup();
|
||||
} else if (role.getId().equals(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Rank.ADMIN;
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake()))
|
||||
return GroupProvider.ADMIN.getGroup();
|
||||
} else if (role.getId().equals(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.MASTER_BUILDER;
|
||||
}
|
||||
else
|
||||
return GroupProvider.MASTER_BUILDER.getGroup();
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class MinecraftListener
|
||||
{
|
||||
Boolean b = m.getMessage()
|
||||
.getChannel()
|
||||
.map(c -> c instanceof TextChannel)
|
||||
.map(TextChannel.class::isInstance)
|
||||
.block();
|
||||
return b != null && b;
|
||||
}).subscribe(this::doMessageBodyDetails);
|
||||
|
@ -24,7 +24,7 @@ public class PrivateMessageListener
|
||||
.on(MessageCreateEvent.class)
|
||||
.filter(event -> event.getMessage().getAuthor().orElse(null) != null)
|
||||
.filter(event -> !event.getMessage().getAuthor().orElseThrow().getId().equals(tfd4j.getBot().getClient().getSelfId()))
|
||||
.filter(event -> event.getMessage().getContent().strip().matches("[0-9][0-9][0-9][0-9][0-9]"))
|
||||
.filter(event -> event.getMessage().getContent().strip().matches("\\d{5}"))
|
||||
.subscribe(event ->
|
||||
{
|
||||
String code = event.getMessage().getContent().strip();
|
||||
|
@ -1,18 +1,12 @@
|
||||
package me.totalfreedom.discord.util;
|
||||
|
||||
import discord4j.common.util.Snowflake;
|
||||
import discord4j.core.object.entity.Guild;
|
||||
import discord4j.core.object.entity.Member;
|
||||
import discord4j.core.object.entity.Role;
|
||||
import me.totalfreedom.discord.Bot;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.Title;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class TFM_Bridge
|
||||
@ -37,33 +31,26 @@ public class TFM_Bridge
|
||||
{
|
||||
if (role.getId().equals(SnowflakeEntry.OWNER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.OWNER.getColoredTag();
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.DEVELOPER_ROLE_ID.getSnowflake()))
|
||||
return FUtil.miniMessage(Title.OWNER.getColoredTag());
|
||||
} else if (role.getId().equals(SnowflakeEntry.DEVELOPER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.DEVELOPER.getColoredTag();
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
return FUtil.miniMessage(Title.DEVELOPER.getColoredTag());
|
||||
} else if (role.getId().equals(SnowflakeEntry.EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.EXECUTIVE.getColoredTag();
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.ASSISTANT_EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
return FUtil.miniMessage(Title.EXECUTIVE.getColoredTag());
|
||||
} else if (role.getId().equals(SnowflakeEntry.ASSISTANT_EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.ASSTEXEC.getColoredTag();
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake()))
|
||||
return FUtil.miniMessage(Title.ASSTEXEC.getColoredTag());
|
||||
} else if (role.getId().equals(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return GroupProvider.SENIOR_ADMIN.getGroup().getColoredTag().toString();
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake()))
|
||||
return FUtil.miniMessage(GroupProvider.SENIOR_ADMIN.getGroup().getColoredTag());
|
||||
} else if (role.getId().equals(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return GroupProvider.ADMIN.getGroup().getColoredTag().toString();
|
||||
}
|
||||
else if (role.getId().equals(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake()))
|
||||
return FUtil.miniMessage(GroupProvider.ADMIN.getGroup().getColoredTag());
|
||||
} else if (role.getId().equals(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return GroupProvider.MASTER_BUILDER.getGroup().getColoredTag().toString());
|
||||
}
|
||||
else
|
||||
return FUtil.miniMessage(GroupProvider.MASTER_BUILDER.getGroup().getColoredTag());
|
||||
} else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user