From 555f151692e516444c058d6e69ac33bb1d3473d6 Mon Sep 17 00:00:00 2001 From: drtshock Date: Fri, 17 Apr 2015 14:48:23 -0500 Subject: [PATCH] Allow commands in kits. Adds #15. Syntax is / with the ability to add {player} as an argument. --- Essentials/src/com/earth2me/essentials/Kit.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java index 0de37957f..904abc502 100644 --- a/Essentials/src/com/earth2me/essentials/Kit.java +++ b/Essentials/src/com/earth2me/essentials/Kit.java @@ -9,6 +9,7 @@ import com.earth2me.essentials.textreader.SimpleTextInput; import com.earth2me.essentials.utils.DateUtil; import com.earth2me.essentials.utils.NumberUtil; import net.ess3.api.IEssentials; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemStack; @@ -131,7 +132,7 @@ public class Kit { delayTime.add(Calendar.MILLISECOND, (int) ((delay * 1000.0) % 1000.0)); if (lastTime == 0L || lastTime > time.getTimeInMillis()) { - // If we have no record of kit use, or its corrupted, give them benifit of the doubt. + // If we have no record of kit use, or its corrupted, give them benefit of the doubt. return 0L; } else if (delay < 0d) { // If the kit has a negative kit time, it can only be used once. @@ -188,6 +189,14 @@ public class Kit { continue; } + if(kitItem.startsWith("/")) { + String command = kitItem.substring(1); + String name = user.getName(); + command = command.replace("{player}", name); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); + continue; + } + final String[] parts = kitItem.split(" +"); final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1);