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
|
@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)
|
||||||
{
|
{
|
||||||
// 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.");
|
||||||
|
|
||||||
|
@ -13,69 +13,69 @@ public class Command_ro 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 < 1 || args.length > 3) {
|
if (args.length < 1 || args.length > 3)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radius = 50;
|
Material from_material = Material.matchMaterial(args[0]);
|
||||||
|
if (from_material == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
from_material = Material.getMaterial(Integer.parseInt(args[0]));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = Math.max(1, Math.min(50, Integer.parseInt(args[1])));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
TFM_Util.playerMsg(sender, "Invalid radius: " + args[1], ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Player target_player = null;
|
Player target_player = null;
|
||||||
Material target_block = Material.matchMaterial(args[0]);
|
if (args.length == 3)
|
||||||
|
|
||||||
if (target_block == null)
|
|
||||||
{
|
|
||||||
TFM_Util.playerMsg(sender, "Invalid block!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.length >= 2)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
radius = Integer.parseInt(args[1]);
|
target_player = getPlayer(args[2]);
|
||||||
}
|
|
||||||
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)
|
catch (CantFindPlayerException ex)
|
||||||
{
|
{
|
||||||
sender.sendMessage(ex.getMessage());
|
TFM_Util.playerMsg(sender, ex.getMessage(), ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (target_player == null)
|
||||||
if(target_player == null)
|
|
||||||
{
|
{
|
||||||
for(Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
boolean is_Op = p.isOp();
|
TFM_Util.replaceBlocks(p.getLocation(), from_material, Material.AIR, radius);
|
||||||
p.setOp(true);
|
|
||||||
server.dispatchCommand(p, "/removenear " + target_block.getId() + " " + radius);
|
|
||||||
p.setOp(is_Op);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boolean is_Op = target_player.isOp();
|
TFM_Util.replaceBlocks(target_player.getLocation(), from_material, Material.AIR, radius);
|
||||||
target_player.setOp(true);
|
|
||||||
server.dispatchCommand(target_player, "/removenear " + target_block.getId() + " " + radius);
|
|
||||||
target_player.setOp(is_Op);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -252,7 +252,7 @@ public class TFM_Util
|
|||||||
return TFM_SuperadminList.checkPartialSuperadminIP(user_ip);
|
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;
|
int removed = 0;
|
||||||
for (World world : Bukkit.getWorlds())
|
for (World world : Bukkit.getWorlds())
|
||||||
@ -263,7 +263,7 @@ public class TFM_Util
|
|||||||
|| ent instanceof Item
|
|| ent instanceof Item
|
||||||
|| ent instanceof ExperienceOrb
|
|| ent instanceof ExperienceOrb
|
||||||
|| (ent instanceof Explosive && wipe_explosives)
|
|| (ent instanceof Explosive && wipe_explosives)
|
||||||
|| (ent instanceof Minecart && wipe_carts))
|
|| (ent instanceof Vehicle && wipe_vehicles))
|
||||||
{
|
{
|
||||||
ent.remove();
|
ent.remove();
|
||||||
removed++;
|
removed++;
|
||||||
@ -959,6 +959,34 @@ public class TFM_Util
|
|||||||
|
|
||||||
return is_match;
|
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...
|
// 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_VIEW_HEIGHT = 1.65;
|
||||||
// public static final double LOOKAT_STEP_DISTANCE = 0.2;
|
// 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.
|
description: Owner Command - Broadcasts the given message with no extra formatting.
|
||||||
usage: /<command> <message>
|
usage: /<command> <message>
|
||||||
rd:
|
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>
|
usage: /<command> <carts>
|
||||||
ro:
|
ro:
|
||||||
description: Superadmin Command - Remove all blocks of a certain type in the radius of certain players.
|
description: Superadmin Command - Remove all blocks of a certain type in the radius of certain players.
|
||||||
|
Loading…
Reference in New Issue
Block a user