[Version 0.7.9.1]

- Optimize gate lookup in onPlayerMove
 - Resolve issue where Stargates would teleport players to the nether
This commit is contained in:
Steven Scott 2012-12-01 11:54:02 -08:00
parent 921d289fc2
commit 422b30d54e
5 changed files with 22 additions and 8 deletions

3
README
View File

@ -213,6 +213,9 @@ Unable to reproduce: Stargates teleport a user into the ground/under the ground
============= =============
Changes Changes
============= =============
[Version 0.7.9.1]
- Optimize gate lookup in onPlayerMove
- Resolve issue where Stargates would teleport players to the nether
[Version 0.7.9.0] [Version 0.7.9.0]
- Added BungeeCord multi-server support (Requires Stargate-Bungee for BungeeCord) - Added BungeeCord multi-server support (Requires Stargate-Bungee for BungeeCord)
- Updated Spanish language file - Updated Spanish language file

View File

@ -316,6 +316,7 @@ public class Gate {
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<Character, Integer> metadata = new HashMap<Character, Integer>();
HashMap<String, String> config = new HashMap<String, String>(); HashMap<String, String> config = new HashMap<String, String>();
HashSet<Integer> frameTypes = new HashSet<Integer>();
int cols = 0; int cols = 0;
// Init types map // Init types map
@ -365,7 +366,7 @@ public class Gate {
Integer id = Integer.parseInt(value); Integer id = Integer.parseInt(value);
types.put(symbol, id); types.put(symbol, id);
frameBlocks.add(id); frameTypes.add(id);
} else { } else {
config.put(key, value); config.put(key, value);
} }
@ -408,10 +409,13 @@ public class Gate {
if (gate.getControls().length != 2) { if (gate.getControls().length != 2) {
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points."); Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points.");
return null; return null;
} else {
gate.save(file.getParent() + "/"); // Updates format for version changes
return gate;
} }
// Merge frame types, add open mat to list
frameBlocks.addAll(frameTypes);
gate.save(file.getParent() + "/"); // Updates format for version changes
return gate;
} }
private static int readConfig(HashMap<String, String> config, Gate gate, File file, String key, int def) { private static int readConfig(HashMap<String, String> config, Gate gate, File file, String key, int def) {

View File

@ -1188,7 +1188,7 @@ public class Portal {
} }
public static Portal getByEntrance(Location location) { public static Portal getByEntrance(Location location) {
return getByEntrance(new Blox(location).getBlock()); return lookupEntrances.get(new Blox(location));
} }
public static Portal getByEntrance(Block block) { public static Portal getByEntrance(Block block) {

View File

@ -723,6 +723,7 @@ public class Stargate extends JavaPlugin {
} }
private class pListener implements Listener { private class pListener implements Listener {
@EventHandler @EventHandler
public void onPlayerPortal(PlayerPortalEvent event) { public void onPlayerPortal(PlayerPortalEvent event) {
if (event.isCancelled()) return; if (event.isCancelled()) return;
@ -741,7 +742,8 @@ public class Stargate extends JavaPlugin {
for (int k = -2; k < 2; k++) { for (int k = -2; k < 2; k++) {
Block b = world.getBlockAt(cX + i, cY + j, cZ + k); Block b = world.getBlockAt(cX + i, cY + j, cZ + k);
// We only need to worry about portal mat // We only need to worry about portal mat
if (b.getType() != Material.PORTAL) continue; // Commented out for now, due to new Minecraft insta-nether
//if (b.getType() != Material.PORTAL) continue;
Portal portal = Portal.getByEntrance(b); Portal portal = Portal.getByEntrance(b);
if (portal != null) { if (portal != null) {
event.setCancelled(true); event.setCancelled(true);
@ -755,9 +757,14 @@ public class Stargate extends JavaPlugin {
@EventHandler @EventHandler
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
if (event.isCancelled()) return; if (event.isCancelled()) return;
// Check to see if the player actually moved
if (event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockY() == event.getTo().getBlockY() && event.getFrom().getBlockZ() == event.getTo().getBlockZ()) {
return;
}
Player player = event.getPlayer(); Player player = event.getPlayer();
Portal portal = Portal.getByEntrance(event.getTo()); Portal portal = Portal.getByEntrance(event.getTo());
// No portal or not open // No portal or not open
if (portal == null || !portal.isOpen()) return; if (portal == null || !portal.isOpen()) return;

View File

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