Merge pull request #1 from AtlasMediaGroup/development

updated stuff
This commit is contained in:
SupItsDillon 2020-12-08 16:07:04 +00:00 committed by GitHub
commit 4a3ce64412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
209 changed files with 1752 additions and 1749 deletions

46
.github/workflows/codacy-analysis.yml vendored Normal file
View File

@ -0,0 +1,46 @@
# This workflow checks out code, performs a Codacy security scan
# and integrates the results with the
# GitHub Advanced Security code scanning feature. For more information on
# the Codacy security scan action usage and parameters, see
# https://github.com/codacy/codacy-analysis-cli-action.
# For more information on Codacy Analysis CLI in general, see
# https://github.com/codacy/codacy-analysis-cli.
name: Codacy Security Scan
on:
push:
branches: [ development ]
pull_request:
branches: [ development ]
jobs:
codacy-security-scan:
name: Codacy Security Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v2
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@1.1.0
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: results.sarif

View File

@ -1,4 +1,4 @@
# TotalFreedomMod [![Build Status](https://github.com/TotalFreedomMC/TotalFreedomMod/workflows/build/badge.svg)](https://travis-ci.org/TotalFreedomMC/TotalFreedomMod) [![codebeat badge](https://codebeat.co/badges/89162bad-47be-4418-b1d4-93431b74762e)](https://codebeat.co/projects/github-com-totalfreedommc-totalfreedommod-development)
# TotalFreedomMod [![Build Status](https://github.com/TotalFreedomMC/TotalFreedomMod/workflows/build/badge.svg)](https://travis-ci.org/TotalFreedomMC/TotalFreedomMod) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/29c0f964da304666bd654bc7b1d556db)](https://www.codacy.com/gh/AtlasMediaGroup/TotalFreedomMod/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AtlasMediaGroup/TotalFreedomMod&utm_campaign=Badge_Grade)
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](https://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.

View File

@ -91,7 +91,7 @@
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9][_]*[T]$)"/>
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module>

View File

@ -195,21 +195,21 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.18.1</version>
<version>2.18.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_168</version>
<version>4.2.0_222</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.coreprotect</groupId>
<artifactId>coreprotect</artifactId>
<version>19.1</version>
<version>19.3</version>
<scope>provided</scope>
</dependency>

View File

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

View File

@ -5,7 +5,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.player.PlayerData;
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.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -65,7 +65,7 @@ public class ChatManager extends FreedomService
return;
}
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.sl.isStaff(player))
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
{
event.setCancelled(true);
playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
@ -87,10 +87,10 @@ public class ChatManager extends FreedomService
return;
}
// Check for staffchat
if (fPlayer.inStaffChat())
// Check for adminchat
if (fPlayer.inAdminChat())
{
FSync.staffChatMessage(player, message);
FSync.adminChatMessage(player, message);
event.setCancelled(true);
return;
}
@ -123,7 +123,7 @@ public class ChatManager extends FreedomService
}
// 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())
{
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
@ -136,7 +136,7 @@ public class ChatManager extends FreedomService
event.setFormat(format);
// 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));
}
@ -154,27 +154,27 @@ public class ChatManager extends FreedomService
return color + display.getAbbr();
}
public void staffChat(CommandSender sender, String message)
public void adminChat(CommandSender sender, String message)
{
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);
for (Player player : server.getOnlinePlayers())
{
if (plugin.sl.isStaff(player))
if (plugin.al.isAdmin(player))
{
StaffMember staffMember = plugin.sl.getAdmin(player);
if (!Strings.isNullOrEmpty(staffMember.getAcFormat()))
Admin admin = plugin.al.getAdmin(player);
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
{
String format = staffMember.getAcFormat();
String format = admin.getAcFormat();
ChatColor color = getColor(display);
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
player.sendMessage(FUtil.colorize(msg));
}
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 +184,7 @@ public class ChatManager extends FreedomService
{
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);
}

View File

@ -23,9 +23,9 @@ public class CommandSpy extends FreedomService
{
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.isAdmin(player))
{
continue;
}
@ -36,5 +36,4 @@ public class CommandSpy extends FreedomService
}
}
}
}

View File

@ -95,7 +95,7 @@ public class GameRuleHandler extends FreedomService
private final String gameRuleName;
private final boolean defaultValue;
private GameRule(String gameRuleName, boolean defaultValue)
GameRule(String gameRuleName, boolean defaultValue)
{
this.gameRuleName = gameRuleName;
this.defaultValue = defaultValue;

View File

@ -53,7 +53,7 @@ public class LoginProcess extends FreedomService
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
{
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
for (Player onlinePlayer : server.getOnlinePlayers())
@ -63,10 +63,10 @@ public class LoginProcess extends FreedomService
continue;
}
if (isStaff)
if (isAdmin)
{
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;
}
@ -113,11 +113,8 @@ public class LoginProcess extends FreedomService
}
}
// Check if player is staff
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null;
// Validation below this point
if (isStaff) // Player is staff
if (plugin.al.getEntryByIp(ip) != null) // Check if player is admin
{
// Force-allow log in
event.allow();
@ -127,9 +124,9 @@ public class LoginProcess extends FreedomService
{
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--;
}
@ -149,7 +146,7 @@ public class LoginProcess extends FreedomService
return;
}
// Player is not a staff member
// Player is not an admin
// Server full check
if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
{
@ -157,10 +154,10 @@ public class LoginProcess extends FreedomService
return;
}
// Staff-only mode
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
// Admin-only mode
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;
}
@ -226,7 +223,7 @@ public class LoginProcess extends FreedomService
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();
if (tag != null)
@ -237,14 +234,14 @@ public class LoginProcess extends FreedomService
int noteCount = playerData.getNotes().size();
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.")
.tooltip("Click here to view them.")
.runCommand("/notes " + player.getName() + " list");
FLog.info(noteMessage);
for (Player p : server.getOnlinePlayers())
{
if (plugin.sl.isStaffImpostor(p))
if (plugin.al.isAdminImpostor(p))
{
notice.send(p);
}
@ -257,9 +254,9 @@ public class LoginProcess extends FreedomService
@Override
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)

View File

@ -46,9 +46,9 @@ 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(),
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") : "")));
}
recentlyThrownPotions.clear();
}, 0L, 40L);

View File

@ -183,5 +183,3 @@ public class MovementValidator extends FreedomService
return stack.getTag().getList("AttributeModifiers", 10);
}
}

View File

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

View File

