[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
=============
[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]
- Added BungeeCord multi-server support (Requires Stargate-Bungee for BungeeCord)
- Updated Spanish language file

View File

@ -316,6 +316,7 @@ public class Gate {
HashMap<Character, Integer> types = new HashMap<Character, Integer>();
HashMap<Character, Integer> metadata = new HashMap<Character, Integer>();
HashMap<String, String> config = new HashMap<String, String>();
HashSet<Integer> frameTypes = new HashSet<Integer>();
int cols = 0;
// Init types map
@ -365,7 +366,7 @@ public class Gate {
Integer id = Integer.parseInt(value);
types.put(symbol, id);
frameBlocks.add(id);
frameTypes.add(id);
} else {
config.put(key, value);
}
@ -408,11 +409,14 @@ public class Gate {
if (gate.getControls().length != 2) {
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points.");
return null;
} else {
}
// 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) {
if (config.containsKey(key)) {

View File

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

View File

@ -723,6 +723,7 @@ public class Stargate extends JavaPlugin {
}
private class pListener implements Listener {
@EventHandler
public void onPlayerPortal(PlayerPortalEvent event) {
if (event.isCancelled()) return;
@ -741,7 +742,8 @@ public class Stargate extends JavaPlugin {
for (int k = -2; k < 2; k++) {
Block b = world.getBlockAt(cX + i, cY + j, cZ + k);
// 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);
if (portal != null) {
event.setCancelled(true);
@ -755,9 +757,14 @@ public class Stargate extends JavaPlugin {
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
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();
Portal portal = Portal.getByEntrance(event.getTo());
// No portal or not open
if (portal == null || !portal.isOpen()) return;

View File

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