Added setlevel.

Added userlist purge command.
Added blaze-rod boomstick.
This commit is contained in:
Steven Lawson 2012-03-12 02:26:13 -04:00
parent ccd13369e5
commit edd2a19ec0
8 changed files with 122 additions and 26 deletions

5
appinfo.properties Normal file
View File

@ -0,0 +1,5 @@
#Sun, 11 Mar 2012 23:38:55 -0500
program.VERSION=2.5
program.BUILDNUM=59
program.BUILDDATE=03/11/2012 11\:38 PM

3
buildnumber.properties Normal file
View File

@ -0,0 +1,3 @@
#Build Number for ANT. Do not edit!
#Sun Mar 11 23:38:55 EDT 2012
build.number=60

View File

@ -6,6 +6,7 @@ import me.StevenLawson.TotalFreedomMod.TFM_UserList;
import me.StevenLawson.TotalFreedomMod.TFM_UserList.TFM_UserListEntry; import me.StevenLawson.TotalFreedomMod.TFM_UserList.TFM_UserListEntry;
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,13 +16,30 @@ public class Command_glist 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 != 2) if (args.length < 1)
{ {
return false; return false;
} }
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
{ {
if (args.length == 1)
{
if (args[0].equalsIgnoreCase("purge"))
{
TFM_UserList.getInstance(plugin).purge();
return true;
}
else
{
return false;
}
}
else if (args.length != 2)
{
return false;
}
String username; String username;
List<String> ip_addresses = new ArrayList<String>(); List<String> ip_addresses = new ArrayList<String>();
@ -30,7 +48,7 @@ public class Command_glist extends TFM_Command
Player p = getPlayer(args[1]); Player p = getPlayer(args[1]);
username = p.getName(); username = p.getName();
ip_addresses.add(p.getAddress().getAddress().getHostName()); ip_addresses.add(p.getAddress().getAddress().getHostAddress());
} }
catch (CantFindPlayerException ex) catch (CantFindPlayerException ex)
{ {
@ -47,8 +65,10 @@ public class Command_glist extends TFM_Command
} }
String mode = args[0].toLowerCase(); String mode = args[0].toLowerCase();
if (mode.equals("ban")) if (mode.equalsIgnoreCase("ban"))
{ {
TFM_Util.bcastMsg(sender.getName() + " - Banning " + username + " and IPs: " + TFM_Util.implodeStringList(",", ip_addresses), ChatColor.RED);
Player p = server.getPlayerExact(username); Player p = server.getPlayerExact(username);
if (p != null) if (p != null)
{ {
@ -67,8 +87,10 @@ public class Command_glist extends TFM_Command
server.banIP(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*"); server.banIP(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*");
} }
} }
else if (mode.equals("unban")) else if (mode.equalsIgnoreCase("unban"))
{ {
TFM_Util.bcastMsg(sender.getName() + " - Unbanning " + username + " and IPs: " + TFM_Util.implodeStringList(",", ip_addresses), ChatColor.RED);
server.getOfflinePlayer(username).setBanned(false); server.getOfflinePlayer(username).setBanned(false);
for (String ip_address : ip_addresses) for (String ip_address : ip_addresses)

View File

@ -4,10 +4,9 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor; 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.ExperienceOrb;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Command_addexp extends TFM_Command public class Command_setlevel 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)
@ -29,33 +28,30 @@ public class Command_addexp extends TFM_Command
return false; return false;
} }
int exp_amount; int new_level;
try try
{ {
exp_amount = Integer.parseInt(args[0]); new_level = Integer.parseInt(args[0]);
if (exp_amount < 0) if (new_level < 0)
{ {
sender.sendMessage(ChatColor.AQUA + "Invalid exp amount (MUST BE POSITIVE)."); new_level = 0;
return true;
} }
else if (exp_amount > 2000) else if (new_level > 50)
{ {
sender.sendMessage(ChatColor.AQUA + "Invalid exp amount (MAX = 2000)."); new_level = 50;
return true;
} }
} }
catch (NumberFormatException ex) catch (NumberFormatException ex)
{ {
sender.sendMessage(ChatColor.AQUA + "Invalid exp amount."); sender.sendMessage(ChatColor.AQUA + "Invalid level.");
return true; return true;
} }
ExperienceOrb exp_orb = sender_p.getWorld().spawn(sender_p.getLocation(), ExperienceOrb.class); sender_p.setLevel(new_level);
exp_orb.setExperience(exp_amount);
sender.sendMessage(ChatColor.AQUA + String.valueOf(exp_amount) + " exp added."); sender.sendMessage(ChatColor.AQUA + "You have been set to level " + Integer.toString(new_level));
return true; return true;
} }

View File

@ -7,12 +7,14 @@ import java.util.logging.Logger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.*; import me.StevenLawson.TotalFreedomMod.*;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -99,6 +101,37 @@ public class TFM_PlayerListener implements Listener
} }
break; break;
} }
case BLAZE_ROD:
{
if (TotalFreedomMod.allowExplosions && (player.getName().equals("Madgeek1450") || player.getName().equals("markbyron")))
{
Block target_block = null;
if (event.getAction().equals(Action.LEFT_CLICK_AIR))
{
target_block = player.getTargetBlock(null, 120);
}
else
{
target_block = event.getClickedBlock();
}
if (target_block != null)
{
player.getWorld().createExplosion(target_block.getLocation(), 4F, true);
player.getWorld().strikeLightning(target_block.getLocation());
}
else
{
player.sendMessage("Can't resolve target block.");
}
event.setCancelled(true);
return;
}
break;
}
} }
break; break;
} }

View File

@ -111,6 +111,18 @@ public class TFM_UserList
return _userlist.get(username.toLowerCase()); return _userlist.get(username.toLowerCase());
} }
public void purge()
{
_userlist.clear();
for (Player p : _plugin.getServer().getOnlinePlayers())
{
addUser(p);
}
exportList();
}
public class TFM_UserListEntry public class TFM_UserListEntry
{ {
private String _username; private String _username;

View File

@ -266,10 +266,10 @@ public class TFM_Util
Player p = (Player) user; Player p = (Player) user;
if (p != null) if (p != null)
{ {
InetSocketAddress ip_address_obj = p.getAddress(); InetSocketAddress address = p.getAddress();
if (ip_address_obj != null) if (address != null)
{ {
String user_ip = ip_address_obj.getAddress().toString().replaceAll("/", "").trim(); String user_ip = address.getAddress().getHostAddress();
if (user_ip != null && !user_ip.isEmpty()) if (user_ip != null && !user_ip.isEmpty())
{ {
if (TotalFreedomMod.superadmin_ips.contains(user_ip)) if (TotalFreedomMod.superadmin_ips.contains(user_ip))
@ -606,4 +606,29 @@ public class TFM_Util
flatlands.generator(new CleanroomChunkGenerator(genParams)); flatlands.generator(new CleanroomChunkGenerator(genParams));
Bukkit.getServer().createWorld(flatlands); Bukkit.getServer().createWorld(flatlands);
} }
// 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;
//
// public static Location getLookatLocation(Player player)
// {
// Location player_loc = player.getLocation();
//
// Vector player_pos = player_loc.toVector().add(new Vector(0.0, LOOKAT_VIEW_HEIGHT, 0.0));
// Vector player_dir = player_loc.getDirection().normalize();
//
// for (double offset = 0.0; offset <= 300.0; offset += LOOKAT_STEP_DISTANCE)
// {
// Location check_loc = player_pos.clone().add(player_dir.clone().multiply(offset)).toLocation(player.getWorld());
//
// if (!check_loc.getBlock().isEmpty())
// {
// return check_loc;
// }
// }
//
// return null;
// }
} }

View File

@ -4,9 +4,6 @@ version: 2.5
description: Plugin for the Total Freedom server. description: Plugin for the Total Freedom server.
author: StevenLawson / Madgeek1450 author: StevenLawson / Madgeek1450
commands: commands:
addexp:
description: Add levels to your survival level.
usage: /<command> [level]
cage: cage:
description: Superadmin command - Place a cage around someone. description: Superadmin command - Place a cage around someone.
usage: /<command> <partialname> [off | outermaterial] [water | lava] usage: /<command> <partialname> [off | outermaterial] [water | lava]
@ -60,7 +57,7 @@ commands:
usage: /<command> <fromname> <outcommand> usage: /<command> <fromname> <outcommand>
glist: glist:
description: Superadmin command - Ban/Unban any player, even those who are not logged in anymore. description: Superadmin command - Ban/Unban any player, even those who are not logged in anymore.
usage: /<command> <ban | unban> <username> usage: /<command> <purge | <ban | unban> <username>>
gtfo: gtfo:
description: Superadmin command - Makes someone GTFO (deop and ip ban by username). description: Superadmin command - Makes someone GTFO (deop and ip ban by username).
usage: /<command> <partialname> usage: /<command> <partialname>
@ -130,6 +127,9 @@ commands:
say: say:
description: Broadcasts the given message as the console, includes sender name. description: Broadcasts the given message as the console, includes sender name.
usage: /<command> <message> usage: /<command> <message>
setlevel:
description: Sets your expierence level.
usage: /<command> [level]
setspawnworld: setspawnworld:
description: Superadmin Command - Set world spawnpoint. description: Superadmin Command - Set world spawnpoint.
usage: /<command> usage: /<command>