mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-02 22:23:08 +00:00
Sync with Local
This commit is contained in:
1 parent
5f0546f9f1
commit
d7da47683d
3 files changed
+105
-79
No files matched your search
@@ -303,13 +303,12 @@ public class SiegeEngines extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
l.setY(l.getY() + 1);
|
l.setY(l.getY() + 1);
|
||||||
int maxNearby = 0;
|
int maxNearby = 0;
|
||||||
|
|
||||||
l.setDirection(player.getFacing().getDirection());
|
l.setDirection(player.getFacing().getDirection());
|
||||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
String id = "";
|
String id = "";
|
||||||
equip.AmmoHolder = new EquipmentMagazine();
|
equip.AmmoHolder = new EquipmentMagazine();
|
||||||
if (equip.HaseBaseStand) {
|
if (equip.HasBaseStand) {
|
||||||
|
|
||||||
Location l2 = l;
|
Location l2 = l;
|
||||||
l2.setY(l.getY() + equip.BaseStandOffset);
|
l2.setY(l.getY() + equip.BaseStandOffset);
|
||||||
@@ -352,14 +351,6 @@ public class SiegeEngines extends JavaPlugin {
|
|||||||
LivingEntity ent = (LivingEntity) entity2;
|
LivingEntity ent = (LivingEntity) entity2;
|
||||||
ArmorStand stand = (ArmorStand) ent;
|
ArmorStand stand = (ArmorStand) ent;
|
||||||
equip.Entity = entity2;
|
equip.Entity = entity2;
|
||||||
for (Entity le : l.getNearbyEntities(5, 5, 5)) {
|
|
||||||
if (maxNearby >= 4) {
|
|
||||||
ent.damage(100.0d, player);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (le instanceof ArmorStand)
|
|
||||||
maxNearby++;
|
|
||||||
}
|
|
||||||
|
|
||||||
equip.EntityId = entity2.getUniqueId();
|
equip.EntityId = entity2.getUniqueId();
|
||||||
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
|
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
|
||||||
@@ -371,12 +362,9 @@ public class SiegeEngines extends JavaPlugin {
|
|||||||
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
|
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
|
||||||
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING);
|
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING);
|
||||||
stand.setInvisible(equip.AllowInvisibleStand);
|
stand.setInvisible(equip.AllowInvisibleStand);
|
||||||
stand.setBasePlate(false);
|
stand.setBasePlate(true);
|
||||||
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
|
|
||||||
// stand.setSmall(true);
|
|
||||||
|
|
||||||
stand.setGravity(false);
|
stand.setGravity(false);
|
||||||
//stand.setSmall(true);
|
|
||||||
ent.getEquipment().setHelmet(item);
|
ent.getEquipment().setHelmet(item);
|
||||||
if (TrackedStands.containsKey(player.getUniqueId())) {
|
if (TrackedStands.containsKey(player.getUniqueId())) {
|
||||||
List<Entity> entities = TrackedStands.get(player.getUniqueId());
|
List<Entity> entities = TrackedStands.get(player.getUniqueId());
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
public String WorldName;
|
public String WorldName;
|
||||||
public String EquipmentName = "Peckle Gun";
|
public String EquipmentName = "Peckle Gun";
|
||||||
public String EquipmentId = this.EquipmentName.replaceAll(" ", "_").toLowerCase();
|
public String EquipmentId = this.EquipmentName.replaceAll(" ", "_").toLowerCase();
|
||||||
public int XOffset = 7;
|
public int XOffset = 2;
|
||||||
public int YOffset = 0;
|
public int YOffset = 0;
|
||||||
public int PitchOffset = 0;
|
public int PitchOffset = 0;
|
||||||
public int MaxFuel = 5;
|
public int MaxFuel = 5;
|
||||||
public double PlacementOffsetY = 0;
|
public double PlacementOffsetY = 0;
|
||||||
public float VelocityPerFuel = 1.75f;
|
public float VelocityPerFuel = 1.0125f;
|
||||||
public ItemStack FuelMaterial = new ItemStack(Material.GUNPOWDER);
|
public ItemStack FuelMaterial = new ItemStack(Material.GUNPOWDER);
|
||||||
public long NextShotTime = System.currentTimeMillis();
|
public long NextShotTime = System.currentTimeMillis();
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
public Boolean HasFired = false;
|
public Boolean HasFired = false;
|
||||||
public Boolean HasReloaded = false;
|
public Boolean HasReloaded = false;
|
||||||
public Boolean AllowInvisibleStand = false;
|
public Boolean AllowInvisibleStand = false;
|
||||||
public Boolean HaseBaseStand = false;
|
public Boolean HasBaseStand = false;
|
||||||
public double BaseStandOffset = 0;
|
public double BaseStandOffset = 0;
|
||||||
public int BaseStandModelNumber = 147;
|
public int BaseStandModelNumber = 147;
|
||||||
public int TaskNumber;
|
public int TaskNumber;
|
||||||
@@ -99,7 +99,7 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
if (((Player) player).getInventory().containsAtLeast(fuelItem, 1) || fuelItem.getType() == Material.AIR) {
|
if (((Player) player).getInventory().containsAtLeast(fuelItem, 1) || fuelItem.getType() == Material.AIR) {
|
||||||
if (CanLoadFuel()) {
|
if (CanLoadFuel()) {
|
||||||
this.AmmoHolder.LoadedFuel += 1;
|
this.AmmoHolder.LoadedFuel += 1;
|
||||||
SaveState();
|
//SaveState();
|
||||||
((Player) player).getInventory().removeItem(fuelItem);
|
((Player) player).getInventory().removeItem(fuelItem);
|
||||||
((Player) player).sendMessage("§eLoaded " + this.AmmoHolder.LoadedFuel + "/" + this.MaxFuel);
|
((Player) player).sendMessage("§eLoaded " + this.AmmoHolder.LoadedFuel + "/" + this.MaxFuel);
|
||||||
return true;
|
return true;
|
||||||
@@ -125,19 +125,21 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
if (this.Projectiles.containsKey(itemInHand.getType()) && this.AmmoHolder.LoadedProjectile == 0) {
|
if (this.Projectiles.containsKey(itemInHand.getType()) && this.AmmoHolder.LoadedProjectile == 0) {
|
||||||
this.AmmoHolder.LoadedProjectile = 1;
|
this.AmmoHolder.LoadedProjectile = 1;
|
||||||
this.AmmoHolder.MaterialName = itemInHand;
|
this.AmmoHolder.MaterialName = itemInHand;
|
||||||
((Player) player).sendMessage("§eAdding Ammo to Weapon");
|
((Player) player).sendMessage("§eAdding Ammunition to Weapon");
|
||||||
itemInHand.setAmount(itemInHand.getAmount() - 1);
|
itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveState() {
|
//public void SaveState() {
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
public Location GetFireLocation(LivingEntity living) {
|
public Location GetFireLocation(LivingEntity living) {
|
||||||
|
if (living == null)
|
||||||
|
return null;
|
||||||
Location loc = living.getEyeLocation();
|
Location loc = living.getEyeLocation();
|
||||||
Vector direction = living.getLocation().getDirection().multiply(XOffset);
|
Vector direction = living.getLocation().getDirection().multiply(XOffset);
|
||||||
loc.add(direction);
|
loc.add(direction);
|
||||||
@@ -176,12 +178,12 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.AmmoHolder.LoadedFuel <= 0)
|
if (this.AmmoHolder.LoadedFuel <= 0)
|
||||||
this.AmmoHolder.LoadedFuel = 3;
|
this.AmmoHolder.LoadedFuel = 0;
|
||||||
float loadedFuel = this.AmmoHolder.LoadedFuel;
|
float loadedFuel = this.AmmoHolder.LoadedFuel;
|
||||||
ItemStack LoadedProjectile = this.AmmoHolder.MaterialName;
|
ItemStack LoadedProjectile = this.AmmoHolder.MaterialName;
|
||||||
|
|
||||||
|
|
||||||
LivingEntity living = (LivingEntity) Entity;
|
LivingEntity living = (LivingEntity) this.Entity;
|
||||||
if (living == null || living.getEquipment() == null || living.getEquipment().getHelmet() == null || living.getEquipment().getHelmet().getItemMeta() == null) {
|
if (living == null || living.getEquipment() == null || living.getEquipment().getHelmet() == null || living.getEquipment().getHelmet().getItemMeta() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -249,7 +251,11 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
SiegeEngines.UpdateEntityIdModel(this.Entity, modelData, this.WorldName);
|
SiegeEngines.UpdateEntityIdModel(this.Entity, modelData, this.WorldName);
|
||||||
if (modelData == this.ModelNumberToFireAt) {
|
if (modelData == this.ModelNumberToFireAt) {
|
||||||
// player.sendMessage("§efiring" + modelData);
|
// player.sendMessage("§efiring" + modelData);
|
||||||
Projectiles.get(LoadedProjectile).Shoot(player, this.Entity, this.GetFireLocation(living), loadedFuel * this.VelocityPerFuel);
|
if (LoadedProjectile == null) return;
|
||||||
|
if (LoadedProjectile.getType() == Material.AIR) return;
|
||||||
|
GunnersProjectile projType = Projectiles.get(LoadedProjectile);
|
||||||
|
if (projType == null) return;
|
||||||
|
projType.Shoot(player, this.Entity, this.GetFireLocation(living), loadedFuel * this.VelocityPerFuel);
|
||||||
}
|
}
|
||||||
this.NextModelNumber += 1;
|
this.NextModelNumber += 1;
|
||||||
|
|
||||||
@@ -273,8 +279,11 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
loc.add(direction);
|
loc.add(direction);
|
||||||
|
|
||||||
this.NextModelNumber = 0;
|
this.NextModelNumber = 0;
|
||||||
|
if (LoadedProjectile == null) return;
|
||||||
Projectiles.get(LoadedProjectile).Shoot(player, this.Entity, this.GetFireLocation(living), loadedFuel * this.VelocityPerFuel);
|
if (LoadedProjectile.getType() == Material.AIR) return;
|
||||||
|
GunnersProjectile projType = Projectiles.get(LoadedProjectile);
|
||||||
|
if (projType == null) return;
|
||||||
|
projType.Shoot(player, this.Entity, this.GetFireLocation(living), loadedFuel * this.VelocityPerFuel);
|
||||||
}, (long) delay);
|
}, (long) delay);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,8 @@ public class ClickHandler implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void BlockPlaceEvent(org.bukkit.event.block.BlockPlaceEvent event) {
|
public void BlockPlaceEvent(org.bukkit.event.block.BlockPlaceEvent event) {
|
||||||
Player thePlayer = event.getPlayer();
|
Player thePlayer = event.getPlayer();
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
if (event.getPlayer().getInventory().getItemInMainHand().getType() == Material.CARVED_PUMPKIN) {
|
if (event.getPlayer().getInventory().getItemInMainHand().getType() == Material.CARVED_PUMPKIN) {
|
||||||
@@ -195,7 +197,8 @@ public class ClickHandler implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double distance = player.getLocation().distance(ent.getLocation());
|
double distance = player.getLocation().distance(ent.getLocation());
|
||||||
if (distance >= 64) {
|
if (distance >= 32) {
|
||||||
|
SiegeEngines.TrackedStands.get(player.getUniqueId()).remove(ent);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SiegeEquipment siege = SiegeEngines.equipment.get(ent.getUniqueId());
|
SiegeEquipment siege = SiegeEngines.equipment.get(ent.getUniqueId());
|
||||||
@@ -244,14 +247,16 @@ public class ClickHandler implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasItem(Inventory inv, ItemStack m) {
|
public static boolean hasItem(Inventory inv, ItemStack m) {
|
||||||
ItemStack[] contents = inv.getStorageContents();
|
//ItemStack[] contents = inv.getStorageContents();
|
||||||
for(int i = 0; i < contents.length; i++) {
|
/*for(int i = 0; i < contents.length; i++) {
|
||||||
if(contents[i] == null) continue;
|
if(contents[i] == null) continue;
|
||||||
if(contents[i].isSimilar(m)) {
|
if(contents[i].isSimilar(m)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
return false;
|
//m.setAmount(1);
|
||||||
|
return inv.containsAtLeast(m,m.getAmount());
|
||||||
|
//return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -279,7 +284,11 @@ public class ClickHandler implements Listener {
|
|||||||
}
|
}
|
||||||
if (!player.isSneaking()) {
|
if (!player.isSneaking()) {
|
||||||
List<Entity> entities = SiegeEngines.TrackedStands.get(player.getUniqueId());
|
List<Entity> entities = SiegeEngines.TrackedStands.get(player.getUniqueId());
|
||||||
|
if (entities == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
|
|
||||||
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
|
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
|
||||||
SiegeEquipment equip = SiegeEngines.equipment.get(entity.getUniqueId());
|
SiegeEquipment equip = SiegeEngines.equipment.get(entity.getUniqueId());
|
||||||
if (equip != null && equip.Enabled && !(entity.isDead())) {
|
if (equip != null && equip.Enabled && !(entity.isDead())) {
|
||||||
@@ -287,12 +296,17 @@ public class ClickHandler implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (SiegeEngines.TrackedStands.containsKey(player.getUniqueId())) {
|
if (SiegeEngines.TrackedStands.containsKey(player.getUniqueId())) {
|
||||||
List<Entity> entities = SiegeEngines.TrackedStands.get(player.getUniqueId());
|
List<Entity> entities = SiegeEngines.TrackedStands.get(player.getUniqueId());
|
||||||
|
if (entities == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
player.sendMessage("§eReloading Ammunition");
|
player.sendMessage("§eReloading Ammunition");
|
||||||
|
boolean foundAmmo = false;
|
||||||
for (Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
boolean foundAmmo = false;
|
foundAmmo = false;
|
||||||
if ((entity.isDead())) continue;
|
if ((entity.isDead())) continue;
|
||||||
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
|
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
|
||||||
SiegeEquipment equip = SiegeEngines.equipment.get(entity.getUniqueId());
|
SiegeEquipment equip = SiegeEngines.equipment.get(entity.getUniqueId());
|
||||||
@@ -306,7 +320,7 @@ public class ClickHandler implements Listener {
|
|||||||
if (foundAmmo)
|
if (foundAmmo)
|
||||||
continue;
|
continue;
|
||||||
if (!hasItem((Inventory)state.getInventory(),stack))
|
if (!hasItem((Inventory)state.getInventory(),stack))
|
||||||
continue;
|
continue;
|
||||||
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
||||||
//state.update(true,true);
|
//state.update(true,true);
|
||||||
equip.AmmoHolder.LoadedProjectile = 1;
|
equip.AmmoHolder.LoadedProjectile = 1;
|
||||||
@@ -316,7 +330,7 @@ public class ClickHandler implements Listener {
|
|||||||
//state.update(true,true);
|
//state.update(true,true);
|
||||||
}
|
}
|
||||||
if (foundAmmo)
|
if (foundAmmo)
|
||||||
continue;
|
break;
|
||||||
if (entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.CHEST) {
|
if (entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.CHEST) {
|
||||||
Block inv = entity.getLocation().getBlock().getRelative(0, -1, 0);
|
Block inv = entity.getLocation().getBlock().getRelative(0, -1, 0);
|
||||||
Container state = ((Container) inv.getState());
|
Container state = ((Container) inv.getState());
|
||||||
@@ -324,7 +338,7 @@ public class ClickHandler implements Listener {
|
|||||||
if (foundAmmo)
|
if (foundAmmo)
|
||||||
continue;
|
continue;
|
||||||
if (!hasItem((Inventory)state.getInventory(),stack))
|
if (!hasItem((Inventory)state.getInventory(),stack))
|
||||||
continue;
|
continue;
|
||||||
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
||||||
//state.update(true,true);
|
//state.update(true,true);
|
||||||
equip.AmmoHolder.LoadedProjectile = 1;
|
equip.AmmoHolder.LoadedProjectile = 1;
|
||||||
@@ -334,7 +348,7 @@ public class ClickHandler implements Listener {
|
|||||||
//state.update(true,true);
|
//state.update(true,true);
|
||||||
}
|
}
|
||||||
if (foundAmmo)
|
if (foundAmmo)
|
||||||
continue;
|
break;
|
||||||
if (entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.CHEST) {
|
if (entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.CHEST) {
|
||||||
Block inv = entity.getLocation().getBlock().getRelative(0, 1, 0);
|
Block inv = entity.getLocation().getBlock().getRelative(0, 1, 0);
|
||||||
Container state = ((Container) inv.getState());
|
Container state = ((Container) inv.getState());
|
||||||
@@ -342,7 +356,7 @@ public class ClickHandler implements Listener {
|
|||||||
if (foundAmmo)
|
if (foundAmmo)
|
||||||
continue;
|
continue;
|
||||||
if (!hasItem((Inventory)state.getInventory(),stack))
|
if (!hasItem((Inventory)state.getInventory(),stack))
|
||||||
continue;
|
continue;
|
||||||
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
||||||
//state.update(true,true);
|
//state.update(true,true);
|
||||||
equip.AmmoHolder.LoadedProjectile = 1;
|
equip.AmmoHolder.LoadedProjectile = 1;
|
||||||
@@ -352,72 +366,50 @@ public class ClickHandler implements Listener {
|
|||||||
//state.update(true,true);
|
//state.update(true,true);
|
||||||
}
|
}
|
||||||
if (foundAmmo)
|
if (foundAmmo)
|
||||||
continue;
|
break;
|
||||||
if (!player.isSneaking())
|
if (!player.isSneaking())
|
||||||
return;
|
break;
|
||||||
if (!foundAmmo) {
|
if (!foundAmmo) {
|
||||||
for (ItemStack inventoryItem : event.getPlayer().getInventory().getContents()) {
|
for (ItemStack inventoryItem : event.getPlayer().getInventory().getContents()) {
|
||||||
for (ItemStack stack : equip.Projectiles.keySet()) {
|
for (ItemStack stack : equip.Projectiles.keySet()) {
|
||||||
if (foundAmmo)
|
if (foundAmmo)
|
||||||
continue;
|
continue;
|
||||||
if (!hasItem(event.getPlayer().getInventory(),stack))
|
if (!hasItem(event.getPlayer().getInventory(),stack))
|
||||||
continue;
|
continue;
|
||||||
if (stack.isSimilar(inventoryItem) && equip.AmmoHolder.LoadedProjectile == 0) {
|
if (stack.isSimilar(inventoryItem) && equip.AmmoHolder.LoadedProjectile == 0) {
|
||||||
equip.AmmoHolder.LoadedProjectile = 1;
|
equip.AmmoHolder.LoadedProjectile = 1;
|
||||||
equip.AmmoHolder.MaterialName = stack;
|
equip.AmmoHolder.MaterialName = stack;
|
||||||
inventoryItem.setAmount(inventoryItem.getAmount() - 1);
|
inventoryItem.setAmount(inventoryItem.getAmount() - 1);
|
||||||
foundAmmo = true;
|
foundAmmo = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!foundAmmo) {
|
||||||
|
event.getPlayer().sendMessage("§eCould not load Ammunition.");
|
||||||
|
}
|
||||||
player.sendMessage("§eReloading Propellant");
|
player.sendMessage("§eReloading Propellant");
|
||||||
for (Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
boolean foundAmmo = false;
|
foundAmmo = false;
|
||||||
if ((entity.isDead())) continue;
|
if ((entity.isDead())) continue;
|
||||||
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
|
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
|
||||||
SiegeEquipment equip = SiegeEngines.equipment.get(entity.getUniqueId());
|
SiegeEquipment equip = SiegeEngines.equipment.get(entity.getUniqueId());
|
||||||
if (equip == null || !equip.Enabled) {
|
if (equip == null || !equip.Enabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
ItemStack stack = equip.FuelMaterial;
|
||||||
if (entity.getLocation().getBlock().getType() == Material.BARREL || entity.getLocation().getBlock().getType() == Material.CHEST) {
|
if (entity.getLocation().getBlock().getType() == Material.BARREL || entity.getLocation().getBlock().getType() == Material.CHEST) {
|
||||||
Block inv = entity.getLocation().getBlock();
|
Block inv = entity.getLocation().getBlock();
|
||||||
Container state = ((Container) inv.getState());
|
Container state = ((Container) inv.getState());
|
||||||
ItemStack stack = equip.FuelMaterial;
|
|
||||||
if (foundAmmo)
|
if (foundAmmo)
|
||||||
continue;
|
continue;
|
||||||
if (!hasItem((Inventory)state.getInventory(),stack))
|
if (!hasItem((Inventory)state.getInventory(),stack))
|
||||||
continue;
|
|
||||||
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
|
||||||
//state.update(true,true);
|
|
||||||
equip.AmmoHolder.LoadedFuel += 1;
|
|
||||||
foundAmmo = true;
|
|
||||||
//state.update(true,true);
|
|
||||||
}
|
|
||||||
if (entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.CHEST) {
|
|
||||||
Block inv = entity.getLocation().getBlock().getRelative(0, -1, 0);;
|
|
||||||
Container state = ((Container) inv.getState());
|
|
||||||
ItemStack stack = equip.FuelMaterial;
|
|
||||||
if (foundAmmo)
|
|
||||||
continue;
|
continue;
|
||||||
if (!hasItem((Inventory)state.getInventory(),stack))
|
if (!equip.CanLoadFuel())
|
||||||
continue;
|
|
||||||
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
|
||||||
//state.update(true,true);
|
|
||||||
equip.AmmoHolder.LoadedFuel += 1;
|
|
||||||
foundAmmo = true;
|
|
||||||
//state.update(true,true);
|
|
||||||
}
|
|
||||||
if (entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.CHEST) {
|
|
||||||
Block inv = entity.getLocation().getBlock().getRelative(0, 1, 0);
|
|
||||||
Container state = ((Container) inv.getState());
|
|
||||||
ItemStack stack = equip.FuelMaterial;
|
|
||||||
if (foundAmmo)
|
|
||||||
continue;
|
continue;
|
||||||
if (!hasItem((Inventory)state.getInventory(),stack))
|
|
||||||
continue;
|
|
||||||
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
||||||
//state.update(true,true);
|
//state.update(true,true);
|
||||||
equip.AmmoHolder.LoadedFuel += 1;
|
equip.AmmoHolder.LoadedFuel += 1;
|
||||||
@@ -425,22 +417,59 @@ public class ClickHandler implements Listener {
|
|||||||
//state.update(true,true);
|
//state.update(true,true);
|
||||||
}
|
}
|
||||||
if (foundAmmo)
|
if (foundAmmo)
|
||||||
continue;
|
break;
|
||||||
|
if (entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.CHEST) {
|
||||||
|
Block inv = entity.getLocation().getBlock().getRelative(0, -1, 0);;
|
||||||
|
Container state = ((Container) inv.getState());
|
||||||
|
if (foundAmmo)
|
||||||
|
continue;
|
||||||
|
if (!hasItem((Inventory)state.getInventory(),stack))
|
||||||
|
continue;
|
||||||
|
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
||||||
|
//state.update(true,true);
|
||||||
|
if (!equip.CanLoadFuel())
|
||||||
|
continue;
|
||||||
|
equip.AmmoHolder.LoadedFuel += 1;
|
||||||
|
foundAmmo = true;
|
||||||
|
//state.update(true,true);
|
||||||
|
}
|
||||||
|
if (foundAmmo)
|
||||||
|
break;
|
||||||
|
if (entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.CHEST) {
|
||||||
|
Block inv = entity.getLocation().getBlock().getRelative(0, 1, 0);
|
||||||
|
Container state = ((Container) inv.getState());
|
||||||
|
if (foundAmmo)
|
||||||
|
continue;
|
||||||
|
if (!hasItem((Inventory)state.getInventory(),stack))
|
||||||
|
continue;
|
||||||
|
if (!equip.CanLoadFuel())
|
||||||
|
continue;
|
||||||
|
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
|
||||||
|
//state.update(true,true);
|
||||||
|
equip.AmmoHolder.LoadedFuel += 1;
|
||||||
|
foundAmmo = true;
|
||||||
|
//state.update(true,true);
|
||||||
|
}
|
||||||
|
if (foundAmmo)
|
||||||
|
break;
|
||||||
if (!player.isSneaking())
|
if (!player.isSneaking())
|
||||||
return;
|
break;
|
||||||
if (!foundAmmo) {
|
if (!foundAmmo) {
|
||||||
for (ItemStack inventoryItem : event.getPlayer().getInventory().getContents()) {
|
if (hasItem((Inventory)event.getPlayer().getInventory(),stack)) {
|
||||||
if (foundAmmo)
|
if (foundAmmo)
|
||||||
continue;
|
break;
|
||||||
if (!equip.CanLoadFuel())
|
if (!equip.CanLoadFuel())
|
||||||
continue;
|
continue;
|
||||||
if (equip.FuelMaterial.isSimilar(inventoryItem)) {
|
equip.AmmoHolder.LoadedFuel += 1;
|
||||||
equip.AmmoHolder.LoadedFuel += 1;
|
stack.setAmount(1);
|
||||||
inventoryItem.setAmount(inventoryItem.getAmount() - 1);
|
event.getPlayer().getInventory().removeItem(stack);
|
||||||
foundAmmo = true;
|
foundAmmo = true;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!foundAmmo) {
|
||||||
|
event.getPlayer().sendMessage("§eCould not load Propellant.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -848,7 +877,7 @@ public class ClickHandler implements Listener {
|
|||||||
if (stack.isSimilar(itemInHand) && equipment.AmmoHolder.LoadedProjectile == 0) {
|
if (stack.isSimilar(itemInHand) && equipment.AmmoHolder.LoadedProjectile == 0) {
|
||||||
equipment.AmmoHolder.LoadedProjectile = 1;
|
equipment.AmmoHolder.LoadedProjectile = 1;
|
||||||
equipment.AmmoHolder.MaterialName = stack;
|
equipment.AmmoHolder.MaterialName = stack;
|
||||||
player.sendMessage("§eAdding Ammo to Weapon");
|
player.sendMessage("§eAdding Ammunition to Weapon");
|
||||||
itemInHand.setAmount(itemInHand.getAmount() - 1);
|
itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user