mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-01 14:38:55 +00:00
Merge branch 'sherman'
This commit is contained in:
commit
80a058a2f1
6 files changed
+763
-783
No files matched your search
@@ -80,7 +80,6 @@ public class SiegeEngine implements Cloneable {
|
||||
}
|
||||
|
||||
public SiegeEngine(@NotNull String name, @NotNull HashMap<ItemStack, GunnersProjectile> projectiles, @NotNull ItemStack fuelItem, int customModelID) {
|
||||
//String name, Integer XOffset, Integer YOffset, Integer fuelMax, Float fuelVelocityMod, Integer customModelId, HashMap<ItemStack, GunnersProjectile> projObj
|
||||
|
||||
// Default custom model data id if it is passes as null
|
||||
if (customModelID == 0) {
|
||||
@@ -141,17 +140,23 @@ public class SiegeEngine implements Cloneable {
|
||||
return id.equals(EquipmentId);
|
||||
}
|
||||
|
||||
public Boolean isLoaded() {
|
||||
if (this.maxFuel <= 0 && ammoHolder.loadedProjectile >= 1)
|
||||
return true;
|
||||
return (ammoHolder.loadedFuel > 0 && ammoHolder.loadedProjectile >= 1);
|
||||
public boolean isLoaded() {
|
||||
return hasPropellant() && hasAmmunition();
|
||||
}
|
||||
|
||||
public boolean hasPropellant() {
|
||||
return ammoHolder.loadedFuel > 0;
|
||||
}
|
||||
|
||||
public boolean hasAmmunition() {
|
||||
return ammoHolder.loadedProjectile >= 1;
|
||||
}
|
||||
|
||||
public Boolean CanLoadFuel() {
|
||||
public boolean canLoadFuel() {
|
||||
return ammoHolder.loadedFuel < maxFuel;
|
||||
}
|
||||
|
||||
public Boolean LoadFuel(Entity player) {
|
||||
public boolean loadFuel(Entity player) {
|
||||
if (ammoHolder.loadedFuel == maxFuel) {
|
||||
return true;
|
||||
}
|
||||
@@ -160,7 +165,7 @@ public class SiegeEngine implements Cloneable {
|
||||
return true;
|
||||
}
|
||||
if (((Player) player).getInventory().containsAtLeast(fuelItem, 1) || fuelItem.getType() == Material.AIR) {
|
||||
if (CanLoadFuel()) {
|
||||
if (canLoadFuel()) {
|
||||
this.ammoHolder.loadedFuel += 1;
|
||||
//SaveState();
|
||||
((Player) player).getInventory().removeItem(fuelItem);
|
||||
@@ -175,7 +180,7 @@ public class SiegeEngine implements Cloneable {
|
||||
|
||||
}
|
||||
|
||||
public Boolean LoadProjectile(Entity player, ItemStack itemInHand) {
|
||||
public boolean LoadProjectile(Entity player, ItemStack itemInHand) {
|
||||
if (itemInHand.getAmount() <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -379,7 +384,6 @@ public class SiegeEngine implements Cloneable {
|
||||
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING);
|
||||
stand.setBasePlate(false);
|
||||
// stand.setSmall(true);
|
||||
item.setItemMeta(meta);
|
||||
stand.setInvisible(this.allowInvisibleStand);
|
||||
ent.getEquipment().setHelmet(item);
|
||||
@@ -418,14 +422,14 @@ public class SiegeEngine implements Cloneable {
|
||||
|
||||
stand.setGravity(false);
|
||||
ent.getEquipment().setHelmet(item);
|
||||
if (SiegeEngines.trackedStands.containsKey(player.getUniqueId())) {
|
||||
List<Entity> entities = SiegeEngines.trackedStands.get(player.getUniqueId());
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) {
|
||||
List<Entity> entities = SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId());
|
||||
entities.add(entity2);
|
||||
SiegeEngines.trackedStands.put(player.getUniqueId(), entities);
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.put(player.getUniqueId(), entities);
|
||||
} else {
|
||||
List<Entity> newList = new ArrayList<Entity>();
|
||||
newList.add(entity2);
|
||||
SiegeEngines.trackedStands.put(player.getUniqueId(), newList);
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.put(player.getUniqueId(), newList);
|
||||
}
|
||||
SiegeEngines.activeSiegeEngines.put(entity2.getUniqueId(), this);
|
||||
return true;
|
||||
|
||||
@@ -34,9 +34,12 @@ public class SiegeEngines extends JavaPlugin {
|
||||
public static MetadataValueAdapter metadata;
|
||||
public static Random random = new Random();
|
||||
|
||||
// model id, defined seige engine types
|
||||
public static HashMap<Integer, SiegeEngine> definedSiegeEngines = new HashMap<Integer, SiegeEngine>();
|
||||
// siege engine entity, siege engine object
|
||||
public static HashMap<UUID, SiegeEngine> activeSiegeEngines = new HashMap<UUID, SiegeEngine>();
|
||||
public static HashMap<UUID, List<Entity>> trackedStands = new HashMap<UUID, List<Entity>>();
|
||||
// Player UUID, siege engine entity
|
||||
public static HashMap<UUID, List<Entity>> siegeEngineEntitiesPerPlayer = new HashMap<UUID, List<Entity>>();
|
||||
|
||||
|
||||
public static SiegeEngines getInstance() {
|
||||
@@ -55,7 +58,7 @@ public class SiegeEngines extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new RotationHandler(), this);
|
||||
getServer().getPluginManager().registerEvents(new ClickHandler(), this);
|
||||
activeSiegeEngines.clear();
|
||||
trackedStands.clear();
|
||||
siegeEngineEntitiesPerPlayer.clear();
|
||||
definedSiegeEngines.clear();
|
||||
AddDefaults();
|
||||
for (SiegeEngine i : definedSiegeEngines.values()) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
@@ -48,4 +49,8 @@ public class SiegeEnginesUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasItem(Inventory inv, ItemStack m) {
|
||||
return inv.containsAtLeast(m, m.getAmount());
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class SiegeEnginesCommand {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>Only players can use this command.").build());
|
||||
|
||||
activeSiegeEngines.clear();
|
||||
trackedStands.clear();
|
||||
siegeEngineEntitiesPerPlayer.clear();
|
||||
definedSiegeEngines.clear();
|
||||
AddDefaults();
|
||||
for (SiegeEngine i : definedSiegeEngines.values()) {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -29,7 +29,7 @@ public class RotationHandler implements Listener {
|
||||
public void playerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
NamespacedKey key = new NamespacedKey(SiegeEngines.getInstance(), "cannons");
|
||||
if (SiegeEngines.trackedStands.containsKey(player.getUniqueId())) {
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) {
|
||||
ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||
if (itemInHand != null) {
|
||||
if (itemInHand.getType() != Config.controlItem) {
|
||||
@@ -37,7 +37,7 @@ public class RotationHandler implements Listener {
|
||||
|
||||
return;
|
||||
}
|
||||
final List<Entity> list = new ArrayList<>(SiegeEngines.trackedStands.get(player.getUniqueId()));
|
||||
final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId()));
|
||||
for (Entity ent : list) {
|
||||
if (ent != null) {
|
||||
SiegeEngine equipment = SiegeEngines.activeSiegeEngines.get(ent.getUniqueId());
|
||||
@@ -85,7 +85,7 @@ public class RotationHandler implements Listener {
|
||||
living.teleport(loc);
|
||||
equipment.ShowFireLocation(player);
|
||||
} else {
|
||||
SiegeEngines.trackedStands.get(player.getUniqueId()).remove(ent);
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId()).remove(ent);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user