~ Updated engine.

This commit is contained in:
Steffion 2013-09-22 15:32:02 +02:00
parent 4b6235d548
commit f2dc0f6211
40 changed files with 1388 additions and 1227 deletions

View File

@ -4,12 +4,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import nl.Steffion.BlockHunt.Arena.ArenaState; import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.PermissionsC.Permissions;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.MessageM.CType; import nl.Steffion.BlockHunt.Managers.MessageM.CType;
import nl.Steffion.BlockHunt.Managers.PlayerM; import nl.Steffion.BlockHunt.Managers.PermissionsM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable; import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -38,19 +37,16 @@ public class ArenaHandler {
String... vars) { String... vars) {
for (Player player : arena.playersInArena) { for (Player player : arena.playersInArena) {
String pMessage = message.replaceAll("%player%", player.getName()); String pMessage = message.replaceAll("%player%", player.getName());
player.sendMessage(MessageM.replaceAll(CType.TAG(tag) + pMessage, player.sendMessage(MessageM.replaceAll(CType.TAG() + pMessage, vars));
vars));
} }
} }
public static void sendFMessage(Arena arena, ConfigC location, Boolean tag, public static void sendFMessage(Arena arena, ConfigC location, Boolean tag,
String... vars) { String... vars) {
for (Player player : arena.playersInArena) { for (Player player : arena.playersInArena) {
String pMessage = location.config.getFile() String pMessage = location.config.getFile().get(location.location)
.get(location.getLocation()).toString() .toString().replaceAll("%player%", player.getName());
.replaceAll("%player%", player.getName()); player.sendMessage(MessageM.replaceAll(CType.TAG() + pMessage, vars));
player.sendMessage(MessageM.replaceAll(CType.TAG(tag) + pMessage,
vars));
} }
} }
@ -71,7 +67,7 @@ public class ArenaHandler {
found = true; found = true;
if (arena.disguiseBlocks.isEmpty()) { if (arena.disguiseBlocks.isEmpty()) {
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.error_joinNoBlocksSet, true); ConfigC.error_joinNoBlocksSet);
} else { } else {
LocationSerializable zero = new LocationSerializable( LocationSerializable zero = new LocationSerializable(
Bukkit.getWorld(player.getWorld().getName() Bukkit.getWorld(player.getWorld().getName()
@ -84,11 +80,10 @@ public class ArenaHandler {
if (arena.gameState == ArenaState.WAITING if (arena.gameState == ArenaState.WAITING
|| arena.gameState == ArenaState.STARTING) { || arena.gameState == ArenaState.STARTING) {
if (arena.playersInArena.size() >= arena.maxPlayers) { if (arena.playersInArena.size() >= arena.maxPlayers) {
if (!PlayerM.hasPerm(player, if (!PermissionsM.hasPerm(player,
PermsC.joinfull, false)) { Permissions.joinfull, false)) {
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.error_joinFull, ConfigC.error_joinFull);
true);
return; return;
} }
} }
@ -143,8 +138,7 @@ public class ArenaHandler {
List<String> lores = W.config List<String> lores = W.config
.getFile() .getFile()
.getStringList( .getStringList(
ConfigC.shop_blockChooserDescription ConfigC.shop_blockChooserDescription.location);
.getLocation());
List<String> lores2 = new ArrayList<String>(); List<String> lores2 = new ArrayList<String>();
for (String lore : lores) { for (String lore : lores) {
lores2.add(MessageM lores2.add(MessageM
@ -180,26 +174,26 @@ public class ArenaHandler {
} }
} else { } else {
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.error_joinArenaIngame, true); ConfigC.error_joinArenaIngame);
} }
} else { } else {
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.error_joinWarpsNotSet, true); ConfigC.error_joinWarpsNotSet);
} }
} else { } else {
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.error_joinWarpsNotSet, true); ConfigC.error_joinWarpsNotSet);
} }
} }
} }
} }
} else { } else {
MessageM.sendFMessage(player, ConfigC.error_joinAlreadyJoined, true); MessageM.sendFMessage(player, ConfigC.error_joinAlreadyJoined);
return; return;
} }
if (!found) { if (!found) {
MessageM.sendFMessage(player, ConfigC.error_noArena, true, "name-" MessageM.sendFMessage(player, ConfigC.error_noArena, "name-"
+ arenaname); + arenaname);
} }
@ -311,7 +305,7 @@ public class ArenaHandler {
ScoreboardHandler.removeScoreboard(player); ScoreboardHandler.removeScoreboard(player);
MessageM.sendFMessage(player, ConfigC.normal_leaveYouLeft, true); MessageM.sendFMessage(player, ConfigC.normal_leaveYouLeft);
if (message) { if (message) {
ArenaHandler.sendFMessage(arena, ConfigC.normal_leaveLeftArena, ArenaHandler.sendFMessage(arena, ConfigC.normal_leaveLeftArena,
true, "playername-" + player.getName(), "1-" true, "playername-" + player.getName(), "1-"
@ -320,8 +314,7 @@ public class ArenaHandler {
} }
} else { } else {
if (message) { if (message) {
MessageM.sendFMessage(player, ConfigC.error_leaveNotInArena, MessageM.sendFMessage(player, ConfigC.error_leaveNotInArena);
true);
} }
return; return;
} }
@ -348,7 +341,7 @@ public class ArenaHandler {
playerTokens + arena.seekersTokenWin); playerTokens + arena.seekersTokenWin);
W.shop.save(); W.shop.save();
MessageM.sendFMessage(player, ConfigC.normal_addedToken, true, MessageM.sendFMessage(player, ConfigC.normal_addedToken,
"amount-" + arena.seekersTokenWin); "amount-" + arena.seekersTokenWin);
} }
} }
@ -387,7 +380,7 @@ public class ArenaHandler {
W.shop.save(); W.shop.save();
MessageM.sendFMessage(player, ConfigC.normal_addedToken, MessageM.sendFMessage(player, ConfigC.normal_addedToken,
true, "amount-" + arena.hidersTokenWin); "amount-" + arena.hidersTokenWin);
} }
} }
} }

View File

