Skip to content

Instantly share code, notes, and snippets.

@Zetaeta
Created May 25, 2013 20:06
Show Gist options
  • Save Zetaeta/5650588 to your computer and use it in GitHub Desktop.
Save Zetaeta/5650588 to your computer and use it in GitHub Desktop.
package net.zetaeta.aoc;
import java.util.EnumSet;
import java.util.List;
import net.zetaeta.bukkit.util.configuration.ConfigOpt;
import net.zetaeta.bukkit.util.configuration.ConfigurationAccess;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
/**
* Configuration options for the plugin.
*
* In messages, certain variables are replaced when the message is sent:
* %p: the name of the player to which the message is relevant.
* %q: the name of the enemy player to which the message is relevant.
* %t: the name of the team to which the message is relevant.
* %o: the name of the enemy team to which the message is relevant.
* %l: the coordinates of the plot to which the message is relevant.
* If immediately suffixed by '{', it will put the coordinates in curly brackets
* Why? I have no idea. Redundant as can just be used around %l anyway. May be removed in future.
*
* @author daniel
*
*/
public class Config extends ConfigurationAccess{
@ConfigOpt(value="game.compass.update_ticks", defInt=20)
public static int compassUpdateTicks;
@ConfigOpt("world.flag.size.x")
public static int flagSizeX;
@ConfigOpt("world.flag.size.z")
public static int flagSizeZ;
@ConfigOpt("world.flag.size.y")
public static int flagSizeY;
@ConfigOpt("world.ground_height")
public static int groundHeight;
/**
* World (square) radius in blocks
*/
@ConfigOpt("world.radius")
public static int worldRadius;
/**
* Numer of types of special plots.
*/
@ConfigOpt(value="world.plots.special_plot_count", defInt=0, hasDefault=true)
public static int specialPlotCount;
/**
* Percentage chance of a plot being any special plot
* (i.e. 10% with 3 special plot types means 3.3...% each).
*/
@ConfigOpt(value="world.plots.special_plot_chance", defInt=10)
public static int specialPlotChance;
/**
* Radius, in plots, around capitals that start off owned by the capital's team.
*/
@ConfigOpt(value="world.plots.radius_owned_around_capital", defInt=1)
public static int radiusOwnedAroundCapital;
@ConfigOpt(value="game.rank.knightcost")
public static double knightCost;
@ConfigOpt(value="game.rank.knight.name", defString="Knight")
public static String knightName;
@ConfigOpt(value="game.rank.militia.name", defString="Militia")
public static String militiaName;
@ConfigOpt(value="game.rank.conscript.name", defString="Conscript")
public static String conscriptName;
@ConfigOpt(value="game.backup", defBoolean=true, hasDefault=true)
public static boolean backupGame;
@ConfigOpt(value="game.paused", defBoolean=false, hasDefault=true)
public static boolean gamePaused;
@ConfigOpt(value="game.pause_on_stop", defBoolean=true, hasDefault=true)
public static boolean pauseOnStop;
@ConfigOpt(value="game.unpause_on_startup", defBoolean=true, hasDefault=true)
public static boolean unpauseOnStartup;
@ConfigOpt("game.reward.claim.plot")
public static double plotClaimReward;
@ConfigOpt("game.reward.claim.capital")
public static double capitalClaimReward;
@ConfigOpt("game.reward.win")
public static double winReward;
@ConfigOpt(value="chat.permission_prefix", defString="mchat.prefix")
public static String chatPermissionPrefix;
@ConfigOpt(value="messages.login", defString = "Welcome, %p, to Madgaming!")
public static String loginMessage;
@ConfigOpt("messages.status.in_game")
public static String statusMessageInGame;
@ConfigOpt("messages.status.before_game")
public static String statusMessageNoGame;
@ConfigOpt(value="messages.game.startup", defString="\u00a7aStarting game!")
public static String startupMessage;
@ConfigOpt(value="messages.game.cancel", defString="\u00a7cCancelling game!")
public static String cancelMessage;
@ConfigOpt(value="messages.game.pause", defString="\u00a7aPausing game!")
public static String pauseMessage;
@ConfigOpt(value="messages.game.unpause", defString="\u00a7aResuming game!")
public static String unPauseMessage;
@ConfigOpt(value="messages.game.win", defString="\u00a7aTeam %t has won the game!")
public static String winMessage;
@ConfigOpt(value="messages.team.player_join.to_player", defString="You have been added to the team %t")
public static String playerJoinTeamMessageToPlayer;
@ConfigOpt(value="messages.player.join.not_started", defString="\u00a7aYou have attempted to join the game.\n" +
"\u00a7aThere are currently %c players online out for 4 required to start the game.\n" +
"\u00a7aPlease wait for more people to join in order to begin the game.")
public static String joinGameNotStartedMessage;
@ConfigOpt(value="messages.team.status", defString = "\u00a7aTeam %t currently has %d players online.\n" +
"\u00a7aIt owns %i plots, of which %j are currently being taken by other teams.\n" +
"\u00a7aIt is currently taking %k plots from other teams.")
public static String teamStatusMessage;
@ConfigOpt(value="messages.flag.break", defString="\u00a7cYou cannot break a flag!")
public static String flagBreakMessage;
@ConfigOpt(value="messages.capture.flag.disallowed", defString="\u00a7cYou cannot take this flag!")
public static String cantTakeFlagMessage;
@ConfigOpt(value="messages.capture.flag.capturingteam", defString="\u00a7a%p has taken the flag of %l for your team!")
public static String flagTakerMessage;
@ConfigOpt(value="messages.capture.flag.alreadytaken", defString="\u00a7cThis flag has already been claimed by %q on %o")
public static String flagAlreadyTakenMessage;
@ConfigOpt(value="messages.capture.alreadycapturing", defString="\u00a7cYou are already capturing a plot (at %m)")
public static String alreadyCapturingMessage;
@ConfigOpt(value="messages.capture.plot.capturingteam", defString="\u00a7a%p has captured plot %l{ for your team!")
public static String plotCapturerMessage;
@ConfigOpt(value="messages.capture.plot.captureeteam", defString="\u00a7c%p has captured plot %l{ for %o")
public static String plotCaptureeMessage;
@ConfigOpt(value="messages.capture.capital.capturingteam", defString="\u00a7a%p has captured the capital of %o for your team!")
public static String capitalCapturerMessage;
@ConfigOpt(value="messages.capture.capital.captureeteam", defString="\u00a7c%p has captured your capital for %o!\nYou have been knocked out!")
public static String capitalCaptureeMessage;
@ConfigOpt(value="messages.capture.capital.broadcast", defString="\u00a7a%o Has been knocked out by %t")
public static String capitalCaptureBroadcast;
@ConfigOpt(value="messages.team.list_colours", defString="ac")
public static String teamListColours;
@ConfigOpt(value="messages.rank.info", defString="\u00a7aYou are a %r")
public static String rankInfoMessage;
@ConfigOpt(value="messages.error.game_not_started", defString="\u00a7cThe game is not running!")
public static String gameNotStartedError;
@ConfigOpt(value="messages.error.no_flagthief", defString="\u00a7cNo-one has taken one of your flags!")
public static String noFlagThiefError;
public static EnumSet<Material> flagBlocks;
@Override
public void load(ConfigurationSection config) {
super.load(config);
if (!config.contains("world.flag.blocks")) {
flagBlocks = EnumSet.of(Material.WOOL, Material.FENCE);
return;
}
List<String> blocksStr = config.getStringList("world.flag.blocks");
flagBlocks = EnumSet.of(Material.AIR);
for (String b : blocksStr) {
Material m = Material.matchMaterial(b);
if (m != null) {
flagBlocks.add(m);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment