mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Cleanup
This commit is contained in:
parent
972e81276d
commit
d066c1b754
@ -102,89 +102,95 @@ public class TFM_PlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
case BLAZE_ROD:
|
case BLAZE_ROD:
|
||||||
{
|
{
|
||||||
if (TotalFreedomMod.allowExplosions && TFM_SuperadminList.isSeniorAdmin(player))
|
if (TotalFreedomMod.allowExplosions)
|
||||||
{
|
{
|
||||||
Block target_block;
|
if (TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||||
|
{
|
||||||
|
Block target_block;
|
||||||
|
|
||||||
if (event.getAction().equals(Action.LEFT_CLICK_AIR))
|
if (event.getAction().equals(Action.LEFT_CLICK_AIR))
|
||||||
{
|
{
|
||||||
target_block = player.getTargetBlock(null, 120);
|
target_block = player.getTargetBlock(null, 120);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
target_block = event.getClickedBlock();
|
target_block = event.getClickedBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target_block != null)
|
if (target_block != null)
|
||||||
{
|
{
|
||||||
player.getWorld().createExplosion(target_block.getLocation(), 4F, true);
|
player.getWorld().createExplosion(target_block.getLocation(), 4F, true);
|
||||||
player.getWorld().strikeLightning(target_block.getLocation());
|
player.getWorld().strikeLightning(target_block.getLocation());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player.sendMessage("Can't resolve target block.");
|
player.sendMessage("Can't resolve target block.");
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CARROT:
|
case CARROT:
|
||||||
{
|
{
|
||||||
if (TotalFreedomMod.allowExplosions && TFM_SuperadminList.isSeniorAdmin(player))
|
if (TotalFreedomMod.allowExplosions)
|
||||||
{
|
{
|
||||||
Location player_location = player.getLocation().clone();
|
if (TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||||
|
|
||||||
Vector player_pos = player_location.toVector().add(new Vector(0.0, 1.65, 0.0));
|
|
||||||
Vector player_dir = player_location.getDirection().normalize();
|
|
||||||
|
|
||||||
double distance = 150.0;
|
|
||||||
Block target_block = player.getTargetBlock(null, Math.round((float) distance));
|
|
||||||
if (target_block != null)
|
|
||||||
{
|
{
|
||||||
distance = player_location.distance(target_block.getLocation());
|
Location player_location = player.getLocation().clone();
|
||||||
}
|
|
||||||
|
|
||||||
final List<Block> affected = new ArrayList<Block>();
|
Vector player_pos = player_location.toVector().add(new Vector(0.0, 1.65, 0.0));
|
||||||
|
Vector player_dir = player_location.getDirection().normalize();
|
||||||
|
|
||||||
Block last_block = null;
|
double distance = 150.0;
|
||||||
for (double offset = 0.0; offset <= distance; offset += (distance / 25.0))
|
Block target_block = player.getTargetBlock(null, Math.round((float) distance));
|
||||||
{
|
if (target_block != null)
|
||||||
Block test_block = player_pos.clone().add(player_dir.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
|
|
||||||
|
|
||||||
if (!test_block.equals(last_block))
|
|
||||||
{
|
{
|
||||||
if (test_block.isEmpty())
|
distance = player_location.distance(target_block.getLocation());
|
||||||
{
|
|
||||||
affected.add(test_block);
|
|
||||||
test_block.setType(Material.TNT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
last_block = test_block;
|
final List<Block> affected = new ArrayList<Block>();
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(TotalFreedomMod.plugin, new Runnable()
|
Block last_block = null;
|
||||||
{
|
for (double offset = 0.0; offset <= distance; offset += (distance / 25.0))
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
{
|
||||||
for (Block tnt_block : affected)
|
Block test_block = player_pos.clone().add(player_dir.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
|
||||||
{
|
|
||||||
TNTPrimed tnt_primed = tnt_block.getWorld().spawn(tnt_block.getLocation(), TNTPrimed.class);
|
|
||||||
tnt_primed.setFuseTicks(5);
|
|
||||||
tnt_block.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 30L);
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
if (!test_block.equals(last_block))
|
||||||
return;
|
{
|
||||||
|
if (test_block.isEmpty())
|
||||||
|
{
|
||||||
|
affected.add(test_block);
|
||||||
|
test_block.setType(Material.TNT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
last_block = test_block;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(TotalFreedomMod.plugin, new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
for (Block tnt_block : affected)
|
||||||
|
{
|
||||||
|
TNTPrimed tnt_primed = tnt_block.getWorld().spawn(tnt_block.getLocation(), TNTPrimed.class);
|
||||||
|
tnt_primed.setFuseTicks(5);
|
||||||
|
tnt_block.setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 30L);
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -291,6 +297,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
|
p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
|
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
|
||||||
{
|
{
|
||||||
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
|
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
|
||||||
|
@ -202,6 +202,19 @@ public class TFM_SuperadminList
|
|||||||
|
|
||||||
public static boolean isSeniorAdmin(CommandSender user)
|
public static boolean isSeniorAdmin(CommandSender user)
|
||||||
{
|
{
|
||||||
|
return isSeniorAdmin(user, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSeniorAdmin(CommandSender user, boolean verify_is_superadmin)
|
||||||
|
{
|
||||||
|
if (verify_is_superadmin)
|
||||||
|
{
|
||||||
|
if (!isUserSuperadmin(user))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String user_name = user.getName().toLowerCase();
|
String user_name = user.getName().toLowerCase();
|
||||||
|
|
||||||
if (!(user instanceof Player))
|
if (!(user instanceof Player))
|
||||||
|
Loading…
Reference in New Issue
Block a user