[Version 0.7.5.8]
- Fixed an exploit with pistons to destroy gates [Version 0.7.5.7] - Removed SignPost class - Resolved issues with signs in 1.2
This commit is contained in:
parent
3ff6b8b253
commit
bfcdd212c4
5
README
5
README
@ -201,6 +201,11 @@ createConflict=Gate conflicts with existing gate
|
|||||||
=============
|
=============
|
||||||
Changes
|
Changes
|
||||||
=============
|
=============
|
||||||
|
[Version 0.7.5.8]
|
||||||
|
- Fixed an exploit with pistons to destroy gates
|
||||||
|
[Version 0.7.5.7]
|
||||||
|
- Removed SignPost class
|
||||||
|
- Resolved issues with signs in 1.2
|
||||||
[Version 0.7.5.6]
|
[Version 0.7.5.6]
|
||||||
- Quick update to the custom event code, works with R5+ now.
|
- Quick update to the custom event code, works with R5+ now.
|
||||||
[Version 0.7.5.5]
|
[Version 0.7.5.5]
|
||||||
|
@ -1,134 +1,165 @@
|
|||||||
package net.TheDgtl.Stargate;
|
package net.TheDgtl.Stargate;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
/**
|
|
||||||
* Blox.java
|
/**
|
||||||
* @author Shaun (sturmeh)
|
* Blox.java
|
||||||
* @author Dinnerbone
|
* @author Shaun (sturmeh)
|
||||||
* @author Steven "Drakia" Scott
|
* @author Dinnerbone
|
||||||
*/
|
* @author Steven "Drakia" Scott
|
||||||
|
*/
|
||||||
public class Blox {
|
|
||||||
private int x;
|
public class Blox {
|
||||||
private int y;
|
private int x;
|
||||||
private int z;
|
private int y;
|
||||||
private World world;
|
private int z;
|
||||||
|
private World world;
|
||||||
public Blox (World world, int x, int y, int z) {
|
private Blox parent = null;
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
public Blox (World world, int x, int y, int z) {
|
||||||
this.z = z;
|
this.x = x;
|
||||||
this.world = world;
|
this.y = y;
|
||||||
}
|
this.z = z;
|
||||||
|
this.world = world;
|
||||||
public Blox (Block block) {
|
}
|
||||||
this.x = block.getX();
|
|
||||||
this.y = block.getY();
|
public Blox (Block block) {
|
||||||
this.z = block.getZ();
|
this.x = block.getX();
|
||||||
this.world = block.getWorld();
|
this.y = block.getY();
|
||||||
}
|
this.z = block.getZ();
|
||||||
|
this.world = block.getWorld();
|
||||||
public Blox (Location location) {
|
}
|
||||||
this.x = location.getBlockX();
|
|
||||||
this.y = location.getBlockY();
|
public Blox (Location location) {
|
||||||
this.z = location.getBlockZ();
|
this.x = location.getBlockX();
|
||||||
this.world = location.getWorld();
|
this.y = location.getBlockY();
|
||||||
}
|
this.z = location.getBlockZ();
|
||||||
|
this.world = location.getWorld();
|
||||||
public Blox (World world, String string) {
|
}
|
||||||
String[] split = string.split(",");
|
|
||||||
this.x = Integer.parseInt(split[0]);
|
public Blox (World world, String string) {
|
||||||
this.y = Integer.parseInt(split[1]);
|
String[] split = string.split(",");
|
||||||
this.z = Integer.parseInt(split[2]);
|
this.x = Integer.parseInt(split[0]);
|
||||||
this.world = world;
|
this.y = Integer.parseInt(split[1]);
|
||||||
}
|
this.z = Integer.parseInt(split[2]);
|
||||||
|
this.world = world;
|
||||||
public Blox makeRelative(int x, int y, int z) {
|
}
|
||||||
return new Blox(this.world, this.x + x, this.y + y, this.z + z);
|
|
||||||
}
|
public Blox makeRelative(int x, int y, int z) {
|
||||||
|
return new Blox(this.world, this.x + x, this.y + y, this.z + z);
|
||||||
public Location makeRelativeLoc(double x, double y, double z, float rotX, float rotY) {
|
}
|
||||||
return new Location(this.world, (double)this.x + x, (double)this.y + y, (double)this.z + z, rotX, rotY);
|
|
||||||
}
|
public Location makeRelativeLoc(double x, double y, double z, float rotX, float 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) {
|
}
|
||||||
return makeRelative(-right * modX + distance * modZ, -depth * modY, -right * modZ + -distance * modX);
|
|
||||||
}
|
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);
|
||||||
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);
|
|
||||||
}
|
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);
|
||||||
public void setType(int type) {
|
}
|
||||||
world.getBlockAt(x, y, z).setTypeId(type);
|
|
||||||
}
|
public void setType(int type) {
|
||||||
|
world.getBlockAt(x, y, z).setTypeId(type);
|
||||||
public int getType() {
|
}
|
||||||
return world.getBlockAt(x, y, z).getTypeId();
|
|
||||||
}
|
public int getType() {
|
||||||
|
return world.getBlockAt(x, y, z).getTypeId();
|
||||||
public void setData(int data) {
|
}
|
||||||
world.getBlockAt(x, y, z).setData((byte)data);
|
|
||||||
}
|
public void setData(int data) {
|
||||||
|
world.getBlockAt(x, y, z).setData((byte)data);
|
||||||
public int getData() {
|
}
|
||||||
return world.getBlockAt(x, y, z).getData();
|
|
||||||
}
|
public int getData() {
|
||||||
|
return world.getBlockAt(x, y, z).getData();
|
||||||
public Block getBlock() {
|
}
|
||||||
return world.getBlockAt(x, y, z);
|
|
||||||
}
|
public Block getBlock() {
|
||||||
|
return world.getBlockAt(x, y, z);
|
||||||
public int getX() {
|
}
|
||||||
return x;
|
|
||||||
}
|
public int getX() {
|
||||||
|
return x;
|
||||||
public int getY() {
|
}
|
||||||
return y;
|
|
||||||
}
|
public int getY() {
|
||||||
|
return y;
|
||||||
public int getZ() {
|
}
|
||||||
return z;
|
|
||||||
}
|
public int getZ() {
|
||||||
|
return z;
|
||||||
public World getWorld() {
|
}
|
||||||
return world;
|
|
||||||
}
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
public String toString() {
|
}
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
//builder.append(world.getName());
|
public Block getParent() {
|
||||||
//builder.append(',');
|
if (parent == null) findParent();
|
||||||
builder.append(x);
|
if (parent == null) return null;
|
||||||
builder.append(',');
|
return parent.getBlock();
|
||||||
builder.append(y);
|
}
|
||||||
builder.append(',');
|
|
||||||
builder.append(z);
|
private void findParent() {
|
||||||
return builder.toString();
|
int offsetX = 0;
|
||||||
}
|
int offsetY = 0;
|
||||||
|
int offsetZ = 0;
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
if (getBlock().getType() == Material.WALL_SIGN) {
|
||||||
int result = 18;
|
if (getData() == 0x2) {
|
||||||
|
offsetZ = 1;
|
||||||
result = result * 27 + x;
|
} else if (getData() == 0x3) {
|
||||||
result = result * 27 + y;
|
offsetZ = -1;
|
||||||
result = result * 27 + z;
|
} else if (getData() == 0x4) {
|
||||||
result = result * 27 + world.getName().hashCode();
|
offsetX = 1;
|
||||||
|
} else if (getData() == 0x5) {
|
||||||
return result;
|
offsetX = -1;
|
||||||
}
|
}
|
||||||
|
} else if (getBlock().getType() == Material.SIGN_POST) {
|
||||||
@Override
|
offsetY = -1;
|
||||||
public boolean equals(Object obj) {
|
} else {
|
||||||
if (this == obj) return true;
|
return;
|
||||||
if (obj == null) return false;
|
}
|
||||||
if (getClass() != obj.getClass()) return false;
|
parent = new Blox(world, getX() + offsetX, getY() + offsetY, getZ() + offsetZ);
|
||||||
|
}
|
||||||
Blox blox = (Blox) obj;
|
|
||||||
return (x == blox.x) && (y == blox.y) && (z == blox.z) && (world.getName().equals(blox.world.getName()));
|
public String toString() {
|
||||||
}
|
StringBuilder builder = new StringBuilder();
|
||||||
|
//builder.append(world.getName());
|
||||||
|
//builder.append(',');
|
||||||
|
builder.append(x);
|
||||||
|
builder.append(',');
|
||||||
|
builder.append(y);
|
||||||
|
builder.append(',');
|
||||||
|
builder.append(z);
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = 18;
|
||||||
|
|
||||||
|
result = result * 27 + x;
|
||||||
|
result = result * 27 + y;
|
||||||
|
result = result * 27 + z;
|
||||||
|
result = result * 27 + world.getName().hashCode();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null) return false;
|
||||||
|
if (getClass() != obj.getClass()) return false;
|
||||||
|
|
||||||
|
Blox blox = (Blox) obj;
|
||||||
|
return (x == blox.x) && (y == blox.y) && (z == blox.z) && (world.getName().equals(blox.world.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
@ -54,7 +54,7 @@ public class Portal {
|
|||||||
private float rotX;
|
private float rotX;
|
||||||
|
|
||||||
// Block references
|
// Block references
|
||||||
private SignPost id;
|
private Blox id;
|
||||||
private Blox button;
|
private Blox button;
|
||||||
private Blox[] frame;
|
private Blox[] frame;
|
||||||
private Blox[] entrances;
|
private Blox[] entrances;
|
||||||
@ -87,7 +87,7 @@ public class Portal {
|
|||||||
private long openTime;
|
private long openTime;
|
||||||
|
|
||||||
private Portal(Blox topLeft, int modX, int modZ,
|
private Portal(Blox topLeft, int modX, int modZ,
|
||||||
float rotX, SignPost id, Blox button,
|
float rotX, Blox id, Blox button,
|
||||||
String dest, String name,
|
String dest, String name,
|
||||||
boolean verified, String network, Gate gate, String owner,
|
boolean verified, String network, Gate gate, String owner,
|
||||||
boolean hidden, boolean alwaysOn, boolean priv, boolean free, boolean backwards, boolean show, boolean noNetwork) {
|
boolean hidden, boolean alwaysOn, boolean priv, boolean free, boolean backwards, boolean show, boolean noNetwork) {
|
||||||
@ -590,29 +590,30 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void drawSign() {
|
public final void drawSign() {
|
||||||
id.setText(0, "--" + name + "--");
|
Sign sign = (Sign)id.getBlock().getState();
|
||||||
|
sign.setLine(0, "--" + name + "--");
|
||||||
int max = destinations.size() - 1;
|
int max = destinations.size() - 1;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
|
|
||||||
if (!isActive()) {
|
if (!isActive()) {
|
||||||
id.setText(++done, "Right click to");
|
sign.setLine(++done, "Right click to");
|
||||||
id.setText(++done, "use the gate");
|
sign.setLine(++done, "use the gate");
|
||||||
if (!noNetwork) {
|
if (!noNetwork) {
|
||||||
id.setText(++done, " (" + network + ") ");
|
sign.setLine(++done, " (" + network + ") ");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isFixed()) {
|
if (isFixed()) {
|
||||||
id.setText(++done, "To: " + destination);
|
sign.setLine(++done, "To: " + destination);
|
||||||
if (noNetwork) {
|
if (noNetwork) {
|
||||||
id.setText(++done, "");
|
sign.setLine(++done, "");
|
||||||
} else {
|
} else {
|
||||||
id.setText(++done, " (" + network + ") ");
|
sign.setLine(++done, " (" + network + ") ");
|
||||||
}
|
}
|
||||||
Portal dest = Portal.getByName(destination, network);
|
Portal dest = Portal.getByName(destination, network);
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
id.setText(++done, "(Not Connected)");
|
sign.setLine(++done, "(Not Connected)");
|
||||||
} else {
|
} else {
|
||||||
id.setText(++done, "");
|
sign.setLine(++done, "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int index = destinations.indexOf(destination);
|
int index = destinations.indexOf(destination);
|
||||||
@ -621,55 +622,55 @@ public class Portal {
|
|||||||
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
|
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
|
||||||
Portal dest = Portal.getByName(destinations.get(index - 2), network);
|
Portal dest = Portal.getByName(destinations.get(index - 2), network);
|
||||||
boolean green = Stargate.isFree(activePlayer, this, dest);
|
boolean green = Stargate.isFree(activePlayer, this, dest);
|
||||||
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 2));
|
sign.setLine(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 2));
|
||||||
} else {
|
} else {
|
||||||
id.setText(done, destinations.get(index - 2));
|
sign.setLine(done, destinations.get(index - 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((index > 0) && (++done <= 3)) {
|
if ((index > 0) && (++done <= 3)) {
|
||||||
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
|
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
|
||||||
Portal dest = Portal.getByName(destinations.get(index - 1), network);
|
Portal dest = Portal.getByName(destinations.get(index - 1), network);
|
||||||
boolean green = Stargate.isFree(activePlayer, this, dest);
|
boolean green = Stargate.isFree(activePlayer, this, dest);
|
||||||
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 1));
|
sign.setLine(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 1));
|
||||||
} else {
|
} else {
|
||||||
id.setText(done, destinations.get(index - 1));
|
sign.setLine(done, destinations.get(index - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (++done <= 3) {
|
if (++done <= 3) {
|
||||||
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
|
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
|
||||||
Portal dest = Portal.getByName(destination, network);
|
Portal dest = Portal.getByName(destination, network);
|
||||||
boolean green = Stargate.isFree(activePlayer, this, dest);
|
boolean green = Stargate.isFree(activePlayer, this, dest);
|
||||||
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + " >" + destination + "< ");
|
sign.setLine(done, (green ? ChatColor.DARK_GREEN : "") + " >" + destination + "< ");
|
||||||
} else {
|
} else {
|
||||||
id.setText(done, " >" + destination + "< ");
|
sign.setLine(done, " >" + destination + "< ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((max >= index + 1) && (++done <= 3)) {
|
if ((max >= index + 1) && (++done <= 3)) {
|
||||||
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
|
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
|
||||||
Portal dest = Portal.getByName(destinations.get(index + 1), network);
|
Portal dest = Portal.getByName(destinations.get(index + 1), network);
|
||||||
boolean green = Stargate.isFree(activePlayer, this, dest);
|
boolean green = Stargate.isFree(activePlayer, this, dest);
|
||||||
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 1));
|
sign.setLine(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 1));
|
||||||
} else {
|
} else {
|
||||||
id.setText(done, destinations.get(index + 1));
|
sign.setLine(done, destinations.get(index + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((max >= index + 2) && (++done <= 3)) {
|
if ((max >= index + 2) && (++done <= 3)) {
|
||||||
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
|
if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
|
||||||
Portal dest = Portal.getByName(destinations.get(index + 2), network);
|
Portal dest = Portal.getByName(destinations.get(index + 2), network);
|
||||||
boolean green = Stargate.isFree(activePlayer, this, dest);
|
boolean green = Stargate.isFree(activePlayer, this, dest);
|
||||||
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 2));
|
sign.setLine(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 2));
|
||||||
} else {
|
} else {
|
||||||
id.setText(done, destinations.get(index + 2));
|
sign.setLine(done, destinations.get(index + 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (done++; done <= 3; done++) {
|
for (done++; done <= 3; done++) {
|
||||||
id.setText(done, "");
|
sign.setLine(done, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
id.update();
|
sign.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregister(boolean removeAll) {
|
public void unregister(boolean removeAll) {
|
||||||
@ -696,11 +697,12 @@ public class Portal {
|
|||||||
allPortalsNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());
|
allPortalsNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());
|
||||||
|
|
||||||
if (id.getBlock().getType() == Material.WALL_SIGN) {
|
if (id.getBlock().getType() == Material.WALL_SIGN) {
|
||||||
id.setText(0, getName());
|
Sign sign = (Sign)id.getBlock().getState();
|
||||||
id.setText(1, "");
|
sign.setLine(0, getName());
|
||||||
id.setText(2, "");
|
sign.setLine(1, "");
|
||||||
id.setText(3, "");
|
sign.setLine(2, "");
|
||||||
id.update();
|
sign.setLine(3, "");
|
||||||
|
sign.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String originName : allPortalsNet.get(getNetwork().toLowerCase())) {
|
for (String originName : allPortalsNet.get(getNetwork().toLowerCase())) {
|
||||||
@ -750,7 +752,7 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Portal createPortal(SignChangeEvent event, Player player) {
|
public static Portal createPortal(SignChangeEvent event, Player player) {
|
||||||
SignPost id = new SignPost(new Blox(event.getBlock()));
|
Blox id = new Blox(event.getBlock());
|
||||||
Block idParent = id.getParent();
|
Block idParent = id.getParent();
|
||||||
if (idParent == null) {
|
if (idParent == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -1117,12 +1119,11 @@ public class Portal {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String name = split[0];
|
String name = split[0];
|
||||||
Blox s = new Blox(world, split[1]);
|
Blox sign = new Blox(world, split[1]);
|
||||||
if (!(s.getBlock().getState() instanceof Sign)) {
|
if (!(sign.getBlock().getState() instanceof Sign)) {
|
||||||
Stargate.log.info("[Stargate] Sign on line " + l + " doesn't exist. BlockType = " + s.getBlock().getType());
|
Stargate.log.info("[Stargate] Sign on line " + l + " doesn't exist. BlockType = " + sign.getBlock().getType());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SignPost sign = new SignPost(s);
|
|
||||||
Blox button = (split[2].length() > 0) ? new Blox(world, split[2]) : null;
|
Blox button = (split[2].length() > 0) ? new Blox(world, split[2]) : null;
|
||||||
int modX = Integer.parseInt(split[3]);
|
int modX = Integer.parseInt(split[3]);
|
||||||
int modZ = Integer.parseInt(split[4]);
|
int modZ = Integer.parseInt(split[4]);
|
||||||
|
@ -1,125 +0,0 @@
|
|||||||
package net.TheDgtl.Stargate;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SignPost.java
|
|
||||||
* @author Shaun (sturmeh)
|
|
||||||
* @author Dinnerbone
|
|
||||||
* @author Steven "Drakia" Scott
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class SignPost {
|
|
||||||
private Blox parent;
|
|
||||||
private Blox block;
|
|
||||||
private World world;
|
|
||||||
|
|
||||||
public SignPost(World world, Sign sign) {
|
|
||||||
this.world = world;
|
|
||||||
this.block = new Blox(world, sign.getX(), sign.getY(), sign.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public SignPost(Blox block) {
|
|
||||||
this.block = block;
|
|
||||||
this.world = block.getWorld();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getParent() {
|
|
||||||
if (parent == null) findParent();
|
|
||||||
if (parent == null) return null;
|
|
||||||
return parent.getBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getBlock() {
|
|
||||||
return block.getBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText(int index) {
|
|
||||||
Sign sign = findSign();
|
|
||||||
if (sign == null) return "";
|
|
||||||
return sign.getLine(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(int index, String value) {
|
|
||||||
Sign sign = findSign();
|
|
||||||
if (sign == null) return;
|
|
||||||
sign.setLine(index, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIdText() {
|
|
||||||
Sign sign = findSign();
|
|
||||||
if (sign == null) return "";
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
|
|
||||||
result.append(getText(0));
|
|
||||||
result.append("\n");
|
|
||||||
result.append(getText(1));
|
|
||||||
result.append("\n");
|
|
||||||
result.append(getText(2));
|
|
||||||
result.append("\n");
|
|
||||||
result.append(getText(3));
|
|
||||||
|
|
||||||
return result.toString().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update() {
|
|
||||||
final Sign sign = findSign();
|
|
||||||
if (sign == null) return;
|
|
||||||
|
|
||||||
sign.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void findParent() {
|
|
||||||
Sign sign = findSign();
|
|
||||||
int offsetX = 0;
|
|
||||||
int offsetY = 0;
|
|
||||||
int offsetZ = 0;
|
|
||||||
|
|
||||||
if (block.getBlock().getType() == Material.WALL_SIGN) {
|
|
||||||
if (block.getData() == 0x2) {
|
|
||||||
offsetZ = 1;
|
|
||||||
} else if (block.getData() == 0x3) {
|
|
||||||
offsetZ = -1;
|
|
||||||
} else if (block.getData() == 0x4) {
|
|
||||||
offsetX = 1;
|
|
||||||
} else if (block.getData() == 0x5) {
|
|
||||||
offsetX = -1;
|
|
||||||
}
|
|
||||||
} else if (block.getBlock().getType() == Material.SIGN_POST) {
|
|
||||||
offsetY = -1;
|
|
||||||
}
|
|
||||||
if (sign == null) {
|
|
||||||
Stargate.debug("findParent", "sign == null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (world == null) {
|
|
||||||
Stargate.debug("findParent", "world == null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parent = new Blox(world, sign.getX() + offsetX, sign.getY() + offsetY, sign.getZ() + offsetZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Sign findSign() {
|
|
||||||
try {
|
|
||||||
BlockState sign = this.world.getBlockAt(block.getX(), block.getY(), block.getZ()).getState();
|
|
||||||
if (sign instanceof Sign) return (Sign)sign;
|
|
||||||
return null;
|
|
||||||
} catch (Exception e) {}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SignPost getFromBlock(Block block) {
|
|
||||||
BlockState state = block.getState();
|
|
||||||
if (!(state instanceof Sign)) return null;
|
|
||||||
return new SignPost(block.getWorld(), (Sign)state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SignPost getFromLocation(Location location) {
|
|
||||||
return getFromBlock(location.getWorld().getBlockAt((int)location.getX(), (int)location.getY(), (int)location.getZ()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,6 +29,8 @@ import org.bukkit.event.block.Action;
|
|||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@ -945,6 +947,25 @@ public class Stargate extends JavaPlugin {
|
|||||||
event.setCancelled((event.getBlock().getY() == event.getToBlock().getY()));
|
event.setCancelled((event.getBlock().getY() == event.getToBlock().getY()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPistonExtend(BlockPistonExtendEvent event) {
|
||||||
|
for(Block block : event.getBlocks()) {
|
||||||
|
Portal portal = Portal.getByBlock(block);
|
||||||
|
if (portal != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPistonRetract(BlockPistonRetractEvent event) {
|
||||||
|
if (!event.isSticky()) return;
|
||||||
|
Block affected = event.getRetractLocation().getBlock();
|
||||||
|
Portal portal = Portal.getByBlock(affected);
|
||||||
|
if (portal != null) event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class wListener implements Listener {
|
private class wListener implements Listener {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.TheDgtl.Stargate.Stargate
|
main: net.TheDgtl.Stargate.Stargate
|
||||||
version: 0.7.5.6
|
version: 0.7.5.8
|
||||||
description: Stargate mod for Bukkit
|
description: Stargate mod for Bukkit
|
||||||
author: Drakia
|
author: Drakia
|
||||||
website: http://www.thedgtl.net
|
website: http://www.thedgtl.net
|
||||||
|
Loading…
Reference in New Issue
Block a user