mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-16 20:36:12 +00:00
Fixed nonstandard formatting in recent commits.
Cleaned up the halt and permban commands. Nobody cares about the "count" when you first load the plugin. Lets not include that.
This commit is contained in:
parent
322f233ce0
commit
30c65d49ed
@ -26,7 +26,7 @@ public class Command_glist extends TFM_Command
|
|||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("purge"))
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Purging the banlist", true);
|
//Purge does not clear the banlist! This is not for clearing bans! This is for clearing the yaml file that stores the player/IP database!
|
||||||
TFM_UserList.getInstance(plugin).purge();
|
TFM_UserList.getInstance(plugin).purge();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
|
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -27,13 +26,13 @@ public class Command_halt extends TFM_Command
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("all"))
|
if (args[0].equalsIgnoreCase("all"))
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Halting all non-Superadmins", true);
|
TFM_Util.adminAction(sender.getName(), "Halting all non-superadmins.", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!TFM_Util.isUserSuperadmin(p))
|
if (!TFM_Util.isUserSuperadmin(p))
|
||||||
{
|
{
|
||||||
halt(p, sender);
|
setHalted(p, true);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,13 +42,13 @@ public class Command_halt extends TFM_Command
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("purge"))
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Unhalting all players", true);
|
TFM_Util.adminAction(sender.getName(), "Unhalting all players.", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (TFM_UserInfo.getPlayerData(p).isHalted())
|
if (TFM_UserInfo.getPlayerData(p).isHalted())
|
||||||
{
|
{
|
||||||
unhalt(p, sender);
|
setHalted(p, false);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,7 +58,6 @@ public class Command_halt extends TFM_Command
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
TFM_Util.playerMsg(sender, "Halted players:");
|
|
||||||
TFM_UserInfo info;
|
TFM_UserInfo info;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Player hp : server.getOnlinePlayers())
|
for (Player hp : server.getOnlinePlayers())
|
||||||
@ -67,13 +65,17 @@ public class Command_halt extends TFM_Command
|
|||||||
info = TFM_UserInfo.getPlayerData(hp);
|
info = TFM_UserInfo.getPlayerData(hp);
|
||||||
if (info.isHalted())
|
if (info.isHalted())
|
||||||
{
|
{
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
TFM_Util.playerMsg(sender, "Halted players:");
|
||||||
|
}
|
||||||
TFM_Util.playerMsg(sender, "- " + hp.getName());
|
TFM_Util.playerMsg(sender, "- " + hp.getName());
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
TFM_Util.playerMsg(sender, "- none");
|
TFM_Util.playerMsg(sender, "There are currently no halted players.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -93,22 +95,23 @@ public class Command_halt extends TFM_Command
|
|||||||
if (!TFM_UserInfo.getPlayerData(p).isHalted())
|
if (!TFM_UserInfo.getPlayerData(p).isHalted())
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Halting " + p.getName(), true);
|
TFM_Util.adminAction(sender.getName(), "Halting " + p.getName(), true);
|
||||||
halt(p, sender);
|
setHalted(p, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Unhalting " + p.getName(), true);
|
TFM_Util.adminAction(sender.getName(), "Unhalting " + p.getName(), true);
|
||||||
|
setHalted(p, false);
|
||||||
unhalt(p, sender);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void halt(Player p, CommandSender sender)
|
private void setHalted(Player p, boolean is_halted)
|
||||||
{
|
{
|
||||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
||||||
|
|
||||||
|
if (is_halted)
|
||||||
|
{
|
||||||
p.setOp(false);
|
p.setOp(false);
|
||||||
p.setGameMode(GameMode.SURVIVAL);
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
p.setFlying(false);
|
p.setFlying(false);
|
||||||
@ -123,11 +126,8 @@ public class Command_halt extends TFM_Command
|
|||||||
|
|
||||||
TFM_Util.playerMsg(p, "You have been halted, don't move!");
|
TFM_Util.playerMsg(p, "You have been halted, don't move!");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
public void unhalt(Player p, CommandSender sender)
|
|
||||||
{
|
{
|
||||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
|
||||||
|
|
||||||
p.setOp(true);
|
p.setOp(true);
|
||||||
p.setGameMode(GameMode.CREATIVE);
|
p.setGameMode(GameMode.CREATIVE);
|
||||||
playerdata.setFrozen(false);
|
playerdata.setFrozen(false);
|
||||||
@ -136,3 +136,4 @@ public class Command_halt extends TFM_Command
|
|||||||
TFM_Util.playerMsg(p, "You are no longer halted.");
|
TFM_Util.playerMsg(p, "You are no longer halted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -25,36 +24,32 @@ public class Command_permban extends TFM_Command
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
TFM_Util.playerMsg(sender, "Permanently banned players:");
|
if (TotalFreedomMod.permbanned_players.size() > 0)
|
||||||
int count = 0;
|
|
||||||
for (String pbp : TotalFreedomMod.permbanned_players)
|
|
||||||
{
|
{
|
||||||
TFM_Util.playerMsg(sender, "- " + pbp);
|
TFM_Util.playerMsg(sender, "No permanently banned player names.");
|
||||||
count++;
|
|
||||||
}
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
TFM_Util.playerMsg(sender, "- none");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TFM_Util.playerMsg(sender, "Total: " + count);
|
TFM_Util.playerMsg(sender, TotalFreedomMod.permbanned_players.size() + " permanently banned players:");
|
||||||
|
|
||||||
|
for (String player_name : TotalFreedomMod.permbanned_players)
|
||||||
|
{
|
||||||
|
TFM_Util.playerMsg(sender, "- " + player_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
count = 0;
|
if (TotalFreedomMod.permbanned_ips.size() > 0)
|
||||||
TFM_Util.playerMsg(sender, "Permanently banned IPs:");
|
|
||||||
for (String pbp : TotalFreedomMod.permbanned_ips)
|
|
||||||
{
|
{
|
||||||
TFM_Util.playerMsg(sender, "- " + pbp);
|
TFM_Util.playerMsg(sender, "No permanently banned IPs.");
|
||||||
count++;
|
|
||||||
}
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
TFM_Util.playerMsg(sender, "- none");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TFM_Util.playerMsg(sender, "Total: " + count);
|
TFM_Util.playerMsg(sender, TotalFreedomMod.permbanned_ips.size() + " permanently banned IPs:");
|
||||||
|
|
||||||
|
for (String ip_address : TotalFreedomMod.permbanned_ips)
|
||||||
|
{
|
||||||
|
TFM_Util.playerMsg(sender, "- " + ip_address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -72,7 +67,6 @@ public class Command_permban extends TFM_Command
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no command executed
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public class Command_rank extends TFM_Command
|
public class Command_rank extends TFM_Command
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -691,6 +691,26 @@ public class TFM_PlayerListener implements Listener
|
|||||||
return;
|
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)
|
||||||
|
{
|
||||||
|
//TODO: Add support for wildcards in permbanned_ips list.
|
||||||
|
//TODO: Create generic wildcard IP matching method since we do this several times already in this project.
|
||||||
|
if (test_ip.equalsIgnoreCase(player_ip))
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your IP address is permanently banned from this server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (server.getOnlinePlayers().length >= server.getMaxPlayers())
|
if (server.getOnlinePlayers().length >= server.getMaxPlayers())
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, but this server is full.");
|
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, but this server is full.");
|
||||||
@ -720,25 +740,6 @@ public class TFM_PlayerListener implements Listener
|
|||||||
return;
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,6 @@ public class TFM_UserInfo
|
|||||||
private int mp44_schedule_id = -1;
|
private int mp44_schedule_id = -1;
|
||||||
private boolean mp44_armed = false;
|
private boolean mp44_armed = false;
|
||||||
private boolean mp44_firing = false;
|
private boolean mp44_firing = false;
|
||||||
|
|
||||||
public static Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
|
public static Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
|
||||||
|
|
||||||
private TFM_UserInfo(Player player)
|
private TFM_UserInfo(Player player)
|
||||||
|
@ -25,9 +25,11 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
private final Server server = Bukkit.getServer();
|
private final Server server = Bukkit.getServer();
|
||||||
|
|
||||||
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
||||||
|
|
||||||
public static final String CONFIG_FILE = "config.yml";
|
public static final String CONFIG_FILE = "config.yml";
|
||||||
public static final String SUPERADMIN_FILE = "superadmin.yml";
|
public static final String SUPERADMIN_FILE = "superadmin.yml";
|
||||||
public static final String PERMBAN_FILE = "permban.yml";
|
public static final String PERMBAN_FILE = "permban.yml";
|
||||||
|
|
||||||
public static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
|
public static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
|
||||||
public static final String COMMAND_PREFIX = "Command_";
|
public static final String COMMAND_PREFIX = "Command_";
|
||||||
|
|
||||||
@ -233,9 +235,6 @@ 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_players = new ArrayList<String>();
|
||||||
@ -244,7 +243,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public void loadPermbanConfig()
|
public void loadPermbanConfig()
|
||||||
{
|
{
|
||||||
TFM_Util.createDefaultConfiguration(PERMBAN_FILE, getFile());
|
TFM_Util.createDefaultConfiguration(PERMBAN_FILE, getFile());
|
||||||
|
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), PERMBAN_FILE));
|
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), PERMBAN_FILE));
|
||||||
|
|
||||||
permbanned_players = new ArrayList<String>();
|
permbanned_players = new ArrayList<String>();
|
||||||
@ -264,9 +262,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_Log.info("Loaded " + permbanned_players.size() + " permanently banned players");
|
|
||||||
TFM_Log.info("Loaded " + permbanned_ips.size() + " permanently banned IPs");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEventHandlers()
|
private void registerEventHandlers()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Permanent bans
|
# Permanent Bans
|
||||||
# Only to be modified by markbyron
|
|
||||||
#
|
#
|
||||||
|
|
||||||
badplayer1:
|
badplayer1:
|
||||||
|
@ -75,7 +75,7 @@ commands:
|
|||||||
usage: /<command> <partialname>
|
usage: /<command> <partialname>
|
||||||
halt:
|
halt:
|
||||||
description: Superadmin command - Halts a player
|
description: Superadmin command - Halts a player
|
||||||
usage: /<command> <<partialname> | all | purge>
|
usage: /<command> <<partialname> | all | purge | list>
|
||||||
kicknoob:
|
kicknoob:
|
||||||
description: Superadmin command - Kick all non-superadmins on server.
|
description: Superadmin command - Kick all non-superadmins on server.
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
Loading…
Reference in New Issue
Block a user