mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-12-05 11:44:15 +01:00
created the tag handler registry
This commit is contained in:
parent
c93b4e92b5
commit
5183684f2f
@ -1,16 +0,0 @@
|
|||||||
package com.sekwah.advancedportals.api.registry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by on 25/07/2016.
|
|
||||||
*
|
|
||||||
* @author sekwah41
|
|
||||||
*/
|
|
||||||
public class TagInfo {
|
|
||||||
|
|
||||||
private final String dataType;
|
|
||||||
|
|
||||||
public TagInfo(String tag, String dataType){
|
|
||||||
this.dataType = dataType;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package com.sekwah.advancedportals.api.registry;
|
package com.sekwah.advancedportals.api.registry;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.api.warphandler.TagHandler;
|
import com.sekwah.advancedportals.api.warphandler.TagHandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -13,15 +14,21 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class TagRegistry {
|
public class TagRegistry {
|
||||||
|
|
||||||
|
private final AdvancedPortalsPlugin plugin;
|
||||||
|
|
||||||
private ArrayList<String> tags = new ArrayList<String>();
|
private ArrayList<String> tags = new ArrayList<String>();
|
||||||
|
|
||||||
private Map<String, TagInfo> tagDesc = new HashMap<String, TagInfo>();
|
private Map<String, TagHandler.Activation> tagActivation = new HashMap<String, TagHandler.Activation>();
|
||||||
|
|
||||||
|
private Map<String, TagHandler.Creation> tagCreation = new HashMap<String, TagHandler.Creation>();
|
||||||
|
|
||||||
|
private Map<String, TagHandler.TagStatus> tagStatus = new HashMap<String, TagHandler.TagStatus>();
|
||||||
|
|
||||||
// TODO the event can be used for general data detection and management, but use a TagHandler to make it so they can register
|
// 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.
|
// the individual class to handle.
|
||||||
|
|
||||||
public TagRegistry(){
|
public TagRegistry(AdvancedPortalsPlugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -30,14 +37,29 @@ public class TagRegistry {
|
|||||||
* @return if the tag has been registered or if it already exists.
|
* @return if the tag has been registered or if it already exists.
|
||||||
*/
|
*/
|
||||||
public boolean registerTag(String tag, TagHandler tagHandler){
|
public boolean registerTag(String tag, TagHandler tagHandler){
|
||||||
tagDesc.
|
|
||||||
if(tagHandler == null){
|
|
||||||
|
|
||||||
|
if(tag == null){
|
||||||
|
plugin.getLogger().warning("A tag can not be null.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
if(!(tagHandler instanceof TagHandler.Activation) && !(tagHandler instanceof TagHandler.TagStatus) &&
|
|
||||||
!(tagHandler instanceof TagHandler.Creation)){
|
|
||||||
|
|
||||||
|
if(tags.contains(tag)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tags.add(tag);
|
||||||
|
|
||||||
|
if(tagHandler != null && !(tagHandler instanceof TagHandler.Activation) && !(tagHandler instanceof TagHandler.TagStatus) &&
|
||||||
|
!(tagHandler instanceof TagHandler.Creation)){
|
||||||
|
plugin.getLogger().warning("Error with tag: " + tag + ". A tag handler must implement one of the handlers. Not just extend.");
|
||||||
|
if(tagHandler instanceof TagHandler.Activation){
|
||||||
|
tagActivation.put(tag, (TagHandler.Activation) tagHandler);
|
||||||
|
}
|
||||||
|
if(tagHandler instanceof TagHandler.TagStatus){
|
||||||
|
tagStatus.put(tag, (TagHandler.TagStatus) tagHandler);
|
||||||
|
}
|
||||||
|
if(tagHandler instanceof TagHandler.Creation){
|
||||||
|
tagCreation.put(tag, (TagHandler.Creation) tagHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user