This commit is contained in:
Steven Lawson 2012-12-01 14:11:47 -05:00
commit 079fe2cb4e
21 changed files with 193 additions and 50 deletions

7
.gitignore vendored
View File

@ -1,11 +1,12 @@
# netbeans excludes (StevenLawson) # netbeans excludes - StevenLawson & JeromSar
/nbproject/private/ /nbproject/private/
/dist/ /dist/
/build/ /build/
appinfo.properties
buildnumber.properties buildnumber.properties
appinfo.properties
manifest.mf
# eclipse excludes (JeromSar) # eclipse excludes - JeromSar (old)
.project .project
.classpath .classpath
/bin/ /bin/

View File

@ -1,6 +1,6 @@
build.xml.data.CRC32=7bf70ec5 build.xml.data.CRC32=7bf70ec5
build.xml.script.CRC32=b1031e10 build.xml.script.CRC32=b1031e10
build.xml.stylesheet.CRC32=28e38971@1.44.1.45 build.xml.stylesheet.CRC32=28e38971@1.53.1.46
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=7bf70ec5 nbproject/build-impl.xml.data.CRC32=7bf70ec5

View File

@ -4,7 +4,7 @@ annotation.processing.processors.list=
annotation.processing.run.all.processors=true annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=TotalFreedomMod application.title=TotalFreedomMod
application.vendor=Michael application.vendor=Madgeek1450/DarthSalamon
build.classes.dir=${build.dir}/classes build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned: # This directory is removed when the project is cleaned:
@ -32,8 +32,8 @@ jar.archive.disabled=${jnlp.enabled}
jar.compress=false jar.compress=false
jar.index=${jnlp.enabled} jar.index=${jnlp.enabled}
javac.classpath=\ javac.classpath=\
\# Space-separated list of extra javac options:\
${libs.CraftBukkit.classpath} ${libs.CraftBukkit.classpath}
# Space-separated list of extra javac options
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
javac.deprecation=false javac.deprecation=false
javac.processorpath=\ javac.processorpath=\
@ -65,7 +65,7 @@ jnlp.signed=false
jnlp.signing= jnlp.signing=
jnlp.signing.alias= jnlp.signing.alias=
jnlp.signing.keystore= jnlp.signing.keystore=
main.class=totalfreedommod.TotalFreedomMod main.class=
manifest.file=manifest.mf manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false mkdist.disabled=false
@ -73,9 +73,9 @@ platform.active=default_platform
run.classpath=\ run.classpath=\
${javac.classpath}:\ ${javac.classpath}:\
${build.classes.dir} ${build.classes.dir}
# Space-separated list of JVM arguments used when running the project # Space-separated list of JVM arguments used when running the project.
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# or test-sys-prop.name=value to set system properties for unit tests): # To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs= run.jvmargs=
run.test.classpath=\ run.test.classpath=\
${javac.test.classpath}:\ ${javac.test.classpath}:\

View File

@ -40,6 +40,7 @@ public class Command_cage extends TFM_Command
{ {
if (TFM_Util.isStopCommand(args[1])) if (TFM_Util.isStopCommand(args[1]))
{ {
TFM_Util.adminAction(sender.getName(), "Uncaging " + p.getName(), true);
playerdata.setCaged(false); playerdata.setCaged(false);
playerdata.regenerateHistory(); playerdata.regenerateHistory();
playerdata.clearHistory(); playerdata.clearHistory();
@ -50,6 +51,15 @@ public class Command_cage extends TFM_Command
{ {
cage_material_outer = Material.matchMaterial(args[1]); cage_material_outer = Material.matchMaterial(args[1]);
if (cage_material_outer == null) if (cage_material_outer == null)
{
TFM_Util.adminAction(sender.getName(), "Uncaging " + p.getName(), true);
playerdata.setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
sender.sendMessage(ChatColor.GREEN + p.getName() + " uncaged.");
return true;
}
else
{ {
cage_material_outer = Material.GLASS; cage_material_outer = Material.GLASS;
} }
@ -75,11 +85,8 @@ public class Command_cage extends TFM_Command
TFM_Util.buildHistory(target_pos, 2, playerdata); TFM_Util.buildHistory(target_pos, 2, playerdata);
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER)); TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER)); TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER));
p.setGameMode(GameMode.SURVIVAL); p.setGameMode(GameMode.SURVIVAL);
TFM_Util.adminAction(sender.getName(), "Caging " + p.getName(), true);
TFM_Util.bcastMsg(sender.getName() + " caged " + p.getName() + "!", ChatColor.YELLOW);
return true; return true;
} }
} }

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
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;
@ -24,6 +25,8 @@ public class Command_explosives extends TFM_Command
} }
catch (NumberFormatException nfex) catch (NumberFormatException nfex)
{ {
TFM_Util.playerMsg(sender, nfex.getMessage());
return true;
} }
} }

