Merge branch 'master' of github.com:StevenLawson/TotalFreedomMod

Conflicts:
	src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java
	src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java
This commit is contained in:
Steven Lawson 2012-09-17 18:36:57 -04:00
commit 49b61f4f55
12 changed files with 432 additions and 60 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

@ -0,0 +1,123 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Arrays;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
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(!(senderIsConsole && players.contains(sender.getName().toLowerCase())))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
if(args.length != 1)
{
return false;
}
final Player p;
try
{
p = getPlayer(args[0]);
}
catch(CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + p.getName(), true);
TFM_Util.bcastMsg(p.getName() + " will be completely obliviated!", ChatColor.RED);
final String IP = p.getAddress().getAddress().getHostAddress().trim();
// remove from superadmin
if(TFM_Util.isUserSuperadmin(p))
{
server.dispatchCommand(sender, "saconfig delete " + p.getName());
}
// remove from whitelist
p.setWhitelisted(false);
// deop
p.setOp(false);
// ban IP
Bukkit.banIP(IP);
// ban name
p.setBanned(true);
// set gamemode to survival
p.setGameMode(GameMode.SURVIVAL);
// clear inventory
p.closeInventory();
p.getInventory().clear();
// ignite player
p.setFireTicks(10000);
// generate explosion
p.getWorld().createExplosion(p.getLocation(), 4F);
server.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable()
{
@Override
public void run() {
// strike lightning
p.getWorld().strikeLightning(p.getLocation());
// kill (if not done already)
p.setHealth(0);
}
}, 40L); // 2 seconds
server.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable()
{
@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;
}
}

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

@ -1,6 +1,5 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Arrays;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
@ -13,27 +12,14 @@ public class Command_rd extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || sender.isOp())
if (!(senderIsConsole || TFM_Util.isUserSuperadmin(sender)))
{
if (args.length == 1)
{
if (Arrays.asList("minecart", "minecarts", "cart", "carts").contains(args[0].toLowerCase()))
{
sender.sendMessage(ChatColor.GRAY + "Removing all projectiles, dropped items, exp. orbs, primed explosives, and minecarts.");
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeEntities(true, true)) + " enties removed.");
}
}
else
{
sender.sendMessage(ChatColor.GRAY + "Removing all projectiles, dropped items, exp. orbs and primed explosives.");
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeEntities(true)) + " enties removed.");
}
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
TFM_Util.adminAction(sender.getName(), "Removing all server entities", false);
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeEntities(true, true)) + " enties removed.");
return 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,194 @@
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;
}
// on
if(args[0].equalsIgnoreCase("on"))
{
TFM_Util.adminAction(sender.getName(), "Turning the whitelist on", false);
server.setWhitelist(true);
return true;
}
// off
if(args[0].equalsIgnoreCase("off"))
{
TFM_Util.adminAction(sender.getName(), "Turning the whitelist off", false);
server.setWhitelist(false);
return true;
}
// add
if(args[0].equalsIgnoreCase("add"))
{
if(args.length < 2)
{
return false;
}
OfflinePlayer p;
try
{
p = getPlayer(args[1]);
}
catch(CantFindPlayerException ex)
{
if(!senderIsConsole)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(ChatColor.YELLOW + "You don't have permissions to whitelist offline players");
return true;
}
else
{
p = server.getOfflinePlayer(args[0]);
}
}
TFM_Util.adminAction(sender.getName(), "Adding " + p.getName() + " to the whitelist", false);
p.setWhitelisted(true);
return true;
}
// remove
if(args[0].equalsIgnoreCase("remove"))
{
if(args.length < 2)
{
return false;
}
OfflinePlayer p;
try
{
p = getPlayer(args[1]);
}
catch(CantFindPlayerException ex)
{
p = server.getOfflinePlayer(args[0]);
}
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.");
return true;
}
// all commands past this line are console/telnet only
if(!senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
//purge
if(args[0].equalsIgnoreCase("purge"))
{
TFM_Util.adminAction(sender.getName(), "Removing all players from the whitelist", true);
int counter = 0;
for(OfflinePlayer p : server.getWhitelistedPlayers())
{
p.setWhitelisted(false);
counter++;
}
TFM_Util.playerMsg(sender, "Removed " + counter + " players from the whitelist");
return true;
}
// none of the commands were executed
return false;
}
}

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

@ -24,13 +24,16 @@ commands:
usage: /<command> [partialname]
csay:
description: Telnet command - Send a chat message with chat formatting over telnet.
usage: /<command> [partialname]
usage: /<command> <message...>
deop:
description: Superadmin command - Deop a player
usage: /<command> <playername>
deopall:
description: Superadmin command - Deop everyone on the server.
usage: /<command>
doom:
description: Owner command - For the bad Superadmins.
usage: /<command> <playername>
enchant:
description: Enchant items.
usage: /<command> <list | addall | reset | add <name> | remove <name>>
@ -162,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.
@ -191,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.