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


Java SignChangeEvent.getLine方法代碼示例

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


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

示例1: createVault

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
/**
 * Create an account chest by adding a sign marker over it.
 * 
 * @param event Event data.
 */
@EventHandler
public void createVault(SignChangeEvent event) {
    String line0 = event.getLine(0);

    Matcher match = vaultPattern.matcher(line0);

    // consider only signs with proper formatting
    if (match.matches()) {
        String type = match.group(1).toLowerCase();

        // default vault is player
        if (type.isEmpty()) type = "player";

        // is sign attached to a valid vault container?
        BlockState signBlock = event.getBlock().getState();
        if (signBlock instanceof Sign &&
                Util.chestBlock((Sign)signBlock) != null) {

            // we made it this far, throw the event to manage vault creation
            VaultCreationEvent creation = new PlayerVaultCreationEvent(type, event);
            Bukkit.getServer().getPluginManager().callEvent(creation);
        }
    }
}
 
開發者ID:sakunc,項目名稱:Gringotts-,代碼行數:30,代碼來源:AccountListener.java

示例2: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onSignChange(SignChangeEvent e) {
	Player p = e.getPlayer();
	if (p.hasPermission("blockparty.admin")) {
		if (e.getLine(0).equalsIgnoreCase("[BlockParty]")) {
			if (e.getLine(1).equalsIgnoreCase("join")) {
				if (e.getLine(2) != null) {
					if (BlockParty.getArena.containsKey(e.getLine(2))) {
						String arenaName = e.getLine(2);
						e.setLine(0, "�6[BlockParty]");
						e.setLine(1, "�7Arena:");
						e.setLine(2, ChatColor.AQUA + arenaName);
						e.setLine(3, "�2Join");
						BlockParty.signs.put(arenaName, (Sign) e.getBlock().getState());
					} else {
						p.sendMessage(BlockParty.messageManager.ARENA_DOES_NOT_EXIST.replace("$ARENANAME$", e.getLine(1)));
					}
				}
			}
			if (e.getLine(1).equalsIgnoreCase("leave")) {
				e.setLine(0, "�6[BlockParty]");
				e.setLine(1, "�4Leave");
			}
		}
	}
}
 
開發者ID:Hansdekip,項目名稱:BlockParty-1.8,代碼行數:27,代碼來源:SignListener.java

示例3: checkUpdateJoin

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
public void checkUpdateJoin(SignChangeEvent e) {

        if (e.getLine(0).equalsIgnoreCase(plugin.getConfig().getString("signs.first-line-text"))) {
            e.setLine(0, joinSignFirstLine);
            String arenaName = e.getLine(1);
            final ArenaManager.Arena arena = plugin.am.getArena(arenaName);
            if (arena != null) {
                plugin.am.addJoinSign(arenaName, e.getBlock().getLocation());
                Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
                        @Override
                        public void run() {
                            arena.updateSigns();
                        }
                    }, 2);
            } else {
                e.setLine(2, ChatColor.translateAlternateColorCodes('&',
                        plugin.getConfig().getString("signs.on-invalid-arena-replacement")));
            }
        }
    }
 
開發者ID:ddonofrio,項目名稱:libelula,代碼行數:21,代碼來源:SignManager.java

示例4: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onSignChange(SignChangeEvent event) {
   if (!(event.getPlayer().isOp() && event.getPlayer().getGameMode() == GameMode.CREATIVE)) {
      return;
   }
   if (event.getLine(0).equalsIgnoreCase("Server")) {
      String server = event.getLine(1);

      event.setLine(0, ChatColor.GOLD + "" + ChatColor.BOLD + "[ Server ]");
      event.setLine(1, event.getLine(2));
      event.setLine(2, "");
      event.setLine(3, ChatColor.BOLD + "Click to join");

      plugin.getConfig().set("Servers." + Utils.getStringBlock(event.getBlock().getLocation()), server);
      plugin.saveConfig();
   }
}
 
開發者ID:PaulBGD,項目名稱:MiniMiniGames,代碼行數:18,代碼來源:PlayerListener.java