@ -7,7 +7,7 @@ import joptsimple.internal.Strings;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
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.FUtil;
import me.totalfreedom.totalfreedommod.util.Response;
@ -34,23 +34,23 @@ 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)
{
return;
}
if (!staffMember.isActive() || staffMember.getRank() != Rank.SENIOR_ADMIN)
if (!admin.isActive() || admin.getRank() != Rank.SENIOR_ADMIN)
{
FLog.debug("Disabling ptero acc");
removeAccountFromServer(id);
return;
}
FLog.debug("Enabling aptero acc");
FLog.debug("Enabling ptero acc");
addAccountToServer(id);
}

View File

@ -44,7 +44,7 @@ public class Reddit extends FreedomService
private Map<Displayable, String> flairNameList = new HashMap<>();
private List<Displayable> noFlairDisplays = Arrays.asList(Title.VERIFIED_STAFF, Rank.IMPOSTOR, Rank.NON_OP, Rank.OP);
private List<Displayable> noFlairDisplays = Arrays.asList(Title.VERIFIED_ADMIN, Rank.IMPOSTOR, Rank.NON_OP, Rank.OP);
public boolean enabled = false;

View File

@ -30,9 +30,9 @@ public class ServerPing extends FreedomService
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;
}
@ -73,5 +73,4 @@ public class ServerPing extends FreedomService
event.setMotd(motd.toString().trim());
}
}

View File

@ -41,8 +41,8 @@ import me.totalfreedom.totalfreedommod.rank.RankManager;
import me.totalfreedom.totalfreedommod.shop.Shop;
import me.totalfreedom.totalfreedommod.shop.Votifier;
import me.totalfreedom.totalfreedommod.sql.SQLite;
import me.totalfreedom.totalfreedommod.staff.ActivityLog;
import me.totalfreedom.totalfreedommod.staff.StaffList;
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.MethodTimer;
@ -84,7 +84,7 @@ public class TotalFreedomMod extends JavaPlugin
public SavedFlags sf;
public WorldManager wm;
public LogViewer lv;
public StaffList sl;
public AdminList al;
public ActivityLog acl;
public RankManager rm;
public CommandBlocker cb;
@ -202,7 +202,7 @@ public class TotalFreedomMod extends JavaPlugin
wm = new WorldManager();
lv = new LogViewer();
sql = new SQLite();
sl = new StaffList();
al = new AdminList();
acl = new ActivityLog();
rm = new RankManager();
cb = new CommandBlocker();

View File

@ -31,7 +31,7 @@ public class VanishHandler extends FreedomService
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);
}
@ -39,17 +39,17 @@ public class VanishHandler extends FreedomService
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);
}
}
if (plugin.sl.isVanished(player.getName()))
if (plugin.al.isVanished(player.getName()))
{
plugin.esb.setVanished(player.getName(), true);
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);
new BukkitRunnable()
@ -57,7 +57,7 @@ public class VanishHandler extends FreedomService
@Override
public void run()
{
if (!plugin.sl.isVanished(player.getName()))
if (!plugin.al.isVanished(player.getName()))
{
this.cancel();
}
@ -73,11 +73,11 @@ public class VanishHandler extends FreedomService
{
Player player = event.getPlayer();
if (plugin.sl.isVanished(player.getName()))
if (plugin.al.isVanished(player.getName()))
{
event.setQuitMessage(null);
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 java.util.Map;
@ -111,10 +111,10 @@ public class ActivityLog extends FreedomService
activityLog = getEntryByIp(ip);
if (activityLog != null)
{
// Set the new username
activityLog.setName(player.getName());
save();
updateTables();
// Set the new username
activityLog.setName(player.getName());
save();
updateTables();
}
else
{
@ -167,7 +167,7 @@ public class ActivityLog extends FreedomService
public void onPlayerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
if (plugin.sl.isStaff(player))
if (plugin.al.isAdmin(player))
{
getActivityLog(event.getPlayer()).addLogin();
plugin.acl.save();
@ -179,7 +179,7 @@ public class ActivityLog extends FreedomService
public void onPlayerQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
if (plugin.sl.isStaff(player))
if (plugin.al.isAdmin(player))
{
getActivityLog(event.getPlayer()).addLogout();
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 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.SQLException;
@ -17,7 +17,7 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Player;
public class StaffMember
public class Admin
{
@Getter
@Setter
@ -45,13 +45,13 @@ public class StaffMember
@Setter
private String pteroID = null;
public StaffMember(Player player)
public Admin(Player player)
{
this.name = player.getName();
this.ips.add(FUtil.getIp(player));
}
public StaffMember(ResultSet resultSet)
public Admin(ResultSet resultSet)
{
try
{
@ -68,7 +68,7 @@ public class StaffMember
}
catch (SQLException e)
{
FLog.severe("Failed to load staff: " + e.getMessage());
FLog.severe("Failed to load admin: " + e.getMessage());
}
}
@ -77,7 +77,7 @@ public class StaffMember
{
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("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
.append("- Rank: ").append(rank.getName()).append("\n")

View File

@ -0,0 +1,383 @@
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() + " admins (" + 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 ? false : admin.getName().equalsIgnoreCase(player.getName());
}
public boolean addAdmin(Admin admin)
{
if (!admin.isValid())
{
logger.warning("Could not add admin: " + admin.getName() + ". Admin is missing details!");
return false;
}
// Store admin, update views
allAdmins.add(admin);
updateTables();
// Save admin
plugin.sql.addAdmin(admin);
return true;
}
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

@ -267,6 +267,5 @@ public class Ban
it.remove();
}
}
}
}

View File

@ -269,9 +269,8 @@ public class BanManager extends FreedomService
public void onPlayerJoin(PlayerJoinEvent event)
{
final Player player = event.getPlayer();
final PlayerData data = plugin.pl.getData(player);
if (!plugin.sl.isStaff(player))
if (!plugin.al.isAdmin(player))
{
return;
}
@ -328,5 +327,4 @@ public class BanManager extends FreedomService
}
}
}
}

View File

@ -132,13 +132,13 @@ public class BlockBlocker extends FreedomService
case PLAYER_HEAD:
case PLAYER_WALL_HEAD:
{
Skull skull = (Skull) event.getBlockPlaced().getState();
Skull skull = (Skull)event.getBlockPlaced().getState();
if (skull.getOwner() != null)
{
if (skull.getOwner().contains("\u00A7"))
{
skull.setOwner(skull.getOwner().replace("\u00A7", ""));
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
SkullMeta meta = (SkullMeta)event.getItemInHand().getItemMeta();
if (meta != null)
{
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);
@ -173,14 +173,14 @@ public class BlockBlocker extends FreedomService
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
{
Banner banner = (Banner) event.getBlockPlaced().getState();
List<Pattern> patterns = banner.getPatterns();;
Banner banner = (Banner)event.getBlockPlaced().getState();
List<Pattern> patterns = banner.getPatterns();
;
if (patterns.size() >= 2)
{
banner.setPatterns(patterns.subList(0, 2));
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
}
}
}
}

View File

@ -30,7 +30,7 @@ public class EditBlocker extends FreedomService
return;
}
if (plugin.sl.isStaffSync(event.getPlayer()))
if (plugin.al.isAdminSync(event.getPlayer()))
{
fPlayer.setEditBlocked(false);
return;
@ -49,7 +49,7 @@ public class EditBlocker extends FreedomService
return;
}
if (plugin.sl.isStaffSync(event.getPlayer()))
if (plugin.al.isAdminSync(event.getPlayer()))
{
fPlayer.setEditBlocked(false);
return;
@ -58,5 +58,4 @@ public class EditBlocker extends FreedomService
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
event.setCancelled(true);
}
}

