[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,6 +1,7 @@
|
|||||||
package net.TheDgtl.Stargate;
|
package net.TheDgtl.Stargate;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ public class Blox {
|
|||||||
private int y;
|
private int y;
|
||||||
private int z;
|
private int z;
|
||||||
private World world;
|
private World world;
|
||||||
|
private Blox parent = null;
|
||||||
|
|
||||||
public Blox (World world, int x, int y, int z) {
|
public Blox (World world, int x, int y, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@ -98,6 +100,35 @@ public class Blox {
|
|||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Block getParent() {
|
||||||
|
if (parent == null) findParent();
|
||||||
|
if (parent == null) return null;
|
||||||
|
return parent.getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findParent() {
|
||||||
|
int offsetX = 0;
|
||||||
|
int offsetY = 0;
|
||||||
|
int offsetZ = 0;
|
||||||
|
|
||||||
|
if (getBlock().getType() == Material.WALL_SIGN) {
|
||||||
|
if (getData() == 0x2) {
|
||||||
|
offsetZ = 1;
|
||||||
|
} else if (getData() == 0x3) {
|
||||||
|
offsetZ = -1;
|
||||||
|
} else if (getData() == 0x4) {
|
||||||
|
offsetX = 1;
|
||||||
|
} else if (getData() == 0x5) {
|
||||||
|
offsetX = -1;
|
||||||
|
}
|
||||||
|
} else if (getBlock().getType() == Material.SIGN_POST) {
|
||||||
|
offsetY = -1;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parent = new Blox(world, getX() + offsetX, getY() + offsetY, getZ() + offsetZ);
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
//builder.append(world.getName());
|
//builder.append(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