@ -1,9 +1,26 @@
package nl.Steffion.BlockHunt; package nl.Steffion.BlockHunt;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import nl.Steffion.BlockHunt.Arena.ArenaState; import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.PermissionsC.Permissions;
import nl.Steffion.BlockHunt.Commands.CMDcreate;
import nl.Steffion.BlockHunt.Commands.CMDhelp;
import nl.Steffion.BlockHunt.Commands.CMDinfo;
import nl.Steffion.BlockHunt.Commands.CMDjoin;
import nl.Steffion.BlockHunt.Commands.CMDleave;
import nl.Steffion.BlockHunt.Commands.CMDlist;
import nl.Steffion.BlockHunt.Commands.CMDnotfound;
import nl.Steffion.BlockHunt.Commands.CMDreload;
import nl.Steffion.BlockHunt.Commands.CMDremove;
import nl.Steffion.BlockHunt.Commands.CMDset;
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.Listeners.OnBlockBreakEvent; import nl.Steffion.BlockHunt.Listeners.OnBlockBreakEvent;
import nl.Steffion.BlockHunt.Listeners.OnBlockPlaceEvent; import nl.Steffion.BlockHunt.Listeners.OnBlockPlaceEvent;
import nl.Steffion.BlockHunt.Listeners.OnEntityDamageByEntityEvent; import nl.Steffion.BlockHunt.Listeners.OnEntityDamageByEntityEvent;
@ -17,9 +34,10 @@ import nl.Steffion.BlockHunt.Listeners.OnPlayerInteractEvent;
import nl.Steffion.BlockHunt.Listeners.OnPlayerMoveEvent; import nl.Steffion.BlockHunt.Listeners.OnPlayerMoveEvent;
import nl.Steffion.BlockHunt.Listeners.OnPlayerQuitEvent; import nl.Steffion.BlockHunt.Listeners.OnPlayerQuitEvent;
import nl.Steffion.BlockHunt.Listeners.OnSignChangeEvent; import nl.Steffion.BlockHunt.Listeners.OnSignChangeEvent;
import nl.Steffion.BlockHunt.Managers.CommandC; import nl.Steffion.BlockHunt.Managers.CommandM;
import nl.Steffion.BlockHunt.Managers.ConfigC; import nl.Steffion.BlockHunt.Managers.ConfigM;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PermissionsM;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable; import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -38,6 +56,7 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.mcstats.Metrics; import org.mcstats.Metrics;
@ -46,10 +65,54 @@ import pgDev.bukkit.DisguiseCraft.disguise.Disguise;
import pgDev.bukkit.DisguiseCraft.disguise.DisguiseType; import pgDev.bukkit.DisguiseCraft.disguise.DisguiseType;
public class BlockHunt extends JavaPlugin implements Listener { public class BlockHunt extends JavaPlugin implements Listener {
/* /**
* Made by @author Steffion, © 2013. * 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
*/ */
public static PluginDescriptionFile pdfFile;
@SuppressWarnings("serial")
public static List<String> BlockHuntCMD = new ArrayList<String>() {
{
add("info");
add("help");
add("reload");
add("join");
add("leave");
add("list");
add("shop");
add("start");
add("wand");
add("create");
add("set");
add("setwarp");
add("remove");
}
};
public static CommandM CMD;
public static CommandM CMDinfo;
public static CommandM CMDhelp;
public static CommandM CMDreload;
public static CommandM CMDjoin;
public static CommandM CMDleave;
public static CommandM CMDlist;
public static CommandM CMDshop;
public static CommandM CMDstart;
public static CommandM CMDwand;
public static CommandM CMDcreate;
public static CommandM CMDset;
public static CommandM CMDsetwarp;
public static CommandM CMDremove;
public void onEnable() { public void onEnable() {
getServer().getPluginManager().registerEvents(this, this); getServer().getPluginManager().registerEvents(this, this);
@ -85,16 +148,78 @@ public class BlockHunt extends JavaPlugin implements Listener {
"BlockHuntLocation"); "BlockHuntLocation");
ConfigurationSerialization.registerClass(Arena.class, "BlockHuntArena"); ConfigurationSerialization.registerClass(Arena.class, "BlockHuntArena");
W.newFiles(); pdfFile = getDescription();
ConfigM.newFiles();
CMD = new CommandM("BlockHunt", "BlockHunt", null, null,
Permissions.info, ConfigC.help_info,
(Boolean) W.config.get(ConfigC.commandEnabled_info),
BlockHuntCMD, new CMDinfo(), null);
CMDinfo = new CommandM("BlockHunt INFO", "BlockHunt", "info", "i",
Permissions.info, ConfigC.help_info,
(Boolean) W.config.get(ConfigC.commandEnabled_info),
BlockHuntCMD, new CMDinfo(), "/BlockHunt [info|i]");
CMDhelp = new CommandM("BlockHunt HELP", "BlockHunt", "help", "h",
Permissions.help, ConfigC.help_help,
(Boolean) W.config.get(ConfigC.commandEnabled_help),
BlockHuntCMD, new CMDhelp(),
"/BlockHunt <help|h> [page number]");
CMDreload = new CommandM("BlockHunt RELOAD", "BlockHunt", "reload",
"r", Permissions.reload, ConfigC.help_reload,
(Boolean) W.config.get(ConfigC.commandEnabled_reload),
BlockHuntCMD, new CMDreload(), "/BlockHunt <reload|r>");
CMDjoin = new CommandM("BlockHunt JOIN", "BlockHunt", "join", "j",
Permissions.join, ConfigC.help_join,
(Boolean) W.config.get(ConfigC.commandEnabled_join),
BlockHuntCMD, new CMDjoin(), "/BlockHunt <join|j> <arenaname>");
CMDleave = new CommandM("BlockHunt LEAVE", "BlockHunt", "leave", "l",
Permissions.leave, ConfigC.help_leave,
(Boolean) W.config.get(ConfigC.commandEnabled_leave),
BlockHuntCMD, new CMDleave(), "/BlockHunt <leave|l>");
CMDlist = new CommandM("BlockHunt LIST", "BlockHunt", "list", "li",
Permissions.list, ConfigC.help_list,
(Boolean) W.config.get(ConfigC.commandEnabled_list),
BlockHuntCMD, new CMDlist(), "/BlockHunt <list|li>");
CMDshop = new CommandM("BlockHunt SHOP", "BlockHunt", "shop", "sh",
Permissions.shop, ConfigC.help_shop,
(Boolean) W.config.get(ConfigC.commandEnabled_shop),
BlockHuntCMD, new CMDshop(), "/BlockHunt <shop|sh>");
CMDstart = new CommandM("BlockHunt START", "BlockHunt", "start", "go",
Permissions.start, ConfigC.help_start,
(Boolean) W.config.get(ConfigC.commandEnabled_start),
BlockHuntCMD, new CMDstart(),
"/BlockHunt <start|st> <arenaname>");
CMDwand = new CommandM("BlockHunt WAND", "BlockHunt", "wand", "w",
Permissions.create, ConfigC.help_wand,
(Boolean) W.config.get(ConfigC.commandEnabled_wand),
BlockHuntCMD, new CMDwand(), "/BlockHunt <wand|w>");
CMDcreate = new CommandM("BlockHunt CREATE", "BlockHunt", "create",
"c", Permissions.create, ConfigC.help_create,
(Boolean) W.config.get(ConfigC.commandEnabled_create),
BlockHuntCMD, new CMDcreate(),
"/BlockHunt <create|c> <arenaname>");
CMDset = new CommandM("BlockHunt SET", "BlockHunt", "set", "s",
Permissions.set, ConfigC.help_set,
(Boolean) W.config.get(ConfigC.commandEnabled_set),
BlockHuntCMD, new CMDset(), "/BlockHunt <set|s> <arenaname>");
CMDsetwarp = new CommandM("BlockHunt SETWARP", "BlockHunt", "setwarp",
"sw", Permissions.setwarp, ConfigC.help_setwarp,
(Boolean) W.config.get(ConfigC.commandEnabled_setwarp),
BlockHuntCMD, new CMDsetwarp(),
"/BlockHunt <setwarp|sw> <lobby|hiders|seekers> <arenaname>");
CMDremove = new CommandM("BlockHunt REMOVE", "BlockHunt", "remove",
"delete", Permissions.remove, ConfigC.help_remove,
(Boolean) W.config.get(ConfigC.commandEnabled_remove),
BlockHuntCMD, new CMDremove(),
"/BlockHunt <remove|delete> <arenaname>");
if (!getServer().getPluginManager().isPluginEnabled("DisguiseCraft")) { if (!getServer().getPluginManager().isPluginEnabled("DisguiseCraft")) {
MessageM.broadcastFMessage(ConfigC.error_disguiseCraftNotInstalled, MessageM.broadcastFMessage(ConfigC.error_disguiseCraftNotInstalled);
true);
} }
if (!getServer().getPluginManager().isPluginEnabled("ProtocolLib")) { if (!getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
MessageM.broadcastFMessage(ConfigC.error_protocolLibNotInstalled, MessageM.broadcastFMessage(ConfigC.error_protocolLibNotInstalled);
true);
} }
W.dcAPI = DisguiseCraft.getAPI(); W.dcAPI = DisguiseCraft.getAPI();
@ -108,38 +233,33 @@ public class BlockHunt extends JavaPlugin implements Listener {
metrics_fc.load(metrics.getConfigFile()); metrics_fc.load(metrics.getConfigFile());
if (!metrics_fc.getBoolean("opt-out", false)) { if (!metrics_fc.getBoolean("opt-out", false)) {
MessageM.sendMessage(null, MessageM.sendMessage(null,
"%NSending %AMCStats %Nto their server.", true); "%TAG%NSending %AMCStats %Nto their server.");
} else { } else {
MessageM.sendMessage( MessageM.sendMessage(null,
null, "%TAG%EUnable to send %AMCStats %Eto their server. %AMCStats%E is disabled?");
"%EUnable to send %AMCStats %Eto their server. %AMCStats%E is disabled?",
true);
} }
} catch (IOException e) { } catch (IOException e) {
MessageM.sendMessage( MessageM.sendMessage(null,
null, "%TAG%EUnable to send %AMCStats %Eto their server. Something went wrong ;(!");
"%EUnable to send %AMCStats %Eto their server. Something went wrong ;(!",
true);
} catch (InvalidConfigurationException e) { } catch (InvalidConfigurationException e) {
MessageM.sendMessage( MessageM.sendMessage(null,
null, "%TAG%EUnable to send %AMCStats %Eto their server. Something went wrong ;(!");
"%EUnable to send %AMCStats %Eto their server. Something went wrong ;(!",
true);
} }
if ((Boolean) W.config.get(ConfigC.autoUpdateCheck)) { if ((Boolean) W.config.get(ConfigC.autoUpdateCheck)) {
if ((Boolean) W.config.get(ConfigC.autoDownloadUpdate)) { if ((Boolean) W.config.get(ConfigC.autoDownloadUpdate)) {
new Updater(this, W.pluginName, this.getFile(), new Updater(this, pdfFile.getName(), this.getFile(),
Updater.UpdateType.DEFAULT, true); Updater.UpdateType.DEFAULT, true);
} else { } else {
new Updater(this, W.pluginName, this.getFile(), new Updater(this, pdfFile.getName(), this.getFile(),
Updater.UpdateType.NO_DOWNLOAD, true); Updater.UpdateType.NO_DOWNLOAD, true);
} }
} }
MessageM.sendFMessage(null, ConfigC.log_Enabled, true, "name-" MessageM.sendFMessage(null, ConfigC.log_enabledPlugin, "name-"
+ W.pluginName, "version-" + W.pluginVersion, "autors-" + BlockHunt.pdfFile.getName(),
+ W.pluginAutors); "version-" + BlockHunt.pdfFile.getVersion(), "autors-"
+ BlockHunt.pdfFile.getAuthors().get(0));
getServer().getScheduler().runTaskTimer(this, new Runnable() { getServer().getScheduler().runTaskTimer(this, new Runnable() {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -274,7 +394,6 @@ public class BlockHunt extends JavaPlugin implements Listener {
MessageM.sendFMessage( MessageM.sendFMessage(
arenaPlayer, arenaPlayer,
ConfigC.normal_ingameBlock, ConfigC.normal_ingameBlock,
true,
"block-" "block-"
+ block.getType() + block.getType()
.name() .name()
@ -290,7 +409,6 @@ public class BlockHunt extends JavaPlugin implements Listener {
MessageM.sendFMessage( MessageM.sendFMessage(
arenaPlayer, arenaPlayer,
ConfigC.normal_ingameBlock, ConfigC.normal_ingameBlock,
true,
"block-" "block-"
+ block.getType() + block.getType()
.name() .name()
@ -346,10 +464,8 @@ public class BlockHunt extends JavaPlugin implements Listener {
if (!arena.seekers.contains(arenaPlayer)) { if (!arena.seekers.contains(arenaPlayer)) {
arenaPlayer.getInventory().addItem( arenaPlayer.getInventory().addItem(
sword); sword);
MessageM.sendFMessage( MessageM.sendFMessage(arenaPlayer,
arenaPlayer, ConfigC.normal_ingameGivenSword);
ConfigC.normal_ingameGivenSword,
true);
} }
} }
} }
@ -478,7 +594,6 @@ public class BlockHunt extends JavaPlugin implements Listener {
MessageM.sendFMessage( MessageM.sendFMessage(
player, player,
ConfigC.normal_ingameNowSolid, ConfigC.normal_ingameNowSolid,
true,
"block-" "block-"
+ block.getType() + block.getType()
.name() .name()
@ -495,7 +610,6 @@ public class BlockHunt extends JavaPlugin implements Listener {
MessageM.sendFMessage( MessageM.sendFMessage(
player, player,
ConfigC.normal_ingameNowSolid, ConfigC.normal_ingameNowSolid,
true,
"block-" "block-"
+ block.getType() + block.getType()
.name() .name()
@ -522,8 +636,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
} else { } else {
MessageM.sendFMessage( MessageM.sendFMessage(
player, player,
ConfigC.warning_ingameNoSolidPlace, ConfigC.warning_ingameNoSolidPlace);
true);
} }
} }
} else { } else {
@ -556,19 +669,23 @@ public class BlockHunt extends JavaPlugin implements Listener {
ArenaHandler.stopArena(arena); ArenaHandler.stopArena(arena);
} }
MessageM.sendFMessage(null, ConfigC.log_Disabled, true, "name-" MessageM.sendFMessage(null, ConfigC.log_disabledPlugin, "name-"
+ W.pluginName, "version-" + W.pluginVersion, "autors-" + BlockHunt.pdfFile.getName(),
+ W.pluginAutors); "version-" + BlockHunt.pdfFile.getVersion(), "autors-"
+ BlockHunt.pdfFile.getAuthors().get(0));
} }
/** /**
* Build a string. * Args to String. Makes 1 string.
* *
* @param input * @param input
* String list which should be converted to a string.
* @param startArg * @param startArg
* @return * Start on this length.
*
* @return The converted string.
*/ */
public static String argsBuild(String[] input, int startArg) { public static String stringBuilder(String[] input, int startArg) {
if (input.length - startArg <= 0) { if (input.length - startArg <= 0) {
return null; return null;
} }
@ -587,51 +704,70 @@ public class BlockHunt extends JavaPlugin implements Listener {
player = (Player) sender; player = (Player) sender;
} }
for (CommandC command : CommandC.values()) { for (CommandM command : W.commands) {
String[] commandArgsSplit = command.command.split("%"); if (PermissionsM.hasPerm(player, command.permission, true)) {
String[] argsSplit = commandArgsSplit[1].split("_"); String[] argsSplit = null;
String[] argsSplitAlias = command.alias.split("%")[1].split("_"); String[] argsSplitAlias = null;
if (cmd.getName().equalsIgnoreCase(commandArgsSplit[0])) { if (command.args != null && command.argsalias != null) {
int i = 0; argsSplit = command.args.split("/");
boolean equals = true; argsSplitAlias = command.argsalias.split("/");
if (command.minLenght == 0) {
if (args.length == 0) {
equals = true;
} else {
equals = false;
}
} else {
if (args.length >= command.minLenght) {
for (String arg : argsSplit) {
for (String arga : argsSplitAlias) {
if (!arg.equalsIgnoreCase(args[i])
&& !arga.equalsIgnoreCase(args[i])) {
equals = false;
}
i = i + 1;
}
}
} else {
equals = false;
}
} }
if (equals) { if (cmd.getName().equalsIgnoreCase(command.label)) {
if (W.config.getFile().getBoolean( boolean equals = true;
command.enabled.getLocation())) {
command.cmd.exectue(player, cmd, label, args); if (argsSplit == null) {
if (args.length == 0) {
equals = true;
} else {
equals = false;
}
} else { } else {
MessageM.sendFMessage(player, if (args.length >= argsSplit.length) {
ConfigC.error_commandNotEnabled, true); for (int i2 = argsSplit.length - 1; i2 >= 0; i2 = i2 - 1) {
int loc = argsSplit.length - i2 - 1;
if (!argsSplit[loc].equalsIgnoreCase(args[loc])
&& !argsSplitAlias[loc]
.equalsIgnoreCase(args[loc])) {
equals = false;
}
}
} else {
equals = false;
}
} }
return true; if (equals) {
if (command.enabled) {
command.CMD.exectue(player, cmd, label, args);
} else {
MessageM.sendFMessage(player,
ConfigC.error_commandNotEnabled);
}
return true;
}
} }
} }
} }
CommandC.NOT_FOUND.cmd.exectue(player, cmd, label, args);
CMDnotfound.exectue(player, cmd, label, args);
return true; return true;
} }
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd,
String label, String[] args) {
for (CommandM command : W.commands) {
if (cmd.getName().equalsIgnoreCase(command.label)) {
if (args.length == 1) {
return command.mainTABlist;
}
}
}
return null;
}
} }

View File

@ -3,14 +3,12 @@ package nl.Steffion.BlockHunt.Commands;
import java.util.ArrayList; import java.util.ArrayList;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.ScoreboardHandler; import nl.Steffion.BlockHunt.ScoreboardHandler;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.Managers.CommandC;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -22,51 +20,45 @@ public class CMDcreate extends DefaultCMD {
@Override @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.create, true)) { if (player != null) {
if (player != null) { if (args.length <= 1) {
if (args.length <= 1) { MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
MessageM.sendFMessage(player, "syntax-" + BlockHunt.CMDcreate.usage);
ConfigC.error_notEnoughArguments, true, "syntax-" } else {
+ CommandC.CREATE.usage); if (W.pos1.get(player) != null && W.pos2.get(player) != null) {
} else { if (W.pos1.get(player).getWorld()
if (W.pos1.get(player) != null .equals(W.pos2.get(player).getWorld())) {
&& W.pos2.get(player) != null) { Arena arena = new Arena(args[1], W.pos1.get(player),
if (W.pos1.get(player).getWorld() W.pos2.get(player), 12, 3, 1, 50, 20, 300, 30,
.equals(W.pos2.get(player).getWorld())) { new ArrayList<ItemStack>(), null, null, null,
Arena arena = new Arena(args[1], new ArrayList<String>(),
W.pos1.get(player), W.pos2.get(player), 12, new ArrayList<String>(),
3, 1, 50, 20, 300, 30, new ArrayList<String>(), 10, 50, 8,
new ArrayList<ItemStack>(), null, null, new ArrayList<Player>(), ArenaState.WAITING, 0,
null, new ArrayList<String>(), new ArrayList<Player>(), Bukkit
new ArrayList<String>(), .getScoreboardManager()
new ArrayList<String>(), 10, 50, 8, .getNewScoreboard());
new ArrayList<Player>(), W.arenas.getFile().set(args[1], arena);
ArenaState.WAITING, 0, W.arenas.save();
new ArrayList<Player>(), Bukkit W.signs.load();
.getScoreboardManager()
.getNewScoreboard());
W.arenas.getFile().set(args[1], arena);
W.arenas.save();
W.signs.load();
W.arenaList.add(arena); W.arenaList.add(arena);
ScoreboardHandler.createScoreboard(arena); ScoreboardHandler.createScoreboard(arena);
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.normal_createCreatedArena, true, ConfigC.normal_createCreatedArena, "name-"
"name-" + args[1]); + args[1]);
} else {
MessageM.sendFMessage(player,
ConfigC.error_createNotSameWorld, true);
}
} else { } else {
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.error_createSelectionFirst, true); ConfigC.error_createNotSameWorld);
} }
} else {
MessageM.sendFMessage(player,
ConfigC.error_createSelectionFirst);
} }
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true);
} }
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame);
} }
return true; return true;
} }

View File

@ -1,124 +1,124 @@
package nl.Steffion.BlockHunt.Commands; package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.CommandC; import nl.Steffion.BlockHunt.Managers.CommandM;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM; import nl.Steffion.BlockHunt.Managers.PermissionsM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CMDhelp extends DefaultCMD { public class CMDhelp 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 @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.help, true)) { int amountCommands = 0;
int amountCommands = 0; for (CommandM command : W.commands) {
for (CommandC command : CommandC.values()) { if (command.usage != null) {
if (command.usage != "-") { amountCommands = amountCommands + 1;
amountCommands = amountCommands + 1; }
}
int maxPages = Math.round(amountCommands / 3);
if (maxPages <= 0) {
maxPages = 1;
}
if (args.length == 1) {
int page = 1;
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-"
+ BlockHunt.pdfFile.getName() + " %Nhelp page %A"
+ page + "%N/%A" + maxPages);
int i = 1;
for (CommandM command : W.commands) {
if (i <= 4) {
if (command.usage != null) {
if (PermissionsM.hasPerm(player, command.permission,
false)) {
MessageM.sendMessage(
player,
"%A"
+ command.usage
+ "%N - "
+ W.messages.getFile().get(
command.help.location));
} else {
MessageM.sendMessage(
player,
"%W"
+ command.usage
+ "%N - "
+ W.messages.getFile().get(
command.help.location));
}
i = i + 1;
}
} }
} }
int maxPages = Math.round(amountCommands / 3); MessageM.sendFMessage(player, ConfigC.chat_headerhigh,
if (maxPages <= 0) { "header-&oHelp Page");
maxPages = 1; } else {
int page = 1;
try {
page = Integer.valueOf(args[1]);
} catch (NumberFormatException e) {
page = 1;
} }
if (args.length == 1) { if (maxPages < page) {
int page = 1; maxPages = page;
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false, }
"header-" + W.pluginName + " %Nhelp page %A" + page
+ "%N/%A" + maxPages); MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-"
int i = 1; + BlockHunt.pdfFile.getName() + " %Nhelp page %A"
for (CommandC command : CommandC.values()) { + page + "%N/%A" + maxPages);
if (i <= 4) {
if (command.usage != "-") { int i = 1;
if (PlayerM.hasPerm(player, command.perm, false)) { for (CommandM command : W.commands) {
if (i <= (page * 4) + 4) {
if (command.usage != null) {
if (i >= ((page - 1) * 4) + 1
&& i <= ((page - 1) * 4) + 4) {
if (PermissionsM.hasPerm(player,
command.permission, false)) {
MessageM.sendMessage( MessageM.sendMessage(
player, player,
"%A/" "%A"
+ command.usage + command.usage
+ "%N - " + "%N - "
+ W.messages.getFile().get( + W.messages.getFile().get(
command.help command.help.location));
.getLocation()),
false);
} else { } else {
MessageM.sendMessage( MessageM.sendMessage(
player, player,
"%W/" "%W"
+ command.usage + command.usage
+ "%N - " + "%N - "
+ W.messages.getFile().get( + W.messages.getFile().get(
command.help command.help.location));
.getLocation()),
false);
} }
i = i + 1;
} }
i = i + 1;
} }
} }
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false,
"header-&oHelp Page");
} else {
int page = 1;
try {
page = Integer.valueOf(args[1]);
} catch (NumberFormatException e) {
page = 1;
}
if (maxPages < page) {
maxPages = page;
}
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false,
"header-" + W.pluginName + " %Nhelp page %A" + page
+ "%N/%A" + maxPages);
int i = 1;
for (CommandC command : CommandC.values()) {
if (i <= (page * 4) + 4) {
if (command.usage != "-") {
if (i >= ((page - 1) * 4) + 1
&& i <= ((page - 1) * 4) + 4) {
if (PlayerM
.hasPerm(player, command.perm, false)) {
MessageM.sendMessage(
player,
"%A/"
+ command.usage
+ "%N - "
+ W.messages
.getFile()
.get(command.help
.getLocation()),
false);
} else {
MessageM.sendMessage(
player,
"%W/"
+ command.usage
+ "%N - "
+ W.messages
.getFile()
.get(command.help
.getLocation()),
false);
}
}
i = i + 1;
}
}
}
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false,
"header-&oHelp Page");
} }
MessageM.sendFMessage(player, ConfigC.chat_headerhigh,
"header-&oHelp Page");
} }
return true; return true;
} }