View File

@ -148,7 +148,7 @@ public class EventBlocker extends FreedomService
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (!plugin.sl.isStaff(event.getPlayer()))
if (!plugin.al.isAdmin(event.getPlayer()))
{
event.setCancelled(true);
}

View File

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

View File

@ -82,5 +82,4 @@ public class PotionBlocker extends FreedomService
}
return false;
}
}

View File

@ -46,12 +46,12 @@ public class CommandBlocker extends FreedomService
{
try
{
SimplePluginManager simplePluginManager = (SimplePluginManager) Bukkit.getServer().getPluginManager();
SimplePluginManager simplePluginManager = (SimplePluginManager)Bukkit.getServer().getPluginManager();
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
commandMapField.setAccessible(true);
SimpleCommandMap simpleCommandMap = (SimpleCommandMap) commandMapField.get(simplePluginManager);
SimpleCommandMap simpleCommandMap = (SimpleCommandMap)commandMapField.get(simplePluginManager);
return simpleCommandMap;
}
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
@ -171,7 +171,7 @@ public class CommandBlocker extends FreedomService
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.");
return true;

View File

@ -8,7 +8,7 @@ public enum CommandBlockerAction
BLOCK_UNKNOWN("u");
private final String token;
private CommandBlockerAction(String token)
CommandBlockerAction(String token)
{
this.token = token;
}

View File

@ -2,23 +2,20 @@ package me.totalfreedom.totalfreedommod.blocking.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
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.entity.Player;
public enum CommandBlockerRank
{
ANYONE("a"),
EVERYONE("e"),
OP("o"),
SUPER("s"),
TELNET("t"),
SENIOR("c"),
ADMIN("a"),
SENIOR_ADMIN("s"),
NOBODY("n");
//
private final String token;
private CommandBlockerRank(String token)
CommandBlockerRank(String token)
{
this.token = token;
}
@ -35,19 +32,14 @@ public enum CommandBlockerRank
public static CommandBlockerRank fromSender(CommandSender sender)
{
if (!(sender instanceof Player))
Admin admin = TotalFreedomMod.plugin().al.getAdmin(sender);
if (admin != null)
{
return TELNET;
}
StaffMember staffMember = TotalFreedomMod.plugin().sl.getAdmin(sender);
if (staffMember != null)
{
if (staffMember.getRank() == Rank.SENIOR_ADMIN)
if (admin.getRank() == Rank.SENIOR_ADMIN)
{
return SENIOR;
return SENIOR_ADMIN;
}
return SUPER;
return ADMIN;
}
if (sender.isOp())
@ -55,8 +47,7 @@ public enum CommandBlockerRank
return OP;
}
return ANYONE;
return EVERYONE;
}
public static CommandBlockerRank fromToken(String token)
@ -68,6 +59,6 @@ public enum CommandBlockerRank
return rank;
}
}
return ANYONE;
return EVERYONE;
}
}

View File

@ -11,7 +11,7 @@ import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
import me.totalfreedom.bukkittelnet.session.ClientSession;
import me.totalfreedom.totalfreedommod.FreedomService;
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 org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -43,15 +43,15 @@ public class BukkitTelnetBridge extends FreedomService
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;
}
event.setBypassPassword(true);
event.setName(staffMember.getName());
event.setName(admin.getName());
}
@EventHandler(priority = EventPriority.NORMAL)
@ -66,10 +66,8 @@ public class BukkitTelnetBridge extends FreedomService
@EventHandler(priority = EventPriority.NORMAL)
public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event)
{
final Iterator<Map.Entry<Player, Map<String, Object>>> it = event.getDataTags().entrySet().iterator();
while (it.hasNext())
for (Map.Entry<Player, Map<String, Object>> entry : event.getDataTags().entrySet())
{
final Map.Entry<Player, Map<String, Object>> entry = it.next();
final Player player = entry.getKey();
final Map<String, Object> playerTags = entry.getValue();
@ -77,14 +75,14 @@ public class BukkitTelnetBridge extends FreedomService
boolean isTelnetAdmin = false;
boolean isSeniorAdmin = false;
final StaffMember staffMember = plugin.sl.getAdmin(player);
if (staffMember != null)
final Admin admin = plugin.al.getAdmin(player);
if (admin != null)
{
boolean active = staffMember.isActive();
boolean active = admin.isActive();
isAdmin = active;
isSeniorAdmin = active && staffMember.getRank() == Rank.SENIOR_ADMIN;
isTelnetAdmin = active && (isSeniorAdmin || staffMember.getRank() == Rank.ADMIN);
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.ADMIN);
}
playerTags.put("tfm.admin.isAdmin", isAdmin);
@ -121,22 +119,22 @@ public class BukkitTelnetBridge extends FreedomService
return bukkitTelnetPlugin;
}
public List<StaffMember> getConnectedAdmins()
public List<Admin> getConnectedAdmins()
{
List<StaffMember> staffMembers = new ArrayList<>();
List<Admin> admins = new ArrayList<>();
final BukkitTelnet telnet = getBukkitTelnetPlugin();
if (telnet != null)
{
for (ClientSession session : telnet.appender.getSessions())
{
StaffMember staffMember = plugin.sl.getEntryByName(session.getUserName().toLowerCase());
if (staffMember != null && !staffMembers.contains(staffMember))
Admin admin = plugin.al.getEntryByName(session.getUserName().toLowerCase());
if (admin != null && !admins.contains(admin))
{
staffMembers.add(staffMember);
admins.add(admin);
}
}
}
return staffMembers;
return admins;
}
public void killTelnetSessions(final String name)

View File

