2018-01-01 01:41:19 +01:00
|
|
|
package us.tastybento.bskyblock.managers;
|
|
|
|
|
2018-01-07 00:23:01 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2018-01-01 01:41:19 +01:00
|
|
|
import us.tastybento.bskyblock.BSkyBlock;
|
|
|
|
import us.tastybento.bskyblock.api.flags.Flag;
|
|
|
|
import us.tastybento.bskyblock.api.panels.PanelItem;
|
|
|
|
|
2018-01-29 05:44:57 +01:00
|
|
|
public class FlagsManager {
|
|
|
|
|
|
|
|
private BSkyBlock plugin;
|
|
|
|
|
|
|
|
public FlagsManager(BSkyBlock plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
2018-01-01 01:41:19 +01:00
|
|
|
|
|
|
|
private List<Flag> flags = new ArrayList<>();
|
|
|
|
|
|
|
|
public void registerFlag(Flag flag) {
|
|
|
|
//TODO all the security checks
|
2018-02-04 21:53:17 +01:00
|
|
|
//plugin.getLogger().info("DEBUG: registering flag " + flag.getID());
|
2018-01-01 01:41:19 +01:00
|
|
|
flags.add(flag);
|
|
|
|
// If there is a listener, register it into Bukkit.
|
2018-01-29 05:44:57 +01:00
|
|
|
flag.getListener().ifPresent(l -> plugin.getServer().getPluginManager().registerEvents(l, plugin));
|
2018-01-01 01:41:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<Flag> getFlags() {
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Flag getFlagByID(String id) {
|
|
|
|
for (Flag flag : flags) {
|
|
|
|
if (flag.getID().equals(id.toUpperCase())) return flag;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Flag getFlagByIcon(PanelItem item) {
|
|
|
|
for (Flag flag : flags) {
|
|
|
|
if (flag.getIcon().equals(item)) return flag;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|