TotalFreedomMod 6.0 Pre release 1

Due to the amount of breaking changes, I thought I would restart the numbering at 6.0
This commit is contained in:
Telesphoreo 2020-11-23 01:09:10 -06:00
parent de0d6853b7
commit edb1f224ca
No known key found for this signature in database
GPG key ID: 50B67E055A6F167C
196 changed files with 1141 additions and 3162 deletions

19
pom.xml
View file

@ -5,12 +5,12 @@
<groupId>me.totalfreedom</groupId> <groupId>me.totalfreedom</groupId>
<artifactId>TotalFreedomMod</artifactId> <artifactId>TotalFreedomMod</artifactId>
<version>2020.11.5</version> <version>6.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tfm.build.codename>Antaeus</tfm.build.codename> <tfm.build.codename>Mirror</tfm.build.codename>
<jar.finalName>${project.name}</jar.finalName> <jar.finalName>${project.name}</jar.finalName>
<timestamp>${maven.build.timestamp}</timestamp> <timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format> <maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format>
@ -33,9 +33,9 @@
</organization> </organization>
<scm> <scm>
<connection>scm:git:git@github.com:TFPatches/TotalFreedomMod.git</connection> <connection>scm:git:git@github.com:TotalFreedomMC/TotalFreedomMod.git</connection>
<developerConnection>scm:git:git@github.com:TFPatches/TotalFreedomMod.git</developerConnection> <developerConnection>scm:git:git@github.com:TotalFreedomMC/TotalFreedomMod.git</developerConnection>
<url>git@github.com:TFPatches/TotalFreedomMod.git</url> <url>git@github.com:TotalFreedomMC/TotalFreedomMod.git</url>
</scm> </scm>
<repositories> <repositories>
@ -195,7 +195,7 @@
<dependency> <dependency>
<groupId>net.ess3</groupId> <groupId>net.ess3</groupId>
<artifactId>EssentialsX</artifactId> <artifactId>EssentialsX</artifactId>
<version>2.18.1</version> <version>2.18.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@ -275,13 +275,6 @@
<version>3.1.1</version> <version>3.1.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>net.dean.jraw</groupId>
<artifactId>JRAW</artifactId>
<version>1.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View file

@ -62,7 +62,7 @@ public class AntiSpam extends FreedomService
{ {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (plugin.sl.isStaff(player)) if (plugin.al.isAdmin(player))
{ {
return; return;
} }
@ -109,7 +109,7 @@ public class AntiSpam extends FreedomService
return; return;
} }
if (plugin.sl.isStaff(player)) if (plugin.al.isAdmin(player))
{ {
return; return;
} }

View file

@ -5,7 +5,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Displayable; import me.totalfreedom.totalfreedommod.rank.Displayable;
import me.totalfreedom.totalfreedommod.staff.StaffMember; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync; import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
@ -65,7 +65,7 @@ public class ChatManager extends FreedomService
return; return;
} }
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.sl.isStaff(player)) if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
{ {
event.setCancelled(true); event.setCancelled(true);
playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED); playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
@ -87,29 +87,14 @@ public class ChatManager extends FreedomService
return; return;
} }
// Check for staffchat // Check for adminchat
if (fPlayer.inStaffChat()) if (fPlayer.inAdminChat())
{ {
FSync.staffChatMessage(player, message); FSync.adminChatMessage(player, message);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
// Check for 4chan trigger
Boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
Boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
{
if (green)
{
message = ChatColor.GREEN + message;
}
else if (orange)
{
message = ChatColor.GOLD + message;
}
}
// Finally, set message // Finally, set message
event.setMessage(message); event.setMessage(message);
@ -123,7 +108,7 @@ public class ChatManager extends FreedomService
} }
// Check for mentions // Check for mentions
Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.sl.isStaff(player); Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player);
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone) if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
@ -135,8 +120,8 @@ public class ChatManager extends FreedomService
// Set format // Set format
event.setFormat(format); event.setFormat(format);
// Send to discord // Send to Discord
if (!ConfigEntry.STAFF_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player)) if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
{ {
plugin.dc.messageChatChannel(plugin.dc.deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message)); plugin.dc.messageChatChannel(plugin.dc.deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message));
} }
@ -144,8 +129,7 @@ public class ChatManager extends FreedomService
public ChatColor getColor(Displayable display) public ChatColor getColor(Displayable display)
{ {
ChatColor color = display.getColor(); return display.getColor();
return color;
} }
public String getColoredTag(Displayable display) public String getColoredTag(Displayable display)
@ -154,27 +138,27 @@ public class ChatManager extends FreedomService
return color + display.getAbbr(); return color + display.getAbbr();
} }
public void staffChat(CommandSender sender, String message) public void adminChat(CommandSender sender, String message)
{ {
Displayable display = plugin.rm.getDisplay(sender); Displayable display = plugin.rm.getDisplay(sender);
FLog.info("[STAFF] " + sender.getName() + " " + display.getTag() + ": " + message, true); FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message); plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (plugin.sl.isStaff(player)) if (plugin.al.isAdmin(player))
{ {
StaffMember staffMember = plugin.sl.getAdmin(player); Admin admin = plugin.al.getAdmin(player);
if (!Strings.isNullOrEmpty(staffMember.getAcFormat())) if (!Strings.isNullOrEmpty(admin.getAcFormat()))
{ {
String format = staffMember.getAcFormat(); String format = admin.getAcFormat();
ChatColor color = getColor(display); ChatColor color = getColor(display);
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message); String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
player.sendMessage(FUtil.colorize(msg)); player.sendMessage(FUtil.colorize(msg));
} }
else else
{ {
player.sendMessage("[" + ChatColor.AQUA + "STAFF" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message)); player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
} }
} }
} }
@ -184,7 +168,7 @@ public class ChatManager extends FreedomService
{ {
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (plugin.sl.isStaff(player)) if (plugin.al.isAdmin(player))
{ {
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report); playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
} }

View file

@ -23,9 +23,9 @@ public class CommandSpy extends FreedomService
{ {
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (plugin.sl.isStaff(player) && plugin.sl.getAdmin(player).getCommandSpy()) if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
{ {
if (plugin.sl.isStaff(event.getPlayer()) && !plugin.sl.isAdmin(player)) if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
{ {
continue; continue;
} }

View file

@ -1,204 +0,0 @@
package me.totalfreedom.totalfreedommod;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class LogViewer extends FreedomService
{
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
{
updateLogsRegistration(sender, target.getName(), mode);
}
public void updateLogsRegistration(final CommandSender sender, final String targetName, final LogsRegistrationMode mode)
{
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
if (logsRegisterUrl == null || logsRegisterPassword == null || logsRegisterUrl.isEmpty() || logsRegisterPassword.isEmpty())
{
return;
}
new BukkitRunnable()
{
@Override
public void run()
{
try
{
if (sender != null)
{
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
}
final String key = SecureCodeGenerator.generateCode(20);
final URL urlAdd = new URLBuilder(logsRegisterUrl)
.addQueryParameter("mode", mode.name())
.addQueryParameter("password", logsRegisterPassword)
.addQueryParameter("name", targetName)
.addQueryParameter("key", key)
.getURL();
final HttpURLConnection connection = (HttpURLConnection)urlAdd.openConnection();
connection.setConnectTimeout(1000 * 5);
connection.setReadTimeout(1000 * 5);
connection.setUseCaches(false);
connection.setRequestMethod("HEAD");
final int responseCode = connection.getResponseCode();
if (sender != null)
{
if (!plugin.isEnabled())
{
return;
}
new BukkitRunnable()
{
@Override
public void run()
{
if (responseCode == 200)
{
if (mode == LogsRegistrationMode.ADD)
{
String link = null;
try
{
final URL urlVerify = new URLBuilder(logsRegisterUrl)
.addQueryParameter("mode", LogsRegistrationMode.VERIFY.name())
.addQueryParameter("name", targetName)
.addQueryParameter("key", key)
.getURL();
link = urlVerify.toString();
}
catch (Exception ex)
{
FLog.severe(ex);
}
sender.sendMessage(ChatColor.GREEN + "Open this link to verify your logviewer registration:\n" + ChatColor.DARK_GREEN + link);
}
else
{
sender.sendMessage(ChatColor.GREEN + "Logviewer access revoked successfully.");
}
}
else
{
sender.sendMessage(ChatColor.RED + "Error contacting logs registration server.");
}
}
}.runTask(plugin);
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
}.runTaskAsynchronously(plugin);
}
public static enum LogsRegistrationMode
{
ADD, DELETE, VERIFY;
}
private static class URLBuilder
{
private final String requestPath;
private final Map<String, String> queryStringMap = new HashMap<>();
private URLBuilder(String requestPath)
{
this.requestPath = requestPath;
}
public URLBuilder addQueryParameter(String key, String value)
{
queryStringMap.put(key, value);
return this;
}
public URL getURL() throws MalformedURLException
{
List<String> pairs = new ArrayList<>();
Iterator<Map.Entry<String, String>> it = queryStringMap.entrySet().iterator();
while (it.hasNext())
{
Map.Entry<String, String> pair = it.next();
try
{
pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"));
}
catch (UnsupportedEncodingException ex)
{
FLog.severe(ex);
}
}
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
}
}
private static class SecureCodeGenerator
{
private static final String CHARACTER_SET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
public static String generateCode(final int length)
{
SecureRandom random;
try
{
random = SecureRandom.getInstance("SHA1PRNG", "SUN");
}
catch (NoSuchAlgorithmException | NoSuchProviderException ex)
{
random = new SecureRandom();
FLog.severe(ex);
}
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++)
{
sb.append(CHARACTER_SET.charAt(random.nextInt(CHARACTER_SET.length())));
}
return sb.toString();
}
}
}

View file

@ -53,7 +53,7 @@ public class LoginProcess extends FreedomService
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event) public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
{ {
final String ip = event.getAddress().getHostAddress().trim(); final String ip = event.getAddress().getHostAddress().trim();
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null; final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
// Check if the player is already online // Check if the player is already online
for (Player onlinePlayer : server.getOnlinePlayers()) for (Player onlinePlayer : server.getOnlinePlayers())
@ -63,10 +63,10 @@ public class LoginProcess extends FreedomService
continue; continue;
} }
if (isStaff) if (isAdmin)
{ {
event.allow(); event.allow();
FSync.playerKick(onlinePlayer, "A staff member just logged in with the username you are using."); FSync.playerKick(onlinePlayer, "An admin just logged in with the username you are using.");
return; return;
} }
@ -113,11 +113,11 @@ public class LoginProcess extends FreedomService
} }
} }
// Check if player is staff // Check if player is admin
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null; final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
// Validation below this point // Validation below this point
if (isStaff) // Player is staff if (isAdmin) // Player is admin
{ {
// Force-allow log in // Force-allow log in
event.allow(); event.allow();
@ -127,9 +127,9 @@ public class LoginProcess extends FreedomService
{ {
for (Player onlinePlayer : server.getOnlinePlayers()) for (Player onlinePlayer : server.getOnlinePlayers())
{ {
if (!plugin.sl.isStaff(onlinePlayer)) if (!plugin.al.isAdmin(onlinePlayer))
{ {
onlinePlayer.kickPlayer("You have been kicked to free up room for a staff member."); onlinePlayer.kickPlayer("You have been kicked to free up room for an admin.");
count--; count--;
} }
@ -149,7 +149,7 @@ public class LoginProcess extends FreedomService
return; return;
} }
// Player is not a staff member // Player is not an admin
// Server full check // Server full check
if (server.getOnlinePlayers().size() >= server.getMaxPlayers()) if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
{ {
@ -157,10 +157,10 @@ public class LoginProcess extends FreedomService
return; return;
} }
// Staff-only mode // Admin-only mode
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean()) if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{ {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to staff only."); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only.");
return; return;
} }
@ -226,7 +226,7 @@ public class LoginProcess extends FreedomService
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n")); player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
} }
if (!plugin.sl.isStaff(player)) if (!plugin.al.isAdmin(player))
{ {
String tag = playerData.getTag(); String tag = playerData.getTag();
if (tag != null) if (tag != null)
@ -237,14 +237,14 @@ public class LoginProcess extends FreedomService
int noteCount = playerData.getNotes().size(); int noteCount = playerData.getNotes().size();
if (noteCount != 0) if (noteCount != 0)
{ {
String noteMessage = "This player has " + noteCount + " staff note" + (noteCount > 1 ? "s" : "") + "."; String noteMessage = "This player has " + noteCount + " admin note" + (noteCount > 1 ? "s" : "") + ".";
JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.") JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
.tooltip("Click here to view them.") .tooltip("Click here to view them.")
.runCommand("/notes " + player.getName() + " list"); .runCommand("/notes " + player.getName() + " list");
FLog.info(noteMessage); FLog.info(noteMessage);
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (plugin.sl.isStaffImpostor(p)) if (plugin.al.isAdminImpostor(p))
{ {
notice.send(p); notice.send(p);
} }
@ -257,14 +257,14 @@ public class LoginProcess extends FreedomService
@Override @Override
public void run() public void run()
{ {
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean()) if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{ {
player.sendMessage(ChatColor.RED + "Server is currently closed to non-staff."); player.sendMessage(ChatColor.RED + "Server is currently closed to non-admins.");
} }
if (lockdownEnabled) if (lockdownEnabled)
{ {
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED); FUtil.playerMsg(player, "Warning: Server is currently in lockdown-mode, new players will not be able to join!", ChatColor.RED);
} }
} }
}.runTaskLater(plugin, 20L); }.runTaskLater(plugin, 20L);

View file

@ -46,7 +46,7 @@ public class Monitors extends FreedomService
} }
} }
plugin.sl.potionSpyMessage(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.", plugin.al.potionSpyMessage(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.",
player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(), player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(),
latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : ""))); latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : "")));
} }

View file

