@Override public String getPromptText(ConversationContext context) { String name = (String) context.getSessionData("name"); boolean success = this.pet.setPetName(name, false); if (success) { return this.admin ? Lang.ADMIN_NAME_PET.toString() .replace("%player%", this.pet.getNameOfOwner()) .replace("%type%", StringUtil.capitalise(this.pet.getPetType().toString().replace("_", " "))) .replace("%name%", name) : Lang.NAME_PET.toString() .replace("%type%", StringUtil.capitalise(this.pet.getPetType().toString().replace("_", " "))) .replace("%name%", name); } else { return Lang.NAME_NOT_ALLOWED.toString().replace("%name%", name); } }
@Override public String getPromptText(ConversationContext context) { String name = (String) context.getSessionData("name"); boolean success = this.pet.setPetName(name, false); if (success) { return this.admin ? Lang.ADMIN_NAME_PET.toString() .replace("%player%", this.pet.getNameOfOwner()) .replace("%type%", this.pet.getPetType().toPrettyString()) .replace("%name%", name) : Lang.NAME_PET.toString() .replace("%type%", this.pet.getPetType().toPrettyString()) .replace("%name%", name); } else { return Lang.NAME_NOT_ALLOWED.toString().replace("%name%", name); } }
@Override public String getPromptText(ConversationContext conversationContext) { if (conversationContext.getSessionData("askingForDelay") == null) { conversationContext.setSessionData("askingForDelay", false); } if (conversationContext.getSessionData("nextFrame") == null) { conversationContext.setSessionData("nextFrame", false); } if ((Boolean) conversationContext.getSessionData("askingForDelay")) { return Lang.PROMPT_DELAY.getValue(); } if ((Boolean) conversationContext.getSessionData("nextFrame")) { conversationContext.setSessionData("nextFrame", false); return Lang.PROMPT_NEXT_FRAME.getValue("num", (this.frames.size() + 1) + ""); } if (this.first) { return Lang.PROMPT_INPUT_FRAMES.getValue(); } else { return Lang.PROMPT_INPUT_NEXT.getValue("input", ChatColor.translateAlternateColorCodes('&', conversationContext.getSessionData("lastAdded") + "")); } }
@Override public void runExtraData(ConversationContext context, Registration plugin) { Player ply = (Player) context.getForWhom(); int amount = (Integer) context.getSessionData("count"); item.setAmount(amount); HashMap<Integer, ItemStack> extraItems = ply.getInventory().addItem(item); int returnAmount = 0; for (ItemStack s : extraItems.values()) { returnAmount += s.getAmount(); } if (returnAmount != 0) { int returnSilver = (int) (returnAmount * (this.getItemCost() - (this.getItemCost() * (Double) context.getSessionData("discount")))); SPlayer sply = plugin.players.get(ply.getName()); sply.setCurrency(sply.getCurrency() + returnSilver); context.getForWhom().sendRawMessage(ChatColor.AQUA + "Shop: Some items you ordered wouldn't fit in your inventory. They have been refunded."); } }
@Override public String getPromptText(ConversationContext conversationContext) { ArrayList<HoloInputBuilder> builders = (ArrayList<HoloInputBuilder>) conversationContext.getSessionData("builders"); //ArrayList<String> lines = new ArrayList<String>(); HologramFactory hf = new HologramFactory(HoloAPI.getCore()); for (HoloInputBuilder b : builders) { if (b.getType() == null || b.getLineData() == null) { continue; } if (b.getType().equalsIgnoreCase("IMAGE")) { ImageGenerator gen = HoloAPI.getImageLoader().getGenerator(b.getLineData()); if (gen == null) { continue; } hf.withImage(gen); } else { hf.withText(b.getLineData()); } } if (hf.isEmpty()) { return Lang.BUILDER_EMPTY_LINES.getValue(); } hf.withLocation(((Player) conversationContext.getForWhom()).getLocation()); Hologram h = hf.build(); return Lang.HOLOGRAM_CREATED.getValue("id", h.getSaveId()); }
@Override public void runPurchaseAnnoucement(ConversationContext context, final Registration plugin) { context.getForWhom() .sendRawMessage( ChatColor.GOLD + "> " + ChatColor.AQUA + "Purchase complete! The server MOTD has been changed."); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { plugin.redisDatabase.sendSettingsUpdate("motd"); } }); }
@Override public void runExtraData(final ConversationContext context, final Registration plugin) { final String name = ((Player) context.getForWhom()).getName(); final SPlayer sply = plugin.players.get(((Player) context.getForWhom()) .getName()); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { try { plugin.sqldb.executeSQL( "UPDATE `data` SET `nickname`=? WHERE Username=?", name, sply.getPlayer().getName()); sply.getPlayer().setDisplayName(name); plugin.conn.setPlayerListName(sply.getPlayer(), true); } catch (Exception e) { e.printStackTrace(); } } }); }
public void setupFinalDiscount(ConversationContext context) { if (plugin.zoneManager.getShopDiscount(((Player) context.getForWhom()).getLocation()) > 0.00) { double discount = plugin.zoneManager.getShopDiscount(((Player) context.getForWhom()).getLocation()); context.getForWhom().sendRawMessage(ChatColor.AQUA + "Shop: " + ChatColor.GOLD + "Regional Discount: " + ChatColor.GRAY + discount * 100 + "%"); double oldDiscount = (Double) context.getSessionData("discount"); discount += oldDiscount; if (discount > .9) { discount = .9; } context.getForWhom().sendRawMessage(ChatColor.AQUA + "Shop: " + ChatColor.GOLD + "Final Discount: " + discount * 100 + "%"); context.setSessionData("discount", discount); context.setSessionData("usingdiscount", true); } }
@Override public String getPromptText(ConversationContext arg0) { sply = plugin.players.get(((Player) arg0.getForWhom()).getName()); item = (Item) arg0.getSessionData("item2"); double discount = (Double) arg0.getSessionData("discount"); arg0.getForWhom().sendRawMessage( ChatColor.AQUA + "Shop: You are purchasing at " + ChatColor.GRAY + NumberFormat.getInstance() .format((int) (item.getItemCost() - (item .getItemCost() * discount))) + " silver " + ChatColor.AQUA + "per unit."); arg0.getForWhom().sendRawMessage( ChatColor.AQUA + "Shop: You currently have " + ChatColor.GRAY + NumberFormat.getInstance().format(sply.getCurrency()) + " silver" + ChatColor.AQUA + "."); return "Enter an amount between 1 and 64. Your price will be calculated based on your choice."; }
@Override public String getPromptText(ConversationContext context) { Player ply = (Player) context.getForWhom(); SPlayer sply = plugin.players.get(ply.getName()); context.getForWhom().sendRawMessage( ChatColor.AQUA + "Inventory: " + "Welcome to your ShankShock inventory!"); context.getForWhom().sendRawMessage( ChatColor.AQUA + "Inventory: " + "To exit at any time, type: " + ChatColor.RED + "LEAVENOW!"); context.getForWhom().sendRawMessage( ChatColor.AQUA + "Inventory: " + ChatColor.GRAY + "Silver: " + NumberFormat.getInstance().format(sply.getCurrency())); context.getForWhom().sendRawMessage( ChatColor.AQUA + "Inventory: " + "Options: "); context.getForWhom().sendRawMessage( ChatColor.AQUA + "Inventory: " + ChatColor.GOLD + "1. " + ChatColor.AQUA + "View items"); context.getForWhom().sendRawMessage( ChatColor.AQUA + "Inventory: " + ChatColor.GOLD + "2. " + ChatColor.AQUA + "Transfer Silver"); context.getForWhom().sendRawMessage( ChatColor.AQUA + "Inventory: " + ChatColor.GOLD + "3. " + ChatColor.AQUA + "View awards"); return "Which option number?"; }
@Override protected Prompt acceptValidatedInput(ConversationContext context, String input) { int option = Integer.parseInt(input); Player ply = (Player) context.getForWhom(); SPlayer sply = plugin.players.get(ply.getName()); if (option == 3) { return new AwardList(plugin); } else if (option == 2) { return new SilverTransferPlayerPrompt(plugin); } else if (option == 1) { if (sply.getInventoryStore().getInventory().size() == 0) { context.getForWhom().sendRawMessage( ChatColor.AQUA + "Inventory: " + ChatColor.RED + "You have no items. Buy some to fix this!"); return new InventoryStart(plugin); } return new ItemList(plugin); } return new InventoryStart(plugin); }
@Override public void runExtraData(ConversationContext context, final Registration plugin) { final SPlayer sply = plugin.players.get(((Player) context.getForWhom()) .getName()); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { try { plugin.sqldb.executeSQL("INSERT INTO `pure-invites` VALUES(?, ?)", sply.getPlayer().getName(), 0); plugin.pureEngine.cacheDatabase(); } catch (Exception e) { e.printStackTrace(); } } }); }
@Override public void runExtraData(ConversationContext context, final Registration plugin) { final String name = (String) context.getSessionData("name"); final SPlayer sply = plugin.players.get(((Player) context.getForWhom()).getName()); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { try { plugin.sqldb.executeSQL("UPDATE `data` SET `nickname`=? WHERE Username=?", name, sply.getPlayer().getName()); sply.getPlayer().setDisplayName(name); plugin.conn.setPlayerListName(sply.getPlayer(), true); } catch (Exception e) { e.printStackTrace(); } } }); }
@Override public Prompt acceptInput(ConversationContext conversationContext, String s) { if (s.length() > 32) { conversationContext.getForWhom().sendRawMessage(EchoPet.getPrefix() + Lang.PET_NAME_TOO_LONG.toString()); return this; } conversationContext.setSessionData("name", s); return new NameSuccessPrompt(this.pet, this.admin); }
@Override protected Prompt acceptValidatedInput(ConversationContext context, String input) { if(input.equalsIgnoreCase("quit") || input.equalsIgnoreCase("stop") || input.equalsIgnoreCase("end")) return Prompt.END_OF_CONVERSATION; if(listener.onAnswer(input)) return Prompt.END_OF_CONVERSATION; else return this; }
@Override public String getPromptText(ConversationContext conversationContext) { List buffer = (List) conversationContext.getSessionData("buffer"); String prefix = String.format(VarScript.promptLinePrefix, buffer.size()); if (buffer.size() == 0) return prefix + translateAlternateColorCodes('&', "&7<no lines>&r"); return prefix + buffer.get(buffer.size()-1); }
@Override public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase("DONE")) { LangSetting.send(context.getForWhom(), "}"); return new ScriptBuilderSuccess(this.lines, this.scriptName); } this.lines.add(currentlyEditing, input); return this; }
@Override public String getPromptText(ConversationContext context) { if (this.currentlyEditing == 0 && lines.isEmpty()) { return ChatColor.DARK_AQUA + "function(hologram, player) {"; } int edit = currentlyEditing; currentlyEditing = lines.size() - 1; return new PowerMessage().then(edit).colour(ChatColor.DARK_AQUA).then(lines.get(edit)).colour(ChatColor.AQUA).group().tooltip(buildCompiledOutput()).tooltip(ChatColor.YELLOW + "" + ChatColor.ITALIC + "Click to edit this line").perform("script editcurrent " + edit).exit().toJson(); }
@Override protected Prompt acceptValidatedInput(ConversationContext conversationContext, String s) { Object findLoc = conversationContext.getSessionData("findloc"); if (findLoc != null && ((Boolean) findLoc)) { if (s.contains(" ")) { String[] split = s.split("\\s"); if (split.length == 4) { if (Bukkit.getWorld(split[0]) != null) { try { conversationContext.setSessionData("location", new Location(Bukkit.getWorld(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]))); return this.successPrompt; } catch (NumberFormatException e) { conversationContext.setSessionData("fail_int", true); } } else { conversationContext.setSessionData("fail_world", true); } } else { conversationContext.setSessionData("fail_format", true); } } else { conversationContext.setSessionData("fail_format", true); } } else if (s.equalsIgnoreCase("DONE")) { conversationContext.setSessionData("lines", this.lines.toArray(new String[this.lines.size()])); if (conversationContext.getSessionData("location") == null) { if (conversationContext.getForWhom() instanceof Player) { conversationContext.setSessionData("location", ((Player) conversationContext.getForWhom()).getLocation()); return this.successPrompt; } else { conversationContext.setSessionData("findloc", true); } } else { return this.successPrompt; } } else { this.lines.add(s); } return new InputPrompt(this.lines, this.successPrompt, s); }
@Override public boolean isValid(ConversationContext context, String input) { if (input.contains(" ")) { String[] split = input.split("\\s"); if (split.length == 4) { if (Bukkit.getWorld(split[0]) != null) { for (int i = 1; i <= 3; i++) { if (!GeneralUtil.isInt(split[i])) { context.setSessionData("fail_int", true); return false; } } this.location = new Location(Bukkit.getWorld(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3])); } else { context.setSessionData("fail_world", true); return false; } } else { context.setSessionData("fail_format", true); return false; } } else { context.setSessionData("fail_format", true); return false; } return true; }
@Override public void runPurchaseAnnoucement(ConversationContext context, Registration plugin) { boolean isFree = (Boolean) context.getSessionData("free"); if (isFree) { context.getForWhom().sendRawMessage(ChatColor.AQUA + "Your chat title has been changed."); } else { context.getForWhom().sendRawMessage(ChatColor.AQUA + "Purchase complete! Your chat title has been changed."); } }
@Override protected Prompt acceptValidatedInput(ConversationContext context, String input) { Prompt next = this.function.function(context, input); if (next != null) { return next; } return this.successPrompt != null ? this.successPrompt : new SimpleInputSuccessPrompt(this.function.getSuccessMessage(context, input)); }
@Override public void runExtraData(ConversationContext context, Registration plugin) { Player ply = (Player) context.getForWhom(); HashMap<Integer, ItemStack> extraItems = ply.getInventory().addItem(item); int returnAmount = 0; for (ItemStack s : extraItems.values()) { returnAmount++; ply.getWorld().dropItem(ply.getLocation(), s); } if (returnAmount != 0) { context.getForWhom().sendRawMessage(ChatColor.AQUA + "Shop: Some items you ordered wouldn't fit in your inventory. They have been dropped on the floor."); } }
@Override public String getPromptText(ConversationContext conversationContext) { ArrayList<Frame> frames = new ArrayList<>(); for (Frame f : this.frames) { frames.add(new Frame(delay, f.getLines())); } // If we're here it should be a player AnimatedHologram h = new AnimatedHologramFactory(HoloAPI.getCore()).withText(new AnimatedTextGenerator(frames.toArray(new Frame[frames.size()]))).withLocation(((Player) conversationContext.getForWhom()).getLocation()).build(); return Lang.HOLOGRAM_CREATED.getValue("id", h.getSaveId()); }
@Override protected boolean isInputValid(ConversationContext conversationContext, String s) { if (s.equalsIgnoreCase("DONE")) { return true; } return this.currentBuilder != null || s.equalsIgnoreCase("TEXT") || s.equalsIgnoreCase("IMAGE"); }
@Override public void runExtraData(ConversationContext context, Registration plugin) { SPlayer sply = plugin.players.get(((Player) context.getForWhom()) .getName()); Player ply = sply.getPlayer(); boolean enableStorm = (Boolean) context.getSessionData("storm"); ply.getWorld().setStorm(enableStorm); }
@Override public String getPromptText(ConversationContext context) { context.getForWhom().sendRawMessage( ChatColor.AQUA + "Shop: Your name must not exceed 14 characters."); return "What name would you like?"; }
@Override protected Prompt acceptValidatedInput(ConversationContext context, boolean input) { if (input) { final SPlayer ply = plugin.players.get(((Player) context.getForWhom()).getName()); final Item i = (Item) context.getSessionData("itemobj"); final boolean clearChatColorCopy = clearChatColor; final boolean clearChatTitleCopy = clearChatTitle; plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { @Override public void run() { ply.addCurrency(refund, false); ply.saveCurrency(); ply.getInventoryStore().delItem(i); if (clearChatColorCopy) { ply.setChatColor(""); } if (clearChatTitleCopy) { ply.setChatPrefix(""); } plugin.conn.cacheChatFormat(ply); ply.saveAccount(); } }); } return new ItemList(plugin); }
@Override protected Prompt acceptValidatedInput(ConversationContext arg0, String arg1) { if (arg1.toLowerCase().equals("sunny")) { arg0.setSessionData("storm", false); } else { arg0.setSessionData("storm", true); } return new FinalShopConfirmation(plugin); }
@Override protected boolean isInputValid(ConversationContext arg0, String arg1) { if (arg1.toLowerCase().equals("stormy") || arg1.toLowerCase().equals("sunny")) { return true; } return false; }
@Override public String getPromptText(ConversationContext arg0) { arg0.getForWhom().sendRawMessage( ChatColor.AQUA + "Shop: " + ChatColor.RED + "Online Players:"); for (Player ply : plugin.getServer().getOnlinePlayers()) { arg0.getForWhom().sendRawMessage( ChatColor.AQUA + "Shop: " + ChatColor.RED + ply.getName() + " (" + ply.getDisplayName() + ")"); } return "Who would you like to assassinate?"; }
@Override protected Prompt acceptValidatedInput(ConversationContext context, Player input) { if (input.getWorld().getName().contains("stock")) { context.getForWhom() .sendRawMessage( ChatColor.RED + "Player is in Pure, and can't be selected at this time."); return new PlayerSelector(plugin); } context.setSessionData("player", input); return new FinalShopConfirmation(plugin); }
@Override public String getPromptText(ConversationContext arg0) { arg0.getForWhom() .sendRawMessage( ChatColor.AQUA + "Shop: Requirements: Given MOTD be between 1 and 30 characters."); return "What would you like the new status screen MOTD to be?"; }
@Override protected boolean isInputValid(ConversationContext arg0, String arg1) { if (arg1.trim().length() == 0 || arg1.trim().length() > 30) { return false; } return true; }
@Override protected Prompt acceptValidatedInput(ConversationContext context, String choice) { if (choice.equalsIgnoreCase("use")) { context.setSessionData("free", true); item.runExtraData(context, plugin); item.runPurchaseAnnoucement(context, plugin); } else if (choice.equalsIgnoreCase("sell")) { context.setSessionData("itemobj", item); return new ItemSellbackConfirmation(plugin); } else if (choice.equalsIgnoreCase("back")) { return new ItemList(plugin); } return Prompt.END_OF_CONVERSATION; }
@Override protected boolean isInputValid(ConversationContext context, String choice) { if (choice.equalsIgnoreCase("back") || choice.equalsIgnoreCase("sell") || choice.equalsIgnoreCase("use")) { return true; } return false; }
@Override public String getPromptText(ConversationContext arg0) { arg0.getForWhom().sendRawMessage( ChatColor.AQUA + "Shop: " + ChatColor.RED + "Online Players:"); for (Player ply : plugin.getServer().getOnlinePlayers()) { arg0.getForWhom().sendRawMessage( ChatColor.AQUA + "Shop: " + ChatColor.RED + ply.getName() + " (" + ply.getDisplayName() + ")"); } return "Who would you like to send Silver to?"; }
@Override protected Prompt acceptValidatedInput(ConversationContext arg0, String arg1) { if (arg1.toLowerCase().equals("back")) { return new InventoryStart(plugin); } int i = Integer.parseInt(arg1); Item choice = items.get(i); arg0.setSessionData("item", choice); return new ItemInfo(plugin); }
@Override public void runPurchaseAnnoucement(ConversationContext context, Registration plugin) { context.getForWhom().sendRawMessage(ChatColor.AQUA + "Purchase complete! Your items have been delivered."); SPlayer sply = plugin.players.get(((Player) context.getForWhom()).getName()); sply.notifyCurrency(); }