Fixed gates no longer show in destination list.

Started adding stuff for later loading of gates (Will be used for multi world)
This commit is contained in:
Drakia 2011-02-18 13:53:00 -08:00
parent 758b15ae69
commit 0d6d680fcc
4 changed files with 44 additions and 28 deletions

2
README
View File

@ -79,6 +79,8 @@ gate-folder - The folder containing your .gate files
============= =============
Changes Changes
============= =============
[Version 0.13]
- Fixed gates no longer show in destination list.
[Version 0.12] [Version 0.12]
- Implemented fixed destination block using * in .gate file. This is the recommended method of doing an exit point for custom gates, as the automatic method doesn't work in a lot of cases. - Implemented fixed destination block using * in .gate file. This is the recommended method of doing an exit point for custom gates, as the automatic method doesn't work in a lot of cases.
- Split networks up in memory, can now use same name in different networks. As a result, fixed gates must now specify a network. - Split networks up in memory, can now use same name in different networks. As a result, fixed gates must now specify a network.

View File

@ -64,6 +64,7 @@ public class Portal {
private boolean priv = false; private boolean priv = false;
private World world; private World world;
private long openTime; private long openTime;
private boolean loaded = false;
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,
@ -96,7 +97,7 @@ public class Portal {
this.register(); this.register();
if (verified) { if (verified) {
this.drawSign(true); this.drawSign();
} }
} }
@ -124,6 +125,10 @@ public class Portal {
return priv; return priv;
} }
public boolean isLoaded() {
return loaded;
}
public boolean open(boolean force) { public boolean open(boolean force) {
return open(null, force); return open(null, force);
} }
@ -140,6 +145,7 @@ public class Portal {
isOpen = true; isOpen = true;
openTime = System.currentTimeMillis() / 1000; openTime = System.currentTimeMillis() / 1000;
Stargate.openList.add(this); Stargate.openList.add(this);
Stargate.activeList.remove(this);
// Open remote gate // Open remote gate
if (!isAlwaysOn()) { if (!isAlwaysOn()) {
player = openFor; player = openFor;
@ -149,7 +155,7 @@ public class Portal {
if (end != null && !end.isOpen()) { if (end != null && !end.isOpen()) {
end.open(openFor, false); end.open(openFor, false);
end.setDestination(this); end.setDestination(this);
if (end.isVerified()) end.drawSign(true); if (end.isVerified()) end.drawSign();
} }
} }
@ -174,6 +180,7 @@ public class Portal {
player = null; player = null;
isOpen = false; isOpen = false;
Stargate.openList.remove(this); Stargate.openList.remove(this);
Stargate.activeList.remove(this);
deactivate(); deactivate();
} }
@ -308,7 +315,7 @@ public class Portal {
public void setName(String name) { public void setName(String name) {
this.name = filterName(name); this.name = filterName(name);
drawSign(true); drawSign();
} }
public String getName() { public String getName() {
@ -356,13 +363,15 @@ public class Portal {
public void activate(Player player) { public void activate(Player player) {
destinations.clear(); destinations.clear();
destination = ""; destination = "";
drawSign(true); drawSign();
Stargate.activeList.add(this); Stargate.activeList.add(this);
activePlayer = player; activePlayer = player;
for (String dest : allPortalsNet.get(getNetwork().toLowerCase())) { for (String dest : allPortalsNet.get(getNetwork().toLowerCase())) {
Portal portal = getByName(dest, getNetwork()); Portal portal = getByName(dest, getNetwork());
if ( (!dest.equalsIgnoreCase(getName())) && // Not this portal // Not fixed, not this portal, and visible to this player.
(!portal.isHidden() || Stargate.hasPerm(player, "stargate.hidden", player.isOp()) || portal.getOwner().equals(player.getName())) // Is not hidden, player can view hidden, or player created if ( (!portal.isFixed()) &&
(!dest.equalsIgnoreCase(getName())) && // Not this portal
(!portal.isHidden() || Stargate.hasPerm(player, "stargate.hidden", player.isOp()) || portal.getOwner().equals(player.getName()))
) { ) {
destinations.add(portal.getName()); destinations.add(portal.getName());
} }
@ -370,14 +379,14 @@ public class Portal {
} }
public void deactivate() { public void deactivate() {
if (fixed) { Stargate.activeList.remove(this);
if (isFixed()) {
return; return;
} }
Stargate.activeList.remove(this);
destinations.clear(); destinations.clear();
destination = ""; destination = "";
activePlayer = null; activePlayer = null;
drawSign(true); drawSign();
} }
public boolean isActive() { public boolean isActive() {
@ -409,10 +418,10 @@ public class Portal {
destination = destinations.get(index); destination = destinations.get(index);
} }
openTime = System.currentTimeMillis() / 1000; openTime = System.currentTimeMillis() / 1000;
drawSign(true); drawSign();
} }
public final void drawSign(boolean update) { public final void drawSign() {
id.setText(0, "--" + name + "--"); id.setText(0, "--" + name + "--");
int max = destinations.size() - 1; int max = destinations.size() - 1;
int done = 0; int done = 0;
@ -451,10 +460,8 @@ public class Portal {
id.setText(done, ""); id.setText(done, "");
} }
if (update) {
id.update(); id.update();
} }
}
public Blox[] getEntrances() { public Blox[] getEntrances() {
if (entrances == null) { if (entrances == null) {
@ -779,6 +786,9 @@ public class Portal {
builder.append(portal.isAlwaysOn()); builder.append(portal.isAlwaysOn());
builder.append(':'); builder.append(':');
builder.append(portal.isPrivate()); builder.append(portal.isPrivate());
builder.append(':');
builder.append(portal.world.getName());
bw.append(builder.toString()); bw.append(builder.toString());
bw.newLine(); bw.newLine();
@ -843,7 +853,7 @@ public class Portal {
portal.unregister(); portal.unregister();
Stargate.log.info("Destroying stargate at " + portal.toString()); Stargate.log.info("Destroying stargate at " + portal.toString());
} else { } else {
portal.drawSign(true); portal.drawSign();
} }
} }
@ -873,6 +883,8 @@ public class Portal {
public static void closeAllGates() { public static void closeAllGates() {
Stargate.log.info("Closing all stargates."); Stargate.log.info("Closing all stargates.");
for (Portal p : allPortals) { for (Portal p : allPortals) {
if (p == null) continue;
//if (!p.isLoaded()) continue;
p.close(true); p.close(true);
} }
} }

View File

@ -26,6 +26,8 @@ import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.vehicle.VehicleListener; import org.bukkit.event.vehicle.VehicleListener;
import org.bukkit.event.vehicle.VehicleMoveEvent; import org.bukkit.event.vehicle.VehicleMoveEvent;
import org.bukkit.event.world.WorldEvent;
import org.bukkit.event.world.WorldListener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.PluginLoader;
@ -48,6 +50,7 @@ public class Stargate extends JavaPlugin {
private final bListener blockListener = new bListener(); private final bListener blockListener = new bListener();
private final pListener playerListener = new pListener(); private final pListener playerListener = new pListener();
private final vListener vehicleListener = new vListener(); private final vListener vehicleListener = new vListener();
private final wListener worldListener = new wListener();
public static Logger log; public static Logger log;
private Configuration config; private Configuration config;
private PluginManager pm; private PluginManager pm;
@ -82,20 +85,10 @@ public class Stargate extends JavaPlugin {
public void onEnable() { public void onEnable() {
PluginDescriptionFile pdfFile = this.getDescription(); PluginDescriptionFile pdfFile = this.getDescription();
pm = getServer().getPluginManager(); pm = getServer().getPluginManager();
config = this.getConfiguration();
/* Lamesauce, they broke this. No way to check build number anymore as far as I know D:
String cbVerStr = CraftServer.class.getPackage().getImplementationVersion();
int cbVersion = Integer.parseInt(cbVerStr.substring(cbVerStr.length() - 3));
if (cbVersion < 319) {
log.info("[" + pdfFile.getName() + " v." + pdfFile.getVersion() + "] CraftBukkit build " + cbVersion + " too old to run Stargate.");
pm.disablePlugin(this);
return;
}*/
log.info(pdfFile.getName() + " v." + pdfFile.getVersion() + " is enabled."); log.info(pdfFile.getName() + " v." + pdfFile.getVersion() + " is enabled.");
config = this.getConfiguration();
pm.registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal, this);
@ -112,6 +105,8 @@ public class Stargate extends JavaPlugin {
pm.registerEvent(Event.Type.VEHICLE_MOVE, vehicleListener, Priority.Normal, this); pm.registerEvent(Event.Type.VEHICLE_MOVE, vehicleListener, Priority.Normal, this);
pm.registerEvent(Event.Type.SIGN_CHANGE, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.SIGN_CHANGE, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.WORLD_LOADED, worldListener, Priority.Normal, this);
getServer().getScheduler().scheduleSyncRepeatingTask(this, new SGThread(), 0L, 100L); getServer().getScheduler().scheduleSyncRepeatingTask(this, new SGThread(), 0L, 100L);
} }
@ -309,7 +304,7 @@ public class Stargate extends JavaPlugin {
player.sendMessage(ChatColor.GREEN + regMsg); player.sendMessage(ChatColor.GREEN + regMsg);
} }
log.info("Initialized stargate: " + portal.getName()); log.info("Initialized stargate: " + portal.getName());
portal.drawSign(true); portal.drawSign();
// Set event text so our new sign is instantly initialized // Set event text so our new sign is instantly initialized
event.setLine(0, sign.getText(0)); event.setLine(0, sign.getText(0));
event.setLine(1, sign.getText(1)); event.setLine(1, sign.getText(1));
@ -402,6 +397,13 @@ public class Stargate extends JavaPlugin {
} }
} }
private class wListener extends WorldListener {
@Override
public void onWorldLoaded(WorldEvent event) {
//Portal.loadQueue(event.getWorld());
}
}
@SuppressWarnings("static-access") @SuppressWarnings("static-access")
public static Boolean hasPerm(Player player, String perm, Boolean def) { public static Boolean hasPerm(Player player, String perm, Boolean def) {
if (Permissions != null) if (Permissions != null)

View File

@ -1,6 +1,6 @@
name: Stargate name: Stargate
main: net.TheDgtl.Stargate.Stargate main: net.TheDgtl.Stargate.Stargate
version: 0.12 version: 0.13
description: Stargate mod for Bukkit description: Stargate mod for Bukkit
author: Drakia author: Drakia
website: http://www.thedgtl.net website: http://www.thedgtl.net