mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-01 14:38:55 +00:00
Merge branch 'ccorp2002-edits2' into sherman
This commit is contained in:
commit
f5ff5f7afd
11 files changed
+204
-95
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.github.alathra</groupId>
|
||||
<artifactId>SiegeEngines</artifactId>
|
||||
<version>0.7.1</version>
|
||||
<version>0.7.5</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<name>SiegeEngines</name>
|
||||
|
||||
@@ -9,9 +9,9 @@ import com.github.alathra.siegeengines.projectile.EntityProjectile;
|
||||
import com.github.alathra.siegeengines.projectile.FireworkProjectile;
|
||||
import com.github.alathra.siegeengines.projectile.SiegeEngineProjectile;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import com.github.alathra.siegeengines.listeners.ClickHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -75,6 +75,7 @@ public class SiegeEngine implements Cloneable {
|
||||
public boolean hasBaseStand;
|
||||
public double baseStandOffset;
|
||||
public int baseStandModelNumber;
|
||||
public boolean canMount = false;
|
||||
|
||||
// Passed parameters
|
||||
public String name = "Unnammed SiegeEngine";
|
||||
@@ -384,9 +385,13 @@ public class SiegeEngine implements Cloneable {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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);
|
||||
NamespacedKey key = new NamespacedKey(SiegeEngines.getInstance(), "siege_engines");
|
||||
if (this == null || !this.enabled) {
|
||||
@@ -402,12 +407,13 @@ public class SiegeEngine implements Cloneable {
|
||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
String id = "";
|
||||
Entity entity3 = null;
|
||||
this.ammoHolder = new SiegeEngineAmmoHolder();
|
||||
if (this.hasBaseStand) {
|
||||
|
||||
Location l2 = l;
|
||||
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;
|
||||
ArmorStand stand = (ArmorStand) ent;
|
||||
@@ -438,7 +444,6 @@ public class SiegeEngine implements Cloneable {
|
||||
meta.setLore(this.itemLore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
// entity3.addPassenger(entity2);
|
||||
|
||||
LivingEntity ent = (LivingEntity) entity2;
|
||||
ArmorStand stand = (ArmorStand) ent;
|
||||
@@ -458,7 +463,7 @@ public class SiegeEngine implements Cloneable {
|
||||
|
||||
stand.setGravity(false);
|
||||
ent.getEquipment().setHelmet(item);
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) {
|
||||
/*if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) {
|
||||
List<Entity> entities = SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId());
|
||||
entities.add(entity2);
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.put(player.getUniqueId(), entities);
|
||||
@@ -466,8 +471,13 @@ public class SiegeEngine implements Cloneable {
|
||||
List<Entity> newList = new ArrayList<Entity>();
|
||||
newList.add(entity2);
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.put(player.getUniqueId(), newList);
|
||||
}
|
||||
}*/
|
||||
SiegeEngines.activeSiegeEngines.put(entity2.getUniqueId(), this);
|
||||
ClickHandler.TakeControl(player,entity2);
|
||||
if (mount != null && !(mount.isDead())) {
|
||||
entity2.setGravity(true);
|
||||
mount.addPassenger(entity2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -130,6 +130,7 @@ public class SiegeEngines extends JavaPlugin {
|
||||
trebuchet.firingModelNumbers = new ArrayList<>(
|
||||
Arrays.asList(123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139));
|
||||
trebuchet.cycleThroughModelsWhileFiring = true;
|
||||
trebuchet.canMount = Config.trebuchetCanMount;
|
||||
definedSiegeEngines.put(trebuchet.readyModelNumber, trebuchet);
|
||||
|
||||
// Ballista
|
||||
@@ -155,6 +156,7 @@ public class SiegeEngines extends JavaPlugin {
|
||||
ballista.preFireModelNumber = 143;
|
||||
ballista.firingModelNumbers = new ArrayList<>(Arrays.asList(143, 144, 145));
|
||||
ballista.cycleThroughModelsWhileFiring = true;
|
||||
ballista.canMount = Config.ballistaCanMount;
|
||||
definedSiegeEngines.put(ballista.readyModelNumber, ballista);
|
||||
|
||||
// Siege Cannon
|
||||
@@ -175,27 +177,30 @@ public class SiegeEngines extends JavaPlugin {
|
||||
swivelCannon.firingModelNumbers = new ArrayList<Integer>();
|
||||
swivelCannon.rotateStandHead = true;
|
||||
swivelCannon.rotateSideways = true;
|
||||
swivelCannon.canMount = Config.swivelCannonCanMount;
|
||||
definedSiegeEngines.put(swivelCannon.readyModelNumber, swivelCannon);
|
||||
|
||||
// Naval Cannon
|
||||
SiegeEngine beachCannon = new SiegeEngine("Breach Cannon", Config.breachCannonProjectiles,
|
||||
SiegeEngine breachCannon = new SiegeEngine("Breach Cannon", Config.breachCannonProjectiles,
|
||||
new ItemStack(Material.GUNPOWDER), 142);
|
||||
// config options
|
||||
beachCannon.type = SiegeEngineType.BREACH_CANNON;
|
||||
beachCannon.itemName = Config.breachCannonItemName;
|
||||
beachCannon.itemLore = Config.breachCannonItemLore;
|
||||
beachCannon.shotAmount = Config.breachCannonShotAmount;
|
||||
beachCannon.velocityPerFuel = Config.breachCannonVelocityPerFuel;
|
||||
beachCannon.maxFuel = Config.breachCannonMaxFuel;
|
||||
beachCannon.fuelItem = new ItemStack(Config.breachCannonFuelItem);
|
||||
beachCannon.projectiles = Config.breachCannonProjectiles;
|
||||
beachCannon.placementOffsetY = -1;
|
||||
beachCannon.readyModelNumber = 142;
|
||||
beachCannon.modelNumberToFireAt = 142;
|
||||
beachCannon.firingModelNumbers = new ArrayList<Integer>();
|
||||
beachCannon.rotateStandHead = true;
|
||||
beachCannon.rotateSideways = false;
|
||||
definedSiegeEngines.put(beachCannon.readyModelNumber, beachCannon);
|
||||
breachCannon.type = SiegeEngineType.BREACH_CANNON;
|
||||
breachCannon.itemName = Config.breachCannonItemName;
|
||||
breachCannon.itemLore = Config.breachCannonItemLore;
|
||||
breachCannon.shotAmount = Config.breachCannonShotAmount;
|
||||
breachCannon.velocityPerFuel = Config.breachCannonVelocityPerFuel;
|
||||
breachCannon.maxFuel = Config.breachCannonMaxFuel;
|
||||
breachCannon.fuelItem = new ItemStack(Config.breachCannonFuelItem);
|
||||
breachCannon.projectiles = Config.breachCannonProjectiles;
|
||||
breachCannon.placementOffsetY = -1;
|
||||
breachCannon.readyModelNumber = 142;
|
||||
breachCannon.modelNumberToFireAt = 142;
|
||||
breachCannon.firingModelNumbers = new ArrayList<Integer>();
|
||||
breachCannon.rotateStandHead = true;
|
||||
breachCannon.rotateSideways = false;
|
||||
breachCannon.canMount = Config.breachCannonCanMount;
|
||||
definedSiegeEngines.put(breachCannon.readyModelNumber, breachCannon);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package com.github.alathra.siegeengines.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -19,8 +23,6 @@ import com.github.alathra.siegeengines.projectile.FireworkProjectile;
|
||||
import com.github.alathra.siegeengines.projectile.ProjectileType;
|
||||
import com.github.alathra.siegeengines.projectile.SiegeEngineProjectile;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class Config {
|
||||
|
||||
private static FileConfiguration config;
|
||||
@@ -34,11 +36,15 @@ public class Config {
|
||||
public static int maxSiegeEnginesControlled = 5;
|
||||
public static boolean autoReload = false;
|
||||
|
||||
|
||||
public static HashSet<World> disabledWorlds = new HashSet<>();
|
||||
|
||||
// Siege Engine Options - Defaults
|
||||
public static int trebuchetShotAmount = 1;
|
||||
public static float trebuchetVelocityPerFuel = 0.3f;
|
||||
public static int trebuchetMaxFuel = 3;
|
||||
public static Material trebuchetFuelItem = Material.STRING;
|
||||
public static boolean trebuchetCanMount = false;
|
||||
public static HashMap<ItemStack, SiegeEngineProjectile> trebuchetProjectiles = new HashMap<>();
|
||||
public static String trebuchetItemName = "&e&oTrebuchet";
|
||||
public static List<String> trebuchetItemLore;
|
||||
@@ -47,6 +53,7 @@ public class Config {
|
||||
public static float ballistaVelocityPerFuel = 0.925f;
|
||||
public static int ballistaMaxFuel = 4;
|
||||
public static Material ballistaFuelItem = Material.STRING;
|
||||
public static boolean ballistaCanMount = false;
|
||||
public static HashMap<ItemStack, SiegeEngineProjectile> ballistaProjectiles = new HashMap<>();
|
||||
public static String ballistaItemName = "&e&oBallista";
|
||||
public static List<String> ballistaItemLore;
|
||||
@@ -55,6 +62,7 @@ public class Config {
|
||||
public static float swivelCannonVelocityPerFuel = 1.0125f;
|
||||
public static int swivelCannonMaxFuel = 5;
|
||||
public static Material swivelCannonFuelItem = Material.GUNPOWDER;
|
||||
public static boolean swivelCannonCanMount = false;
|
||||
public static HashMap<ItemStack, SiegeEngineProjectile> swivelCannonProjectiles = new HashMap<>();
|
||||
public static String swivelCannonItemName = "&e&oSwivel Cannon";
|
||||
public static List<String> swivelCannonItemLore;
|
||||
@@ -63,6 +71,7 @@ public class Config {
|
||||
public static float breachCannonVelocityPerFuel = 1.075f;
|
||||
public static int breachCannonMaxFuel = 4;
|
||||
public static Material breachCannonFuelItem = Material.GUNPOWDER;
|
||||
public static boolean breachCannonCanMount = false;
|
||||
public static HashMap<ItemStack, SiegeEngineProjectile> breachCannonProjectiles = new HashMap<>();
|
||||
public static String breachCannonItemName = "&e&oBreach Cannon";
|
||||
public static List<String> breachCannonItemLore;
|
||||
@@ -124,6 +133,7 @@ public class Config {
|
||||
ballistaShotAmount = config.getInt("SiegeEngines.Ballista.ShotAmount");
|
||||
ballistaVelocityPerFuel = (float) config.getDouble("SiegeEngines.Ballista.VelocityPerFuel");
|
||||
ballistaMaxFuel = config.getInt("SiegeEngines.Ballista.MaxFuel");
|
||||
ballistaCanMount = config.getBoolean("SiegeEngines.Ballista.CanMount");
|
||||
try {
|
||||
ballistaFuelItem = Material.getMaterial(config.getString("SiegeEngines.Ballista.FuelItem"));
|
||||
} catch (Exception e) {
|
||||
@@ -149,6 +159,7 @@ public class Config {
|
||||
swivelCannonShotAmount = config.getInt("SiegeEngines.SwivelCannon.ShotAmount");
|
||||
swivelCannonVelocityPerFuel = (float) config.getDouble("SiegeEngines.SwivelCannon.VelocityPerFuel");
|
||||
swivelCannonMaxFuel = config.getInt("SiegeEngines.SwivelCannon.MaxFuel");
|
||||
swivelCannonCanMount = config.getBoolean("SiegeEngines.SwivelCannon.CanMount");
|
||||
try {
|
||||
swivelCannonFuelItem = Material.getMaterial(config.getString("SiegeEngines.SwivelCannon.FuelItem"));
|
||||
} catch (Exception e) {
|
||||
@@ -174,6 +185,7 @@ public class Config {
|
||||
breachCannonShotAmount = config.getInt("SiegeEngines.BreachCannon.ShotAmount");
|
||||
breachCannonVelocityPerFuel = (float) config.getDouble("SiegeEngines.BreachCannon.VelocityPerFuel");
|
||||
breachCannonMaxFuel = config.getInt("SiegeEngines.BreachCannon.MaxFuel");
|
||||
breachCannonCanMount = config.getBoolean("SiegeEngines.BreachCannon.CanMount");
|
||||
try {
|
||||
breachCannonFuelItem = Material.getMaterial(config.getString("SiegeEngines.BreachCannon.FuelItem"));
|
||||
} catch (Exception e) {
|
||||
@@ -196,11 +208,23 @@ public class Config {
|
||||
}
|
||||
|
||||
private static void loadSiegeEngineConfig() {
|
||||
|
||||
|
||||
loadTrebuchetValues();
|
||||
loadBallistaValues();
|
||||
loadSwivelCannonValues();
|
||||
loadBreachCannonValues();
|
||||
|
||||
try {
|
||||
for (String worldName : config.getStringList("DisabledWorlds")) {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world != null) {
|
||||
disabledWorlds.add(world);
|
||||
}
|
||||
}
|
||||
SiegeEnginesLogger.info("Disabled in worlds: "+ config.getStringList("DisabledWorlds"));
|
||||
} catch (Exception e) {
|
||||
SiegeEnginesLogger.warn("Missing Disabled Worlds-List");
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadProjectilesConfig() {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.github.alathra.siegeengines.listeners;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
@@ -158,6 +159,10 @@ public class ClickHandler implements Listener {
|
||||
}
|
||||
// If SiegeEngine found, place it
|
||||
if (siegeEngine != null) {
|
||||
if (Config.disabledWorlds.contains(thePlayer.getWorld())) {
|
||||
thePlayer.sendMessage("§eSiege Engines cannot be placed in this World.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (fluidMaterials.contains(replaced)) {
|
||||
thePlayer.sendMessage("§eSiege Engines cannot be placed in Fluid Blocks.");
|
||||
event.setCancelled(true);
|
||||
@@ -591,11 +596,12 @@ public class ClickHandler implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void damage(EntityDamageByEntityEvent event) {
|
||||
public void onProjectileDamage(EntityDamageByEntityEvent event) {
|
||||
if (event.getEntity() instanceof ArmorStand) {
|
||||
if (event.getDamager() instanceof Projectile) {
|
||||
event.setDamage(0);
|
||||
event.setCancelled(true);
|
||||
if (isSiegeEngine(event.getEntity(),false)) {
|
||||
if (event.getDamager() instanceof Projectile) {
|
||||
event.setDamage(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -673,14 +679,13 @@ public class ClickHandler implements Listener {
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
for (UUID uuid : keys) {
|
||||
if (uuid.equals(player.getUniqueId())) {
|
||||
continue;
|
||||
}
|
||||
numPilots++;
|
||||
|
||||
}
|
||||
if (numPilots > 1) {
|
||||
if (player instanceof Player)
|
||||
@@ -688,11 +693,12 @@ public class ClickHandler implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId()) != null) {
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) {
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId())
|
||||
.size() >= Config.maxSiegeEnginesControlled) {
|
||||
.size() > Config.maxSiegeEnginesControlled) {
|
||||
if (player instanceof Player) {
|
||||
((Player) player).sendMessage("§eYou are already commanding too many Siege Engines!");
|
||||
PlayerHandler.releasePlayerSiegeEngine(((Player) player),entity);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -832,8 +838,8 @@ public class ClickHandler implements Listener {
|
||||
|
||||
NamespacedKey key = new NamespacedKey(SiegeEngines.getInstance(), "siege_engines");
|
||||
|
||||
@EventHandler
|
||||
public void DeathEvent(EntityDeathEvent event) {
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
|
||||
public void onSiegeEngineDeathEvent(EntityDeathEvent event) {
|
||||
Boolean removeStands = false;
|
||||
List<ItemStack> items = event.getDrops();
|
||||
if (event.getEntity() instanceof ArmorStand) {
|
||||
@@ -864,16 +870,7 @@ public class ClickHandler implements Listener {
|
||||
}
|
||||
}
|
||||
if (removeStands) {
|
||||
for (UUID key : SiegeEngines.siegeEngineEntitiesPerPlayer.keySet()) {
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(key) != null) {
|
||||
final List<Entity> entities = new ArrayList<>(
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.get(key));
|
||||
if (entities.contains(event.getEntity())) {
|
||||
entities.remove(event.getEntity());
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.put(key, entities);
|
||||
}
|
||||
}
|
||||
}
|
||||
PlayerHandler.siegeEngineEntityDied(event.getEntity());
|
||||
for (ItemStack i : items) {
|
||||
if (i.getType() == Material.ARMOR_STAND) {
|
||||
i.setAmount(0);
|
||||
@@ -1035,7 +1032,7 @@ public class ClickHandler implements Listener {
|
||||
if (entity.getType() == EntityType.ARMOR_STAND) {
|
||||
if ((itemInHand.getType() == Material.AIR || itemInHand == null)) {
|
||||
if (player.isSneaking()) {
|
||||
if (isSiegeEngine(entity, false)) PlayerHandler.releasePlayerSiegeEngine(player,entity);
|
||||
if (isSiegeEngine(entity, false)) PlayerHandler.siegeEngineEntityDied(entity);
|
||||
else PlayerHandler.releasePlayerSiegeEngine(player,null);
|
||||
if (SiegeEngines.activeSiegeEngines.containsKey(entity.getUniqueId())) {
|
||||
SiegeEngines.activeSiegeEngines.remove(entity.getUniqueId());
|
||||
@@ -1113,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,35 +29,37 @@ public class PlayerHandler implements Listener {
|
||||
public void playerDeathEvent(PlayerDeathEvent event) {
|
||||
playerJoinLeave(event.getPlayer());
|
||||
}
|
||||
@EventHandler
|
||||
public void entityDeathEvent(EntityDeathEvent event) {
|
||||
siegeEngineEntityDied(event.getEntity());
|
||||
}
|
||||
public static void siegeEngineEntityDied(Entity entity) {
|
||||
for (UUID uuid : SiegeEngines.siegeEngineEntitiesPerPlayer.keySet()) {
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(uuid)) {
|
||||
final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid));
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid).contains(entity.getUniqueId())) {
|
||||
list.remove(entity);
|
||||
SiegeEngines.activeSiegeEngines.remove(entity.getUniqueId());
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void playerJoinLeave(Player player) {
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) {
|
||||
final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId()));
|
||||
if (player == null) return;
|
||||
final UUID uuid = player.getUniqueId();
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(uuid)) {
|
||||
final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid));
|
||||
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) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (player == null) return;
|
||||
final UUID uuid = player.getUniqueId();
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(uuid)) {
|
||||
final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid));
|
||||
if (entity != null) {
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid).contains(entity.getUniqueId())) {
|
||||
list.remove(entity);
|
||||
SiegeEngines.activeSiegeEngines.remove(entity.getUniqueId());
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list);
|
||||
player.sendMessage("§eReleased this SiegeEngine!");
|
||||
}
|
||||
@@ -66,6 +68,7 @@ public class PlayerHandler implements Listener {
|
||||
list.clear();
|
||||
player.sendMessage("§eReleased all SiegeEngines!");
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list);
|
||||
SiegeEngines.siegeEngineEntitiesPerPlayer.remove(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,30 +26,40 @@ import com.github.alathra.siegeengines.config.Config;
|
||||
public class RotationHandler implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void playerMove(PlayerMoveEvent event) {
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
NamespacedKey key = new NamespacedKey(SiegeEngines.getInstance(), "siege_engines");
|
||||
if (SiegeEngines.siegeEngineEntitiesPerPlayer.containsKey(player.getUniqueId())) {
|
||||
ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||
if (itemInHand != null) {
|
||||
if (itemInHand.getType() != Config.controlItem) {
|
||||
// TrackedStands.remove(player.getUniqueId());
|
||||
|
||||
return;
|
||||
}
|
||||
final List<Entity> list = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.get(player.getUniqueId()));
|
||||
final List<Entity> concurrentFix = new ArrayList<>(list);
|
||||
for (Entity ent : list) {
|
||||
if (ent != null) {
|
||||
SiegeEngine equipment = SiegeEngines.activeSiegeEngines.get(ent.getUniqueId());
|
||||
if (equipment == null) continue;
|
||||
final LivingEntity living = (LivingEntity) ent;
|
||||
if (Config.disabledWorlds.contains(ent.getWorld())) {
|
||||
PlayerHandler.siegeEngineEntityDied(ent);
|
||||
living.setHealth(0.0d);
|
||||
continue;
|
||||
}
|
||||
if (!(ent.getLocation().getWorld().equals(player.getLocation().getWorld()))) {
|
||||
PlayerHandler.releasePlayerSiegeEngine(player, ent);
|
||||
continue;
|
||||
}
|
||||
final double distance = player.getLocation().distance(ent.getLocation());
|
||||
if (distance >= Config.controlDistance) {
|
||||
PlayerHandler.releasePlayerSiegeEngine(player, ent);
|
||||
continue;
|
||||
}
|
||||
if (itemInHand.getType() != Config.controlItem) {
|
||||
continue;
|
||||
}
|
||||
if (ent.isDead()) {
|
||||
continue;
|
||||
}
|
||||
double distance = player.getLocation().distance(ent.getLocation());
|
||||
if (distance <= Config.rotateDistance) {
|
||||
// player.sendMessage("§egot id");
|
||||
LivingEntity living = (LivingEntity) ent;
|
||||
Location loc = ent.getLocation();
|
||||
|
||||
if (equipment.rotateSideways) {
|
||||
@@ -60,12 +70,10 @@ public class RotationHandler implements Listener {
|
||||
Entity base = Bukkit.getEntity(UUID.fromString(ent.getPersistentDataContainer().get(key, PersistentDataType.STRING)));
|
||||
Location baseloc = base.getLocation();
|
||||
baseloc.setDirection(dirBetweenLocations);
|
||||
base.teleport(baseloc);
|
||||
base.teleport(baseloc,io.papermc.paper.entity.TeleportFlag.EntityState.values());
|
||||
}
|
||||
loc.setDirection(dirBetweenLocations);
|
||||
}
|
||||
//loc.setYaw(player.getLocation().getYaw());
|
||||
//loc.setPitch(player.getLocation().getPitch());
|
||||
|
||||
|
||||
ArmorStand stand = (ArmorStand) living;
|
||||
@@ -84,11 +92,8 @@ public class RotationHandler implements Listener {
|
||||
}
|
||||
|
||||
|
||||
living.teleport(loc);
|
||||
living.teleport(loc,io.papermc.paper.entity.TeleportFlag.EntityState.values());
|
||||
equipment.ShowFireLocation(player);
|
||||
} else {
|
||||
PlayerHandler.releasePlayerSiegeEngine(player, ent);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class EntityProjectile extends SiegeEngineProjectile {
|
||||
public int delayTime = 6;
|
||||
public EntityType entityType = EntityType.ARROW;
|
||||
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;
|
||||
|
||||
private boolean playSound = true;
|
||||
@@ -62,7 +62,6 @@ public class EntityProjectile extends SiegeEngineProjectile {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity));
|
||||
}
|
||||
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 (player instanceof org.bukkit.projectiles.ProjectileSource)
|
||||
@@ -75,6 +74,8 @@ public class EntityProjectile extends SiegeEngineProjectile {
|
||||
arr.setShooter((org.bukkit.projectiles.ProjectileSource) player);
|
||||
arr.setPickupStatus(org.bukkit.entity.AbstractArrow.PickupStatus.CREATIVE_ONLY);
|
||||
}
|
||||
} else {
|
||||
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
|
||||
}
|
||||
if (playSound) {
|
||||
world.playSound(loc, this.soundType, 20, 2);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class FireworkProjectile extends SiegeEngineProjectile {
|
||||
public int delayTime = 6;
|
||||
public EntityType entityType = EntityType.FIREWORK;
|
||||
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 float velocityFactor = 0.5f;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class PotionProjectile extends SiegeEngineProjectile {
|
||||
} else {
|
||||
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));
|
||||
ItemStack itemStack = new ItemStack(Material.SPLASH_POTION);
|
||||
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
||||
|
||||
@@ -15,17 +15,20 @@ config-version: 1
|
||||
ControlItem: CLOCK
|
||||
|
||||
# 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
|
||||
RotateDistance: 32
|
||||
RotateDistance: 16
|
||||
|
||||
# The maximum siege engines a player can control at the same time
|
||||
MaxSiegeEnginesControlled: 5
|
||||
MaxSiegeEnginesControlled: 1
|
||||
|
||||
# The auto-reload feature by shift-clicking
|
||||
AutoReload: false
|
||||
|
||||
DisabledWorlds:
|
||||
- world_nether
|
||||
- World-o_nether
|
||||
|
||||
# ======================================
|
||||
# | SiegeEngine Options |
|
||||
@@ -34,43 +37,43 @@ AutoReload: false
|
||||
Projectiles:
|
||||
StoneShot:
|
||||
ProjectileType: EXPLOSIVE
|
||||
ExplodePower: 1.5
|
||||
ExplodePower: 3.25
|
||||
Inaccuracy: 0.125
|
||||
ProjectileCount: 1
|
||||
AmmoItem: COBBLESTONE
|
||||
FireSound: ENTITY_GENERIC_EXPLODE
|
||||
BreachShot:
|
||||
ProjectileType: EXPLOSIVE
|
||||
ExplodePower: 3.75
|
||||
Inaccuracy: 0.3
|
||||
ExplodePower: 5.25
|
||||
Inaccuracy: 0.375
|
||||
ProjectileCount: 1
|
||||
AmmoItem: IRON_BLOCK
|
||||
FireSound: ENTITY_GENERIC_EXPLODE
|
||||
RepeatingShot:
|
||||
ProjectileType: EXPLOSIVE
|
||||
ExplodePower: 1.0
|
||||
Inaccuracy: 0.325
|
||||
ProjectileCount: 5
|
||||
ExplodePower: 1.75
|
||||
Inaccuracy: 0.525
|
||||
ProjectileCount: 6
|
||||
AmmoItem: TNT
|
||||
FireSound: ENTITY_GENERIC_EXPLODE
|
||||
ScatterShot:
|
||||
ProjectileType: ENTITY
|
||||
Inaccuracy: 0.325
|
||||
Inaccuracy: 0.365
|
||||
EntityCount: 24
|
||||
EntityType: ARROW
|
||||
AmmoItem: GRAVEL
|
||||
FireSound: ENTITY_GENERIC_EXPLODE
|
||||
FireSound: ITEM_CROSSBOW_SHOOT
|
||||
BallistaBoltShot:
|
||||
ProjectileType: ENTITY
|
||||
Inaccuracy: 0.025
|
||||
Inaccuracy: 0.0125
|
||||
EntityCount: 1
|
||||
EntityType: ARROW
|
||||
AmmoItem: ARROW
|
||||
FireSound: ITEM_CROSSBOW_SHOOT
|
||||
DragonsBreath:
|
||||
ProjectileType: ENTITY
|
||||
Inaccuracy: 0.25
|
||||
EntityCount: 3
|
||||
Inaccuracy: 0.125
|
||||
EntityCount: 1
|
||||
EntityType: DRAGON_FIREBALL
|
||||
AmmoItem: DRAGON_BREATH
|
||||
FireSound: ENTITY_GENERIC_EXPLODE
|
||||
@@ -91,7 +94,7 @@ Projectiles:
|
||||
SiegeEngines:
|
||||
Trebuchet:
|
||||
ShotAmount: 1
|
||||
VelocityPerFuel: 0.3
|
||||
VelocityPerFuel: 0.75
|
||||
MaxFuel: 3
|
||||
FuelItem: STRING
|
||||
Projectiles:
|
||||
@@ -102,9 +105,10 @@ SiegeEngines:
|
||||
ItemName: "&e&lTrebuchet"
|
||||
Lore:
|
||||
- "&ePlace as a block to spawn a Trebuchet"
|
||||
CanMount: false
|
||||
Ballista:
|
||||
ShotAmount: 1
|
||||
VelocityPerFuel: 1.25
|
||||
VelocityPerFuel: 0.975
|
||||
MaxFuel: 2
|
||||
FuelItem: STRING
|
||||
Projectiles:
|
||||
@@ -115,22 +119,25 @@ SiegeEngines:
|
||||
ItemName: "&e&lBallista"
|
||||
Lore:
|
||||
- "&ePlace as a block to spawn a Ballista"
|
||||
CanMount: false
|
||||
SwivelCannon:
|
||||
ShotAmount: 1
|
||||
VelocityPerFuel: 1.0125
|
||||
VelocityPerFuel: 0.975
|
||||
MaxFuel: 5
|
||||
FuelItem: GUNPOWDER
|
||||
Projectiles:
|
||||
- StoneShot
|
||||
- RepeatingShot
|
||||
- ScatterShot
|
||||
- FireShot
|
||||
- FireworkShot
|
||||
ItemName: "&e&lSwivel Cannon"
|
||||
Lore:
|
||||
- "&ePlace as a block to spawn a Swivel Cannon"
|
||||
CanMount: false
|
||||
BreachCannon:
|
||||
ShotAmount: 1
|
||||
VelocityPerFuel: 0.975
|
||||
VelocityPerFuel: 1.0625
|
||||
MaxFuel: 4
|
||||
FuelItem: GUNPOWDER
|
||||
Projectiles:
|
||||
@@ -142,4 +149,4 @@ SiegeEngines:
|
||||
ItemName: "&e&lBreach Cannon"
|
||||
Lore:
|
||||
- "&ePlace as a block to spawn a Breach Cannon"
|
||||
|
||||
CanMount: false
|
||||
Reference in new issue
Block a user