mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-03 14:38:53 +00:00
Merge branch 'sherman'
This commit is contained in:
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.NamespacedKey;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
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;
|
||||||
import org.bukkit.entity.ArmorStand.LockType;
|
import org.bukkit.entity.ArmorStand.LockType;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
@@ -36,17 +31,11 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
import org.bukkit.metadata.MetadataValueAdapter;
|
import org.bukkit.metadata.MetadataValueAdapter;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
//import com.palmergames.bukkit.towny.Towny;
|
|
||||||
|
|
||||||
import com.github.alathra.siegeengines.listeners.ClickHandler;
|
import com.github.alathra.siegeengines.listeners.ClickHandler;
|
||||||
import com.github.alathra.siegeengines.listeners.RotationHandler;
|
import com.github.alathra.siegeengines.listeners.RotationHandler;
|
||||||
import com.github.alathra.siegeengines.projectile.EntityProjectile;
|
import com.github.alathra.siegeengines.projectile.EntityProjectile;
|
||||||
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
|
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
|
||||||
import com.github.alathra.siegeengines.projectile.GunnersProjectile;
|
import com.github.alathra.siegeengines.projectile.GunnersProjectile;
|
||||||
//import GunnersProjectiles.EntityProjectile;
|
|
||||||
//import GunnersProjectiles.GunnersProjectile;
|
|
||||||
//import GunnersProjectiles.ExplosiveProjectile;
|
|
||||||
//import GunnersProjectiles.PotionProjectile;
|
|
||||||
|
|
||||||
|
|
||||||
public class SiegeEngines extends JavaPlugin {
|
public class SiegeEngines extends JavaPlugin {
|
||||||
@@ -58,7 +47,6 @@ public class SiegeEngines extends JavaPlugin {
|
|||||||
public static Random random = new Random();
|
public static Random random = new Random();
|
||||||
private static String Path;
|
private static String Path;
|
||||||
private CommandHandler commandHandler;
|
private CommandHandler commandHandler;
|
||||||
//public static Towny towny;
|
|
||||||
|
|
||||||
|
|
||||||
public static SiegeEngines getInstance() {
|
public static SiegeEngines getInstance() {
|
||||||
@@ -77,16 +65,12 @@ public class SiegeEngines extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
Path = this.getDataFolder().getAbsolutePath();
|
Path = this.getDataFolder().getAbsolutePath();
|
||||||
//this.getCommand("SiegeEngines").setExecutor(new GunnersCommand()); // Fixed Start-up
|
|
||||||
getServer().getPluginManager().registerEvents(new RotationHandler(), this);
|
getServer().getPluginManager().registerEvents(new RotationHandler(), this);
|
||||||
getServer().getPluginManager().registerEvents(new ClickHandler(), this);
|
getServer().getPluginManager().registerEvents(new ClickHandler(), this);
|
||||||
//StorageManager.setup(Path, plugin);
|
|
||||||
equipment.clear();
|
equipment.clear();
|
||||||
TrackedStands.clear();
|
TrackedStands.clear();
|
||||||
DefinedEquipment.clear();
|
DefinedEquipment.clear();
|
||||||
AddDefaults();
|
AddDefaults();
|
||||||
//HashMap<ItemStack,GunnersProjectile> projObj = new HashMap<>();
|
|
||||||
//GunnerEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj);
|
|
||||||
for (SiegeEquipment i : DefinedEquipment.values()) {
|
for (SiegeEquipment i : DefinedEquipment.values()) {
|
||||||
System.out.println("§eEnabled Weapon : " + i.EquipmentName);
|
System.out.println("§eEnabled Weapon : " + i.EquipmentName);
|
||||||
System.out.println("§eWeapon Propellant/\"Fuel\" ItemStacks : " + i.FuelMaterial);
|
System.out.println("§eWeapon Propellant/\"Fuel\" ItemStacks : " + i.FuelMaterial);
|
||||||
@@ -281,20 +265,9 @@ public class SiegeEngines extends JavaPlugin {
|
|||||||
scatterShot.SoundType = Sound.ITEM_CROSSBOW_SHOOT;
|
scatterShot.SoundType = Sound.ITEM_CROSSBOW_SHOOT;
|
||||||
equip.Projectiles.put(new ItemStack(Material.GRAVEL), scatterShot);
|
equip.Projectiles.put(new ItemStack(Material.GRAVEL), scatterShot);
|
||||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
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) {
|
public static Boolean placeEquipment(Entity player, int CustomModelData, Location l) {
|
||||||
//l.setY(l.getY() - 1);
|
|
||||||
l.add(0.5, 0, 0.5);
|
l.add(0.5, 0, 0.5);
|
||||||
NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
|
NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
|
||||||
SiegeEquipment equip = CreateClone(CustomModelData);
|
SiegeEquipment equip = CreateClone(CustomModelData);
|
||||||
@@ -373,10 +346,8 @@ public class SiegeEngines extends JavaPlugin {
|
|||||||
stand.setInvisible(equip.AllowInvisibleStand);
|
stand.setInvisible(equip.AllowInvisibleStand);
|
||||||
stand.setBasePlate(false);
|
stand.setBasePlate(false);
|
||||||
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
|
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
|
||||||
// stand.setSmall(true);
|
|
||||||
|
|
||||||
stand.setGravity(false);
|
stand.setGravity(false);
|
||||||
//stand.setSmall(true);
|
|
||||||
ent.getEquipment().setHelmet(item);
|
ent.getEquipment().setHelmet(item);
|
||||||
if (TrackedStands.containsKey(player.getUniqueId())) {
|
if (TrackedStands.containsKey(player.getUniqueId())) {
|
||||||
List<Entity> entities = TrackedStands.get(player.getUniqueId());
|
List<Entity> entities = TrackedStands.get(player.getUniqueId());
|
||||||
@@ -400,7 +371,6 @@ public class SiegeEngines extends JavaPlugin {
|
|||||||
meta.setCustomModelData(modelNumber);
|
meta.setCustomModelData(modelNumber);
|
||||||
Helmet.setItemMeta(meta);
|
Helmet.setItemMeta(meta);
|
||||||
liv.getEquipment().setHelmet(Helmet);
|
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 Material controlItem = Material.COMPASS;
|
||||||
|
|
||||||
|
public static int controlDistance = 64;
|
||||||
|
|
||||||
|
public static int rotateDistance = 32;
|
||||||
|
|
||||||
public static void initConfigVals() {
|
public static void initConfigVals() {
|
||||||
// init config
|
// init config
|
||||||
config = SiegeEngines.getInstance().getConfig();
|
config = SiegeEngines.getInstance().getConfig();
|
||||||
@@ -28,6 +32,9 @@ public class Config {
|
|||||||
controlItem = Material.COMPASS;
|
controlItem = Material.COMPASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
controlDistance = config.getInt("ControlDistance");
|
||||||
|
|
||||||
|
rotateDistance = config.getInt("RotateDistance");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload() {
|
public static void reload() {
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class ClickHandler implements Listener {
|
|||||||
ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
|
ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
|
||||||
if (item.getItemMeta() != null && item.getItemMeta().hasCustomModelData()) {
|
if (item.getItemMeta() != null && item.getItemMeta().hasCustomModelData()) {
|
||||||
int customModel = item.getItemMeta().getCustomModelData();
|
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) {
|
if (created) {
|
||||||
item.setAmount(item.getAmount() - 1);
|
item.setAmount(item.getAmount() - 1);
|
||||||
thePlayer.getInventory().setItemInMainHand(item);
|
thePlayer.getInventory().setItemInMainHand(item);
|
||||||
@@ -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 >= 64) {
|
if (distance >= Config.controlDistance) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SiegeEquipment siege = SiegeEngines.equipment.get(ent.getUniqueId());
|
SiegeEquipment siege = SiegeEngines.equipment.get(ent.getUniqueId());
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class RotationHandler implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double distance = player.getLocation().distance(ent.getLocation());
|
double distance = player.getLocation().distance(ent.getLocation());
|
||||||
if (distance <= 32) {
|
if (distance <= Config.rotateDistance) {
|
||||||
// player.sendMessage("§egot id");
|
// player.sendMessage("§egot id");
|
||||||
LivingEntity living = (LivingEntity) ent;
|
LivingEntity living = (LivingEntity) ent;
|
||||||
Location loc = ent.getLocation();
|
Location loc = ent.getLocation();
|
||||||
|
|||||||
@@ -13,3 +13,9 @@ config-version: 1
|
|||||||
# The item used to aim and fire siege engines
|
# 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
|
# Must be a valid material. See https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html
|
||||||
ControlItem: COMPASS
|
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
|
||||||
Reference in new issue
Block a user