Started creating the tag handlers

This commit is contained in:
Alastair 2016-07-31 02:22:43 +00:00 committed by Max Qian
parent 09ac2adf06
commit c93b4e92b5
4 changed files with 178 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -2,7 +2,7 @@ package com.sekwah.advancedportals.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
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.*;
@ -80,7 +80,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.