Initial commit: LoParkour v1.1.0
This commit is contained in:
commit
aecb03ccf8
120 changed files with 9668 additions and 0 deletions
156
src/main/java/dev/loki/loparkour/LoParkour.java
Normal file
156
src/main/java/dev/loki/loparkour/LoParkour.java
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
package dev.loki.loparkour;
|
||||
|
||||
import dev.loki.loparkour.api.Registry;
|
||||
import dev.loki.loparkour.config.Config;
|
||||
import dev.loki.loparkour.config.Locales;
|
||||
import dev.loki.loparkour.config.Option;
|
||||
import dev.loki.loparkour.hook.HoloHook;
|
||||
import dev.loki.loparkour.hook.PAPIHook;
|
||||
import dev.loki.loparkour.mode.DefaultMode;
|
||||
import dev.loki.loparkour.mode.Modes;
|
||||
import dev.loki.loparkour.mode.SpectatorMode;
|
||||
import dev.loki.loparkour.player.ParkourUser;
|
||||
import dev.loki.loparkour.reward.Rewards;
|
||||
import dev.loki.loparkour.storage.Storage;
|
||||
import dev.loki.loparkour.world.World;
|
||||
import dev.efnilite.vilib.ViPlugin;
|
||||
import dev.efnilite.vilib.bstats.bukkit.Metrics;
|
||||
import dev.efnilite.vilib.bstats.charts.SimplePie;
|
||||
import dev.efnilite.vilib.bstats.charts.SingleLineChart;
|
||||
import dev.efnilite.vilib.inventory.Menu;
|
||||
import dev.efnilite.vilib.util.Logging;
|
||||
import dev.efnilite.vilib.util.UpdateChecker;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Main class of LoParkour
|
||||
*
|
||||
* @author loki
|
||||
*/
|
||||
public final class LoParkour extends ViPlugin {
|
||||
|
||||
public static final String NAME = "&#FF6464<bold>LoParkour<reset>";
|
||||
public static final String PREFIX = NAME + " 񢩈» &#A0A0A0";
|
||||
|
||||
private static Logging logging;
|
||||
private static LoParkour instance;
|
||||
|
||||
@Nullable
|
||||
private static PAPIHook placeholderHook;
|
||||
|
||||
public static void log(String message) {
|
||||
if (Config.CONFIG.getBoolean("debug")) {
|
||||
logging.info("[Debug] " + message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param child The file name.
|
||||
* @return A file from within the plugin folder.
|
||||
*/
|
||||
public static File getInFolder(String child) {
|
||||
return new File(instance.getDataFolder(), child);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return This plugin's {@link Logging} instance.
|
||||
*/
|
||||
public static Logging logging() {
|
||||
return logging;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The plugin instance.
|
||||
*/
|
||||
public static LoParkour getPlugin() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PAPIHook getPlaceholderHook() {
|
||||
return placeholderHook;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
instance = this;
|
||||
logging = new Logging(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
|
||||
// ----- Configurations -----
|
||||
|
||||
Config.reload(true);
|
||||
|
||||
// ----- Registry -----
|
||||
|
||||
Registry.register(new DefaultMode());
|
||||
Registry.register(new SpectatorMode());
|
||||
|
||||
Modes.init();
|
||||
Menu.init(this);
|
||||
|
||||
// hook with hd / papi after gamemode leaderboards have initialized
|
||||
if (getServer().getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||
logging.info("Registered Holographic Displays hook");
|
||||
HoloHook.init();
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
logging.info("Registered PlaceholderAPI hook");
|
||||
placeholderHook = new PAPIHook();
|
||||
placeholderHook.register();
|
||||
}
|
||||
|
||||
if (Config.CONFIG.getBoolean("bungeecord.enabled")) {
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
logging.info("Registered BungeeCord hook");
|
||||
}
|
||||
|
||||
// ----- Worlds -----
|
||||
|
||||
if (Config.CONFIG.getBoolean("joining")) {
|
||||
World.create();
|
||||
}
|
||||
|
||||
// ----- Events -----
|
||||
|
||||
registerListener(new Events());
|
||||
registerCommand("LoParkour", new Command());
|
||||
|
||||
// ----- Metrics -----
|
||||
|
||||
Metrics metrics = new Metrics(this, 9272);
|
||||
metrics.addCustomChart(new SimplePie("using_sql", () -> Boolean.toString(Option.SQL)));
|
||||
metrics.addCustomChart(new SimplePie("using_rewards", () -> Boolean.toString(Rewards.REWARDS_ENABLED)));
|
||||
metrics.addCustomChart(new SimplePie("locale_count", () -> Integer.toString(Locales.locales.size())));
|
||||
metrics.addCustomChart(new SingleLineChart("player_joins", () -> {
|
||||
int joins = ParkourUser.joinCount;
|
||||
ParkourUser.joinCount = 0;
|
||||
return joins;
|
||||
}));
|
||||
|
||||
UpdateChecker.check(this, 87226);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
try {
|
||||
for (ParkourUser user : ParkourUser.getUsers()) {
|
||||
ParkourUser.leave(user);
|
||||
}
|
||||
|
||||
// write all LoParkour gamemodes
|
||||
Modes.DEFAULT.getLeaderboard().write(false);
|
||||
|
||||
Storage.close();
|
||||
World.delete();
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue