mirror of
https://github.com/Maxlego08/zKoth.git
synced 2024-11-26 12:35:17 +01:00
🚧 Add scoreboard load
This commit is contained in:
parent
9b814aaca0
commit
b60d6bf52d
@ -1,9 +1,13 @@
|
||||
package fr.maxlego08.koth;
|
||||
|
||||
import fr.maxlego08.koth.api.KothScoreboard;
|
||||
import fr.maxlego08.koth.command.commands.CommandKoth;
|
||||
import fr.maxlego08.koth.hook.ScoreboardPlugin;
|
||||
import fr.maxlego08.koth.hook.scoreboard.DefaultHook;
|
||||
import fr.maxlego08.koth.placeholder.LocalPlaceholder;
|
||||
import fr.maxlego08.koth.save.MessageLoader;
|
||||
import fr.maxlego08.koth.zcore.ZPlugin;
|
||||
import fr.maxlego08.koth.zcore.logger.Logger;
|
||||
|
||||
/**
|
||||
* System to create your plugins very simply Projet:
|
||||
@ -14,6 +18,7 @@ import fr.maxlego08.koth.zcore.ZPlugin;
|
||||
public class KothPlugin extends ZPlugin {
|
||||
|
||||
private KothManager kothManager;
|
||||
private KothScoreboard kothScoreboard = new DefaultHook();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@ -36,6 +41,14 @@ public class KothPlugin extends ZPlugin {
|
||||
|
||||
this.loadFiles();
|
||||
|
||||
for (ScoreboardPlugin value : ScoreboardPlugin.values()) {
|
||||
if (value.isEnable()) {
|
||||
kothScoreboard = value.init(this);
|
||||
Logger.info("Register " + value.getPluginName() + " scoreboard implementation.", Logger.LogType.INFO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.postEnable();
|
||||
}
|
||||
|
||||
@ -50,6 +63,10 @@ public class KothPlugin extends ZPlugin {
|
||||
}
|
||||
|
||||
public KothManager getKothManager() {
|
||||
return kothManager;
|
||||
return this.kothManager;
|
||||
}
|
||||
|
||||
public KothScoreboard getKothScoreboard() {
|
||||
return this.kothScoreboard;
|
||||
}
|
||||
}
|
||||
|
51
src/fr/maxlego08/koth/hook/ScoreboardPlugin.java
Normal file
51
src/fr/maxlego08/koth/hook/ScoreboardPlugin.java
Normal file
@ -0,0 +1,51 @@
|
||||
package fr.maxlego08.koth.hook;
|
||||
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.api.KothScoreboard;
|
||||
import fr.maxlego08.koth.hook.scoreboard.FeatherBoardHook;
|
||||
import fr.maxlego08.koth.hook.scoreboard.SternalBoardHook;
|
||||
import fr.maxlego08.koth.hook.scoreboard.TabHook;
|
||||
import fr.maxlego08.koth.hook.scoreboard.TitleManagerHook;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public enum ScoreboardPlugin {
|
||||
|
||||
FEATHERBOARD("FeatherBoard", FeatherBoardHook.class),
|
||||
TAB("TAB", TabHook.class),
|
||||
STERNALBOARD("SternalBoard", SternalBoardHook.class),
|
||||
TITLEMANAGER("TitleManager", TitleManagerHook.class),
|
||||
|
||||
;
|
||||
|
||||
private final String pluginName;
|
||||
private final Class<? extends KothScoreboard> scoreboardClass;
|
||||
|
||||
private static KothScoreboard kothScoreboard;
|
||||
|
||||
ScoreboardPlugin(String pluginName, Class<? extends KothScoreboard> scoreboardClass) {
|
||||
this.pluginName = pluginName;
|
||||
this.scoreboardClass = scoreboardClass;
|
||||
}
|
||||
|
||||
public String getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
public boolean isEnable() {
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(this.pluginName);
|
||||
return plugin != null && plugin.isEnabled();
|
||||
}
|
||||
|
||||
public KothScoreboard init(KothPlugin plugin) {
|
||||
try {
|
||||
return scoreboardClass.getConstructor(KothPlugin.class).newInstance(plugin);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
|
||||
NoSuchMethodException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
21
src/fr/maxlego08/koth/hook/scoreboard/DefaultHook.java
Normal file
21
src/fr/maxlego08/koth/hook/scoreboard/DefaultHook.java
Normal file
@ -0,0 +1,21 @@
|
||||
package fr.maxlego08.koth.hook.scoreboard;
|
||||
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.api.KothScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class DefaultHook implements KothScoreboard {
|
||||
|
||||
|
||||
@Override
|
||||
public void toggle(Player player, Consumer<Player> after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide(Player player, Consumer<Player> after) {
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package fr.maxlego08.koth.hook.scoreboard;
|
||||
|
||||
import be.maximvdw.featherboard.api.FeatherBoardAPI;
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.api.KothScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -8,6 +9,10 @@ import java.util.function.Consumer;
|
||||
|
||||
public class FeatherBoardHook implements KothScoreboard {
|
||||
|
||||
public FeatherBoardHook(KothPlugin plugin){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggle(Player player, Consumer<Player> after) {
|
||||
if (!FeatherBoardAPI.isToggled(player)) {
|
||||
|
@ -2,6 +2,7 @@ package fr.maxlego08.koth.hook.scoreboard;
|
||||
|
||||
import com.xism4.sternalboard.SternalBoardPlugin;
|
||||
import com.xism4.sternalboard.managers.ScoreboardManager;
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.api.KothScoreboard;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -13,7 +14,7 @@ public class SternalBoardHook implements KothScoreboard {
|
||||
|
||||
private final ScoreboardManager manager;
|
||||
|
||||
public SternalBoardHook(Plugin plugin) {
|
||||
public SternalBoardHook(KothPlugin plugin) {
|
||||
super();
|
||||
this.manager = ((SternalBoardPlugin) Bukkit.getPluginManager().getPlugin("SternalBoard")).getScoreboardManager();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package fr.maxlego08.koth.hook.scoreboard;
|
||||
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.api.KothScoreboard;
|
||||
import me.neznamy.tab.api.TabAPI;
|
||||
import me.neznamy.tab.api.TabPlayer;
|
||||
@ -11,9 +12,9 @@ import org.bukkit.plugin.Plugin;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class TabHook implements KothScoreboard {
|
||||
private final Plugin plugin;
|
||||
private final KothPlugin plugin;
|
||||
|
||||
public TabHook(Plugin plugin) {
|
||||
public TabHook(KothPlugin plugin) {
|
||||
super();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package fr.maxlego08.koth.hook.scoreboard;
|
||||
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.api.KothScoreboard;
|
||||
import io.puharesource.mc.titlemanager.api.v2.TitleManagerAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -11,6 +12,10 @@ public class TitleManagerHook implements KothScoreboard {
|
||||
|
||||
private TitleManagerAPI api;
|
||||
|
||||
public TitleManagerHook(KothPlugin plugin){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggle(Player player, Consumer<Player> after) {
|
||||
if (api == null)
|
||||
|
@ -11,9 +11,15 @@
|
||||
# /zkoth - zkoth.use - Displays the list of commands
|
||||
# /zkoth reload - zkoth.reload - Reload configuration files
|
||||
# /zkoth axe - zkoth.axe - Getting the selection axe
|
||||
# /zkoth create <koth name> [<koth type>] [<capture/score] - zkoth.create - Create koth
|
||||
#
|
||||
# Placeholders:
|
||||
#
|
||||
#
|
||||
# Supported Scoreboard Plugin:
|
||||
# - FeatherBoard
|
||||
# - SternalBoard
|
||||
# - Tab
|
||||
# - TitleManager
|
||||
#
|
||||
#########################################################################################################
|
||||
|
@ -5,4 +5,21 @@ website: https://www.spigotmc.org/resources/76749/
|
||||
description: Default plugin developed by GroupeZ
|
||||
version: 3.0.0
|
||||
api-version: 1.13
|
||||
softdepend:
|
||||
- PlaceholderAPI
|
||||
- FeatherBoard
|
||||
- TAB
|
||||
- TitleManager
|
||||
- SternalBoard
|
||||
- Guilds
|
||||
- Factions
|
||||
- FactionsX
|
||||
- SuperiorSkyblock2
|
||||
- LegacyFactions
|
||||
- UltimateFactions
|
||||
- Multiverse-Core
|
||||
- SimpleClan
|
||||
- zSchedulers
|
||||
- DecentHolograms
|
||||
- HuskTowns
|
||||
commands:
|
Loading…
Reference in New Issue
Block a user