mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-11 21:43:54 +00:00
1.16 Update (#219)
This commit is contained in:
@ -1,45 +1,59 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import net.pravian.aero.command.handler.SimpleCommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CommandLoader extends FreedomService
|
||||
{
|
||||
|
||||
@Getter
|
||||
private final SimpleCommandHandler<TotalFreedomMod> handler;
|
||||
private final List<FreedomCommand> commands;
|
||||
|
||||
public CommandLoader(TotalFreedomMod plugin)
|
||||
public CommandLoader()
|
||||
{
|
||||
super(plugin);
|
||||
|
||||
handler = new SimpleCommandHandler<>(plugin);
|
||||
commands = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
public void onStart()
|
||||
{
|
||||
handler.clearCommands();
|
||||
handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory(plugin));
|
||||
handler.setCommandClassPrefix("Command_");
|
||||
handler.setPermissionMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
handler.setOnlyConsoleMessage(ChatColor.RED + "This command can only be used from the console.");
|
||||
handler.setOnlyPlayerMessage(ChatColor.RED + "This command can only be used by players.");
|
||||
|
||||
handler.loadFrom(FreedomCommand.class.getPackage());
|
||||
handler.registerAll(plugin.getDescription().getName(), true);
|
||||
|
||||
FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
public void onStop()
|
||||
{
|
||||
handler.clearCommands();
|
||||
}
|
||||
|
||||
public void add(FreedomCommand command)
|
||||
{
|
||||
commands.add(command);
|
||||
command.register();
|
||||
}
|
||||
|
||||
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))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getCommandAmount()
|
||||
{
|
||||
return commands.size();
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -12,7 +12,7 @@ public class Command_announce extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -74,7 +73,7 @@ public class Command_ban extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getUsername();
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
else
|
||||
@ -82,7 +81,7 @@ public class Command_ban extends FreedomCommand
|
||||
final PlayerData entry = plugin.pl.getData(player);
|
||||
username = player.getName();
|
||||
//ips.addAll(entry.getIps());/
|
||||
ips.add(Ips.getIp(player));
|
||||
ips.add(FUtil.getIp(player));
|
||||
|
||||
// Deop
|
||||
player.setOp(false);
|
||||
@ -152,7 +151,7 @@ public class Command_ban extends FreedomCommand
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (Ips.getIp(p).equals(Ips.getIp(player)))
|
||||
if (FUtil.getIp(p).equals(FUtil.getIp(player)))
|
||||
{
|
||||
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
|
||||
}
|
||||
|
@ -2,13 +2,13 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.Random;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
|
||||
|
@ -48,14 +48,6 @@ public class Command_cage extends FreedomCommand
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
|
||||
if (fPlayer.getCageData().isCaged())
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
||||
final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
||||
playerdata.getCageData().setCaged(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
Material outerMaterial = Material.GLASS;
|
||||
Material innerMaterial = Material.AIR;
|
||||
if (args.length >= 2 && args[1] != null)
|
||||
|
@ -1,16 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
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)
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Clears the chat for players who are not opt-out.", usage = "/<command>", aliases = "cc")
|
||||
public class Command_clearchat extends FreedomCommand
|
||||
{
|
||||
@ -19,51 +15,12 @@ public class Command_clearchat extends FreedomCommand
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (plugin.al.isAdmin(playerSender))
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
boolean optedOut = false;
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
optedOut = true;
|
||||
}
|
||||
else if (plugin.mbl.isMasterBuilder(player) && plugin.mbl.getMasterBuilder(player).isClearChatOptOut())
|
||||
{
|
||||
optedOut = true;
|
||||
}
|
||||
else if (plugin.pv.getVerificationPlayer(player).getEnabled() && plugin.pv.getVerificationPlayer(player).isClearChatOptOut())
|
||||
{
|
||||
optedOut = true;
|
||||
}
|
||||
|
||||
if (!optedOut)
|
||||
{
|
||||
IntStream.range(0, 100).mapToObj(i -> "").forEach(player::sendMessage);
|
||||
}
|
||||
IntStream.range(0, 100).mapToObj(i -> "").forEach(player::sendMessage);
|
||||
}
|
||||
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
||||
}
|
||||
else if (plugin.mbl.isMasterBuilder(playerSender))
|
||||
{
|
||||
MasterBuilder mb = plugin.mbl.getMasterBuilder(playerSender);
|
||||
mb.setClearChatOptOut(!mb.isClearChatOptOut());
|
||||
msg((mb.isClearChatOptOut() ? "Opted-out of" : "Opted-in to") + " clear chat.");
|
||||
plugin.mbl.save();
|
||||
plugin.mbl.updateTables();
|
||||
}
|
||||
else if (plugin.pv.getVerificationPlayer(playerSender).getEnabled())
|
||||
{
|
||||
VPlayer vp = plugin.pv.getVerificationPlayer(playerSender);
|
||||
vp.setClearChatOptOut(!vp.isClearChatOptOut());
|
||||
msg((vp.isClearChatOptOut() ? "Opted-out of" : "Opted-in to") + " clear chat.");
|
||||
plugin.pv.saveVerificationData(vp);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Only Master Builders, admins, and players with verification enabled can opt-out of clear chat.", ChatColor.RED);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -67,7 +67,7 @@ public class Command_clearinventory extends FreedomCommand
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1 && plugin.al.isAdmin(playerSender))
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||
{
|
||||
List<String> players = FUtil.getPlayerList();
|
||||
players.add("-a");
|
||||
|
@ -0,0 +1,29 @@
|
||||
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))
|
||||
{
|
||||
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! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopData;
|
||||
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", usage = "/<command> [playername]")
|
||||
@CommandParameters(description = "Shows the amount of coins you have or another player has", usage = "/<command> [playername]")
|
||||
public class Command_coins extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -48,8 +48,8 @@ public class Command_coins extends FreedomCommand
|
||||
p = playerSender;
|
||||
}
|
||||
}
|
||||
ShopData sd = plugin.sh.getData(p);
|
||||
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
|
||||
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,10 +1,8 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -1,54 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Cuck someone - sends an unclearable title to the specified player.", usage = "/<command> <player>")
|
||||
public class Command_cuck extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (FUtil.isPaper())
|
||||
{
|
||||
msg("This command won't work on Paper!", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
player.remove();
|
||||
msg("Cucked " + player.getName());
|
||||
player.sendTitle(ChatColor.DARK_RED + "HAHA CUCKED", ChatColor.RED + "relog if u want to be uncucked loser", 20, 200, 60);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -4,10 +4,10 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Curse someone - sends a cursed texture pack to the specified player.", usage = "/<command> <player>")
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.libsdisguises.BlockedDisguises;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
@ -21,7 +20,7 @@ public class Command_disguisetoggle extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), (BlockedDisguises.disabled ? "Enabling" : "Disabling") + " disguises", false);
|
||||
FUtil.adminAction(sender.getName(), (plugin.ldb.isDisguisesEnabled() ? "Disabling" : "Enabling") + " disguises", false);
|
||||
|
||||
if (plugin.ldb.isDisguisesEnabled())
|
||||
{
|
||||
@ -33,7 +32,7 @@ public class Command_disguisetoggle extends FreedomCommand
|
||||
plugin.ldb.setDisguisesEnabled(true);
|
||||
}
|
||||
|
||||
msg("Disguises are now " + (BlockedDisguises.disabled ? "disabled." : "enabled."));
|
||||
msg("Disguises are now " + (plugin.ldb.isDisguisesEnabled() ? "enabled." : "disabled."));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,87 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
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.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Adds or removes donators", usage = "/<command> <mode> <name> <ip> <package> [forum_user]")
|
||||
public class Command_donator extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!FUtil.isFromHostConsole(sender.getName()) && !ConfigEntry.SERVER_OWNERS.getStringList().contains(sender.getName()))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
|
||||
Boolean mode = args[0].equals("add");
|
||||
String name = args[1];
|
||||
String ip = args[2];
|
||||
String pkg = args[3];
|
||||
String forum_id = null;
|
||||
|
||||
if (args.length > 4)
|
||||
{
|
||||
forum_id = args[4];
|
||||
}
|
||||
|
||||
PlayerData data = plugin.pl.getData(name);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = plugin.pl.getDataByIp(ip);
|
||||
}
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
data.setDonator(mode);
|
||||
plugin.pl.save(data);
|
||||
}
|
||||
|
||||
Player player = getPlayer(name);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
|
||||
if (forum_id != null && !forum_id.equals("0"))
|
||||
{
|
||||
String baseurl = ConfigEntry.DONATION_PROBOARDS_URL.getString();
|
||||
String group_id = ConfigEntry.DONATION_GROUP_ID.getString();
|
||||
String session_id = ConfigEntry.DONATION_SESSION_ID.getString();
|
||||
String csrf_token = ConfigEntry.DONATION_CSRF_TOKEN.getString();
|
||||
if (baseurl == null || group_id == null || session_id == null || csrf_token == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
String url = baseurl + "/user/group_members/" + (mode ? "adding" : "remove");
|
||||
List<String> headers = Arrays.asList("Cookie:session_id=" + session_id, "X-Requested-With:XMLHttpRequest");
|
||||
String payload = "group_id=" + group_id + "&user_ids[]=" + forum_id + "&csrf_token=" + csrf_token;
|
||||
|
||||
try
|
||||
{
|
||||
String result = FUtil.postRequestToEndpoint(url, "POST", headers, payload);
|
||||
msg(result);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -7,8 +7,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -55,7 +53,7 @@ public class Command_doom extends FreedomCommand
|
||||
plugin.al.updateTables();
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
plugin.dc.syncRoles(admin);
|
||||
plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +98,7 @@ public class Command_doom extends FreedomCommand
|
||||
final String kickReason = (reason == null ? "FUCKOFF, and get your shit together!" : reason);
|
||||
|
||||
// Log doom
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.DOOM, reason));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.DOOM, reason));
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
|
@ -4,12 +4,11 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Surprise someone.", usage = "/<command> <player>")
|
||||
@ -32,10 +31,26 @@ public class Command_explode extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Exploded " + player.getName());
|
||||
player.setHealth(0.0);
|
||||
player.getWorld().createExplosion(player.getLocation(), 0F, false);
|
||||
|
||||
player.setFlying(false);
|
||||
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 50, 0)));
|
||||
for (int i = 1; i <= 3; i++)
|
||||
{
|
||||
FUtil.createExplosionOnDelay(player.getLocation(), 2L, i * 10);
|
||||
}
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
player.getWorld().strikeLightning(player.getLocation());
|
||||
player.getWorld().createExplosion(player.getLocation(), 4L);
|
||||
}
|
||||
player.setHealth(0.0);
|
||||
msg("Exploded " + player.getName());
|
||||
}
|
||||
}.runTaskLater(plugin, 40);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class Command_fireball extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
|
||||
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);
|
||||
|
@ -1,211 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
|
||||
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.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(
|
||||
description = "Use admin commands on someone by hash. Use mode 'list' to get a player's hash. Other modes are kick, nameban, ipban, ban, op, deop, ci, fr, smite.",
|
||||
usage = "/<command> [list | [<kick | nameban | ipban | ban | op | deop | ci | fr | smite> <targethash>] ]")
|
||||
//codebeat:disable
|
||||
//basically a deprecated command that still exists
|
||||
public class Command_gadmin extends FreedomCommand
|
||||
{
|
||||
|
||||
private enum GadminMode
|
||||
{
|
||||
|
||||
LIST("list"),
|
||||
KICK("kick"),
|
||||
NAMEBAN("nameban"),
|
||||
IPBAN("ipban"),
|
||||
BAN("ban"),
|
||||
OP("op"),
|
||||
DEOP("deop"),
|
||||
CI("ci"),
|
||||
FR("fr"),
|
||||
SMITE("smite");
|
||||
private final String modeName;
|
||||
|
||||
private GadminMode(String command)
|
||||
{
|
||||
this.modeName = command;
|
||||
}
|
||||
|
||||
public String getModeName()
|
||||
{
|
||||
return modeName;
|
||||
}
|
||||
|
||||
public static GadminMode findMode(String needle)
|
||||
{
|
||||
for (final GadminMode mode : GadminMode.values())
|
||||
{
|
||||
if (needle.equalsIgnoreCase(mode.getModeName()))
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getPlayerHash(Player player)
|
||||
{
|
||||
return UUID.nameUUIDFromBytes(player.getName().toLowerCase().getBytes(StandardCharsets.UTF_8)).toString().substring(0, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final GadminMode mode = GadminMode.findMode(args[0].toLowerCase());
|
||||
if (mode == null)
|
||||
{
|
||||
msg("Invalid mode: " + args[0], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
final Iterator<? extends Player> it = server.getOnlinePlayers().iterator();
|
||||
|
||||
if (mode == GadminMode.LIST)
|
||||
{
|
||||
msg("[ Real Name ] : [ Display Name ] - Hash:");
|
||||
while (it.hasNext())
|
||||
{
|
||||
final Player player = it.next();
|
||||
sender.sendMessage(ChatColor.GRAY + String.format("[ %s ] : [ %s ] - %s",
|
||||
player.getName(),
|
||||
ChatColor.stripColor(player.getDisplayName()),
|
||||
getPlayerHash(player)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Player target = null;
|
||||
while (it.hasNext() && target == null)
|
||||
{
|
||||
final Player player = it.next();
|
||||
final String hash = getPlayerHash(player);
|
||||
|
||||
if (hash.equalsIgnoreCase(args[1]))
|
||||
{
|
||||
target = player;
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
msg("Invalid player hash: " + args[1], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case KICK:
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), String.format("Kicking: %s.", target.getName()), false);
|
||||
target.kickPlayer("Kicked by Administrator");
|
||||
|
||||
break;
|
||||
}
|
||||
case NAMEBAN:
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s.", target.getName()), true);
|
||||
plugin.bm.addBan(Ban.forPlayerName(target, sender, null, null));
|
||||
target.kickPlayer("Username banned by Administrator.");
|
||||
|
||||
break;
|
||||
}
|
||||
case IPBAN:
|
||||
{
|
||||
String ip = target.getAddress().getAddress().getHostAddress();
|
||||
String[] ip_parts = ip.split("\\.");
|
||||
if (ip_parts.length == 4)
|
||||
{
|
||||
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
||||
}
|
||||
FUtil.adminAction(sender.getName(), String.format("Banning IP: %s.", ip), true);
|
||||
plugin.bm.addBan(Ban.forPlayerIp(ip, sender, null, null));
|
||||
|
||||
target.kickPlayer("IP address banned by Administrator.");
|
||||
|
||||
break;
|
||||
}
|
||||
case BAN:
|
||||
{
|
||||
String ip = target.getAddress().getAddress().getHostAddress();
|
||||
String[] ip_parts = ip.split("\\.");
|
||||
if (ip_parts.length == 4)
|
||||
{
|
||||
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
||||
}
|
||||
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", target.getName(), ip), true);
|
||||
|
||||
plugin.bm.addBan(Ban.forPlayer(target, sender));
|
||||
|
||||
target.kickPlayer("IP and username banned by Administrator.");
|
||||
|
||||
break;
|
||||
}
|
||||
case OP:
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), String.format("Opping %s.", target.getName()), false);
|
||||
target.setOp(true);
|
||||
target.sendMessage(FreedomCommand.YOU_ARE_OP);
|
||||
|
||||
break;
|
||||
}
|
||||
case DEOP:
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), String.format("Deopping %s.", target.getName()), false);
|
||||
target.setOp(false);
|
||||
target.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
|
||||
|
||||
break;
|
||||
}
|
||||
case CI:
|
||||
{
|
||||
target.getInventory().clear();
|
||||
|
||||
break;
|
||||
}
|
||||
case FR:
|
||||
{
|
||||
FreezeData fd = plugin.pl.getPlayer(target).getFreezeData();
|
||||
fd.setFrozen(!fd.isFrozen());
|
||||
|
||||
msg(target.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
target.sendMessage(ChatColor.AQUA + "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
|
||||
break;
|
||||
}
|
||||
case SMITE:
|
||||
{
|
||||
Command_smite.smite(sender, target);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -25,25 +24,6 @@ public class Command_glist 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.length == 1)
|
||||
{
|
||||
if ("purge".equals(args[0]))
|
||||
{
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
plugin.pl.purgeAllData();
|
||||
msg("Purged playerbase.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
@ -71,13 +51,13 @@ public class Command_glist extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getUsername();
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
else
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(player);
|
||||
username = entry.getUsername();
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Toggles the glowing outline effect because y'all lazy as fuck", usage = "/<command>")
|
||||
public class Command_glow extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
boolean glowing = false;
|
||||
if (playerSender.getPotionEffect(PotionEffectType.GLOWING) != null)
|
||||
{
|
||||
playerSender.removePotionEffect(PotionEffectType.GLOWING);
|
||||
}
|
||||
else
|
||||
{
|
||||
PotionEffect glow = new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false);
|
||||
playerSender.addPotionEffect(glow);
|
||||
glowing = true;
|
||||
}
|
||||
msg("You " + (glowing ? "are now" : "no longer") + " glowing.");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ public class Command_grapplinghook extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.GRAPPLING_HOOK))
|
||||
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);
|
||||
|
@ -1,16 +1,10 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.google.common.collect.ContiguousSet;
|
||||
import com.google.common.collect.DiscreteDomain;
|
||||
import com.google.common.collect.Range;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.DoubleStream;
|
||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||
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;
|
||||
|
@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -16,7 +15,7 @@ import org.bukkit.entity.Player;
|
||||
public class Command_kick extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
@ -53,7 +52,7 @@ public class Command_kick extends FreedomCommand
|
||||
|
||||
player.kickPlayer(builder.toString());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.KICK, reason));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.KICK, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class Command_lightningrod extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.LIGHTNING_ROD))
|
||||
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);
|
||||
|
@ -1,9 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -11,7 +9,7 @@ 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>")
|
||||
@CommandParameters(description = "Link your Discord account to your Minecraft account", usage = "/<command> [<name> <id>]")
|
||||
public class Command_linkdiscord extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -24,64 +22,37 @@ public class Command_linkdiscord extends FreedomCommand
|
||||
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;
|
||||
|
||||
if (plugin.al.isAdmin(playerSender))
|
||||
PlayerData data = plugin.pl.getData(playerSender);
|
||||
if (data.getDiscordID() != null)
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(playerSender);
|
||||
if (admin.getDiscordID() != null)
|
||||
{
|
||||
msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Discord.ADMIN_LINK_CODES.containsValue(admin))
|
||||
{
|
||||
code = Discord.getCodeForAdmin(admin);
|
||||
}
|
||||
else
|
||||
{
|
||||
code = plugin.dc.generateCode(5);
|
||||
Discord.ADMIN_LINK_CODES.put(code, admin);
|
||||
}
|
||||
msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else if (plugin.mbl.isMasterBuilder(playerSender))
|
||||
{
|
||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(playerSender);
|
||||
if (masterBuilder.getDiscordID() != null)
|
||||
{
|
||||
msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Discord.MASTER_BUILDER_LINK_CODES.containsValue(masterBuilder))
|
||||
{
|
||||
code = Discord.getCodeForMasterBuilder(masterBuilder);
|
||||
}
|
||||
else
|
||||
{
|
||||
code = plugin.dc.generateCode(5);
|
||||
Discord.MASTER_BUILDER_LINK_CODES.put(code, masterBuilder);
|
||||
}
|
||||
if (Discord.LINK_CODES.containsValue(data))
|
||||
{
|
||||
code = Discord.getCode(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
|
||||
if (data.getDiscordId() != null)
|
||||
{
|
||||
msg("Your Minecraft account is already linked to a Discord account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Discord.PLAYER_LINK_CODES.containsValue(data))
|
||||
{
|
||||
code = Discord.getCodeForPlayer(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
code = plugin.dc.generateCode(5);
|
||||
Discord.PLAYER_LINK_CODES.put(code, data);
|
||||
}
|
||||
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)");
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.entity.Player;
|
||||
public class Command_links extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
protected 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)
|
||||
{
|
||||
YamlConfiguration config = plugin.config.configuration;
|
||||
ConfigurationSection section = config.getConfigurationSection("social_links");
|
||||
|
@ -7,10 +7,9 @@ import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopData;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -48,21 +48,21 @@ public class Command_manageshop extends FreedomCommand
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.setCoins(shopData.getCoins() + amount);
|
||||
plugin.sh.save(shopData);
|
||||
msg("Successfully added " + amount + " coins to " + player.getName() + ". Their new balance is " + shopData.getCoins(), ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + shopData.getCoins());
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setCoins(playerData.getCoins() + amount);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully added " + amount + " coins to " + player.getName() + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.setCoins(shopData.getCoins() + amount);
|
||||
plugin.sh.save(shopData);
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + shopData.getCoins());
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setCoins(playerData.getCoins() + amount);
|
||||
plugin.pl.save(playerData);
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||
}
|
||||
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
|
||||
return true;
|
||||
@ -85,29 +85,29 @@ public class Command_manageshop extends FreedomCommand
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.setCoins(shopData.getCoins() + amount);
|
||||
if (shopData.getCoins() < 0)
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setCoins(playerData.getCoins() + amount);
|
||||
if (playerData.getCoins() < 0)
|
||||
{
|
||||
shopData.setCoins(0);
|
||||
playerData.setCoins(0);
|
||||
}
|
||||
plugin.sh.save(shopData);
|
||||
msg("Successfully removed " + amount + " coins from " + player.getName() + ". Their new balance is " + shopData.getCoins(), ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + shopData.getCoins());
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully removed " + amount + " coins from " + player.getName() + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.setCoins(shopData.getCoins() - amount);
|
||||
if (shopData.getCoins() < 0)
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setCoins(playerData.getCoins() - amount);
|
||||
if (playerData.getCoins() < 0)
|
||||
{
|
||||
shopData.setCoins(0);
|
||||
playerData.setCoins(0);
|
||||
}
|
||||
plugin.sh.save(shopData);
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + shopData.getCoins());
|
||||
plugin.pl.save(playerData);
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||
}
|
||||
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
|
||||
return true;
|
||||
@ -128,9 +128,9 @@ public class Command_manageshop extends FreedomCommand
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.setCoins(amount);
|
||||
plugin.sh.save(shopData);
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setCoins(amount);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully set " + player.getName() + "'s coins to " + amount, ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount);
|
||||
return true;
|
||||
@ -171,9 +171,9 @@ public class Command_manageshop extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.giveItem(item);
|
||||
plugin.sh.save(shopData);
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.giveItem(item);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully gave the " + item.getName() + " to " + player.getName(), ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you");
|
||||
return true;
|
||||
@ -194,9 +194,9 @@ public class Command_manageshop extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.removeItem(item);
|
||||
plugin.sh.save(shopData);
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.removeItem(item);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully took the " + item.getName() + " from " + player.getName(), ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you");
|
||||
return true;
|
||||
|
@ -0,0 +1,57 @@
|
||||
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.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manually verify someone", usage = "/<command> <playername>", aliases="mv")
|
||||
public class Command_manuallyverify 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 == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.pl.isImposter(player))
|
||||
{
|
||||
msg("That player is not an impostor.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false);
|
||||
player.setOp(true);
|
||||
player.sendMessage(YOU_ARE_OP);
|
||||
|
||||
if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
|
||||
{
|
||||
plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
|
||||
player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
|
||||
}
|
||||
|
||||
plugin.pl.verify(player, null);
|
||||
plugin.rm.updateDisplay(player);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "seth's personal command", usage = "/<command> <players>", aliases = "genocide")
|
||||
public class Command_massmurder extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!ConfigEntry.SERVER_OWNERS.getStringList().contains(playerSender.getName()))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (String name : args)
|
||||
{
|
||||
Player player = getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
player.setHealth(0);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
msg("Mass murdered a school of " + count);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||
import org.bukkit.World;
|
||||
|
@ -1,23 +1,19 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "List, add, or remove master builders, reload the master builder list, or view the info of master builders.", usage = "/<command> <list | reload | | <add | remove | info> <username>>")
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "List, add, or remove master builders, reload the master builder list, or view the info of master builders.", usage = "/<command> <list | <<add | remove> <username>>>")
|
||||
public class Command_mbconfig extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -33,50 +29,7 @@ public class Command_mbconfig extends FreedomCommand
|
||||
{
|
||||
case "list":
|
||||
{
|
||||
msg("Master Builders: " + StringUtils.join(plugin.mbl.getMasterBuilderNames(), ", "), ChatColor.GOLD);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case "reload":
|
||||
{
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Reloading the Master Builder list", true);
|
||||
plugin.mbl.load();
|
||||
msg("Master Builder list reloaded!");
|
||||
return true;
|
||||
}
|
||||
|
||||
case "info":
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
checkRank(Rank.SUPER_ADMIN);
|
||||
|
||||
MasterBuilder masterBuilder = plugin.mbl.getEntryByName(args[1]);
|
||||
|
||||
if (masterBuilder == null)
|
||||
{
|
||||
final Player player = getPlayer(args[1]);
|
||||
if (player != null)
|
||||
{
|
||||
masterBuilder = plugin.mbl.getMasterBuilder(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (masterBuilder == null)
|
||||
{
|
||||
msg("Master Builder not found: " + args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(masterBuilder.toString());
|
||||
}
|
||||
|
||||
msg("Master Builders: " + StringUtils.join(plugin.pl.getMasterBuilderNames(), ", "), ChatColor.GOLD);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -87,89 +40,43 @@ public class Command_mbconfig extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
checkConsole();
|
||||
checkRank(Rank.TELNET_ADMIN);
|
||||
if (!plugin.pl.canManageMasterBuilders(sender.getName()))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
|
||||
// Player already on the list?
|
||||
final Player player = getPlayer(args[1]);
|
||||
if (player != null && plugin.mbl.isMasterBuilder(player))
|
||||
PlayerData data = plugin.pl.getData(player);
|
||||
|
||||
if (data.isMasterBuilder() && plugin.pl.isPlayerImpostor(player))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the Master Builder list", true);
|
||||
player.setOp(true);
|
||||
player.sendMessage(YOU_ARE_OP);
|
||||
|
||||
if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
|
||||
{
|
||||
plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
|
||||
player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
|
||||
}
|
||||
plugin.pl.verify(player, null);
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
else if (!data.isMasterBuilder())
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the Master Builder list", true);
|
||||
data.setMasterBuilder(true);
|
||||
data.setVerification(true);
|
||||
plugin.pl.save(data);
|
||||
plugin.rm.updateDisplay(player);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("That player is already on the Master Builder list.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Find the entry
|
||||
String name = player != null ? player.getName() : args[1];
|
||||
MasterBuilder masterBuilder = null;
|
||||
for (MasterBuilder loopMasterBuilder : plugin.mbl.getAllMasterBuilders().values())
|
||||
{
|
||||
if (loopMasterBuilder.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
masterBuilder = loopMasterBuilder;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (masterBuilder == null) // New entry
|
||||
{
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
if (!FUtil.canManageMasterBuilders(sender.getName()))
|
||||
{
|
||||
noPerms();
|
||||
}
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the Master Builder list", true);
|
||||
plugin.mbl.addMasterBuilder(new MasterBuilder(player));
|
||||
if (player != null)
|
||||
{
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
}
|
||||
else // Existing admin
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Readding " + masterBuilder.getName() + " to the Master Builder list", true);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
masterBuilder.setName(player.getName());
|
||||
masterBuilder.addIp(Ips.getIp(player));
|
||||
}
|
||||
|
||||
masterBuilder.setLastLogin(new Date());
|
||||
|
||||
plugin.mbl.save();
|
||||
plugin.mbl.updateTables();
|
||||
if (player != null)
|
||||
{
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
{
|
||||
fPlayer.getFreezeData().setFrozen(false);
|
||||
msg(player.getPlayer(), "You have been unfrozen.");
|
||||
}
|
||||
|
||||
if (!player.isOp())
|
||||
{
|
||||
player.setOp(true);
|
||||
player.sendMessage(YOU_ARE_OP);
|
||||
}
|
||||
plugin.pv.removeEntry(player.getName()); // master builders can't have player verification entries
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case "remove":
|
||||
{
|
||||
if (args.length < 2)
|
||||
@ -177,28 +84,28 @@ public class Command_mbconfig extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
checkConsole();
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
if (!FUtil.canManageMasterBuilders(sender.getName()))
|
||||
if (!plugin.pl.canManageMasterBuilders(sender.getName()))
|
||||
{
|
||||
noPerms();
|
||||
return noPerms();
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[1]);
|
||||
MasterBuilder masterBuilder = player != null ? plugin.mbl.getMasterBuilder(player) : plugin.mbl.getEntryByName(args[1]);
|
||||
PlayerData data = plugin.pl.getData(player);
|
||||
|
||||
if (masterBuilder == null)
|
||||
if (!data.isMasterBuilder())
|
||||
{
|
||||
msg("Master Builder not found: " + args[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Removing " + masterBuilder.getName() + " from the Master Builder list", true);
|
||||
plugin.mbl.removeMasterBuilder(masterBuilder);
|
||||
if (player != null)
|
||||
FUtil.adminAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true);
|
||||
data.setMasterBuilder(false);
|
||||
if (data.getDiscordID() == null)
|
||||
{
|
||||
plugin.rm.updateDisplay(player);
|
||||
data.setVerification(false);
|
||||
}
|
||||
plugin.pl.save(data);
|
||||
plugin.rm.updateDisplay(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -211,39 +118,21 @@ public class Command_mbconfig extends FreedomCommand
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.add("list");
|
||||
if (plugin.al.isAdmin(sender))
|
||||
{
|
||||
arguments.add("info");
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
else if (args.length == 2 && args[0].equals("info") && plugin.al.isAdmin(sender))
|
||||
{
|
||||
return plugin.al.getActiveAdminNames();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return Arrays.asList("add", "remove", "list");
|
||||
}
|
||||
else
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args.length == 1)
|
||||
if (args[0].equals("add"))
|
||||
{
|
||||
return Arrays.asList("add", "remove", "reload", "list", "info");
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
else if (args.length == 2)
|
||||
else if (args[0].equals("remove"))
|
||||
{
|
||||
if (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info"))
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
return plugin.pl.getMasterBuilderNames();
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -4,15 +4,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagInt;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagString;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R1.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_15_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -189,7 +186,7 @@ public class Command_modifyitem extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_15_R1.ItemStack stack)
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R1.ItemStack stack)
|
||||
{
|
||||
if (stack.getTag() == null)
|
||||
{
|
||||
|
@ -9,7 +9,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -153,7 +152,7 @@ public class Command_mute extends FreedomCommand
|
||||
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
||||
msg("Muted " + player.getName());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.MUTE, reason));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.MUTE, reason));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -6,9 +6,9 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
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 net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -16,12 +16,12 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Manage your admin entry.", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin | setacformat <format> | clearacformat> | oldtags | logstick | syncroles | genbackupcodes>")
|
||||
@CommandParameters(description = "Manage your admin entry.", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin | setacformat <format> | clearacformat> | oldtags | logstick | syncroles>")
|
||||
public class Command_myadmin extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@ -59,7 +59,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
final String targetIp = Ips.getIp(targetPlayer);
|
||||
final String targetIp = FUtil.getIp(targetPlayer);
|
||||
|
||||
switch (args[0])
|
||||
{
|
||||
@ -86,6 +86,8 @@ public class Command_myadmin extends FreedomCommand
|
||||
plugin.al.save(target);
|
||||
plugin.al.updateTables();
|
||||
|
||||
plugin.pl.syncIps(target);
|
||||
|
||||
msg(counter + " IPs removed.");
|
||||
msg(targetPlayer, target.getIps().get(0) + " is now your only IP address");
|
||||
return true;
|
||||
@ -130,6 +132,8 @@ public class Command_myadmin extends FreedomCommand
|
||||
plugin.al.save(target);
|
||||
plugin.al.updateTables();
|
||||
|
||||
plugin.pl.syncIps(target);
|
||||
|
||||
msg("Removed IP " + args[1]);
|
||||
msg("Current IPs: " + StringUtils.join(target.getIps(), ", "));
|
||||
return true;
|
||||
@ -154,9 +158,9 @@ public class Command_myadmin extends FreedomCommand
|
||||
msg("Your login message cannot be more than 64 characters (excluding your rank and your name)", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
String previewMessage = plugin.rm.craftLoginMessage(targetPlayer, message);
|
||||
FUtil.adminAction(sender.getName(), "Setting personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
||||
target.setLoginMessage(message);
|
||||
String previewMessage = plugin.rm.craftLoginMessage(targetPlayer, message);
|
||||
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: ");
|
||||
msg("> " + previewMessage);
|
||||
plugin.al.save(target);
|
||||
@ -173,17 +177,6 @@ public class Command_myadmin extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
case "settag":
|
||||
{
|
||||
msg("Please use /tag set to set your tag.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
case "cleartag":
|
||||
{
|
||||
msg("Please use /tag off to remove your tag.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
case "setacformat":
|
||||
{
|
||||
String format = StringUtils.join(args, " ", 1, args.length);
|
||||
@ -229,12 +222,13 @@ public class Command_myadmin extends FreedomCommand
|
||||
msg("Role syncing is not enabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
boolean synced = plugin.dc.syncRoles(target);
|
||||
if (target.getDiscordID() == null)
|
||||
PlayerData playerData = plugin.pl.getData(target.getName());
|
||||
if (playerData.getDiscordID() == null)
|
||||
{
|
||||
msg("Please run /linkdiscord first!", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
boolean synced = plugin.dc.syncRoles(target, playerData.getDiscordID());
|
||||
if (synced)
|
||||
{
|
||||
msg("Successfully synced your roles.", ChatColor.GREEN);
|
||||
@ -249,29 +243,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
}
|
||||
|
||||
case "genbackupcodes":
|
||||
if (!plugin.dc.enabled)
|
||||
{
|
||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else if (target.getDiscordID() == null || target.getDiscordID().isEmpty())
|
||||
{
|
||||
msg("Discord verification is not enabled for you.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Generating backup codes...", ChatColor.GREEN);
|
||||
|
||||
boolean generated = plugin.dc.sendBackupCodes(target);
|
||||
|
||||
if (generated)
|
||||
{
|
||||
msg("Your backup codes have been sent to your discord account. They can be re-generated at anytime.", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Failed to generate backup codes, please contact a developer (preferably Seth)", ChatColor.RED);
|
||||
}
|
||||
msg("Moved to /pv genbackupcodes", ChatColor.RED);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@ -290,7 +262,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
}
|
||||
|
||||
List<String> singleArguments = Arrays.asList("clearips", "setlogin", "setacformat");
|
||||
List<String> doubleArguments = Arrays.asList("clearip", "clearlogin", "clearacformat", "oldtags", "logstick", "syncroles", "genbackupcodes");
|
||||
List<String> doubleArguments = Arrays.asList("clearip", "clearlogin", "clearacformat", "oldtags", "logstick", "syncroles");
|
||||
if (args.length == 1)
|
||||
{
|
||||
List<String> options = new ArrayList<>();
|
||||
@ -312,7 +284,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
if (args[0].equals("clearip"))
|
||||
{
|
||||
List<String> ips = plugin.al.getAdmin(sender).getIps();
|
||||
ips.remove(Ips.getIp(playerSender));
|
||||
ips.remove(FUtil.getIp((Player) sender));
|
||||
return ips;
|
||||
}
|
||||
}
|
||||
|
@ -1,237 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Manage your Master Builder entry", usage = "/<command> [-o <masterbuilder>] <clearips | clearip <ip> | genbackupcodes>", aliases = "mymb")
|
||||
public class Command_mymasterbuilder extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Player init = null;
|
||||
MasterBuilder target = plugin.mbl.getMasterBuilder(playerSender);
|
||||
Player targetPlayer = playerSender;
|
||||
|
||||
// -o switch
|
||||
if (args[0].equals("-o"))
|
||||
{
|
||||
if (!FUtil.canManageMasterBuilders(playerSender.getName()))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
init = playerSender;
|
||||
targetPlayer = getPlayer(args[1]);
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
target = plugin.mbl.getMasterBuilder(playerSender);
|
||||
if (target == null)
|
||||
{
|
||||
msg("That player is not a Master Builder", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Shift 2
|
||||
args = Arrays.copyOfRange(args, 2, args.length);
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final String targetIp = Ips.getIp(targetPlayer);
|
||||
|
||||
switch (args[0])
|
||||
{
|
||||
case "clearips":
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false; // Double check: the player might mean "clearip"
|
||||
}
|
||||
|
||||
if (init == null)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Clearing my IPs", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Clearing " + target.getName() + "' IPs", true);
|
||||
}
|
||||
|
||||
int counter = target.getIps().size() - 1;
|
||||
target.clearIPs();
|
||||
target.addIp(targetIp);
|
||||
|
||||
plugin.mbl.save();
|
||||
plugin.mbl.updateTables();
|
||||
|
||||
msg(counter + " IPs removed.");
|
||||
msg(targetPlayer, target.getIps().get(0) + " is now your only IP address");
|
||||
return true;
|
||||
}
|
||||
|
||||
case "clearip":
|
||||
{
|
||||
if (args.length != 2)
|
||||
{
|
||||
return false; // Double check: the player might mean "clearips"
|
||||
}
|
||||
|
||||
if (!target.getIps().contains(args[1]))
|
||||
{
|
||||
if (init == null)
|
||||
{
|
||||
msg("That IP is not registered to you.");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("That IP does not belong to that player.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (targetIp.equals(args[1]))
|
||||
{
|
||||
if (init == null)
|
||||
{
|
||||
msg("You cannot remove your current IP.");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You cannot remove that Master Builders's current IP.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Removing an IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true);
|
||||
|
||||
target.removeIp(args[1]);
|
||||
plugin.mbl.save();
|
||||
plugin.mbl.updateTables();
|
||||
|
||||
msg("Removed IP " + args[1]);
|
||||
msg("Current IPs: " + StringUtils.join(target.getIps(), ", "));
|
||||
return true;
|
||||
}
|
||||
|
||||
case "genbackupcodes":
|
||||
if (!plugin.dc.enabled)
|
||||
{
|
||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else if (target.getDiscordID() == null || target.getDiscordID().isEmpty())
|
||||
{
|
||||
msg("Discord verification is not enabled for you.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Generating backup codes...", ChatColor.GREEN);
|
||||
|
||||
boolean generated = plugin.dc.sendBackupCodes(target);
|
||||
|
||||
if (generated)
|
||||
{
|
||||
msg("Your backup codes have been sent to your discord account. They can be re-generated at anytime.", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Failed to generate backup codes, please contact a developer (preferably Seth)", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
|
||||
if (!plugin.mbl.isMasterBuilder(playerSender) && !FUtil.canManageMasterBuilders(playerSender.getName()))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> singleArguments = Arrays.asList("clearips");
|
||||
List<String> doubleArguments = Arrays.asList("clearip", "genbackupcodes");
|
||||
if (args.length == 1)
|
||||
{
|
||||
List<String> options = new ArrayList<>();
|
||||
options.add("-o");
|
||||
options.addAll(singleArguments);
|
||||
options.addAll(doubleArguments);
|
||||
return options;
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equals("-o"))
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doubleArguments.contains(args[0]))
|
||||
{
|
||||
if (args[0].equals("clearip"))
|
||||
{
|
||||
if (args[0].equals("clearip"))
|
||||
{
|
||||
List<String> ips = plugin.mbl.getMasterBuilder(sender).getIps();
|
||||
ips.remove(Ips.getIp(playerSender));
|
||||
return ips;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args.length == 3)
|
||||
{
|
||||
if (args[0].equals("-o"))
|
||||
{
|
||||
List<String> options = new ArrayList<>();
|
||||
options.addAll(singleArguments);
|
||||
options.addAll(doubleArguments);
|
||||
return options;
|
||||
}
|
||||
}
|
||||
else if (args.length == 4)
|
||||
{
|
||||
if (args[0].equals("-o") && args[2].equals("clearip"))
|
||||
{
|
||||
MasterBuilder masterBuilder = plugin.mbl.getEntryByName(args[1]);
|
||||
if (masterBuilder != null)
|
||||
{
|
||||
return masterBuilder.getIps();
|
||||
}
|
||||
}
|
||||
}
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Essentials Interface Command - Remove illegal chatcodes from nicknames of all players on server.", usage = "/<command>", aliases = "nc")
|
||||
@CommandParameters(description = "Essentials Interface Command - Remove illegal chatcodes from nicknames of one or all players on server.", usage = "/<command> [player]", aliases = "nc")
|
||||
public class Command_nickclean extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -25,21 +25,43 @@ public class Command_nickclean extends FreedomCommand
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Cleaning all nicknames", false);
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Cleaning " + player.getName() + "'s nickname", false);
|
||||
cleanNickname(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Cleaning all nicknames", false);
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final String playerName = player.getName();
|
||||
final String nickName = plugin.esb.getNickname(playerName);
|
||||
if (nickName != null && !nickName.isEmpty() && !nickName.equalsIgnoreCase(playerName))
|
||||
{
|
||||
final Matcher matcher = REGEX.matcher(nickName);
|
||||
if (matcher.find())
|
||||
{
|
||||
final String newNickName = matcher.replaceAll("");
|
||||
msg(ChatColor.RESET + playerName + ": \"" + nickName + ChatColor.RESET + "\" -> \"" + newNickName + ChatColor.RESET + "\".");
|
||||
plugin.esb.setNickname(playerName, newNickName);
|
||||
}
|
||||
}
|
||||
cleanNickname(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void cleanNickname(Player player)
|
||||
{
|
||||
final String playerName = player.getName();
|
||||
final String nickName = plugin.esb.getNickname(playerName);
|
||||
if (nickName != null && !nickName.isEmpty() && !nickName.equalsIgnoreCase(playerName))
|
||||
{
|
||||
final Matcher matcher = REGEX.matcher(nickName);
|
||||
if (matcher.find())
|
||||
{
|
||||
final String newNickName = matcher.replaceAll("");
|
||||
msg(ChatColor.RESET + playerName + ": \"" + nickName + ChatColor.RESET + "\" -> \"" + newNickName + ChatColor.RESET + "\".");
|
||||
plugin.esb.setNickname(playerName, newNickName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,11 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -28,7 +26,7 @@ public class Command_notes extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
VPlayer vPlayer;
|
||||
PlayerData playerData;
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
@ -41,23 +39,21 @@ public class Command_notes extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
vPlayer = plugin.pv.getVerificationPlayer(entry.getUsername());
|
||||
playerData = plugin.pl.getData(entry.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
vPlayer = plugin.pv.getVerificationPlayer(player);
|
||||
playerData = plugin.pl.getData(player);
|
||||
}
|
||||
|
||||
if (args[1].equals("list"))
|
||||
{
|
||||
final StringBuilder noteList = new StringBuilder();
|
||||
noteList.append(ChatColor.GREEN + "Player notes for " + vPlayer.getName() + ":");
|
||||
noteList.append(ChatColor.GREEN + "Player notes for " + playerData.getName() + ":");
|
||||
int id = 1;
|
||||
for (Map<?, ?> noteMap : vPlayer.getNotes())
|
||||
for (String note : playerData.getNotes())
|
||||
{
|
||||
String admin = String.valueOf(noteMap.keySet().toArray()[0]);
|
||||
String note = String.valueOf(noteMap.get(admin));
|
||||
String noteLine = id + ". " + admin + ": " + note;
|
||||
String noteLine = id + ". " + note;
|
||||
noteList.append("\n" + ChatColor.GOLD + noteLine);
|
||||
id++;
|
||||
}
|
||||
@ -70,9 +66,9 @@ public class Command_notes extends FreedomCommand
|
||||
{
|
||||
return false;
|
||||
}
|
||||
String note = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
|
||||
vPlayer.addNote(sender.getName(), note);
|
||||
plugin.pv.saveVerificationData(vPlayer);
|
||||
String note = sender.getName() + ": " + StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
|
||||
playerData.addNote(note);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Note added.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
@ -93,9 +89,9 @@ public class Command_notes extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
id--;
|
||||
if (vPlayer.removeNote(id))
|
||||
if (playerData.removeNote(id))
|
||||
{
|
||||
plugin.pv.saveVerificationData(vPlayer);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Note removed.");
|
||||
}
|
||||
else
|
||||
@ -106,9 +102,9 @@ public class Command_notes extends FreedomCommand
|
||||
}
|
||||
else if (args[1].equals("clear"))
|
||||
{
|
||||
int count = vPlayer.getNotes().size();
|
||||
vPlayer.clearNotes();
|
||||
plugin.pv.saveVerificationData(vPlayer);
|
||||
int count = playerData.getNotes().size();
|
||||
playerData.clearNotes();
|
||||
plugin.pl.save(playerData);
|
||||
msg("Cleared " + count + " notes.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -25,8 +25,8 @@ public class Command_permban extends FreedomCommand
|
||||
}
|
||||
|
||||
msg("Reloading permban list...", ChatColor.RED);
|
||||
plugin.pm.stop();
|
||||
plugin.pm.start();
|
||||
plugin.pm.onStop();
|
||||
plugin.pm.onStart();
|
||||
msg("Reloaded permban list.");
|
||||
msg(plugin.pm.getPermbannedIps().size() + " IPs and "
|
||||
+ plugin.pm.getPermbannedNames().size() + " usernames loaded.");
|
||||
|
@ -4,22 +4,22 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.pravian.aero.util.Ips;
|
||||
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.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Manage your verification", usage = "/<command> <enable | disable | clearips | status | genbackupcodes>", aliases = "playerverification,pv")
|
||||
public class Command_playerverify extends FreedomCommand
|
||||
@CommandParameters(description = "Manage your verification", usage = "/<command> <enable | disable | clearips | clearip <ip> | status | genbackupcodes>", aliases = "playerverify,pv")
|
||||
public class Command_playerverification extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
protected 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)
|
||||
{
|
||||
VPlayer target = plugin.pv.getVerificationPlayer(playerSender);
|
||||
PlayerData target = plugin.pl.getData(playerSender);
|
||||
|
||||
List<String> ips = new ArrayList<>();
|
||||
ips.addAll(target.getIps());
|
||||
@ -31,16 +31,29 @@ public class Command_playerverify extends FreedomCommand
|
||||
int cleared = 0;
|
||||
for (String ip : ips)
|
||||
{
|
||||
if (!ip.equals(Ips.getIp(playerSender)))
|
||||
if (!ip.equals(FUtil.getIp(playerSender)))
|
||||
{
|
||||
target.removeIp(ip);
|
||||
cleared++;
|
||||
}
|
||||
}
|
||||
|
||||
msg("Cleared all IP's except your current IP \"" + Ips.getIp(playerSender) + "\"");
|
||||
msg("Cleared all IP's except your current IP \"" + FUtil.getIp(playerSender) + "\"");
|
||||
msg("Cleared " + cleared + " IP's.");
|
||||
plugin.pv.saveVerificationData(target);
|
||||
plugin.pl.save(target);
|
||||
plugin.pl.syncIps(target);
|
||||
return true;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("clearip"))
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
target.removeIp(args[1]);
|
||||
msg("Removed" + args[1] + " from your list of IPs");
|
||||
plugin.pl.save(target);
|
||||
plugin.pl.syncIps(target);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -50,13 +63,7 @@ public class Command_playerverify extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(sender))
|
||||
{
|
||||
msg("This command is only for OP's.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
|
||||
PlayerData data = plugin.pl.getData(playerSender);
|
||||
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
@ -66,37 +73,37 @@ public class Command_playerverify extends FreedomCommand
|
||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else if (data.getEnabled())
|
||||
else if (data.hasVerification())
|
||||
{
|
||||
msg("Discord verification is already enabled for you.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else if (data.getDiscordId() == null)
|
||||
else if (data.getDiscordID() == null)
|
||||
{
|
||||
msg("Please link a discord account with /linkdiscord.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
data.setEnabled(true);
|
||||
plugin.pv.saveVerificationData(data);
|
||||
data.setVerification(true);
|
||||
plugin.pl.save(data);
|
||||
msg("Re-enabled Discord verification.", ChatColor.GREEN);
|
||||
return true;
|
||||
|
||||
case "disable":
|
||||
if (!data.getEnabled())
|
||||
if (!data.hasVerification())
|
||||
{
|
||||
msg("Discord verification is already disabled for you.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
data.setEnabled(false);
|
||||
plugin.pv.saveVerificationData(data);
|
||||
data.setVerification(false);
|
||||
plugin.pl.save(data);
|
||||
msg("Disabled Discord verification.", ChatColor.GREEN);
|
||||
return true;
|
||||
|
||||
case "status":
|
||||
boolean enabled = target.getEnabled();
|
||||
boolean specified = target.getDiscordId() != null;
|
||||
boolean enabled = target.hasVerification();
|
||||
boolean specified = target.getDiscordID() != null;
|
||||
msg(ChatColor.GRAY + "Discord Verification Enabled: " + (enabled ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
|
||||
msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.GREEN + target.getDiscordId() : ChatColor.RED + "not set"));
|
||||
msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.GREEN + target.getDiscordID() : ChatColor.RED + "not set"));
|
||||
msg(ChatColor.GRAY + "Backup Codes: " + data.getBackupCodes().size() + "/" + "10");
|
||||
return true;
|
||||
|
||||
@ -106,7 +113,7 @@ public class Command_playerverify extends FreedomCommand
|
||||
msg("The Discord verification system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else if (!data.getEnabled())
|
||||
else if (!data.hasVerification())
|
||||
{
|
||||
msg("Discord verification is not enabled for you.", ChatColor.RED);
|
||||
return true;
|
@ -1,12 +1,8 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.io.IOException;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||
|
@ -1,24 +1,25 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.connorlinfoot.actionbarapi.ActionBarAPI;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
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.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Brings the current reaction string up on your action bar", usage = "/<command>")
|
||||
@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 (!plugin.sh.reactionString.isEmpty())
|
||||
if (!FUtil.isDeveloper(sender.getName()))
|
||||
{
|
||||
ActionBarAPI.sendActionBar(playerSender, ChatColor.BOLD + plugin.sh.reactionString, 15 * 20);
|
||||
return noPerms();
|
||||
}
|
||||
plugin.sh.forceStartReaction();
|
||||
msg("Started a reaction.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
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.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Sync your time with the real world time.", usage = "/<command> <on <utc_offset> | off>", aliases = "rt")
|
||||
public class Command_realtime extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
VPlayer player = plugin.pv.getVerificationPlayer(playerSender);
|
||||
if (args.length == 0 || args.length > 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
int tz;
|
||||
try
|
||||
{
|
||||
tz = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid UTC offset.");
|
||||
return true;
|
||||
}
|
||||
if (FUtil.timeZoneOutOfBounds(tz))
|
||||
{
|
||||
msg("Invalid UTC offset.");
|
||||
return true;
|
||||
}
|
||||
player.setUtcOffset(tz);
|
||||
player.setRealTime(true);
|
||||
plugin.rt.enable(playerSender);
|
||||
plugin.pv.saveVerificationData(player);
|
||||
msg("Your in-game time is now synced with real time.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
if (!player.isRealTime())
|
||||
{
|
||||
msg("You aren't on real time.");
|
||||
return true;
|
||||
}
|
||||
player.setRealTime(false);
|
||||
msg("Your in-game time is no longer synced with real time.");
|
||||
plugin.rt.disable(playerSender);
|
||||
plugin.pv.saveVerificationData(player);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -4,8 +4,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TimerTask;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
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.Location;
|
||||
import org.bukkit.command.Command;
|
||||
@ -76,8 +77,9 @@ public class Command_ride extends FreedomCommand
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("normal") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("ask"))
|
||||
{
|
||||
VPlayer vPlayerSender = plugin.pv.getVerificationPlayer(playerSender);
|
||||
vPlayerSender.setRideMode(args[1].toLowerCase());
|
||||
PlayerData playerDataSender = plugin.pl.getData(playerSender);
|
||||
playerDataSender.setRideMode(args[1].toLowerCase());
|
||||
plugin.pl.save(playerDataSender);
|
||||
msg("Ride mode is now set to " + args[1].toLowerCase() + ".");
|
||||
return true;
|
||||
}
|
||||
@ -90,7 +92,7 @@ public class Command_ride extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
final VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
|
||||
final PlayerData playerData = plugin.pl.getData(player);
|
||||
|
||||
if (player == playerSender)
|
||||
{
|
||||
@ -98,19 +100,13 @@ public class Command_ride extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (vPlayer.getRideMode().equals("off") && !isAdmin(sender))
|
||||
if (playerData.getRideMode().equals("off") && !isAdmin(sender))
|
||||
{
|
||||
msg("That player cannot be ridden.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player.getName().equals("Catholic_Mario"))
|
||||
{
|
||||
msg("no", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (vPlayer.getRideMode().equals("ask") && !isAdmin(sender))
|
||||
if (playerData.getRideMode().equals("ask") && !FUtil.isExecutive(playerSender.getName()))
|
||||
{
|
||||
msg("Sent a request to the player.", ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.AQUA + sender.getName() + " has requested to ride you.");
|
||||
@ -118,7 +114,7 @@ public class Command_ride extends FreedomCommand
|
||||
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.");
|
||||
player.sendMessage(ChatColor.AQUA + "Request will expire after 30 seconds.");
|
||||
RIDE_REQUESTS.put(player, playerSender);
|
||||
FreedomCommandExecutor.timer.schedule(new TimerTask()
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@ -15,7 +15,7 @@ public class Command_rideablepearl extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.RIDEABLE_PEARL))
|
||||
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);
|
||||
|
@ -11,25 +11,18 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "You know the words - gives a campfire to everyone on the server.", usage = "/<command>")
|
||||
public class Command_campfire extends FreedomCommand
|
||||
@CommandParameters(description = "You have thrown a rock, but you have also summoned a meteor!", usage = "/<command>")
|
||||
public class Command_rock extends FreedomCommand
|
||||
{
|
||||
|
||||
public static final String CAMPFIRE_LYRICS = "Let's gather round the campfire, and sing our campfire song....";
|
||||
public static final String ROCK_LYRICS = ChatColor.BLUE + "You have thrown a rock, but you have also summoned a meteor!";
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
final StringBuilder output = new StringBuilder();
|
||||
|
||||
for (final String word : CAMPFIRE_LYRICS.split(" "))
|
||||
{
|
||||
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||
}
|
||||
|
||||
final ItemStack heldItem = new ItemStack(Material.CAMPFIRE);
|
||||
final ItemStack heldItem = new ItemStack(Material.STONE);
|
||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||
heldItemMeta.setDisplayName(ChatColor.DARK_RED + "The " + ChatColor.DARK_RED + "Campfire");
|
||||
heldItemMeta.setDisplayName(ChatColor.BLUE + "Rock");
|
||||
heldItem.setItemMeta(heldItemMeta);
|
||||
|
||||
for (final Player player : this.server.getOnlinePlayers())
|
||||
@ -41,7 +34,7 @@ public class Command_campfire extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
FUtil.bcastMsg(output.toString());
|
||||
FUtil.bcastMsg(ROCK_LYRICS);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -7,12 +7,9 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -109,7 +106,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
plugin.dc.syncRoles(admin);
|
||||
plugin.dc.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
}
|
||||
|
||||
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
||||
@ -166,7 +163,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player != null && plugin.al.isAdmin(player))
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
msg("That player is already admin.");
|
||||
return true;
|
||||
@ -177,14 +174,14 @@ public class Command_saconfig extends FreedomCommand
|
||||
Admin admin = null;
|
||||
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
||||
{
|
||||
if (loopAdmin.getName().equalsIgnoreCase(name))
|
||||
if (loopAdmin.getName().equalsIgnoreCase(name) || loopAdmin.getIps().contains(FUtil.getIp(player)))
|
||||
{
|
||||
admin = loopAdmin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.pv.isPlayerImpostor(player))
|
||||
if (plugin.pl.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;
|
||||
@ -192,11 +189,6 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
if (admin == null) // New admin
|
||||
{
|
||||
if (plugin.mbl.isMasterBuilderImpostor(player))
|
||||
{
|
||||
msg("This player was labeled as a Master Builder impostor and is not an admin, therefore they cannot be added to the admin list.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
@ -206,81 +198,25 @@ public class Command_saconfig extends FreedomCommand
|
||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
||||
admin = new Admin(player);
|
||||
|
||||
// Attempt to find discord account
|
||||
if (plugin.mbl.isMasterBuilder(player))
|
||||
{
|
||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
|
||||
admin.setDiscordID(plugin.mbl.getMasterBuilder(player).getDiscordID());
|
||||
}
|
||||
else if (plugin.pv.getVerificationPlayer(player.getName()) != null)
|
||||
{
|
||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player.getName());
|
||||
if (vPlayer.getDiscordId() != null)
|
||||
{
|
||||
admin.setDiscordID(vPlayer.getDiscordId());
|
||||
}
|
||||
}
|
||||
plugin.al.addAdmin(admin);
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
else // Existing admin
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Re-adding " + admin.getName() + " to the admin list", true);
|
||||
FUtil.adminAction(sender.getName(), "Re-adding " + player.getName() + " to the admin list", true);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
String oldName = admin.getName();
|
||||
if (oldName != player.getName())
|
||||
admin.setName(player.getName());
|
||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||
admin.addIp(Ips.getIp(player));
|
||||
}
|
||||
|
||||
// Handle master builders
|
||||
if (!plugin.mbl.isMasterBuilder(player))
|
||||
{
|
||||
MasterBuilder masterBuilder = null;
|
||||
for (MasterBuilder loopMasterBuilder : plugin.mbl.getAllMasterBuilders().values())
|
||||
{
|
||||
if (loopMasterBuilder.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
masterBuilder = loopMasterBuilder;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (masterBuilder != null)
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
masterBuilder.setName(player.getName());
|
||||
masterBuilder.addIp(Ips.getIp(player));
|
||||
}
|
||||
|
||||
masterBuilder.setLastLogin(new Date());
|
||||
|
||||
plugin.mbl.save();
|
||||
plugin.mbl.updateTables();
|
||||
}
|
||||
admin.addIp(FUtil.getIp(player));
|
||||
}
|
||||
|
||||
admin.setActive(true);
|
||||
admin.setLastLogin(new Date());
|
||||
|
||||
// Attempt to find discord account
|
||||
if (plugin.mbl.isMasterBuilder(player))
|
||||
{
|
||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
|
||||
admin.setDiscordID(plugin.mbl.getMasterBuilder(player).getDiscordID());
|
||||
}
|
||||
else if (plugin.pv.getVerificationPlayer(admin.getName()) != null)
|
||||
{
|
||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(admin.getName());
|
||||
if (vPlayer.getDiscordId() != null)
|
||||
{
|
||||
admin.setDiscordID(vPlayer.getDiscordId());
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.al.isVerifiedAdmin(player))
|
||||
{
|
||||
plugin.al.verifiedNoAdmins.remove(player.getName());
|
||||
@ -296,7 +232,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
plugin.dc.syncRoles(admin);
|
||||
plugin.dc.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,7 +250,6 @@ public class Command_saconfig extends FreedomCommand
|
||||
player.setOp(true);
|
||||
player.sendMessage(YOU_ARE_OP);
|
||||
}
|
||||
plugin.pv.removeEntry(player.getName()); // admins can't have player verification entries
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -348,7 +283,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
plugin.dc.syncRoles(admin);
|
||||
plugin.dc.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -364,41 +299,34 @@ public class Command_saconfig extends FreedomCommand
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args.length == 1)
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.add("list");
|
||||
if (plugin.al.isAdmin(sender))
|
||||
{
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.add("list");
|
||||
if (plugin.al.isAdmin(sender))
|
||||
{
|
||||
arguments.add("info");
|
||||
}
|
||||
return arguments;
|
||||
arguments.add("info");
|
||||
}
|
||||
else if (args.length == 2 && args[0].equals("info") && plugin.al.isAdmin(sender))
|
||||
if (plugin.al.isTelnetAdmin(sender))
|
||||
{
|
||||
return plugin.al.getActiveAdminNames();
|
||||
arguments.add("add");
|
||||
arguments.add("remove");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
if (plugin.al.isSeniorAdmin(sender))
|
||||
{
|
||||
arguments.add("reload");
|
||||
arguments.add("clean");
|
||||
arguments.add("setrank");
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
else
|
||||
if (args.length == 2 && (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info")))
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("add", "remove", "clean", "reload", "setrank", "info", "list");
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info"))
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
}
|
||||
else if (args.length == 3 && args[0].equals("setrank"))
|
||||
{
|
||||
return Arrays.asList("super_admin", "telnet_admin", "senior_admin");
|
||||
}
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
if (args.length == 3 && args[0].equals("setrank"))
|
||||
{
|
||||
return Arrays.asList("SUPER_ADMIN", "TELNET_ADMIN", "SENIOR_ADMIN");
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
@ -1,11 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
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;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Check the status of the server, including opped players, staff, etc.", usage = "/<command>", aliases = "ss")
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
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;
|
||||
@ -20,7 +20,7 @@ public class Command_shop extends FreedomCommand
|
||||
msg("The shop is currently disabled!", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
playerSender.openInventory(plugin.sh.generateShopGUI(plugin.sh.getData(playerSender)));
|
||||
playerSender.openInventory(plugin.sh.generateShopGUI(plugin.pl.getData(playerSender)));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -60,7 +59,7 @@ public class Command_smite extends FreedomCommand
|
||||
|
||||
smite(sender, player, reason, silent);
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -20,7 +20,7 @@ public class Command_spawnmob extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
|
@ -0,0 +1,29 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -20,27 +20,26 @@ public class Command_stop extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (STOP_CONFIRM.containsKey(sender))
|
||||
{
|
||||
FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
player.kickPlayer(ChatColor.LIGHT_PURPLE + STOP_CONFIRM.get(sender));
|
||||
}
|
||||
|
||||
STOP_CONFIRM.remove(sender);
|
||||
|
||||
server.shutdown();
|
||||
}
|
||||
|
||||
String reason = "Server is going offline, come back in about 20 seconds.";
|
||||
|
||||
if (args.length > 0)
|
||||
if (args.length != 0)
|
||||
{
|
||||
reason = StringUtils.join(args, " ");
|
||||
}
|
||||
|
||||
if (sender.getName().equals("CONSOLE"))
|
||||
{
|
||||
shutdown(reason);
|
||||
return true;
|
||||
}
|
||||
else if (STOP_CONFIRM.containsKey(sender))
|
||||
{
|
||||
shutdown(STOP_CONFIRM.get(sender));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
msg("Warning: You're about to stop the server. Type /stop again to confirm you want to do this.");
|
||||
|
||||
STOP_CONFIRM.put(sender, reason);
|
||||
@ -58,4 +57,18 @@ public class Command_stop extends FreedomCommand
|
||||
}.runTaskLater(plugin, 15 * 20);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void shutdown(String reason)
|
||||
{
|
||||
FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
player.kickPlayer(ChatColor.LIGHT_PURPLE + reason);
|
||||
}
|
||||
|
||||
STOP_CONFIRM.remove(sender);
|
||||
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,8 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
@ -23,11 +21,12 @@ public class Command_tag extends FreedomCommand
|
||||
public static final List<String> FORBIDDEN_WORDS = Arrays.asList(
|
||||
"admin", "owner", "moderator", "developer", "console", "dev", "staff", "mod", "sra", "tca", "sta", "sa");
|
||||
|
||||
public boolean save = false;
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
boolean save = false;
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
@ -35,11 +34,6 @@ public class Command_tag extends FreedomCommand
|
||||
|
||||
if (args[0].equals("-s") || args[0].equals("-save"))
|
||||
{
|
||||
if (!plugin.al.isAdmin(playerSender) && !plugin.mbl.isMasterBuilder(playerSender) && !plugin.pv.getVerificationPlayer(playerSender).getEnabled())
|
||||
{
|
||||
msg("Only admins, Master Builders, and players with verification enabled can save their tags.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
save = true;
|
||||
args = ArrayUtils.remove(args, 0);
|
||||
}
|
||||
@ -199,25 +193,8 @@ public class Command_tag extends FreedomCommand
|
||||
|
||||
public void save(Player player, String tag)
|
||||
{
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
admin.setTag(tag);
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
}
|
||||
else if (plugin.mbl.isMasterBuilder(player))
|
||||
{
|
||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
|
||||
masterBuilder.setTag(tag);
|
||||
plugin.mbl.save();
|
||||
plugin.mbl.updateTables();
|
||||
}
|
||||
else if (plugin.pv.getVerificationPlayer(player).getEnabled())
|
||||
{
|
||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
|
||||
vPlayer.setTag(tag);
|
||||
plugin.pv.saveVerificationData(vPlayer);
|
||||
}
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setTag(tag);
|
||||
plugin.pl.save(playerData);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
@ -10,11 +8,7 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -47,7 +41,7 @@ public class Command_tban extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getUsername();
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
else
|
||||
|
@ -10,7 +10,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
@ -47,7 +46,7 @@ public class Command_tempban extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getUsername();
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
else
|
||||
@ -97,7 +96,7 @@ public class Command_tempban extends FreedomCommand
|
||||
plugin.bm.addBan(ban);
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public class Command_toggle extends FreedomCommand
|
||||
msg("- spawners");
|
||||
msg("- 4chan");
|
||||
msg("- beehives");
|
||||
msg("- respawnanchors");
|
||||
msg("- autotp");
|
||||
msg("- autoclear");
|
||||
return false;
|
||||
@ -215,6 +216,11 @@ public class Command_toggle extends FreedomCommand
|
||||
toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES);
|
||||
return true;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("respawnanchors"))
|
||||
{
|
||||
toggle("Respawn anchors are", ConfigEntry.ALLOW_RESPAWN_ANCHORS);
|
||||
return true;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("autotp"))
|
||||
{
|
||||
toggle("Teleportation on join is", ConfigEntry.AUTO_TP);
|
||||
@ -245,7 +251,7 @@ public class Command_toggle extends FreedomCommand
|
||||
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
|
||||
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
|
||||
"autotp", "autoclear");
|
||||
"respawnanchors", "autotp", "autoclear");
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -34,8 +35,11 @@ public class Command_totalfreedommod extends FreedomCommand
|
||||
}
|
||||
|
||||
plugin.config.load();
|
||||
plugin.services.stop();
|
||||
plugin.services.start();
|
||||
for (FreedomService service : plugin.fsh.getServices())
|
||||
{
|
||||
service.onStop();
|
||||
service.onStart();
|
||||
}
|
||||
|
||||
final String message = String.format("%s v%s reloaded.",
|
||||
TotalFreedomMod.pluginName,
|
||||
|
@ -1,22 +1,19 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/<command> [off]")
|
||||
@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 (args.length > 0 && "off".equals(args[0]))
|
||||
if (plugin.tr.contains(playerSender))
|
||||
{
|
||||
plugin.tr.remove(playerSender);
|
||||
msg("Trail disabled.");
|
||||
@ -30,15 +27,4 @@ public class Command_trail extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||
{
|
||||
return Arrays.asList("off");
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class Command_unban extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getUsername();
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
||||
|
@ -0,0 +1,47 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
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.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Uncage a player", usage = "/<command> <name>")
|
||||
public class Command_uncage extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
|
||||
if (fPlayer.getCageData().isCaged())
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
||||
final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
||||
playerdata.getCageData().setCaged(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("That player is not caged!", ChatColor.RED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.libsdisguises.BlockedDisguises;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.command.Command;
|
||||
@ -21,12 +20,6 @@ public class Command_undisguiseall extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (BlockedDisguises.disabled)
|
||||
{
|
||||
msg("Disguises are not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean admins = false;
|
||||
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("-a"))
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -9,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Unlink your Discord account from your Minecraft account", usage = "/<command>")
|
||||
@CommandParameters(description = "Unlink your Discord account from your Minecraft account", usage = "/<command> [player]")
|
||||
public class Command_unlinkdiscord extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -22,32 +21,30 @@ public class Command_unlinkdiscord extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(playerSender))
|
||||
if (args.length != 0 && plugin.al.isAdmin(playerSender))
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(playerSender);
|
||||
if (admin.getDiscordID() == null)
|
||||
PlayerData playerData = plugin.pl.getData(args[0]);
|
||||
if (playerData == null)
|
||||
{
|
||||
msg("Your Minecraft account is not linked to a Discord account.", ChatColor.RED);
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
admin.setDiscordID(null);
|
||||
plugin.al.save(admin);
|
||||
msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
|
||||
|
||||
playerData.setDiscordID(null);
|
||||
msg("Unlinked " + args[0] + "'s discord account.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
PlayerData data = plugin.pl.getData(playerSender);
|
||||
if (data.getDiscordID() == null)
|
||||
{
|
||||
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
|
||||
if (data.getDiscordId() == null)
|
||||
{
|
||||
msg("Your Minecraft account is not linked to a Discord account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
data.setDiscordId(null);
|
||||
data.setEnabled(false);
|
||||
plugin.pv.saveVerificationData(data);
|
||||
msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
|
||||
msg("Your Minecraft account is not linked to a Discord account.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
data.setDiscordID(null);
|
||||
data.setVerification(false);
|
||||
plugin.pl.save(data);
|
||||
msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -57,18 +53,11 @@ public class Command_unmute extends FreedomCommand
|
||||
playerdata.setMuted(false);
|
||||
msg(player, "You have been unmuted.", ChatColor.RED);
|
||||
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
if (quiet)
|
||||
if (!quiet)
|
||||
{
|
||||
playerdata.setMuted(false);
|
||||
return true;
|
||||
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
||||
playerdata.setMuted(false);
|
||||
msg("Unmuted " + player.getName());
|
||||
|
||||
msg(player, "You have been unmuted.", ChatColor.RED);
|
||||
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -77,23 +66,4 @@ public class Command_unmute extends FreedomCommand
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.addAll(FUtil.getPlayerList());
|
||||
arguments.addAll(Arrays.asList("list", "purge", "all"));
|
||||
return arguments;
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
@ -11,8 +11,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@ -23,7 +21,6 @@ public class Command_vanish extends FreedomCommand
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
Displayable display = plugin.rm.getDisplay(playerSender);
|
||||
String loginMsg = display.getColoredLoginMessage();
|
||||
String displayName = display.getColor() + playerSender.getName();
|
||||
String tag = display.getColoredTag();
|
||||
Admin admin = plugin.al.getAdmin(playerSender);
|
||||
@ -38,21 +35,18 @@ public class Command_vanish extends FreedomCommand
|
||||
if (plugin.al.vanished.contains(playerSender))
|
||||
{
|
||||
msg(ChatColor.GOLD + "You have been unvanished.");
|
||||
if (admin.hasLoginMessage())
|
||||
{
|
||||
loginMsg = FUtil.colorize(admin.getLoginMessage()).replace("%rank%", plugin.rm.getDisplay(admin).getName()).replace("%coloredrank%", plugin.rm.getDisplay(admin).getColoredName()).replace("%name%", admin.getName());
|
||||
}
|
||||
if (!silent)
|
||||
{
|
||||
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
|
||||
FUtil.bcastMsg(playerSender.getName() + " joined the game.", ChatColor.YELLOW);
|
||||
plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**");
|
||||
}
|
||||
if (admin.getTag() != null)
|
||||
PlayerData playerData = plugin.pl.getData(playerSender);
|
||||
if (playerData.getTag() != null)
|
||||
{
|
||||
tag = FUtil.colorize(admin.getTag());
|
||||
tag = FUtil.colorize(playerData.getTag());
|
||||
}
|
||||
plugin.pl.getPlayer(playerSender).setTag(tag);
|
||||
plugin.pl.getData(playerSender).setTag(tag);
|
||||
FLog.info(playerSender.getName() + " is no longer vanished.");
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
@ -79,9 +73,13 @@ public class Command_vanish extends FreedomCommand
|
||||
{
|
||||
{
|
||||
if (plugin.al.isAdmin(player))
|
||||
playerMsg(player, ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins." );
|
||||
{
|
||||
playerMsg(player, ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins.");
|
||||
}
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
player.hidePlayer(plugin, playerSender);
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.esb.setVanished(playerSender.getName(), true);
|
||||
|
@ -1,14 +1,9 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Date;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -22,258 +17,76 @@ public class Command_verify extends FreedomCommand
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (args.length == 1 && plugin.al.isAdmin(playerSender))
|
||||
if (!plugin.dc.enabled)
|
||||
{
|
||||
final Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
if (!plugin.pv.isPlayerImpostor(player))
|
||||
{
|
||||
msg("That player is not an impostor.");
|
||||
return true;
|
||||
}
|
||||
FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false);
|
||||
player.setOp(true);
|
||||
player.sendMessage(YOU_ARE_OP);
|
||||
if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
|
||||
{
|
||||
plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
|
||||
player.sendMessage(ChatColor.GRAY + "You have been unfrozen.");
|
||||
}
|
||||
plugin.pv.verifyPlayer(player, null);
|
||||
plugin.rm.updateDisplay(player);
|
||||
msg("The Discord verification system is currently disabled", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
if (senderIsConsole)
|
||||
{
|
||||
if (!plugin.dc.enabled)
|
||||
{
|
||||
msg("The Discord verification system is currently disabled", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
msg("/manuallyverify <playername>", ChatColor.WHITE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (senderIsConsole || plugin.al.isAdmin(playerSender))
|
||||
{
|
||||
msg("/verify <playername>", ChatColor.WHITE);
|
||||
return true;
|
||||
}
|
||||
if (!plugin.pl.isImposter(playerSender))
|
||||
{
|
||||
msg("You are not an impostor, therefore you do not need to verify.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.pv.isPlayerImpostor(playerSender) && !plugin.al.isAdminImpostor(playerSender) && !plugin.mbl.isMasterBuilderImpostor(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 = "";
|
||||
String discordId = playerData.getDiscordID();
|
||||
|
||||
if (plugin.pv.isPlayerImpostor(playerSender))
|
||||
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.bot.getUserById(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.isImposter(playerSender))
|
||||
{
|
||||
PlayerData mapPlayer = plugin.dc.getVerificationCodes().get(code);
|
||||
if (mapPlayer == null)
|
||||
{
|
||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(playerSender);
|
||||
if (vPlayer.getDiscordId() == null)
|
||||
if (!playerData.getBackupCodes().contains(plugin.dc.getMD5(code)))
|
||||
{
|
||||
msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
|
||||
msg("You have entered an invalid verification code", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
discordId = vPlayer.getDiscordId();
|
||||
}
|
||||
else if (plugin.al.isAdminImpostor(playerSender))
|
||||
{
|
||||
Admin admin = plugin.al.getEntryByName(playerSender.getName());
|
||||
if (admin.getDiscordID() == null)
|
||||
else
|
||||
{
|
||||
msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
|
||||
return true;
|
||||
backupCode = plugin.dc.getMD5(code);
|
||||
}
|
||||
discordId = admin.getDiscordID();
|
||||
}
|
||||
else if (plugin.mbl.isMasterBuilderImpostor(playerSender))
|
||||
{
|
||||
MasterBuilder masterBuilder = plugin.mbl.getEntryByName(playerSender.getName());
|
||||
if (masterBuilder.getDiscordID() == null)
|
||||
{
|
||||
msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
discordId = masterBuilder.getDiscordID();
|
||||
}
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
String code = plugin.dc.generateCode(10);
|
||||
if (plugin.pv.isPlayerImpostor(playerSender))
|
||||
{
|
||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(playerSender);
|
||||
plugin.dc.addPlayerVerificationCode(code, vPlayer);
|
||||
}
|
||||
else if (plugin.al.isAdminImpostor(playerSender))
|
||||
{
|
||||
Admin admin = plugin.al.getEntryByName(playerSender.getName());
|
||||
plugin.dc.addAdminVerificationCode(code, admin);
|
||||
}
|
||||
else if (plugin.mbl.isMasterBuilderImpostor(playerSender))
|
||||
{
|
||||
MasterBuilder masterBuilder = plugin.mbl.getEntryByName(playerSender.getName());
|
||||
plugin.dc.addMasterBuilderVerificationCode(code, masterBuilder);
|
||||
}
|
||||
plugin.dc.bot.getUserById(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + Ips.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);
|
||||
}
|
||||
else
|
||||
{
|
||||
String code = args[0];
|
||||
String backupCode = null;
|
||||
|
||||
if (plugin.pv.isPlayerImpostor(playerSender))
|
||||
{
|
||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(playerSender);
|
||||
VPlayer mapPlayer = plugin.dc.getPlayerVerificationCodes().get(code);
|
||||
if (mapPlayer == null)
|
||||
{
|
||||
if (!vPlayer.getBackupCodes().contains(plugin.dc.getMD5(code)))
|
||||
{
|
||||
msg("You have entered an invalid verification code", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
backupCode = plugin.dc.getMD5(code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.dc.removePlayerVerificationCode(code);
|
||||
}
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
||||
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
||||
playerSender.setOp(true);
|
||||
msg(YOU_ARE_OP);
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
{
|
||||
fPlayer.getFreezeData().setFrozen(false);
|
||||
msg("You have been unfrozen.");
|
||||
}
|
||||
plugin.pv.verifyPlayer(playerSender, backupCode);
|
||||
plugin.rm.updateDisplay(playerSender);
|
||||
return true;
|
||||
}
|
||||
else if (plugin.al.isAdminImpostor(playerSender))
|
||||
{
|
||||
Admin admin = plugin.al.getEntryByName(playerSender.getName());
|
||||
Admin mapAdmin = plugin.dc.getAdminVerificationCodes().get(code);
|
||||
if (mapAdmin == null)
|
||||
{
|
||||
if (!admin.getBackupCodes().contains(plugin.dc.getMD5(code)))
|
||||
{
|
||||
msg("You have entered an invalid verification code", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
backupCode = plugin.dc.getMD5(code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.dc.removeAdminVerificationCode(code);
|
||||
}
|
||||
|
||||
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
||||
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Re-adding " + admin.getName() + " to the admin list", true);
|
||||
|
||||
admin.setName(playerSender.getName());
|
||||
admin.addIp(Ips.getIp(playerSender));
|
||||
|
||||
if (backupCode != null)
|
||||
{
|
||||
admin.removeBackupCode(backupCode);
|
||||
}
|
||||
|
||||
if (!plugin.mbl.isMasterBuilder(playerSender))
|
||||
{
|
||||
MasterBuilder masterBuilder = null;
|
||||
for (MasterBuilder loopMasterBuilder : plugin.mbl.getAllMasterBuilders().values())
|
||||
{
|
||||
if (loopMasterBuilder.getName().equalsIgnoreCase(playerSender.getName()))
|
||||
{
|
||||
masterBuilder = loopMasterBuilder;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (masterBuilder != null)
|
||||
{
|
||||
masterBuilder.setName(playerSender.getName());
|
||||
masterBuilder.addIp(Ips.getIp(playerSender));
|
||||
|
||||
masterBuilder.setLastLogin(new Date());
|
||||
|
||||
plugin.mbl.save();
|
||||
plugin.mbl.updateTables();
|
||||
}
|
||||
}
|
||||
|
||||
admin.setActive(true);
|
||||
admin.setLastLogin(new Date());
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
plugin.rm.updateDisplay(playerSender);
|
||||
playerSender.setOp(true);
|
||||
msg(YOU_ARE_OP);
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
{
|
||||
fPlayer.getFreezeData().setFrozen(false);
|
||||
msg("You have been unfrozen.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (plugin.mbl.isMasterBuilderImpostor(playerSender))
|
||||
{
|
||||
MasterBuilder masterBuilder = plugin.mbl.getEntryByName(playerSender.getName());
|
||||
MasterBuilder mapMasterBuilder = plugin.dc.getMasterBuilderVerificationCodes().get(code);
|
||||
if (mapMasterBuilder == null)
|
||||
{
|
||||
if (!masterBuilder.getBackupCodes().contains(plugin.dc.getMD5(code)))
|
||||
{
|
||||
msg("You have entered an invalid verification code", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
backupCode = plugin.dc.getMD5(code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.dc.removeMasterBuilderVerificationCode(code);
|
||||
}
|
||||
|
||||
if (backupCode != null)
|
||||
{
|
||||
masterBuilder.removeBackupCode(backupCode);
|
||||
}
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
||||
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
||||
masterBuilder.setLastLogin(new Date());
|
||||
masterBuilder.addIp(Ips.getIp(playerSender));
|
||||
plugin.mbl.save();
|
||||
plugin.mbl.updateTables();
|
||||
plugin.rm.updateDisplay(playerSender);
|
||||
playerSender.setOp(true);
|
||||
msg(YOU_ARE_OP);
|
||||
if (fPlayer.getFreezeData().isFrozen())
|
||||
{
|
||||
fPlayer.getFreezeData().setFrozen(false);
|
||||
msg("You have been unfrozen.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -40,7 +38,7 @@ public class Command_verifynoadmin extends FreedomCommand
|
||||
{
|
||||
plugin.al.verifiedNoAdmins.add(player.getName());
|
||||
}
|
||||
String ip = Ips.getIp(player);
|
||||
String ip = FUtil.getIp(player);
|
||||
if (!plugin.al.verifiedNoAdminIps.containsKey(player.getName()))
|
||||
{
|
||||
List<String> ips = new ArrayList<>();
|
||||
|
@ -46,7 +46,7 @@ public class Command_warn extends FreedomCommand
|
||||
|
||||
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
|
||||
msg(player, ChatColor.RED + "[WARNING] You received a warning: " + warnReason);
|
||||
msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason);
|
||||
player.sendTitle(ChatColor.RED + "You've been warned.", ChatColor.YELLOW + "Reason: " + warnReason, 20, 100, 60);
|
||||
msg(ChatColor.GREEN + "You have successfully warned " + player.getName());
|
||||
final StringBuilder adminNotice = new StringBuilder()
|
||||
|
@ -1,8 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.nio.channels.FileLock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -31,16 +34,33 @@ public class Command_wildcard extends FreedomCommand
|
||||
}
|
||||
|
||||
Command runCmd = server.getPluginCommand(args[0]);
|
||||
if (runCmd == null)
|
||||
FreedomCommand fCmd = plugin.cl.getByName(args[0]);
|
||||
boolean alias = plugin.cl.isAlias(args[0]);
|
||||
if (runCmd == null && fCmd == null && !alias)
|
||||
{
|
||||
msg("Unknown command: " + args[0], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (BLOCKED_COMMANDS.contains(runCmd.getName()))
|
||||
List<String> aliases = new ArrayList<>();
|
||||
|
||||
if (runCmd != null)
|
||||
{
|
||||
msg("Did you really think that was going to work?", ChatColor.RED);
|
||||
return true;
|
||||
aliases = runCmd.getAliases();
|
||||
}
|
||||
|
||||
if (fCmd != null)
|
||||
{
|
||||
aliases = Arrays.asList(fCmd.getAliases().split(","));
|
||||
}
|
||||
|
||||
for (String blockedCommand : BLOCKED_COMMANDS)
|
||||
{
|
||||
if (blockedCommand.equals(args[0].toLowerCase()) || aliases.contains(blockedCommand))
|
||||
{
|
||||
msg("Did you really think that was going to work?", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
String baseCommand = StringUtils.join(args, " ");
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.Server;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandParameters(description = "Wipe the flatlands map. Requires manual restart after command is used.", usage = "/<command>")
|
||||
|
@ -1,98 +1,233 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.lang.reflect.Field;
|
||||
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 lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.command.AbstractCommandBase;
|
||||
import net.pravian.aero.util.Players;
|
||||
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.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.spigotmc.SpigotConfig;
|
||||
|
||||
public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod>
|
||||
public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
{
|
||||
public static final String COMMAND_PREFIX = "Command_";
|
||||
|
||||
@Getter
|
||||
private static CommandMap commandMap;
|
||||
@Getter
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String usage;
|
||||
@Getter
|
||||
private final String aliases;
|
||||
private final Rank level;
|
||||
private final SourceType source;
|
||||
private final boolean blockHostConsole;
|
||||
private final int cooldown;
|
||||
private final CommandParameters params;
|
||||
@Getter
|
||||
private final CommandPermissions perms;
|
||||
|
||||
protected CommandSender sender;
|
||||
|
||||
protected final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
||||
protected final Server server = plugin.getServer();
|
||||
|
||||
public static final String UNKNOWN_COMMAND = ChatColor.WHITE + SpigotConfig.unknownCommandMessage;
|
||||
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!";
|
||||
//
|
||||
@Getter
|
||||
private final CommandParameters params;
|
||||
@Getter
|
||||
private final CommandPermissions perms;
|
||||
//
|
||||
public static final String ONLY_CONSOLE = ChatColor.RED + "Only console senders may execute this command!";
|
||||
public static final String ONLY_IN_GAME = ChatColor.RED + "Only in-game players may execute this command!";
|
||||
public static final String NO_PERMISSION = ChatColor.RED + "You do not have permission to execute this command.";
|
||||
|
||||
public FreedomCommand()
|
||||
public static final Timer timer = new Timer();
|
||||
public static final Map<CommandSender, FreedomCommand> COOLDOWN_TIMERS = new HashMap<>();
|
||||
|
||||
FreedomCommand()
|
||||
{
|
||||
this.params = getClass().getAnnotation(CommandParameters.class);
|
||||
if (params == null)
|
||||
{
|
||||
FLog.warning("Ignoring command usage for command " + getClass().getSimpleName() + ". Command is not annotated!");
|
||||
}
|
||||
|
||||
this.perms = getClass().getAnnotation(CommandPermissions.class);
|
||||
if (perms == null)
|
||||
{
|
||||
FLog.warning("Ignoring permissions for command " + getClass().getSimpleName() + ". Command is not annotated!");
|
||||
}
|
||||
params = getClass().getAnnotation(CommandParameters.class);
|
||||
perms = getClass().getAnnotation(CommandPermissions.class);
|
||||
this.name = getClass().getSimpleName().replace(COMMAND_PREFIX, "").toLowerCase();
|
||||
this.description = params.description();
|
||||
this.usage = params.usage();
|
||||
this.aliases = params.aliases();
|
||||
this.level = perms.level();
|
||||
this.source = perms.source();
|
||||
this.blockHostConsole = perms.blockHostConsole();
|
||||
this.cooldown = perms.cooldown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean runCommand(final CommandSender sender, final Command command, final String label, final String[] args)
|
||||
public void register()
|
||||
{
|
||||
setVariables(sender, command, label, args);
|
||||
|
||||
try
|
||||
{
|
||||
return run(sender, playerSender, command, label, args, isConsole());
|
||||
}
|
||||
catch (CommandFailException ex)
|
||||
{
|
||||
msg(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe("Uncaught exception executing command: " + command.getName());
|
||||
FLog.severe(ex);
|
||||
sender.sendMessage(ChatColor.RED + "Command error: " + (ex.getMessage() == null ? "Unknown cause" : ex.getMessage()));
|
||||
return true;
|
||||
}
|
||||
FCommand cmd = new FCommand(this.name);
|
||||
if (this.aliases != null) cmd.setAliases(Arrays.asList(StringUtils.split(this.aliases, ",")));
|
||||
if (this.description != null) cmd.setDescription(this.description);
|
||||
if (this.usage != null) cmd.setUsage(this.usage);
|
||||
getCommandMap().register("", cmd);
|
||||
cmd.setExecutor(this);
|
||||
}
|
||||
|
||||
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return null;
|
||||
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)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return commandMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
|
||||
private final class FCommand extends Command
|
||||
{
|
||||
List<String> options = getTabCompleteOptions(sender, command, alias, args);
|
||||
if (options == null)
|
||||
private FreedomCommand cmd = null;
|
||||
private FCommand(String command)
|
||||
{
|
||||
super(command);
|
||||
}
|
||||
public void setExecutor(FreedomCommand cmd)
|
||||
{
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
public boolean execute(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
if (cmd != null)
|
||||
{
|
||||
cmd.sender = sender;
|
||||
|
||||
if (COOLDOWN_TIMERS.containsKey(sender) && COOLDOWN_TIMERS.containsValue(cmd))
|
||||
{
|
||||
msg(ChatColor.RED + "You are on cooldown for this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()))
|
||||
{
|
||||
msg(ChatColor.RED + "Host console is not allowed to use this command!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.rm.getRank(sender).isAtLeast(perms.level()))
|
||||
{
|
||||
msg(NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.source() == SourceType.ONLY_CONSOLE && sender instanceof Player)
|
||||
{
|
||||
msg(ONLY_CONSOLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.source() == SourceType.ONLY_IN_GAME && sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
msg(ONLY_IN_GAME);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.cooldown() != 0 && !isAdmin(sender))
|
||||
{
|
||||
COOLDOWN_TIMERS.put(sender, cmd);
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
COOLDOWN_TIMERS.remove(sender);
|
||||
}
|
||||
}, perms.cooldown() * 1000);
|
||||
}
|
||||
return cmd.onCommand(sender, this, commandLabel, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args)
|
||||
{
|
||||
if (cmd != null)
|
||||
{
|
||||
return cmd.onTabComplete(sender, this, alias, args);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.<String>newArrayList());
|
||||
}
|
||||
|
||||
protected abstract boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole);
|
||||
protected void msg(CommandSender sender, String message)
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + message);
|
||||
}
|
||||
|
||||
protected void msg(Player player, String message)
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + message);
|
||||
}
|
||||
|
||||
protected void msg(Player player, String message, ChatColor color)
|
||||
{
|
||||
player.sendMessage(color + message);
|
||||
}
|
||||
|
||||
protected void msg(String message)
|
||||
{
|
||||
msg(sender, message);
|
||||
}
|
||||
|
||||
protected void msg(String message, ChatColor color)
|
||||
{
|
||||
msg(color + message);
|
||||
}
|
||||
|
||||
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(CommandSender sender)
|
||||
{
|
||||
return plugin.al.isAdmin(sender);
|
||||
}
|
||||
|
||||
protected void checkConsole()
|
||||
{
|
||||
if (!isConsole())
|
||||
{
|
||||
throw new CommandFailException(getHandler().getOnlyConsoleMessage());
|
||||
throw new CommandFailException(ONLY_CONSOLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,15 +235,7 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
||||
{
|
||||
if (isConsole())
|
||||
{
|
||||
throw new CommandFailException(getHandler().getOnlyPlayerMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkNotHostConsole()
|
||||
{
|
||||
if (isConsole() && FUtil.isFromHostConsole(sender.getName()))
|
||||
{
|
||||
throw new CommandFailException("This command can not be used from the host console.");
|
||||
throw new CommandFailException(ONLY_IN_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,58 +247,67 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean noPerms()
|
||||
protected void checkNotHostConsole()
|
||||
{
|
||||
throw new CommandFailException(getHandler().getPermissionMessage());
|
||||
if (isConsole() && FUtil.isFromHostConsole(sender.getName()))
|
||||
{
|
||||
throw new CommandFailException("This command can not be used from the host console.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, 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)
|
||||
{
|
||||
msg(ChatColor.RED + ex.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
List<String> options = getTabCompleteOptions(sender, command, alias, args);
|
||||
if (options == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.newArrayList());
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
|
||||
protected boolean isConsole()
|
||||
{
|
||||
return !(sender instanceof Player);
|
||||
return sender instanceof ConsoleCommandSender;
|
||||
}
|
||||
|
||||
protected Player getPlayer(String name)
|
||||
{
|
||||
return Players.getPlayer(name);
|
||||
return Bukkit.getPlayer(name);
|
||||
}
|
||||
|
||||
protected Player getPlayer(String name, Boolean nullVanished)
|
||||
{
|
||||
Player player = Players.getPlayer(name);
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if (nullVanished && plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return Players.getPlayer(name);
|
||||
}
|
||||
|
||||
protected void msg(final CommandSender sender, final String message, final ChatColor color)
|
||||
{
|
||||
if (sender == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(color + message);
|
||||
}
|
||||
|
||||
protected void msg(final String message, final ChatColor color)
|
||||
{
|
||||
msg(sender, message, color);
|
||||
}
|
||||
|
||||
protected void msg(final CommandSender sender, final String message)
|
||||
{
|
||||
msg(sender, message, ChatColor.GRAY);
|
||||
}
|
||||
|
||||
protected void msg(final String message)
|
||||
{
|
||||
msg(sender, message);
|
||||
}
|
||||
|
||||
protected boolean isAdmin(CommandSender sender)
|
||||
{
|
||||
return plugin.al.isAdmin(sender);
|
||||
return player;
|
||||
}
|
||||
|
||||
protected Admin getAdmin(CommandSender sender)
|
||||
@ -189,12 +325,16 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
||||
return plugin.pl.getData(player);
|
||||
}
|
||||
|
||||
protected boolean noPerms()
|
||||
{
|
||||
throw new CommandFailException(NO_PERMISSION);
|
||||
}
|
||||
|
||||
public static FreedomCommand getFrom(Command command)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (FreedomCommand)((FreedomCommandExecutor)(((PluginCommand)command).getExecutor())).getCommandBase();
|
||||
return (FreedomCommand) (((PluginCommand) command).getExecutor());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,221 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.command.AeroCommandBase;
|
||||
import net.pravian.aero.command.executor.AbstractCommandExecutor;
|
||||
import net.pravian.aero.command.executor.AeroCommandExecutor;
|
||||
import net.pravian.aero.command.executor.AeroCommandExecutorFactory;
|
||||
import net.pravian.aero.command.handler.AeroCommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FreedomCommandExecutor<C extends AeroCommandBase<?>> extends AbstractCommandExecutor<C>
|
||||
{
|
||||
|
||||
private final TotalFreedomMod plugin;
|
||||
//
|
||||
public static Map<CommandSender, FreedomCommand> commandCooldown = new HashMap<>();
|
||||
public static final Timer timer = new Timer();
|
||||
|
||||
public FreedomCommandExecutor(TotalFreedomMod plugin, AeroCommandHandler<?> handler, String name, C command)
|
||||
{
|
||||
super(handler, name, command);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
protected FreedomCommand getCommand()
|
||||
{
|
||||
return commandBase instanceof FreedomCommand ? (FreedomCommand)commandBase : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupCommand(PluginCommand pluginCommand)
|
||||
{
|
||||
final FreedomCommand command = getCommand();
|
||||
if (command == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final CommandParameters params = command.getParams();
|
||||
if (params == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String aliasString = params.aliases();
|
||||
|
||||
if (aliasString.length() > 0)
|
||||
{
|
||||
pluginCommand.setAliases(Arrays.asList(params.aliases().split(",")));
|
||||
}
|
||||
pluginCommand.setDescription(params.description());
|
||||
pluginCommand.setUsage(params.usage());
|
||||
|
||||
// Check if permisions are correctly set up
|
||||
CommandPermissions perms = command.getPerms();
|
||||
if (perms != null)
|
||||
{
|
||||
if (perms.level().isConsole())
|
||||
{
|
||||
FLog.warning("[Command] " + pluginCommand.getName() + " - permission is set to a console rank, "
|
||||
+ "should be set to player variant with 'source = SourceType.ONLY_CONSOLE'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (!hasPermission(sender, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isOnCooldown(sender))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
boolean run = commandBase.runCommand(sender, command, label, args);
|
||||
FreedomCommand c = getCommand();
|
||||
CommandPermissions perms = c.getPerms();
|
||||
if (perms.cooldown() > 0 && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
commandCooldown.put(sender, c);
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
commandCooldown.remove(sender);
|
||||
}
|
||||
}, perms.cooldown() * 1000);
|
||||
}
|
||||
return run;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// If this is ever ran, TFM failed :
|
||||
FLog.severe("Unhandled command exception: " + command.getName());
|
||||
FLog.severe(ex);
|
||||
sender.sendMessage(ChatColor.RED + "Unhandled Command Error: " + command.getName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender, boolean sendMsg)
|
||||
{
|
||||
final FreedomCommand command = getCommand();
|
||||
if (command == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final CommandPermissions perms = command.getPerms();
|
||||
if (perms == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Block host console
|
||||
if (FUtil.isFromHostConsole(sender.getName())
|
||||
&& perms.blockHostConsole())
|
||||
{
|
||||
if (sendMsg)
|
||||
{
|
||||
sender.sendMessage(handler.getPermissionMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = sender instanceof Player ? (Player)sender : null;
|
||||
|
||||
// Only console
|
||||
if (perms.source() == SourceType.ONLY_CONSOLE
|
||||
&& player != null)
|
||||
{
|
||||
if (sendMsg)
|
||||
{
|
||||
sender.sendMessage(handler.getOnlyConsoleMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only in game
|
||||
if (perms.source() == SourceType.ONLY_IN_GAME
|
||||
&& player == null)
|
||||
{
|
||||
if (sendMsg)
|
||||
{
|
||||
sender.sendMessage(handler.getOnlyPlayerMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player permissions
|
||||
if (player != null)
|
||||
{
|
||||
Rank rank = plugin.rm.getRank(player);
|
||||
boolean result = rank.isAtLeast(perms.level());
|
||||
if (!result && sendMsg)
|
||||
{
|
||||
sender.sendMessage(handler.getPermissionMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Console permissions
|
||||
Rank rank = plugin.rm.getRank(sender);
|
||||
boolean result = rank.isAtLeast(perms.level());
|
||||
if (!result && sendMsg)
|
||||
{
|
||||
sender.sendMessage(handler.getPermissionMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isOnCooldown(CommandSender sender)
|
||||
{
|
||||
final FreedomCommand command = getCommand();
|
||||
if (commandCooldown.containsKey(sender) && commandCooldown.containsValue(command))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You're on cooldown for this command.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class FreedomExecutorFactory implements AeroCommandExecutorFactory
|
||||
{
|
||||
|
||||
private final TotalFreedomMod plugin;
|
||||
|
||||
public FreedomExecutorFactory(TotalFreedomMod plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AeroCommandExecutor<? extends AeroCommandBase<?>> newExecutor(AeroCommandHandler<?> handler, String name, AeroCommandBase<?> command)
|
||||
{
|
||||
return new FreedomCommandExecutor<>(plugin, handler, name, command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user