mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Changes to /rd and /ro.
Eliminated use of WorldEdit and op, deop kludge :P
This commit is contained in:
parent
dbed25d79f
commit
ff7a77cbfd
@ -12,8 +12,6 @@ public class Command_rd extends TFM_Command
|
||||
@Override
|
||||
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
|
||||
// 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);
|
||||
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeEntities(true, true)) + " enties removed.");
|
||||
|
||||
|
@ -13,38 +13,44 @@ 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) {
|
||||
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)
|
||||
Material from_material = Material.matchMaterial(args[0]);
|
||||
if (from_material == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
from_material = Material.getMaterial(Integer.parseInt(args[0]));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "Invalid block!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (from_material == null)
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "Invalid block: " + args[0], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int radius = 25;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
radius = Integer.parseInt(args[1]);
|
||||
radius = Math.max(1, Math.min(50, Integer.parseInt(args[1])));
|
||||
}
|
||||
catch(NumberFormatException nfex)
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
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);
|
||||
TFM_Util.playerMsg(sender, "Invalid radius: " + args[1], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Player target_player = null;
|
||||
if (args.length == 3)
|
||||
{
|
||||
try
|
||||
@ -53,29 +59,23 @@ public class Command_ro extends TFM_Command
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
TFM_Util.playerMsg(sender, ex.getMessage(), ChatColor.RED);
|
||||
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);
|
||||
TFM_Util.replaceBlocks(p.getLocation(), from_material, Material.AIR, radius);
|
||||
}
|
||||
}
|
||||
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);
|
||||
TFM_Util.replaceBlocks(target_player.getLocation(), from_material, Material.AIR, radius);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -252,7 +252,7 @@ public class TFM_Util
|
||||
return TFM_SuperadminList.checkPartialSuperadminIP(user_ip);
|
||||
}
|
||||
|
||||
public static int wipeEntities(boolean wipe_explosives, boolean wipe_carts)
|
||||
public static int wipeEntities(boolean wipe_explosives, boolean wipe_vehicles)
|
||||
{
|
||||
int removed = 0;
|
||||
for (World world : Bukkit.getWorlds())
|
||||
@ -263,7 +263,7 @@ public class TFM_Util
|
||||
|| ent instanceof Item
|
||||
|| ent instanceof ExperienceOrb
|
||||
|| (ent instanceof Explosive && wipe_explosives)
|
||||
|| (ent instanceof Minecart && wipe_carts))
|
||||
|| (ent instanceof Vehicle && wipe_vehicles))
|
||||
{
|
||||
ent.remove();
|
||||
removed++;
|
||||
@ -959,6 +959,34 @@ public class TFM_Util
|
||||
|
||||
return is_match;
|
||||
}
|
||||
|
||||
public static int replaceBlocks(Location center_location, Material from_material, Material to_material, int radius)
|
||||
{
|
||||
int affected = 0;
|
||||
|
||||
Block center_block = center_location.getBlock();
|
||||
for (int x_offset = -radius; x_offset <= radius; x_offset++)
|
||||
{
|
||||
for (int y_offset = -radius; y_offset <= radius; y_offset++)
|
||||
{
|
||||
for (int z_offset = -radius; z_offset <= radius; z_offset++)
|
||||
{
|
||||
Block test_block = center_block.getRelative(x_offset, y_offset, z_offset);
|
||||
|
||||
if (test_block.getType().equals(from_material))
|
||||
{
|
||||
if (test_block.getLocation().distanceSquared(center_location) < (radius * radius))
|
||||
{
|
||||
test_block.setType(to_material);
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
}
|
||||
// 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;
|
||||
|
@ -162,7 +162,7 @@ commands:
|
||||
description: Owner Command - Broadcasts the given message with no extra formatting.
|
||||
usage: /<command> <message>
|
||||
rd:
|
||||
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.
|
||||
description: Superadmin command - Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.
|
||||
usage: /<command> <carts>
|
||||
ro:
|
||||
description: Superadmin Command - Remove all blocks of a certain type in the radius of certain players.
|
||||
|
Loading…
Reference in New Issue
Block a user