示例5: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onSignChange(SignChangeEvent event) {
    Location l = event.getBlock().getLocation();
    if (event.getPlayer().hasPermission("theplague.arena.signPlace"))
        if (event.getLine(0).equalsIgnoreCase("[ThePlague]") || event.getLine(0).equalsIgnoreCase("[Plague]")) {
            if (event.getLine(1).equalsIgnoreCase("arena")) {
                String arenaName = event.getLine(2);
                if (Arenas.findByName(arenaName) == null) {
                    ChatHelper.sendToPlayer(event.getPlayer(), ChatColor.GOLD + "There is no arena by the name of " + arenaName + "!");
                    return;
                }
                ArenaSign arenaSign = new ArenaSign(l, Arenas.findByName(arenaName));
                Signs.addSign(arenaSign);
            }
        }
}
 
開發者ID:mrkirby153,項目名稱:The-Plague,代碼行數:17,代碼來源:CreationListener.java

示例6: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onSignChange(SignChangeEvent e) {
	Player p = e.getPlayer();
	if (p.hasPermission("blockparty.admin")) {
		if (e.getLine(0).equalsIgnoreCase("[BlockParty]")) {
			if (e.getLine(1).equalsIgnoreCase("join")) {
				if (e.getLine(2) != null) {
					if (BlockParty.getArena.containsKey(e.getLine(2))) {
						String arenaName = e.getLine(2);
						e.setLine(0, "§6[BlockParty]");
						e.setLine(1, "§7Arena:");
						e.setLine(2, ChatColor.AQUA + arenaName);
						e.setLine(3, "§2Join");
						BlockParty.signs.put(arenaName, (Sign) e.getBlock().getState());
					} else {
						p.sendMessage(BlockParty.messageManager.ARENT_DOES_NOT_EXIST.replace("$ARENANAME$", e.getLine(1)));
					}
				}
			}
			if (e.getLine(1).equalsIgnoreCase("leave")) {
				e.setLine(0, "§6[BlockParty]");
				e.setLine(1, "§4Leave");
			}
		}
	}
}
 
開發者ID:LekoHD,項目名稱:BlockParty,代碼行數:27,代碼來源:SignListener.java

示例7: 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

示例8: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
/**
 * Event fired when a player rename his team
 *
 * @param event Event
 */
