Separated out instance from static properties in DiscoParty class.

This commit is contained in:
RangerMauve 2013-11-09 14:16:36 -05:00
parent b1fc524725
commit ca8d41a7ae

View File

@ -22,11 +22,8 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class DiscoParty { public class DiscoParty {
private DiscoSheep parent; // Static properties
private Player player;
private ArrayList<Sheep> sheepList = new ArrayList<Sheep>();
private ArrayList<Entity> guestList = new ArrayList<Entity>();
static int defaultDuration = 300; // ticks for entire party static int defaultDuration = 300; // ticks for entire party
static int defaultPeriod = 10; // ticks per state change static int defaultPeriod = 10; // ticks per state change
static int defaultRadius = 5; static int defaultRadius = 5;
@ -37,15 +34,8 @@ public class DiscoParty {
static int maxRadius = 100; static int maxRadius = 100;
static int minPeriod = 5; // 0.25 seconds static int minPeriod = 5; // 0.25 seconds
static int maxPeriod = 40; // 2.0 seconds static int maxPeriod = 40; // 2.0 seconds
private HashMap<String, Integer> guestNumbers = new HashMap<String, Integer>();
private static HashMap<String, Integer> defaultGuestNumbers = new HashMap<String, Integer>(); private static HashMap<String, Integer> defaultGuestNumbers = new HashMap<String, Integer>();
private static HashMap<String, Integer> maxGuestNumbers = new HashMap<String, Integer>(); private static HashMap<String, Integer> maxGuestNumbers = new HashMap<String, Integer>();
private boolean doFireworks = false;
private boolean doJump = true;
private boolean doLightning = false;
private int duration, period, radius, sheep;
private int state = 0; // basically our own tick system
private DiscoUpdater updater;
private static final DyeColor[] discoColours = { private static final DyeColor[] discoColours = {
DyeColor.RED, DyeColor.RED,
DyeColor.ORANGE, DyeColor.ORANGE,
@ -69,8 +59,21 @@ public class DiscoParty {
1.667f, 1.667f,
2.0f 2.0f
}; };
private Random r=new Random();
// Instance properties
private Random r = new Random();
private PartyEvents partyEvents; private PartyEvents partyEvents;
private DiscoSheep parent;
private Player player;
private ArrayList<Sheep> sheepList = new ArrayList<Sheep>();
private ArrayList<Entity> guestList = new ArrayList<Entity>();
private HashMap<String, Integer> guestNumbers = new HashMap<String, Integer>();
private boolean doFireworks = false;
private boolean doJump = true;
private boolean doLightning = false;
private int duration, period, radius, sheep;
private int state = 0; // basically our own tick system
private DiscoUpdater updater;
public DiscoParty(DiscoSheep parent, Player player) { public DiscoParty(DiscoSheep parent, Player player) {
this(parent); this(parent);
@ -188,7 +191,7 @@ public class DiscoParty {
this.doFireworks = doFireworks; this.doFireworks = doFireworks;
return this; return this;
} }
public DiscoParty setDoLightning(boolean doLightning) { public DiscoParty setDoLightning(boolean doLightning) {
this.doLightning = doLightning; this.doLightning = doLightning;
return this; return this;
@ -391,7 +394,7 @@ public class DiscoParty {
private float getPentatonicNote() { private float getPentatonicNote() {
return DiscoParty.pentatonicNotes[r.nextInt(pentatonicNotes.length)]; return DiscoParty.pentatonicNotes[r.nextInt(pentatonicNotes.length)];
} }
void playSounds() { void playSounds() {
player.playSound(player.getLocation(), Sound.NOTE_BASS_DRUM, 0.75f, 1.0f); player.playSound(player.getLocation(), Sound.NOTE_BASS_DRUM, 0.75f, 1.0f);
if (this.state % 2 == 0) { if (this.state % 2 == 0) {