Minor changes to naming.

This commit is contained in:
RangerMauve 2013-07-29 19:50:14 -04:00
parent a7f9b4358a
commit ae93d9a5e4
5 changed files with 357 additions and 390 deletions

View File

@ -18,12 +18,9 @@ import org.bukkit.FireworkEffect.Builder;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
/**
*
* @author Georgiy
*/
public class DiscoParty { public class DiscoParty {
private DiscoSheep parent; private DiscoSheep parent;
@ -426,34 +423,17 @@ public class DiscoParty {
playSounds(); playSounds();
duration -= period; duration -= period;
this.scheduleUpdate(); this.scheduleUpdate();
if (state < 10000) { this.state = (this.state + 1) % 10000;
this.state++;
} else {
state = 1; // prevent overflow
}
} else { } else {
this.stopDisco(); this.stopDisco();
} }
} }
void scheduleUpdate() { void scheduleUpdate() {
updater = new DiscoUpdater(this); updater = new DiscoUpdater();
updater.runTaskLater(parent, this.period); updater.runTaskLater(parent, this.period);
} }
@Deprecated
void startDisco(int duration, int sheepAmount, int radius, int period, boolean fireworks) {
if (this.duration > 0) {
stopDisco();
}
this.spawnAll(sheepAmount, radius);
this.doFireworks = fireworks;
this.period = period;
this.duration = duration;
this.scheduleUpdate();
parent.getPartyMap().put(this.player.getName(), this);
}
void startDisco() { void startDisco() {
this.spawnAll(sheep, radius); this.spawnAll(sheep, radius);
this.scheduleUpdate(); this.scheduleUpdate();
@ -474,4 +454,12 @@ public class DiscoParty {
// stop listening // stop listening
HandlerList.unregisterAll(this.partyEvents); HandlerList.unregisterAll(this.partyEvents);
} }
class DiscoUpdater extends BukkitRunnable {
@Override
public void run() {
update();
}
}
} }

View File

@ -1,309 +1,309 @@
package ca.gibstick.discosheep; package ca.gibstick.discosheep;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public final class DiscoSheep extends JavaPlugin { public final class DiscoSheep extends JavaPlugin {
static final String PERMISSION_PARTY = "discosheep.party.me"; static final String PERMISSION_PARTY = "discosheep.party.me";
static final String PERMISSION_ALL = "discosheep.party.all"; static final String PERMISSION_ALL = "discosheep.party.all";
static final String PERMISSION_FIREWORKS = "discosheep.party.fireworks"; static final String PERMISSION_FIREWORKS = "discosheep.party.fireworks";
static final String PERMISSION_STOPALL = "discosheep.admin.stopall"; static final String PERMISSION_STOPALL = "discosheep.admin.stopall";
static final String PERMISSION_RELOAD = "discosheep.admin.reload"; static final String PERMISSION_RELOAD = "discosheep.admin.reload";
static final String PERMISSION_OTHER = "discosheep.party.other"; static final String PERMISSION_OTHER = "discosheep.party.other";
static final String PERMISSION_CHANGEPERIOD = "discosheep.party.changeperiod"; static final String PERMISSION_CHANGEPERIOD = "discosheep.party.changeperiod";
static final String PERMISSION_CHANGEDEFAULTS = "discosheep.admin.changedefaults"; static final String PERMISSION_CHANGEDEFAULTS = "discosheep.admin.changedefaults";
static final String PERMISSION_SAVECONFIG = "discosheep.admin.saveconfig"; static final String PERMISSION_SAVECONFIG = "discosheep.admin.saveconfig";
static final String PERMISSION_ONJOIN = "discosheep.party.onjoin"; static final String PERMISSION_ONJOIN = "discosheep.party.onjoin";
static final String PERMISSION_SPAWNGUESTS = "discosheep.party.spawnguests"; static final String PERMISSION_SPAWNGUESTS = "discosheep.party.spawnguests";
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>();
@Override @Override
public void onEnable() { public void onEnable() {
getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this)); getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this));
getServer().getPluginManager().registerEvents(new GlobalEvents(this), this); getServer().getPluginManager().registerEvents(new GlobalEvents(this), this);
getConfig().addDefault("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));
getConfig().addDefault("max.period-ticks", DiscoParty.maxPeriod); getConfig().addDefault("max.period-ticks", DiscoParty.maxPeriod);
getConfig().addDefault("min.period-ticks", DiscoParty.minPeriod); getConfig().addDefault("min.period-ticks", DiscoParty.minPeriod);
getConfig().addDefault("default.sheep", DiscoParty.defaultSheep); getConfig().addDefault("default.sheep", DiscoParty.defaultSheep);
getConfig().addDefault("default.radius", DiscoParty.defaultRadius); getConfig().addDefault("default.radius", DiscoParty.defaultRadius);
getConfig().addDefault("default.duration", toSeconds_i(DiscoParty.defaultDuration)); getConfig().addDefault("default.duration", toSeconds_i(DiscoParty.defaultDuration));
getConfig().addDefault("default.period-ticks", DiscoParty.defaultPeriod); getConfig().addDefault("default.period-ticks", DiscoParty.defaultPeriod);
/* /*
* Iterate through all live entities and create default configuration values for them * Iterate through all live entities and create default configuration values for them
* excludes bosses and other mobs that throw NPE * excludes bosses and other mobs that throw NPE
*/ */
for (EntityType ent : EntityType.values()) { for (EntityType ent : EntityType.values()) {
if (ent.isAlive() if (ent.isAlive()
&& !ent.equals(EntityType.ENDER_DRAGON) && !ent.equals(EntityType.ENDER_DRAGON)
&& !ent.equals(EntityType.WITHER) && !ent.equals(EntityType.WITHER)
&& !ent.equals(EntityType.PIG_ZOMBIE) && !ent.equals(EntityType.PIG_ZOMBIE)
&& !ent.equals(EntityType.OCELOT) && !ent.equals(EntityType.OCELOT)
&& !ent.equals(EntityType.CAVE_SPIDER) && !ent.equals(EntityType.CAVE_SPIDER)
&& !ent.equals(EntityType.MAGMA_CUBE) && !ent.equals(EntityType.MAGMA_CUBE)
&& !ent.equals(EntityType.MUSHROOM_COW) && !ent.equals(EntityType.MUSHROOM_COW)
&& !ent.equals(EntityType.IRON_GOLEM) && !ent.equals(EntityType.IRON_GOLEM)
&& !ent.equals(EntityType.PLAYER)) { && !ent.equals(EntityType.PLAYER)) {
getConfig().addDefault("default.guests." + ent.toString(), 0); getConfig().addDefault("default.guests." + ent.toString(), 0);
getConfig().addDefault("max.guests." + ent.toString(), 0); getConfig().addDefault("max.guests." + ent.toString(), 0);
} }
} }
loadConfigFromDisk(); loadConfigFromDisk();
} }
void loadConfigFromDisk() { void loadConfigFromDisk() {
getConfig().options().copyDefaults(true); getConfig().options().copyDefaults(true);
saveConfig(); saveConfig();
partyOnJoin = getConfig().getBoolean("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"));
DiscoParty.maxPeriod = getConfig().getInt("max.period-ticks"); DiscoParty.maxPeriod = getConfig().getInt("max.period-ticks");
DiscoParty.minPeriod = getConfig().getInt("min.period-ticks"); DiscoParty.minPeriod = getConfig().getInt("min.period-ticks");
DiscoParty.defaultSheep = getConfig().getInt("default.sheep"); DiscoParty.defaultSheep = getConfig().getInt("default.sheep");
DiscoParty.defaultRadius = getConfig().getInt("default.radius"); DiscoParty.defaultRadius = getConfig().getInt("default.radius");
DiscoParty.defaultDuration = toTicks(getConfig().getInt("default.duration")); DiscoParty.defaultDuration = toTicks(getConfig().getInt("default.duration"));
DiscoParty.defaultPeriod = getConfig().getInt("default.period-ticks"); DiscoParty.defaultPeriod = getConfig().getInt("default.period-ticks");
for (String key : getConfig().getConfigurationSection("default.guests").getKeys(false)) { for (String key : getConfig().getConfigurationSection("default.guests").getKeys(false)) {
DiscoParty.getDefaultGuestNumbers().put(key, getConfig().getInt("default.guests." + key)); DiscoParty.getDefaultGuestNumbers().put(key, getConfig().getInt("default.guests." + key));
} }
for (String key : getConfig().getConfigurationSection("max.guests").getKeys(false)) { for (String key : getConfig().getConfigurationSection("max.guests").getKeys(false)) {
DiscoParty.getMaxGuestNumbers().put(key, getConfig().getInt("max.guests." + key)); DiscoParty.getMaxGuestNumbers().put(key, getConfig().getInt("max.guests." + key));
} }
} }
void reloadConfigFromDisk() { void reloadConfigFromDisk() {
reloadConfig(); reloadConfig();
loadConfigFromDisk(); loadConfigFromDisk();
} }
void saveConfigToDisk() { void saveConfigToDisk() {
getConfig().set("on-join.enabled", partyOnJoin); 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));
getConfig().set("default.period-ticks", DiscoParty.defaultPeriod); getConfig().set("default.period-ticks", DiscoParty.defaultPeriod);
for (Map.Entry<String, Integer> entry : DiscoParty.getDefaultGuestNumbers().entrySet()) { for (Map.Entry<String, Integer> entry : DiscoParty.getDefaultGuestNumbers().entrySet()) {
getConfig().set("default.guests." + entry.getKey(), entry.getValue()); getConfig().set("default.guests." + entry.getKey(), entry.getValue());
} }
saveConfig(); saveConfig();
} }
@Override @Override
public void onDisable() { public void onDisable() {
this.stopAllParties(); // or else the parties will continue FOREVER this.stopAllParties(); // or else the parties will continue FOREVER
} }
int toTicks(double seconds) { static int toTicks(double seconds) {
return (int) Math.round(seconds * 20.0); return (int) Math.round(seconds * 20.0);
} }
double toSeconds(int ticks) { static double toSeconds(int ticks) {
return (double) Math.round(ticks / 20.0); return (double) Math.round(ticks / 20.0);
} }
int toSeconds_i(int ticks) { static int toSeconds_i(int ticks) {
return (int) Math.round(ticks / 20.0); return (int) Math.round(ticks / 20.0);
} }
public synchronized Map<String, DiscoParty> getPartyMap() { public synchronized Map<String, DiscoParty> getPartyMap() {
return this.parties; return this.parties;
} }
public synchronized ArrayList<DiscoParty> getParties() { public synchronized ArrayList<DiscoParty> getParties() {
return new ArrayList<DiscoParty>(this.getPartyMap().values()); return new ArrayList<DiscoParty>(this.getPartyMap().values());
} }
public void stopParty(String name) { public void stopParty(String name) {
if (this.hasParty(name)) { if (this.hasParty(name)) {
this.getParty(name).stopDisco(); this.getParty(name).stopDisco();
} }
} }
public void stopAllParties() { public void stopAllParties() {
for (DiscoParty party : this.getParties()) { for (DiscoParty party : this.getParties()) {
party.stopDisco(); party.stopDisco();
} }
} }
public boolean hasParty(String name) { public boolean hasParty(String name) {
return this.getPartyMap().containsKey(name); return this.getPartyMap().containsKey(name);
} }
public DiscoParty getParty(String name) { public DiscoParty getParty(String name) {
return this.getPartyMap().get(name); return this.getPartyMap().get(name);
} }
public void removeParty(String name) { public void removeParty(String name) {
if (this.hasParty(name)) { if (this.hasParty(name)) {
this.getPartyMap().remove(name); this.getPartyMap().remove(name);
} }
} }
/*-- Actual commands begin here --*/ /*-- Actual commands begin here --*/
boolean helpCommand(CommandSender sender) { boolean helpCommand(CommandSender sender) {
sender.sendMessage(ChatColor.YELLOW sender.sendMessage(ChatColor.YELLOW
+ "DiscoSheep Help\n" + "DiscoSheep Help\n"
+ ChatColor.GRAY + ChatColor.GRAY
+ " Subcommands\n" + " Subcommands\n"
+ ChatColor.WHITE + "me, stop, all, stopall, save, reload\n" + ChatColor.WHITE + "me, stop, all, stopall, save, reload\n"
+ "other <players>: start a party for the space-delimited list of players\n" + "other <players>: start a party for the space-delimited list of players\n"
+ "defaults: Change the default settings for parties (takes normal arguments)\n" + "defaults: Change the default settings for parties (takes normal arguments)\n"
+ ChatColor.GRAY + " Arguments\n" + ChatColor.GRAY + " Arguments\n"
+ ChatColor.WHITE + "-n <integer>: set the number of sheep per player that spawn\n" + ChatColor.WHITE + "-n <integer>: set the number of sheep per player that spawn\n"
+ "-t <integer>: set the party duration in seconds\n" + "-t <integer>: set the party duration in seconds\n"
+ "-p <ticks>: set the number of ticks between each disco beat\n" + "-p <ticks>: set the number of ticks between each disco beat\n"
+ "-r <integer>: set radius of the area in which sheep can spawn\n" + "-r <integer>: set radius of the area in which sheep can spawn\n"
+ "-g <mob> <number>: set spawns for other mobs" + "-g <mob> <number>: set spawns for other mobs"
+ "-fw: enables fireworks"); + "-fw: enables fireworks");
return true; return true;
} }
boolean stopMeCommand(CommandSender sender) { boolean stopMeCommand(CommandSender sender) {
stopParty(sender.getName()); stopParty(sender.getName());
return true; return true;
} }
boolean stopAllCommand(CommandSender sender) { boolean stopAllCommand(CommandSender sender) {
if (sender.hasPermission(PERMISSION_STOPALL)) { if (sender.hasPermission(PERMISSION_STOPALL)) {
stopAllParties(); stopAllParties();
return true; return true;
} else { } else {
return noPermsMessage(sender, PERMISSION_STOPALL); return noPermsMessage(sender, PERMISSION_STOPALL);
} }
} }
boolean partyCommand(Player player, DiscoParty party) { boolean partyCommand(Player player, DiscoParty party) {
if (player.hasPermission(PERMISSION_PARTY)) { if (player.hasPermission(PERMISSION_PARTY)) {
if (!hasParty(player.getName())) { if (!hasParty(player.getName())) {
party.setPlayer(player); party.setPlayer(player);
party.startDisco(); party.startDisco();
} else { } else {
player.sendMessage(ChatColor.RED + "You already have a party. Are you underground?"); player.sendMessage(ChatColor.RED + "You already have a party. Are you underground?");
} }
return true; return true;
} else { } else {
return noPermsMessage(player, PERMISSION_PARTY); return noPermsMessage(player, PERMISSION_PARTY);
} }
} }
boolean reloadCommand(CommandSender sender) { boolean reloadCommand(CommandSender sender) {
if (sender.hasPermission(PERMISSION_RELOAD)) { if (sender.hasPermission(PERMISSION_RELOAD)) {
reloadConfigFromDisk(); reloadConfigFromDisk();
sender.sendMessage(ChatColor.GREEN + "DiscoSheep config reloaded from disk"); sender.sendMessage(ChatColor.GREEN + "DiscoSheep config reloaded from disk");
return true; return true;
} else { } else {
return noPermsMessage(sender, PERMISSION_RELOAD); return noPermsMessage(sender, PERMISSION_RELOAD);
} }
} }
boolean partyOtherCommand(String[] players, CommandSender sender, DiscoParty party) { boolean partyOtherCommand(String[] players, CommandSender sender, DiscoParty party) {
if (sender.hasPermission(PERMISSION_OTHER)) { if (sender.hasPermission(PERMISSION_OTHER)) {
Player p; Player p;
for (String playerName : players) { for (String playerName : players) {
p = Bukkit.getServer().getPlayer(playerName); p = Bukkit.getServer().getPlayer(playerName);
if (p != null) { if (p != null) {
if (!hasParty(p.getName())) { if (!hasParty(p.getName())) {
DiscoParty individualParty = party.DiscoParty(p); DiscoParty individualParty = party.DiscoParty(p);
individualParty.startDisco(); individualParty.startDisco();
} }
} else { } else {
sender.sendMessage("Invalid player: " + playerName); sender.sendMessage("Invalid player: " + playerName);
} }
} }
return true; return true;
} else { } else {
return noPermsMessage(sender, PERMISSION_OTHER); return noPermsMessage(sender, PERMISSION_OTHER);
} }
} }
boolean partyAllCommand(CommandSender sender, DiscoParty party) { boolean partyAllCommand(CommandSender sender, DiscoParty party) {
if (sender.hasPermission(PERMISSION_ALL)) { if (sender.hasPermission(PERMISSION_ALL)) {
for (Player p : Bukkit.getServer().getOnlinePlayers()) { for (Player p : Bukkit.getServer().getOnlinePlayers()) {
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;
} else { } else {
return noPermsMessage(sender, PERMISSION_ALL); return noPermsMessage(sender, PERMISSION_ALL);
} }
} }
void partyOnJoin(Player player) { void partyOnJoin(Player player) {
if (!partyOnJoin) { if (!partyOnJoin) {
return; return;
} }
if (player.hasPermission(PERMISSION_ONJOIN)) { if (player.hasPermission(PERMISSION_ONJOIN)) {
DiscoParty party = new DiscoParty(this, player); DiscoParty party = new DiscoParty(this, player);
party.startDisco(); party.startDisco();
} }
} }
boolean togglePartyOnJoinCommand(CommandSender sender) { boolean togglePartyOnJoinCommand(CommandSender sender) {
if (!sender.hasPermission(PERMISSION_TOGGLEPARTYONJOIN)) { if (!sender.hasPermission(PERMISSION_TOGGLEPARTYONJOIN)) {
return noPermsMessage(sender, PERMISSION_TOGGLEPARTYONJOIN); return noPermsMessage(sender, PERMISSION_TOGGLEPARTYONJOIN);
} }
partyOnJoin = !partyOnJoin; partyOnJoin = !partyOnJoin;
if (partyOnJoin) { if (partyOnJoin) {
sender.sendMessage(ChatColor.GREEN + "DiscoSheep party on join functionality enabled."); sender.sendMessage(ChatColor.GREEN + "DiscoSheep party on join functionality enabled.");
} else { } else {
sender.sendMessage(ChatColor.GREEN + "DiscoSheep party on join functionality disabled."); sender.sendMessage(ChatColor.GREEN + "DiscoSheep party on join functionality disabled.");
} }
return true; return true;
} }
boolean setDefaultsCommand(CommandSender sender, DiscoParty party) { boolean setDefaultsCommand(CommandSender sender, DiscoParty party) {
if (sender.hasPermission(PERMISSION_CHANGEDEFAULTS)) { if (sender.hasPermission(PERMISSION_CHANGEDEFAULTS)) {
party.setDefaultsFromCurrent(); party.setDefaultsFromCurrent();
sender.sendMessage(ChatColor.GREEN + "DiscoSheep configured with new defaults (not saved to disk yet)"); sender.sendMessage(ChatColor.GREEN + "DiscoSheep configured with new defaults (not saved to disk yet)");
return true; return true;
} else { } else {
return noPermsMessage(sender, PERMISSION_CHANGEDEFAULTS); return noPermsMessage(sender, PERMISSION_CHANGEDEFAULTS);
} }
} }
boolean saveConfigCommand(CommandSender sender) { boolean saveConfigCommand(CommandSender sender) {
if (sender.hasPermission(PERMISSION_SAVECONFIG)) { if (sender.hasPermission(PERMISSION_SAVECONFIG)) {
saveConfigToDisk(); saveConfigToDisk();
sender.sendMessage(ChatColor.GREEN + "DiscoSheep config saved to disk"); sender.sendMessage(ChatColor.GREEN + "DiscoSheep config saved to disk");
return true; return true;
} else { } else {
return noPermsMessage(sender, PERMISSION_SAVECONFIG); return noPermsMessage(sender, PERMISSION_SAVECONFIG);
} }
} }
boolean zeroGuests(DiscoParty party) { boolean clearGuests(DiscoParty party) {
party.getGuestNumbers().clear(); party.getGuestNumbers().clear();
return true; return true;
} }
boolean noPermsMessage(CommandSender sender, String permission) { boolean noPermsMessage(CommandSender sender, String permission) {
sender.sendMessage(ChatColor.RED + "You do not have the permission node " + ChatColor.GRAY + permission); sender.sendMessage(ChatColor.RED + "You do not have the permission node " + ChatColor.GRAY + permission);
return false; return false;
} }
} }

