本文整理汇总了Java中org.bukkit.conversations.ConversationContext.getSessionData方法的典型用法代码示例。如果您正苦于以下问题:Java ConversationContext.getSessionData方法的具体用法?Java ConversationContext.getSessionData怎么用?Java ConversationContext.getSessionData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.conversations.ConversationContext
的用法示例。
在下文中一共展示了ConversationContext.getSessionData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPromptText
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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);
}
}
示例2: getPromptText
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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);
}
}
示例3: runExtraData
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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.");
}
}
示例4: 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") + ""));
}
}
示例5: getPromptText
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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());
}
示例6: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@Override
protected Prompt acceptValidatedInput(ConversationContext arg0, Number arg1) {
if (arg1.intValue() < 0) {
return new SilverTransferItem(plugin);
}
if (arg1.intValue() > sply.getCurrency()) {
return new SilverTransferItem(plugin);
}
Player dply = (Player) arg0.getSessionData("player");
SPlayer dsply = plugin.players.get(dply.getName());
dsply.sendMessage(sply.getPlayer().getDisplayName() + " (" + sply.getPlayer().getName() + ") just sent you " + arg1.intValue() + " silver.");
dsply.addCurrency(arg1.intValue(), false);
sply.delCurrency(arg1.intValue());
arg0.getForWhom().sendRawMessage(
ChatColor.AQUA + "Inventory: Transferred "
+ NumberFormat.getInstance().format(arg1.intValue())
+ " silver to " + dply.getName() + ".");
return Prompt.END_OF_CONVERSATION;
}
示例7: getPromptText
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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);
}
示例8: getPromptText
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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));
}
示例9: getPromptText
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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());
}
示例10: getFailedText
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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 "";
}
示例11: 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());
}
示例12: getPromptText
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@Override
public String getPromptText(ConversationContext context) {
Item i = (Item) context.getSessionData("itemobj");
int cost = i.getItemCost();
refund = (int) Math.round(cost - (.5 * cost));
context.getForWhom().sendRawMessage(ChatColor.GREEN + "Original Price: " + ChatColor.GRAY + NumberFormat.getInstance().format(i.getItemCost()) + ChatColor.GOLD + " silver.");
context.getForWhom().sendRawMessage(ChatColor.GREEN + "Refund Amount: " + ChatColor.GRAY + NumberFormat.getInstance().format(refund) + ChatColor.GOLD + " silver.");
SPlayer sply = plugin.players.get(((Player) context.getForWhom()).getName());
if (i instanceof ChatTitleItem) {
ChatTitleItem chatTitle = (ChatTitleItem) i;
if (chatTitle.getPrefix().equals(sply.getChatPrefix())) {
clearChatTitle = true;
}
}
if (i instanceof ChatColorItem) {
ChatColorItem chatColor = (ChatColorItem) i;
if (chatColor.getChatColor().equals(sply.getChatColor())) {
clearChatColor = true;
}
}
if (i.getItemCategory() == ShopType.NOT_FOR_SALE) {
context.getForWhom().sendRawMessage(ChatColor.RED + "WARNING: " + ChatColor.YELLOW + "This item is not for sale in any shop. Selling this item back will destroy the item. You may not be able to get another.");
}
return "Are you sure you want to sell the item back?";
}
示例13: acceptValidatedInput
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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);
}
示例14: runPurchaseAnnoucement
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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.");
}
}
示例15: runExtraData
import org.bukkit.conversations.ConversationContext; //导入方法依赖的package包/类
@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);
}