mirror of
https://github.com/MilkBowl/Vault.git
synced 2025-02-28 18:21:26 +01:00
Removed PermissionManager & EconomyManager (pointless)
This commit is contained in:
parent
ccdc903007
commit
9dd74441ab
@ -4,3 +4,8 @@ version: 1.0.0dev
|
||||
author: Cereal
|
||||
description: >
|
||||
Abstraction Library for Bukkit Plugins
|
||||
commands:
|
||||
vault:
|
||||
description: Generic command for Vault API
|
||||
usage: |
|
||||
/<command> - displays vault command help
|
@ -19,18 +19,30 @@
|
||||
|
||||
package net.milkbowl.vault;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.EconomyManager;
|
||||
import net.milkbowl.vault.permission.PermissionManager;
|
||||
import net.milkbowl.vault.economy.*;
|
||||
import net.milkbowl.vault.economy.plugins.*;
|
||||
import net.milkbowl.vault.permission.*;
|
||||
import net.milkbowl.vault.permission.plugins.*;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Vault extends JavaPlugin {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private EconomyManager econManager = new EconomyManager(this);
|
||||
private PermissionManager permManager = new PermissionManager(this);
|
||||
|
||||
// Economy
|
||||
private TreeMap<Integer, Economy> econs = new TreeMap<Integer, Economy>();
|
||||
private Economy activeEconomy = null;
|
||||
|
||||
// Permission
|
||||
private TreeMap<Integer,Permission> perms = new TreeMap<Integer,Permission>();
|
||||
private Permission activePermission = null;
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
@ -39,14 +51,131 @@ public class Vault extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Load Vault Addons
|
||||
loadEconomy();
|
||||
loadPermission();
|
||||
|
||||
getCommand("vault").setExecutor(this);
|
||||
log.info(String.format("[%s] Enabled Version %s", getDescription().getName(), getDescription().getVersion()));
|
||||
}
|
||||
|
||||
public EconomyManager getEconomy() {
|
||||
return econManager;
|
||||
public Economy getEconomy() {
|
||||
if (activeEconomy == null) {
|
||||
Iterator<Economy> it = econs.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
Economy e = it.next();
|
||||
if (e.isEnabled()) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return activeEconomy;
|
||||
}
|
||||
}
|
||||
|
||||
public PermissionManager getPermission() {
|
||||
return permManager;
|
||||
public Permission getPermission() {
|
||||
if(activePermission == null) {
|
||||
Iterator<Permission> it = perms.values().iterator();
|
||||
while(it.hasNext()) {
|
||||
Permission p = it.next();
|
||||
if(p.isEnabled()) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return activePermission;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadEconomy() {
|
||||
// Try to load 3co
|
||||
if(packageExists(new String[] { "me.ic3d.eco.ECO" })) {
|
||||
Economy econ = new Economy_3co(this);
|
||||
econs.put(11, econ);
|
||||
log.info(String.format("[%s][Economy] 3co found: %s", getDescription().getName(), econ.isEnabled() ? "Loaded" : "Waiting"));
|
||||
} else {
|
||||
log.info(String.format("[%s][Economy] 3co not found.", getDescription().getName()));
|
||||
}
|
||||
|
||||
// Try to load BOSEconomy
|
||||
if (packageExists(new String[] { "cosine.boseconomy.BOSEconomy" })) {
|
||||
Economy bose = new Economy_BOSE(this);
|
||||
econs.put(10, bose);
|
||||
log.info(String.format("[%s][Economy] BOSEconomy found: %s", getDescription().getName(), bose.isEnabled() ? "Loaded" : "Waiting"));
|
||||
} else {
|
||||
log.info(String.format("[%s][Economy] BOSEconomy not found.", getDescription().getName()));
|
||||
}
|
||||
|
||||
// Try to load Essentials Economy
|
||||
if (packageExists(new String[] { "com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException", "com.earth2me.essentials.api.UserDoesNotExistException" })) {
|
||||
Economy essentials = new Economy_Essentials(this);
|
||||
econs.put(9, essentials);
|
||||
log.info(String.format("[%s][Economy] Essentials Economy found: %s", getDescription().getName(), essentials.isEnabled() ? "Loaded" : "Waiting"));
|
||||
} else {
|
||||
log.info(String.format("[%s][Economy] Essentials Economy not found.", getDescription().getName()));
|
||||
}
|
||||
|
||||
// Try to load iConomy 4
|
||||
if (packageExists(new String[] { "com.nijiko.coelho.iConomy.iConomy", "com.nijiko.coelho.iConomy.system.Account" })) {
|
||||
Economy icon4 = new Economy_iConomy4(this);
|
||||
econs.put(8, icon4);
|
||||
log.info(String.format("[%s][Economy] iConomy 4 found: ", getDescription().getName(), icon4.isEnabled() ? "Loaded" : "Waiting"));
|
||||
} else {
|
||||
log.info(String.format("[%s][Economy] iConomy 4 not found.", getDescription().getName()));
|
||||
}
|
||||
|
||||
// Try to load iConomy 5
|
||||
if (packageExists(new String[] { "com.iConomy.iConomy", "com.iConomy.system.Account", "com.iConomy.system.Holdings" })) {
|
||||
Economy icon5 = new Economy_iConomy5(this);
|
||||
econs.put(7, icon5);
|
||||
log.info(String.format("[%s][Economy] iConomy 5 found: %s", getDescription().getName(), icon5.isEnabled() ? "Loaded" : "Waiting"));
|
||||
} else {
|
||||
log.info(String.format("[%s][Economy] iConomy 5 not found.", getDescription().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPermission() {
|
||||
// Try to load PermissionsEx
|
||||
if(packageExists(new String[] { "ru.tehkode.permissions.bukkit.PermissionsEx" })) {
|
||||
Permission ePerms = new Permission_PermissionsEx(this);
|
||||
perms.put(8, ePerms);
|
||||
log.info(String.format("[%s][Permission] PermissionsEx found: %s", getDescription().getName(), ePerms.isEnabled() ? "Loaded" : "Waiting"));
|
||||
} else {
|
||||
log.info(String.format("[%s][Permission] PermissionsEx not found.", getDescription().getName()));
|
||||
}
|
||||
|
||||
// Try to load Permissions (Phoenix)
|
||||
if (packageExists(new String[] { "com.nijikokun.bukkit.Permissions.Permissions" })) {
|
||||
Permission nPerms = new Permission_Permissions(this);
|
||||
perms.put(9, nPerms);
|
||||
log.info(String.format("[%s][Permission] Permissions (Phoenix) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
|
||||
} else {
|
||||
log.info(String.format("[%s][Permission] Permissions (Phoenix) not found.", getDescription().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
|
||||
if(command.getLabel().equals("vault")) {
|
||||
// do stuff!
|
||||
sender.sendMessage(String.format("[%s] Vault v%s Information", getDescription().getName(), getDescription().getVersion()));
|
||||
sender.sendMessage(String.format("[%s] Economy: %s", getDescription().getName(), getEconomy().getName()));
|
||||
sender.sendMessage(String.format("[%s] Permission: %s", getDescription().getName(), getPermission().getName()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean packageExists(String[] packages) {
|
||||
try {
|
||||
for (String pkg : packages) {
|
||||
Class.forName(pkg);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user