mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-01 22:22:10 +00:00
.
This commit is contained in:
1 parent
a3912d7889
commit
1e28214ce9
10 files changed
+80
-24
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -24,6 +24,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -31,6 +32,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
@@ -160,11 +162,20 @@ public class ClickHandler implements Listener {
|
||||
if (topline == null) topline = "";
|
||||
Player player = event.getPlayer();
|
||||
String toplinetrimmed = topline.trim();
|
||||
event.getPlayer().sendMessage("1");
|
||||
if (toplinetrimmed.equals("[Cannon]")) {
|
||||
SaveCannons(player, event.getBlock());
|
||||
}
|
||||
event.getPlayer().sendMessage("2");
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void damage(EntityDamageByEntityEvent event){
|
||||
if (event.getEntity() instanceof ArmorStand) {
|
||||
if (event.getDamager() instanceof Projectile) {
|
||||
event.setDamage(0);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,6 +216,7 @@ public class ClickHandler implements Listener {
|
||||
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING_OR_CHANGING);
|
||||
stand.setBasePlate(false);
|
||||
if (CrunchSiegeCore.TrackedStands.containsKey(player.getUniqueId())) {
|
||||
List<Entity> entities = CrunchSiegeCore.TrackedStands.get(player.getUniqueId());
|
||||
entities.add(entity);
|
||||
|
||||
@@ -93,7 +93,7 @@ public class CrunchSiegeCore extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new ClickHandler(), this);
|
||||
StorageManager.setup(Path, plugin);
|
||||
AddDefined();
|
||||
File f = new File(Path + "/Example.Json");
|
||||
File f = new File(Path + "/Trebuchet.Json");
|
||||
if (!f.exists()) {
|
||||
for (SiegeEquipment i : DefinedEquipment.values()) {
|
||||
StorageManager.Save(i);
|
||||
@@ -107,7 +107,8 @@ public class CrunchSiegeCore extends JavaPlugin {
|
||||
|
||||
File folder = new File(Path);
|
||||
File[] listOfFiles = folder.listFiles();
|
||||
|
||||
equipment.clear();
|
||||
TrackedStands.clear();
|
||||
for (int i = 0; i < listOfFiles.length; i++) {
|
||||
if (listOfFiles[i].isFile()) {
|
||||
SiegeEquipment equip = StorageManager.load(listOfFiles[i].getAbsolutePath());
|
||||
@@ -207,9 +208,63 @@ public class CrunchSiegeCore extends JavaPlugin {
|
||||
|
||||
public static void AddDefined() {
|
||||
SiegeEquipment equip = new SiegeEquipment();
|
||||
equip.EquipmentName = "Trebuchet";
|
||||
equip.XOffset = 5;
|
||||
equip.YOffset = 5;
|
||||
equip.VelocityPerFuel = 0.3f;
|
||||
ExplosiveProjectile proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 1;
|
||||
proj.ExplodePower = 2;
|
||||
equip.RotateStandHead = false;
|
||||
equip.RotateSideways = true;
|
||||
equip.FuelMaterial = Material.STRING;
|
||||
equip.Projectiles.put(Material.COBBLESTONE, proj);
|
||||
equip.ReadyModelNumber = 122;
|
||||
equip.ModelNumberToFireAt = 135;
|
||||
equip.MillisecondsBetweenFiringStages = 2;
|
||||
equip.MillisecondsBetweenReloadingStages = 10;
|
||||
equip.FiringModelNumbers = new ArrayList<>(Arrays.asList(
|
||||
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139
|
||||
));
|
||||
equip.CycleThroughModelsBeforeFiring = true;
|
||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
||||
|
||||
equip = new SiegeEquipment();
|
||||
equip.EquipmentName = "Naval Cannon";
|
||||
equip.Projectiles.put(Material.COBBLESTONE, proj);
|
||||
equip.PlacementOffsetY = -1;
|
||||
equip.ReadyModelNumber = 142;
|
||||
equip.ModelNumberToFireAt = 142;
|
||||
equip.FiringModelNumbers = new ArrayList<Integer>();
|
||||
equip.RotateStandHead = true;
|
||||
equip.RotateSideways = false;
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 1;
|
||||
proj.ProjectilesCount = 3;
|
||||
proj.DelayedFire = true;
|
||||
proj.Inaccuracy = 0.5f;
|
||||
equip.Projectiles.put(Material.TNT, proj);
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 4;
|
||||
proj.ProjectilesCount = 1;
|
||||
equip.Projectiles.put(Material.COPPER_BLOCK, proj);
|
||||
|
||||
EntityProjectile fireProj = new EntityProjectile();
|
||||
fireProj.EntityCount = 2;
|
||||
fireProj.EntityTyp = EntityType.SMALL_FIREBALL;
|
||||
fireProj.ParticleType = Particle.WHITE_ASH;
|
||||
fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT;
|
||||
equip.Projectiles.put(Material.FIRE_CHARGE, fireProj);
|
||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
||||
equip = new SiegeEquipment();
|
||||
equip.EquipmentName = "Siege Cannon";
|
||||
proj.ExplodePower = 2;
|
||||
equip.Projectiles.put(Material.COBBLESTONE, proj);
|
||||
equip.PlacementOffsetY = -1;
|
||||
equip.ReadyModelNumber = 141;
|
||||
equip.ModelNumberToFireAt = 141;
|
||||
equip.FiringModelNumbers = new ArrayList<Integer>();
|
||||
equip.RotateStandHead = true;
|
||||
equip.RotateSideways = true;
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 1;
|
||||
proj.ProjectilesCount = 3;
|
||||
@@ -221,13 +276,7 @@ public class CrunchSiegeCore extends JavaPlugin {
|
||||
proj.ProjectilesCount = 1;
|
||||
equip.Projectiles.put(Material.COPPER_BLOCK, proj);
|
||||
equip.Projectiles.put(Material.GRAVEL, new EntityProjectile());
|
||||
EntityProjectile fireProj = new EntityProjectile();
|
||||
fireProj.EntityCount = 3;
|
||||
fireProj.EntityTyp = EntityType.SMALL_FIREBALL;
|
||||
fireProj.ParticleType = Particle.WHITE_ASH;
|
||||
fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT;
|
||||
equip.Projectiles.put(Material.DIAMOND, fireProj);
|
||||
|
||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
||||
// EntityProjectile pig = new EntityProjectile();
|
||||
// pig.EntityCount = 100;
|
||||
// pig.DelayedFire = true;
|
||||
@@ -237,26 +286,19 @@ public class CrunchSiegeCore extends JavaPlugin {
|
||||
// pig.ParticleType = Particle.GLOW;
|
||||
// equip.Projectiles.put(Material.PORKCHOP, pig);
|
||||
// equip.Projectiles.put(Material.BONE, new PotionProjectile());
|
||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||
equip.ReadyModelNumber = 122;
|
||||
equip.ModelNumberToFireAt = 135;
|
||||
equip.MillisecondsBetweenFiringStages = 2;
|
||||
equip.MillisecondsBetweenReloadingStages = 30;
|
||||
equip.FiringModelNumbers = new ArrayList<>(Arrays.asList(
|
||||
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139
|
||||
));
|
||||
equip.CycleThroughModelsBeforeFiring = false;
|
||||
|
||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
||||
}
|
||||
|
||||
public static Boolean CreateTrebuchet(Player player, int CustomModelData, Location l) {
|
||||
//l.setY(l.getY() - 1);
|
||||
l.add(0.5, 0, 0.5);
|
||||
|
||||
SiegeEquipment equip = CreateClone(CustomModelData);
|
||||
if (equip == null || !equip.Enabled) {
|
||||
return false;
|
||||
}
|
||||
l.setY(l.getY() + 1);
|
||||
l.setY(l.getY() + equip.PlacementOffsetY);
|
||||
l.setDirection(player.getLocation().getDirection());
|
||||
Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
|
||||
|
||||
@@ -280,6 +322,7 @@ public class CrunchSiegeCore extends JavaPlugin {
|
||||
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING_OR_CHANGING);
|
||||
stand.setBasePlate(false);
|
||||
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
|
||||
// stand.setSmall(true);
|
||||
stand.setVisible(true);
|
||||
|
||||
@@ -43,6 +43,7 @@ public class SiegeEquipment implements Cloneable {
|
||||
public int XOffset = 7;
|
||||
public int YOffset = 0;
|
||||
public int MaxFuel = 5;
|
||||
public int PlacementOffsetY = 0;
|
||||
public float VelocityPerFuel = 0.75f;
|
||||
public Material FuelMaterial = Material.GUNPOWDER;
|
||||
public long NextShotTime = System.currentTimeMillis();
|
||||
|
||||
@@ -74,7 +74,7 @@ public class StorageManager {
|
||||
|
||||
public static void Save(SiegeEquipment equipment) {
|
||||
|
||||
storage = new File(folder, "Example.json");
|
||||
storage = new File(folder, equipment.EquipmentName + ".json");
|
||||
FileWriter writer;
|
||||
try {
|
||||
writer = new FileWriter(storage, false);
|
||||
@@ -95,7 +95,7 @@ public class StorageManager {
|
||||
public CrunchProjectile deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
|
||||
JsonObject Object = json.getAsJsonObject();
|
||||
JsonElement type = Object.get(TypeName);
|
||||
System.out.println(type.getAsString());
|
||||
|
||||
switch (type.getAsString()) {
|
||||
case "Entity":
|
||||
return gson.fromJson(Object, EntityProjectile.class);
|
||||
|
||||
Reference in new issue
Block a user