zKoth/src/fr/maxlego08/koth/hook/TeamPlugin.java

56 lines
1.8 KiB
Java
Raw Normal View History

2024-02-22 13:14:16 +01:00
package fr.maxlego08.koth.hook;
import fr.maxlego08.koth.KothPlugin;
import fr.maxlego08.koth.api.KothTeam;
2024-02-22 21:04:51 +01:00
import fr.maxlego08.koth.hook.teams.BetterTeamHook;
2024-03-16 11:57:10 +01:00
import fr.maxlego08.koth.hook.teams.GangsHook;
2024-02-22 13:14:16 +01:00
import fr.maxlego08.koth.hook.teams.HuskTownHook;
import fr.maxlego08.koth.hook.teams.LandHook;
import fr.maxlego08.koth.hook.teams.SaberFactionHook;
2024-02-24 15:31:30 +01:00
import fr.maxlego08.koth.hook.teams.SimpleClanHook;
2024-02-22 20:59:04 +01:00
import fr.maxlego08.koth.hook.teams.SuperiorSkyblock2Hook;
2024-02-22 13:14:16 +01:00
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.lang.reflect.InvocationTargetException;
public enum TeamPlugin {
LANDS("Lands", LandHook.class),
HUSKTOWN("HuskTowns", HuskTownHook.class),
2024-02-22 20:59:04 +01:00
SUPERIORSKYBLOCK("SuperiorSkyblock2", SuperiorSkyblock2Hook.class),
2024-02-22 21:04:51 +01:00
BETTERTEAMS("BetterTeams", BetterTeamHook.class),
FACTIONS("Factions", SaberFactionHook.class),
2024-02-24 15:31:30 +01:00
SIMPLECLANS("SimpleClans", SimpleClanHook.class),
2024-03-16 11:57:10 +01:00
GANGSPLUS("GangsPlus", GangsHook.class),
2024-02-22 13:14:16 +01:00
;
private final String pluginName;
private final Class<? extends KothTeam> teamHook;
TeamPlugin(String pluginName, Class<? extends KothTeam> teamHook) {
this.pluginName = pluginName;
this.teamHook = teamHook;
}
public String getPluginName() {
return pluginName;
}
public boolean isEnable() {
Plugin plugin = Bukkit.getPluginManager().getPlugin(this.pluginName);
return plugin != null && plugin.isEnabled();
}
public KothTeam init(KothPlugin plugin) {
try {
return teamHook.getConstructor(KothPlugin.class).newInstance(plugin);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
NoSuchMethodException exception) {
exception.printStackTrace();
}
return null;
}
}