@ -301,7 +301,7 @@ public class CoreProtectBridge extends FreedomService
}
}
if (!plugin.sl.isStaff(player))
if (!plugin.al.isAdmin(player))
{
cooldown.put(player.getName(), System.currentTimeMillis());
}
@ -333,10 +333,14 @@ public class CoreProtectBridge extends FreedomService
{
s = " placed ";
}
else
else if (result.getActionString().equals("Removal"))
{
s = " broke ";
}
else
{
s = " interacted with ";
}
if (result.isRolledBack())
{
@ -365,9 +369,15 @@ public class CoreProtectBridge extends FreedomService
{
if (data.hasInspection())
{
BlockState placedBlock = block.getRelative(event.getBlockFace()).getState();
BlockState blockState = block.getRelative(event.getBlockFace()).getState();
Block placedBlock = blockState.getBlock();
event.setCancelled(true);
List<String[]> lookup = coreProtect.blockLookup(placedBlock.getBlock(), -1);
List<String[]> lookup = coreProtect.blockLookup(placedBlock, -1);
if (lookup.isEmpty())
{
lookup = coreProtect.blockLookup(block, -1);
}
int cooldownTime = 3;
@ -382,7 +392,7 @@ public class CoreProtectBridge extends FreedomService
}
}
if (!plugin.sl.isStaff(player))
if (!plugin.al.isAdmin(player))
{
cooldown.put(player.getName(), System.currentTimeMillis());
}
@ -414,10 +424,14 @@ public class CoreProtectBridge extends FreedomService
{
s = " placed ";
}
else
else if (result.getActionString().equals("Removal"))
{
s = " broke ";
}
else
{
s = " interacted with ";
}
if (result.isRolledBack())
{

View File

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

View File

@ -31,8 +31,7 @@ public class Cager extends FreedomService
public void onBreakBlock(BlockBreakEvent event)
{
Player player = event.getPlayer();
if (player == null
|| plugin.sl.isStaff(player))
if (player == null || plugin.al.isAdmin(player))
{
return;
}
@ -113,5 +112,4 @@ public class Cager extends FreedomService
cage.playerJoin();
}
}
}

View File

@ -40,7 +40,9 @@ public class CommandLoader extends FreedomService
for (FreedomCommand command : commands)
{
if (name.equals(command.getName()))
{
return command;
}
}
return null;
}
@ -50,7 +52,9 @@ public class CommandLoader extends FreedomService
for (FreedomCommand command : commands)
{
if (Arrays.asList(command.getAliases().split(",")).contains(alias))
{
return true;
}
}
return false;
}
@ -69,7 +73,7 @@ public class CommandLoader extends FreedomService
}
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
{
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_" , ""));
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_", ""));
}
}

View File

@ -8,8 +8,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Talk privately with other staff on the server.", usage = "/<command> [message]", aliases = "o,sc")
public class Command_staffchat extends FreedomCommand
@CommandParameters(description = "Talk privately with other admins on the server.", usage = "/<command> [message]", aliases = "o,sc,ac,staffchat")
public class Command_adminchat extends FreedomCommand
{
@Override
@ -19,17 +19,17 @@ public class Command_staffchat extends FreedomCommand
{
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;
}
FPlayer userinfo = plugin.pl.getPlayer(playerSender);
userinfo.setStaffChat(!userinfo.inStaffChat());
msg("Toggled your staff chat " + (userinfo.inStaffChat() ? "on" : "off") + ".");
userinfo.setAdminChat(!userinfo.inAdminChat());
msg("Admin chat turned " + (userinfo.inAdminChat() ? "on" : "off") + ".");
}
else
{
plugin.cm.staffChat(sender, StringUtils.join(args, " "));
plugin.cm.adminChat(sender, StringUtils.join(args, " "));
}
return true;
}

View File

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

View File

@ -11,8 +11,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Denies joining of operators and only allows staff members to join.", usage = "/<command> [on | off]")
public class Command_staffmode extends FreedomCommand
@CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]", aliases = "staffmode")
public class Command_adminmode extends FreedomCommand
{
@Override
@ -25,19 +25,19 @@ public class Command_staffmode extends FreedomCommand
if (args[0].equalsIgnoreCase("off"))
{
ConfigEntry.STAFF_ONLY_MODE.setBoolean(false);
FUtil.staffAction(sender.getName(), "Opening the server to all players.", true);
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
FUtil.adminAction(sender.getName(), "Opening the server to all players", true);
return true;
}
else if (args[0].equalsIgnoreCase("on"))
{
ConfigEntry.STAFF_ONLY_MODE.setBoolean(true);
FUtil.staffAction(sender.getName(), "Closing the server to non-staff.", true);
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true);
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;
@ -49,7 +49,7 @@ public class Command_staffmode extends FreedomCommand
@Override
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");
}

View File

@ -13,10 +13,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@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>]",
aliases = "sw")
public class Command_staffworld extends FreedomCommand
aliases = "sw,aw,staffworld")
public class Command_adminworld extends FreedomCommand
{
private enum CommandMode
@ -61,24 +61,24 @@ public class Command_staffworld extends FreedomCommand
return false;
}
World staffWorld = null;
World adminWorld = null;
try
{
staffWorld = plugin.wm.staffworld.getWorld();
adminWorld = plugin.wm.adminworld.getWorld();
}
catch (Exception ex)
{
}
if (staffWorld == null || playerSender.getWorld() == staffWorld)
if (adminWorld == null || playerSender.getWorld() == adminWorld)
{
msg("Going to the main world.");
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
}
else
{
msg("Going to the StaffWorld.");
plugin.wm.staffworld.sendToWorld(playerSender);
msg("Going to the AdminWorld.");
plugin.wm.adminworld.sendToWorld(playerSender);
}
break;
}
@ -91,8 +91,8 @@ public class Command_staffworld extends FreedomCommand
WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
if (timeOfDay != null)
{
plugin.wm.staffworld.setTimeOfDay(timeOfDay);
msg("StaffWorld time set to: " + timeOfDay.name());
plugin.wm.adminworld.setTimeOfDay(timeOfDay);
msg("AdminWorld time set to: " + timeOfDay.name());
}
else
{
@ -115,8 +115,8 @@ public class Command_staffworld extends FreedomCommand
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
if (weatherMode != null)
{
plugin.wm.staffworld.setWeatherMode(weatherMode);
msg("StaffWorld weather set to: " + weatherMode.name());
plugin.wm.adminworld.setWeatherMode(weatherMode);
msg("AdminWorld weather set to: " + weatherMode.name());
}
else
{
@ -152,7 +152,7 @@ public class Command_staffworld extends FreedomCommand
// TODO: Redo this properly
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();
}
@ -177,7 +177,7 @@ public class Command_staffworld extends FreedomCommand
@Override
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();
}

View File

@ -37,7 +37,7 @@ public class Command_adventure extends FreedomCommand
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.");
return true;
}

View File

@ -17,7 +17,7 @@ public class Command_aeclear extends FreedomCommand
@Override
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;
for (World world : server.getWorlds())
{

View File

@ -22,5 +22,4 @@ public class Command_announce extends FreedomCommand
plugin.an.announce(StringUtils.join(args, " "));
return true;
}
}

