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


Java SignChangeEvent类代码示例

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


SignChangeEvent类属于cn.nukkit.event.block包,在下文中一共展示了SignChangeEvent类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSignChangeEvent

import cn.nukkit.event.block.SignChangeEvent; //导入依赖的package包/类
@EventHandler
public void onSignChangeEvent(SignChangeEvent e) {
    if (plugin.getMainConfig().isUseSigns()) {
        if (e.getPlayer().hasPermission("minecraftmarket.signs")) {
            List<String> lines = Arrays.asList(e.getLines());
            if (lines.size() > 1 && lines.get(0).equals("[RecentDonor]") && Utils.isInt(lines.get(1))) {
                int order = Utils.getInt(lines.get(1));
                if (order > 0) {
                    if (plugin.getSignsConfig().addDonorSign(order, e.getBlock())) {
                        e.getPlayer().sendMessage(Colors.color(I18n.tl("prefix") + " " + I18n.tl("sign_added")));
                        plugin.getSignsTask().updateSigns();
                    }
                }
            }
        }
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:18,代码来源:SignsListener.java

示例2: updateCompoundTag

import cn.nukkit.event.block.SignChangeEvent; //导入依赖的package包/类
@Override
public boolean updateCompoundTag(CompoundTag nbt, Player player) {
    if (!nbt.getString("id").equals(BlockEntity.SIGN)) {
        return false;
    }
    String[] text = nbt.getString("Text").split("\n", 4);

    SignChangeEvent signChangeEvent = new SignChangeEvent(this.getBlock(), player, text);

    if (!this.namedTag.contains("Creator") || !Objects.equals(player.getUniqueId().toString(), this.namedTag.getString("Creator"))) {
        signChangeEvent.setCancelled();
    }

    if (player.getRemoveFormat()) {
        for (int i = 0; i < text.length; i++) {
            text[i] = TextFormat.clean(text[i]);
        }
    }

    this.server.getPluginManager().callEvent(signChangeEvent);

    if (!signChangeEvent.isCancelled()) {
        this.setText(signChangeEvent.getLines());
        return true;
    }

    return false;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:29,代码来源:BlockEntitySign.java

示例3: onSignChange

import cn.nukkit.event.block.SignChangeEvent; //导入依赖的package包/类
@EventHandler
public void onSignChange(SignChangeEvent event) {
	String[] lines = event.getLines();

	if (lines[0].equalsIgnoreCase("sell") || lines[0].equalsIgnoreCase("[sell]")) {
		Position pos = event.getBlock();
		String key = pos.x + ":" + pos.y + ":" + pos.z + ":" + pos.level.getFolderName();
		if(!this.sells.containsKey(key)){
			Player player = event.getPlayer();
			
			if(player.hasPermission("economysell.create")){
				float price;
				int amount;
				
				try{
					price = Float.parseFloat(lines[1]);
					amount = Integer.parseInt(lines[3]);
				}catch(NumberFormatException e){
					player.sendMessage(this.getMessage("invalid-format"));
					return;
				}
				
				Item item = Item.fromString(lines[2]);
				item.setCount(amount);
				
				this.provider.addSell(pos, item, price, -2);
				
				Sell sell = new Sell(pos, pos.level.getFolderName(), item, price, -2);
				
				this.sells.put(key, sell);
				
				event.setLine(0, this.getMessage("sign-text-1"));
				event.setLine(1, this.getMessage("sign-text-2", new Object[]{price}));
				event.setLine(2, this.getMessage("sign-text-3", new Object[]{item.getName()}));
				event.setLine(3, this.getMessage("sign-text-4", new Object[]{amount}));
				
				player.sendMessage(this.getMessage("sell-created"));
			}
		}
	}
}
 
开发者ID:EconomyS,项目名称:EconomySell,代码行数:42,代码来源:EconomySell.java

示例4: onSignChange

import cn.nukkit.event.block.SignChangeEvent; //导入依赖的package包/类
@EventHandler
   public void onSignChange(SignChangeEvent event) {
       String[] lines = event.getLines();

       if (lines[0].equalsIgnoreCase("shop") || lines[0].equalsIgnoreCase("[shop]")) {
		Position pos = event.getBlock();
		String key = pos.x + ":" + pos.y + ":" + pos.z + ":" + pos.level.getFolderName();
		if(!this.shops.containsKey(key)){
			Player player = event.getPlayer();
			
			if(player.hasPermission("economyshop.create")){
				float price;
				int amount;
				
				try{
					price = Float.parseFloat(lines[1]);
					amount = Integer.parseInt(lines[3]);
				}catch(NumberFormatException e){
					player.sendMessage(this.getMessage("invalid-format"));
					return;
				}
				
				Item item = Item.fromString(lines[2]);
				item.setCount(amount);
				
				this.provider.addShop(pos, item, price, -2);
				
				Shop shop = new Shop(pos, pos.level.getFolderName(), item, price, -2);
				
				this.shops.put(key, shop);
				
				event.setLine(0, this.getMessage("sign-text-1"));
				event.setLine(1, this.getMessage("sign-text-2", new Object[]{price}));
				event.setLine(2, this.getMessage("sign-text-3", new Object[]{item.getName()}));
				event.setLine(3, this.getMessage("sign-text-4", new Object[]{amount}));
				
				player.sendMessage(this.getMessage("shop-created"));
			}
		}
	}
}
 
开发者ID:EconomyS,项目名称:EconomyShop,代码行数:42,代码来源:EconomyShop.java


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