Skip to content

Commit

Permalink
bungeecord hooks for NuVotifier, LiteBans, AdvancedBan
Browse files Browse the repository at this point in the history
  • Loading branch information
quiquelhappy committed Mar 13, 2021
1 parent b9cb01c commit c8668e9
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 5 deletions.
27 changes: 22 additions & 5 deletions module/universal/src/io/purecore/mcplugin/bungee/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
import io.purecore.api.versioning.Version;
import io.purecore.mcplugin.API;
import io.purecore.mcplugin.PluginException;
import io.purecore.mcplugin.bungee.events.AdvancedBanHandler;
import io.purecore.mcplugin.bungee.events.BungeeHandler;
import io.purecore.mcplugin.bungee.events.LiteBansHandler;
import io.purecore.mcplugin.bungee.events.NuVotifierHandler;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
Expand Down Expand Up @@ -42,8 +45,26 @@ public void onEnable() {
super.onEnable();
Core.setClientVersion(API.getCurrentRelease());
try {
this.getLogger().log(Level.INFO,"purecore has been enabled. Feel free to join our Discord server: https://discord.gg/rhpcSnK");

if(handler==null){
Instance.handler=new Handler(this.getLogger(),this);
}

getProxy().getPluginManager().registerListener(this, new BungeeHandler(this));

if(this.getProxy().getPluginManager().getPlugin("LiteBans")!=null){
new LiteBansHandler(this);
}

if(this.getProxy().getPluginManager().getPlugin("AdvancedBan")!=null){
getProxy().getPluginManager().registerListener(this, new AdvancedBanHandler(this));
}

if(this.getProxy().getPluginManager().getPlugin("NuVotifier")!=null){
getProxy().getPluginManager().registerListener(this, new NuVotifierHandler(this));
}

this.getLogger().log(Level.INFO,"purecore has been enabled. Feel free to join our Discord server: https://discord.gg/rhpcSnK");
this.reload();
ProxyServer.getInstance().getScheduler().runAsync(this, new Runnable() {
@Override
Expand All @@ -60,10 +81,6 @@ public void reload() throws PluginException {

try {

if(handler==null){
Instance.handler=new Handler(this.getLogger(),this);
}

if (!getDataFolder().exists()) {
getDataFolder().mkdir();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.purecore.mcplugin.bungee.events;

import io.purecore.api.call.ApiException;
import io.purecore.mcplugin.common.thirdPartyIntegration.LiteBans;
import litebans.api.Entry;
import litebans.api.Events;
import net.md_5.bungee.api.plugin.Plugin;
import org.json.JSONException;

import java.io.IOException;
import java.util.logging.Level;

public class LiteBansHandler {

Plugin plugin;

public LiteBansHandler(Plugin plugin){
this.plugin=plugin;
this.plugin.getLogger().log(Level.INFO,"Hooked into LiteBans");

// no need for scheduler, this block is already async
Events.get().register(new Events.Listener() {
@Override
public void entryRemoved(Entry entry){
try {
LiteBans.handleEntryDelete(entry);
} catch (JSONException | ApiException | IOException e) {
plugin.getLogger().log(Level.WARNING, "There was an error while removing a LiteBans punishment: " + e.getMessage());
}
}

@Override
public void entryAdded(Entry entry) {
try {
LiteBans.handleEntryAdd(entry);
} catch (JSONException | ApiException | IOException e) {
plugin.getLogger().log(Level.WARNING, "There was an error while creating a LiteBans punishment: " + e.getMessage());
}
}
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.purecore.mcplugin.bungee.events;

import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;

import java.util.logging.Level;

public class NuVotifierHandler implements Listener {

Plugin plugin;

public NuVotifierHandler(Plugin plugin){
this.plugin=plugin;
this.plugin.getLogger().log(Level.INFO,"Hooked into NuVotifier");
}

}

0 comments on commit c8668e9

Please sign in to comment.