mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-03 16:13:30 +01:00
fa1ccd0c99
Added the adapter annotation to MySQL and fixed issues with empty hashmaps causing null errors. Added a flag serializer adapter for the protection flags so that flags are saved and loaded correctly. Renamed the Adapter notation class to be clearer about what it is doing.
46 lines
1.2 KiB
Java
46 lines
1.2 KiB
Java
package us.tastybento.bskyblock.managers;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import us.tastybento.bskyblock.BSkyBlock;
|
|
import us.tastybento.bskyblock.api.flags.Flag;
|
|
import us.tastybento.bskyblock.api.panels.PanelItem;
|
|
|
|
public class FlagsManager {
|
|
|
|
private BSkyBlock plugin;
|
|
|
|
public FlagsManager(BSkyBlock plugin) {
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
private List<Flag> flags = new ArrayList<>();
|
|
|
|
public void registerFlag(Flag flag) {
|
|
//TODO all the security checks
|
|
//plugin.getLogger().info("DEBUG: registering flag " + flag.getID());
|
|
flags.add(flag);
|
|
// If there is a listener, register it into Bukkit.
|
|
flag.getListener().ifPresent(l -> plugin.getServer().getPluginManager().registerEvents(l, plugin));
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|