+ Added tokens set/take/add command.
This commit is contained in:
parent
c3d4585b74
commit
a8f5d2b22d
@ -21,6 +21,7 @@ import nl.Steffion.BlockHunt.Commands.CMDsetwarp;
|
||||
import nl.Steffion.BlockHunt.Commands.CMDshop;
|
||||
import nl.Steffion.BlockHunt.Commands.CMDstart;
|
||||
import nl.Steffion.BlockHunt.Commands.CMDwand;
|
||||
import nl.Steffion.BlockHunt.Commands.CMDtokens;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnBlockBreakEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnBlockPlaceEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnEntityDamageByEntityEvent;
|
||||
@ -95,6 +96,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
add("set");
|
||||
add("setwarp");
|
||||
add("remove");
|
||||
add("tokens");
|
||||
}
|
||||
};
|
||||
|
||||
@ -112,6 +114,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
public static CommandM CMDset;
|
||||
public static CommandM CMDsetwarp;
|
||||
public static CommandM CMDremove;
|
||||
public static CommandM CMDtokens;
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
@ -213,6 +216,11 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_remove),
|
||||
BlockHuntCMD, new CMDremove(),
|
||||
"/BlockHunt <remove|delete> <arenaname>");
|
||||
CMDtokens = new CommandM("BlockHunt TOKENS", "BlockHunt", "tokens",
|
||||
"t", Permissions.tokens, ConfigC.help_tokens,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_tokens),
|
||||
BlockHuntCMD, new CMDtokens(),
|
||||
"/BlockHunt <tokens|t> <set|add|take> <playername> <amount>");
|
||||
|
||||
if (!getServer().getPluginManager().isPluginEnabled("DisguiseCraft")) {
|
||||
MessageM.broadcastFMessage(ConfigC.error_disguiseCraftNotInstalled);
|
||||
|
91
src/nl/Steffion/BlockHunt/Commands/CMDtokens.java
Normal file
91
src/nl/Steffion/BlockHunt/Commands/CMDtokens.java
Normal file
@ -0,0 +1,91 @@
|
||||
package nl.Steffion.BlockHunt.Commands;
|
||||
|
||||
import nl.Steffion.BlockHunt.BlockHunt;
|
||||
import nl.Steffion.BlockHunt.ConfigC;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CMDtokens extends DefaultCMD {
|
||||
/**
|
||||
* Steffion's Engine - Made by Steffion.
|
||||
*
|
||||
* You're allowed to use this engine for own usage, you're not allowed to
|
||||
* republish the engine. Using this for your own plugin is allowed when a
|
||||
* credit is placed somewhere in the plugin.
|
||||
*
|
||||
* Thanks for your cooperate!
|
||||
*
|
||||
* @author Steffion
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
if (args.length <= 3) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
|
||||
"syntax-" + BlockHunt.CMDtokens.usage);
|
||||
} else {
|
||||
String option = args[1];
|
||||
String playerName = args[2];
|
||||
int amount = 0;
|
||||
try {
|
||||
amount = Integer.valueOf(args[3]);
|
||||
} catch (NumberFormatException e) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_notANumber, "1-"
|
||||
+ args[3]);
|
||||
return true;
|
||||
}
|
||||
|
||||
Player tokenPlayer = Bukkit.getPlayer(playerName);
|
||||
if (tokenPlayer == null) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_tokensPlayerNotOnline, "playername-"
|
||||
+ playerName);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (option.equalsIgnoreCase("set")) {
|
||||
W.shop.getFile().set(tokenPlayer.getName() + ".tokens", amount);
|
||||
W.shop.save();
|
||||
MessageM.sendFMessage(tokenPlayer,
|
||||
ConfigC.normal_tokensChanged, "option-Set",
|
||||
"playername-" + tokenPlayer.getName(), "option2-to",
|
||||
"amount-" + amount);
|
||||
} else if (option.equalsIgnoreCase("add")) {
|
||||
int tokens = 0;
|
||||
if (W.shop.getFile().getInt(tokenPlayer.getName() + ".tokens") != 0) {
|
||||
tokens = W.shop.getFile().getInt(
|
||||
tokenPlayer.getName() + ".tokens");
|
||||
}
|
||||
W.shop.getFile().set(tokenPlayer.getName() + ".tokens",
|
||||
tokens + amount);
|
||||
W.shop.save();
|
||||
MessageM.sendFMessage(tokenPlayer,
|
||||
ConfigC.normal_tokensChanged, "option-Added",
|
||||
"playername-" + tokenPlayer.getName(), "option2-to",
|
||||
"amount-" + amount);
|
||||
} else if (option.equalsIgnoreCase("take")) {
|
||||
int tokens = 0;
|
||||
if (W.shop.getFile().getInt(tokenPlayer.getName() + ".tokens") != 0) {
|
||||
tokens = W.shop.getFile().getInt(
|
||||
tokenPlayer.getName() + ".tokens");
|
||||
}
|
||||
W.shop.getFile().set(tokenPlayer.getName() + ".tokens",
|
||||
tokens - amount);
|
||||
W.shop.save();
|
||||
MessageM.sendFMessage(tokenPlayer,
|
||||
ConfigC.normal_tokensChanged, "option-Took",
|
||||
"playername-" + tokenPlayer.getName(), "option2-from",
|
||||
"amount-" + amount);
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_tokensUnknownsetting, "option-" + option);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ public enum ConfigC {
|
||||
commandEnabled_set (true, W.config),
|
||||
commandEnabled_setwarp (true, W.config),
|
||||
commandEnabled_remove (true, W.config),
|
||||
commandEnabled_tokens (true, W.config),
|
||||
|
||||
autoUpdateCheck (true, W.config),
|
||||
autoDownloadUpdate (false, W.config),
|
||||
@ -109,6 +110,7 @@ public enum ConfigC {
|
||||
help_set ("%NOpens a panel to set settings.", W.messages),
|
||||
help_setwarp ("%NSets warps for your arena.", W.messages),
|
||||
help_remove ("%NDeletes an Arena.", W.messages),
|
||||
help_tokens ("%NChange someones tokens.", W.messages),
|
||||
|
||||
button_add ("%NAdd %A%1%%N to %A%2%%N", W.messages),
|
||||
button_add2 ("Add", W.messages),
|
||||
@ -153,13 +155,15 @@ public enum ConfigC {
|
||||
normal_addedToken ("%TAG%A%amount%%N tokens were added to your account!",
|
||||
W.messages),
|
||||
normal_removeRemovedArena ("%TAG%NRemoved arena '%A%name%%N'!", W.messages),
|
||||
normal_tokensChanged ("%TAG%N%option% %A%amount%%N tokens %option2% %A%playername%%N.",
|
||||
W.messages),
|
||||
normal_ingameNowSolid ("%TAG%NYou're now a solid '%A%block%%N' block!",
|
||||
W.messages),
|
||||
normal_ingameNoMoreSolid ("%TAG%NYou're no longer a solid block!",
|
||||
W.messages),
|
||||
normal_ShopBoughtItem ("%TAG%NYou've bought the '%A%itemname%%N' item!",
|
||||
normal_shopBoughtItem ("%TAG%NYou've bought the '%A%itemname%%N' item!",
|
||||
W.messages),
|
||||
normal_ShopChoosenBlock ("%TAG%NYou've choosen to be a(n) '%A%block%%N' block!",
|
||||
normal_shopChoosenBlock ("%TAG%NYou've choosen to be a(n) '%A%block%%N' block!",
|
||||
W.messages),
|
||||
|
||||
warning_lobbyNeedAtleast ("%TAG%WYou need atleast %A%1%%W player(s) to start the game!",
|
||||
@ -175,12 +179,13 @@ public enum ConfigC {
|
||||
|
||||
error_noPermission ("%TAG%EYou don't have the permissions to do that!",
|
||||
W.messages),
|
||||
error_notANumber ("%TAG%E'%A%1%%E' is not a number!", W.messages),
|
||||
error_commandNotEnabled ("%TAG%EThis command has been disabled!",
|
||||
W.messages),
|
||||
error_commandNotFound ("%TAG%ECouldn't find the command. Try %A/"
|
||||
+ BlockHunt.pdfFile.getName() + " help %Efor more info.",
|
||||
W.messages),
|
||||
error_notEnoughArguments ("%TAG%EYou're missing arguments, correct syntax: %A/%syntax%",
|
||||
error_notEnoughArguments ("%TAG%EYou're missing arguments, correct syntax: %A%syntax%",
|
||||
W.messages),
|
||||
error_disguiseCraftNotInstalled ("%TAG%EThe plugin '%ADisguiseCraft%E' is required to run this plugin! Intall it or it won't work!",
|
||||
W.messages),
|
||||
@ -210,7 +215,11 @@ public enum ConfigC {
|
||||
error_setNotABlock ("%TAG%EThat is not a block!", W.messages),
|
||||
error_setwarpWarpNotFound ("%TAG%EWarp '%A%warp%%E' is not valid!",
|
||||
W.messages),
|
||||
error_ShopNeedMoreTokens ("%TAG%EYou need more tokens before you can buy this item.",
|
||||
error_tokensPlayerNotOnline ("%TAG%ENo player found with the name '%A%playername%%E'!",
|
||||
W.messages),
|
||||
error_tokensUnknownsetting ("%TAG%E'%A%option%%E' is not a known option!",
|
||||
W.messages),
|
||||
error_shopNeedMoreTokens ("%TAG%EYou need more tokens before you can buy this item.",
|
||||
W.messages);
|
||||
|
||||
public Object value;
|
||||
|
@ -75,13 +75,13 @@ public class OnInventoryClickEvent implements Listener {
|
||||
W.shop.save();
|
||||
MessageM.sendFMessage(
|
||||
player,
|
||||
ConfigC.normal_ShopBoughtItem,
|
||||
ConfigC.normal_shopBoughtItem,
|
||||
"itemname-"
|
||||
+ W.config
|
||||
.get(ConfigC.shop_blockChooserName));
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_ShopNeedMoreTokens);
|
||||
ConfigC.error_shopNeedMoreTokens);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class OnInventoryClickEvent implements Listener {
|
||||
if (event.getCurrentItem().getType() != Material.AIR) {
|
||||
W.choosenBlock.put(player, event.getCurrentItem());
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_ShopChoosenBlock, "block-"
|
||||
ConfigC.normal_shopChoosenBlock, "block-"
|
||||
+ event.getCurrentItem().getType()
|
||||
.toString().replaceAll("_", "")
|
||||
.replaceAll("BLOCK", "")
|
||||
|
@ -13,8 +13,7 @@ public class PermissionsC {
|
||||
* @author Steffion
|
||||
*/
|
||||
|
||||
public static String main = BlockHunt.pdfFile.getName().toLowerCase()
|
||||
+ ".";
|
||||
public static String main = BlockHunt.pdfFile.getName().toLowerCase() + ".";
|
||||
|
||||
public enum PType {
|
||||
ALL, PLAYER, MODERATOR, ADMIN, OP;
|
||||
@ -35,7 +34,8 @@ public class PermissionsC {
|
||||
set (main + "set", PType.MODERATOR),
|
||||
setwarp (main + "setwarp", PType.MODERATOR),
|
||||
signcreate (main + "signcreate", PType.MODERATOR),
|
||||
remove (main + "remove", PType.ADMIN);
|
||||
remove (main + "remove", PType.ADMIN),
|
||||
tokens (main + "tokens", PType.ADMIN);
|
||||
|
||||
public String perm;
|
||||
public PType type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user