API changes for StargateCommand
This commit is contained in:
		
							
								
								
									
										2
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								README
									
									
									
									
									
								
							@@ -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]
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
@@ -175,6 +175,14 @@ public class Gate {
 | 
			
		||||
	public Character[][] getLayout() {
 | 
			
		||||
		return layout;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public HashMap<Character, Integer> getTypes() {
 | 
			
		||||
		return types;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public HashMap<Character, Integer> getMetaData() {
 | 
			
		||||
		return metadata;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public RelativeBlockVector[] getEntrances() {
 | 
			
		||||
		return entrances;
 | 
			
		||||
@@ -206,11 +214,19 @@ public class Gate {
 | 
			
		||||
	public int getPortalBlockOpen() {
 | 
			
		||||
		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>>();
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -262,6 +262,10 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
	public static String getSaveLocation() {
 | 
			
		||||
		return portalFolder;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static String getGateFolder() {
 | 
			
		||||
		return gateFolder;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static String getDefaultNetwork() {
 | 
			
		||||
		return defNetwork;
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user