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