1
0
mirror of https://e.coding.net/circlecloud/YumCore.git synced 2024-12-25 07:08:52 +00:00

feat: 添加Vault操作类

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-09-26 20:13:37 +08:00
parent 757ad7065e
commit 029a1ee226
4 changed files with 246 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package pw.yumc.YumCore.plugin.vault;
import org.bukkit.Bukkit;
import pw.yumc.YumCore.kit.PKit;
/**
* Vault 基础
*
* @since 2016年5月12日 下午4:52:57
* @author
*/
public class VaultBase {
static {
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
PKit.disable("未找到 Vault 插件 停止加载...");
}
}
}

View File

@ -0,0 +1,61 @@
package pw.yumc.YumCore.plugin.vault;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import net.milkbowl.vault.chat.Chat;
import pw.yumc.YumCore.bukkit.Log;
import pw.yumc.YumCore.kit.PKit;
/**
* Vault 聊天管理
*
* @since 2016年5月12日 下午5:02:03
* @author
*/
public class VaultChat extends VaultBase {
private static Chat chat;
static {
final RegisteredServiceProvider<Chat> rsp = Bukkit.getServer().getServicesManager().getRegistration(Chat.class);
chat = rsp.getProvider();
if (chat == null) {
PKit.disable("已加载 Vault 但是未找到聊天相关插件 停止加载...");
} else {
Log.info("发现 Vault 使用聊天管理系统 " + chat.getName());
}
}
/**
* 获得Chat实例
*
* @return {@link Chat}
*/
public static Chat getChat() {
return chat;
}
/**
* 获得玩家称号
*
* @param player
* 玩家实体
* @return 玩家称号
*/
public static String getPlayerPrefix(final Player player) {
return chat.getPlayerPrefix(player);
}
/**
* 设置玩家所有世界称号
*
* @param player
* 玩家实体
* @param prefix
* 玩家称号
*/
public static void setPlayerPrefix(final Player player, final String prefix) {
chat.setPlayerPrefix(player, prefix);
}
}

View File

@ -0,0 +1,78 @@
package pw.yumc.YumCore.plugin.vault;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.RegisteredServiceProvider;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import pw.yumc.YumCore.bukkit.Log;
import pw.yumc.YumCore.kit.PKit;
/**
* Vault 经济管理
*
* @since 2016年5月12日 下午5:02:03
* @author
*/
public class VaultEconomy extends VaultBase {
private static Economy economy;
static {
final RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
economy = rsp.getProvider();
if (economy == null) {
PKit.disable("已加载 Vault 但是未找到经济相关插件 停止加载...");
} else {
Log.info("发现 Vault 使用经济管理系统 " + economy.getName());
}
}
/**
* 添加金额
*
* @param oPlayer
* 玩家
* @param amont
* 数量
* @return {@link EconomyResponse}
*/
public static EconomyResponse add(final OfflinePlayer oPlayer, final double amont) {
return economy.depositPlayer(oPlayer, amont);
}
/**
* 获得Economy实例
*
* @return {@link Economy}
*/
public static Economy getEconomy() {
return economy;
}
/**
* 判断玩家是否有指定的金额
*
* @param oPlayer
* 玩家
* @param amont
* 数量
* @return 是否
*/
public static boolean had(final OfflinePlayer oPlayer, final double amont) {
return economy.has(oPlayer, amont);
}
/**
* 减少金额
*
* @param oPlayer
* 玩家
* @param amont
* 数量
* @return {@link EconomyResponse}
*/
public static EconomyResponse remove(final OfflinePlayer oPlayer, final double amont) {
return economy.withdrawPlayer(oPlayer, amont);
}
}

View File

@ -0,0 +1,88 @@
package pw.yumc.YumCore.plugin.vault;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import net.milkbowl.vault.permission.Permission;
import pw.yumc.YumCore.bukkit.Log;
import pw.yumc.YumCore.kit.PKit;
/**
* Vault 权限管理
*
* @since 2016年5月12日 下午5:02:03
* @author
*/
public class VaultPermission extends VaultBase {
private static Permission permission;
static {
final RegisteredServiceProvider<Permission> rsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
permission = rsp.getProvider();
if (permission == null) {
PKit.disable("已加载 Vault 但是未找到权限相关插件 停止加载...");
} else {
Log.info("发现 Vault 使用权限管理系统 " + permission.getName());
}
}
/**
* 给玩家添加权限
*
* @param player
* 玩家
* @param perm
* 权限
* @return 结果
*/
public static boolean add(final Player player, final String perm) {
return permission.playerAdd(player, perm);
}
/**
* 获得玩家权限组
*
* @param player
* 玩家
* @return 权限组
*/
public static String getGroup(final Player player) {
return permission.getPrimaryGroup(player);
}
/**
* 获得Permission实例
*
* @return {@link Permission}
*/
public static Permission getPermission() {
return permission;
}
/**
* 判断玩家是否有权限
*
* @param player
* 玩家
* @param perm
* 权限
* @return 结果
*/
public static boolean has(final Player player, final String perm) {
return permission.has(player, perm);
}
/**
* 移除玩家权限
*
* @param player
* 玩家
* @param perm
* 权限
* @return 结果
*/
public static boolean remove(final Player player, final String perm) {
return permission.playerRemove(player, perm);
}
}