[Version 0.7.4.0]
- Fixed issue with non-air closed portal blocks - Added StargatePortalEvent/onStargatePortal event
This commit is contained in:
parent
89491a5c26
commit
5c34a21bf6
3
README
3
README
@ -198,6 +198,9 @@ createConflict=Gate conflicts with existing gate
|
||||
=============
|
||||
Changes
|
||||
=============
|
||||
[Version 0.7.4.0]
|
||||
- Fixed issue with non-air closed portal blocks
|
||||
- Added StargatePortalEvent/onStargatePortal event
|
||||
[Version 0.7.3.3]
|
||||
- Added "ignoreEntrance" option to not check entrance to gate on integrity check (Workaround for snowmen until event is pulled)
|
||||
[Version 0.7.3.2]
|
||||
|
@ -216,12 +216,12 @@ public class Gate {
|
||||
public Boolean getToOwner() {
|
||||
return toOwner;
|
||||
}
|
||||
|
||||
public boolean matches(Block topleft, int modX, int modZ) {
|
||||
return matches(new Blox(topleft), modX, modZ);
|
||||
|
||||
public boolean matches(Blox topleft, int modX, int modZ) {
|
||||
return matches(topleft, modX, modZ, false);
|
||||
}
|
||||
|
||||
public boolean matches(Blox topleft, int modX, int modZ) {
|
||||
public boolean matches(Blox topleft, int modX, int modZ, boolean onCreate) {
|
||||
for (int y = 0; y < layout.length; y++) {
|
||||
for (int x = 0; x < layout[y].length; x++) {
|
||||
int id = types.get(layout[y][x]);
|
||||
@ -231,6 +231,10 @@ public class Gate {
|
||||
if (Stargate.ignoreEntrance) continue;
|
||||
|
||||
int type = topleft.modRelative(x, y, 0, modX, 1, modZ).getType();
|
||||
|
||||
// Ignore entrance if it's air and we're creating a new gate
|
||||
if (onCreate && type == Material.AIR.getId()) continue;
|
||||
|
||||
if (type != portalBlockClosed && type != portalBlockOpen) {
|
||||
// Special case for water gates
|
||||
if (portalBlockOpen == Material.WATER.getId() || portalBlockOpen == Material.STATIONARY_WATER.getId()) {
|
||||
|
@ -13,6 +13,7 @@ import net.TheDgtl.Stargate.event.StargateActivateEvent;
|
||||
import net.TheDgtl.Stargate.event.StargateCloseEvent;
|
||||
import net.TheDgtl.Stargate.event.StargateDeactivateEvent;
|
||||
import net.TheDgtl.Stargate.event.StargateOpenEvent;
|
||||
import net.TheDgtl.Stargate.event.StargatePortalEvent;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -326,6 +327,19 @@ public class Portal {
|
||||
// Handle backwards gates
|
||||
int adjust = isBackwards() ? 0 :180;
|
||||
exit.setYaw(origin.getRotation() - traveller.getYaw() + this.getRotation() + adjust);
|
||||
|
||||
// Call the StargatePortalEvent to allow plugins to change destination
|
||||
if (!origin.equals(this)) {
|
||||
StargatePortalEvent pEvent = new StargatePortalEvent(player, origin, this, exit);
|
||||
Stargate.server.getPluginManager().callEvent(pEvent);
|
||||
// Teleport is cancelled
|
||||
if (pEvent.isCancelled()) {
|
||||
origin.teleport(player, origin, event);
|
||||
return;
|
||||
}
|
||||
// Update exit if needed
|
||||
exit = pEvent.getExit();
|
||||
}
|
||||
|
||||
// The new method to teleport in a move event is set the "to" field.
|
||||
event.setTo(exit);
|
||||
@ -755,7 +769,7 @@ public class Portal {
|
||||
Blox tl = parent.modRelative(-vector.getRight(), -vector.getDepth(), -vector.getDistance(), modX, 1, modZ);
|
||||
|
||||
if (gate == null) {
|
||||
if (possibility.matches(tl, modX, modZ)) {
|
||||
if (possibility.matches(tl, modX, modZ, true)) {
|
||||
gate = possibility;
|
||||
topleft = tl;
|
||||
|
||||
@ -882,6 +896,11 @@ public class Portal {
|
||||
portal.open(true);
|
||||
dest.drawSign();
|
||||
}
|
||||
// Set the inside of the gate to its closed material
|
||||
} else {
|
||||
for (Blox inside : portal.getEntrances()) {
|
||||
inside.setType(portal.getGate().getPortalBlockClosed());
|
||||
}
|
||||
}
|
||||
|
||||
// Open any always on gate pointing at this gate
|
||||
|
@ -25,6 +25,10 @@ public class StargateListener extends CustomEventListener implements Listener {
|
||||
|
||||
}
|
||||
|
||||
public void onStargatePortal(StargatePortalEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCustomEvent(Event event) {
|
||||
if (event instanceof StargateOpenEvent) {
|
||||
@ -35,6 +39,8 @@ public class StargateListener extends CustomEventListener implements Listener {
|
||||
onStargateActivate((StargateActivateEvent)event);
|
||||
} else if (event instanceof StargateDeactivateEvent) {
|
||||
onStargateDeactivate((StargateDeactivateEvent)event);
|
||||
} else if (event instanceof StargatePortalEvent) {
|
||||
onStargatePortal((StargatePortalEvent)event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
52
src/net/TheDgtl/Stargate/event/StargatePortalEvent.java
Normal file
52
src/net/TheDgtl/Stargate/event/StargatePortalEvent.java
Normal file
@ -0,0 +1,52 @@
|
||||
package net.TheDgtl.Stargate.event;
|
||||
|
||||
import net.TheDgtl.Stargate.Portal;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class StargatePortalEvent extends StargateEvent {
|
||||
private static final long serialVersionUID = -7263321536459960366L;
|
||||
private Player player;
|
||||
private Portal destination;
|
||||
private Location exit;
|
||||
|
||||
public StargatePortalEvent(Player player, Portal portal, Portal dest, Location exit) {
|
||||
super ("StargatePortalEvent", portal);
|
||||
|
||||
this.player = player;
|
||||
this.destination = dest;
|
||||
this.exit = exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the player that went through the gate.
|
||||
* @return player that went through the gate
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the destination gate
|
||||
* @return destination gate
|
||||
*/
|
||||
public Portal getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the location of the players exit point
|
||||
* @return org.bukkit.Location Location of the exit point
|
||||
*/
|
||||
public Location getExit() {
|
||||
return exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the location of the players exit point
|
||||
*/
|
||||
public void setExit(Location loc) {
|
||||
this.exit = loc;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
name: Stargate
|
||||
main: net.TheDgtl.Stargate.Stargate
|
||||
version: 0.7.3.3
|
||||
version: 0.7.4.0
|
||||
description: Stargate mod for Bukkit
|
||||
author: Drakia
|
||||
website: http://www.thedgtl.net
|
||||
|
Loading…
Reference in New Issue
Block a user