當前位置: 首頁>>代碼示例>>Java>>正文


Java SignChangeEvent.getBlock方法代碼示例

本文整理匯總了Java中org.bukkit.event.block.SignChangeEvent.getBlock方法的典型用法代碼示例。如果您正苦於以下問題:Java SignChangeEvent.getBlock方法的具體用法?Java SignChangeEvent.getBlock怎麽用?Java SignChangeEvent.getBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.block.SignChangeEvent的用法示例。


在下文中一共展示了SignChangeEvent.getBlock方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onSignChange(final SignChangeEvent e) {
	final Block b = e.getBlock();
	if (b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN || b.getType() == Material.SIGN_POST) {
		plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
			if (b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN || b.getType() == Material.SIGN_POST) {
				Sign sign = (Sign) e.getBlock().getState();
				if (sign.getLine(0).equalsIgnoreCase("[atm]")) {
					if (!e.getPlayer().hasPermission("tim.atm.place")) {
						e.getPlayer().sendMessage(CC("&cYou dont have permissions to build ATM's!"));
						sign.setLine(0, "");
					} else {
						sign.setLine(0, CC("&cATM"));
						sign.update();
						e.getPlayer().sendMessage(CC("&2ATM created! (You can also write something in the Lines 2-4)"));
					}
				}
			}
		}, 10L);
	}
}
 
開發者ID:mastercake10,項目名稱:TimeIsMoney,代碼行數:22,代碼來源:ATM.java

示例2: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler
  public void onSignChange(SignChangeEvent event)
  {
    Player p = event.getPlayer();
    Sign sign = (Sign)event.getBlock();

    if (event.getLine(0).equalsIgnoreCase("[TeamTag]"))
    {
      if (!(p.hasPermission("TeamTag.admin.sign.place"))&&(!(p.hasPermission("TeamTag.admin.*")))&&(!(p.isOp()))) {
        return;
      }
    	  sign.setLine(0, "§3[TeamTag]");
    	  if (event.getLine(2).equalsIgnoreCase("Auto Assign")){
    		  sign.setLine(2, "§6Auto §2Assign");
    	  }
    	  if (event.getLine(2).equalsIgnoreCase("Join Red")){
    		  sign.setLine(2, "§LJoin §r§4Red");
    	  }
    	  if (event.getLine(2).equalsIgnoreCase("Join Blue")){
    		  sign.setLine(2, "§LJoin §r§1Blue");
    	  }
          sign.update();
  }
}
 
開發者ID:Dragonzslayer,項目名稱:TeamTag-plugin,代碼行數:25,代碼來源:signListener.java

示例3: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onSignChange(SignChangeEvent event) {
	if (event.getBlock() == null)
		return;
	if (event.getBlock().getState() == null)
		return;
	if(event.getLines()[0] == null)
		return;
	if (event.getLines()[0].equals("[SGJoin]")) {
		event.setLine(0, ChatColor.BLUE + "[SGJoin]");
		return;
	}

	if (event.getLines()[0].equals("[SGKit]")) {
		event.setLine(0, ChatColor.BLUE + "[SGKit]");
		return;
	}
	
	if (event.getLines()[0].equals("[SGSign]")) {
		if(event.getLines()[1] == null)
			return;
		SGApi.getSignManager().addSign(event.getBlock().getLocation(), Integer.parseInt(event.getLines()[1]));
		return;
	}
}
 
開發者ID:SurvivalGamesDevTeam,項目名稱:TheSurvivalGames,代碼行數:26,代碼來源:SignListener.java