@ -23,7 +23,6 @@ import org.bukkit.inventory.ItemStack;
public class MovementValidator extends FreedomService public class MovementValidator extends FreedomService
{ {
public static final int MAX_XYZ_COORD = 29999998; public static final int MAX_XYZ_COORD = 29999998;
public static final int MAX_DISTANCE_TRAVELED = 100; public static final int MAX_DISTANCE_TRAVELED = 100;

View file

@ -45,7 +45,7 @@ public class Muter extends FreedomService
return; return;
} }
if (plugin.sl.isStaffSync(player)) if (plugin.al.isAdminSync(player))
{ {
fPlayer.setMuted(false); fPlayer.setMuted(false);
MUTED_PLAYERS.remove(player.getName()); MUTED_PLAYERS.remove(player.getName());
@ -70,7 +70,7 @@ public class Muter extends FreedomService
} }
String message = event.getMessage(); String message = event.getMessage();
if (plugin.sl.isStaff(player)) if (plugin.al.isAdmin(player))
{ {
fPlayer.setMuted(false); fPlayer.setMuted(false);
return; return;

View file

@ -7,7 +7,7 @@ import joptsimple.internal.Strings;
import lombok.Getter; import lombok.Getter;
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.staff.StaffMember; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.Response; import me.totalfreedom.totalfreedommod.util.Response;
@ -34,16 +34,16 @@ public class Pterodactyl extends FreedomService
{ {
} }
public void updateAccountStatus(StaffMember staffMember) public void updateAccountStatus(Admin admin)
{ {
String id = staffMember.getPteroID(); String id = admin.getPteroID();
if (Strings.isNullOrEmpty(id) || !enabled) if (Strings.isNullOrEmpty(id) || !enabled)
{ {
return; return;
} }
if (!staffMember.isActive() || staffMember.getRank() != Rank.SENIOR_ADMIN) if (!admin.isActive() || admin.getRank() != Rank.SENIOR_ADMIN)
{ {
FLog.debug("Disabling ptero acc"); FLog.debug("Disabling ptero acc");
removeAccountFromServer(id); removeAccountFromServer(id);

View file

@ -1,217 +0,0 @@
package me.totalfreedom.totalfreedommod;
import com.google.common.base.Strings;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Displayable;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.rank.Title;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.dean.jraw.ApiException;
import net.dean.jraw.RedditClient;
import net.dean.jraw.http.OkHttpNetworkAdapter;
import net.dean.jraw.http.UserAgent;
import net.dean.jraw.models.CurrentFlair;
import net.dean.jraw.models.Flair;
import net.dean.jraw.oauth.Credentials;
import net.dean.jraw.oauth.OAuthHelper;
import net.dean.jraw.references.SubredditReference;
import org.bukkit.entity.Player;
public class Reddit extends FreedomService
{
private final String SUBREDDIT_NAME = ConfigEntry.REDDIT_SUBREDDIT_NAME.getString();
private final String USERNAME = ConfigEntry.REDDIT_USERNAME.getString();
private final String PASSWORD = ConfigEntry.REDDIT_PASSWORD.getString();
private final String CLIENT_ID = ConfigEntry.REDDIT_CLIENT_ID.getString();
private final String CLIENT_SECRET = ConfigEntry.REDDIT_CLIENT_SECRET.getString();
private final UserAgent userAgent = new UserAgent("bot", "me.totalfreedom.reddit", TotalFreedomMod.build.version, USERNAME);
private final Credentials credentials = Credentials.script(USERNAME, PASSWORD, CLIENT_ID, CLIENT_SECRET);
private RedditClient reddit = null;
private SubredditReference subreddit = null;
private HashMap<String, PlayerData> linkCodes = new HashMap<>();
private HashMap<PlayerData, String> pending = new HashMap<>();
private Map<Displayable, String> flairList = new HashMap<>();
private Map<Displayable, String> flairNameList = new HashMap<>();
private List<Displayable> noFlairDisplays = Arrays.asList(Title.VERIFIED_STAFF, Rank.IMPOSTOR, Rank.NON_OP, Rank.OP);
public boolean enabled = false;
@Override
public void onStart()
{
enabled = ConfigEntry.REDDIT_CLIENT_ID.getString() == null;
if (!enabled)
{
return;
}
if (reddit == null)
{
try
{
reddit = OAuthHelper.automatic(new OkHttpNetworkAdapter(userAgent), credentials);
reddit.setLogHttp(FUtil.inDeveloperMode());
}
catch (NoClassDefFoundError e)
{
FLog.warning("The JRAW plugin is not installed, therefore the Reddit service cannot start.");
FLog.warning("To resolve this error, please download the latest JRAW from: https://github.com/TFPatches/Minecraft-JRAW/releases");
enabled = false;
return;
}
catch (NullPointerException e)
{
FLog.warning("Invalid Reddit credentials specified, please double check everything in the config.");
enabled = false;
return;
}
}
if (subreddit == null)
{
subreddit = reddit.subreddit(SUBREDDIT_NAME);
}
loadFlairList();
}
@Override
public void onStop()
{
}
public void setFlair(String username, String flairID)
{
List<Flair> flairs = subreddit.userFlairOptions();
Flair flair = null;
for (Flair f : flairs)
{
if (f.getId().equals(flairID))
{
flair = f;
break;
}
}
if (flair == null)
{
return;
}
subreddit.otherUserFlair(username).updateToTemplate(flair.getId(), "");
}
public void removeFlair(String username)
{
subreddit.otherUserFlair(username).updateToTemplate("", "");
}
public void sendModMessage(String username, String subject, String body) throws ApiException
{
reddit.me().inbox().compose("/r/" + SUBREDDIT_NAME, username, subject, body);
}
public String addLinkCode(PlayerData data, String username)
{
String code = FUtil.randomAlphanumericString(10);
linkCodes.put(code, data);
pending.put(data, username);
return code;
}
public String checkLinkCode(String code)
{
PlayerData data = linkCodes.get(code);
String username = pending.get(data);
if (data == null || username == null)
{
return null;
}
linkCodes.remove(code);
pending.remove(data);
data.setRedditUsername(username);
plugin.pl.save(data);
return username;
}
public boolean updateFlair(Player player)
{
if (!enabled)
{
return false;
}
PlayerData data = plugin.pl.getData(player);
String username = data.getRedditUsername();
Displayable display = plugin.rm.getDisplay(player);
if (username == null)
{
FLog.debug("No Reddit account");
return false;
}
CurrentFlair currentFlair = subreddit.otherUserFlair(username).current();
String currentFlairName = currentFlair.getText();
String currentFlairID = currentFlair.getId();
String neededFlairID = flairList.get(display);
String neededFlairName = flairNameList.get(display);
FLog.debug("Current ID: " + currentFlairID);
FLog.debug("Needed ID: " + neededFlairID);
FLog.debug("Current Name: " + currentFlairName);
FLog.debug("Needed Name: " + neededFlairName);
// Work around
//if (currentFlairID == null && neededFlairID != null || currentFlairID != null && neededFlairID != null && !currentFlairID.equals(neededFlairID))
if (Strings.isNullOrEmpty(currentFlairName) && neededFlairName != null || !Strings.isNullOrEmpty(currentFlairName) && neededFlairName != null && !currentFlairName.equals(neededFlairName))
{
FLog.debug("Setting flair");
setFlair(username, neededFlairID);
return true;
}
if (noFlairDisplays.contains(display) && !Strings.isNullOrEmpty(currentFlairName))
{
FLog.debug("Removing flair");
removeFlair(username);
return true;
}
return false;
}
public void loadFlairList()
{
flairList.put(Title.OWNER, ConfigEntry.REDDIT_SERVER_OWNER_FLAIR_ID.getString());
flairList.put(Title.EXECUTIVE, ConfigEntry.REDDIT_EXECUTIVE_FLAIR_ID.getString());
flairList.put(Title.DEVELOPER, ConfigEntry.REDDIT_DEVELOPER_FLAIR_ID.getString());
flairList.put(Rank.SENIOR_ADMIN, ConfigEntry.REDDIT_SENIOR_ADMIN_FLAIR_ID.getString());
flairList.put(Rank.ADMIN, ConfigEntry.REDDIT_NEW_ADMIN_FLAIR_ID.getString());
flairList.put(Title.MASTER_BUILDER, ConfigEntry.REDDIT_MASTER_BUILDER_FLAIR_ID.getString());
// Work around because the current flair ID keeps returning null, either a JRAW bug or a Reddit bug
flairNameList.put(Title.OWNER, "Server Owner");
flairNameList.put(Title.EXECUTIVE, "Executive");
flairNameList.put(Title.DEVELOPER, "Developer");
flairNameList.put(Rank.SENIOR_ADMIN, "Senior Admin");
flairNameList.put(Rank.ADMIN, "Admin");
flairNameList.put(Title.MASTER_BUILDER, "Master Builder");
}
}

View file

@ -94,5 +94,4 @@ public class SavedFlags extends FreedomService
FLog.severe(ex); FLog.severe(ex);
} }
} }
} }

View file

@ -30,9 +30,9 @@ public class ServerPing extends FreedomService
return; return;
} }
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean()) if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{ {
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_STAFFMODE_MOTD.getString())); event.setMotd(FUtil.colorize(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
return; return;
} }

View file

@ -1,34 +0,0 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.command.Command_sit;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.spigotmc.event.entity.EntityDismountEvent;
public class Sitter extends FreedomService
{
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
@EventHandler
public void onEntityDismount(EntityDismountEvent e)
{
Entity dm = e.getDismounted();
if (dm instanceof ArmorStand)
{
if (Command_sit.STANDS.contains(dm))
{
Command_sit.STANDS.remove(dm);
dm.remove();
}
}
}
}

View file

@ -26,11 +26,8 @@ import me.totalfreedom.totalfreedommod.command.CommandLoader;
import me.totalfreedom.totalfreedommod.config.MainConfig; import me.totalfreedom.totalfreedommod.config.MainConfig;
import me.totalfreedom.totalfreedommod.discord.Discord; import me.totalfreedom.totalfreedommod.discord.Discord;
import me.totalfreedom.totalfreedommod.freeze.Freezer; import me.totalfreedom.totalfreedommod.freeze.Freezer;
import me.totalfreedom.totalfreedommod.fun.CurseListener;
import me.totalfreedom.totalfreedommod.fun.ItemFun; import me.totalfreedom.totalfreedommod.fun.ItemFun;
import me.totalfreedom.totalfreedommod.fun.Jumppads; import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.fun.Landminer;
import me.totalfreedom.totalfreedommod.fun.MP44;
import me.totalfreedom.totalfreedommod.fun.Trailer; import me.totalfreedom.totalfreedommod.fun.Trailer;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon; import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig; import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
@ -41,8 +38,8 @@ import me.totalfreedom.totalfreedommod.rank.RankManager;
import me.totalfreedom.totalfreedommod.shop.Shop; import me.totalfreedom.totalfreedommod.shop.Shop;
import me.totalfreedom.totalfreedommod.shop.Votifier; import me.totalfreedom.totalfreedommod.shop.Votifier;
import me.totalfreedom.totalfreedommod.sql.SQLite; import me.totalfreedom.totalfreedommod.sql.SQLite;
import me.totalfreedom.totalfreedommod.staff.ActivityLog; import me.totalfreedom.totalfreedommod.admin.ActivityLog;
import me.totalfreedom.totalfreedommod.staff.StaffList; import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.MethodTimer; import me.totalfreedom.totalfreedommod.util.MethodTimer;
@ -83,8 +80,7 @@ public class TotalFreedomMod extends JavaPlugin
public ServerInterface si; public ServerInterface si;
public SavedFlags sf; public SavedFlags sf;
public WorldManager wm; public WorldManager wm;
public LogViewer lv; public AdminList al;
public StaffList sl;
public ActivityLog acl; public ActivityLog acl;
public RankManager rm; public RankManager rm;
public CommandBlocker cb; public CommandBlocker cb;
@ -107,7 +103,6 @@ public class TotalFreedomMod extends JavaPlugin
public BanManager bm; public BanManager bm;
public IndefiniteBanList im; public IndefiniteBanList im;
public PermissionManager pem; public PermissionManager pem;
public Reddit rd;
public GameRuleHandler gr; public GameRuleHandler gr;
public CommandSpy cs; public CommandSpy cs;
public Cager ca; public Cager ca;
@ -122,22 +117,16 @@ public class TotalFreedomMod extends JavaPlugin
public Monitors mo; public Monitors mo;
public MovementValidator mv; public MovementValidator mv;
public ServerPing sp; public ServerPing sp;
public CurseListener cul;
public ItemFun it; public ItemFun it;
public Landminer lm;
public MP44 mp;
public Jumppads jp; public Jumppads jp;
public Trailer tr; public Trailer tr;
public HTTPDaemon hd; public HTTPDaemon hd;
public WorldRestrictions wr; public WorldRestrictions wr;
public SignBlocker snp; public SignBlocker snp;
public EntityWiper ew; public EntityWiper ew;
public Sitter st;
public VanishHandler vh; public VanishHandler vh;
public Pterodactyl ptero; public Pterodactyl ptero;
//public HubWorldRestrictions hwr;
//
// Bridges // Bridges
public BukkitTelnetBridge btb; public BukkitTelnetBridge btb;
public EssentialsBridge esb; public EssentialsBridge esb;
@ -200,9 +189,8 @@ public class TotalFreedomMod extends JavaPlugin
si = new ServerInterface(); si = new ServerInterface();
sf = new SavedFlags(); sf = new SavedFlags();
wm = new WorldManager(); wm = new WorldManager();
lv = new LogViewer();
sql = new SQLite(); sql = new SQLite();
sl = new StaffList(); al = new AdminList();
acl = new ActivityLog(); acl = new ActivityLog();
rm = new RankManager(); rm = new RankManager();
cb = new CommandBlocker(); cb = new CommandBlocker();
@ -225,11 +213,9 @@ public class TotalFreedomMod extends JavaPlugin
bm = new BanManager(); bm = new BanManager();
im = new IndefiniteBanList(); im = new IndefiniteBanList();
pem = new PermissionManager(); pem = new PermissionManager();
rd = new Reddit();
gr = new GameRuleHandler(); gr = new GameRuleHandler();
snp = new SignBlocker(); snp = new SignBlocker();
ew = new EntityWiper(); ew = new EntityWiper();
st = new Sitter();
vh = new VanishHandler(); vh = new VanishHandler();
ptero = new Pterodactyl(); ptero = new Pterodactyl();
@ -250,10 +236,7 @@ public class TotalFreedomMod extends JavaPlugin
sp = new ServerPing(); sp = new ServerPing();
// Fun // Fun
cul = new CurseListener();
it = new ItemFun(); it = new ItemFun();
lm = new Landminer();
mp = new MP44();
jp = new Jumppads(); jp = new Jumppads();
tr = new Trailer(); tr = new Trailer();
// HTTPD // HTTPD