View File

@ -154,7 +154,7 @@ public class Command_ban extends FreedomCommand
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
}
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + 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

View File

@ -72,7 +72,7 @@ public class Command_banip extends FreedomCommand
{
// Broadcast
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);
}
}

View File

@ -20,7 +20,7 @@ public class Command_banlist extends FreedomCommand
{
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();
msg("Purged " + amount + " player bans.");
return true;

View File

@ -27,7 +27,7 @@ public class Command_banname extends FreedomCommand
String reason = null;
String name = args[0];;
String name = args[0];
if (plugin.bm.getByUsername(name) != null)
{
@ -55,7 +55,7 @@ public class Command_banname extends FreedomCommand
if (!silent)
{
FUtil.staffAction(sender.getName(), "Banned the name " + name, true);
FUtil.adminAction(sender.getName(), "Banned the name " + name, true);
}
Player player = getPlayer(name);

View File

@ -23,7 +23,7 @@ public class Command_blockcmd extends FreedomCommand
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;
for (Player player : server.getOnlinePlayers())
{
@ -40,18 +40,18 @@ public class Command_blockcmd extends FreedomCommand
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;
for (Player player : server.getOnlinePlayers())
{
if (isStaff(player))
if (isAdmin(player))
{
continue;
}
counter += 1;
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.");
@ -66,9 +66,9 @@ public class Command_blockcmd extends FreedomCommand
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;
}
@ -76,7 +76,7 @@ public class Command_blockcmd extends FreedomCommand
if (!playerdata.allCommandsBlocked())
{
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() + ".");
}
else

View File

@ -46,7 +46,7 @@ public class Command_blockedit extends FreedomCommand
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;
for (final Player player : this.server.getOnlinePlayers())
{
@ -63,11 +63,11 @@ public class Command_blockedit extends FreedomCommand
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;
for (final Player player : this.server.getOnlinePlayers())
{
if (!plugin.sl.isStaff(player))
if (!plugin.al.isAdmin(player))
{
final FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setEditBlocked(true);
@ -105,20 +105,20 @@ public class Command_blockedit extends FreedomCommand
final FPlayer pd = plugin.pl.getPlayer(player2);
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);
msg("Unblocking block modification abilities for " + player2.getName());
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
}
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;
}
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);
if (smite)

View File

@ -46,7 +46,7 @@ public class Command_blockpvp extends FreedomCommand
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;
for (Player player : server.getOnlinePlayers())
{
@ -64,11 +64,11 @@ public class Command_blockpvp extends FreedomCommand
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;
for (Player player : server.getOnlinePlayers())
{
if (!plugin.sl.isStaff(player))
if (!plugin.al.isAdmin(player))
{
final FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setPvpBlocked(true);
@ -106,20 +106,20 @@ public class Command_blockpvp extends FreedomCommand
final FPlayer pd = plugin.pl.getPlayer(p);
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);
msg("Enabling PVP for " + p.getName());
msg("Enabling PVP for " + p.getName());
msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
}
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;
}
FUtil.staffAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
FUtil.adminAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
pd.setPvpBlocked(true);
if (smite)
{

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@ public class Command_clearchat extends FreedomCommand
{
for (Player player : server.getOnlinePlayers())
{
if (!plugin.sl.isStaff(player))
if (!plugin.al.isAdmin(player))
{
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;
}
}

View File

@ -29,11 +29,11 @@ public class Command_clearinventory extends FreedomCommand
}
else
{
if (plugin.sl.isStaff(sender))
if (plugin.al.isAdmin(sender))
{
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())
{
player.getInventory().clear();
@ -67,7 +67,7 @@ public class Command_clearinventory extends FreedomCommand
@Override
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();
players.add("-a");

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.command;
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.CommandSender;
import org.bukkit.entity.Player;
@ -14,12 +14,11 @@ public class Command_cmdspy extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
StaffMember staffMember = plugin.sl.getAdmin(playerSender);
staffMember.setCommandSpy(!staffMember.getCommandSpy());
msg("CommandSpy " + (staffMember.getCommandSpy() ? "enabled." : "disabled."));
plugin.sl.save(staffMember);
plugin.sl.updateTables();
Admin admin = plugin.al.getAdmin(playerSender);
admin.setCommandSpy(!admin.getCommandSpy());
msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
plugin.al.save(admin);
plugin.al.updateTables();
return true;
}
}

View File

@ -1,6 +1,5 @@
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;
@ -23,7 +22,7 @@ public class Command_colorme extends FreedomCommand
return false;
}
if ("list".equalsIgnoreCase(args[0]))
if (args[0].equalsIgnoreCase("list"))
{
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
return true;
@ -31,10 +30,8 @@ public class Command_colorme extends FreedomCommand
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())
for (Map.Entry<String, ChatColor> entry : FUtil.CHAT_COLOR_NAMES.entrySet())
{
final Map.Entry<String, ChatColor> entry = it.next();
if (entry.getKey().contains(needle))
{
color = entry.getValue();
@ -53,7 +50,6 @@ public class Command_colorme extends FreedomCommand
plugin.esb.setNickname(sender.getName(), newNick);
msg("Your nickname is now: " + newNick);
return true;
}
}

View File

@ -37,7 +37,7 @@ public class Command_creative extends FreedomCommand
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.");
return true;
}

View File

@ -49,15 +49,13 @@ public class Command_curse extends FreedomCommand
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()))
if (args.length == 1 && plugin.al.isAdmin(sender) && FUtil.isExecutive(sender.getName()))
{
return FUtil.getPlayerList();
}

View File

@ -20,7 +20,7 @@ public class Command_denick extends FreedomCommand
return true;
}
FUtil.staffAction(sender.getName(), "Removing all nicknames", false);
FUtil.adminAction(sender.getName(), "Removing all nicknames", false);
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)
|| 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());
player.setOp(false);
@ -48,7 +48,7 @@ public class Command_deop extends FreedomCommand
{
if (!silent)
{
FUtil.staffAction(sender.getName(), "De-opping " + StringUtils.join(matchedPlayerNames, ", "), false);
FUtil.adminAction(sender.getName(), "De-opping " + StringUtils.join(matchedPlayerNames, ", "), false);
}
}
else

View File

@ -14,7 +14,7 @@ public class Command_deopall extends FreedomCommand
@Override
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())
{

View File

@ -20,7 +20,7 @@ public class Command_disguisetoggle extends FreedomCommand
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())
{
@ -33,7 +33,6 @@ public class Command_disguisetoggle extends FreedomCommand
}
msg("Disguises are now " + (plugin.ldb.isDisguisesEnabled() ? "enabled." : "disabled."));
return true;
}
}

View File