示例4: signChanged

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
public void signChanged(SignChangeEvent event) {
	Player player = event.getPlayer();
	String[] lines = event.getLines();
	Block block = event.getBlock();

	if (event.getLine(0).toLowerCase().equals("[ems]")) {
		// Only process the sign if the player has an edit session open
		EMSEditState editState = getArenaEditState(player, true);
		if (editState == null) {
			player.sendMessage(ChatColor.RED + "[EMS] Fatal error while getting edit state");
			return;
		}

		String arenaName = event.getLine(1);
		EMSArena arena = getArena(arenaName);
		if (arena == editState.arena) {
			if (arena.signUpdated(block, lines)) {
				player.sendMessage(ChatColor.GREEN + "Created join sign");
				event.setCancelled(true);
			}
		} else {
			player.sendMessage(ChatColor.RED + "[EMS] Tried to create sign for " + arena.getName() + " but arena in edit was " + editState.arena.getName());
		}
	}
}
 
開發者ID:basicmark,項目名稱:EMS,代碼行數:26,代碼來源:EMSManager.java

示例5: onSignChangeEvent

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onSignChangeEvent(SignChangeEvent event) {
	if (!event.getLine(1).equalsIgnoreCase("[Quest]"))
		return;
	Player player = event.getPlayer();
	Block block = event.getBlock();
	if (!player.hasPermission("minequest.sign.placesign")) {
		player.sendMessage(ChatColor.RED + "You do not have permission to do this!");
		block.breakNaturally();
		return;
	}
	if (event.getLine(2).equalsIgnoreCase("")) {
		event.setCancelled(true);
		player.sendMessage(ChatColor.RED + "Must specify a quest!");
		block.breakNaturally();
		return;
	}
	if (Managers.getQuestManager().getDetails(event.getLine(2)) == null) {
		event.setCancelled(true);
		player.sendMessage(ChatColor.RED + "No such quest!");
		block.breakNaturally();
		return;
	}
	// oh, prettify it ;D
	event.setLine(1, ChatColor.GREEN + "[Quest]");
}
 
開發者ID:Minequest,項目名稱:Core-Bukkit,代碼行數:27,代碼來源:QuestSign.java

示例6: onSignCreate

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
/**
 * 
 * @param event
 */
@EventHandler(ignoreCancelled = true)
public void onSignCreate(SignChangeEvent event) {
	Player player = event.getPlayer();
	
	// Check if player has permission to create bedwars signs
	if(!player.hasPermission("bw.createsigns")) {
		return;
	}
	
	// Check if first line equals "[bw]"
	if(!event.getLine(0).trim().equals("[bw]")) {
		return;
	}
	
	// Check if second and third line aren't empty
	if(event.getLine(1).trim().equals("") || event.getLine(2).trim().equals("")) {
		return;
	}
	
	Block signBlock = event.getBlock();
	
	// Check if sign block is really a sign block
	if(signBlock == null || (signBlock.getType() != Material.SIGN
								&& signBlock.getType() != Material.SIGN_POST
								&& signBlock.getType() != Material.WALL_SIGN)) {
		return;
	}
	
	Main.getInstance().getSignManager().addSign(new JoinSign(signBlock.getLocation(), event.getLine(1), event.getLine(2)));
}
 
開發者ID:Yannici,項目名稱:bedwars-reloaded-bungee,代碼行數:35,代碼來源:SignListener.java

示例7: handleSignNearbyProtection

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
private void handleSignNearbyProtection(SignChangeEvent event, Protection protection) {
    Block block = event.getBlock();
    Player player = event.getPlayer();

    Profile playerProfile = plugin.getProfileFactory().fromPlayer(player);
    Optional<SignType> parsedSign = plugin.getSignParser().getSignType(event);

    // Only protection signs should be handled
    if (!parsedSign.isPresent()) {
        return;
    }

    // Only the owner may add signs nearby a protection
    if (!protection.isOwner(playerProfile)) {
        plugin.getTranslator().sendMessage(player, Translation.PROTECTION_CANNOT_CHANGE_SIGN);
        event.setCancelled(true);
        return;
    }


    if (parsedSign.get().isMainSign()) {
        if (this.isExistingSign(block)) {
            // Make sure the owner name on the sign stays the same
            Optional<Profile> owner = protection.getOwner();
            if (owner.isPresent()) {
                event.setLine(1, owner.get().getDisplayName());
            }
        } else {
            plugin.getTranslator().sendMessage(player, Translation.PROTECTION_ADD_MORE_USERS_SIGN_INSTEAD);
            block.breakNaturally();
            event.setCancelled(true);
            return;
        }
    }

    // Mark protection for UUID update
    // Note that we can't use the Protection instance for this, it will
    // still use the outdated signs the next tick
    updateBlockForUniqueIdsSoon(block);
}
 
