API changes for StargateCommand

This commit is contained in:
Steven Scott 2012-03-14 21:57:54 -07:00
parent 4367e3a36a
commit 88b30b3579
6 changed files with 59 additions and 10 deletions

2
README
View File

@ -202,6 +202,8 @@ createConflict=Gate conflicts with existing gate
=============
Changes
=============
[Version 0.7.6.1]
- API update to support StargateCommand
[Version 0.7.6]
- Moved gate opening/closing to a Queue/Runnable system to resolve server lag issues with very large gates
[Version 0.7.5.11]

View File

@ -61,7 +61,7 @@ public class Gate {
private int destroyCost = -1;
private boolean toOwner = false;
private Gate(String filename, Character[][] layout, HashMap<Character, Integer> types, HashMap<Character, Integer> metadata) {
public Gate(String filename, Character[][] layout, HashMap<Character, Integer> types, HashMap<Character, Integer> metadata) {
this.filename = filename;
this.layout = layout;
this.metadata = metadata;
@ -176,6 +176,14 @@ public class Gate {
return layout;
}
public HashMap<Character, Integer> getTypes() {
return types;
}
public HashMap<Character, Integer> getMetaData() {
return metadata;
}
public RelativeBlockVector[] getEntrances() {
return entrances;
}
@ -207,10 +215,18 @@ public class Gate {
return portalBlockOpen;
}
public void setPortalBlockOpen(int type) {
portalBlockOpen = type;
}
public int getPortalBlockClosed() {
return portalBlockClosed;
}
public void setPortalBlockClosed(int type) {
portalBlockClosed = type;
}
public int getUseCost() {
if (useCost < 0) return iConomyHandler.useCost;
return useCost;
@ -281,7 +297,7 @@ public class Gate {
return true;
}
private static void registerGate(Gate gate) {
public static void registerGate(Gate gate) {
gates.put(gate.getFilename(), gate);
int blockID = gate.getControlBlock();
@ -293,7 +309,7 @@ public class Gate {
controlBlocks.get(blockID).add(gate);
}
private static Gate loadGate(File file) {
public static Gate loadGate(File file) {
Scanner scanner = null;
boolean designing = false;
ArrayList<ArrayList<Character>> design = new ArrayList<ArrayList<Character>>();

View File

@ -524,10 +524,6 @@ public class Portal {
}
public void activate(Player player) {
StargateActivateEvent event = new StargateActivateEvent(this, player);
Stargate.server.getPluginManager().callEvent(event);
if (event.isCancelled()) return;
destinations.clear();
destination = "";
Stargate.activeList.add(this);
@ -554,6 +550,15 @@ public class Portal {
if (Stargate.destMemory && !lastDest.isEmpty() && destinations.contains(lastDest)) {
destination = lastDest;
}
StargateActivateEvent event = new StargateActivateEvent(this, player, destinations, destination);
Stargate.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
Stargate.activeList.remove(this);
return;
}
destination = event.getDestination();
destinations = event.getDestinations();
drawSign();
}

View File

@ -263,6 +263,10 @@ public class Stargate extends JavaPlugin {
return portalFolder;
}
public static String getGateFolder() {
return gateFolder;
}
public static String getDefaultNetwork() {
return defNetwork;
}

View File

@ -1,5 +1,7 @@
package net.TheDgtl.Stargate.event;
import java.util.ArrayList;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
@ -24,7 +26,9 @@ import net.TheDgtl.Stargate.Portal;
*/
public class StargateActivateEvent extends StargateEvent {
Player player;
private Player player;
private ArrayList<String> destinations;
private String destination;
private static final HandlerList handlers = new HandlerList();
@ -35,13 +39,31 @@ public class StargateActivateEvent extends StargateEvent {
public static HandlerList getHandlerList() {
return handlers;
}
public StargateActivateEvent(Portal portal, Player player) {
public StargateActivateEvent(Portal portal, Player player, ArrayList<String> destinations, String destination) {
super("StargatActivateEvent", portal);
this.player = player;
this.destinations = destinations;
this.destination = destination;
}
public Player getPlayer() {
return player;
}
public ArrayList<String> getDestinations() {
return destinations;
}
public void setDestinations(ArrayList<String> destinations) {
this.destinations = destinations;
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
}

View File

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