Skip to content

Commit

Permalink
Paper plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
JLyne committed Aug 5, 2024
1 parent dbb4bd8 commit 61b78ef
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 48 deletions.
25 changes: 13 additions & 12 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,51 @@ public final class PlatformDetectionPaper extends JavaPlugin implements Listener

@Override
public void onEnable() {
boolean floodgateEnabled = getServer().getPluginManager().isPluginEnabled("floodgate");
boolean vivecraftEnabled = getServer().getPluginManager().isPluginEnabled("Vivecraft-Spigot-Extensions");

if(floodgateEnabled) {
floodgateHandler = new FloodgateHandlerPaper();
}

if(vivecraftEnabled) {
vivecraftHandler = new VivecraftHandlerPaper();
}

expansion = new PlatformPlaceholders(this);
expansion.register();

getServer().getPluginManager().registerEvents(this, this);
}

@EventHandler
public void onPluginEnable(PluginEnableEvent event) {
if(event.getPlugin().getName().equals("floodgate")) {
floodgateHandler = new FloodgateHandlerPaper();
}

if(event.getPlugin().getName().equals("Vivecraft-Spigot-Extensions")) {
vivecraftHandler = new VivecraftHandlerPaper();
switch (event.getPlugin().getName()) {
case "PlaceholderAPI" -> {
getLogger().info("Registering PlaceholderAPI expansion");
expansion = new PlatformPlaceholders(this);
expansion.register();
}
case "floodgate" -> {
getLogger().info("Initialising Floodgate handler");
floodgateHandler = new FloodgateHandlerPaper();
}
case "Vivecraft-Spigot-Extensions" -> {
getLogger().info("Initialising Vivecraft handler");
vivecraftHandler = new VivecraftHandlerPaper();
}
}
}

@EventHandler
public void onPluginDisable(PluginDisableEvent event) {
if(event.getPlugin().getName().equals("floodgate")) {
floodgateHandler = null;
}

if(event.getPlugin().getName().equals("Vivecraft-Spigot-Extensions")) {
vivecraftHandler = null;
switch (event.getPlugin().getName()) {
case "PlaceholderAPI" -> {
getLogger().info("Disabling PlaceholderAPI expansion");
expansion = null;
}
case "floodgate" -> {
getLogger().info("Disabling Floodgate handler");
floodgateHandler = null;
}
case "Vivecraft-Spigot-Extensions" -> {
getLogger().info("Disabling Vivecraft handler");
vivecraftHandler = null;
}
}
}

@Override
public void onDisable() {
expansion.unregister();
if(expansion != null) {
expansion.unregister();
}
}

public Platform getPlatform(Player player) {
Expand Down
19 changes: 19 additions & 0 deletions PlatformDetection-paper/src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: PlatformDetection
version: @project.version@
main: uk.co.notnull.platformdetection.PlatformDetectionPaper
author: Jim (AnEnragedPigeon)
api-version: '1.21'
load: STARTUP
description: Detects the platform/mod players are using

dependencies:
server:
PlaceholderAPI:
load: BEFORE
required: false
floodgate:
load: BEFORE
required: false
Vivecraft-Spigot-Extensions:
load: BEFORE
required: false
9 changes: 0 additions & 9 deletions PlatformDetection-paper/src/main/resources/plugin.yml

This file was deleted.

0 comments on commit 61b78ef

Please sign in to comment.