Skip to content

Commit

Permalink
add support for WorldGuard regions
Browse files Browse the repository at this point in the history
  • Loading branch information
WegFetZ committed Dec 18, 2014
1 parent 0facbeb commit 40f24d1
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ public Area(short id, String owner, SCLocation c1, SCLocation c2, int fadeout) {
setCorners(c1, c2);
this.fadeout = fadeout;
}

@Override
public boolean equals(Station station) {
return this.id == station.getId() && this.type == station.getType();
}
@Override
public int hashCode() {
return (int) id/12+type;
}


@Override
public byte getType() {
Expand Down Expand Up @@ -121,6 +113,8 @@ public void setEditableByOthers(boolean editableByOthers) {
public void setName(String name) {}
@Override
public SCLocation getLocation() { return null; }
@Override
public List<SCLocation2D> getPoints() { return null; }

/* we need to set default values for new variables, which aren't defined in the serialized object */
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
Expand Down
12 changes: 2 additions & 10 deletions SoundCenterLib/src/com/soundcenter/soundcenter/lib/data/Box.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ public Box(short id, String owner, SCLocation location, int range) {
this.range = range;
}


@Override
public boolean equals(Station station) {
return this.id == station.getId() && this.type == station.getType();
}
@Override
public int hashCode() {
return (int) id/12+type;
}

@Override
public byte getType() {
return type;
Expand Down Expand Up @@ -117,6 +107,8 @@ public void setName(String name) {}
public SCLocation getMax() { return null; }
@Override
public SCLocation getMin() { return null; }
@Override
public List<SCLocation2D> getPoints() { return null; }


/* we need to set default values for new variables, which aren't defined in the serialized object */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ public class GlobalConstants {
public static final byte TYPE_BIOME = 2;
public static final byte TYPE_WORLD = 3;
public static final byte TYPE_GLOBAL = 4;
public static final byte TYPE_WGREGION = 5;

public static final byte TYPE_VOICE = 5;
public static final byte TYPE_VOICE = 6;

/* MISC */
public static List<String> supportedExtensions = Arrays.asList("mp3", "midi", "mid");
public static final String[] permissions = {"sc.init", "sc.upload.mp3", "sc.upload.midi",
"sc.set.area", "sc.set.box", "sc.set.biome", "sc.set.world", "sc.set.overlap",
"sc.set.area", "sc.set.box", "sc.set.biome", "sc.set.world", "sc.set.wgregion", "sc.set.wgregion.nomember", "sc.set.overlap",
"sc.play.global", "sc.speak", "sc.speak.global",
"sc.others.use.songs", "sc.others.edit", "sc.others.delete",
"sc.nolimits" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ public Region(short id, String owner, String name, byte type) {
this.name = name;
this.type = type;
}

@Override
public boolean equals(Station station) {
return this.id == station.getId() && this.type == station.getType();
}
@Override
public int hashCode() {
return (int) id/12+type;
}

@Override
public byte getType() {
Expand Down Expand Up @@ -113,6 +104,8 @@ public void setEditableByOthers(boolean editableByOthers) {
@Override
public SCLocation getMin() { return null; }
@Override
public List<SCLocation2D> getPoints() { return null; }
@Override
public SCLocation getLocation() { return null; }
@Override
public String getWorld() { return null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import java.util.List;

public interface Station {

public boolean equals(Station station);
public int hashCode();

public byte getType();

Expand All @@ -22,6 +19,8 @@ public interface Station {

public SCLocation getMin();

public List<SCLocation2D> getPoints();

public SCLocation getLocation();

public String getWorld();
Expand Down
129 changes: 129 additions & 0 deletions SoundCenterLib/src/com/soundcenter/soundcenter/lib/data/WGRegion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package com.soundcenter.soundcenter.lib.data;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class WGRegion implements Station, Serializable {

private static final long serialVersionUID = 4655360206783598943L;

private byte type = GlobalConstants.TYPE_WGREGION;
private short id = 0;
private SCLocation min = null;
private SCLocation max = null;
private List<SCLocation2D> points;
private String name = null;
private String owner = null;
private byte priority = 1;
private byte maxVolume = 100;
private boolean editableByOthers = false;
private int fadeout = 0;
private boolean radio = false;
private String radioUrl = "";
private ConcurrentHashMap<String, Song> songs = new ConcurrentHashMap<String, Song>();


public WGRegion(short id, String owner, String name, SCLocation min, SCLocation max, List<SCLocation2D> points) {
this.id = id;
this.owner = owner;
this.name = name;
this.min = min;
this.max = max;
this.points = points;
}

@Override
public byte getType() {
return type;
}

@Override
public short getId() { return id; }
@Override
public void setId(short id) { this.id = id; }

@Override
public SCLocation getMin() { return min; }
public void setMin(SCLocation min) { this.min = min; }

@Override
public SCLocation getMax() { return max; }
public void setMax(SCLocation max) { this.max = max; }

public List<SCLocation2D> getPoints() { return points; }
public void setPoints(List<SCLocation2D> points) { this.points = points; }

@Override
public String getWorld() { return max.getWorld(); }

public String getOwner() { return owner;}
@Override
public void setOwner(String owner) { this.owner = owner; }

@Override
public String getName() { return name; }
@Override
public void setName(String name) { this.name = name; }

@Override
public byte getPriority() { return priority; }
@Override
public void setPriority(byte priority) { this.priority = priority; }

@Override
public byte getMaxVolume() { return maxVolume; }
@Override
public void setMaxVolume(byte maxVolume) { this.maxVolume = maxVolume; }

@Override
public boolean isEditableByOthers() { return editableByOthers; }
@Override
public void setEditableByOthers(boolean editableByOthers) {
this.editableByOthers = editableByOthers;
}

@Override
public int getRange() { return fadeout; }
@Override
public void setRange(int fadeout) { this.fadeout = fadeout; }

@Override
public boolean isRadio() { return radio; }
@Override
public void setRadio(boolean value) { this.radio = value; }

@Override
public String getRadioURL() { return radioUrl; }
@Override
public void setRadioURL(String url) { this.radioUrl = url; }

@Override
public void addSong(Song song) { songs.put(song.getPath(), song); }
@Override
public void removeSong(String path) { songs.remove(path); }
@Override
public void removeSong(Song song) { songs.remove(song.getPath()); }
@Override
public void removeAllSongs() { songs.clear(); }
@Override
public List<Song> getSongs() { return new ArrayList<Song>(songs.values()); }



/* not needed for wgregions */
@Override
public SCLocation getLocation() { return null; }


/* we need to set default values for new variables, which aren't defined in the serialized object */
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
ois.defaultReadObject();
if (maxVolume == 0) {
maxVolume = 100;
}
}
}

0 comments on commit 40f24d1

Please sign in to comment.