allow other plugins to register requirements and operaitons

This commit is contained in:
okx-code
2018-10-23 16:43:50 +01:00
parent 2542d24cf2
commit 11b3fab568
6 changed files with 19 additions and 9 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ plugins {
} }
group 'sh.okx' group 'sh.okx'
version '3.2-beta.1' version '3.2'
repositories { repositories {
mavenCentral() mavenCentral()
@@ -33,7 +33,7 @@ dependencies {
compile('net.milkbowl.vault:VaultAPI:1.6') { compile('net.milkbowl.vault:VaultAPI:1.6') {
exclude group: 'org.bukkit' exclude group: 'org.bukkit'
} }
compile 'me.clip:placeholderapi:2.9.+' compile 'me.clip:placeholderapi:2.9.2'
// if compiling this you will have to download and install mcMMO locally // if compiling this you will have to download and install mcMMO locally
compile 'com.gmail.nossr50.mcMMO:mcMMO:1.6.0-SNAPSHOT' compile 'com.gmail.nossr50.mcMMO:mcMMO:1.6.0-SNAPSHOT'
} }
+3 -3
View File
@@ -152,11 +152,13 @@ public class Rankup extends JavaPlugin {
private void loadConfigs() { private void loadConfigs() {
messages = loadConfig("messages.yml"); messages = loadConfig("messages.yml");
config = loadConfig("config.yml"); config = loadConfig("config.yml");
refreshRanks(); Bukkit.getScheduler().scheduleSyncDelayedTask(this, this::refreshRanks);
} }
public void refreshRanks() { public void refreshRanks() {
registerRequirements(); registerRequirements();
Bukkit.getPluginManager().callEvent(new RankupRegisterEvent(this));
rankups = new Rankups(this, loadConfig("rankups.yml")); rankups = new Rankups(this, loadConfig("rankups.yml"));
if(config.getBoolean("prestige")) { if(config.getBoolean("prestige")) {
prestiges = new Prestiges(this, loadConfig("prestiges.yml")); prestiges = new Prestiges(this, loadConfig("prestiges.yml"));
@@ -191,8 +193,6 @@ public class Rankup extends JavaPlugin {
operationRegistry.addOperation("none", new NoneOperation()); operationRegistry.addOperation("none", new NoneOperation());
operationRegistry.addOperation("one", new OneOperation()); operationRegistry.addOperation("one", new OneOperation());
operationRegistry.addOperation("any", new AnyOperation()); operationRegistry.addOperation("any", new AnyOperation());
Bukkit.getPluginManager().callEvent(new RankupRegisterEvent(this));
} }
private void setupPermissions() { private void setupPermissions() {
@@ -4,7 +4,9 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import sh.okx.rankup.requirements.Operation;
import sh.okx.rankup.requirements.OperationRegistry; import sh.okx.rankup.requirements.OperationRegistry;
import sh.okx.rankup.requirements.Requirement;
import sh.okx.rankup.requirements.RequirementRegistry; import sh.okx.rankup.requirements.RequirementRegistry;
/** /**
@@ -27,6 +29,14 @@ public class RankupRegisterEvent extends Event {
return plugin.getOperationRegistry(); return plugin.getOperationRegistry();
} }
public void addRequirement(Requirement requirement) {
plugin.getRequirementRegistry().addRequirement(requirement);
}
public void addOperation(String name, Operation operation) {
plugin.getOperationRegistry().addOperation(name, operation);
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
@@ -2,6 +2,6 @@ package sh.okx.rankup.requirements;
import java.util.List; import java.util.List;
public abstract class Operation { public interface Operation {
public abstract boolean check(List<Boolean> booleans); boolean check(List<Boolean> booleans);
} }
@@ -2,7 +2,7 @@ package sh.okx.rankup.requirements;
import java.util.List; import java.util.List;
public abstract class ReducerOperation extends Operation { public abstract class ReducerOperation implements Operation {
public abstract boolean check(boolean a, boolean b); public abstract boolean check(boolean a, boolean b);
@Override @Override
+1 -1
View File
@@ -1,5 +1,5 @@
name: Rankup name: Rankup
version: 3.2-beta.1 version: 3.2
main: sh.okx.rankup.Rankup main: sh.okx.rankup.Rankup
author: Okx author: Okx
depend: [Vault] depend: [Vault]