View File

@ -1,39 +1,43 @@
package nl.Steffion.BlockHunt.Commands; package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.Managers.CommandC; import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CMDinfo extends DefaultCMD { public class CMDinfo 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 @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.info, true)) { MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-"
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false, + BlockHunt.pdfFile.getName());
"header-" + W.pluginName); MessageM.sendMessage(player, "%A%name%%N made by %A%autors%%N.",
MessageM.sendMessage(player, "%A%name%%N made by %A%autors%%N.", "name-" + BlockHunt.pdfFile.getName(), "autors-"
false, "name-" + W.pluginName, "autors-" + W.pluginAutors); + BlockHunt.pdfFile.getAuthors().get(0));
MessageM.sendMessage(player, "%NVersion: %A%version%%N.", false, MessageM.sendMessage(player, "%NVersion: %A%version%%N.", "version-"
"version-" + W.pluginVersion); + BlockHunt.pdfFile.getVersion());
MessageM.sendMessage(player, "%NType %A/%helpusage% %Nfor help.", MessageM.sendMessage(player, "%NType %A%helpusage% %Nfor help.",
false, "helpusage-" + CommandC.HELP.usage); "helpusage-" + BlockHunt.CMDhelp.usage);
MessageM.sendMessage( MessageM.sendMessage(player,
player, "%NDev-Page: %Ahttp://dev.bukkit.org/bukkit-plugins/blockhunt/");
"%NDev-Page: %Ahttp://dev.bukkit.org/bukkit-plugins/blockhunt/", MessageM.sendMessage(player, "%NDonations are welcome!");
false); MessageM.sendMessage(player, "%NMade by help from some friends &c<3%N!");
MessageM.sendMessage(player, "%NDonations are welcome!", false); MessageM.sendFMessage(player, ConfigC.chat_headerhigh,
MessageM.sendMessage(player, "header-&oInfo Page");
"%NMade by help from some friends &c<3%N!", false);
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false,
"header-&oInfo Page");
}
return true; return true;
} }
} }

View File

@ -1,11 +1,10 @@
package nl.Steffion.BlockHunt.Commands; package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.ArenaHandler; import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.Managers.CommandC; import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.Managers.ConfigC; import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -14,18 +13,15 @@ public class CMDjoin extends DefaultCMD {
@Override @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.join, true)) { if (player != null) {
if (player != null) { if (args.length <= 1) {
if (args.length <= 1) { MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
MessageM.sendFMessage(player, "syntax-" + BlockHunt.CMDjoin.usage);
ConfigC.error_notEnoughArguments, true, "syntax-"
+ CommandC.JOIN.usage);
} else {
ArenaHandler.playerJoinArena(player, args[1]);
}
} else { } else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true); ArenaHandler.playerJoinArena(player, args[1]);
} }
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame);
} }
return true; return true;
} }

View File

@ -1,10 +1,9 @@
package nl.Steffion.BlockHunt.Commands; package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.ArenaHandler; import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.Managers.ConfigC; import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -13,12 +12,10 @@ public class CMDleave extends DefaultCMD {
@Override @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.leave, true)) { if (player != null) {
if (player != null) { ArenaHandler.playerLeaveArena(player, true, true);
ArenaHandler.playerLeaveArena(player, true, true); } else {
} else { MessageM.sendFMessage(player, ConfigC.error_onlyIngame);
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true);
}
} }
return true; return true;
} }

View File

@ -1,11 +1,10 @@
package nl.Steffion.BlockHunt.Commands; package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -15,23 +14,19 @@ public class CMDlist extends DefaultCMD {
@Override @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.list, true)) { MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-"
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false, + BlockHunt.pdfFile.getName());
"header-" + W.pluginName); if (W.arenaList.size() >= 1) {
if (W.arenaList.size() >= 1) { for (Arena arena : W.arenaList) {
for (Arena arena : W.arenaList) { MessageM.sendMessage(player, "&7Available arena(s):");
MessageM.sendMessage(player, "&7Available arena(s):", false); MessageM.sendMessage(player, "%A" + arena.arenaName);
MessageM.sendMessage(player, "%A" + arena.arenaName, false);
}
} else {
MessageM.sendMessage(player, "&7&oNo arenas available...",
false);
MessageM.sendMessage(player,
"&7&oCreate an arena first please.", false);
} }
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false, } else {
"header-&oArenas list"); MessageM.sendMessage(player, "&7&oNo arenas available...");
MessageM.sendMessage(player, "&7&oCreate an arena first please.");
} }
MessageM.sendFMessage(player, ConfigC.chat_headerhigh,
"header-&oArenas list");
return true; return true;
} }
} }

View File

@ -1,16 +1,27 @@
package nl.Steffion.BlockHunt.Commands; package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.Managers.ConfigC; import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CMDnotfound extends DefaultCMD { public class CMDnotfound {
@Override /**
public boolean exectue(Player player, Command cmd, String label, * 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
*/
public static boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
MessageM.sendFMessage(player, ConfigC.error_commandNotFound, true); MessageM.sendFMessage(player, ConfigC.error_commandNotFound);
return true; return true;
} }
} }

View File

@ -2,34 +2,43 @@ package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.ArenaHandler; import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.ConfigC; import nl.Steffion.BlockHunt.Managers.ConfigM;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CMDreload extends DefaultCMD { public class CMDreload 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 @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.reload, true)) { ConfigM.newFiles();
W.config.load();
W.messages.load();
W.arenas.load();
W.signs.load();
W.shop.load();
for (Arena arena : W.arenaList) {
ArenaHandler.stopArena(arena);
}
ArenaHandler.loadArenas(); W.config.load();
W.newFiles(); W.messages.load();
MessageM.sendFMessage(player, ConfigC.normal_reloadedConfigs, true); W.arenas.load();
W.signs.load();
W.shop.load();
for (Arena arena : W.arenaList) {
ArenaHandler.stopArena(arena);
} }
ArenaHandler.loadArenas();
MessageM.sendFMessage(player, ConfigC.normal_reloadedConfigs);
return true; return true;
} }
} }

View File

@ -1,12 +1,10 @@
package nl.Steffion.BlockHunt.Commands; package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.CommandC;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable; import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -21,48 +19,45 @@ public class CMDremove extends DefaultCMD {
@Override @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.remove, true)) { if (player != null) {
if (player != null) { if (args.length <= 1) {
if (args.length <= 1) { MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
MessageM.sendFMessage(player, "syntax-" + BlockHunt.CMDremove.usage);
ConfigC.error_notEnoughArguments, true, "syntax-"
+ CommandC.REMOVE.usage);
} else {
for (Arena arena : W.arenaList) {
if (args[1].equalsIgnoreCase(arena.arenaName)) {
MessageM.sendFMessage(player,
ConfigC.normal_removeRemovedArena, true,
"name-" + args[1]);
W.arenas.getFile().set(args[1], null);
for (String sign : W.signs.getFile().getKeys(false)) {
if (W.signs.getFile().get(sign + ".arenaName")
.toString().equalsIgnoreCase(args[1])) {
LocationSerializable signLoc = new LocationSerializable(
(Location) W.signs.getFile().get(
sign + ".location"));
signLoc.getBlock().setType(Material.AIR);
signLoc.getWorld().playEffect(signLoc,
Effect.MOBSPAWNER_FLAMES, 0);
signLoc.getWorld().playSound(signLoc,
Sound.ENDERDRAGON_WINGS, 1, 1);
W.signs.getFile().set(sign, null);
}
}
W.arenas.save();
W.signs.load();
W.arenaList.remove((Arena) arena);
return true;
}
}
MessageM.sendFMessage(player, ConfigC.error_noArena, true,
"name-" + args[1]);
}
} else { } else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true); for (Arena arena : W.arenaList) {
if (args[1].equalsIgnoreCase(arena.arenaName)) {
MessageM.sendFMessage(player,
ConfigC.normal_removeRemovedArena, "name-"
+ args[1]);
W.arenas.getFile().set(args[1], null);
for (String sign : W.signs.getFile().getKeys(false)) {
if (W.signs.getFile().get(sign + ".arenaName")
.toString().equalsIgnoreCase(args[1])) {
LocationSerializable signLoc = new LocationSerializable(
(Location) W.signs.getFile().get(
sign + ".location"));
signLoc.getBlock().setType(Material.AIR);
signLoc.getWorld().playEffect(signLoc,
Effect.MOBSPAWNER_FLAMES, 0);
signLoc.getWorld().playSound(signLoc,
Sound.ENDERDRAGON_WINGS, 1, 1);
W.signs.getFile().set(sign, null);
}
}
W.arenas.save();
W.signs.load();
W.arenaList.remove((Arena) arena);
return true;
}
}
MessageM.sendFMessage(player, ConfigC.error_noArena, "name-"
+ args[1]);
} }
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame);
} }
return true; return true;
} }

View File

@ -1,11 +1,9 @@
package nl.Steffion.BlockHunt.Commands; package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.InventoryHandler; import nl.Steffion.BlockHunt.InventoryHandler;
import nl.Steffion.BlockHunt.Managers.CommandC;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -15,19 +13,16 @@ public class CMDset extends DefaultCMD {
@Override @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.set, true)) { if (player != null) {
if (player != null) { if (args.length <= 1) {
if (args.length <= 1) { MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
MessageM.sendFMessage(player, "syntax-" + BlockHunt.CMDset.usage);
ConfigC.error_notEnoughArguments, true, "syntax-"
+ CommandC.SET.usage);
} else {
String arenaname = args[1];
InventoryHandler.openPanel(player, arenaname);
}
} else { } else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true); String arenaname = args[1];
InventoryHandler.openPanel(player, arenaname);
} }
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame);
} }
return true; return true;
} }

View File

@ -2,12 +2,10 @@ package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.ArenaHandler; import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.CommandC;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable; import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -18,56 +16,53 @@ public class CMDsetwarp extends DefaultCMD {
@Override @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.set, true)) { if (player != null) {
if (player != null) { if (args.length <= 2) {
if (args.length <= 2) { MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
MessageM.sendFMessage(player, "syntax-" + BlockHunt.CMDsetwarp.usage);
ConfigC.error_notEnoughArguments, true, "syntax-" } else {
+ CommandC.SETWARP.usage); String arenaname = args[2];
} else { String warpname = args[1];
String arenaname = args[2];
String warpname = args[1];
Arena arena = null; Arena arena = null;
for (Arena arena2 : W.arenaList) { for (Arena arena2 : W.arenaList) {
if (arena2.arenaName.equalsIgnoreCase(arenaname)) { if (arena2.arenaName.equalsIgnoreCase(arenaname)) {
arena = arena2; arena = arena2;
}
}
if (arena != null) {
LocationSerializable loc = new LocationSerializable(
player.getLocation());
if (warpname.equalsIgnoreCase("lobby")) {
arena.lobbyWarp = loc;
save(arena);
MessageM.sendFMessage(player,
ConfigC.normal_setwarpWarpSet, true,
"warp-" + warpname);
} else if (warpname.equalsIgnoreCase("hiders")) {
arena.hidersWarp = loc;
save(arena);
MessageM.sendFMessage(player,
ConfigC.normal_setwarpWarpSet, true,
"warp-" + warpname);
} else if (warpname.equalsIgnoreCase("seekers")) {
arena.seekersWarp = loc;
save(arena);
MessageM.sendFMessage(player,
ConfigC.normal_setwarpWarpSet, true,
"warp-" + warpname);
} else {
MessageM.sendFMessage(player,
ConfigC.error_setwarpWarpNotFound, true,
"warp-" + warpname);
}
} else {
MessageM.sendFMessage(player, ConfigC.error_noArena,
true, "name-" + arenaname);
} }
} }
} else { if (arena != null) {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true); LocationSerializable loc = new LocationSerializable(
player.getLocation());
if (warpname.equalsIgnoreCase("lobby")) {
arena.lobbyWarp = loc;
save(arena);
MessageM.sendFMessage(player,
ConfigC.normal_setwarpWarpSet, "warp-"
+ warpname);
} else if (warpname.equalsIgnoreCase("hiders")) {
arena.hidersWarp = loc;
save(arena);
MessageM.sendFMessage(player,
ConfigC.normal_setwarpWarpSet, "warp-"
+ warpname);
} else if (warpname.equalsIgnoreCase("seekers")) {
arena.seekersWarp = loc;
save(arena);
MessageM.sendFMessage(player,
ConfigC.normal_setwarpWarpSet, "warp-"
+ warpname);
} else {
MessageM.sendFMessage(player,
ConfigC.error_setwarpWarpNotFound, "warp-"
+ warpname);
}
} else {
MessageM.sendFMessage(player, ConfigC.error_noArena,
"name-" + arenaname);
}
} }
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame);
} }
return true; return true;
} }

View File

@ -1,8 +1,6 @@
package nl.Steffion.BlockHunt.Commands; package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.InventoryHandler; import nl.Steffion.BlockHunt.InventoryHandler;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -12,9 +10,7 @@ public class CMDshop extends DefaultCMD {
@Override @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.shop, true)) { InventoryHandler.openShop(player);
InventoryHandler.openShop(player);
}
return true; return true;
} }
} }

