diff --git a/pom.xml b/pom.xml
index 8c991ea..b597461 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,6 +15,20 @@
1.5.1
1_5_R2
+
+
+ ${project.artifactId}
+
+
+ ${project.basedir}/src/main/resources
+
+
+ **
+
+ true
+
+
+
scm:git:git://github.com/Dragonphase/Kits.git
diff --git a/src/main/java/com/dragonphase/Kits/Commands/KitCommandExecutor.java b/src/main/java/com/dragonphase/Kits/Commands/KitCommandExecutor.java
index f132a1c..7e3791f 100644
--- a/src/main/java/com/dragonphase/Kits/Commands/KitCommandExecutor.java
+++ b/src/main/java/com/dragonphase/Kits/Commands/KitCommandExecutor.java
@@ -18,12 +18,37 @@ public class KitCommandExecutor implements CommandExecutor{
public KitCommandExecutor(Kits instance) {
plugin = instance;
+ Kit.setParent(plugin);
}
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
- if (!(sender instanceof Player)) return false;
+ if (!(sender instanceof Player)){
+ if (args.length == 2){
+ String arg = args[0];
+
+ Player receiver = Bukkit.getPlayerExact(args[1]);
+
+ if (Kit.exists(arg)){
+ if (receiver != null){
+ ItemStack[] itemList = Kit.getKit(arg);
+ for (int i = 0; i < itemList.length; i ++){
+ receiver.getInventory().setItem(i, itemList[i]);
+ }
+ receiver.updateInventory();
+ receiver.sendMessage(Message.info("Kit " + arg + " spawned by Console."));
+ sender.sendMessage(Message.info("Kit " + arg + " spawned for " + receiver.getName() + "."));
+ }else{
+ sender.sendMessage(Message.warning(args[1] + " is not online."));
+ }
+ }else{
+ sender.sendMessage(Message.warning("Kit " + arg + " does not exist."));
+ }
+ }
+ return false;
+ }
+
Player player = (Player) sender;
if (args.length == 0){
@@ -40,11 +65,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String command, Stri
player.sendMessage(Message.info("/kit remove "));
}else{
if (player.hasPermission("kits.spawn." + arg)){
- if (Kits.playerDelayed(player)){
- if (Kits.getRemainingTime(player) < 1){
- Kits.removeDelayedPlayer(player);
+ if (plugin.playerDelayed(player)){
+ if (plugin.getRemainingTime(player) < 1){
+ plugin.removeDelayedPlayer(player);
}else{
- int remaining = Kits.getRemainingTime(player);
+ int remaining = plugin.getRemainingTime(player);
String seconds = remaining == 1 ? " second" : " seconds";
player.sendMessage(Message.warning("You must wait " + remaining + seconds + " before spawning another kit."));
return false;
@@ -58,7 +83,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String command, Stri
player.updateInventory();
player.sendMessage(Message.info("Kit " + arg + " spawned."));
- if (!player.hasPermission("kits.bypassdelay") && Kits.getDelay(1) > 0) Kits.addDelayedPlayer(player);
+ if (!player.hasPermission("kits.bypassdelay") && plugin.getDelay(1) > 0) plugin.addDelayedPlayer(player);
}else{
player.sendMessage(Message.warning("Kit " + arg + " does not exist."));
}
@@ -94,7 +119,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String command, Stri
}else if (arg.equalsIgnoreCase("remove")){
if (player.hasPermission("kits.admin")){
if (Kit.exists(args[1])){
- Kits.kitsFile.set(args[1], null, false);
+ plugin.getKitsConfig().set(args[1], null, false);
player.sendMessage(Message.info("Kit " + args[1] + " has been removed."));
}else{
player.sendMessage(Message.warning("Kit " + args[1] + " does not exist."));
@@ -106,11 +131,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String command, Stri
if (player.hasPermission("kits.others.spawn." + arg)){
Player receiver = Bukkit.getPlayerExact(args[1]);
- if (Kits.playerDelayed(receiver)){
- if (Kits.getRemainingTime(receiver) < 1){
- Kits.removeDelayedPlayer(receiver);
+ if (plugin.playerDelayed(receiver)){
+ if (plugin.getRemainingTime(receiver) < 1){
+ plugin.removeDelayedPlayer(receiver);
}else{
- int remaining = Kits.getRemainingTime(receiver);
+ int remaining = plugin.getRemainingTime(receiver);
String seconds = remaining == 1 ? " second" : " seconds";
player.sendMessage(Message.warning(receiver.getName() + " must wait " + remaining + seconds + " before spawning another kit."));
return false;
@@ -127,7 +152,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String command, Stri
receiver.sendMessage(Message.info("Kit " + arg + " spawned by " + player.getName() + "."));
player.sendMessage(Message.info("Kit " + arg + " spawned for " + receiver.getName() + "."));
- if (!receiver.hasPermission("kits.bypassdelay") && Kits.getDelay(1) > 0) Kits.addDelayedPlayer(receiver);
+ if (!receiver.hasPermission("kits.bypassdelay") && plugin.getDelay(1) > 0) plugin.addDelayedPlayer(receiver);
}else{
player.sendMessage(Message.warning(args[1] + " is not online."));
}
diff --git a/src/main/java/com/dragonphase/Kits/Commands/KitsCommandExecutor.java b/src/main/java/com/dragonphase/Kits/Commands/KitsCommandExecutor.java
index d3897c5..0ad3b3a 100644
--- a/src/main/java/com/dragonphase/Kits/Commands/KitsCommandExecutor.java
+++ b/src/main/java/com/dragonphase/Kits/Commands/KitsCommandExecutor.java
@@ -32,7 +32,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String command, Stri
}
}else{
String kits = "";
- for (String string : Kits.kitsFile.getKeys(false)){
+ for (String string : plugin.getKitsConfig().getKeys(false)){
kits += string + ", ";
}
if (kits != "" || !kits.isEmpty()){
diff --git a/src/main/java/com/dragonphase/Kits/Kits.java b/src/main/java/com/dragonphase/Kits/Kits.java
index e32e7cc..9ccd1c4 100644
--- a/src/main/java/com/dragonphase/Kits/Kits.java
+++ b/src/main/java/com/dragonphase/Kits/Kits.java
@@ -14,12 +14,10 @@
public class Kits extends JavaPlugin{
public final Logger logger = Logger.getLogger("Minecraft");
- public static Kits plugin;
- public static FileManager configurationFile;
- public static FileManager kitsFile;
+ private FileManager config, kits;
- private static HashMap delayedPlayers;
- private static int delay;
+ private HashMap delayedPlayers;
+ private int delay;
@Override
public void onDisable(){
@@ -34,11 +32,11 @@ public void onEnable(){
saveDefaultConfig();
getConfig().options().copyDefaults(true);
- configurationFile = new FileManager(this, "config.yml");
- kitsFile = new FileManager(this, "kits.yml");
+ config = new FileManager(this, "config.yml");
+ setKits(new FileManager(this, "kits.yml"));
delayedPlayers = new HashMap();
- delay = Kits.configurationFile.getInt("options.delay");
+ delay = config.getInt("options.delay");
getServer().getPluginManager().registerEvents(new EventListener(this), this);
@@ -48,10 +46,10 @@ public void onEnable(){
public void reload(){
reloadConfig();
- configurationFile.loadFile();
- kitsFile.loadFile();
+ config.loadFile();
+ getKitsConfig().loadFile();
- delay = Kits.configurationFile.getInt("options.delay");
+ delay = config.getInt("options.delay");
}
public String getPluginDetails(){
@@ -66,27 +64,35 @@ public String getPluginVersion(){
return getDescription().getVersion();
}
- public static void addDelayedPlayer(Player player){
+ public void addDelayedPlayer(Player player){
delayedPlayers.put(player, System.currentTimeMillis());
}
- public static void removeDelayedPlayer(Player player){
+ public void removeDelayedPlayer(Player player){
delayedPlayers.remove(player);
}
- public static boolean playerDelayed(Player player){
+ public boolean playerDelayed(Player player){
return delayedPlayers.containsKey(player);
}
- public static Long getPlayerDelay(Player player){
+ public Long getPlayerDelay(Player player){
return delayedPlayers.get(player);
}
- public static int getDelay(int multiplier){
+ public int getDelay(int multiplier){
return delay*multiplier;
}
- public static int getRemainingTime(Player player){
+ public int getRemainingTime(Player player){
return (int) (getDelay(1) - ((System.currentTimeMillis() - getPlayerDelay(player))/1000));
}
+
+ public FileManager getKitsConfig() {
+ return kits;
+ }
+
+ public void setKits(FileManager kits) {
+ this.kits = kits;
+ }
}
diff --git a/src/main/java/com/dragonphase/Kits/Listeners/EventListener.java b/src/main/java/com/dragonphase/Kits/Listeners/EventListener.java
index 867f557..4442a42 100644
--- a/src/main/java/com/dragonphase/Kits/Listeners/EventListener.java
+++ b/src/main/java/com/dragonphase/Kits/Listeners/EventListener.java
@@ -6,6 +6,7 @@
import java.util.logging.Logger;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
@@ -43,22 +44,22 @@ public void onInventoryClose(InventoryCloseEvent event){
if (((MetadataValue)player.getMetadata("editingKit").get(0)).asBoolean()){
String kit = inventory.getTitle();
- Kits.kitsFile.set(kit, inventory.getContents(), false);
+ plugin.getKitsConfig().set(kit, inventory.getContents(), false);
player.sendMessage(Message.info("Kit " + kit + " has been updated."));
player.setMetadata("editingKit", new FixedMetadataValue(plugin, Boolean.valueOf(false)));
- Kits.kitsFile.loadFile();
+ plugin.getKitsConfig().loadFile();
}
if (((MetadataValue)player.getMetadata("creatingKit").get(0)).asBoolean()){
String kit = inventory.getTitle();
- Kits.kitsFile.set(kit, inventory.getContents(), false);
+ plugin.getKitsConfig().set(kit, inventory.getContents(), false);
player.sendMessage(Message.info("Kit " + kit + " has been created."));
player.setMetadata("creatingKit", new FixedMetadataValue(plugin, Boolean.valueOf(false)));
- Kits.kitsFile.loadFile();
+ plugin.getKitsConfig().loadFile();
}
}
catch (Exception ex)
@@ -67,47 +68,58 @@ public void onInventoryClose(InventoryCloseEvent event){
}
}
- @SuppressWarnings("deprecation")
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
- if ((event.getAction() != Action.RIGHT_CLICK_BLOCK) && (event.getAction() != Action.RIGHT_CLICK_AIR)) return;
+ if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getState() instanceof Sign){
+ handleSignClick(event.getPlayer(), (Sign)event.getClickedBlock().getState());
- if ((event.getClickedBlock().getState() instanceof Sign)){
- for (int i = 0; i < 4; i++){
- if (((Sign)event.getClickedBlock().getState()).getLines()[i].equalsIgnoreCase("[kit]") && i != 3){
- try{
- Player player = event.getPlayer();
- String arg = ((Sign)event.getClickedBlock().getState()).getLines()[i+1];
- if (player.hasPermission("kits.spawn." + arg)){
- if (Kits.playerDelayed(player)){
- if (Kits.getRemainingTime(player) < 1){
- Kits.removeDelayedPlayer(player);
- }else{
- int remaining = Kits.getRemainingTime(player);
- String seconds = remaining == 1 ? " second" : " seconds";
- player.sendMessage(Message.warning("You must wait " + remaining + seconds + " before spawning another kit."));
- return;
- }
- }
- if (Kit.exists(arg)){
- ItemStack[] itemList = Kit.getKit(arg);
- for (int x = 0; x < itemList.length; x++){
- player.getInventory().setItem(x, itemList[x]);
- }
- player.updateInventory();
- player.sendMessage(Message.info("Kit " + arg + " spawned."));
+ event.setUseItemInHand(Result.DENY);
+ event.setUseInteractedBlock(Result.DENY);
+ }else if (event.getAction() == Action.RIGHT_CLICK_AIR && event.getPlayer().getTargetBlock(null, 5).getState() instanceof Sign){
+ handleSignClick(event.getPlayer(), (Sign)event.getPlayer().getTargetBlock(null, 5).getState());
- if ((!player.hasPermission("kits.bypassdelay")) && (Kits.getDelay(1) > 0)) Kits.addDelayedPlayer(player);
+ event.setUseItemInHand(Result.DENY);
+ event.setUseInteractedBlock(Result.DENY);
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public void handleSignClick(Player player, Sign sign){
+ for (int i = 0; i < 4; i++){
+ if (sign.getLines()[i].equalsIgnoreCase("[kit]") && i != 3){
+ try{
+ String arg = sign.getLines()[i+1];
+ if (player.hasPermission("kits.spawn." + arg)){
+ if (plugin.playerDelayed(player)){
+ if (plugin.getRemainingTime(player) < 1){
+ plugin.removeDelayedPlayer(player);
+ }else{
+ int remaining = plugin.getRemainingTime(player);
+ String seconds = remaining == 1 ? " second" : " seconds";
+ player.sendMessage(Message.warning("You must wait " + remaining + seconds + " before spawning another kit."));
+ return;
}
- else{ player.sendMessage(Message.warning("Kit " + arg + " does not exist.")); }
+ }
+ if (Kit.exists(arg)){
+ ItemStack[] itemList = Kit.getKit(arg);
+ for (int x = 0; x < itemList.length; x++){
+ player.getInventory().setItem(x, itemList[x]);
+ }
+ player.updateInventory();
+ player.sendMessage(Message.info("Kit " + arg + " spawned."));
+
+ if ((!player.hasPermission("kits.bypassdelay")) && (plugin.getDelay(1) > 0)) plugin.addDelayedPlayer(player);
}
else{
- player.sendMessage(Message.warning("Incorrect Permissions."));
+ player.sendMessage(Message.warning("Kit " + arg + " does not exist."));
}
- }catch (Exception ex){
- continue;
}
+ else{
+ player.sendMessage(Message.warning("Incorrect Permissions."));
+ }
+ }catch (Exception ex){
+ continue;
}
}
}
diff --git a/src/main/java/com/dragonphase/Kits/Util/Kit.java b/src/main/java/com/dragonphase/Kits/Util/Kit.java
index ab7b793..0882f82 100644
--- a/src/main/java/com/dragonphase/Kits/Util/Kit.java
+++ b/src/main/java/com/dragonphase/Kits/Util/Kit.java
@@ -8,16 +8,22 @@
public class Kit {
+ private static Kits plugin;
+
+ public static void setParent(Kits instance){
+ plugin = instance;
+ }
+
public static boolean exists(String kitName){
boolean exists = false;
- for (String key : Kits.kitsFile.getKeys(false)){
+ for (String key : plugin.getKitsConfig().getKeys(false)){
if (key.equals(kitName)) exists = true;
}
return exists;
}
public static ItemStack[] getKit(String kitName){
- return Kits.kitsFile.getInventory(kitName);
+ return plugin.getKitsConfig().getInventory(kitName);
}
public static void create(Plugin plugin, Player player, String kitName) {
@@ -34,6 +40,6 @@ public static void edit(Plugin plugin, Player player, String kitName) {
}
public static int kitSize(String kit){
- return Kits.kitsFile.getConfigurationSection(kit).getKeys(false).size();
+ return plugin.getKitsConfig().getConfigurationSection(kit).getKeys(false).size();
}
}
\ No newline at end of file
diff --git a/src/main/java/com/dragonphase/Kits/Util/Message.java b/src/main/java/com/dragonphase/Kits/Util/Message.java
index 2a0528a..dde0975 100644
--- a/src/main/java/com/dragonphase/Kits/Util/Message.java
+++ b/src/main/java/com/dragonphase/Kits/Util/Message.java
@@ -5,22 +5,21 @@
import com.dragonphase.Kits.Kits;
public class Message {
-
- public static Kits plugin;
-
- public static void setParent(Kits instance){
- plugin = instance;
- }
-
- public static String message(String message){
- return ChatColor.DARK_GRAY + plugin.getPluginName() + ": " + ChatColor.GRAY + message;
- }
-
- public static String warning(String message){
- return ChatColor.DARK_GRAY + plugin.getPluginName() + ": " + ChatColor.RED + message;
- }
-
- public static String info(String message){
- return ChatColor.DARK_GRAY + plugin.getPluginName() + ": " + ChatColor.DARK_AQUA + message;
- }
+ private static String pluginName;
+
+ public static void setParent(Kits instance){
+ pluginName = instance.getPluginName();
+ }
+
+ public static String message(String message){
+ return ChatColor.DARK_GRAY + pluginName + ": " + ChatColor.GRAY + message;
+ }
+
+ public static String warning(String message){
+ return ChatColor.DARK_GRAY + pluginName + ": " + ChatColor.RED + message;
+ }
+
+ public static String info(String message){
+ return ChatColor.DARK_GRAY + pluginName + ": " + ChatColor.DARK_AQUA + message;
+ }
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index df1e535..f353c63 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -2,6 +2,9 @@
# Kits Configuration #
#--------------------------------------#
# #
+# The amount of bars in kit creation #
+# chere are in the kits. T #
+# #
# Delays can be set up when spawning #
# kits. Delays are managed in seconds. #
# #
@@ -16,4 +19,6 @@
#--------------------------------------#
options:
- delay: 0
\ No newline at end of file
+ bars: 1
+ delay: 0
+ overwrite: false
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index d02eb58..35660f0 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
name: Kits
main: com.dragonphase.Kits.Kits
-version: 1.3
+version: ${project.version}
website: http://dragonphase.com/
depend: []
description: >