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:
		
							
								
								
									
										2
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								README
									
									
									
									
									
								
							| @@ -79,6 +79,8 @@ gate-folder - The folder containing your .gate files | ||||
| ============= | ||||
|   Changes | ||||
| ============= | ||||
| [Version 0.13] | ||||
|  - Fixed gates no longer show in destination list. | ||||
| [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. | ||||
|  - Split networks up in memory, can now use same name in different networks. As a result, fixed gates must now specify a network. | ||||
|   | ||||
| @@ -64,6 +64,7 @@ public class Portal { | ||||
|     private boolean priv = false; | ||||
|     private World world; | ||||
|     private long openTime; | ||||
|     private boolean loaded = false; | ||||
|  | ||||
|     private Portal(Blox topLeft, int modX, int modZ, | ||||
|             float rotX, SignPost id, Blox button, | ||||
| @@ -96,7 +97,7 @@ public class Portal { | ||||
|  | ||||
|         this.register(); | ||||
|         if (verified) { | ||||
|             this.drawSign(true); | ||||
|             this.drawSign(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -124,6 +125,10 @@ public class Portal { | ||||
|     	return priv; | ||||
|     } | ||||
|      | ||||
|     public boolean isLoaded() { | ||||
|     	return loaded; | ||||
|     } | ||||
|  | ||||
|     public boolean open(boolean force) { | ||||
|         return open(null, force); | ||||
|     } | ||||
| @@ -140,6 +145,7 @@ public class Portal { | ||||
|         isOpen = true; | ||||
|         openTime = System.currentTimeMillis() / 1000; | ||||
|         Stargate.openList.add(this); | ||||
|         Stargate.activeList.remove(this); | ||||
|         // Open remote gate | ||||
|         if (!isAlwaysOn()) { | ||||
|             player = openFor; | ||||
| @@ -149,7 +155,7 @@ public class Portal { | ||||
|             if (end != null && !end.isOpen()) { | ||||
|                 end.open(openFor, false); | ||||
|                 end.setDestination(this); | ||||
|                 if (end.isVerified()) end.drawSign(true); | ||||
|                 if (end.isVerified()) end.drawSign(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -174,6 +180,7 @@ public class Portal { | ||||
|         player = null; | ||||
|         isOpen = false; | ||||
|         Stargate.openList.remove(this); | ||||
|         Stargate.activeList.remove(this); | ||||
|  | ||||
|         deactivate(); | ||||
|     } | ||||
| @@ -308,7 +315,7 @@ public class Portal { | ||||
|     public void setName(String name) { | ||||
|         this.name = filterName(name); | ||||
|  | ||||
|         drawSign(true); | ||||
|         drawSign(); | ||||
|     } | ||||
|  | ||||
|     public String getName() { | ||||
| @@ -356,13 +363,15 @@ public class Portal { | ||||
|     public void activate(Player player) { | ||||
|         destinations.clear(); | ||||
|         destination = ""; | ||||
|         drawSign(true); | ||||
|         drawSign(); | ||||
|         Stargate.activeList.add(this); | ||||
|         activePlayer = player; | ||||
|         for (String dest : allPortalsNet.get(getNetwork().toLowerCase())) { | ||||
|             Portal portal = getByName(dest, getNetwork()); | ||||
|             if (	(!dest.equalsIgnoreCase(getName())) && 							// Not this portal | ||||
|             		(!portal.isHidden() || Stargate.hasPerm(player, "stargate.hidden", player.isOp()) || portal.getOwner().equals(player.getName()))	// Is not hidden, player can view hidden, or player created | ||||
|             // Not fixed, not this portal, and visible to this player. | ||||
|             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()); | ||||
|             } | ||||
| @@ -370,14 +379,14 @@ public class Portal { | ||||
|     } | ||||
|  | ||||
|     public void deactivate() { | ||||
|         if (fixed) { | ||||
|     	Stargate.activeList.remove(this); | ||||
|         if (isFixed()) { | ||||
|             return; | ||||
|         } | ||||
|         Stargate.activeList.remove(this); | ||||
|         destinations.clear(); | ||||
|         destination = ""; | ||||
|         activePlayer = null; | ||||
|         drawSign(true); | ||||
|         drawSign(); | ||||
|     } | ||||
|  | ||||
|     public boolean isActive() { | ||||
| @@ -409,10 +418,10 @@ public class Portal { | ||||
|             destination = destinations.get(index); | ||||
|         } | ||||
|         openTime = System.currentTimeMillis() / 1000; | ||||
|         drawSign(true); | ||||
|         drawSign(); | ||||
|     } | ||||
|  | ||||
|     public final void drawSign(boolean update) { | ||||
|     public final void drawSign() { | ||||
|         id.setText(0, "--" + name + "--"); | ||||
|         int max = destinations.size() - 1; | ||||
|         int done = 0; | ||||
| @@ -451,10 +460,8 @@ public class Portal { | ||||
|             id.setText(done, ""); | ||||
|         } | ||||
|  | ||||
|         if (update) { | ||||
|         id.update(); | ||||
|     } | ||||
|     } | ||||
|  | ||||
|     public Blox[] getEntrances() { | ||||
|         if (entrances == null) { | ||||
| @@ -779,6 +786,9 @@ public class Portal { | ||||
|                 builder.append(portal.isAlwaysOn()); | ||||
|                 builder.append(':'); | ||||
|                 builder.append(portal.isPrivate()); | ||||
|                 builder.append(':'); | ||||
|                 builder.append(portal.world.getName()); | ||||
|                  | ||||
|  | ||||
|                 bw.append(builder.toString()); | ||||
|                 bw.newLine(); | ||||
| @@ -843,7 +853,7 @@ public class Portal { | ||||
|                             portal.unregister(); | ||||
|                             Stargate.log.info("Destroying stargate at " + portal.toString()); | ||||
|                     } else { | ||||
|                     	portal.drawSign(true); | ||||
|                     	portal.drawSign(); | ||||
|                     } | ||||
|  | ||||
|                 } | ||||
| @@ -873,6 +883,8 @@ public class Portal { | ||||
|     public static void closeAllGates() { | ||||
|     	Stargate.log.info("Closing all stargates."); | ||||
|     	for (Portal p : allPortals) { | ||||
|     		if (p == null) continue; | ||||
|     		//if (!p.isLoaded()) continue; | ||||
|     		p.close(true); | ||||
|     	} | ||||
|     } | ||||
|   | ||||
| @@ -26,6 +26,8 @@ import org.bukkit.event.player.PlayerListener; | ||||
| import org.bukkit.event.player.PlayerMoveEvent; | ||||
| import org.bukkit.event.vehicle.VehicleListener; | ||||
| 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.PluginDescriptionFile; | ||||
| import org.bukkit.plugin.PluginLoader; | ||||
| @@ -48,6 +50,7 @@ public class Stargate extends JavaPlugin { | ||||
|     private final bListener blockListener = new bListener(); | ||||
|     private final pListener playerListener = new pListener(); | ||||
|     private final vListener vehicleListener = new vListener(); | ||||
|     private final wListener worldListener = new wListener(); | ||||
|     public static Logger log; | ||||
|     private Configuration config; | ||||
|     private PluginManager pm; | ||||
| @@ -82,20 +85,10 @@ public class Stargate extends JavaPlugin { | ||||
|     public void onEnable() { | ||||
|         PluginDescriptionFile pdfFile = this.getDescription(); | ||||
|         pm = getServer().getPluginManager(); | ||||
|          | ||||
|         /* 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; | ||||
|         }*/ | ||||
|         config = this.getConfiguration(); | ||||
|          | ||||
|         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_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.SIGN_CHANGE, blockListener, Priority.Normal, this); | ||||
|     	 | ||||
|     	pm.registerEvent(Event.Type.WORLD_LOADED, worldListener, Priority.Normal, this); | ||||
|     	 | ||||
|     	getServer().getScheduler().scheduleSyncRepeatingTask(this, new SGThread(), 0L, 100L); | ||||
|     } | ||||
|  | ||||
| @@ -309,7 +304,7 @@ public class Stargate extends JavaPlugin { | ||||
|                     player.sendMessage(ChatColor.GREEN + regMsg); | ||||
|                 } | ||||
|                 log.info("Initialized stargate: " + portal.getName()); | ||||
|                 portal.drawSign(true); | ||||
|                 portal.drawSign(); | ||||
|                 // Set event text so our new sign is instantly initialized | ||||
|                 event.setLine(0, sign.getText(0)); | ||||
|                 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") | ||||
| 	public static Boolean hasPerm(Player player, String perm, Boolean def) { | ||||
|     	if (Permissions != null) | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| name: Stargate | ||||
| main: net.TheDgtl.Stargate.Stargate | ||||
| version: 0.12 | ||||
| version: 0.13 | ||||
| description: Stargate mod for Bukkit | ||||
| author: Drakia | ||||
| website: http://www.thedgtl.net | ||||
		Reference in New Issue
	
	Block a user
	 Drakia
					Drakia