mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-04 14:38:53 +00:00
config loading fix
This commit is contained in:
1 parent
09a148b5bc
commit
e1f1f6a15d
5 files changed
+26
-23
No files matched your search
@@ -52,7 +52,7 @@ public class SiegeEngines extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.saveDefaultConfig();
|
this.saveDefaultConfig();
|
||||||
Config.initConfigVals();
|
Config.reload();
|
||||||
activeSiegeEngines.clear();
|
activeSiegeEngines.clear();
|
||||||
siegeEngineEntitiesPerPlayer.clear();
|
siegeEngineEntitiesPerPlayer.clear();
|
||||||
definedSiegeEngines.clear();
|
definedSiegeEngines.clear();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -12,6 +13,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
public class SiegeEnginesUtil {
|
public class SiegeEnginesUtil {
|
||||||
|
|
||||||
public static final ItemStack DEFAULT_ROCKET = new ItemStack(Material.FIREWORK_ROCKET);
|
public static final ItemStack DEFAULT_ROCKET = new ItemStack(Material.FIREWORK_ROCKET);
|
||||||
public static void UpdateEntityIdModel(Entity ent, int modelNumber, String WorldName) {
|
public static void UpdateEntityIdModel(Entity ent, int modelNumber, String WorldName) {
|
||||||
if (ent instanceof LivingEntity) {
|
if (ent instanceof LivingEntity) {
|
||||||
@@ -54,4 +56,5 @@ public class SiegeEnginesUtil {
|
|||||||
public static boolean hasItem(Inventory inv, ItemStack m) {
|
public static boolean hasItem(Inventory inv, ItemStack m) {
|
||||||
return inv.containsAtLeast(m, m.getAmount());
|
return inv.containsAtLeast(m, m.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,10 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void loadProjectilesConfig() {
|
private static void loadProjectilesConfig() {
|
||||||
|
projectileMap.clear();
|
||||||
|
|
||||||
for (String projectileName : config.getConfigurationSection("Projectiles").getKeys(false)) {
|
for (String projectileName : config.getConfigurationSection("Projectiles").getKeys(false)) {
|
||||||
|
|
||||||
ProjectileType projectileType = null;
|
ProjectileType projectileType = null;
|
||||||
try {
|
try {
|
||||||
projectileType = ProjectileType
|
projectileType = ProjectileType
|
||||||
@@ -141,28 +144,25 @@ public class Config {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
projectileMap.clear();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (projectileType) {
|
switch (projectileType) {
|
||||||
case EXPLOSIVE:
|
case EXPLOSIVE:
|
||||||
SiegeEnginesLogger.info(projectileName);
|
|
||||||
ExplosiveProjectile explosiveProjectile = new ExplosiveProjectile(new ItemStack(
|
ExplosiveProjectile explosiveProjectile = new ExplosiveProjectile(new ItemStack(
|
||||||
Material.getMaterial(config.getString("Projectiles." + projectileName + ".AmmoItem"))));
|
Material.getMaterial(config.getString("Projectiles." + projectileName + ".AmmoItem"))));
|
||||||
explosiveProjectile.explodePower = (float) config.getDouble("Projectiles." + projectileName + ".ExplodePower");
|
explosiveProjectile.explodePower = (float) config.getDouble("Projectiles." + projectileName + ".ExplodePower");
|
||||||
explosiveProjectile.inaccuracy = (float) config.getDouble("Projectiles." + projectileName + ".Inaccuracy");
|
explosiveProjectile.inaccuracy = (float) config.getDouble("Projectiles." + projectileName + ".Inaccuracy");
|
||||||
explosiveProjectile.projectilesCount = config.getInt("Projectiles." + projectileName + ".ProjectileCount");
|
explosiveProjectile.projectilesCount = config.getInt("Projectiles." + projectileName + ".ProjectileCount");
|
||||||
projectileMap.put(projectileName, explosiveProjectile);
|
projectileMap.put(projectileName, explosiveProjectile);
|
||||||
|
break;
|
||||||
case ENTITY:
|
case ENTITY:
|
||||||
SiegeEnginesLogger.info(projectileName);
|
|
||||||
EntityProjectile entityProjectile = new EntityProjectile(new ItemStack(
|
EntityProjectile entityProjectile = new EntityProjectile(new ItemStack(
|
||||||
Material.getMaterial(config.getString("Projectiles." + projectileName + ".AmmoItem"))));
|
Material.getMaterial(config.getString("Projectiles." + projectileName + ".AmmoItem"))));
|
||||||
entityProjectile.inaccuracy = (float) config.getDouble("Projectiles." + projectileName + ".Inaccuracy");
|
entityProjectile.inaccuracy = (float) config.getDouble("Projectiles." + projectileName + ".Inaccuracy");
|
||||||
entityProjectile.entityCount = config.getInt("Projectiles." + projectileName + ".EntityCount");
|
entityProjectile.entityCount = config.getInt("Projectiles." + projectileName + ".EntityCount");
|
||||||
entityProjectile.entityType = EntityType.valueOf(config.getString("Projectiles." + projectileName + ".EntityType"));
|
entityProjectile.entityType = EntityType.valueOf(config.getString("Projectiles." + projectileName + ".EntityShotType"));
|
||||||
projectileMap.put(projectileName, entityProjectile);
|
projectileMap.put(projectileName, entityProjectile);
|
||||||
|
break;
|
||||||
case FIREWORK:
|
case FIREWORK:
|
||||||
SiegeEnginesLogger.info(projectileName);
|
|
||||||
FireworkProjectile fireworkProjectile = new FireworkProjectile(SiegeEnginesUtil.DEFAULT_ROCKET);
|
FireworkProjectile fireworkProjectile = new FireworkProjectile(SiegeEnginesUtil.DEFAULT_ROCKET);
|
||||||
fireworkProjectile.inaccuracy = (float) config.getDouble("Projectiles." + projectileName + ".Inaccuracy");
|
fireworkProjectile.inaccuracy = (float) config.getDouble("Projectiles." + projectileName + ".Inaccuracy");
|
||||||
fireworkProjectile.entityCount = config.getInt("Projectiles." + projectileName + ".EntityCount");
|
fireworkProjectile.entityCount = config.getInt("Projectiles." + projectileName + ".EntityCount");
|
||||||
@@ -173,11 +173,11 @@ public class Config {
|
|||||||
fireworkProjectile.delayedFire = true;
|
fireworkProjectile.delayedFire = true;
|
||||||
}
|
}
|
||||||
projectileMap.put(projectileName, fireworkProjectile);
|
projectileMap.put(projectileName, fireworkProjectile);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
} catch(Exception e) {
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ public class ClickHandler implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void interact(PlayerInteractEvent event, ItemStack inventoryItem) {
|
public void interact(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
ItemStack ItemInHand = event.getPlayer().getInventory().getItemInMainHand();
|
ItemStack ItemInHand = event.getPlayer().getInventory().getItemInMainHand();
|
||||||
|
|||||||
@@ -33,37 +33,37 @@ AutoReload: false
|
|||||||
|
|
||||||
Projectiles:
|
Projectiles:
|
||||||
StoneShot:
|
StoneShot:
|
||||||
ProjectileType: EXPLOSIVE
|
ProjectileType: "EXPLOSIVE"
|
||||||
ExplodePower: 1.0
|
ExplodePower: 1.0
|
||||||
Inaccuracy: 0.3
|
Inaccuracy: 0.3
|
||||||
ProjectileCount: 1
|
ProjectileCount: 1
|
||||||
AmmoItem: COBBLESTONE
|
AmmoItem: "COBBLESTONE"
|
||||||
BreachShot:
|
BreachShot:
|
||||||
ProjectileType: EXPLOSIVE
|
ProjectileType: "EXPLOSIVE"
|
||||||
ExplodePower: 3.0
|
ExplodePower: 3.0
|
||||||
Inaccuracy: 0.3
|
Inaccuracy: 0.3
|
||||||
ProjectileCount: 1
|
ProjectileCount: 1
|
||||||
AmmoItem: IRON_BLOCK
|
AmmoItem: "IRON_BLOCK"
|
||||||
RepeatingShot:
|
RepeatingShot:
|
||||||
ProjectileType: EXPLOSIVE
|
ProjectileType: "EXPLOSIVE"
|
||||||
ExplodePower: 1.0
|
ExplodePower: 1.0
|
||||||
Inaccuracy: 0.45
|
Inaccuracy: 0.45
|
||||||
ProjectileCount: 5
|
ProjectileCount: 5
|
||||||
AmmoItem: TNT
|
AmmoItem: "TNT"
|
||||||
ScatterShot:
|
ScatterShot:
|
||||||
ProjectileType: ENTITY
|
ProjectileType: "ENTITY"
|
||||||
Inaccuracy: 0.325
|
Inaccuracy: 0.325
|
||||||
EntityCount: 24
|
EntityCount: 24
|
||||||
EntityType: ARROW
|
EntityShotType: "ARROW"
|
||||||
AmmoItem: GRAVEL
|
AmmoItem: "GRAVEL"
|
||||||
FireShot:
|
FireShot:
|
||||||
ProjectileType: ENTITY
|
ProjectileType: "ENTITY"
|
||||||
Inaccuracy: 0.75
|
Inaccuracy: 0.75
|
||||||
EntityCount: 4
|
EntityCount: 4
|
||||||
EntityType: SMALL_FIREBALL
|
EntityShotType: "SMALL_FIREBALL"
|
||||||
AmmoItem: MAGMA_BLOCK
|
AmmoItem: "MAGMA_BLOCK"
|
||||||
FireworkShot:
|
FireworkShot:
|
||||||
ProjectileType: FIREWORK
|
ProjectileType: "FIREWORK"
|
||||||
Inaccuracy: 0.125
|
Inaccuracy: 0.125
|
||||||
EntityCount: 1
|
EntityCount: 1
|
||||||
Delay: 6
|
Delay: 6
|
||||||
|
|||||||
Reference in new issue
Block a user