mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-01 05:57:09 +00:00
I was on a development roll and now I need to sleep
- Removes commands /aec, /attributelist, /reactionbar, /playtime, /settotalvotes, /status - Removes unused activity log functionality - Migrates many more commands to use MiniMessage - Merges /disguisetoggle with /toggle - Reimplements explosive arrows in a much better way
This commit is contained in:
parent
34269bde09
commit
6c983f6b97
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.api.Aggregator;
|
||||
import me.totalfreedom.totalfreedommod.api.ShoppeCommons;
|
||||
@ -58,7 +57,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public CommandLoader cl;
|
||||
// Services
|
||||
public WorldManager wm;
|
||||
public ActivityLog acl;
|
||||
public AdminList al;
|
||||
public RankManager rm;
|
||||
public CommandBlocker cb;
|
||||
@ -285,7 +283,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
wm = new WorldManager();
|
||||
sql = new SQLite();
|
||||
al = new AdminList();
|
||||
acl = new ActivityLog();
|
||||
rm = new RankManager();
|
||||
cb = new CommandBlocker();
|
||||
eb = new EventBlocker();
|
||||
|
@ -1,212 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.admin;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class ActivityLog extends FreedomService
|
||||
{
|
||||
|
||||
public static final String FILENAME = "activitylog.yml";
|
||||
|
||||
private final Map<String, ActivityLogEntry> allActivityLogs = Maps.newHashMap();
|
||||
private final Map<String, ActivityLogEntry> nameTable = Maps.newHashMap();
|
||||
private final Map<String, ActivityLogEntry> ipTable = Maps.newHashMap();
|
||||
|
||||
private final YamlConfig config;
|
||||
|
||||
public ActivityLog()
|
||||
{
|
||||
this.config = new YamlConfig(plugin, FILENAME, true);
|
||||
}
|
||||
|
||||
public static String getFILENAME()
|
||||
{
|
||||
return FILENAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
config.load();
|
||||
|
||||
allActivityLogs.clear();
|
||||
nameTable.clear();
|
||||
ipTable.clear();
|
||||
for (String key : config.getKeys(false))
|
||||
{
|
||||
ConfigurationSection section = config.getConfigurationSection(key);
|
||||
if (section == null)
|
||||
{
|
||||
FLog.warning("Invalid activity log format: " + key);
|
||||
continue;
|
||||
}
|
||||
|
||||
ActivityLogEntry activityLogEntry = new ActivityLogEntry(key);
|
||||
activityLogEntry.loadFrom(section);
|
||||
|
||||
if (!activityLogEntry.isValid())
|
||||
{
|
||||
FLog.warning("Could not load activity log: " + key + ". Missing details!");
|
||||
continue;
|
||||
}
|
||||
|
||||
allActivityLogs.put(key, activityLogEntry);
|
||||
}
|
||||
|
||||
updateTables();
|
||||
FLog.info("Loaded " + allActivityLogs.size() + " activity logs");
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
// Clear the config
|
||||
for (String key : config.getKeys(false))
|
||||
{
|
||||
config.set(key, null);
|
||||
}
|
||||
|
||||
for (ActivityLogEntry activityLog : allActivityLogs.values())
|
||||
{
|
||||
activityLog.saveTo(config.createSection(activityLog.getConfigKey()));
|
||||
}
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
||||
public ActivityLogEntry getActivityLog(CommandSender sender)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
return getActivityLog((Player)sender);
|
||||
}
|
||||
|
||||
return getEntryByName(sender.getName());
|
||||
}
|
||||
|
||||
public ActivityLogEntry getActivityLog(Player player)
|
||||
{
|
||||
ActivityLogEntry activityLog = getEntryByName(player.getName());
|
||||
if (activityLog == null)
|
||||
{
|
||||
String ip = FUtil.getIp(player);
|
||||
activityLog = getEntryByIp(ip);
|
||||
if (activityLog != null)
|
||||
{
|
||||
// Set the new username
|
||||
activityLog.setName(player.getName());
|
||||
save();
|
||||
updateTables();
|
||||
}
|
||||
else
|
||||
{
|
||||
activityLog = new ActivityLogEntry(player);
|
||||
allActivityLogs.put(activityLog.getConfigKey(), activityLog);
|
||||
updateTables();
|
||||
|
||||
activityLog.saveTo(config.createSection(activityLog.getConfigKey()));
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
String ip = FUtil.getIp(player);
|
||||
if (!activityLog.getIps().contains(ip))
|
||||
{
|
||||
activityLog.addIp(ip);
|
||||
save();
|
||||
updateTables();
|
||||
}
|
||||
return activityLog;
|
||||
}
|
||||
|
||||
public ActivityLogEntry getEntryByName(String name)
|
||||
{
|
||||
return nameTable.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public ActivityLogEntry getEntryByIp(String ip)
|
||||
{
|
||||
return ipTable.get(ip);
|
||||
}
|
||||
|
||||
public void updateTables()
|
||||
{
|
||||
nameTable.clear();
|
||||
ipTable.clear();
|
||||
|
||||
for (ActivityLogEntry activityLog : allActivityLogs.values())
|
||||
{
|
||||
nameTable.put(activityLog.getName().toLowerCase(), activityLog);
|
||||
|
||||
for (String ip : activityLog.getIps())
|
||||
{
|
||||
ipTable.put(ip, activityLog);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
getActivityLog(event.getPlayer()).addLogin();
|
||||
plugin.acl.save();
|
||||
plugin.acl.updateTables();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
getActivityLog(event.getPlayer()).addLogout();
|
||||
plugin.acl.save();
|
||||
plugin.acl.updateTables();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, ActivityLogEntry> getAllActivityLogs()
|
||||
{
|
||||
return allActivityLogs;
|
||||
}
|
||||
|
||||
public Map<String, ActivityLogEntry> getNameTable()
|
||||
{
|
||||
return nameTable;
|
||||
}
|
||||
|
||||
public Map<String, ActivityLogEntry> getIpTable()
|
||||
{
|
||||
return ipTable;
|
||||
}
|
||||
|
||||
public YamlConfig getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.admin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ActivityLogEntry implements IConfig
|
||||
{
|
||||
|
||||
public static final String FILENAME = "activitylog.yml";
|
||||
private final List<String> ips = Lists.newArrayList();
|
||||
private final List<String> timestamps = Lists.newArrayList();
|
||||
private final List<String> durations = Lists.newArrayList();
|
||||
private String configKey;
|
||||
private String name;
|
||||
|
||||
public ActivityLogEntry(Player player)
|
||||
{
|
||||
this.configKey = player.getName().toLowerCase();
|
||||
this.name = player.getName();
|
||||
}
|
||||
|
||||
public ActivityLogEntry(String configKey)
|
||||
{
|
||||
this.configKey = configKey;
|
||||
}
|
||||
|
||||
public static String getFILENAME()
|
||||
{
|
||||
return FILENAME;
|
||||
}
|
||||
|
||||
public void loadFrom(Player player)
|
||||
{
|
||||
configKey = player.getName().toLowerCase();
|
||||
name = player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFrom(ConfigurationSection cs)
|
||||
{
|
||||
name = cs.getString("username", configKey);
|
||||
ips.clear();
|
||||
ips.addAll(cs.getStringList("ips"));
|
||||
timestamps.clear();
|
||||
timestamps.addAll(cs.getStringList("timestamps"));
|
||||
durations.clear();
|
||||
durations.addAll(cs.getStringList("durations"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTo(ConfigurationSection cs)
|
||||
{
|
||||
Validate.isTrue(isValid(), "Could not save activity entry: " + name + ". Entry not valid!");
|
||||
cs.set("username", name);
|
||||
cs.set("ips", Lists.newArrayList(ips));
|
||||
cs.set("timestamps", Lists.newArrayList(timestamps));
|
||||
cs.set("durations", Lists.newArrayList(durations));
|
||||
}
|
||||
|
||||
public void addLogin()
|
||||
{
|
||||
Date currentTime = Date.from(Instant.now());
|
||||
timestamps.add("Login: " + FUtil.dateToString(currentTime));
|
||||
}
|
||||
|
||||
public void addLogout()
|
||||
{
|
||||
// Fix of Array index out of bonds issue: FS-131
|
||||
String lastLoginString;
|
||||
if(timestamps.size() > 1)
|
||||
{
|
||||
lastLoginString = timestamps.get(timestamps.size() - 1);
|
||||
}else
|
||||
{
|
||||
lastLoginString = timestamps.get(0);
|
||||
}
|
||||
Date currentTime = Date.from(Instant.now());
|
||||
timestamps.add("Logout: " + FUtil.dateToString(currentTime));
|
||||
lastLoginString = lastLoginString.replace("Login: ", "");
|
||||
Date lastLogin = FUtil.stringToDate(lastLoginString);
|
||||
|
||||
long duration = currentTime.getTime() - lastLogin.getTime();
|
||||
long seconds = duration / 1000 % 60;
|
||||
long minutes = duration / (60 * 1000) % 60;
|
||||
long hours = duration / (60 * 60 * 1000);
|
||||
durations.add(hours + " hours, " + minutes + " minutes, and " + seconds + " seconds");
|
||||
}
|
||||
|
||||
public void addIp(String ip)
|
||||
{
|
||||
if (!ips.contains(ip))
|
||||
{
|
||||
ips.add(ip);
|
||||
}
|
||||
}
|
||||
|
||||
public void addIps(List<String> ips)
|
||||
{
|
||||
for (String ip : ips)
|
||||
{
|
||||
addIp(ip);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeIp(String ip)
|
||||
{
|
||||
ips.remove(ip);
|
||||
}
|
||||
|
||||
public void clearIPs()
|
||||
{
|
||||
ips.clear();
|
||||
}
|
||||
|
||||
public int getTotalSecondsPlayed()
|
||||
{
|
||||
int result = 0;
|
||||
for (String duration : durations)
|
||||
{
|
||||
String[] spl = duration.split(" ");
|
||||
result += Integer.parseInt(spl[0]) * 60 * 60;
|
||||
result += Integer.parseInt(spl[2]) * 60;
|
||||
result += Integer.parseInt(spl[5]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return configKey != null
|
||||
&& name != null;
|
||||
}
|
||||
|
||||
public String getConfigKey()
|
||||
{
|
||||
return configKey;
|
||||
}
|
||||
|
||||
public void setConfigKey(String configKey)
|
||||
{
|
||||
this.configKey = configKey;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<String> getIps()
|
||||
{
|
||||
return ips;
|
||||
}
|
||||
|
||||
public List<String> getTimestamps()
|
||||
{
|
||||
return timestamps;
|
||||
}
|
||||
|
||||
public List<String> getDurations()
|
||||
{
|
||||
return durations;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -67,12 +68,12 @@ public class Command_adminworld extends FreedomCommand
|
||||
|
||||
if (adminWorld == null || playerSender.getWorld() == adminWorld)
|
||||
{
|
||||
msg("Going to the main world.");
|
||||
msgNew("Going to the main world.");
|
||||
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Going to the AdminWorld.");
|
||||
msgNew("Going to the AdminWorld.");
|
||||
plugin.wm.adminworld.sendToWorld(playerSender);
|
||||
}
|
||||
break;
|
||||
@ -87,11 +88,11 @@ public class Command_adminworld extends FreedomCommand
|
||||
if (timeOfDay != null)
|
||||
{
|
||||
plugin.wm.adminworld.setTimeOfDay(timeOfDay);
|
||||
msg("AdminWorld time set to: " + timeOfDay.name());
|
||||
msgNew("AdminWorld time set to: <time>", Placeholder.unparsed("time", timeOfDay.name()));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
|
||||
msgNew("<red>Invalid time of day. Can be: sunrise, noon, sunset, midnight");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -111,11 +112,11 @@ public class Command_adminworld extends FreedomCommand
|
||||
if (weatherMode != null)
|
||||
{
|
||||
plugin.wm.adminworld.setWeatherMode(weatherMode);
|
||||
msg("AdminWorld weather set to: " + weatherMode.name());
|
||||
msgNew("AdminWorld weather set to <mode>.", Placeholder.unparsed("mode", weatherMode.name()));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Invalid weather mode. Can be: off, rain, storm");
|
||||
msgNew("<red>Invalid weather mode. Can be: off, rain, storm");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -137,7 +138,7 @@ public class Command_adminworld extends FreedomCommand
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
msg(ex.getMessage());
|
||||
msgNew("<red>" + ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Clears lingering potion area effect clouds.", usage = "/<command>", aliases = "aec")
|
||||
public class Command_aeclear extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Removing all area effect clouds", true);
|
||||
int removed = 0;
|
||||
for (World world : server.getWorlds())
|
||||
{
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
if (entity instanceof AreaEffectCloud)
|
||||
{
|
||||
entity.remove();
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
msg(removed + " area effect clouds removed.");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,22 +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.attribute.Attribute;
|
||||
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.BOTH)
|
||||
@CommandParameters(description = "Lists all possible attributes.", usage = "/<command>")
|
||||
public class Command_attributelist extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
msgNew("All possible attributes: <attributes>", Placeholder.unparsed("attributes", FUtil.listToString(Arrays.stream(Attribute.values()).map(Enum::name).toList())));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ 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.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -118,7 +119,7 @@ public class Command_ban extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Banned " + player.getName() + " quietly.");
|
||||
msgNew("Banned <player> quietly.", Placeholder.unparsed("player", player.getName()));
|
||||
}
|
||||
// Kill player
|
||||
player.setHealth(0.0);
|
||||
@ -160,7 +161,9 @@ public class Command_ban extends FreedomCommand
|
||||
{
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||
}
|
||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + ip);
|
||||
msgNew("<name> has been banned and their IP is <ip>.",
|
||||
Placeholder.unparsed("name", username),
|
||||
Placeholder.unparsed("ip", ip));
|
||||
FUtil.adminAction(sender.getName(), bcast.toString(), true);
|
||||
}
|
||||
|
||||
@ -168,13 +171,9 @@ public class Command_ban extends FreedomCommand
|
||||
if (player != null)
|
||||
{
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (FUtil.getIp(p).equals(FUtil.getIp(player)))
|
||||
{
|
||||
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
|
||||
}
|
||||
}
|
||||
|
||||
server.getOnlinePlayers().stream().filter(pl -> FUtil.getIp(pl).equalsIgnoreCase(ip)).forEach(pl ->
|
||||
player.kickPlayer(ban.bakeKickMessage()));
|
||||
}
|
||||
|
||||
// Log ban
|
||||
|
@ -3,6 +3,7 @@ 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.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -31,7 +32,7 @@ public class Command_banname extends FreedomCommand
|
||||
|
||||
if (plugin.bm.getByUsername(name) != null)
|
||||
{
|
||||
msg("The name " + name + " is already banned", ChatColor.RED);
|
||||
msgNew("<red>The name <name> is already banned.", Placeholder.unparsed("name", name));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,11 @@ 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.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
@ -29,12 +31,13 @@ public class Command_blockedit extends FreedomCommand
|
||||
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||
plugin.pl.getPlayer(player).isEditBlocked()).sorted().toList();
|
||||
|
||||
// Oh dear god, why do I have to do it like this?
|
||||
msg("There " + (list.size() != 1 ? "are " : "is ") + list.size() + " player"
|
||||
+ (list.size() != 1 ? "s" : "") + " online with restricted block modification abilities"
|
||||
+ (list.size() > 0 ? ":" : "."));
|
||||
|
||||
list.forEach(player -> msg("- " + player.getName()));
|
||||
boolean plural = list.size() != 1;
|
||||
msgNew("There <grammar> <count> player<plural> online with restricted block modification abilities: <players>",
|
||||
Placeholder.unparsed("grammar", plural ? "are" : "is"),
|
||||
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||
Placeholder.unparsed("plural", plural ? "s" : ""),
|
||||
Placeholder.unparsed("colon", list.size() > 0 ? ":" : "."),
|
||||
Placeholder.unparsed("players", FUtil.listToString(list.stream().map(HumanEntity::getName).toList())));
|
||||
}
|
||||
case "purge" ->
|
||||
{
|
||||
@ -46,11 +49,12 @@ public class Command_blockedit extends FreedomCommand
|
||||
list.forEach(player ->
|
||||
{
|
||||
plugin.pl.getPlayer(player).setEditBlocked(false);
|
||||
msg(player, "Your block modification abilities have been restored.", ChatColor.GREEN);
|
||||
msgNew(player, "<green>Your block modification abilities have been restored.");
|
||||
});
|
||||
|
||||
msg("Restored block modification abilities for " + list.size() + " player"
|
||||
+ (list.size() != 1 ? "s" : "") + ".");
|
||||
msgNew("Restored block modification abilities for <count> player<plural>.",
|
||||
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||
Placeholder.unparsed("plural", list.size() != 1 ? "s" : ""));
|
||||
}
|
||||
case "all", "-a" ->
|
||||
{
|
||||
@ -62,11 +66,12 @@ public class Command_blockedit extends FreedomCommand
|
||||
list.forEach(player ->
|
||||
{
|
||||
plugin.pl.getPlayer(player).setEditBlocked(true);
|
||||
msg(player, "Your block modification abilities have been restricted.", ChatColor.RED);
|
||||
msgNew(player, "<red>Your block modification abilities have been restricted.");
|
||||
});
|
||||
|
||||
msg("Restricted block modification abilities for " + list.size() + " player"
|
||||
+ (list.size() != 1 ? "s" : "") + ".");
|
||||
msgNew("Restricted block modification abilities for <count> player<plural>.",
|
||||
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||
Placeholder.unparsed("plural", list.size() != 1 ? "s" : ""));
|
||||
}
|
||||
default -> Optional.ofNullable(getPlayer(args[0])).ifPresentOrElse(player ->
|
||||
{
|
||||
@ -76,21 +81,21 @@ public class Command_blockedit extends FreedomCommand
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Restoring block modification abilities for " + player.getName(), true);
|
||||
fPlayer.setEditBlocked(false);
|
||||
msg("Restored block modification abilities for " + player.getName() + ".");
|
||||
msg(player, "Your block modification abilities have been restored.", ChatColor.GREEN);
|
||||
msgNew("Restored block modification abilities for <player>.", Placeholder.unparsed("player", player.getName()));
|
||||
msgNew(player, "<green>Your block modification abilities have been restored.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
msg(player.getName() + " is an admin, and as such cannot have their block modification abilities restricted.", ChatColor.RED);
|
||||
msgNew("<red><player> is an admin, and as such cannot have their block modification abilities restricted.", Placeholder.unparsed("player", player.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Restricting block modification abilities for " + player.getName(), true);
|
||||
fPlayer.setEditBlocked(true);
|
||||
msg("Restricted block modification abilities for " + player.getName() + ".");
|
||||
msg(player, "Your block modification abilities have been restricted.", ChatColor.RED);
|
||||
msgNew("Restricted block modification abilities for <player>.", Placeholder.unparsed("player", player.getName()));
|
||||
msgNew(player, "<red>Your block modification abilities have been restricted.");
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player),
|
||||
sender.getName(), PunishmentType.BLOCKEDIT, null));
|
||||
|
@ -5,18 +5,17 @@ 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.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggle PVP mode for everyone or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "pvpblock,pvpmode")
|
||||
@CommandParameters(description = "Toggle PVP mode for everyone or a certain player.", usage = "/<command> [<player> | list | purge | all]", aliases = "pvpblock,pvpmode")
|
||||
public class Command_blockpvp extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
@ -25,113 +24,89 @@ public class Command_blockpvp extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equals("list"))
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
msg("PVP is blocked for players:");
|
||||
int count = 0;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
// List
|
||||
case "list" ->
|
||||
{
|
||||
final FPlayer info = plugin.pl.getPlayer(player);
|
||||
if (info.isPvpBlocked())
|
||||
List<String> restricted = server.getOnlinePlayers().stream().filter(player ->
|
||||
plugin.pl.getPlayer(player).isPvpBlocked()).map(Player::getName).toList();
|
||||
|
||||
if (restricted.isEmpty())
|
||||
{
|
||||
msg(" - " + player.getName());
|
||||
++count;
|
||||
msgNew("Nobody currently has their PVP abilities restricted.");
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
msg(" - none");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equals("purge"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true);
|
||||
int count = 0;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final FPlayer info = plugin.pl.getPlayer(player);
|
||||
if (info.isPvpBlocked())
|
||||
else
|
||||
{
|
||||
info.setPvpBlocked(false);
|
||||
++count;
|
||||
msgNew("PVP abilities are restricted for these player(s): <players>",
|
||||
Placeholder.unparsed("players", FUtil.listToString(restricted)));
|
||||
}
|
||||
}
|
||||
|
||||
msg("Enabled PVP for " + count + " players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equals("all"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true);
|
||||
int counter = 0;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
playerdata.setPvpBlocked(true);
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
|
||||
msg("Disabling PVP for " + counter + " players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
final boolean smite = args[0].equals("-s");
|
||||
if (smite)
|
||||
{
|
||||
args = ArrayUtils.subarray(args, 1, args.length);
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final Player p = getPlayer(args[0]);
|
||||
if (p == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
if (args.length > 1)
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 1, args.length);
|
||||
}
|
||||
|
||||
final FPlayer pd = plugin.pl.getPlayer(p);
|
||||
if (pd.isPvpBlocked())
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
|
||||
pd.setPvpBlocked(false);
|
||||
msg("Enabling PVP for " + p.getName());
|
||||
msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.al.isAdmin(p))
|
||||
{
|
||||
msg(p.getName() + " is an admin, and cannot have their PVP disabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
|
||||
pd.setPvpBlocked(true);
|
||||
if (smite)
|
||||
// Purge
|
||||
case "purge" ->
|
||||
{
|
||||
Command_smite.smite(sender, p, reason);
|
||||
FUtil.adminAction(sender.getName(), "Restoring PVP abilities for all players", true);
|
||||
List<? extends Player> affected = server.getOnlinePlayers().stream().filter(player -> plugin.pl.getPlayer(player).isPvpBlocked()).toList();
|
||||
affected.forEach(player ->
|
||||
{
|
||||
msgNew(player, "<green>Your PVP abilities have been restored.");
|
||||
plugin.pl.getPlayer(player).setPvpBlocked(false);
|
||||
});
|
||||
msgNew("Restored PVP abilities for <count> players.", Placeholder.unparsed("count", String.valueOf(affected.size())));
|
||||
}
|
||||
plugin.pul.logPunishment(new Punishment(p.getName(), FUtil.getIp(p), sender.getName(), PunishmentType.BLOCKPVP, null));
|
||||
|
||||
msg(p, "Your PVP has been disabled.", ChatColor.RED);
|
||||
msg("Disabled PVP for " + p.getName());
|
||||
// All
|
||||
case "all" ->
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Restricting PVP capabilities for all non-admins", true);
|
||||
List<? extends Player> affected = server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).toList();
|
||||
affected.forEach(player ->
|
||||
{
|
||||
msgNew(player, "<red>Your PVP abilities have been restricted.");
|
||||
plugin.pl.getPlayer(player).setPvpBlocked(true);
|
||||
});
|
||||
msgNew("Restricted PVP abilities for <count> players.", Placeholder.unparsed("count", String.valueOf(affected.size())));
|
||||
}
|
||||
|
||||
// Specific players
|
||||
default ->
|
||||
{
|
||||
final Player p = getPlayer(args[0]);
|
||||
if (p == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
final FPlayer pd = plugin.pl.getPlayer(p);
|
||||
if (pd.isPvpBlocked())
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Restoring PVP capabilities for " + p.getName(), true);
|
||||
pd.setPvpBlocked(false);
|
||||
msgNew("Enabled the ability to PVP for <player>.", Placeholder.unparsed("player", p.getName()));
|
||||
msgNew(p, "<green>Your PVP abilities have been restored.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.al.isAdmin(p))
|
||||
{
|
||||
msgNew("<red><player> is an admin, and cannot have their PVP disabled.", Placeholder.unparsed("player", p.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Restricting PVP for " + p.getName(), true);
|
||||
pd.setPvpBlocked(true);
|
||||
plugin.pul.logPunishment(new Punishment(p.getName(), FUtil.getIp(p), sender.getName(), PunishmentType.BLOCKPVP, null));
|
||||
|
||||
msgNew(p, "<red>Your PVP abilities have been restricted.");
|
||||
msgNew("Restricted PVP abilities for <player>. ", Placeholder.unparsed("player", p.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ public class Command_cage extends FreedomCommand
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
if (fPlayer.getCageData().isCaged())
|
||||
{
|
||||
msg("That player is already caged.", ChatColor.RED);
|
||||
msgNew("<red>That player is already caged.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public class Command_cage extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Invalid block!", ChatColor.RED);
|
||||
msgNew("<red>Invalid block!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class Command_cleanchat extends FreedomCommand
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
msg(player, Component.empty());
|
||||
msg(player, Component.space());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class Command_cleardiscordqueue extends FreedomCommand
|
||||
}
|
||||
|
||||
plugin.dc.clearQueue();
|
||||
msg("<green>Cleared the Discord message queue.");
|
||||
msgNew("<green>Cleared the Discord message queue.");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
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;
|
||||
@ -12,11 +13,9 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Clear your inventory.", usage = "/<command> [player]", aliases = "ci,clear")
|
||||
public class Command_clearinventory extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
if (senderIsConsole)
|
||||
@ -25,7 +24,7 @@ public class Command_clearinventory extends FreedomCommand
|
||||
}
|
||||
|
||||
playerSender.getInventory().clear();
|
||||
msg("Your inventory has been cleared.");
|
||||
msgNew("<green>Your inventory has been cleared.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -34,11 +33,8 @@ public class Command_clearinventory extends FreedomCommand
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Clearing everyone's inventory", true);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
player.getInventory().clear();
|
||||
}
|
||||
msg("Sucessfully cleared everyone's inventory.");
|
||||
server.getOnlinePlayers().forEach(player -> player.getInventory().clear());
|
||||
msgNew("<green>Successfully cleared everyone's inventory.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -51,8 +47,8 @@ public class Command_clearinventory extends FreedomCommand
|
||||
}
|
||||
|
||||
player.getInventory().clear();
|
||||
msg("Cleared " + player.getName() + "'s inventory.");
|
||||
msg(player, sender.getName() + " has cleared your inventory.");
|
||||
msgNew("<green>Successfully cleared <player>'s inventory.", Placeholder.unparsed("player", player.getName()));
|
||||
msgNew(player, "<sender> has cleared your inventory.", Placeholder.unparsed("sender", sender.getName()));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1,8 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@ -15,49 +19,20 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
@CommandParameters(description = "For those who have no friends - gives a cookie to everyone on the server.", usage = "/<command>")
|
||||
public class Command_cookie extends FreedomCommand
|
||||
{
|
||||
public static final String COOKIE_LYRICS = "Imagine that you have zero cookies and you split them evenly among zero friends. How many cookies does each person get? See? It doesn't make sense. And Cookie Monster is sad that there are no cookies, and you are sad that you have no friends.";
|
||||
public static final String LORE = "But, you can have a cookie anyways,\nsince you are sad you are have no friends.";
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
final StringBuilder output = new StringBuilder();
|
||||
|
||||
for (final String word : COOKIE_LYRICS.split(" "))
|
||||
{
|
||||
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||
}
|
||||
|
||||
final StringBuilder lore = new StringBuilder();
|
||||
|
||||
for (final String word : LORE.split(" "))
|
||||
{
|
||||
lore.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||
}
|
||||
|
||||
final ItemStack heldItem = new ItemStack(Material.COOKIE);
|
||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||
String name = ChatColor.DARK_RED + "C" +
|
||||
ChatColor.GOLD + "o" +
|
||||
ChatColor.YELLOW + "o" +
|
||||
ChatColor.DARK_GREEN + "k" +
|
||||
ChatColor.DARK_BLUE + "i" +
|
||||
ChatColor.DARK_PURPLE + "e";
|
||||
assert heldItemMeta != null;
|
||||
heldItemMeta.setDisplayName(name);
|
||||
heldItemMeta.setLore(Arrays.asList(lore.toString().split("\n")));
|
||||
heldItemMeta.displayName(FUtil.miniMessage("<rainbow>Cookie"));
|
||||
heldItemMeta.lore(Collections.singletonList(FUtil.miniMessage("<rainbow>But, you can have a cookie anyways,\nsince you are sad you are have no friends.")));
|
||||
heldItem.setItemMeta(heldItemMeta);
|
||||
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final int firstEmpty = player.getInventory().firstEmpty();
|
||||
if (firstEmpty >= 0)
|
||||
{
|
||||
player.getInventory().setItem(firstEmpty, heldItem);
|
||||
}
|
||||
}
|
||||
|
||||
FUtil.bcastMsg(output.toString());
|
||||
server.getOnlinePlayers().forEach(player -> player.getInventory().addItem(heldItem));
|
||||
server.broadcast(FUtil.miniMessage("<rainbow:" + RANDOM.nextInt() + ">Imagine that you have zero cookies and you split them evenly among zero friends. How many cookies does each person get? See? It doesn't make sense. And Cookie Monster is sad that there are no cookies, and you are sad that you have no friends."));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class Command_denick extends FreedomCommand
|
||||
{
|
||||
if (!plugin.esb.isEnabled())
|
||||
{
|
||||
msg("Essentials is not enabled on this server.");
|
||||
msgNew("<red>Essentials is not enabled on this server.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class Command_deop extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Either the player is already deopped, or the player could not be found.");
|
||||
msgNew("Either the player is already deopped, or the player could not be found.");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,38 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggle LibsDisguises for everyone online.", usage = "/<command>", aliases = "dtoggle")
|
||||
public class Command_disguisetoggle extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.ldb.isEnabled())
|
||||
{
|
||||
msg("LibsDisguises is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), (plugin.ldb.isDisguisesEnabled() ? "Disabling" : "Enabling") + " disguises", false);
|
||||
|
||||
if (plugin.ldb.isDisguisesEnabled())
|
||||
{
|
||||
plugin.ldb.undisguiseAll(true);
|
||||
plugin.ldb.setDisguisesEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.ldb.setDisguisesEnabled(true);
|
||||
}
|
||||
|
||||
msg("Disguises are now " + (plugin.ldb.isDisguisesEnabled() ? "enabled." : "disabled."));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -43,7 +44,7 @@ public class Command_dispfill extends FreedomCommand
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid radius.");
|
||||
msgNew("<red>Invalid radius: <amount>", Placeholder.unparsed("amount", args[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -60,7 +61,7 @@ public class Command_dispfill extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Skipping invalid item: " + searchItem);
|
||||
msgNew("Skipping invalid item: <item>", Placeholder.unparsed("item", searchItem));
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,21 +77,23 @@ public class Command_dispfill extends FreedomCommand
|
||||
for (int zOffset = -radius; zOffset <= radius; zOffset++)
|
||||
{
|
||||
final Block targetBlock = centerBlock.getRelative(xOffset, yOffset, zOffset);
|
||||
if (targetBlock.getLocation().distanceSquared(centerLocation) < (radius * radius))
|
||||
if (targetBlock.getLocation().distanceSquared(centerLocation) < (radius * radius) && targetBlock.getType().equals(Material.DISPENSER))
|
||||
{
|
||||
if (targetBlock.getType().equals(Material.DISPENSER))
|
||||
msgNew("Filling dispenser @ <location>", Placeholder.unparsed("location", FUtil.formatLocation(targetBlock.getLocation())));
|
||||
|
||||
if (plugin.cpb.isEnabled())
|
||||
{
|
||||
msg("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation()));
|
||||
plugin.cpb.getCoreProtectAPI().logContainerTransaction(sender.getName(), targetBlock.getLocation());
|
||||
setDispenserContents(targetBlock, itemsArray);
|
||||
affected++;
|
||||
}
|
||||
|
||||
setDispenserContents(targetBlock, itemsArray);
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg("Done. " + affected + " dispenser(s) filled.");
|
||||
msgNew("Done. <amount> dispenser(s) filled.", Placeholder.unparsed("amount", String.valueOf(affected)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ 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.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -117,7 +118,10 @@ public class Command_doom extends FreedomCommand
|
||||
{
|
||||
// message
|
||||
FUtil.adminAction(sender.getName(), "Banning " + player.getName(), true);
|
||||
msg(sender, player.getName() + " has been banned and IP is: " + ip);
|
||||
|
||||
msgNew("<name> has been banned and their IP is <ip>.",
|
||||
Placeholder.unparsed("name", player.getName()),
|
||||
Placeholder.unparsed("ip", ip));
|
||||
|
||||
// generate explosion
|
||||
player.getWorld().createExplosion(player.getLocation(), 0F, false);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -38,11 +39,13 @@ public class Command_eject extends FreedomCommand
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
msg(count + " entit" + (count == 1 ? "y was" : "ies were") + " ejected.", ChatColor.GREEN);
|
||||
msgNew("<green><count> entit<grammar> ejected.",
|
||||
Placeholder.unparsed("count", String.valueOf(count)),
|
||||
Placeholder.unparsed("grammar", count == 1 ? "y was" : "ies were"));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Nothing was ejected.", ChatColor.GREEN);
|
||||
msgNew("<green>Nothing was ejected.");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -9,6 +9,8 @@ import java.util.stream.IntStream;
|
||||
|
||||
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.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@ -34,31 +36,21 @@ public class Command_enchant extends FreedomCommand
|
||||
|
||||
if (item.getType() == Material.AIR)
|
||||
{
|
||||
msg("You have to hold an item to enchant it");
|
||||
msgNew("<red>You have to hold an item to enchant it.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
boolean has_enchantments = false;
|
||||
List<String> enchants = Arrays.stream(Enchantment.values()).filter(enchantment -> enchantment.canEnchantItem(item)).map(enchantment -> enchantment.getName()).toList();
|
||||
|
||||
StringBuilder possible_ench = new StringBuilder("Possible enchantments for held item: ");
|
||||
for (Enchantment ench : Enchantment.values())
|
||||
if (enchants.isEmpty())
|
||||
{
|
||||
if (ench.canEnchantItem(item))
|
||||
{
|
||||
has_enchantments = true;
|
||||
possible_ench.append(ench.getName()).append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
if (has_enchantments)
|
||||
{
|
||||
msg(possible_ench.toString());
|
||||
msgNew("<red>There are no enchantments that work with this item.");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("The held item has no enchantments.");
|
||||
msgNew("Possible enchantments for this item: <enchants>", Placeholder.unparsed("enchants", FUtil.listToString(enchants)));
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("addall"))
|
||||
@ -69,18 +61,17 @@ public class Command_enchant extends FreedomCommand
|
||||
{
|
||||
item.addEnchantment(ench, ench.getMaxLevel());
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception ignored)
|
||||
{
|
||||
msg("Could not add enchantment: " + ench.getName());
|
||||
}
|
||||
});
|
||||
|
||||
msg("Added all possible enchantments for this item.");
|
||||
msgNew("<green>Added all possible enchantments for this item.");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("reset"))
|
||||
{
|
||||
item.getEnchantments().keySet().forEach(item::removeEnchantment);
|
||||
msg("Removed all enchantments.");
|
||||
msgNew("<green>Removed all enchantments.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -89,19 +80,11 @@ public class Command_enchant extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
Enchantment ench = null;
|
||||
|
||||
try
|
||||
{
|
||||
ench = Enchantment.getByName(args[1].toUpperCase());
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
Enchantment ench = Enchantment.getByName(args[1].toUpperCase());
|
||||
|
||||
if (ench == null)
|
||||
{
|
||||
msg(args[1] + " is an invalid enchantment for the held item. Type \"/enchant list\" for valid enchantments for this item.");
|
||||
msgNew("<red><enchant> is an invalid enchantment for the held item. Type \"/enchant list\" for valid enchantments for this item.", Placeholder.unparsed("enchant", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -109,7 +92,7 @@ public class Command_enchant extends FreedomCommand
|
||||
{
|
||||
if (!ench.canEnchantItem(item) && !ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean())
|
||||
{
|
||||
msg("Can't use this enchantment on held item.");
|
||||
msgNew("<red>Can't use this enchantment on that item.");
|
||||
return true;
|
||||
}
|
||||
int level = ench.getMaxLevel();
|
||||
@ -128,7 +111,7 @@ public class Command_enchant extends FreedomCommand
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("\"" + args[2] + "\" is not a valid number", ChatColor.RED);
|
||||
msgNew("Invalid number: <number>", Placeholder.unparsed("number", args[2]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -141,13 +124,13 @@ public class Command_enchant extends FreedomCommand
|
||||
item.addUnsafeEnchantment(ench, level);
|
||||
}
|
||||
|
||||
msg("Added enchantment: " + ench.getName());
|
||||
msgNew("<green>Added enchantment: <enchantment>", Placeholder.unparsed("enchantment", ench.getName()));
|
||||
}
|
||||
else if (args[0].equals("remove"))
|
||||
{
|
||||
item.removeEnchantment(ench);
|
||||
|
||||
msg("Removed enchantment: " + ench.getName());
|
||||
msgNew("<green>Removed enchantment: <enchantment>", Placeholder.unparsed("enchantment", ench.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
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;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -93,13 +94,16 @@ public class Command_entitywipe extends FreedomCommand
|
||||
{
|
||||
count = plugin.ew.wipeEntities(bypassBlacklist);
|
||||
}
|
||||
|
||||
if (count == 1)
|
||||
{
|
||||
msg(count + " " + (type != null ? entityName : "entity") + " removed.");
|
||||
msgNew("<count> <name> removed.", Placeholder.unparsed("count", String.valueOf(count)),
|
||||
Placeholder.unparsed("name", type != null ? entityName : "entity"));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(count + " " + (type != null ? entityName : "entitie") + FUtil.showS(count) + " removed.");
|
||||
msgNew("<count> <name>s removed.", Placeholder.unparsed("count", String.valueOf(count)),
|
||||
Placeholder.unparsed("name", type != null ? entityName : "entitie"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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.Location;
|
||||
import org.bukkit.command.Command;
|
||||
@ -78,11 +79,13 @@ public class Command_expel extends FreedomCommand
|
||||
|
||||
if (pushedPlayers.isEmpty())
|
||||
{
|
||||
msg("No players pushed.");
|
||||
msgNew("No players were pushed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Pushed " + pushedPlayers.size() + " players: " + StringUtils.join(pushedPlayers, ", "));
|
||||
msgNew("Pushed <amount> players: <players>",
|
||||
Placeholder.unparsed("amount", String.valueOf(pushedPlayers.size())),
|
||||
Placeholder.unparsed("players", StringUtils.join(pushedPlayers, ", ")));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,7 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
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.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -10,21 +14,15 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Make arrows explode", usage = "/<command>", aliases = "ea")
|
||||
public class Command_explosivearrows extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
boolean onList = plugin.it.explosivePlayers.contains(playerSender);
|
||||
if (onList)
|
||||
{
|
||||
plugin.it.explosivePlayers.remove(playerSender);
|
||||
msg("You no longer have explosive arrows", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.it.explosivePlayers.add(playerSender);
|
||||
msg("You now have explosive arrows", ChatColor.GREEN);
|
||||
}
|
||||
FPlayer player = plugin.pl.getPlayer(playerSender);
|
||||
player.setExplosiveArrowsEnabled(!player.isExplosiveArrowsEnabled());
|
||||
|
||||
msgNew("<statuscolor>You <status> have explosive arrows.",
|
||||
TagResolver.resolver("statuscolor", Tag.styling(player.isExplosiveArrowsEnabled() ? NamedTextColor.GREEN : NamedTextColor.RED)),
|
||||
Placeholder.unparsed("status", player.isExplosiveArrowsEnabled() ? "now" : "no longer"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -28,7 +28,9 @@ public class Command_findip extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
msg(Component.text(player.getName() + "'s IPs: " + StringUtils.join(plugin.pl.getData(player).getIps(), ", ")));
|
||||
msgNew("<player>'s IPs: <ips>",
|
||||
Placeholder.unparsed("player", player.getName()),
|
||||
Placeholder.unparsed("ips", StringUtils.join(plugin.pl.getData(player).getIps(), ", ")));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,23 +11,23 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Obtain a fire ball", usage = "/<command>")
|
||||
public class Command_fireball extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("The shop is currently disabled.", ChatColor.RED);
|
||||
if (plugin.sh == null)
|
||||
{
|
||||
msgNew("<red>Shop is currently disabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getFireBall());
|
||||
msg("You have been given a Fire Ball", ChatColor.GREEN);
|
||||
msgNew("<green>You have been given the <item>.", Placeholder.unparsed("item", ShopItem.FIRE_BALL.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Fire Ball! Purchase one from the shop.", ChatColor.RED);
|
||||
msgNew("<red>You don't own the <item>! Purchase it from the shop.", Placeholder.unparsed("item", ShopItem.FIRE_BALL.getName()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class Command_flatlands extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Flatlands is currently disabled in the TotalFreedomMod configuration.");
|
||||
msgNew("<red>Flatlands is currently disabled in the TotalFreedomMod configuration.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
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;
|
||||
@ -26,7 +27,8 @@ public class Command_glow extends FreedomCommand
|
||||
playerSender.addPotionEffect(glow);
|
||||
glowing = true;
|
||||
}
|
||||
msg("You are " + (glowing ? "now" : "no longer") + " glowing.");
|
||||
|
||||
msgNew("You are <status> glowing.", Placeholder.unparsed("status", glowing ? "now" : "no longer"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ public class Command_indefban extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
msg("Reloading the indefinite ban list...");
|
||||
msgNew("Reloading the indefinite ban list...");
|
||||
plugin.im.onStop();
|
||||
plugin.im.onStart();
|
||||
msg("Reloaded the indefinite ban list.");
|
||||
msgNew("<green>Reloaded the indefinite ban list.");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import java.util.stream.IntStream;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -30,7 +31,7 @@ public class Command_inspect extends FreedomCommand
|
||||
PlayerData playerData = plugin.pl.getData(playerSender);
|
||||
playerData.setInspect(!playerData.hasInspection());
|
||||
plugin.pl.save(playerData);
|
||||
msg("Block inspector " + (playerData.hasInspection() ? "enabled." : "disabled."));
|
||||
msgNew("Block inspector <status>.", Placeholder.unparsed("status", playerData.hasInspection() ? "enabled." : "disabled."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ public class Command_inspect extends FreedomCommand
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
msg("Invalid number.", ChatColor.RED);
|
||||
msgNew("<red>Invalid number.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -54,7 +55,7 @@ public class Command_inspect extends FreedomCommand
|
||||
int godDammit = pageIndex;
|
||||
Optional.ofNullable(plugin.cpb.getHistoryForPlayer(playerSender)).ifPresentOrElse(page ->
|
||||
plugin.cpb.showPageToPlayer(playerSender, page, godDammit),
|
||||
() -> msg("You haven't inspected anything yet!", ChatColor.RED));
|
||||
() -> msgNew("<red>You haven't inspected anything yet!"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
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;
|
||||
@ -28,7 +29,7 @@ public class Command_lockup extends FreedomCommand
|
||||
{
|
||||
startLockup(player);
|
||||
}
|
||||
msg("Locked up all players.");
|
||||
msgNew("Locked up all players.");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
@ -38,7 +39,7 @@ public class Command_lockup extends FreedomCommand
|
||||
cancelLockup(player);
|
||||
}
|
||||
|
||||
msg("Unlocked all players.");
|
||||
msgNew("Unlocked all players.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -62,7 +63,7 @@ public class Command_lockup extends FreedomCommand
|
||||
FUtil.adminAction(sender.getName(), "Locking up " + player.getName(), true);
|
||||
}
|
||||
startLockup(player);
|
||||
msg("Locked up " + player.getName() + ".");
|
||||
msgNew("Locked up <player>.", Placeholder.unparsed("player", player.getName()));
|
||||
}
|
||||
else if ("off".equals(args[1]))
|
||||
{
|
||||
@ -79,7 +80,7 @@ public class Command_lockup extends FreedomCommand
|
||||
FUtil.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
|
||||
}
|
||||
cancelLockup(player);
|
||||
msg("Unlocked " + player.getName() + ".");
|
||||
msgNew("Unlocked <player>.", Placeholder.unparsed("player", player.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||
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;
|
||||
@ -17,8 +18,9 @@ public class Command_manageshop extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("The shop is currently disabled.", ChatColor.RED);
|
||||
if (plugin.sh == null)
|
||||
{
|
||||
msgNew("<red>Shop is currently disabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -54,11 +56,17 @@ public class Command_manageshop extends FreedomCommand
|
||||
}
|
||||
playerData.setCoins(playerData.getCoins() + amount);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully added " + amount + " coins to " + args[3] + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||
msgNew("<green>Successfully gave <amount> coins to <player>. Their new balance is <balance>.",
|
||||
Placeholder.unparsed("amount", String.valueOf(amount)),
|
||||
Placeholder.unparsed("player", playerData.getName()),
|
||||
Placeholder.unparsed("balance", String.valueOf(playerData.getCoins())));
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player != null)
|
||||
{
|
||||
msg(player, sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||
msgNew(player, "<green><player> gave you <amount> coins. Your new balance is <balance>.",
|
||||
Placeholder.unparsed("player", sender.getName()),
|
||||
Placeholder.unparsed("amount", String.valueOf(amount)),
|
||||
Placeholder.unparsed("balance", String.valueOf(playerData.getCoins())));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -68,15 +76,21 @@ public class Command_manageshop extends FreedomCommand
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setCoins(playerData.getCoins() + amount);
|
||||
plugin.pl.save(playerData);
|
||||
msg(player, sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||
|
||||
msgNew(player, "<green><player> gave you <amount> coins. Your new balance is <balance>.",
|
||||
Placeholder.unparsed("player", sender.getName()),
|
||||
Placeholder.unparsed("amount", String.valueOf(amount)),
|
||||
Placeholder.unparsed("balance", String.valueOf(playerData.getCoins())));
|
||||
}
|
||||
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
|
||||
|
||||
msgNew("<green>Successfully gave <amount> coins to all online players.",
|
||||
Placeholder.unparsed("amount", String.valueOf(amount)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
msgNew("<red>Invalid number: <amount>", Placeholder.unparsed("amount", args[2]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -99,11 +113,18 @@ public class Command_manageshop extends FreedomCommand
|
||||
playerData.setCoins(0);
|
||||
}
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully removed " + amount + " coins from " + args[3] + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||
msgNew("<green>Successfully took <amount> coins from <player>. Their new balance is <balance>.",
|
||||
Placeholder.unparsed("amount", String.valueOf(amount)),
|
||||
Placeholder.unparsed("player", playerData.getName()),
|
||||
Placeholder.unparsed("balance", String.valueOf(playerData.getCoins())));
|
||||
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player != null)
|
||||
{
|
||||
msg(player, sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins(), ChatColor.RED);
|
||||
msgNew(player, "<red><player> took <amount> coins from you. Your new balance is <balance>.",
|
||||
Placeholder.unparsed("player", sender.getName()),
|
||||
Placeholder.unparsed("amount", String.valueOf(amount)),
|
||||
Placeholder.unparsed("balance", String.valueOf(playerData.getCoins())));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -117,15 +138,21 @@ public class Command_manageshop extends FreedomCommand
|
||||
playerData.setCoins(0);
|
||||
}
|
||||
plugin.pl.save(playerData);
|
||||
msg(player, sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins(), ChatColor.RED);
|
||||
|
||||
msgNew(player, "<red><player> took <amount> coins from you. Your new balance is <balance>.",
|
||||
Placeholder.unparsed("player", sender.getName()),
|
||||
Placeholder.unparsed("amount", String.valueOf(amount)),
|
||||
Placeholder.unparsed("balance", String.valueOf(playerData.getCoins())));
|
||||
}
|
||||
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
|
||||
|
||||
msgNew("<green>Successfully took <amount> coins from all online players.",
|
||||
Placeholder.unparsed("amount", String.valueOf(amount)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
msgNew("<red>Invalid number: <amount>", Placeholder.unparsed("amount", args[2]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -142,17 +169,23 @@ public class Command_manageshop extends FreedomCommand
|
||||
}
|
||||
playerData.setCoins(amount);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully set " + args[3] + "'s coins to " + amount, ChatColor.GREEN);
|
||||
|
||||
msgNew("<green>Successfully set <player>'s coin balance to <amount>.",
|
||||
Placeholder.unparsed("player", playerData.getName()),
|
||||
Placeholder.unparsed("amount", String.valueOf(amount)));
|
||||
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player != null)
|
||||
{
|
||||
msg(player, sender.getName() + " set your coin balance to " + amount, ChatColor.GREEN);
|
||||
msgNew(player, "<green><player> set your coin balance to <amount>.",
|
||||
Placeholder.unparsed("player", sender.getName()),
|
||||
Placeholder.unparsed("amount", String.valueOf(amount)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
msgNew("<red>Invalid number: <amount>", Placeholder.unparsed("amount", args[2]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -166,7 +199,7 @@ public class Command_manageshop extends FreedomCommand
|
||||
{
|
||||
if (args[1].equals("list"))
|
||||
{
|
||||
msg("List of all shop items: " + StringUtils.join(ShopItem.values(), ", "));
|
||||
msgNew("List of all shop items: <items>", Placeholder.unparsed("items", StringUtils.join(ShopItem.values(), ", ")));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -180,7 +213,7 @@ public class Command_manageshop extends FreedomCommand
|
||||
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
||||
if (item == null)
|
||||
{
|
||||
msg(args[2] + " is not a valid item.", ChatColor.RED);
|
||||
msgNew("<red><item> is not a valid item.", Placeholder.unparsed("item", args[2]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -192,11 +225,16 @@ public class Command_manageshop extends FreedomCommand
|
||||
}
|
||||
playerData.giveItem(item);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully gave the " + item.getName() + " to " + args[3], ChatColor.GREEN);
|
||||
msgNew("<green>Successfully gave the <item> to <player>.",
|
||||
Placeholder.unparsed("item", item.getName()),
|
||||
Placeholder.unparsed("player", playerData.getName()));
|
||||
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player != null)
|
||||
{
|
||||
msg(player, sender.getName() + " gave the " + item.getName() + " to you", ChatColor.GREEN);
|
||||
msgNew(player, "<green><player> gave the <item> to you.",
|
||||
Placeholder.unparsed("item", item.getName()),
|
||||
Placeholder.unparsed("player", sender.getName()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -205,7 +243,7 @@ public class Command_manageshop extends FreedomCommand
|
||||
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
||||
if (item == null)
|
||||
{
|
||||
msg(args[2] + " is not a valid item.", ChatColor.RED);
|
||||
msgNew("<red><item> is not a valid item.", Placeholder.unparsed("item", args[2]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -217,11 +255,17 @@ public class Command_manageshop extends FreedomCommand
|
||||
}
|
||||
playerData.removeItem(item);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully took the " + item.getName() + " from " + args[3], ChatColor.GREEN);
|
||||
|
||||
msgNew("<green>Successfully took the <item> from <player>.",
|
||||
Placeholder.unparsed("item", item.getName()),
|
||||
Placeholder.unparsed("player", playerData.getName()));
|
||||
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player != null)
|
||||
{
|
||||
msg(player, sender.getName() + " took the " + item.getName() + " from you", ChatColor.RED);
|
||||
msgNew(player, "<red><player> took the <item> from you.",
|
||||
Placeholder.unparsed("item", item.getName()),
|
||||
Placeholder.unparsed("player", sender.getName()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ 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.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -13,7 +14,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-s | -q] <player> [reason] | list | purge | all>", aliases = "stfu")
|
||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-q] <player> [reason] | list | purge | all>", aliases = "stfu")
|
||||
public class Command_mute extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
@ -28,14 +29,16 @@ public class Command_mute extends FreedomCommand
|
||||
{
|
||||
case "list" ->
|
||||
{
|
||||
msg("Muted players:");
|
||||
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||
plugin.pl.getPlayer(player).isMuted()).toList();
|
||||
List<String> muted = server.getOnlinePlayers().stream().filter(player -> plugin.pl.getPlayer(player).isMuted()).map(player -> player.getName()).toList();
|
||||
|
||||
if (list.size() > 0)
|
||||
list.forEach(player -> msg("- " + player.getName()));
|
||||
if (muted.isEmpty())
|
||||
{
|
||||
msgNew("Nobody is currently muted.");
|
||||
}
|
||||
else
|
||||
msg("- none");
|
||||
{
|
||||
msgNew("Muted players: <players>", Placeholder.unparsed("players", FUtil.listToString(muted)));
|
||||
}
|
||||
}
|
||||
case "purge" ->
|
||||
{
|
||||
@ -46,11 +49,12 @@ public class Command_mute extends FreedomCommand
|
||||
list.forEach(player ->
|
||||
{
|
||||
plugin.pl.getPlayer(player).setMuted(false);
|
||||
player.sendTitle(ChatColor.RED + "You have been unmuted.",
|
||||
ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
FUtil.playerTitle(player, "<red>You have been unmuted.", "<yellow>Be sure to follow the rules!");
|
||||
});
|
||||
|
||||
msg("Unmuted " + list.size() + " player" + (list.size() != 1 ? "s" : "") + ".");
|
||||
msgNew("Unmuted <count> player<plural>.",
|
||||
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||
Placeholder.unparsed("plural", list.size() != 1 ? "s" : ""));
|
||||
}
|
||||
case "all" ->
|
||||
{
|
||||
@ -61,19 +65,19 @@ public class Command_mute extends FreedomCommand
|
||||
list.forEach(player ->
|
||||
{
|
||||
plugin.pl.getPlayer(player).setMuted(true);
|
||||
player.sendTitle(ChatColor.RED + "You've been muted globally.",
|
||||
ChatColor.YELLOW + "Please be patient and you will be unmuted shortly.", 20, 100, 60);
|
||||
FUtil.playerTitle(player, "<red>You have been globally muted.", "<yellow>Please be patient and you will be unmuted shortly.");
|
||||
});
|
||||
|
||||
msg("Muted " + list.size() + " player" + (list.size() != 1 ? "s" : "") + ".");
|
||||
msgNew("Muted <count> player<plural>.",
|
||||
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||
Placeholder.unparsed("plural", list.size() != 1 ? "s" : ""));
|
||||
}
|
||||
default ->
|
||||
{
|
||||
boolean quiet = args[0].equalsIgnoreCase("-q");
|
||||
boolean smite = args[0].equalsIgnoreCase("-s");
|
||||
|
||||
// Handling the -q parameter
|
||||
if (quiet || smite)
|
||||
if (quiet)
|
||||
{
|
||||
if (args.length == 1) return false;
|
||||
args = ArrayUtils.subarray(args, 1, args.length);
|
||||
@ -87,12 +91,12 @@ public class Command_mute extends FreedomCommand
|
||||
{
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
msg(player.getName() + " is an admin, and as such can't be muted.", ChatColor.RED);
|
||||
msgNew("<red><player> is an admin, and as such can't be muted.", Placeholder.unparsed("player", player.getName()));
|
||||
return;
|
||||
}
|
||||
else if (plugin.pl.getPlayer(player).isMuted())
|
||||
{
|
||||
msg(player.getName() + " is already muted.", ChatColor.RED);
|
||||
msgNew("<red><player> is already muted.", Placeholder.unparsed("player", player.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -102,28 +106,28 @@ public class Command_mute extends FreedomCommand
|
||||
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
||||
}
|
||||
|
||||
// Smite the player if we're supposed to
|
||||
if (smite)
|
||||
{
|
||||
Command_smite.smite(sender, player, reason, true, false);
|
||||
}
|
||||
|
||||
// Mutes the player
|
||||
plugin.pl.getPlayer(player).setMuted(true);
|
||||
|
||||
// Notify the player that they have been muted
|
||||
player.sendTitle(ChatColor.RED + "You've been muted.",
|
||||
ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName()
|
||||
+ ChatColor.RED + ".", ChatColor.RED);
|
||||
FUtil.playerTitle(player, "<red>You have been muted.", "<yellow>Be sure to follow the rules!");
|
||||
msgNew(player, "<red>You have been muted by <yellow><sender>", Placeholder.unparsed("sender", sender.getName()));
|
||||
|
||||
// Give them the reason if one is present.
|
||||
if (reason != null)
|
||||
{
|
||||
msg(player, "Reason: " + ChatColor.YELLOW + reason, ChatColor.RED);
|
||||
msgNew(player, "<red>Reason: <yellow><reason>", Placeholder.unparsed("reason", reason));
|
||||
}
|
||||
|
||||
if (quiet)
|
||||
{
|
||||
msgNew("Muted <player>.", Placeholder.unparsed("player", player.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
msgNew("Quietly muted <player>.", Placeholder.unparsed("player", player.getName()));
|
||||
}
|
||||
|
||||
msg((quiet ? "Quietly m" : "M") + "uted " + player.getName() + ".");
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(),
|
||||
PunishmentType.MUTE, reason));
|
||||
}, () -> msg(PLAYER_NOT_FOUND));
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -17,7 +18,7 @@ public class Command_nicknyan extends FreedomCommand
|
||||
{
|
||||
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
||||
{
|
||||
msg("Essentials is not enabled on this server.");
|
||||
msgNew("<red>Essentials is not enabled on this server.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -29,7 +30,7 @@ public class Command_nicknyan extends FreedomCommand
|
||||
if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
plugin.esb.setNickname(sender.getName(), null);
|
||||
msg("Nickname cleared.");
|
||||
msgNew("<green>Nickname cleared.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -37,12 +38,12 @@ public class Command_nicknyan extends FreedomCommand
|
||||
|
||||
if (!nickPlain.matches("^[a-zA-Z_0-9" + ChatColor.COLOR_CHAR + "]+$"))
|
||||
{
|
||||
msg("That nickname contains invalid characters.");
|
||||
msgNew("<red>That nickname contains invalid characters.");
|
||||
return true;
|
||||
}
|
||||
else if (nickPlain.length() < 3 || nickPlain.length() > 30)
|
||||
{
|
||||
msg("Your nickname must be between 3 and 30 characters long.");
|
||||
msgNew("<red>Your nickname must be between 3 and 30 characters long.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -51,7 +52,7 @@ public class Command_nicknyan extends FreedomCommand
|
||||
&& (player.getName().equalsIgnoreCase(nickPlain)
|
||||
|| ChatColor.stripColor(plugin.esb.getNickname(player.getName())).trim().equalsIgnoreCase(nickPlain))))
|
||||
{
|
||||
msg("That nickname is already in use.");
|
||||
msgNew("<red>That nickname is already in use.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -63,7 +64,7 @@ public class Command_nicknyan extends FreedomCommand
|
||||
|
||||
plugin.esb.setNickname(sender.getName(), newNick.toString());
|
||||
|
||||
msg("Your nickname is now: " + newNick);
|
||||
msgNew("Your nickname is now: <new>", Placeholder.component("new", FUtil.colorizeAsComponent(newNick.toString())));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -17,7 +18,7 @@ public class Command_nickrainbow extends FreedomCommand
|
||||
{
|
||||
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
||||
{
|
||||
msg("Essentials is not enabled on this server.");
|
||||
msgNew("<red>Essentials is not enabled on this server.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -30,13 +31,13 @@ public class Command_nickrainbow extends FreedomCommand
|
||||
|
||||
if (!nickPlain.matches("^[a-zA-Z_0-9" + ChatColor.COLOR_CHAR + "]+$"))
|
||||
{
|
||||
msg("That nickname contains invalid characters.");
|
||||
msgNew("<red>That nickname contains invalid characters.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (nickPlain.length() < 3 || nickPlain.length() > 30)
|
||||
{
|
||||
msg("Your nickname must be between 3 and 30 characters long.");
|
||||
msgNew("<red>Your nickname must be between 3 and 30 characters long.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ public class Command_nickrainbow extends FreedomCommand
|
||||
}
|
||||
if (player.getName().equalsIgnoreCase(nickPlain) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain))
|
||||
{
|
||||
msg("That nickname is already in use.");
|
||||
msgNew("<red>That nickname is already in use.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -57,7 +58,7 @@ public class Command_nickrainbow extends FreedomCommand
|
||||
|
||||
plugin.esb.setNickname(sender.getName(), newNick);
|
||||
|
||||
msg("Your nickname is now: " + newNick);
|
||||
msgNew("Your nickname is now: <new>", Placeholder.component("new", FUtil.colorizeAsComponent(newNick)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ 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;
|
||||
@ -24,19 +25,11 @@ public class Command_ops extends FreedomCommand
|
||||
if (args[0].equalsIgnoreCase("count"))
|
||||
{
|
||||
int totalOps = server.getOperators().size();
|
||||
int onlineOps = 0;
|
||||
long onlineOps = server.getOnlinePlayers().stream().filter(player -> player.isOp()).count();
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (player.isOp())
|
||||
{
|
||||
onlineOps++;
|
||||
}
|
||||
}
|
||||
|
||||
msg("Online OPs: " + onlineOps);
|
||||
msg("Offline OPs: " + (totalOps - onlineOps));
|
||||
msg("Total OPs: " + totalOps);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -50,14 +43,16 @@ public class Command_ops extends FreedomCommand
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Purging all operators", true);
|
||||
|
||||
for (OfflinePlayer player : server.getOperators())
|
||||
server.getOperators().forEach(operator ->
|
||||
{
|
||||
player.setOp(false);
|
||||
if (player.isOnline())
|
||||
operator.setOp(false);
|
||||
|
||||
if (operator.isOnline())
|
||||
{
|
||||
msg(Objects.requireNonNull(player.getPlayer()), FreedomCommand.YOU_ARE_NOT_OP);
|
||||
msg(Objects.requireNonNull(operator.getPlayer()), YOU_ARE_NOT_OP);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1,79 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.ActivityLogEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Gets your playtime statistics.", usage = "/<command>")
|
||||
public class Command_playtime extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
ActivityLogEntry entry = plugin.acl.getActivityLog(playerSender);
|
||||
int seconds = entry.getTotalSecondsPlayed();
|
||||
int minutes = 0;
|
||||
int hours = 0;
|
||||
while (seconds >= 60)
|
||||
{
|
||||
seconds -= 60;
|
||||
minutes += 1;
|
||||
}
|
||||
while (minutes >= 60)
|
||||
{
|
||||
minutes -= 60;
|
||||
hours += 1;
|
||||
}
|
||||
if (entry.getTimestamps().size() == 0)
|
||||
{
|
||||
entry.addLogin();
|
||||
}
|
||||
String lastLoginString = entry.getTimestamps().get(entry.getTimestamps().size() - 1);
|
||||
Date currentTime = Date.from(Instant.now());
|
||||
lastLoginString = lastLoginString.replace("Login: ", "");
|
||||
Date lastLogin = FUtil.stringToDate(lastLoginString);
|
||||
|
||||
long duration = currentTime.getTime() - lastLogin.getTime();
|
||||
long cseconds = duration / 1000 % 60;
|
||||
long cminutes = duration / (60 * 1000) % 60;
|
||||
long chours = duration / (60 * 60 * 1000);
|
||||
StringBuilder sb = new StringBuilder()
|
||||
.append("Playtime - ")
|
||||
.append(sender.getName())
|
||||
.append("\n")
|
||||
.append("Current Session: ")
|
||||
.append(chours)
|
||||
.append(" hours, ")
|
||||
.append(cminutes)
|
||||
.append(" minutes, and ")
|
||||
.append(cseconds)
|
||||
.append(" seconds")
|
||||
.append("\n")
|
||||
.append("Overall: ")
|
||||
.append(hours)
|
||||
.append(" hours, ")
|
||||
.append(minutes)
|
||||
.append(" minutes, and ")
|
||||
.append(seconds)
|
||||
.append(" seconds")
|
||||
.append("\n");
|
||||
List<String> durations = entry.getDurations();
|
||||
if (durations.size() >= 3)
|
||||
{
|
||||
sb.append("Recent Sessions:");
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
sb.append("\n" + " - ").append(durations.get((durations.size() - 1) - i));
|
||||
}
|
||||
}
|
||||
msg(sb.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Forcefully start a reaction", usage = "/<command>")
|
||||
public class Command_reactionbar extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("The shop is currently disabled", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!FUtil.isDeveloper(playerSender))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
|
||||
plugin.sh.forceStartReaction();
|
||||
msg("Started a reaction.");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -36,14 +36,14 @@ public class Command_report extends FreedomCommand
|
||||
{
|
||||
if (player.equals(playerSender))
|
||||
{
|
||||
msg(ChatColor.RED + "Please, don't try to report yourself.");
|
||||
msgNew("<red>Please, don't try to report yourself.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
msg(ChatColor.RED + "You can not report admins.");
|
||||
msgNew("<red>You can't report admins with this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -59,8 +59,11 @@ public class Command_report extends FreedomCommand
|
||||
logged = (player == null) ? plugin.dc.sendReportOffline(playerSender, offlinePlayer, report) : plugin.dc.sendReport(playerSender, player, report);
|
||||
}
|
||||
|
||||
msg(ChatColor.GREEN + "Thank you, your report has been successfully logged."
|
||||
+ (logged ? ChatColor.RED + "\nNote: This report has been logged to a discord channel, as with any report system, spamming reports can lead to you getting banned." : ""));
|
||||
msgNew("<green>Thank you, your report has been successfully logged.");
|
||||
if (logged)
|
||||
{
|
||||
msgNew("<red>Note: This report has been logged to a Discord channel, as with any report system, spamming reports can lead to you getting banned.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ 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;
|
||||
@ -26,7 +27,7 @@ public class Command_ride extends FreedomCommand
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
||||
if (fPlayer.getCageData().isCaged())
|
||||
{
|
||||
msg("You cannot use this command while caged.");
|
||||
msgNew("<red>You cannot use this command while caged.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -39,20 +40,20 @@ public class Command_ride extends FreedomCommand
|
||||
{
|
||||
if (!RIDE_REQUESTS.containsKey(playerSender))
|
||||
{
|
||||
msg("You don't have any pending requests.");
|
||||
msgNew("<red>You don't have any pending requests.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player requester = RIDE_REQUESTS.get(playerSender);
|
||||
if (requester == null)
|
||||
{
|
||||
msg("The player who sent the request is no longer online.");
|
||||
msgNew("<red>The player who sent the request is no longer online.");
|
||||
RIDE_REQUESTS.remove(playerSender);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Request accepted.");
|
||||
msg(requester, "Your request has been accepted.");
|
||||
msgNew("Request accepted.");
|
||||
msgNew(requester, "<green>Your request has been accepted.");
|
||||
|
||||
if (requester.getWorld() != playerSender.getWorld())
|
||||
{
|
||||
@ -68,19 +69,19 @@ public class Command_ride extends FreedomCommand
|
||||
{
|
||||
if (!RIDE_REQUESTS.containsKey(playerSender))
|
||||
{
|
||||
msg("You don't have any pending requests.");
|
||||
msgNew("<red>You don't have any pending requests.");
|
||||
return true;
|
||||
}
|
||||
Player requester = RIDE_REQUESTS.get(playerSender);
|
||||
if (requester == null)
|
||||
{
|
||||
msg("The player who sent the request is no longer online.");
|
||||
msgNew("<red>The player who sent the request is no longer online.");
|
||||
RIDE_REQUESTS.remove(playerSender);
|
||||
return true;
|
||||
}
|
||||
msg("Request denied.");
|
||||
msgNew("Request denied.");
|
||||
RIDE_REQUESTS.remove(playerSender);
|
||||
msg(requester, "Your request has been denied.");
|
||||
msgNew(requester, "<red>Your request has been denied.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -92,11 +93,11 @@ public class Command_ride extends FreedomCommand
|
||||
PlayerData playerDataSender = plugin.pl.getData(playerSender);
|
||||
playerDataSender.setRideMode(mode);
|
||||
plugin.pl.save(playerDataSender);
|
||||
msg("Ride mode is now set to " + mode.name().toLowerCase() + ".");
|
||||
msgNew("Ride mode is now set to <mode>.", Placeholder.unparsed("mode", mode.name().toLowerCase()));
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
msg("Invalid mode.", ChatColor.RED);
|
||||
msgNew("<red>Invalid mode.");
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -113,23 +114,23 @@ public class Command_ride extends FreedomCommand
|
||||
|
||||
if (player == playerSender)
|
||||
{
|
||||
msg("You can't ride yourself. smh.", ChatColor.RED);
|
||||
msgNew("<red>You can't ride yourself.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerData.getRideMode() == PlayerData.RideMode.OFF && !isAdmin(sender))
|
||||
{
|
||||
msg("That player cannot be ridden.", ChatColor.RED);
|
||||
msgNew("<red>That player cannot be ridden.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerData.getRideMode() == PlayerData.RideMode.ASK && !FUtil.isExecutive(playerSender.getName()))
|
||||
{
|
||||
msg("Sent a request to the player.", ChatColor.GREEN);
|
||||
msg(player, sender.getName() + " has requested to ride you.", ChatColor.AQUA);
|
||||
msg(player, "Type " + ChatColor.GREEN + "/ride accept" + ChatColor.AQUA + " to allow the player to ride you.", ChatColor.AQUA);
|
||||
msg(player, "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.", ChatColor.AQUA);
|
||||
msg(player, "Request will expire in 30 seconds.", ChatColor.AQUA);
|
||||
msgNew("<green>Sent a request to the player.");
|
||||
msgNew(player, "<aqua><player> has requested to ride you.", Placeholder.unparsed("player", sender.getName()));
|
||||
msgNew(player, "<aqua>Type <green>/ride accept</green> to allow the player to ride you.");
|
||||
msgNew(player, "<aqua>Type <red>/ride deny</red> to deny their request.");
|
||||
msgNew(player, "<aqua>This request will expire in 30 seconds.");
|
||||
RIDE_REQUESTS.put(player, playerSender);
|
||||
|
||||
new BukkitRunnable()
|
||||
@ -142,8 +143,8 @@ public class Command_ride extends FreedomCommand
|
||||
}
|
||||
|
||||
RIDE_REQUESTS.remove(player);
|
||||
msg(playerSender, "It has been 30 seconds and " + player.getName() + " has not accepted your request.", ChatColor.RED);
|
||||
msg(player, "Request expired.", ChatColor.RED);
|
||||
msgNew(playerSender, "<red>Your request to ride <player> has automatically expired.", Placeholder.unparsed("player", player.getName()));
|
||||
msgNew(player, "<red>Request expired.");
|
||||
}
|
||||
}.runTaskLater(plugin, 20 * 30);
|
||||
return true;
|
||||
@ -155,7 +156,7 @@ public class Command_ride extends FreedomCommand
|
||||
}
|
||||
|
||||
player.addPassenger(playerSender);
|
||||
msg(player, playerSender.getName() + " is now riding you, run /eject to eject them.");
|
||||
msgNew(player, "<player> is now riding you, run /eject to eject them.", Placeholder.unparsed("player", sender.getName()));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ 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 net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -33,7 +34,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
{
|
||||
case "list":
|
||||
{
|
||||
msg("Admins: " + StringUtils.join(plugin.al.getAdminNames(), ", "), ChatColor.GOLD);
|
||||
msgNew("<gold>Admins: <admins>", Placeholder.unparsed("admins", StringUtils.join(plugin.al.getAdminNames(), ", ")));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -44,8 +45,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Cleaning the admin list", true);
|
||||
plugin.al.deactivateOldEntries(true);
|
||||
msg("Admins: " + StringUtils.join(plugin.al.getAdminNames(), ", "), ChatColor.GOLD);
|
||||
|
||||
msgNew("<gold>Admins: <admins>", Placeholder.unparsed("admins", StringUtils.join(plugin.al.getAdminNames(), ", ")));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Reloading the admin list", true);
|
||||
plugin.al.load();
|
||||
msg("Admin list reloaded!");
|
||||
msgNew("Admin list reloaded!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -72,26 +72,26 @@ public class Command_saconfig extends FreedomCommand
|
||||
Rank rank = Rank.findRank(args[2]);
|
||||
if (rank == null)
|
||||
{
|
||||
msg("Unknown rank: " + args[2]);
|
||||
msgNew("<red>Unknown rank: <rank>", Placeholder.unparsed("rank", args[2]));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rank.isConsole())
|
||||
{
|
||||
msg("You cannot set players to a console rank");
|
||||
msgNew("<red>What, did you think it was going to be that easy?");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!rank.isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
msg("Rank must be Admin or higher.", ChatColor.RED);
|
||||
msgNew("<red>Rank must be Admin or higher.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Admin admin = plugin.al.getEntryByName(args[1]);
|
||||
if (admin == null)
|
||||
{
|
||||
msg("Unknown admin: " + args[1]);
|
||||
msgNew("Unknown admin: <player>", Placeholder.unparsed("player", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -111,7 +111,9 @@ public class Command_saconfig extends FreedomCommand
|
||||
plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
}
|
||||
|
||||
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
||||
msgNew("Set <admin>'s rank to <rank>.", Placeholder.unparsed("admin", admin.getName()),
|
||||
Placeholder.unparsed("rank", rank.getName()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -137,11 +139,12 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
if (admin == null)
|
||||
{
|
||||
msg("Admin not found: " + args[1]);
|
||||
msgNew("Unknown admin: <player>", Placeholder.unparsed("player", args[1]));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(admin.toString());
|
||||
msgNew(admin.toString());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -162,13 +165,13 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
msg("That player is already an admin.");
|
||||
msgNew("<red>That player is already an admin.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -212,7 +215,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
{
|
||||
fPlayer.getFreezeData().setFrozen(false);
|
||||
msg(player, "You have been unfrozen.");
|
||||
msgNew(player, "You have been unfrozen.");
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -234,7 +237,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
if (admin == null)
|
||||
{
|
||||
msg("Admin not found: " + args[1]);
|
||||
msgNew("Unknown admin: <player>", Placeholder.unparsed("player", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -12,7 +13,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Broadcasts the given message as the server, includes sender name.", usage = "/<command> <message>")
|
||||
public class Command_say extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -23,26 +23,12 @@ public class Command_say extends FreedomCommand
|
||||
|
||||
String message = StringUtils.join(args, " ");
|
||||
|
||||
if (senderIsConsole && FUtil.isFromHostConsole(sender.getName()))
|
||||
server.broadcast(FUtil.miniMessage("<light_purple>[Server:<player>] <message>",
|
||||
Placeholder.unparsed("player", sender.getName()),
|
||||
Placeholder.unparsed("message", message)));
|
||||
|
||||
if (plugin.dc != null)
|
||||
{
|
||||
if (message.equalsIgnoreCase("WARNING: Server is restarting, you will be kicked"))
|
||||
{
|
||||
FUtil.bcastMsg("Server is going offline.", ChatColor.GRAY);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
player.kickPlayer(ChatColor.LIGHT_PURPLE + "Server is going offline, come back in about 20 seconds.");
|
||||
}
|
||||
|
||||
server.shutdown();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
FUtil.bcastMsg(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE);
|
||||
|
||||
if (plugin.dc != null) {
|
||||
plugin.dc.messageChatChannel(String.format("[Server:%s] \u00BB %s", sender.getName(), message), true);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
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 net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.Command;
|
||||
@ -18,12 +15,6 @@ public class Command_scare extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!FUtil.isPaper())
|
||||
{
|
||||
msg("This command won't work without Paper!", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
@ -33,30 +24,20 @@ public class Command_scare extends FreedomCommand
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Scared " + player.getName());
|
||||
msg(player, "ZING", ChatColor.RED);
|
||||
msgNew("Spooked the hell out of <player>.", Placeholder.unparsed("player", player.getName()));
|
||||
msgNew(player, "<red>ZING");
|
||||
|
||||
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_SCREAM, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -14,6 +15,12 @@ public class Command_setlimit extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!server.getPluginManager().isPluginEnabled("WorldEdit"))
|
||||
{
|
||||
msgNew("<red>WorldEdit is not enabled on this server.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int amount = plugin.web.getDefaultLimit();
|
||||
if (args.length > 0)
|
||||
{
|
||||
@ -23,28 +30,14 @@ public class Command_setlimit extends FreedomCommand
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[0], ChatColor.RED);
|
||||
msgNew("<red>Invalid number: <number>", Placeholder.unparsed("number", args[0]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
boolean success = false;
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.web.setLimit(player, amount);
|
||||
success = true;
|
||||
}
|
||||
catch (NoClassDefFoundError | NullPointerException ex)
|
||||
{
|
||||
msg("WorldEdit is not enabled on this server.");
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Setting everyone's WorldEdit block modification limit to " + amount + ".", true);
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Setting everyone's WorldEdit block modification limit to " + amount + ".", true);
|
||||
int finalAmount = amount;
|
||||
server.getOnlinePlayers().forEach(player -> plugin.web.setLimit(player, finalAmount));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -15,6 +16,12 @@ public class Command_setplayerlimit extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!server.getPluginManager().isPluginEnabled("WorldEdit"))
|
||||
{
|
||||
msgNew("<red>WorldEdit is not enabled on this server.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int amount;
|
||||
if (args.length > 0)
|
||||
{
|
||||
@ -33,7 +40,7 @@ public class Command_setplayerlimit extends FreedomCommand
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[1], ChatColor.RED);
|
||||
msgNew("<red>Invalid number: <amount>", Placeholder.unparsed("amount", args[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -46,22 +53,11 @@ public class Command_setplayerlimit extends FreedomCommand
|
||||
{
|
||||
return false;
|
||||
}
|
||||
boolean success = false;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
try
|
||||
{
|
||||
plugin.web.setLimit(player, amount);
|
||||
success = true;
|
||||
}
|
||||
catch (NoClassDefFoundError | NullPointerException ex)
|
||||
{
|
||||
msg("WorldEdit is not enabled on this server.");
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
assert player != null;
|
||||
FUtil.adminAction(sender.getName(), "Setting " + player.getName() + "'s WorldEdit block modification limit to " + amount + ".", true);
|
||||
}
|
||||
FUtil.adminAction(sender.getName(), "Setting " + player.getName() + "'s WorldEdit block modification limit to " + amount + ".", true);
|
||||
plugin.web.setLimit(player, amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ 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;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -18,8 +19,7 @@ public class Command_setspawnworld extends FreedomCommand
|
||||
Location pos = playerSender.getLocation();
|
||||
playerSender.getWorld().setSpawnLocation(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
|
||||
msg("Spawn location for this world set to: " + FUtil.formatLocation(playerSender.getWorld().getSpawnLocation()));
|
||||
|
||||
msgNew("Set the spawn location for this world to <location>", Placeholder.unparsed("location", FUtil.formatLocation(playerSender.getWorld().getSpawnLocation())));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,63 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
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.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Set a player's total votes", usage = "/<command> <player> <votes>")
|
||||
public class Command_settotalvotes extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (!ConfigEntry.SERVER_OWNERS.getStringList().contains(sender.getName()))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int votes;
|
||||
try
|
||||
{
|
||||
votes = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
msg("Invalid number: " + args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData playerData = plugin.pl.getData(args[1]);
|
||||
|
||||
if (playerData == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Set " + args[1] + "'s votes to " + args[0]);
|
||||
|
||||
playerData.setTotalVotes(votes);
|
||||
plugin.pl.save(playerData);
|
||||
|
||||
Player player = getPlayer(args[1]);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
msg(player, sender.getName() + " has set your total votes to " + votes, ChatColor.GREEN);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ 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;
|
||||
@ -11,15 +10,15 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Open the shop GUI", usage = "/<command>", aliases = "sh")
|
||||
public class Command_shop extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null || !ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||
{
|
||||
msg("The shop is currently disabled!", ChatColor.RED);
|
||||
msgNew("<red>Shop is currently disabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
playerSender.openInventory(plugin.sh.generateShopGUI(plugin.pl.getData(playerSender)));
|
||||
return true;
|
||||
}
|
||||
|
@ -18,17 +18,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-ci | -q]")
|
||||
public class Command_smite extends FreedomCommand
|
||||
{
|
||||
|
||||
public static void smite(CommandSender sender, Player player)
|
||||
{
|
||||
smite(sender, player, null, false, false);
|
||||
}
|
||||
|
||||
public static void smite(CommandSender sender, Player player, String reason)
|
||||
{
|
||||
smite(sender, player, reason, false, false);
|
||||
}
|
||||
|
||||
public static void smite(CommandSender sender, Player player, String reason, Boolean silent, Boolean clearinv)
|
||||
{
|
||||
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
|
@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Quickly spectate someone.", usage = "/<command> <playername>", aliases = "spec")
|
||||
public class Command_spectate extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -30,7 +29,7 @@ public class Command_spectate extends FreedomCommand
|
||||
|
||||
if (player.getGameMode().equals(GameMode.SPECTATOR))
|
||||
{
|
||||
msg("You cannot spectate other players that are in spectator mode.", ChatColor.RED);
|
||||
msgNew("<red>You cannot spectate other players that are in spectator mode.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -11,23 +12,23 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Obtain a stacking potato", usage = "/<command>")
|
||||
public class Command_stackingpotato extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("The shop is currently disabled.", ChatColor.RED);
|
||||
if (plugin.sh == null)
|
||||
{
|
||||
msgNew("<red>Shop is currently disabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.STACKING_POTATO))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getStackingPotato());
|
||||
msg("You have been given a Stacking Potato", ChatColor.GREEN);
|
||||
msgNew("<green>You have been given the <item>.", Placeholder.unparsed("item", ShopItem.STACKING_POTATO.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own the Stacking Potato! Purchase one from the shop.", ChatColor.RED);
|
||||
msgNew("<red>You don't own the <item>! Purchase it from the shop.", Placeholder.unparsed("item", ShopItem.STACKING_POTATO.getName()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
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.BOTH)
|
||||
@CommandParameters(description = "Shows Minecraft server info, such as authentication status.", usage = "/<command>")
|
||||
public class Command_status extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
msg("For information about TotalFreedomMod, try /tfm", ChatColor.GREEN); // Temporary
|
||||
|
||||
msg("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.YELLOW);
|
||||
msg("Loaded worlds:", ChatColor.BLUE);
|
||||
int i = 0;
|
||||
for (World world : server.getWorlds())
|
||||
{
|
||||
msg(String.format("World %d: %s - %d players.", i++, world.getName(), world.getPlayers().size()), ChatColor.BLUE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ public class Command_stopsound extends FreedomCommand
|
||||
|
||||
playerSender.stopAllSounds();
|
||||
|
||||
msg("Stopped all sounds.", ChatColor.GREEN);
|
||||
msgNew("<green>Stopped all sounds.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class Command_toggle extends FreedomCommand
|
||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]",
|
||||
"explosives [radius]", "unsafeenchs", "bells", "armorstands", "masterblocks", "books", "grindstones",
|
||||
"jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44",
|
||||
"landmines", "tossmob", "gravity", "chat");
|
||||
"landmines", "tossmob", "gravity", "chat", "disguises");
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
@ -134,6 +134,22 @@ public class Command_toggle extends FreedomCommand
|
||||
case "tossmob" -> toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED);
|
||||
case "gravity" -> toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY);
|
||||
case "chat" -> toggle("Chat is", ConfigEntry.TOGGLE_CHAT);
|
||||
case "disguises" ->
|
||||
{
|
||||
if (!plugin.ldb.isEnabled())
|
||||
{
|
||||
msgNew("<red>LibsDisguises is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.ldb.isDisguisesEnabled())
|
||||
{
|
||||
plugin.ldb.undisguiseAll(true);
|
||||
}
|
||||
|
||||
plugin.ldb.setDisguisesEnabled(!plugin.ldb.isDisguisesEnabled());
|
||||
msgNew("Disguises are now <status>.", Placeholder.unparsed("status", plugin.ldb.isDisguisesEnabled() ? "enabled." : "disabled."));
|
||||
}
|
||||
default ->
|
||||
{
|
||||
msgNew("Available toggles: ");
|
||||
@ -164,7 +180,7 @@ public class Command_toggle extends FreedomCommand
|
||||
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
|
||||
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
|
||||
"respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob", "gravity", "chat");
|
||||
"respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob", "gravity", "chat", "disguises");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -16,7 +17,8 @@ public class Command_togglediscord extends FreedomCommand
|
||||
PlayerData data = plugin.pl.getData(playerSender);
|
||||
data.setDisplayDiscord(!data.doesDisplayDiscord());
|
||||
plugin.pl.save(data);
|
||||
msg("Discord messages will " + (data.doesDisplayDiscord() ? "now" : "no longer") + " be shown.");
|
||||
|
||||
msgNew("Discord messages will <status> be shown.", Placeholder.unparsed("status", data.doesDisplayDiscord() ? "now" : "no longer"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ public class Command_togglepickup extends FreedomCommand
|
||||
{
|
||||
boolean enabled = !playerSender.getCanPickupItems();
|
||||
playerSender.setCanPickupItems(enabled);
|
||||
msg((enabled ? "En" : "Dis") + "abled item pickup.", (enabled ? ChatColor.GREEN : ChatColor.RED));
|
||||
|
||||
msgNew(enabled ? "<green>Enabled item pickup." : "<red>Disabled item pickup.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class Command_tossmob extends FreedomCommand
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msgNew("<red>The input provided is not a valid integer.");
|
||||
msgNew("<red>Invalid speed: <speed>", Placeholder.unparsed("speed", args[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ 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;
|
||||
@ -38,33 +39,28 @@ public class Command_totalfreedommod extends FreedomCommand
|
||||
plugin.fsh.stopServices();
|
||||
plugin.fsh.startServices();
|
||||
|
||||
final String message = String.format("%s v%s reloaded.",
|
||||
msgNew("<name> v<version> reloaded.",
|
||||
Placeholder.unparsed("name", TotalFreedomMod.pluginName),
|
||||
Placeholder.unparsed("version", TotalFreedomMod.pluginVersion));
|
||||
FLog.info(String.format("%s v%s reloaded.",
|
||||
TotalFreedomMod.pluginName,
|
||||
TotalFreedomMod.pluginVersion);
|
||||
|
||||
msg(message);
|
||||
FLog.info(message);
|
||||
TotalFreedomMod.pluginVersion));
|
||||
return true;
|
||||
}
|
||||
|
||||
TotalFreedomMod.BuildProperties build = TotalFreedomMod.build;
|
||||
msg("TotalFreedomMod for 'Total Freedom', the original all-op server.", ChatColor.GOLD);
|
||||
msg("Running on " + ConfigEntry.SERVER_NAME.getString() + ".", ChatColor.GOLD);
|
||||
msg("Created by Madgeek1450 and Prozza.", ChatColor.GOLD);
|
||||
msg(String.format("Version "
|
||||
+ ChatColor.BLUE + "%s - %s Build %s " + ChatColor.GOLD + "("
|
||||
+ ChatColor.BLUE + "%s" + ChatColor.GOLD + ")",
|
||||
build.codename,
|
||||
build.version,
|
||||
build.number,
|
||||
build.head), ChatColor.GOLD);
|
||||
msg(String.format("Compiled "
|
||||
+ ChatColor.BLUE + "%s" + ChatColor.GOLD + " by "
|
||||
+ ChatColor.BLUE + "%s",
|
||||
build.date,
|
||||
build.author), ChatColor.GOLD);
|
||||
msg("Visit " + ChatColor.AQUA + "http://github.com/TotalFreedom/TotalFreedomMod"
|
||||
+ ChatColor.GREEN + " for more information.", ChatColor.GREEN);
|
||||
msgNew("<gold>TotalFreedomMod for 'Total Freedom', the original all-op server.");
|
||||
msgNew("<gold>Running on <server>.", Placeholder.unparsed("server", ConfigEntry.SERVER_NAME.getString()));
|
||||
msgNew("<gold>Created by Madgeek1450 and Prozza.");
|
||||
msgNew("<gold>Version <blue><codename> - <version> Build <number> </blue>(<blue><head></blue>)",
|
||||
Placeholder.unparsed("codename", build.codename),
|
||||
Placeholder.unparsed("version", build.version),
|
||||
Placeholder.unparsed("number", build.number),
|
||||
Placeholder.unparsed("head", build.head));
|
||||
msgNew("<gold>Compiled <blue><date></blue> by <blue><author></blue>",
|
||||
Placeholder.unparsed("date", build.date),
|
||||
Placeholder.unparsed("author", build.author));
|
||||
msgNew("<green>Visit <aqua>http://github.com/TotalFreedom/TotalFreedomMod</aqua> for more information.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ import java.util.*;
|
||||
public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
{
|
||||
public static final String COMMAND_PREFIX = "Command_";
|
||||
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
||||
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
||||
public static final Component YOU_ARE_OP = Component.text("You are now op!", NamedTextColor.YELLOW);
|
||||
public static final Component YOU_ARE_NOT_OP = Component.text("You are no longer op!", NamedTextColor.YELLOW);
|
||||
public static final Component PLAYER_NOT_FOUND = Component.text("Player not found!", NamedTextColor.GRAY);
|
||||
public static final String ONLY_CONSOLE = ChatColor.RED + "Only console senders may execute this command!";
|
||||
public static final String ONLY_IN_GAME = ChatColor.RED + "Only in-game players may execute this command!";
|
||||
@ -123,22 +123,12 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
protected void msg(CommandSender sender, String message)
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + message);
|
||||
}
|
||||
|
||||
protected void msg(Player player, String message)
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + message);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void msg(Player player, String message, ChatColor color)
|
||||
{
|
||||
player.sendMessage(color + message);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void msg(String message)
|
||||
{
|
||||
@ -155,8 +145,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
msgNew(sender, message, placeholders);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Deprecated
|
||||
protected void msg(String message, ChatColor color)
|
||||
{
|
||||
msg(color + message);
|
||||
|
@ -308,8 +308,8 @@ public class ItemFun extends FreedomService
|
||||
}
|
||||
//Redundant Player cast is required to avoid suspicious method calls.
|
||||
if (arrow != null
|
||||
&& (arrow.getShooter() instanceof Player)
|
||||
&& explosivePlayers.contains(arrow.getShooter()))
|
||||
&& (arrow.getShooter() instanceof Player player)
|
||||
&& plugin.pl.getPlayer(player).isExplosiveArrowsEnabled())
|
||||
{
|
||||
Objects.requireNonNull(arrow.getLocation().getWorld()).createExplosion(arrow.getLocation().getX(), arrow.getLocation().getY(), arrow.getLocation().getZ(), ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue(), false, ConfigEntry.ALLOW_EXPLOSIONS.getBoolean());
|
||||
arrow.remove();
|
||||
|
@ -11,7 +11,6 @@ import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_activitylog;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_admins;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_bans;
|
||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_file;
|
||||
@ -89,7 +88,6 @@ public class HTTPDaemon extends FreedomService
|
||||
|
||||
// Modules
|
||||
modules.clear();
|
||||
module("activitylog", Module_activitylog.class, true);
|
||||
module("admins", Module_admins.class, true);
|
||||
module("bans", Module_bans.class, true);
|
||||
module("help", Module_help.class, false);
|
||||
|
@ -1,44 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||
|
||||
import java.io.File;
|
||||
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||
|
||||
public class Module_activitylog extends HTTPDModule
|
||||
{
|
||||
|
||||
public Module_activitylog(NanoHTTPD.HTTPSession session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NanoHTTPD.Response getResponse()
|
||||
{
|
||||
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
||||
|
||||
if (!isAuthorized(remoteAddress))
|
||||
{
|
||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||
"You may not view the activity log. Your IP, " + remoteAddress + ", is not registered to an admin on the server.");
|
||||
}
|
||||
File activityLogFile = new File(plugin.getDataFolder(), ActivityLog.FILENAME);
|
||||
if (activityLogFile.exists())
|
||||
{
|
||||
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), ActivityLog.FILENAME));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||
"Error 404: Not Found - The requested resource was not found on this server.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAuthorized(String remoteAddress)
|
||||
{
|
||||
Admin entry = plugin.al.getEntryByIp(remoteAddress);
|
||||
return entry != null && entry.isActive();
|
||||
}
|
||||
}
|
@ -64,6 +64,7 @@ public class FPlayer
|
||||
private boolean invSee = false;
|
||||
|
||||
private boolean clownfishDisabled = false;
|
||||
private boolean explosiveArrowsEnabled = false;
|
||||
|
||||
public FPlayer(TotalFreedomMod plugin, Player player)
|
||||
{
|
||||
@ -447,6 +448,16 @@ public class FPlayer
|
||||
this.clownfishDisabled = bool;
|
||||
}
|
||||
|
||||
public boolean isExplosiveArrowsEnabled()
|
||||
{
|
||||
return explosiveArrowsEnabled;
|
||||
}
|
||||
|
||||
public void setExplosiveArrowsEnabled(boolean bool)
|
||||
{
|
||||
this.explosiveArrowsEnabled = bool;
|
||||
}
|
||||
|
||||
private static class ArrowShooter extends BukkitRunnable
|
||||
{
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
#
|
||||
# TotalFreedomMod Activity Log
|
||||
#
|
Loading…
Reference in New Issue
Block a user