Version 0.7.5

Added Mounting, Fixed Releasing from distance
This commit is contained in:
C_Corp2002 authored and GitHub committed 2024-01-27 13:39:52 -05:00
1 parent 7e1a4a6269
commit 9b30e0749f
11 files changed
+148 -56

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.github.alathra</groupId> <groupId>com.github.alathra</groupId>
<artifactId>SiegeEngines</artifactId> <artifactId>SiegeEngines</artifactId>
<version>0.7.2</version> <version>0.7.5</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SiegeEngines</name> <name>SiegeEngines</name>
@@ -8,6 +8,7 @@ import java.util.UUID;
import com.github.alathra.siegeengines.projectile.EntityProjectile; import com.github.alathra.siegeengines.projectile.EntityProjectile;
import com.github.alathra.siegeengines.projectile.FireworkProjectile; import com.github.alathra.siegeengines.projectile.FireworkProjectile;
import com.github.alathra.siegeengines.projectile.SiegeEngineProjectile; import com.github.alathra.siegeengines.projectile.SiegeEngineProjectile;
import com.github.alathra.siegeengines.listeners.ClickHandler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@@ -31,7 +32,7 @@ import org.jetbrains.annotations.NotNull;
public class SiegeEngine implements Cloneable { public class SiegeEngine implements Cloneable {
// Core variables // Core variables
public Boolean enabled; public boolean enabled;
public String id; public String id;
public String worldName; public String worldName;
public UUID entityId; public UUID entityId;
@@ -69,6 +70,7 @@ public class SiegeEngine implements Cloneable {
public boolean hasBaseStand; public boolean hasBaseStand;
public double baseStandOffset; public double baseStandOffset;
public int baseStandModelNumber; public int baseStandModelNumber;
public boolean canMount = false;
// Passed parameters // Passed parameters
public String name = "Unnammed SiegeEngine"; public String name = "Unnammed SiegeEngine";
@@ -375,9 +377,13 @@ public class SiegeEngine implements Cloneable {
} }
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean place(Entity player, Location l) { public boolean place(Entity player, Location l) {
return place(player,l,null);
}
@SuppressWarnings("deprecation")
public boolean place(Entity player, Location l, Entity mount) {
l.add(0.5, 0, 0.5); l.add(0.5, 0, 0.5);
NamespacedKey key = new NamespacedKey(SiegeEngines.getInstance(), "siege_engines"); NamespacedKey key = new NamespacedKey(SiegeEngines.getInstance(), "siege_engines");
if (this == null || !this.enabled) { if (this == null || !this.enabled) {
@@ -393,12 +399,13 @@ public class SiegeEngine implements Cloneable {
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 = "";
Entity entity3 = null;
this.ammoHolder = new SiegeEngineAmmoHolder(); this.ammoHolder = new SiegeEngineAmmoHolder();
if (this.hasBaseStand) { if (this.hasBaseStand) {
Location l2 = l; Location l2 = l;
l2.setY(l.getY() + this.baseStandOffset); l2.setY(l.getY() + this.baseStandOffset);
Entity entity3 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND); entity3 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
LivingEntity ent = (LivingEntity) entity3; LivingEntity ent = (LivingEntity) entity3;
ArmorStand stand = (ArmorStand) ent; ArmorStand stand = (ArmorStand) ent;
@@ -431,7 +438,6 @@ public class SiegeEngine implements Cloneable {
meta.setLore(Lore); meta.setLore(Lore);
item.setItemMeta(meta); item.setItemMeta(meta);
// entity3.addPassenger(entity2);
LivingEntity ent = (LivingEntity) entity2; LivingEntity ent = (LivingEntity) entity2;
ArmorStand stand = (ArmorStand) ent; ArmorStand stand = (ArmorStand) ent;
@@ -451,7 +457,7 @@ public class SiegeEngine implements Cloneable {
stand.setGravity(false); stand.setGravity(false);
ent.getEquipment().setHelmet(item); ent.getEquipment().setHelmet(item);
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) { /*if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) {
List<Entity> entities = SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId()); List<Entity> entities = SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId());
entities.add(entity2); entities.add(entity2);
SiegeEngines.siegeEngineEntitiesPerPlayer.put(player.getUniqueId(), entities); SiegeEngines.siegeEngineEntitiesPerPlayer.put(player.getUniqueId(), entities);
@@ -459,8 +465,13 @@ public class SiegeEngine implements Cloneable {
List<Entity> newList = new ArrayList<Entity>(); List<Entity> newList = new ArrayList<Entity>();
newList.add(entity2); newList.add(entity2);
SiegeEngines.siegeEngineEntitiesPerPlayer.put(player.getUniqueId(), newList); SiegeEngines.siegeEngineEntitiesPerPlayer.put(player.getUniqueId(), newList);
} }*/
SiegeEngines.activeSiegeEngines.put(entity2.getUniqueId(), this); SiegeEngines.activeSiegeEngines.put(entity2.getUniqueId(), this);
ClickHandler.TakeControl(player,entity2);
if (mount != null && !(mount.isDead())) {
entity2.setGravity(true);
mount.addPassenger(entity2);
}
return true; return true;
} }
} }
@@ -114,6 +114,7 @@ public class SiegeEngines extends JavaPlugin {
trebuchet.firingModelNumbers = new ArrayList<>( trebuchet.firingModelNumbers = new ArrayList<>(
Arrays.asList(123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139)); Arrays.asList(123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139));
trebuchet.cycleThroughModelsWhileFiring = true; trebuchet.cycleThroughModelsWhileFiring = true;
trebuchet.canMount = Config.trebuchetCanMount;
definedSiegeEngines.put(trebuchet.readyModelNumber, trebuchet); definedSiegeEngines.put(trebuchet.readyModelNumber, trebuchet);
// Ballista // Ballista
@@ -136,6 +137,7 @@ public class SiegeEngines extends JavaPlugin {
ballista.preFireModelNumber = 143; ballista.preFireModelNumber = 143;
ballista.firingModelNumbers = new ArrayList<>(Arrays.asList(143, 144, 145)); ballista.firingModelNumbers = new ArrayList<>(Arrays.asList(143, 144, 145));
ballista.cycleThroughModelsWhileFiring = true; ballista.cycleThroughModelsWhileFiring = true;
ballista.canMount = Config.ballistaCanMount;
definedSiegeEngines.put(ballista.readyModelNumber, ballista); definedSiegeEngines.put(ballista.readyModelNumber, ballista);
// Siege Cannon // Siege Cannon
@@ -154,25 +156,27 @@ public class SiegeEngines extends JavaPlugin {
swivelCannon.firingModelNumbers = new ArrayList<Integer>(); swivelCannon.firingModelNumbers = new ArrayList<Integer>();
swivelCannon.rotateStandHead = true; swivelCannon.rotateStandHead = true;
swivelCannon.rotateSideways = true; swivelCannon.rotateSideways = true;
swivelCannon.canMount = Config.swivelCannonCanMount;
definedSiegeEngines.put(swivelCannon.readyModelNumber, swivelCannon); definedSiegeEngines.put(swivelCannon.readyModelNumber, swivelCannon);
// Naval Cannon // Naval Cannon
SiegeEngine beachCannon = new SiegeEngine("Breach Cannon", Config.breachCannonProjectiles, SiegeEngine breachCannon = new SiegeEngine("Breach Cannon", Config.breachCannonProjectiles,
new ItemStack(Material.GUNPOWDER), 142); new ItemStack(Material.GUNPOWDER), 142);
// config options // config options
beachCannon.shotAmount = Config.breachCannonShotAmount; breachCannon.shotAmount = Config.breachCannonShotAmount;
beachCannon.velocityPerFuel = Config.breachCannonVelocityPerFuel; breachCannon.velocityPerFuel = Config.breachCannonVelocityPerFuel;
beachCannon.maxFuel = Config.breachCannonMaxFuel; breachCannon.maxFuel = Config.breachCannonMaxFuel;
beachCannon.fuelItem = new ItemStack(Config.breachCannonFuelItem); breachCannon.fuelItem = new ItemStack(Config.breachCannonFuelItem);
beachCannon.projectiles = Config.breachCannonProjectiles; breachCannon.projectiles = Config.breachCannonProjectiles;
beachCannon.placementOffsetY = -1; breachCannon.placementOffsetY = -1;
beachCannon.readyModelNumber = 142; breachCannon.readyModelNumber = 142;
beachCannon.modelNumberToFireAt = 142; breachCannon.modelNumberToFireAt = 142;
beachCannon.firingModelNumbers = new ArrayList<Integer>(); breachCannon.firingModelNumbers = new ArrayList<Integer>();
beachCannon.rotateStandHead = true; breachCannon.rotateStandHead = true;
beachCannon.rotateSideways = false; breachCannon.rotateSideways = false;
definedSiegeEngines.put(beachCannon.readyModelNumber, beachCannon); breachCannon.canMount = Config.breachCannonCanMount;
definedSiegeEngines.put(breachCannon.readyModelNumber, breachCannon);
} }
} }
@@ -42,24 +42,28 @@ public class Config {
public static float trebuchetVelocityPerFuel = 0.3f; public static float trebuchetVelocityPerFuel = 0.3f;
public static int trebuchetMaxFuel = 3; public static int trebuchetMaxFuel = 3;
public static Material trebuchetFuelItem = Material.STRING; public static Material trebuchetFuelItem = Material.STRING;
public static boolean trebuchetCanMount = false;
public static HashMap<ItemStack, SiegeEngineProjectile> trebuchetProjectiles = new HashMap<>(); public static HashMap<ItemStack, SiegeEngineProjectile> trebuchetProjectiles = new HashMap<>();
public static int ballistaShotAmount = 1; public static int ballistaShotAmount = 1;
public static float ballistaVelocityPerFuel = 0.925f; public static float ballistaVelocityPerFuel = 0.925f;
public static int ballistaMaxFuel = 4; public static int ballistaMaxFuel = 4;
public static Material ballistaFuelItem = Material.STRING; public static Material ballistaFuelItem = Material.STRING;
public static boolean ballistaCanMount = false;
public static HashMap<ItemStack, SiegeEngineProjectile> ballistaProjectiles = new HashMap<>(); public static HashMap<ItemStack, SiegeEngineProjectile> ballistaProjectiles = new HashMap<>();
public static int swivelCannonShotAmount = 1; public static int swivelCannonShotAmount = 1;
public static float swivelCannonVelocityPerFuel = 1.0125f; public static float swivelCannonVelocityPerFuel = 1.0125f;
public static int swivelCannonMaxFuel = 5; public static int swivelCannonMaxFuel = 5;
public static Material swivelCannonFuelItem = Material.GUNPOWDER; public static Material swivelCannonFuelItem = Material.GUNPOWDER;
public static boolean swivelCannonCanMount = false;
public static HashMap<ItemStack, SiegeEngineProjectile> swivelCannonProjectiles = new HashMap<>(); public static HashMap<ItemStack, SiegeEngineProjectile> swivelCannonProjectiles = new HashMap<>();
public static int breachCannonShotAmount = 1; public static int breachCannonShotAmount = 1;
public static float breachCannonVelocityPerFuel = 1.075f; public static float breachCannonVelocityPerFuel = 1.075f;
public static int breachCannonMaxFuel = 4; public static int breachCannonMaxFuel = 4;
public static Material breachCannonFuelItem = Material.GUNPOWDER; public static Material breachCannonFuelItem = Material.GUNPOWDER;
public static boolean breachCannonCanMount = false;
public static HashMap<ItemStack, SiegeEngineProjectile> breachCannonProjectiles = new HashMap<>(); public static HashMap<ItemStack, SiegeEngineProjectile> breachCannonProjectiles = new HashMap<>();
@@ -108,6 +112,7 @@ public class Config {
trebuchetShotAmount = config.getInt("SiegeEngines.Trebuchet.ShotAmount"); trebuchetShotAmount = config.getInt("SiegeEngines.Trebuchet.ShotAmount");
trebuchetVelocityPerFuel = (float) config.getDouble("SiegeEngines.Trebuchet.VelocityPerFuel"); trebuchetVelocityPerFuel = (float) config.getDouble("SiegeEngines.Trebuchet.VelocityPerFuel");
trebuchetMaxFuel = config.getInt("SiegeEngines.Trebuchet.MaxFuel"); trebuchetMaxFuel = config.getInt("SiegeEngines.Trebuchet.MaxFuel");
trebuchetCanMount = config.getBoolean("SiegeEngines.Trebuchet.CanMount");
try { try {
trebuchetFuelItem = Material.getMaterial(config.getString("SiegeEngines.Trebuchet.FuelItem")); trebuchetFuelItem = Material.getMaterial(config.getString("SiegeEngines.Trebuchet.FuelItem"));
} catch (Exception e) { } catch (Exception e) {
@@ -124,6 +129,7 @@ public class Config {
ballistaShotAmount = config.getInt("SiegeEngines.Ballista.ShotAmount"); ballistaShotAmount = config.getInt("SiegeEngines.Ballista.ShotAmount");
ballistaVelocityPerFuel = (float) config.getDouble("SiegeEngines.Ballista.VelocityPerFuel"); ballistaVelocityPerFuel = (float) config.getDouble("SiegeEngines.Ballista.VelocityPerFuel");
ballistaMaxFuel = config.getInt("SiegeEngines.Ballista.MaxFuel"); ballistaMaxFuel = config.getInt("SiegeEngines.Ballista.MaxFuel");
ballistaCanMount = config.getBoolean("SiegeEngines.Ballista.CanMount");
try { try {
ballistaFuelItem = Material.getMaterial(config.getString("SiegeEngines.Ballista.FuelItem")); ballistaFuelItem = Material.getMaterial(config.getString("SiegeEngines.Ballista.FuelItem"));
} catch (Exception e) { } catch (Exception e) {
@@ -140,6 +146,7 @@ public class Config {
swivelCannonShotAmount = config.getInt("SiegeEngines.SwivelCannon.ShotAmount"); swivelCannonShotAmount = config.getInt("SiegeEngines.SwivelCannon.ShotAmount");
swivelCannonVelocityPerFuel = (float) config.getDouble("SiegeEngines.SwivelCannon.VelocityPerFuel"); swivelCannonVelocityPerFuel = (float) config.getDouble("SiegeEngines.SwivelCannon.VelocityPerFuel");
swivelCannonMaxFuel = config.getInt("SiegeEngines.SwivelCannon.MaxFuel"); swivelCannonMaxFuel = config.getInt("SiegeEngines.SwivelCannon.MaxFuel");
swivelCannonCanMount = config.getBoolean("SiegeEngines.SwivelCannon.CanMount");
try { try {
swivelCannonFuelItem = Material.getMaterial(config.getString("SiegeEngines.SwivelCannon.FuelItem")); swivelCannonFuelItem = Material.getMaterial(config.getString("SiegeEngines.SwivelCannon.FuelItem"));
} catch (Exception e) { } catch (Exception e) {
@@ -156,6 +163,7 @@ public class Config {
breachCannonShotAmount = config.getInt("SiegeEngines.BreachCannon.ShotAmount"); breachCannonShotAmount = config.getInt("SiegeEngines.BreachCannon.ShotAmount");
breachCannonVelocityPerFuel = (float) config.getDouble("SiegeEngines.BreachCannon.VelocityPerFuel"); breachCannonVelocityPerFuel = (float) config.getDouble("SiegeEngines.BreachCannon.VelocityPerFuel");
breachCannonMaxFuel = config.getInt("SiegeEngines.BreachCannon.MaxFuel"); breachCannonMaxFuel = config.getInt("SiegeEngines.BreachCannon.MaxFuel");
breachCannonCanMount = config.getBoolean("SiegeEngines.BreachCannon.CanMount");
try { try {
breachCannonFuelItem = Material.getMaterial(config.getString("SiegeEngines.BreachCannon.FuelItem")); breachCannonFuelItem = Material.getMaterial(config.getString("SiegeEngines.BreachCannon.FuelItem"));
} catch (Exception e) { } catch (Exception e) {
@@ -3,6 +3,7 @@ package com.github.alathra.siegeengines.listeners;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
@@ -678,14 +679,13 @@ public class ClickHandler implements Listener {
} }
} }
// Can only have one pilot // Can only have one pilot
final List<UUID> keys = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.keySet()); final HashSet<UUID> keys = new HashSet<>(SiegeEngines.siegeEngineEntitiesPerPlayer.keySet());
int numPilots = 0; int numPilots = 0;
for (UUID uuid : keys) { for (UUID uuid : keys) {
if (uuid.equals(player.getUniqueId())) { if (uuid.equals(player.getUniqueId())) {
continue; continue;
} }
numPilots++; numPilots++;
} }
if (numPilots > 1) { if (numPilots > 1) {
if (player instanceof Player) if (player instanceof Player)
@@ -693,11 +693,12 @@ public class ClickHandler implements Listener {
return; return;
} }
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId()) != null) { if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) {
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId()) if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId())
.size() >= Config.maxSiegeEnginesControlled) { .size() > Config.maxSiegeEnginesControlled) {
if (player instanceof Player) { if (player instanceof Player) {
((Player) player).sendMessage("§eYou are already commanding too many Siege Engines!"); ((Player) player).sendMessage("§eYou are already commanding too many Siege Engines!");
PlayerHandler.releasePlayerSiegeEngine(((Player) player),entity);
} }
return; return;
} }
@@ -1031,7 +1032,7 @@ public class ClickHandler implements Listener {
if (entity.getType() == EntityType.ARMOR_STAND) { if (entity.getType() == EntityType.ARMOR_STAND) {
if ((itemInHand.getType() == Material.AIR || itemInHand == null)) { if ((itemInHand.getType() == Material.AIR || itemInHand == null)) {
if (player.isSneaking()) { if (player.isSneaking()) {
if (isSiegeEngine(entity, false)) PlayerHandler.releasePlayerSiegeEngine(player,entity); if (isSiegeEngine(entity, false)) PlayerHandler.siegeEngineEntityDied(entity);
else PlayerHandler.releasePlayerSiegeEngine(player,null); else PlayerHandler.releasePlayerSiegeEngine(player,null);
if (SiegeEngines.activeSiegeEngines.containsKey(entity.getUniqueId())) { if (SiegeEngines.activeSiegeEngines.containsKey(entity.getUniqueId())) {
SiegeEngines.activeSiegeEngines.remove(entity.getUniqueId()); SiegeEngines.activeSiegeEngines.remove(entity.getUniqueId());
@@ -1109,5 +1110,62 @@ public class ClickHandler implements Listener {
} }
} }
} }
if (entity.getType() == EntityType.RAVAGER || entity.getType() == EntityType.HORSE || entity.getType() == EntityType.DONKEY) {
if (player.getInventory().getItemInMainHand().getType() == Material.CARVED_PUMPKIN) {
final ItemStack item = player.getInventory().getItemInMainHand();
if (item.getItemMeta() != null && item.getItemMeta().hasCustomModelData()) {
int customModel = item.getItemMeta().getCustomModelData();
SiegeEngine siegeEngine = null;
// Search for match in custom model data value in defined siege engines
for (SiegeEngine entry : SiegeEngines.definedSiegeEngines.values()) {
if (entry.customModelID == customModel) {
try {
siegeEngine = entry.clone();
} catch (CloneNotSupportedException e) {
}
break;
} else {
// if siege engine was broken during one of its firing stages
if (entry.firingModelNumbers.contains(customModel)) {
try {
siegeEngine = entry.clone();
} catch (CloneNotSupportedException e) {
break;
}
}
}
}
// If SiegeEngine found, place it
if (siegeEngine != null) {
if (!siegeEngine.canMount) {
player.sendMessage("§eThis type of Siege Engine cannot be mounted to mobs.");
event.setCancelled(true);
return;
}
if (Config.disabledWorlds.contains(entity.getWorld())) {
player.sendMessage("§eSiege Engines cannot be placed in this World.");
event.setCancelled(true);
}
if (fluidMaterials.contains(entity.getLocation().getBlock().getType())) {
player.sendMessage("§eSiege Engines cannot be placed in Fluid Blocks.");
event.setCancelled(true);
}
if (event.isCancelled()) {
return;
}
if (siegeEngine.place(player, entity.getLocation(),entity)) {
item.setAmount(item.getAmount() - 1);
player.getInventory().setItemInMainHand(item);
player.sendMessage("§eSiege Engine mounted to the "+entity.getType().toString().toLowerCase()+"!");
} else {
player.sendMessage(
"§eSiege Engine cannot be placed within a 2.5 Block-Radius of other Siege Engines.");
}
event.setCancelled(true);
}
}
}
return;
}
} }
} }
@@ -35,25 +35,31 @@ public class PlayerHandler implements Listener {
final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid)); final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid));
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid).contains(entity.getUniqueId())) { if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid).contains(entity.getUniqueId())) {
list.remove(entity); list.remove(entity);
SiegeEngines.activeSiegeEngines.remove(entity.getUniqueId());
SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list); SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list);
} }
} }
} }
} }
public static void playerJoinLeave(Player player) { public static void playerJoinLeave(Player player) {
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) { if (player == null) return;
final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId())); final UUID uuid = player.getUniqueId();
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(uuid)) {
final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid));
list.clear(); list.clear();
SiegeEngines.siegeEngineEntitiesPerPlayer.put(player.getUniqueId(),list); SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list);
SiegeEngines.siegeEngineEntitiesPerPlayer.remove(uuid);
} }
} }
public static void releasePlayerSiegeEngine(Player player, Entity entity) { public static void releasePlayerSiegeEngine(Player player, Entity entity) {
UUID uuid = player.getUniqueId(); if (player == null) return;
final UUID uuid = player.getUniqueId();
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(uuid)) { if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(uuid)) {
final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid)); final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid));
if (entity != null) { if (entity != null) {
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid).contains(entity.getUniqueId())) { if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid).contains(entity.getUniqueId())) {
list.remove(entity); list.remove(entity);
SiegeEngines.activeSiegeEngines.remove(entity.getUniqueId());
SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list); SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list);
player.sendMessage("§eReleased this SiegeEngine!"); player.sendMessage("§eReleased this SiegeEngine!");
} }
@@ -62,6 +68,7 @@ public class PlayerHandler implements Listener {
list.clear(); list.clear();
player.sendMessage("§eReleased all SiegeEngines!"); player.sendMessage("§eReleased all SiegeEngines!");
SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list); SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list);
SiegeEngines.siegeEngineEntitiesPerPlayer.remove(uuid);
} }
} }
} }
@@ -70,7 +70,7 @@ public class RotationHandler implements Listener {
Entity base = Bukkit.getEntity(UUID.fromString(ent.getPersistentDataContainer().get(key, PersistentDataType.STRING))); Entity base = Bukkit.getEntity(UUID.fromString(ent.getPersistentDataContainer().get(key, PersistentDataType.STRING)));
Location baseloc = base.getLocation(); Location baseloc = base.getLocation();
baseloc.setDirection(dirBetweenLocations); baseloc.setDirection(dirBetweenLocations);
base.teleport(baseloc); base.teleport(baseloc,io.papermc.paper.entity.TeleportFlag.EntityState.values());
} }
loc.setDirection(dirBetweenLocations); loc.setDirection(dirBetweenLocations);
} }
@@ -92,7 +92,7 @@ public class RotationHandler implements Listener {
} }
living.teleport(loc); living.teleport(loc,io.papermc.paper.entity.TeleportFlag.EntityState.values());
equipment.ShowFireLocation(player); equipment.ShowFireLocation(player);
} }
} }
@@ -24,7 +24,7 @@ public class EntityProjectile extends SiegeEngineProjectile {
public int delayTime = 6; public int delayTime = 6;
public EntityType entityType = EntityType.ARROW; public EntityType entityType = EntityType.ARROW;
public float inaccuracy = 0.2f; public float inaccuracy = 0.2f;
public Particle particleType = Particle.EXPLOSION_LARGE; public Particle particleType = Particle.CAMPFIRE_SIGNAL_SMOKE;
public Sound soundType = Sound.ENTITY_GENERIC_EXPLODE; public Sound soundType = Sound.ENTITY_GENERIC_EXPLODE;
private boolean playSound = true; private boolean playSound = true;
@@ -62,7 +62,6 @@ public class EntityProjectile extends SiegeEngineProjectile {
arrow.setVelocity(loc.getDirection().multiply(velocity)); arrow.setVelocity(loc.getDirection().multiply(velocity));
} }
arrow.setMetadata("isEntityProj", SiegeEnginesUtil.addMetaDataValue("true")); arrow.setMetadata("isEntityProj", SiegeEnginesUtil.addMetaDataValue("true"));
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
if (arrow instanceof org.bukkit.entity.Projectile) { if (arrow instanceof org.bukkit.entity.Projectile) {
if (player instanceof org.bukkit.projectiles.ProjectileSource) if (player instanceof org.bukkit.projectiles.ProjectileSource)
@@ -75,6 +74,8 @@ public class EntityProjectile extends SiegeEngineProjectile {
arr.setShooter((org.bukkit.projectiles.ProjectileSource) player); arr.setShooter((org.bukkit.projectiles.ProjectileSource) player);
arr.setPickupStatus(org.bukkit.entity.AbstractArrow.PickupStatus.CREATIVE_ONLY); arr.setPickupStatus(org.bukkit.entity.AbstractArrow.PickupStatus.CREATIVE_ONLY);
} }
} else {
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
} }
if (playSound) { if (playSound) {
world.playSound(loc, this.soundType, 20, 2); world.playSound(loc, this.soundType, 20, 2);
@@ -23,7 +23,7 @@ public class FireworkProjectile extends SiegeEngineProjectile {
public int delayTime = 6; public int delayTime = 6;
public EntityType entityType = EntityType.FIREWORK; public EntityType entityType = EntityType.FIREWORK;
public float inaccuracy = 0.125f; public float inaccuracy = 0.125f;
public Particle particleType = Particle.EXPLOSION_NORMAL; public Particle particleType = Particle.FLASH;
public Sound soundType = Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR; public Sound soundType = Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR;
public float velocityFactor = 0.5f; public float velocityFactor = 0.5f;
@@ -57,7 +57,7 @@ public class PotionProjectile extends SiegeEngineProjectile {
} else { } else {
arrow.setVelocity(loc.getDirection().multiply(velocity)); arrow.setVelocity(loc.getDirection().multiply(velocity));
} }
arrow.setMetadata("isExplosiveProj", SiegeEnginesUtil.addMetaDataValue("true")); arrow.setMetadata("isPotionProj", SiegeEnginesUtil.addMetaDataValue("true"));
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow)); Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
ItemStack itemStack = new ItemStack(Material.SPLASH_POTION); ItemStack itemStack = new ItemStack(Material.SPLASH_POTION);
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta(); PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
+24 -21
View File
@@ -15,19 +15,20 @@ config-version: 1
ControlItem: CLOCK ControlItem: CLOCK
# The maxmimum distance the player can be away from the SiegeEngine before total control is terminated # The maxmimum distance the player can be away from the SiegeEngine before total control is terminated
ControlDistance: 64 ControlDistance: 24
# The maximum distance the player can be away from the SiegeEngine before rotation control is terminated # The maximum distance the player can be away from the SiegeEngine before rotation control is terminated
RotateDistance: 32 RotateDistance: 16
# The maximum siege engines a player can control at the same time # The maximum siege engines a player can control at the same time
MaxSiegeEnginesControlled: 2 MaxSiegeEnginesControlled: 1
# The auto-reload feature by shift-clicking # The auto-reload feature by shift-clicking
AutoReload: false AutoReload: false
DisabledWorlds: DisabledWorlds:
- world_nether - world_nether
- World-o_nether
# ====================================== # ======================================
# | SiegeEngine Options | # | SiegeEngine Options |
@@ -36,43 +37,43 @@ DisabledWorlds:
Projectiles: Projectiles:
StoneShot: StoneShot:
ProjectileType: EXPLOSIVE ProjectileType: EXPLOSIVE
ExplodePower: 1.5 ExplodePower: 3.25
Inaccuracy: 0.125 Inaccuracy: 0.125
ProjectileCount: 1 ProjectileCount: 1
AmmoItem: COBBLESTONE AmmoItem: COBBLESTONE
FireSound: ENTITY_GENERIC_EXPLODE FireSound: ENTITY_GENERIC_EXPLODE
BreachShot: BreachShot:
ProjectileType: EXPLOSIVE ProjectileType: EXPLOSIVE
ExplodePower: 3.75 ExplodePower: 5.25
Inaccuracy: 0.3 Inaccuracy: 0.375
ProjectileCount: 1 ProjectileCount: 1
AmmoItem: IRON_BLOCK AmmoItem: IRON_BLOCK
FireSound: ENTITY_GENERIC_EXPLODE FireSound: ENTITY_GENERIC_EXPLODE
RepeatingShot: RepeatingShot:
ProjectileType: EXPLOSIVE ProjectileType: EXPLOSIVE
ExplodePower: 1.0 ExplodePower: 1.75
Inaccuracy: 0.325 Inaccuracy: 0.525
ProjectileCount: 5 ProjectileCount: 6
AmmoItem: TNT AmmoItem: TNT
FireSound: ENTITY_GENERIC_EXPLODE FireSound: ENTITY_GENERIC_EXPLODE
ScatterShot: ScatterShot:
ProjectileType: ENTITY ProjectileType: ENTITY
Inaccuracy: 0.325 Inaccuracy: 0.365
EntityCount: 24 EntityCount: 24
EntityType: ARROW EntityType: ARROW
AmmoItem: GRAVEL AmmoItem: GRAVEL
FireSound: ENTITY_GENERIC_EXPLODE FireSound: ITEM_CROSSBOW_SHOOT
BallistaBoltShot: BallistaBoltShot:
ProjectileType: ENTITY ProjectileType: ENTITY
Inaccuracy: 0.025 Inaccuracy: 0.0125
EntityCount: 1 EntityCount: 1
EntityType: ARROW EntityType: ARROW
AmmoItem: ARROW AmmoItem: ARROW
FireSound: ITEM_CROSSBOW_SHOOT FireSound: ITEM_CROSSBOW_SHOOT
DragonsBreath: DragonsBreath:
ProjectileType: ENTITY ProjectileType: ENTITY
Inaccuracy: 0.25 Inaccuracy: 0.125
EntityCount: 3 EntityCount: 1
EntityType: DRAGON_FIREBALL EntityType: DRAGON_FIREBALL
AmmoItem: DRAGON_BREATH AmmoItem: DRAGON_BREATH
FireSound: ENTITY_GENERIC_EXPLODE FireSound: ENTITY_GENERIC_EXPLODE
@@ -93,7 +94,7 @@ Projectiles:
SiegeEngines: SiegeEngines:
Trebuchet: Trebuchet:
ShotAmount: 1 ShotAmount: 1
VelocityPerFuel: 0.3 VelocityPerFuel: 0.75
MaxFuel: 3 MaxFuel: 3
FuelItem: STRING FuelItem: STRING
Projectiles: Projectiles:
@@ -101,9 +102,10 @@ SiegeEngines:
- BreachShot - BreachShot
- FireShot - FireShot
- RepeatingShot - RepeatingShot
CanMount: false
Ballista: Ballista:
ShotAmount: 1 ShotAmount: 1
VelocityPerFuel: 1.25 VelocityPerFuel: 0.975
MaxFuel: 2 MaxFuel: 2
FuelItem: STRING FuelItem: STRING
Projectiles: Projectiles:
@@ -111,25 +113,26 @@ SiegeEngines:
- ScatterShot - ScatterShot
- DragonsBreath - DragonsBreath
- FireworkShot - FireworkShot
CanMount: false
SwivelCannon: SwivelCannon:
ShotAmount: 1 ShotAmount: 1
VelocityPerFuel: 1.0125 VelocityPerFuel: 0.975
MaxFuel: 5 MaxFuel: 5
FuelItem: GUNPOWDER FuelItem: GUNPOWDER
Projectiles: Projectiles:
- StoneShot - StoneShot
- RepeatingShot
- ScatterShot - ScatterShot
- FireShot - FireShot
- FireworkShot - FireworkShot
CanMount: false
BreachCannon: BreachCannon:
ShotAmount: 1 ShotAmount: 1
VelocityPerFuel: 0.975 VelocityPerFuel: 1.0625
MaxFuel: 4 MaxFuel: 4
FuelItem: GUNPOWDER FuelItem: GUNPOWDER
Projectiles: Projectiles:
- StoneShot - StoneShot
- RepeatingShot - RepeatingShot
- BreachShot - BreachShot
- FireShot CanMount: false
- FireworkShot