Java Code Examples for org.bukkit.conversations.ConversationContext#setSessionData()
The following examples show how to use
org.bukkit.conversations.ConversationContext#setSessionData() .
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: 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 2
Source File: NamePrompt.java From SonarPet with GNU General Public License v3.0 | 5 votes |
@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); }
Example 3
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 4
Source File: LocationFunction.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@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; }
Example 5
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 6
Source File: UHPrompts.java From KTP with GNU General Public License v3.0 | 5 votes |
@Override public Prompt acceptInput(ConversationContext context, String input) { if (input.length() > 16) { context.getForWhom().sendRawMessage(ChatColor.RED+"Le nom de la team doit faire 16 caractères maximum."); return this; } context.setSessionData("nomTeam", input); return new TeamColorPrompt(); }
Example 7
Source File: UHPrompts.java From KTP with GNU General Public License v3.0 | 5 votes |
@Override protected Prompt acceptValidatedInput(ConversationContext context, String input) { context.setSessionData("color", StringToChatColor.getChatColorByName(ChatColor.stripColor(input))); p.createTeam((String) context.getSessionData("nomTeam"), (ChatColor) context.getSessionData("color")); context.getForWhom().sendRawMessage(ChatColor.GRAY+"Team "+((ChatColor)context.getSessionData("color"))+context.getSessionData("nomTeam")+ChatColor.GRAY+" créée."); return Prompt.END_OF_CONVERSATION; }
Example 8
Source File: NamePrompt.java From EchoPet with GNU General Public License v3.0 | 5 votes |
@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); }