@ -5,7 +5,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
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 org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
@ -38,23 +38,23 @@ public class Command_doom extends FreedomCommand
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);
final String ip = player.getAddress().getAddress().getHostAddress().trim();
// Remove from admin
StaffMember staffMember = getStaffMember(player);
if (staffMember != null)
Admin admin = getAdmin(player);
if (admin != null)
{
FUtil.staffAction(sender.getName(), "Removing " + player.getName() + " from the staff list", true);
staffMember.setActive(false);
plugin.sl.save(staffMember);
plugin.sl.updateTables();
plugin.ptero.updateAccountStatus(staffMember);
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the admin list", true);
admin.setActive(false);
plugin.al.save(admin);
plugin.al.updateTables();
plugin.ptero.updateAccountStatus(admin);
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,11 +120,12 @@ public class Command_doom extends FreedomCommand
public void run()
{
// 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);
// generate explosion
player.getWorld().createExplosion(player.getLocation(), 0F, false);;
player.getWorld().createExplosion(player.getLocation(), 0F, false);
;
// kick player
player.kickPlayer(ChatColor.RED + kickReason);

View File

@ -266,5 +266,4 @@ public class Command_enchant extends FreedomCommand
return Collections.emptyList();
}
}

View File

@ -54,7 +54,7 @@ public class Command_entitywipe extends FreedomCommand
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;
if (type != null)
{

View File

@ -33,10 +33,12 @@ public class Command_explode extends FreedomCommand
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
@ -58,7 +60,7 @@ public class Command_explode extends FreedomCommand
@Override
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 FUtil.getPlayerList();
}

View File

@ -13,7 +13,7 @@ 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)
if (!plugin.al.isAdmin(sender) && !senderIsConsole)
{
playerSender.setHealth(0);
return true;

View File

@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@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
{
@ -23,15 +23,15 @@ public class Command_freeze extends FreedomCommand
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.");
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())
{
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);
msg(player, "You have been globally frozen due to an OP breaking the rules, please wait and you will be unfrozen soon.", ChatColor.RED);
@ -41,12 +41,12 @@ public class Command_freeze extends FreedomCommand
return true;
}
if (args[0].equals("purge"))
if (args[0].equalsIgnoreCase("purge"))
{
FUtil.staffAction(sender.getName(), "Unfreezing all players", false);
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
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);
}

View File

@ -21,13 +21,8 @@ public class Command_fuckoff extends FreedomCommand
FPlayer player = plugin.pl.getPlayer(playerSender);
if (!args[0].equals("on"))
if (args[0].equalsIgnoreCase("off"))
{
player.disableFuckoff();
}
else
{
double radius = 25.0;
if (args.length >= 2)
{
@ -39,12 +34,14 @@ public class Command_fuckoff extends FreedomCommand
{
}
}
player.setFuckoff(radius);
}
else
{
player.disableFuckoff();
}
msg("Fuckoff " + (player.isFuckOff() ? ("enabled. Radius: " + player.getFuckoffRadius() + ".") : "disabled."));
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

@ -107,5 +107,4 @@ public class Command_health extends FreedomCommand
return (double)tickCount / ((double)elapsed / 1000.0);
}
}
}

View File

@ -153,7 +153,7 @@ public class Command_hubworld extends FreedomCommand
@Override
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();
}
@ -178,7 +178,7 @@ public class Command_hubworld extends FreedomCommand
// TODO: Redo this properly
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.isAdmin(playerSender))
{
throw new PermissionDeniedException();
}

View File

@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
@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
{
@ -29,5 +29,4 @@ public class Command_indefban extends FreedomCommand
msg("Reloaded the indefinite ban list.");
return true;
}
}

View File

@ -26,16 +26,20 @@ public class Command_invis extends FreedomCommand
{
if (args[0].equalsIgnoreCase("clear"))
{
if(!plugin.sl.isStaff(sender))
if (!plugin.al.isAdmin(sender))
{
return noPerms();
}
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;
}
}
else
{
return false;
}
}
List<String> players = new ArrayList<String>();
@ -43,10 +47,10 @@ public class Command_invis extends FreedomCommand
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());
if (clear && !plugin.sl.isStaff(player))
if (clear && !plugin.al.isAdmin(player))
{
player.removePotionEffect((PotionEffectType.INVISIBILITY));
clears++;
@ -61,9 +65,13 @@ public class Command_invis extends FreedomCommand
}
if (clear)
{
msg("Cleared " + clears + " players");
}
else
{
msg("Invisible players (" + players.size() + "): " + StringUtils.join(players, ", "));
}
return true;
}
@ -71,8 +79,10 @@ public class Command_invis extends FreedomCommand
@Override
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 Collections.emptyList();
}

View File

@ -35,9 +35,9 @@ public class Command_invsee extends FreedomCommand
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 admins.", ChatColor.RED);
return true;
}
@ -67,7 +67,7 @@ public class Command_invsee extends FreedomCommand
}
inv = player.getInventory();
playerSender.closeInventory();
if (!plugin.sl.isStaff(player))
if (!plugin.al.isAdmin(player))
{
FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
fPlayer.setInvSee(true);

View File

@ -32,9 +32,9 @@ public class Command_jumppads extends FreedomCommand
return true;
}
if ("off".equals(args[0]))
if (args[0].equalsIgnoreCase("off"))
{
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.OFF)
if (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.OFF)
{
msg("Your jumppads are already disabled.");
return true;
@ -44,7 +44,7 @@ public class Command_jumppads extends FreedomCommand
}
else
{
if(plugin.jp.players.get(playerSender) != Jumppads.JumpPadMode.OFF)
if (plugin.jp.players.get(playerSender) != Jumppads.JumpPadMode.OFF)
{
msg("Your jumppads are already enabled.");
return true;
@ -65,7 +65,7 @@ public class Command_jumppads extends FreedomCommand
{
if ("off".equals(args[1]))
{
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.MADGEEK)
if (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.MADGEEK)
{
msg("Your jumppads are already set to normal mode.");
return true;
@ -75,7 +75,7 @@ public class Command_jumppads extends FreedomCommand
}
else
{
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS)
if (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS)
{
msg("Your jumppads are already set to normal and sideways mode.");
return true;
@ -95,7 +95,7 @@ public class Command_jumppads extends FreedomCommand
@Override
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();
}

View File

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

View File

@ -8,20 +8,20 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@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
{
@Override
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())
{
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() + ".");
}
}

View File

@ -60,8 +60,6 @@ public class Command_landmine extends FreedomCommand
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;
}
if (args.length > 1 && plugin.sl.isStaff(playerSender))
if (args.length > 1 && plugin.al.isAdmin(playerSender))
{
PlayerData playerData = plugin.pl.getData(args[0]);
if (playerData == null)

View File

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

View File

@ -22,7 +22,7 @@ public class Command_lockup extends FreedomCommand
{
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())
{
@ -32,7 +32,7 @@ public class Command_lockup extends FreedomCommand
}
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())
{
cancelLockup(player);
@ -59,7 +59,7 @@ public class Command_lockup extends FreedomCommand
if (!silent)
{
FUtil.staffAction(sender.getName(), "Locking up " + player.getName(), true);
FUtil.adminAction(sender.getName(), "Locking up " + player.getName(), true);
}
startLockup(player);
msg("Locked up " + player.getName() + ".");
@ -76,7 +76,7 @@ public class Command_lockup extends FreedomCommand
if (!silent)
{
FUtil.staffAction(sender.getName(), "Unlocking " + player.getName(), true);
FUtil.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
}
cancelLockup(player);
msg("Unlocked " + player.getName() + ".");

View File

@ -16,7 +16,7 @@ public class Command_loginmessage extends FreedomCommand
@Override
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);
return true;

