Updated Some stuff, Ported over my Changes

Hi!
This commit is contained in:
C_Corp2002 committed 2024-01-05 21:59:11 -05:00
1 parent 4283710716
commit 09eecbb8ee
4 files changed
+60 -38

No files matched your search

@@ -161,7 +161,7 @@ public class SiegeEngines extends JavaPlugin {
if (customModelId == null || customModelId == 0) if (customModelId == null || customModelId == 0)
customModelId = 150; customModelId = 150;
if (name == null) if (name == null)
name = "Light Turret"; name = "Unnamed Cannon";
if (XOffset == null) if (XOffset == null)
XOffset = 0; XOffset = 0;
if (YOffset == null) if (YOffset == null)
@@ -208,8 +208,8 @@ public class SiegeEngines extends JavaPlugin {
equip.YOffset = 5; equip.YOffset = 5;
equip.VelocityPerFuel = 0.3f; equip.VelocityPerFuel = 0.3f;
ExplosiveProjectile proj = new ExplosiveProjectile(); ExplosiveProjectile proj = new ExplosiveProjectile();
proj.ExplodePower = 2; proj.ExplodePower = 1;
equip.shotAmount = 1; equip.shotAmount = 2;
equip.RotateStandHead = false; equip.RotateStandHead = false;
equip.RotateSideways = true; equip.RotateSideways = true;
equip.FuelMaterial = new ItemStack(Material.STRING); equip.FuelMaterial = new ItemStack(Material.STRING);
@@ -236,20 +236,21 @@ public class SiegeEngines extends JavaPlugin {
equip.RotateSideways = false; equip.RotateSideways = false;
proj = new ExplosiveProjectile(); proj = new ExplosiveProjectile();
proj.ExplodePower = 1; proj.ExplodePower = 1;
proj.ProjectilesCount = 3; proj.ProjectilesCount = 5;
proj.DelayedFire = true; proj.DelayedFire = true;
proj.Inaccuracy = 0.75f; proj.Inaccuracy = 0.75f;
equip.Projectiles.put(new ItemStack(Material.TNT), proj); equip.Projectiles.put(new ItemStack(Material.TNT), proj);
proj = new ExplosiveProjectile(); proj = new ExplosiveProjectile();
proj.ExplodePower = 4; proj.ExplodePower = 3;
proj.ProjectilesCount = 1; proj.ProjectilesCount = 1;
equip.Projectiles.put(new ItemStack(Material.COPPER_BLOCK), proj); equip.Projectiles.put(new ItemStack(Material.IRON_BLOCK), proj);
EntityProjectile fireProj = new EntityProjectile(); EntityProjectile fireProj = new EntityProjectile();
fireProj.EntityCount = 2; fireProj.EntityCount = 4;
fireProj.EntityTyp = EntityType.SMALL_FIREBALL; fireProj.EntityTyp = EntityType.SMALL_FIREBALL;
fireProj.ParticleType = Particle.WHITE_ASH; fireProj.ParticleType = Particle.WHITE_ASH;
fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT; fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT;
fireProj.Inaccuracy = 0.75f;
equip.Projectiles.put(new ItemStack(Material.FIRE_CHARGE), fireProj); equip.Projectiles.put(new ItemStack(Material.FIRE_CHARGE), fireProj);
DefinedEquipment.put(equip.ReadyModelNumber, equip); DefinedEquipment.put(equip.ReadyModelNumber, equip);
equip = new SiegeEquipment(); equip = new SiegeEquipment();
@@ -264,16 +265,21 @@ public class SiegeEngines extends JavaPlugin {
equip.RotateStandHead = true; equip.RotateStandHead = true;
equip.RotateSideways = true; equip.RotateSideways = true;
proj = new ExplosiveProjectile(); proj = new ExplosiveProjectile();
proj.ExplodePower = 1; proj.ExplodePower = 2;
proj.ProjectilesCount = 3; proj.ProjectilesCount = 3;
proj.DelayedFire = true; proj.DelayedFire = true;
proj.Inaccuracy = 0.5f; proj.Inaccuracy = 0.75f;
equip.Projectiles.put(new ItemStack(Material.TNT), proj); equip.Projectiles.put(new ItemStack(Material.TNT), proj);
proj = new ExplosiveProjectile(); proj = new ExplosiveProjectile();
proj.ExplodePower = 4; proj.ExplodePower = 3;
proj.ProjectilesCount = 1; proj.ProjectilesCount = 1;
equip.Projectiles.put(new ItemStack(Material.COPPER_BLOCK), proj); equip.Projectiles.put(new ItemStack(Material.IRON_BLOCK), proj);
equip.Projectiles.put(new ItemStack(Material.GRAVEL), new EntityProjectile()); EntityProjectile scatterShot = new EntityProjectile();
scatterShot.Inaccuracy = 0.5f;
scatterShot.EntityCount = 24;
scatterShot.ParticleType = Particle.ELECTRIC_SPARK;
scatterShot.SoundType = Sound.ITEM_CROSSBOW_SHOOT;
equip.Projectiles.put(new ItemStack(Material.GRAVEL), scatterShot);
DefinedEquipment.put(equip.ReadyModelNumber, equip); DefinedEquipment.put(equip.ReadyModelNumber, equip);
// EntityProjectile pig = new EntityProjectile(); // EntityProjectile pig = new EntityProjectile();
// pig.EntityCount = 100; // pig.EntityCount = 100;
@@ -1,7 +1,6 @@
package com.github.alathra.siegeengines.command; package com.github.alathra.siegeengines.command;
import com.github.alathra.siegeengines.SiegeEquipment; import com.github.alathra.siegeengines.SiegeEquipment;
import com.github.alathra.siegeengines.config.Config;
import com.github.alathra.siegeengines.projectile.GunnersProjectile; import com.github.alathra.siegeengines.projectile.GunnersProjectile;
import com.github.milkdrinkers.colorparser.ColorParser; import com.github.milkdrinkers.colorparser.ColorParser;
import dev.jorel.commandapi.CommandAPIBukkit; import dev.jorel.commandapi.CommandAPIBukkit;
@@ -50,7 +49,7 @@ public class SiegeEnginesCommand {
new StringArgument("equipmentid") new StringArgument("equipmentid")
.replaceSuggestions( .replaceSuggestions(
ArgumentSuggestions.strings( ArgumentSuggestions.strings(
DefinedEquipment.values().stream().map(gunnerEquipment -> gunnerEquipment.EquipmentId).toList() DefinedEquipment.values().stream().map(SiegeEquipment -> SiegeEquipment.EquipmentId).toList()
) )
), ),
new PlayerArgument("target") new PlayerArgument("target")
@@ -77,9 +76,9 @@ public class SiegeEnginesCommand {
Player player = (Player) args.getOptional("target").orElse(sender); Player player = (Player) args.getOptional("target").orElse(sender);
for (SiegeEquipment gunnerEquipment : DefinedEquipment.values()) { for (SiegeEquipment SiegeEquipment : DefinedEquipment.values()) {
if (gunnerEquipment.equals(equipmentId)) { if (SiegeEquipment.equals(equipmentId)) {
giveEquipment(player, gunnerEquipment); giveEquipment(player, SiegeEquipment);
break; break;
} }
} }
@@ -103,7 +102,7 @@ public class SiegeEnginesCommand {
DefinedEquipment.clear(); DefinedEquipment.clear();
AddDefaults(); AddDefaults();
HashMap<ItemStack, GunnersProjectile> projObj = new HashMap<>(); HashMap<ItemStack, GunnersProjectile> projObj = new HashMap<>();
SiegeEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj); //SiegeEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj);
for (SiegeEquipment i : DefinedEquipment.values()) { for (SiegeEquipment i : DefinedEquipment.values()) {
sender.sendMessage(ColorParser.of("<yellow>Enabled Weapon : %s".formatted(i.EquipmentName)).build()); sender.sendMessage(ColorParser.of("<yellow>Enabled Weapon : %s".formatted(i.EquipmentName)).build());
sender.sendMessage(ColorParser.of("<yellow>Weapon Propellant/\"Fuel\" ItemStacks : %s".formatted(i.FuelMaterial)).build()); sender.sendMessage(ColorParser.of("<yellow>Weapon Propellant/\"Fuel\" ItemStacks : %s".formatted(i.FuelMaterial)).build());
@@ -111,17 +110,16 @@ public class SiegeEnginesCommand {
sender.sendMessage(ColorParser.of("<yellow>Weapon Projectile ItemStacks : %s".formatted(proj)).build()); sender.sendMessage(ColorParser.of("<yellow>Weapon Projectile ItemStacks : %s".formatted(proj)).build());
} }
} }
Config.reload();
sender.sendMessage("<yellow>Gunners Core configs reloaded"); sender.sendMessage("<yellow>Gunners Core configs reloaded");
} }
private void giveEquipment(Player player, SiegeEquipment gunnerEquipment) { private void giveEquipment(Player player, SiegeEquipment SiegeEquipment) {
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN); ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setCustomModelData(gunnerEquipment.ReadyModelNumber); meta.setCustomModelData(SiegeEquipment.ReadyModelNumber);
meta.displayName(ColorParser.of("<yellow>%s Item".formatted(gunnerEquipment.EquipmentName)).build()); meta.displayName(ColorParser.of("<yellow>%s Item".formatted(SiegeEquipment.EquipmentName)).build());
List<Component> lore = new ArrayList<>(); List<Component> lore = new ArrayList<>();
lore.add(ColorParser.of("<yellow>Place as a block to spawn a '%s'".formatted(gunnerEquipment.EquipmentName)).build()); lore.add(ColorParser.of("<yellow>Place as a block to spawn a '%s'".formatted(SiegeEquipment.EquipmentName)).build());
lore.add(ColorParser.of("<yellow>or put on an Armor Stand.").build()); lore.add(ColorParser.of("<yellow>or put on an Armor Stand.").build());
lore.add(ColorParser.of("<yellow>Right click to toggle visibility of stand.").build()); lore.add(ColorParser.of("<yellow>Right click to toggle visibility of stand.").build());
meta.lore(lore); meta.lore(lore);
@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
import com.github.alathra.siegeengines.config.Config;
import com.github.alathra.siegeengines.EquipmentMagazine; import com.github.alathra.siegeengines.EquipmentMagazine;
import com.github.alathra.siegeengines.SiegeEngines; import com.github.alathra.siegeengines.SiegeEngines;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -44,7 +45,6 @@ import org.bukkit.persistence.PersistentDataType;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import com.github.alathra.siegeengines.SiegeEquipment; import com.github.alathra.siegeengines.SiegeEquipment;
import com.github.alathra.siegeengines.config.Config;
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile; import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
//import com.palmergames.bukkit.towny.TownyAPI; //import com.palmergames.bukkit.towny.TownyAPI;
@@ -195,7 +195,7 @@ public class ClickHandler implements Listener {
continue; continue;
} }
double distance = player.getLocation().distance(ent.getLocation()); double distance = player.getLocation().distance(ent.getLocation());
if (distance >= 127) { if (distance >= 64) {
continue; continue;
} }
SiegeEquipment siege = SiegeEngines.equipment.get(ent.getUniqueId()); SiegeEquipment siege = SiegeEngines.equipment.get(ent.getUniqueId());
@@ -228,7 +228,6 @@ public class ClickHandler implements Listener {
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)) {
System.out.println(m.toString());
int amountInInv = contents[i].getAmount(); int amountInInv = contents[i].getAmount();
if (toRemove >= amountInInv) { if (toRemove >= amountInInv) {
contents[i].setType(Material.AIR); contents[i].setType(Material.AIR);
@@ -249,7 +248,6 @@ public class ClickHandler implements Listener {
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)) {
System.out.println(m.toString());
return true; return true;
} }
} }
@@ -279,12 +277,23 @@ public class ClickHandler implements Listener {
if (ItemInHand.getType() != Config.controlItem) { if (ItemInHand.getType() != Config.controlItem) {
return; return;
} }
if (!player.isSneaking()) if (!player.isSneaking()) {
Shoot((Entity) player, 7);
if (SiegeEngines.TrackedStands.containsKey(player.getUniqueId())) {
List<Entity> entities = SiegeEngines.TrackedStands.get(player.getUniqueId()); List<Entity> entities = SiegeEngines.TrackedStands.get(player.getUniqueId());
for (Entity entity : entities) {
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
SiegeEquipment equip = SiegeEngines.equipment.get(entity.getUniqueId());
if (equip != null && equip.Enabled && !(entity.isDead())) {
equip.Fire(player,10f,1);
}
}
}
}
if (SiegeEngines.TrackedStands.containsKey(player.getUniqueId())) {
List<Entity> entities = SiegeEngines.TrackedStands.get(player.getUniqueId());
player.sendMessage("§eReloading Ammunition");
for (Entity entity : entities) { for (Entity entity : entities) {
boolean foundAmmo = false; boolean foundAmmo = false;
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) {
@@ -364,9 +373,10 @@ public class ClickHandler implements Listener {
} }
} }
} }
player.sendMessage("§eReloading Ammunition"); player.sendMessage("§eReloading Propellant");
for (Entity entity : entities) { for (Entity entity : entities) {
boolean foundAmmo = false; boolean foundAmmo = false;
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) {
@@ -383,7 +393,6 @@ public class ClickHandler implements Listener {
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;
equip.AmmoHolder.MaterialName = stack;
foundAmmo = true; foundAmmo = true;
//state.update(true,true); //state.update(true,true);
} }
@@ -398,7 +407,6 @@ public class ClickHandler implements Listener {
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;
equip.AmmoHolder.MaterialName = stack;
foundAmmo = true; foundAmmo = true;
//state.update(true,true); //state.update(true,true);
} }
@@ -413,7 +421,6 @@ public class ClickHandler implements Listener {
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;
equip.AmmoHolder.MaterialName = stack;
foundAmmo = true; foundAmmo = true;
//state.update(true,true); //state.update(true,true);
} }
@@ -436,7 +443,6 @@ public class ClickHandler implements Listener {
} }
} }
} }
player.sendMessage("§eReloading Propellant");
return; return;
} }
@@ -449,7 +455,7 @@ public class ClickHandler implements Listener {
if (topline == null) topline = ""; if (topline == null) topline = "";
Player player = event.getPlayer(); Player player = event.getPlayer();
String toplinetrimmed = topline.trim(); String toplinetrimmed = topline.trim();
if (toplinetrimmed.equals("[Cannon]")) { if (toplinetrimmed.equalsIgnoreCase("[Cannon]")) {
SaveCannons(player, event.getBlock()); SaveCannons(player, event.getBlock());
} }
@@ -527,6 +533,9 @@ public class ClickHandler implements Listener {
return; return;
} }
for (Entity ent : SiegeEngines.TrackedStands.get(player.getUniqueId())) { for (Entity ent : SiegeEngines.TrackedStands.get(player.getUniqueId())) {
if (ent.isDead()) {
continue;
}
Ids.add(ent.getUniqueId().toString()); Ids.add(ent.getUniqueId().toString());
} }
TileState state = ((TileState) block.getState()); TileState state = ((TileState) block.getState());
@@ -787,7 +796,13 @@ public class ClickHandler implements Listener {
return; return;
} }
if (entity.getType() == EntityType.ARMOR_STAND) { if (entity.getType() == EntityType.ARMOR_STAND) {
if (itemInHand.getType() != Config.controlItem) {
SiegeEngines.TrackedStands.get(player.getUniqueId()).remove(entity);
player.sendMessage("§eThis Equipment is no longer commanded by you.");
return;
} else {
TakeControl(player, entity); TakeControl(player, entity);
}
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) { if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
if (itemInHand.getType() == Material.CLOCK) { if (itemInHand.getType() == Material.CLOCK) {
if (player.isSneaking()) { if (player.isSneaking()) {
@@ -42,7 +42,7 @@ public class RotationHandler implements Listener {
continue; continue;
} }
double distance = player.getLocation().distance(ent.getLocation()); double distance = player.getLocation().distance(ent.getLocation());
if (distance <= 250) { if (distance <= 32) {
// player.sendMessage("§egot id"); // player.sendMessage("§egot id");
LivingEntity living = (LivingEntity) ent; LivingEntity living = (LivingEntity) ent;
Location loc = ent.getLocation(); Location loc = ent.getLocation();
@@ -81,6 +81,9 @@ public class RotationHandler implements Listener {
living.teleport(loc); living.teleport(loc);
equipment.ShowFireLocation(player); equipment.ShowFireLocation(player);
} else {
SiegeEngines.TrackedStands.get(player.getUniqueId()).remove(ent);
continue;
} }
} }
} }
@@ -88,7 +91,7 @@ public class RotationHandler implements Listener {
} }
} }
Vector getDirectionBetweenLocations(Location Start, Location End) { public Vector getDirectionBetweenLocations(Location Start, Location End) {
Vector from = Start.toVector(); Vector from = Start.toVector();
Vector to = End.toVector(); Vector to = End.toVector();
return to.subtract(from); return to.subtract(from);