Replaced spaces with tabs
This commit is contained in:
parent
67e54157bc
commit
eef287f526
@ -47,13 +47,13 @@ public class Blox {
|
|||||||
return new Location(this.world, (double)this.x + x, (double)this.y + y, (double)this.z + z, rotX, rotY);
|
return new Location(this.world, (double)this.x + x, (double)this.y + y, (double)this.z + z, rotX, rotY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Blox modRelative(int right, int depth, int distance, int modX, int modY, int modZ) {
|
public Blox modRelative(int right, int depth, int distance, int modX, int modY, int modZ) {
|
||||||
return makeRelative(-right * modX + distance * modZ, -depth * modY, -right * modZ + -distance * modX);
|
return makeRelative(-right * modX + distance * modZ, -depth * modY, -right * modZ + -distance * modX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location modRelativeLoc(double right, double depth, double distance, float rotX, float rotY, int modX, int modY, int modZ) {
|
public Location modRelativeLoc(double right, double depth, double distance, float rotX, float rotY, int modX, int modY, int modZ) {
|
||||||
return makeRelativeLoc(0.5 + -right * modX + distance * modZ, depth, 0.5 + -right * modZ + -distance * modX, rotX, 0);
|
return makeRelativeLoc(0.5 + -right * modX + distance * modZ, depth, 0.5 + -right * modZ + -distance * modX, rotX, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(int type) {
|
public void setType(int type) {
|
||||||
world.getBlockAt(x, y, z).setTypeId(type);
|
world.getBlockAt(x, y, z).setTypeId(type);
|
||||||
|
@ -19,387 +19,387 @@ import org.bukkit.block.Block;
|
|||||||
* @author Dinnerbone
|
* @author Dinnerbone
|
||||||
*/
|
*/
|
||||||
public class Gate {
|
public class Gate {
|
||||||
public static final int ANYTHING = -1;
|
public static final int ANYTHING = -1;
|
||||||
public static final int ENTRANCE = -2;
|
public static final int ENTRANCE = -2;
|
||||||
public static final int CONTROL = -3;
|
public static final int CONTROL = -3;
|
||||||
public static final int EXIT = -4;
|
public static final int EXIT = -4;
|
||||||
private static HashMap<String, Gate> gates = new HashMap<String, Gate>();
|
private static HashMap<String, Gate> gates = new HashMap<String, Gate>();
|
||||||
private static HashMap<Integer, ArrayList<Gate>> controlBlocks = new HashMap<Integer, ArrayList<Gate>>();
|
private static HashMap<Integer, ArrayList<Gate>> controlBlocks = new HashMap<Integer, ArrayList<Gate>>();
|
||||||
|
|
||||||
private String filename;
|
private String filename;
|
||||||
private Integer[][] layout;
|
private Integer[][] layout;
|
||||||
private HashMap<Character, Integer> types;
|
private HashMap<Character, Integer> types;
|
||||||
private RelativeBlockVector[] entrances = new RelativeBlockVector[0];
|
private RelativeBlockVector[] entrances = new RelativeBlockVector[0];
|
||||||
private RelativeBlockVector[] border = new RelativeBlockVector[0];
|
private RelativeBlockVector[] border = new RelativeBlockVector[0];
|
||||||
private RelativeBlockVector[] controls = new RelativeBlockVector[0];
|
private RelativeBlockVector[] controls = new RelativeBlockVector[0];
|
||||||
private RelativeBlockVector exitBlock = null;
|
private RelativeBlockVector exitBlock = null;
|
||||||
private HashMap<RelativeBlockVector, Integer> exits = new HashMap<RelativeBlockVector, Integer>();
|
private HashMap<RelativeBlockVector, Integer> exits = new HashMap<RelativeBlockVector, Integer>();
|
||||||
private int portalBlockOpen = Material.PORTAL.getId();
|
private int portalBlockOpen = Material.PORTAL.getId();
|
||||||
private int portalBlockClosed = Material.AIR.getId();
|
private int portalBlockClosed = Material.AIR.getId();
|
||||||
|
|
||||||
private Gate(String filename, Integer[][] layout, HashMap<Character, Integer> types) {
|
private Gate(String filename, Integer[][] layout, HashMap<Character, Integer> types) {
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
this.types = types;
|
this.types = types;
|
||||||
|
|
||||||
populateCoordinates();
|
populateCoordinates();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateCoordinates() {
|
private void populateCoordinates() {
|
||||||
ArrayList<RelativeBlockVector> entranceList = new ArrayList<RelativeBlockVector>();
|
ArrayList<RelativeBlockVector> entranceList = new ArrayList<RelativeBlockVector>();
|
||||||
ArrayList<RelativeBlockVector> borderList = new ArrayList<RelativeBlockVector>();
|
ArrayList<RelativeBlockVector> borderList = new ArrayList<RelativeBlockVector>();
|
||||||
ArrayList<RelativeBlockVector> controlList = new ArrayList<RelativeBlockVector>();
|
ArrayList<RelativeBlockVector> controlList = new ArrayList<RelativeBlockVector>();
|
||||||
RelativeBlockVector[] relativeExits = new RelativeBlockVector[layout[0].length];
|
RelativeBlockVector[] relativeExits = new RelativeBlockVector[layout[0].length];
|
||||||
int[] exitDepths = new int[layout[0].length];
|
int[] exitDepths = new int[layout[0].length];
|
||||||
//int bottom = 0;
|
//int bottom = 0;
|
||||||
RelativeBlockVector lastExit = null;
|
RelativeBlockVector lastExit = null;
|
||||||
|
|
||||||
for (int y = 0; y < layout.length; y++) {
|
for (int y = 0; y < layout.length; y++) {
|
||||||
for (int x = 0; x < layout[y].length; x++) {
|
for (int x = 0; x < layout[y].length; x++) {
|
||||||
Integer id = layout[y][x];
|
Integer id = layout[y][x];
|
||||||
|
|
||||||
if (id == ENTRANCE || id == EXIT) {
|
if (id == ENTRANCE || id == EXIT) {
|
||||||
entranceList.add(new RelativeBlockVector(x, y, 0));
|
entranceList.add(new RelativeBlockVector(x, y, 0));
|
||||||
exitDepths[x] = y;
|
exitDepths[x] = y;
|
||||||
if (id == EXIT)
|
if (id == EXIT)
|
||||||
this.exitBlock = new RelativeBlockVector(x, y, 0);
|
this.exitBlock = new RelativeBlockVector(x, y, 0);
|
||||||
//bottom = y;
|
//bottom = y;
|
||||||
} else if (id == CONTROL) {
|
} else if (id == CONTROL) {
|
||||||
controlList.add(new RelativeBlockVector(x, y, 0));
|
controlList.add(new RelativeBlockVector(x, y, 0));
|
||||||
} else if (id != ANYTHING) {
|
} else if (id != ANYTHING) {
|
||||||
borderList.add(new RelativeBlockVector(x, y, 0));
|
borderList.add(new RelativeBlockVector(x, y, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = 0; x < exitDepths.length; x++) {
|
for (int x = 0; x < exitDepths.length; x++) {
|
||||||
relativeExits[x] = new RelativeBlockVector(x, exitDepths[x], 0);
|
relativeExits[x] = new RelativeBlockVector(x, exitDepths[x], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = relativeExits.length - 1; x >= 0; x--) {
|
for (int x = relativeExits.length - 1; x >= 0; x--) {
|
||||||
if (relativeExits[x] != null) {
|
if (relativeExits[x] != null) {
|
||||||
lastExit = relativeExits[x];
|
lastExit = relativeExits[x];
|
||||||
} else {
|
} else {
|
||||||
relativeExits[x] = lastExit;
|
relativeExits[x] = lastExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exitDepths[x] > 0) this.exits.put(relativeExits[x], x);
|
if (exitDepths[x] > 0) this.exits.put(relativeExits[x], x);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entrances = entranceList.toArray(this.entrances);
|
this.entrances = entranceList.toArray(this.entrances);
|
||||||
this.border = borderList.toArray(this.border);
|
this.border = borderList.toArray(this.border);
|
||||||
this.controls = controlList.toArray(this.controls);
|
this.controls = controlList.toArray(this.controls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(String gateFolder) {
|
public void save(String gateFolder) {
|
||||||
HashMap<Integer, Character> reverse = new HashMap<Integer, Character>();
|
HashMap<Integer, Character> reverse = new HashMap<Integer, Character>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BufferedWriter bw = new BufferedWriter(new FileWriter(gateFolder + filename));
|
BufferedWriter bw = new BufferedWriter(new FileWriter(gateFolder + filename));
|
||||||
|
|
||||||
writeConfig(bw, "portal-open", portalBlockOpen);
|
writeConfig(bw, "portal-open", portalBlockOpen);
|
||||||
writeConfig(bw, "portal-closed", portalBlockClosed);
|
writeConfig(bw, "portal-closed", portalBlockClosed);
|
||||||
|
|
||||||
for (Character type : types.keySet()) {
|
for (Character type : types.keySet()) {
|
||||||
Integer value = types.get(type);
|
Integer value = types.get(type);
|
||||||
|
|
||||||
if (!type.equals('-')) {
|
if (!type.equals('-')) {
|
||||||
reverse.put(value, type);
|
reverse.put(value, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bw.append(type);
|
bw.append(type);
|
||||||
bw.append('=');
|
bw.append('=');
|
||||||
bw.append(value.toString());
|
bw.append(value.toString());
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
|
|
||||||
for (int y = 0; y < layout.length; y++) {
|
for (int y = 0; y < layout.length; y++) {
|
||||||
for (int x = 0; x < layout[y].length; x++) {
|
for (int x = 0; x < layout[y].length; x++) {
|
||||||
Integer id = layout[y][x];
|
Integer id = layout[y][x];
|
||||||
Character symbol;
|
Character symbol;
|
||||||
|
|
||||||
if (id == ENTRANCE) {
|
if (id == ENTRANCE) {
|
||||||
symbol = '.';
|
symbol = '.';
|
||||||
} else if (id == ANYTHING) {
|
} else if (id == ANYTHING) {
|
||||||
symbol = ' ';
|
symbol = ' ';
|
||||||
} else if (id == CONTROL) {
|
} else if (id == CONTROL) {
|
||||||
symbol = '-';
|
symbol = '-';
|
||||||
} else if (id == EXIT) {
|
} else if (id == EXIT) {
|
||||||
symbol = '*';
|
symbol = '*';
|
||||||
} else if (reverse.containsKey(id)) {
|
} else if (reverse.containsKey(id)) {
|
||||||
symbol = reverse.get(id);
|
symbol = reverse.get(id);
|
||||||
} else {
|
} else {
|
||||||
symbol = '?';
|
symbol = '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
bw.append(symbol);
|
bw.append(symbol);
|
||||||
}
|
}
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Stargate.log.log(Level.SEVERE, "Could not load Gate " + filename + " - " + ex.getMessage());
|
Stargate.log.log(Level.SEVERE, "Could not load Gate " + filename + " - " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeConfig(BufferedWriter bw, String key, int value) throws IOException {
|
private void writeConfig(BufferedWriter bw, String key, int value) throws IOException {
|
||||||
bw.append(String.format("%s=%d", key, value));
|
bw.append(String.format("%s=%d", key, value));
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer[][] getLayout() {
|
public Integer[][] getLayout() {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelativeBlockVector[] getEntrances() {
|
public RelativeBlockVector[] getEntrances() {
|
||||||
return entrances;
|
return entrances;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelativeBlockVector[] getBorder() {
|
public RelativeBlockVector[] getBorder() {
|
||||||
return border;
|
return border;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelativeBlockVector[] getControls() {
|
public RelativeBlockVector[] getControls() {
|
||||||
return controls;
|
return controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<RelativeBlockVector, Integer> getExits() {
|
public HashMap<RelativeBlockVector, Integer> getExits() {
|
||||||
return exits;
|
return exits;
|
||||||
}
|
}
|
||||||
public RelativeBlockVector getExit() {
|
public RelativeBlockVector getExit() {
|
||||||
return exitBlock;
|
return exitBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getControlBlock() {
|
public int getControlBlock() {
|
||||||
return types.get('-');
|
return types.get('-');
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFilename() {
|
public String getFilename() {
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPortalBlockOpen() {
|
public int getPortalBlockOpen() {
|
||||||
return portalBlockOpen;
|
return portalBlockOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPortalBlockClosed() {
|
public int getPortalBlockClosed() {
|
||||||
return portalBlockClosed;
|
return portalBlockClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(Block topleft, int modX, int modZ) {
|
public boolean matches(Block topleft, int modX, int modZ) {
|
||||||
return matches(new Blox(topleft), modX, modZ);
|
return matches(new Blox(topleft), modX, modZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(Blox topleft, int modX, int modZ) {
|
public boolean matches(Blox topleft, int modX, int modZ) {
|
||||||
for (int y = 0; y < layout.length; y++) {
|
for (int y = 0; y < layout.length; y++) {
|
||||||
for (int x = 0; x < layout[y].length; x++) {
|
for (int x = 0; x < layout[y].length; x++) {
|
||||||
int id = layout[y][x];
|
int id = layout[y][x];
|
||||||
|
|
||||||
if (id == ENTRANCE || id == EXIT) {
|
if (id == ENTRANCE || id == EXIT) {
|
||||||
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != 0) {
|
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (id == CONTROL) {
|
} else if (id == CONTROL) {
|
||||||
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != getControlBlock()) {
|
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != getControlBlock()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (id != ANYTHING) {
|
} else if (id != ANYTHING) {
|
||||||
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != id) {
|
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerGate(Gate gate) {
|
private static void registerGate(Gate gate) {
|
||||||
gates.put(gate.getFilename(), gate);
|
gates.put(gate.getFilename(), gate);
|
||||||
|
|
||||||
int blockID = gate.getControlBlock();
|
int blockID = gate.getControlBlock();
|
||||||
|
|
||||||
if (!controlBlocks.containsKey(blockID)) {
|
if (!controlBlocks.containsKey(blockID)) {
|
||||||
controlBlocks.put(blockID, new ArrayList<Gate>());
|
controlBlocks.put(blockID, new ArrayList<Gate>());
|
||||||
}
|
}
|
||||||
|
|
||||||
controlBlocks.get(blockID).add(gate);
|
controlBlocks.get(blockID).add(gate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Gate loadGate(File file) {
|
private static Gate loadGate(File file) {
|
||||||
Scanner scanner = null;
|
Scanner scanner = null;
|
||||||
boolean designing = false;
|
boolean designing = false;
|
||||||
ArrayList<ArrayList<Integer>> design = new ArrayList<ArrayList<Integer>>();
|
ArrayList<ArrayList<Integer>> design = new ArrayList<ArrayList<Integer>>();
|
||||||
HashMap<Character, Integer> types = new HashMap<Character, Integer>();
|
HashMap<Character, Integer> types = new HashMap<Character, Integer>();
|
||||||
HashMap<String, String> config = new HashMap<String, String>();
|
HashMap<String, String> config = new HashMap<String, String>();
|
||||||
int cols = 0;
|
int cols = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
scanner = new Scanner(file);
|
scanner = new Scanner(file);
|
||||||
|
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
String line = scanner.nextLine();
|
String line = scanner.nextLine();
|
||||||
|
|
||||||
if (designing) {
|
if (designing) {
|
||||||
ArrayList<Integer> row = new ArrayList<Integer>();
|
ArrayList<Integer> row = new ArrayList<Integer>();
|
||||||
|
|
||||||
if (line.length() > cols) {
|
if (line.length() > cols) {
|
||||||
cols = line.length();
|
cols = line.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Character symbol : line.toCharArray()) {
|
for (Character symbol : line.toCharArray()) {
|
||||||
Integer id = ANYTHING;
|
Integer id = ANYTHING;
|
||||||
|
|
||||||
if (symbol.equals('.')) {
|
if (symbol.equals('.')) {
|
||||||
id = ENTRANCE;
|
id = ENTRANCE;
|
||||||
} else if (symbol.equals('*')) {
|
} else if (symbol.equals('*')) {
|
||||||
id = EXIT;
|
id = EXIT;
|
||||||
} else if (symbol.equals(' ')) {
|
} else if (symbol.equals(' ')) {
|
||||||
id = ANYTHING;
|
id = ANYTHING;
|
||||||
} else if (symbol.equals('-')) {
|
} else if (symbol.equals('-')) {
|
||||||
id = CONTROL;
|
id = CONTROL;
|
||||||
} else if ((symbol.equals('?')) || (!types.containsKey(symbol))) {
|
} else if ((symbol.equals('?')) || (!types.containsKey(symbol))) {
|
||||||
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Unknown symbol '" + symbol + "' in diagram");
|
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Unknown symbol '" + symbol + "' in diagram");
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
id = types.get(symbol);
|
id = types.get(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
row.add(id);
|
row.add(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
design.add(row);
|
design.add(row);
|
||||||
} else {
|
} else {
|
||||||
if ((line.isEmpty()) || (!line.contains("="))) {
|
if ((line.isEmpty()) || (!line.contains("="))) {
|
||||||
designing = true;
|
designing = true;
|
||||||
} else {
|
} else {
|
||||||
String[] split = line.split("=");
|
String[] split = line.split("=");
|
||||||
String key = split[0].trim();
|
String key = split[0].trim();
|
||||||
String value = split[1].trim();
|
String value = split[1].trim();
|
||||||
|
|
||||||
if (key.length() == 1) {
|
if (key.length() == 1) {
|
||||||
Character symbol = key.charAt(0);
|
Character symbol = key.charAt(0);
|
||||||
Integer id = Integer.parseInt(value);
|
Integer id = Integer.parseInt(value);
|
||||||
|
|
||||||
types.put(symbol, id);
|
types.put(symbol, id);
|
||||||
} else {
|
} else {
|
||||||
config.put(key, value);
|
config.put(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Invalid block ID given");
|
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Invalid block ID given");
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
if (scanner != null) scanner.close();
|
if (scanner != null) scanner.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer[][] layout = new Integer[design.size()][cols];
|
Integer[][] layout = new Integer[design.size()][cols];
|
||||||
|
|
||||||
for (int y = 0; y < design.size(); y++) {
|
for (int y = 0; y < design.size(); y++) {
|
||||||
ArrayList<Integer> row = design.get(y);
|
ArrayList<Integer> row = design.get(y);
|
||||||
Integer[] result = new Integer[cols];
|
Integer[] result = new Integer[cols];
|
||||||
|
|
||||||
for (int x = 0; x < cols; x++) {
|
for (int x = 0; x < cols; x++) {
|
||||||
if (x < row.size()) {
|
if (x < row.size()) {
|
||||||
result[x] = row.get(x);
|
result[x] = row.get(x);
|
||||||
} else {
|
} else {
|
||||||
result[x] = ANYTHING;
|
result[x] = ANYTHING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layout[y] = result;
|
layout[y] = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gate gate = new Gate(file.getName(), layout, types);
|
Gate gate = new Gate(file.getName(), layout, types);
|
||||||
|
|
||||||
gate.portalBlockOpen = readConfig(config, gate, file, "portal-open", gate.portalBlockOpen);
|
gate.portalBlockOpen = readConfig(config, gate, file, "portal-open", gate.portalBlockOpen);
|
||||||
gate.portalBlockClosed = readConfig(config, gate, file, "portal-closed", gate.portalBlockClosed);
|
gate.portalBlockClosed = readConfig(config, gate, file, "portal-closed", gate.portalBlockClosed);
|
||||||
|
|
||||||
if (gate.getControls().length != 2) {
|
if (gate.getControls().length != 2) {
|
||||||
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points.");
|
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points.");
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
gate.save(file.getParent() + "/"); // Updates format for version changes
|
gate.save(file.getParent() + "/"); // Updates format for version changes
|
||||||
return gate;
|
return gate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int readConfig(HashMap<String, String> config, Gate gate, File file, String key, int def) {
|
private static int readConfig(HashMap<String, String> config, Gate gate, File file, String key, int def) {
|
||||||
if (config.containsKey(key)) {
|
if (config.containsKey(key)) {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(config.get(key));
|
return Integer.parseInt(config.get(key));
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
Stargate.log.log(Level.WARNING, String.format("%s reading %s: %s is not numeric", ex.getClass().getName(), file, key));
|
Stargate.log.log(Level.WARNING, String.format("%s reading %s: %s is not numeric", ex.getClass().getName(), file, key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadGates(String gateFolder) {
|
public static void loadGates(String gateFolder) {
|
||||||
File dir = new File(gateFolder);
|
File dir = new File(gateFolder);
|
||||||
File[] files;
|
File[] files;
|
||||||
|
|
||||||
if (dir.exists()) {
|
if (dir.exists()) {
|
||||||
files = dir.listFiles(new StargateFilenameFilter());
|
files = dir.listFiles(new StargateFilenameFilter());
|
||||||
} else {
|
} else {
|
||||||
files = new File[0];
|
files = new File[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (files.length == 0) {
|
if (files.length == 0) {
|
||||||
dir.mkdir();
|
dir.mkdir();
|
||||||
populateDefaults(gateFolder);
|
populateDefaults(gateFolder);
|
||||||
} else {
|
} else {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
Gate gate = loadGate(file);
|
Gate gate = loadGate(file);
|
||||||
if (gate != null) registerGate(gate);
|
if (gate != null) registerGate(gate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void populateDefaults(String gateFolder) {
|
public static void populateDefaults(String gateFolder) {
|
||||||
int Obsidian = Material.OBSIDIAN.getId();
|
int Obsidian = Material.OBSIDIAN.getId();
|
||||||
Integer[][] layout = new Integer[][] {
|
Integer[][] layout = new Integer[][] {
|
||||||
{ANYTHING, Obsidian,Obsidian, ANYTHING},
|
{ANYTHING, Obsidian,Obsidian, ANYTHING},
|
||||||
{Obsidian, ENTRANCE, ENTRANCE, Obsidian},
|
{Obsidian, ENTRANCE, ENTRANCE, Obsidian},
|
||||||
{CONTROL, ENTRANCE, ENTRANCE, CONTROL},
|
{CONTROL, ENTRANCE, ENTRANCE, CONTROL},
|
||||||
{Obsidian, EXIT, ENTRANCE, Obsidian},
|
{Obsidian, EXIT, ENTRANCE, Obsidian},
|
||||||
{ANYTHING, Obsidian, Obsidian, ANYTHING},
|
{ANYTHING, Obsidian, Obsidian, ANYTHING},
|
||||||
};
|
};
|
||||||
HashMap<Character, Integer> types = new HashMap<Character, Integer>();
|
HashMap<Character, Integer> types = new HashMap<Character, Integer>();
|
||||||
types.put('X', Obsidian);
|
types.put('X', Obsidian);
|
||||||
types.put('-', Obsidian);
|
types.put('-', Obsidian);
|
||||||
|
|
||||||
Gate gate = new Gate("nethergate.gate", layout, types);
|
Gate gate = new Gate("nethergate.gate", layout, types);
|
||||||
gate.save(gateFolder);
|
gate.save(gateFolder);
|
||||||
registerGate(gate);
|
registerGate(gate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Gate[] getGatesByControlBlock(Block block) {
|
public static Gate[] getGatesByControlBlock(Block block) {
|
||||||
return getGatesByControlBlock(block.getTypeId());
|
return getGatesByControlBlock(block.getTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Gate[] getGatesByControlBlock(int type) {
|
public static Gate[] getGatesByControlBlock(int type) {
|
||||||
Gate[] result = new Gate[0];
|
Gate[] result = new Gate[0];
|
||||||
ArrayList<Gate> lookup = controlBlocks.get(type);
|
ArrayList<Gate> lookup = controlBlocks.get(type);
|
||||||
|
|
||||||
if (lookup != null) result = lookup.toArray(result);
|
if (lookup != null) result = lookup.toArray(result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Gate getGateByName(String name) {
|
public static Gate getGateByName(String name) {
|
||||||
return gates.get(name);
|
return gates.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class StargateFilenameFilter implements FilenameFilter {
|
static class StargateFilenameFilter implements FilenameFilter {
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
return name.endsWith(".gate");
|
return name.endsWith(".gate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -6,25 +6,25 @@ package net.TheDgtl.Stargate;
|
|||||||
* @author Dinnerbone
|
* @author Dinnerbone
|
||||||
*/
|
*/
|
||||||
public class RelativeBlockVector {
|
public class RelativeBlockVector {
|
||||||
private int right = 0;
|
private int right = 0;
|
||||||
private int depth = 0;
|
private int depth = 0;
|
||||||
private int distance = 0;
|
private int distance = 0;
|
||||||
|
|
||||||
public RelativeBlockVector(int right, int depth, int distance) {
|
public RelativeBlockVector(int right, int depth, int distance) {
|
||||||
this.right = right;
|
this.right = right;
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRight() {
|
public int getRight() {
|
||||||
return right;
|
return right;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDepth() {
|
public int getDepth() {
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDistance() {
|
public int getDistance() {
|
||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,123 +54,123 @@ public class Stargate extends JavaPlugin {
|
|||||||
// Permissions
|
// Permissions
|
||||||
private static Permissions permissions = null;
|
private static Permissions permissions = null;
|
||||||
|
|
||||||
private final bListener blockListener = new bListener();
|
private final bListener blockListener = new bListener();
|
||||||
private final pListener playerListener = new pListener();
|
private final pListener playerListener = new pListener();
|
||||||
private final vListener vehicleListener = new vListener();
|
private final vListener vehicleListener = new vListener();
|
||||||
private final wListener worldListener = new wListener();
|
private final wListener worldListener = new wListener();
|
||||||
private final eListener entityListener = new eListener();
|
private final eListener entityListener = new eListener();
|
||||||
private final sListener serverListener = new sListener();
|
private final sListener serverListener = new sListener();
|
||||||
|
|
||||||
public static Logger log;
|
|
||||||
private Configuration config;
|
|
||||||
private PluginManager pm;
|
|
||||||
|
|
||||||
private static String portalFolder;
|
|
||||||
private static String gateFolder;
|
|
||||||
private static String teleMsg = "Teleported";
|
|
||||||
private static String regMsg = "Gate Created";
|
|
||||||
private static String dmgMsg = "Gate Destroyed";
|
|
||||||
private static String denyMsg = "Access Denied";
|
|
||||||
private static String invMsg = "Invalid Destination";
|
|
||||||
private static String blockMsg = "Destination Blocked";
|
|
||||||
private static String defNetwork = "central";
|
|
||||||
private static boolean destroyExplosion = false;
|
|
||||||
private static int activeLimit = 10;
|
|
||||||
private static int openLimit = 10;
|
|
||||||
|
|
||||||
public static ConcurrentLinkedQueue<Portal> openList = new ConcurrentLinkedQueue<Portal>();
|
|
||||||
public static ConcurrentLinkedQueue<Portal> activeList = new ConcurrentLinkedQueue<Portal>();
|
|
||||||
//private HashMap<Integer, Location> vehicles = new HashMap<Integer, Location>();
|
|
||||||
|
|
||||||
public void onDisable() {
|
public static Logger log;
|
||||||
Portal.closeAllGates();
|
private Configuration config;
|
||||||
Portal.clearGates();
|
private PluginManager pm;
|
||||||
}
|
|
||||||
|
private static String portalFolder;
|
||||||
|
private static String gateFolder;
|
||||||
|
private static String teleMsg = "Teleported";
|
||||||
|
private static String regMsg = "Gate Created";
|
||||||
|
private static String dmgMsg = "Gate Destroyed";
|
||||||
|
private static String denyMsg = "Access Denied";
|
||||||
|
private static String invMsg = "Invalid Destination";
|
||||||
|
private static String blockMsg = "Destination Blocked";
|
||||||
|
private static String defNetwork = "central";
|
||||||
|
private static boolean destroyExplosion = false;
|
||||||
|
private static int activeLimit = 10;
|
||||||
|
private static int openLimit = 10;
|
||||||
|
|
||||||
|
public static ConcurrentLinkedQueue<Portal> openList = new ConcurrentLinkedQueue<Portal>();
|
||||||
|
public static ConcurrentLinkedQueue<Portal> activeList = new ConcurrentLinkedQueue<Portal>();
|
||||||
|
//private HashMap<Integer, Location> vehicles = new HashMap<Integer, Location>();
|
||||||
|
|
||||||
|
public void onDisable() {
|
||||||
|
Portal.closeAllGates();
|
||||||
|
Portal.clearGates();
|
||||||
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
PluginDescriptionFile pdfFile = this.getDescription();
|
||||||
pm = getServer().getPluginManager();
|
pm = getServer().getPluginManager();
|
||||||
config = this.getConfiguration();
|
config = this.getConfiguration();
|
||||||
log = Logger.getLogger("Minecraft");
|
log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
// Set portalFile and gateFolder to the plugin folder as defaults.
|
|
||||||
portalFolder = getDataFolder() + "/portals";
|
|
||||||
gateFolder = getDataFolder() + "/gates/";
|
|
||||||
|
|
||||||
log.info(pdfFile.getName() + " v." + pdfFile.getVersion() + " is enabled.");
|
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal, this);
|
// Set portalFile and gateFolder to the plugin folder as defaults.
|
||||||
pm.registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal, this);
|
portalFolder = getDataFolder() + "/portals";
|
||||||
|
gateFolder = getDataFolder() + "/gates/";
|
||||||
|
|
||||||
this.reloadConfig();
|
log.info(pdfFile.getName() + " v." + pdfFile.getVersion() + " is enabled.");
|
||||||
this.migrate();
|
|
||||||
this.reloadGates();
|
pm.registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal, this);
|
||||||
// Check to see if iConomy/Permissions is loaded yet.
|
|
||||||
checkiConomy();
|
this.reloadConfig();
|
||||||
checkPermissions();
|
this.migrate();
|
||||||
|
this.reloadGates();
|
||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
|
||||||
|
// Check to see if iConomy/Permissions is loaded yet.
|
||||||
pm.registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.Normal, this);
|
checkiConomy();
|
||||||
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
|
checkPermissions();
|
||||||
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
|
|
||||||
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.VEHICLE_MOVE, vehicleListener, Priority.Normal, this);
|
|
||||||
pm.registerEvent(Event.Type.SIGN_CHANGE, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.WORLD_LOADED, worldListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.VEHICLE_MOVE, vehicleListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.SIGN_CHANGE, blockListener, Priority.Normal, this);
|
||||||
// iConomy Loading
|
|
||||||
pm.registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Priority.Monitor, this);
|
pm.registerEvent(Event.Type.WORLD_LOADED, worldListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Priority.Monitor, this);
|
|
||||||
|
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
|
||||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new SGThread(), 0L, 100L);
|
|
||||||
}
|
// iConomy Loading
|
||||||
|
pm.registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Priority.Monitor, this);
|
||||||
|
pm.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Priority.Monitor, this);
|
||||||
|
|
||||||
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, new SGThread(), 0L, 100L);
|
||||||
|
}
|
||||||
|
|
||||||
public void reloadConfig() {
|
public void reloadConfig() {
|
||||||
config.load();
|
config.load();
|
||||||
portalFolder = config.getString("portal-folder", portalFolder);
|
portalFolder = config.getString("portal-folder", portalFolder);
|
||||||
gateFolder = config.getString("gate-folder", gateFolder);
|
gateFolder = config.getString("gate-folder", gateFolder);
|
||||||
teleMsg = config.getString("teleport-message", teleMsg);
|
teleMsg = config.getString("teleport-message", teleMsg);
|
||||||
regMsg = config.getString("portal-create-message", regMsg);
|
regMsg = config.getString("portal-create-message", regMsg);
|
||||||
dmgMsg = config.getString("portal-destroy-message", dmgMsg);
|
dmgMsg = config.getString("portal-destroy-message", dmgMsg);
|
||||||
denyMsg = config.getString("not-owner-message", denyMsg);
|
denyMsg = config.getString("not-owner-message", denyMsg);
|
||||||
invMsg = config.getString("not-selected-message", invMsg);
|
invMsg = config.getString("not-selected-message", invMsg);
|
||||||
blockMsg = config.getString("other-side-blocked-message", blockMsg);
|
blockMsg = config.getString("other-side-blocked-message", blockMsg);
|
||||||
defNetwork = config.getString("default-gate-network", defNetwork).trim();
|
defNetwork = config.getString("default-gate-network", defNetwork).trim();
|
||||||
destroyExplosion = config.getBoolean("destroyexplosion", destroyExplosion);
|
destroyExplosion = config.getBoolean("destroyexplosion", destroyExplosion);
|
||||||
// iConomy
|
// iConomy
|
||||||
iConomyHandler.useiConomy = config.getBoolean("useiconomy", iConomyHandler.useiConomy);
|
iConomyHandler.useiConomy = config.getBoolean("useiconomy", iConomyHandler.useiConomy);
|
||||||
iConomyHandler.createCost = config.getInt("createcost", iConomyHandler.createCost);
|
iConomyHandler.createCost = config.getInt("createcost", iConomyHandler.createCost);
|
||||||
iConomyHandler.destroyCost = config.getInt("destroycost", iConomyHandler.destroyCost);
|
iConomyHandler.destroyCost = config.getInt("destroycost", iConomyHandler.destroyCost);
|
||||||
iConomyHandler.useCost = config.getInt("usecost", iConomyHandler.useCost);
|
iConomyHandler.useCost = config.getInt("usecost", iConomyHandler.useCost);
|
||||||
iConomyHandler.inFundMsg = config.getString("not-enough-money-message", iConomyHandler.inFundMsg);
|
iConomyHandler.inFundMsg = config.getString("not-enough-money-message", iConomyHandler.inFundMsg);
|
||||||
|
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveConfig() {
|
public void saveConfig() {
|
||||||
config.setProperty("portal-folder", portalFolder);
|
config.setProperty("portal-folder", portalFolder);
|
||||||
config.setProperty("gate-folder", gateFolder);
|
config.setProperty("gate-folder", gateFolder);
|
||||||
config.setProperty("teleport-message", teleMsg);
|
config.setProperty("teleport-message", teleMsg);
|
||||||
config.setProperty("portal-create-message", regMsg);
|
config.setProperty("portal-create-message", regMsg);
|
||||||
config.setProperty("portal-destroy-message", dmgMsg);
|
config.setProperty("portal-destroy-message", dmgMsg);
|
||||||
config.setProperty("not-owner-message", denyMsg);
|
config.setProperty("not-owner-message", denyMsg);
|
||||||
config.setProperty("not-selected-message", invMsg);
|
config.setProperty("not-selected-message", invMsg);
|
||||||
config.setProperty("other-side-blocked-message", blockMsg);
|
config.setProperty("other-side-blocked-message", blockMsg);
|
||||||
config.setProperty("default-gate-network", defNetwork);
|
config.setProperty("default-gate-network", defNetwork);
|
||||||
config.setProperty("destroyexplosion", destroyExplosion);
|
config.setProperty("destroyexplosion", destroyExplosion);
|
||||||
// iConomy
|
// iConomy
|
||||||
config.setProperty("useiconomy", iConomyHandler.useiConomy);
|
config.setProperty("useiconomy", iConomyHandler.useiConomy);
|
||||||
config.setProperty("createcost", iConomyHandler.createCost);
|
config.setProperty("createcost", iConomyHandler.createCost);
|
||||||
config.setProperty("destroycost", iConomyHandler.destroyCost);
|
config.setProperty("destroycost", iConomyHandler.destroyCost);
|
||||||
config.setProperty("usecost", iConomyHandler.useCost);
|
config.setProperty("usecost", iConomyHandler.useCost);
|
||||||
config.setProperty("not-enough-money-message", iConomyHandler.inFundMsg);
|
config.setProperty("not-enough-money-message", iConomyHandler.inFundMsg);
|
||||||
|
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadGates() {
|
public void reloadGates() {
|
||||||
@ -194,87 +194,87 @@ public class Stargate extends JavaPlugin {
|
|||||||
File newFile = new File(portalFolder, getServer().getWorlds().get(0).getName() + ".db");
|
File newFile = new File(portalFolder, getServer().getWorlds().get(0).getName() + ".db");
|
||||||
if (!newFile.exists()) {
|
if (!newFile.exists()) {
|
||||||
newFile.getParentFile().mkdirs();
|
newFile.getParentFile().mkdirs();
|
||||||
// Migrate not-so-old stargate db
|
// Migrate not-so-old stargate db
|
||||||
File oldishFile = new File("plugins/Stargate/stargate.db");
|
File oldishFile = new File("plugins/Stargate/stargate.db");
|
||||||
if (oldishFile.exists()) {
|
if (oldishFile.exists()) {
|
||||||
Stargate.log.info("[Stargate] Migrating existing stargate.db");
|
Stargate.log.info("[Stargate] Migrating existing stargate.db");
|
||||||
oldishFile.renameTo(newFile);
|
oldishFile.renameTo(newFile);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Migrate old gates if applicaple
|
||||||
|
File oldDir = new File("stargates");
|
||||||
|
if (oldDir.exists()) {
|
||||||
|
File newDir = new File(gateFolder);
|
||||||
|
if (!newDir.exists()) newDir.mkdirs();
|
||||||
|
for (File file : oldDir.listFiles(new Gate.StargateFilenameFilter())) {
|
||||||
|
Stargate.log.info("[Stargate] Migrating existing gate " + file.getName());
|
||||||
|
file.renameTo(new File(gateFolder, file.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate old gates if applicaple
|
|
||||||
File oldDir = new File("stargates");
|
|
||||||
if (oldDir.exists()) {
|
|
||||||
File newDir = new File(gateFolder);
|
|
||||||
if (!newDir.exists()) newDir.mkdirs();
|
|
||||||
for (File file : oldDir.listFiles(new Gate.StargateFilenameFilter())) {
|
|
||||||
Stargate.log.info("[Stargate] Migrating existing gate " + file.getName());
|
|
||||||
file.renameTo(new File(gateFolder, file.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSaveLocation() {
|
public static String getSaveLocation() {
|
||||||
return portalFolder;
|
return portalFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDefaultNetwork() {
|
public static String getDefaultNetwork() {
|
||||||
return defNetwork;
|
return defNetwork;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onButtonPressed(Player player, Portal gate) {
|
private void onButtonPressed(Player player, Portal gate) {
|
||||||
Portal destination = gate.getDestination();
|
Portal destination = gate.getDestination();
|
||||||
|
|
||||||
if (!gate.isOpen()) {
|
if (!gate.isOpen()) {
|
||||||
if (iConomyHandler.useiConomy() && iConomyHandler.getBalance(player.getName()) < iConomyHandler.useCost) {
|
if (iConomyHandler.useiConomy() && iConomyHandler.getBalance(player.getName()) < iConomyHandler.useCost) {
|
||||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||||
} else if ((!gate.isFixed()) && gate.isActive() && (gate.getActivePlayer() != player)) {
|
} else if ((!gate.isFixed()) && gate.isActive() && (gate.getActivePlayer() != player)) {
|
||||||
gate.deactivate();
|
gate.deactivate();
|
||||||
if (!denyMsg.isEmpty()) {
|
if (!denyMsg.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
player.sendMessage(ChatColor.RED + denyMsg);
|
||||||
}
|
}
|
||||||
} else if (gate.isPrivate() && !gate.getOwner().equals(player.getName()) && !hasPerm(player, "stargate.private", player.isOp())) {
|
} else if (gate.isPrivate() && !gate.getOwner().equals(player.getName()) && !hasPerm(player, "stargate.private", player.isOp())) {
|
||||||
if (!denyMsg.isEmpty()) {
|
if (!denyMsg.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
player.sendMessage(ChatColor.RED + denyMsg);
|
||||||
}
|
}
|
||||||
} else if ((destination == null) || (destination == gate)) {
|
} else if ((destination == null) || (destination == gate)) {
|
||||||
if (!invMsg.isEmpty()) {
|
if (!invMsg.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.RED + invMsg);
|
player.sendMessage(ChatColor.RED + invMsg);
|
||||||
}
|
}
|
||||||
} else if ((destination.isOpen()) && (!destination.isAlwaysOn())) {
|
} else if ((destination.isOpen()) && (!destination.isAlwaysOn())) {
|
||||||
if (!blockMsg.isEmpty()) {
|
if (!blockMsg.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.RED + blockMsg);
|
player.sendMessage(ChatColor.RED + blockMsg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gate.open(player, false);
|
gate.open(player, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gate.close(false);
|
gate.close(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if iConomy is loaded/enabled already
|
* Check if iConomy is loaded/enabled already
|
||||||
*/
|
*/
|
||||||
private void checkiConomy() {
|
private void checkiConomy() {
|
||||||
if (!iConomyHandler.useiConomy) return;
|
if (!iConomyHandler.useiConomy) return;
|
||||||
Plugin ico = pm.getPlugin("iConomy");
|
Plugin ico = pm.getPlugin("iConomy");
|
||||||
if (ico != null && ico.isEnabled()) {
|
if (ico != null && ico.isEnabled()) {
|
||||||
iConomyHandler.iConomy = (iConomy)ico;
|
iConomyHandler.iConomy = (iConomy)ico;
|
||||||
Stargate.log.info("[Stargate] Using iConomy (v" + iConomyHandler.iConomy.getDescription().getVersion() + ")");
|
Stargate.log.info("[Stargate] Using iConomy (v" + iConomyHandler.iConomy.getDescription().getVersion() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if Permissions is loaded/enabled already
|
* Check if Permissions is loaded/enabled already
|
||||||
*/
|
*/
|
||||||
private void checkPermissions() {
|
private void checkPermissions() {
|
||||||
Plugin perm = pm.getPlugin("Permissions");
|
Plugin perm = pm.getPlugin("Permissions");
|
||||||
if (perm != null && perm.isEnabled()) {
|
if (perm != null && perm.isEnabled()) {
|
||||||
permissions = (Permissions)perm;
|
permissions = (Permissions)perm;
|
||||||
Stargate.log.info("[Stargate] Using Permissions (v" + permissions.getDescription().getVersion() + ")");
|
Stargate.log.info("[Stargate] Using Permissions (v" + permissions.getDescription().getVersion() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check whether the player has the given permissions.
|
* Check whether the player has the given permissions.
|
||||||
@ -286,308 +286,308 @@ public class Stargate extends JavaPlugin {
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class vListener extends VehicleListener {
|
|
||||||
@Override
|
|
||||||
public void onVehicleMove(VehicleMoveEvent event) {
|
|
||||||
Entity passenger = event.getVehicle().getPassenger();
|
|
||||||
Vehicle vehicle = event.getVehicle();
|
|
||||||
|
|
||||||
Portal portal = Portal.getByEntrance(event.getTo());
|
|
||||||
if (portal != null && portal.isOpen()) {
|
|
||||||
if (passenger instanceof Player) {
|
|
||||||
Player player = (Player)event.getVehicle().getPassenger();
|
|
||||||
if (!portal.isOpenFor(player)) {
|
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Portal dest = portal.getDestination();
|
|
||||||
if (dest == null) return;
|
|
||||||
dest.teleport(vehicle, portal);
|
|
||||||
|
|
||||||
if (!teleMsg.isEmpty())
|
|
||||||
player.sendMessage(ChatColor.BLUE + teleMsg);
|
|
||||||
portal.close(false);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class pListener extends PlayerListener {
|
|
||||||
@Override
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
Portal portal = Portal.getByEntrance(event.getTo());
|
|
||||||
|
|
||||||
if ((portal != null) && (portal.isOpen())) {
|
|
||||||
if (portal.isOpenFor(player)) {
|
|
||||||
Portal destination = portal.getDestination();
|
|
||||||
|
|
||||||
if (destination != null) {
|
|
||||||
if (!iConomyHandler.useiConomy() || iConomyHandler.chargePlayer(player.getName(), iConomyHandler.useCost)) {
|
|
||||||
if (iConomyHandler.useiConomy()) {
|
|
||||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.useCost));
|
|
||||||
}
|
|
||||||
if (!teleMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.BLUE + teleMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
destination.teleport(player, portal, event);
|
private class vListener extends VehicleListener {
|
||||||
} else {
|
@Override
|
||||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
public void onVehicleMove(VehicleMoveEvent event) {
|
||||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
Entity passenger = event.getVehicle().getPassenger();
|
||||||
}
|
Vehicle vehicle = event.getVehicle();
|
||||||
}
|
|
||||||
portal.close(false);
|
Portal portal = Portal.getByEntrance(event.getTo());
|
||||||
}
|
if (portal != null && portal.isOpen()) {
|
||||||
} else {
|
if (passenger instanceof Player) {
|
||||||
if (!denyMsg.isEmpty()) {
|
Player player = (Player)event.getVehicle().getPassenger();
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
if (!portal.isOpenFor(player)) {
|
||||||
}
|
player.sendMessage(ChatColor.RED + denyMsg);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
Portal dest = portal.getDestination();
|
||||||
}
|
if (dest == null) return;
|
||||||
|
dest.teleport(vehicle, portal);
|
||||||
|
|
||||||
|
if (!teleMsg.isEmpty())
|
||||||
|
player.sendMessage(ChatColor.BLUE + teleMsg);
|
||||||
|
portal.close(false);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class pListener extends PlayerListener {
|
||||||
|
@Override
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Portal portal = Portal.getByEntrance(event.getTo());
|
||||||
|
|
||||||
private class bListener extends BlockListener {
|
if ((portal != null) && (portal.isOpen())) {
|
||||||
@Override
|
if (portal.isOpenFor(player)) {
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
Portal destination = portal.getDestination();
|
||||||
// Stop player from placing a block touching a portals controls
|
|
||||||
if (event.getBlockAgainst().getType() == Material.STONE_BUTTON ||
|
|
||||||
event.getBlockAgainst().getType() == Material.WALL_SIGN) {
|
|
||||||
Portal portal = Portal.getByBlock(event.getBlockAgainst());
|
|
||||||
if (portal != null) event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSignChange(SignChangeEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
Block block = event.getBlock();
|
|
||||||
if (block.getType() != Material.WALL_SIGN) return;
|
|
||||||
|
|
||||||
// Initialize a stargate
|
|
||||||
if (hasPerm(player, "stargate.create", player.isOp()) ||
|
|
||||||
hasPerm(player, "stargate.create.personal", false)) {
|
|
||||||
if (iConomyHandler.useiConomy() && !iConomyHandler.chargePlayer(player.getName(), iConomyHandler.createCost)) {
|
|
||||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SignPost sign = new SignPost(new Blox(block));
|
|
||||||
// Set sign text so we can create a gate with it.
|
|
||||||
sign.setText(0, event.getLine(0));
|
|
||||||
sign.setText(1, event.getLine(1));
|
|
||||||
sign.setText(2, event.getLine(2));
|
|
||||||
sign.setText(3, event.getLine(3));
|
|
||||||
Portal portal = Portal.createPortal(sign, player);
|
|
||||||
if (portal == null) return;
|
|
||||||
|
|
||||||
if (iConomyHandler.useiConomy()) {
|
|
||||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.createCost));
|
|
||||||
}
|
|
||||||
if (!regMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.GREEN + regMsg);
|
|
||||||
}
|
|
||||||
log.info("[Stargate] Initialized stargate: " + portal.getName());
|
|
||||||
portal.drawSign();
|
|
||||||
// Set event text so our new sign is instantly initialized
|
|
||||||
event.setLine(0, sign.getText(0));
|
|
||||||
event.setLine(1, sign.getText(1));
|
|
||||||
event.setLine(2, sign.getText(2));
|
|
||||||
event.setLine(3, sign.getText(3));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (destination != null) {
|
||||||
public void onBlockRightClick(BlockRightClickEvent event) {
|
if (!iConomyHandler.useiConomy() || iConomyHandler.chargePlayer(player.getName(), iConomyHandler.useCost)) {
|
||||||
Player player = event.getPlayer();
|
if (iConomyHandler.useiConomy()) {
|
||||||
Block block = event.getBlock();
|
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.useCost));
|
||||||
if (block.getType() == Material.WALL_SIGN) {
|
}
|
||||||
Portal portal = Portal.getByBlock(block);
|
if (!teleMsg.isEmpty()) {
|
||||||
// Cycle through a stargates locations
|
player.sendMessage(ChatColor.BLUE + teleMsg);
|
||||||
if (portal != null) {
|
}
|
||||||
if (hasPerm(player, "stargate.use", true)) {
|
|
||||||
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
destination.teleport(player, portal, event);
|
||||||
portal.cycleDestination(player);
|
} else {
|
||||||
}
|
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
||||||
} else {
|
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||||
if (!denyMsg.isEmpty()) {
|
}
|
||||||
player.sendMessage(denyMsg);
|
}
|
||||||
}
|
portal.close(false);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
if (!denyMsg.isEmpty()) {
|
||||||
|
player.sendMessage(ChatColor.RED + denyMsg);
|
||||||
// Implement right-click to toggle a stargate, gets around spawn protection problem.
|
}
|
||||||
if ((block.getType() == Material.STONE_BUTTON)) {
|
}
|
||||||
if (hasPerm(player, "stargate.use", true)) {
|
}
|
||||||
Portal portal = Portal.getByBlock(block);
|
}
|
||||||
if (portal != null) {
|
}
|
||||||
onButtonPressed(player, portal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private class bListener extends BlockListener {
|
||||||
public void onBlockDamage(BlockDamageEvent event) {
|
@Override
|
||||||
Player player = event.getPlayer();
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
Block block = event.getBlock();
|
// Stop player from placing a block touching a portals controls
|
||||||
// Check if we're pushing a button.
|
if (event.getBlockAgainst().getType() == Material.STONE_BUTTON ||
|
||||||
if (block.getType() == Material.STONE_BUTTON && event.getDamageLevel() == BlockDamageLevel.STARTED) {
|
event.getBlockAgainst().getType() == Material.WALL_SIGN) {
|
||||||
if (hasPerm(player, "stargate.use", true)) {
|
Portal portal = Portal.getByBlock(event.getBlockAgainst());
|
||||||
Portal portal = Portal.getByBlock(block);
|
if (portal != null) event.setCancelled(true);
|
||||||
if (portal != null) {
|
}
|
||||||
onButtonPressed(player, portal);
|
}
|
||||||
}
|
|
||||||
}
|
@Override
|
||||||
}
|
public void onSignChange(SignChangeEvent event) {
|
||||||
}
|
Player player = event.getPlayer();
|
||||||
|
Block block = event.getBlock();
|
||||||
@Override
|
if (block.getType() != Material.WALL_SIGN) return;
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
|
||||||
Block block = event.getBlock();
|
// Initialize a stargate
|
||||||
Player player = event.getPlayer();
|
if (hasPerm(player, "stargate.create", player.isOp()) ||
|
||||||
if (block.getType() != Material.WALL_SIGN && block.getType() != Material.STONE_BUTTON && Gate.getGatesByControlBlock(block).length == 0) {
|
hasPerm(player, "stargate.create.personal", false)) {
|
||||||
return;
|
if (iConomyHandler.useiConomy() && !iConomyHandler.chargePlayer(player.getName(), iConomyHandler.createCost)) {
|
||||||
}
|
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
||||||
|
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SignPost sign = new SignPost(new Blox(block));
|
||||||
|
// Set sign text so we can create a gate with it.
|
||||||
|
sign.setText(0, event.getLine(0));
|
||||||
|
sign.setText(1, event.getLine(1));
|
||||||
|
sign.setText(2, event.getLine(2));
|
||||||
|
sign.setText(3, event.getLine(3));
|
||||||
|
Portal portal = Portal.createPortal(sign, player);
|
||||||
|
if (portal == null) return;
|
||||||
|
|
||||||
|
if (iConomyHandler.useiConomy()) {
|
||||||
|
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.createCost));
|
||||||
|
}
|
||||||
|
if (!regMsg.isEmpty()) {
|
||||||
|
player.sendMessage(ChatColor.GREEN + regMsg);
|
||||||
|
}
|
||||||
|
log.info("[Stargate] Initialized stargate: " + portal.getName());
|
||||||
|
portal.drawSign();
|
||||||
|
// Set event text so our new sign is instantly initialized
|
||||||
|
event.setLine(0, sign.getText(0));
|
||||||
|
event.setLine(1, sign.getText(1));
|
||||||
|
event.setLine(2, sign.getText(2));
|
||||||
|
event.setLine(3, sign.getText(3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Portal portal = Portal.getByBlock(block);
|
@Override
|
||||||
if (portal == null) return;
|
public void onBlockRightClick(BlockRightClickEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
if (hasPerm(player, "stargate.destroy", player.isOp()) || hasPerm(player, "stargate.destroy.all", player.isOp()) ||
|
Block block = event.getBlock();
|
||||||
( portal.getOwner().equalsIgnoreCase(player.getName()) && hasPerm(player, "stargate.destroy.owner", false) )) {
|
if (block.getType() == Material.WALL_SIGN) {
|
||||||
// Can't afford
|
Portal portal = Portal.getByBlock(block);
|
||||||
if (iConomyHandler.useiConomy() && (iConomyHandler.destroyCost > 0 && iConomyHandler.getBalance(player.getName()) < iConomyHandler.destroyCost)) {
|
// Cycle through a stargates locations
|
||||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
if (portal != null) {
|
||||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
if (hasPerm(player, "stargate.use", true)) {
|
||||||
event.setCancelled(true);
|
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
||||||
return;
|
portal.cycleDestination(player);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (iConomyHandler.useiConomy()) {
|
if (!denyMsg.isEmpty()) {
|
||||||
iConomyHandler.chargePlayer(player.getName(), iConomyHandler.destroyCost);
|
player.sendMessage(denyMsg);
|
||||||
if (iConomyHandler.destroyCost > 0) {
|
}
|
||||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.destroyCost));
|
}
|
||||||
} else if (iConomyHandler.destroyCost < 0) {
|
}
|
||||||
player.sendMessage(ChatColor.GREEN + "Refunded " + iConomy.getBank().format(-iConomyHandler.destroyCost));
|
}
|
||||||
}
|
|
||||||
}
|
// Implement right-click to toggle a stargate, gets around spawn protection problem.
|
||||||
|
if ((block.getType() == Material.STONE_BUTTON)) {
|
||||||
portal.unregister(true);
|
if (hasPerm(player, "stargate.use", true)) {
|
||||||
if (!dmgMsg.isEmpty()) {
|
Portal portal = Portal.getByBlock(block);
|
||||||
player.sendMessage(ChatColor.RED + dmgMsg);
|
if (portal != null) {
|
||||||
}
|
onButtonPressed(player, portal);
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
event.setCancelled(true);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
Block block = event.getBlock();
|
Player player = event.getPlayer();
|
||||||
if (block.getType() == Material.PORTAL) {
|
Block block = event.getBlock();
|
||||||
event.setCancelled((Portal.getByEntrance(block) != null));
|
// Check if we're pushing a button.
|
||||||
}
|
if (block.getType() == Material.STONE_BUTTON && event.getDamageLevel() == BlockDamageLevel.STARTED) {
|
||||||
}
|
if (hasPerm(player, "stargate.use", true)) {
|
||||||
|
Portal portal = Portal.getByBlock(block);
|
||||||
|
if (portal != null) {
|
||||||
|
onButtonPressed(player, portal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
Block block = event.getBlock();
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (block.getType() != Material.WALL_SIGN && block.getType() != Material.STONE_BUTTON && Gate.getGatesByControlBlock(block).length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
Portal portal = Portal.getByBlock(block);
|
||||||
public void onBlockFlow(BlockFromToEvent event) {
|
if (portal == null) return;
|
||||||
Portal portal = Portal.getByEntrance(event.getBlock());
|
|
||||||
|
if (hasPerm(player, "stargate.destroy", player.isOp()) || hasPerm(player, "stargate.destroy.all", player.isOp()) ||
|
||||||
|
( portal.getOwner().equalsIgnoreCase(player.getName()) && hasPerm(player, "stargate.destroy.owner", false) )) {
|
||||||
|
// Can't afford
|
||||||
|
if (iConomyHandler.useiConomy() && (iConomyHandler.destroyCost > 0 && iConomyHandler.getBalance(player.getName()) < iConomyHandler.destroyCost)) {
|
||||||
|
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
||||||
|
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (iConomyHandler.useiConomy()) {
|
||||||
|
iConomyHandler.chargePlayer(player.getName(), iConomyHandler.destroyCost);
|
||||||
|
if (iConomyHandler.destroyCost > 0) {
|
||||||
|
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomy.getBank().format(iConomyHandler.destroyCost));
|
||||||
|
} else if (iConomyHandler.destroyCost < 0) {
|
||||||
|
player.sendMessage(ChatColor.GREEN + "Refunded " + iConomy.getBank().format(-iConomyHandler.destroyCost));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
portal.unregister(true);
|
||||||
|
if (!dmgMsg.isEmpty()) {
|
||||||
|
player.sendMessage(ChatColor.RED + dmgMsg);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (portal != null) {
|
@Override
|
||||||
event.setCancelled((event.getBlock().getY() == event.getToBlock().getY()));
|
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
}
|
Block block = event.getBlock();
|
||||||
}
|
if (block.getType() == Material.PORTAL) {
|
||||||
}
|
event.setCancelled((Portal.getByEntrance(block) != null));
|
||||||
|
}
|
||||||
private class wListener extends WorldListener {
|
}
|
||||||
@Override
|
|
||||||
public void onWorldLoaded(WorldEvent event) {
|
@Override
|
||||||
World w = event.getWorld();
|
public void onBlockFlow(BlockFromToEvent event) {
|
||||||
// We have to make sure the world is actually loaded. This gets called twice for some reason.
|
Portal portal = Portal.getByEntrance(event.getBlock());
|
||||||
if (w.getBlockAt(w.getSpawnLocation()).getWorld() != null) {
|
|
||||||
Portal.loadAllGates(w);
|
if (portal != null) {
|
||||||
}
|
event.setCancelled((event.getBlock().getY() == event.getToBlock().getY()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private class eListener extends EntityListener {
|
|
||||||
@Override
|
private class wListener extends WorldListener {
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
@Override
|
||||||
if (event.isCancelled()) return;
|
public void onWorldLoaded(WorldEvent event) {
|
||||||
for (Block b : event.blockList()) {
|
World w = event.getWorld();
|
||||||
if (b.getTypeId() != Material.WALL_SIGN.getId() && b.getTypeId() != Material.STONE_BUTTON.getId()) continue;
|
// We have to make sure the world is actually loaded. This gets called twice for some reason.
|
||||||
Portal portal = Portal.getByBlock(b);
|
if (w.getBlockAt(w.getSpawnLocation()).getWorld() != null) {
|
||||||
if (portal == null) continue;
|
Portal.loadAllGates(w);
|
||||||
if (destroyExplosion) {
|
}
|
||||||
portal.unregister(true);
|
}
|
||||||
} else {
|
}
|
||||||
b.setType(b.getType());
|
|
||||||
event.setCancelled(true);
|
private class eListener extends EntityListener {
|
||||||
}
|
@Override
|
||||||
}
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
}
|
if (event.isCancelled()) return;
|
||||||
}
|
for (Block b : event.blockList()) {
|
||||||
|
if (b.getTypeId() != Material.WALL_SIGN.getId() && b.getTypeId() != Material.STONE_BUTTON.getId()) continue;
|
||||||
private class sListener extends ServerListener {
|
Portal portal = Portal.getByBlock(b);
|
||||||
@Override
|
if (portal == null) continue;
|
||||||
public void onPluginEnabled(PluginEvent event) {
|
if (destroyExplosion) {
|
||||||
if (iConomyHandler.useiConomy && iConomyHandler.iConomy == null) {
|
portal.unregister(true);
|
||||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("iConomy")) {
|
} else {
|
||||||
iConomyHandler.iConomy = (iConomy)event.getPlugin();
|
b.setType(b.getType());
|
||||||
Stargate.log.info("[Stargate] Using iConomy (v" + iConomyHandler.iConomy.getDescription().getVersion() + ")");
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (permissions == null) {
|
}
|
||||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("Permissions")) {
|
}
|
||||||
permissions = (Permissions)event.getPlugin();
|
|
||||||
Stargate.log.info("[Stargate] Using Permissions (v" + permissions.getDescription().getVersion() + ")");
|
private class sListener extends ServerListener {
|
||||||
}
|
@Override
|
||||||
}
|
public void onPluginEnabled(PluginEvent event) {
|
||||||
}
|
if (iConomyHandler.useiConomy && iConomyHandler.iConomy == null) {
|
||||||
|
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("iConomy")) {
|
||||||
@Override
|
iConomyHandler.iConomy = (iConomy)event.getPlugin();
|
||||||
public void onPluginDisabled(PluginEvent event) {
|
Stargate.log.info("[Stargate] Using iConomy (v" + iConomyHandler.iConomy.getDescription().getVersion() + ")");
|
||||||
if (iConomyHandler.useiConomy && iConomyHandler.iConomy != null) {
|
}
|
||||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("iConomy")) {
|
}
|
||||||
iConomyHandler.iConomy = null;
|
if (permissions == null) {
|
||||||
Stargate.log.info("[Stargate] iConomy Disabled");
|
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("Permissions")) {
|
||||||
}
|
permissions = (Permissions)event.getPlugin();
|
||||||
}
|
Stargate.log.info("[Stargate] Using Permissions (v" + permissions.getDescription().getVersion() + ")");
|
||||||
if (permissions != null) {
|
}
|
||||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("Permissions")) {
|
}
|
||||||
permissions = null;
|
}
|
||||||
Stargate.log.info("[Stargate] Permissions Disabled");
|
|
||||||
}
|
@Override
|
||||||
}
|
public void onPluginDisabled(PluginEvent event) {
|
||||||
}
|
if (iConomyHandler.useiConomy && iConomyHandler.iConomy != null) {
|
||||||
}
|
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("iConomy")) {
|
||||||
|
iConomyHandler.iConomy = null;
|
||||||
private class SGThread implements Runnable {
|
Stargate.log.info("[Stargate] iConomy Disabled");
|
||||||
public void run() {
|
}
|
||||||
long time = System.currentTimeMillis() / 1000;
|
}
|
||||||
// Close open portals
|
if (permissions != null) {
|
||||||
for (Iterator<Portal> iter = Stargate.openList.iterator(); iter.hasNext();) {
|
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("Permissions")) {
|
||||||
Portal p = iter.next();
|
permissions = null;
|
||||||
if (time > p.getOpenTime() + Stargate.openLimit) {
|
Stargate.log.info("[Stargate] Permissions Disabled");
|
||||||
p.close(false);
|
}
|
||||||
iter.remove();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Deactivate active portals
|
|
||||||
for (Iterator<Portal> iter = Stargate.activeList.iterator(); iter.hasNext();) {
|
private class SGThread implements Runnable {
|
||||||
Portal p = iter.next();
|
public void run() {
|
||||||
if (time > p.getOpenTime() + Stargate.activeLimit) {
|
long time = System.currentTimeMillis() / 1000;
|
||||||
p.deactivate();
|
// Close open portals
|
||||||
iter.remove();
|
for (Iterator<Portal> iter = Stargate.openList.iterator(); iter.hasNext();) {
|
||||||
}
|
Portal p = iter.next();
|
||||||
}
|
if (time > p.getOpenTime() + Stargate.openLimit) {
|
||||||
}
|
p.close(false);
|
||||||
}
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Deactivate active portals
|
||||||
|
for (Iterator<Portal> iter = Stargate.activeList.iterator(); iter.hasNext();) {
|
||||||
|
Portal p = iter.next();
|
||||||
|
if (time > p.getOpenTime() + Stargate.activeLimit) {
|
||||||
|
p.deactivate();
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user