Merge branch 'sherman'

This commit is contained in:
ShermansWorld committed 2024-01-06 18:16:59 -05:00
commit 82124563b3
5 files changed
+17 -34

No files matched your search

@@ -15,16 +15,11 @@ import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.ArmorStand.LockType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -36,17 +31,11 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.metadata.MetadataValueAdapter;
import org.bukkit.metadata.FixedMetadataValue;
//import com.palmergames.bukkit.towny.Towny;
import com.github.alathra.siegeengines.listeners.ClickHandler;
import com.github.alathra.siegeengines.listeners.RotationHandler;
import com.github.alathra.siegeengines.projectile.EntityProjectile;
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
import com.github.alathra.siegeengines.projectile.GunnersProjectile;
//import GunnersProjectiles.EntityProjectile;
//import GunnersProjectiles.GunnersProjectile;
//import GunnersProjectiles.ExplosiveProjectile;
//import GunnersProjectiles.PotionProjectile;
public class SiegeEngines extends JavaPlugin {
@@ -58,7 +47,6 @@ public class SiegeEngines extends JavaPlugin {
public static Random random = new Random();
private static String Path;
private CommandHandler commandHandler;
//public static Towny towny;
public static SiegeEngines getInstance() {
@@ -77,16 +65,12 @@ public class SiegeEngines extends JavaPlugin {
public void onEnable() {
instance = this;
Path = this.getDataFolder().getAbsolutePath();
//this.getCommand("SiegeEngines").setExecutor(new GunnersCommand()); // Fixed Start-up
getServer().getPluginManager().registerEvents(new RotationHandler(), this);
getServer().getPluginManager().registerEvents(new ClickHandler(), this);
//StorageManager.setup(Path, plugin);
equipment.clear();
TrackedStands.clear();
DefinedEquipment.clear();
AddDefaults();
//HashMap<ItemStack,GunnersProjectile> projObj = new HashMap<>();
//GunnerEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj);
for (SiegeEquipment i : DefinedEquipment.values()) {
System.out.println("§eEnabled Weapon : " + i.EquipmentName);
System.out.println("§eWeapon Propellant/\"Fuel\" ItemStacks : " + i.FuelMaterial);
@@ -281,20 +265,9 @@ public class SiegeEngines extends JavaPlugin {
scatterShot.SoundType = Sound.ITEM_CROSSBOW_SHOOT;
equip.Projectiles.put(new ItemStack(Material.GRAVEL), scatterShot);
DefinedEquipment.put(equip.ReadyModelNumber, equip);
// EntityProjectile pig = new EntityProjectile();
// pig.EntityCount = 100;
// pig.DelayedFire = true;
// pig.DelayTime = 3;
// pig.EntityTyp = EntityType.ARROW;
// pig.SoundType = Sound.ITEM_CROSSBOW_SHOOT;
// pig.ParticleType = Particle.GLOW;
// equip.Projectiles.put(Material.PORKCHOP, pig);
// equip.Projectiles.put(Material.BONE, new PotionProjectile());
}
public static Boolean CreateCannon(Entity player, int CustomModelData, Location l) {
//l.setY(l.getY() - 1);
public static Boolean placeEquipment(Entity player, int CustomModelData, Location l) {
l.add(0.5, 0, 0.5);
NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
SiegeEquipment equip = CreateClone(CustomModelData);
@@ -373,10 +346,8 @@ public class SiegeEngines extends JavaPlugin {
stand.setInvisible(equip.AllowInvisibleStand);
stand.setBasePlate(false);
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
// stand.setSmall(true);
stand.setGravity(false);
//stand.setSmall(true);
ent.getEquipment().setHelmet(item);
if (TrackedStands.containsKey(player.getUniqueId())) {
List<Entity> entities = TrackedStands.get(player.getUniqueId());
@@ -400,7 +371,6 @@ public class SiegeEngines extends JavaPlugin {
meta.setCustomModelData(modelNumber);
Helmet.setItemMeta(meta);
liv.getEquipment().setHelmet(Helmet);
// plugin.getLogger().log(Level.INFO, "Updating stand?");
}
}
}
@@ -16,6 +16,10 @@ public class Config {
public static Material controlItem = Material.COMPASS;
public static int controlDistance = 64;
public static int rotateDistance = 32;
public static void initConfigVals() {
// init config
config = SiegeEngines.getInstance().getConfig();
@@ -28,6 +32,9 @@ public class Config {
controlItem = Material.COMPASS;
}
controlDistance = config.getInt("ControlDistance");
rotateDistance = config.getInt("RotateDistance");
}
public static void reload() {
@@ -157,7 +157,7 @@ public class ClickHandler implements Listener {
ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
if (item.getItemMeta() != null && item.getItemMeta().hasCustomModelData()) {
int customModel = item.getItemMeta().getCustomModelData();
Boolean created = SiegeEngines.CreateCannon(thePlayer, customModel, event.getBlockAgainst().getLocation());
Boolean created = SiegeEngines.placeEquipment(thePlayer, customModel, event.getBlockAgainst().getLocation());
if (created) {
item.setAmount(item.getAmount() - 1);
thePlayer.getInventory().setItemInMainHand(item);
@@ -195,7 +195,7 @@ public class ClickHandler implements Listener {
continue;
}
double distance = player.getLocation().distance(ent.getLocation());
if (distance >= 64) {
if (distance >= Config.controlDistance) {
continue;
}
SiegeEquipment siege = SiegeEngines.equipment.get(ent.getUniqueId());
@@ -45,7 +45,7 @@ public class RotationHandler implements Listener {
continue;
}
double distance = player.getLocation().distance(ent.getLocation());
if (distance <= 32) {
if (distance <= Config.rotateDistance) {
// player.sendMessage("§egot id");
LivingEntity living = (LivingEntity) ent;
Location loc = ent.getLocation();
+6
View File
@@ -13,3 +13,9 @@ config-version: 1
# The item used to aim and fire siege engines
# Must be a valid material. See https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html
ControlItem: COMPASS
# The maxmimum distance the player can be away from the siege engine before total control is terminated
ControlDistance: 64
# The maximum distance the player can be away from the siege engine before rotation control is terminated
RotateDistance: 32