From 1e69394db758cc02c79630c336d8fe2bcd57e3c8 Mon Sep 17 00:00:00 2001 From: ShermansWorld <77093412+ShermansWorld@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:28:37 -0400 Subject: [PATCH] Latest CCorp build --- .../gunners/gunnerscore/GunnerEquipment.java | 5 +++ .../com/gunners/gunnerscore/GunnersCore.java | 42 +++++++++++++++---- .../gunnerscore/listeners/ClickHandler.java | 6 +-- .../listeners/RotationHandler.java | 6 +++ .../projectile/EntityProjectile.java | 14 +++++-- .../projectile/ExplosiveProjectile.java | 5 ++- .../projectile/GunnersProjectile.java | 8 ++++ .../projectile/PotionProjectile.java | 8 +++- 8 files changed, 77 insertions(+), 17 deletions(-) diff --git a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/GunnerEquipment.java b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/GunnerEquipment.java index abef3d4..26c2d5a 100644 --- a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/GunnerEquipment.java +++ b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/GunnerEquipment.java @@ -3,13 +3,18 @@ package com.gunners.gunnerscore; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Random; import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Firework; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; diff --git a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/GunnersCore.java b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/GunnersCore.java index 9098644..caa73a6 100644 --- a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/GunnersCore.java +++ b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/GunnersCore.java @@ -1,28 +1,48 @@ package com.gunners.gunnerscore; +import java.io.File; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; import java.util.HashMap; import java.util.List; import java.util.Random; import java.util.UUID; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.Particle; import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.attribute.Attribute; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.enchantments.Enchantment; 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.Horse; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Mule; import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.inventory.InventoryType.SlotType; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -31,14 +51,18 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; +import org.bukkit.metadata.MetadataValueAdapter; +import org.bukkit.metadata.FixedMetadataValue; +import com.comphenix.protocol.wrappers.EnumWrappers.Direction; //import com.palmergames.bukkit.towny.Towny; + import com.gunners.gunnerscore.listeners.ClickHandler; import com.gunners.gunnerscore.listeners.RotationHandler; import com.gunners.gunnerscore.projectile.EntityProjectile; import com.gunners.gunnerscore.projectile.ExplosiveProjectile; import com.gunners.gunnerscore.projectile.GunnersProjectile; - //import GunnersProjectiles.EntityProjectile; //import GunnersProjectiles.GunnersProjectile; //import GunnersProjectiles.ExplosiveProjectile; @@ -46,7 +70,7 @@ import com.gunners.gunnerscore.projectile.GunnersProjectile; public class GunnersCore extends JavaPlugin { public static Plugin plugin; - + public static MetadataValueAdapter metadata; public static Random random = new Random(); private static String Path; @@ -85,9 +109,9 @@ public class GunnersCore extends JavaPlugin { equipment.clear(); TrackedStands.clear(); DefinedEquipment.clear(); - AddDefaults(); - HashMap projObj = new HashMap<>(); - GunnerEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj); + //AddDefaults(); + //HashMap projObj = new HashMap<>(); + //GunnerEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj); for (GunnerEquipment i : DefinedEquipment.values()) { System.out.println("§eEnabled Weapon : "+i.EquipmentName); System.out.println("§eWeapon Propellant/\"Fuel\" ItemStacks : "+i.FuelMaterial); @@ -96,6 +120,9 @@ public class GunnersCore extends JavaPlugin { } } } + public static FixedMetadataValue addMetaDataValue(Object value) { + return new FixedMetadataValue(Bukkit.getServer().getPluginManager().getPlugin("GunnersCore"),value); + } public class GunnersCommand implements CommandExecutor { @Override @@ -199,7 +226,7 @@ public class GunnersCore extends JavaPlugin { if (customModelId == null || customModelId == 0) customModelId = 150; if (name == null) - name = "Peckle Gun"; + name = "Light Turret"; if (XOffset == null) XOffset = 0; if (YOffset == null) @@ -220,11 +247,12 @@ public class GunnersCore extends JavaPlugin { equip.VelocityPerFuel = fuelVelocityMod; equip.FuelMaterial = new ItemStack(Material.GUNPOWDER); equip.CycleThroughModelsBeforeFiring = false; + equip.AllowInvisibleStand = false; equip.MaxFuel = fuelMax; equip.shotAmount = 1; equip.AmmoHolder.LoadedFuel = fuelMax; EntityProjectile defaultProj = new EntityProjectile(); - defaultProj.EntityCount = 6; + defaultProj.EntityCount = 2; defaultProj.EntityTyp = EntityType.SHULKER_BULLET; defaultProj.ParticleType = Particle.WHITE_ASH; defaultProj.SoundType = Sound.ENTITY_BLAZE_SHOOT; diff --git a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/listeners/ClickHandler.java b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/listeners/ClickHandler.java index 473b80e..db6ca50 100644 --- a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/listeners/ClickHandler.java +++ b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/listeners/ClickHandler.java @@ -193,9 +193,6 @@ public class ClickHandler implements Listener { TakeControl(player,ent); } } - if (player instanceof Player) { - player.sendMessage("§eNow controlling nearby equipment."); - } } if (GunnersCore.TrackedStands.get(player.getUniqueId()) == null) return; @@ -695,6 +692,7 @@ public class ClickHandler implements Listener { } } player.sendMessage("§eNow controlling nearby equipment."); + return; } } @@ -713,7 +711,7 @@ public class ClickHandler implements Listener { if (entity.getType() == EntityType.ARMOR_STAND){ TakeControl(player, entity); if (GunnersCore.equipment.containsKey(entity.getUniqueId())) { - if (itemInHand.getType() == Material.RECOVERY_COMPASS) { + if (itemInHand.getType() == Material.CLOCK) { if (player.isSneaking()) { DoAimDown(entity, 1, player); } diff --git a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/listeners/RotationHandler.java b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/listeners/RotationHandler.java index 50d314f..0cd557d 100644 --- a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/listeners/RotationHandler.java +++ b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/listeners/RotationHandler.java @@ -1,11 +1,14 @@ package com.gunners.gunnerscore.listeners; +import java.awt.Color; import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.Particle; +import org.bukkit.block.Block; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -15,11 +18,14 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.persistence.PersistentDataType; +import org.bukkit.util.BlockIterator; import org.bukkit.util.EulerAngle; import org.bukkit.util.Vector; +import com.gunners.gunnerscore.EquipmentMagazine; import com.gunners.gunnerscore.GunnerEquipment; import com.gunners.gunnerscore.GunnersCore; +import com.gunners.gunnerscore.projectile.ExplosiveProjectile; public class RotationHandler implements Listener { diff --git a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/EntityProjectile.java b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/EntityProjectile.java index 9e42626..003f98e 100644 --- a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/EntityProjectile.java +++ b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/EntityProjectile.java @@ -8,13 +8,13 @@ import org.bukkit.World; import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; - +import org.bukkit.entity.Fireball; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.gunners.gunnerscore.GunnersCore; - - +import com.gunners.gunnerscore.listeners.ClickHandler; public class EntityProjectile implements GunnersProjectile{ public String ProjectileType = "Entity"; @@ -47,7 +47,7 @@ public class EntityProjectile implements GunnersProjectile{ } } private boolean PlaySound = true; - private void CreateEntity(Entity entity, Location loc, Float velocity, Entity player) { + private void CreateEntity(Entity entity, Location loc, Float velocity, Entity player) { World world = entity.getLocation().getWorld(); LivingEntity living = (LivingEntity) entity; @@ -59,7 +59,13 @@ public class EntityProjectile implements GunnersProjectile{ else { arrow.setVelocity(loc.getDirection().multiply(velocity)); } + arrow.setMetadata("isEntityProj",GunnersCore.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) + ((org.bukkit.entity.Projectile)arrow).setShooter((org.bukkit.projectiles.ProjectileSource)player); + } if (arrow instanceof Arrow) { Arrow arr = (Arrow) arrow; arr.setDamage(8); diff --git a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/ExplosiveProjectile.java b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/ExplosiveProjectile.java index 21e31b9..4c13b2d 100644 --- a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/ExplosiveProjectile.java +++ b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/ExplosiveProjectile.java @@ -9,12 +9,13 @@ import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; +import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import com.gunners.gunnerscore.GunnersCore; import com.gunners.gunnerscore.listeners.ClickHandler; - //import me.libraryaddict.disguise.disguisetypes.DisguiseType; //import me.libraryaddict.disguise.disguisetypes.MiscDisguise; @@ -68,6 +69,8 @@ public class ExplosiveProjectile implements GunnersProjectile { else { tnt.setVelocity(loc.getDirection().multiply(velocity)); } + tnt.setMetadata("isExplosiveProj",GunnersCore.addMetaDataValue("true")); + Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(tnt)); if (PlaySound) { world.playSound(loc, this.SoundType, 20, 2); diff --git a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/GunnersProjectile.java b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/GunnersProjectile.java index bd1d654..859cee2 100644 --- a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/GunnersProjectile.java +++ b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/GunnersProjectile.java @@ -1,7 +1,15 @@ package com.gunners.gunnerscore.projectile; import org.bukkit.Location; +import org.bukkit.Particle; +import org.bukkit.Sound; import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import com.gunners.gunnerscore.GunnersCore; +import com.gunners.gunnerscore.listeners.ClickHandler; public interface GunnersProjectile { public void Shoot(Entity player, Entity entity, Location fireLocation, Float velocity); diff --git a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/PotionProjectile.java b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/PotionProjectile.java index b7d3858..89c1c6b 100644 --- a/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/PotionProjectile.java +++ b/CrunchSiegeEquipment/src/main/java/com/gunners/gunnerscore/projectile/PotionProjectile.java @@ -6,18 +6,22 @@ import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.World; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.SplashPotion; import org.bukkit.entity.ThrownPotion; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.Potion; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import com.gunners.gunnerscore.GunnersCore; - +import com.gunners.gunnerscore.listeners.ClickHandler; public class PotionProjectile implements GunnersProjectile { public String ProjectileType = "Potion"; @@ -57,6 +61,8 @@ public class PotionProjectile implements GunnersProjectile { else { arrow.setVelocity(loc.getDirection().multiply(velocity)); } + arrow.setMetadata("isExplosiveProj",GunnersCore.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(); potionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 100, 3, true), true);