use of mc.dragons.core.gameobject.item.ItemClass in project DragonsOnline by UniverseCraft.
the class ItemCommand method giveItemOfClass.
private void giveItemOfClass(CommandSender sender, String[] args) {
if (args.length == 1) {
sender.sendMessage(ChatColor.RED + "Insufficient arguments! /item give <ClassName> [Player] [Quantity]");
return;
}
ItemClass itemClass = lookupItemClass(sender, args[1]);
if (itemClass == null)
return;
Item item = itemLoader.registerNew(itemClass);
if (args.length > 3) {
Integer quantityOpt = parseInt(sender, args[3]);
if (quantityOpt == null)
return;
item.setQuantity(quantityOpt);
}
if (args.length > 2) {
Player target = Bukkit.getPlayerExact(args[2]);
if (target == null) {
sender.sendMessage(ChatColor.RED + "That player is not online!");
return;
}
User targetUser = UserLoader.fromPlayer(target);
targetUser.giveItem(item);
} else if (!isPlayer(sender)) {
sender.sendMessage(ChatColor.RED + "Console must specify a player to give the item to!");
} else {
user(sender).giveItem(item);
}
}
use of mc.dragons.core.gameobject.item.ItemClass in project DragonsOnline by UniverseCraft.
the class ItemCommand method push.
private void push(CommandSender sender, String[] args) {
ItemClass itemClass = lookupItemClass(sender, args[0]);
if (itemClass == null)
return;
Document update = new Document(itemClass.getData());
update.remove("_id");
update.remove("type");
storageManager.push(GameObjectType.ITEM, new Document("className", itemClass.getClassName()), update);
sender.sendMessage(ChatColor.GREEN + "Updated all items matching class " + itemClass.getClassName() + " in database.");
sender.sendMessage(ChatColor.GREEN + "Players must rejoin to receive the updated items.");
AUDIT_LOG.savePush(itemClass, user(sender));
}
use of mc.dragons.core.gameobject.item.ItemClass in project DragonsOnline by UniverseCraft.
the class ItemCommand method listClasses.
private void listClasses(CommandSender sender, String[] args) {
String startingWith = "";
if (args.length > 1) {
startingWith = args[1];
}
sender.sendMessage(ChatColor.GREEN + "Listing all item classes" + (startingWith.length() > 0 ? (" starting with \"" + startingWith + "\"") : "") + ":");
for (GameObject gameObject : registry.getRegisteredObjects(GameObjectType.ITEM_CLASS)) {
ItemClass itemClass = (ItemClass) gameObject;
if (!itemClass.getClassName().startsWith(startingWith))
continue;
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "- " + itemClass.getClassName() + " [Lv Min " + itemClass.getLevelMin() + "]", "/item give " + itemClass.getClassName(), true, "Click to receive this item"));
}
}
use of mc.dragons.core.gameobject.item.ItemClass in project DragonsOnline by UniverseCraft.
the class ItemCommand method manageLore.
private void manageLore(CommandSender sender, String[] args) {
ItemClass itemClass = lookupItemClass(sender, args[0]);
if (itemClass == null)
return;
User user = user(sender);
if (args.length == 2) {
if (itemClass.getLore().size() == 0) {
sender.sendMessage(ChatColor.RED + "This item has no lore!");
} else {
sender.sendMessage(ChatColor.GREEN + "Item lore:");
for (String line : itemClass.getLore()) {
sender.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + line);
}
}
} else if (args[2].equalsIgnoreCase("add")) {
Document base = Document.parse(itemClass.getData().toJson());
String loreLine = StringUtil.concatArgs(args, 3);
List<String> lore = itemClass.getLore();
lore.add(loreLine);
itemClass.setLore(lore);
sender.sendMessage(ChatColor.GREEN + "Updated item lore successfully.");
AUDIT_LOG.saveEntry(itemClass, user, base, "Added lore line " + loreLine);
} else if (args[2].equalsIgnoreCase("remove")) {
Document base = Document.parse(itemClass.getData().toJson());
List<String> lore = itemClass.getLore();
lore.remove(Integer.valueOf(args[3]) - 1);
itemClass.setLore(lore);
sender.sendMessage(ChatColor.GREEN + "Updated item lore successfully.");
AUDIT_LOG.saveEntry(itemClass, user, base, "Removed lore line #" + args[3]);
} else {
sender.sendMessage(ChatColor.RED + "Invalid arguments! /item <ClassName> lore [add <Lore>|remove <LineNo>]");
}
}
use of mc.dragons.core.gameobject.item.ItemClass in project DragonsOnline by UniverseCraft.
the class PlayerEventListeners method onJoin.
@EventHandler
public void onJoin(PlayerJoinEvent event) {
LOGGER.debug("Join event on " + event.getPlayer().getName());
event.setJoinMessage(null);
Player player = event.getPlayer();
if (!plugin.isJoinable()) {
event.getPlayer().kickPlayer(ChatColor.YELLOW + "This server (" + plugin.getServerName() + ") is still loading and is not joinable yet.\n" + "Please try again in a few minutes.\n\n" + "This is not a punishment-related kick.");
return;
}
rollingAsync(() -> {
UUID uuid = player.getUniqueId();
User user = userLoader.loadObject(uuid);
boolean firstJoin = false;
if (user == null) {
firstJoin = true;
plugin.getLogger().info("Player " + player.getName() + " joined for the first time");
user = userLoader.registerNew(player);
user.sendToFloor("BeginnerTown");
int i = 1;
final User fUser = user;
for (ItemClass itemClass : DEFAULT_INVENTORY) {
sync(() -> fUser.giveItem(itemLoader.registerNew(itemClass), true, false, true), i);
i++;
}
}
Floor floor = FloorLoader.fromLocation(player.getLocation());
if (floor.isPlayerLocked() && !PermissionUtil.verifyActivePermissionLevel(user, PermissionLevel.GM, false)) {
sync(() -> player.kickPlayer(ChatColor.RED + "This floor (#" + floor.getLevelMin() + " " + floor.getDisplayName() + ") is currently locked for maintenance.\n" + "You will be allowed to re-join once the maintenance completes.\n\n" + "This is not a punishment-related kick.\n\n" + StringUtil.dateFormatNow()));
return;
}
if (user.getRank().isStaff()) {
GameMode restoreTo = user.getSavedGameMode();
final User fUser = user;
sync(() -> {
fUser.setGameMode(GameMode.ADVENTURE, true);
fUser.setGameMode(restoreTo, false);
fUser.sendToFloor("Staff");
player.setPlayerListName(ChatColor.DARK_GRAY + "" + ChatColor.MAGIC + "[Staff Joining]");
fUser.updatePrimaryNameTag();
});
player.sendMessage(ChatColor.AQUA + "Please login to your system profile or select \"Join as player\".");
} else {
user.handleJoin(firstJoin);
}
});
}
Aggregations