本文整理汇总了Java中org.bukkit.conversations.ConversationContext.setSessionData方法的典型用法代码示例。如果您正苦于以下问题:Java ConversationContext.setSessionData方法的具体用法?Java ConversationContext.setSessionData怎么用?Java ConversationContext.setSessionData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.conversations.ConversationContext
的用法示例。
在下文中一共展示了ConversationContext.setSessionData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPromptText
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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") + ""));
}
}
示例2: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@Override
protected Prompt acceptValidatedInput(ConversationContext arg0, String arg1) {
if (arg1.equals("back")) {
return new ShopCategoryChooser(plugin);
}
Item i = itemCache.get(Integer.parseInt(arg1));
arg0.setSessionData("item", itemCache.get(Integer.parseInt(arg1))
.getItemType());
if (inventory.contains(i.getItemType())) {
arg0.setSessionData("free", true);
} else {
arg0.setSessionData("free", false);
}
return new ItemInfoPrompt(plugin);
}
示例3: setupFinalDiscount
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
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);
}
}
示例4: acceptInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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);
}
示例5: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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);
}
示例6: isValid
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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;
}
示例7: isInputValid
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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());
}
示例8: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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);
}
示例9: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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);
}
示例10: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@Override
protected Prompt acceptValidatedInput(ConversationContext arg0, Number arg1) {
double discount = (Double) arg0.getSessionData("discount");
if (arg1.intValue() > 64 || arg1.intValue() < 1) {
return new MCItemAmountSelector(plugin);
}
if (arg1.intValue()
* (item.getItemCost() - (item.getItemCost() * discount)) > sply.getCurrency()) {
return new MCItemAmountSelector(plugin);
}
arg0.setSessionData("count", arg1.intValue());
return new FinalShopConfirmation(plugin);
}
示例11: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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;
}
示例12: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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);
}
示例13: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@Override
protected Prompt acceptValidatedInput(ConversationContext arg0, String arg1) {
int i = Integer.parseInt(arg1);
Award choice = awards.get(i);
arg0.setSessionData("award", choice);
return new AwardInfo(plugin);
}
示例14: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@Override
protected Prompt acceptValidatedInput(ConversationContext arg0, String arg1) {
arg0.setSessionData("name", arg1);
return new FinalShopConfirmation(plugin);
}
示例15: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@Override
protected Prompt acceptValidatedInput(ConversationContext arg0, boolean arg1) {
if ((canPurchase || isFree) && arg1) {
arg0.setSessionData("item2", item);
SPlayer sply = plugin.players.get(((Player) arg0.getForWhom())
.getName());
if (item instanceof PureInvitationItem && sply.hasPureAccess()) {
return new ShopCategoryChooser(plugin);
}
if (item instanceof NameChangeItem) {
return new NameChangePrompt(plugin);
} else if (item instanceof MOTDChangeItem) {
return new MOTDChangePrompt(plugin);
} else if (item instanceof WeatherChangeItem) {
return new WeatherChangePrompt(plugin);
} else if (item instanceof AssassinationItem) {
return new PlayerSelector(plugin);
}
if (item instanceof MinecraftItem) {
return new MCItemAmountSelector(plugin);
}
return new FinalShopConfirmation(plugin);
}
if (canPurchase && !arg1) {
return new ShopCategoryChooser(plugin);
}
if (!canPurchase && arg1) {
return new ShopCategoryChooser(plugin);
}
if (!canPurchase && !arg1) {
return Prompt.END_OF_CONVERSATION;
}
return null;
}