View file

@ -31,7 +31,7 @@ public class VanishHandler extends FreedomService
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (!plugin.sl.isStaff(player) && plugin.sl.isVanished(p.getName())) if (!plugin.al.isAdmin(player) && plugin.al.isVanished(p.getName()))
{ {
player.hidePlayer(plugin, p); player.hidePlayer(plugin, p);
} }
@ -39,17 +39,17 @@ public class VanishHandler extends FreedomService
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (!plugin.sl.isStaff(p) && plugin.sl.isVanished(player.getName())) if (!plugin.al.isAdmin(p) && plugin.al.isVanished(player.getName()))
{ {
p.hidePlayer(plugin, player); p.hidePlayer(plugin, player);
} }
} }
if (plugin.sl.isVanished(player.getName())) if (plugin.al.isVanished(player.getName()))
{ {
plugin.esb.setVanished(player.getName(), true); plugin.esb.setVanished(player.getName(), true);
FLog.info(player.getName() + " joined while still vanished."); FLog.info(player.getName() + " joined while still vanished.");
plugin.sl.messageAllStaff(ChatColor.YELLOW + player.getName() + " has joined silently."); plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has joined silently.");
event.setJoinMessage(null); event.setJoinMessage(null);
new BukkitRunnable() new BukkitRunnable()
@ -57,7 +57,7 @@ public class VanishHandler extends FreedomService
@Override @Override
public void run() public void run()
{ {
if (!plugin.sl.isVanished(player.getName())) if (!plugin.al.isVanished(player.getName()))
{ {
this.cancel(); this.cancel();
} }
@ -73,11 +73,11 @@ public class VanishHandler extends FreedomService
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (plugin.sl.isVanished(player.getName())) if (plugin.al.isVanished(player.getName()))
{ {
event.setQuitMessage(null); event.setQuitMessage(null);
FLog.info(player.getName() + " left while still vanished."); FLog.info(player.getName() + " left while still vanished.");
plugin.sl.messageAllStaff(ChatColor.YELLOW + player.getName() + " has left silently."); plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has left silently.");
} }
} }
} }

View file

@ -1,4 +1,4 @@
package me.totalfreedom.totalfreedommod.staff; package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import java.util.Map; import java.util.Map;
@ -17,7 +17,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class ActivityLog extends FreedomService public class ActivityLog extends FreedomService
{ {
public static final String FILENAME = "activitylog.yml"; public static final String FILENAME = "activitylog.yml";
@Getter @Getter
@ -167,7 +166,7 @@ public class ActivityLog extends FreedomService
public void onPlayerJoin(PlayerJoinEvent event) public void onPlayerJoin(PlayerJoinEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (plugin.sl.isStaff(player)) if (plugin.al.isAdmin(player))
{ {
getActivityLog(event.getPlayer()).addLogin(); getActivityLog(event.getPlayer()).addLogin();
plugin.acl.save(); plugin.acl.save();
@ -179,7 +178,7 @@ public class ActivityLog extends FreedomService
public void onPlayerQuit(PlayerQuitEvent event) public void onPlayerQuit(PlayerQuitEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (plugin.sl.isStaff(player)) if (plugin.al.isAdmin(player))
{ {
getActivityLog(event.getPlayer()).addLogout(); getActivityLog(event.getPlayer()).addLogout();
plugin.acl.save(); plugin.acl.save();

View file

@ -1,4 +1,4 @@
package me.totalfreedom.totalfreedommod.staff; package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.time.Instant; import java.time.Instant;

View file

@ -1,4 +1,4 @@
package me.totalfreedom.totalfreedommod.staff; package me.totalfreedom.totalfreedommod.admin;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -9,7 +9,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
@ -17,7 +16,7 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class StaffMember public class Admin
{ {
@Getter @Getter
@Setter @Setter
@ -45,13 +44,13 @@ public class StaffMember
@Setter @Setter
private String pteroID = null; private String pteroID = null;
public StaffMember(Player player) public Admin(Player player)
{ {
this.name = player.getName(); this.name = player.getName();
this.ips.add(FUtil.getIp(player)); this.ips.add(FUtil.getIp(player));
} }
public StaffMember(ResultSet resultSet) public Admin(ResultSet resultSet)
{ {
try try
{ {
@ -68,7 +67,7 @@ public class StaffMember
} }
catch (SQLException e) catch (SQLException e)
{ {
FLog.severe("Failed to load staff: " + e.getMessage()); FLog.severe("Failed to load admin: " + e.getMessage());
} }
} }
@ -77,7 +76,7 @@ public class StaffMember
{ {
final StringBuilder output = new StringBuilder(); final StringBuilder output = new StringBuilder();
output.append("Staff: ").append(name).append("\n") output.append("Admin: ").append(name).append("\n")
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n") .append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n") .append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
.append("- Rank: ").append(rank.getName()).append("\n") .append("- Rank: ").append(rank.getName()).append("\n")
@ -151,8 +150,6 @@ public class StaffMember
plugin.btb.killTelnetSessions(getName()); plugin.btb.killTelnetSessions(getName());
} }
} }
plugin.lv.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE);
} }
} }

View file

@ -0,0 +1,381 @@
package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class AdminList extends FreedomService
{
@Getter
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
// Only active admins below
@Getter
private final Set<Admin> activeAdmins = Sets.newHashSet();
private final Map<String, Admin> nameTable = Maps.newHashMap();
private final Map<String, Admin> ipTable = Maps.newHashMap();
public final List<String> verifiedNoAdmin = new ArrayList<>();
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
public static final List<String> vanished = new ArrayList<>();
@Override
public void onStart()
{
load();
deactivateOldEntries(false);
}
@Override
public void onStop()
{
}
public void load()
{
allAdmins.clear();
try
{
ResultSet adminSet = plugin.sql.getAdminlist();
{
while (adminSet.next())
{
Admin admin = new Admin(adminSet);
allAdmins.add(admin);
}
}
}
catch (SQLException e)
{
FLog.severe("Failed to load admin list: " + e.getMessage());
}
updateTables();
FLog.info("Loaded " + allAdmins.size() + " admin members (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
}
public void messageAllAdmins(String message)
{
for (Player player : server.getOnlinePlayers())
{
if (isAdmin(player))
{
player.sendMessage(message);
}
}
}
public void potionSpyMessage(String message)
{
for (Player player : server.getOnlinePlayers())
{
Admin admin = getAdmin(player.getPlayer());
if (isAdmin(player) && admin.getPotionSpy())
{
player.sendMessage(message);
}
}
}
public synchronized boolean isAdminSync(CommandSender sender)
{
return isAdmin(sender);
}
public List<String> getActiveAdminNames()
{
List<String> names = new ArrayList();
for (Admin admin : activeAdmins)
{
names.add(admin.getName());
}
return names;
}
public boolean isAdmin(CommandSender sender)
{
if (!(sender instanceof Player))
{
return true;
}
Admin admin = getAdmin((Player)sender);
return admin != null && admin.isActive();
}
public boolean isAdmin(Player player)
{
if (player == null)
{
return true;
}
Admin admin = getAdmin(player);
return admin != null && admin.isActive();
}
public boolean isSeniorAdmin(CommandSender sender)
{
Admin admin = getAdmin(sender);
if (admin == null)
{
return false;
}
return admin.getRank().ordinal() >= Rank.SENIOR_ADMIN.ordinal();
}
public Admin getAdmin(CommandSender sender)
{
if (sender instanceof Player)
{
return getAdmin((Player)sender);
}
return getEntryByName(sender.getName());
}
public Admin getAdmin(Player player)
{
// Find admin
String ip = FUtil.getIp(player);
Admin admin = getEntryByName(player.getName());
// Admin by name
if (admin != null)
{
// Check if we're in online mode,
// Or the players IP is in the admin entry
if (Bukkit.getOnlineMode() || admin.getIps().contains(ip))
{
if (!admin.getIps().contains(ip))
{
// Add the new IP if we have to
admin.addIp(ip);
save(admin);
updateTables();
}
return admin;
}
}
// Admin by ip
admin = getEntryByIp(ip);
if (admin != null)
{
// Set the new username
String oldName = admin.getName();
admin.setName(player.getName());
plugin.sql.updateAdminName(oldName, admin.getName());
updateTables();
}
return null;
}
public Admin getEntryByName(String name)
{
return nameTable.get(name.toLowerCase());
}
public Admin getEntryByIp(String ip)
{
return ipTable.get(ip);
}
public Admin getEntryByIpFuzzy(String needleIp)
{
final Admin directAdmin = getEntryByIp(needleIp);
if (directAdmin != null)
{
return directAdmin;
}
for (String ip : ipTable.keySet())
{
if (FUtil.fuzzyIpMatch(needleIp, ip, 3))
{
return ipTable.get(ip);
}
}
return null;
}
public void updateLastLogin(Player player)
{
final Admin admin = getAdmin(player);
if (admin == null)
{
return;
}
admin.setLastLogin(new Date());
admin.setName(player.getName());
save(admin);
}
public boolean isAdminImpostor(Player player)
{
return getEntryByName(player.getName()) != null && !isAdmin(player) && !isVerifiedAdmin(player);
}
public boolean isVerifiedAdmin(Player player)
{
return verifiedNoAdmin.contains(player.getName()) && verifiedNoAdminIps.get(player.getName()).contains(FUtil.getIp(player));
}
public boolean isIdentityMatched(Player player)
{
if (Bukkit.getOnlineMode())
{
return true;
}
Admin admin = getAdmin(player);
return admin != null && admin.getName().equalsIgnoreCase(player.getName());
}
public void addAdmin(Admin admin)
{
if (!admin.isValid())
{
FLog.warning("Could not add admin: " + admin.getName() + ". Admin is missing details!");
return;
}
// Store admin, update views
allAdmins.add(admin);
updateTables();
// Save admin
plugin.sql.addAdmin(admin);
}
public boolean removeAdmin(Admin admin)
{
if (admin.getRank().isAtLeast(Rank.ADMIN))
{
if (plugin.btb != null)
{
plugin.btb.killTelnetSessions(admin.getName());
}
}
// Remove admin, update views
if (!allAdmins.remove(admin))
{
return false;
}
updateTables();
// Unsave admin
plugin.sql.removeAdmin(admin);
return true;
}
public void updateTables()
{
activeAdmins.clear();
nameTable.clear();
ipTable.clear();
for (Admin admin : allAdmins)
{
if (!admin.isActive())
{
continue;
}
activeAdmins.add(admin);
nameTable.put(admin.getName().toLowerCase(), admin);
for (String ip : admin.getIps())
{
ipTable.put(ip, admin);
}
}
}
public Set<String> getAdminNames()
{
return nameTable.keySet();
}
public Set<String> getAdminIps()
{
return ipTable.keySet();
}
public void save(Admin admin)
{
try
{
ResultSet currentSave = plugin.sql.getAdminByName(admin.getName());
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
{
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
{
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
}
}
}
catch (SQLException e)
{
FLog.severe("Failed to save admin: " + e.getMessage());
}
}
public void deactivateOldEntries(boolean verbose)
{
for (Admin admin : allAdmins)
{
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
{
continue;
}
final Date lastLogin = admin.getLastLogin();
final long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
if (lastLoginHours < ConfigEntry.ADMINLIST_CLEAN_THESHOLD_HOURS.getInteger())
{
continue;
}
if (verbose)
{
FUtil.adminAction("TotalFreedomMod", "Deactivating admin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
}
admin.setActive(false);
save(admin);
}
updateTables();
}
public boolean isVanished(String player)
{
return vanished.contains(player);
}
}

View file

@ -271,7 +271,7 @@ public class BanManager extends FreedomService
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final PlayerData data = plugin.pl.getData(player); final PlayerData data = plugin.pl.getData(player);
if (!plugin.sl.isStaff(player)) if (!plugin.al.isAdmin(player))
{ {
return; return;
} }

View file

@ -181,6 +181,5 @@ public class BlockBlocker extends FreedomService
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed."); player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
} }
} }
} }
} }

View file

@ -30,7 +30,7 @@ public class EditBlocker extends FreedomService
return; return;
} }
if (plugin.sl.isStaffSync(event.getPlayer())) if (plugin.al.isAdminSync(event.getPlayer()))
{ {
fPlayer.setEditBlocked(false); fPlayer.setEditBlocked(false);
return; return;
@ -49,7 +49,7 @@ public class EditBlocker extends FreedomService
return; return;
} }
if (plugin.sl.isStaffSync(event.getPlayer())) if (plugin.al.isAdminSync(event.getPlayer()))
{ {
fPlayer.setEditBlocked(false); fPlayer.setEditBlocked(false);
return; return;

View file

@ -148,11 +148,6 @@ public class EventBlocker extends FreedomService
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event) public void onPlayerDropItem(PlayerDropItemEvent event)
{ {
if (!plugin.sl.isStaff(event.getPlayer()))
{
event.setCancelled(true);
}
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean()) if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{ {
return; return;
@ -213,7 +208,7 @@ public class EventBlocker extends FreedomService
} }
// TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper. // TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
private ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP)); private final ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
@EventHandler @EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) public void onBlockPhysics(BlockPhysicsEvent event)

View file