View File

@ -2,12 +2,10 @@ package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.Arena.ArenaState; import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.CommandC;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -17,54 +15,50 @@ public class CMDstart extends DefaultCMD {
@Override @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.start, true)) { if (player != null) {
if (player != null) { if (args.length <= 1) {
if (args.length <= 1) { MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
MessageM.sendFMessage(player, "syntax-" + BlockHunt.CMDstart.usage);
ConfigC.error_notEnoughArguments, true, "syntax-" } else {
+ CommandC.START.usage); Arena arena = null;
} else { for (Arena arena2 : W.arenaList) {
Arena arena = null; if (arena2.arenaName.equalsIgnoreCase(args[1])) {
for (Arena arena2 : W.arenaList) { arena = arena2;
if (arena2.arenaName.equalsIgnoreCase(args[1])) {
arena = arena2;
}
}
if (arena != null) {
if (arena.gameState.equals(ArenaState.WAITING)) {
if (arena.playersInArena.size() >= 2) {
arena.timer = 11;
arena.gameState = ArenaState.STARTING;
MessageM.sendFMessage(player,
ConfigC.normal_startForced, true,
"arenaname-" + arena.arenaName);
} else {
MessageM.sendFMessage(player,
ConfigC.warning_lobbyNeedAtleast, true,
"1-2");
}
} else if (arena.gameState.equals(ArenaState.STARTING)) {
if (arena.playersInArena.size() < arena.maxPlayers) {
if (arena.timer >= 10) {
arena.timer = 11;
}
} else {
arena.timer = 1;
}
MessageM.sendFMessage(player,
ConfigC.normal_startForced, true,
"arenaname-" + arena.arenaName);
}
} else {
MessageM.sendFMessage(player, ConfigC.error_noArena,
true, "name-" + args[1]);
} }
} }
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true); if (arena != null) {
if (arena.gameState.equals(ArenaState.WAITING)) {
if (arena.playersInArena.size() >= 2) {
arena.timer = 11;
arena.gameState = ArenaState.STARTING;
MessageM.sendFMessage(player,
ConfigC.normal_startForced, "arenaname-"
+ arena.arenaName);
} else {
MessageM.sendFMessage(player,
ConfigC.warning_lobbyNeedAtleast, "1-2");
}
} else if (arena.gameState.equals(ArenaState.STARTING)) {
if (arena.playersInArena.size() < arena.maxPlayers) {
if (arena.timer >= 10) {
arena.timer = 11;
}
} else {
arena.timer = 1;
}
MessageM.sendFMessage(player,
ConfigC.normal_startForced, "arenaname-"
+ arena.arenaName);
}
} else {
MessageM.sendFMessage(player, ConfigC.error_noArena,
"name-" + args[1]);
}
} }
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame);
} }
return true; return true;
} }

View File

@ -3,11 +3,9 @@ package nl.Steffion.BlockHunt.Commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -21,33 +19,29 @@ public class CMDwand extends DefaultCMD {
@Override @Override
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
if (PlayerM.hasPerm(player, PermsC.create, true)) { if (player != null) {
if (player != null) { ItemStack wand = new ItemStack(
ItemStack wand = new ItemStack( Material.getMaterial((Integer) W.config.get(ConfigC.wandID)));
Material.getMaterial((Integer) W.config ItemMeta im = wand.getItemMeta();
.get(ConfigC.wandID))); im.setDisplayName(MessageM.replaceAll((String) W.config
ItemMeta im = wand.getItemMeta(); .get(ConfigC.wandName)));
im.setDisplayName(MessageM.replaceAll((String) W.config W.config.load();
.get(ConfigC.wandName))); List<String> lores = W.config.getFile().getStringList(
W.config.load(); ConfigC.wandDescription.location);
List<String> lores = W.config.getFile().getStringList( List<String> lores2 = new ArrayList<String>();
ConfigC.wandDescription.getLocation()); for (String lore : lores) {
List<String> lores2 = new ArrayList<String>(); lores2.add(MessageM.replaceAll(lore));
for (String lore : lores) {
lores2.add(MessageM.replaceAll(lore));
}
im.setLore(lores2);
wand.setItemMeta(im);
player.getInventory().addItem(wand);
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 5, 0);
MessageM.sendFMessage(player, ConfigC.normal_wandGaveWand, true,
"type-"
+ wand.getType().toString()
.replaceAll("_", " ").toLowerCase());
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true);
} }
im.setLore(lores2);
wand.setItemMeta(im);
player.getInventory().addItem(wand);
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 5, 0);
MessageM.sendFMessage(player, ConfigC.normal_wandGaveWand, "type-"
+ wand.getType().toString().replaceAll("_", " ")
.toLowerCase());
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame);
} }
return true; return true;
} }

View File

@ -6,11 +6,22 @@ import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class DefaultCMD { public class 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
*/
public boolean exectue(Player player, Command cmd, String label, public boolean exectue(Player player, Command cmd, String label,
String[] args) { String[] args) {
MessageM.sendMessage(player, "%NExample of a Command!", true); MessageM.sendMessage(player, "%TAG%NExample of a Command!");
//TODO Place the command stuff here. // TODO Place the command stuff here.
return true; return true;
} }
} }

View File

@ -0,0 +1,231 @@
package nl.Steffion.BlockHunt;
import nl.Steffion.BlockHunt.Managers.ConfigM;
public enum ConfigC {
/**
* 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
*/
chat_tag ("[" + BlockHunt.pdfFile.getName() + "] ", W.config),
chat_normal ("&b", W.config),
chat_warning ("&c", W.config),
chat_error ("&c", W.config),
chat_arg ("&e", W.config),
chat_header ("&9", W.config),
chat_headerhigh ("%H_______.[ %A%header%%H ]._______", W.config),
commandEnabled_info (true, W.config),
commandEnabled_help (true, W.config),
commandEnabled_reload (true, W.config),
commandEnabled_join (true, W.config),
commandEnabled_leave (true, W.config),
commandEnabled_list (true, W.config),
commandEnabled_shop (true, W.config),
commandEnabled_start (true, W.config),
commandEnabled_wand (true, W.config),
commandEnabled_create (true, W.config),
commandEnabled_set (true, W.config),
commandEnabled_setwarp (true, W.config),
commandEnabled_remove (true, W.config),
autoUpdateCheck (true, W.config),
autoDownloadUpdate (false, W.config),
wandID (280, W.config),
wandName ("%A&l" + BlockHunt.pdfFile.getName() + "%N's selection wand",
W.config),
wandDescription (new String[] {
"%NUse this item to select an arena for your arena.",
"%ALeft-Click%N to select point #1.",
"%ARight-Click%N to select point #2.",
"%NUse the create command to define your arena.",
"%A/" + BlockHunt.pdfFile.getName() + " <help|h>" }, W.config),
shop_price ("%NPrice: %A%amount% %Ntokens.", W.config),
shop_blockChooserEnabled (true, W.config),
shop_blockChooserID (340, W.config),
shop_blockChooserPrice (3000, W.config),
shop_blockChooserName ("%H&lBlock Chooser", W.config),
shop_blockChooserDescription (new String[] {
"%NUse this item before the arena starts.",
"%ARight-Click%N in the lobby and choose",
"%Nthe block you want to be!", "&6Unlimited uses." }, W.config),
shop_BlockHuntPassEnabled (true, W.config),
shop_BlockHuntPassID (421, W.config),
shop_BlockHuntPassPrice (150, W.config),
shop_BlockHuntPassName ("%H&lBlockHunt Pass", W.config),
shop_BlockHuntPassDescription (new String[] {
"%NUse this item before the arena starts.",
"%ARight-Click%N in the lobby and choose",
"%Nif you want to be a Hider or a Seeker!", "&61 use.",
"&c&lCOMING SOON!" }, W.config),
sign_LEAVE (new String[] { "%H[" + BlockHunt.pdfFile.getName() + "%H]",
"&4LEAVE", "&8Right-Click", "&8To leave." }, W.config),
sign_WAITING (new String[] { "%H[" + BlockHunt.pdfFile.getName() + "%H]",
"%A%arenaname%", "%A%players%%N/%A%maxplayers%", "&8Waiting..." },
W.config),
sign_STARTING (new String[] { "%H[" + BlockHunt.pdfFile.getName() + "%H]",
"%A%arenaname%", "%A%players%%N/%A%maxplayers%",
"&2Start: %A%timeleft%" }, W.config),
sign_INGAME (new String[] { "%H[" + BlockHunt.pdfFile.getName() + "%H]",
"%A%arenaname%", "%A%players%%N/%A%maxplayers%",
"%EIngame: %A%timeleft%" }, W.config),
scoreboard_timeleft ("%ATime left:", W.config),
scoreboard_seekers ("%NSeekers:", W.config),
scoreboard_hiders ("%NHiders:", W.config),
log_enabledPlugin ("%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.",
W.messages),
log_disabledPlugin ("%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.",
W.messages),
help_info ("%NDisplays the plugin's info.", W.messages),
help_help ("%NShows a list of commands.", W.messages),
help_reload ("%NReloads all configs.", W.messages),
help_join ("%NJoins a " + BlockHunt.pdfFile.getName() + " game.",
W.messages),
help_leave ("%NLeave a " + BlockHunt.pdfFile.getName() + " game.",
W.messages),
help_list ("%NShows a list of available arenas.", W.messages),
help_shop ("%NOpens the " + BlockHunt.pdfFile.getName() + " shop.",
W.messages),
help_start ("%NForces an arena to start.", W.messages),
help_wand ("%NGives you the wand selection tool.", W.messages),
help_create ("%NCreates an arena from your selection.", W.messages),
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),
button_add ("%NAdd %A%1%%N to %A%2%%N", W.messages),
button_add2 ("Add", W.messages),
button_setting ("%NSetting %A%1%%N is now: %A%2%%N.", W.messages),
button_remove ("%NRemove %A%1%%N from %A%2%%N", W.messages),
button_remove2 ("Remove", W.messages),
normal_reloadedConfigs ("%TAG&aReloaded all configs!", W.messages),
normal_joinJoinedArena ("%TAG%A%playername%%N joined your arena. (%A%1%%N/%A%2%%N)",
W.messages),
normal_leaveYouLeft ("%TAG%NYou left the arena! Thanks for playing ;)!",
W.messages),
normal_leaveLeftArena ("%TAG%A%playername%%N left your arena. (%A%1%%N/%A%2%%N)",
W.messages),
normal_startForced ("%TAG%NYou forced to start arena '%A%arenaname%%N'!",
W.messages),
normal_wandGaveWand ("%TAG%NHere you go ;)! &o(Use the %A&o%type%%N&o!)",
W.messages),
normal_wandSetPosition ("%TAG%NSet position %A#%number%%N to location: (%A%x%%N, %A%y%%N, %A%z%%N).",
W.messages),
normal_createCreatedArena ("%TAG%NCreated an arena with the name '%A%name%%N'.",
W.messages),
normal_lobbyArenaIsStarting ("%TAG%NThe arena will start in %A%1%%N second(s)!",
W.messages),
normal_lobbyArenaStarted ("%TAG%NThe arena has been started! The seeker is coming to find you in %A%secs%%N seconds!",
W.messages),
normal_ingameSeekerChoosen ("%TAG%NPlayer %A%seeker%%N has been choosen as seeker!",
W.messages),
normal_ingameBlock ("%TAG%NYou're disguised as a(n) '%A%block%%N' block.",
W.messages),
normal_ingameArenaEnd ("%TAG%NThe arena will end in %A%1%%N second(s)!",
W.messages),
normal_ingameGivenSword ("%TAG%NYou were given a sword!", W.messages),
normal_HiderDied ("%TAG%NHider %A%playername%%N died! %A%left%%N hider(s) remain...",
W.messages),
normal_SeekerDied ("%TAG%NSeeker %A%playername%%N died! He will respawn in %A%secs%%N seconds!",
W.messages),
normal_winSeekers ("%TAG%NThe %ASEEKERS%N have won!", W.messages),
normal_winHiders ("%TAG%NThe %AHIDERS%N have won!", W.messages),
normal_setwarpWarpSet ("%TAG%NSet warp '%A%warp%%N' to your location!",
W.messages),
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_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!",
W.messages),
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!",
W.messages),
warning_ingameNEWSeekerChoosen ("%TAG%WThe last seeker left and a new seeker has been choosen!",
W.messages),
warning_unableToCommand ("%TAG%WSorry but that command is disabled in the arena.",
W.messages),
warning_ingameNoSolidPlace ("%TAG%WThat's not a valid place to become solid!",
W.messages),
warning_arenaStopped ("%TAG%WThe arena has been forced to stop!",
W.messages),
error_noPermission ("%TAG%EYou don't have the permissions to do that!",
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%",
W.messages),
error_disguiseCraftNotInstalled ("%TAG%EThe plugin '%ADisguiseCraft%E' is required to run this plugin! Intall it or it won't work!",
W.messages),
error_protocolLibNotInstalled ("%TAG%EThe plugin '%AProtocolLib%E' is required to run this plugin! Intall it or it won't work!",
W.messages),
error_noArena ("%TAG%ENo arena found with the name '%A%name%%E'.",
W.messages),
error_onlyIngame ("%TAG%EThis is an only in-game command!", W.messages),
error_joinAlreadyJoined ("%TAG%EYou've already joined an arena!",
W.messages),
error_joinNoBlocksSet ("%TAG%EThere are none blocks set for this arena. Notify the administrator.",
W.messages),
error_joinWarpsNotSet ("%TAG%EThere are no warps set for this arena. Notify the administrator.",
W.messages),
error_joinArenaIngame ("%TAG%EThis game has already started.", W.messages),
error_joinFull ("%TAG%EUnable to join this arena. It's full!", W.messages),
error_leaveNotInArena ("%TAG%EYou're not in an arena!", W.messages),
error_createSelectionFirst ("%TAG%EMake a selection first. Use the wand command: %A/"
+ BlockHunt.pdfFile.getName() + " <wand|w>%E.",
W.messages),
error_createNotSameWorld ("%TAG%EMake your selection points in the same world!",
W.messages),
error_setTooHighNumber ("%TAG%EThat amount is too high! Max amount is: %A%max%%E.",
W.messages),
error_setTooLowNumber ("%TAG%EThat amount is too low! Minimal amount is: %A%min%%E.",
W.messages),
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.",
W.messages);
public Object value;
public ConfigM config;
public String location;
/**
* Makes an object from the list above.
*
* @param value
* Setting in the config file.
* @param config
* The config file.
*/
private ConfigC (Object value, ConfigM config) {
this.value = value;
this.config = config;
this.location = this.name().replaceAll("_", ".");
}
}

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import nl.Steffion.BlockHunt.Arena.ArenaType; import nl.Steffion.BlockHunt.Arena.ArenaType;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -158,7 +157,7 @@ public class InventoryHandler {
player.openInventory(panel); player.openInventory(panel);
} else { } else {
MessageM.sendFMessage(player, ConfigC.error_noArena, true, "name-" MessageM.sendFMessage(player, ConfigC.error_noArena, "name-"
+ arenaname); + arenaname);
} }
} }
@ -272,7 +271,7 @@ public class InventoryHandler {
.replaceAll((String) W.config .replaceAll((String) W.config
.get(ConfigC.shop_blockChooserName))); .get(ConfigC.shop_blockChooserName)));
lores = W.config.getFile().getStringList( lores = W.config.getFile().getStringList(
ConfigC.shop_blockChooserDescription.getLocation()); ConfigC.shop_blockChooserDescription.location);
lores2 = new ArrayList<String>(); lores2 = new ArrayList<String>();
for (String lore : lores) { for (String lore : lores) {
lores2.add(MessageM.replaceAll(lore)); lores2.add(MessageM.replaceAll(lore));
@ -293,7 +292,7 @@ public class InventoryHandler {
.replaceAll((String) W.config .replaceAll((String) W.config
.get(ConfigC.shop_BlockHuntPassName))); .get(ConfigC.shop_BlockHuntPassName)));
lores = W.config.getFile().getStringList( lores = W.config.getFile().getStringList(
ConfigC.shop_BlockHuntPassDescription.getLocation()); ConfigC.shop_BlockHuntPassDescription.location);
lores2 = new ArrayList<String>(); lores2 = new ArrayList<String>();
for (String lore : lores) { for (String lore : lores) {
lores2.add(MessageM.replaceAll(lore)); lores2.add(MessageM.replaceAll(lore));

View File

@ -1,9 +1,10 @@
package nl.Steffion.BlockHunt.Listeners; package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.PermissionsC.Permissions;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.PlayerM; import nl.Steffion.BlockHunt.Managers.PermissionsM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -25,7 +26,7 @@ public class OnBlockBreakEvent implements Listener {
if (event.getBlock().equals(Material.SIGN_POST) if (event.getBlock().equals(Material.SIGN_POST)
|| event.getBlock().equals(Material.WALL_SIGN)) { || event.getBlock().equals(Material.WALL_SIGN)) {
if (!PlayerM.hasPerm(player, PermsC.signcreate, true)) { if (!PermissionsM.hasPerm(player, Permissions.signcreate, true)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -3,8 +3,8 @@ package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.Arena.ArenaState; import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.ArenaHandler; import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -74,7 +74,7 @@ public class OnEntityDamageByEntityEvent implements Listener {
W.shop.save(); W.shop.save();
MessageM.sendFMessage(damager, MessageM.sendFMessage(damager,
ConfigC.normal_addedToken, true, ConfigC.normal_addedToken,
"amount-" + arena.killTokens); "amount-" + arena.killTokens);
if (W.shop.getFile().get( if (W.shop.getFile().get(
@ -93,7 +93,7 @@ public class OnEntityDamageByEntityEvent implements Listener {
W.shop.save(); W.shop.save();
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.normal_addedToken, true, ConfigC.normal_addedToken,
"amount-" + (int) addingTokens); "amount-" + (int) addingTokens);
arena.seekers.add(player); arena.seekers.add(player);

View File

@ -3,9 +3,9 @@ package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.Arena.ArenaType; import nl.Steffion.BlockHunt.Arena.ArenaType;
import nl.Steffion.BlockHunt.ArenaHandler; import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.InventoryHandler; import nl.Steffion.BlockHunt.InventoryHandler;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -40,7 +40,7 @@ public class OnInventoryClickEvent implements Listener {
if (!event.getCurrentItem().getType().isBlock()) { if (!event.getCurrentItem().getType().isBlock()) {
event.setCancelled(true); event.setCancelled(true);
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.error_setNotABlock, true); ConfigC.error_setNotABlock);
} }
} }
@ -74,13 +74,12 @@ public class OnInventoryClickEvent implements Listener {
MessageM.sendFMessage( MessageM.sendFMessage(
player, player,
ConfigC.normal_ShopBoughtItem, ConfigC.normal_ShopBoughtItem,
true,
"itemname-" "itemname-"
+ W.config + W.config
.get(ConfigC.shop_blockChooserName)); .get(ConfigC.shop_blockChooserName));
} else { } else {
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.error_ShopNeedMoreTokens, true); ConfigC.error_ShopNeedMoreTokens);
} }
} }
@ -92,7 +91,7 @@ public class OnInventoryClickEvent implements Listener {
if (event.getCurrentItem().getType() != Material.AIR) { if (event.getCurrentItem().getType() != Material.AIR) {
W.choosenBlock.put(player, event.getCurrentItem()); W.choosenBlock.put(player, event.getCurrentItem());
MessageM.sendFMessage(player, MessageM.sendFMessage(player,
ConfigC.normal_ShopChoosenBlock, true, "block-" ConfigC.normal_ShopChoosenBlock, "block-"
+ event.getCurrentItem().getType() + event.getCurrentItem().getType()
.toString().replaceAll("_", "") .toString().replaceAll("_", "")
.replaceAll("BLOCK", "") .replaceAll("BLOCK", "")
@ -235,7 +234,7 @@ public class OnInventoryClickEvent implements Listener {
} }
} else { } else {
MessageM.sendFMessage(player, ConfigC.error_setTooHighNumber, MessageM.sendFMessage(player, ConfigC.error_setTooHighNumber,
true, "max-" + max); "max-" + max);
} }
} else if (item.getItemMeta().getDisplayName() } else if (item.getItemMeta().getDisplayName()
.contains((String) W.messages.get(ConfigC.button_remove2))) { .contains((String) W.messages.get(ConfigC.button_remove2))) {
@ -274,7 +273,7 @@ public class OnInventoryClickEvent implements Listener {
} }
} else { } else {
MessageM.sendFMessage(player, ConfigC.error_setTooLowNumber, MessageM.sendFMessage(player, ConfigC.error_setTooLowNumber,
true, "min-" + min); "min-" + min);
} }
} }
} }

