mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-01 22:22:10 +00:00
removed duplicate commands & added config option
This commit is contained in:
1 parent
1987acd70a
commit
4283710716
7 files changed
+42
-69
No files matched your search
@@ -75,6 +75,7 @@ public class SiegeEngines extends JavaPlugin {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
Path = this.getDataFolder().getAbsolutePath();
|
||||
//this.getCommand("SiegeEngines").setExecutor(new GunnersCommand()); // Fixed Start-up
|
||||
getServer().getPluginManager().registerEvents(new RotationHandler(), this);
|
||||
@@ -122,69 +123,6 @@ public class SiegeEngines extends JavaPlugin {
|
||||
return new FixedMetadataValue(Bukkit.getServer().getPluginManager().getPlugin("SiegeEngines"), value);
|
||||
}
|
||||
|
||||
public class GunnersCommand implements CommandExecutor {
|
||||
@Override
|
||||
@EventHandler
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
if (args != null && args.length > 0) {
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "get":
|
||||
if (player == null) {
|
||||
sender.sendMessage("§eonly a player can use this command.");
|
||||
return true;
|
||||
}
|
||||
if (!sender.hasPermission("SiegeEngines.get")) {
|
||||
sender.sendMessage("§eNo perms to SiegeEngines.get");
|
||||
return true;
|
||||
}
|
||||
for (SiegeEquipment i : DefinedEquipment.values()) {
|
||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setCustomModelData(i.ReadyModelNumber);
|
||||
meta.setDisplayName("§e" + i.EquipmentName + " Item");
|
||||
List<String> Lore = new ArrayList<String>();
|
||||
Lore.add("§ePlace as a block to spawn a " + i.EquipmentName);
|
||||
Lore.add("§eor put on an Armor Stand.");
|
||||
Lore.add("§eRight click to toggle visibility of stand.");
|
||||
meta.setLore(Lore);
|
||||
item.setItemMeta(meta);
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
break;
|
||||
case "reload":
|
||||
if (!sender.hasPermission("SiegeEngines.reload")) {
|
||||
sender.sendMessage("§eNo perms to SiegeEngines.reload");
|
||||
return true;
|
||||
}
|
||||
equipment.clear();
|
||||
TrackedStands.clear();
|
||||
DefinedEquipment.clear();
|
||||
AddDefaults();
|
||||
HashMap<ItemStack, GunnersProjectile> projObj = new HashMap<>();
|
||||
SiegeEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj);
|
||||
for (SiegeEquipment i : DefinedEquipment.values()) {
|
||||
sender.sendMessage("§eEnabled Weapon : " + i.EquipmentName);
|
||||
sender.sendMessage("§eWeapon Propellant/\"Fuel\" ItemStacks : " + i.FuelMaterial);
|
||||
for (ItemStack proj : i.Projectiles.keySet()) {
|
||||
sender.sendMessage("§eWeapon Projectile ItemStacks : " + proj);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§eGunners Core configs reloaded");
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
sender.sendMessage("§eIncorrect usage, /SiegeEngines get, /SiegeEngines reload");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static SiegeEquipment CreateClone(Integer ModelId) {
|
||||
try {
|
||||
return DefinedEquipment.get(ModelId).clone();
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.github.alathra.siegeengines;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class SiegeEnginesLogger {
|
||||
|
||||
public static void info(String msg) {
|
||||
Bukkit.getLogger().info("[" + SiegeEngines.plugin.getName() + "]" + msg);
|
||||
}
|
||||
|
||||
public static void warn(String msg) {
|
||||
Bukkit.getLogger().warning("[" + SiegeEngines.plugin.getName() + "]" + msg);
|
||||
}
|
||||
|
||||
public static void severe(String msg) {
|
||||
Bukkit.getLogger().severe("[" + SiegeEngines.plugin.getName() + "]" + msg);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,33 @@
|
||||
package com.github.alathra.siegeengines.config;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.github.alathra.siegeengines.SiegeEngines;
|
||||
import com.github.alathra.siegeengines.SiegeEnginesLogger;
|
||||
|
||||
|
||||
public class Config {
|
||||
|
||||
private static FileConfiguration config;
|
||||
|
||||
// global config version
|
||||
// DEFAULTS
|
||||
public static int configVersion = 1;
|
||||
|
||||
public static Material controlItem = Material.COMPASS;
|
||||
|
||||
public static void initConfigVals() {
|
||||
//init config
|
||||
// init config
|
||||
config = SiegeEngines.getInstance().getConfig();
|
||||
|
||||
// get config values
|
||||
try {
|
||||
controlItem = Material.getMaterial(config.getString("ControlItem"));
|
||||
} catch (Exception e) {
|
||||
SiegeEnginesLogger.warn("Control item material could not be found, defaulting to compass!");
|
||||
controlItem = Material.COMPASS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
import com.github.alathra.siegeengines.SiegeEquipment;
|
||||
import com.github.alathra.siegeengines.config.Config;
|
||||
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
|
||||
|
||||
//import com.palmergames.bukkit.towny.TownyAPI;
|
||||
@@ -275,7 +276,7 @@ public class ClickHandler implements Listener {
|
||||
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||
if (ItemInHand.getType() != Material.COMPASS) {
|
||||
if (ItemInHand.getType() != Config.controlItem) {
|
||||
return;
|
||||
}
|
||||
if (!player.isSneaking())
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.UUID;
|
||||
import com.github.alathra.siegeengines.SiegeEngines;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -20,6 +19,7 @@ import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.github.alathra.siegeengines.SiegeEquipment;
|
||||
import com.github.alathra.siegeengines.config.Config;
|
||||
|
||||
public class RotationHandler implements Listener {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class RotationHandler implements Listener {
|
||||
if (SiegeEngines.TrackedStands.containsKey(player.getUniqueId())) {
|
||||
ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||
if (itemInHand != null) {
|
||||
if (itemInHand.getType() != Material.COMPASS) {
|
||||
if (itemInHand.getType() != Config.controlItem) {
|
||||
// TrackedStands.remove(player.getUniqueId());
|
||||
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user