Java Code Examples for org.bukkit.conversations.ConversationContext#getSessionData()
The following examples show how to use
org.bukkit.conversations.ConversationContext#getSessionData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NameSuccessPrompt.java From SonarPet with GNU General Public License v3.0 | 6 votes |
@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); } }
Example 2
Source File: AnimationBuilderInputPrompt.java From HoloAPI with GNU General Public License v3.0 | 6 votes |
@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") + "")); } }
Example 3
Source File: BuilderInputSuccessPrompt.java From HoloAPI with GNU General Public License v3.0 | 6 votes |
@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()); }
Example 4
Source File: NameSuccessPrompt.java From EchoPet with GNU General Public License v3.0 | 6 votes |
@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); } }
Example 5
Source File: InputPrompt.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@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); }
Example 6
Source File: InputPrompt.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@Override public String getPromptText(ConversationContext conversationContext) { Object findLoc = conversationContext.getSessionData("findloc"); if (findLoc != null && ((Boolean) findLoc)) { return Lang.PROMPT_FIND_LOCATION.getValue(); } if (this.first) { return Lang.PROMPT_INPUT.getValue(); } else return Lang.PROMPT_INPUT_NEXT.getValue("input", ChatColor.translateAlternateColorCodes('&', this.lastAdded)); }
Example 7
Source File: InputPrompt.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@Override protected String getFailedValidationText(ConversationContext context, String invalidInput) { Object failInt = context.getSessionData("fail_int"); Object failFormat = context.getSessionData("fail_format"); Object failWorld = context.getSessionData("fail_world"); if (failInt != null && ((Boolean) failInt)) { return Lang.PROMPT_INPUT_FAIL_INT.getValue(); } else if (failFormat != null && (Boolean) failFormat) { return Lang.PROMPT_INPUT_FAIL_FORMAT.getValue(); } else if (failWorld != null && (Boolean) failWorld) { return Lang.PROMPT_INPUT_FAIL_WORLD.getValue("world", invalidInput.split(" ")[0]); } return Lang.PROMPT_INPUT_FAIL.getValue(); }
Example 8
Source File: InputSuccessPrompt.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@Override public String getPromptText(ConversationContext conversationContext) { String[] lines = (String[]) conversationContext.getSessionData("lines"); Location location = (Location) conversationContext.getSessionData("location"); Hologram h = new HologramFactory(HoloAPI.getCore()).withText(lines).withLocation(location).build(); return Lang.HOLOGRAM_CREATED.getValue("id", h.getSaveId()); }
Example 9
Source File: LocationFunction.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@Override public String getFailedText(ConversationContext context, String invalidInput) { Object failInt = context.getSessionData("fail_int"); Object failFormat = context.getSessionData("fail_format"); Object failWorld = context.getSessionData("fail_world"); if (failInt != null && ((Boolean) failInt)) { return Lang.PROMPT_INPUT_FAIL_INT.getValue(); } else if (failFormat != null && (Boolean) failFormat) { return Lang.PROMPT_INPUT_FAIL_FORMAT.getValue(); } else if (failWorld != null && (Boolean) failWorld) { return Lang.PROMPT_INPUT_FAIL_WORLD.getValue("world", invalidInput.split("\\s")[0]); } return ""; }
Example 10
Source File: AnimationBuilderInputPrompt.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@Override protected boolean isInputValid(ConversationContext conversationContext, String s) { if (conversationContext.getSessionData("askingForDelay") == null) { conversationContext.setSessionData("askingForDelay", false); } if (conversationContext.getSessionData("nextFrame") == null) { conversationContext.setSessionData("nextFrame", false); } return !((Boolean) conversationContext.getSessionData("askingForDelay") && !GeneralUtil.isInt(s)) && !(this.first && s.equalsIgnoreCase("DONE")) && !(s.equalsIgnoreCase("NEXT") && this.lines.isEmpty()); }
Example 11
Source File: UHPrompts.java From KTP with GNU General Public License v3.0 | 4 votes |
@Override public String getPromptText(ConversationContext context) { return ChatColor.GRAY+"Entrez le nom du joueur à ajouter dans la team "+((ChatColor)context.getSessionData("color"))+context.getSessionData("nomTeam")+ChatColor.WHITE+"."; }