General stuff & whitelist (work in progress)

This commit is contained in:
Jerom van der Sar 2012-09-17 18:29:43 +02:00
parent 9fcc195959
commit 92110f78c4
13 changed files with 221 additions and 47 deletions

View file

@ -21,13 +21,13 @@ public class Command_adminmode extends TFM_Command
if (args[0].equalsIgnoreCase("off")) if (args[0].equalsIgnoreCase("off"))
{ {
TotalFreedomMod.adminOnlyMode = false; TotalFreedomMod.adminOnlyMode = false;
TFM_Util.bcastMsg("Server is now open to all players.", ChatColor.RED); TFM_Util.adminAction(sender.getName(), "Opening the server to all players.", true);
return true; return true;
} }
else if (args[0].equalsIgnoreCase("on")) else if (args[0].equalsIgnoreCase("on"))
{ {
TotalFreedomMod.adminOnlyMode = true; TotalFreedomMod.adminOnlyMode = true;
TFM_Util.bcastMsg("Server is now closed to non-superadmins.", ChatColor.RED); TFM_Util.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (!TFM_Util.isUserSuperadmin(p)) if (!TFM_Util.isUserSuperadmin(p))

View file

@ -1,5 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Arrays;
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;
@ -12,10 +15,22 @@ import org.bukkit.entity.Player;
public class Command_doom extends TFM_Command public class Command_doom extends TFM_Command
{ {
public String[] p =
{
"madgeek",
"darth",
"madgeek1450",
"mark",
"markbyron",
"darthsalamon"
};
public List<String> players = Arrays.asList(p);
@Override @Override
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
if(!(TFM_Util.isUserSuperadmin(sender))) if(!(senderIsConsole && players.contains(sender.getName().toLowerCase())))
{ {
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true; return true;
@ -39,7 +54,7 @@ public class Command_doom extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + p.getName(), true); TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + p.getName(), true);
TFM_Util.bcastMsg(p.getName() + " will be completely obliveriated!", ChatColor.RED); TFM_Util.bcastMsg(p.getName() + " will be completely obliviated!", ChatColor.RED);
final String IP = p.getAddress().getAddress().getHostAddress().trim(); final String IP = p.getAddress().getAddress().getHostAddress().trim();
@ -98,7 +113,7 @@ public class Command_doom extends TFM_Command
p.getWorld().createExplosion(p.getLocation(), 4F); p.getWorld().createExplosion(p.getLocation(), 4F);
// kick player // kick player
p.kickPlayer(ChatColor.RED + "You, my dear friend must FUCKOFF!"); p.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
} }
}, 60L); // 3 seconds }, 60L); // 3 seconds

View file

