renamed config entry for party-on-join, registered events with better method

This commit is contained in:
Gibstick 2013-07-28 19:01:30 -04:00
parent d76681400d
commit 4ac1e7a758

View File

@ -26,14 +26,13 @@ public final class DiscoSheep extends JavaPlugin {
static final String PERMISSION_TOGGLEPARTYONJOIN = "discosheep.admin.toggleonjoin"; static final String PERMISSION_TOGGLEPARTYONJOIN = "discosheep.admin.toggleonjoin";
static boolean partyOnJoin = true; static boolean partyOnJoin = true;
Map<String, DiscoParty> parties = new HashMap<String, DiscoParty>(); Map<String, DiscoParty> parties = new HashMap<String, DiscoParty>();
private GlobalEvents globalEvents = new GlobalEvents(this);
@Override @Override
public void onEnable() { public void onEnable() {
getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this)); getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this));
getServer().getPluginManager().registerEvents(globalEvents, this); getServer().getPluginManager().registerEvents(new GlobalEvents(this), this);
getConfig().addDefault("party-on-join.enabled", partyOnJoin); getConfig().addDefault("on-join.enabled", partyOnJoin);
getConfig().addDefault("max.sheep", DiscoParty.maxSheep); getConfig().addDefault("max.sheep", DiscoParty.maxSheep);
getConfig().addDefault("max.radius", DiscoParty.maxRadius); getConfig().addDefault("max.radius", DiscoParty.maxRadius);
getConfig().addDefault("max.duration", toSeconds_i(DiscoParty.maxDuration)); getConfig().addDefault("max.duration", toSeconds_i(DiscoParty.maxDuration));
@ -71,7 +70,7 @@ public final class DiscoSheep extends JavaPlugin {
getConfig().options().copyDefaults(true); getConfig().options().copyDefaults(true);
saveConfig(); saveConfig();
partyOnJoin = getConfig().getBoolean("party-on-join.enabled"); partyOnJoin = getConfig().getBoolean("on-join.enabled");
DiscoParty.maxSheep = getConfig().getInt("max.sheep"); DiscoParty.maxSheep = getConfig().getInt("max.sheep");
DiscoParty.maxRadius = getConfig().getInt("max.radius"); DiscoParty.maxRadius = getConfig().getInt("max.radius");
DiscoParty.maxDuration = toTicks(getConfig().getInt("max.duration")); DiscoParty.maxDuration = toTicks(getConfig().getInt("max.duration"));
@ -98,6 +97,7 @@ public final class DiscoSheep extends JavaPlugin {
} }
void saveConfigToDisk() { void saveConfigToDisk() {
getConfig().set("on-join.enabled", partyOnJoin);
getConfig().set("default.sheep", DiscoParty.defaultSheep); getConfig().set("default.sheep", DiscoParty.defaultSheep);
getConfig().set("default.radius", DiscoParty.defaultRadius); getConfig().set("default.radius", DiscoParty.defaultRadius);
getConfig().set("default.duration", toSeconds_i(DiscoParty.defaultDuration)); getConfig().set("default.duration", toSeconds_i(DiscoParty.defaultDuration));
@ -244,7 +244,7 @@ public final class DiscoSheep extends JavaPlugin {
if (!hasParty(p.getName())) { if (!hasParty(p.getName())) {
DiscoParty individualParty = party.DiscoParty(p); DiscoParty individualParty = party.DiscoParty(p);
individualParty.startDisco(); individualParty.startDisco();
p.sendMessage(ChatColor.RED + "LET'S DISCO!"); p.sendMessage(ChatColor.RED + "LET'S DISCO!!");
} }
} }
return true; return true;