mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Made Vault soft dependency only
This commit is contained in:
parent
ebd644afe7
commit
e0a87dd2ac
@ -42,6 +42,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
public class DungeonsXL extends JavaPlugin {
|
public class DungeonsXL extends JavaPlugin {
|
||||||
|
|
||||||
private static DungeonsXL plugin;
|
private static DungeonsXL plugin;
|
||||||
|
private Economy economyProvider;
|
||||||
|
private Permission permissionProvider;
|
||||||
|
|
||||||
private MainConfig mainConfig;
|
private MainConfig mainConfig;
|
||||||
private DMessages dMessages;
|
private DMessages dMessages;
|
||||||
@ -80,10 +82,10 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
initFolders();
|
initFolders();
|
||||||
|
|
||||||
// Setup Permissions
|
// Setup Permissions
|
||||||
setupPermissions();
|
loadPermissionProvider();
|
||||||
|
|
||||||
// Setup Economy
|
// Setup Economy
|
||||||
setupEconomy();
|
loadEconomyProvider();
|
||||||
|
|
||||||
getCommand("dungeonsxl").setExecutor(new CommandListener());
|
getCommand("dungeonsxl").setExecutor(new CommandListener());
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new EntityListener(), this);
|
Bukkit.getServer().getPluginManager().registerEvents(new EntityListener(), this);
|
||||||
@ -195,43 +197,6 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
}, 0L, 2L);
|
}, 0L, 2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permissions
|
|
||||||
public Permission permission = null;
|
|
||||||
|
|
||||||
private Boolean setupPermissions() {
|
|
||||||
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
|
||||||
if (permissionProvider != null) {
|
|
||||||
permission = permissionProvider.getProvider();
|
|
||||||
}
|
|
||||||
return permission != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean GroupEnabled(String group) {
|
|
||||||
|
|
||||||
for (String agroup : permission.getGroups()) {
|
|
||||||
if (agroup.equalsIgnoreCase(group)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Economy
|
|
||||||
public Economy economy = null;
|
|
||||||
|
|
||||||
private Boolean setupEconomy() {
|
|
||||||
if (mainConfig.enableEconomy()) {
|
|
||||||
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
|
||||||
if (economyProvider != null) {
|
|
||||||
economy = economyProvider.getProvider();
|
|
||||||
}
|
|
||||||
return economy != null;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save and Load
|
// Save and Load
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
File file = new File(getDataFolder(), "data.yml");
|
File file = new File(getDataFolder(), "data.yml");
|
||||||
@ -293,6 +258,64 @@ public class DungeonsXL extends JavaPlugin {
|
|||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the loaded instance of Economy
|
||||||
|
*/
|
||||||
|
public Economy getEconomyProvider() {
|
||||||
|
return economyProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load / reload a new instance of Permission
|
||||||
|
*/
|
||||||
|
public void loadEconomyProvider() {
|
||||||
|
try {
|
||||||
|
if (mainConfig.enableEconomy()) {
|
||||||
|
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
|
if (economyProvider != null) {
|
||||||
|
this.economyProvider = economyProvider.getProvider();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (NoClassDefFoundError error) {
|
||||||
|
getLogger().info("Could not hook into Vault to register an economy provider!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the loaded instance of Permission
|
||||||
|
*/
|
||||||
|
public Permission getPermissionProvider() {
|
||||||
|
return permissionProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load / reload a new instance of Permission
|
||||||
|
*/
|
||||||
|
public void loadPermissionProvider() {
|
||||||
|
try {
|
||||||
|
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(Permission.class);
|
||||||
|
if (permissionProvider != null) {
|
||||||
|
this.permissionProvider = permissionProvider.getProvider();
|
||||||
|
}
|
||||||
|
} catch (NoClassDefFoundError error) {
|
||||||
|
getLogger().info("Could not hook into Vault to register a permission provider!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param group
|
||||||
|
* the group to be checked
|
||||||
|
*/
|
||||||
|
public boolean isGroupEnabled(String group) {
|
||||||
|
for (String agroup : permissionProvider.getGroups()) {
|
||||||
|
if (agroup.equalsIgnoreCase(group)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the loaded instance of MainConfig
|
* @return the loaded instance of MainConfig
|
||||||
*/
|
*/
|
||||||
|
@ -198,7 +198,7 @@ public class GameWorld {
|
|||||||
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + dungeon, "config.yml"));
|
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + dungeon, "config.yml"));
|
||||||
|
|
||||||
if (plugin.getMainConfig().enableEconomy()) {
|
if (plugin.getMainConfig().enableEconomy()) {
|
||||||
if ( !(DungeonsXL.getPlugin().economy.getBalance(player) >= worldConfig.getFee())) {
|
if ( !(DungeonsXL.getPlugin().getEconomyProvider().getBalance(player) >= worldConfig.getFee())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,7 +413,7 @@ public class PlayerListener implements Listener {
|
|||||||
if (plugin.getMainConfig().isTutorialActivated()) {
|
if (plugin.getMainConfig().isTutorialActivated()) {
|
||||||
if (DPlayer.get(player) == null) {
|
if (DPlayer.get(player) == null) {
|
||||||
if (plugin.getMainConfig().getTutorialDungeon() != null && plugin.getMainConfig().getTutorialStartGroup() != null && plugin.getMainConfig().getTutorialEndGroup() != null) {
|
if (plugin.getMainConfig().getTutorialDungeon() != null && plugin.getMainConfig().getTutorialStartGroup() != null && plugin.getMainConfig().getTutorialEndGroup() != null) {
|
||||||
for (String group : plugin.permission.getPlayerGroups(player)) {
|
for (String group : plugin.getPermissionProvider().getPlayerGroups(player)) {
|
||||||
if (plugin.getMainConfig().getTutorialStartGroup().equalsIgnoreCase(group)) {
|
if (plugin.getMainConfig().getTutorialStartGroup().equalsIgnoreCase(group)) {
|
||||||
DGroup dgroup = new DGroup(player, plugin.getMainConfig().getTutorialDungeon(), false);
|
DGroup dgroup = new DGroup(player, plugin.getMainConfig().getTutorialDungeon(), false);
|
||||||
|
|
||||||
|
@ -233,8 +233,8 @@ public class DGroup {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.economy != null) {
|
if (plugin.getEconomyProvider() != null) {
|
||||||
DungeonsXL.getPlugin().economy.withdrawPlayer(player, fee);
|
plugin.getEconomyProvider().withdrawPlayer(player, fee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,6 +249,7 @@ public class DGroup {
|
|||||||
return dgroup;
|
return dgroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,6 +259,7 @@ public class DGroup {
|
|||||||
return dgroup;
|
return dgroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ public class DPlayer {
|
|||||||
if ( !isinTestMode) {// Nur wenn man nicht am Testen ist
|
if ( !isinTestMode) {// Nur wenn man nicht am Testen ist
|
||||||
if (isFinished) {
|
if (isFinished) {
|
||||||
addTreasure();
|
addTreasure();
|
||||||
if (plugin.economy != null) {
|
if (plugin.getEconomyProvider() != null) {
|
||||||
plugin.economy.depositPlayer(player, treasureMoney);
|
plugin.getEconomyProvider().depositPlayer(player, treasureMoney);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Time
|
// Set Time
|
||||||
@ -172,8 +172,15 @@ public class DPlayer {
|
|||||||
|
|
||||||
// Tutorial Permissions
|
// Tutorial Permissions
|
||||||
if (gWorld.isTutorial) {
|
if (gWorld.isTutorial) {
|
||||||
plugin.permission.playerAddGroup(player, plugin.getMainConfig().getTutorialEndGroup());
|
String endGroup = plugin.getMainConfig().getTutorialEndGroup();
|
||||||
plugin.permission.playerRemoveGroup(player, plugin.getMainConfig().getTutorialStartGroup());
|
if (plugin.isGroupEnabled(endGroup)) {
|
||||||
|
plugin.getPermissionProvider().playerAddGroup(player, endGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
String startGroup = plugin.getMainConfig().getTutorialStartGroup();
|
||||||
|
if (plugin.isGroupEnabled(startGroup)) {
|
||||||
|
plugin.getPermissionProvider().playerRemoveGroup(player, startGroup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,7 +242,6 @@ public class DPlayer {
|
|||||||
|
|
||||||
// Respawn Items
|
// Respawn Items
|
||||||
if (GameWorld.get(world).getConfig().getKeepInventoryOnDeath()) {
|
if (GameWorld.get(world).getConfig().getKeepInventoryOnDeath()) {
|
||||||
org.bukkit.Bukkit.broadcastMessage("deactivated code triggered");
|
|
||||||
if (respawnInventory != null || respawnArmor != null) {
|
if (respawnInventory != null || respawnArmor != null) {
|
||||||
player.getInventory().setContents(respawnInventory);
|
player.getInventory().setContents(respawnInventory);
|
||||||
player.getInventory().setArmorContents(respawnArmor);
|
player.getInventory().setArmorContents(respawnArmor);
|
||||||
@ -300,6 +306,10 @@ public class DPlayer {
|
|||||||
dGroup.removeUnplayedFloor(dGroup.getMapName());
|
dGroup.removeUnplayedFloor(dGroup.getMapName());
|
||||||
dGroup.setMapName(newFloor);
|
dGroup.setMapName(newFloor);
|
||||||
dGroup.setGWorld(GameWorld.load(newFloor));
|
dGroup.setGWorld(GameWorld.load(newFloor));
|
||||||
|
for (Player player : dGroup.getPlayers()) {
|
||||||
|
DPlayer dPlayer = get(player);
|
||||||
|
dPlayer.checkpoint = dGroup.getGWorld().locStart;
|
||||||
|
}
|
||||||
dGroup.startGame();
|
dGroup.startGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user