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