View File

@ -3,8 +3,8 @@ package ca.gibstick.discosheep;
import java.util.Arrays; import java.util.Arrays;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class DiscoSheepCommandExecutor implements CommandExecutor { public class DiscoSheepCommandExecutor implements CommandExecutor {
@ -153,7 +153,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
} }
if (parseNextArg(args, i, "none")) { if (parseNextArg(args, i, "none")) {
return parent.zeroGuests(mainParty); return parent.clearGuests(mainParty);
} }
String[] guests = getNextArgs(args, i + 1); String[] guests = getNextArgs(args, i + 1);

View File

@ -1,17 +0,0 @@
package ca.gibstick.discosheep;
import org.bukkit.scheduler.BukkitRunnable;
public class DiscoUpdater extends BukkitRunnable {
private DiscoParty parent;
public DiscoUpdater(DiscoParty parent) {
this.parent = parent;
}
@Override
public void run() {
parent.update();
}
}

View File

@ -1,39 +1,35 @@
/* /*
* BaaBaaBlockSheep have you any wool? * BaaBaaBlockSheep have you any wool?
* Nope, event got cancelled. * Nope, event got cancelled.
* Also listens to other events, not just sheep events * Also listens to other events, not just sheep events
*/ */
package ca.gibstick.discosheep; package ca.gibstick.discosheep;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
/** public class GlobalEvents implements Listener {
*
* @author Mauve DiscoSheep parent;
*/
public class GlobalEvents implements Listener { public GlobalEvents(DiscoSheep parent) {
this.parent = parent;
DiscoSheep parent; }
public GlobalEvents(DiscoSheep parent) { @EventHandler (priority = EventPriority.MONITOR)
this.parent = parent; public void onPlayerQuitEvent(PlayerQuitEvent e) {
} String name = e.getPlayer().getName();
parent.stopParty(name);
@EventHandler (priority = EventPriority.MONITOR) // stop party on player quit or else it will CONTINUE FOR ETERNITY
public void onPlayerQuitEvent(PlayerQuitEvent e) { }
String name = e.getPlayer().getName();
parent.stopParty(name); @EventHandler (priority = EventPriority.MONITOR)
// stop party on player quit or else it will CONTINUE FOR ETERNITY public void onPlayerJoinEvent(PlayerJoinEvent e) {
} Player player = e.getPlayer();
parent.partyOnJoin(player);
@EventHandler (priority = EventPriority.MONITOR) }
public void onPlayerJoinEvent(PlayerJoinEvent e) { }
Player player = e.getPlayer();
parent.partyOnJoin(player);
}
}