本文整理汇总了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();
}
}
}
}
}
}
示例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;
}
示例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"));
}
}
}
}
示例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"));
}
}
}
}