当前位置: 首页>>代码示例>>Java>>正文


Java ConversationContext类代码示例

本文整理汇总了Java中org.bukkit.conversations.ConversationContext的典型用法代码示例。如果您正苦于以下问题:Java ConversationContext类的具体用法?Java ConversationContext怎么用?Java ConversationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConversationContext类属于org.bukkit.conversations包,在下文中一共展示了ConversationContext类的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);
    }
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:18,代码来源:NameSuccessPrompt.java

示例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);
    }
}
 
开发者ID:TechzoneMC,项目名称:SonarPet,代码行数:18,代码来源:NameSuccessPrompt.java

示例3: 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") + ""));
    }
}
 
开发者ID:DSH105,项目名称:HoloAPI,代码行数:23,代码来源:AnimationBuilderInputPrompt.java

示例4: 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.");
	}
}
 
开发者ID:hakusaro,项目名称:ShankShock-Core,代码行数:20,代码来源:MinecraftItem.java

示例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());
}
 
开发者ID:DSH105,项目名称:HoloAPI,代码行数:27,代码来源:BuilderInputSuccessPrompt.java

示例6: runPurchaseAnnoucement

import org.bukkit.conversations.ConversationContext; //导入依赖的package包/类
@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");
		}
		
	});
}
 
开发者ID:hakusaro,项目名称:ShankShock-Core,代码行数:20,代码来源:MOTDChangeItem.java

示例7: runExtraData

import org.bukkit.conversations.ConversationContext; //导入依赖的package包/类
@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();
			}
		}
	});
}
 
开发者ID:hakusaro,项目名称:ShankShock-Core,代码行数:21,代码来源:NameResetItem.java

示例8: 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);

	}
}
 
开发者ID:hakusaro,项目名称:ShankShock-Core,代码行数:19,代码来源:ShopCategoryChooser.java

示例9: getPromptText

import org.bukkit.conversations.ConversationContext; //导入依赖的package包/类
@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.";
}
 
开发者ID:hakusaro,项目名称:ShankShock-Core,代码行数:21,代码来源:MCItemAmountSelector.java

示例10: getPromptText

import org.bukkit.conversations.ConversationContext; //导入依赖的package包/类
@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?";
}
 
开发者ID:hakusaro,项目名称:ShankShock-Core,代码行数:27,代码来源:InventoryStart.java

示例11: acceptValidatedInput

import org.bukkit.conversations.ConversationContext; //导入依赖的package包/类
@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);
}
 
开发者ID:hakusaro,项目名称:ShankShock-Core,代码行数:23,代码来源:InventoryStart.java

示例12: runExtraData

import org.bukkit.conversations.ConversationContext; //导入依赖的package包/类
@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();
			}
		}
	});
}
 
开发者ID:hakusaro,项目名称:ShankShock-Core,代码行数:19,代码来源:PureInvitationItem.java

示例13: runExtraData

import org.bukkit.conversations.ConversationContext; //导入依赖的package包/类
@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();
			}
		}
	});
}
 
开发者ID:hakusaro,项目名称:ShankShock-Core,代码行数:19,代码来源:NameChangeItem.java

示例14: 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);
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:10,代码来源:NamePrompt.java

示例15: acceptValidatedInput

import org.bukkit.conversations.ConversationContext; //导入依赖的package包/类
@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;
}
 
开发者ID:MrLittleKitty,项目名称:AnnihilationPro,代码行数:12,代码来源:SingleQuestionPrompt.java


注:本文中的org.bukkit.conversations.ConversationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。