@ -26,16 +26,10 @@ public class Command_ops extends TFM_Command
if (args[0].equalsIgnoreCase("list")) if (args[0].equalsIgnoreCase("list"))
{ {
String ops = ""; String ops = TFM_Util.arrayToString(server.getOperators());
String delim = "";
for (OfflinePlayer p : server.getOperators())
{
ops += delim;
ops += p.getName();
delim = ",";
}
TFM_Util.playerMsg(sender, "Operators: " + ops); TFM_Util.playerMsg(sender, "Operators:");
TFM_Util.playerMsg(sender, ops);
return true; return true;
} }
@ -68,7 +62,7 @@ public class Command_ops extends TFM_Command
if (args[0].equalsIgnoreCase("purge")) if (args[0].equalsIgnoreCase("purge"))
{ {
if (!(TFM_Util.isUserSuperadmin(sender) || senderIsConsole)) if (!senderIsConsole)
{ {
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true; return true;

View file

@ -24,11 +24,11 @@ public class Command_qdeop extends TFM_Command
boolean matched_player = false; boolean matched_player = false;
String target_name = args[0].toLowerCase(); String target = args[0].toLowerCase();
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (p.getName().toLowerCase().indexOf(target_name) > 0 || p.getDisplayName().toLowerCase().indexOf(target_name) > 0) if (p.getName().toLowerCase().contains(target))
{ {
matched_player = true; matched_player = true;

View file

@ -24,11 +24,11 @@ public class Command_qop extends TFM_Command
boolean matched_player = false; boolean matched_player = false;
String target_name = args[0].toLowerCase(); String target = args[0].toLowerCase();
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (p.getName().toLowerCase().indexOf(target_name) > 0 || p.getDisplayName().toLowerCase().indexOf(target_name) > 0) if (p.getName().toLowerCase().contains(target))
{ {
matched_player = true; matched_player = true;

View file

@ -36,6 +36,11 @@ public class Command_saconfig extends TFM_Command
return true; return true;
} }
if (sender.getName().equalsIgnoreCase("remotebukkit"))
{
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
}
if (args.length < 2) if (args.length < 2)
{ {
return false; return false;

View file

@ -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.ChatColor;
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;
@ -15,7 +14,7 @@ public class Command_stfu 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 || args.length > 1) if (args.length != 1)
{ {
return false; return false;
} }
@ -49,7 +48,7 @@ public class Command_stfu extends TFM_Command
if (args[0].equalsIgnoreCase("purge")) if (args[0].equalsIgnoreCase("purge"))
{ {
TFM_Util.bcastMsg(ChatColor.RED + sender.getName() + " - Unmuting all players."); TFM_Util.adminAction(sender.getName(), "Unmuting all players.", true);
TFM_UserInfo info; TFM_UserInfo info;
int count = 0; int count = 0;
for (Player mp : server.getOnlinePlayers()) for (Player mp : server.getOnlinePlayers())
@ -64,7 +63,27 @@ public class Command_stfu extends TFM_Command
TFM_Util.playerMsg(sender, "Unmuted " + count + " players."); TFM_Util.playerMsg(sender, "Unmuted " + count + " players.");
return true; return true;
} }
if(args[0].equalsIgnoreCase("all"))
{
TFM_Util.adminAction(sender.getName(), "Muting all non-Superadmins", true);
TFM_UserInfo playerdata;
int counter = 0;
for(Player p : server.getOnlinePlayers())
{
if(!TFM_Util.isUserSuperadmin(p))
{
playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setMuted(true);
counter++;
}
}
TFM_Util.playerMsg(sender, "Muted " + counter + " players.");
}
Player p; Player p;
try try
{ {

View file

@ -0,0 +1,93 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Command_whitelist extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if(args.length < 1)
{
return false;
}
if(!sender.isOp())
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
// list
if(args[0].equalsIgnoreCase("list"))
{
String players = TFM_Util.arrayToString(server.getWhitelistedPlayers());
TFM_Util.playerMsg(sender, "Whitelisted players:");
TFM_Util.playerMsg(sender, players);
return true;
}
// count
if(args[0].equalsIgnoreCase("count"))
{
int onlineWPs = 0;
int offlineWPs = 0;
int totalWPs = 0;
for (OfflinePlayer p : server.getWhitelistedPlayers())
{
if (p.isOnline())
{
onlineWPs++;
}
else
{
offlineWPs++;
}
totalWPs++;
}
sender.sendMessage(ChatColor.GRAY + "Online whitelisted players: " + onlineWPs);
sender.sendMessage(ChatColor.GRAY + "Offline whitelisted players: " + offlineWPs);
sender.sendMessage(ChatColor.GRAY + "Total whitelisted players: " + totalWPs);
return true;
}
// all commands past this line are superadmin-only
if(!(senderIsConsole || TFM_Util.isUserSuperadmin(sender)))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
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.");
}
return true;
}
}

View file

@ -231,25 +231,24 @@ 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();
// if (p.getItemInHand().getType() == Material.SPECKLED_MELON)
// { Block block_pos = user_pos.clone().add(user_pos.getDirection().multiply(-2.0)).getBlock();
// 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 ((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();

View file

@ -712,16 +712,20 @@ public class TFM_Util
if (sender.getName().equalsIgnoreCase("markbyron")) if (sender.getName().equalsIgnoreCase("markbyron"))
{ {
return "the " + ChatColor.LIGHT_PURPLE + "server owner" + ChatColor.AQUA + "."; return "the " + ChatColor.LIGHT_PURPLE + "owner" + ChatColor.AQUA + ".";
} }
if (sender.getName().equalsIgnoreCase("madgeek1450")) if (sender.getName().equalsIgnoreCase("madgeek1450"))
{ {
return "the " + ChatColor.DARK_PURPLE + "server chief-developer" + ChatColor.AQUA + "."; return "the " + ChatColor.DARK_PURPLE + "developer" + ChatColor.AQUA + ".";
} }
if (sender.getName().equalsIgnoreCase("darthsalamon")) if (sender.getName().equalsIgnoreCase("darthsalamon"))
{ {
return "a " + ChatColor.DARK_PURPLE + "server developer" + ChatColor.AQUA + "!"; return "a " + ChatColor.DARK_PURPLE + "developer" + ChatColor.AQUA + "!";
}
if (sender.getName().equalsIgnoreCase("miwojedk"))
{
return "a " + ChatColor.DARK_RED+ "master-builder" + ChatColor.AQUA + "!";
} }
if (TFM_Util.isUserSuperadmin(sender)) if (TFM_Util.isUserSuperadmin(sender))
@ -734,7 +738,7 @@ public class TFM_Util
return "an " + ChatColor.DARK_GREEN + "OP" + ChatColor.AQUA + "."; return "an " + ChatColor.DARK_GREEN + "OP" + ChatColor.AQUA + ".";
} }
return "a " + ChatColor.GREEN + "standard player" + ChatColor.AQUA + "."; return "a " + ChatColor.GREEN + "non-OP" + ChatColor.AQUA + ".";
} }
public static void banUsername(String name, String reason, String source, Date expire_date) public static void banUsername(String name, String reason, String source, Date expire_date)
@ -921,6 +925,21 @@ public class TFM_Util
return c.getTime(); return c.getTime();
} }
public static String arrayToString(Set<OfflinePlayer> set)
{
String players = "";
String delim = "";
for (OfflinePlayer p : set)
{
players += delim;
players += p.getName();
delim = ", ";
}
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;
// public static final double LOOKAT_STEP_DISTANCE = 0.2; // public static final double LOOKAT_STEP_DISTANCE = 0.2;

View file

@ -0,0 +1,26 @@
package me.StevenLawson.TotalFreedomMod;
import org.bukkit.ChatColor;
// Work in progress
@Deprecated
public enum TFM_message {
NO_PERMS(ChatColor.YELLOW + "You do not have permission to use this command."),
YOU_ARE_OP(ChatColor.YELLOW + "You are now op!"),
YOU_ARE_NOT_OP(ChatColor.YELLOW + "You are no longer op!"),
CAKE_LYRICS("But there's no sense crying over every mistake. You just keep on trying till you run out of cake."),
NOT_FROM_CONSOLE("This command may not be used from the console.")
;
private final String message;
TFM_message(String message)
{
this.message = message;
}
@Override
public String toString()
{
return message;
}
}

View file

@ -29,6 +29,7 @@ public class TotalFreedomMod extends JavaPlugin
public static final String SUPERADMIN_FILE = "superadmin.yml"; public static final String SUPERADMIN_FILE = "superadmin.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_";
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command."; public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!"; 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 YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";

View file

@ -32,7 +32,7 @@ commands:
description: Superadmin command - Deop everyone on the server. description: Superadmin command - Deop everyone on the server.
usage: /<command> usage: /<command>
doom: doom:
description: Owner command - For the worst of the worst, completely remove a player. description: Owner command - For the bad Superadmins.
usage: /<command> <playername> usage: /<command> <playername>
enchant: enchant:
description: Enchant items. description: Enchant items.
@ -165,7 +165,7 @@ commands:
usage: /<command> usage: /<command>
stfu: stfu:
description: Superadmin Command - Mutes a player with brute force. description: Superadmin Command - Mutes a player with brute force.
usage: /<command> [list | purge | <player>] usage: /<command> [<player> | list | purge | all]
aliases: [mute] aliases: [mute]
stop: stop:
description: Superadmin command - Kicks everyone and stops the server. description: Superadmin command - Kicks everyone and stops the server.
@ -194,11 +194,14 @@ commands:
waterplace: waterplace:
description: Superadmin command - Enable/disable water placement. description: Superadmin command - Enable/disable water placement.
usage: /<command> <on | off> usage: /<command> <on | off>
whitelist:
description: Superadmin command - Manage the whitelist.
usage: /<command> <on | off | list | count | add <player> | remove <player> | addall | purge>
wildcard: wildcard:
description: Superadmin command - Run any command on all users, username placeholder = ?. description: Superadmin command - Run any command on all users, username placeholder = ?.
usage: /<command> [fluff] ? [fluff] ? usage: /<command> [fluff] ? [fluff] ?
# wipeflatlands: # wipeflatlands:
# description: Console Command - Wipe the flatlands map. # description: Owner command - Wipe the flatlands map.
# usage: /<command> # usage: /<command>
ziptool: ziptool:
description: Owner command - Zip and unzip files. description: Owner command - Zip and unzip files.