use of mc.dragons.core.gameobject.item.ItemClass in project DragonsOnline by UniverseCraft.
the class ResetProfileCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!requirePermission(sender, PermissionLevel.TESTER))
return true;
User target = user(sender);
if (args.length != 0 && requirePermission(sender, PermissionLevel.ADMIN)) {
target = lookupUser(sender, args[0]);
}
if (target == null)
return true;
boolean resetRank = false;
if (args.length > 1) {
resetRank = hasPermission(sender, PermissionLevel.ADMIN) && (args[1].equalsIgnoreCase("-r") || args[1].equalsIgnoreCase("-resetrank"));
}
target.setXP(0);
target.setActivePermissionLevel(PermissionLevel.USER);
target.setGold(0.0);
target.setChatSpy(false);
target.setGodMode(false);
target.setGameMode(GameMode.ADVENTURE, true);
// target.setDebuggingErrors(false);
target.setStreamConsoleLevel(Level.OFF);
target.clearInventory();
for (SkillType skill : SkillType.values()) {
target.setSkillLevel(skill, 0);
target.setSkillProgress(skill, 0.0);
}
for (Quest quest : new HashSet<>(target.getQuestProgress().keySet())) {
target.updateQuestProgress(quest, null);
}
target.sendToFloor("BeginnerTown");
for (ItemClass itemClass : PlayerEventListeners.DEFAULT_INVENTORY) {
target.giveItem(itemLoader.registerNew(itemClass));
}
if (resetRank) {
target.setRank(Rank.DEFAULT);
}
target.getPlayer().sendTitle(ChatColor.DARK_RED + "RESET", ChatColor.RED + "Your stats have been wiped!", 10, 70, 20);
target.sendActionBar(ChatColor.DARK_RED + "- Your stats have been wiped! -");
target.debug("Profile forcibly reset");
if (target.equals(user(sender))) {
sender.sendMessage(ChatColor.GREEN + "Wiped your stats.");
} else {
sender.sendMessage(ChatColor.GREEN + "Wiped " + target.getName() + "'s stats.");
}
return true;
}
use of mc.dragons.core.gameobject.item.ItemClass in project DragonsOnline by UniverseCraft.
the class NPCAction method execute.
/**
* Run the specified action on the specified user and NPC.
*
* @param user
* @param npc
*/
public void execute(final User user, NPC npc) {
switch(type) {
case BEGIN_QUEST:
if (quest.isLocked()) {
user.getPlayer().sendMessage(ChatColor.RED + "This quest is currently locked! Try again later.");
return;
}
GUI confirmation = new GUI(1, "Accept quest?");
confirmation.add(new GUIElement(1, Material.EMERALD_BLOCK, ChatColor.GREEN + "✓ " + ChatColor.DARK_GREEN + ChatColor.BOLD + "Accept", ChatColor.GRAY + "You will be unable to interact with\n" + ChatColor.GRAY + "other players, mobs, or NPCs during\n" + ChatColor.GRAY + "quest dialogue.", u -> {
u.updateQuestProgress(quest, quest.getSteps().get(0));
u.closeGUI(true);
}));
confirmation.add(new GUIElement(4, Material.PAPER, ChatColor.YELLOW + "Quest Information", ChatColor.GRAY + "Quest: " + ChatColor.RESET + quest.getQuestName() + "\n" + ChatColor.GRAY + "Lv Min: " + ChatColor.RESET + quest.getLevelMin()));
confirmation.add(new GUIElement(7, Material.REDSTONE_BLOCK, ChatColor.RED + "✘ " + ChatColor.DARK_RED + ChatColor.BOLD + "Not Now", ChatColor.GRAY + "You can always come back later to\n" + ChatColor.GRAY + "start the quest.", u -> u.closeGUI(true)));
confirmation.open(user);
break;
case BEGIN_DIALOGUE:
user.setDialogueBatch(null, npcClass.getName(), dialogue);
new BukkitRunnable() {
@Override
public void run() {
if (!user.nextDialogue()) {
cancel();
}
}
}.runTaskTimer(Dragons.getInstance(), 0L, 40L);
break;
case TELEPORT_NPC:
npc.getEntity().teleport(to);
break;
case PATHFIND_NPC:
boolean hasAI = Dragons.getInstance().getBridge().hasAI(npc.getEntity());
if (hasAI) {
Dragons.getInstance().getBridge().setEntityAI(npc.getEntity(), false);
}
PathfindingUtil.walkToLocation(npc.getEntity(), to, 0.15D, (e) -> {
if (hasAI) {
Dragons.getInstance().getBridge().setEntityAI(e, true);
}
});
break;
case OPEN_SHOP:
int rows = 2 + (int) Math.ceil(shopItems.size() / 7.0D);
GUI shop = new GUI(rows, shopName);
user.debug("opening shop with " + rows + " rows and name " + shopName + " with " + shopItems.size() + " items");
int slot = 10;
for (ShopItem item : shopItems) {
ItemClass itemClass = itemClassLoader.getItemClassByClassName(item.getItemClassName());
shop.add(itemClass.getAsGuiElement(slot, item.getQuantity(), item.getCostPer(), false, u -> u.buyItem(itemClass, item.getQuantity(), item.getCostPer())));
slot++;
if ((slot + 1) % 9 == 0) {
slot += 2;
}
}
shop.open(user);
break;
}
}
use of mc.dragons.core.gameobject.item.ItemClass in project DragonsOnline by UniverseCraft.
the class DragonsDev method onEnable.
public void onEnable() {
enableDebugLogging();
saveDefaultConfig();
dragons = getDragonsInstance();
buildNotifier = new DiscordNotifier(getConfig().getString("discord-notifier-webhook-url"));
buildNotifier.setEnabled(getConfig().getBoolean("discord-notifier-enabled"));
ADVICE_BROADCASTER_PERIOD_SECONDS = getConfig().getInt("staff-advice.period-seconds", 60 * 2);
BACKUP_FOLDER = getConfig().getString("backup.folder", "C:\\DragonsBackups\\");
BACKUP_PERIOD_MINUTES = getConfig().getInt("backup.period-minutes", 60);
BACKUP_RETENTION_DAYS = getConfig().getInt("backup.retention-days", 30);
MAX_STARS = getConfig().getInt("stars.max-stars", 5);
MAX_ASSIGN_STARS = getConfig().getInt("stars.max-assign-stars", 10);
Map<String, Object> shop = getConfig().getConfigurationSection("stars.staff-shop").getValues(false);
ItemClassLoader itemClassLoader = GameObjectType.ITEM_CLASS.getLoader();
ItemLoader itemLoader = GameObjectType.ITEM.getLoader();
int rows = (int) Math.ceil(2 + (double) shop.size() / 7);
int slot = 10;
int run = 0;
STAFF_SHOP = new GUI(rows, "Staff Shop");
for (Entry<String, Object> entry : shop.entrySet()) {
String className = entry.getKey();
int price = (int) entry.getValue();
ItemClass itemClass = itemClassLoader.getItemClassByClassName(className);
if (itemClass == null) {
getLogger().warning("Could not add item to staff shop: No item class \"" + className + "\" exists");
continue;
}
List<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "Price: " + ChatColor.GOLD + price + TaskLoader.STAR);
lore.addAll(Item.getCompleteLore(itemClass.getData(), itemClass.getLore().<String>toArray(new String[itemClass.getLore().size()]), null, false, itemClass));
GUIElement elem = new GUIElement(slot, itemClass.getMaterial(), itemClass.getDecoratedName(), lore, 1, user -> {
int stars = DevUserHook.getStars(user);
if (stars < price) {
user.getPlayer().sendMessage(ChatColor.RED + "This item costs " + price + TaskLoader.STAR + "! (Need " + (price - stars) + " more)");
} else {
user.giveItem(itemLoader.registerNew(itemClass));
dragons.getStaffAlertHandler().sendGenericMessage(PermissionLevel.TESTER, ChatColor.GOLD + user.getName() + " redeemed " + price + TaskLoader.STAR + " for a " + itemClass.getDecoratedName() + "!");
DevUserHook.addStars(user, -price);
}
});
STAFF_SHOP.add(elem);
slot++;
run++;
if (run == 7) {
run = 0;
slot += 2;
}
}
TaskLoader taskLoader = new TaskLoader(dragons);
dragons.getLightweightLoaderRegistry().register(taskLoader);
DevUserHook hook = new DevUserHook();
dragons.getUserHookRegistry().registerHook(hook);
Bukkit.getPluginManager().registerEvents(hook, this);
CommandExecutor taskCommands = new TaskCommands(this);
getCommand("task").setExecutor(taskCommands);
getCommand("tasks").setExecutor(taskCommands);
getCommand("taskinfo").setExecutor(taskCommands);
getCommand("assign").setExecutor(taskCommands);
getCommand("unassign").setExecutor(taskCommands);
getCommand("done").setExecutor(taskCommands);
getCommand("approve").setExecutor(taskCommands);
getCommand("reject").setExecutor(taskCommands);
getCommand("close").setExecutor(taskCommands);
getCommand("taskloc").setExecutor(taskCommands);
getCommand("tasknote").setExecutor(taskCommands);
getCommand("gototask").setExecutor(taskCommands);
getCommand("togglediscordnotifier").setExecutor(taskCommands);
getCommand("discordnotifyraw").setExecutor(taskCommands);
getCommand("deletetask").setExecutor(taskCommands);
getCommand("taskhelp").setExecutor(taskCommands);
getCommand("reopen").setExecutor(taskCommands);
getCommand("reloadtasks").setExecutor(taskCommands);
getCommand("stars").setExecutor(taskCommands);
getCommand("takestars").setExecutor(taskCommands);
getCommand("givestars").setExecutor(taskCommands);
getCommand("getstars").setExecutor(taskCommands);
getCommand("taskrename").setExecutor(taskCommands);
getCommand("findtasks").setExecutor(taskCommands);
getCommand("staffshop").setExecutor(new StaffShopCommand());
getCommand("backup").setExecutor(new BackupCommand(this));
getCommand("starttrial").setExecutor(new StartTrialCommand());
getCommand("tips").setExecutor(new TipsCommand());
new AdviceBroadcaster().runTaskTimer(this, 20L * ADVICE_BROADCASTER_PERIOD_SECONDS, 20L * ADVICE_BROADCASTER_PERIOD_SECONDS);
syncPeriodic(() -> {
if (Bukkit.getOnlinePlayers().size() > 0) {
backupFloors();
}
}, 20 * 60 * BACKUP_PERIOD_MINUTES, 20 * 60 * BACKUP_PERIOD_MINUTES);
}
use of mc.dragons.core.gameobject.item.ItemClass in project DragonsOnline by UniverseCraft.
the class ItemCommand method deleteClass.
private void deleteClass(CommandSender sender, String[] args) {
if (!requirePermission(sender, SystemProfileFlag.GM_DELETE))
return;
if (args.length == 1) {
sender.sendMessage(ChatColor.RED + "Insufficient arguments! /item delete <ClassName>");
return;
}
ItemClass itemClass = lookupItemClass(sender, args[1]);
if (itemClass == null)
return;
registry.removeFromDatabase(itemClass);
AUDIT_LOG.saveEntry(itemClass, user(sender), "Deleted");
sender.sendMessage(ChatColor.GREEN + "Deleted item class successfully.");
}
use of mc.dragons.core.gameobject.item.ItemClass in project DragonsOnline by UniverseCraft.
the class ItemCommand method displayItemClass.
private void displayItemClass(CommandSender sender, String[] args) {
ItemClass itemClass = lookupItemClass(sender, args[0]);
if (itemClass == null)
return;
sender.sendMessage(ChatColor.GREEN + "=== Item Class: " + itemClass.getClassName() + " ===");
sender.sendMessage(ChatColor.GRAY + "Database identifier: " + ChatColor.GREEN + itemClass.getIdentifier().toString());
sender.sendMessage(ChatColor.GRAY + "Display name: " + ChatColor.GREEN + itemClass.getDecoratedName());
sender.sendMessage(ChatColor.GRAY + "Level min: " + ChatColor.GREEN + itemClass.getLevelMin());
sender.sendMessage(ChatColor.GRAY + "Material type: " + ChatColor.GREEN + itemClass.getMaterial().toString());
sender.sendMessage(ChatColor.GRAY + "Damage: " + ChatColor.GREEN + itemClass.getDamage() + ChatColor.GRAY + " - Armor: " + ChatColor.GREEN + itemClass.getArmor());
sender.sendMessage(ChatColor.GRAY + "Cooldown: " + ChatColor.GREEN + itemClass.getCooldown());
sender.sendMessage(ChatColor.GRAY + "Walk Speed Boost: " + ChatColor.GREEN + itemClass.getSpeedBoost());
sender.sendMessage(ChatColor.GRAY + "Unbreakable: " + ChatColor.GREEN + itemClass.isUnbreakable());
sender.sendMessage(ChatColor.GRAY + "Undroppable: " + ChatColor.GREEN + itemClass.isUndroppable());
sender.sendMessage(ChatColor.GRAY + "GM Locked: " + ChatColor.GREEN + itemClass.isGMLocked());
sender.sendMessage(ChatColor.GRAY + "Max. Stack Size: " + ChatColor.GREEN + itemClass.getMaxStackSize());
sender.sendMessage(ChatColor.GRAY + "Lore:");
for (String loreLine : itemClass.getLore()) {
sender.sendMessage(ChatColor.GREEN + " " + loreLine);
}
if (!itemClass.verifyAddons()) {
sender.sendMessage(ChatColor.RED + "Item class add-on verification failed!");
}
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "[Receive Item] ", "/item give " + itemClass.getClassName(), true, "Click to receive this item"), ObjectMetadataCommand.getClickableMetadataLink(GameObjectType.ITEM_CLASS, itemClass.getUUID()));
}
Aggregations