Enhanced network/world security.
This commit is contained in:
parent
54af5f449e
commit
806f5e5e71
2
README
2
README
@ -126,6 +126,8 @@ toowner - Whether the money from gate-use goes to the owner or nobody
|
|||||||
=============
|
=============
|
||||||
Changes
|
Changes
|
||||||
=============
|
=============
|
||||||
|
[Version 0.4.4]
|
||||||
|
- Added a check for stargate.network.*/stargate.world.* on gate creation
|
||||||
[Version 0.4.3]
|
[Version 0.4.3]
|
||||||
- Made some errors more user-friendly
|
- Made some errors more user-friendly
|
||||||
- Properly take into account portal-closed material
|
- Properly take into account portal-closed material
|
||||||
|
@ -132,7 +132,7 @@ public class Portal {
|
|||||||
public boolean open(Player openFor, boolean force) {
|
public boolean open(Player openFor, boolean force) {
|
||||||
if (isOpen() && !force) return false;
|
if (isOpen() && !force) return false;
|
||||||
|
|
||||||
world.loadChunk(world.getChunkAt(topLeft.getBlock()));
|
getWorld().loadChunk(getWorld().getChunkAt(topLeft.getBlock()));
|
||||||
|
|
||||||
for (Blox inside : getEntrances()) {
|
for (Blox inside : getEntrances()) {
|
||||||
inside.setType(gate.getPortalBlockOpen());
|
inside.setType(gate.getPortalBlockOpen());
|
||||||
@ -208,7 +208,7 @@ public class Portal {
|
|||||||
|
|
||||||
public void teleport(Player player, Portal origin, PlayerMoveEvent event) {
|
public void teleport(Player player, Portal origin, PlayerMoveEvent event) {
|
||||||
Location traveller = player.getLocation();
|
Location traveller = player.getLocation();
|
||||||
Location exit = getExit(traveller, origin);
|
Location exit = getExit(traveller);
|
||||||
|
|
||||||
exit.setYaw(origin.getRotation() - traveller.getYaw() + this.getRotation() + 180);
|
exit.setYaw(origin.getRotation() - traveller.getYaw() + this.getRotation() + 180);
|
||||||
|
|
||||||
@ -218,9 +218,9 @@ public class Portal {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleport(final Vehicle vehicle, Portal origin) {
|
public void teleport(final Vehicle vehicle) {
|
||||||
Location traveller = new Location(this.world, vehicle.getLocation().getX(), vehicle.getLocation().getY(), vehicle.getLocation().getZ());
|
Location traveller = new Location(this.world, vehicle.getLocation().getX(), vehicle.getLocation().getY(), vehicle.getLocation().getZ());
|
||||||
Location exit = getExit(traveller, origin);
|
Location exit = getExit(traveller);
|
||||||
|
|
||||||
double velocity = vehicle.getVelocity().length();
|
double velocity = vehicle.getVelocity().length();
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getExit(Location traveller, Portal origin) {
|
public Location getExit(Location traveller) {
|
||||||
Location loc = null;
|
Location loc = null;
|
||||||
// Check if the gate has an exit block
|
// Check if the gate has an exit block
|
||||||
if (gate.getExit() != null) {
|
if (gate.getExit() != null) {
|
||||||
@ -273,7 +273,7 @@ public class Portal {
|
|||||||
Stargate.log.log(Level.WARNING, "[Stargate] Missing destination point in .gate file " + gate.getFilename());
|
Stargate.log.log(Level.WARNING, "[Stargate] Missing destination point in .gate file " + gate.getFilename());
|
||||||
}
|
}
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
Block block = world.getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
Block block = getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||||
|
|
||||||
if (block.getType() == Material.STEP) {
|
if (block.getType() == Material.STEP) {
|
||||||
loc.setY(loc.getY() + 0.5);
|
loc.setY(loc.getY() + 0.5);
|
||||||
@ -316,11 +316,11 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChunkLoaded() {
|
public boolean isChunkLoaded() {
|
||||||
return topLeft.getWorld().isChunkLoaded(topLeft.getBlock().getChunk());
|
return getWorld().isChunkLoaded(topLeft.getBlock().getChunk());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadChunk() {
|
public void loadChunk() {
|
||||||
topLeft.getWorld().loadChunk(topLeft.getBlock().getChunk());
|
getWorld().loadChunk(topLeft.getBlock().getChunk());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVerified() {
|
public boolean isVerified() {
|
||||||
@ -354,7 +354,7 @@ public class Portal {
|
|||||||
for (String dest : allPortalsNet.get(getNetwork().toLowerCase())) {
|
for (String dest : allPortalsNet.get(getNetwork().toLowerCase())) {
|
||||||
Portal portal = getByName(dest, getNetwork());
|
Portal portal = getByName(dest, getNetwork());
|
||||||
// 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.topLeft.getWorld().getName(), player.isOp())) continue;
|
if (Stargate.worldFilter && !Stargate.hasPerm(player, "stargate.world." + portal.getWorld().getName(), player.isOp())) 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
|
// Check if dest is a fixed gate
|
||||||
@ -482,6 +482,10 @@ public class Portal {
|
|||||||
return frame;
|
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.log.info("[Stargate] Unregistering gate " + getName());
|
||||||
close(true);
|
close(true);
|
||||||
@ -520,7 +524,7 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAllGates(world);
|
saveAllGates(getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Blox getBlockAt(RelativeBlockVector vector) {
|
private Blox getBlockAt(RelativeBlockVector vector) {
|
||||||
@ -575,13 +579,6 @@ public class Portal {
|
|||||||
if (!Stargate.hasPerm(player, "stargate.option.private", player.isOp())) priv = false;
|
if (!Stargate.hasPerm(player, "stargate.option.private", player.isOp())) priv = false;
|
||||||
if (!Stargate.hasPerm(player, "stargate.option.free", player.isOp())) free = false;
|
if (!Stargate.hasPerm(player, "stargate.option.free", player.isOp())) free = false;
|
||||||
|
|
||||||
// Check if the user can only create personal gates, set network if so
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
||||||
@ -590,10 +587,35 @@ public class Portal {
|
|||||||
if ((network.length() < 1) || (network.length() > 11)) {
|
if ((network.length() < 1) || (network.length() > 11)) {
|
||||||
network = Stargate.getDefaultNetwork();
|
network = Stargate.getDefaultNetwork();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((name.length() < 1) || (name.length() > 11) || (getByName(name, network) != null)) {
|
if ((name.length() < 1) || (name.length() > 11) || (getByName(name, network) != null)) {
|
||||||
return null;
|
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 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;
|
||||||
@ -693,7 +715,7 @@ public class Portal {
|
|||||||
origin.open(true);
|
origin.open(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAllGates(topleft.getWorld());
|
saveAllGates(portal.getWorld());
|
||||||
|
|
||||||
return portal;
|
return portal;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
if (!teleMsg.isEmpty()) {
|
if (!teleMsg.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.BLUE + teleMsg);
|
player.sendMessage(ChatColor.BLUE + teleMsg);
|
||||||
}
|
}
|
||||||
dest.teleport(vehicle, portal);
|
dest.teleport(vehicle);
|
||||||
} else {
|
} else {
|
||||||
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
if (!iConomyHandler.inFundMsg.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
player.sendMessage(ChatColor.RED + iConomyHandler.inFundMsg);
|
||||||
@ -335,7 +335,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
} else {
|
} else {
|
||||||
Portal dest = portal.getDestination();
|
Portal dest = portal.getDestination();
|
||||||
if (dest == null) return;
|
if (dest == null) return;
|
||||||
dest.teleport(vehicle, portal);
|
dest.teleport(vehicle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,12 +351,25 @@ public class Stargate extends JavaPlugin {
|
|||||||
if (!denyMsg.isEmpty()) {
|
if (!denyMsg.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.RED + denyMsg);
|
player.sendMessage(ChatColor.RED + denyMsg);
|
||||||
}
|
}
|
||||||
|
portal.teleport(player, portal, event);
|
||||||
|
event.setCancelled(true);
|
||||||
return;
|
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())) ||
|
||||||
|
(worldFilter && !hasPerm(player, "stargate.world." + portal.getDestination().getWorld().getName(), player.isOp()))) {
|
||||||
|
if (!denyMsg.isEmpty()) {
|
||||||
|
player.sendMessage(ChatColor.RED + denyMsg);
|
||||||
|
}
|
||||||
|
portal.teleport(player, portal, event);
|
||||||
|
event.setCancelled(true);
|
||||||
|
portal.close(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean iConCharge = (iConomyHandler.useiConomy() && !portal.isFree() && !hasPerm(player, "stargate.free.use", player.isOp()));
|
boolean iConCharge = (iConomyHandler.useiConomy() && !portal.isFree() && !hasPerm(player, "stargate.free.use", player.isOp()));
|
||||||
|
|
||||||
if (!iConCharge || iConomyHandler.chargePlayer(player.getName(), portal.getOwner(), portal.getGate().getUseCost())) {
|
if (!iConCharge || iConomyHandler.chargePlayer(player.getName(), portal.getOwner(), portal.getGate().getUseCost())) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.TheDgtl.Stargate.Stargate
|
main: net.TheDgtl.Stargate.Stargate
|
||||||
version: 0.4.3
|
version: 0.4.4
|
||||||
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…
x
Reference in New Issue
Block a user