use of mc.dragons.core.gameobject.floor.Floor in project DragonsOnline by UniverseCraft.
the class SystemLogonCommand method opFloor.
private void opFloor(CommandSender sender, String[] args) {
if (!requirePermission(sender, PermissionLevel.ADMIN))
return;
Floor floor = lookupFloor(sender, args[2]);
if (floor == null)
return;
systemProfileLoader.addAdminFloor(args[1], floor);
sender.sendMessage(ChatColor.GREEN + "Added admin floor successfully.");
}
use of mc.dragons.core.gameobject.floor.Floor in project DragonsOnline by UniverseCraft.
the class SystemLogonCommand method deopFloor.
private void deopFloor(CommandSender sender, String[] args) {
if (!requirePermission(sender, PermissionLevel.ADMIN))
return;
Floor floor = lookupFloor(sender, args[2]);
if (floor == null)
return;
systemProfileLoader.removeAdminFloor(args[1], floor);
sender.sendMessage(ChatColor.GREEN + "Removed admin floor successfully.");
}
use of mc.dragons.core.gameobject.floor.Floor in project DragonsOnline by UniverseCraft.
the class ContentToolsListeners method onChangeWorld.
@EventHandler
public void onChangeWorld(PlayerChangedWorldEvent e) {
User user = UserLoader.fromPlayer(e.getPlayer());
Floor floor = FloorLoader.fromLocation(e.getPlayer().getLocation());
boolean isAdminWorld = user.getSystemProfile() != null && user.getSystemProfile().getLocalAdminFloors().contains(floor);
if (e.getPlayer().getGameMode() != GameMode.ADVENTURE && !isAdminWorld && !PermissionUtil.verifyActivePermissionLevel(user, PermissionLevel.BUILDER, false)) {
e.getPlayer().sendMessage(ChatColor.RED + "You are not authorized for this gamemode in this world!");
e.getPlayer().setGameMode(GameMode.ADVENTURE);
} else if (e.getPlayer().getGameMode() != GameMode.ADVENTURE && !floor.isGMLocked() && !PermissionUtil.verifyActivePermissionLevel(user, PermissionLevel.ADMIN, false)) {
e.getPlayer().sendMessage(ChatColor.RED + "This floor is currently edit-locked and cannot be edited.");
e.getPlayer().setGameMode(GameMode.ADVENTURE);
}
}
use of mc.dragons.core.gameobject.floor.Floor in project DragonsOnline by UniverseCraft.
the class NPCCommand method propagateRevisions.
/**
* Propagates revisions on this NPC class
* to any floors containing NPCs of this class.
*
* Non-persistent NPCs (i.e. mobs) are not
* counted.
*
* @param npcClass
*/
private void propagateRevisions(NPCClass npcClass) {
if (!npcClass.getNPCType().isPersistent())
return;
Bukkit.getScheduler().runTaskAsynchronously(dragons, () -> {
for (GameObject obj : dragons.getGameObjectRegistry().getRegisteredObjects(GameObjectType.FLOOR)) {
Floor floor = (Floor) obj;
for (Entity e : floor.getWorld().getEntities()) {
NPC npc = NPCLoader.fromBukkit(e);
if (npc == null)
continue;
if (npc.getNPCClass().equals(npcClass)) {
LOGGER.trace("Automatically incremented revision count on " + floor.getFloorName() + " due to modification of NPC class " + npcClass.getClassName());
AUDIT_LOG.saveEntry(floor, null, "Picked up revision of NPC class " + npcClass.getClassName());
break;
}
}
}
});
}
use of mc.dragons.core.gameobject.floor.Floor in project DragonsOnline by UniverseCraft.
the class FloorCommand method selectFloor.
private void selectFloor(CommandSender sender, String[] args) {
User user = user(sender);
Floor floor = lookupFloor(sender, args[0]);
if (floor == null)
return;
if (args.length == 1) {
sender.sendMessage(ChatColor.GREEN + "=== Floor: " + floor.getFloorName() + " ===");
String usable = floor.isPlayerLocked() ? ChatColor.RED + "Closed to players" : ChatColor.GREEN + "Open to players";
String editable = floor.isGMLocked() ? ChatColor.RED + "Closed to editing" : ChatColor.GREEN + "Open to editing";
sender.sendMessage(usable + ChatColor.GRAY + " - " + editable);
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "[Go To Floor]", "/floor goto " + floor.getFloorName(), "Click to go to floor " + floor.getFloorName()));
sender.sendMessage(ChatColor.GRAY + "Database identifier: " + ChatColor.GREEN + floor.getIdentifier().toString());
sender.sendMessage(ChatColor.GRAY + "Floor Name: " + ChatColor.GREEN + floor.getFloorName());
sender.sendMessage(ChatColor.GRAY + "Display Name: " + ChatColor.GREEN + floor.getDisplayName());
sender.sendMessage(ChatColor.GRAY + "Status: " + ChatColor.GREEN + floor.getFloorStatus());
sender.sendMessage(ChatColor.GRAY + "World Name: " + ChatColor.GREEN + floor.getWorldName());
sender.sendMessage(ChatColor.GRAY + "Level Min: " + ChatColor.GREEN + floor.getLevelMin());
sender.sendMessage(ChatColor.GRAY + "Volatile: " + ChatColor.GREEN + floor.isVolatile());
sender.spigot().sendMessage(ObjectMetadataCommand.getClickableMetadataLink(GameObjectType.FLOOR, floor.getUUID()));
return;
}
Document base = Document.parse(floor.getData().toJson());
if (floor.isGMLocked() && !hasPermission(sender, PermissionLevel.ADMIN)) {
sender.sendMessage(ChatColor.RED + "This floor is not currently editable. (Status: " + floor.getFloorStatus() + ")");
} else if (args.length <= 2) {
sender.sendMessage(ChatColor.RED + "Insufficient arguments! /floor <FloorName> <name|displayname|lvmin|volatile|status> <Value>");
} else if (args[1].equalsIgnoreCase("name")) {
floor.setFloorName(args[2]);
sender.sendMessage(ChatColor.GREEN + "Updated floor name successfully.");
AUDIT_LOG.saveEntry(floor, user, base, "Updated floor internal name to " + args[2]);
} else if (args[1].equalsIgnoreCase("displayname")) {
floor.setDisplayName(StringUtil.concatArgs(args, 2));
sender.sendMessage(ChatColor.GREEN + "Updated floor display name successfully.");
AUDIT_LOG.saveEntry(floor, user, base, "Updated floor display name to " + StringUtil.concatArgs(args, 2));
} else if (args[1].equalsIgnoreCase("status")) {
if (!requirePermission(sender, SystemProfileFlag.TASK_MANAGER))
return;
FloorStatus status = StringUtil.parseEnum(sender, FloorStatus.class, args[2]);
if (status == null)
return;
floor.setFloorStatus(status);
sender.sendMessage(ChatColor.GREEN + "Updated floor status successfully.");
AUDIT_LOG.saveEntry(floor, user, base, "Updated floor status to " + status);
} else if (args[1].equalsIgnoreCase("lvmin")) {
Integer lvMin = parseInt(sender, args[2]);
if (lvMin == null)
return;
floor.setLevelMin(lvMin);
sender.sendMessage(ChatColor.GREEN + "Updated floor level requirement successfully.");
AUDIT_LOG.saveEntry(floor, user, base, "Updated floor level min to " + lvMin);
} else if (args[1].equalsIgnoreCase("volatile")) {
Boolean isVolatile = parseBoolean(sender, args[2]);
if (isVolatile == null)
return;
floor.setVolatile(isVolatile);
sender.sendMessage(ChatColor.GREEN + "Updated floor volatility status sucessfully.");
AUDIT_LOG.saveEntry(floor, user, base, "Updated floor volatility to " + isVolatile);
} else {
sender.sendMessage(ChatColor.RED + "Invalid arguments! /floor <FloorName> <name|displayname|lvmin|volatile> <Value>");
}
}
Aggregations