View File

@ -55,7 +55,7 @@ public class Command_makeopregion extends FreedomCommand
LocalSession session = plugin.web.getWorldEditPlugin().getSession(playerSender);
Region selection = null;
Region selection;
try
{
@ -91,7 +91,6 @@ public class Command_makeopregion extends FreedomCommand
regionManager.addRegion(region);
msg("Successfully created the region '" + name + "' for " + player.getName(), ChatColor.GREEN);
return true;
}
}

View File

@ -218,5 +218,4 @@ public class Command_manageshop extends FreedomCommand
}
return false;
}
}

View File

@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Manually verify someone", usage = "/<command> <playername>", aliases="mv")
@CommandParameters(description = "Manually verify someone", usage = "/<command> <playername>", aliases = "mv")
public class Command_manuallyverify extends FreedomCommand
{
@Override
@ -39,7 +39,7 @@ public class Command_manuallyverify extends FreedomCommand
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.sendMessage(YOU_ARE_OP);

View File

@ -153,7 +153,7 @@ public class Command_masterbuilderworld extends FreedomCommand
@Override
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();
}
@ -178,7 +178,7 @@ public class Command_masterbuilderworld extends FreedomCommand
// TODO: Redo this properly
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.isAdmin(playerSender))
{
throw new PermissionDeniedException();
}
@ -199,5 +199,4 @@ public class Command_masterbuilderworld extends FreedomCommand
super(string);
}
}
}

View File

@ -58,7 +58,7 @@ public class Command_mbconfig extends FreedomCommand
plugin.sql.addPlayer(data);
msg(counter + " IPs removed.");
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;
}
case "clearip":
@ -118,7 +118,7 @@ public class Command_mbconfig extends FreedomCommand
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())
{
@ -134,7 +134,7 @@ public class Command_mbconfig extends FreedomCommand
}
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.setVerification(true);
plugin.pl.save(data);
@ -171,7 +171,7 @@ public class Command_mbconfig extends FreedomCommand
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);
if (data.getDiscordID() == null)
{

View File

@ -46,7 +46,7 @@ public class Command_mobpurge extends FreedomCommand
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);
msg(count + " " + (type != null ? mobName : "mob") + FUtil.showS(count) + " removed.");
return true;

View File

@ -29,7 +29,7 @@ public class Command_mute extends FreedomCommand
return false;
}
if (args[0].equals("list"))
if (args[0].equalsIgnoreCase("list"))
{
msg("Muted players:");
FPlayer info;
@ -51,9 +51,9 @@ public class Command_mute extends FreedomCommand
return true;
}
if (args[0].equals("purge"))
if (args[0].equalsIgnoreCase("purge"))
{
FUtil.staffAction(sender.getName(), "Unmuting all players.", true);
FUtil.adminAction(sender.getName(), "Unmuting all players.", true);
FPlayer info;
int count = 0;
for (Player mp : server.getOnlinePlayers())
@ -71,15 +71,15 @@ public class Command_mute extends FreedomCommand
return true;
}
if (args[0].equals("all"))
if (args[0].equalsIgnoreCase("all"))
{
FUtil.staffAction(sender.getName(), "Muting all non-staff", true);
FUtil.adminAction(sender.getName(), "Muting all non-admins", true);
FPlayer playerdata;
int counter = 0;
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);
playerdata = plugin.pl.getPlayer(player);
@ -120,9 +120,9 @@ public class Command_mute extends FreedomCommand
}
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;
}
@ -140,7 +140,7 @@ public class Command_mute extends FreedomCommand
return true;
}
FUtil.staffAction(sender.getName(), "Muting " + player.getName(), true);
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
if (smite)
{
@ -163,7 +163,7 @@ public class Command_mute extends FreedomCommand
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (!plugin.sl.isStaff(sender))
if (!plugin.al.isAdmin(sender))
{
return null;
}

View File

@ -8,7 +8,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.discord.Discord;
import me.totalfreedom.totalfreedommod.player.PlayerData;
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 org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
@ -29,7 +29,7 @@ public class Command_myadmin extends FreedomCommand
}
Player init = null;
StaffMember target = getStaffMember(playerSender);
Admin target = getAdmin(playerSender);
Player targetPlayer = playerSender;
// -o switch
@ -44,10 +44,10 @@ public class Command_myadmin extends FreedomCommand
return true;
}
target = getStaffMember(targetPlayer);
target = getAdmin(targetPlayer);
if (target == null)
{
msg("That player is not a staff member", ChatColor.RED);
msg("That player is not an admin", ChatColor.RED);
return true;
}
@ -72,19 +72,19 @@ public class Command_myadmin extends FreedomCommand
if (init == null)
{
FUtil.staffAction(sender.getName(), "Clearing my IPs", true);
FUtil.adminAction(sender.getName(), "Clearing my IPs", true);
}
else
{
FUtil.staffAction(sender.getName(), "Clearing " + target.getName() + "'s IPs", true);
FUtil.adminAction(sender.getName(), "Clearing " + target.getName() + "'s IPs", true);
}
int counter = target.getIps().size() - 1;
target.clearIPs();
target.addIp(targetIp);
plugin.sl.save(target);
plugin.sl.updateTables();
plugin.al.save(target);
plugin.al.updateTables();
plugin.pl.syncIps(target);
msg(counter + " IPs removed.");
@ -120,16 +120,16 @@ public class Command_myadmin extends FreedomCommand
}
else
{
msg("You cannot remove that staff members current IP.");
msg("You cannot remove that admins current IP.");
}
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]);
plugin.sl.save(target);
plugin.sl.updateTables();
plugin.al.save(target);
plugin.al.updateTables();
plugin.pl.syncIps(target);
@ -142,10 +142,10 @@ public class Command_myadmin extends FreedomCommand
{
String format = StringUtils.join(args, " ", 1, args.length);
target.setAcFormat(format);
plugin.sl.save(target);
plugin.sl.updateTables();
msg("Set staff 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.");
plugin.al.save(target);
plugin.al.updateTables();
msg("Set admin chat format to \"" + format + "\".", ChatColor.GRAY);
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));
return true;
}
@ -153,9 +153,9 @@ public class Command_myadmin extends FreedomCommand
case "clearscformat":
{
target.setAcFormat(null);
plugin.sl.save(target);
plugin.sl.updateTables();
msg("Cleared staff chat format.", ChatColor.GRAY);
plugin.al.save(target);
plugin.al.updateTables();
msg("Cleared admin chat format.", ChatColor.GRAY);
return true;
}
@ -198,7 +198,7 @@ public class Command_myadmin extends FreedomCommand
@Override
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();
}
@ -225,7 +225,7 @@ public class Command_myadmin extends FreedomCommand
{
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));
return ips;
}
@ -246,10 +246,10 @@ public class Command_myadmin extends FreedomCommand
{
if (args[0].equals("-o") && args[2].equals("clearip"))
{
StaffMember staffMember = plugin.sl.getEntryByName(args[1]);
if (staffMember != null)
Admin admin = plugin.al.getEntryByName(args[1]);
if (admin != null)
{
return staffMember.getIps();
return admin.getIps();
}
}
}