@EventHandler
public void onSignChange(SignChangeEvent event)
{
    if (this.game.getStatus().equals(Status.IN_GAME))
    {
        event.getHandlers().unregister(this);
        return;
    }

    if (!this.game.getStatus().equals(Status.IN_GAME))
    {
        SurvivalTeam team = this.game.getPlayerTeam(event.getPlayer().getUniqueId());
        String name = event.getLine(0);
        name = name.trim();

        if (!name.isEmpty())
        {
            team.setTeamName(name);
            event.getPlayer().sendMessage(this.game.getCoherenceMachine().getGameTag() + " " + ChatColor.GREEN + "Le nom de votre équipe est désormais : " + team.getChatColor() + team.getTeamName());
            this.openGui(event.getPlayer(), new GuiSelectTeam());
        }
        else
        {
            event.getPlayer().sendMessage(this.game.getCoherenceMachine().getGameTag() + " " + ChatColor.RED + "Le nom de l'équipe ne peut être vide.");
            this.openGui(event.getPlayer(), new GuiSelectTeam());
        }
        this.game.getPlugin().getServer().getScheduler().runTaskLater(this.game.getPlugin(), () ->
        {
            event.getBlock().setType(Material.AIR);
            event.getBlock().getRelative(BlockFace.DOWN).setType(Material.AIR);
        }, 1L);
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:39,代碼來源:SurvivalTeamSelector.java

示例9: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
void onSignChange(SignChangeEvent event) {
	if (!event.getPlayer().hasPermission("emojichat.use") || !event.getPlayer().hasPermission("emojichat.use.sign"))
		return; // Don't do anything if they don't have permission
	
	if (!plugin.getConfig().getBoolean("emojis-on-signs")) // Feature is disabled
		return;
	
	for (int i = 0; i < 4; i++) {
		String line = event.getLine(i);
		
		// Checks if the user disabled shortcuts via /emojichat toggle
		if (!plugin.getEmojiHandler().hasShortcutsOff(event.getPlayer())) {
			line = plugin.getEmojiHandler().translateShorthand(line);
		}
		
		// Replace shortcuts with emojis
		line = plugin.getEmojiHandler().toEmojiFromSign(line);
		
		// If the message contains a disabled character
		if (plugin.getEmojiHandler().containsDisabledCharacter(line)) {
			event.setCancelled(true);
			event.getPlayer().sendMessage(ChatColor.RED + "Oops! You can't use disabled emoji characters!");
			return;
		}
		
		event.setLine(i, line);
	}
}
 
開發者ID:RadBuilder,項目名稱:EmojiChat,代碼行數:30,代碼來源:EmojiChatListener.java

示例10: onSignEdit

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onSignEdit(SignChangeEvent event) {
    Zone signZone = this.getZoneManager().getZone(ZoneType.SIGN);

    if(!(signZone.isEnabled()) || event.getPlayer() == null)
        return;

    Player player = event.getPlayer();
    Instant signCreateInstant;

    for (int i = 0; i < event.getLines().length; i++) {
        signCreateInstant = Instant.now();

        FixedMessage message = new FixedMessage(event.getLine(i), signCreateInstant);
        message.setFixed(message.getOriginal());

        if (event.getLine(i).equals("") || event.getLine(i) == null) {
            continue;
        }

        for (Filter filter : this.getFilterManager().getFiltersForZone(signZone)) {
            filter.filter(message, player, ZoneType.SIGN, event);
        }

        event.setLine(i, message.getOriginal());

        for (Violation v : plugin.getPlayerManager().getViolationSet(player).getViolationsForTime(signCreateInstant)) {
            if (v.isCancelled()) {
                event.setLine(i, "");
                event.setCancelled(true);
                break;
            }

            if (v.isFixed()) {
                event.setLine(i, message.getFixed());
            }
        }

    }
}
 
開發者ID:OvercastNetwork,項目名稱:ChatModerator,代碼行數:41,代碼來源:ChatModeratorListener.java

示例11: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
/**
 * Detects when a player creates a RC sign.
 * @param e The sign change event.
 */
@EventHandler
public void onSignChange(final SignChangeEvent e) {
    if (e.getLine(0) == null) {
        return;
    }
    if (!(e.getLine(0).equalsIgnoreCase("[RandomCoords]"))) {
        return;
    }
    if (RandomCoords.getPlugin().hasPermission(e.getPlayer(), "Random.Admin.Sign") || RandomCoords.getPlugin().hasPermission(e.getPlayer(), "Random.Admin.*") || RandomCoords.getPlugin().hasPermission(e.getPlayer(), "Random.*")) {
        if (e.getLine(1).length() == 0 || e.getLine(1) == null) {
            e.setLine(0, ChatColor.GREEN + "[RandomCoords]");
            messages.signCreated(e.getPlayer());
        } else if (e.getLine(2).length() == 0 || e.getLine(2) == null) {
            final String wName = e.getLine(1).replaceAll("\uF701", "");
            if (wName.length() == 0 || wName.equals("")) {
                return;
            }
            if (e.getPlayer().getServer().getWorld(wName) == null) {
                messages.invalidWorld(e.getPlayer(), wName);
            } else {
                e.setLine(0, ChatColor.GREEN + "[RandomCoords]");
                messages.signCreated(e.getPlayer());
            }
        } else {
            e.setLine(0, ChatColor.GREEN + "[RandomCoords]");
            messages.signCreated(e.getPlayer());
        }
    } else {
        messages.noPermission(e.getPlayer());

    }


}
 
開發者ID:jolbol1,項目名稱:RandomCoordinatesV2,代碼行數:39,代碼來源:Signs.java

示例12: onSignChange

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onSignChange(SignChangeEvent e) {
    String noPermMsg = wild.getConfig().getString("No-Perm");
    Checks check = new Checks(wild);
    if (e.getLine(1).equalsIgnoreCase("[wild]") &&
            e.getLine(0).equalsIgnoreCase("wildtp")) {
        if (e.getPlayer().hasPermission("wild.wildtp.create.sign")) {
            if (check.world(e.getPlayer())) {
                if(e.getLine(2)!=null)
                    e.setLine(3, e.getLine(2));
                e.setLine(0, "§4====================");
                e.setLine(1, "[§1Wild§0]");
                e.setLine(2, "§4====================");
                e.getPlayer().sendMessage(ChatColor.GREEN + "Successfully made a new WildTP sign");
            } else {
                e.getPlayer().sendMessage(ChatColor.RED + "Signs cannot be placed in this world as the command isnt allowed in this world");
                e.getBlock().breakNaturally();
                e.setCancelled(true);
            }
        } else {
            e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes((char) '&', noPermMsg));
            e.setCancelled(true);
        }
    }


}
 
開發者ID:Qballl,項目名稱:WildernessTp,代碼行數:28,代碼來源:SignChange.java

示例13: onPlayerCreateSign

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onPlayerCreateSign(SignChangeEvent ev) {
    if (!ev.getPlayer().hasPermission("nb.sign_create")) return;
    String firstLine = ev.getLine(0);
    if (!SignHelper.stringEqIgnoreColor(firstLine, SIGN_MAGIC_FALLBACK, true) &&
            !SignHelper.stringEqIgnoreColor(firstLine, plugin.cfg.signMagic, true))
        return; // not a bank sign
    SignRegistration sr = SignHelper.getSign(plugin, ev.getBlock().getLocation());
    boolean newSign = false;
    if (sr == null) newSign = true;
    sr = SignHelper.parseSign(plugin, ev.getLines(), sr, ev.getBlock().getLocation());
    if (sr == null) {
        ev.getPlayer().sendMessage(I18n.format("user.sign.create_fail"));
        return;
    }
    if (!ev.getPlayer().hasPermission("nb.sign_create_admin")) { // skip bank owner check for admins
        BankRegistration bank = plugin.dbm.getUniqueBank(sr.getBankId());
        if (bank == null || !ev.getPlayer().getUniqueId().equals(bank.ownerId)) {
            ev.getPlayer().sendMessage(I18n.format("user.sign.create_fail"));
            return;
        }
    }
    if (newSign) {
        plugin.dbm.query(SignRegistration.class).insert(sr);
    } else {
        plugin.dbm.query(SignRegistration.class).whereEq(SignRegistration.N_SIGN_ID, sr.getSignId()).update(sr);
    }
    ev.getPlayer().sendMessage(I18n.format("user.sign.create_success"));

    // update sign next tick
    final SignRegistration fsr = sr;
    new BukkitRunnable() {
        @Override
        public void run() {
            SignHelper.updateSignBlock(plugin, ev.getBlock().getLocation(), fsr);
        }
    }.runTaskLater(plugin, 1);
}
 
開發者ID:NyaaCat,項目名稱:NyaaBank,代碼行數:39,代碼來源:SignListener.java

示例14: vaultCreated

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void vaultCreated(PlayerVaultCreationEvent event) {
    // some listener already claimed this event
    if (event.isValid()) return;

    // only interested in player vaults
    if (! event.getType().equals("player")) return;

    SignChangeEvent cause = event.getCause();
    String ownername = cause.getLine(2);

    Player player = cause.getPlayer();

    if (! createvault_player.allowed(player)) {
        player.sendMessage(LANG.vault_noVaultPerm);
        return;
    }

    AccountHolder owner;
    if (ownername != null && ownername.length() > 0 && createvault_admin.allowed(player)) {
        // attempting to create account for other player
        owner = Gringotts.G.accountHolderFactory.get("player", ownername);
        if (owner==null) return;
    } else {
        // regular vault creation for self
        owner = new PlayerAccountHolder(player);
    }

    event.setOwner(owner);
    event.setValid(true);
}
 
開發者ID:sakunc,項目名稱:Gringotts-,代碼行數:32,代碼來源:PlayerVaultListener.java

示例15: onSign

import org.bukkit.event.block.SignChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onSign(SignChangeEvent event){
    Player player = event.getPlayer();

    if(!(event.getLine(0).contains("[CR]")
            && player.hasPermission("castlerush.createsign"))){
        return;
    }

    String l1 = event.getLine(1);
    if(l1 == null || l1.isEmpty()){
        return;
    }


    if(l1.equalsIgnoreCase("create")){
        event.setLine(0, SIGN_HEADER);
        event.setLine(1, SIGN_CREATE);
        event.setLine(2, ChatUtil.colored(SIGN_SPACER));
        event.setLine(3, ChatUtil.colored(SIGN_ENDLINE));
    }
    else if(l1.equalsIgnoreCase("join")){
        event.setLine(0, SIGN_HEADER);
        event.setLine(1, SIGN_JOIN);
        event.setLine(2, ChatUtil.colored(SIGN_SPACER));
        event.setLine(3, ChatUtil.colored(SIGN_ENDLINE));
    }
    else{
        event.getBlock().breakNaturally();
        ChatManager.info().write("&cWrong sign command.", player);
        return;
    }

    ChatManager.info().write("&7Sign created.", player);
}
 
開發者ID:Superioz,項目名稱:CastleRush,代碼行數:36,代碼來源:SignListener.java


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