This commit is contained in:
TheCrunchy committed 2023-08-01 11:51:34 +01:00
1 parent 9dbb1cd17f
commit a7cf287a20
5 files changed
+43 -9

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
+39 -7
View File
@@ -34,6 +34,7 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
@@ -60,6 +61,25 @@ public class ClickHandler implements Listener {
public float MinDelay = 5; public float MinDelay = 5;
public static HashMap<UUID, ExplosiveProjectile> projectiles = new HashMap<UUID, ExplosiveProjectile>(); public static HashMap<UUID, ExplosiveProjectile> projectiles = new HashMap<UUID, ExplosiveProjectile>();
@EventHandler
public void onExplode(EntityExplodeEvent e) {
for (Entity entity : e.getEntity().getNearbyEntities(e.getYield() + 1, e.getYield()+ 1, e.getYield()+ 1)) {
if(entity instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) entity;
if (CrunchSiegeCore.towny != null) {
TownBlock block = TownyAPI.getInstance().getTownBlock(stand.getLocation());
if (block != null) {
if (block.hasTown()) {
if (!block.getTownBlockOwner().getPermissions().explosion) {
return;
}
}
}
}
stand.remove();
}
}
}
@EventHandler @EventHandler
public void onHit(ProjectileHitEvent event) { public void onHit(ProjectileHitEvent event) {
@@ -70,9 +90,9 @@ public class ClickHandler implements Listener {
World world = event.getEntity().getWorld(); World world = event.getEntity().getWorld();
// world.createExplosion(loc, proj.Radius, proj.DoFire); // world.createExplosion(loc, proj.Radius, proj.DoFire);
Entity tnt = event.getEntity().getWorld().spawnEntity(loc, EntityType.PRIMED_TNT); Entity tnt = event.getEntity().getWorld().spawnEntity(loc, EntityType.PRIMED_TNT);
projectiles.remove(event.getEntity().getUniqueId()); projectiles.remove(event.getEntity().getUniqueId());
if (proj.PlaceBlocks) { if (proj.PlaceBlocks) {
TNTPrimed tntEnt = (TNTPrimed) tnt; TNTPrimed tntEnt = (TNTPrimed) tnt;
tntEnt.setYield(0); tntEnt.setYield(0);
@@ -100,7 +120,7 @@ public class ClickHandler implements Listener {
tntEnt.setYield(proj.ExplodePower); tntEnt.setYield(proj.ExplodePower);
tntEnt.setFuseTicks(0); tntEnt.setFuseTicks(0);
} }
} }
} }
@@ -331,7 +351,7 @@ public class ClickHandler implements Listener {
ent.teleport(loc); ent.teleport(loc);
} }
public void DoAimDown(Entity ent, float amount, Player player) { public void DoAimDown(Entity ent, float amount, Player player) {
Location loc = ent.getLocation(); Location loc = ent.getLocation();
ArmorStand stand = (ArmorStand) ent; ArmorStand stand = (ArmorStand) ent;
@@ -352,7 +372,7 @@ public class ClickHandler implements Listener {
ent.teleport(loc); ent.teleport(loc);
} }
@EventHandler @EventHandler
public void DeathEvent(EntityDeathEvent event) { public void DeathEvent(EntityDeathEvent event) {
Boolean removeStands = false; Boolean removeStands = false;
@@ -389,7 +409,7 @@ public class ClickHandler implements Listener {
if (ent.isDead()) { if (ent.isDead()) {
continue; continue;
} }
DoAimDown(ent, amount, player); DoAimDown(ent, amount, player);
} }
} }
@@ -528,7 +548,7 @@ public class ClickHandler implements Listener {
if (entity.getType() == EntityType.ARMOR_STAND){ if (entity.getType() == EntityType.ARMOR_STAND){
TakeControl(player, entity); TakeControl(player, entity);
if (CrunchSiegeCore.equipment.containsKey(entity.getUniqueId())) { if (CrunchSiegeCore.equipment.containsKey(entity.getUniqueId())) {
if (itemInHand == null || itemInHand.getType() == Material.AIR) { if (itemInHand.getType() == Material.COMPASS) {
if (player.isSneaking()) { if (player.isSneaking()) {
DoAimDown(entity, 1, player); DoAimDown(entity, 1, player);
} }
@@ -537,7 +557,19 @@ public class ClickHandler implements Listener {
} }
return; return;
} }
SiegeEquipment equipment = CrunchSiegeCore.equipment.get(entity.getUniqueId()); SiegeEquipment equipment = CrunchSiegeCore.equipment.get(entity.getUniqueId());
if (itemInHand == null || itemInHand.getType() == Material.AIR) {
ArmorStand stand = (ArmorStand) entity;
if (stand.isInvisible()) {
stand.setInvisible(false);
}
else{
stand.setInvisible(true);
}
return;
}
if (itemInHand.getType().equals(equipment.FuelMaterial)) { if (itemInHand.getType().equals(equipment.FuelMaterial)) {
if (!equipment.LoadFuel(player)) { if (!equipment.LoadFuel(player)) {
player.sendMessage("Could not load powder."); player.sendMessage("Could not load powder.");
+4 -2
View File
@@ -153,7 +153,9 @@ public class CrunchSiegeCore extends JavaPlugin {
meta.setCustomModelData(i.ReadyModelNumber); meta.setCustomModelData(i.ReadyModelNumber);
meta.setDisplayName("§e" + i.EquipmentName +" spawn item"); meta.setDisplayName("§e" + i.EquipmentName +" spawn item");
List<String> Lore = new ArrayList<String>(); List<String> Lore = new ArrayList<String>();
Lore.add("§ePlace as a block to spawn a " + i.EquipmentName + " or put on an armour stand."); Lore.add("§ePlace as a block to spawn a " + i.EquipmentName);
Lore.add("§eor put on an armour stand.");
Lore.add("§eRight click to toggle visibility of stand.");
meta.setLore(Lore); meta.setLore(Lore);
item.setItemMeta(meta); item.setItemMeta(meta);
player.getInventory().addItem(item); player.getInventory().addItem(item);
@@ -332,7 +334,7 @@ public class CrunchSiegeCore extends JavaPlugin {
stand.setBasePlate(false); stand.setBasePlate(false);
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1)); ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
// stand.setSmall(true); // stand.setSmall(true);
stand.setVisible(true); stand.setInvisible(true);
stand.setGravity(false); stand.setGravity(false);
//stand.setSmall(true); //stand.setSmall(true);
ent.getEquipment().setHelmet(item); ent.getEquipment().setHelmet(item);