mc服务器权限组配置文件,【插件百科】GroupManager组权限插件详细教程(更新至v2.2版本)...

import java.util.Arrays;

import java.util.List;

import org.anjocaido.groupmanager.GroupManager;

import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;

import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;

import org.bukkit.entity.Player;

import org.bukkit.event.EventHandler;

import org.bukkit.event.EventPriority;

import org.bukkit.event.server.PluginDisableEvent;

import org.bukkit.event.server.PluginEnableEvent;

import org.bukkit.plugin.Plugin;

import org.bukkit.plugin.PluginManager;

public class GMHook

{

private GroupManager groupManager;

private Plugin plugin;

public GMHook(final Plugin plugin)

{

this.plugin = plugin;

}

@EventHandler(priority = EventPriority.MONITOR)

public void onPluginEnable(final PluginEnableEvent event)

{

final PluginManager pluginManager = plugin.getServer().getPluginManager();

final Plugin GMplugin = pluginManager.getPlugin("GroupManager");

if (GMplugin != null && GMplugin.isEnabled())

{

groupManager = (GroupManager)GMplugin;

}

}

@EventHandler(priority = EventPriority.MONITOR)

public void onPluginDisable(PluginDisableEvent event)

{

if (groupManager != null)

{

if (event.getPlugin().getDescription().getName().equals("GroupManager"))

{

groupManager = null;

}

}

}

public String getGroup(final Player base)

{

final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);

if (handler == null)

{

return null;

}

return handler.getGroup(base.getName());

}

public boolean setGroup(final Player base, final String group)

{

final OverloadedWorldHolder handler = groupManager.getWorldsHolder().getWorldData(base);

if (handler == null)

{

return false;

}

handler.getUser(base.getName()).setGroup(handler.getGroup(group));

return true;

}

public List getGroups(final Player base)

{

final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);

if (handler == null)

{

return null;

}

return Arrays.asList(handler.getGroups(base.getName()));

}

public String getPrefix(final Player base)

{

final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);

if (handler == null)

{

return null;

}

return handler.getUserPrefix(base.getName());

}

public String getSuffix(final Player base)

{

final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);

if (handler == null)

{

return null;

}

return handler.getUserSuffix(base.getName());

}

public boolean hasPermission(final Player base, final String node)

{

final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);

if (handler == null)

{

return false;

}

return handler.has(base, node);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值