View File

@ -1,8 +1,8 @@
package nl.Steffion.BlockHunt.Listeners; package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,8 +38,7 @@ public class OnPlayerCommandPreprocessEvent implements Listener {
} }
} }
MessageM.sendFMessage(player, ConfigC.warning_unableToCommand, MessageM.sendFMessage(player, ConfigC.warning_unableToCommand);
true);
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -3,13 +3,13 @@ package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.Arena.ArenaState; import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.ArenaHandler; import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.PermissionsC.Permissions;
import nl.Steffion.BlockHunt.SignsHandler; import nl.Steffion.BlockHunt.SignsHandler;
import nl.Steffion.BlockHunt.SolidBlockHandler; import nl.Steffion.BlockHunt.SolidBlockHandler;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM; import nl.Steffion.BlockHunt.Managers.PermissionsM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable; import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -33,7 +33,7 @@ public class OnPlayerInteractEvent implements Listener {
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerInteractEvent(PlayerInteractEvent event) { public void onPlayerInteractEvent(PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (PlayerM.hasPerm(player, PermsC.create, false)) { if (PermissionsM.hasPerm(player, Permissions.create, false)) {
ItemStack item = player.getItemInHand(); ItemStack item = player.getItemInHand();
if (item.getType() != Material.AIR) { if (item.getType() != Material.AIR) {
if (item.getItemMeta().hasDisplayName()) { if (item.getItemMeta().hasDisplayName()) {
@ -52,7 +52,6 @@ public class OnPlayerInteractEvent implements Listener {
MessageM.sendFMessage( MessageM.sendFMessage(
player, player,
ConfigC.normal_wandSetPosition, ConfigC.normal_wandSetPosition,
true,
"number-1", "number-1",
"pos-%N(%A" + location.getX() "pos-%N(%A" + location.getX()
+ "%N, %A" + "%N, %A"
@ -71,7 +70,6 @@ public class OnPlayerInteractEvent implements Listener {
MessageM.sendFMessage( MessageM.sendFMessage(
player, player,
ConfigC.normal_wandSetPosition, ConfigC.normal_wandSetPosition,
true,
"number-2", "number-2",
"pos-%N(%A" + location.getX() "pos-%N(%A" + location.getX()
+ "%N, %A" + "%N, %A"
@ -100,15 +98,15 @@ public class OnPlayerInteractEvent implements Listener {
.getClickedBlock().getLocation()))) { .getClickedBlock().getLocation()))) {
Sign sign = (Sign) event.getClickedBlock().getState(); Sign sign = (Sign) event.getClickedBlock().getState();
if (sign.getLine(1) != null) { if (sign.getLine(1) != null) {
if (sign.getLine(1).equals( if (sign.getLine(1)
MessageM.replaceAll(W.config .equals(MessageM
.getFile() .replaceAll(W.config
.getStringList( .getFile()
ConfigC.sign_LEAVE .getStringList(
.getLocation()) ConfigC.sign_LEAVE.location)
.get(1)))) { .get(1)))) {
if (PlayerM.hasPerm(player, PermsC.joinsign, if (PermissionsM.hasPerm(player,
true)) { Permissions.joinsign, true)) {
ArenaHandler.playerLeaveArena(player, true, ArenaHandler.playerLeaveArena(player, true,
true); true);
} }
@ -116,8 +114,8 @@ public class OnPlayerInteractEvent implements Listener {
for (Arena arena : W.arenaList) { for (Arena arena : W.arenaList) {
if (sign.getLines()[1] if (sign.getLines()[1]
.contains(arena.arenaName)) { .contains(arena.arenaName)) {
if (PlayerM.hasPerm(player, if (PermissionsM.hasPerm(player,
PermsC.joinsign, true)) { Permissions.joinsign, true)) {
ArenaHandler.playerJoinArena( ArenaHandler.playerJoinArena(
player, arena.arenaName); player, arena.arenaName);
} }

View File

@ -1,9 +1,9 @@
package nl.Steffion.BlockHunt.Listeners; package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.PermissionsC.Permissions;
import nl.Steffion.BlockHunt.SignsHandler; import nl.Steffion.BlockHunt.SignsHandler;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.Managers.PermissionsM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable; import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -19,10 +19,12 @@ public class OnSignChangeEvent implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
String[] lines = event.getLines(); String[] lines = event.getLines();
if (lines[0] != null) { if (lines[0] != null) {
if (lines[0].equalsIgnoreCase("[" + W.pluginName + "]")) { if (lines[0].equalsIgnoreCase("[" + BlockHunt.pdfFile.getName()
if (PlayerM.hasPerm(player, PermsC.signcreate, true)) { + "]")) {
SignsHandler.createSign(event, lines, new LocationSerializable( if (PermissionsM.hasPerm(player, Permissions.signcreate, true)) {
event.getBlock().getLocation())); SignsHandler.createSign(event, lines,
new LocationSerializable(event.getBlock()
.getLocation()));
} }
} }
} }

View File

@ -1,155 +0,0 @@
package nl.Steffion.BlockHunt.Managers;
import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Commands.*;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
public enum CommandC {
/*
* Made by @author Steffion, © 2013.
*/
INFO ("BlockHunt%_",
"BlockHunt%_",
new CMDinfo(),
ConfigC.commandEnabled_info,
PermsC.info,
ConfigC.help_info,
0,
"-"),
INFO2 ("BlockHunt%info_",
"BlockHunt%i_",
new CMDinfo(),
ConfigC.commandEnabled_info,
PermsC.info,
ConfigC.help_info,
1,
W.pluginName + " [info|i]"),
HELP ("BlockHunt%help_",
"BlockHunt%h_",
new CMDhelp(),
ConfigC.commandEnabled_help,
PermsC.help,
ConfigC.help_help,
1,
W.pluginName + " <help|h> [pagenumber]"),
RELOAD ("BlockHunt%reload_",
"BlockHunt%r_",
new CMDreload(),
ConfigC.commandEnabled_reload,
PermsC.reload,
ConfigC.help_reload,
1,
W.pluginName + " <reload|r>"),
JOIN ("BlockHunt%join_",
"BlockHunt%j_",
new CMDjoin(),
ConfigC.commandEnabled_join,
PermsC.join,
ConfigC.help_join,
1,
W.pluginName + " <join|j> <arenaname>"),
LEAVE ("BlockHunt%leave_",
"BlockHunt%l_",
new CMDleave(),
ConfigC.commandEnabled_leave,
PermsC.leave,
ConfigC.help_leave,
1,
W.pluginName + " <leave|l>"),
LIST ("BlockHunt%list_",
"BlockHunt%li_",
new CMDlist(),
ConfigC.commandEnabled_list,
PermsC.list,
ConfigC.help_list,
1,
W.pluginName + " <list|li>"),
SHOP ("BlockHunt%shop_",
"BlockHunt%sh_",
new CMDshop(),
ConfigC.commandEnabled_shop,
PermsC.shop,
ConfigC.help_shop,
1,
W.pluginName + " <shop|sh>"),
START ("BlockHunt%start_",
"BlockHunt%go_",
new CMDstart(),
ConfigC.commandEnabled_start,
PermsC.start,
ConfigC.help_start,
1,
W.pluginName + " <start|go> <arenaname>"),
WAND ("BlockHunt%wand_",
"BlockHunt%w_",
new CMDwand(),
ConfigC.commandEnabled_wand,
PermsC.create,
ConfigC.help_wand,
1,
W.pluginName + " <wand|w>"),
CREATE ("BlockHunt%create_",
"BlockHunt%c_",
new CMDcreate(),
ConfigC.commandEnabled_create,
PermsC.create,
ConfigC.help_create,
1,
W.pluginName + " <create|c> <arenaname>"),
SET ("BlockHunt%set_",
"BlockHunt%s_",
new CMDset(),
ConfigC.commandEnabled_set,
PermsC.set,
ConfigC.help_set,
1,
W.pluginName + " <set|s> <arenaname>"),
SETWARP ("BlockHunt%setwarp_",
"BlockHunt%sw_",
new CMDsetwarp(),
ConfigC.commandEnabled_setwarp,
PermsC.setwarp,
ConfigC.help_setwarp,
1,
W.pluginName + " <setwarp|sw> <lobby|hiders|seekers> <arenaname>"),
REMOVE ("BlockHunt%remove_",
"BlockHunt%delete_",
new CMDremove(),
ConfigC.commandEnabled_remove,
PermsC.remove,
ConfigC.help_remove,
1,
W.pluginName + " <remove|delete> <arenaname>"),
NOT_FOUND ("%_",
"%_",
new CMDnotfound(),
null,
PermsC.info,
ConfigC.help_info,
0,
"-");
public String command;
public String alias;
public DefaultCMD cmd;
public ConfigC enabled;
public PermsC perm;
public ConfigC help;
public int minLenght;
public String usage;
private CommandC (String command, String alias, DefaultCMD cmd,
ConfigC enabled, PermsC perm, ConfigC help, int minLenght,
String usage) {
this.command = command;
this.alias = alias;
this.cmd = cmd;
this.enabled = enabled;
this.perm = perm;
this.help = help;
this.minLenght = minLenght;
this.usage = usage;
}
}

View File

@ -0,0 +1,50 @@
package nl.Steffion.BlockHunt.Managers;
import java.util.List;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.PermissionsC.Permissions;
import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Commands.DefaultCMD;
public class CommandM {
/**
* 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
*/
public String name;
public String label;
public String args;
public String argsalias;
public Permissions permission;
public ConfigC help;
public boolean enabled;
public List<String> mainTABlist;
public DefaultCMD CMD;
public String usage;
public CommandM (String name, String label, String args, String argsalias,
Permissions permission, ConfigC help, Boolean enabled,
List<String> mainTABlist, DefaultCMD CMD, String usage) {
this.name = name;
this.label = label;
this.args = args;
this.argsalias = argsalias;
this.permission = permission;
this.help = help;
this.enabled = enabled;
this.mainTABlist = mainTABlist;
this.CMD = CMD;
this.usage = usage;
W.commands.add(this);
}
}

View File

@ -1,206 +0,0 @@
package nl.Steffion.BlockHunt.Managers;
import nl.Steffion.BlockHunt.W;
public enum ConfigC {
/*
* Made by @author Steffion, © 2013.
*/
chat_tag ("[" + W.pluginName + "] ", W.config),
chat_normal ("&b", W.config),
chat_warning ("&c", W.config),
chat_error ("&c", W.config),
chat_arg ("&e", W.config),
chat_header ("&9", W.config),
chat_headerhigh ("%H_______.[ %A%header%%H ]._______", W.config),
commandEnabled_info (true, W.config),
commandEnabled_help (true, W.config),
commandEnabled_reload (true, W.config),
commandEnabled_join (true, W.config),
commandEnabled_leave (true, W.config),
commandEnabled_list (true, W.config),
commandEnabled_shop (true, W.config),
commandEnabled_start (true, W.config),
commandEnabled_wand (true, W.config),
commandEnabled_create (true, W.config),
commandEnabled_set (true, W.config),
commandEnabled_setwarp (true, W.config),
commandEnabled_remove (true, W.config),
autoUpdateCheck (true, W.config),
autoDownloadUpdate (false, W.config),
wandID (280, W.config),
wandName ("%A&l" + W.pluginName + "%N's selection wand", W.config),
wandDescription (new String[] {
"%NUse this item to select an arena for your arena.",
"%ALeft-Click%N to select point #1.",
"%ARight-Click%N to select point #2.",
"%NUse the create command to define your arena.",
"%A/" + W.pluginName + " <help|h>" }, W.config),
shop_price ("%NPrice: %A%amount% %Ntokens.", W.config),
shop_blockChooserEnabled (true, W.config),
shop_blockChooserID (340, W.config),
shop_blockChooserPrice (3000, W.config),
shop_blockChooserName ("%H&lBlock Chooser", W.config),
shop_blockChooserDescription (new String[] {
"%NUse this item before the arena starts.",
"%ARight-Click%N in the lobby and choose",
"%Nthe block you want to be!", "&6Unlimited uses." }, W.config),
shop_BlockHuntPassEnabled (true, W.config),
shop_BlockHuntPassID (421, W.config),
shop_BlockHuntPassPrice (150, W.config),
shop_BlockHuntPassName ("%H&lBlockHunt Pass", W.config),
shop_BlockHuntPassDescription (new String[] {
"%NUse this item before the arena starts.",
"%ARight-Click%N in the lobby and choose",
"%Nif you want to be a Hider or a Seeker!", "&61 use.",
"&c&lCOMING SOON!" }, W.config),
sign_LEAVE (new String[] { "%H[" + W.pluginName + "%H]", "&4LEAVE",
"&8Right-Click", "&8To leave." }, W.config),
sign_WAITING (new String[] { "%H[" + W.pluginName + "%H]", "%A%arenaname%",
"%A%players%%N/%A%maxplayers%", "&8Waiting..." }, W.config),
sign_STARTING (new String[] { "%H[" + W.pluginName + "%H]",
"%A%arenaname%", "%A%players%%N/%A%maxplayers%",
"&2Start: %A%timeleft%" }, W.config),
sign_INGAME (new String[] { "%H[" + W.pluginName + "%H]", "%A%arenaname%",
"%A%players%%N/%A%maxplayers%", "%EIngame: %A%timeleft%" },
W.config),
scoreboard_timeleft ("%ATime left:", W.config),
scoreboard_seekers ("%NSeekers:", W.config),
scoreboard_hiders ("%NHiders:", W.config),
log_Enabled ("%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.",
W.messages),
log_Disabled ("%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.",
W.messages),
help_info ("%NDisplays the plugin's info.", W.messages),
help_help ("%NShows a list of commands.", W.messages),
help_reload ("%NReloads all configs.", W.messages),
help_join ("%NJoins a " + W.pluginName + " game.", W.messages),
help_leave ("%NLeave a " + W.pluginName + " game.", W.messages),
help_list ("%NShows a list of available arenas.", W.messages),
help_shop ("%NOpens the " + W.pluginName + " shop.", W.messages),
help_start ("%NForces an arena to start.", W.messages),
help_wand ("%NGives you the wand selection tool.", W.messages),
help_create ("%NCreates an arena from your selection.", W.messages),
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),
button_add ("%NAdd %A%1%%N to %A%2%%N", W.messages),
button_add2 ("Add", W.messages),
button_setting ("%NSetting %A%1%%N is now: %A%2%%N.", W.messages),
button_remove ("%NRemove %A%1%%N from %A%2%%N", W.messages),
button_remove2 ("Remove", W.messages),
normal_reloadedConfigs ("&aReloaded all configs!", W.messages),
normal_joinJoinedArena ("%A%playername%%N joined your arena. (%A%1%%N/%A%2%%N)",
W.messages),
normal_leaveYouLeft ("%NYou left the arena! Thanks for playing ;)!",
W.messages),
normal_leaveLeftArena ("%A%playername%%N left your arena. (%A%1%%N/%A%2%%N)",
W.messages),
normal_startForced ("%NYou forced to start arena '%A%arenaname%%N'!",
W.messages),
normal_wandGaveWand ("%NHere you go ;)! &o(Use the %A&o%type%%N&o!)",
W.messages),
normal_wandSetPosition ("%NSet position %A#%number%%N to location: (%A%x%%N, %A%y%%N, %A%z%%N).",
W.messages),
normal_createCreatedArena ("%NCreated an arena with the name '%A%name%%N'.",
W.messages),
normal_lobbyArenaIsStarting ("%NThe arena will start in %A%1%%N second(s)!",
W.messages),
normal_lobbyArenaStarted ("%NThe arena has been started! The seeker is coming to find you in %A%secs%%N seconds!",
W.messages),
normal_ingameSeekerChoosen ("%NPlayer %A%seeker%%N has been choosen as seeker!",
W.messages),
normal_ingameBlock ("%NYou're disguised as a(n) '%A%block%%N' block.",
W.messages),
normal_ingameArenaEnd ("%NThe arena will end in %A%1%%N second(s)!",
W.messages),
normal_ingameGivenSword ("%NYou were given a sword!", W.messages),
normal_HiderDied ("%NHider %A%playername%%N died! %A%left%%N hider(s) remain...",
W.messages),
normal_SeekerDied ("%NSeeker %A%playername%%N died! He will respawn in %A%secs%%N seconds!",
W.messages),
normal_winSeekers ("%NThe %ASEEKERS%N have won!", W.messages),
normal_winHiders ("%NThe %AHIDERS%N have won!", W.messages),
normal_setwarpWarpSet ("%NSet warp '%A%warp%%N' to your location!",
W.messages),
normal_addedToken ("%A%amount%%N tokens were added to your account!",
W.messages),
normal_removeRemovedArena ("%NRemoved arena '%A%name%%N'!", W.messages),
normal_ingameNowSolid ("%NYou're now a solid '%A%block%%N' block!",
W.messages),
normal_ingameNoMoreSolid ("%NYou're no longer a solid block!", W.messages),
normal_ShopBoughtItem ("%NYou've bought the '%A%itemname%%N' item!",
W.messages),
normal_ShopChoosenBlock ("%NYou've choosen to be a(n) '%A%block%%N' block!",
W.messages),
warning_lobbyNeedAtleast ("%WYou need atleast %A%1%%W player(s) to start the game!",
W.messages),
warning_ingameNEWSeekerChoosen ("%WThe last seeker left and a new seeker has been choosen!",
W.messages),
warning_unableToCommand ("%WSorry but that command is disabled in the arena.",
W.messages),
warning_ingameNoSolidPlace ("%WThat's not a valid place to become solid!",
W.messages),
warning_arenaStopped ("%WThe arena has been forced to stop!", W.messages),
error_noPermission ("%EYou don't have the permissions to do that!",
W.messages),
error_commandNotEnabled ("%EThis command has been disabled!", W.messages),
error_commandNotFound ("%ECouldn't find the command. Try %A/"
+ W.pluginName + " help %Efor more info.", W.messages),
error_notEnoughArguments ("%EYou're missing arguments, correct syntax: %A/%syntax%",
W.messages),
error_disguiseCraftNotInstalled ("%EThe plugin '%ADisguiseCraft%E' is required to run this plugin! Intall it or it won't work!",
W.messages),
error_protocolLibNotInstalled ("%EThe plugin '%AProtocolLib%E' is required to run this plugin! Intall it or it won't work!",
W.messages),
error_noArena ("%ENo arena found with the name '%A%name%%E'.", W.messages),
error_onlyIngame ("%EThis is an only in-game command!", W.messages),
error_joinAlreadyJoined ("%EYou've already joined an arena!", W.messages),
error_joinNoBlocksSet ("%EThere are none blocks set for this arena. Notify the administrator.",
W.messages),
error_joinWarpsNotSet ("%EThere are no warps set for this arena. Notify the administrator.",
W.messages),
error_joinArenaIngame ("%EThis game has already started.", W.messages),
error_joinFull ("%EUnable to join this arena. It's full!", W.messages),
error_leaveNotInArena ("%EYou're not in an arena!", W.messages),
error_createSelectionFirst ("%EMake a selection first. Use the wand command: %A/"
+ W.pluginName + " <wand|w>%E.",
W.messages),
error_createNotSameWorld ("%EMake your selection points in the same world!",
W.messages),
error_setTooHighNumber ("%EThat amount is too high! Max amount is: %A%max%%E.",
W.messages),
error_setTooLowNumber ("%EThat amount is too low! Minimal amount is: %A%min%%E.",
W.messages),
error_setNotABlock ("%EThat is not a block!", W.messages),
error_setwarpWarpNotFound ("%EWarp '%A%warp%%E' is not valid!", W.messages),
error_ShopNeedMoreTokens ("%EYou need more tokens before you can buy this item.",
W.messages);
public Object value;
public ConfigM config;
private ConfigC (Object value, ConfigM config) {
this.value = value;
this.config = config;
}
public String getLocation() {
return this.name().replaceAll("_", ".");
}
}

View File

@ -2,6 +2,8 @@ package nl.Steffion.BlockHunt.Managers;
import java.io.File; import java.io.File;
import nl.Steffion.BlockHunt.BlockHunt;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -9,28 +11,90 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
public class ConfigM { public class ConfigM {
/* /**
* Made by @author Steffion, © 2013. * 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
*/ */
String fileName; String fileName;
File file; File file;
FileConfiguration fileC; FileConfiguration fileC;
ConfigurationSection fileCS; ConfigurationSection fileCS;
String location; String fileLocation;
public ConfigM (String fileName, String location) { /**
* Use this class to create an automated config file.
*
* @param fileName
* Name of the file.
*/
public ConfigM (String fileName) {
this.fileName = fileName; this.fileName = fileName;
this.file = new File("plugins/" + W.pluginName + "/" + location, fileName this.file = new File("plugins/" + BlockHunt.pdfFile.getName(),
+ ".yml"); fileName + ".yml");
this.location = W.pluginName + "/" + location; this.fileLocation = BlockHunt.pdfFile.getName();
this.fileC = new YamlConfiguration(); this.fileC = new YamlConfiguration();
this.checkFile(); this.checkFile();
this.fileCS = fileC.getConfigurationSection(""); this.fileCS = fileC.getConfigurationSection("");
this.load(); this.load();
} }
/**
* Use this class to create an automated config file.
*
* @param fileName
* Name of the file.
* @param fileLocation
* Sub-Location of the file.
*/
public ConfigM (String fileName, String fileLocation) {
this.fileName = fileName;
this.file = new File("plugins/" + BlockHunt.pdfFile.getName()
+ "/" + fileLocation, fileName + ".yml");
this.fileLocation = BlockHunt.pdfFile.getName() + "/"
+ fileLocation;
this.fileC = new YamlConfiguration();
this.checkFile();
this.fileCS = fileC.getConfigurationSection("");
this.load();
}
/**
* Check if there are new files created if so, display a message to the
* console.
*/
public static void newFiles() {
ConfigM.setDefaults();
for (String fileName : W.newFiles) {
MessageM.sendMessage(
null,
"%TAG%WCouldn't find '%A%fileName%.yml%W' creating new one.",
"fileName-" + fileName);
}
W.newFiles.clear();
}
/**
* Add config settings to the files if they don't exist.
*/
public static void setDefaults() {
for (ConfigC value : ConfigC.values()) {
value.config.load();
if (value.config.getFile().get(value.location) == null) {
value.config.getFile().set(value.location, value.value);
value.config.save();
}
}
}
/** /**
* Check if file exists, if not create one. * Check if file exists, if not create one.
*/ */
@ -39,7 +103,11 @@ public class ConfigM {
try { try {
this.file.getParentFile().mkdirs(); this.file.getParentFile().mkdirs();
this.file.createNewFile(); this.file.createNewFile();
W.newFiles.add(this.location + this.fileName); if (this.fileLocation == BlockHunt.pdfFile.getName()) {
W.newFiles.add(this.fileName);
} else {
W.newFiles.add(this.fileLocation + this.fileName);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -72,21 +140,7 @@ public class ConfigM {
} }
/** /**
* Add variables to the files if they don't exist. * Get the File. Very useful for just loading/saving.
*/
public static void setDefaults() {
for (ConfigC value : ConfigC.values()) {
value.config.load();
String location = value.getLocation();
if (value.config.getFile().get(location) == null) {
value.config.getFile().set(location, value.value);
value.config.save();
}
}
}
/**
* Get the File.
*/ */
public FileConfiguration getFile() { public FileConfiguration getFile() {
return this.fileC; return this.fileC;
@ -94,10 +148,12 @@ public class ConfigM {
/** /**
* Get object from a Config. * Get object from a Config.
*
* @param location * @param location
* Config location.
* @return * @return
*/ */
public Object get(ConfigC location) { public Object get(ConfigC location) {
return this.getFile().get(location.getLocation()); return this.getFile().get(location.location);
} }
} }

View File

@ -0,0 +1,18 @@
package nl.Steffion.BlockHunt.Managers;
public class EngineInfo {
/**
* 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
*/
public static String engineVersion = "3.0.0";
public static String engineAuthors = "Steffion";
}

View File

@ -1,105 +1,134 @@
package nl.Steffion.BlockHunt.Managers; package nl.Steffion.BlockHunt.Managers;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class MessageM { public class MessageM {
/* /**
* Made by @author Steffion, © 2013. * 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
*/ */
/** /**
* Send a message to a player. * Send a message to a player. Also replaces the "%player%" variable to the
* player's name.
* *
* @param player * @param player
* The player receiving the message.
* @param message * @param message
* @param tag * Message which needs to be send to the player.
* @param vars * @param vars
* Variables. Seperated with a - . Ex: "playerName-" +
* player.getName();
*/ */
public static void sendMessage(Player player, String message, Boolean tag, public static void sendMessage(Player player, String message,
String... vars) { String... vars) {
if (player == null) {
Bukkit.getConsoleSender().sendMessage(
MessageM.replaceAll(CType.TAG(tag) + message, vars));
} else {
player.sendMessage(MessageM.replaceAll(CType.TAG(tag) + message,
vars));
}
}
/**
* Send a message to a player from a Config.
*
* @param player
* @param location
* @param tag
* @param vars
*/
public static void sendFMessage(Player player, ConfigC location,
Boolean tag, String... vars) {
if (player == null) { if (player == null) {
Bukkit.getConsoleSender().sendMessage( Bukkit.getConsoleSender().sendMessage(
MessageM.replaceAll( MessageM.replaceAll(
CType.TAG(tag) message.replaceAll("%player%", "Console"), vars));
+ location.config.getFile().get(
location.getLocation()), vars));
} else { } else {
player.sendMessage(MessageM.replaceAll(CType.TAG(tag) player.sendMessage(MessageM.replaceAll(
+ location.config.getFile().get(location.getLocation()), message.replaceAll("%player%", player.getName()), vars));
vars));
} }
} }
/** /**
* Sends a message to all online players. Replaces %player% tag to the * Send a message to a player from a Config. Also replaces the "%player%"
* Player's name or "Console". * variable to the player's name.
*
* @param player
* The player receiving the message.
* @param location
* Location in the config of the message being send.
* @param vars
* Variables. Seperated with a - . Ex: "playerName-" +
* player.getName();
*/
public static void sendFMessage(Player player, ConfigC location,
String... vars) {
if (player == null) {
Bukkit.getConsoleSender().sendMessage(
MessageM.replaceAll(
location.config.getFile().get(location.location)
.toString()
.replaceAll("%player%", "Console"), vars));
} else {
player.sendMessage(MessageM.replaceAll(
location.config.getFile().get(location.location).toString()
.replaceAll("%player%", player.getName()), vars));
}
}
/**
* Send a message to all players online. Also replaces the "%player%"
* variable to the player's name.
* *
* @param message * @param message
* @param tag * Message which needs to be send to the player.
* @param vars * @param vars
* Variables. Seperated with a - . Ex: "playerName-" +
* player.getName();
*/ */
public static void broadcastMessage(String message, Boolean tag, public static void broadcastMessage(String message, String... vars) {
String... vars) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
String pMessage = message.replaceAll("%player%", player.getName()); // String pMessage = message.replaceAll("%player%",
player.sendMessage(MessageM.replaceAll(CType.TAG(tag) + pMessage, // player.getName());
vars)); player.sendMessage(MessageM.replaceAll(
message.replaceAll("%player%", player.getName()), vars));
} }
message = message.replaceAll("%player%", "Console"); // message = message.replaceAll("%player%", "Console");
Bukkit.getConsoleSender().sendMessage( Bukkit.getConsoleSender().sendMessage(
MessageM.replaceAll(CType.TAG(tag) + message, vars)); MessageM.replaceAll(message.replaceAll("%player%", "Console"),
vars));
} }
/** /**
* Sends a message to all online players from a Config. Replaces %player% * Send a message to all players online from a Config. Also replaces the
* tag to the Player's name or "Console". * "%player%" variable to the player's name.
* *
* @param location * @param location
* @param tag * Location in the config of the message being send.
* @param vars * @param vars
* Variables . Seperated with a - . Ex: "playerName-" +
* player.getName();
*/ */
public static void broadcastFMessage(ConfigC location, Boolean tag, public static void broadcastFMessage(ConfigC location, String... vars) {
String... vars) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
String pMessage = location.config.getFile() // String pMessage =
.get(location.getLocation()).toString() // location.config.getFile().get(location.location)
.replaceAll("%player%", player.getName()); // .toString().replaceAll("%player%", player.getName());
player.sendMessage(MessageM.replaceAll(CType.TAG(tag) + pMessage, player.sendMessage(MessageM.replaceAll(
vars)); location.config.getFile().get(location.location).toString()
.replaceAll("%player%", player.getName()), vars));
} }
String message = location.config.getFile().get(location.getLocation()) // String message = location.config.getFile().get(location.location)
.toString().replaceAll("%player%", "Console"); // .toString().replaceAll("%player%", "Console");
Bukkit.getConsoleSender().sendMessage( Bukkit.getConsoleSender().sendMessage(
MessageM.replaceAll(CType.TAG(tag) + message, vars)); MessageM.replaceAll(
location.config.getFile().get(location.location)
.toString().replaceAll("%player%", "Console"),
vars));
} }
/** /**
* Replace all variable codes. * Replace all variables.
* *
* @param message * @param message
* Message which needs to be replaced.
* @param vars * @param vars
* Variables. Seperated with a - . Ex: "playerName-" +
* player.getName();
* @return * @return
*/ */
public static String replaceAll(String message, String... vars) { public static String replaceAll(String message, String... vars) {
@ -108,20 +137,22 @@ public class MessageM {
} }
/** /**
* Replace all colour codes. * Replace default Minecraft colour codes.
* *
* @param message * @param message
* @return * Message which needs to be replaced.
* @return Colour replaced message.
*/ */
public static String replaceColours(String message) { public static String replaceColours(String message) {
return message.replaceAll("(&([a-fk-or0-9]))", "\u00A7$2"); return message.replaceAll("(&([a-fk-or0-9]))", "\u00A7$2");
} }
/** /**
* Replace Colour codes from config. * Replace colour codes of this plugin.
* *
* @param message * @param message
* @return * Message which needs to be replaced.
* @return Colour replaced message.
*/ */
public static String replaceColourVars(String message) { public static String replaceColourVars(String message) {
message = message.replaceAll("%N", CType.NORMAL()); message = message.replaceAll("%N", CType.NORMAL());
@ -129,14 +160,18 @@ public class MessageM {
message = message.replaceAll("%E", CType.ERROR()); message = message.replaceAll("%E", CType.ERROR());
message = message.replaceAll("%A", CType.ARG()); message = message.replaceAll("%A", CType.ARG());
message = message.replaceAll("%H", CType.HEADER()); message = message.replaceAll("%H", CType.HEADER());
message = message.replaceAll("%TAG", CType.TAG());
return message; return message;
} }
/** /**
* Replace all variables. * Replace custom variables.
* *
* @param message * @param message
* Message which needs to be replaced.
* @param vars * @param vars
* Variables. Seperated with a - . Ex: "playerName-" +
* player.getName();
* @return Replaced String. * @return Replaced String.
*/ */
public static String replaceVars(String message, String... vars) { public static String replaceVars(String message, String... vars) {
@ -171,16 +206,8 @@ public class MessageM {
public static String TAG() { public static String TAG() {
return (String) W.config.get(ConfigC.chat_header) return (String) W.config.get(ConfigC.chat_header)
+ (String) W.config.get(ConfigC.chat_tag); + (String) W.config.get(ConfigC.chat_tag)
} + (String) W.config.get(ConfigC.chat_normal);
public static String TAG(Boolean enabled) {
if (enabled) {
return (String) W.config.get(ConfigC.chat_header)
+ (String) W.config.get(ConfigC.chat_tag);
} else {
return "";
}
} }
} }
} }

View File

@ -0,0 +1,135 @@
package nl.Steffion.BlockHunt.Managers;
import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.PermissionsC;
import nl.Steffion.BlockHunt.PermissionsC.PType;
import nl.Steffion.BlockHunt.PermissionsC.Permissions;
import org.bukkit.entity.Player;
public class PermissionsM {
/**
* 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
*/
/**
* Check if an player has the permission. Also checks * related permissions.
* This permission DOES HAVE TO be registered.
*
* @param player
* The player who needs the permission.
* @param perm
* The permission.
* @param message
* Send a message to the player saying you don't have the
* permission.
* @return True/False when either the player has the permission.
*/
public static boolean hasPerm(Player player, Permissions perm,
Boolean message) {
PType type = perm.type;
if (player == null) {
return true;
}
if (type == PType.ALL) {
return true;
} else if (type == PType.OP) {
if (player.isOp()) {
return true;
}
} else if (type == PType.ADMIN) {
if (player.hasPermission(PermissionsC.main + "admin")) {
return true;
}
} else if (type == PType.MODERATOR) {
if (player.hasPermission(PermissionsC.main + "moderator")) {
return true;
}
} else if (type == PType.PLAYER) {
if (player.hasPermission(PermissionsC.main + "player")) {
return true;
}
}
if (player.hasPermission("*")) {
return true;
} else if (player.hasPermission(PermissionsC.main + "*")) {
return true;
} else if (player.hasPermission(PermissionsC.main + perm.perm)) {
return true;
} else if (player.hasPermission(PermissionsC.main + perm.perm + "*")) {
return true;
} else {
if (message) {
MessageM.sendFMessage(player, ConfigC.error_noPermission);
}
}
return false;
}
/**
* Check if an player has the permission. Also checks * related permissions.
* This permission does NOT have to be registered.
*
* @param player
* The player who needs the permission.
* @param type
* Type permission.
* @param perm
* The permission.
* @param message
* Send a message to the player saying you don't have the
* permission.
* @return True/False when either the player has the permission.
*/
public static boolean hasRawPerm(Player player, PType type, String perm,
Boolean message) {
if (player == null) {
return true;
}
if (type == PType.ALL) {
return true;
} else if (type == PType.OP) {
if (player.isOp()) {
return true;
}
} else if (type == PType.ADMIN) {
if (player.hasPermission(PermissionsC.main + "admin")) {
return true;
}
} else if (type == PType.MODERATOR) {
if (player.hasPermission(PermissionsC.main + "moderator")) {
return true;
}
} else if (type == PType.PLAYER) {
if (player.hasPermission(PermissionsC.main + "player")) {
return true;
}
}
if (player.hasPermission("*")) {
return true;
} else if (player.hasPermission(PermissionsC.main + "*")) {
return true;
} else if (player.hasPermission(perm)) {
return true;
} else if (player.hasPermission(perm)) {
return true;
} else {
if (message) {
MessageM.sendFMessage(player, ConfigC.error_noPermission);
}
}
return false;
}
}

View File

@ -1,144 +0,0 @@
package nl.Steffion.BlockHunt.Managers;
import nl.Steffion.BlockHunt.W;
import org.bukkit.entity.Player;
public class PlayerM {
/*
* Made by @author Steffion, © 2013.
*/
public static String main = W.pluginMainPermission;
public enum PType {
ALL, PLAYER, MODERATOR, ADMIN, OP;
}
public enum PermsC {
info (main + "info", PType.ALL),
help (main + "help", PType.ALL),
reload (main + "reload", PType.ADMIN),
join (main + "join", PType.PLAYER),
joinfull (main + "joinfull", PType.MODERATOR),
joinsign (main + "joinsign", PType.PLAYER),
leave (main + "leave", PType.PLAYER),
list (main + "list", PType.PLAYER),
shop (main + "shop", PType.PLAYER),
start (main + "start", PType.MODERATOR),
create (main + "create", PType.ADMIN),
set (main + "set", PType.MODERATOR),
setwarp (main + "setwarp", PType.MODERATOR),
signcreate (main + "signcreate", PType.MODERATOR),
remove (main + "remove", PType.ADMIN);
public String perm;
public PType type;
private PermsC (String perm, PType type) {
this.perm = perm;
this.type = type;
}
}
/**
* Check if the player has a permission.
*
* @param player
* @param perm
* @param message
* @return
*/
public static boolean hasPerm(Player player, PermsC perm, Boolean message) {
PType type = perm.type;
if (player == null) {
return true;
}
if (type == PType.ALL) {
return true;
} else if (type == PType.OP) {
if (player.isOp()) {
return true;
}
} else if (type == PType.ADMIN) {
if (player.hasPermission(main + "admin")) {
return true;
}
} else if (type == PType.MODERATOR) {
if (player.hasPermission(main + "moderator")) {
return true;
}
} else if (type == PType.PLAYER) {
if (player.hasPermission(main + "player")) {
return true;
}
}
if (player.hasPermission("*")) {
return true;
} else if (player.hasPermission(main + "*")) {
return true;
} else if (player.hasPermission(main + perm)) {
return true;
} else if (player.hasPermission(main + perm + "*")) {
return true;
} else {
if (message) {
MessageM.sendFMessage(player, ConfigC.error_noPermission, true);
}
}
return false;
}
/**
* Check if the player has a permission.
*
* @param player
* @param perm
* @param type
* @param message
* @return
*/
public static boolean hasPermRaw(Player player, String perm, PType type,
Boolean message) {
if (player == null) {
return true;
}
if (type == PType.ALL) {
return true;
} else if (type == PType.OP) {
if (player.isOp()) {
return true;
}
} else if (type == PType.ADMIN) {
if (player.hasPermission(main + "admin")) {
return true;
}
} else if (type == PType.MODERATOR) {
if (player.hasPermission(main + "moderator")) {
return true;
}
} else if (type == PType.PLAYER) {
if (player.hasPermission(main + "player")) {
return true;
}
}
if (player.hasPermission("*")) {
return true;
} else if (player.hasPermission(main + "*")) {
return true;
} else if (player.hasPermission(main + perm)) {
return true;
} else if (player.hasPermission(main + perm + "*")) {
return true;
} else {
if (message) {
MessageM.sendFMessage(player, ConfigC.error_noPermission, true);
}
}
return false;
}
}

View File

@ -0,0 +1,48 @@
package nl.Steffion.BlockHunt;
public class PermissionsC {
/**
* 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
*/
public static String main = BlockHunt.pdfFile.getName().toLowerCase()
+ ".";
public enum PType {
ALL, PLAYER, MODERATOR, ADMIN, OP;
}
public enum Permissions {
info (main + "info", PType.ALL),
help (main + "help", PType.ALL),
reload (main + "reload", PType.ADMIN),
join (main + "join", PType.PLAYER),
joinfull (main + "joinfull", PType.MODERATOR),
joinsign (main + "joinsign", PType.PLAYER),
leave (main + "leave", PType.PLAYER),
list (main + "list", PType.PLAYER),
shop (main + "shop", PType.PLAYER),
start (main + "start", PType.MODERATOR),
create (main + "create", PType.ADMIN),
set (main + "set", PType.MODERATOR),
setwarp (main + "setwarp", PType.MODERATOR),
signcreate (main + "signcreate", PType.MODERATOR),
remove (main + "remove", PType.ADMIN);
public String perm;
public PType type;
private Permissions (String perm, PType type) {
this.perm = perm;
this.type = type;
}
}
}

View File

@ -1,7 +1,6 @@
package nl.Steffion.BlockHunt; package nl.Steffion.BlockHunt;
import nl.Steffion.BlockHunt.Arena.ArenaState; import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -56,7 +56,7 @@ public class LocationSerializable extends Location implements
MessageM.sendMessage( MessageM.sendMessage(
null, null,
"%EError deserializing LocationSerializable - world not found! (%A%w%%E)", "%EError deserializing LocationSerializable - world not found! (%A%w%%E)",
true, "w-" + w); "w-" + w);
return null; return null;
} }
return new LocationSerializable(w, (Double) M.g(map, "x", 0D), return new LocationSerializable(w, (Double) M.g(map, "x", 0D),

View File

@ -2,7 +2,6 @@ package nl.Steffion.BlockHunt;
import java.util.ArrayList; import java.util.ArrayList;
import nl.Steffion.BlockHunt.Arena.ArenaState; import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable; import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
@ -57,7 +56,7 @@ public class SignsHandler {
if (!saved) { if (!saved) {
MessageM.sendFMessage(event.getPlayer(), MessageM.sendFMessage(event.getPlayer(),
ConfigC.error_noArena, true, "name-" + lines[1]); ConfigC.error_noArena, "name-" + lines[1]);
} }
} }
} }
@ -101,8 +100,7 @@ public class SignsHandler {
String[] lines = signblock.getLines(); String[] lines = signblock.getLines();
if (sign.contains("leave")) { if (sign.contains("leave")) {
ArrayList<String> signLines = (ArrayList<String>) W.config ArrayList<String> signLines = (ArrayList<String>) W.config
.getFile() .getFile().getList(ConfigC.sign_LEAVE.location);
.getList(ConfigC.sign_LEAVE.getLocation());
int linecount = 0; int linecount = 0;
for (String line : signLines) { for (String line : signLines) {
if (linecount <= 3) { if (linecount <= 3) {
@ -119,8 +117,7 @@ public class SignsHandler {
if (arena.gameState.equals(ArenaState.WAITING)) { if (arena.gameState.equals(ArenaState.WAITING)) {
ArrayList<String> signLines = (ArrayList<String>) W.config ArrayList<String> signLines = (ArrayList<String>) W.config
.getFile().getList( .getFile().getList(
ConfigC.sign_WAITING ConfigC.sign_WAITING.location);
.getLocation());
int linecount = 0; int linecount = 0;
if (signLines != null) { if (signLines != null) {
for (String line : signLines) { for (String line : signLines) {
@ -149,8 +146,7 @@ public class SignsHandler {
.equals(ArenaState.STARTING)) { .equals(ArenaState.STARTING)) {
ArrayList<String> signLines = (ArrayList<String>) W.config ArrayList<String> signLines = (ArrayList<String>) W.config
.getFile().getList( .getFile().getList(
ConfigC.sign_STARTING ConfigC.sign_STARTING.location);
.getLocation());
int linecount = 0; int linecount = 0;
if (signLines != null) { if (signLines != null) {
for (String line : signLines) { for (String line : signLines) {
@ -179,8 +175,7 @@ public class SignsHandler {
.equals(ArenaState.INGAME)) { .equals(ArenaState.INGAME)) {
ArrayList<String> signLines = (ArrayList<String>) W.config ArrayList<String> signLines = (ArrayList<String>) W.config
.getFile().getList( .getFile().getList(
ConfigC.sign_INGAME ConfigC.sign_INGAME.location);
.getLocation());
int linecount = 0; int linecount = 0;
if (signLines != null) { if (signLines != null) {
for (String line : signLines) { for (String line : signLines) {

View File

@ -2,7 +2,6 @@ package nl.Steffion.BlockHunt;
import java.util.LinkedList; import java.util.LinkedList;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.MessageM;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -59,6 +58,6 @@ public class SolidBlockHandler {
W.dcAPI.disguisePlayer(player, disguise); W.dcAPI.disguisePlayer(player, disguise);
} }
MessageM.sendFMessage(player, ConfigC.normal_ingameNoMoreSolid, true); MessageM.sendFMessage(player, ConfigC.normal_ingameNoMoreSolid);
} }
} }

View File

@ -201,11 +201,11 @@ public class Updater {
url = new URL(DBOUrl + slug + "/files.rss"); url = new URL(DBOUrl + slug + "/files.rss");
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
// Invalid slug // Invalid slug
MessageM.sendMessage(null, "%WThe author of this plugin (" MessageM.sendMessage(null, "%TAG%WThe author of this plugin ("
+ plugin.getDescription().getAuthors().get(0) + plugin.getDescription().getAuthors().get(0)
+ ") has misconfigured their Auto Update system", true); + ") has misconfigured their Auto Update system");
MessageM.sendMessage(null, "%WThe project slug given ('" + slug MessageM.sendMessage(null, "%TAG%WThe project slug given ('" + slug
+ "') is invalid. Please nag the author about this.", true); + "') is invalid. Please nag the author about this.");
result = Updater.UpdateResult.FAIL_BADSLUG; // Bad slug! Bad! result = Updater.UpdateResult.FAIL_BADSLUG; // Bad slug! Bad!
} }
thread = new Thread(new UpdateRunnable()); thread = new Thread(new UpdateRunnable());
@ -271,16 +271,16 @@ public class Updater {
byte[] data = new byte[BYTE_SIZE]; byte[] data = new byte[BYTE_SIZE];
int count; int count;
if (announce) if (announce)
MessageM.sendMessage(null, "%NAbout to download a new update: " MessageM.sendMessage(null,
+ versionTitle, true); "%TAG%NAbout to download a new update: " + versionTitle);
long downloaded = 0; long downloaded = 0;
while ((count = in.read(data, 0, BYTE_SIZE)) != -1) { while ((count = in.read(data, 0, BYTE_SIZE)) != -1) {
downloaded += count; downloaded += count;
fout.write(data, 0, count); fout.write(data, 0, count);
int percent = (int) (downloaded * 100 / fileLength); int percent = (int) (downloaded * 100 / fileLength);
if (announce & (percent % 10 == 0)) { if (announce & (percent % 10 == 0)) {
MessageM.sendMessage(null, "%NDownloading update: " MessageM.sendMessage(null, "%TAG%NDownloading update: "
+ percent + "% of " + fileLength + " bytes.", true); + percent + "% of " + fileLength + " bytes.");
} }
} }
// Just a quick check to make sure we didn't leave any files from // Just a quick check to make sure we didn't leave any files from
@ -297,12 +297,10 @@ public class Updater {
unzip(dFile.getCanonicalPath()); unzip(dFile.getCanonicalPath());
} }
if (announce) if (announce)
MessageM.sendMessage(null, "%NFinished updating.", true); MessageM.sendMessage(null, "%TAG%NFinished updating.");
} catch (Exception ex) { } catch (Exception ex) {
MessageM.sendMessage( MessageM.sendMessage(null,
null, "%TAG%WThe auto-updater tried to download a new update, but was unsuccessful.");
"%WThe auto-updater tried to download a new update, but was unsuccessful.",
true);
result = Updater.UpdateResult.FAIL_DOWNLOAD; result = Updater.UpdateResult.FAIL_DOWNLOAD;
} finally { } finally {
try { try {
@ -405,8 +403,7 @@ public class Updater {
ex.printStackTrace(); ex.printStackTrace();
MessageM.sendMessage( MessageM.sendMessage(
null, null,
"%WThe auto-updater tried to unzip a new update file, but was unsuccessful.", "%TAG%WThe auto-updater tried to unzip a new update file, but was unsuccessful.");
true);
result = Updater.UpdateResult.FAIL_DOWNLOAD; result = Updater.UpdateResult.FAIL_DOWNLOAD;
} }
new File(file).delete(); new File(file).delete();
@ -465,10 +462,8 @@ public class Updater {
buff = null; buff = null;
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
MessageM.sendMessage( MessageM.sendMessage(null,
null, "%TAG%WThe auto-updater tried to contact dev.bukkit.org, but was unsuccessful.");
"%WThe auto-updater tried to contact dev.bukkit.org, but was unsuccessful.",
true);
result = Updater.UpdateResult.FAIL_DBO; result = Updater.UpdateResult.FAIL_DBO;
return null; return null;
} }
@ -505,13 +500,12 @@ public class Updater {
} }
} else { } else {
// The file's name did not contain the string 'vVersion' // The file's name did not contain the string 'vVersion'
MessageM.sendMessage(null, "%WThe author of this plugin (" MessageM.sendMessage(null, "%TAG%WThe author of this plugin ("
+ plugin.getDescription().getAuthors().get(0) + plugin.getDescription().getAuthors().get(0)
+ ") has misconfigured their Auto Update system", true); + ") has misconfigured their Auto Update system");
MessageM.sendMessage( MessageM.sendMessage(
null, null,
"%WFiles uploaded to BukkitDev should contain the version number, seperated from the name by a 'v', such as PluginName v1.0", "%TAG%WFiles uploaded to BukkitDev should contain the version number, seperated from the name by a 'v', such as PluginName v1.0");
true);
result = Updater.UpdateResult.FAIL_NOVERSION; result = Updater.UpdateResult.FAIL_NOVERSION;
return false; return false;
} }
@ -598,10 +592,8 @@ public class Updater {
return false; return false;
} }
} catch (XMLStreamException e) { } catch (XMLStreamException e) {
MessageM.sendMessage( MessageM.sendMessage(null,
null, "%TAG%WCould not reach dev.bukkit.org for update checking. Is it offline?");
"%WCould not reach dev.bukkit.org for update checking. Is it offline?",
true);
return false; return false;
} }
} }
@ -615,8 +607,7 @@ public class Updater {
} catch (IOException e) { } catch (IOException e) {
MessageM.sendMessage( MessageM.sendMessage(
null, null,
"%WCould not reach BukkitDev file stream for update checking. Is dev.bukkit.org offline?", "%TAG%WCould not reach BukkitDev file stream for update checking. Is dev.bukkit.org offline?");
true);
return null; return null;
} }
} }

View File

@ -4,8 +4,8 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Random; import java.util.Random;
import nl.Steffion.BlockHunt.Managers.CommandM;
import nl.Steffion.BlockHunt.Managers.ConfigM; import nl.Steffion.BlockHunt.Managers.ConfigM;
import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable; import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import org.bukkit.Location; import org.bukkit.Location;
@ -15,24 +15,40 @@ import org.bukkit.inventory.ItemStack;
import pgDev.bukkit.DisguiseCraft.api.DisguiseCraftAPI; import pgDev.bukkit.DisguiseCraft.api.DisguiseCraftAPI;
public class W { public class W {
/* /**
* Made by @author Steffion, © 2013. * 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
*/ */
public static String pluginName = "BlockHunt"; /*
public static String pluginVersion = "v0.1.5_ALPHA"; * Standard stuff.
public static String engineVersion = "v1.1.0"; */
public static String pluginAutors = "Steffion";
public static String pluginMainPermission = pluginName + ".";
public static ArrayList<String> newFiles = new ArrayList<String>(); public static ArrayList<String> newFiles = new ArrayList<String>();
public static ArrayList<CommandM> commands = new ArrayList<CommandM>();
/*
* If you want another file to be created. Copy and paste this line.
*/
public static ConfigM config = new ConfigM("config");
public static ConfigM messages = new ConfigM("messages");
public static ConfigM arenas = new ConfigM("arenas");
public static ConfigM signs = new ConfigM("signs");
public static ConfigM shop = new ConfigM("shop");
/*
* Add any variable you need in different classes here:
*/
public static HashMap<Player, LocationSerializable> pos1 = new HashMap<Player, LocationSerializable>(); public static HashMap<Player, LocationSerializable> pos1 = new HashMap<Player, LocationSerializable>();
public static HashMap<Player, LocationSerializable> pos2 = new HashMap<Player, LocationSerializable>(); public static HashMap<Player, LocationSerializable> pos2 = new HashMap<Player, LocationSerializable>();
public static ConfigM config = new ConfigM("config", "");
public static ConfigM messages = new ConfigM("messages", "");
public static ConfigM arenas = new ConfigM("arenas", "");
public static ConfigM signs = new ConfigM("signs", "");
public static ConfigM shop = new ConfigM("shop", "");
public static ArrayList<Arena> arenaList = new ArrayList<Arena>(); public static ArrayList<Arena> arenaList = new ArrayList<Arena>();
public static Random random = new Random(); public static Random random = new Random();
public static DisguiseCraftAPI dcAPI; public static DisguiseCraftAPI dcAPI;
@ -45,14 +61,4 @@ public class W {
public static HashMap<Player, Location> moveLoc = new HashMap<Player, Location>(); public static HashMap<Player, Location> moveLoc = new HashMap<Player, Location>();
public static HashMap<Player, Location> hiddenLoc = new HashMap<Player, Location>(); public static HashMap<Player, Location> hiddenLoc = new HashMap<Player, Location>();
public static HashMap<Player, Boolean> hiddenLocWater = new HashMap<Player, Boolean>(); public static HashMap<Player, Boolean> hiddenLocWater = new HashMap<Player, Boolean>();
public static void newFiles() {
ConfigM.setDefaults();
for (String Filename : newFiles) {
MessageM.sendMessage(null,
"%WCouldn't find '%A%Filename%.yml%W' creating new one.",
true, "Filename-" + Filename);
}
newFiles.clear();
}
} }