View File

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

View File

@ -41,11 +41,11 @@ public class Command_nickfilter extends FreedomCommand
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);
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);
return true;

View File

@ -56,7 +56,9 @@ public class Command_nickgradient extends FreedomCommand
from = " (From: " + FUtil.getHexStringOfAWTColor(awt1) + ")";
}
else
{
awt1 = java.awt.Color.decode(args[0]);
}
if (args[1].equalsIgnoreCase("random") ||
args[1].equalsIgnoreCase("r"))
{
@ -64,7 +66,9 @@ public class Command_nickgradient extends FreedomCommand
to = " (To: " + FUtil.getHexStringOfAWTColor(awt2) + ")";
}
else
{
awt2 = java.awt.Color.decode(args[1]);
}
}
catch (NumberFormatException ex)
{
@ -85,7 +89,6 @@ public class Command_nickgradient extends FreedomCommand
plugin.esb.setNickname(sender.getName(), outputNick);
msg("Your nickname is now: '" + outputNick + ChatColor.GRAY + "'" + from + to);
return true;
}
}

View File

@ -21,7 +21,7 @@ public class Command_nicknyan extends FreedomCommand
return false;
}
if ("off".equals(args[0]))
if (args[0].equalsIgnoreCase("off"))
{
plugin.esb.setNickname(sender.getName(), null);
msg("Nickname cleared.");
@ -67,7 +67,6 @@ public class Command_nicknyan extends FreedomCommand
plugin.esb.setNickname(sender.getName(), newNick.toString());
msg("Your nickname is now: " + newNick.toString());
return true;
}
}

View File

@ -46,67 +46,76 @@ public class Command_notes extends FreedomCommand
playerData = plugin.pl.getData(player);
}
if (args[1].equals("list"))
switch (args[1])
{
final StringBuilder noteList = new StringBuilder();
noteList.append(ChatColor.GREEN + "Player notes for " + playerData.getName() + ":");
int id = 1;
for (String note : playerData.getNotes())
case "list":
{
String noteLine = id + ". " + note;
noteList.append("\n" + ChatColor.GOLD + noteLine);
id++;
}
msg(noteList.toString());
return true;
}
else if (args[1].equals("add"))
{
if (args.length < 3)
{
return false;
}
String note = sender.getName() + ": " + StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
playerData.addNote(note);
plugin.pl.save(playerData);
msg("Note added.", ChatColor.GREEN);
return true;
}
else if (args[1].equals("remove"))
{
if (args.length < 3)
{
return false;
}
int id;
try
{
id = Integer.valueOf(args[2]);
}
catch (NumberFormatException e)
{
msg("Invalid number: " + args[2], ChatColor.RED);
final StringBuilder noteList = new StringBuilder();
noteList.append(ChatColor.GREEN + "Player notes for " + playerData.getName() + ":");
int id = 1;
for (String note : playerData.getNotes())
{
String noteLine = id + ". " + note;
noteList.append("\n" + ChatColor.GOLD + noteLine);
id++;
}
msg(noteList.toString());
return true;
}
id--;
if (playerData.removeNote(id))
case "add":
{
if (args.length < 3)
{
return false;
}
String note = sender.getName() + ": " + StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
playerData.addNote(note);
plugin.pl.save(playerData);
msg("Note removed.");
msg("Note added.", ChatColor.GREEN);
return true;
}
else
case "remove":
{
msg("No note with the ID of " + args[2] + " exists.", ChatColor.RED);
if (args.length < 3)
{
return false;
}
int id;
try
{
id = Integer.parseInt(args[2]);
}
catch (NumberFormatException e)
{
msg("Invalid number: " + args[2], ChatColor.RED);
return true;
}
id--;
if (playerData.removeNote(id))
{
plugin.pl.save(playerData);
msg("Note removed.");
}
else
{
msg("No note with the ID of " + args[2] + " exists.", ChatColor.RED);
}
return true;
}
case "clear":
{
int count = playerData.getNotes().size();
playerData.clearNotes();
plugin.pl.save(playerData);
msg("Cleared " + count + " notes.", ChatColor.GREEN);
return true;
}
return true;
}
else if (args[1].equals("clear"))
{
int count = playerData.getNotes().size();
playerData.clearNotes();
plugin.pl.save(playerData);
msg("Cleared " + count + " notes.", ChatColor.GREEN);
return true;
}
return false;
}

View File

@ -36,7 +36,7 @@ public class Command_op extends FreedomCommand
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().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());
player.setOp(true);
@ -49,7 +49,7 @@ public class Command_op extends FreedomCommand
{
if (!silent)
{
FUtil.staffAction(sender.getName(), "Opping " + StringUtils.join(matchedPlayerNames, ", "), false);
FUtil.adminAction(sender.getName(), "Opping " + StringUtils.join(matchedPlayerNames, ", "), false);
}
}
else

View File

@ -14,12 +14,15 @@ public class Command_opall extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FUtil.staffAction(sender.getName(), "Opping all players on the server", false);
FUtil.adminAction(sender.getName(), "Opping all players on the server", false);
for (Player player : server.getOnlinePlayers())
{
player.setOp(true);
player.sendMessage(FreedomCommand.YOU_ARE_OP);
if (!player.isOp())
{
player.setOp(true);
player.sendMessage(FreedomCommand.YOU_ARE_OP);
}
}
return true;

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