mirror of
https://github.com/TotalFreedomMC/TotalFreedomMod.git
synced 2024-05-17 10:01:25 +00:00
Merge branch '1.17' of https://github.com/AtlasMediaGroup/TotalFreedomMod into 1.18
This commit is contained in:
commit
18e58efaff
|
@ -1,137 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import com.mattmalec.pterodactyl4j.Permission;
|
||||
import com.mattmalec.pterodactyl4j.PowerAction;
|
||||
import com.mattmalec.pterodactyl4j.PteroAction;
|
||||
import com.mattmalec.pterodactyl4j.PteroBuilder;
|
||||
import com.mattmalec.pterodactyl4j.application.entities.ApplicationUser;
|
||||
import com.mattmalec.pterodactyl4j.application.entities.PteroApplication;
|
||||
import com.mattmalec.pterodactyl4j.application.managers.UserAction;
|
||||
import com.mattmalec.pterodactyl4j.client.entities.ClientServer;
|
||||
import com.mattmalec.pterodactyl4j.client.entities.ClientSubuser;
|
||||
import com.mattmalec.pterodactyl4j.client.entities.PteroClient;
|
||||
import joptsimple.internal.Strings;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
|
||||
public class Pterodactyl extends FreedomService
|
||||
{
|
||||
public final String URL = ConfigEntry.PTERO_URL.getString();
|
||||
private final String ADMIN_KEY = ConfigEntry.PTERO_ADMIN_KEY.getString();
|
||||
private final String CLIENT_KEY = ConfigEntry.PTERO_SERVER_KEY.getString();
|
||||
private final String IDENTIFIER = ConfigEntry.PTERO_SERVER_UUID.getString();
|
||||
PteroApplication adminAPI = PteroBuilder.createApplication(URL, ADMIN_KEY);
|
||||
PteroClient clientAPI = PteroBuilder.createClient(URL, CLIENT_KEY);
|
||||
|
||||
private boolean enabled = !Strings.isNullOrEmpty(URL);
|
||||
|
||||
public void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public void updateAccountStatus(Admin admin)
|
||||
{
|
||||
String id = admin.getPteroID();
|
||||
|
||||
if (Strings.isNullOrEmpty(id) || !enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!admin.isActive() || admin.getRank() != Rank.SENIOR_ADMIN)
|
||||
{
|
||||
FLog.debug("Disabling Pterodactyl account");
|
||||
removeAccountFromServer(id);
|
||||
return;
|
||||
}
|
||||
|
||||
FLog.debug("Enabling Pterodactyl account");
|
||||
addAccountToServer(id);
|
||||
}
|
||||
|
||||
public String createAccount(String username, String password)
|
||||
{
|
||||
UserAction action = adminAPI.getUserManager().createUser()
|
||||
.setUserName(username)
|
||||
.setEmail(username.toLowerCase() + "@" + ConfigEntry.PTERO_DEFAULT_EMAIL_DOMAIN.getString())
|
||||
.setFirstName(username)
|
||||
.setLastName("\u200E") // Required - make it appear empty
|
||||
.setPassword(password);
|
||||
|
||||
return action.execute().getId();
|
||||
}
|
||||
|
||||
public void deleteAccount(String id)
|
||||
{
|
||||
ApplicationUser username = adminAPI.retrieveUserById(id).execute();
|
||||
PteroAction<Void> action = adminAPI.getUserManager().deleteUser(username);
|
||||
action.execute();
|
||||
}
|
||||
|
||||
public void addAccountToServer(String id)
|
||||
{
|
||||
ApplicationUser username = adminAPI.retrieveUserById(id).execute();
|
||||
String email = username.getEmail();
|
||||
PteroAction<ClientServer> server = clientAPI.retrieveServerByIdentifier(IDENTIFIER);
|
||||
server.execute().getSubuserManager().createUser()
|
||||
.setEmail(email)
|
||||
.setPermissions(Permission.CONTROL_PERMISSIONS).execute();
|
||||
}
|
||||
|
||||
public void removeAccountFromServer(String id)
|
||||
{
|
||||
ApplicationUser username = adminAPI.retrieveUserById(id).execute();
|
||||
PteroAction<ClientServer> server = clientAPI.retrieveServerByIdentifier(IDENTIFIER);
|
||||
ClientSubuser clientSubuser = server.execute().getSubuser(username.getUUID()).retrieve().execute();
|
||||
server.execute().getSubuserManager().deleteUser(clientSubuser).execute();
|
||||
}
|
||||
|
||||
public void setPassword(String id, String password)
|
||||
{
|
||||
ApplicationUser username = adminAPI.retrieveUserById(id).execute();
|
||||
UserAction action = adminAPI.getUserManager().editUser(username).setPassword(password);
|
||||
action.execute();
|
||||
}
|
||||
|
||||
public void restartServer()
|
||||
{
|
||||
clientAPI.retrieveServerByIdentifier(IDENTIFIER).flatMap(ClientServer::restart).execute();
|
||||
}
|
||||
|
||||
public void fionnTheServer()
|
||||
{
|
||||
clientAPI.retrieveServerByIdentifier(IDENTIFIER).flatMap(ClientServer::stop).execute();
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> clientAPI.retrieveServerByIdentifier(IDENTIFIER).flatMap(ClientServer::kill).execute(), 0, 60);
|
||||
}
|
||||
|
||||
public String getURL()
|
||||
{
|
||||
return URL;
|
||||
}
|
||||
|
||||
public String getServerKey()
|
||||
{
|
||||
return CLIENT_KEY;
|
||||
}
|
||||
|
||||
public String getAdminKey()
|
||||
{
|
||||
return ADMIN_KEY;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
|
||||
|
||||
public class SavedFlags extends FreedomService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Boolean> getSavedFlags()
|
||||
{
|
||||
Map<String, Boolean> flags = null;
|
||||
File input = new File(TotalFreedomMod.getPlugin().getDataFolder(), SAVED_FLAGS_FILENAME);
|
||||
|
||||
if (input.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
try (FileInputStream fis = new FileInputStream(input); ObjectInputStream ois = new ObjectInputStream(fis))
|
||||
{
|
||||
flags = (HashMap<String, Boolean>)ois.readObject();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
public boolean getSavedFlag(String flag) throws Exception
|
||||
{
|
||||
Boolean flagValue = null;
|
||||
|
||||
Map<String, Boolean> flags = getSavedFlags();
|
||||
|
||||
if (flags != null)
|
||||
{
|
||||
if (flags.containsKey(flag))
|
||||
{
|
||||
flagValue = flags.get(flag);
|
||||
}
|
||||
}
|
||||
|
||||
if (flagValue != null)
|
||||
{
|
||||
return flagValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSavedFlag(String flag, boolean value)
|
||||
{
|
||||
Map<String, Boolean> flags = getSavedFlags();
|
||||
|
||||
if (flags == null)
|
||||
{
|
||||
flags = new HashMap<>();
|
||||
}
|
||||
|
||||
flags.put(flag, value);
|
||||
|
||||
try
|
||||
{
|
||||
final FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), SAVED_FLAGS_FILENAME));
|
||||
final ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||
oos.writeObject(flags);
|
||||
oos.close();
|
||||
fos.close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public class ServerInterface extends FreedomService
|
||||
{
|
||||
public static final String COMPILE_NMS_VERSION = "v1_17_R1";
|
||||
|
||||
public static void warnVersion()
|
||||
{
|
||||
final String nms = FUtil.getNMSVersion();
|
||||
|
||||
if (!COMPILE_NMS_VERSION.equals(nms))
|
||||
{
|
||||
FLog.warning(TotalFreedomMod.pluginName + " is compiled for " + COMPILE_NMS_VERSION + " but the server is running version " + nms + "!");
|
||||
FLog.warning("This might result in unexpected behaviour!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public int purgeWhitelist()
|
||||
{
|
||||
Set<OfflinePlayer> whitelisted = Bukkit.getWhitelistedPlayers();
|
||||
int size = whitelisted.size();
|
||||
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers())
|
||||
{
|
||||
Bukkit.getServer().getWhitelistedPlayers().remove(player);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Bukkit.reloadWhitelist();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.warning("Could not purge the whitelist!");
|
||||
FLog.warning(ex);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
public boolean isWhitelisted()
|
||||
{
|
||||
return Bukkit.getServer().hasWhitelist();
|
||||
}
|
||||
|
||||
public List<?> getWhitelisted()
|
||||
{
|
||||
return Collections.singletonList(Bukkit.getWhitelistedPlayers());
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return Bukkit.getVersion();
|
||||
}
|
||||
}
|
|
@ -1,12 +1,18 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||
import me.totalfreedom.totalfreedommod.admin.module.CommandSpy;
|
||||
import me.totalfreedom.totalfreedommod.admin.module.Fuckoff;
|
||||
import me.totalfreedom.totalfreedommod.admin.module.Muter;
|
||||
import me.totalfreedom.totalfreedommod.admin.module.Orbiter;
|
||||
import me.totalfreedom.totalfreedommod.anticheat.AutoEject;
|
||||
import me.totalfreedom.totalfreedommod.punishments.banning.BanManager;
|
||||
import me.totalfreedom.totalfreedommod.punishments.banning.IndefiniteBanList;
|
||||
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||
|
@ -23,39 +29,43 @@ import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
|
|||
import me.totalfreedom.totalfreedommod.bridge.TFGuildsBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
|
||||
import me.totalfreedom.totalfreedommod.caging.Cager;
|
||||
import me.totalfreedom.totalfreedommod.punishments.caging.Cager;
|
||||
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
||||
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
||||
import me.totalfreedom.totalfreedommod.punishments.freeze.Freezer;
|
||||
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
||||
import me.totalfreedom.totalfreedommod.fun.MP44;
|
||||
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
||||
import me.totalfreedom.totalfreedommod.anticheat.AntiNuke;
|
||||
import me.totalfreedom.totalfreedommod.anticheat.AntiSpam;
|
||||
import me.totalfreedom.totalfreedommod.anticheat.AutoKick;
|
||||
import me.totalfreedom.totalfreedommod.player.permissions.PermissionConfig;
|
||||
import me.totalfreedom.totalfreedommod.player.permissions.PermissionManager;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||
import me.totalfreedom.totalfreedommod.services.ServiceHandler;
|
||||
import me.totalfreedom.totalfreedommod.services.impl.*;
|
||||
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||
import me.totalfreedom.totalfreedommod.shop.Votifier;
|
||||
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
|
||||
import me.totalfreedom.totalfreedommod.world.generator.CleanroomChunkGenerator;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spigotmc.SpigotCommand;
|
||||
import org.spigotmc.SpigotConfig;
|
||||
|
||||
public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
|
@ -66,76 +76,80 @@ public class TotalFreedomMod extends JavaPlugin
|
|||
public static String pluginName;
|
||||
public static String pluginVersion;
|
||||
private static TotalFreedomMod plugin;
|
||||
|
||||
private File spigotFile;
|
||||
private YamlConfiguration spigotConfig;
|
||||
|
||||
//
|
||||
public MainConfig config;
|
||||
public PermissionConfig permissions;
|
||||
//
|
||||
// Service Handler
|
||||
public FreedomServiceHandler fsh;
|
||||
public ServiceHandler serviceHandler;
|
||||
// Command Loader
|
||||
public CommandLoader cl;
|
||||
public CommandLoader commandLoader;
|
||||
// Services
|
||||
public ServerInterface si;
|
||||
public SavedFlags sf;
|
||||
public WorldManager wm;
|
||||
public LogViewer lv;
|
||||
public AdminList al;
|
||||
public ActivityLog acl;
|
||||
public RankManager rm;
|
||||
public CommandBlocker cb;
|
||||
public EventBlocker eb;
|
||||
public BlockBlocker bb;
|
||||
public MobBlocker mb;
|
||||
public InteractBlocker ib;
|
||||
public PotionBlocker pb;
|
||||
public LoginProcess lp;
|
||||
public AntiNuke nu;
|
||||
public AntiSpam as;
|
||||
public PlayerList pl;
|
||||
public Shop sh;
|
||||
public Votifier vo;
|
||||
public ServerInterface serverInterface;
|
||||
public WorldManager worldManager;
|
||||
public LogViewer logViewer;
|
||||
public AdminList adminList;
|
||||
public ActivityLog activityLog;
|
||||
public RankManager rankManager;
|
||||
public CommandBlocker commandBlocker;
|
||||
public EventBlocker eventBlocker;
|
||||
public BlockBlocker blockBlocker;
|
||||
public MobBlocker mobBlocker;
|
||||
public InteractBlocker interactBlocker;
|
||||
public PotionBlocker potionBlocker;
|
||||
public LoginProcess loginProcess;
|
||||
public AntiNuke antiNuke;
|
||||
public AntiSpam antiSpam;
|
||||
public PlayerList playerList;
|
||||
public Shop shop;
|
||||
public Votifier votifier;
|
||||
public SQLite sql;
|
||||
public Announcer an;
|
||||
public ChatManager cm;
|
||||
public Discord dc;
|
||||
public PunishmentList pul;
|
||||
public BanManager bm;
|
||||
public IndefiniteBanList im;
|
||||
public PermissionManager pem;
|
||||
public GameRuleHandler gr;
|
||||
public CommandSpy cs;
|
||||
public Cager ca;
|
||||
public Freezer fm;
|
||||
public EditBlocker ebl;
|
||||
public PVPBlocker pbl;
|
||||
public Orbiter or;
|
||||
public Muter mu;
|
||||
public Fuckoff fo;
|
||||
public AutoKick ak;
|
||||
public AutoEject ae;
|
||||
public Monitors mo;
|
||||
public MovementValidator mv;
|
||||
public ServerPing sp;
|
||||
public ItemFun it;
|
||||
public Landminer lm;
|
||||
public MP44 mp;
|
||||
public Jumppads jp;
|
||||
public Trailer tr;
|
||||
public HTTPDaemon hd;
|
||||
public WorldRestrictions wr;
|
||||
public SignBlocker snp;
|
||||
public EntityWiper ew;
|
||||
public VanishHandler vh;
|
||||
public Pterodactyl ptero;
|
||||
public Announcer announcer;
|
||||
public ChatHandler chatManager;
|
||||
public Discord discord;
|
||||
public PunishmentList punishmentList;
|
||||
public BanManager banManager;
|
||||
public IndefiniteBanList indefiniteBanList;
|
||||
public PermissionManager permissionManager;
|
||||
public GameRuleHandler gameRuleHandler;
|
||||
public CommandSpy commandSpy;
|
||||
public Cager cager;
|
||||
public Freezer freezer;
|
||||
public EditBlocker editBlocker;
|
||||
public PVPBlocker pvpBlocker;
|
||||
public Orbiter orbiter;
|
||||
public Muter muter;
|
||||
public Fuckoff fuckoff;
|
||||
public AutoKick autoKick;
|
||||
public AutoEject autoEject;
|
||||
public Monitors monitors;
|
||||
public MovementValidator movementValidator;
|
||||
public ServerPing serverPing;
|
||||
public ItemFun itemFun;
|
||||
public Landminer landMiner;
|
||||
public MP44 mp44;
|
||||
public Jumppads jumpPads;
|
||||
public Trailer trailer;
|
||||
public HTTPDaemon httpDaemon;
|
||||
public WorldRestrictions worldRestrictions;
|
||||
public SignBlocker signBlocker;
|
||||
public EntityWiper entityWiper;
|
||||
public Sitter sitter;
|
||||
public VanishHandler vanishHandler;
|
||||
public Pterodactyl pterodactyl;
|
||||
//
|
||||
// Bridges
|
||||
public BukkitTelnetBridge btb;
|
||||
public EssentialsBridge esb;
|
||||
public LibsDisguisesBridge ldb;
|
||||
public CoreProtectBridge cpb;
|
||||
public TFGuildsBridge tfg;
|
||||
public WorldEditBridge web;
|
||||
public WorldGuardBridge wgb;
|
||||
public BukkitTelnetBridge bukkitTelnetBridge;
|
||||
public EssentialsBridge essentialsBridge;
|
||||
public LibsDisguisesBridge libsDisguisesBridge;
|
||||
public CoreProtectBridge coreProtectBridge;
|
||||
public TFGuildsBridge tfGuildsBridge;
|
||||
public WorldEditBridge worldEditBridge;
|
||||
public WorldGuardBridge worldGuardBridge;
|
||||
|
||||
public static TotalFreedomMod getPlugin()
|
||||
{
|
||||
|
@ -178,13 +192,13 @@ public class TotalFreedomMod extends JavaPlugin
|
|||
timer.start();
|
||||
|
||||
// Warn if we're running on a wrong version
|
||||
ServerInterface.warnVersion();
|
||||
//ServerInterface.warnVersion();no more nms
|
||||
|
||||
// Delete unused files
|
||||
FUtil.deleteCoreDumps();
|
||||
FUtil.deleteFolder(new File("./_deleteme"));
|
||||
|
||||
fsh = new FreedomServiceHandler();
|
||||
serviceHandler = new ServiceHandler();
|
||||
|
||||
config = new MainConfig();
|
||||
config.load();
|
||||
|
@ -194,39 +208,53 @@ public class TotalFreedomMod extends JavaPlugin
|
|||
FLog.debug("Developer mode enabled.");
|
||||
}
|
||||
|
||||
cl = new CommandLoader();
|
||||
cl.loadCommands();
|
||||
commandLoader = new CommandLoader();
|
||||
commandLoader.loadCommands();
|
||||
|
||||
BackupManager backups = new BackupManager();
|
||||
BackupHandler backups = new BackupHandler();
|
||||
backups.createAllBackups();
|
||||
|
||||
permissions = new PermissionConfig();
|
||||
permissions.load();
|
||||
|
||||
mv = new MovementValidator();
|
||||
sp = new ServerPing();
|
||||
movementValidator = new MovementValidator();
|
||||
serverPing = new ServerPing();
|
||||
|
||||
new Initializer();
|
||||
|
||||
fsh.startServices();
|
||||
serviceHandler.startServices();
|
||||
|
||||
FLog.info("Started " + fsh.getServiceAmount() + " services.");
|
||||
FLog.info("Started " + serviceHandler.getServiceAmount() + " services.");
|
||||
|
||||
timer.update();
|
||||
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
||||
FLog.info("Version " + pluginVersion + " for " + getServer().getBukkitVersion() + " enabled in " + timer.getTotal() + "ms");
|
||||
|
||||
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod/2966
|
||||
new Metrics(this, 2966);
|
||||
|
||||
// Revert AMP changes
|
||||
SpigotConfig.config.set("settings.restart-on-crash", true);
|
||||
// little workaround to stop spigot from autorestarting - causing AMP to detach from process.
|
||||
//SpigotConfig.config.set("settings.restart-on-crash", false);
|
||||
|
||||
|
||||
this.spigotFile = new File(getServer().getWorldContainer(), "spigot.yml");
|
||||
this.spigotConfig = YamlConfiguration.loadConfiguration(this.spigotFile);
|
||||
|
||||
this.spigotConfig.set("settings.restart-on-crash", false);
|
||||
try {
|
||||
this.spigotConfig.save(this.spigotFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Possibly could make it so after reloads, players regain their tag
|
||||
Bukkit.getOnlinePlayers().forEach(player -> this.rankManager.updateDisplay(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
// Stop services and bridges
|
||||
fsh.stopServices();
|
||||
serviceHandler.stopServices();
|
||||
|
||||
getServer().getScheduler().cancelTasks(plugin);
|
||||
|
||||
|
@ -266,7 +294,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||
number = props.getProperty("buildNumber", "1");
|
||||
date = props.getProperty("buildDate", "unknown");
|
||||
// Need to do this or it will display ${git.commit.id.abbrev}
|
||||
head = props.getProperty("buildHead", "unknown");
|
||||
head = props.getProperty("buildHead", "unknown").replace("${git.commit.id.abbrev}", "unknown");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -298,83 +326,100 @@ public class TotalFreedomMod extends JavaPlugin
|
|||
private void initServices()
|
||||
{
|
||||
// Start services
|
||||
si = new ServerInterface();
|
||||
sf = new SavedFlags();
|
||||
wm = new WorldManager();
|
||||
lv = new LogViewer();
|
||||
serverInterface = new ServerInterface();
|
||||
gameRuleHandler = new GameRuleHandler();
|
||||
worldManager = new WorldManager();
|
||||
logViewer = new LogViewer();
|
||||
sql = new SQLite();
|
||||
al = new AdminList();
|
||||
acl = new ActivityLog();
|
||||
rm = new RankManager();
|
||||
cb = new CommandBlocker();
|
||||
eb = new EventBlocker();
|
||||
bb = new BlockBlocker();
|
||||
mb = new MobBlocker();
|
||||
ib = new InteractBlocker();
|
||||
pb = new PotionBlocker();
|
||||
lp = new LoginProcess();
|
||||
nu = new AntiNuke();
|
||||
as = new AntiSpam();
|
||||
wr = new WorldRestrictions();
|
||||
pl = new PlayerList();
|
||||
sh = new Shop();
|
||||
vo = new Votifier();
|
||||
an = new Announcer();
|
||||
cm = new ChatManager();
|
||||
dc = new Discord();
|
||||
pul = new PunishmentList();
|
||||
bm = new BanManager();
|
||||
im = new IndefiniteBanList();
|
||||
pem = new PermissionManager();
|
||||
gr = new GameRuleHandler();
|
||||
snp = new SignBlocker();
|
||||
ew = new EntityWiper();
|
||||
vh = new VanishHandler();
|
||||
ptero = new Pterodactyl();
|
||||
adminList = new AdminList();
|
||||
activityLog = new ActivityLog();
|
||||
rankManager = new RankManager();
|
||||
commandBlocker = new CommandBlocker();
|
||||
eventBlocker = new EventBlocker();
|
||||
blockBlocker = new BlockBlocker();
|
||||
mobBlocker = new MobBlocker();
|
||||
interactBlocker = new InteractBlocker();
|
||||
potionBlocker = new PotionBlocker();
|
||||
loginProcess = new LoginProcess();
|
||||
antiNuke = new AntiNuke();
|
||||
antiSpam = new AntiSpam();
|
||||
playerList = new PlayerList();
|
||||
shop = new Shop();
|
||||
votifier = new Votifier();
|
||||
announcer = new Announcer();
|
||||
chatManager = new ChatHandler();
|
||||
discord = new Discord();
|
||||
punishmentList = new PunishmentList();
|
||||
banManager = new BanManager();
|
||||
indefiniteBanList = new IndefiniteBanList();
|
||||
permissionManager = new PermissionManager();
|
||||
signBlocker = new SignBlocker();
|
||||
entityWiper = new EntityWiper();
|
||||
sitter = new Sitter();
|
||||
vanishHandler = new VanishHandler();
|
||||
pterodactyl = new Pterodactyl();
|
||||
|
||||
if (isPluginPresent("WorldGuard"))
|
||||
worldRestrictions = new WorldRestrictions();
|
||||
}
|
||||
|
||||
private void initAdminUtils()
|
||||
{
|
||||
// Single admin utils
|
||||
cs = new CommandSpy();
|
||||
ca = new Cager();
|
||||
fm = new Freezer();
|
||||
or = new Orbiter();
|
||||
mu = new Muter();
|
||||
ebl = new EditBlocker();
|
||||
pbl = new PVPBlocker();
|
||||
fo = new Fuckoff();
|
||||
ak = new AutoKick();
|
||||
ae = new AutoEject();
|
||||
mo = new Monitors();
|
||||
commandSpy = new CommandSpy();
|
||||
cager = new Cager();
|
||||
freezer = new Freezer();
|
||||
orbiter = new Orbiter();
|
||||
muter = new Muter();
|
||||
editBlocker = new EditBlocker();
|
||||
pvpBlocker = new PVPBlocker();
|
||||
fuckoff = new Fuckoff();
|
||||
autoKick = new AutoKick();
|
||||
autoEject = new AutoEject();
|
||||
monitors = new Monitors();
|
||||
}
|
||||
|
||||
private void initBridges()
|
||||
{
|
||||
// Start bridges
|
||||
btb = new BukkitTelnetBridge();
|
||||
cpb = new CoreProtectBridge();
|
||||
esb = new EssentialsBridge();
|
||||
ldb = new LibsDisguisesBridge();
|
||||
tfg = new TFGuildsBridge();
|
||||
web = new WorldEditBridge();
|
||||
wgb = new WorldGuardBridge();
|
||||
if (isPluginPresent("BukkitTelnet"))
|
||||
bukkitTelnetBridge = new BukkitTelnetBridge();
|
||||
if (isPluginPresent("CoreProtect"))
|
||||
coreProtectBridge = new CoreProtectBridge();
|
||||
if (isPluginPresent("WorldGuard"))
|
||||
worldGuardBridge = new WorldGuardBridge();
|
||||
if (isPluginPresent("WorldEdit"))
|
||||
worldEditBridge = new WorldEditBridge();
|
||||
|
||||
essentialsBridge = new EssentialsBridge();
|
||||
libsDisguisesBridge = new LibsDisguisesBridge();
|
||||
tfGuildsBridge = new TFGuildsBridge();
|
||||
|
||||
}
|
||||
|
||||
private void initFun()
|
||||
{
|
||||
// Fun
|
||||
it = new ItemFun();
|
||||
lm = new Landminer();
|
||||
mp = new MP44();
|
||||
jp = new Jumppads();
|
||||
tr = new Trailer();
|
||||
itemFun = new ItemFun();
|
||||
landMiner = new Landminer();
|
||||
mp44 = new MP44();
|
||||
jumpPads = new Jumppads();
|
||||
trailer = new Trailer();
|
||||
}
|
||||
|
||||
private void initHTTPD()
|
||||
{
|
||||
// HTTPD
|
||||
hd = new HTTPDaemon();
|
||||
httpDaemon = new HTTPDaemon();
|
||||
}
|
||||
|
||||
private boolean isPluginPresent(String plugin)
|
||||
{
|
||||
return TotalFreedomMod.getPlugin().getServer().getPluginManager().isPluginEnabled(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
public YamlConfiguration getSpigotConfig() {
|
||||
return spigotConfig;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,13 @@
|
|||
package me.totalfreedom.totalfreedommod.admin;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
|
@ -14,7 +19,7 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class ActivityLog extends FreedomService
|
||||
public class ActivityLog extends AbstractService
|
||||
{
|
||||
|
||||
public static final String FILENAME = "activitylog.yml";
|
||||
|
@ -170,23 +175,26 @@ public class ActivityLog extends FreedomService
|
|||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.al.isAdmin(player))
|
||||
if (plugin.adminList.isAdmin(player))
|
||||
{
|
||||
getActivityLog(event.getPlayer()).addLogin();
|
||||
plugin.acl.save();
|
||||
plugin.acl.updateTables();
|
||||
plugin.activityLog.save();
|
||||
plugin.activityLog.updateTables();
|
||||
}
|
||||
|
||||
FPlayer fPlayer = plugin.playerList.getPlayer(player);
|
||||
fPlayer.setCurrentSessionStart(new Date());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.al.isAdmin(player))
|
||||
if (plugin.adminList.isAdmin(player))
|
||||
{
|
||||
getActivityLog(event.getPlayer()).addLogout();
|
||||
plugin.acl.save();
|
||||
plugin.acl.updateTables();
|
||||
plugin.activityLog.save();
|
||||
plugin.activityLog.updateTables();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,10 @@ import com.google.common.collect.Lists;
|
|||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
@ -14,15 +17,20 @@ public class ActivityLogEntry implements IConfig
|
|||
{
|
||||
|
||||
public static final String FILENAME = "activitylog.yml";
|
||||
|
||||
private final List<String> ips = Lists.newArrayList();
|
||||
private final List<String> timestamps = Lists.newArrayList();
|
||||
private final List<String> durations = Lists.newArrayList();
|
||||
|
||||
private Player player;
|
||||
private String configKey;
|
||||
private String name;
|
||||
|
||||
public ActivityLogEntry(Player player)
|
||||
{
|
||||
this.configKey = player.getName().toLowerCase();
|
||||
this(player.getName().toLowerCase());
|
||||
|
||||
this.player = player;
|
||||
this.name = player.getName();
|
||||
}
|
||||
|
||||
|
@ -73,15 +81,22 @@ public class ActivityLogEntry implements IConfig
|
|||
public void addLogout()
|
||||
{
|
||||
// Fix of Array index out of bonds issue: FS-131
|
||||
String lastLoginString;
|
||||
if (timestamps.size() > 1)
|
||||
String lastLoginString = null;
|
||||
|
||||
if(timestamps.size() > 1)
|
||||
{
|
||||
lastLoginString = timestamps.get(timestamps.size() - 1);
|
||||
}
|
||||
else
|
||||
else if (!timestamps.isEmpty())
|
||||
{
|
||||
lastLoginString = timestamps.get(0);
|
||||
}
|
||||
if (lastLoginString == null)
|
||||
{
|
||||
FPlayer fPlayer = TotalFreedomMod.getPlugin().playerList.getPlayer(this.player);
|
||||
lastLoginString = "Login: " + FUtil.dateToString(fPlayer.getCurrentSessionStart());
|
||||
}
|
||||
|
||||
Date currentTime = Date.from(Instant.now());
|
||||
timestamps.add("Logout: " + FUtil.dateToString(currentTime));
|
||||
lastLoginString = lastLoginString.replace("Login: ", "");
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||
import me.totalfreedom.totalfreedommod.services.impl.LogViewer.LogsRegistrationMode;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
|
@ -158,13 +158,13 @@ public class Admin
|
|||
{
|
||||
if (getRank().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
if (plugin.btb != null)
|
||||
if (plugin.bukkitTelnetBridge != null)
|
||||
{
|
||||
plugin.btb.killTelnetSessions(getName());
|
||||
plugin.bukkitTelnetBridge.killTelnetSessions(getName());
|
||||
}
|
||||
}
|
||||
|
||||
plugin.lv.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE);
|
||||
plugin.logViewer.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
|
@ -19,7 +19,7 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AdminList extends FreedomService
|
||||
public class AdminList extends AbstractService
|
||||
{
|
||||
public static final List<String> vanished = new ArrayList<>();
|
||||
public final Map<String, List<String>> verifiedNoAdmin = Maps.newHashMap();
|
||||
|
@ -275,9 +275,9 @@ public class AdminList extends FreedomService
|
|||
{
|
||||
if (admin.getRank().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
if (plugin.btb != null)
|
||||
if (plugin.bukkitTelnetBridge != null)
|
||||
{
|
||||
plugin.btb.killTelnetSessions(admin.getName());
|
||||
plugin.bukkitTelnetBridge.killTelnetSessions(admin.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
package me.totalfreedom.totalfreedommod.admin.module;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
public class CommandSpy extends FreedomService
|
||||
public class CommandSpy extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -23,7 +24,7 @@ public class CommandSpy extends FreedomService
|
|||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
|
||||
if (plugin.adminList.isAdmin(player) && plugin.adminList.getAdmin(player).getCommandSpy())
|
||||
{
|
||||
if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
|
||||
{
|
|
@ -1,5 +1,6 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
package me.totalfreedom.totalfreedommod.admin.module;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -7,7 +8,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class Fuckoff extends FreedomService
|
||||
public class Fuckoff extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -25,7 +26,7 @@ public class Fuckoff extends FreedomService
|
|||
final Player fuckoffPlayer = event.getPlayer();
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(onlinePlayer);
|
||||
final FPlayer fPlayer = plugin.playerList.getPlayer(onlinePlayer);
|
||||
if (!fPlayer.isFuckOff()
|
||||
|| fuckoffPlayer.equals(onlinePlayer))
|
||||
{
|
|
@ -1,7 +1,9 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
package me.totalfreedom.totalfreedommod.admin.module;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
|
@ -15,7 +17,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class Muter extends FreedomService
|
||||
public class Muter extends AbstractService
|
||||
{
|
||||
|
||||
public final List<String> MUTED_PLAYERS = new ArrayList<>();
|
||||
|
@ -35,14 +37,14 @@ public class Muter extends FreedomService
|
|||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||
FPlayer fPlayer = plugin.playerList.getPlayerSync(player);
|
||||
|
||||
if (!fPlayer.isMuted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdminSync(player))
|
||||
if (plugin.adminList.isAdminSync(player))
|
||||
{
|
||||
fPlayer.setMuted(false);
|
||||
MUTED_PLAYERS.remove(player.getName());
|
||||
|
@ -58,7 +60,7 @@ public class Muter extends FreedomService
|
|||
{
|
||||
|
||||
Player player = event.getPlayer();
|
||||
FPlayer fPlayer = plugin.pl.getPlayer(event.getPlayer());
|
||||
FPlayer fPlayer = plugin.playerList.getPlayer(event.getPlayer());
|
||||
|
||||
// Block commands if player is muted
|
||||
if (!fPlayer.isMuted())
|
||||
|
@ -67,7 +69,7 @@ public class Muter extends FreedomService
|
|||
}
|
||||
|
||||
String message = event.getMessage();
|
||||
if (plugin.al.isAdmin(player))
|
||||
if (plugin.adminList.isAdmin(player))
|
||||
{
|
||||
fPlayer.setMuted(false);
|
||||
return;
|
||||
|
@ -103,7 +105,7 @@ public class Muter extends FreedomService
|
|||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
FPlayer playerdata = plugin.playerList.getPlayer(player);
|
||||
|
||||
if (MUTED_PLAYERS.contains(player.getName()))
|
||||
{
|
|
@ -1,5 +1,6 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
package me.totalfreedom.totalfreedommod.admin.module;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -7,7 +8,7 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Orbiter extends FreedomService
|
||||
public class Orbiter extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -24,7 +25,7 @@ public class Orbiter extends FreedomService
|
|||
{
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
final FPlayer fPlayer = plugin.playerList.getPlayer(player);
|
||||
|
||||
if (!fPlayer.isOrbiting())
|
||||
{
|
|
@ -1,5 +1,6 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
package me.totalfreedom.totalfreedommod.anticheat;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
|
@ -10,7 +11,7 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class AntiNuke extends FreedomService
|
||||
public class AntiNuke extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -31,7 +32,7 @@ public class AntiNuke extends FreedomService
|
|||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
final FPlayer fPlayer = plugin.playerList.getPlayer(player);
|
||||
|
||||
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
||||
{
|
||||
|
@ -54,7 +55,7 @@ public class AntiNuke extends FreedomService
|
|||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
FPlayer fPlayer = plugin.playerList.getPlayer(player);
|
||||
|
||||
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
||||
{
|
|
@ -1,7 +1,6 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
package me.totalfreedom.totalfreedommod.anticheat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||
|
@ -15,14 +14,17 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class AntiSpam extends FreedomService
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AntiSpam extends AbstractService
|
||||
{
|
||||
|
||||
public static final int MSG_PER_CYCLE = 8;
|
||||
public static final int TICKS_PER_CYCLE = 2 * 10;
|
||||
//
|
||||
public BukkitTask cycleTask = null;
|
||||
private final Map<Player, Integer> muteCounts = new HashMap<>();
|
||||
private Map<Player, Integer> muteCounts = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -48,7 +50,7 @@ public class AntiSpam extends FreedomService
|
|||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
final FPlayer playerdata = plugin.playerList.getPlayer(player);
|
||||
|
||||
// TODO: Move each to their own section
|
||||
playerdata.resetMsgCount();
|
||||
|
@ -62,12 +64,12 @@ public class AntiSpam extends FreedomService
|
|||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
if (plugin.adminList.isAdmin(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
||||
final FPlayer playerdata = plugin.playerList.getPlayerSync(player);
|
||||
int count = muteCounts.getOrDefault(player, 0);
|
||||
int minutes = ConfigEntry.ANTISPAM_MINUTES.getInteger();
|
||||
|
||||
|
@ -81,8 +83,8 @@ public class AntiSpam extends FreedomService
|
|||
playerdata.setMuted(true, time);
|
||||
|
||||
FSync.bcastMsg(String.format("%s has automatically been muted for %d minutes for spamming chat.",
|
||||
player.getName(),
|
||||
time),
|
||||
player.getName(),
|
||||
time),
|
||||
ChatColor.RED);
|
||||
|
||||
playerdata.resetMsgCount();
|
||||
|
@ -101,7 +103,7 @@ public class AntiSpam extends FreedomService
|
|||
{
|
||||
String command = event.getMessage();
|
||||
final Player player = event.getPlayer();
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
final FPlayer fPlayer = plugin.playerList.getPlayer(player);
|
||||
fPlayer.setLastCommand(command);
|
||||
|
||||
if (fPlayer.allCommandsBlocked())
|
||||
|
@ -111,7 +113,7 @@ public class AntiSpam extends FreedomService
|
|||
return;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
if (plugin.adminList.isAdmin(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -119,7 +121,7 @@ public class AntiSpam extends FreedomService
|
|||
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||
{
|
||||
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
||||
plugin.ae.autoEject(player, "Kicked for spamming commands.");
|
||||
plugin.autoEject.autoEject(player, "Kicked for spamming commands.");
|
||||
|
||||
fPlayer.resetMsgCount();
|
||||
event.setCancelled(true);
|
|
@ -1,11 +1,13 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
package me.totalfreedom.totalfreedommod.anticheat;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.punishments.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -13,7 +15,7 @@ import org.bukkit.ChatColor;
|
|||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AutoEject extends FreedomService
|
||||
public class AutoEject extends AbstractService
|
||||
{
|
||||
|
||||
private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount
|
||||
|
@ -68,7 +70,7 @@ public class AutoEject extends FreedomService
|
|||
|
||||
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 5 minutes.");
|
||||
|
||||
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
|
||||
plugin.banManager.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
|
||||
player.kickPlayer(kickMessage);
|
||||
|
||||
break;
|
||||
|
@ -81,13 +83,13 @@ public class AutoEject extends FreedomService
|
|||
|
||||
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 10 minutes.");
|
||||
|
||||
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
|
||||
plugin.banManager.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
|
||||
player.kickPlayer(kickMessage);
|
||||
break;
|
||||
}
|
||||
case STRIKE_THREE:
|
||||
{
|
||||
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
|
||||
plugin.banManager.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
|
||||
|
||||
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
package me.totalfreedom.totalfreedommod;
|
||||
package me.totalfreedom.totalfreedommod.anticheat;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class AutoKick extends FreedomService
|
||||
public class AutoKick extends AbstractService
|
||||
{
|
||||
|
||||
public static final long AUTOKICK_RATE = 10 * 20L;
|
||||
|
@ -48,7 +49,7 @@ public class AutoKick extends FreedomService
|
|||
{
|
||||
// No type cast was provided, one has been supplied.
|
||||
final boolean doAwayKickCheck
|
||||
= plugin.esb.isEnabled()
|
||||
= plugin.essentialsBridge.isEnabled()
|
||||
&& (((float)server.getOnlinePlayers().size() / (float)server.getMaxPlayers()) > autoKickThreshold);
|
||||
|
||||
if (!doAwayKickCheck)
|
||||
|
@ -58,7 +59,7 @@ public class AutoKick extends FreedomService
|
|||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final long lastActivity = plugin.esb.getLastActivity(player.getName());
|
||||
final long lastActivity = plugin.essentialsBridge.getLastActivity(player.getName());
|
||||
if (lastActivity > 0 && lastActivity + autoKickTicks < System.currentTimeMillis())
|
||||
{
|
||||
player.kickPlayer("Automatically kicked by server for inactivity.");
|
|
@ -1,7 +1,7 @@
|
|||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -17,7 +17,7 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
public class BlockBlocker extends FreedomService
|
||||
public class BlockBlocker extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class EditBlocker extends FreedomService
|
||||
public class EditBlocker extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -25,13 +25,13 @@ public class EditBlocker extends FreedomService
|
|||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||
FPlayer fPlayer = plugin.playerList.getPlayerSync(event.getPlayer());
|
||||
if (!fPlayer.isEditBlocked())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||
if (plugin.adminList.isAdminSync(event.getPlayer()))
|
||||
{
|
||||
fPlayer.setEditBlocked(false);
|
||||
return;
|
||||
|
@ -44,13 +44,13 @@ public class EditBlocker extends FreedomService
|
|||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||
FPlayer fPlayer = plugin.playerList.getPlayerSync(event.getPlayer());
|
||||
if (!fPlayer.isEditBlocked())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||
if (plugin.adminList.isAdminSync(event.getPlayer()))
|
||||
{
|
||||
fPlayer.setEditBlocked(false);
|
||||
return;
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
|
@ -38,7 +38,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
|||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
public class EventBlocker extends FreedomService
|
||||
public class EventBlocker extends AbstractService
|
||||
{
|
||||
/**
|
||||
* /@EventHandler(priority = EventPriority.HIGH)
|
||||
|
@ -159,7 +159,7 @@ public class EventBlocker extends FreedomService
|
|||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
if (!plugin.al.isAdmin(event.getPlayer()))
|
||||
if (!plugin.adminList.isAdmin(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerBedEnterEvent;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class InteractBlocker extends FreedomService
|
||||
public class InteractBlocker extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -89,7 +89,7 @@ public class InteractBlocker extends FreedomService
|
|||
{
|
||||
case WATER_BUCKET:
|
||||
{
|
||||
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
if (plugin.adminList.isAdmin(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class InteractBlocker extends FreedomService
|
|||
|
||||
case LAVA_BUCKET:
|
||||
{
|
||||
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
if (plugin.adminList.isAdmin(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import org.bukkit.attribute.Attributable;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
|
@ -19,7 +19,7 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
||||
public class MobBlocker extends FreedomService
|
||||
public class MobBlocker extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Arrow;
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class PVPBlocker extends FreedomService
|
||||
public class PVPBlocker extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -70,24 +70,24 @@ public class PVPBlocker extends FreedomService
|
|||
}
|
||||
}
|
||||
|
||||
if (player != null & !plugin.al.isAdmin(player))
|
||||
if (player != null & !plugin.adminList.isAdmin(player))
|
||||
{
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Creative PvP is not allowed!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
|
||||
else if (plugin.essentialsBridge.getEssentialsUser(player.getName()).isGodModeEnabled())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "God mode PvP is not allowed!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (plugin.pl.getPlayer(target).isPvpBlocked())
|
||||
else if (plugin.playerList.getPlayer(target).isPvpBlocked())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + target.getName() + " has PvP disabled!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (plugin.pl.getPlayer(player).isPvpBlocked())
|
||||
else if (plugin.playerList.getPlayer(player).isPvpBlocked())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "You have PvP disabled!");
|
||||
event.setCancelled(true);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import java.util.Collection;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.potion.PotionEffect;
|
|||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
public class PotionBlocker extends FreedomService
|
||||
public class PotionBlocker extends AbstractService
|
||||
{
|
||||
|
||||
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -15,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
|||
|
||||
//codebeat:disable[LOC,ABC]
|
||||
|
||||
public class SignBlocker extends FreedomService
|
||||
public class SignBlocker extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -27,11 +25,13 @@ public class SignBlocker extends FreedomService
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
//TODO: KYORI
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerPlaceBlock(BlockPlaceEvent event)
|
||||
{
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
/*final Player player = event.getPlayer();
|
||||
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
|
||||
{
|
||||
ItemStack sign = event.getItemInHand();
|
||||
|
@ -48,7 +48,7 @@ public class SignBlocker extends FreedomService
|
|||
player.sendMessage(ChatColor.GRAY + "You are not allowed to place command signs.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
|
@ -22,7 +22,7 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.plugin.SimplePluginManager;
|
||||
|
||||
public class CommandBlocker extends FreedomService
|
||||
public class CommandBlocker extends AbstractService
|
||||
{
|
||||
|
||||
private final Pattern flagPattern = Pattern.compile("(:([0-9]){5,})");
|
||||
|
@ -171,7 +171,7 @@ public class CommandBlocker extends FreedomService
|
|||
|
||||
for (String part : commandParts)
|
||||
{
|
||||
if (command.startsWith("/") && !plugin.al.isAdmin(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
||||
if (command.startsWith("/") && !plugin.adminList.isAdmin(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
||||
{
|
||||
FUtil.playerMsg(sender, "WorldEdit copy variables are disabled.");
|
||||
return true;
|
||||
|
|
|
@ -5,12 +5,8 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
|
|||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.spigotmc.SpigotConfig;
|
||||
|
||||
public class CommandBlockerEntry
|
||||
{
|
||||
|
||||
|
||||
private final CommandBlockerRank rank;
|
||||
|
||||
private final CommandBlockerAction action;
|
||||
|
@ -39,13 +35,14 @@ public class CommandBlockerEntry
|
|||
{
|
||||
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
||||
{
|
||||
TotalFreedomMod.getPlugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
|
||||
TotalFreedomMod.getPlugin().autoEject.autoEject((Player)sender, "You used a prohibited command: " + command);
|
||||
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||
return;
|
||||
}
|
||||
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
|
||||
{
|
||||
sender.sendMessage(SpigotConfig.unknownCommandMessage);
|
||||
String spigotUnknownCMD = TotalFreedomMod.getPlugin().getSpigotConfig().getString("messages.unknown-command");
|
||||
sender.sendMessage(spigotUnknownCMD == null || spigotUnknownCMD.isEmpty() ? "Unknown command. Type \"/help\" for help." : spigotUnknownCMD);
|
||||
return;
|
||||
}
|
||||
FUtil.playerMsg(sender, FUtil.colorize(message));
|
||||
|
|
|
@ -22,7 +22,7 @@ public enum CommandBlockerRank
|
|||
|
||||
public static CommandBlockerRank fromSender(CommandSender sender)
|
||||
{
|
||||
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(sender);
|
||||
Admin admin = TotalFreedomMod.getPlugin().adminList.getAdmin(sender);
|
||||
if (admin != null)
|
||||
{
|
||||
if (admin.getRank() == Rank.SENIOR_ADMIN)
|
||||
|
|
|
@ -8,7 +8,7 @@ import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
|||
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
||||
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
|
@ -17,7 +17,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BukkitTelnetBridge extends FreedomService
|
||||
public class BukkitTelnetBridge extends AbstractService
|
||||
{
|
||||
|
||||
private BukkitTelnet bukkitTelnetPlugin = null;
|
||||
|
@ -42,7 +42,7 @@ public class BukkitTelnetBridge extends FreedomService
|
|||
return;
|
||||
}
|
||||
|
||||
final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
|
||||
final Admin admin = plugin.adminList.getEntryByIpFuzzy(ip);
|
||||
|
||||
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ public class BukkitTelnetBridge extends FreedomService
|
|||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onTelnetCommand(TelnetCommandEvent event)
|
||||
{
|
||||
if (plugin.cb.isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
if (plugin.commandBlocker.isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class BukkitTelnetBridge extends FreedomService
|
|||
boolean isTelnetAdmin = false;
|
||||
boolean isSeniorAdmin = false;
|
||||
|
||||
final Admin admin = plugin.al.getAdmin(player);
|
||||
final Admin admin = plugin.adminList.getAdmin(player);
|
||||
if (admin != null)
|
||||
{
|
||||
boolean active = admin.isActive();
|
||||
|
@ -88,9 +88,9 @@ public class BukkitTelnetBridge extends FreedomService
|
|||
playerTags.put("tfm.admin.isTelnetAdmin", isTelnetAdmin);
|
||||
playerTags.put("tfm.admin.isSeniorAdmin", isSeniorAdmin);
|
||||
|
||||
playerTags.put("tfm.playerdata.getTag", plugin.pl.getPlayer(player).getTag());
|
||||
playerTags.put("tfm.playerdata.getTag", plugin.playerList.getPlayer(player).getTag());
|
||||
|
||||
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
||||
playerTags.put("tfm.essentialsBridge.getNickname", plugin.essentialsBridge.getNickname(player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class BukkitTelnetBridge extends FreedomService
|
|||
{
|
||||
for (ClientSession session : telnet.appender.getSessions())
|
||||
{
|
||||
Admin admin = plugin.al.getEntryByName(session.getUserName().toLowerCase());
|
||||
Admin admin = plugin.adminList.getEntryByName(session.getUserName().toLowerCase());
|
||||
if (admin != null && !admins.contains(admin))
|
||||
{
|
||||
admins.add(admin);
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
|
@ -34,7 +30,7 @@ import org.bukkit.plugin.Plugin;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class CoreProtectBridge extends FreedomService
|
||||
public class CoreProtectBridge extends AbstractService
|
||||
{
|
||||
public static Map<Player, FUtil.PaginationList<String>> HISTORY_MAP = new HashMap<>();
|
||||
private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block");
|
||||
|
@ -196,7 +192,6 @@ public class CoreProtectBridge extends FreedomService
|
|||
return (megabytes / 1024);
|
||||
}
|
||||
|
||||
// Wipes DB for the specified world
|
||||
public void clearDatabase(World world)
|
||||
{
|
||||
clearDatabase(world, false);
|
||||
|
@ -264,46 +259,43 @@ public class CoreProtectBridge extends FreedomService
|
|||
{
|
||||
FLog.warning("Failed to delete the CoreProtect data for the " + world.getName());
|
||||
}
|
||||
|
||||
// This exits for flatlands wipes
|
||||
if (shutdown)
|
||||
{
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
PlayerData data = plugin.pl.getData(player);
|
||||
PlayerData data = plugin.playerList.getData(player);
|
||||
Block block = event.getClickedBlock();
|
||||
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||
|
||||
// TODO: Rewrite this
|
||||
if (data.hasInspection())
|
||||
{
|
||||
int cooldownTime = 3;
|
||||
|
||||
// Cooldown check
|
||||
if ((event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
&& cooldown.containsKey(player.getName()))
|
||||
{
|
||||
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
|
||||
if (secondsLeft > 0L)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Actual lookup time
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
int cooldownTime = 3;
|
||||
|
||||
if (cooldown.containsKey(player.getName()))
|
||||
{
|
||||
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
|
||||
if (secondsLeft > 0L)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
List<String[]> lookup = coreProtect.blockLookup(block, -1);
|
||||
|
||||
if (!plugin.al.isAdmin(player))
|
||||
if (!plugin.adminList.isAdmin(player))
|
||||
{
|
||||
cooldown.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
|
@ -320,8 +312,8 @@ public class CoreProtectBridge extends FreedomService
|
|||
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
|
||||
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
|
||||
|
||||
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- "
|
||||
+ ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
|
||||
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- " +
|
||||
ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
|
||||
|
||||
for (String[] value : lookup)
|
||||
{
|
||||
|
@ -351,8 +343,8 @@ public class CoreProtectBridge extends FreedomService
|
|||
|
||||
int time = (int)(System.currentTimeMillis() / 1000L);
|
||||
|
||||
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4")
|
||||
+ st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
|
||||
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4") +
|
||||
st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
|
||||
}
|
||||
|
||||
List<String> page = paged.getPage(1);
|
||||
|
@ -369,91 +361,75 @@ public class CoreProtectBridge extends FreedomService
|
|||
{
|
||||
if (block != null)
|
||||
{
|
||||
if (data.hasInspection())
|
||||
{
|
||||
BlockState blockState = block.getRelative(event.getBlockFace()).getState();
|
||||
Block placedBlock = blockState.getBlock();
|
||||
event.setCancelled(true);
|
||||
List<String[]> lookup = coreProtect.blockLookup(placedBlock, -1);
|
||||
BlockState blockState = block.getRelative(event.getBlockFace()).getState();
|
||||
Block placedBlock = blockState.getBlock();
|
||||
event.setCancelled(true);
|
||||
List<String[]> lookup = coreProtect.blockLookup(placedBlock, -1);
|
||||
|
||||
if (lookup.isEmpty())
|
||||
{
|
||||
lookup = coreProtect.blockLookup(block, -1);
|
||||
}
|
||||
|
||||
if (!plugin.adminList.isAdmin(player))
|
||||
{
|
||||
cooldown.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
if (lookup != null)
|
||||
{
|
||||
if (lookup.isEmpty())
|
||||
{
|
||||
lookup = coreProtect.blockLookup(block, -1);
|
||||
player.sendMessage(net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector " + ChatColor.WHITE + "- " + "No block data found for this location");
|
||||
return;
|
||||
}
|
||||
|
||||
int cooldownTime = 3;
|
||||
HISTORY_MAP.remove(event.getPlayer());
|
||||
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
|
||||
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
|
||||
|
||||
if (cooldown.containsKey(player.getName()))
|
||||
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- " +
|
||||
ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
|
||||
|
||||
for (String[] value : lookup)
|
||||
{
|
||||
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
|
||||
if (secondsLeft > 0L)
|
||||
CoreProtectAPI.ParseResult result = coreProtect.parseResult(value);
|
||||
BlockData bl = result.getBlockData();
|
||||
|
||||
String s;
|
||||
String st = "";
|
||||
|
||||
if (result.getActionString().equals("Placement"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
|
||||
return;
|
||||
s = " placed ";
|
||||
}
|
||||
else if (result.getActionString().equals("Removal"))
|
||||
{
|
||||
s = " broke ";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = " interacted with ";
|
||||
}
|
||||
|
||||
if (result.isRolledBack())
|
||||
{
|
||||
st += "§m";
|
||||
}
|
||||
|
||||
int time = (int)(System.currentTimeMillis() / 1000L);
|
||||
|
||||
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4") +
|
||||
st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
|
||||
}
|
||||
|
||||
if (!plugin.al.isAdmin(player))
|
||||
List<String> page = paged.getPage(1);
|
||||
for (String entries : page)
|
||||
{
|
||||
cooldown.put(player.getName(), System.currentTimeMillis());
|
||||
player.sendMessage(entries);
|
||||
}
|
||||
|
||||
if (lookup != null)
|
||||
{
|
||||
if (lookup.isEmpty())
|
||||
{
|
||||
player.sendMessage(net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector " + ChatColor.WHITE + "- " + "No block data found for this location");
|
||||
return;
|
||||
}
|
||||
|
||||
HISTORY_MAP.remove(event.getPlayer());
|
||||
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
|
||||
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
|
||||
|
||||
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- "
|
||||
+ ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
|
||||
|
||||
for (String[] value : lookup)
|
||||
{
|
||||
CoreProtectAPI.ParseResult result = coreProtect.parseResult(value);
|
||||
BlockData bl = result.getBlockData();
|
||||
|
||||
String s;
|
||||
String st = "";
|
||||
|
||||
if (result.getActionString().equals("Placement"))
|
||||
{
|
||||
s = " placed ";
|
||||
}
|
||||
else if (result.getActionString().equals("Removal"))
|
||||
{
|
||||
s = " broke ";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = " interacted with ";
|
||||
}
|
||||
|
||||
if (result.isRolledBack())
|
||||
{
|
||||
st += "§m";
|
||||
}
|
||||
|
||||
int time = (int)(System.currentTimeMillis() / 1000L);
|
||||
|
||||
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4")
|
||||
+ st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
|
||||
}
|
||||
|
||||
List<String> page = paged.getPage(1);
|
||||
for (String entries : page)
|
||||
{
|
||||
player.sendMessage(entries);
|
||||
}
|
||||
|
||||
player.sendMessage("Page 1/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
|
||||
}
|
||||
player.sendMessage("Page 1/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.bridge;
|
|||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
|
@ -20,7 +20,7 @@ import org.bukkit.inventory.InventoryHolder;
|
|||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class EssentialsBridge extends FreedomService
|
||||
public class EssentialsBridge extends AbstractService
|
||||
{
|
||||
|
||||
private Essentials essentialsPlugin = null;
|
||||
|
@ -139,6 +139,7 @@ public class EssentialsBridge extends FreedomService
|
|||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
|
@ -148,15 +149,15 @@ public class EssentialsBridge extends FreedomService
|
|||
Inventory inventory = event.getView().getTopInventory();
|
||||
InventoryType inventoryType = inventory.getType();
|
||||
Player player = (Player)event.getWhoClicked();
|
||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
FPlayer fPlayer = plugin.playerList.getPlayer(player);
|
||||
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
||||
{
|
||||
final InventoryHolder inventoryHolder = inventory.getHolder();
|
||||
if (inventoryHolder instanceof HumanEntity)
|
||||
{
|
||||
Player invOwner = (Player)inventoryHolder;
|
||||
Rank recieverRank = plugin.rm.getRank(player);
|
||||
Rank playerRank = plugin.rm.getRank(invOwner);
|
||||
Rank recieverRank = plugin.rankManager.getRank(player);
|
||||
Rank playerRank = plugin.rankManager.getRank(invOwner);
|
||||
if (playerRank.ordinal() >= recieverRank.ordinal() || !invOwner.isOnline())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
@ -185,7 +186,7 @@ public class EssentialsBridge extends FreedomService
|
|||
Inventory inventory = event.getView().getTopInventory();
|
||||
InventoryType inventoryType = inventory.getType();
|
||||
Player player = (Player)event.getPlayer();
|
||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
FPlayer fPlayer = plugin.playerList.getPlayer(player);
|
||||
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
||||
{
|
||||
fPlayer.setInvSee(false);
|
||||
|
|
|
@ -3,12 +3,12 @@ package me.totalfreedom.totalfreedommod.bridge;
|
|||
import me.libraryaddict.disguise.BlockedDisguises;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class LibsDisguisesBridge extends FreedomService
|
||||
public class LibsDisguisesBridge extends AbstractService
|
||||
{
|
||||
private LibsDisguises libsDisguisesPlugin = null;
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class LibsDisguisesBridge extends FreedomService
|
|||
{
|
||||
if (DisguiseAPI.isDisguised(player))
|
||||
{
|
||||
if (!admin && plugin.al.isAdmin(player))
|
||||
if (!admin && plugin.adminList.isAdmin(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ package me.totalfreedom.totalfreedommod.bridge;
|
|||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.TFGuilds;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TFGuildsBridge extends FreedomService
|
||||
public class TFGuildsBridge extends AbstractService
|
||||
{
|
||||
public boolean enabled = false;
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@ package me.totalfreedom.totalfreedommod.bridge;
|
|||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class WorldEditBridge extends FreedomService
|
||||
public class WorldEditBridge extends AbstractService
|
||||
{
|
||||
|
||||
//
|
||||
|
|
|
@ -1,21 +1,26 @@
|
|||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class WorldGuardBridge extends FreedomService
|
||||
public class WorldGuardBridge extends AbstractService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
|
||||
plugin.worldRestrictions.protectWorld(plugin.worldManager.masterBuilderWorld.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,6 +28,16 @@ public class WorldGuardBridge extends FreedomService
|
|||
{
|
||||
}
|
||||
|
||||
public boolean canEditCurrentWorld(Player player)
|
||||
{
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery query = container.createQuery();
|
||||
|
||||
return query.testBuild(localPlayer.getLocation(), localPlayer);
|
||||
}
|
||||
|
||||
public RegionManager getRegionManager(World world)
|
||||
{
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
public class CommandFailException extends RuntimeException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -92333791173123L;
|
||||
|
||||
public CommandFailException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,85 +1,83 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.services.AbstractService;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
public class CommandLoader extends FreedomService
|
||||
{
|
||||
public class CommandLoader extends AbstractService {
|
||||
private final List<FreedomCommand> commands;
|
||||
|
||||
public CommandLoader()
|
||||
{
|
||||
public CommandLoader() {
|
||||
commands = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
public void onStart() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
public void onStop() {
|
||||
}
|
||||
|
||||
public void add(FreedomCommand command)
|
||||
{
|
||||
commands.add(command);
|
||||
command.register();
|
||||
public void add(Class<? extends FreedomCommand> command) {
|
||||
FreedomCommand cmd = null;
|
||||
try {
|
||||
Constructor<?> constructor = command.getDeclaredConstructor();
|
||||
constructor.setAccessible(true);
|
||||
cmd = (FreedomCommand) constructor.newInstance();
|
||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
if (cmd != null) {
|
||||
commands.add(cmd);
|
||||
cmd.register();
|
||||
}
|
||||
}
|
||||
|
||||
public FreedomCommand getByName(String name)
|
||||
{
|
||||
for (FreedomCommand command : commands)
|
||||
{
|
||||
if (name.equals(command.getName()))
|
||||
{
|
||||
public FreedomCommand getByName(String name) {
|
||||
for (FreedomCommand command : commands) {
|
||||
if (name.equals(command.getName())) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isAlias(String alias)
|
||||
{
|
||||
for (FreedomCommand command : commands)
|
||||
{
|
||||
if (Arrays.asList(command.getAliases().split(",")).contains(alias))
|
||||
{
|
||||
public boolean isAlias(String alias) {
|
||||
for (FreedomCommand command : commands) {
|
||||
if (Arrays.asList(command.getAliases().split(",")).contains(alias)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void loadCommands()
|
||||
{
|
||||
public void loadCommands() {
|
||||
Reflections commandDir = new Reflections("me.totalfreedom.totalfreedommod.command");
|
||||
|
||||
Set<Class<? extends FreedomCommand>> commandClasses = commandDir.getSubTypesOf(FreedomCommand.class);
|
||||
|
||||
for (Class<? extends FreedomCommand> commandClass : commandClasses)
|
||||
{
|
||||
try
|
||||
{
|
||||
add(commandClass.newInstance());
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
|
||||
{
|
||||
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_", ""));
|
||||
for (Class<? extends FreedomCommand> commandClass : commandClasses) {
|
||||
try {
|
||||
add(commandClass);
|
||||
} catch (ExceptionInInitializerError ex) {
|
||||
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("CMD", ""));
|
||||
}
|
||||
}
|
||||
|
||||
FLog.info("Loaded " + commands.size() + " commands");
|
||||
}
|
||||
|
||||
public List<FreedomCommand> getCommands()
|
||||
{
|
||||
public List<FreedomCommand> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Make an announcement anonymously to operators.", usage = "/<command> <message>")
|
||||
public class Command_announce extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
plugin.an.announce(StringUtils.join(args, " "));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>")
|
||||
public class Command_autoclear extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean enabled = plugin.lp.CLEAR_ON_JOIN.contains(args[0]);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
plugin.lp.CLEAR_ON_JOIN.remove(args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.lp.CLEAR_ON_JOIN.add(args[0]);
|
||||
}
|
||||
|
||||
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " have their inventory cleared when they join.");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
|
||||
public class Command_autotp extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean enabled = plugin.lp.TELEPORT_ON_JOIN.contains(args[0]);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
plugin.lp.TELEPORT_ON_JOIN.remove(args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.lp.TELEPORT_ON_JOIN.add(args[0]);
|
||||
}
|
||||
|
||||
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " be automatically teleported when they join.");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows all banned player names. Admins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||
public class Command_banlist extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
||||
int amount = plugin.bm.purge();
|
||||
msg("Purged " + amount + " player bans.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
msg(plugin.bm.getAllBans().size() + " player bans ("
|
||||
+ plugin.bm.getUsernameBans().size() + " usernames, "
|
||||
+ plugin.bm.getIpBans().size() + " IPs)");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Clears the chat.", usage = "/<command>", aliases = "cc")
|
||||
public class Command_cleanchat extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
msg(player, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Clear the Discord message queue.", usage = "/<command>")
|
||||
public class Command_cleardiscordqueue extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
plugin.dc.clearQueue();
|
||||
msg("Cleared the Discord message queue.");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a clown fish", usage = "/<command>")
|
||||
public class Command_clownfish extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH) && (!plugin.lp.CLOWNFISH_TOGGLE.contains(playerSender.getName())))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getClownFish());
|
||||
msg("You have been given a Clown Fish", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Clown Fish or an admin has toggled your ability to use it. Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Spy on commands", usage = "/<command>", aliases = "commandspy")
|
||||
public class Command_cmdspy extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows the amount of coins you have or another player has", usage = "/<command> [playername]")
|
||||
public class Command_coins extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||
{
|
||||
msg("The shop is currently disabled!", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
Player p;
|
||||
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
|
||||
if (args.length > 0)
|
||||
{
|
||||
if (getPlayer(args[0]) != null)
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (senderIsConsole)
|
||||
{
|
||||
msg(prefix + ChatColor.RED + "You are not a player, use /coins <playername>");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = playerSender;
|
||||
}
|
||||
}
|
||||
PlayerData playerData = plugin.pl.getData(p);
|
||||
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins.");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Essentials Interface Command - Remove the nickname of all players on the server.", usage = "/<command>")
|
||||
public class Command_denick extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.esb.isEnabled())
|
||||
{
|
||||
msg("Essentials is not enabled on this server.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Removing all nicknames", false);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
plugin.esb.setNickname(player.getName(), null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggle LibsDisguises for everyone online.", usage = "/<command>", aliases = "dtoggle")
|
||||
public class Command_disguisetoggle extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.ldb.isEnabled())
|
||||
{
|
||||
msg("LibsDisguises is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), (plugin.ldb.isDisguisesEnabled() ? "Disabling" : "Enabling") + " disguises", false);
|
||||
|
||||
if (plugin.ldb.isDisguisesEnabled())
|
||||
{
|
||||
plugin.ldb.undisguiseAll(true);
|
||||
plugin.ldb.setDisguisesEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.ldb.setDisguisesEnabled(true);
|
||||
}
|
||||
|
||||
msg("Disguises are now " + (plugin.ldb.isDisguisesEnabled() ? "enabled." : "disabled."));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Eject players that are riding you.", usage = "/<command>")
|
||||
public class Command_eject extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
List<String> names = new ArrayList<>();
|
||||
|
||||
for (Entity entity : playerSender.getPassengers())
|
||||
{
|
||||
names.add(entity.getName());
|
||||
}
|
||||
|
||||
if (names.isEmpty())
|
||||
{
|
||||
msg("Nothing was ejected.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Ejecting " + StringUtils.join(names, ", ") + ".", ChatColor.GREEN);
|
||||
playerSender.eject();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to \"The End\".", usage = "/<command>")
|
||||
public class Command_end extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
plugin.wm.gotoWorld(playerSender, server.getWorlds().get(0).getName() + "_the_end");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Make arrows explode", usage = "/<command>", aliases = "ea")
|
||||
public class Command_explosivearrows extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
boolean onList = plugin.it.explosivePlayers.contains(playerSender);
|
||||
if (onList)
|
||||
{
|
||||
plugin.it.explosivePlayers.remove(playerSender);
|
||||
msg("You no longer have explosive arrows", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.it.explosivePlayers.add(playerSender);
|
||||
msg("You now have explosive arrows", ChatColor.GREEN);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows all IPs registered to a player", usage = "/<command> <player>", aliases = "showip,listip")
|
||||
public class Command_findip extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Player IPs: " + StringUtils.join(plugin.pl.getData(player).getIps(), ", "));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a fire ball", usage = "/<command>")
|
||||
public class Command_fireball extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getFireBall());
|
||||
msg("You have been given a Fire Ball", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Fire Ball! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to the Flatlands.", usage = "/<command>")
|
||||
public class Command_flatlands extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (ConfigEntry.FLATLANDS_GENERATE.getBoolean())
|
||||
{
|
||||
plugin.wm.flatlands.sendToWorld(playerSender);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Flatlands is currently disabled in the TotalFreedomMod configuration.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Forcefully kill someone - for those who REALLY need to die.", usage = "/<command> <playername>")
|
||||
public class Command_forcekill extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender) && !senderIsConsole)
|
||||
{
|
||||
playerSender.setHealth(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
player.setHealth(0);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a grappling hook", usage = "/<command>")
|
||||
public class Command_grapplinghook extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.GRAPPLING_HOOK))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getGrapplingHook());
|
||||
msg("You have been given a Grappling Hook", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Grappling Hook! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Reload the indefinite ban list.", usage = "/<command> <reload>", aliases = "ib")
|
||||
public class Command_indefban extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!args[0].equalsIgnoreCase("reload"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
msg("Reloading the indefinite ban list...");
|
||||
plugin.im.onStop();
|
||||
plugin.im.onStart();
|
||||
msg("Reloaded the indefinite ban list.");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Toggles jumppads on/off, view the status of jumppads, or make them sideways.", usage = "/<command> <on | off | info | sideways <on | off>>", aliases = "launchpads,jp")
|
||||
public class Command_jumppads extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0 || args.length > 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("info"))
|
||||
{
|
||||
msg("Jumppads: " + (plugin.jp.players.get(playerSender).isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
msg("Sideways: " + (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
if (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.OFF)
|
||||
{
|
||||
msg("Your jumppads are already disabled.");
|
||||
return true;
|
||||
}
|
||||
msg("Disabled your jumppads.", ChatColor.GRAY);
|
||||
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.jp.players.get(playerSender) != Jumppads.JumpPadMode.OFF)
|
||||
{
|
||||
msg("Your jumppads are already enabled.");
|
||||
return true;
|
||||
}
|
||||
msg("Enabled your jumpppads.", ChatColor.GRAY);
|
||||
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.MADGEEK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.OFF)
|
||||
{
|
||||
msg("Your jumppads are currently disabled, please enable them before changing jumppads settings.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("sideways"))
|
||||
{
|
||||
if ("off".equals(args[1]))
|
||||
{
|
||||
if (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.MADGEEK)
|
||||
{
|
||||
msg("Your jumppads are already set to normal mode.");
|
||||
return true;
|
||||
}
|
||||
msg("Set Jumppads mode to: Normal", ChatColor.GRAY);
|
||||
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.MADGEEK);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS)
|
||||
{
|
||||
msg("Your jumppads are already set to normal and sideways mode.");
|
||||
return true;
|
||||
}
|
||||
msg("Set Jumppads mode to: Normal and Sideways", ChatColor.GRAY);
|
||||
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("on", "off", "info", "sideways");
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equals("sideways"))
|
||||
{
|
||||
return Arrays.asList("on", "off");
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a lightning rod", usage = "/<command>")
|
||||
public class Command_lightningrod extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.LIGHTNING_ROD))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getLightningRod());
|
||||
msg("You have been given a Lightning Rod", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Lightning Rod! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Link your Discord account to your Minecraft account", usage = "/<command> [<name> <id>]")
|
||||
public class Command_linkdiscord extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.dc.enabled)
|
||||
{
|
||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length > 1 && plugin.al.isAdmin(playerSender))
|
||||
{
|
||||
PlayerData playerData = plugin.pl.getData(args[0]);
|
||||
if (playerData == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
playerData.setDiscordID(args[1]);
|
||||
msg("Linked " + args[0] + "'s Discord account.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
String code;
|
||||
|
||||
PlayerData data = plugin.pl.getData(playerSender);
|
||||
if (data.getDiscordID() != null)
|
||||
{
|
||||
msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Discord.LINK_CODES.containsValue(data))
|
||||
{
|
||||
code = Discord.getCode(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
code = plugin.dc.generateCode(5);
|
||||
Discord.LINK_CODES.put(code, data);
|
||||
}
|
||||
msg("Your linking code is " + ChatColor.AQUA + code, ChatColor.GREEN);
|
||||
msg("Take this code and DM the server bot (" + plugin.dc.formatBotTag() + ") the code (do not put anything else in the message, only the code)");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Register your connection with the TFM logviewer.", usage = "/<command> [off]")
|
||||
public class Command_logs extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
LogsRegistrationMode mode = LogsRegistrationMode.ADD;
|
||||
if (args.length == 1 && "off".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
mode = LogsRegistrationMode.DELETE;
|
||||
}
|
||||
plugin.lv.updateLogsRegistration(sender, playerSender, mode);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.RegionGroup;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Make a WorldGuard region for an OP.", usage = "/<command> <playername> <name>", aliases = "mor")
|
||||
public class Command_makeopregion extends FreedomCommand
|
||||
{
|
||||
|
||||
final Map<Flag<?>, Object> flags = new HashMap<Flag<?>, Object>()
|
||||
{{
|
||||
put(Flags.BLOCK_PLACE, StateFlag.State.ALLOW);
|
||||
put(Flags.BLOCK_BREAK, StateFlag.State.ALLOW);
|
||||
put(Flags.BUILD, StateFlag.State.ALLOW);
|
||||
put(Flags.PLACE_VEHICLE, StateFlag.State.ALLOW);
|
||||
put(Flags.DESTROY_VEHICLE, StateFlag.State.ALLOW);
|
||||
put(Flags.ENTITY_ITEM_FRAME_DESTROY, StateFlag.State.ALLOW);
|
||||
put(Flags.ENTITY_PAINTING_DESTROY, StateFlag.State.ALLOW);
|
||||
put(net.goldtreeservers.worldguardextraflags.flags.Flags.WORLDEDIT, StateFlag.State.ALLOW);
|
||||
}};
|
||||
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = args[1];
|
||||
|
||||
LocalSession session = plugin.web.getWorldEditPlugin().getSession(playerSender);
|
||||
|
||||
Region selection;
|
||||
|
||||
try
|
||||
{
|
||||
selection = session.getSelection(session.getSelectionWorld());
|
||||
}
|
||||
catch (IncompleteRegionException e)
|
||||
{
|
||||
msg("Please make a WorldEdit selection", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (selection == null)
|
||||
{
|
||||
msg("Please make a WorldEdit selection", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(name, selection.getMinimumPoint(), selection.getMaximumPoint());
|
||||
|
||||
DefaultDomain owners = new DefaultDomain();
|
||||
owners.addPlayer(playerSender.getName());
|
||||
owners.addPlayer(player.getName());
|
||||
region.setOwners(owners);
|
||||
region.setFlags(flags);
|
||||
|
||||
for (Flag<?> flag : flags.keySet())
|
||||
{
|
||||
region.setFlag(flag.getRegionGroupFlag(), RegionGroup.MEMBERS);
|
||||
}
|
||||
|
||||
RegionManager regionManager = plugin.wgb.getRegionManager(playerSender.getWorld());
|
||||
|
||||
regionManager.addRegion(region);
|
||||
|
||||
msg("Successfully created the region '" + name + "' for " + player.getName(), ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,265 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.SplittableRandom;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Modify the current item you are holding.", usage = "/<command> <name <message> | lore <message> | enchant <enchantment> <level> | potion <effect> <duration> <amplifier> | attribute <name> <amount> | clear>", aliases = "mi")
|
||||
public class Command_modifyitem extends FreedomCommand
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack item = playerSender.getInventory().getItemInMainHand();
|
||||
if (item.getType().equals(Material.AIR))
|
||||
{
|
||||
msg("You must have an item in your hand!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("clear"))
|
||||
{
|
||||
item.setItemMeta(null);
|
||||
playerSender.getInventory().setItemInMainHand(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
assert meta != null;
|
||||
switch (args[0])
|
||||
{
|
||||
case "name":
|
||||
String name = FUtil.colorize(StringUtils.join(args, " ", 1, args.length));
|
||||
meta.setDisplayName(name);
|
||||
item.setItemMeta(meta);
|
||||
break;
|
||||
|
||||
case "lore":
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String line : StringUtils.join(args, " ", 1, args.length).split("\\\\n"))
|
||||
{
|
||||
lore.add(FUtil.colorize(line));
|
||||
}
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
break;
|
||||
|
||||
case "enchant":
|
||||
if (args.length < 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Enchantment enchantment = Enchantment.getByName(args[1].toUpperCase());
|
||||
if (enchantment == null)
|
||||
{
|
||||
msg("Invalid enchantment. Please run /enchant list for a list of valid enchantments.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int level;
|
||||
try
|
||||
{
|
||||
level = Integer.parseInt(args[2]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("The level specified is not a valid integer.");
|
||||
return true;
|
||||
}
|
||||
meta.addEnchant(enchantment, level, true);
|
||||
item.setItemMeta(meta);
|
||||
break;
|
||||
|
||||
case "potion":
|
||||
{
|
||||
if (!item.getType().equals(Material.POTION) & !item.getType().equals(Material.SPLASH_POTION) & !item.getType().equals(Material.LINGERING_POTION) & !item.getType().equals(Material.TIPPED_ARROW))
|
||||
{
|
||||
msg("This item can not have potion effects added to it.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
PotionEffectType type = PotionEffectType.getByName(args[1]);
|
||||
if (type == null)
|
||||
{
|
||||
msg("Invalid potion effect. Please run /potion list for a list of valid potion effects.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int duration;
|
||||
try
|
||||
{
|
||||
duration = Math.max(1, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("The duration specified is not a valid integer.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int amplifier;
|
||||
try
|
||||
{
|
||||
amplifier = Math.max(1, Math.min(256, Integer.parseInt(args[2])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("The amplifier specified is not a valid integer.");
|
||||
return true;
|
||||
}
|
||||
PotionMeta potionMeta = (PotionMeta)meta;
|
||||
potionMeta.addCustomEffect(type.createEffect(duration, amplifier), true);
|
||||
item.setItemMeta(potionMeta);
|
||||
break;
|
||||
}
|
||||
|
||||
case "attribute":
|
||||
if (args.length < 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
|
||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||
NBTTagCompound cmpnd = new NBTTagCompound();
|
||||
Attribute attribute = Attribute.getByName(args[1].toUpperCase());
|
||||
if (attribute == null)
|
||||
{
|
||||
msg("Invalid attribute. Please run /attributelist for a list of valid attributes.");
|
||||
return true;
|
||||
}
|
||||
cmpnd.setString("AttributeName", attribute.getAttribute());
|
||||
cmpnd.setString("Name", attribute.getAttribute());
|
||||
double amount;
|
||||
try
|
||||
{
|
||||
amount = Double.parseDouble(args[2]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("The amount specified is not a valid integer.");
|
||||
return true;
|
||||
}
|
||||
if (Double.isNaN(amount))
|
||||
{
|
||||
msg("The amount specified is illegal.");
|
||||
return true;
|
||||
}
|
||||
cmpnd.setDouble("Amount", amount);
|
||||
cmpnd.setInt("Operation", 0);
|
||||
SplittableRandom random = new SplittableRandom();
|
||||
cmpnd.setIntArray("UUID", new int[]
|
||||
{
|
||||
random.nextInt(),
|
||||
random.nextInt(),
|
||||
random.nextInt(),
|
||||
random.nextInt()
|
||||
});
|
||||
cmpnd.setString("Slot", "mainhand");
|
||||
modifiers.add(cmpnd);
|
||||
assert compound != null;
|
||||
compound.set("AttributeModifiers", modifiers);
|
||||
nmsStack.setTag(compound);
|
||||
item = CraftItemStack.asBukkitCopy(nmsStack);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
playerSender.getInventory().setItemInMainHand(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
private NBTTagList getAttributeList(net.minecraft.world.item.ItemStack stack)
|
||||
{
|
||||
if (stack.getTag() == null)
|
||||
{
|
||||
stack.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagList attr = stack.getTag().getList("AttributeModifiers", 10);
|
||||
if (attr == null)
|
||||
{
|
||||
stack.getTag().set("AttributeModifiers", new NBTTagList());
|
||||
}
|
||||
return stack.getTag().getList("AttributeModifiers", 10);
|
||||
}
|
||||
|
||||
private enum Attribute
|
||||
{
|
||||
GENERIC_MAX_HEALTH("GENERIC_MAX_HEALTH", "generic.max_health"),
|
||||
GENERIC_FOLLOW_RANGE("GENERIC_FOLLOW_RANGE", "generic.follow_range"),
|
||||
GENERIC_KNOCKBACK_RESISTANCE("GENERIC_KNOCKBACK_RESISTANCE", "generic.knockback_resistance"),
|
||||
GENERIC_MOVEMENT_SPEED("GENERIC_MOVEMENT_SPEED", "generic.movement_speed"),
|
||||
GENERIC_FLYING_SPEED("GENERIC_FLYING_SPEED", "generic.flying_speed"),
|
||||
GENERIC_ATTACK_DAMAGE("GENERIC_ATTACK_DAMAGE", "generic.attack_damage"),
|
||||
GENERIC_ATTACK_SPEED("GENERIC_ATTACK_SPEED", "generic.attack_speed"),
|
||||
GENERIC_ARMOR("GENERIC_ARMOR", "generic.armor"),
|
||||
GENERIC_ARMOR_TOUGHNESS("GENERIC_ARMOR_TOUGHNESS", "generic.armor_toughmess"),
|
||||
GENERIC_LUCK("GENERIC_LUCK", "generic.luck"),
|
||||
HORSE_JUMP_STRENGTH("GENERIC_MAX_HEALTH", "horse.jump_strength"),
|
||||
ZOMBIE_SPAWN_REINFORCEMENTS("ZOMBIE_SPAWN_REINFORCEMENTS", "zombie.spawn_reinforcements");
|
||||
|
||||
private final String name;
|
||||
private final String attribute;
|
||||
|
||||
Attribute(String name, String attribute)
|
||||
{
|
||||
this.name = name;
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
public static Attribute getByName(String name)
|
||||
{
|
||||
for (Attribute attr : Attribute.values())
|
||||
{
|
||||
if (attr.toString().toUpperCase().equals(name))
|
||||
{
|
||||
return attr;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getAttribute()
|
||||
{
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Check your personal data", usage = "/<command>")
|
||||
public class Command_myinfo extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
msg(plugin.pl.getData(playerSender).toString());
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.History;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Check the name history of a specified player.", usage = "/<command> <username>", aliases = "nh")
|
||||
public class Command_namehistory extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
History.reportHistory(sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to the Nether.", usage = "/<command>", aliases = "hell")
|
||||
public class Command_nether extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
plugin.wm.gotoWorld(playerSender, server.getWorlds().get(0).getName() + "_nether");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH, cooldown = 30)
|
||||
@CommandParameters(description = "OP everyone on the server.", usage = "/<command>")
|
||||
public class Command_opall extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Opping all players on the server", false);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!player.isOp())
|
||||
{
|
||||
player.setOp(true);
|
||||
msg(player, YOU_ARE_OP);
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Forcefully start a reaction", usage = "/<command>")
|
||||
public class Command_reactionbar extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!FUtil.isDeveloper(playerSender))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
|
||||
plugin.sh.forceStartReaction();
|
||||
msg("Started a reaction.");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Release parrots from your shoulders.", usage = "/<command>", aliases = "removeparrots")
|
||||
public class Command_releaseparrots extends FreedomCommand
|
||||
{
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
Entity leftShoulderEntity = playerSender.getShoulderEntityLeft();
|
||||
Entity rightShoulderEntity = playerSender.getShoulderEntityRight();
|
||||
|
||||
if (rightShoulderEntity == null && leftShoulderEntity == null)
|
||||
{
|
||||
msg("No parrots were detected on either of your shoulders.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (leftShoulderEntity != null && leftShoulderEntity.getType().equals(EntityType.PARROT))
|
||||
{
|
||||
playerSender.setShoulderEntityLeft(null);
|
||||
msg("Removed the parrot on your left shoulder.");
|
||||
}
|
||||
|
||||
if (rightShoulderEntity != null && rightShoulderEntity.getType().equals(EntityType.PARROT))
|
||||
{
|
||||
playerSender.setShoulderEntityRight(null);
|
||||
msg("Removed the parrot on your right shoulder.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a rideable ender pearl", usage = "/<command>")
|
||||
public class Command_rideablepearl extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.RIDEABLE_PEARL))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getRideablePearl());
|
||||
msg("You have been given a Rideable Ender Pearl", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Rideable Ender Pearl! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Check the status of the server, including opped players, admins, etc.", usage = "/<command>", aliases = "ss")
|
||||
public class Command_serverstats extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
msg("-==" + ConfigEntry.SERVER_NAME.getString() + " server stats==-", ChatColor.GOLD);
|
||||
msg("Total opped players: " + server.getOperators().size(), ChatColor.RED);
|
||||
msg("Total admins: " + plugin.al.getAllAdmins().size() + " (" + plugin.al.getActiveAdmins().size() + " active)", ChatColor.BLUE);
|
||||
int bans = plugin.im.getIndefBans().size();
|
||||
int nameBans = plugin.im.getNameBanCount();
|
||||
int uuidBans = plugin.im.getUuidBanCount();
|
||||
int ipBans = plugin.im.getIpBanCount();
|
||||
msg("Total indefinite ban entries: " + bans + " (" + nameBans + " name bans, " + uuidBans + " UUID bans, and " + ipBans + " IP bans)", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Sets your experience level (XP).", usage = "/<command> [level]")
|
||||
public class Command_setlevel extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int new_level;
|
||||
|
||||
try
|
||||
{
|
||||
new_level = Integer.parseInt(args[0]);
|
||||
|
||||
if (new_level < 0)
|
||||
{
|
||||
new_level = 0;
|
||||
}
|
||||
else if (new_level > 50)
|
||||
{
|
||||
new_level = 50;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid level.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
playerSender.setLevel(new_level);
|
||||
|
||||
msg("Your XP level is now set to " + ChatColor.GOLD + new_level);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sets everyone's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> [limit]", aliases = "setl,swl")
|
||||
public class Command_setlimit extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
int amount = plugin.web.getDefaultLimit();
|
||||
if (args.length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
amount = Math.max(-1, Math.min(plugin.web.getMaxLimit(), Integer.parseInt(args[0])));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[0], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
boolean success = false;
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.web.setLimit(player, amount);
|
||||
success = true;
|
||||
}
|
||||
catch (NoClassDefFoundError | NullPointerException ex)
|
||||
{
|
||||
msg("WorldEdit is not enabled on this server.");
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Setting everyone's WorldEdit block modification limit to " + amount + ".", true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Open the shop GUI", usage = "/<command>", aliases = "sh")
|
||||
public class Command_shop extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||
{
|
||||
msg("The shop is currently disabled!", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
playerSender.openInventory(plugin.sh.generateShopGUI(plugin.pl.getData(playerSender)));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a stacking potato", usage = "/<command>")
|
||||
public class Command_stackingpotato extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.STACKING_POTATO))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getStackingPotato());
|
||||
msg("You have been given a Stacking Potato", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own the Stacking Potato! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggle whether or not a player has the ability to use clownfish", usage = "/<command> <player>", aliases = "togglecf")
|
||||
public class Command_toggleclownfish extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean enabled = plugin.lp.CLOWNFISH_TOGGLE.contains(args[0]);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
plugin.lp.CLOWNFISH_TOGGLE.remove(args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.lp.CLOWNFISH_TOGGLE.add(args[0]);
|
||||
}
|
||||
|
||||
msg(args[0] + " will " + (enabled ? "now" : "no longer") + " have the ability to use clownfish.");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Toggle the display of Discord messages in-game.", usage = "/<command>", aliases = "tdiscord,tdisc")
|
||||
public class Command_togglediscord extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
PlayerData data = plugin.pl.getData(playerSender);
|
||||
data.setDisplayDiscord(!data.doesDisplayDiscord());
|
||||
plugin.pl.save(data);
|
||||
msg("Discord messages will " + (data.doesDisplayDiscord() ? "now" : "no longer") + " be shown.");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/<command>")
|
||||
public class Command_trail extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.tr.contains(playerSender))
|
||||
{
|
||||
plugin.tr.remove(playerSender);
|
||||
msg("Trail disabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.tr.add(playerSender);
|
||||
msg("Trail enabled. Use \"/trail off\" to disable.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unbans the specified player.", usage = "/<command> <username> [-r]")
|
||||
public class Command_unban extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
String username;
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getName();
|
||||
final List<String> ips = new ArrayList<>(entry.getIps());
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
||||
msg(username + " has been unbanned along with the following IPs: " + StringUtils.join(ips, ", "));
|
||||
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
||||
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("-r"))
|
||||
{
|
||||
plugin.cpb.restore(username);
|
||||
msg("Restored edits for: " + username);
|
||||
}
|
||||
}
|
||||
|
||||
for (String ip : ips)
|
||||
{
|
||||
Ban ban = plugin.bm.getByIp(ip);
|
||||
if (ban != null)
|
||||
{
|
||||
plugin.bm.removeBan(ban);
|
||||
}
|
||||
ban = plugin.bm.getByIp(FUtil.getFuzzyIp(ip));
|
||||
if (ban != null)
|
||||
{
|
||||
plugin.bm.removeBan(ban);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sends a verification code to the player, or the player can input the sent code. Admins can manually verify a player impostor.", usage = "/<command> <code | <playername>>")
|
||||
public class Command_verify extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
boolean verificationEnabled = ConfigEntry.DISCORD_VERIFICATION.getBoolean();
|
||||
if (!plugin.dc.enabled)
|
||||
{
|
||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!verificationEnabled)
|
||||
{
|
||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (senderIsConsole)
|
||||
{
|
||||
msg("/manuallyverify <playername>", ChatColor.WHITE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.pl.IsImpostor(playerSender))
|
||||
{
|
||||
msg("You are not an impostor, therefore you do not need to verify.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData playerData = plugin.pl.getData(playerSender);
|
||||
String discordId = playerData.getDiscordID();
|
||||
|
||||
if (playerData.getDiscordID() == null)
|
||||
{
|
||||
msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
String code = plugin.dc.generateCode(10);
|
||||
plugin.dc.addVerificationCode(code, playerData);
|
||||
plugin.dc.getUser(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + FUtil.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete();
|
||||
msg("A verification code has been sent to your account, please copy the code and run /verify <code>", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
String code = args[0];
|
||||
String backupCode = null;
|
||||
|
||||
if (plugin.pl.IsImpostor(playerSender))
|
||||
{
|
||||
PlayerData mapPlayer = plugin.dc.getVerificationCodes().get(code);
|
||||
if (mapPlayer == null)
|
||||
{
|
||||
if (!playerData.getBackupCodes().contains(Discord.getMD5(code)))
|
||||
{
|
||||
msg("You have entered an invalid verification code", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
backupCode = Discord.getMD5(code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.dc.removeVerificationCode(code);
|
||||
}
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
{
|
||||
fPlayer.getFreezeData().setFrozen(false);
|
||||
msg("You have been unfrozen.");
|
||||
}
|
||||
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
||||
playerSender.setOp(true);
|
||||
plugin.pl.verify(playerSender, backupCode);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import org.bukkit.command.Command;
|
||||
|
||||
public abstract class FreedomCMD extends Command
|
||||
{
|
||||
protected final TotalFreedomMod plugin = TotalFreedomMod.plugin();
|
||||
|
||||
private final CommandParameters parameters;
|
||||
private final CommandPermissions permissions;
|
||||
|
||||
public FreedomCMD() {
|
||||
super("");
|
||||
|
||||
this.parameters = this.getClass().getDeclaredAnnotation(CommandParameters.class);
|
||||
this.permissions = this.getClass().getDeclaredAnnotation(CommandPermissions.class);
|
||||
|
||||
this.setName(parameters.name());
|
||||
this.setLabel(parameters.name());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +1,12 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.command.exception.CommandFailException;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
|
@ -18,20 +14,15 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
{
|
||||
public static final String COMMAND_PREFIX = "Command_";
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class FreedomCommand implements CommandExecutor, TabCompleter {
|
||||
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
||||
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
||||
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
|
||||
|
@ -55,11 +46,10 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||
private final CommandPermissions perms;
|
||||
protected CommandSender sender;
|
||||
|
||||
FreedomCommand()
|
||||
{
|
||||
params = getClass().getAnnotation(CommandParameters.class);
|
||||
perms = getClass().getAnnotation(CommandPermissions.class);
|
||||
this.name = getClass().getSimpleName().replace(COMMAND_PREFIX, "").toLowerCase();
|
||||
public FreedomCommand() {
|
||||
this.params = getClass().getAnnotation(CommandParameters.class);
|
||||
this.perms = getClass().getAnnotation(CommandPermissions.class);
|
||||
this.name = params.name();
|
||||
this.description = params.description();
|
||||
this.usage = params.usage();
|
||||
this.aliases = params.aliases();
|
||||
|
@ -69,148 +59,109 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||
this.cooldown = perms.cooldown();
|
||||
}
|
||||
|
||||
public static CommandMap getCommandMap()
|
||||
{
|
||||
if (commandMap == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static CommandMap getCommandMap() {
|
||||
if (commandMap == null) {
|
||||
try {
|
||||
final Field f = Bukkit.getServer().getPluginManager().getClass().getDeclaredField("commandMap");
|
||||
f.setAccessible(true);
|
||||
commandMap = (CommandMap)f.get(Bukkit.getServer().getPluginManager());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
commandMap = (CommandMap) f.get(Bukkit.getServer().getPluginManager());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return commandMap;
|
||||
}
|
||||
|
||||
public static FreedomCommand getFrom(Command command)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (FreedomCommand)(((PluginCommand)command).getExecutor());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
public static FreedomCommand getFrom(Command command) {
|
||||
try {
|
||||
return (FreedomCommand) (((PluginCommand) command).getExecutor());
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getCommandPrefix()
|
||||
{
|
||||
return COMMAND_PREFIX;
|
||||
}
|
||||
|
||||
public void register()
|
||||
{
|
||||
public void register() {
|
||||
FCommand cmd = new FCommand(this.name);
|
||||
if (this.aliases != null)
|
||||
{
|
||||
if (this.aliases != null) {
|
||||
cmd.setAliases(Arrays.asList(StringUtils.split(this.aliases, ",")));
|
||||
}
|
||||
if (this.description != null)
|
||||
{
|
||||
if (this.description != null) {
|
||||
cmd.setDescription(this.description);
|
||||
}
|
||||
if (this.usage != null)
|
||||
{
|
||||
if (this.usage != null) {
|
||||
cmd.setUsage(this.usage);
|
||||
}
|
||||
getCommandMap().register("totalfreedommod", cmd);
|
||||
cmd.setExecutor(this);
|
||||
}
|
||||
|
||||
protected void msg(CommandSender sender, String message)
|
||||
{
|
||||
protected void msg(CommandSender sender, String message) {
|
||||
sender.sendMessage(ChatColor.GRAY + message);
|
||||
}
|
||||
|
||||
protected void msg(Player player, String message)
|
||||
{
|
||||
protected void msg(Player player, String message) {
|
||||
player.sendMessage(ChatColor.GRAY + message);
|
||||
}
|
||||
|
||||
protected void msg(Player player, String message, ChatColor color)
|
||||
{
|
||||
protected void msg(Player player, String message, ChatColor color) {
|
||||
player.sendMessage(color + message);
|
||||
}
|
||||
|
||||
protected void msg(String message)
|
||||
{
|
||||
protected void msg(String message) {
|
||||
msg(sender, message);
|
||||
}
|
||||
|
||||
protected void msg(String message, ChatColor color)
|
||||
{
|
||||
protected void msg(String message, ChatColor color) {
|
||||
msg(color + message);
|
||||
}
|
||||
|
||||
protected void msg(String message, net.md_5.bungee.api.ChatColor color)
|
||||
{
|
||||
protected void msg(String message, net.md_5.bungee.api.ChatColor color) {
|
||||
msg(color + message);
|
||||
}
|
||||
|
||||
protected boolean isAdmin(Player player)
|
||||
{
|
||||
return plugin.al.isAdmin(player);
|
||||
protected boolean isAdmin(Player player) {
|
||||
return plugin.adminList.isAdmin(player);
|
||||
}
|
||||
|
||||
protected boolean isAdmin(CommandSender sender)
|
||||
{
|
||||
return plugin.al.isAdmin(sender);
|
||||
protected boolean isAdmin(CommandSender sender) {
|
||||
return plugin.adminList.isAdmin(sender);
|
||||
}
|
||||
|
||||
protected void checkConsole()
|
||||
{
|
||||
if (!isConsole())
|
||||
{
|
||||
protected void checkConsole() {
|
||||
if (!isConsole()) {
|
||||
throw new CommandFailException(ONLY_CONSOLE);
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkPlayer()
|
||||
{
|
||||
if (isConsole())
|
||||
{
|
||||
protected void checkPlayer() {
|
||||
if (isConsole()) {
|
||||
throw new CommandFailException(ONLY_IN_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkRank(Rank rank)
|
||||
{
|
||||
if (!plugin.rm.getRank(sender).isAtLeast(rank))
|
||||
{
|
||||
protected void checkRank(Rank rank) {
|
||||
if (!plugin.rankManager.getRank(sender).isAtLeast(rank)) {
|
||||
noPerms();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String commandLabel, @NotNull String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
boolean run = run(sender, sender instanceof ConsoleCommandSender ? null : (Player)sender, cmd, commandLabel, args, sender instanceof ConsoleCommandSender);
|
||||
if (!run)
|
||||
{
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
try {
|
||||
boolean run = run(sender, sender instanceof ConsoleCommandSender ? null : (Player) sender, cmd, commandLabel, args, sender instanceof ConsoleCommandSender);
|
||||
if (!run) {
|
||||
msg(ChatColor.WHITE + cmd.getUsage().replace("<command>", cmd.getLabel()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (CommandFailException ex)
|
||||
{
|
||||
} catch (CommandFailException ex) {
|
||||
msg(ChatColor.RED + ex.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args)
|
||||
{
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
List<String> options = getTabCompleteOptions(sender, command, alias, args);
|
||||
if (options == null)
|
||||
{
|
||||
if (options == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.newArrayList());
|
||||
|
@ -218,136 +169,108 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||
|
||||
public abstract boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole);
|
||||
|
||||
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
|
||||
protected boolean isConsole()
|
||||
{
|
||||
protected boolean isConsole() {
|
||||
return sender instanceof ConsoleCommandSender;
|
||||
}
|
||||
|
||||
protected Player getPlayer(String name)
|
||||
{
|
||||
protected Player getPlayer(String name) {
|
||||
return Bukkit.getPlayer(name);
|
||||
}
|
||||
|
||||
protected Player getPlayer(String name, Boolean nullVanished)
|
||||
{
|
||||
protected Player getPlayer(String name, Boolean nullVanished) {
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
if (nullVanished && plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
if (player != null) {
|
||||
if (nullVanished && plugin.adminList.isVanished(player.getName()) && !plugin.adminList.isAdmin(sender)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
protected Admin getAdmin(CommandSender sender)
|
||||
{
|
||||
return plugin.al.getAdmin(sender);
|
||||
protected Admin getAdmin(CommandSender sender) {
|
||||
return plugin.adminList.getAdmin(sender);
|
||||
}
|
||||
|
||||
protected Admin getAdmin(Player player)
|
||||
{
|
||||
return plugin.al.getAdmin(player);
|
||||
protected Admin getAdmin(Player player) {
|
||||
return plugin.adminList.getAdmin(player);
|
||||
}
|
||||
|
||||
protected PlayerData getData(Player player)
|
||||
{
|
||||
return plugin.pl.getData(player);
|
||||
protected PlayerData getData(Player player) {
|
||||
return plugin.playerList.getData(player);
|
||||
}
|
||||
|
||||
protected boolean noPerms()
|
||||
{
|
||||
protected boolean noPerms() {
|
||||
throw new CommandFailException(NO_PERMISSION);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getUsage()
|
||||
{
|
||||
public String getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
public String getAliases()
|
||||
{
|
||||
public String getAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public Rank getLevel()
|
||||
{
|
||||
public Rank getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public SourceType getSource()
|
||||
{
|
||||
public SourceType getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public boolean isBlockHostConsole()
|
||||
{
|
||||
public boolean isBlockHostConsole() {
|
||||
return blockHostConsole;
|
||||
}
|
||||
|
||||
public int getCooldown()
|
||||
{
|
||||
public int getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
public CommandParameters getParams()
|
||||
{
|
||||
public CommandParameters getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public CommandPermissions getPerms()
|
||||
{
|
||||
public CommandPermissions getPerms() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
private final class FCommand extends Command
|
||||
{
|
||||
private final class FCommand extends Command {
|
||||
private FreedomCommand cmd = null;
|
||||
|
||||
private FCommand(String command)
|
||||
{
|
||||
private FCommand(String command) {
|
||||
super(command);
|
||||
}
|
||||
|
||||
public void setExecutor(FreedomCommand cmd)
|
||||
{
|
||||
public void setExecutor(FreedomCommand cmd) {
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, String[] args)
|
||||
{
|
||||
if (cmd != null)
|
||||
{
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, String[] args) {
|
||||
if (cmd != null) {
|
||||
cmd.sender = sender;
|
||||
|
||||
if (func4())
|
||||
{
|
||||
if (func4()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (func1())
|
||||
{
|
||||
if (func1()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (func2())
|
||||
{
|
||||
if (func2()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -358,16 +281,13 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean func1()
|
||||
{
|
||||
if (perms.source() == SourceType.ONLY_CONSOLE && sender instanceof Player)
|
||||
{
|
||||
public boolean func1() {
|
||||
if (perms.source() == SourceType.ONLY_CONSOLE && sender instanceof Player) {
|
||||
msg(ONLY_CONSOLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.source() == SourceType.ONLY_IN_GAME && sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
if (perms.source() == SourceType.ONLY_IN_GAME && sender instanceof ConsoleCommandSender) {
|
||||
msg(ONLY_IN_GAME);
|
||||
return true;
|
||||
}
|
||||
|
@ -375,42 +295,33 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean func2()
|
||||
{
|
||||
if (!plugin.rm.getRank(sender).isAtLeast(perms.level()))
|
||||
{
|
||||
public boolean func2() {
|
||||
if (!plugin.rankManager.getRank(sender).isAtLeast(perms.level())) {
|
||||
msg(NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()) && !FUtil.inDeveloperMode())
|
||||
{
|
||||
if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()) && !FUtil.inDeveloperMode()) {
|
||||
msg(ChatColor.RED + "Host console is not allowed to use this command!");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void func3()
|
||||
{
|
||||
if (perms.cooldown() != 0 && !isAdmin(sender))
|
||||
{
|
||||
public void func3() {
|
||||
if (perms.cooldown() != 0 && !isAdmin(sender)) {
|
||||
COOLDOWN_TIMERS.put(sender, cmd);
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
public void run() {
|
||||
COOLDOWN_TIMERS.remove(sender);
|
||||
}
|
||||
}, perms.cooldown() * 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean func4()
|
||||
{
|
||||
if (COOLDOWN_TIMERS.containsKey(sender) && COOLDOWN_TIMERS.containsValue(cmd))
|
||||
{
|
||||
public boolean func4() {
|
||||
if (COOLDOWN_TIMERS.containsKey(sender) && COOLDOWN_TIMERS.containsValue(cmd)) {
|
||||
msg(ChatColor.RED + "You are on cooldown for this command.");
|
||||
return true;
|
||||
}
|
||||
|
@ -419,10 +330,8 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, String[] args)
|
||||
{
|
||||
if (cmd != null)
|
||||
{
|
||||
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, String[] args) {
|
||||
if (cmd != null) {
|
||||
return cmd.onTabComplete(sender, this, alias, args);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
public enum SourceType
|
||||
{
|
||||
ONLY_IN_GAME, ONLY_CONSOLE, BOTH
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package me.totalfreedom.totalfreedommod.command.exception;
|
||||
|
||||
public class CommandFailException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -92333791173123L;
|
||||
|
||||
public CommandFailException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.World;
|
||||
|
@ -10,21 +14,16 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Clears lingering potion area effect clouds.", usage = "/<command>", aliases = "aec")
|
||||
public class Command_aeclear extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "aeclear", description = "Clears lingering potion area effect clouds.", usage = "/<command>", aliases = "aec")
|
||||
public class AEClearCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
FUtil.adminAction(sender.getName(), "Removing all area effect clouds", true);
|
||||
int removed = 0;
|
||||
for (World world : server.getWorlds())
|
||||
{
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
if (entity instanceof AreaEffectCloud)
|
||||
{
|
||||
for (World world : server.getWorlds()) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity instanceof AreaEffectCloud) {
|
||||
entity.remove();
|
||||
removed++;
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -8,28 +12,22 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Talk privately with other admins on the server.", usage = "/<command> [message]", aliases = "o,sc,ac,staffchat")
|
||||
public class Command_adminchat extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "adminchat", description = "Talk privately with other admins on the server.", usage = "/<command> [message]", aliases = "o,sc,ac,staffchat")
|
||||
public class AdminChatCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (senderIsConsole)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length == 0) {
|
||||
if (senderIsConsole) {
|
||||
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);
|
||||
FPlayer userinfo = plugin.playerList.getPlayer(playerSender);
|
||||
userinfo.setAdminChat(!userinfo.inAdminChat());
|
||||
msg("Admin chat turned " + (userinfo.inAdminChat() ? "on" : "off") + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.cm.adminChat(sender, StringUtils.join(args, " "));
|
||||
} else {
|
||||
plugin.chatManager.adminChat(sender, StringUtils.join(args, " "));
|
||||
}
|
||||
return true;
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
|
@ -17,81 +16,70 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "List, add, remove, or set the rank of admins, clean or reload the admin list, or view admin information.", usage = "/<command> <list | clean | reload | | setrank <username> <rank> | <add | remove | info> <username>>", aliases = "slconfig")
|
||||
public class Command_saconfig extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "saconfig", description = "List, add, remove, or set the rank of admins, clean or reload the admin list, or view admin information.", usage = "/<command> <list | clean | reload | | setrank <username> <rank> | <add | remove | info> <username>>", aliases = "slconfig")
|
||||
public class AdminConfigCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (args[0])
|
||||
{
|
||||
case "list":
|
||||
{
|
||||
msg("Admins: " + StringUtils.join(plugin.al.getAdminNames(), ", "), ChatColor.GOLD);
|
||||
switch (args[0]) {
|
||||
case "list": {
|
||||
msg("Admins: " + StringUtils.join(plugin.adminList.getAdminNames(), ", "), ChatColor.GOLD);
|
||||
return true;
|
||||
}
|
||||
|
||||
case "clean":
|
||||
{
|
||||
case "clean": {
|
||||
checkConsole();
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Cleaning the admin list", true);
|
||||
plugin.al.deactivateOldEntries(true);
|
||||
msg("Admins: " + StringUtils.join(plugin.al.getAdminNames(), ", "), ChatColor.GOLD);
|
||||
plugin.adminList.deactivateOldEntries(true);
|
||||
msg("Admins: " + StringUtils.join(plugin.adminList.getAdminNames(), ", "), ChatColor.GOLD);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case "reload":
|
||||
{
|
||||
case "reload": {
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Reloading the admin list", true);
|
||||
plugin.al.load();
|
||||
plugin.adminList.load();
|
||||
msg("Admin list reloaded!");
|
||||
return true;
|
||||
}
|
||||
|
||||
case "setrank":
|
||||
{
|
||||
case "setrank": {
|
||||
checkConsole();
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
if (args.length < 3)
|
||||
{
|
||||
if (args.length < 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Rank rank = Rank.findRank(args[2]);
|
||||
if (rank == null)
|
||||
{
|
||||
if (rank == null) {
|
||||
msg("Unknown rank: " + args[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rank.isConsole())
|
||||
{
|
||||
if (rank.isConsole()) {
|
||||
msg("You cannot set players to a console rank");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!rank.isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
if (!rank.isAtLeast(Rank.ADMIN)) {
|
||||
msg("Rank must be Admin or higher.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
Admin admin = plugin.al.getEntryByName(args[1]);
|
||||
if (admin == null)
|
||||
{
|
||||
Admin admin = plugin.adminList.getEntryByName(args[1]);
|
||||
if (admin == null) {
|
||||
msg("Unknown admin: " + args[1]);
|
||||
return true;
|
||||
}
|
||||
|
@ -99,61 +87,50 @@ public class Command_saconfig extends FreedomCommand
|
|||
FUtil.adminAction(sender.getName(), "Setting " + admin.getName() + "'s rank to " + rank.getName(), true);
|
||||
|
||||
admin.setRank(rank);
|
||||
plugin.al.save(admin);
|
||||
plugin.adminList.save(admin);
|
||||
|
||||
Player player = getPlayer(admin.getName());
|
||||
if (player != null)
|
||||
{
|
||||
plugin.rm.updateDisplay(player);
|
||||
if (player != null) {
|
||||
plugin.rankManager.updateDisplay(player);
|
||||
}
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
if (plugin.discord.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) {
|
||||
Discord.syncRoles(admin, plugin.playerList.getData(admin.getName()).getDiscordID());
|
||||
}
|
||||
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
plugin.pterodactyl.updateAccountStatus(admin);
|
||||
|
||||
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
case "info":
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
case "info": {
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
checkRank(Rank.ADMIN);
|
||||
|
||||
Admin admin = plugin.al.getEntryByName(args[1]);
|
||||
Admin admin = plugin.adminList.getEntryByName(args[1]);
|
||||
|
||||
if (admin == null)
|
||||
{
|
||||
if (admin == null) {
|
||||
final Player player = getPlayer(args[1]);
|
||||
if (player != null)
|
||||
{
|
||||
admin = plugin.al.getAdmin(player);
|
||||
if (player != null) {
|
||||
admin = plugin.adminList.getAdmin(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (admin == null)
|
||||
{
|
||||
if (admin == null) {
|
||||
msg("Admin not found: " + args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
msg(admin.toString());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case "add":
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
case "add": {
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -163,14 +140,12 @@ public class Command_saconfig extends FreedomCommand
|
|||
// Player already admin?
|
||||
final Player player = getPlayer(args[1]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
if (player == null) {
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
if (plugin.adminList.isAdmin(player)) {
|
||||
msg("That player is already an admin.");
|
||||
return true;
|
||||
}
|
||||
|
@ -178,17 +153,14 @@ public class Command_saconfig extends FreedomCommand
|
|||
// Find the old admin entry
|
||||
String name = player.getName();
|
||||
Admin admin = null;
|
||||
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
||||
{
|
||||
if (loopAdmin.getName().equalsIgnoreCase(name) || loopAdmin.getIps().contains(FUtil.getIp(player)))
|
||||
{
|
||||
for (Admin loopAdmin : plugin.adminList.getAllAdmins()) {
|
||||
if (loopAdmin.getName().equalsIgnoreCase(name) || loopAdmin.getIps().contains(FUtil.getIp(player))) {
|
||||
admin = loopAdmin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.pl.isPlayerImpostor(player))
|
||||
{
|
||||
if (plugin.playerList.isPlayerImpostor(player)) {
|
||||
msg("This player was labeled as a Player impostor and is not an admin, therefore they cannot be added to the admin list.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
@ -199,16 +171,14 @@ public class Command_saconfig extends FreedomCommand
|
|||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
||||
admin = new Admin(player);
|
||||
|
||||
plugin.al.addAdmin(admin);
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
else // Existing admin
|
||||
plugin.adminList.addAdmin(admin);
|
||||
plugin.rankManager.updateDisplay(player);
|
||||
} else // Existing admin
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the admin list", true);
|
||||
|
||||
String oldName = admin.getName();
|
||||
if (!oldName.equals(player.getName()))
|
||||
{
|
||||
if (!oldName.equals(player.getName())) {
|
||||
admin.setName(player.getName());
|
||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||
}
|
||||
|
@ -217,41 +187,35 @@ public class Command_saconfig extends FreedomCommand
|
|||
admin.setActive(true);
|
||||
admin.setLastLogin(new Date());
|
||||
|
||||
if (plugin.al.isVerifiedAdmin(player))
|
||||
{
|
||||
plugin.al.verifiedNoAdmin.remove(player.getName());
|
||||
if (plugin.adminList.isVerifiedAdmin(player)) {
|
||||
plugin.adminList.verifiedNoAdmin.remove(player.getName());
|
||||
}
|
||||
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
plugin.rm.updateDisplay(player);
|
||||
plugin.adminList.save(admin);
|
||||
plugin.adminList.updateTables();
|
||||
plugin.rankManager.updateDisplay(player);
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
Discord.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||
if (plugin.discord.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) {
|
||||
Discord.syncRoles(admin, plugin.playerList.getData(player).getDiscordID());
|
||||
}
|
||||
}
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
plugin.pterodactyl.updateAccountStatus(admin);
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
{
|
||||
final FPlayer fPlayer = plugin.playerList.getPlayer(player);
|
||||
if (fPlayer.getFreezeData().isFrozen()) {
|
||||
fPlayer.getFreezeData().setFrozen(false);
|
||||
msg(player, "You have been unfrozen.");
|
||||
}
|
||||
|
||||
if (!player.isOp())
|
||||
{
|
||||
if (!player.isOp()) {
|
||||
player.setOp(true);
|
||||
msg(player, YOU_ARE_OP);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case "remove":
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
case "remove": {
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -259,10 +223,9 @@ public class Command_saconfig extends FreedomCommand
|
|||
checkRank(Rank.ADMIN);
|
||||
|
||||
Player player = getPlayer(args[1]);
|
||||
Admin admin = player != null ? plugin.al.getAdmin(player) : plugin.al.getEntryByName(args[1]);
|
||||
Admin admin = player != null ? plugin.adminList.getAdmin(player) : plugin.adminList.getEntryByName(args[1]);
|
||||
|
||||
if (admin == null)
|
||||
{
|
||||
if (admin == null) {
|
||||
msg("Admin not found: " + args[1]);
|
||||
return true;
|
||||
}
|
||||
|
@ -270,58 +233,49 @@ public class Command_saconfig extends FreedomCommand
|
|||
FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true);
|
||||
admin.setActive(false);
|
||||
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
if (player != null)
|
||||
{
|
||||
plugin.rm.updateDisplay(player);
|
||||
plugin.pl.getPlayer(player).setAdminChat(false);
|
||||
plugin.adminList.save(admin);
|
||||
plugin.adminList.updateTables();
|
||||
if (player != null) {
|
||||
plugin.rankManager.updateDisplay(player);
|
||||
plugin.playerList.getPlayer(player).setAdminChat(false);
|
||||
}
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
if (plugin.discord.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) {
|
||||
Discord.syncRoles(admin, plugin.playerList.getData(admin.getName()).getDiscordID());
|
||||
}
|
||||
|
||||
plugin.ptero.updateAccountStatus(admin);
|
||||
plugin.pterodactyl.updateAccountStatus(admin);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.add("list");
|
||||
if (plugin.al.isAdmin(sender))
|
||||
{
|
||||
if (plugin.adminList.isAdmin(sender)) {
|
||||
arguments.add("info");
|
||||
arguments.add("add");
|
||||
arguments.add("remove");
|
||||
}
|
||||
if (plugin.al.isSeniorAdmin(sender))
|
||||
{
|
||||
if (plugin.adminList.isSeniorAdmin(sender)) {
|
||||
arguments.add("reload");
|
||||
arguments.add("clean");
|
||||
arguments.add("setrank");
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
if (args.length == 2 && (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info")))
|
||||
{
|
||||
if (args.length == 2 && (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info"))) {
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
if (args.length == 3 && args[0].equals("setrank"))
|
||||
{
|
||||
if (args.length == 3 && args[0].equals("setrank")) {
|
||||
return Arrays.asList("ADMIN", "SENIOR_ADMIN");
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
|
@ -10,22 +13,19 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "si,ai,staffinfo")
|
||||
public class Command_admininfo extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "admininfo", description = "Information on how to apply for admin.", usage = "/<command>", aliases = "si,ai,staffinfo")
|
||||
public class AdminInfoCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
List<String> adminInfo = ConfigEntry.ADMIN_INFO.getStringList();
|
||||
|
||||
if (adminInfo.isEmpty())
|
||||
{
|
||||
if (adminInfo.isEmpty()) {
|
||||
msg("The admin information section of the config.yml file has not been configured.", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
msg(FUtil.colorize(StringUtils.join(adminInfo, "\n")));
|
||||
}
|
||||
return true;
|
|
@ -1,8 +1,9 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
|
@ -10,33 +11,29 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]", aliases = "staffmode")
|
||||
public class Command_adminmode extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "adminmode", description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]", aliases = "staffmode")
|
||||
public class AdminModeCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("off")) {
|
||||
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"))
|
||||
{
|
||||
} else if (args[0].equalsIgnoreCase("on")) {
|
||||
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
||||
FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!isAdmin(player))
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers()) {
|
||||
if (!isAdmin(player)) {
|
||||
player.kickPlayer("Server is now closed to non-admins.");
|
||||
}
|
||||
}
|
||||
|
@ -47,10 +44,8 @@ public class Command_adminmode extends FreedomCommand
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender) && !(sender instanceof Player))
|
||||
{
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if (args.length == 1 && plugin.adminList.isAdmin(sender) && !(sender instanceof Player)) {
|
||||
return Arrays.asList("on", "off");
|
||||
}
|
||||
|
|
@ -1,140 +1,108 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||
import me.totalfreedom.totalfreedommod.world.manager.WorldTime;
|
||||
import me.totalfreedom.totalfreedommod.world.manager.WorldWeather;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Allows for admins to configure time, and weather of the AdminWorld, and allows for admins and ops to go to the AdminWorld.",
|
||||
@CommandParameters(name = "adminworld", 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,aw,staffworld")
|
||||
public class Command_adminworld extends FreedomCommand
|
||||
{
|
||||
public class AdminWorldCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
CommandMode commandMode = null;
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (args.length == 0) {
|
||||
commandMode = CommandMode.TELEPORT;
|
||||
}
|
||||
else if (args.length >= 2)
|
||||
{
|
||||
if ("time".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
} else if (args.length >= 2) {
|
||||
if ("time".equalsIgnoreCase(args[0])) {
|
||||
commandMode = CommandMode.TIME;
|
||||
}
|
||||
else if ("weather".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
} else if ("weather".equalsIgnoreCase(args[0])) {
|
||||
commandMode = CommandMode.WEATHER;
|
||||
}
|
||||
}
|
||||
|
||||
if (commandMode == null)
|
||||
{
|
||||
if (commandMode == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (commandMode)
|
||||
{
|
||||
case TELEPORT:
|
||||
{
|
||||
if (!(sender instanceof Player) || playerSender == null)
|
||||
{
|
||||
try {
|
||||
switch (commandMode) {
|
||||
case TELEPORT: {
|
||||
if (!(sender instanceof Player) || playerSender == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
World adminWorld = null;
|
||||
try
|
||||
{
|
||||
adminWorld = plugin.wm.adminworld.getWorld();
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
try {
|
||||
adminWorld = plugin.worldManager.adminworld.getWorld();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
if (adminWorld == null || playerSender.getWorld() == adminWorld)
|
||||
{
|
||||
if (adminWorld == null || playerSender.getWorld() == adminWorld) {
|
||||
msg("Going to the main world.");
|
||||
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
msg("Going to the AdminWorld.");
|
||||
plugin.wm.adminworld.sendToWorld(playerSender);
|
||||
plugin.worldManager.adminworld.sendToWorld(playerSender);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TIME:
|
||||
{
|
||||
case TIME: {
|
||||
assertCommandPerms(sender, playerSender);
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (args.length == 2) {
|
||||
WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
|
||||
if (timeOfDay != null)
|
||||
{
|
||||
plugin.wm.adminworld.setTimeOfDay(timeOfDay);
|
||||
if (timeOfDay != null) {
|
||||
plugin.worldManager.adminworld.setTimeOfDay(timeOfDay);
|
||||
msg("AdminWorld time set to: " + timeOfDay.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
msg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case WEATHER:
|
||||
{
|
||||
case WEATHER: {
|
||||
assertCommandPerms(sender, playerSender);
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (args.length == 2) {
|
||||
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
|
||||
if (weatherMode != null)
|
||||
{
|
||||
plugin.wm.adminworld.setWeatherMode(weatherMode);
|
||||
if (weatherMode != null) {
|
||||
plugin.worldManager.adminworld.setWeatherMode(weatherMode);
|
||||
msg("AdminWorld weather set to: " + weatherMode.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
msg("Invalid weather mode. Can be: off, rain, storm");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (PermissionDeniedException ex)
|
||||
{
|
||||
if (ex.getMessage().isEmpty())
|
||||
{
|
||||
} catch (PermissionDeniedException ex) {
|
||||
if (ex.getMessage().isEmpty()) {
|
||||
return noPerms();
|
||||
}
|
||||
msg(ex.getMessage());
|
||||
|
@ -145,56 +113,42 @@ public class Command_adminworld extends FreedomCommand
|
|||
}
|
||||
|
||||
// TODO: Redo this properly
|
||||
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
||||
{
|
||||
if (!(sender instanceof Player) || playerSender == null || !isAdmin(sender))
|
||||
{
|
||||
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException {
|
||||
if (!(sender instanceof Player) || playerSender == null || !isAdmin(sender)) {
|
||||
throw new PermissionDeniedException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
{
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if (!plugin.adminList.isAdmin(sender)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args.length == 1) {
|
||||
return Arrays.asList("time", "weather");
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equals("time"))
|
||||
{
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equals("time")) {
|
||||
return Arrays.asList("morning", "noon", "evening", "night");
|
||||
}
|
||||
else if (args[0].equals("weather"))
|
||||
{
|
||||
} else if (args[0].equals("weather")) {
|
||||
return Arrays.asList("off", "rain", "storm");
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private enum CommandMode
|
||||
{
|
||||
private enum CommandMode {
|
||||
TELEPORT, TIME, WEATHER
|
||||
}
|
||||
|
||||
private static class PermissionDeniedException extends Exception
|
||||
{
|
||||
private static class PermissionDeniedException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PermissionDeniedException()
|
||||
{
|
||||
private PermissionDeniedException() {
|
||||
super("");
|
||||
}
|
||||
|
||||
private PermissionDeniedException(String string)
|
||||
{
|
||||
private PermissionDeniedException(String string) {
|
||||
super(string);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.GameMode;
|
||||
|
@ -8,17 +12,13 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Quickly change your own gamemode to adventure, define someone's username to change theirs, or change everyone's gamemode on the server.", usage = "/<command> <[partialname] | -a>", aliases = "gma")
|
||||
public class Command_adventure extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "adventure", description = "Quickly change your own gamemode to adventure, define someone's username to change theirs, or change everyone's gamemode on the server.", usage = "/<command> <[partialname] | -a>", aliases = "gma")
|
||||
public class AdventureCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (isConsole())
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length == 0) {
|
||||
if (isConsole()) {
|
||||
msg("When used from the console, you must define a target player.");
|
||||
return true;
|
||||
}
|
||||
|
@ -30,10 +30,8 @@ public class Command_adventure extends FreedomCommand
|
|||
|
||||
checkRank(Rank.ADMIN);
|
||||
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
for (Player targetPlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (args[0].equals("-a")) {
|
||||
for (Player targetPlayer : server.getOnlinePlayers()) {
|
||||
targetPlayer.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
|
||||
|
@ -44,8 +42,7 @@ public class Command_adventure extends FreedomCommand
|
|||
|
||||
Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
if (player == null) {
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(name = "announce", description = "Make an announcement anonymously to operators.", usage = "/<command> <message>")
|
||||
public class AnnounceCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
plugin.announcer.announce(StringUtils.join(args, " "));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -7,17 +11,14 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Lists all possible attributes.", usage = "/<command>")
|
||||
public class Command_attributelist extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "attributelist", description = "Lists all possible attributes.", usage = "/<command>", aliases = "attrlist")
|
||||
public class AttributeListCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
StringBuilder list = new StringBuilder("All possible attributes: ");
|
||||
|
||||
for (Attribute attribute : Attribute.values())
|
||||
{
|
||||
for (Attribute attribute : Attribute.values()) {
|
||||
list.append(attribute.name()).append(", ");
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(name = "autoclear", description = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>")
|
||||
public class AutoClearCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean enabled = plugin.loginProcess.CLEAR_ON_JOIN.contains(args[0]);
|
||||
|
||||
if (enabled) {
|
||||
plugin.loginProcess.CLEAR_ON_JOIN.remove(args[0]);
|
||||
} else {
|
||||
plugin.loginProcess.CLEAR_ON_JOIN.add(args[0]);
|
||||
}
|
||||
|
||||
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " have their inventory cleared when they join.");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(name = "autotp", description = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
|
||||
public class AutoTPCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean enabled = plugin.loginProcess.TELEPORT_ON_JOIN.contains(args[0]);
|
||||
|
||||
if (enabled) {
|
||||
plugin.loginProcess.TELEPORT_ON_JOIN.remove(args[0]);
|
||||
} else {
|
||||
plugin.loginProcess.TELEPORT_ON_JOIN.add(args[0]);
|
||||
}
|
||||
|
||||
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " be automatically teleported when they join.");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import com.earth2me.essentials.User;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.punishments.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
|
@ -19,69 +21,64 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb | -q]", aliases = "gtfo")
|
||||
public class Command_ban extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "ban", description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb | -q]", aliases = "gtfo")
|
||||
public class BanCMD extends FreedomCommand {
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
boolean silent = false;
|
||||
boolean cancelRollback = false;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-nrb"))
|
||||
{
|
||||
if (args.length >= 2) {
|
||||
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q")) {
|
||||
if (args[args.length - 1].equalsIgnoreCase("-nrb")) {
|
||||
cancelRollback = true;
|
||||
}
|
||||
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q")) {
|
||||
silent = true;
|
||||
}
|
||||
|
||||
if (args.length >= 3)
|
||||
{
|
||||
if (args.length >= 3) {
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
}
|
||||
}
|
||||
|
||||
final String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
final String ip;
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
||||
return true;
|
||||
if (player == null) {
|
||||
// Gets the IP using Essentials data if available
|
||||
if (plugin.essentialsBridge.isEnabled() && plugin.essentialsBridge.getEssentialsUser(args[0]) != null) {
|
||||
User essUser = plugin.essentialsBridge.getEssentialsUser(args[0]);
|
||||
//
|
||||
username = essUser.getName();
|
||||
ip = essUser.getLastLoginAddress();
|
||||
}
|
||||
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
else
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(player);
|
||||
// Last resort - Getting the first result from the username itself
|
||||
else {
|
||||
PlayerData entry = plugin.playerList.getData(args[0]);
|
||||
if (entry == null) {
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
} else {
|
||||
username = entry.getName();
|
||||
ip = entry.getIps().get(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
username = player.getName();
|
||||
//ips.addAll(entry.getIps());/
|
||||
ips.add(FUtil.getIp(player));
|
||||
ip = FUtil.getIp(player);
|
||||
|
||||
// Deop
|
||||
player.setOp(false);
|
||||
|
@ -92,21 +89,16 @@ public class Command_ban extends FreedomCommand
|
|||
// Clear inventory
|
||||
player.getInventory().clear();
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
if (!silent) {
|
||||
// Strike with lightning
|
||||
final Location targetPos = player.getLocation();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
Objects.requireNonNull(targetPos.getWorld()).strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
msg("Banned " + player.getName() + " quietly.");
|
||||
}
|
||||
// Kill player
|
||||
|
@ -114,65 +106,50 @@ public class Command_ban extends FreedomCommand
|
|||
}
|
||||
|
||||
// Checks if CoreProtect is loaded and installed, and skips the rollback and uses CoreProtect directly
|
||||
if (!cancelRollback)
|
||||
{
|
||||
plugin.cpb.rollback(username);
|
||||
if (!cancelRollback) {
|
||||
plugin.coreProtectBridge.rollback(username);
|
||||
}
|
||||
|
||||
if (player != null && !silent)
|
||||
{
|
||||
if (player != null && !silent) {
|
||||
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||
}
|
||||
|
||||
// Ban player
|
||||
Ban ban;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
if (player != null) {
|
||||
ban = Ban.forPlayer(player, sender, null, reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ban = Ban.forPlayerName(username, sender, null, reason);
|
||||
}
|
||||
ban.addIp(ip);
|
||||
|
||||
for (String ip : ips)
|
||||
{
|
||||
ban.addIp(ip);
|
||||
ban.addIp(FUtil.getFuzzyIp(ip));
|
||||
}
|
||||
plugin.bm.addBan(ban);
|
||||
plugin.banManager.addBan(ban);
|
||||
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
if (!silent) {
|
||||
// Broadcast
|
||||
final StringBuilder bcast = new StringBuilder()
|
||||
.append("Banning: ")
|
||||
.append(username);
|
||||
if (reason != null)
|
||||
{
|
||||
if (reason != null) {
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||
}
|
||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + ip);
|
||||
FUtil.adminAction(sender.getName(), bcast.toString(), true);
|
||||
}
|
||||
|
||||
// Kick player and handle others on IP
|
||||
if (player != null)
|
||||
{
|
||||
if (player != null) {
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (FUtil.getIp(p).equals(FUtil.getIp(player)))
|
||||
{
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (FUtil.getIp(p).equals(FUtil.getIp(player))) {
|
||||
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Log ban
|
||||
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, reason));
|
||||
plugin.punishmentList.logPunishment(new Punishment(username, ip, sender.getName(), PunishmentType.BAN, reason));
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.punishments.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
|
@ -12,15 +16,12 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Bans the specified ip.", usage = "/<command> <ip> [reason] [-q]")
|
||||
public class Command_banip extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "banip", description = "Bans the specified ip.", usage = "/<command> <ip> [reason] [-q]")
|
||||
public class BanIPCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -30,49 +31,40 @@ public class Command_banip extends FreedomCommand
|
|||
|
||||
String ip = args[0];
|
||||
|
||||
if (FUtil.isValidIPv4(ip))
|
||||
{
|
||||
if (FUtil.isValidIPv4(ip)) {
|
||||
msg(ip + " is not a valid IP address", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.bm.getByIp(ip) != null)
|
||||
{
|
||||
if (plugin.banManager.getByIp(ip) != null) {
|
||||
msg("The IP " + ip + " is already banned", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q")) {
|
||||
silent = true;
|
||||
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args.length >= 2) {
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
}
|
||||
}
|
||||
else if (args.length > 1)
|
||||
{
|
||||
} else if (args.length > 1) {
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
}
|
||||
|
||||
// Ban player
|
||||
Ban ban = Ban.forPlayerIp(ip, sender, null, reason);
|
||||
plugin.bm.addBan(ban);
|
||||
plugin.banManager.addBan(ban);
|
||||
|
||||
// Kick player and handle others on IP
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (FUtil.getIp(player).equals(ip))
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers()) {
|
||||
if (FUtil.getIp(player).equals(ip)) {
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
if (!silent) {
|
||||
// Broadcast
|
||||
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
|
||||
String message = sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
|
||||
String message = sender.getName() + " - Banned " + (plugin.adminList.isAdmin(player) ? "the IP " + ip : "an IP");
|
||||
msg(player, message, ChatColor.RED);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(name = "banlist", description = "Shows all banned player names. Admins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||
public class BanListCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("purge")) {
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
||||
int amount = plugin.banManager.purge();
|
||||
msg("Purged " + amount + " player bans.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
msg(plugin.banManager.getAllBans().size() + " player bans ("
|
||||
+ plugin.banManager.getUsernameBans().size() + " usernames, "
|
||||
+ plugin.banManager.getIpBans().size() + " IPs)");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.punishments.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
|
@ -11,15 +15,12 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Bans the specified name.", usage = "/<command> <name> [reason] [-q]")
|
||||
public class Command_banname extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "banname", description = "Bans the specified name.", usage = "/<command> <name> [reason] [-q]")
|
||||
public class BanNameCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -29,38 +30,31 @@ public class Command_banname extends FreedomCommand
|
|||
|
||||
String name = args[0];
|
||||
|
||||
if (plugin.bm.getByUsername(name) != null)
|
||||
{
|
||||
if (plugin.banManager.getByUsername(name) != null) {
|
||||
msg("The name " + name + " is already banned", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q")) {
|
||||
silent = true;
|
||||
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args.length >= 2) {
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
}
|
||||
}
|
||||
else if (args.length > 1)
|
||||
{
|
||||
} else if (args.length > 1) {
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
}
|
||||
|
||||
// Ban player
|
||||
Ban ban = Ban.forPlayerName(name, sender, null, reason);
|
||||
plugin.bm.addBan(ban);
|
||||
plugin.banManager.addBan(ban);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
if (!silent) {
|
||||
FUtil.adminAction(sender.getName(), "Banned the name " + name, true);
|
||||
}
|
||||
|
||||
Player player = getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
if (player != null) {
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
}
|
||||
return true;
|
|
@ -1,8 +1,9 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.SplittableRandom;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -10,22 +11,23 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.SplittableRandom;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
|
||||
public class Command_bird extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "bird", description = "Spawns a random type of fish at your location.", usage = "/<command>")
|
||||
public class BirdCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
|
||||
playerSender.getWorld().spawnEntity(location, getRandomFish());
|
||||
msg(":goodbird:");
|
||||
return true;
|
||||
}
|
||||
|
||||
public EntityType getRandomFish()
|
||||
{
|
||||
public EntityType getRandomFish() {
|
||||
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
|
||||
SplittableRandom random = new SplittableRandom();
|
||||
return fishTypes.get(random.nextInt(fishTypes.size()));
|
|
@ -1,5 +1,9 @@
|
|||
package me.totalfreedom.totalfreedommod.command;
|
||||
package me.totalfreedom.totalfreedommod.command.impl;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandParameters;
|
||||
import me.totalfreedom.totalfreedommod.command.input.CommandPermissions;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.command.input.SourceType;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
|
@ -11,27 +15,21 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Block all commands for everyone on the server, or a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
||||
public class Command_blockcmd extends FreedomCommand
|
||||
{
|
||||
@CommandParameters(name = "blockcommand", description = "Block all commands for everyone on the server, or a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcmd,bc,bcmd")
|
||||
public class BlockCommandCMD extends FreedomCommand {
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
if (args.length != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equals("purge"))
|
||||
{
|
||||
if (args[0].equals("purge")) {
|
||||
FUtil.adminAction(sender.getName(), "Unblocking commands for all players", true);
|
||||
int counter = 0;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
if (playerdata.allCommandsBlocked())
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers()) {
|
||||
FPlayer playerdata = plugin.playerList.getPlayer(player);
|
||||
if (playerdata.allCommandsBlocked()) {
|
||||
counter += 1;
|
||||
playerdata.setCommandsBlocked(false);
|
||||
}
|
||||
|
@ -40,19 +38,16 @@ public class Command_blockcmd extends FreedomCommand
|
|||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
if (args[0].equals("-a")) {
|
||||
FUtil.adminAction(sender.getName(), "Blocking commands for all non-admins", true);
|
||||
int counter = 0;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (isAdmin(player))
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers()) {
|
||||
if (isAdmin(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
counter += 1;
|
||||
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
||||
plugin.playerList.getPlayer(player).setCommandsBlocked(true);
|
||||
msg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
||||
}
|
||||
|
||||
|
@ -62,28 +57,24 @@ public class Command_blockcmd extends FreedomCommand
|
|||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
if (player == null) {
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isAdmin(player))
|
||||
{
|
||||
if (isAdmin(player)) {
|
||||
msg(player.getName() + " is an admin, and cannot have their commands blocked.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
if (!playerdata.allCommandsBlocked())
|
||||
{
|
||||
FPlayer playerdata = plugin.playerList.getPlayer(player);
|
||||
if (!playerdata.allCommandsBlocked()) {
|
||||
FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
|
||||
playerdata.setCommandsBlocked(true);
|
||||
msg("Blocked commands for " + player.getName() + ".");
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.BLOCKCMD, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
plugin.punishmentList.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.BLOCKCMD, null));
|
||||
} else {
|
||||
msg("That players commands are already blocked.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue