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_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,13 +16,30 @@ public class Command_glist extends TFM_Command
@Override
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;
}
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;
List<String> ip_addresses = new ArrayList<String>();
@ -30,7 +48,7 @@ public class Command_glist extends TFM_Command
Player p = getPlayer(args[1]);
username = p.getName();
ip_addresses.add(p.getAddress().getAddress().getHostName());
ip_addresses.add(p.getAddress().getAddress().getHostAddress());
}
catch (CantFindPlayerException ex)
{
@ -47,8 +65,10 @@ public class Command_glist extends TFM_Command
}
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);
if (p != null)
{
@ -67,8 +87,10 @@ public class Command_glist extends TFM_Command
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);
for (String ip_address : ip_addresses)

View file

@ -4,10 +4,9 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.Player;
public class Command_addexp extends TFM_Command
public class Command_setlevel extends TFM_Command
{
@Override
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;
}
int exp_amount;
int new_level;
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).");
return true;
new_level = 0;
}
else if (exp_amount > 2000)
else if (new_level > 50)
{
sender.sendMessage(ChatColor.AQUA + "Invalid exp amount (MAX = 2000).");
return true;
new_level = 50;
}
}
catch (NumberFormatException ex)
{
sender.sendMessage(ChatColor.AQUA + "Invalid exp amount.");
sender.sendMessage(ChatColor.AQUA + "Invalid level.");
return true;
}
ExperienceOrb exp_orb = sender_p.getWorld().spawn(sender_p.getLocation(), ExperienceOrb.class);
exp_orb.setExperience(exp_amount);
sender_p.setLevel(new_level);
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;
}

View file

@ -7,12 +7,14 @@ import java.util.logging.Logger;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.*;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
@ -99,6 +101,37 @@ public class TFM_PlayerListener implements Listener
}
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;
}

View file

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

View file

@ -266,10 +266,10 @@ public class TFM_Util
Player p = (Player) user;
if (p != null)
{
InetSocketAddress ip_address_obj = p.getAddress();
if (ip_address_obj != null)
InetSocketAddress address = p.getAddress();
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 (TotalFreedomMod.superadmin_ips.contains(user_ip))
@ -606,4 +606,29 @@ public class TFM_Util
flatlands.generator(new CleanroomChunkGenerator(genParams));
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.
author: StevenLawson / Madgeek1450
commands:
addexp:
description: Add levels to your survival level.
usage: /<command> [level]
cage:
description: Superadmin command - Place a cage around someone.
usage: /<command> <partialname> [off | outermaterial] [water | lava]
@ -60,7 +57,7 @@ commands:
usage: /<command> <fromname> <outcommand>
glist:
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:
description: Superadmin command - Makes someone GTFO (deop and ip ban by username).
usage: /<command> <partialname>
@ -130,6 +127,9 @@ commands:
say:
description: Broadcasts the given message as the console, includes sender name.
usage: /<command> <message>
setlevel:
description: Sets your expierence level.
usage: /<command> [level]
setspawnworld:
description: Superadmin Command - Set world spawnpoint.
usage: /<command>