mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-27 20:27:37 +00:00
added permban feature
This commit is contained in:
parent
6aefb4e4cc
commit
322f233ce0
@ -57,6 +57,27 @@ public class Command_halt extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "Halted players:");
|
||||
TFM_UserInfo info;
|
||||
int count = 0;
|
||||
for (Player hp : server.getOnlinePlayers())
|
||||
{
|
||||
info = TFM_UserInfo.getPlayerData(hp);
|
||||
if (info.isHalted())
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "- " + hp.getName());
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "- none");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p;
|
||||
try
|
||||
{
|
||||
@ -112,7 +133,6 @@ public class Command_halt extends TFM_Command
|
||||
playerdata.setFrozen(false);
|
||||
playerdata.setMuted(false);
|
||||
playerdata.setHalted(false);
|
||||
|
||||
TFM_Util.playerMsg(p, "You are no longer halted.");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,78 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Command_permban extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if(!sender.isOp())
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "Permanently banned players:");
|
||||
int count = 0;
|
||||
for (String pbp : TotalFreedomMod.permbanned_players)
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "- " + pbp);
|
||||
count++;
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "- none");
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "Total: " + count);
|
||||
}
|
||||
|
||||
count = 0;
|
||||
TFM_Util.playerMsg(sender, "Permanently banned IPs:");
|
||||
for (String pbp : TotalFreedomMod.permbanned_ips)
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "- " + pbp);
|
||||
count++;
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "- none");
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "Total: " + count);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!senderIsConsole)
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("reload"))
|
||||
{
|
||||
plugin.loadPermbanConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
// no command executed
|
||||
return false;
|
||||
}
|
||||
}
|
@ -720,6 +720,25 @@ public class TFM_PlayerListener implements Listener
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for(String test_player : TotalFreedomMod.permbanned_players)
|
||||
{
|
||||
if(test_player.equalsIgnoreCase(player_name))
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your username is permanently banned from this server.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for(String test_ip : TotalFreedomMod.permbanned_ips)
|
||||
{
|
||||
if(test_ip.equalsIgnoreCase(player_ip))
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your IP-address is permanently banned from this server.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -342,7 +342,7 @@ public class TFM_UserInfo
|
||||
|
||||
public boolean isHalted()
|
||||
{
|
||||
return this.is_halted;
|
||||
return is_halted;
|
||||
}
|
||||
|
||||
public void setHalted(boolean is_halted)
|
||||
|
@ -27,6 +27,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
||||
public static final String CONFIG_FILE = "config.yml";
|
||||
public static final String SUPERADMIN_FILE = "superadmin.yml";
|
||||
public static final String PERMBAN_FILE = "permban.yml";
|
||||
public static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
|
||||
public static final String COMMAND_PREFIX = "Command_";
|
||||
|
||||
@ -54,9 +55,10 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
TotalFreedomMod.pluginName = this.getDescription().getName();
|
||||
|
||||
setAppProperties();
|
||||
|
||||
|
||||
loadMainConfig();
|
||||
loadSuperadminConfig();
|
||||
loadPermbanConfig();
|
||||
|
||||
TFM_UserList.getInstance(this);
|
||||
|
||||
@ -231,6 +233,40 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TFM_Log.info("Loaded " + superadmins.size() + " superadmins");
|
||||
TFM_Log.info("Loaded " + superadmin_ips.size() + " superadmin IPs");
|
||||
}
|
||||
|
||||
public static List<String> permbanned_players = new ArrayList<String>();
|
||||
public static List<String> permbanned_ips = new ArrayList<String>();
|
||||
|
||||
public void loadPermbanConfig()
|
||||
{
|
||||
TFM_Util.createDefaultConfiguration(PERMBAN_FILE, getFile());
|
||||
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), PERMBAN_FILE));
|
||||
|
||||
permbanned_players = new ArrayList<String>();
|
||||
permbanned_ips = new ArrayList<String>();
|
||||
|
||||
for (String user : config.getKeys(false))
|
||||
{
|
||||
permbanned_players.add(user.toLowerCase().trim());
|
||||
|
||||
List<String> user_ips = (List<String>) config.getStringList(user);
|
||||
for (String ip : user_ips)
|
||||
{
|
||||
ip = ip.toLowerCase().trim();
|
||||
if (!permbanned_ips.contains(ip))
|
||||
{
|
||||
permbanned_ips.add(ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TFM_Log.info("Loaded " + permbanned_players.size() + " permanently banned players");
|
||||
TFM_Log.info("Loaded " + permbanned_ips.size() + " permanently banned IPs");
|
||||
}
|
||||
|
||||
private void registerEventHandlers()
|
||||
|
10
src/permban.yml
Normal file
10
src/permban.yml
Normal file
@ -0,0 +1,10 @@
|
||||
#
|
||||
# Permanent bans
|
||||
# Only to be modified by markbyron
|
||||
#
|
||||
|
||||
badplayer1:
|
||||
- 123.123.123.123
|
||||
- 321.321.321.321
|
||||
badplayer2:
|
||||
- 111.111.111.111
|
@ -125,6 +125,9 @@ commands:
|
||||
orbit:
|
||||
description: Superadmin command - POW!!! Right in the kisser! One of these days Alice, straight to the Moon!
|
||||
usage: /<command> <target> [power]
|
||||
permban:
|
||||
description: Manage permanently banned players and IPs
|
||||
usage: /<command> <list | reload>
|
||||
prelog:
|
||||
description: Superadmin command - Enable/disable the command prelogger. When this is on, logs will be filled with many duplicate messages.
|
||||
usage: /<command> <on | off>
|
||||
|
Loading…
Reference in New Issue
Block a user