allow other plugins to register requirements and operaitons
This commit is contained in:
+2
-2
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'sh.okx'
|
||||
version '3.2-beta.1'
|
||||
version '3.2'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -33,7 +33,7 @@ dependencies {
|
||||
compile('net.milkbowl.vault:VaultAPI:1.6') {
|
||||
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
|
||||
compile 'com.gmail.nossr50.mcMMO:mcMMO:1.6.0-SNAPSHOT'
|
||||
}
|
||||
|
||||
@@ -152,11 +152,13 @@ public class Rankup extends JavaPlugin {
|
||||
private void loadConfigs() {
|
||||
messages = loadConfig("messages.yml");
|
||||
config = loadConfig("config.yml");
|
||||
refreshRanks();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, this::refreshRanks);
|
||||
}
|
||||
|
||||
public void refreshRanks() {
|
||||
registerRequirements();
|
||||
Bukkit.getPluginManager().callEvent(new RankupRegisterEvent(this));
|
||||
|
||||
rankups = new Rankups(this, loadConfig("rankups.yml"));
|
||||
if(config.getBoolean("prestige")) {
|
||||
prestiges = new Prestiges(this, loadConfig("prestiges.yml"));
|
||||
@@ -191,8 +193,6 @@ public class Rankup extends JavaPlugin {
|
||||
operationRegistry.addOperation("none", new NoneOperation());
|
||||
operationRegistry.addOperation("one", new OneOperation());
|
||||
operationRegistry.addOperation("any", new AnyOperation());
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new RankupRegisterEvent(this));
|
||||
}
|
||||
|
||||
private void setupPermissions() {
|
||||
|
||||
@@ -4,7 +4,9 @@ import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import sh.okx.rankup.requirements.Operation;
|
||||
import sh.okx.rankup.requirements.OperationRegistry;
|
||||
import sh.okx.rankup.requirements.Requirement;
|
||||
import sh.okx.rankup.requirements.RequirementRegistry;
|
||||
|
||||
/**
|
||||
@@ -27,6 +29,14 @@ public class RankupRegisterEvent extends Event {
|
||||
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
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
||||
@@ -2,6 +2,6 @@ package sh.okx.rankup.requirements;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Operation {
|
||||
public abstract boolean check(List<Boolean> booleans);
|
||||
public interface Operation {
|
||||
boolean check(List<Boolean> booleans);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package sh.okx.rankup.requirements;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ReducerOperation extends Operation {
|
||||
public abstract class ReducerOperation implements Operation {
|
||||
public abstract boolean check(boolean a, boolean b);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: Rankup
|
||||
version: 3.2-beta.1
|
||||
version: 3.2
|
||||
main: sh.okx.rankup.Rankup
|
||||
author: Okx
|
||||
depend: [Vault]
|
||||
|
||||
Reference in New Issue
Block a user