mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +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;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||||
import me.totalfreedom.totalfreedommod.api.Aggregator;
|
import me.totalfreedom.totalfreedommod.api.Aggregator;
|
||||||
import me.totalfreedom.totalfreedommod.api.ShoppeCommons;
|
import me.totalfreedom.totalfreedommod.api.ShoppeCommons;
|
||||||
@ -58,7 +57,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public CommandLoader cl;
|
public CommandLoader cl;
|
||||||
// Services
|
// Services
|
||||||
public WorldManager wm;
|
public WorldManager wm;
|
||||||
public ActivityLog acl;
|
|
||||||
public AdminList al;
|
public AdminList al;
|
||||||
public RankManager rm;
|
public RankManager rm;
|
||||||
public CommandBlocker cb;
|
public CommandBlocker cb;
|
||||||
@ -285,7 +283,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
wm = new WorldManager();
|
wm = new WorldManager();
|
||||||
sql = new SQLite();
|
sql = new SQLite();
|
||||||
al = new AdminList();
|
al = new AdminList();
|
||||||
acl = new ActivityLog();
|
|
||||||
rm = new RankManager();
|
rm = new RankManager();
|
||||||
cb = new CommandBlocker();
|
cb = new CommandBlocker();
|
||||||
eb = new EventBlocker();
|
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.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||||
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -67,12 +68,12 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
|
|
||||||
if (adminWorld == null || playerSender.getWorld() == adminWorld)
|
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());
|
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("Going to the AdminWorld.");
|
msgNew("Going to the AdminWorld.");
|
||||||
plugin.wm.adminworld.sendToWorld(playerSender);
|
plugin.wm.adminworld.sendToWorld(playerSender);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -87,11 +88,11 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
if (timeOfDay != null)
|
if (timeOfDay != null)
|
||||||
{
|
{
|
||||||
plugin.wm.adminworld.setTimeOfDay(timeOfDay);
|
plugin.wm.adminworld.setTimeOfDay(timeOfDay);
|
||||||
msg("AdminWorld time set to: " + timeOfDay.name());
|
msgNew("AdminWorld time set to: <time>", Placeholder.unparsed("time", timeOfDay.name()));
|
||||||
}
|
}
|
||||||
else
|
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
|
else
|
||||||
@ -111,11 +112,11 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
if (weatherMode != null)
|
if (weatherMode != null)
|
||||||
{
|
{
|
||||||
plugin.wm.adminworld.setWeatherMode(weatherMode);
|
plugin.wm.adminworld.setWeatherMode(weatherMode);
|
||||||
msg("AdminWorld weather set to: " + weatherMode.name());
|
msgNew("AdminWorld weather set to <mode>.", Placeholder.unparsed("mode", weatherMode.name()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("Invalid weather mode. Can be: off, rain, storm");
|
msgNew("<red>Invalid weather mode. Can be: off, rain, storm");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -137,7 +138,7 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
{
|
{
|
||||||
return noPerms();
|
return noPerms();
|
||||||
}
|
}
|
||||||
msg(ex.getMessage());
|
msgNew("<red>" + ex.getMessage());
|
||||||
return true;
|
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.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -118,7 +119,7 @@ public class Command_ban extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("Banned " + player.getName() + " quietly.");
|
msgNew("Banned <player> quietly.", Placeholder.unparsed("player", player.getName()));
|
||||||
}
|
}
|
||||||
// Kill player
|
// Kill player
|
||||||
player.setHealth(0.0);
|
player.setHealth(0.0);
|
||||||
@ -160,7 +161,9 @@ public class Command_ban extends FreedomCommand
|
|||||||
{
|
{
|
||||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
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);
|
FUtil.adminAction(sender.getName(), bcast.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,13 +171,9 @@ public class Command_ban extends FreedomCommand
|
|||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
player.kickPlayer(ban.bakeKickMessage());
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
server.getOnlinePlayers().stream().filter(pl -> FUtil.getIp(pl).equalsIgnoreCase(ip)).forEach(pl ->
|
||||||
if (FUtil.getIp(p).equals(FUtil.getIp(player)))
|
player.kickPlayer(ban.bakeKickMessage()));
|
||||||
{
|
|
||||||
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log ban
|
// Log ban
|
||||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -31,7 +32,7 @@ public class Command_banname extends FreedomCommand
|
|||||||
|
|
||||||
if (plugin.bm.getByUsername(name) != null)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,11 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -29,12 +31,13 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||||
plugin.pl.getPlayer(player).isEditBlocked()).sorted().toList();
|
plugin.pl.getPlayer(player).isEditBlocked()).sorted().toList();
|
||||||
|
|
||||||
// Oh dear god, why do I have to do it like this?
|
boolean plural = list.size() != 1;
|
||||||
msg("There " + (list.size() != 1 ? "are " : "is ") + list.size() + " player"
|
msgNew("There <grammar> <count> player<plural> online with restricted block modification abilities: <players>",
|
||||||
+ (list.size() != 1 ? "s" : "") + " online with restricted block modification abilities"
|
Placeholder.unparsed("grammar", plural ? "are" : "is"),
|
||||||
+ (list.size() > 0 ? ":" : "."));
|
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||||
|
Placeholder.unparsed("plural", plural ? "s" : ""),
|
||||||
list.forEach(player -> msg("- " + player.getName()));
|
Placeholder.unparsed("colon", list.size() > 0 ? ":" : "."),
|
||||||
|
Placeholder.unparsed("players", FUtil.listToString(list.stream().map(HumanEntity::getName).toList())));
|
||||||
}
|
}
|
||||||
case "purge" ->
|
case "purge" ->
|
||||||
{
|
{
|
||||||
@ -46,11 +49,12 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
list.forEach(player ->
|
list.forEach(player ->
|
||||||
{
|
{
|
||||||
plugin.pl.getPlayer(player).setEditBlocked(false);
|
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"
|
msgNew("Restored block modification abilities for <count> player<plural>.",
|
||||||
+ (list.size() != 1 ? "s" : "") + ".");
|
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||||
|
Placeholder.unparsed("plural", list.size() != 1 ? "s" : ""));
|
||||||
}
|
}
|
||||||
case "all", "-a" ->
|
case "all", "-a" ->
|
||||||
{
|
{
|
||||||
@ -62,11 +66,12 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
list.forEach(player ->
|
list.forEach(player ->
|
||||||
{
|
{
|
||||||
plugin.pl.getPlayer(player).setEditBlocked(true);
|
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"
|
msgNew("Restricted block modification abilities for <count> player<plural>.",
|
||||||
+ (list.size() != 1 ? "s" : "") + ".");
|
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||||
|
Placeholder.unparsed("plural", list.size() != 1 ? "s" : ""));
|
||||||
}
|
}
|
||||||
default -> Optional.ofNullable(getPlayer(args[0])).ifPresentOrElse(player ->
|
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);
|
FUtil.adminAction(sender.getName(), "Restoring block modification abilities for " + player.getName(), true);
|
||||||
fPlayer.setEditBlocked(false);
|
fPlayer.setEditBlocked(false);
|
||||||
msg("Restored block modification abilities for " + player.getName() + ".");
|
msgNew("Restored block modification abilities for <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
msg(player, "Your block modification abilities have been restored.", ChatColor.GREEN);
|
msgNew(player, "<green>Your block modification abilities have been restored.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
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
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Restricting block modification abilities for " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Restricting block modification abilities for " + player.getName(), true);
|
||||||
fPlayer.setEditBlocked(true);
|
fPlayer.setEditBlocked(true);
|
||||||
msg("Restricted block modification abilities for " + player.getName() + ".");
|
msgNew("Restricted block modification abilities for <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
msg(player, "Your block modification abilities have been restricted.", ChatColor.RED);
|
msgNew(player, "<red>Your block modification abilities have been restricted.");
|
||||||
|
|
||||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player),
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player),
|
||||||
sender.getName(), PunishmentType.BLOCKEDIT, null));
|
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.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
@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
|
public class Command_blockpvp extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -25,113 +24,89 @@ public class Command_blockpvp extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equals("list"))
|
switch (args[0].toLowerCase())
|
||||||
{
|
{
|
||||||
msg("PVP is blocked for players:");
|
// List
|
||||||
int count = 0;
|
case "list" ->
|
||||||
for (Player player : server.getOnlinePlayers())
|
|
||||||
{
|
{
|
||||||
final FPlayer info = plugin.pl.getPlayer(player);
|
List<String> restricted = server.getOnlinePlayers().stream().filter(player ->
|
||||||
if (info.isPvpBlocked())
|
plugin.pl.getPlayer(player).isPvpBlocked()).map(Player::getName).toList();
|
||||||
|
|
||||||
|
if (restricted.isEmpty())
|
||||||
{
|
{
|
||||||
msg(" - " + player.getName());
|
msgNew("Nobody currently has their PVP abilities restricted.");
|
||||||
++count;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
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())
|
|
||||||
{
|
{
|
||||||
info.setPvpBlocked(false);
|
msgNew("PVP abilities are restricted for these player(s): <players>",
|
||||||
++count;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
|
// Purge
|
||||||
pd.setPvpBlocked(true);
|
case "purge" ->
|
||||||
if (smite)
|
|
||||||
{
|
{
|
||||||
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);
|
// All
|
||||||
msg("Disabled PVP for " + p.getName());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -48,7 +48,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
if (fPlayer.getCageData().isCaged())
|
if (fPlayer.getCageData().isCaged())
|
||||||
{
|
{
|
||||||
msg("That player is already caged.", ChatColor.RED);
|
msgNew("<red>That player is already caged.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("Invalid block!", ChatColor.RED);
|
msgNew("<red>Invalid block!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class Command_cleanchat extends FreedomCommand
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 100; i++)
|
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();
|
plugin.dc.clearQueue();
|
||||||
msg("<green>Cleared the Discord message queue.");
|
msgNew("<green>Cleared the Discord message queue.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -12,11 +13,9 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Clear your inventory.", usage = "/<command> [player]", aliases = "ci,clear")
|
@CommandParameters(description = "Clear your inventory.", usage = "/<command> [player]", aliases = "ci,clear")
|
||||||
public class Command_clearinventory extends FreedomCommand
|
public class Command_clearinventory extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
@ -25,7 +24,7 @@ public class Command_clearinventory extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
playerSender.getInventory().clear();
|
playerSender.getInventory().clear();
|
||||||
msg("Your inventory has been cleared.");
|
msgNew("<green>Your inventory has been cleared.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -34,11 +33,8 @@ public class Command_clearinventory extends FreedomCommand
|
|||||||
if (args[0].equals("-a"))
|
if (args[0].equals("-a"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Clearing everyone's inventory", true);
|
FUtil.adminAction(sender.getName(), "Clearing everyone's inventory", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
server.getOnlinePlayers().forEach(player -> player.getInventory().clear());
|
||||||
{
|
msgNew("<green>Successfully cleared everyone's inventory.");
|
||||||
player.getInventory().clear();
|
|
||||||
}
|
|
||||||
msg("Sucessfully cleared everyone's inventory.");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -51,8 +47,8 @@ public class Command_clearinventory extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
msg("Cleared " + player.getName() + "'s inventory.");
|
msgNew("<green>Successfully cleared <player>'s inventory.", Placeholder.unparsed("player", player.getName()));
|
||||||
msg(player, sender.getName() + " has cleared your inventory.");
|
msgNew(player, "<sender> has cleared your inventory.", Placeholder.unparsed("sender", sender.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -15,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>")
|
@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 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.";
|
private static final Random RANDOM = new Random();
|
||||||
public static final String LORE = "But, you can have a cookie anyways,\nsince you are sad you are have no friends.";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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 ItemStack heldItem = new ItemStack(Material.COOKIE);
|
||||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
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;
|
assert heldItemMeta != null;
|
||||||
heldItemMeta.setDisplayName(name);
|
heldItemMeta.displayName(FUtil.miniMessage("<rainbow>Cookie"));
|
||||||
heldItemMeta.setLore(Arrays.asList(lore.toString().split("\n")));
|
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);
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
for (final Player player : server.getOnlinePlayers())
|
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."));
|
||||||
final int firstEmpty = player.getInventory().firstEmpty();
|
|
||||||
if (firstEmpty >= 0)
|
|
||||||
{
|
|
||||||
player.getInventory().setItem(firstEmpty, heldItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.bcastMsg(output.toString());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public class Command_denick extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!plugin.esb.isEnabled())
|
if (!plugin.esb.isEnabled())
|
||||||
{
|
{
|
||||||
msg("Essentials is not enabled on this server.");
|
msgNew("<red>Essentials is not enabled on this server.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class Command_deop extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
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;
|
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 java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -43,7 +44,7 @@ public class Command_dispfill extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid radius.");
|
msgNew("<red>Invalid radius: <amount>", Placeholder.unparsed("amount", args[0]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ public class Command_dispfill extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
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++)
|
for (int zOffset = -radius; zOffset <= radius; zOffset++)
|
||||||
{
|
{
|
||||||
final Block targetBlock = centerBlock.getRelative(xOffset, yOffset, 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());
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -117,7 +118,10 @@ public class Command_doom extends FreedomCommand
|
|||||||
{
|
{
|
||||||
// message
|
// message
|
||||||
FUtil.adminAction(sender.getName(), "Banning " + player.getName(), true);
|
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
|
// generate explosion
|
||||||
player.getWorld().createExplosion(player.getLocation(), 0F, false);
|
player.getWorld().createExplosion(player.getLocation(), 0F, false);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -38,11 +39,13 @@ public class Command_eject extends FreedomCommand
|
|||||||
|
|
||||||
if (count != 0)
|
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
|
else
|
||||||
{
|
{
|
||||||
msg("Nothing was ejected.", ChatColor.GREEN);
|
msgNew("<green>Nothing was ejected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,6 +9,8 @@ import java.util.stream.IntStream;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -34,31 +36,21 @@ public class Command_enchant extends FreedomCommand
|
|||||||
|
|
||||||
if (item.getType() == Material.AIR)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
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: ");
|
if (enchants.isEmpty())
|
||||||
for (Enchantment ench : Enchantment.values())
|
|
||||||
{
|
{
|
||||||
if (ench.canEnchantItem(item))
|
msgNew("<red>There are no enchantments that work with this item.");
|
||||||
{
|
|
||||||
has_enchantments = true;
|
|
||||||
possible_ench.append(ench.getName()).append(", ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (has_enchantments)
|
|
||||||
{
|
|
||||||
msg(possible_ench.toString());
|
|
||||||
}
|
}
|
||||||
else
|
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"))
|
else if (args[0].equalsIgnoreCase("addall"))
|
||||||
@ -69,18 +61,17 @@ public class Command_enchant extends FreedomCommand
|
|||||||
{
|
{
|
||||||
item.addEnchantment(ench, ench.getMaxLevel());
|
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"))
|
else if (args[0].equalsIgnoreCase("reset"))
|
||||||
{
|
{
|
||||||
item.getEnchantments().keySet().forEach(item::removeEnchantment);
|
item.getEnchantments().keySet().forEach(item::removeEnchantment);
|
||||||
msg("Removed all enchantments.");
|
msgNew("<green>Removed all enchantments.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -89,19 +80,11 @@ public class Command_enchant extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Enchantment ench = null;
|
Enchantment ench = Enchantment.getByName(args[1].toUpperCase());
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ench = Enchantment.getByName(args[1].toUpperCase());
|
|
||||||
}
|
|
||||||
catch (Exception ignored)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ench == null)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +92,7 @@ public class Command_enchant extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!ench.canEnchantItem(item) && !ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean())
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
int level = ench.getMaxLevel();
|
int level = ench.getMaxLevel();
|
||||||
@ -128,7 +111,7 @@ public class Command_enchant extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("\"" + args[2] + "\" is not a valid number", ChatColor.RED);
|
msgNew("Invalid number: <number>", Placeholder.unparsed("number", args[2]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,13 +124,13 @@ public class Command_enchant extends FreedomCommand
|
|||||||
item.addUnsafeEnchantment(ench, level);
|
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"))
|
else if (args[0].equals("remove"))
|
||||||
{
|
{
|
||||||
item.removeEnchantment(ench);
|
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.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -93,13 +94,16 @@ public class Command_entitywipe extends FreedomCommand
|
|||||||
{
|
{
|
||||||
count = plugin.ew.wipeEntities(bypassBlacklist);
|
count = plugin.ew.wipeEntities(bypassBlacklist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 1)
|
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
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -78,11 +79,13 @@ public class Command_expel extends FreedomCommand
|
|||||||
|
|
||||||
if (pushedPlayers.isEmpty())
|
if (pushedPlayers.isEmpty())
|
||||||
{
|
{
|
||||||
msg("No players pushed.");
|
msgNew("No players were pushed.");
|
||||||
}
|
}
|
||||||
else
|
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;
|
return true;
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
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.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -10,21 +14,15 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Make arrows explode", usage = "/<command>", aliases = "ea")
|
@CommandParameters(description = "Make arrows explode", usage = "/<command>", aliases = "ea")
|
||||||
public class Command_explosivearrows extends FreedomCommand
|
public class Command_explosivearrows extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
boolean onList = plugin.it.explosivePlayers.contains(playerSender);
|
FPlayer player = plugin.pl.getPlayer(playerSender);
|
||||||
if (onList)
|
player.setExplosiveArrowsEnabled(!player.isExplosiveArrowsEnabled());
|
||||||
{
|
|
||||||
plugin.it.explosivePlayers.remove(playerSender);
|
msgNew("<statuscolor>You <status> have explosive arrows.",
|
||||||
msg("You no longer have explosive arrows", ChatColor.RED);
|
TagResolver.resolver("statuscolor", Tag.styling(player.isExplosiveArrowsEnabled() ? NamedTextColor.GREEN : NamedTextColor.RED)),
|
||||||
}
|
Placeholder.unparsed("status", player.isExplosiveArrowsEnabled() ? "now" : "no longer"));
|
||||||
else
|
|
||||||
{
|
|
||||||
plugin.it.explosivePlayers.add(playerSender);
|
|
||||||
msg("You now have explosive arrows", ChatColor.GREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
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.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -28,7 +28,9 @@ public class Command_findip extends FreedomCommand
|
|||||||
return true;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
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.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -11,23 +11,23 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Obtain a fire ball", usage = "/<command>")
|
@CommandParameters(description = "Obtain a fire ball", usage = "/<command>")
|
||||||
public class Command_fireball extends FreedomCommand
|
public class Command_fireball extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (plugin.sh == null) {
|
if (plugin.sh == null)
|
||||||
msg("The shop is currently disabled.", ChatColor.RED);
|
{
|
||||||
|
msgNew("<red>Shop is currently disabled.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
|
if (plugin.pl.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
|
||||||
{
|
{
|
||||||
playerSender.getInventory().addItem(plugin.sh.getFireBall());
|
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
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class Command_flatlands extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("Flatlands is currently disabled in the TotalFreedomMod configuration.");
|
msgNew("<red>Flatlands is currently disabled in the TotalFreedomMod configuration.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -26,7 +27,8 @@ public class Command_glow extends FreedomCommand
|
|||||||
playerSender.addPotionEffect(glow);
|
playerSender.addPotionEffect(glow);
|
||||||
glowing = true;
|
glowing = true;
|
||||||
}
|
}
|
||||||
msg("You are " + (glowing ? "now" : "no longer") + " glowing.");
|
|
||||||
|
msgNew("You are <status> glowing.", Placeholder.unparsed("status", glowing ? "now" : "no longer"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,10 @@ public class Command_indefban extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Reloading the indefinite ban list...");
|
msgNew("Reloading the indefinite ban list...");
|
||||||
plugin.im.onStop();
|
plugin.im.onStop();
|
||||||
plugin.im.onStart();
|
plugin.im.onStart();
|
||||||
msg("Reloaded the indefinite ban list.");
|
msgNew("<green>Reloaded the indefinite ban list.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ import java.util.stream.IntStream;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -30,7 +31,7 @@ public class Command_inspect extends FreedomCommand
|
|||||||
PlayerData playerData = plugin.pl.getData(playerSender);
|
PlayerData playerData = plugin.pl.getData(playerSender);
|
||||||
playerData.setInspect(!playerData.hasInspection());
|
playerData.setInspect(!playerData.hasInspection());
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
msg("Block inspector " + (playerData.hasInspection() ? "enabled." : "disabled."));
|
msgNew("Block inspector <status>.", Placeholder.unparsed("status", playerData.hasInspection() ? "enabled." : "disabled."));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ public class Command_inspect extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
msg("Invalid number.", ChatColor.RED);
|
msgNew("<red>Invalid number.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,7 +55,7 @@ public class Command_inspect extends FreedomCommand
|
|||||||
int godDammit = pageIndex;
|
int godDammit = pageIndex;
|
||||||
Optional.ofNullable(plugin.cpb.getHistoryForPlayer(playerSender)).ifPresentOrElse(page ->
|
Optional.ofNullable(plugin.cpb.getHistoryForPlayer(playerSender)).ifPresentOrElse(page ->
|
||||||
plugin.cpb.showPageToPlayer(playerSender, page, godDammit),
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -28,7 +29,7 @@ public class Command_lockup extends FreedomCommand
|
|||||||
{
|
{
|
||||||
startLockup(player);
|
startLockup(player);
|
||||||
}
|
}
|
||||||
msg("Locked up all players.");
|
msgNew("Locked up all players.");
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("purge"))
|
else if (args[0].equalsIgnoreCase("purge"))
|
||||||
{
|
{
|
||||||
@ -38,7 +39,7 @@ public class Command_lockup extends FreedomCommand
|
|||||||
cancelLockup(player);
|
cancelLockup(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Unlocked all players.");
|
msgNew("Unlocked all players.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -62,7 +63,7 @@ public class Command_lockup extends FreedomCommand
|
|||||||
FUtil.adminAction(sender.getName(), "Locking up " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Locking up " + player.getName(), true);
|
||||||
}
|
}
|
||||||
startLockup(player);
|
startLockup(player);
|
||||||
msg("Locked up " + player.getName() + ".");
|
msgNew("Locked up <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
}
|
}
|
||||||
else if ("off".equals(args[1]))
|
else if ("off".equals(args[1]))
|
||||||
{
|
{
|
||||||
@ -79,7 +80,7 @@ public class Command_lockup extends FreedomCommand
|
|||||||
FUtil.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
|
||||||
}
|
}
|
||||||
cancelLockup(player);
|
cancelLockup(player);
|
||||||
msg("Unlocked " + player.getName() + ".");
|
msgNew("Unlocked <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.player.PlayerData;
|
|||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -17,8 +18,9 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (plugin.sh == null) {
|
if (plugin.sh == null)
|
||||||
msg("The shop is currently disabled.", ChatColor.RED);
|
{
|
||||||
|
msgNew("<red>Shop is currently disabled.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,11 +56,17 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
}
|
}
|
||||||
playerData.setCoins(playerData.getCoins() + amount);
|
playerData.setCoins(playerData.getCoins() + amount);
|
||||||
plugin.pl.save(playerData);
|
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]);
|
Player player = getPlayer(args[3]);
|
||||||
if (player != null)
|
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
|
else
|
||||||
@ -68,15 +76,21 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
PlayerData playerData = plugin.pl.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
playerData.setCoins(playerData.getCoins() + amount);
|
playerData.setCoins(playerData.getCoins() + amount);
|
||||||
plugin.pl.save(playerData);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
msgNew("<red>Invalid number: <amount>", Placeholder.unparsed("amount", args[2]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,11 +113,18 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
playerData.setCoins(0);
|
playerData.setCoins(0);
|
||||||
}
|
}
|
||||||
plugin.pl.save(playerData);
|
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]);
|
Player player = getPlayer(args[3]);
|
||||||
if (player != null)
|
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
|
else
|
||||||
@ -117,15 +138,21 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
playerData.setCoins(0);
|
playerData.setCoins(0);
|
||||||
}
|
}
|
||||||
plugin.pl.save(playerData);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
msgNew("<red>Invalid number: <amount>", Placeholder.unparsed("amount", args[2]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,17 +169,23 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
}
|
}
|
||||||
playerData.setCoins(amount);
|
playerData.setCoins(amount);
|
||||||
plugin.pl.save(playerData);
|
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]);
|
Player player = getPlayer(args[3]);
|
||||||
if (player != null)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
msgNew("<red>Invalid number: <amount>", Placeholder.unparsed("amount", args[2]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,7 +199,7 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args[1].equals("list"))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +213,7 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
||||||
if (item == null)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,11 +225,16 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
}
|
}
|
||||||
playerData.giveItem(item);
|
playerData.giveItem(item);
|
||||||
plugin.pl.save(playerData);
|
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]);
|
Player player = getPlayer(args[3]);
|
||||||
if (player != null)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@ -205,7 +243,7 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
||||||
if (item == null)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,11 +255,17 @@ public class Command_manageshop extends FreedomCommand
|
|||||||
}
|
}
|
||||||
playerData.removeItem(item);
|
playerData.removeItem(item);
|
||||||
plugin.pl.save(playerData);
|
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]);
|
Player player = getPlayer(args[3]);
|
||||||
if (player != null)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -13,7 +14,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
@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
|
public class Command_mute extends FreedomCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -28,14 +29,16 @@ public class Command_mute extends FreedomCommand
|
|||||||
{
|
{
|
||||||
case "list" ->
|
case "list" ->
|
||||||
{
|
{
|
||||||
msg("Muted players:");
|
List<String> muted = server.getOnlinePlayers().stream().filter(player -> plugin.pl.getPlayer(player).isMuted()).map(player -> player.getName()).toList();
|
||||||
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
|
||||||
plugin.pl.getPlayer(player).isMuted()).toList();
|
|
||||||
|
|
||||||
if (list.size() > 0)
|
if (muted.isEmpty())
|
||||||
list.forEach(player -> msg("- " + player.getName()));
|
{
|
||||||
|
msgNew("Nobody is currently muted.");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
msg("- none");
|
{
|
||||||
|
msgNew("Muted players: <players>", Placeholder.unparsed("players", FUtil.listToString(muted)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "purge" ->
|
case "purge" ->
|
||||||
{
|
{
|
||||||
@ -46,11 +49,12 @@ public class Command_mute extends FreedomCommand
|
|||||||
list.forEach(player ->
|
list.forEach(player ->
|
||||||
{
|
{
|
||||||
plugin.pl.getPlayer(player).setMuted(false);
|
plugin.pl.getPlayer(player).setMuted(false);
|
||||||
player.sendTitle(ChatColor.RED + "You have been unmuted.",
|
FUtil.playerTitle(player, "<red>You have been unmuted.", "<yellow>Be sure to follow the rules!");
|
||||||
ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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" ->
|
case "all" ->
|
||||||
{
|
{
|
||||||
@ -61,19 +65,19 @@ public class Command_mute extends FreedomCommand
|
|||||||
list.forEach(player ->
|
list.forEach(player ->
|
||||||
{
|
{
|
||||||
plugin.pl.getPlayer(player).setMuted(true);
|
plugin.pl.getPlayer(player).setMuted(true);
|
||||||
player.sendTitle(ChatColor.RED + "You've been muted globally.",
|
FUtil.playerTitle(player, "<red>You have been globally muted.", "<yellow>Please be patient and you will be unmuted shortly.");
|
||||||
ChatColor.YELLOW + "Please be patient and you will be unmuted shortly.", 20, 100, 60);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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 ->
|
default ->
|
||||||
{
|
{
|
||||||
boolean quiet = args[0].equalsIgnoreCase("-q");
|
boolean quiet = args[0].equalsIgnoreCase("-q");
|
||||||
boolean smite = args[0].equalsIgnoreCase("-s");
|
|
||||||
|
|
||||||
// Handling the -q parameter
|
// Handling the -q parameter
|
||||||
if (quiet || smite)
|
if (quiet)
|
||||||
{
|
{
|
||||||
if (args.length == 1) return false;
|
if (args.length == 1) return false;
|
||||||
args = ArrayUtils.subarray(args, 1, args.length);
|
args = ArrayUtils.subarray(args, 1, args.length);
|
||||||
@ -87,12 +91,12 @@ public class Command_mute extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
else if (plugin.pl.getPlayer(player).isMuted())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,28 +106,28 @@ public class Command_mute extends FreedomCommand
|
|||||||
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
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
|
// Mutes the player
|
||||||
plugin.pl.getPlayer(player).setMuted(true);
|
plugin.pl.getPlayer(player).setMuted(true);
|
||||||
|
|
||||||
// Notify the player that they have been muted
|
// Notify the player that they have been muted
|
||||||
player.sendTitle(ChatColor.RED + "You've been muted.",
|
FUtil.playerTitle(player, "<red>You have been muted.", "<yellow>Be sure to follow the rules!");
|
||||||
ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
msgNew(player, "<red>You have been muted by <yellow><sender>", Placeholder.unparsed("sender", sender.getName()));
|
||||||
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName()
|
|
||||||
+ ChatColor.RED + ".", ChatColor.RED);
|
|
||||||
|
|
||||||
// Give them the reason if one is present.
|
// Give them the reason if one is present.
|
||||||
if (reason != null)
|
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(),
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(),
|
||||||
PunishmentType.MUTE, reason));
|
PunishmentType.MUTE, reason));
|
||||||
}, () -> msg(PLAYER_NOT_FOUND));
|
}, () -> msg(PLAYER_NOT_FOUND));
|
||||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -17,7 +18,7 @@ public class Command_nicknyan extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
||||||
{
|
{
|
||||||
msg("Essentials is not enabled on this server.");
|
msgNew("<red>Essentials is not enabled on this server.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ public class Command_nicknyan extends FreedomCommand
|
|||||||
if (args[0].equalsIgnoreCase("off"))
|
if (args[0].equalsIgnoreCase("off"))
|
||||||
{
|
{
|
||||||
plugin.esb.setNickname(sender.getName(), null);
|
plugin.esb.setNickname(sender.getName(), null);
|
||||||
msg("Nickname cleared.");
|
msgNew("<green>Nickname cleared.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,12 +38,12 @@ public class Command_nicknyan extends FreedomCommand
|
|||||||
|
|
||||||
if (!nickPlain.matches("^[a-zA-Z_0-9" + ChatColor.COLOR_CHAR + "]+$"))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
else if (nickPlain.length() < 3 || nickPlain.length() > 30)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ public class Command_nicknyan extends FreedomCommand
|
|||||||
&& (player.getName().equalsIgnoreCase(nickPlain)
|
&& (player.getName().equalsIgnoreCase(nickPlain)
|
||||||
|| ChatColor.stripColor(plugin.esb.getNickname(player.getName())).trim().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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ public class Command_nicknyan extends FreedomCommand
|
|||||||
|
|
||||||
plugin.esb.setNickname(sender.getName(), newNick.toString());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -17,7 +18,7 @@ public class Command_nickrainbow extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
||||||
{
|
{
|
||||||
msg("Essentials is not enabled on this server.");
|
msgNew("<red>Essentials is not enabled on this server.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,13 +31,13 @@ public class Command_nickrainbow extends FreedomCommand
|
|||||||
|
|
||||||
if (!nickPlain.matches("^[a-zA-Z_0-9" + ChatColor.COLOR_CHAR + "]+$"))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nickPlain.length() < 3 || nickPlain.length() > 30)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ public class Command_nickrainbow extends FreedomCommand
|
|||||||
}
|
}
|
||||||
if (player.getName().equalsIgnoreCase(nickPlain) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,7 +58,7 @@ public class Command_nickrainbow extends FreedomCommand
|
|||||||
|
|
||||||
plugin.esb.setNickname(sender.getName(), newNick);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -24,19 +25,11 @@ public class Command_ops extends FreedomCommand
|
|||||||
if (args[0].equalsIgnoreCase("count"))
|
if (args[0].equalsIgnoreCase("count"))
|
||||||
{
|
{
|
||||||
int totalOps = server.getOperators().size();
|
int totalOps = server.getOperators().size();
|
||||||
int onlineOps = 0;
|
long onlineOps = server.getOnlinePlayers().stream().filter(player -> player.isOp()).count();
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
msgNew("Online OPs: <online>", Placeholder.unparsed("online", String.valueOf(onlineOps)));
|
||||||
{
|
msgNew("Offline OPs: <offline>", Placeholder.unparsed("offline", String.valueOf(totalOps - onlineOps)));
|
||||||
if (player.isOp())
|
msgNew("Total OPs: <total>", Placeholder.unparsed("total", String.valueOf(totalOps)));
|
||||||
{
|
|
||||||
onlineOps++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Online OPs: " + onlineOps);
|
|
||||||
msg("Offline OPs: " + (totalOps - onlineOps));
|
|
||||||
msg("Total OPs: " + totalOps);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,14 +43,16 @@ public class Command_ops extends FreedomCommand
|
|||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Purging all operators", true);
|
FUtil.adminAction(sender.getName(), "Purging all operators", true);
|
||||||
|
|
||||||
for (OfflinePlayer player : server.getOperators())
|
server.getOperators().forEach(operator ->
|
||||||
{
|
{
|
||||||
player.setOp(false);
|
operator.setOp(false);
|
||||||
if (player.isOnline())
|
|
||||||
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
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))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
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;
|
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);
|
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."
|
msgNew("<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." : ""));
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -26,7 +27,7 @@ public class Command_ride extends FreedomCommand
|
|||||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
||||||
if (fPlayer.getCageData().isCaged())
|
if (fPlayer.getCageData().isCaged())
|
||||||
{
|
{
|
||||||
msg("You cannot use this command while caged.");
|
msgNew("<red>You cannot use this command while caged.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,20 +40,20 @@ public class Command_ride extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!RIDE_REQUESTS.containsKey(playerSender))
|
if (!RIDE_REQUESTS.containsKey(playerSender))
|
||||||
{
|
{
|
||||||
msg("You don't have any pending requests.");
|
msgNew("<red>You don't have any pending requests.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player requester = RIDE_REQUESTS.get(playerSender);
|
Player requester = RIDE_REQUESTS.get(playerSender);
|
||||||
if (requester == null)
|
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);
|
RIDE_REQUESTS.remove(playerSender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Request accepted.");
|
msgNew("Request accepted.");
|
||||||
msg(requester, "Your request has been accepted.");
|
msgNew(requester, "<green>Your request has been accepted.");
|
||||||
|
|
||||||
if (requester.getWorld() != playerSender.getWorld())
|
if (requester.getWorld() != playerSender.getWorld())
|
||||||
{
|
{
|
||||||
@ -68,19 +69,19 @@ public class Command_ride extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!RIDE_REQUESTS.containsKey(playerSender))
|
if (!RIDE_REQUESTS.containsKey(playerSender))
|
||||||
{
|
{
|
||||||
msg("You don't have any pending requests.");
|
msgNew("<red>You don't have any pending requests.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player requester = RIDE_REQUESTS.get(playerSender);
|
Player requester = RIDE_REQUESTS.get(playerSender);
|
||||||
if (requester == null)
|
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);
|
RIDE_REQUESTS.remove(playerSender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
msg("Request denied.");
|
msgNew("Request denied.");
|
||||||
RIDE_REQUESTS.remove(playerSender);
|
RIDE_REQUESTS.remove(playerSender);
|
||||||
msg(requester, "Your request has been denied.");
|
msgNew(requester, "<red>Your request has been denied.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,11 +93,11 @@ public class Command_ride extends FreedomCommand
|
|||||||
PlayerData playerDataSender = plugin.pl.getData(playerSender);
|
PlayerData playerDataSender = plugin.pl.getData(playerSender);
|
||||||
playerDataSender.setRideMode(mode);
|
playerDataSender.setRideMode(mode);
|
||||||
plugin.pl.save(playerDataSender);
|
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)
|
catch (IllegalArgumentException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid mode.", ChatColor.RED);
|
msgNew("<red>Invalid mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -113,23 +114,23 @@ public class Command_ride extends FreedomCommand
|
|||||||
|
|
||||||
if (player == playerSender)
|
if (player == playerSender)
|
||||||
{
|
{
|
||||||
msg("You can't ride yourself. smh.", ChatColor.RED);
|
msgNew("<red>You can't ride yourself.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerData.getRideMode() == PlayerData.RideMode.OFF && !isAdmin(sender))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerData.getRideMode() == PlayerData.RideMode.ASK && !FUtil.isExecutive(playerSender.getName()))
|
if (playerData.getRideMode() == PlayerData.RideMode.ASK && !FUtil.isExecutive(playerSender.getName()))
|
||||||
{
|
{
|
||||||
msg("Sent a request to the player.", ChatColor.GREEN);
|
msgNew("<green>Sent a request to the player.");
|
||||||
msg(player, sender.getName() + " has requested to ride you.", ChatColor.AQUA);
|
msgNew(player, "<aqua><player> has requested to ride you.", Placeholder.unparsed("player", sender.getName()));
|
||||||
msg(player, "Type " + ChatColor.GREEN + "/ride accept" + ChatColor.AQUA + " to allow the player to ride you.", ChatColor.AQUA);
|
msgNew(player, "<aqua>Type <green>/ride accept</green> to allow the player to ride you.");
|
||||||
msg(player, "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.", ChatColor.AQUA);
|
msgNew(player, "<aqua>Type <red>/ride deny</red> to deny their request.");
|
||||||
msg(player, "Request will expire in 30 seconds.", ChatColor.AQUA);
|
msgNew(player, "<aqua>This request will expire in 30 seconds.");
|
||||||
RIDE_REQUESTS.put(player, playerSender);
|
RIDE_REQUESTS.put(player, playerSender);
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
@ -142,8 +143,8 @@ public class Command_ride extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
RIDE_REQUESTS.remove(player);
|
RIDE_REQUESTS.remove(player);
|
||||||
msg(playerSender, "It has been 30 seconds and " + player.getName() + " has not accepted your request.", ChatColor.RED);
|
msgNew(playerSender, "<red>Your request to ride <player> has automatically expired.", Placeholder.unparsed("player", player.getName()));
|
||||||
msg(player, "Request expired.", ChatColor.RED);
|
msgNew(player, "<red>Request expired.");
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 20 * 30);
|
}.runTaskLater(plugin, 20 * 30);
|
||||||
return true;
|
return true;
|
||||||
@ -155,7 +156,7 @@ public class Command_ride extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.addPassenger(playerSender);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -33,7 +34,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
{
|
{
|
||||||
case "list":
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,8 +45,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Cleaning the admin list", true);
|
FUtil.adminAction(sender.getName(), "Cleaning the admin list", true);
|
||||||
plugin.al.deactivateOldEntries(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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Reloading the admin list", true);
|
FUtil.adminAction(sender.getName(), "Reloading the admin list", true);
|
||||||
plugin.al.load();
|
plugin.al.load();
|
||||||
msg("Admin list reloaded!");
|
msgNew("Admin list reloaded!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,26 +72,26 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
Rank rank = Rank.findRank(args[2]);
|
Rank rank = Rank.findRank(args[2]);
|
||||||
if (rank == null)
|
if (rank == null)
|
||||||
{
|
{
|
||||||
msg("Unknown rank: " + args[2]);
|
msgNew("<red>Unknown rank: <rank>", Placeholder.unparsed("rank", args[2]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rank.isConsole())
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rank.isAtLeast(Rank.ADMIN))
|
if (!rank.isAtLeast(Rank.ADMIN))
|
||||||
{
|
{
|
||||||
msg("Rank must be Admin or higher.", ChatColor.RED);
|
msgNew("<red>Rank must be Admin or higher.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Admin admin = plugin.al.getEntryByName(args[1]);
|
Admin admin = plugin.al.getEntryByName(args[1]);
|
||||||
if (admin == null)
|
if (admin == null)
|
||||||
{
|
{
|
||||||
msg("Unknown admin: " + args[1]);
|
msgNew("Unknown admin: <player>", Placeholder.unparsed("player", args[1]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,9 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,11 +139,12 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (admin == null)
|
if (admin == null)
|
||||||
{
|
{
|
||||||
msg("Admin not found: " + args[1]);
|
msgNew("Unknown admin: <player>", Placeholder.unparsed("player", args[1]));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg(admin.toString());
|
msgNew(admin.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -162,13 +165,13 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
msg("That player is already an admin.");
|
msgNew("<red>That player is already an admin.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +215,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
if (fPlayer.getFreezeData().isFrozen())
|
if (fPlayer.getFreezeData().isFrozen())
|
||||||
{
|
{
|
||||||
fPlayer.getFreezeData().setFrozen(false);
|
fPlayer.getFreezeData().setFrozen(false);
|
||||||
msg(player, "You have been unfrozen.");
|
msgNew(player, "You have been unfrozen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -234,7 +237,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (admin == null)
|
if (admin == null)
|
||||||
{
|
{
|
||||||
msg("Admin not found: " + args[1]);
|
msgNew("Unknown admin: <player>", Placeholder.unparsed("player", args[1]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -12,7 +13,6 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Broadcasts the given message as the server, includes sender name.", usage = "/<command> <message>")
|
@CommandParameters(description = "Broadcasts the given message as the server, includes sender name.", usage = "/<command> <message>")
|
||||||
public class Command_say extends FreedomCommand
|
public class Command_say extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -23,26 +23,12 @@ public class Command_say extends FreedomCommand
|
|||||||
|
|
||||||
String message = StringUtils.join(args, " ");
|
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);
|
plugin.dc.messageChatChannel(String.format("[Server:%s] \u00BB %s", sender.getName(), message), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -18,12 +15,6 @@ public class Command_scare extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (!FUtil.isPaper())
|
|
||||||
{
|
|
||||||
msg("This command won't work without Paper!", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -33,30 +24,20 @@ public class Command_scare extends FreedomCommand
|
|||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Scared " + player.getName());
|
msgNew("Spooked the hell out of <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
msg(player, "ZING", ChatColor.RED);
|
msgNew(player, "<red>ZING");
|
||||||
|
|
||||||
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4);
|
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4);
|
||||||
|
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_SCREAM, 1, 0);
|
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_SCREAM, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
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.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -14,6 +15,12 @@ public class Command_setlimit extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
if (!server.getPluginManager().isPluginEnabled("WorldEdit"))
|
||||||
|
{
|
||||||
|
msgNew("<red>WorldEdit is not enabled on this server.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int amount = plugin.web.getDefaultLimit();
|
int amount = plugin.web.getDefaultLimit();
|
||||||
if (args.length > 0)
|
if (args.length > 0)
|
||||||
{
|
{
|
||||||
@ -23,28 +30,14 @@ public class Command_setlimit extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid number: " + args[0], ChatColor.RED);
|
msgNew("<red>Invalid number: <number>", Placeholder.unparsed("number", args[0]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean success = false;
|
|
||||||
for (final Player player : server.getOnlinePlayers())
|
FUtil.adminAction(sender.getName(), "Setting everyone's WorldEdit block modification limit to " + amount + ".", true);
|
||||||
{
|
int finalAmount = amount;
|
||||||
try
|
server.getOnlinePlayers().forEach(player -> plugin.web.setLimit(player, finalAmount));
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -15,6 +16,12 @@ public class Command_setplayerlimit extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
if (!server.getPluginManager().isPluginEnabled("WorldEdit"))
|
||||||
|
{
|
||||||
|
msgNew("<red>WorldEdit is not enabled on this server.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int amount;
|
int amount;
|
||||||
if (args.length > 0)
|
if (args.length > 0)
|
||||||
{
|
{
|
||||||
@ -33,7 +40,7 @@ public class Command_setplayerlimit extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid number: " + args[1], ChatColor.RED);
|
msgNew("<red>Invalid number: <amount>", Placeholder.unparsed("amount", args[1]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,22 +53,11 @@ public class Command_setplayerlimit extends FreedomCommand
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean success = false;
|
|
||||||
Player player = Bukkit.getPlayer(args[0]);
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
try
|
FUtil.adminAction(sender.getName(), "Setting " + player.getName() + "'s WorldEdit block modification limit to " + amount + ".", true);
|
||||||
{
|
plugin.web.setLimit(player, amount);
|
||||||
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);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -18,8 +19,7 @@ public class Command_setspawnworld extends FreedomCommand
|
|||||||
Location pos = playerSender.getLocation();
|
Location pos = playerSender.getLocation();
|
||||||
playerSender.getWorld().setSpawnLocation(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
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;
|
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.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -11,15 +10,15 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Open the shop GUI", usage = "/<command>", aliases = "sh")
|
@CommandParameters(description = "Open the shop GUI", usage = "/<command>", aliases = "sh")
|
||||||
public class Command_shop extends FreedomCommand
|
public class Command_shop extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (plugin.sh == null || !ConfigEntry.SHOP_ENABLED.getBoolean())
|
if (plugin.sh == null || !ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
msg("The shop is currently disabled!", ChatColor.RED);
|
msgNew("<red>Shop is currently disabled.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerSender.openInventory(plugin.sh.generateShopGUI(plugin.pl.getData(playerSender)));
|
playerSender.openInventory(plugin.sh.generateShopGUI(plugin.pl.getData(playerSender)));
|
||||||
return true;
|
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]")
|
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-ci | -q]")
|
||||||
public class Command_smite extends FreedomCommand
|
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)
|
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);
|
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")
|
@CommandParameters(description = "Quickly spectate someone.", usage = "/<command> <playername>", aliases = "spec")
|
||||||
public class Command_spectate extends FreedomCommand
|
public class Command_spectate extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -30,7 +29,7 @@ public class Command_spectate extends FreedomCommand
|
|||||||
|
|
||||||
if (player.getGameMode().equals(GameMode.SPECTATOR))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -11,23 +12,23 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Obtain a stacking potato", usage = "/<command>")
|
@CommandParameters(description = "Obtain a stacking potato", usage = "/<command>")
|
||||||
public class Command_stackingpotato extends FreedomCommand
|
public class Command_stackingpotato extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (plugin.sh == null) {
|
if (plugin.sh == null)
|
||||||
msg("The shop is currently disabled.", ChatColor.RED);
|
{
|
||||||
|
msgNew("<red>Shop is currently disabled.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.STACKING_POTATO))
|
if (plugin.pl.getData(playerSender).hasItem(ShopItem.STACKING_POTATO))
|
||||||
{
|
{
|
||||||
playerSender.getInventory().addItem(plugin.sh.getStackingPotato());
|
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
|
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;
|
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();
|
playerSender.stopAllSounds();
|
||||||
|
|
||||||
msg("Stopped all sounds.", ChatColor.GREEN);
|
msgNew("<green>Stopped all sounds.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class Command_toggle extends FreedomCommand
|
|||||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]",
|
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]",
|
||||||
"explosives [radius]", "unsafeenchs", "bells", "armorstands", "masterblocks", "books", "grindstones",
|
"explosives [radius]", "unsafeenchs", "bells", "armorstands", "masterblocks", "books", "grindstones",
|
||||||
"jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44",
|
"jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44",
|
||||||
"landmines", "tossmob", "gravity", "chat");
|
"landmines", "tossmob", "gravity", "chat", "disguises");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
@ -134,6 +134,22 @@ public class Command_toggle extends FreedomCommand
|
|||||||
case "tossmob" -> toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED);
|
case "tossmob" -> toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED);
|
||||||
case "gravity" -> toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY);
|
case "gravity" -> toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY);
|
||||||
case "chat" -> toggle("Chat is", ConfigEntry.TOGGLE_CHAT);
|
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 ->
|
default ->
|
||||||
{
|
{
|
||||||
msgNew("Available toggles: ");
|
msgNew("Available toggles: ");
|
||||||
@ -164,7 +180,7 @@ public class Command_toggle extends FreedomCommand
|
|||||||
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
||||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
|
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
|
||||||
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
|
"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();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -16,7 +17,8 @@ public class Command_togglediscord extends FreedomCommand
|
|||||||
PlayerData data = plugin.pl.getData(playerSender);
|
PlayerData data = plugin.pl.getData(playerSender);
|
||||||
data.setDisplayDiscord(!data.doesDisplayDiscord());
|
data.setDisplayDiscord(!data.doesDisplayDiscord());
|
||||||
plugin.pl.save(data);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@ public class Command_togglepickup extends FreedomCommand
|
|||||||
{
|
{
|
||||||
boolean enabled = !playerSender.getCanPickupItems();
|
boolean enabled = !playerSender.getCanPickupItems();
|
||||||
playerSender.setCanPickupItems(enabled);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class Command_tossmob extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -38,33 +39,28 @@ public class Command_totalfreedommod extends FreedomCommand
|
|||||||
plugin.fsh.stopServices();
|
plugin.fsh.stopServices();
|
||||||
plugin.fsh.startServices();
|
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.pluginName,
|
||||||
TotalFreedomMod.pluginVersion);
|
TotalFreedomMod.pluginVersion));
|
||||||
|
|
||||||
msg(message);
|
|
||||||
FLog.info(message);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TotalFreedomMod.BuildProperties build = TotalFreedomMod.build;
|
TotalFreedomMod.BuildProperties build = TotalFreedomMod.build;
|
||||||
msg("TotalFreedomMod for 'Total Freedom', the original all-op server.", ChatColor.GOLD);
|
msgNew("<gold>TotalFreedomMod for 'Total Freedom', the original all-op server.");
|
||||||
msg("Running on " + ConfigEntry.SERVER_NAME.getString() + ".", ChatColor.GOLD);
|
msgNew("<gold>Running on <server>.", Placeholder.unparsed("server", ConfigEntry.SERVER_NAME.getString()));
|
||||||
msg("Created by Madgeek1450 and Prozza.", ChatColor.GOLD);
|
msgNew("<gold>Created by Madgeek1450 and Prozza.");
|
||||||
msg(String.format("Version "
|
msgNew("<gold>Version <blue><codename> - <version> Build <number> </blue>(<blue><head></blue>)",
|
||||||
+ ChatColor.BLUE + "%s - %s Build %s " + ChatColor.GOLD + "("
|
Placeholder.unparsed("codename", build.codename),
|
||||||
+ ChatColor.BLUE + "%s" + ChatColor.GOLD + ")",
|
Placeholder.unparsed("version", build.version),
|
||||||
build.codename,
|
Placeholder.unparsed("number", build.number),
|
||||||
build.version,
|
Placeholder.unparsed("head", build.head));
|
||||||
build.number,
|
msgNew("<gold>Compiled <blue><date></blue> by <blue><author></blue>",
|
||||||
build.head), ChatColor.GOLD);
|
Placeholder.unparsed("date", build.date),
|
||||||
msg(String.format("Compiled "
|
Placeholder.unparsed("author", build.author));
|
||||||
+ ChatColor.BLUE + "%s" + ChatColor.GOLD + " by "
|
msgNew("<green>Visit <aqua>http://github.com/TotalFreedom/TotalFreedomMod</aqua> for more information.");
|
||||||
+ 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);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ import java.util.*;
|
|||||||
public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||||
{
|
{
|
||||||
public static final String COMMAND_PREFIX = "Command_";
|
public static final String COMMAND_PREFIX = "Command_";
|
||||||
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
public static final Component YOU_ARE_OP = Component.text("You are now op!", NamedTextColor.YELLOW);
|
||||||
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
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 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_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!";
|
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)
|
protected void msg(CommandSender sender, String message)
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GRAY + 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
|
@Deprecated
|
||||||
protected void msg(String message)
|
protected void msg(String message)
|
||||||
{
|
{
|
||||||
@ -155,8 +145,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||||||
msgNew(sender, message, placeholders);
|
msgNew(sender, message, placeholders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
|
||||||
protected void msg(String message, ChatColor color)
|
protected void msg(String message, ChatColor color)
|
||||||
{
|
{
|
||||||
msg(color + message);
|
msg(color + message);
|
||||||
|
@ -308,8 +308,8 @@ public class ItemFun extends FreedomService
|
|||||||
}
|
}
|
||||||
//Redundant Player cast is required to avoid suspicious method calls.
|
//Redundant Player cast is required to avoid suspicious method calls.
|
||||||
if (arrow != null
|
if (arrow != null
|
||||||
&& (arrow.getShooter() instanceof Player)
|
&& (arrow.getShooter() instanceof Player player)
|
||||||
&& explosivePlayers.contains(arrow.getShooter()))
|
&& 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());
|
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();
|
arrow.remove();
|
||||||
|
@ -11,7 +11,6 @@ import me.totalfreedom.totalfreedommod.FreedomService;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
|
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_admins;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_bans;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_bans;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_file;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_file;
|
||||||
@ -89,7 +88,6 @@ public class HTTPDaemon extends FreedomService
|
|||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
modules.clear();
|
modules.clear();
|
||||||
module("activitylog", Module_activitylog.class, true);
|
|
||||||
module("admins", Module_admins.class, true);
|
module("admins", Module_admins.class, true);
|
||||||
module("bans", Module_bans.class, true);
|
module("bans", Module_bans.class, true);
|
||||||
module("help", Module_help.class, false);
|
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 invSee = false;
|
||||||
|
|
||||||
private boolean clownfishDisabled = false;
|
private boolean clownfishDisabled = false;
|
||||||
|
private boolean explosiveArrowsEnabled = false;
|
||||||
|
|
||||||
public FPlayer(TotalFreedomMod plugin, Player player)
|
public FPlayer(TotalFreedomMod plugin, Player player)
|
||||||
{
|
{
|
||||||
@ -447,6 +448,16 @@ public class FPlayer
|
|||||||
this.clownfishDisabled = bool;
|
this.clownfishDisabled = bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isExplosiveArrowsEnabled()
|
||||||
|
{
|
||||||
|
return explosiveArrowsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExplosiveArrowsEnabled(boolean bool)
|
||||||
|
{
|
||||||
|
this.explosiveArrowsEnabled = bool;
|
||||||
|
}
|
||||||
|
|
||||||
private static class ArrowShooter extends BukkitRunnable
|
private static class ArrowShooter extends BukkitRunnable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#
|
|
||||||
# TotalFreedomMod Activity Log
|
|
||||||
#
|
|
Loading…
Reference in New Issue
Block a user