開發者ID:rutgerkok,項目名稱:BlockLocker,代碼行數:41,代碼來源:SignChangeListener.java

示例8: onBlockSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.NORMAL )
public void onBlockSignChange(SignChangeEvent event) 
{
	Block block = event.getBlock();
	int iBlockID = block.getTypeId();
	if(iBlockID==137)   // Kommandoblock
	{
		System.out.println(" MCBP plugin:  Kommandoblock  onBlockSignChange()  ");
	}
}
 
開發者ID:memoryleakx,項目名稱:MultiCommandBlockPlugin,代碼行數:11,代碼來源:CommandBlockExt.java

示例9: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onSignChange(SignChangeEvent event) {
    Block block = event.getBlock();

    blockBridge.notifySignChange(block.getLocation(), block.getType(), block.getState(), event.getLines());
}
 
開發者ID:satoshinm,項目名稱:WebSandboxMC,代碼行數:7,代碼來源:BlockListener.java

示例10: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onSignChange(SignChangeEvent event) {
    String[] lines = event.getLines();
    if (!SignSubclaimListener.SUBCLAIM_ALIASES.contains(SignSubclaimListener.SQUARE_PATTERN_REPLACER.matcher(lines[0].toUpperCase()).replaceAll(""))) {
        return; // is not a subclaim written sign
    }

    Block block = event.getBlock();
    MaterialData materialData = block.getState().getData();
    if (materialData instanceof org.bukkit.material.Sign) {
        org.bukkit.material.Sign sign = (org.bukkit.material.Sign) materialData;
        Block attachedBlock = block.getRelative(sign.getAttachedFace());

        if (this.isSubclaimable(attachedBlock)) {
            Player player = event.getPlayer();
            PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
            if (playerFaction == null) {
                return; // only allow officers to create Subclaims
            }

            Faction factionAt = plugin.getFactionManager().getFactionAt(block.getLocation());
            if (playerFaction == factionAt) {
                if (this.isSubclaimed(attachedBlock)) {
                    player.sendMessage(ChatColor.RED + "There is already a subclaim sign on this " + attachedBlock.getType().toString() + '.');
                    return;
                }

                List<String> memberList = new ArrayList<>(3);
                for (int i = 1; i < lines.length; i++) {
                    String line = lines[i];
                    if (StringUtils.isNotBlank(line)) memberList.add(line);
                }

                if (memberList.isEmpty()) {
                    player.sendMessage(ChatColor.RED + "Subclaim signs need to have at least 1 player name inserted.");
                    return;
                }

                boolean leaderChest = lines[1].equals(Role.LEADER.getAstrix()) || lines[1].equalsIgnoreCase("LEADER");

                if (leaderChest) {
                    if (playerFaction.getMember(player).getRole() != Role.LEADER) {
                        player.sendMessage(ChatColor.RED + "Only faction leaders can create leader subclaimed objects.");
                        return;
                    }

                    // Clear the other lines.
                    event.setLine(2, null);
                    event.setLine(3, null);
                }

                event.setLine(0, SignSubclaimListener.SUBCLAIM_CONVERSION_PREFIX); // officialise this as a Subclaim chest.

                // the lines may contain a name of a user not in the faction.
                List<String> actualMembers = memberList.stream().filter(member -> playerFaction.getMember(member) != null).collect(Collectors.toList());
                playerFaction.broadcast(SettingsYML.TEAMMATE_COLOUR + player.getName() + ChatColor.YELLOW + " has created a subclaim on block type " +
                        ChatColor.AQUA + attachedBlock.getType().toString() + ChatColor.YELLOW + " at " + ChatColor.WHITE + '(' + attachedBlock.getX() + ", " + attachedBlock.getZ() + ')' +
                        ChatColor.YELLOW + " for " + (leaderChest ? "leaders" : actualMembers.isEmpty() ? "captains" : "members " + ChatColor.RED + '[' + StringUtils.join(actualMembers, ", ") + ']'));
            }
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:63,代碼來源:SignSubclaimListener.java

示例11: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onSignChange(final SignChangeEvent event) {
    if(event.getBlock().hasMetadata("armorStand")) {
        final Block b = event.getBlock();
        final ArmorStand as = getArmorStand(b);
        if (as != null) {
            String input = "";
            for (String line : event.getLines()) {
                if (line != null && line.length() > 0) {
                    input += ChatColor.translateAlternateColorCodes('&', line);
                }
            }
            if(b.hasMetadata("setName")) {
                if (input.length() > 0) {
                    as.setCustomName(input);
                    as.setCustomNameVisible(true);
                } else {
                    as.setCustomName("");
                    as.setCustomNameVisible(false);
                    as.setCustomNameVisible(false);
                }
            } else if(b.hasMetadata("setSkull")) {
                if(MC_USERNAME_PATTERN.matcher(input).matches()) {
                    b.setMetadata("protected", new FixedMetadataValue(plugin, true));
                    event.getPlayer().sendMessage(ChatColor.GOLD + Config.pleaseWait);
                    String cmd = "minecraft:give " + event.getPlayer().getName() + " minecraft:skull 1 3 {SkullOwner:\"" + input + "\"}";
                    String current = b.getWorld().getGameRuleValue("sendCommandFeedback");
                    b.getWorld().setGameRuleValue("sendCommandFeedback", "false");
                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
                    b.getWorld().setGameRuleValue("sendCommandFeedback", current);
                    boolean found = false;
                    for(int slot : event.getPlayer().getInventory().all(Material.SKULL_ITEM).keySet()) {
                        ItemStack skull = event.getPlayer().getInventory().getItem(slot);
                        SkullMeta sm = (SkullMeta) skull.getItemMeta();
                        if(sm.hasOwner() && input.equalsIgnoreCase(sm.getOwner())) {
                            as.setHelmet(skull);
                            event.getPlayer().sendMessage(ChatColor.GREEN + Config.appliedHead + ChatColor.GOLD + " " + input);
                            event.getPlayer().getInventory().setItem(slot, null);
                            found = true;
                            break;
                        }
                    }
                    if(!found) {
                        event.getPlayer().sendMessage(ChatColor.GOLD + Config.headFailed);
                    }
                } else {
                    event.getPlayer().sendMessage(ChatColor.RED + input + " " + Config.invalidName);
                }
            }
        }
        event.setCancelled(true);
        b.removeMetadata("armorStand", plugin);
        b.removeMetadata("setName", plugin);
        b.removeMetadata("setSkull", plugin);
        b.setType(Material.AIR);
        //noinspection deprecation
        b.setData((byte) 0);
    }
}
 
開發者ID:St3venAU,項目名稱:ArmorStandTools,代碼行數:60,代碼來源:MainListener.java

示例12: handleSignNotNearbyProtection

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
private void handleSignNotNearbyProtection(SignChangeEvent event) {
    Optional<SignType> parsedSign = plugin.getSignParser().getSignType(event);
    if (!parsedSign.isPresent()) {
        // Not trying to claim a container
        return;
    }

    SignType signType = parsedSign.get();
    Player player = event.getPlayer();
    Block block = event.getBlock();

    if (!player.hasPermission(Permissions.CAN_PROTECT)) {
        plugin.getTranslator().sendMessage(player, Translation.PROTECTION_NO_PERMISSION_FOR_CLAIM);
        block.breakNaturally();
        event.setCancelled(true);
        return;
    }

    // Only the main sign can be used to create new protections
    if (!signType.isMainSign()) {
        plugin.getTranslator().sendMessage(player, Translation.PROTECTION_NOT_NEARBY);
        block.breakNaturally();
        event.setCancelled(true);
        return;
    }

    // Sign must be attached to container
    if (!plugin.getProtectionFinder().isSignNearbyProtection(block)) {
        plugin.getTranslator().sendMessage(player, Translation.PROTECTION_NOT_NEARBY);
        block.breakNaturally();
        event.setCancelled(true);
        return;
    }

    // Make sure the owner name is on the second line
    event.setLine(1, event.getPlayer().getName());

    // We need to fetch UUIDs soon
    updateBlockForUniqueIdsSoon(block);

    // Send confirmation
    plugin.getTranslator().sendMessage(player, Translation.PROTECTION_CLAIMED_MANUALLY);
}
 
開發者ID:rutgerkok,項目名稱:BlockLocker,代碼行數:44,代碼來源:SignChangeListener.java

示例13: onSign

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onSign(SignChangeEvent event) {

    if (event.getBlock().getState() instanceof Sign) {

        if (bc.runSignChecks(event.getPlayer(), (Sign) event.getBlock().getState()) != 0) {

            event.setCancelled(true);

            BlockBreakEvent cevent = new BlockBreakEvent(event.getBlock(), event.getPlayer());

            nh.getServer().getPluginManager().callEvent(cevent);

            if (!cevent.isCancelled()) {

                event.getBlock().breakNaturally();

            }

            cevent = null;

        }

    }

}
 
開發者ID:johnnywoof,項目名稱:NoHack,代碼行數:27,代碼來源:NoHackListener.java

示例14: onSignCreate

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onSignCreate(SignChangeEvent event) {
	Player player = event.getPlayer();
	Sign sign = (Sign) event.getBlock();
	//TODO actions
}
 
開發者ID:Goldhill,項目名稱:Economy,代碼行數:7,代碼來源:GlobalPlayerListener.java

示例15: onSignEdit

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler (priority = EventPriority.NORMAL)
public void onSignEdit(SignChangeEvent e) {
    Player player = e.getPlayer();
    Block block = e.getBlock();
    String line1 = e.getLine(0);
    String line2 = e.getLine(1);
    DuelManager dm = plugin.getDuelManager();
    FileManager fm = plugin.getFileManager();

    if(line1 == null) {
        return;
    }

    if(line1.equalsIgnoreCase("[duelme]")) {
        if(!player.hasPermission("duelme.admin.signs.create")) {
            Util.sendMsg(player, ChatColor.RED + "You do not have the permission duelme.admin.signs.create!");
            return;
        }
        if(line2 == null || line2.equals("")) {
            Util.sendMsg(player, ChatColor.RED + "You must provide an arena name to create a duel status sign!.");
            block.breakNaturally();
            return;
        }

        DuelArena arena = dm.getDuelArenaByName(line2);

        if(arena == null) {
            Util.sendMsg(player, ChatColor.RED + "Duel arena " + line2 + " does not exist!");
            block.breakNaturally();
            return;
        }

        e.setLine(0, ChatColor.GREEN + "[DuelMe]");
        e.setLine(1, arena.getName());
        e.setLine(2, ChatColor.AQUA + arena.getDuelState().toString());
        e.setLine(3, arena.getPlayers().size() + "/2");

        fm.saveArenaSign(arena.getName(), block.getWorld().getName(), block.getX(), block.getY(), block.getZ());

        Util.sendMsg(player, ChatColor.GREEN + "Successfully created a duel arena status sign!");

    }

}
 
開發者ID:teozfrank,項目名稱:DuelMe,代碼行數:45,代碼來源:SignEdit.java


注:本文中的org.bukkit.event.block.SignChangeEvent.getBlock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。