mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-02 17:09:51 +01:00
Started creating the tag handlers
This commit is contained in:
parent
8a528230a3
commit
c3f466720d
@ -1,6 +1,6 @@
|
||||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.events.WarpEvent;
|
||||
import com.sekwah.advancedportals.api.events.WarpEvent;
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -86,7 +86,7 @@ public class Listeners implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Location fromloc = event.getFrom();
|
||||
//Location fromloc = event.getFrom();
|
||||
Location loc = event.getTo();
|
||||
// Potentially fixes that stupid error cauzed by a bukkit update.
|
||||
// Would save event.getTo() as eyeLoc and change the Y position but that seemed to teleport players.
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.sekwah.advancedportals.api.registry;
|
||||
|
||||
import com.sekwah.advancedportals.api.warphandler.TagHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -15,11 +17,33 @@ public class TagRegistry {
|
||||
|
||||
private Map<String, TagInfo> tagDesc = new HashMap<String, TagInfo>();
|
||||
|
||||
// TODO the event can be used for general data detection and management, but use a TagHandler to make it so they can register
|
||||
// the individual class to handle.
|
||||
|
||||
public TagRegistry(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return if the tag has been registered or if it already exists.
|
||||
*/
|
||||
public boolean registerTag(String tag, TagHandler tagHandler){
|
||||
tagDesc.
|
||||
if(tagHandler == null){
|
||||
|
||||
}
|
||||
else{
|
||||
if(!(tagHandler instanceof TagHandler.Activation) && !(tagHandler instanceof TagHandler.TagStatus) &&
|
||||
!(tagHandler instanceof TagHandler.Creation)){
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package com.sekwah.advancedportals.api.warphandler;
|
||||
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
|
||||
/**
|
||||
* Created by on 30/07/2016.
|
||||
*
|
||||
* @author sekwah41
|
||||
*/
|
||||
public class ActivationData {
|
||||
|
||||
private boolean warpAllowed = true;
|
||||
|
||||
private WarpedStatus warpStatus = WarpedStatus.INACTIVE;
|
||||
|
||||
private Portal activePortal;
|
||||
|
||||
public ActivationData(Portal portal){
|
||||
this.activePortal = portal;
|
||||
}
|
||||
|
||||
public WarpedStatus getWarped(){
|
||||
return this.warpStatus;
|
||||
}
|
||||
|
||||
public void setWarpStatus(WarpedStatus warped){
|
||||
if(this.warpStatus == WarpedStatus.WARPED){
|
||||
return;
|
||||
}
|
||||
else if(this.warpStatus == WarpedStatus.INACTIVE){
|
||||
return;
|
||||
}
|
||||
this.warpStatus = warped;
|
||||
}
|
||||
|
||||
/**
|
||||
* In case you need to set the status back down a step for whatever reason. However it is not recommended.
|
||||
* @param warped
|
||||
*/
|
||||
public void setWarpStatusAbsolute(WarpedStatus warped){
|
||||
this.warpStatus = warped;
|
||||
}
|
||||
|
||||
public boolean getAllowed(){
|
||||
return this.warpAllowed;
|
||||
}
|
||||
|
||||
public void setAllowed(boolean allowed){
|
||||
this.warpAllowed = allowed;
|
||||
}
|
||||
|
||||
public enum WarpedStatus{
|
||||
/**
|
||||
* Player has moved or something major has happened. (only one of these should activate)
|
||||
*/
|
||||
WARPED,
|
||||
/**
|
||||
* Shows that the portal has been activated even if a major function is not performed.
|
||||
*/
|
||||
ACTIVATED,
|
||||
/**
|
||||
* Nothing has activated on the portal.
|
||||
*/
|
||||
INACTIVE;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.sekwah.advancedportals.api.warphandler;
|
||||
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by on 30/07/2016.
|
||||
*
|
||||
* @author sekwah41
|
||||
*/
|
||||
public class TagHandler {
|
||||
|
||||
public interface Creation{
|
||||
|
||||
/**
|
||||
* Example if the player does not have access to use a tag on the portal.
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the portal can be created.
|
||||
*/
|
||||
boolean portalCreated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Example if the player does not have access to remove the portal.
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the portal can be destroyed.
|
||||
*/
|
||||
boolean portalDestroyed(Player player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
public interface Activation{
|
||||
|
||||
/**
|
||||
* Activates before the main part of portal activation.
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*/
|
||||
void portalPreActivated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Activates after portal activation
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*/
|
||||
void portalPostActivated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Activates if the portal is allowed from pre
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*/
|
||||
void portalActivated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
public interface TagStatus{
|
||||
|
||||
/**
|
||||
* If the user has access to add the tag
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the tag will be added.
|
||||
*/
|
||||
boolean tagAdded(Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* If the user has access to remove the tag
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the tag will be removed.
|
||||
*/
|
||||
boolean ragRemoved(Player player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user