@ -90,7 +90,7 @@ public class InteractBlocker extends FreedomService
{ {
case WATER_BUCKET: case WATER_BUCKET:
{ {
if (plugin.sl.isStaff(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean()) if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{ {
break; break;
} }
@ -103,7 +103,7 @@ public class InteractBlocker extends FreedomService
case LAVA_BUCKET: case LAVA_BUCKET:
{ {
if (plugin.sl.isStaff(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean()) if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{ {
break; break;
} }

View file

@ -70,7 +70,7 @@ public class PVPBlocker extends FreedomService
} }
} }
if (player != null & !plugin.sl.isStaff(player)) if (player != null & !plugin.al.isAdmin(player))
{ {
if (player.getGameMode() == GameMode.CREATIVE) if (player.getGameMode() == GameMode.CREATIVE)
{ {

View file

@ -24,7 +24,6 @@ import org.bukkit.plugin.SimplePluginManager;
public class CommandBlocker extends FreedomService public class CommandBlocker extends FreedomService
{ {
private final Pattern flagPattern = Pattern.compile("(:([0-9]){5,})"); private final Pattern flagPattern = Pattern.compile("(:([0-9]){5,})");
// //
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap(); private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
@ -171,7 +170,7 @@ public class CommandBlocker extends FreedomService
for (String part : commandParts) for (String part : commandParts)
{ {
if (command.startsWith("/") && !plugin.sl.isStaff(sender) && (part.contains("#copy") || part.contains("#clipboard"))) if (command.startsWith("/") && !plugin.al.isAdmin(sender) && (part.contains("#copy") || part.contains("#clipboard")))
{ {
FUtil.playerMsg(sender, "WorldEdit copy variables are disabled."); FUtil.playerMsg(sender, "WorldEdit copy variables are disabled.");
return true; return true;

View file

@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.blocking.command;
public enum CommandBlockerAction public enum CommandBlockerAction
{ {
BLOCK("b"), BLOCK("b"),
BLOCK_AND_EJECT("a"), BLOCK_AND_EJECT("a"),
BLOCK_UNKNOWN("u"); BLOCK_UNKNOWN("u");

View file

@ -10,7 +10,6 @@ import org.spigotmc.SpigotConfig;
public class CommandBlockerEntry public class CommandBlockerEntry
{ {
@Getter @Getter
private final CommandBlockerRank rank; private final CommandBlockerRank rank;
@Getter @Getter

View file

@ -2,18 +2,15 @@ package me.totalfreedom.totalfreedommod.blocking.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.staff.StaffMember; import me.totalfreedom.totalfreedommod.admin.Admin;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public enum CommandBlockerRank public enum CommandBlockerRank
{ {
ANYONE("a"), ANYONE("a"),
OP("o"), OP("o"),
SUPER("s"), ADMIN("a"),
TELNET("t"), SENIOR_ADMIN("s"),
SENIOR("c"),
NOBODY("n"); NOBODY("n");
// //
private final String token; private final String token;
@ -35,19 +32,14 @@ public enum CommandBlockerRank
public static CommandBlockerRank fromSender(CommandSender sender) public static CommandBlockerRank fromSender(CommandSender sender)
{ {
if (!(sender instanceof Player)) Admin admin = TotalFreedomMod.plugin().al.getAdmin(sender);
if (admin != null)
{ {
return TELNET; if (admin.getRank() == Rank.SENIOR_ADMIN)
{
return SENIOR_ADMIN;
} }
return ADMIN;
StaffMember staffMember = TotalFreedomMod.plugin().sl.getAdmin(sender);
if (staffMember != null)
{
if (staffMember.getRank() == Rank.SENIOR_ADMIN)
{
return SENIOR;
}
return SUPER;
} }
if (sender.isOp()) if (sender.isOp())

View file

@ -11,7 +11,7 @@ import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
import me.totalfreedom.bukkittelnet.session.ClientSession; import me.totalfreedom.bukkittelnet.session.ClientSession;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.staff.StaffMember; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -43,15 +43,15 @@ public class BukkitTelnetBridge extends FreedomService
return; return;
} }
final StaffMember staffMember = plugin.sl.getEntryByIpFuzzy(ip); final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
if (staffMember == null || !staffMember.isActive() || !staffMember.getRank().hasConsoleVariant()) if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
{ {
return; return;
} }
event.setBypassPassword(true); event.setBypassPassword(true);
event.setName(staffMember.getName()); event.setName(admin.getName());
} }
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
@ -77,14 +77,14 @@ public class BukkitTelnetBridge extends FreedomService
boolean isTelnetAdmin = false; boolean isTelnetAdmin = false;
boolean isSeniorAdmin = false; boolean isSeniorAdmin = false;
final StaffMember staffMember = plugin.sl.getAdmin(player); final Admin admin = plugin.al.getAdmin(player);
if (staffMember != null) if (admin != null)
{ {
boolean active = staffMember.isActive(); boolean active = admin.isActive();
isAdmin = active; isAdmin = active;
isSeniorAdmin = active && staffMember.getRank() == Rank.SENIOR_ADMIN; isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
isTelnetAdmin = active && (isSeniorAdmin || staffMember.getRank() == Rank.ADMIN); isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.ADMIN);
} }
playerTags.put("tfm.admin.isAdmin", isAdmin); playerTags.put("tfm.admin.isAdmin", isAdmin);
@ -121,22 +121,22 @@ public class BukkitTelnetBridge extends FreedomService
return bukkitTelnetPlugin; return bukkitTelnetPlugin;
} }
public List<StaffMember> getConnectedAdmins() public List<Admin> getConnectedAdmins()
{ {
List<StaffMember> staffMembers = new ArrayList<>(); List<Admin> admins = new ArrayList<>();
final BukkitTelnet telnet = getBukkitTelnetPlugin(); final BukkitTelnet telnet = getBukkitTelnetPlugin();
if (telnet != null) if (telnet != null)
{ {
for (ClientSession session : telnet.appender.getSessions()) for (ClientSession session : telnet.appender.getSessions())
{ {
StaffMember staffMember = plugin.sl.getEntryByName(session.getUserName().toLowerCase()); Admin admin = plugin.al.getEntryByName(session.getUserName().toLowerCase());
if (staffMember != null && !staffMembers.contains(staffMember)) if (admin != null && !admins.contains(admin))
{ {
staffMembers.add(staffMember); admins.add(admin);
} }
} }
} }
return staffMembers; return admins;
} }
public void killTelnetSessions(final String name) public void killTelnetSessions(final String name)

View file

@ -46,7 +46,7 @@ public class LibsDisguisesBridge extends FreedomService
return libsDisguisesPlugin; return libsDisguisesPlugin;
} }
public void undisguiseAll(boolean staff) public void undisguiseAll(boolean admins)
{ {
try try
{ {
@ -61,7 +61,7 @@ public class LibsDisguisesBridge extends FreedomService
{ {
if (DisguiseAPI.isDisguised(player)) if (DisguiseAPI.isDisguised(player))
{ {
if (!staff && plugin.sl.isStaff(player)) if (!admins && plugin.al.isAdmin(player))
{ {
continue; continue;
} }

View file

@ -32,7 +32,7 @@ public class Cager extends FreedomService
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player == null if (player == null
|| plugin.sl.isStaff(player)) || plugin.al.isAdmin(player))
{ {
return; return;
} }

View file

@ -8,10 +8,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Talk privately with other staff on the server.", usage = "/<command> [message]", aliases = "o,sc") @CommandParameters(description = "Talk privately with other admins on the server.", usage = "/<command> [message]", aliases = "o,sc")
public class Command_staffchat extends FreedomCommand public class Command_adminchat 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)
{ {
@ -19,17 +18,17 @@ public class Command_staffchat extends FreedomCommand
{ {
if (senderIsConsole) if (senderIsConsole)
{ {
msg("You must be in-game to toggle staff chat, it cannot be toggled via CONSOLE or Telnet."); msg("You must be in-game to toggle admin chat, it cannot be toggled via CONSOLE or Telnet.");
return true; return true;
} }
FPlayer userinfo = plugin.pl.getPlayer(playerSender); FPlayer userinfo = plugin.pl.getPlayer(playerSender);
userinfo.setStaffChat(!userinfo.inStaffChat()); userinfo.setAdminChat(!userinfo.inAdminChat());
msg("Toggled your staff chat " + (userinfo.inStaffChat() ? "on" : "off") + "."); msg("Toggled your admin chat " + (userinfo.inAdminChat() ? "on" : "off") + ".");
} }
else else
{ {
plugin.cm.staffChat(sender, StringUtils.join(args, " ")); plugin.cm.adminChat(sender, StringUtils.join(args, " "));
} }
return true; return true;
} }

View file

@ -11,22 +11,21 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) @CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Information on how to apply for staff.", usage = "/<command>", aliases = "si") @CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "ai")
public class Command_staffinfo extends FreedomCommand public class Command_admininfo 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)
{ {
List<String> staffInfo = ConfigEntry.STAFF_INFO.getStringList(); List<String> adminInfo = ConfigEntry.ADMIN_INFO.getStringList();
if (staffInfo.isEmpty()) if (adminInfo.isEmpty())
{ {
msg("The staff information section of the config.yml file has not been configured.", ChatColor.RED); msg("The admin information section in the config.yml file has not been configured.", ChatColor.RED);
} }
else else
{ {
msg(FUtil.colorize(StringUtils.join(staffInfo, "\n"))); msg(FUtil.colorize(StringUtils.join(adminInfo, "\n")));
} }
return true; return true;
} }

View file

@ -11,10 +11,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Denies joining of operators and only allows staff members to join.", usage = "/<command> [on | off]") @CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]")
public class Command_staffmode extends FreedomCommand public class Command_adminmode 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)
{ {
@ -25,19 +24,19 @@ public class Command_staffmode extends FreedomCommand
if (args[0].equalsIgnoreCase("off")) if (args[0].equalsIgnoreCase("off"))
{ {
ConfigEntry.STAFF_ONLY_MODE.setBoolean(false); ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
FUtil.staffAction(sender.getName(), "Opening the server to all players.", true); FUtil.adminAction(sender.getName(), "Opening the server to all players.", true);
return true; return true;
} }
else if (args[0].equalsIgnoreCase("on")) else if (args[0].equalsIgnoreCase("on"))
{ {
ConfigEntry.STAFF_ONLY_MODE.setBoolean(true); ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
FUtil.staffAction(sender.getName(), "Closing the server to non-staff.", true); FUtil.adminAction(sender.getName(), "Closing the server to non-admins.", true);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (!isStaff(player)) if (!isAdmin(player))
{ {
player.kickPlayer("Server is now closed to non-staff."); player.kickPlayer("Server is now closed to non-admins.");
} }
} }
return true; return true;
@ -49,7 +48,7 @@ public class Command_staffmode extends FreedomCommand
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {
if (args.length == 1 && plugin.sl.isStaff(sender) && !(sender instanceof Player)) if (args.length == 1 && plugin.al.isAdmin(sender) && !(sender instanceof Player))
{ {
return Arrays.asList("on", "off"); return Arrays.asList("on", "off");
} }

View file

@ -13,12 +13,11 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) @CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Allows for staff to configure time, and weather of the StaffWorld, and allows for staff and ops to go to the StaffWorld.", @CommandParameters(description = "Allows for admins to configure time, and weather of the AdminWorld, and allows for admins and ops to go to the AdminWorld.",
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]", usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
aliases = "sw") aliases = "aw")
public class Command_staffworld extends FreedomCommand public class Command_adminworld extends FreedomCommand
{ {
private enum CommandMode private enum CommandMode
{ {
TELEPORT, TIME, WEATHER TELEPORT, TIME, WEATHER
@ -61,24 +60,24 @@ public class Command_staffworld extends FreedomCommand
return false; return false;
} }
World staffWorld = null; World adminWorld = null;
try try
{ {
staffWorld = plugin.wm.staffworld.getWorld(); adminWorld = plugin.wm.adminworld.getWorld();
} }
catch (Exception ex) catch (Exception ex)
{ {
} }
if (staffWorld == null || playerSender.getWorld() == staffWorld) if (adminWorld == null || playerSender.getWorld() == adminWorld)
{ {
msg("Going to the main world."); msg("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 StaffWorld."); msg("Going to the AdminWorld.");
plugin.wm.staffworld.sendToWorld(playerSender); plugin.wm.adminworld.sendToWorld(playerSender);
} }
break; break;
} }
@ -91,8 +90,8 @@ public class Command_staffworld extends FreedomCommand
WorldTime timeOfDay = WorldTime.getByAlias(args[1]); WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
if (timeOfDay != null) if (timeOfDay != null)
{ {
plugin.wm.staffworld.setTimeOfDay(timeOfDay); plugin.wm.adminworld.setTimeOfDay(timeOfDay);
msg("StaffWorld time set to: " + timeOfDay.name()); msg("AdminWorld time set to: " + timeOfDay.name());
} }
else else
{ {
@ -115,8 +114,8 @@ public class Command_staffworld extends FreedomCommand
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]); WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
if (weatherMode != null) if (weatherMode != null)
{ {
plugin.wm.staffworld.setWeatherMode(weatherMode); plugin.wm.adminworld.setWeatherMode(weatherMode);
msg("StaffWorld weather set to: " + weatherMode.name()); msg("AdminWorld weather set to: " + weatherMode.name());
} }
else else
{ {
@ -152,7 +151,7 @@ public class Command_staffworld extends FreedomCommand
// TODO: Redo this properly // TODO: Redo this properly
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
{ {
if (!(sender instanceof Player) || playerSender == null || !isStaff(sender)) if (!(sender instanceof Player) || playerSender == null || !isAdmin(sender))
{ {
throw new PermissionDeniedException(); throw new PermissionDeniedException();
} }
@ -177,7 +176,7 @@ public class Command_staffworld extends FreedomCommand
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {
if (!plugin.sl.isStaff(sender)) if (!plugin.al.isAdmin(sender))
{ {
return Collections.emptyList(); return Collections.emptyList();
} }

View file

@ -37,7 +37,7 @@ public class Command_adventure extends FreedomCommand
targetPlayer.setGameMode(GameMode.ADVENTURE); targetPlayer.setGameMode(GameMode.ADVENTURE);
} }
FUtil.staffAction(sender.getName(), "Changing everyone's gamemode to adventure", false); FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to adventure", false);
msg("Your gamemode has been set to adventure."); msg("Your gamemode has been set to adventure.");
return true; return true;
} }

View file

@ -17,7 +17,7 @@ public class Command_aeclear extends FreedomCommand
@Override @Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
FUtil.staffAction(sender.getName(), "Removing all area effect clouds.", true); FUtil.adminAction(sender.getName(), "Removing all area effect clouds.", true);
int removed = 0; int removed = 0;
for (World world : server.getWorlds()) for (World world : server.getWorlds())
{ {

View file

@ -1,30 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.attribute.Attribute;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = 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)
{
String list = "All possible attributes: ";
for (Attribute attribute : Attribute.values())
{
list += attribute.name() + ", ";
}
// Remove extra comma at the end of the list
list = list.substring(0, list.length() - 2);
msg(list);
return true;
}
}

View file

@ -154,7 +154,7 @@ 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: " + StringUtils.join(ips, ", ")); msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
FUtil.staffAction(sender.getName(), String.format(bcast.toString()), true); FUtil.adminAction(sender.getName(), String.format(bcast.toString()), true);
} }
// Kick player and handle others on IP // Kick player and handle others on IP

View file

@ -72,7 +72,7 @@ public class Command_banip extends FreedomCommand
{ {
// Broadcast // Broadcast
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip); FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.sl.isStaff(player) ? "the IP " + ip : "an IP"); String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
player.sendMessage(message); player.sendMessage(message);
} }
} }

View file

@ -20,7 +20,7 @@ public class Command_banlist extends FreedomCommand
{ {
checkRank(Rank.SENIOR_ADMIN); checkRank(Rank.SENIOR_ADMIN);
FUtil.staffAction(sender.getName(), "Purging the ban list", true); FUtil.adminAction(sender.getName(), "Purging the ban list", true);
int amount = plugin.bm.purge(); int amount = plugin.bm.purge();
msg("Purged " + amount + " player bans."); msg("Purged " + amount + " player bans.");
return true; return true;

View file

@ -55,7 +55,7 @@ public class Command_banname extends FreedomCommand
if (!silent) if (!silent)
{ {
FUtil.staffAction(sender.getName(), "Banned the name " + name, true); FUtil.adminAction(sender.getName(), "Banned the name " + name, true);
} }
Player player = getPlayer(name); Player player = getPlayer(name);

View file

@ -1,33 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
public class Command_bird extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
playerSender.getWorld().spawnEntity(location, getRandomFish());
msg(":goodbird:");
return true;
}
public EntityType getRandomFish()
{
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
Random random = new Random();
return fishTypes.get(random.nextInt(fishTypes.size()));
}
}

View file

@ -23,7 +23,7 @@ public class Command_blockcmd extends FreedomCommand
if (args[0].equals("purge")) if (args[0].equals("purge"))
{ {
FUtil.staffAction(sender.getName(), "Unblocking commands for all players", true); FUtil.adminAction(sender.getName(), "Unblocking commands for all players", true);
int counter = 0; int counter = 0;
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
@ -40,18 +40,18 @@ public class Command_blockcmd extends FreedomCommand
if (args[0].equals("-a")) if (args[0].equals("-a"))
{ {
FUtil.staffAction(sender.getName(), "Blocking commands for all non-staff", true); FUtil.adminAction(sender.getName(), "Blocking commands for all non-admins", true);
int counter = 0; int counter = 0;
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (isStaff(player)) if (isAdmin(player))
{ {
continue; continue;
} }
counter += 1; counter += 1;
plugin.pl.getPlayer(player).setCommandsBlocked(true); plugin.pl.getPlayer(player).setCommandsBlocked(true);
msg(player, "Your commands have been blocked by a staff member.", ChatColor.RED); msg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
} }
msg("Blocked commands for " + counter + " players."); msg("Blocked commands for " + counter + " players.");
@ -66,9 +66,9 @@ public class Command_blockcmd extends FreedomCommand
return true; return true;
} }
if (isStaff(player)) if (isAdmin(player))
{ {
msg(player.getName() + " is a staff member, and cannot have their commands blocked."); msg(player.getName() + " is an admin, and cannot have their commands blocked.");
return true; return true;
} }
@ -76,7 +76,7 @@ public class Command_blockcmd extends FreedomCommand
if (!playerdata.allCommandsBlocked()) if (!playerdata.allCommandsBlocked())
{ {
playerdata.setCommandsBlocked(true); playerdata.setCommandsBlocked(true);
FUtil.staffAction(sender.getName(), "Blocking all commands for " + player.getName(), true); FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
msg("Blocked commands for " + player.getName() + "."); msg("Blocked commands for " + player.getName() + ".");
} }
else else

View file

@ -46,7 +46,7 @@ public class Command_blockedit extends FreedomCommand
if (args[0].equals("purge")) if (args[0].equals("purge"))
{ {
FUtil.staffAction(sender.getName(), "Unblocking block modification abilities for all players.", true); FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for all players.", true);
int count = 0; int count = 0;
for (final Player player : this.server.getOnlinePlayers()) for (final Player player : this.server.getOnlinePlayers())
{ {
@ -63,11 +63,11 @@ public class Command_blockedit extends FreedomCommand
if (args[0].equals("all")) if (args[0].equals("all"))
{ {
FUtil.staffAction(sender.getName(), "Blocking block modification abilities for all non-staff.", true); FUtil.adminAction(sender.getName(), "Blocking block modification abilities for all non-admins.", true);
int counter = 0; int counter = 0;
for (final Player player : this.server.getOnlinePlayers()) for (final Player player : this.server.getOnlinePlayers())
{ {
if (!plugin.sl.isStaff(player)) if (!plugin.al.isAdmin(player))
{ {
final FPlayer playerdata = plugin.pl.getPlayer(player); final FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setEditBlocked(true); playerdata.setEditBlocked(true);
@ -105,20 +105,20 @@ public class Command_blockedit extends FreedomCommand
final FPlayer pd = plugin.pl.getPlayer(player2); final FPlayer pd = plugin.pl.getPlayer(player2);
if (pd.isEditBlocked()) if (pd.isEditBlocked())
{ {
FUtil.staffAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true); FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
pd.setEditBlocked(false); pd.setEditBlocked(false);
msg("Unblocking block modification abilities for " + player2.getName()); msg("Unblocking block modification abilities for " + player2.getName());
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED); msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
} }
else else
{ {
if (plugin.sl.isStaff(player2)) if (plugin.al.isAdmin(player2))
{ {
msg(player2.getName() + " is a staff member, and cannot have their block edits blocked."); msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true); FUtil.adminAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
pd.setEditBlocked(true); pd.setEditBlocked(true);
if (smite) if (smite)

View file

@ -46,7 +46,7 @@ public class Command_blockpvp extends FreedomCommand
if (args[0].equals("purge")) if (args[0].equals("purge"))
{ {
FUtil.staffAction(sender.getName(), "Enabling PVP for all players.", true); FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true);
int count = 0; int count = 0;
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
@ -64,11 +64,11 @@ public class Command_blockpvp extends FreedomCommand
if (args[0].equals("all")) if (args[0].equals("all"))
{ {
FUtil.staffAction(sender.getName(), "Disabling PVP for all non-staff", true); FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true);
int counter = 0; int counter = 0;
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (!plugin.sl.isStaff(player)) if (!plugin.al.isAdmin(player))
{ {
final FPlayer playerdata = plugin.pl.getPlayer(player); final FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setPvpBlocked(true); playerdata.setPvpBlocked(true);
@ -106,20 +106,20 @@ public class Command_blockpvp extends FreedomCommand
final FPlayer pd = plugin.pl.getPlayer(p); final FPlayer pd = plugin.pl.getPlayer(p);
if (pd.isPvpBlocked()) if (pd.isPvpBlocked())
{ {
FUtil.staffAction(sender.getName(), "Enabling PVP for " + p.getName(), true); FUtil.adminAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
pd.setPvpBlocked(false); pd.setPvpBlocked(false);
msg("Enabling PVP for " + p.getName()); msg("Enabling PVP for " + p.getName());
msg(p, "Your PVP have been enabled.", ChatColor.GREEN); msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
} }
else else
{ {
if (plugin.sl.isStaff(p)) if (plugin.al.isAdmin(p))
{ {
msg(p.getName() + " is a staff member, and cannot have their PVP disabled."); msg(p.getName() + " is an admin and cannot have their PVP disabled.");
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Disabling PVP for " + p.getName(), true); FUtil.adminAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
pd.setPvpBlocked(true); pd.setPvpBlocked(true);
if (smite) if (smite)
{ {

View file

@ -18,14 +18,14 @@ public class Command_blockredstone extends FreedomCommand
if (ConfigEntry.ALLOW_REDSTONE.getBoolean()) if (ConfigEntry.ALLOW_REDSTONE.getBoolean())
{ {
ConfigEntry.ALLOW_REDSTONE.setBoolean(false); ConfigEntry.ALLOW_REDSTONE.setBoolean(false);
FUtil.staffAction(sender.getName(), "Blocking all redstone", true); FUtil.adminAction(sender.getName(), "Blocking all redstone", true);
new BukkitRunnable() new BukkitRunnable()
{ {
public void run() public void run()
{ {
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean()) if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
{ {
FUtil.staffAction("TotalFreedom", "Unblocking all redstone", false); FUtil.adminAction("TotalFreedom", "Unblocking all redstone", false);
ConfigEntry.ALLOW_REDSTONE.setBoolean(true); ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
} }
} }
@ -34,7 +34,7 @@ public class Command_blockredstone extends FreedomCommand
else else
{ {
ConfigEntry.ALLOW_REDSTONE.setBoolean(true); ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
FUtil.staffAction(sender.getName(), "Unblocking all redstone", true); FUtil.adminAction(sender.getName(), "Unblocking all redstone", true);
} }
return true; return true;
} }

View file

@ -30,7 +30,7 @@ public class Command_cage extends FreedomCommand
String skullName = null; String skullName = null;
if ("purge".equals(args[0])) if ("purge".equals(args[0]))
{ {
FUtil.staffAction(sender.getName(), "Uncaging all players", true); FUtil.adminAction(sender.getName(), "Uncaging all players", true);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
final FPlayer fPlayer = plugin.pl.getPlayer(player); final FPlayer fPlayer = plugin.pl.getPlayer(player);
@ -101,11 +101,11 @@ public class Command_cage extends FreedomCommand
if (outerMaterial == Material.PLAYER_HEAD) if (outerMaterial == Material.PLAYER_HEAD)
{ {
FUtil.staffAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true); FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
} }
else else
{ {
FUtil.staffAction(sender.getName(), "Caging " + player.getName(), true); FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
} }
return true; return true;
} }
@ -113,7 +113,7 @@ public class Command_cage extends FreedomCommand
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {
if (!plugin.sl.isStaff(sender)) if (!plugin.al.isAdmin(sender))
{ {
return null; return null;
} }

View file

@ -16,7 +16,7 @@ public class Command_cartsit extends FreedomCommand
{ {
Player targetPlayer = playerSender; Player targetPlayer = playerSender;
if (args.length == 1 && plugin.sl.isStaff(sender)) if (args.length == 1 && plugin.al.isAdmin(sender))
{ {
targetPlayer = getPlayer(args[0]); targetPlayer = getPlayer(args[0]);

View file

@ -16,7 +16,7 @@ public class Command_clearchat extends FreedomCommand
{ {
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (!plugin.sl.isStaff(player)) if (!plugin.al.isAdmin(player))
{ {
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {
@ -24,7 +24,7 @@ public class Command_clearchat extends FreedomCommand
} }
} }
} }
FUtil.staffAction(sender.getName(), "Cleared chat", true); FUtil.adminAction(sender.getName(), "Cleared chat", true);
return true; return true;
} }
} }

View file

@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Clear the discord message queue.", usage = "/<command>") @CommandParameters(description = "Clear the discord message queue.", usage = "/<command>")
public class Command_cleardiscordqueue extends FreedomCommand public class Command_cleardiscordqueue 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)
{ {

View file

@ -29,11 +29,11 @@ public class Command_clearinventory extends FreedomCommand
} }
else else
{ {
if (plugin.sl.isStaff(sender)) if (plugin.al.isAdmin(sender))
{ {
if (args[0].equals("-a")) if (args[0].equals("-a"))
{ {
FUtil.staffAction(sender.getName(), "Clearing everyone's inventory", true); FUtil.adminAction(sender.getName(), "Clearing everyone's inventory", true);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
player.getInventory().clear(); player.getInventory().clear();
@ -67,7 +67,7 @@ public class Command_clearinventory extends FreedomCommand
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {
if (args.length == 1 && plugin.sl.isStaff(sender)) if (args.length == 1 && plugin.al.isAdmin(sender))
{ {
List<String> players = FUtil.getPlayerList(); List<String> players = FUtil.getPlayerList();
players.add("-a"); players.add("-a");

View file

@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Obtain a clown fish", usage = "/<command>") @CommandParameters(description = "Obtain a clown fish", usage = "/<command>")
public class Command_clownfish extends FreedomCommand public class Command_clownfish 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)
{ {

View file

@ -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 me.totalfreedom.totalfreedommod.staff.StaffMember; import me.totalfreedom.totalfreedommod.admin.Admin;
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;
@ -14,11 +14,11 @@ public class Command_cmdspy 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)
{ {
StaffMember staffMember = plugin.sl.getAdmin(playerSender); Admin admin = plugin.al.getAdmin(playerSender);
staffMember.setCommandSpy(!staffMember.getCommandSpy()); admin.setCommandSpy(!admin.getCommandSpy());
msg("CommandSpy " + (staffMember.getCommandSpy() ? "enabled." : "disabled.")); msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
plugin.sl.save(staffMember); plugin.al.save(admin);
plugin.sl.updateTables(); plugin.al.updateTables();
return true; return true;
} }

View file

@ -1,59 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Iterator;
import java.util.Map;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Essentials Interface Command - Set your nickname to a certain color.", usage = "/<command> <color>")
public class Command_colorme extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if ("list".equalsIgnoreCase(args[0]))
{
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
return true;
}
final String needle = args[0].trim().toLowerCase();
ChatColor color = null;
final Iterator<Map.Entry<String, ChatColor>> it = FUtil.CHAT_COLOR_NAMES.entrySet().iterator();
while (it.hasNext())
{
final Map.Entry<String, ChatColor> entry = it.next();
if (entry.getKey().contains(needle))
{
color = entry.getValue();
break;
}
}
if (color == null)
{
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
return true;
}
final String newNick = color + ChatColor.stripColor(playerSender.getDisplayName()).trim() + ChatColor.WHITE;
plugin.esb.setNickname(sender.getName(), newNick);
msg("Your nickname is now: " + newNick);
return true;
}
}

View file

@ -1,53 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
@CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>", aliases = "cmdlist")
public class Command_commandlist extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
List<String> commands = new ArrayList<>();
for (Plugin targetPlugin : server.getPluginManager().getPlugins())
{
try
{
PluginDescriptionFile desc = targetPlugin.getDescription();
Map<String, Map<String, Object>> map = desc.getCommands();
if (map != null)
{
for (Entry<String, Map<String, Object>> entry : map.entrySet())
{
String command_name = entry.getKey();
commands.add(command_name);
}
}
}
catch (Throwable ex)
{
}
}
Collections.sort(commands);
sender.sendMessage(StringUtils.join(commands, ", "));
return true;
}
}

View file

@ -37,7 +37,7 @@ public class Command_creative extends FreedomCommand
targetPlayer.setGameMode(GameMode.CREATIVE); targetPlayer.setGameMode(GameMode.CREATIVE);
} }
FUtil.staffAction(sender.getName(), "Changing everyone's gamemode to creative", false); FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false);
msg("Your gamemode has been set to creative."); msg("Your gamemode has been set to creative.");
return true; return true;
} }

View file

@ -1,66 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Curse someone - sends a cursed texture pack to the specified player.", usage = "/<command> <player>")
public class Command_curse extends FreedomCommand
{
/* The only problem with this is someone can prevent themself from being cursed by declining to download the
resource pack. However, if they hit yes, then you can curse them whenever you want and they can't stop it unless
they go into their server settings. and set server resource packs to prompt or disabled */
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!FUtil.isExecutive(sender.getName()))
{
return noPerms();
}
if (args.length == 0)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
if (plugin.cul.cursedPlayers.containsKey(player))
{
msg("Already attempting to curse!", ChatColor.RED);
return true;
}
player.setResourcePack("http://play.totalfreedom.me/cursed.zip");
msg("Attempting to curse " + player.getName(), ChatColor.GREEN);
plugin.cul.cursedPlayers.put(player, playerSender);
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.sl.isStaff(sender) && FUtil.isExecutive(sender.getName()))
{
return FUtil.getPlayerList();
}
return Collections.emptyList();
}
}

View file

@ -20,7 +20,7 @@ public class Command_denick extends FreedomCommand
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Removing all nicknames", false); FUtil.adminAction(sender.getName(), "Removing all nicknames", false);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {

View file

@ -35,7 +35,7 @@ public class Command_deop extends FreedomCommand
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName) if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName)) || player.getName().contains(targetName) || player.getDisplayName().contains(targetName))
{ {
if (player.isOp() && !plugin.sl.isVanished(player.getName())) if (player.isOp() && !plugin.al.isVanished(player.getName()))
{ {
matchedPlayerNames.add(player.getName()); matchedPlayerNames.add(player.getName());
player.setOp(false); player.setOp(false);
@ -48,7 +48,7 @@ public class Command_deop extends FreedomCommand
{ {
if (!silent) if (!silent)
{ {
FUtil.staffAction(sender.getName(), "De-opping " + StringUtils.join(matchedPlayerNames, ", "), false); FUtil.adminAction(sender.getName(), "De-opping " + StringUtils.join(matchedPlayerNames, ", "), false);
} }
} }
else else

View file

@ -14,7 +14,7 @@ public class Command_deopall extends FreedomCommand
@Override @Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
FUtil.staffAction(sender.getName(), "De-opping all players on the server", true); FUtil.adminAction(sender.getName(), "De-opping all players on the server", true);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {

View file

@ -20,7 +20,7 @@ public class Command_disguisetoggle extends FreedomCommand
return true; return true;
} }
FUtil.staffAction(sender.getName(), (plugin.ldb.isDisguisesEnabled() ? "Disabling" : "Enabling") + " disguises", false); FUtil.adminAction(sender.getName(), (plugin.ldb.isDisguisesEnabled() ? "Disabling" : "Enabling") + " disguises", false);
if (plugin.ldb.isDisguisesEnabled()) if (plugin.ldb.isDisguisesEnabled())
{ {

View file

@ -5,7 +5,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.punishments.Punishment; import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType; import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.staff.StaffMember; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -38,23 +38,23 @@ public class Command_doom extends FreedomCommand
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Casting oblivion over " + player.getName(), true); FUtil.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED); FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
final String ip = player.getAddress().getAddress().getHostAddress().trim(); final String ip = player.getAddress().getAddress().getHostAddress().trim();
// Remove from admin // Remove from admin
StaffMember staffMember = getStaffMember(player); Admin admin = getAdmin(player);
if (staffMember != null) if (admin != null)
{ {
FUtil.staffAction(sender.getName(), "Removing " + player.getName() + " from the staff list", true); FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the admin list", true);
staffMember.setActive(false); admin.setActive(false);
plugin.sl.save(staffMember); plugin.al.save(admin);
plugin.sl.updateTables(); plugin.al.updateTables();
plugin.ptero.updateAccountStatus(staffMember); plugin.ptero.updateAccountStatus(admin);
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
{ {
plugin.dc.syncRoles(staffMember, plugin.pl.getData(staffMember.getName()).getDiscordID()); plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
} }
} }
@ -120,7 +120,7 @@ public class Command_doom extends FreedomCommand
public void run() public void run()
{ {
// message // message
FUtil.staffAction(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); msg(sender, player.getName() + " has been banned and IP is: " + ip);
// generate explosion // generate explosion

View file

@ -54,7 +54,7 @@ public class Command_entitywipe extends FreedomCommand
entityName = FUtil.formatName(type.name()); entityName = FUtil.formatName(type.name());
} }
FUtil.staffAction(sender.getName(), "Purging all " + (type != null ? entityName + "s" : "entities"), true); FUtil.adminAction(sender.getName(), "Purging all " + (type != null ? entityName + "s" : "entities"), true);
int count; int count;
if (type != null) if (type != null)
{ {

View file

@ -1,67 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Surprise someone.", usage = "/<command> <player>")
public class Command_explode extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
player.setFlying(false);
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 50, 0)));
for (int i = 1; i <= 3; i++)
{
FUtil.createExplosionOnDelay(player.getLocation(), 2L, i * 10);
}
new BukkitRunnable()
{
@Override
public void run()
{
for (int i = 0; i < 4; i++)
{
player.getWorld().strikeLightning(player.getLocation());
player.getWorld().createExplosion(player.getLocation(), 4L);
}
player.setHealth(0.0);
msg("Exploded " + player.getName());
}
}.runTaskLater(plugin, 40);
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.sl.isStaff(sender))
{
return FUtil.getPlayerList();
}
return Collections.emptyList();
}
}

View file

@ -11,7 +11,6 @@ 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)
{ {

View file

@ -1,38 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Forcefully kill someone - for those who REALLY need to die.", usage = "/<command> <playername>")
public class Command_forcekill extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.sl.isMod(sender) && !senderIsConsole)
{
playerSender.setHealth(0);
return true;
}
if (args.length < 1)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(PLAYER_NOT_FOUND);
return true;
}
player.setHealth(0);
return true;
}
}

View file

@ -9,10 +9,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Freeze/Unfreeze a specified player, or all non-staff on the server.", usage = "/<command> [target | purge]", aliases = "fr") @CommandParameters(description = "Freeze/Unfreeze a specified player, or all non-admins on the server.", usage = "/<command> [target | purge]", aliases = "fr")
public class Command_freeze extends FreedomCommand public class Command_freeze 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,15 +22,15 @@ public class Command_freeze extends FreedomCommand
if (!gFreeze) if (!gFreeze)
{ {
FUtil.staffAction(sender.getName(), "Disabling global player freeze", false); FUtil.adminAction(sender.getName(), "Disabling global player freeze", false);
msg("Players are now free to move."); msg("Players are now free to move.");
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Enabling global player freeze", false); FUtil.adminAction(sender.getName(), "Enabling global player freeze", false);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (!isStaff(player)) if (!isAdmin(player))
{ {
player.sendTitle(ChatColor.RED + "You've been globally frozen.", ChatColor.YELLOW + "Please be patient and you will be unfrozen shortly.", 20, 100, 60); player.sendTitle(ChatColor.RED + "You've been globally frozen.", ChatColor.YELLOW + "Please be patient and you will be unfrozen shortly.", 20, 100, 60);
msg(player, "You have been globally frozen due to an OP breaking the rules, please wait and you will be unfrozen soon.", ChatColor.RED); msg(player, "You have been globally frozen due to an OP breaking the rules, please wait and you will be unfrozen soon.", ChatColor.RED);
@ -43,10 +42,10 @@ public class Command_freeze extends FreedomCommand
if (args[0].equals("purge")) if (args[0].equals("purge"))
{ {
FUtil.staffAction(sender.getName(), "Unfreezing all players", false); FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (!isStaff(player)) if (!isAdmin(player))
{ {
player.sendTitle(ChatColor.GREEN + "You've been unfrozen.", ChatColor.YELLOW + "You may now move again.", 20, 100, 60); player.sendTitle(ChatColor.GREEN + "You've been unfrozen.", ChatColor.YELLOW + "You may now move again.", 20, 100, 60);
} }

View file

@ -1,32 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Toggles the glowing outline effect because y'all lazy as fuck", usage = "/<command>")
public class Command_glow extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean glowing = false;
if (playerSender.getPotionEffect(PotionEffectType.GLOWING) != null)
{
playerSender.removePotionEffect(PotionEffectType.GLOWING);
}
else
{
PotionEffect glow = new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false);
playerSender.addPotionEffect(glow);
glowing = true;
}
msg("You " + (glowing ? "are now" : "no longer") + " glowing.");
return true;
}
}

View file

@ -1,22 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Toggles player gravity on/off.", usage = "/<command>")
public class Command_gravity extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean enabled = !playerSender.hasGravity();
playerSender.setGravity(enabled);
msg((enabled ? "En" : "Dis") + "abled gravity.", (enabled ? ChatColor.GREEN : ChatColor.RED));
return true;
}
}

View file

@ -1,35 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Send a chat message as someone else.", usage = "/<command> <fromname> <outmessage>")
public class Command_gsay extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 2)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
final String outMessage = StringUtils.join(args, " ", 1, args.length);
msg("Sending message as " + player.getName() + ": " + outMessage);
player.chat(outMessage);
msg("Message sent.");
return true;
}
}

View file

@ -17,7 +17,6 @@ import org.bukkit.scheduler.BukkitTask;
@CommandParameters(description = "View server health, such as ticks-per-second, memory, etc.", usage = "/<command>") @CommandParameters(description = "View server health, such as ticks-per-second, memory, etc.", usage = "/<command>")
public class Command_health extends FreedomCommand public class Command_health extends FreedomCommand
{ {
private static final int BYTES_PER_MB = 1024 * 1024; private static final int BYTES_PER_MB = 1024 * 1024;
private static final DoubleRange TPS_RANGE = new DoubleRange(20.0 - 0.1, 20.0 + 0.1); private static final DoubleRange TPS_RANGE = new DoubleRange(20.0 - 0.1, 20.0 + 0.1);
@ -40,7 +39,7 @@ public class Command_health extends FreedomCommand
{ {
try try
{ {
TFM_TickMeter tickMeter = new TFM_TickMeter(plugin); TickMeter tickMeter = new TickMeter(plugin);
tickMeter.startTicking(); tickMeter.startTicking();
Thread.sleep(2500); Thread.sleep(2500);
final double ticksPerSecond = tickMeter.stopTicking(); final double ticksPerSecond = tickMeter.stopTicking();
@ -70,15 +69,14 @@ public class Command_health extends FreedomCommand
return true; return true;
} }
private class TFM_TickMeter private class TickMeter
{ {
private final AtomicInteger ticks = new AtomicInteger(); private final AtomicInteger ticks = new AtomicInteger();
private final TotalFreedomMod plugin; private final TotalFreedomMod plugin;
private long startTime; private long startTime;
private BukkitTask task; private BukkitTask task;
public TFM_TickMeter(TotalFreedomMod plugin) public TickMeter(TotalFreedomMod plugin)
{ {
this.plugin = plugin; this.plugin = plugin;
} }
@ -107,5 +105,4 @@ public class Command_health extends FreedomCommand
return (double)tickCount / ((double)elapsed / 1000.0); return (double)tickCount / ((double)elapsed / 1000.0);
} }
} }
} }

View file

@ -153,7 +153,7 @@ public class Command_hubworld extends FreedomCommand
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {
if (!plugin.sl.isStaff(sender)) if (!plugin.al.isAdmin(sender))
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
@ -178,7 +178,7 @@ public class Command_hubworld extends FreedomCommand
// TODO: Redo this properly // TODO: Redo this properly
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
{ {
if (!(sender instanceof Player) || playerSender == null || !plugin.sl.isAdmin(playerSender)) if (!(sender instanceof Player) || playerSender == null || !plugin.al.isSeniorAdmin(playerSender))
{ {
throw new PermissionDeniedException(); throw new PermissionDeniedException();
} }

View file

@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Reload the indefinite ban list.", usage = "/<command> reload", aliases = "ib") @CommandParameters(description = "Reload the indefinite ban list.", usage = "/<command> reload", aliases = "ib")
public class Command_indefban extends FreedomCommand public class Command_indefban 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)
{ {

View file

@ -26,11 +26,11 @@ public class Command_invis extends FreedomCommand
{ {
if (args[0].equalsIgnoreCase("clear")) if (args[0].equalsIgnoreCase("clear"))
{ {
if(!plugin.sl.isStaff(sender)) if(!plugin.al.isAdmin(sender))
return noPerms(); return noPerms();
else else
{ {
FUtil.staffAction(sender.getName(), "Clearing all invisibility potion effects from all players", true); FUtil.adminAction(sender.getName(), "Clearing all invisibility potion effects from all players", true);
clear = true; clear = true;
} }
} }
@ -43,10 +43,10 @@ public class Command_invis extends FreedomCommand
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY) && !plugin.sl.isVanished(player.getName())) if (player.hasPotionEffect(PotionEffectType.INVISIBILITY) && !plugin.al.isVanished(player.getName()))
{ {
players.add(player.getName()); players.add(player.getName());
if (clear && !plugin.sl.isStaff(player)) if (clear && !plugin.al.isAdmin(player))
{ {
player.removePotionEffect((PotionEffectType.INVISIBILITY)); player.removePotionEffect((PotionEffectType.INVISIBILITY));
clears++; clears++;
@ -71,7 +71,7 @@ public class Command_invis extends FreedomCommand
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {
if (args.length == 1 && plugin.sl.isStaff(sender)) if (args.length == 1 && plugin.al.isAdmin(sender))
return Arrays.asList("clear"); return Arrays.asList("clear");
return Collections.emptyList(); return Collections.emptyList();

View file

@ -35,9 +35,9 @@ public class Command_invsee extends FreedomCommand
return true; return true;
} }
if (plugin.sl.isStaff(player) && !plugin.sl.isStaff(playerSender)) if (plugin.al.isAdmin(player) && !plugin.al.isAdmin(playerSender))
{ {
msg("You cannot see the inventory of staff members.", ChatColor.RED); msg("You cannot see the inventory of admin members.", ChatColor.RED);
return true; return true;
} }
@ -67,7 +67,7 @@ public class Command_invsee extends FreedomCommand
} }
inv = player.getInventory(); inv = player.getInventory();
playerSender.closeInventory(); playerSender.closeInventory();
if (!plugin.sl.isStaff(player)) if (!plugin.al.isAdmin(player))
{ {
FPlayer fPlayer = plugin.pl.getPlayer(playerSender); FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
fPlayer.setInvSee(true); fPlayer.setInvSee(true);

View file

@ -95,7 +95,7 @@ public class Command_jumppads extends FreedomCommand
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {
if (!plugin.sl.isStaff(sender)) if (!plugin.al.isAdmin(sender))
{ {
return Collections.emptyList(); return Collections.emptyList();
} }

View file

@ -65,11 +65,11 @@ public class Command_kick extends FreedomCommand
{ {
if (reason != null) if (reason != null)
{ {
FUtil.staffAction(sender.getName(), "Kicking " + player.getName() + " - Reason: " + reason, true); FUtil.adminAction(sender.getName(), "Kicking " + player.getName() + " - Reason: " + reason, true);
} }
else else
{ {
FUtil.staffAction(sender.getName(), "Kicking " + player.getName(), true); FUtil.adminAction(sender.getName(), "Kicking " + player.getName(), true);
} }
} }
else else

View file

@ -8,23 +8,21 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Kick all non-staff on server.", usage = "/<command>", aliases = "kickall") @CommandParameters(description = "Kick all non-admins on server.", usage = "/<command>", aliases = "kickall")
public class Command_kicknoob extends FreedomCommand public class Command_kicknoob extends FreedomCommand
{ {
@Override @Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
FUtil.staffAction(sender.getName(), "Disconnecting all non-staff.", true); FUtil.adminAction(sender.getName(), "Disconnecting all non-admins.", true);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (!plugin.sl.isStaff(player)) if (!plugin.al.isAdmin(player))
{ {
player.kickPlayer(ChatColor.RED + "All non-staff were kicked by " + sender.getName() + "."); player.kickPlayer(ChatColor.RED + "All non-admins were kicked by " + sender.getName() + ".");
} }
} }
return true; return true;
} }
} }

View file

@ -1,67 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Iterator;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.fun.Landminer.Landmine;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Set a landmine trap.", usage = "/<command>")
public class Command_landmine extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!ConfigEntry.LANDMINES_ENABLED.getBoolean())
{
msg("The landmine is currently disabled.", ChatColor.GREEN);
return true;
}
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
msg("Explosions are currently disabled.", ChatColor.GREEN);
return true;
}
double radius = 2.0;
if (args.length >= 1)
{
if ("list".equals(args[0]))
{
final Iterator<Landmine> landmines = plugin.lm.getLandmines().iterator();
while (landmines.hasNext())
{
msg(landmines.next().toString());
}
return true;
}
try
{
radius = Math.max(2.0, Math.min(6.0, Double.parseDouble(args[0])));
}
catch (NumberFormatException ex)
{
}
}
final Block landmine = playerSender.getLocation().getBlock().getRelative(BlockFace.DOWN);
landmine.setType(Material.TNT);
plugin.lm.add(new Landmine(landmine.getLocation(), playerSender, radius));
msg("Landmine planted - Radius = " + radius + " blocks.", ChatColor.GREEN);
return true;
}
}

View file

@ -22,7 +22,7 @@ public class Command_linkdiscord extends FreedomCommand
return true; return true;
} }
if (args.length > 1 && plugin.sl.isStaff(playerSender)) if (args.length > 1 && plugin.al.isAdmin(playerSender))
{ {
PlayerData playerData = plugin.pl.getData(args[0]); PlayerData playerData = plugin.pl.getData(args[0]);
if (playerData == null) if (playerData == null)

View file

@ -1,69 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import net.dean.jraw.ApiException;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Link your reddit account", usage = "/<command> <username | code <code>>")
public class Command_linkreddit extends FreedomCommand
{
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
{
if (!plugin.rd.enabled)
{
msg("The Reddit system is currently disabled.", ChatColor.RED);
return true;
}
if (getData(playerSender).getRedditUsername() != null)
{
msg("Your Reddit account is already linked.");
return true;
}
if (args.length == 0)
{
return false;
}
if (args.length == 1 && !args[0].equals("code"))
{
String username = args[0];
String code = plugin.rd.addLinkCode(getData(playerSender), username);
try
{
plugin.rd.sendModMessage(username, "Link Code", "Please run the following in-game to link your Reddit account: /linkreddit code " + code);
}
catch (ApiException e)
{
msg("Could not find a Reddit account by the name of " + args[0], ChatColor.RED);
return true;
}
msg("A linking code has been sent to " + username + ". Please check your mod mail at " + ChatColor.AQUA + "https://www.reddit.com/message/moderator", ChatColor.GREEN);
return true;
}
String code = args[1];
String username = plugin.rd.checkLinkCode(code);
if (username == null)
{
msg(code + " is not a valid code", ChatColor.RED);
return true;
}
msg("Successfully linked the Reddit account " + username + " to your Minecraft account.", ChatColor.GREEN);
if (plugin.rd.updateFlair(playerSender))
{
msg("Your flair has been updated.", ChatColor.GREEN);
}
return true;
}
}

View file

@ -5,8 +5,8 @@ import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Displayable; import me.totalfreedom.totalfreedommod.rank.Displayable;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.staff.StaffList; import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.staff.StaffMember; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -42,13 +42,13 @@ public class Command_list extends FreedomCommand
{ {
case "-s": case "-s":
{ {
listFilter = ListFilter.STAFF; listFilter = ListFilter.ADMINS;
break; break;
} }
case "-v": case "-v":
{ {
checkRank(Rank.ADMIN); checkRank(Rank.ADMIN);
listFilter = ListFilter.VANISHED_STAFF; listFilter = ListFilter.VANISHED_ADMINS;
break; break;
} }
case "-t": case "-t":
@ -82,20 +82,20 @@ public class Command_list extends FreedomCommand
List<String> n = new ArrayList<>(); List<String> n = new ArrayList<>();
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.sl.isStaff(sender) && plugin.sl.getAdmin(playerSender).getRank().isAtLeast(Rank.ADMIN)) if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender) && plugin.al.getAdmin(playerSender).getRank().isAtLeast(Rank.ADMIN))
{ {
List<StaffMember> connectedStaffMembers = plugin.btb.getConnectedAdmins(); List<Admin> connectedAdmins = plugin.btb.getConnectedAdmins();
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedStaffMembers.size()) onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedAdmins.size())
.append(ChatColor.BLUE) .append(ChatColor.BLUE)
.append(" staff members connected to telnet."); .append(" admins connected to telnet.");
for (StaffMember staffMember : connectedStaffMembers) for (Admin admin : connectedAdmins)
{ {
n.add(staffMember.getName()); n.add(admin.getName());
} }
} }
else else
{ {
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - StaffList.vanished.size()) onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - AdminList.vanished.size())
.append(ChatColor.BLUE) .append(ChatColor.BLUE)
.append(" out of a maximum ") .append(" out of a maximum ")
.append(ChatColor.RED) .append(ChatColor.RED)
@ -104,19 +104,19 @@ public class Command_list extends FreedomCommand
.append(" players online."); .append(" players online.");
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (listFilter == ListFilter.STAFF && !plugin.sl.isStaff(p)) if (listFilter == ListFilter.ADMINS && !plugin.al.isAdmin(p))
{ {
continue; continue;
} }
if (listFilter == ListFilter.STAFF && plugin.sl.isVanished(p.getName())) if (listFilter == ListFilter.ADMINS && plugin.al.isVanished(p.getName()))
{ {
continue; continue;
} }
if (listFilter == ListFilter.VANISHED_STAFF && !plugin.sl.isVanished(p.getName())) if (listFilter == ListFilter.VANISHED_ADMINS && !plugin.al.isVanished(p.getName()))
{ {
continue; continue;
} }
if (listFilter == ListFilter.IMPOSTORS && !plugin.sl.isStaffImpostor(p)) if (listFilter == ListFilter.IMPOSTORS && !plugin.al.isAdminImpostor(p))
{ {
continue; continue;
} }
@ -124,7 +124,7 @@ public class Command_list extends FreedomCommand
{ {
continue; continue;
} }
if (listFilter == ListFilter.PLAYERS && plugin.sl.isVanished(p.getName())) if (listFilter == ListFilter.PLAYERS && plugin.al.isVanished(p.getName()))
{ {
continue; continue;
} }
@ -155,8 +155,8 @@ public class Command_list extends FreedomCommand
private enum ListFilter private enum ListFilter
{ {
PLAYERS, PLAYERS,
STAFF, ADMINS,
VANISHED_STAFF, VANISHED_ADMINS,
TELNET_SESSIONS, TELNET_SESSIONS,
FAMOUS_PLAYERS, FAMOUS_PLAYERS,
IMPOSTORS IMPOSTORS

View file

@ -22,7 +22,7 @@ public class Command_lockup extends FreedomCommand
{ {
if (args[0].equalsIgnoreCase("all")) if (args[0].equalsIgnoreCase("all"))
{ {
FUtil.staffAction(sender.getName(), "Locking up all players", true); FUtil.adminAction(sender.getName(), "Locking up all players", true);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
@ -32,7 +32,7 @@ public class Command_lockup extends FreedomCommand
} }
else if (args[0].equalsIgnoreCase("purge")) else if (args[0].equalsIgnoreCase("purge"))
{ {
FUtil.staffAction(sender.getName(), "Unlocking all players", true); FUtil.adminAction(sender.getName(), "Unlocking all players", true);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
cancelLockup(player); cancelLockup(player);
@ -59,7 +59,7 @@ public class Command_lockup extends FreedomCommand
if (!silent) if (!silent)
{ {
FUtil.staffAction(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() + "."); msg("Locked up " + player.getName() + ".");
@ -76,7 +76,7 @@ public class Command_lockup extends FreedomCommand
if (!silent) if (!silent)
{ {
FUtil.staffAction(sender.getName(), "Unlocking " + player.getName(), true); FUtil.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
} }
cancelLockup(player); cancelLockup(player);
msg("Unlocked " + player.getName() + "."); msg("Unlocked " + player.getName() + ".");

View file

@ -16,7 +16,7 @@ public class Command_loginmessage 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.pl.getData(playerSender).hasItem(ShopItem.LOGIN_MESSAGES) && !isStaff(playerSender)) if (!plugin.pl.getData(playerSender).hasItem(ShopItem.LOGIN_MESSAGES) && !isAdmin(playerSender))
{ {
msg("You did not purchase the ability to use login messages! Purchase the ability from the shop.", ChatColor.RED); msg("You did not purchase the ability to use login messages! Purchase the ability from the shop.", ChatColor.RED);
return true; return true;

View file

@ -1,26 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Register your connection with the TFM logviewer.", usage = "/<command> [off]")
public class Command_logs extends FreedomCommand
{
@Override
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
LogsRegistrationMode mode = LogsRegistrationMode.ADD;
if (args.length == 1 && "off".equalsIgnoreCase(args[0]))
{
mode = LogsRegistrationMode.DELETE;
}
plugin.lv.updateLogsRegistration(sender, playerSender, mode);
return true;
}
}

View file

@ -39,7 +39,7 @@ public class Command_manuallyverify extends FreedomCommand
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Manually verifying player " + player.getName(), false); FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false);
player.setOp(true); player.setOp(true);
player.sendMessage(YOU_ARE_OP); player.sendMessage(YOU_ARE_OP);

View file

@ -1,42 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "seth's personal command", usage = "/<command> <players>", aliases = "genocide")
public class Command_massmurder extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!ConfigEntry.SERVER_OWNERS.getStringList().contains(playerSender.getName()))
{
return noPerms();
}
if (args.length < 1)
{
return false;
}
int count = 0;
for (String name : args)
{
Player player = getPlayer(name);
if (player != null)
{
player.setHealth(0);
count++;
}
}
msg("Mass murdered a school of " + count);
return true;
}
}

View file

@ -14,7 +14,6 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Information on how to apply for Master Builder.", usage = "/<command>", aliases = "mbi") @CommandParameters(description = "Information on how to apply for Master Builder.", usage = "/<command>", aliases = "mbi")
public class Command_masterbuilderinfo extends FreedomCommand public class Command_masterbuilderinfo 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)
{ {
@ -22,7 +21,7 @@ public class Command_masterbuilderinfo extends FreedomCommand
if (masterBuilderInfo.isEmpty()) if (masterBuilderInfo.isEmpty())
{ {
msg("The master builder information section of the config.yml file has not been configured.", ChatColor.RED); msg("The master builder information section in the config.yml file has not been configured.", ChatColor.RED);
} }
else else
{ {

View file

@ -153,7 +153,7 @@ public class Command_masterbuilderworld extends FreedomCommand
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {
if (!plugin.sl.isStaff(sender)) if (!plugin.al.isAdmin(sender))
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
@ -178,7 +178,7 @@ public class Command_masterbuilderworld extends FreedomCommand
// TODO: Redo this properly // TODO: Redo this properly
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
{ {
if (!(sender instanceof Player) || playerSender == null || !plugin.sl.isAdmin(playerSender)) if (!(sender instanceof Player) || playerSender == null || !plugin.al.isSeniorAdmin(playerSender))
{ {
throw new PermissionDeniedException(); throw new PermissionDeniedException();
} }

View file

@ -58,7 +58,7 @@ public class Command_mbconfig extends FreedomCommand
plugin.sql.addPlayer(data); plugin.sql.addPlayer(data);
msg(counter + " IPs removed."); msg(counter + " IPs removed.");
msg(data.getIps().get(0) + " is now your only IP address"); msg(data.getIps().get(0) + " is now your only IP address");
FUtil.staffAction(sender.getName(), "Clearing my IPs", true); FUtil.adminAction(sender.getName(), "Clearing my IPs", true);
return true; return true;
} }
case "clearip": case "clearip":
@ -118,7 +118,7 @@ public class Command_mbconfig extends FreedomCommand
if (data.isMasterBuilder() && plugin.pl.isPlayerImpostor(player)) if (data.isMasterBuilder() && plugin.pl.isPlayerImpostor(player))
{ {
FUtil.staffAction(sender.getName(), "Re-adding " + data.getName() + " to the Master Builder list", true); FUtil.adminAction(sender.getName(), "Re-adding " + data.getName() + " to the Master Builder list", true);
if (plugin.pl.getPlayer(player).getFreezeData().isFrozen()) if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
{ {
@ -134,7 +134,7 @@ public class Command_mbconfig extends FreedomCommand
} }
else if (!data.isMasterBuilder()) else if (!data.isMasterBuilder())
{ {
FUtil.staffAction(sender.getName(), "Adding " + data.getName() + " to the Master Builder list", true); FUtil.adminAction(sender.getName(), "Adding " + data.getName() + " to the Master Builder list", true);
data.setMasterBuilder(true); data.setMasterBuilder(true);
data.setVerification(true); data.setVerification(true);
plugin.pl.save(data); plugin.pl.save(data);
@ -171,7 +171,7 @@ public class Command_mbconfig extends FreedomCommand
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true); FUtil.adminAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true);
data.setMasterBuilder(false); data.setMasterBuilder(false);
if (data.getDiscordID() == null) if (data.getDiscordID() == null)
{ {

View file

@ -46,7 +46,7 @@ public class Command_mobpurge extends FreedomCommand
mobName = FUtil.formatName(type.name()); mobName = FUtil.formatName(type.name());
} }
FUtil.staffAction(sender.getName(), "Purging all " + (type != null ? mobName + "s" : "mobs"), true); FUtil.adminAction(sender.getName(), "Purging all " + (type != null ? mobName + "s" : "mobs"), true);
int count = plugin.ew.purgeMobs(type); int count = plugin.ew.purgeMobs(type);
msg(count + " " + (type != null ? mobName : "mob") + FUtil.showS(count) + " removed."); msg(count + " " + (type != null ? mobName : "mob") + FUtil.showS(count) + " removed.");
return true; return true;

View file

@ -23,7 +23,6 @@ import org.bukkit.potion.PotionEffectType;
@CommandParameters(description = "Modify the current item you are holding.", usage = "/<command> <name <message> | lore <message> | enchant <enchantment> <level> | potion <effect> <duration> <amplifier> | attribute <name> <amount> | clear>", aliases = "mi") @CommandParameters(description = "Modify the current item you are holding.", usage = "/<command> <name <message> | lore <message> | enchant <enchantment> <level> | potion <effect> <duration> <amplifier> | attribute <name> <amount> | clear>", aliases = "mi")
public class Command_modifyitem extends FreedomCommand public class Command_modifyitem 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)
{ {

View file

@ -1,52 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Modern weaponry, FTW. Use 'draw' to start firing, 'sling' to stop firing.", usage = "/<command> <draw | sling>")
public class Command_mp44 extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!ConfigEntry.MP44_ENABLED.getBoolean())
{
msg("The mp44 is currently disabled.", ChatColor.GREEN);
return true;
}
if (args.length == 0)
{
return false;
}
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
if (args[0].equalsIgnoreCase("draw"))
{
playerdata.armMP44();
msg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN);
msg("Type /mp44 sling to disable. -by Madgeek1450", ChatColor.GREEN);
playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.GUNPOWDER, 1));
}
else
{
playerdata.disarmMP44();
sender.sendMessage(ChatColor.GREEN + "mp44 Disarmed.");
}
return true;
}
}

View file

@ -53,7 +53,7 @@ public class Command_mute extends FreedomCommand
if (args[0].equals("purge")) if (args[0].equals("purge"))
{ {
FUtil.staffAction(sender.getName(), "Unmuting all players.", true); FUtil.adminAction(sender.getName(), "Unmuting all players.", true);
FPlayer info; FPlayer info;
int count = 0; int count = 0;
for (Player mp : server.getOnlinePlayers()) for (Player mp : server.getOnlinePlayers())
@ -73,13 +73,13 @@ public class Command_mute extends FreedomCommand
if (args[0].equals("all")) if (args[0].equals("all"))
{ {
FUtil.staffAction(sender.getName(), "Muting all non-staff", true); FUtil.adminAction(sender.getName(), "Muting all non-admins", true);
FPlayer playerdata; FPlayer playerdata;
int counter = 0; int counter = 0;
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (!plugin.sl.isStaff(player)) if (!plugin.al.isAdmin(player))
{ {
player.sendTitle(ChatColor.RED + "You've been muted globally.", ChatColor.YELLOW + "Please be patient and you will be unmuted shortly.", 20, 100, 60); player.sendTitle(ChatColor.RED + "You've been muted globally.", ChatColor.YELLOW + "Please be patient and you will be unmuted shortly.", 20, 100, 60);
playerdata = plugin.pl.getPlayer(player); playerdata = plugin.pl.getPlayer(player);
@ -120,9 +120,9 @@ public class Command_mute extends FreedomCommand
} }
FPlayer playerdata = plugin.pl.getPlayer(player); FPlayer playerdata = plugin.pl.getPlayer(player);
if (plugin.sl.isStaff(player)) if (plugin.al.isAdmin(player))
{ {
msg(player.getName() + " is a staff member, and can't be muted."); msg(player.getName() + " is an admin, and can't be muted.");
return true; return true;
} }
@ -140,7 +140,7 @@ public class Command_mute extends FreedomCommand
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Muting " + player.getName(), true); FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
if (smite) if (smite)
{ {
@ -163,7 +163,7 @@ public class Command_mute extends FreedomCommand
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {
if (!plugin.sl.isStaff(sender)) if (!plugin.al.isAdmin(sender))
{ {
return null; return null;
} }

View file

@ -8,7 +8,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.discord.Discord; import me.totalfreedom.totalfreedommod.discord.Discord;
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.staff.StaffMember; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -29,7 +29,7 @@ public class Command_myadmin extends FreedomCommand
} }
Player init = null; Player init = null;
StaffMember target = getStaffMember(playerSender); Admin target = getAdmin(playerSender);
Player targetPlayer = playerSender; Player targetPlayer = playerSender;
// -o switch // -o switch
@ -44,10 +44,10 @@ public class Command_myadmin extends FreedomCommand
return true; return true;
} }
target = getStaffMember(targetPlayer); target = getAdmin(targetPlayer);
if (target == null) if (target == null)
{ {
msg("That player is not a staff member", ChatColor.RED); msg("That player is not an admin", ChatColor.RED);
return true; return true;
} }
@ -72,19 +72,19 @@ public class Command_myadmin extends FreedomCommand
if (init == null) if (init == null)
{ {
FUtil.staffAction(sender.getName(), "Clearing my IPs", true); FUtil.adminAction(sender.getName(), "Clearing my IPs", true);
} }
else else
{ {
FUtil.staffAction(sender.getName(), "Clearing " + target.getName() + "' IPs", true); FUtil.adminAction(sender.getName(), "Clearing " + target.getName() + "' IPs", true);
} }
int counter = target.getIps().size() - 1; int counter = target.getIps().size() - 1;
target.clearIPs(); target.clearIPs();
target.addIp(targetIp); target.addIp(targetIp);
plugin.sl.save(target); plugin.al.save(target);
plugin.sl.updateTables(); plugin.al.updateTables();
plugin.pl.syncIps(target); plugin.pl.syncIps(target);
msg(counter + " IPs removed."); msg(counter + " IPs removed.");
@ -120,16 +120,16 @@ public class Command_myadmin extends FreedomCommand
} }
else else
{ {
msg("You cannot remove that staff members current IP."); msg("You cannot remove that admins current IP.");
} }
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Removing an IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true); FUtil.adminAction(sender.getName(), "Removing an IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true);
target.removeIp(args[1]); target.removeIp(args[1]);
plugin.sl.save(target); plugin.al.save(target);
plugin.sl.updateTables(); plugin.al.updateTables();
plugin.pl.syncIps(target); plugin.pl.syncIps(target);
@ -142,10 +142,10 @@ public class Command_myadmin extends FreedomCommand
{ {
String format = StringUtils.join(args, " ", 1, args.length); String format = StringUtils.join(args, " ", 1, args.length);
target.setAcFormat(format); target.setAcFormat(format);
plugin.sl.save(target); plugin.al.save(target);
plugin.sl.updateTables(); plugin.al.updateTables();
msg("Set staff chat format to \"" + format + "\".", ChatColor.GRAY); msg("Set admin chat format to \"" + format + "\".", ChatColor.GRAY);
String example = format.replace("%name%", "ExampleStaff").replace("%rank%", Rank.ADMIN.getAbbr()).replace("%rankcolor%", Rank.ADMIN.getColor().toString()).replace("%msg%", "The quick brown fox jumps over the lazy dog."); String example = format.replace("%name%", "ExampleAdmin").replace("%rank%", Rank.ADMIN.getAbbr()).replace("%rankcolor%", Rank.ADMIN.getColor().toString()).replace("%msg%", "The quick brown fox jumps over the lazy dog.");
msg(ChatColor.GRAY + "Example: " + FUtil.colorize(example)); msg(ChatColor.GRAY + "Example: " + FUtil.colorize(example));
return true; return true;
} }
@ -153,9 +153,9 @@ public class Command_myadmin extends FreedomCommand
case "clearscformat": case "clearscformat":
{ {
target.setAcFormat(null); target.setAcFormat(null);
plugin.sl.save(target); plugin.al.save(target);
plugin.sl.updateTables(); plugin.al.updateTables();
msg("Cleared staff chat format.", ChatColor.GRAY); msg("Cleared admin chat format.", ChatColor.GRAY);
return true; return true;
} }
@ -198,7 +198,7 @@ public class Command_myadmin extends FreedomCommand
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {
if (!plugin.sl.isStaff(sender)) if (!plugin.al.isAdmin(sender))
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
@ -225,7 +225,7 @@ public class Command_myadmin extends FreedomCommand
{ {
if (args[0].equals("clearip")) if (args[0].equals("clearip"))
{ {
List<String> ips = plugin.sl.getAdmin(sender).getIps(); List<String> ips = plugin.al.getAdmin(sender).getIps();
ips.remove(FUtil.getIp((Player)sender)); ips.remove(FUtil.getIp((Player)sender));
return ips; return ips;
} }
@ -246,10 +246,10 @@ public class Command_myadmin extends FreedomCommand
{ {
if (args[0].equals("-o") && args[2].equals("clearip")) if (args[0].equals("-o") && args[2].equals("clearip"))
{ {
StaffMember staffMember = plugin.sl.getEntryByName(args[1]); Admin admin = plugin.al.getEntryByName(args[1]);
if (staffMember != null) if (admin != null)
{ {
return staffMember.getIps(); return admin.getIps();
} }
} }
} }

View file

@ -53,12 +53,12 @@ public class Command_nickclean extends FreedomCommand
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Cleaning " + player.getName() + "'s nickname", false); FUtil.adminAction(sender.getName(), "Cleaning " + player.getName() + "'s nickname", false);
cleanNickname(player); cleanNickname(player);
return true; return true;
} }
FUtil.staffAction(sender.getName(), "Cleaning all nicknames", false); FUtil.adminAction(sender.getName(), "Cleaning all nicknames", false);
for (final Player player : server.getOnlinePlayers()) for (final Player player : server.getOnlinePlayers())
{ {
cleanNickname(player); cleanNickname(player);

View file

@ -41,11 +41,11 @@ public class Command_nickfilter extends FreedomCommand
player = getPlayerByDisplayName(displayName); player = getPlayerByDisplayName(displayName);
if (player == null || plugin.sl.isVanished(player.getName()) && !plugin.sl.isStaff(sender)) if (player == null || plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
{ {
player = getPlayerByDisplayNameAlt(displayName); player = getPlayerByDisplayNameAlt(displayName);
if (player == null || !plugin.sl.isVanished(player.getName()) && !plugin.sl.isStaff(sender)) if (player == null || !plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
{ {
sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName); sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName);
return true; return true;

Some files were not shown because too many files have changed in this diff Show more