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"))
{
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;
}
else if (args[0].equalsIgnoreCase("on"))
{
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())
{
if (!TFM_Util.isUserSuperadmin(p))

View File

@ -1,5 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Arrays;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
@ -12,10 +15,22 @@ import org.bukkit.entity.Player;
public class Command_doom extends TFM_Command
{
public String[] p =
{
"madgeek",
"darth",
"madgeek1450",
"mark",
"markbyron",
"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(!(TFM_Util.isUserSuperadmin(sender)))
if(!(senderIsConsole && players.contains(sender.getName().toLowerCase())))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
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.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();
@ -98,7 +113,7 @@ public class Command_doom extends TFM_Command
p.getWorld().createExplosion(p.getLocation(), 4F);
// 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

View File

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

View File

@ -24,11 +24,11 @@ public class Command_qdeop extends TFM_Command
boolean matched_player = false;
String target_name = args[0].toLowerCase();
String target = args[0].toLowerCase();
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;

View File

@ -24,11 +24,11 @@ public class Command_qop extends TFM_Command
boolean matched_player = false;
String target_name = args[0].toLowerCase();
String target = args[0].toLowerCase();
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;

View File

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

View File

@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -15,7 +14,7 @@ public class Command_stfu extends TFM_Command
@Override
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;
}
@ -49,7 +48,7 @@ public class Command_stfu extends TFM_Command
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;
int count = 0;
for (Player mp : server.getOnlinePlayers())
@ -64,7 +63,27 @@ public class Command_stfu extends TFM_Command
TFM_Util.playerMsg(sender, "Unmuted " + count + " players.");
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;
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));
}
}
/*
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)
// {
// 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);
// }
// */
// }
// }
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)
{
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();

View File

@ -712,16 +712,20 @@ public class TFM_Util
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"))
{
return "the " + ChatColor.DARK_PURPLE + "server chief-developer" + ChatColor.AQUA + ".";
return "the " + ChatColor.DARK_PURPLE + "developer" + ChatColor.AQUA + ".";
}
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))
@ -734,7 +738,7 @@ public class TFM_Util
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)
@ -921,6 +925,21 @@ public class TFM_Util
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...
// public static final double LOOKAT_VIEW_HEIGHT = 1.65;
// 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 COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
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 YOU_ARE_OP = ChatColor.YELLOW + "You are now 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.
usage: /<command>
doom:
description: Owner command - For the worst of the worst, completely remove a player.
description: Owner command - For the bad Superadmins.
usage: /<command> <playername>
enchant:
description: Enchant items.
@ -165,7 +165,7 @@ commands:
usage: /<command>
stfu:
description: Superadmin Command - Mutes a player with brute force.
usage: /<command> [list | purge | <player>]
usage: /<command> [<player> | list | purge | all]
aliases: [mute]
stop:
description: Superadmin command - Kicks everyone and stops the server.
@ -194,11 +194,14 @@ commands:
waterplace:
description: Superadmin command - Enable/disable water placement.
usage: /<command> <on | off>
whitelist:
description: Superadmin command - Manage the whitelist.
usage: /<command> <on | off | list | count | add <player> | remove <player> | addall | purge>
wildcard:
description: Superadmin command - Run any command on all users, username placeholder = ?.
usage: /<command> [fluff] ? [fluff] ?
# wipeflatlands:
# description: Console Command - Wipe the flatlands map.
# description: Owner command - Wipe the flatlands map.
# usage: /<command>
ziptool:
description: Owner command - Zip and unzip files.