use of de.dytanic.cloudnet.bridge.internal.util.CloudPermissble in project CloudNet by Dytanic.
the class BukkitListener method handle.
@EventHandler(priority = EventPriority.LOWEST)
public void handle(PlayerLoginEvent event) {
if (CloudServer.getInstance().getCloudPlayers().containsKey(event.getPlayer().getUniqueId()) && requests.contains(event.getPlayer().getUniqueId())) {
requests.remove(event.getPlayer().getUniqueId());
if (CloudAPI.getInstance().getPermissionPool() != null && CloudAPI.getInstance().getPermissionPool().isAvailable())
try {
Field field;
Class<?> clazz = ReflectionUtil.reflectCraftClazz(".entity.CraftHumanEntity");
if (clazz != null)
field = clazz.getDeclaredField("perm");
else
field = Class.forName("net.glowstone.entity.GlowHumanEntity").getDeclaredField("permissions");
field.setAccessible(true);
field.set(event.getPlayer(), new CloudPermissble(event.getPlayer()));
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
event.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("server-kick-proxy-disallow")));
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("server-kick-proxy-disallow")));
return;
}
if (CloudServer.getInstance().getGroupData() != null) {
if (CloudAPI.getInstance().getServerGroupData(CloudAPI.getInstance().getGroup()).isMaintenance()) {
if (!event.getPlayer().hasPermission("cloudnet.group.maintenance")) {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("server-group-maintenance-kick")));
return;
}
}
if (CloudAPI.getInstance().getServerGroupData(CloudAPI.getInstance().getGroup()).getJoinPower() > 0 && (!CloudAPI.getInstance().getServerGroupData(CloudAPI.getInstance().getGroup()).getMode().equals(ServerGroupMode.LOBBY) || !CloudAPI.getInstance().getServerGroupData(CloudAPI.getInstance().getGroup()).getMode().equals(ServerGroupMode.STATIC_LOBBY))) {
CloudPlayer cloudPlayer = CloudServer.getInstance().getCloudPlayers().get(event.getPlayer().getUniqueId());
int joinPower = CloudAPI.getInstance().getServerGroupData(CloudAPI.getInstance().getGroup()).getJoinPower();
boolean acceptLogin = false;
for (GroupEntityData entityData : cloudPlayer.getPermissionEntity().getGroups()) {
if (CloudAPI.getInstance().getPermissionGroup(entityData.getGroup()).getJoinPower() >= joinPower)
acceptLogin = true;
if (event.getPlayer().hasPermission("cloudnet.joinpower." + CloudAPI.getInstance().getPermissionGroup(entityData.getGroup()).getJoinPower()))
acceptLogin = true;
}
if (!acceptLogin) {
CloudServer.getInstance().getCloudPlayers().remove(event.getPlayer().getUniqueId());
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("joinpower-deny")));
}
}
}
}
Aggregations