Complete re-write of Permissions
Far more advanced API for checking if people can do things Better implementation of personal gate creation that works alongside other network restrictions Debug option now hides 90% of output if disabled Better handling of undefined costs in .gate files Network/World filter option now removed SuperPerms support Probably a lot more stuff I don't remember
This commit is contained in:
parent
e1e3cd5e39
commit
1b117c3132
2
README
2
README
@ -139,6 +139,8 @@ maxgates - If non-zero, will define the maximum amount of gates allowed on a net
|
|||||||
=============
|
=============
|
||||||
Changes
|
Changes
|
||||||
=============
|
=============
|
||||||
|
[Version 0.6.0]
|
||||||
|
- Oh god the changes, hopefully I didn't fuck anything up, README updates coming later
|
||||||
[Version 0.5.5]
|
[Version 0.5.5]
|
||||||
- Added 'B'ackwards option
|
- Added 'B'ackwards option
|
||||||
- Fixed opening of gates with a fixed gate as a destination
|
- Fixed opening of gates with a fixed gate as a destination
|
||||||
|
@ -43,9 +43,9 @@ public class Gate {
|
|||||||
private int portalBlockClosed = Material.AIR.getId();
|
private int portalBlockClosed = Material.AIR.getId();
|
||||||
|
|
||||||
// iConomy information
|
// iConomy information
|
||||||
private int useCost = 0;
|
private int useCost = -1;
|
||||||
private int createCost = 0;
|
private int createCost = -1;
|
||||||
private int destroyCost = 0;
|
private int destroyCost = -1;
|
||||||
private boolean toOwner = false;
|
private boolean toOwner = false;
|
||||||
|
|
||||||
private Gate(String filename, Character[][] layout, HashMap<Character, Integer> types, HashMap<Character, Integer> metadata) {
|
private Gate(String filename, Character[][] layout, HashMap<Character, Integer> types, HashMap<Character, Integer> metadata) {
|
||||||
@ -108,11 +108,11 @@ public class Gate {
|
|||||||
|
|
||||||
writeConfig(bw, "portal-open", portalBlockOpen);
|
writeConfig(bw, "portal-open", portalBlockOpen);
|
||||||
writeConfig(bw, "portal-closed", portalBlockClosed);
|
writeConfig(bw, "portal-closed", portalBlockClosed);
|
||||||
if (useCost != iConomyHandler.useCost)
|
if (useCost != -1)
|
||||||
writeConfig(bw, "usecost", useCost);
|
writeConfig(bw, "usecost", useCost);
|
||||||
if (createCost != iConomyHandler.createCost)
|
if (createCost != -1)
|
||||||
writeConfig(bw, "createcost", createCost);
|
writeConfig(bw, "createcost", createCost);
|
||||||
if (destroyCost != iConomyHandler.destroyCost)
|
if (destroyCost != -1)
|
||||||
writeConfig(bw, "destroycost", destroyCost);
|
writeConfig(bw, "destroycost", destroyCost);
|
||||||
writeConfig(bw, "toowner", toOwner);
|
writeConfig(bw, "toowner", toOwner);
|
||||||
|
|
||||||
@ -199,14 +199,17 @@ public class Gate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getUseCost() {
|
public int getUseCost() {
|
||||||
|
if (useCost < 0) return iConomyHandler.useCost;
|
||||||
return useCost;
|
return useCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getCreateCost() {
|
public Integer getCreateCost() {
|
||||||
|
if (createCost < 0) return iConomyHandler.createCost;
|
||||||
return createCost;
|
return createCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getDestroyCost() {
|
public Integer getDestroyCost() {
|
||||||
|
if (destroyCost < 0) return iConomyHandler.destroyCost;
|
||||||
return destroyCost;
|
return destroyCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,9 +348,9 @@ public class Gate {
|
|||||||
|
|
||||||
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);
|
||||||
gate.useCost = readConfig(config, gate, file, "usecost", iConomyHandler.useCost);
|
gate.useCost = readConfig(config, gate, file, "usecost", -1);
|
||||||
gate.destroyCost = readConfig(config, gate, file, "destroycost", iConomyHandler.destroyCost);
|
gate.destroyCost = readConfig(config, gate, file, "destroycost", -1);
|
||||||
gate.createCost = readConfig(config, gate, file, "createcost", iConomyHandler.createCost);
|
gate.createCost = readConfig(config, gate, file, "createcost", -1);
|
||||||
gate.toOwner = (config.containsKey("toowner") ? Boolean.valueOf(config.get("toowner")) : iConomyHandler.toOwner);
|
gate.toOwner = (config.containsKey("toowner") ? Boolean.valueOf(config.get("toowner")) : iConomyHandler.toOwner);
|
||||||
|
|
||||||
if (gate.getControls().length != 2) {
|
if (gate.getControls().length != 2) {
|
||||||
|
@ -32,7 +32,7 @@ import org.bukkit.util.Vector;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class Portal {
|
public class Portal {
|
||||||
// Variables used to store portal lists
|
// Static variables used to store portal lists
|
||||||
private static final HashMap<Blox, Portal> lookupBlocks = new HashMap<Blox, Portal>();
|
private static final HashMap<Blox, Portal> lookupBlocks = new HashMap<Blox, Portal>();
|
||||||
private static final HashMap<Blox, Portal> lookupEntrances = new HashMap<Blox, Portal>();
|
private static final HashMap<Blox, Portal> lookupEntrances = new HashMap<Blox, Portal>();
|
||||||
private static final ArrayList<Portal> allPortals = new ArrayList<Portal>();
|
private static final ArrayList<Portal> allPortals = new ArrayList<Portal>();
|
||||||
@ -44,17 +44,23 @@ public class Portal {
|
|||||||
private int modX;
|
private int modX;
|
||||||
private int modZ;
|
private int modZ;
|
||||||
private float rotX;
|
private float rotX;
|
||||||
|
|
||||||
// Block references
|
// Block references
|
||||||
private SignPost id;
|
private SignPost id;
|
||||||
private Blox button;
|
private Blox button;
|
||||||
private Blox[] frame;
|
private Blox[] frame;
|
||||||
private Blox[] entrances;
|
private Blox[] entrances;
|
||||||
|
|
||||||
// Gate information
|
// Gate information
|
||||||
private String name;
|
private String name;
|
||||||
private String destination;
|
private String destination;
|
||||||
private String network;
|
private String network;
|
||||||
private Gate gate;
|
private Gate gate;
|
||||||
private String owner = "";
|
private String owner = "";
|
||||||
|
private World world;
|
||||||
|
private boolean verified;
|
||||||
|
private boolean fixed;
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
private boolean hidden = false;
|
private boolean hidden = false;
|
||||||
private boolean alwaysOn = false;
|
private boolean alwaysOn = false;
|
||||||
@ -62,10 +68,6 @@ public class Portal {
|
|||||||
private boolean free = false;
|
private boolean free = false;
|
||||||
private boolean backwards = false;
|
private boolean backwards = false;
|
||||||
|
|
||||||
private World world;
|
|
||||||
// Gate options
|
|
||||||
private boolean verified;
|
|
||||||
private boolean fixed;
|
|
||||||
// In-use information
|
// In-use information
|
||||||
private Player player;
|
private Player player;
|
||||||
private Player activePlayer;
|
private Player activePlayer;
|
||||||
@ -86,7 +88,6 @@ public class Portal {
|
|||||||
this.destination = dest;
|
this.destination = dest;
|
||||||
this.button = button;
|
this.button = button;
|
||||||
this.verified = verified;
|
this.verified = verified;
|
||||||
this.fixed = dest.length() > 0;
|
|
||||||
this.network = network;
|
this.network = network;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.gate = gate;
|
this.gate = gate;
|
||||||
@ -97,10 +98,11 @@ public class Portal {
|
|||||||
this.free = free;
|
this.free = free;
|
||||||
this.backwards = backwards;
|
this.backwards = backwards;
|
||||||
this.world = topLeft.getWorld();
|
this.world = topLeft.getWorld();
|
||||||
|
this.fixed = dest.length() > 0;
|
||||||
|
|
||||||
if (this.alwaysOn && !this.fixed) {
|
if (this.isAlwaysOn() && !this.isFixed()) {
|
||||||
this.alwaysOn = false;
|
this.alwaysOn = false;
|
||||||
Stargate.log.log(Level.WARNING, "Can not create a non-fixed always-on gate.");
|
Stargate.debug("Portal", "Can not create a non-fixed always-on gate. Setting AlwaysOn = false");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.register();
|
this.register();
|
||||||
@ -109,12 +111,15 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Option Check Functions
|
||||||
|
*/
|
||||||
public boolean isOpen() {
|
public boolean isOpen() {
|
||||||
return isOpen || isAlwaysOn();
|
return isOpen || isAlwaysOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAlwaysOn() {
|
public boolean isAlwaysOn() {
|
||||||
return alwaysOn && isFixed();
|
return alwaysOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHidden() {
|
public boolean isHidden() {
|
||||||
@ -133,11 +138,76 @@ public class Portal {
|
|||||||
return backwards;
|
return backwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFree(Player player, Portal dest) {
|
/**
|
||||||
// This gate is free, the player gets all gates free, or we don't charge for free dest and dest is free
|
* Getters and Setters
|
||||||
boolean isFree = isFree() || Stargate.hasPerm(player, "stargate.free.use", player.isOp()) ||
|
*/
|
||||||
(!iConomyHandler.chargeFreeDestination && dest.isFree());
|
|
||||||
return isFree;
|
public float getRotation() {
|
||||||
|
return rotX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = filterName(name);
|
||||||
|
drawSign();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Portal getDestination() {
|
||||||
|
return Portal.getByName(destination, getNetwork());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDestination(Portal destination) {
|
||||||
|
setDestination(destination.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDestination(String destination) {
|
||||||
|
this.destination = destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDestinationName() {
|
||||||
|
return destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gate getGate() {
|
||||||
|
return gate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blox[] getEntrances() {
|
||||||
|
if (entrances == null) {
|
||||||
|
RelativeBlockVector[] space = gate.getEntrances();
|
||||||
|
entrances = new Blox[space.length];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (RelativeBlockVector vector : space) {
|
||||||
|
entrances[i++] = getBlockAt(vector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entrances;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blox[] getFrame() {
|
||||||
|
if (frame == null) {
|
||||||
|
RelativeBlockVector[] border = gate.getBorder();
|
||||||
|
frame = new Blox[border.length];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (RelativeBlockVector vector : border) {
|
||||||
|
frame[i++] = getBlockAt(vector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean open(boolean force) {
|
public boolean open(boolean force) {
|
||||||
@ -157,12 +227,14 @@ public class Portal {
|
|||||||
openTime = System.currentTimeMillis() / 1000;
|
openTime = System.currentTimeMillis() / 1000;
|
||||||
Stargate.openList.add(this);
|
Stargate.openList.add(this);
|
||||||
Stargate.activeList.remove(this);
|
Stargate.activeList.remove(this);
|
||||||
|
|
||||||
// Open remote gate
|
// Open remote gate
|
||||||
if (!isAlwaysOn()) {
|
if (!isAlwaysOn()) {
|
||||||
player = openFor;
|
player = openFor;
|
||||||
|
|
||||||
Portal end = getDestination();
|
Portal end = getDestination();
|
||||||
if (end != null && !end.isAlwaysOn() && !end.isOpen()) {
|
// Only open dest if it's not-fixed or points at this gate
|
||||||
|
if (end != null && (!end.isFixed() || end.getDestinationName().equalsIgnoreCase(getName())) && !end.isOpen()) {
|
||||||
end.open(openFor, false);
|
end.open(openFor, false);
|
||||||
end.setDestination(this);
|
end.setDestination(this);
|
||||||
if (end.isVerified()) end.drawSign();
|
if (end.isVerified()) end.drawSign();
|
||||||
@ -304,36 +376,6 @@ public class Portal {
|
|||||||
return traveller;
|
return traveller;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRotation() {
|
|
||||||
return rotX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = filterName(name);
|
|
||||||
|
|
||||||
drawSign();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDestination(Portal destination) {
|
|
||||||
setDestination(destination.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDestination(String destination) {
|
|
||||||
this.destination = destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Portal getDestination() {
|
|
||||||
return Portal.getByName(destination, getNetwork());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDestinationName() {
|
|
||||||
return destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isChunkLoaded() {
|
public boolean isChunkLoaded() {
|
||||||
return getWorld().isChunkLoaded(topLeft.getBlock().getChunk());
|
return getWorld().isChunkLoaded(topLeft.getBlock().getChunk());
|
||||||
}
|
}
|
||||||
@ -356,32 +398,25 @@ public class Portal {
|
|||||||
return gate.matches(topLeft, modX, modZ);
|
return gate.matches(topLeft, modX, modZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gate getGate() {
|
|
||||||
return gate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOwner() {
|
|
||||||
return owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void activate(Player player) {
|
public void activate(Player player) {
|
||||||
destinations.clear();
|
destinations.clear();
|
||||||
destination = "";
|
destination = "";
|
||||||
drawSign();
|
drawSign();
|
||||||
Stargate.activeList.add(this);
|
Stargate.activeList.add(this);
|
||||||
activePlayer = player;
|
activePlayer = player;
|
||||||
for (String dest : allPortalsNet.get(getNetwork().toLowerCase())) {
|
String network = getNetwork();
|
||||||
Portal portal = getByName(dest, getNetwork());
|
for (String dest : allPortalsNet.get(network.toLowerCase())) {
|
||||||
|
Portal portal = getByName(dest, network);
|
||||||
// Check if dest is always open (Don't show if so)
|
// Check if dest is always open (Don't show if so)
|
||||||
if (portal.isAlwaysOn()) continue;
|
if (portal.isAlwaysOn()) continue;
|
||||||
// Check if this player can access the dest world
|
// Check if this player can access the dest world
|
||||||
if (Stargate.worldFilter && !Stargate.hasPerm(player, "stargate.world." + portal.getWorld().getName(), player.isOp())) continue;
|
if (!Stargate.canAccessWorld(player, portal.getWorld().getName())) continue;
|
||||||
// Check if dest is this portal
|
// Check if dest is this portal
|
||||||
if (dest.equalsIgnoreCase(getName())) continue;
|
if (dest.equalsIgnoreCase(getName())) continue;
|
||||||
// Check if dest is a fixed gate not pointing to this gate
|
// Check if dest is a fixed gate not pointing to this gate
|
||||||
if (portal.isFixed() && !portal.getDestinationName().equalsIgnoreCase(getName())) continue;
|
if (portal.isFixed() && !portal.getDestinationName().equalsIgnoreCase(getName())) continue;
|
||||||
// Visible to this player.
|
// Visible to this player.
|
||||||
if (!portal.isHidden() || Stargate.hasPerm(player, "stargate.hidden", player.isOp()) || portal.getOwner().equals(player.getName())) {
|
if (Stargate.canSee(player, portal)) {
|
||||||
destinations.add(portal.getName());
|
destinations.add(portal.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,7 +434,7 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return fixed || (destinations.size() > 0);
|
return isFixed() || (destinations.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getActivePlayer() {
|
public Player getActivePlayer() {
|
||||||
@ -417,6 +452,7 @@ public class Portal {
|
|||||||
public void cycleDestination(Player player) {
|
public void cycleDestination(Player player) {
|
||||||
cycleDestination(player, 1);
|
cycleDestination(player, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cycleDestination(Player player, int dir) {
|
public void cycleDestination(Player player, int dir) {
|
||||||
if (!isActive() || getActivePlayer() != player) {
|
if (!isActive() || getActivePlayer() != player) {
|
||||||
activate(player);
|
activate(player);
|
||||||
@ -458,7 +494,7 @@ public class Portal {
|
|||||||
if ((index == max) && (max > 1) && (++done <= 3)) {
|
if ((index == max) && (max > 1) && (++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 = isFree(activePlayer, dest);
|
boolean green = Stargate.isFree(activePlayer, this, dest);
|
||||||
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 2));
|
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 2));
|
||||||
} else {
|
} else {
|
||||||
id.setText(done, destinations.get(index - 2));
|
id.setText(done, destinations.get(index - 2));
|
||||||
@ -467,7 +503,7 @@ public class Portal {
|
|||||||
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 = isFree(activePlayer, dest);
|
boolean green = Stargate.isFree(activePlayer, this, dest);
|
||||||
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 1));
|
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 1));
|
||||||
} else {
|
} else {
|
||||||
id.setText(done, destinations.get(index - 1));
|
id.setText(done, destinations.get(index - 1));
|
||||||
@ -476,7 +512,7 @@ public class Portal {
|
|||||||
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 = isFree(activePlayer, dest);
|
boolean green = Stargate.isFree(activePlayer, this, dest);
|
||||||
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + " >" + destination + "< ");
|
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + " >" + destination + "< ");
|
||||||
} else {
|
} else {
|
||||||
id.setText(done, " >" + destination + "< ");
|
id.setText(done, " >" + destination + "< ");
|
||||||
@ -485,7 +521,7 @@ public class Portal {
|
|||||||
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 = isFree(activePlayer, dest);
|
boolean green = Stargate.isFree(activePlayer, this, dest);
|
||||||
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 1));
|
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 1));
|
||||||
} else {
|
} else {
|
||||||
id.setText(done, destinations.get(index + 1));
|
id.setText(done, destinations.get(index + 1));
|
||||||
@ -494,7 +530,7 @@ public class Portal {
|
|||||||
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 = isFree(activePlayer, dest);
|
boolean green = Stargate.isFree(activePlayer, this, dest);
|
||||||
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 2));
|
id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 2));
|
||||||
} else {
|
} else {
|
||||||
id.setText(done, destinations.get(index + 2));
|
id.setText(done, destinations.get(index + 2));
|
||||||
@ -510,39 +546,8 @@ public class Portal {
|
|||||||
id.update();
|
id.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Blox[] getEntrances() {
|
|
||||||
if (entrances == null) {
|
|
||||||
RelativeBlockVector[] space = gate.getEntrances();
|
|
||||||
entrances = new Blox[space.length];
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (RelativeBlockVector vector : space) {
|
|
||||||
entrances[i++] = getBlockAt(vector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entrances;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Blox[] getFrame() {
|
|
||||||
if (frame == null) {
|
|
||||||
RelativeBlockVector[] border = gate.getBorder();
|
|
||||||
frame = new Blox[border.length];
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (RelativeBlockVector vector : border) {
|
|
||||||
frame[i++] = getBlockAt(vector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
public World getWorld() {
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unregister(boolean removeAll) {
|
public void unregister(boolean removeAll) {
|
||||||
Stargate.log.info("[Stargate] Unregistering gate " + getName());
|
Stargate.debug("Unregister", "Unregistering gate " + getName());
|
||||||
close(true);
|
close(true);
|
||||||
lookupNamesNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());
|
lookupNamesNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());
|
||||||
|
|
||||||
@ -589,8 +594,10 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void register() {
|
private void register() {
|
||||||
if (!lookupNamesNet.containsKey(getNetwork().toLowerCase()))
|
if (!lookupNamesNet.containsKey(getNetwork().toLowerCase())) {
|
||||||
|
Stargate.debug("register", "Network not in lookupNamesNet, adding");
|
||||||
lookupNamesNet.put(getNetwork().toLowerCase(), new HashMap<String, Portal>());
|
lookupNamesNet.put(getNetwork().toLowerCase(), new HashMap<String, Portal>());
|
||||||
|
}
|
||||||
lookupNamesNet.get(getNetwork().toLowerCase()).put(getName().toLowerCase(), this);
|
lookupNamesNet.get(getNetwork().toLowerCase()).put(getName().toLowerCase(), this);
|
||||||
|
|
||||||
for (Blox block : getFrame()) {
|
for (Blox block : getFrame()) {
|
||||||
@ -608,18 +615,21 @@ public class Portal {
|
|||||||
|
|
||||||
allPortals.add(this);
|
allPortals.add(this);
|
||||||
// Check if this network exists
|
// Check if this network exists
|
||||||
if (!allPortalsNet.containsKey(getNetwork().toLowerCase()))
|
if (!allPortalsNet.containsKey(getNetwork().toLowerCase())) {
|
||||||
|
Stargate.debug("register", "Network not in allPortalsNet, adding");
|
||||||
allPortalsNet.put(getNetwork().toLowerCase(), new ArrayList<String>());
|
allPortalsNet.put(getNetwork().toLowerCase(), new ArrayList<String>());
|
||||||
|
}
|
||||||
allPortalsNet.get(getNetwork().toLowerCase()).add(getName().toLowerCase());
|
allPortalsNet.get(getNetwork().toLowerCase()).add(getName().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Portal createPortal(SignPost id, Player player) {
|
public static Portal createPortal(SignPost id, Player player) {
|
||||||
Block idParent = id.getParent();
|
Block idParent = id.getParent();
|
||||||
if (idParent == null) {
|
if (idParent == null) {
|
||||||
Stargate.debug("createPortal", "idParent == null");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Gate.getGatesByControlBlock(idParent).length == 0) return null;
|
if (Gate.getGatesByControlBlock(idParent).length == 0) return null;
|
||||||
|
|
||||||
if (Portal.getByBlock(idParent) != null) {
|
if (Portal.getByBlock(idParent) != null) {
|
||||||
Stargate.debug("createPortal", "idParent belongs to existing gate");
|
Stargate.debug("createPortal", "idParent belongs to existing gate");
|
||||||
return null;
|
return null;
|
||||||
@ -638,60 +648,18 @@ public class Portal {
|
|||||||
boolean backwards = (options.indexOf('b') != -1 || options.indexOf('B') != -1);
|
boolean backwards = (options.indexOf('b') != -1 || options.indexOf('B') != -1);
|
||||||
|
|
||||||
// Check permissions for options.
|
// Check permissions for options.
|
||||||
if (!Stargate.hasPerm(player, "stargate.option.hidden", player.isOp())) hidden = false;
|
if (!Stargate.canOption(player, "hidden")) hidden = false;
|
||||||
if (!Stargate.hasPerm(player, "stargate.option.alwayson", player.isOp())) alwaysOn = false;
|
if (!Stargate.canOption(player, "alwayson")) alwaysOn = false;
|
||||||
if (!Stargate.hasPerm(player, "stargate.option.private", player.isOp())) priv = false;
|
if (!Stargate.canOption(player, "private")) priv = false;
|
||||||
if (!Stargate.hasPerm(player, "stargate.option.free", player.isOp())) free = false;
|
if (!Stargate.canOption(player, "free")) free = false;
|
||||||
if (!Stargate.hasPerm(player, "stargate.option.backwards", player.isOp())) backwards = false;
|
if (!Stargate.canOption(player, "backwards")) backwards = false;
|
||||||
|
|
||||||
// Can not create a non-fixed always-on gate.
|
// Can not create a non-fixed always-on gate.
|
||||||
if (alwaysOn && destName.length() == 0) {
|
if (alwaysOn && destName.length() == 0) {
|
||||||
alwaysOn = false;
|
alwaysOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug
|
// Moved the layout check so as to avoid invalid messages when not making a gate
|
||||||
Stargate.debug("createPortal", "h = " + hidden + " a = " + alwaysOn + " p = " + priv + " f = " + free + " b = " + backwards);
|
|
||||||
|
|
||||||
if ((network.length() < 1) || (network.length() > 11)) {
|
|
||||||
network = Stargate.getDefaultNetwork();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((name.length() < 1) || (name.length() > 11) || (getByName(name, network) != null)) {
|
|
||||||
Stargate.debug("createPortal", "Name Error");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the user can only create personal gates, set network if so
|
|
||||||
boolean createPersonal = false;
|
|
||||||
if (Stargate.hasPerm(player, "stargate.create.personal", false) &&
|
|
||||||
!Stargate.hasPerm(player, "stargate.create", player.isOp()) ) {
|
|
||||||
network = player.getName();
|
|
||||||
if (network.length() > 11) network = network.substring(0, 11);
|
|
||||||
createPersonal = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if there are too many gates in this network
|
|
||||||
ArrayList<String> netList = allPortalsNet.get(network);
|
|
||||||
if (Stargate.maxGates > 0 && netList != null && netList.size() >= Stargate.maxGates) {
|
|
||||||
player.sendMessage(ChatColor.RED + "[Stargate]" + ChatColor.WHITE + " This network is full.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the user can create gates on this network.
|
|
||||||
if (!createPersonal && !Stargate.hasPerm(player, "stargate.network." + network, player.isOp())) {
|
|
||||||
player.sendMessage(ChatColor.RED + "[Stargate]" + ChatColor.WHITE + " You don't have access to that network");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the user can create gates to this world.
|
|
||||||
if (destName.length() != 0) {
|
|
||||||
Portal d = Portal.getByName(destName, network);
|
|
||||||
if (d != null && !Stargate.hasPerm(player, "stargate.world." + d.getWorld().getName(), player.isOp())) {
|
|
||||||
player.sendMessage(ChatColor.RED + "[Stargate]" + ChatColor.WHITE + " You don't have access to that world");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int modX = 0;
|
int modX = 0;
|
||||||
int modZ = 0;
|
int modZ = 0;
|
||||||
float rotX = 0f;
|
float rotX = 0f;
|
||||||
@ -750,6 +718,62 @@ public class Portal {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug
|
||||||
|
Stargate.debug("createPortal", "h = " + hidden + " a = " + alwaysOn + " p = " + priv + " f = " + free + " b = " + backwards);
|
||||||
|
|
||||||
|
if ((network.length() < 1) || (network.length() > 11)) {
|
||||||
|
Stargate.debug("createPortal", "Network name too long. Shortening");
|
||||||
|
network = Stargate.getDefaultNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the player can create gates on this network
|
||||||
|
if (!Stargate.canCreate(player, network)) {
|
||||||
|
Stargate.debug("createPortal", "Player doesn't have create permissions on network. Trying personal");
|
||||||
|
network = player.getName().substring(0, 11);
|
||||||
|
|
||||||
|
// Check if we can create a gate on our own network
|
||||||
|
if (!Stargate.canCreate(player, network)) {
|
||||||
|
Stargate.debug("createPortal", "Player does not have access to network");
|
||||||
|
Stargate.sendMessage(player, "You do not have access to that network");
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
Stargate.debug("createPortal", "Creating personal portal");
|
||||||
|
Stargate.sendMessage(player, "Creating gate on personal network");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.length() < 1 || name.length() > 11) {
|
||||||
|
Stargate.debug("createPortal", "Name length error");
|
||||||
|
Stargate.sendMessage(player, "Name too short or too long.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getByName(name, network) != null) {
|
||||||
|
Stargate.debug("createPortal", "Name Error");
|
||||||
|
Stargate.sendMessage(player, "A gate by that name already exists!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if there are too many gates in this network
|
||||||
|
ArrayList<String> netList = allPortalsNet.get(network.toLowerCase());
|
||||||
|
if (Stargate.maxGates > 0 && netList != null && netList.size() >= Stargate.maxGates) {
|
||||||
|
Stargate.sendMessage(player, "This network is full.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the user can create gates to this world.
|
||||||
|
if (destName.length() > 0) {
|
||||||
|
Portal p = Portal.getByName(destName, network);
|
||||||
|
if (p != null) {
|
||||||
|
String world = p.getWorld().getName();
|
||||||
|
if (!Stargate.canAccessWorld(player, world)) {
|
||||||
|
Stargate.debug("canCreate", "Player does not have access to destination world");
|
||||||
|
Stargate.sendMessage(player, "You do not have access to that world.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bleh, gotta check to make sure none of this gate belongs to another gate. Boo slow.
|
// Bleh, gotta check to make sure none of this gate belongs to another gate. Boo slow.
|
||||||
for (RelativeBlockVector v : gate.getBorder()) {
|
for (RelativeBlockVector v : gate.getBorder()) {
|
||||||
Blox b = topleft.modRelative(v.getRight(), v.getDepth(), v.getDistance(), modX, 1, modZ);
|
Blox b = topleft.modRelative(v.getRight(), v.getDepth(), v.getDistance(), modX, 1, modZ);
|
||||||
@ -759,15 +783,9 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iConomyHandler.useiConomy() && !Stargate.hasPerm(player, "stargate.free.create", player.isOp())) {
|
if (!Stargate.chargePlayer(player, null, "create", gate.getCreateCost())) {
|
||||||
if (!iConomyHandler.chargePlayer(player.getName(), null, gate.getCreateCost())) {
|
Stargate.debug("createPortal", "Insufficient Funds");
|
||||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
return null;
|
||||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (gate.getCreateCost() > 0)
|
|
||||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomyHandler.format(gate.getCreateCost()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Portal portal = null;
|
Portal portal = null;
|
||||||
|
@ -83,11 +83,9 @@ public class Stargate extends JavaPlugin {
|
|||||||
private static String blockMsg = "Destination Blocked";
|
private static String blockMsg = "Destination Blocked";
|
||||||
private static String defNetwork = "central";
|
private static String defNetwork = "central";
|
||||||
private static boolean destroyExplosion = false;
|
private static boolean destroyExplosion = false;
|
||||||
public static boolean networkFilter = false;
|
|
||||||
public static boolean worldFilter = false;
|
|
||||||
public static int maxGates = 0;
|
public static int maxGates = 0;
|
||||||
private static int activeLimit = 10;
|
private static int activeTime = 10;
|
||||||
private static int openLimit = 10;
|
private static int openTime = 10;
|
||||||
|
|
||||||
// Used for debug
|
// Used for debug
|
||||||
private static boolean debug = false;
|
private static boolean debug = false;
|
||||||
@ -162,8 +160,6 @@ public class Stargate extends JavaPlugin {
|
|||||||
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);
|
||||||
networkFilter = config.getBoolean("networkfilter", networkFilter);
|
|
||||||
worldFilter = config.getBoolean("worldfilter", worldFilter);
|
|
||||||
maxGates = config.getInt("maxgates", maxGates);
|
maxGates = config.getInt("maxgates", maxGates);
|
||||||
// Debug
|
// Debug
|
||||||
debug = config.getBoolean("debug", debug);
|
debug = config.getBoolean("debug", debug);
|
||||||
@ -191,8 +187,6 @@ public class Stargate extends JavaPlugin {
|
|||||||
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);
|
||||||
config.setProperty("networkfilter", networkFilter);
|
|
||||||
config.setProperty("worldfilter", worldFilter);
|
|
||||||
config.setProperty("maxgates", maxGates);
|
config.setProperty("maxgates", maxGates);
|
||||||
// iConomy
|
// iConomy
|
||||||
config.setProperty("useiconomy", iConomyHandler.useiConomy);
|
config.setProperty("useiconomy", iConomyHandler.useiConomy);
|
||||||
@ -256,6 +250,18 @@ public class Stargate extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendMessage(Player player, String message) {
|
||||||
|
sendMessage(player, message, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendMessage(Player player, String message, boolean error) {
|
||||||
|
if (message.isEmpty()) return;
|
||||||
|
if (error)
|
||||||
|
player.sendMessage(ChatColor.RED + "[Stargate] " + ChatColor.WHITE + message);
|
||||||
|
else
|
||||||
|
player.sendMessage(ChatColor.GREEN + "[Stargate] " + ChatColor.WHITE + message);
|
||||||
|
}
|
||||||
|
|
||||||
public static String getSaveLocation() {
|
public static String getSaveLocation() {
|
||||||
return portalFolder;
|
return portalFolder;
|
||||||
}
|
}
|
||||||
@ -264,46 +270,197 @@ public class Stargate extends JavaPlugin {
|
|||||||
return defNetwork;
|
return defNetwork;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onButtonPressed(Player player, Portal gate) {
|
private void onButtonPressed(Player player, Portal portal) {
|
||||||
Portal destination = gate.getDestination();
|
Portal destination = portal.getDestination();
|
||||||
|
|
||||||
if (!gate.isOpen()) {
|
// Always-open gate -- Do nothing
|
||||||
if ((!gate.isFixed()) && gate.isActive() && (gate.getActivePlayer() != player)) {
|
if (portal.isAlwaysOn()) {
|
||||||
gate.deactivate();
|
return;
|
||||||
if (!denyMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
|
||||||
}
|
|
||||||
} else if (gate.isPrivate() && !gate.getOwner().equals(player.getName()) && !hasPerm(player, "stargate.private", player.isOp())) {
|
|
||||||
if (!denyMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
|
||||||
}
|
|
||||||
} else if ((destination == null) || (destination == gate)) {
|
|
||||||
if (!invMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + invMsg);
|
|
||||||
}
|
|
||||||
} else if ((destination.isOpen()) && (!destination.isAlwaysOn())) {
|
|
||||||
if (!blockMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + blockMsg);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
gate.open(player, false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
gate.close(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Invalid destination
|
||||||
|
if ((destination == null) || (destination == portal)) {
|
||||||
|
Stargate.sendMessage(player, invMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gate is already open
|
||||||
|
if (portal.isOpen()) {
|
||||||
|
// Close if this player opened the gate
|
||||||
|
if (portal.getActivePlayer() == player) {
|
||||||
|
portal.close(false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gate that someone else is using -- Deny access
|
||||||
|
if ((!portal.isFixed()) && portal.isActive() && (portal.getActivePlayer() != player)) {
|
||||||
|
Stargate.sendMessage(player, denyMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the player can use the private gate
|
||||||
|
if (portal.isPrivate() && !Stargate.canPrivate(player, portal)) {
|
||||||
|
Stargate.sendMessage(player, denyMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destination blocked
|
||||||
|
if ((destination.isOpen()) && (!destination.isAlwaysOn())) {
|
||||||
|
Stargate.sendMessage(player, blockMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open gate
|
||||||
|
portal.open(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check whether the player has the given permissions.
|
* Check whether the player has the given permissions.
|
||||||
*/
|
*/
|
||||||
public static boolean hasPerm(Player player, String perm, boolean def) {
|
public static boolean hasPerm(Player player, String perm) {
|
||||||
if (permissions != null) {
|
if (permissions != null) {
|
||||||
return permissions.getHandler().has(player, perm);
|
return permissions.getHandler().has(player, perm);
|
||||||
} else {
|
} else {
|
||||||
return def;
|
return player.hasPermission(perm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether player can teleport to dest world
|
||||||
|
*/
|
||||||
|
public static boolean canAccessWorld(Player player, String world) {
|
||||||
|
// Can use all Stargate player features
|
||||||
|
if (hasPerm(player, "stargate.use")) return true;
|
||||||
|
// Can access all worlds
|
||||||
|
if (hasPerm(player, "stargate.world")) return true;
|
||||||
|
// Can access dest world
|
||||||
|
if (hasPerm(player, "stargate.world." + world)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether player can use network
|
||||||
|
*/
|
||||||
|
public static boolean canAccessNetwork(Player player, String network) {
|
||||||
|
// Can use all Stargate player features
|
||||||
|
if (hasPerm(player, "stargate.use")) return true;
|
||||||
|
// Can access all networks
|
||||||
|
if (hasPerm(player, "stargate.network")) return true;
|
||||||
|
// Can access this network
|
||||||
|
if (hasPerm(player, "stargate.network." + network)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return true if the portal is free for the player
|
||||||
|
*/
|
||||||
|
public static boolean isFree(Player player, Portal src, Portal dest) {
|
||||||
|
// This gate is free
|
||||||
|
if (src.isFree()) return true;
|
||||||
|
// Player gets free use
|
||||||
|
if (hasPerm(player, "stargate.free") || Stargate.hasPerm(player, "stargate.free.use")) return true;
|
||||||
|
// Don't charge for free destination gates
|
||||||
|
if (!iConomyHandler.chargeFreeDestination && dest.isFree()) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether the player can see this gate (Hidden property check)
|
||||||
|
*/
|
||||||
|
public static boolean canSee(Player player, Portal portal) {
|
||||||
|
// The gate is not hidden
|
||||||
|
if (!portal.isHidden()) return true;
|
||||||
|
// The player is an admin with the ability to see hidden gates
|
||||||
|
if (hasPerm(player, "stargate.admin") || hasPerm(player, "stargate.admin.hidden")) return true;
|
||||||
|
// The player is the owner of the gate
|
||||||
|
if (portal.getOwner().equalsIgnoreCase(player.getName())) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the player can use this private gate
|
||||||
|
*/
|
||||||
|
public static boolean canPrivate(Player player, Portal portal) {
|
||||||
|
// Check if the player is the owner of the gate
|
||||||
|
if (portal.getOwner().equalsIgnoreCase(player.getName())) return true;
|
||||||
|
// The player is an admin with the ability to use private gates
|
||||||
|
if (hasPerm(player, "stargate.admin") || hasPerm(player, "stargate.admin.private")) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the player has access to {option}
|
||||||
|
*/
|
||||||
|
public static boolean canOption(Player player, String option) {
|
||||||
|
// Check if the player can use all options
|
||||||
|
if (hasPerm(player, "stargate.option")) return true;
|
||||||
|
// Check if they can use this specific option
|
||||||
|
if (hasPerm(player, "stargate.option." + option)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the player can create gates on {network}
|
||||||
|
*/
|
||||||
|
public static boolean canCreate(Player player, String network) {
|
||||||
|
// Check for general create
|
||||||
|
if (hasPerm(player, "stargate.create")) return true;
|
||||||
|
// Check for all network create permission
|
||||||
|
if (hasPerm(player, "stargate.create.network")) return true;
|
||||||
|
// Check for this specific network
|
||||||
|
if (hasPerm(player, "stargate.create.network." + network)) return true;
|
||||||
|
|
||||||
|
// Check if this is a personal gate, and if the player has create.personal
|
||||||
|
if (player.getName().substring(0, 11).equalsIgnoreCase(network) && hasPerm(player, "stargate.create.personal")) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the player can destroy this gate
|
||||||
|
*/
|
||||||
|
public static boolean canDestroy(Player player, Portal portal) {
|
||||||
|
// Check for general destroy
|
||||||
|
if (hasPerm(player, "stargate.destroy")) return true;
|
||||||
|
// Check for all network destroy permission
|
||||||
|
if (hasPerm(player, "stargate.destroy.network")) return true;
|
||||||
|
// Check for this specific network
|
||||||
|
if (hasPerm(player, "stargate.destroy.network." + portal.getNetwork())) return true;
|
||||||
|
// Check for personal gate
|
||||||
|
if (player.getName().equalsIgnoreCase(portal.getOwner()) && hasPerm(player, "stargate.destroy.personal")) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Charge player for {action} if required, true on success, false if can't afford
|
||||||
|
*/
|
||||||
|
public static boolean chargePlayer(Player player, String target, String action, int cost) {
|
||||||
|
// If cost is 0
|
||||||
|
if (cost <= 0) return true;
|
||||||
|
// iConomy is disabled
|
||||||
|
if (!iConomyHandler.useiConomy()) return true;
|
||||||
|
// Player gets free {action}
|
||||||
|
if (hasPerm(player, "stargate.free") || hasPerm(player, "stargate.free." + action)) return true;
|
||||||
|
// Charge player
|
||||||
|
return iConomyHandler.chargePlayer(player.getName(), target, cost);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine the cost of a gate
|
||||||
|
*/
|
||||||
|
public static int getUseCost(Player player, Portal src, Portal dest) {
|
||||||
|
// Not using iConomy
|
||||||
|
if (!iConomyHandler.useiConomy()) return 0;
|
||||||
|
// Portal is free
|
||||||
|
if (src.isFree()) return 0;
|
||||||
|
// Not charging for free destinations
|
||||||
|
if (!iConomyHandler.chargeFreeDestination && dest.isFree()) return 0;
|
||||||
|
// Cost is 0 if the player owns this gate and funds go to the owner
|
||||||
|
if (src.getGate().getToOwner() && src.getOwner().equalsIgnoreCase(player.getName())) return 0;
|
||||||
|
|
||||||
|
return src.getGate().getUseCost();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if a plugin is loaded/enabled already. Returns the plugin if so, null otherwise
|
* Check if a plugin is loaded/enabled already. Returns the plugin if so, null otherwise
|
||||||
*/
|
*/
|
||||||
@ -332,46 +489,46 @@ public class Stargate extends JavaPlugin {
|
|||||||
if (passenger instanceof Player) {
|
if (passenger instanceof Player) {
|
||||||
Player player = (Player)passenger;
|
Player player = (Player)passenger;
|
||||||
if (!portal.isOpenFor(player)) {
|
if (!portal.isOpenFor(player)) {
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
Stargate.sendMessage(player, denyMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Portal dest = portal.getDestination();
|
Portal dest = portal.getDestination();
|
||||||
if (dest == null) return;
|
if (dest == null) return;
|
||||||
|
// Check if player has access to this network
|
||||||
if ((networkFilter && !hasPerm(player, "stargate.network." + portal.getNetwork(), player.isOp())) ||
|
if (!canAccessNetwork(player, portal.getNetwork())) {
|
||||||
(worldFilter && !hasPerm(player, "stargate.world." + portal.getDestination().getWorld().getName(), player.isOp()))) {
|
Stargate.sendMessage(player, denyMsg);
|
||||||
if (!denyMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
|
||||||
}
|
|
||||||
portal.close(false);
|
portal.close(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean iConCharge = (iConomyHandler.useiConomy() && !portal.isFree() && !hasPerm(player, "stargate.free.use", player.isOp()));
|
// Check if player has access to destination world
|
||||||
if (!iConomyHandler.chargeFreeDestination)
|
if (!canAccessWorld(player, dest.getWorld().getName())) {
|
||||||
iConCharge = iConCharge && !dest.isFree();
|
Stargate.sendMessage(player, denyMsg);
|
||||||
|
portal.close(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String target = (portal.getGate().getToOwner() ? portal.getOwner() : null);
|
int cost = Stargate.getUseCost(player, portal, dest);
|
||||||
if (target != null)
|
if (cost > 0) {
|
||||||
iConCharge = iConCharge && !target.equals(player.getName());
|
String target = portal.getGate().getToOwner() ? portal.getOwner() : null;
|
||||||
|
if (!Stargate.chargePlayer(player, target, "use", cost)) {
|
||||||
if (!iConCharge || iConomyHandler.chargePlayer(player.getName(), target, portal.getGate().getUseCost())) {
|
// Insufficient Funds
|
||||||
if (iConCharge && portal.getGate().getUseCost() > 0) {
|
Stargate.sendMessage(player, "Insufficient Funds");
|
||||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomyHandler.format(portal.getGate().getUseCost()));
|
portal.close(false);
|
||||||
|
return;
|
||||||
Player p = server.getPlayer(portal.getOwner());
|
|
||||||
if (portal.getGate().getToOwner() && p != null)
|
|
||||||
p.sendMessage(ChatColor.GREEN + "Obtained " + iConomyHandler.format(portal.getGate().getUseCost()) + " from Stargate " + portal.getName());
|
|
||||||
}
|
}
|
||||||
if (!teleMsg.isEmpty()) {
|
sendMessage(player, "Deducted " + iConomyHandler.format(cost), false);
|
||||||
player.sendMessage(ChatColor.BLUE + teleMsg);
|
if (target != null) {
|
||||||
}
|
Player p = server.getPlayer(target);
|
||||||
dest.teleport(vehicle);
|
if (p != null) {
|
||||||
} else {
|
Stargate.sendMessage(p, "Obtained " + iConomyHandler.format(cost) + " from Stargate " + portal.getName(), false);
|
||||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
}
|
||||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stargate.sendMessage(player, teleMsg, false);
|
||||||
|
dest.teleport(vehicle);
|
||||||
portal.close(false);
|
portal.close(false);
|
||||||
} else {
|
} else {
|
||||||
Portal dest = portal.getDestination();
|
Portal dest = portal.getDestination();
|
||||||
@ -403,62 +560,64 @@ public class Stargate extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Portal portal = Portal.getByEntrance(event.getTo());
|
Portal portal = Portal.getByEntrance(event.getTo());
|
||||||
|
|
||||||
if ((portal != null) && (portal.isOpen())) {
|
// No portal or not open
|
||||||
if (!portal.isOpenFor(player)) {
|
if (portal == null || !portal.isOpen()) return;
|
||||||
if (!denyMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
// Not open for this player
|
||||||
}
|
if (!portal.isOpenFor(player)) {
|
||||||
portal.teleport(player, portal, event);
|
if (!denyMsg.isEmpty()) {
|
||||||
return;
|
Stargate.sendMessage(player, denyMsg);
|
||||||
}
|
}
|
||||||
|
portal.teleport(player, portal, event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Portal destination = portal.getDestination();
|
Portal destination = portal.getDestination();
|
||||||
if (destination == null) return;
|
if (destination == null) return;
|
||||||
|
|
||||||
if ((networkFilter && !hasPerm(player, "stargate.network." + portal.getNetwork(), player.isOp())) ||
|
// Check if player has access to this network
|
||||||
(worldFilter && !hasPerm(player, "stargate.world." + portal.getDestination().getWorld().getName(), player.isOp()))) {
|
if (!canAccessNetwork(player, portal.getNetwork())) {
|
||||||
if (!denyMsg.isEmpty()) {
|
Stargate.sendMessage(player, denyMsg);
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
portal.teleport(player, portal, event);
|
||||||
}
|
portal.close(false);
|
||||||
portal.teleport(player, portal, event);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if player has access to destination world
|
||||||
|
if (!canAccessWorld(player, destination.getWorld().getName())) {
|
||||||
|
Stargate.sendMessage(player, denyMsg);
|
||||||
|
portal.teleport(player, portal, event);
|
||||||
|
portal.close(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cost = Stargate.getUseCost(player, portal, destination);
|
||||||
|
if (cost > 0) {
|
||||||
|
String target = portal.getGate().getToOwner() ? portal.getOwner() : null;
|
||||||
|
if (!Stargate.chargePlayer(player, target, "use", cost)) {
|
||||||
|
// Insufficient Funds
|
||||||
|
Stargate.sendMessage(player, "Insufficient Funds");
|
||||||
portal.close(false);
|
portal.close(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sendMessage(player, "Deducted " + iConomyHandler.format(cost), false);
|
||||||
boolean iConCharge = (iConomyHandler.useiConomy() && !portal.isFree() && !hasPerm(player, "stargate.free.use", player.isOp()));
|
if (target != null) {
|
||||||
if (!iConomyHandler.chargeFreeDestination)
|
Player p = server.getPlayer(target);
|
||||||
iConCharge = iConCharge && !destination.isFree();
|
if (p != null) {
|
||||||
|
Stargate.sendMessage(p, "Obtained " + iConomyHandler.format(cost) + " from Stargate " + portal.getName(), false);
|
||||||
String target = (portal.getGate().getToOwner() ? portal.getOwner() : null);
|
|
||||||
if (target != null)
|
|
||||||
iConCharge = iConCharge && !target.equals(player.getName());
|
|
||||||
|
|
||||||
if (!iConCharge || iConomyHandler.chargePlayer(player.getName(), target, portal.getGate().getUseCost())) {
|
|
||||||
if (iConCharge && portal.getGate().getUseCost() > 0) {
|
|
||||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomyHandler.format(portal.getGate().getUseCost()));
|
|
||||||
|
|
||||||
Player p = server.getPlayer(portal.getOwner());
|
|
||||||
if (portal.getGate().getToOwner() && p != null) {
|
|
||||||
p.sendMessage(ChatColor.GREEN + "Obtained " + iConomyHandler.format(portal.getGate().getUseCost()) + " from Stargate " + portal.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!teleMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.BLUE + teleMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
destination.teleport(player, portal, event);
|
|
||||||
} else {
|
|
||||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
portal.close(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stargate.sendMessage(player, teleMsg);
|
||||||
|
destination.teleport(player, portal, event);
|
||||||
|
portal.close(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -470,33 +629,33 @@ public class Stargate extends JavaPlugin {
|
|||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
if (block.getType() == Material.WALL_SIGN) {
|
if (block.getType() == Material.WALL_SIGN) {
|
||||||
Portal portal = Portal.getByBlock(block);
|
Portal portal = Portal.getByBlock(block);
|
||||||
// Cycle through a stargates locations
|
if (portal == null) return;
|
||||||
if (portal != null) {
|
// Cancel item use
|
||||||
event.setUseItemInHand(Result.DENY);
|
event.setUseItemInHand(Result.DENY);
|
||||||
event.setUseInteractedBlock(Result.DENY);
|
event.setUseInteractedBlock(Result.DENY);
|
||||||
if (!hasPerm(player, "stargate.use", true) ||
|
|
||||||
(networkFilter && !hasPerm(player, "stargate.network." + portal.getNetwork(), player.isOp()))) {
|
|
||||||
if (!denyMsg.isEmpty()) {
|
|
||||||
player.sendMessage(denyMsg);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||||
portal.cycleDestination(player);
|
Stargate.sendMessage(player, denyMsg);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
||||||
|
portal.cycleDestination(player);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement right-click to toggle a stargate, gets around spawn protection problem.
|
// Implement right-click to toggle a stargate, gets around spawn protection problem.
|
||||||
if ((block.getType() == Material.STONE_BUTTON)) {
|
if ((block.getType() == Material.STONE_BUTTON)) {
|
||||||
if (hasPerm(player, "stargate.use", true)) {
|
Portal portal = Portal.getByBlock(block);
|
||||||
Portal portal = Portal.getByBlock(block);
|
if (portal == null) return;
|
||||||
if (portal != null) {
|
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||||
onButtonPressed(player, portal);
|
Stargate.sendMessage(player, denyMsg);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
onButtonPressed(player, portal);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Left click
|
// Left click
|
||||||
@ -504,29 +663,31 @@ public class Stargate extends JavaPlugin {
|
|||||||
// Check if we're scrolling a sign
|
// Check if we're scrolling a sign
|
||||||
if (block.getType() == Material.WALL_SIGN) {
|
if (block.getType() == Material.WALL_SIGN) {
|
||||||
Portal portal = Portal.getByBlock(block);
|
Portal portal = Portal.getByBlock(block);
|
||||||
// Cycle through a stargates locations
|
if (portal == null) return;
|
||||||
if (portal != null) {
|
// Cancel item use
|
||||||
if (!hasPerm(player, "stargate.use", true) ||
|
event.setUseItemInHand(Result.DENY);
|
||||||
(networkFilter && !hasPerm(player, "stargate.network." + portal.getNetwork(), player.isOp()))) {
|
event.setUseInteractedBlock(Result.DENY);
|
||||||
if (!denyMsg.isEmpty()) {
|
|
||||||
player.sendMessage(denyMsg);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||||
portal.cycleDestination(player, -1);
|
Stargate.sendMessage(player, denyMsg);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
||||||
|
portal.cycleDestination(player, -1);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we're pushing a button.
|
// Check if we're pushing a button.
|
||||||
if (block.getType() == Material.STONE_BUTTON) {
|
if (block.getType() == Material.STONE_BUTTON) {
|
||||||
if (hasPerm(player, "stargate.use", true)) {
|
Portal portal = Portal.getByBlock(block);
|
||||||
Portal portal = Portal.getByBlock(block);
|
if (portal == null) return;
|
||||||
if (portal != null) {
|
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||||
onButtonPressed(player, portal);
|
Stargate.sendMessage(player, denyMsg);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
onButtonPressed(player, portal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,34 +700,25 @@ public class Stargate extends JavaPlugin {
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (block.getType() != Material.WALL_SIGN) return;
|
if (block.getType() != Material.WALL_SIGN) return;
|
||||||
|
|
||||||
// Initialize a stargate
|
// Initialize a stargate -- Permission check is done in createPortal
|
||||||
if (hasPerm(player, "stargate.create", player.isOp()) ||
|
SignPost sign = new SignPost(new Blox(block));
|
||||||
hasPerm(player, "stargate.create.personal", false)) {
|
// Set sign text so we can create a gate with it.
|
||||||
SignPost sign = new SignPost(new Blox(block));
|
sign.setText(0, event.getLine(0));
|
||||||
// Set sign text so we can create a gate with it.
|
sign.setText(1, event.getLine(1));
|
||||||
sign.setText(0, event.getLine(0));
|
sign.setText(2, event.getLine(2));
|
||||||
sign.setText(1, event.getLine(1));
|
sign.setText(3, event.getLine(3));
|
||||||
sign.setText(2, event.getLine(2));
|
Portal portal = Portal.createPortal(sign, player);
|
||||||
sign.setText(3, event.getLine(3));
|
// Not creating a gate, just placing a sign
|
||||||
Portal portal = Portal.createPortal(sign, player);
|
if (portal == null) return;
|
||||||
if (portal == null) {
|
|
||||||
Stargate.debug("SignChange", "createPortal returned null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!regMsg.isEmpty()) {
|
Stargate.sendMessage(player, regMsg, false);
|
||||||
player.sendMessage(ChatColor.GREEN + regMsg);
|
Stargate.debug("onSignChange", "Initialized stargate: " + portal.getName());
|
||||||
}
|
portal.drawSign();
|
||||||
log.info("[Stargate] Initialized stargate: " + portal.getName());
|
// Set event text so our new sign is instantly initialized
|
||||||
portal.drawSign();
|
event.setLine(0, sign.getText(0));
|
||||||
// Set event text so our new sign is instantly initialized
|
event.setLine(1, sign.getText(1));
|
||||||
event.setLine(0, sign.getText(0));
|
event.setLine(2, sign.getText(2));
|
||||||
event.setLine(1, sign.getText(1));
|
event.setLine(3, sign.getText(3));
|
||||||
event.setLine(2, sign.getText(2));
|
|
||||||
event.setLine(3, sign.getText(3));
|
|
||||||
} else {
|
|
||||||
Stargate.debug("SignChange", player.getName() + " tried to create gate without permissions");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -581,33 +733,27 @@ public class Stargate extends JavaPlugin {
|
|||||||
Portal portal = Portal.getByBlock(block);
|
Portal portal = Portal.getByBlock(block);
|
||||||
if (portal == null) return;
|
if (portal == null) return;
|
||||||
|
|
||||||
if (hasPerm(player, "stargate.destroy", player.isOp()) || hasPerm(player, "stargate.destroy.all", player.isOp()) ||
|
if (!Stargate.canDestroy(player, portal)) {
|
||||||
( portal.getOwner().equalsIgnoreCase(player.getName()) && hasPerm(player, "stargate.destroy.owner", false) )) {
|
Stargate.sendMessage(player, "Permission Denied");
|
||||||
// Can't afford
|
event.setCancelled(true);
|
||||||
if (iConomyHandler.useiConomy() && !hasPerm(player, "stargate.free.destroy", player.isOp())) {
|
|
||||||
if (!iConomyHandler.chargePlayer(player.getName(), null, portal.getGate().getDestroyCost())) {
|
|
||||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
|
||||||
}
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (portal.getGate().getDestroyCost() > 0) {
|
|
||||||
player.sendMessage(ChatColor.GREEN + "Deducted " + iConomyHandler.format(portal.getGate().getDestroyCost()));
|
|
||||||
} else if (portal.getGate().getDestroyCost() < 0) {
|
|
||||||
player.sendMessage(ChatColor.GREEN + "Refunded " + iConomyHandler.format(-portal.getGate().getDestroyCost()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
portal.unregister(true);
|
|
||||||
if (!dmgMsg.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + dmgMsg);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
if (!Stargate.chargePlayer(player, null, "destroy", portal.getGate().getDestroyCost())) {
|
||||||
|
Stargate.debug("onBlockBreak", "Insufficient Funds");
|
||||||
|
Stargate.sendMessage(player, iConomyHandler.inFundMsg);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (portal.getGate().getDestroyCost() > 0) {
|
||||||
|
Stargate.sendMessage(player, "Deducted " + iConomyHandler.format(portal.getGate().getDestroyCost()), false);
|
||||||
|
} else if (portal.getGate().getDestroyCost() < 0) {
|
||||||
|
Stargate.sendMessage(player, "Refunded " + iConomyHandler.format(-portal.getGate().getDestroyCost()), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
portal.unregister(true);
|
||||||
|
Stargate.sendMessage(player, dmgMsg, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -773,7 +919,9 @@ public class Stargate extends JavaPlugin {
|
|||||||
// Close open portals
|
// Close open portals
|
||||||
for (Iterator<Portal> iter = Stargate.openList.iterator(); iter.hasNext();) {
|
for (Iterator<Portal> iter = Stargate.openList.iterator(); iter.hasNext();) {
|
||||||
Portal p = iter.next();
|
Portal p = iter.next();
|
||||||
if (time > p.getOpenTime() + Stargate.openLimit) {
|
// Skip always open gates
|
||||||
|
if (p.isAlwaysOn()) continue;
|
||||||
|
if (time > p.getOpenTime() + Stargate.openTime) {
|
||||||
p.close(false);
|
p.close(false);
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
@ -781,7 +929,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
// Deactivate active portals
|
// Deactivate active portals
|
||||||
for (Iterator<Portal> iter = Stargate.activeList.iterator(); iter.hasNext();) {
|
for (Iterator<Portal> iter = Stargate.activeList.iterator(); iter.hasNext();) {
|
||||||
Portal p = iter.next();
|
Portal p = iter.next();
|
||||||
if (time > p.getOpenTime() + Stargate.activeLimit) {
|
if (time > p.getOpenTime() + Stargate.activeTime) {
|
||||||
p.deactivate();
|
p.deactivate();
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
@ -792,7 +940,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
sender.sendMessage("Permission Denied");
|
Stargate.sendMessage((Player)sender, "Permission Denied");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String cmd = command.getName();
|
String cmd = command.getName();
|
||||||
|
@ -26,7 +26,7 @@ public class iConomyHandler {
|
|||||||
if (useiConomy && iconomy != null) {
|
if (useiConomy && iconomy != null) {
|
||||||
Account acc = iConomy.getAccount(player);
|
Account acc = iConomy.getAccount(player);
|
||||||
if (acc == null) {
|
if (acc == null) {
|
||||||
Stargate.log.info("[" + pName + "::ich::getBalance] Error fetching iConomy account for " + player);
|
Stargate.debug("ich::getBalance", "Error fetching iConomy account for " + player);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return acc.getHoldings().balance();
|
return acc.getHoldings().balance();
|
||||||
@ -41,7 +41,7 @@ public class iConomyHandler {
|
|||||||
|
|
||||||
Account acc = iConomy.getAccount(player);
|
Account acc = iConomy.getAccount(player);
|
||||||
if (acc == null) {
|
if (acc == null) {
|
||||||
Stargate.log.info("[" + pName + "::ich::chargePlayer] Error fetching iConomy account for " + player);
|
Stargate.debug("ich::chargePlayer", "Error fetching iConomy account for " + player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Holdings hold = acc.getHoldings();
|
Holdings hold = acc.getHoldings();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.TheDgtl.Stargate.Stargate
|
main: net.TheDgtl.Stargate.Stargate
|
||||||
version: 0.5.5
|
version: 0.6.0
|
||||||
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