View File

@ -40,7 +40,9 @@ public class Command_gadmin extends TFM_Command
{ {
if (mode.equals("kick")) if (mode.equals("kick"))
{ {
TFM_Util.adminAction(sender.getName(), "Kicking " + p.getName(), true);
p.kickPlayer("Kicked by Administrator"); p.kickPlayer("Kicked by Administrator");
} }
else if (mode.equals("nameban")) else if (mode.equals("nameban"))
{ {

View File

@ -34,9 +34,9 @@ public class Command_list extends TFM_Command
{ {
if (TFM_SuperadminList.isUserSuperadmin(p)) if (TFM_SuperadminList.isUserSuperadmin(p))
{ {
if (p.isOp()) if(TFM_SuperadminList.isSeniorAdmin(p))
{ {
prefix = (ChatColor.GOLD + "[SA+OP]"); prefix = (ChatColor.LIGHT_PURPLE + "[SrA]");
} }
else else
{ {

View File

@ -2,6 +2,7 @@ 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 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;
@ -48,8 +49,10 @@ public class Command_orbit extends TFM_Command
{ {
strength = Math.max(1.0, Math.min(150.0, Double.parseDouble(args[1]))); strength = Math.max(1.0, Math.min(150.0, Double.parseDouble(args[1])));
} }
catch (NumberFormatException nfex) catch (NumberFormatException ex)
{ {
sender.sendMessage(ex.getMessage());
return true;
} }
} }
@ -57,8 +60,7 @@ public class Command_orbit extends TFM_Command
playerdata.startOrbiting(strength); playerdata.startOrbiting(strength);
p.setVelocity(new Vector(0, strength, 0)); p.setVelocity(new Vector(0, strength, 0));
TFM_Util.adminAction(sender.getName(), "Orbiting " + p.getName(), true);
sender.sendMessage(ChatColor.GRAY + "Orbiting " + p.getName());
return true; return true;
} }

View File

@ -45,10 +45,7 @@ public class Command_permban extends TFM_Command
else else
{ {
TFM_Util.playerMsg(sender, TotalFreedomMod.permbanned_players.size() + " permanently banned players:"); TFM_Util.playerMsg(sender, TotalFreedomMod.permbanned_players.size() + " permanently banned players:");
for (String player_name : TotalFreedomMod.permbanned_players) TFM_Util.playerMsg(sender, ChatColor.GRAY + TFM_Util.implodeStringList(", ", TotalFreedomMod.permbanned_players));
{
TFM_Util.playerMsg(sender, "- " + player_name);
}
} }
if (TotalFreedomMod.permbanned_ips.isEmpty()) if (TotalFreedomMod.permbanned_ips.isEmpty())
@ -58,10 +55,7 @@ public class Command_permban extends TFM_Command
else else
{ {
TFM_Util.playerMsg(sender, TotalFreedomMod.permbanned_ips.size() + " permanently banned IPs:"); TFM_Util.playerMsg(sender, TotalFreedomMod.permbanned_ips.size() + " permanently banned IPs:");
for (String ip_address : TotalFreedomMod.permbanned_ips) TFM_Util.playerMsg(sender, ChatColor.GRAY + TFM_Util.implodeStringList(", ", TotalFreedomMod.permbanned_ips));
{
TFM_Util.playerMsg(sender, "- " + ip_address);
}
} }
} }
} }

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
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;
@ -16,7 +17,6 @@ public class Command_qdeop extends TFM_Command
{ {
return false; return false;
} }
boolean silent = false; boolean silent = false;
if (args.length == 2) if (args.length == 2)
{ {

View File

@ -28,7 +28,7 @@ public class Command_rank extends TFM_Command
if (args.length == 0) if (args.length == 0)
{ {
TFM_Util.playerMsg(sender, sender.getName() + " is " + TFM_Util.getRank(sender), ChatColor.AQUA); TFM_Util.bcastMsg(sender.getName() + " is " + TFM_Util.getRank(sender), ChatColor.AQUA);
return true; return true;
} }

View File

@ -13,6 +13,7 @@ public class Command_rd extends TFM_Command
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)
{ {
// This terminology is wrong, this doesn't remove *all* entities, by far. - Madgeek // This terminology is wrong, this doesn't remove *all* entities, by far. - Madgeek
// Back when I was just a player, I didn't even know what "entity" meant... :P - Darth
TFM_Util.adminAction(sender.getName(), "Removing all server entities.", false); 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.");

View File

@ -0,0 +1,81 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.BOTH, block_web_console = false, ignore_permissions = false)
public class Command_ro 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 > 3) {
return false;
}
int radius = 50;
Player target_player = null;
Material target_block = Material.matchMaterial(args[0]);
if (target_block == null)
{
TFM_Util.playerMsg(sender, "Invalid block!");
return true;
}
if(args.length >= 2)
{
try
{
radius = Integer.parseInt(args[1]);
}
catch(NumberFormatException nfex)
{
TFM_Util.playerMsg(sender, nfex.getMessage());
return true;
}
if(radius > 3000)
{
TFM_Util.playerMsg(sender, "What the hell are you trying to do, you stupid idiot!", ChatColor.RED);
return true;
}
}
if(args.length == 3)
{
try
{
target_player = getPlayer(args[2]);
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
}
if(target_player == null)
{
for(Player p : server.getOnlinePlayers())
{
boolean is_Op = p.isOp();
p.setOp(true);
server.dispatchCommand(p, "/removenear " + target_block.getId() + " " + radius);
p.setOp(is_Op);
}
}
else
{
boolean is_Op = target_player.isOp();
target_player.setOp(true);
server.dispatchCommand(target_player, "/removenear " + target_block.getId() + " " + radius);
target_player.setOp(is_Op);
}
return true;
}
}

View File

@ -12,7 +12,8 @@ public class Command_stop 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)
{ {
TFM_Util.bcastMsg("Server is going offline.", ChatColor.GRAY);
TFM_Util.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {

View File

@ -108,6 +108,13 @@ public class TFM_Command
List<Player> matches = server.matchPlayer(partialname); List<Player> matches = server.matchPlayer(partialname);
if (matches.isEmpty()) if (matches.isEmpty())
{ {
for(Player p : server.getOnlinePlayers())
{
if(p.getDisplayName().toLowerCase().indexOf(partialname) != -1)
{
return p;
}
}
throw new CantFindPlayerException(partialname); throw new CantFindPlayerException(partialname);
} }
else else

View File

@ -101,7 +101,6 @@ public class TFM_PlayerListener implements Listener
} }
event.setCancelled(true); event.setCancelled(true);
return;
} }
break; break;
} }
@ -109,7 +108,7 @@ public class TFM_PlayerListener implements Listener
{ {
if (TotalFreedomMod.allowExplosions && TFM_SuperadminList.isSeniorAdmin(player)) if (TotalFreedomMod.allowExplosions && TFM_SuperadminList.isSeniorAdmin(player))
{ {
Block target_block = null; Block target_block;
if (event.getAction().equals(Action.LEFT_CLICK_AIR)) if (event.getAction().equals(Action.LEFT_CLICK_AIR))
{ {
@ -131,7 +130,6 @@ public class TFM_PlayerListener implements Listener
} }
event.setCancelled(true); event.setCancelled(true);
return;
} }
break; break;
@ -211,7 +209,7 @@ public class TFM_PlayerListener implements Listener
{ {
Location target_pos = p.getLocation().add(0, 1, 0); Location target_pos = p.getLocation().add(0, 1, 0);
boolean out_of_cage = false; boolean out_of_cage;
if (!target_pos.getWorld().equals(playerdata.getCagePos().getWorld())) if (!target_pos.getWorld().equals(playerdata.getCagePos().getWorld()))
{ {
out_of_cage = true; out_of_cage = true;
@ -290,10 +288,22 @@ public class TFM_PlayerListener implements Listener
try try
{ {
final Player p = event.getPlayer(); final Player p = event.getPlayer();
String message = event.getMessage().trim();
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.incrementMsgCount(); playerdata.incrementMsgCount();
// check for message repeat
if(playerdata.getLastMessage().equalsIgnoreCase(message))
{
TFM_Util.playerMsg(p, "Please do not repeat messages.");
event.setCancelled(true);
playerdata.setLastMessage(message);
return;
}
playerdata.setLastMessage(message);
// check for spam // check for spam
if (playerdata.getMsgCount() > 10) if (playerdata.getMsgCount() > 10)
{ {
@ -321,8 +331,6 @@ public class TFM_PlayerListener implements Listener
} }
} }
String message = event.getMessage().trim();
// strip color from messages // strip color from messages
message = ChatColor.stripColor(message); message = ChatColor.stripColor(message);
@ -333,21 +341,33 @@ public class TFM_PlayerListener implements Listener
TFM_Util.playerMsg(p, "Message was shortened because it was too long to send."); TFM_Util.playerMsg(p, "Message was shortened because it was too long to send.");
} }
// check for caps
// check for caps and exclamation marks
if (message.length() >= 6) if (message.length() >= 6)
{ {
int caps = 0; int caps = 0;
int excl = 0;
for (char c : message.toCharArray()) for (char c : message.toCharArray())
{ {
if (Character.isUpperCase(c)) if (Character.isUpperCase(c))
{ {
caps++; caps++;
} }
if(c == '!')
{
excl++;
} }
if (((float) caps / (float) message.length()) > 0.75) //Compute a ratio so that longer sentences can have more caps. }
if (caps > 6 || caps > 3 && ((float) caps / (float) message.length()) > 0.55)
{ {
message = message.toLowerCase(); message = message.toLowerCase();
} }
if(excl++ > 3)
{
message = message.replaceAll("!", "") + '!';
}
} }
// finally, set message // finally, set message
@ -472,6 +492,18 @@ public class TFM_PlayerListener implements Listener
{ {
block_command = true; block_command = true;
} }
else if (Pattern.compile("^/clear").matcher(command).find())
{
block_command = true;
}
else if (!TFM_SuperadminList.isUserSuperadmin(p) && Pattern.compile("^/socialspy").matcher(command).find())
{
block_command = true;
}
else if (!TFM_SuperadminList.isUserSuperadmin(p) && Pattern.compile("^/packet").matcher(command).find())
{
block_command = true;
}
} }
if (block_command) if (block_command)
@ -481,7 +513,7 @@ public class TFM_PlayerListener implements Listener
return; return;
} }
if (playerdata.isMuted()) // block muted commands
{ {
if (!TFM_SuperadminList.isUserSuperadmin(p)) if (!TFM_SuperadminList.isUserSuperadmin(p))
{ {

View File

@ -15,6 +15,8 @@ import org.bukkit.World;
public class TFM_ProtectedArea implements Serializable public class TFM_ProtectedArea implements Serializable
{ {
private static final long serialVersionUID = -3270338811000937254L;
public static final double MAX_RADIUS = 50.0D; public static final double MAX_RADIUS = 50.0D;
private static Map<String, TFM_ProtectedArea> protectedAreas = new HashMap<String, TFM_ProtectedArea>(); private static Map<String, TFM_ProtectedArea> protectedAreas = new HashMap<String, TFM_ProtectedArea>();
private final SerializableLocation center_location; private final SerializableLocation center_location;

View File

@ -45,6 +45,7 @@ public class TFM_UserInfo
private boolean mp44_armed = false; private boolean mp44_armed = false;
private boolean mp44_firing = false; private boolean mp44_firing = false;
private int lockup_schedule_id = -1; private int lockup_schedule_id = -1;
private String last_message = "";
public TFM_UserInfo(Player player) public TFM_UserInfo(Player player)
{ {
@ -406,4 +407,14 @@ public class TFM_UserInfo
{ {
this.lockup_schedule_id = lockup_schedule_id; this.lockup_schedule_id = lockup_schedule_id;
} }
public void setLastMessage(String last_message)
{
this.last_message = last_message;
}
public String getLastMessage()
{
return this.last_message;
}
} }

View File

@ -68,19 +68,16 @@ public class TFM_Util
TFM_Util.bcastMsg(message, null); TFM_Util.bcastMsg(message, null);
} }
//JeromSar
public static void playerMsg(CommandSender sender, String message, ChatColor color) public static void playerMsg(CommandSender sender, String message, ChatColor color)
{ {
sender.sendMessage(color + message); sender.sendMessage(color + message);
} }
//JeromSar
public static void playerMsg(CommandSender sender, String message) public static void playerMsg(CommandSender sender, String message)
{ {
TFM_Util.playerMsg(sender, message, ChatColor.GRAY); TFM_Util.playerMsg(sender, message, ChatColor.GRAY);
} }
//JeromSar
public static void adminAction(String adminName, String action, boolean isRed) public static void adminAction(String adminName, String action, boolean isRed)
{ {
TFM_Util.bcastMsg(adminName + " - " + action, (isRed ? ChatColor.RED : ChatColor.AQUA)); TFM_Util.bcastMsg(adminName + " - " + action, (isRed ? ChatColor.RED : ChatColor.AQUA));
@ -545,7 +542,6 @@ public class TFM_Util
return TFM_SuperadminList.isSuperadminImpostor(user); return TFM_SuperadminList.isSuperadminImpostor(user);
} }
//JeromSar
public static String getRank(CommandSender sender) public static String getRank(CommandSender sender)
{ {
if (TFM_SuperadminList.isSuperadminImpostor(sender)) if (TFM_SuperadminList.isSuperadminImpostor(sender))
@ -571,11 +567,11 @@ public class TFM_Util
if (admin_entry.isSeniorAdmin()) if (admin_entry.isSeniorAdmin())
{ {
return "a " + ChatColor.GOLD + "senior admin" + ChatColor.AQUA + "."; return "a " + ChatColor.LIGHT_PURPLE + "Senior Admin" + ChatColor.AQUA + ".";
} }
else else
{ {
return "an " + ChatColor.RED + "admin" + ChatColor.AQUA + "."; return "a " + ChatColor.GOLD + "Super Admin" + ChatColor.AQUA + ".";
} }
} }
} }

View File

@ -162,8 +162,11 @@ commands:
description: Owner Command - Broadcasts the given message with no extra formatting. description: Owner Command - Broadcasts the given message with no extra formatting.
usage: /<command> <message> usage: /<command> <message>
rd: rd:
description: Remove all projectiles, dropped items, experience orbs, primed explosives, and minecarts. Minecarts are optional, based on if "carts" is included after the command. description: Superadmin command - Remove all projectiles, dropped items, experience orbs, primed explosives, and minecarts. Minecarts are optional, based on if "carts" is included after the command.
usage: /<command> <carts> usage: /<command> <carts>
ro:
description: Superadmin Command - Remove all blocks of a certain type in the radius of certain players.
usage: /<command> <block> [radius (default=50)] [player]
saconfig: saconfig:
description: Owner command - Manage superadmins. description: Owner command - Manage superadmins.
usage: /<command> <list | clean | <add|delete> <username>> usage: /<command> <list | clean | <add|delete> <username>>