Added 'B'ackwards option
Fixed opening of gates with a fixed destination Added block metadata support
This commit is contained in:
parent
4968927528
commit
e1e3cd5e39
15
README
15
README
@ -30,6 +30,7 @@ Hmm.. None?
|
|||||||
- stargate.option.alwayson - Allow this user/group to create always-on gates.
|
- stargate.option.alwayson - Allow this user/group to create always-on gates.
|
||||||
- stargate.option.private - Allow this user/group to create private gates.
|
- stargate.option.private - Allow this user/group to create private gates.
|
||||||
- stargate.option.free - Allow this user/group to create free gates.
|
- stargate.option.free - Allow this user/group to create free gates.
|
||||||
|
- stargate.option.backwards - Allow this user/group to create backwards gates.
|
||||||
|
|
||||||
=============
|
=============
|
||||||
Instructions
|
Instructions
|
||||||
@ -45,7 +46,12 @@ Sign Layout:
|
|||||||
- Line 1: Gate Name (Max 12 characters)
|
- Line 1: Gate Name (Max 12 characters)
|
||||||
- Line 2: Destination Name [Optional] (Max 12 characters, used for fixed-gates only)
|
- Line 2: Destination Name [Optional] (Max 12 characters, used for fixed-gates only)
|
||||||
- Line 3: Network name [Optional] (Max 12 characters)
|
- Line 3: Network name [Optional] (Max 12 characters)
|
||||||
- Line 4: Options [Optional] ('A' for always-on fixed gate, 'H' for hidden networked gate, 'P' for a private gate, 'F' for a free gate)
|
- Line 4: Options [Optional] :
|
||||||
|
'A' for always-on fixed gate
|
||||||
|
'H' for hidden networked gate
|
||||||
|
'P' for a private gate
|
||||||
|
'F' for a free gate
|
||||||
|
'B' is for a backwards facing gate (You will exit the back)
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
The options are the single letter, not the word. So to make a private hidden gate, your 4th line would be 'PH'.
|
The options are the single letter, not the word. So to make a private hidden gate, your 4th line would be 'PH'.
|
||||||
@ -100,6 +106,9 @@ portal-open/closed are used to define the material in the gate when it is open o
|
|||||||
"X" and "-" are used to define block "types" for the layout (Any single-character can be used, such as "#").
|
"X" and "-" are used to define block "types" for the layout (Any single-character can be used, such as "#").
|
||||||
In the gate format, you can see we use "X" to show where obsidian must be, "-" where the controls (Button/sign) are.
|
In the gate format, you can see we use "X" to show where obsidian must be, "-" where the controls (Button/sign) are.
|
||||||
You will also notice a "*" in the gate layout, this is the "exit point" of the gate, the block at which the player will teleport in front of.
|
You will also notice a "*" in the gate layout, this is the "exit point" of the gate, the block at which the player will teleport in front of.
|
||||||
|
As of version 0.5.5 you can supply block data in the format
|
||||||
|
X=35:15
|
||||||
|
Which would only allow black wool. If no data is supplied any version of a block will work (Any color of wool for example)
|
||||||
|
|
||||||
==============
|
==============
|
||||||
Configuration
|
Configuration
|
||||||
@ -130,6 +139,10 @@ maxgates - If non-zero, will define the maximum amount of gates allowed on a net
|
|||||||
=============
|
=============
|
||||||
Changes
|
Changes
|
||||||
=============
|
=============
|
||||||
|
[Version 0.5.5]
|
||||||
|
- Added 'B'ackwards option
|
||||||
|
- Fixed opening of gates with a fixed gate as a destination
|
||||||
|
- Added block metadata support to gates
|
||||||
[Version 0.5.1]
|
[Version 0.5.1]
|
||||||
- Take into account world/network restrictions for Vehicles
|
- Take into account world/network restrictions for Vehicles
|
||||||
- Properly teleport empty vehicles between worlds
|
- Properly teleport empty vehicles between worlds
|
||||||
|
@ -31,8 +31,9 @@ public class Gate {
|
|||||||
private static HashSet<Integer> frameBlocks = new HashSet<Integer>();
|
private static HashSet<Integer> frameBlocks = new HashSet<Integer>();
|
||||||
|
|
||||||
private String filename;
|
private String filename;
|
||||||
private Integer[][] layout;
|
private Character[][] layout;
|
||||||
private HashMap<Character, Integer> types;
|
private HashMap<Character, Integer> types;
|
||||||
|
private HashMap<Character, Integer> metadata;
|
||||||
private RelativeBlockVector[] entrances = new RelativeBlockVector[0];
|
private RelativeBlockVector[] entrances = new RelativeBlockVector[0];
|
||||||
private RelativeBlockVector[] border = new RelativeBlockVector[0];
|
private RelativeBlockVector[] border = new RelativeBlockVector[0];
|
||||||
private RelativeBlockVector[] controls = new RelativeBlockVector[0];
|
private RelativeBlockVector[] controls = new RelativeBlockVector[0];
|
||||||
@ -47,9 +48,10 @@ public class Gate {
|
|||||||
private int destroyCost = 0;
|
private int destroyCost = 0;
|
||||||
private boolean toOwner = false;
|
private boolean toOwner = false;
|
||||||
|
|
||||||
private Gate(String filename, Integer[][] layout, HashMap<Character, Integer> types) {
|
private Gate(String filename, Character[][] layout, HashMap<Character, Integer> types, HashMap<Character, Integer> metadata) {
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
|
this.metadata = metadata;
|
||||||
this.types = types;
|
this.types = types;
|
||||||
|
|
||||||
populateCoordinates();
|
populateCoordinates();
|
||||||
@ -61,21 +63,20 @@ public class Gate {
|
|||||||
ArrayList<RelativeBlockVector> controlList = new ArrayList<RelativeBlockVector>();
|
ArrayList<RelativeBlockVector> controlList = new ArrayList<RelativeBlockVector>();
|
||||||
RelativeBlockVector[] relativeExits = new RelativeBlockVector[layout[0].length];
|
RelativeBlockVector[] relativeExits = new RelativeBlockVector[layout[0].length];
|
||||||
int[] exitDepths = new int[layout[0].length];
|
int[] exitDepths = new int[layout[0].length];
|
||||||
//int bottom = 0;
|
|
||||||
RelativeBlockVector lastExit = null;
|
RelativeBlockVector lastExit = null;
|
||||||
|
|
||||||
for (int y = 0; y < layout.length; y++) {
|
for (int y = 0; y < layout.length; y++) {
|
||||||
for (int x = 0; x < layout[y].length; x++) {
|
for (int x = 0; x < layout[y].length; x++) {
|
||||||
Integer id = layout[y][x];
|
Integer id = types.get(layout[y][x]);
|
||||||
|
if (layout[y][x] == '-') {
|
||||||
|
controlList.add(new RelativeBlockVector(x, y, 0));
|
||||||
|
}
|
||||||
|
|
||||||
if (id == ENTRANCE || id == EXIT) {
|
if (id == ENTRANCE || id == EXIT) {
|
||||||
entranceList.add(new RelativeBlockVector(x, y, 0));
|
entranceList.add(new RelativeBlockVector(x, y, 0));
|
||||||
exitDepths[x] = y;
|
exitDepths[x] = y;
|
||||||
if (id == EXIT)
|
if (id == EXIT)
|
||||||
this.exitBlock = new RelativeBlockVector(x, y, 0);
|
this.exitBlock = new RelativeBlockVector(x, y, 0);
|
||||||
//bottom = y;
|
|
||||||
} else if (id == CONTROL) {
|
|
||||||
controlList.add(new RelativeBlockVector(x, y, 0));
|
|
||||||
} else if (id != ANYTHING) {
|
} else if (id != ANYTHING) {
|
||||||
borderList.add(new RelativeBlockVector(x, y, 0));
|
borderList.add(new RelativeBlockVector(x, y, 0));
|
||||||
}
|
}
|
||||||
@ -102,8 +103,6 @@ public class Gate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save(String gateFolder) {
|
public void save(String gateFolder) {
|
||||||
HashMap<Integer, Character> reverse = new HashMap<Integer, Character>();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BufferedWriter bw = new BufferedWriter(new FileWriter(gateFolder + filename));
|
BufferedWriter bw = new BufferedWriter(new FileWriter(gateFolder + filename));
|
||||||
|
|
||||||
@ -119,14 +118,18 @@ public class Gate {
|
|||||||
|
|
||||||
for (Character type : types.keySet()) {
|
for (Character type : types.keySet()) {
|
||||||
Integer value = types.get(type);
|
Integer value = types.get(type);
|
||||||
|
// Skip control values
|
||||||
if (!type.equals('-')) {
|
if (value < 0) continue;
|
||||||
reverse.put(value, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
bw.append(type);
|
bw.append(type);
|
||||||
bw.append('=');
|
bw.append('=');
|
||||||
bw.append(value.toString());
|
bw.append(value.toString());
|
||||||
|
Integer mData = metadata.get(type);
|
||||||
|
// Append metadata
|
||||||
|
if (mData != null) {
|
||||||
|
bw.append(':');
|
||||||
|
bw.append(mData.toString());
|
||||||
|
}
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,23 +137,7 @@ public class Gate {
|
|||||||
|
|
||||||
for (int y = 0; y < layout.length; y++) {
|
for (int y = 0; y < layout.length; y++) {
|
||||||
for (int x = 0; x < layout[y].length; x++) {
|
for (int x = 0; x < layout[y].length; x++) {
|
||||||
Integer id = layout[y][x];
|
Character symbol = layout[y][x];
|
||||||
Character symbol;
|
|
||||||
|
|
||||||
if (id == ENTRANCE) {
|
|
||||||
symbol = '.';
|
|
||||||
} else if (id == ANYTHING) {
|
|
||||||
symbol = ' ';
|
|
||||||
} else if (id == CONTROL) {
|
|
||||||
symbol = '-';
|
|
||||||
} else if (id == EXIT) {
|
|
||||||
symbol = '*';
|
|
||||||
} else if (reverse.containsKey(id)) {
|
|
||||||
symbol = reverse.get(id);
|
|
||||||
} else {
|
|
||||||
symbol = '?';
|
|
||||||
}
|
|
||||||
|
|
||||||
bw.append(symbol);
|
bw.append(symbol);
|
||||||
}
|
}
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
@ -158,7 +145,7 @@ public class Gate {
|
|||||||
|
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Stargate.log.log(Level.SEVERE, "Could not load Gate " + filename + " - " + ex.getMessage());
|
Stargate.log.log(Level.SEVERE, "Could not save Gate " + filename + " - " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +159,7 @@ public class Gate {
|
|||||||
bw.newLine();
|
bw.newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer[][] getLayout() {
|
public Character[][] getLayout() {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,20 +221,20 @@ public class Gate {
|
|||||||
public boolean matches(Blox topleft, int modX, int modZ) {
|
public boolean matches(Blox topleft, int modX, int modZ) {
|
||||||
for (int y = 0; y < layout.length; y++) {
|
for (int y = 0; y < layout.length; y++) {
|
||||||
for (int x = 0; x < layout[y].length; x++) {
|
for (int x = 0; x < layout[y].length; x++) {
|
||||||
int id = layout[y][x];
|
int id = types.get(layout[y][x]);
|
||||||
|
|
||||||
if (id == ENTRANCE || id == EXIT) {
|
if (id == ENTRANCE || id == EXIT) {
|
||||||
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != portalBlockClosed) {
|
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != portalBlockClosed) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (id == CONTROL) {
|
|
||||||
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != getControlBlock()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (id != ANYTHING) {
|
} else if (id != ANYTHING) {
|
||||||
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != id) {
|
if (topleft.modRelative(x, y, 0, modX, 1, modZ).getType() != id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Integer mData = metadata.get(layout[y][x]);
|
||||||
|
if (mData != null && topleft.modRelative(x, y, 0, modX, 1, modZ).getData() != mData) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,10 +257,16 @@ public class Gate {
|
|||||||
private static Gate loadGate(File file) {
|
private static Gate loadGate(File file) {
|
||||||
Scanner scanner = null;
|
Scanner scanner = null;
|
||||||
boolean designing = false;
|
boolean designing = false;
|
||||||
ArrayList<ArrayList<Integer>> design = new ArrayList<ArrayList<Integer>>();
|
ArrayList<ArrayList<Character>> design = new ArrayList<ArrayList<Character>>();
|
||||||
HashMap<Character, Integer> types = new HashMap<Character, Integer>();
|
HashMap<Character, Integer> types = new HashMap<Character, Integer>();
|
||||||
|
HashMap<Character, Integer> metadata = new HashMap<Character, Integer>();
|
||||||
HashMap<String, String> config = new HashMap<String, String>();
|
HashMap<String, String> config = new HashMap<String, String>();
|
||||||
int cols = 0;
|
int cols = 0;
|
||||||
|
|
||||||
|
// Init types map
|
||||||
|
types.put('.', ENTRANCE);
|
||||||
|
types.put('*', EXIT);
|
||||||
|
types.put(' ', ANYTHING);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
scanner = new Scanner(file);
|
scanner = new Scanner(file);
|
||||||
@ -282,31 +275,18 @@ public class Gate {
|
|||||||
String line = scanner.nextLine();
|
String line = scanner.nextLine();
|
||||||
|
|
||||||
if (designing) {
|
if (designing) {
|
||||||
ArrayList<Integer> row = new ArrayList<Integer>();
|
ArrayList<Character> row = new ArrayList<Character>();
|
||||||
|
|
||||||
if (line.length() > cols) {
|
if (line.length() > cols) {
|
||||||
cols = line.length();
|
cols = line.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Character symbol : line.toCharArray()) {
|
for (Character symbol : line.toCharArray()) {
|
||||||
Integer id = ANYTHING;
|
if ((symbol.equals('?')) || (!types.containsKey(symbol))) {
|
||||||
|
|
||||||
if (symbol.equals('.')) {
|
|
||||||
id = ENTRANCE;
|
|
||||||
} else if (symbol.equals('*')) {
|
|
||||||
id = EXIT;
|
|
||||||
} else if (symbol.equals(' ')) {
|
|
||||||
id = ANYTHING;
|
|
||||||
} else if (symbol.equals('-')) {
|
|
||||||
id = CONTROL;
|
|
||||||
} else if ((symbol.equals('?')) || (!types.containsKey(symbol))) {
|
|
||||||
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Unknown symbol '" + symbol + "' in diagram");
|
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Unknown symbol '" + symbol + "' in diagram");
|
||||||
return null;
|
return null;
|
||||||
} else {
|
|
||||||
id = types.get(symbol);
|
|
||||||
}
|
}
|
||||||
|
row.add(symbol);
|
||||||
row.add(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
design.add(row);
|
design.add(row);
|
||||||
@ -320,6 +300,13 @@ public class Gate {
|
|||||||
|
|
||||||
if (key.length() == 1) {
|
if (key.length() == 1) {
|
||||||
Character symbol = key.charAt(0);
|
Character symbol = key.charAt(0);
|
||||||
|
// Check for metadata
|
||||||
|
if (value.contains(":")) {
|
||||||
|
split = value.split(":");
|
||||||
|
value = split[0].trim();
|
||||||
|
String mData = split[1].trim();
|
||||||
|
metadata.put(symbol, Integer.parseInt(mData));
|
||||||
|
}
|
||||||
Integer id = Integer.parseInt(value);
|
Integer id = Integer.parseInt(value);
|
||||||
|
|
||||||
types.put(symbol, id);
|
types.put(symbol, id);
|
||||||
@ -337,24 +324,24 @@ public class Gate {
|
|||||||
if (scanner != null) scanner.close();
|
if (scanner != null) scanner.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer[][] layout = new Integer[design.size()][cols];
|
Character[][] layout = new Character[design.size()][cols];
|
||||||
|
|
||||||
for (int y = 0; y < design.size(); y++) {
|
for (int y = 0; y < design.size(); y++) {
|
||||||
ArrayList<Integer> row = design.get(y);
|
ArrayList<Character> row = design.get(y);
|
||||||
Integer[] result = new Integer[cols];
|
Character[] result = new Character[cols];
|
||||||
|
|
||||||
for (int x = 0; x < cols; x++) {
|
for (int x = 0; x < cols; x++) {
|
||||||
if (x < row.size()) {
|
if (x < row.size()) {
|
||||||
result[x] = row.get(x);
|
result[x] = row.get(x);
|
||||||
} else {
|
} else {
|
||||||
result[x] = ANYTHING;
|
result[x] = ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layout[y] = result;
|
layout[y] = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gate gate = new Gate(file.getName(), layout, types);
|
Gate gate = new Gate(file.getName(), layout, types, metadata);
|
||||||
|
|
||||||
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);
|
||||||
@ -407,18 +394,22 @@ public class Gate {
|
|||||||
|
|
||||||
public static void populateDefaults(String gateFolder) {
|
public static void populateDefaults(String gateFolder) {
|
||||||
int Obsidian = Material.OBSIDIAN.getId();
|
int Obsidian = Material.OBSIDIAN.getId();
|
||||||
Integer[][] layout = new Integer[][] {
|
Character[][] layout = new Character[][] {
|
||||||
{ANYTHING, Obsidian,Obsidian, ANYTHING},
|
{' ', 'X','X', ' '},
|
||||||
{Obsidian, ENTRANCE, ENTRANCE, Obsidian},
|
{'X', '.', '.', 'X'},
|
||||||
{CONTROL, ENTRANCE, ENTRANCE, CONTROL},
|
{'-', '.', '.', '-'},
|
||||||
{Obsidian, EXIT, ENTRANCE, Obsidian},
|
{'X', '*', '.', 'X'},
|
||||||
{ANYTHING, Obsidian, Obsidian, ANYTHING},
|
{' ', 'X', 'X', ' '},
|
||||||
};
|
};
|
||||||
HashMap<Character, Integer> types = new HashMap<Character, Integer>();
|
HashMap<Character, Integer> types = new HashMap<Character, Integer>();
|
||||||
|
types.put('.', ENTRANCE);
|
||||||
|
types.put('*', EXIT);
|
||||||
|
types.put(' ', ANYTHING);
|
||||||
types.put('X', Obsidian);
|
types.put('X', Obsidian);
|
||||||
types.put('-', Obsidian);
|
types.put('-', Obsidian);
|
||||||
|
HashMap<Character, Integer> metadata = new HashMap<Character, Integer>();
|
||||||
|
|
||||||
Gate gate = new Gate("nethergate.gate", layout, types);
|
Gate gate = new Gate("nethergate.gate", layout, types, metadata);
|
||||||
gate.save(gateFolder);
|
gate.save(gateFolder);
|
||||||
registerGate(gate);
|
registerGate(gate);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Minecart;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.StorageMinecart;
|
import org.bukkit.entity.StorageMinecart;
|
||||||
import org.bukkit.entity.Vehicle;
|
import org.bukkit.entity.Vehicle;
|
||||||
@ -56,10 +55,13 @@ public class Portal {
|
|||||||
private String network;
|
private String network;
|
||||||
private Gate gate;
|
private Gate gate;
|
||||||
private String owner = "";
|
private String owner = "";
|
||||||
|
// Options
|
||||||
private boolean hidden = false;
|
private boolean hidden = false;
|
||||||
private boolean alwaysOn = false;
|
private boolean alwaysOn = false;
|
||||||
private boolean priv = false;
|
private boolean priv = false;
|
||||||
private boolean free = false;
|
private boolean free = false;
|
||||||
|
private boolean backwards = false;
|
||||||
|
|
||||||
private World world;
|
private World world;
|
||||||
// Gate options
|
// Gate options
|
||||||
private boolean verified;
|
private boolean verified;
|
||||||
@ -74,8 +76,8 @@ public class Portal {
|
|||||||
private Portal(Blox topLeft, int modX, int modZ,
|
private Portal(Blox topLeft, int modX, int modZ,
|
||||||
float rotX, SignPost id, Blox button,
|
float rotX, SignPost id, Blox button,
|
||||||
String dest, String name,
|
String dest, String name,
|
||||||
boolean verified, String network, Gate gate,
|
boolean verified, String network, Gate gate, String owner,
|
||||||
String owner, boolean hidden, boolean alwaysOn, boolean priv, boolean free) {
|
boolean hidden, boolean alwaysOn, boolean priv, boolean free, boolean backwards) {
|
||||||
this.topLeft = topLeft;
|
this.topLeft = topLeft;
|
||||||
this.modX = modX;
|
this.modX = modX;
|
||||||
this.modZ = modZ;
|
this.modZ = modZ;
|
||||||
@ -93,6 +95,7 @@ public class Portal {
|
|||||||
this.alwaysOn = alwaysOn;
|
this.alwaysOn = alwaysOn;
|
||||||
this.priv = priv;
|
this.priv = priv;
|
||||||
this.free = free;
|
this.free = free;
|
||||||
|
this.backwards = backwards;
|
||||||
this.world = topLeft.getWorld();
|
this.world = topLeft.getWorld();
|
||||||
|
|
||||||
if (this.alwaysOn && !this.fixed) {
|
if (this.alwaysOn && !this.fixed) {
|
||||||
@ -126,6 +129,10 @@ public class Portal {
|
|||||||
return free;
|
return free;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBackwards() {
|
||||||
|
return backwards;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFree(Player player, Portal dest) {
|
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
|
// This gate is free, the player gets all gates free, or we don't charge for free dest and dest is free
|
||||||
boolean isFree = isFree() || Stargate.hasPerm(player, "stargate.free.use", player.isOp()) ||
|
boolean isFree = isFree() || Stargate.hasPerm(player, "stargate.free.use", player.isOp()) ||
|
||||||
@ -155,7 +162,7 @@ public class Portal {
|
|||||||
player = openFor;
|
player = openFor;
|
||||||
|
|
||||||
Portal end = getDestination();
|
Portal end = getDestination();
|
||||||
if (end != null && !end.isFixed() && !end.isOpen()) {
|
if (end != null && !end.isAlwaysOn() && !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();
|
||||||
@ -218,7 +225,9 @@ public class Portal {
|
|||||||
Location traveller = player.getLocation();
|
Location traveller = player.getLocation();
|
||||||
Location exit = getExit(traveller);
|
Location exit = getExit(traveller);
|
||||||
|
|
||||||
exit.setYaw(origin.getRotation() - traveller.getYaw() + this.getRotation() + 180);
|
// Handle backwards gates
|
||||||
|
int adjust = isBackwards() ? 0 :180;
|
||||||
|
exit.setYaw(origin.getRotation() - traveller.getYaw() + this.getRotation() + adjust);
|
||||||
|
|
||||||
// The new method to teleport in a move event is set the "to" field.
|
// The new method to teleport in a move event is set the "to" field.
|
||||||
event.setTo(exit);
|
event.setTo(exit);
|
||||||
@ -278,14 +287,14 @@ public class Portal {
|
|||||||
// Check if the gate has an exit block
|
// Check if the gate has an exit block
|
||||||
if (gate.getExit() != null) {
|
if (gate.getExit() != null) {
|
||||||
Blox exit = getBlockAt(gate.getExit());
|
Blox exit = getBlockAt(gate.getExit());
|
||||||
loc = exit.modRelativeLoc(0D, 0D, 1D, traveller.getYaw(), traveller.getPitch(), modX, 1, modZ);
|
int back = (isBackwards()) ? -1 : 1;
|
||||||
|
loc = exit.modRelativeLoc(0D, 0D, 1D, traveller.getYaw(), traveller.getPitch(), modX * back, 1, modZ * back);
|
||||||
} else {
|
} else {
|
||||||
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 = getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
|
||||||
|
|
||||||
if (block.getType() == Material.STEP) {
|
if (getWorld().getBlockTypeIdAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()) == Material.STEP.getId()) {
|
||||||
loc.setY(loc.getY() + 0.5);
|
loc.setY(loc.getY() + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,17 +526,12 @@ public class Portal {
|
|||||||
public Blox[] getFrame() {
|
public Blox[] getFrame() {
|
||||||
if (frame == null) {
|
if (frame == null) {
|
||||||
RelativeBlockVector[] border = gate.getBorder();
|
RelativeBlockVector[] border = gate.getBorder();
|
||||||
RelativeBlockVector[] controls = gate.getControls();
|
frame = new Blox[border.length];
|
||||||
frame = new Blox[border.length + controls.length];
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (RelativeBlockVector vector : border) {
|
for (RelativeBlockVector vector : border) {
|
||||||
frame[i++] = getBlockAt(vector);
|
frame[i++] = getBlockAt(vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RelativeBlockVector vector : controls) {
|
|
||||||
frame[i++] = getBlockAt(vector);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
@ -631,12 +635,14 @@ public class Portal {
|
|||||||
boolean alwaysOn = (options.indexOf('a') != -1 || options.indexOf('A') != -1);
|
boolean alwaysOn = (options.indexOf('a') != -1 || options.indexOf('A') != -1);
|
||||||
boolean priv = (options.indexOf('p') != -1 || options.indexOf('P') != -1);
|
boolean priv = (options.indexOf('p') != -1 || options.indexOf('P') != -1);
|
||||||
boolean free = (options.indexOf('f') != - 1|| options.indexOf('F') != -1);
|
boolean free = (options.indexOf('f') != - 1|| options.indexOf('F') != -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.hasPerm(player, "stargate.option.hidden", player.isOp())) hidden = false;
|
||||||
if (!Stargate.hasPerm(player, "stargate.option.alwayson", player.isOp())) alwaysOn = false;
|
if (!Stargate.hasPerm(player, "stargate.option.alwayson", player.isOp())) alwaysOn = false;
|
||||||
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;
|
||||||
|
if (!Stargate.hasPerm(player, "stargate.option.backwards", player.isOp())) 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) {
|
||||||
@ -644,7 +650,7 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
Stargate.debug("createPortal", "h = " + hidden + " a = " + alwaysOn + " p = " + priv + " f = " + free);
|
Stargate.debug("createPortal", "h = " + hidden + " a = " + alwaysOn + " p = " + priv + " f = " + free + " b = " + backwards);
|
||||||
|
|
||||||
if ((network.length() < 1) || (network.length() > 11)) {
|
if ((network.length() < 1) || (network.length() > 11)) {
|
||||||
network = Stargate.getDefaultNetwork();
|
network = Stargate.getDefaultNetwork();
|
||||||
@ -773,7 +779,7 @@ public class Portal {
|
|||||||
button.setType(Material.STONE_BUTTON.getId());
|
button.setType(Material.STONE_BUTTON.getId());
|
||||||
button.setData(facing);
|
button.setData(facing);
|
||||||
}
|
}
|
||||||
portal = new Portal(topleft, modX, modZ, rotX, id, button, destName, name, true, network, gate, player.getName(), hidden, alwaysOn, priv, free);
|
portal = new Portal(topleft, modX, modZ, rotX, id, button, destName, name, true, network, gate, player.getName(), hidden, alwaysOn, priv, free, backwards);
|
||||||
|
|
||||||
// Open always on gate
|
// Open always on gate
|
||||||
if (portal.isAlwaysOn()) {
|
if (portal.isAlwaysOn()) {
|
||||||
@ -861,6 +867,8 @@ public class Portal {
|
|||||||
builder.append(portal.world.getName());
|
builder.append(portal.world.getName());
|
||||||
builder.append(':');
|
builder.append(':');
|
||||||
builder.append(portal.isFree());
|
builder.append(portal.isFree());
|
||||||
|
builder.append(':');
|
||||||
|
builder.append(portal.isBackwards());
|
||||||
|
|
||||||
bw.append(builder.toString());
|
bw.append(builder.toString());
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
@ -927,8 +935,9 @@ public class Portal {
|
|||||||
boolean alwaysOn = (split.length > 12) ? split[12].equalsIgnoreCase("true") : false;
|
boolean alwaysOn = (split.length > 12) ? split[12].equalsIgnoreCase("true") : false;
|
||||||
boolean priv = (split.length > 13) ? split[13].equalsIgnoreCase("true") : false;
|
boolean priv = (split.length > 13) ? split[13].equalsIgnoreCase("true") : false;
|
||||||
boolean free = (split.length > 15) ? split[15].equalsIgnoreCase("true") : false;
|
boolean free = (split.length > 15) ? split[15].equalsIgnoreCase("true") : false;
|
||||||
|
boolean backwards = (split.length > 16) ? split[16].equalsIgnoreCase("true") : false;
|
||||||
|
|
||||||
Portal portal = new Portal(topLeft, modX, modZ, rotX, sign, button, dest, name, false, network, gate, owner, hidden, alwaysOn, priv, free);
|
Portal portal = new Portal(topLeft, modX, modZ, rotX, sign, button, dest, name, false, network, gate, owner, hidden, alwaysOn, priv, free, backwards);
|
||||||
portal.close(true);
|
portal.close(true);
|
||||||
}
|
}
|
||||||
scanner.close();
|
scanner.close();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.TheDgtl.Stargate.Stargate
|
main: net.TheDgtl.Stargate.Stargate
|
||||||
version: 0.5.1
|
version: 0.5.5
|
||||||
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