use of de.dytanic.cloudnet.lib.player.permission.PermissionEntity in project CloudNet by Dytanic.
the class VaultPermissionImpl method playerAdd.
@Override
public boolean playerAdd(String s, String s1, String s2) {
OfflinePlayer offlinePlayer = getPlayer(s1);
PermissionEntity permissionEntity = offlinePlayer.getPermissionEntity();
permissionEntity.getPermissions().put(s2, true);
offlinePlayer.setPermissionEntity(permissionEntity);
updatePlayer(offlinePlayer);
return true;
}
use of de.dytanic.cloudnet.lib.player.permission.PermissionEntity in project CloudNet by Dytanic.
the class VaultPermissionImpl method playerRemoveGroup.
@Override
public boolean playerRemoveGroup(String s, String s1, String s2) {
OfflinePlayer offlinePlayer = getPlayer(s1);
PermissionEntity permissionEntity = offlinePlayer.getPermissionEntity();
GroupEntityData groupEntityData = CollectionWrapper.filter(permissionEntity.getGroups(), new Acceptable<GroupEntityData>() {
@Override
public boolean isAccepted(GroupEntityData groupEntityData) {
return groupEntityData.getGroup().equalsIgnoreCase(s2);
}
});
if (groupEntityData != null)
permissionEntity.getGroups().remove(groupEntityData);
offlinePlayer.setPermissionEntity(permissionEntity);
updatePlayer(offlinePlayer);
return true;
}
use of de.dytanic.cloudnet.lib.player.permission.PermissionEntity in project CloudNet by Dytanic.
the class VaultPermissionImpl method playerRemove.
@Override
public boolean playerRemove(String s, String s1, String s2) {
OfflinePlayer offlinePlayer = getPlayer(s1);
PermissionEntity permissionEntity = offlinePlayer.getPermissionEntity();
permissionEntity.getPermissions().remove(s2);
offlinePlayer.setPermissionEntity(permissionEntity);
updatePlayer(offlinePlayer);
return true;
}
use of de.dytanic.cloudnet.lib.player.permission.PermissionEntity in project CloudNet by Dytanic.
the class VaultPermissionImpl method getPlayerGroups.
@Override
public String[] getPlayerGroups(String s, String s1) {
PermissionEntity permissionEntity = getPlayer(s1).getPermissionEntity();
String[] data = new String[permissionEntity.getGroups().size()];
short i = 0;
for (GroupEntityData groupEntityData : permissionEntity.getGroups()) {
data[i++] = groupEntityData.getGroup();
}
return data;
}
use of de.dytanic.cloudnet.lib.player.permission.PermissionEntity in project CloudNet by Dytanic.
the class PlayerExample method examplePlayer.
public void examplePlayer() {
// Returns the CloudPlayer if the play is online or null if isn't online
CloudPlayer cloudPlayer = CloudAPI.getInstance().getOnlinePlayer(UUID.fromString("e71d69dd-058f-4319-9ae9-8c8f0a7a61f5"));
{
// Returns the online player connection metadata
PlayerConnection playerConnection = cloudPlayer.getPlayerConnection();
// Returns the IP
playerConnection.getHost();
// Returns the port of the last connection
playerConnection.getPort();
// Returns the UUID of the connection
playerConnection.getUniqueId();
// Returns the legacy version
playerConnection.getVersion();
// Returns if the player was in onlinemode
playerConnection.isOnlineMode();
}
System.out.println("The player " + cloudPlayer.getName() + " is on " + cloudPlayer.getProxy() + NetworkUtils.SLASH_STRING + cloudPlayer.getServer() + " and connected at " + cloudPlayer.getLoginTimeStamp().getTime());
// Returns a util Class for some network methods
PlayerExecutor playerExecutor = cloudPlayer.getPlayerExecutor();
// writes a message to the player if the player is online
playerExecutor.sendMessage(cloudPlayer, "Hello world!");
// send a player to a some server
playerExecutor.sendPlayer(cloudPlayer, "Lobby-2");
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Kick a player from the network
playerExecutor.kickPlayer(cloudPlayer, "you are a cool guy for the network");
}
}).start();
OfflinePlayer offlinePlayer = CloudAPI.getInstance().getOfflinePlayer("Dytanic");
if (// If the player is registered
offlinePlayer != null) {
// Returns the permissionentity for manage some permission systems
PermissionEntity permissionEntity = offlinePlayer.getPermissionEntity();
// add a permission group with the delay of 30 days
permissionEntity.getGroups().add(new GroupEntityData("VIP", System.currentTimeMillis() + TimeUnit.DAYS.toMillis(30)));
// add a permission for this player
permissionEntity.getPermissions().put("minecraft.command.tp", true);
if (permissionEntity.isInGroup("VIP")) {
System.out.println("The player " + offlinePlayer.getUniqueId() + NetworkUtils.SLASH_STRING + offlinePlayer.getName() + " is in the group VIP");
}
PlayerConnection playerConnection = offlinePlayer.getLastPlayerConnection();
// Returns the IP
playerConnection.getHost();
// Returns the port of the last connection
playerConnection.getPort();
// Returns the UUID of the connection
playerConnection.getUniqueId();
// Returns the legacy version
playerConnection.getVersion();
// Returns if the player was in onlinemode
playerConnection.isOnlineMode();
}
// update the player
// cloudplayer update
CloudAPI.getInstance().updatePlayer(cloudPlayer);
// update the offline player
CloudAPI.getInstance().updatePlayer(offlinePlayer);
}
Aggregations