mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Use Allman style, please!
Code cleanup. Switched to StringUtils.join, we are re-inventing the wheel :D Added whitelist support to TFM_PlayerListener auth code. @Deprecated some utility methods, will remove shortly.
This commit is contained in:
parent
c9c1b7519d
commit
3feec18131
@ -2,11 +2,8 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
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.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -15,109 +12,104 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class Command_doom extends TFM_Command
|
public class Command_doom extends TFM_Command
|
||||||
{
|
{
|
||||||
public String[] p =
|
public final static List<String> ALLOWED_USERS = Arrays.asList(
|
||||||
{
|
"madgeek",
|
||||||
"madgeek",
|
"darth",
|
||||||
"darth",
|
"madgeek1450",
|
||||||
"madgeek1450",
|
"mark",
|
||||||
"mark",
|
"markbyron",
|
||||||
"markbyron",
|
"darthsalamon");
|
||||||
"darthsalamon"
|
|
||||||
};
|
|
||||||
|
|
||||||
public List<String> players = Arrays.asList(p);
|
@Override
|
||||||
|
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (!(senderIsConsole && ALLOWED_USERS.contains(sender.getName().toLowerCase())))
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
if (args.length != 1)
|
||||||
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
{
|
||||||
{
|
return false;
|
||||||
if(!(senderIsConsole && players.contains(sender.getName().toLowerCase())))
|
}
|
||||||
{
|
|
||||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.length != 1)
|
final Player p;
|
||||||
{
|
try
|
||||||
return false;
|
{
|
||||||
}
|
p = getPlayer(args[0]);
|
||||||
|
}
|
||||||
|
catch (CantFindPlayerException ex)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
final Player p;
|
TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + p.getName(), true);
|
||||||
try
|
TFM_Util.bcastMsg(p.getName() + " will be completely obliviated!", ChatColor.RED);
|
||||||
{
|
|
||||||
p = getPlayer(args[0]);
|
|
||||||
}
|
|
||||||
catch(CantFindPlayerException ex)
|
|
||||||
{
|
|
||||||
sender.sendMessage(ex.getMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
final String IP = p.getAddress().getAddress().getHostAddress().trim();
|
||||||
|
|
||||||
TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + p.getName(), true);
|
// remove from superadmin
|
||||||
TFM_Util.bcastMsg(p.getName() + " will be completely obliviated!", ChatColor.RED);
|
if (TFM_Util.isUserSuperadmin(p))
|
||||||
|
{
|
||||||
|
server.dispatchCommand(sender, "saconfig delete " + p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
final String IP = p.getAddress().getAddress().getHostAddress().trim();
|
// remove from whitelist
|
||||||
|
p.setWhitelisted(false);
|
||||||
|
|
||||||
// remove from superadmin
|
// deop
|
||||||
if(TFM_Util.isUserSuperadmin(p))
|
p.setOp(false);
|
||||||
{
|
|
||||||
server.dispatchCommand(sender, "saconfig delete " + p.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove from whitelist
|
// ban IP
|
||||||
p.setWhitelisted(false);
|
TFM_Util.banIP(IP, null, null, null);
|
||||||
|
|
||||||
// deop
|
// ban name
|
||||||
p.setOp(false);
|
TFM_Util.banUsername(p.getName(), null, null, null);
|
||||||
|
|
||||||
// ban IP
|
// set gamemode to survival
|
||||||
Bukkit.banIP(IP);
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
// ban name
|
// clear inventory
|
||||||
p.setBanned(true);
|
p.closeInventory();
|
||||||
|
p.getInventory().clear();
|
||||||
|
|
||||||
// set gamemode to survival
|
// ignite player
|
||||||
p.setGameMode(GameMode.SURVIVAL);
|
p.setFireTicks(10000);
|
||||||
|
|
||||||
// clear inventory
|
// generate explosion
|
||||||
p.closeInventory();
|
p.getWorld().createExplosion(p.getLocation(), 4F);
|
||||||
p.getInventory().clear();
|
|
||||||
|
|
||||||
// ignite player
|
server.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable()
|
||||||
p.setFireTicks(10000);
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
// strike lightning
|
||||||
|
p.getWorld().strikeLightning(p.getLocation());
|
||||||
|
|
||||||
// generate explosion
|
// kill (if not done already)
|
||||||
p.getWorld().createExplosion(p.getLocation(), 4F);
|
p.setHealth(0);
|
||||||
|
}
|
||||||
|
}, 40L); // 2 seconds
|
||||||
|
|
||||||
server.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable()
|
server.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run()
|
||||||
// strike lightning
|
{
|
||||||
p.getWorld().strikeLightning(p.getLocation());
|
// message
|
||||||
|
TFM_Util.adminAction(sender.getName(), "Banning " + p.getName() + ", IP: " + IP, true);
|
||||||
|
|
||||||
// kill (if not done already)
|
// generate explosion
|
||||||
p.setHealth(0);
|
p.getWorld().createExplosion(p.getLocation(), 4F);
|
||||||
}
|
|
||||||
|
|
||||||
}, 40L); // 2 seconds
|
// kick player
|
||||||
|
p.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
|
||||||
|
}
|
||||||
|
}, 60L); // 3 seconds
|
||||||
|
|
||||||
server.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable()
|
return true;
|
||||||
{
|
}
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// message
|
|
||||||
TFM_Util.adminAction(sender.getName(), "Banning " + p.getName() + ", IP: " + IP, true);
|
|
||||||
|
|
||||||
// generate explosion
|
|
||||||
p.getWorld().createExplosion(p.getLocation(), 4F);
|
|
||||||
|
|
||||||
// kick player
|
|
||||||
p.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}, 60L); // 3 seconds
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ 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.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -26,10 +27,7 @@ public class Command_ops extends TFM_Command
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
String ops = TFM_Util.arrayToString(server.getOperators());
|
TFM_Util.playerMsg(sender, "Operators: " + StringUtils.join(server.getOperators(), ", "));
|
||||||
|
|
||||||
TFM_Util.playerMsg(sender, "Operators:");
|
|
||||||
TFM_Util.playerMsg(sender, ops);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,12 @@ public class Command_rd extends TFM_Command
|
|||||||
{
|
{
|
||||||
if (!(senderIsConsole || TFM_Util.isUserSuperadmin(sender)))
|
if (!(senderIsConsole || TFM_Util.isUserSuperadmin(sender)))
|
||||||
{
|
{
|
||||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
TFM_Util.adminAction(sender.getName(), "Removing all server entities", false);
|
|
||||||
|
//This terminology is wrong, this doesn't remove *all* entities, by far. - Madgeek
|
||||||
|
TFM_Util.adminAction(sender.getName(), "Removing all server entities.", false);
|
||||||
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeEntities(true, true)) + " enties removed.");
|
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeEntities(true, true)) + " enties removed.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -64,24 +64,24 @@ public class Command_stfu extends TFM_Command
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("all"))
|
if (args[0].equalsIgnoreCase("all"))
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Muting all non-Superadmins", true);
|
TFM_Util.adminAction(sender.getName(), "Muting all non-Superadmins", true);
|
||||||
|
|
||||||
TFM_UserInfo playerdata;
|
TFM_UserInfo playerdata;
|
||||||
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))
|
||||||
{
|
{
|
||||||
playerdata = TFM_UserInfo.getPlayerData(p);
|
playerdata = TFM_UserInfo.getPlayerData(p);
|
||||||
playerdata.setMuted(true);
|
playerdata.setMuted(true);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_Util.playerMsg(sender, "Muted " + counter + " players.");
|
|
||||||
|
|
||||||
|
TFM_Util.playerMsg(sender, "Muted " + counter + " players.");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player p;
|
Player p;
|
||||||
@ -101,7 +101,6 @@ public class Command_stfu extends TFM_Command
|
|||||||
TFM_Util.adminAction(sender.getName(), "Unmuting " + p.getName(), true);
|
TFM_Util.adminAction(sender.getName(), "Unmuting " + p.getName(), true);
|
||||||
playerdata.setMuted(false);
|
playerdata.setMuted(false);
|
||||||
TFM_Util.playerMsg(sender, "Unmuted " + p.getName());
|
TFM_Util.playerMsg(sender, "Unmuted " + p.getName());
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -11,33 +13,30 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class Command_whitelist extends TFM_Command
|
public class Command_whitelist extends TFM_Command
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if(args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!sender.isOp())
|
if (!sender.isOp())
|
||||||
{
|
{
|
||||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// list
|
// list
|
||||||
if(args[0].equalsIgnoreCase("list"))
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
String players = TFM_Util.arrayToString(server.getWhitelistedPlayers());
|
TFM_Util.playerMsg(sender, "Whitelisted players: " + StringUtils.join(server.getWhitelistedPlayers(), ", "));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
TFM_Util.playerMsg(sender, "Whitelisted players:");
|
// count
|
||||||
TFM_Util.playerMsg(sender, players);
|
if (args[0].equalsIgnoreCase("count"))
|
||||||
return true;
|
{
|
||||||
}
|
|
||||||
|
|
||||||
// count
|
|
||||||
if(args[0].equalsIgnoreCase("count"))
|
|
||||||
{
|
|
||||||
int onlineWPs = 0;
|
int onlineWPs = 0;
|
||||||
int offlineWPs = 0;
|
int offlineWPs = 0;
|
||||||
int totalWPs = 0;
|
int totalWPs = 0;
|
||||||
@ -60,135 +59,132 @@ public class Command_whitelist extends TFM_Command
|
|||||||
sender.sendMessage(ChatColor.GRAY + "Total whitelisted players: " + totalWPs);
|
sender.sendMessage(ChatColor.GRAY + "Total whitelisted players: " + totalWPs);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// all commands past this line are superadmin-only
|
// all commands past this line are superadmin-only
|
||||||
if(!(senderIsConsole || TFM_Util.isUserSuperadmin(sender)))
|
if (!(senderIsConsole || TFM_Util.isUserSuperadmin(sender)))
|
||||||
{
|
{
|
||||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// on
|
// on
|
||||||
if(args[0].equalsIgnoreCase("on"))
|
if (args[0].equalsIgnoreCase("on"))
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Turning the whitelist on", false);
|
TFM_Util.adminAction(sender.getName(), "Turning the whitelist on", false);
|
||||||
server.setWhitelist(true);
|
server.setWhitelist(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// off
|
// off
|
||||||
if(args[0].equalsIgnoreCase("off"))
|
if (args[0].equalsIgnoreCase("off"))
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Turning the whitelist off", false);
|
TFM_Util.adminAction(sender.getName(), "Turning the whitelist off", false);
|
||||||
server.setWhitelist(false);
|
server.setWhitelist(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
if(args[0].equalsIgnoreCase("add"))
|
if (args[0].equalsIgnoreCase("add"))
|
||||||
{
|
{
|
||||||
if(args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer p;
|
OfflinePlayer p;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p = getPlayer(args[1]);
|
p = getPlayer(args[1]);
|
||||||
}
|
}
|
||||||
catch(CantFindPlayerException ex)
|
catch (CantFindPlayerException ex)
|
||||||
{
|
{
|
||||||
if(!senderIsConsole)
|
if (!senderIsConsole)
|
||||||
{
|
{
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage(ex.getMessage());
|
||||||
sender.sendMessage(ChatColor.YELLOW + "You don't have permissions to whitelist offline players");
|
sender.sendMessage(ChatColor.YELLOW + "You don't have permissions to whitelist offline players");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p = server.getOfflinePlayer(args[0]);
|
p = server.getOfflinePlayer(args[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TFM_Util.adminAction(sender.getName(), "Adding " + p.getName() + " to the whitelist", false);
|
|
||||||
p.setWhitelisted(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove
|
TFM_Util.adminAction(sender.getName(), "Adding " + p.getName() + " to the whitelist", false);
|
||||||
if(args[0].equalsIgnoreCase("remove"))
|
p.setWhitelisted(true);
|
||||||
{
|
return true;
|
||||||
if(args.length < 2)
|
}
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
OfflinePlayer p;
|
// remove
|
||||||
try
|
if (args[0].equalsIgnoreCase("remove"))
|
||||||
{
|
{
|
||||||
p = getPlayer(args[1]);
|
if (args.length < 2)
|
||||||
}
|
{
|
||||||
catch(CantFindPlayerException ex)
|
return false;
|
||||||
{
|
}
|
||||||
p = server.getOfflinePlayer(args[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p.isWhitelisted())
|
OfflinePlayer p;
|
||||||
{
|
try
|
||||||
TFM_Util.adminAction(sender.getName(), "Removing " + p.getName() + "from the whitelist", false);
|
{
|
||||||
p.setWhitelisted(false);
|
p = getPlayer(args[1]);
|
||||||
return true;
|
}
|
||||||
}
|
catch (CantFindPlayerException ex)
|
||||||
else
|
{
|
||||||
{
|
p = server.getOfflinePlayer(args[0]);
|
||||||
TFM_Util.playerMsg(sender, "That player is not whitelisted");
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
if (p.isWhitelisted())
|
||||||
|
{
|
||||||
|
TFM_Util.adminAction(sender.getName(), "Removing " + p.getName() + "from the whitelist", false);
|
||||||
|
p.setWhitelisted(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TFM_Util.playerMsg(sender, "That player is not whitelisted");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// addall
|
}
|
||||||
if(args[0].equalsIgnoreCase("addall"))
|
|
||||||
{
|
|
||||||
TFM_Util.adminAction(sender.getName(), "Adding all online players to the whitelist", false);
|
|
||||||
int counter = 0;
|
|
||||||
for(Player p : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if(!p.isWhitelisted())
|
|
||||||
{
|
|
||||||
p.setWhitelisted(true);
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TFM_Util.playerMsg(sender, "Whitelisted " + counter + " players.");
|
// addall
|
||||||
return true;
|
if (args[0].equalsIgnoreCase("addall"))
|
||||||
}
|
{
|
||||||
|
TFM_Util.adminAction(sender.getName(), "Adding all online players to the whitelist", false);
|
||||||
|
int counter = 0;
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!p.isWhitelisted())
|
||||||
|
{
|
||||||
|
p.setWhitelisted(true);
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// all commands past this line are console/telnet only
|
TFM_Util.playerMsg(sender, "Whitelisted " + counter + " players.");
|
||||||
if(!senderIsConsole)
|
return true;
|
||||||
{
|
}
|
||||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//purge
|
// all commands past this line are console/telnet only
|
||||||
if(args[0].equalsIgnoreCase("purge"))
|
if (!senderIsConsole)
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Removing all players from the whitelist", true);
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
int counter = 0;
|
return true;
|
||||||
for(OfflinePlayer p : server.getWhitelistedPlayers())
|
}
|
||||||
{
|
|
||||||
p.setWhitelisted(false);
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
TFM_Util.playerMsg(sender, "Removed " + counter + " players from the whitelist");
|
|
||||||
|
|
||||||
return true;
|
//purge
|
||||||
}
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
|
{
|
||||||
|
Set whitelisted = MinecraftServer.getServer().getServerConfigurationManager().getWhitelisted();
|
||||||
|
TFM_Util.adminAction(sender.getName(), "Removing all players from the whitelist", true);
|
||||||
|
TFM_Util.playerMsg(sender, "Removed " + whitelisted.size() + " players from the whitelist.");
|
||||||
|
whitelisted.clear();
|
||||||
|
|
||||||
// none of the commands were executed
|
return true;
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
// none of the commands were executed
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,24 +231,6 @@ public class TFM_PlayerListener implements Listener
|
|||||||
p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
|
p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (p.getItemInHand().getType() == Material.SPECKLED_MELON)
|
|
||||||
{
|
|
||||||
if (TFM_Util.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
Location from_pos = event.getFrom().clone();
|
|
||||||
Location to_pos = event.getTo().clone();
|
|
||||||
|
|
||||||
|
|
||||||
Block block_pos = user_pos.clone().add(user_pos.getDirection().multiply(-2.0)).getBlock();
|
|
||||||
|
|
||||||
if ((block_pos.isEmpty() || block_pos.isLiquid()))
|
|
||||||
{
|
|
||||||
block_pos.setTypeIdAndData(Material.WOOL.getId(), DyeColor.values()[randomGenerator.nextInt(DyeColor.values().length)].getData(), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
|
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
|
||||||
{
|
{
|
||||||
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
|
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
|
||||||
@ -387,7 +369,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
|
|
||||||
playerdata.resetMsgCount();
|
playerdata.resetMsgCount();
|
||||||
|
|
||||||
TFM_Util.wipeEntities(true);
|
TFM_Util.wipeEntities(true, true);
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -721,6 +703,15 @@ public class TFM_PlayerListener implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scm.hasWhitelist)
|
||||||
|
{
|
||||||
|
if (!scm.getWhitelisted().contains(player_name))
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Player test_player : server.getOnlinePlayers())
|
for (Player test_player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (test_player.getName().equalsIgnoreCase(player_name))
|
if (test_player.getName().equalsIgnoreCase(player_name))
|
||||||
|
@ -28,7 +28,7 @@ public class TFM_Heartbeat implements Runnable
|
|||||||
|
|
||||||
if (TotalFreedomMod.autoEntityWipe)
|
if (TotalFreedomMod.autoEntityWipe)
|
||||||
{
|
{
|
||||||
TFM_Util.wipeEntities(!TotalFreedomMod.allowExplosions);
|
TFM_Util.wipeEntities(!TotalFreedomMod.allowExplosions, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TotalFreedomMod.disableNight)
|
if (TotalFreedomMod.disableNight)
|
||||||
|
@ -13,6 +13,7 @@ import java.util.zip.ZipOutputStream;
|
|||||||
import net.minecraft.server.BanEntry;
|
import net.minecraft.server.BanEntry;
|
||||||
import net.minecraft.server.BanList;
|
import net.minecraft.server.BanList;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -106,16 +107,17 @@ public class TFM_Util
|
|||||||
|
|
||||||
public static String implodeStringList(String glue, List<String> pieces)
|
public static String implodeStringList(String glue, List<String> pieces)
|
||||||
{
|
{
|
||||||
StringBuilder output = new StringBuilder();
|
// StringBuilder output = new StringBuilder();
|
||||||
for (int i = 0; i < pieces.size(); i++)
|
// for (int i = 0; i < pieces.size(); i++)
|
||||||
{
|
// {
|
||||||
if (i != 0)
|
// if (i != 0)
|
||||||
{
|
// {
|
||||||
output.append(glue);
|
// output.append(glue);
|
||||||
}
|
// }
|
||||||
output.append(pieces.get(i));
|
// output.append(pieces.get(i));
|
||||||
}
|
// }
|
||||||
return output.toString();
|
// return output.toString();
|
||||||
|
return StringUtils.join(pieces, glue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatLocation(Location in_loc)
|
public static String formatLocation(Location in_loc)
|
||||||
@ -396,6 +398,7 @@ public class TFM_Util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static int wipeEntities(boolean wipe_explosives)
|
public static int wipeEntities(boolean wipe_explosives)
|
||||||
{
|
{
|
||||||
return wipeEntities(wipe_explosives, false);
|
return wipeEntities(wipe_explosives, false);
|
||||||
@ -725,7 +728,7 @@ public class TFM_Util
|
|||||||
}
|
}
|
||||||
if (sender.getName().equalsIgnoreCase("miwojedk"))
|
if (sender.getName().equalsIgnoreCase("miwojedk"))
|
||||||
{
|
{
|
||||||
return "a " + ChatColor.DARK_RED+ "master-builder" + ChatColor.AQUA + "!";
|
return "a " + ChatColor.DARK_RED + "master-builder" + ChatColor.AQUA + "!";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TFM_Util.isUserSuperadmin(sender))
|
if (TFM_Util.isUserSuperadmin(sender))
|
||||||
@ -926,19 +929,20 @@ public class TFM_Util
|
|||||||
return c.getTime();
|
return c.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static String arrayToString(Set<OfflinePlayer> set)
|
public static String arrayToString(Set<OfflinePlayer> set)
|
||||||
{
|
{
|
||||||
String players = "";
|
String players = "";
|
||||||
String delim = "";
|
String delim = "";
|
||||||
|
|
||||||
for (OfflinePlayer p : set)
|
for (OfflinePlayer p : set)
|
||||||
{
|
{
|
||||||
players += delim;
|
players += delim;
|
||||||
players += p.getName();
|
players += p.getName();
|
||||||
delim = ", ";
|
delim = ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
// I wrote all this before i discovered getTargetBlock >.> - might come in handy some day...
|
// I wrote all this before i discovered getTargetBlock >.> - might come in handy some day...
|
||||||
// public static final double LOOKAT_VIEW_HEIGHT = 1.65;
|
// public static final double LOOKAT_VIEW_HEIGHT = 1.65;
|
||||||
|
Loading…
Reference in New Issue
Block a user