mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Merge branch 'master' into nanohttpd
This commit is contained in:
commit
3e5e11197f
@ -1,5 +1,5 @@
|
||||
#Mon, 26 Aug 2013 17:47:26 +0200
|
||||
#Tue, 27 Aug 2013 12:35:14 +0200
|
||||
|
||||
program.VERSION=3.1
|
||||
program.BUILDNUM=507
|
||||
program.BUILDDATE=08/26/2013 05\:47 PM
|
||||
program.BUILDNUM=514
|
||||
program.BUILDDATE=08/27/2013 12\:35 PM
|
||||
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Mon Aug 26 17:47:26 CEST 2013
|
||||
build.number=508
|
||||
#Tue Aug 27 12:35:14 CEST 2013
|
||||
build.number=515
|
||||
|
@ -72,7 +72,7 @@ public class TFM_BlockListener implements Listener
|
||||
Long lastRan = TFM_Heartbeat.getLastRan();
|
||||
if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
|
||||
{
|
||||
//TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
|
||||
// TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -101,12 +101,6 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onRollbackBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
TFM_RollbackManager.blockBreak(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
@ -252,11 +246,23 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onRollbackBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(event.getPlayer()))
|
||||
{
|
||||
TFM_RollbackManager.blockBreak(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onRollbackBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(event.getPlayer()))
|
||||
{
|
||||
TFM_RollbackManager.blockPlace(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockFromTo(BlockFromToEvent event)
|
||||
|
@ -37,7 +37,8 @@ public class TFM_PlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
switch (event.getAction())
|
||||
{
|
||||
@ -48,37 +49,46 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
case WATER_BUCKET:
|
||||
{
|
||||
if (!TFM_ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
if (TFM_ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LAVA_BUCKET:
|
||||
{
|
||||
if (!TFM_ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
if (TFM_ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EXPLOSIVE_MINECART:
|
||||
{
|
||||
if (!TFM_ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||
if (TFM_ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LEFT_CLICK_AIR:
|
||||
case LEFT_CLICK_BLOCK:
|
||||
{
|
||||
@ -102,11 +112,10 @@ public class TFM_PlayerListener implements Listener
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_Util.playerMsg(player, "Block edits at (" + ChatColor.WHITE + "X" + location.getBlockX() + ", Y" + location.getBlockY() + ", Z" + location.getBlockZ() + ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE);
|
||||
TFM_Util.playerMsg(player, "Block edits at (" + ChatColor.WHITE + "x" + location.getBlockX() + ", y" + location.getBlockY() + ", z" + location.getBlockZ() + ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE);
|
||||
for (RollbackEntry entry : entries)
|
||||
{
|
||||
String material = (entry.getType() == EntryType.BLOCK_BREAK ? String.valueOf(entry.getFromMaterial()) : entry.getToMaterial() + (entry.getData() != 0 ? ":" + String.valueOf(entry.getData()) : ""));
|
||||
TFM_Util.playerMsg(player, " - " + ChatColor.BLUE + entry.getAuthor() + " " + entry.getType() + " " + material);
|
||||
TFM_Util.playerMsg(player, " - " + ChatColor.BLUE + entry.getAuthor() + " " + entry.getType() + " " + StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.getData() == 0 ? "" : ":" + entry.getData()));
|
||||
}
|
||||
|
||||
break;
|
||||
@ -114,9 +123,11 @@ public class TFM_PlayerListener implements Listener
|
||||
|
||||
case BONE:
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
if (playerdata.mobThrowerEnabled())
|
||||
if (!playerdata.mobThrowerEnabled())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Location player_pos = player.getLocation();
|
||||
Vector direction = player_pos.getDirection().normalize();
|
||||
|
||||
@ -125,15 +136,18 @@ public class TFM_PlayerListener implements Listener
|
||||
playerdata.enqueueMob(rezzed_mob);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SULPHUR:
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
if (playerdata.isMP44Armed())
|
||||
if (!playerdata.isMP44Armed())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (playerdata.toggleMP44Firing())
|
||||
{
|
||||
playerdata.startArrowShooter(TotalFreedomMod.plugin);
|
||||
@ -142,18 +156,22 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
playerdata.stopArrowShooter();
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BLAZE_ROD:
|
||||
{
|
||||
if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
if (TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
Block targetBlock;
|
||||
|
||||
if (event.getAction().equals(Action.LEFT_CLICK_AIR))
|
||||
@ -165,53 +183,55 @@ public class TFM_PlayerListener implements Listener
|
||||
targetBlock = event.getClickedBlock();
|
||||
}
|
||||
|
||||
if (targetBlock != null)
|
||||
{
|
||||
player.getWorld().createExplosion(targetBlock.getLocation(), 4F, true);
|
||||
player.getWorld().strikeLightning(targetBlock.getLocation());
|
||||
}
|
||||
else
|
||||
if (targetBlock == null)
|
||||
{
|
||||
player.sendMessage("Can't resolve target block.");
|
||||
break;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
player.getWorld().createExplosion(targetBlock.getLocation(), 4F, true);
|
||||
player.getWorld().strikeLightning(targetBlock.getLocation());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CARROT:
|
||||
{
|
||||
if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
if (TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||
{
|
||||
Location player_location = player.getLocation().clone();
|
||||
break;
|
||||
}
|
||||
|
||||
Vector player_pos = player_location.toVector().add(new Vector(0.0, 1.65, 0.0));
|
||||
Vector player_dir = player_location.getDirection().normalize();
|
||||
if (!TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Location location = player.getLocation().clone();
|
||||
|
||||
Vector playerPostion = location.toVector().add(new Vector(0.0, 1.65, 0.0));
|
||||
Vector playerDirection = location.getDirection().normalize();
|
||||
|
||||
double distance = 150.0;
|
||||
Block targetBlock = player.getTargetBlock(null, Math.round((float) distance));
|
||||
if (targetBlock != null)
|
||||
{
|
||||
distance = player_location.distance(targetBlock.getLocation());
|
||||
distance = location.distance(targetBlock.getLocation());
|
||||
}
|
||||
|
||||
final List<Block> affected = new ArrayList<Block>();
|
||||
|
||||
Block last_block = null;
|
||||
Block lastBlock = null;
|
||||
for (double offset = 0.0; offset <= distance; offset += (distance / 25.0))
|
||||
{
|
||||
Block test_block = player_pos.clone().add(player_dir.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
|
||||
Block block = playerPostion.clone().add(playerDirection.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
|
||||
|
||||
if (!test_block.equals(last_block))
|
||||
if (!block.equals(lastBlock))
|
||||
{
|
||||
if (test_block.isEmpty())
|
||||
if (block.isEmpty())
|
||||
{
|
||||
affected.add(test_block);
|
||||
test_block.setType(Material.TNT);
|
||||
affected.add(block);
|
||||
block.setType(Material.TNT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -219,7 +239,7 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
last_block = test_block;
|
||||
lastBlock = block;
|
||||
}
|
||||
|
||||
new BukkitRunnable()
|
||||
@ -227,18 +247,16 @@ public class TFM_PlayerListener implements Listener
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (Block tnt_block : affected)
|
||||
for (Block tntBlock : affected)
|
||||
{
|
||||
TNTPrimed tnt_primed = tnt_block.getWorld().spawn(tnt_block.getLocation(), TNTPrimed.class);
|
||||
tnt_primed.setFuseTicks(5);
|
||||
tnt_block.setType(Material.AIR);
|
||||
TNTPrimed tnt = tntBlock.getWorld().spawn(tntBlock.getLocation(), TNTPrimed.class);
|
||||
tnt.setFuseTicks(5);
|
||||
tntBlock.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 30L);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -280,52 +298,52 @@ public class TFM_PlayerListener implements Listener
|
||||
|
||||
for (Entry<Player, Double> fuckoff : TotalFreedomMod.fuckoffEnabledFor.entrySet())
|
||||
{
|
||||
Player fuckoff_player = fuckoff.getKey();
|
||||
Player fuckoffPlayer = fuckoff.getKey();
|
||||
|
||||
if (fuckoff_player.equals(player) || !fuckoff_player.isOnline())
|
||||
if (fuckoffPlayer.equals(player) || !fuckoffPlayer.isOnline())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double fuckoff_range = fuckoff.getValue().doubleValue();
|
||||
double fuckoffRange = fuckoff.getValue().doubleValue();
|
||||
|
||||
Location mover_pos = player.getLocation();
|
||||
Location fuckoff_pos = fuckoff_player.getLocation();
|
||||
Location playerLocation = player.getLocation();
|
||||
Location fuckoffLocation = fuckoffPlayer.getLocation();
|
||||
|
||||
double distanceSquared;
|
||||
try
|
||||
{
|
||||
distanceSquared = mover_pos.distanceSquared(fuckoff_pos);
|
||||
distanceSquared = playerLocation.distanceSquared(fuckoffLocation);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (distanceSquared < (fuckoff_range * fuckoff_range))
|
||||
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
||||
{
|
||||
event.setTo(fuckoff_pos.clone().add(mover_pos.subtract(fuckoff_pos).toVector().normalize().multiply(fuckoff_range * 1.1)));
|
||||
event.setTo(fuckoffLocation.clone().add(playerLocation.subtract(fuckoffLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean do_freeze = false;
|
||||
boolean freeze = false;
|
||||
if (TotalFreedomMod.allPlayersFrozen)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
do_freeze = true;
|
||||
freeze = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerdata.isFrozen())
|
||||
{
|
||||
do_freeze = true;
|
||||
freeze = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_freeze)
|
||||
if (freeze)
|
||||
{
|
||||
Location freezeTo = to.clone();
|
||||
|
||||
@ -340,17 +358,17 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
Location targetPos = player.getLocation().add(0, 1, 0);
|
||||
|
||||
boolean out_of_cage;
|
||||
boolean outOfCage;
|
||||
if (!targetPos.getWorld().equals(playerdata.getCagePos().getWorld()))
|
||||
{
|
||||
out_of_cage = true;
|
||||
outOfCage = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
out_of_cage = targetPos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5);
|
||||
outOfCage = targetPos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5);
|
||||
}
|
||||
|
||||
if (out_of_cage)
|
||||
if (outOfCage)
|
||||
{
|
||||
playerdata.setCaged(true, targetPos, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER), playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
||||
playerdata.regenerateHistory();
|
||||
@ -374,43 +392,51 @@ public class TFM_PlayerListener implements Listener
|
||||
TFM_Jumppads.getInstance().PlayerMoveEvent(event);
|
||||
}
|
||||
|
||||
if (TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean() && TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
if (!(TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean() && TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
|
||||
while (landmines.hasNext())
|
||||
{
|
||||
TFM_LandmineData landmine = landmines.next();
|
||||
|
||||
Location landmine_pos = landmine.location;
|
||||
if (landmine_pos.getBlock().getType() != Material.TNT)
|
||||
Location location = landmine.location;
|
||||
if (location.getBlock().getType() != Material.TNT)
|
||||
{
|
||||
landmines.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!landmine.player.equals(player))
|
||||
if (landmine.player.equals(player))
|
||||
{
|
||||
if (player.getWorld().equals(landmine_pos.getWorld()))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!player.getWorld().equals(location.getWorld()))
|
||||
{
|
||||
if (player.getLocation().distanceSquared(landmine_pos) <= (landmine.radius * landmine.radius))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(player.getLocation().distanceSquared(location) <= (landmine.radius * landmine.radius)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
landmine.location.getBlock().setType(Material.AIR);
|
||||
|
||||
TNTPrimed tnt1 = landmine_pos.getWorld().spawn(landmine_pos, TNTPrimed.class);
|
||||
TNTPrimed tnt1 = location.getWorld().spawn(location, TNTPrimed.class);
|
||||
tnt1.setFuseTicks(40);
|
||||
tnt1.setPassenger(player);
|
||||
tnt1.setVelocity(new Vector(0.0, 2.0, 0.0));
|
||||
|
||||
TNTPrimed tnt2 = landmine_pos.getWorld().spawn(player.getLocation(), TNTPrimed.class);
|
||||
TNTPrimed tnt2 = location.getWorld().spawn(player.getLocation(), TNTPrimed.class);
|
||||
tnt2.setFuseTicks(1);
|
||||
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
landmines.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -457,6 +483,7 @@ public class TFM_PlayerListener implements Listener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
playerdata.setLastMessage(message);
|
||||
|
||||
// Check for muted
|
||||
@ -468,11 +495,9 @@ public class TFM_PlayerListener implements Listener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
playerdata.setMuted(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Strip color from messages
|
||||
message = ChatColor.stripColor(message);
|
||||
@ -559,9 +584,9 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
for (String test_command : BLOCKED_MUTED_CMDS)
|
||||
for (String commandName : BLOCKED_MUTED_CMDS)
|
||||
{
|
||||
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command).find())
|
||||
if (Pattern.compile("^/" + commandName.toLowerCase() + " ").matcher(command).find())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
||||
event.setCancelled(true);
|
||||
@ -662,13 +687,13 @@ public class TFM_PlayerListener implements Listener
|
||||
|
||||
TFM_UserList.getInstance(TotalFreedomMod.plugin).addUser(player);
|
||||
|
||||
boolean superadmin_impostor = TFM_SuperadminList.isSuperadminImpostor(player);
|
||||
boolean impostor = TFM_SuperadminList.isSuperadminImpostor(player);
|
||||
|
||||
if (superadmin_impostor || TFM_SuperadminList.isUserSuperadmin(player))
|
||||
if (impostor || TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_Util.getRank(player));
|
||||
|
||||
if (superadmin_impostor)
|
||||
if (impostor)
|
||||
{
|
||||
player.getInventory().clear();
|
||||
player.setOp(false);
|
||||
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -140,28 +141,37 @@ public class TFM_RollbackManager
|
||||
|
||||
public static class RollbackEntry
|
||||
{
|
||||
// Use of primitives to decrease overhead
|
||||
private final String author;
|
||||
private final Location location;
|
||||
private final int toBlockId; // ints have less overhead than Materials
|
||||
private final int fromBlockId;
|
||||
private final String worldName;
|
||||
private final int x;
|
||||
private final short y;
|
||||
private final int z;
|
||||
private final short blockId;
|
||||
private final byte data;
|
||||
private final boolean isBreak;
|
||||
|
||||
private RollbackEntry(String author, Block block, EntryType entryType)
|
||||
{
|
||||
this.location = block.getLocation().clone();
|
||||
final Location location = block.getLocation();
|
||||
|
||||
this.x = location.getBlockX();
|
||||
this.y = (short) location.getBlockY();
|
||||
this.z = location.getBlockZ();
|
||||
this.worldName = location.getWorld().getName();
|
||||
this.author = author;
|
||||
|
||||
if (entryType == EntryType.BLOCK_BREAK)
|
||||
{
|
||||
fromBlockId = block.getTypeId();
|
||||
toBlockId = Material.AIR.getId();
|
||||
data = block.getData();
|
||||
this.blockId = (short) block.getTypeId();
|
||||
this.data = block.getData();
|
||||
this.isBreak = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fromBlockId = Material.AIR.getId();
|
||||
toBlockId = block.getTypeId();
|
||||
blockId = (short) block.getTypeId();
|
||||
data = 0;
|
||||
this.isBreak = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,17 +182,35 @@ public class TFM_RollbackManager
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return location;
|
||||
try
|
||||
{
|
||||
return new Location(Bukkit.getWorld(worldName), (double) x, (double) y, (double) z);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.warning("Could not get location of rollback entry at (" + worldName + ":" + x + "," + y + "," + x + ")!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Material getFromMaterial()
|
||||
public Material getMaterial()
|
||||
{
|
||||
return Material.getMaterial(fromBlockId);
|
||||
return Material.getMaterial(blockId);
|
||||
}
|
||||
|
||||
public Material getToMaterial()
|
||||
public int getX()
|
||||
{
|
||||
return Material.getMaterial(toBlockId);
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
public byte getData()
|
||||
@ -192,14 +220,21 @@ public class TFM_RollbackManager
|
||||
|
||||
public EntryType getType()
|
||||
{
|
||||
return (getFromMaterial() == Material.AIR ? EntryType.BLOCK_PLACE : EntryType.BLOCK_BREAK);
|
||||
return (isBreak ? EntryType.BLOCK_BREAK : EntryType.BLOCK_PLACE);
|
||||
}
|
||||
|
||||
public void restore()
|
||||
{
|
||||
Block block = location.getWorld().getBlockAt(location);
|
||||
block.setType(getFromMaterial());
|
||||
Block block = Bukkit.getWorld(worldName).getBlockAt(x, y, z);
|
||||
if (isBreak)
|
||||
{
|
||||
block.setType(getMaterial());
|
||||
block.setData(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user