Java Code Examples for org.bukkit.block.Sign#getLocation()

The following examples show how to use org.bukkit.block.Sign#getLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EconomyUtil.java    From GriefDefender with MIT License 6 votes vote down vote up
private Consumer<CommandSender> createSellCancelConfirmed(CommandSender src, Claim claim, Sign sign) {
    return confirm -> {
        if (!claim.getEconomyData().isForSale()) {
            return;
        }

        Location location = null;
        if (sign != null) {
            location = sign.getLocation();
        } else {
            final Sign saleSign = SignUtil.getSign(((GDClaim) claim).getWorld(), claim.getEconomyData().getSaleSignPosition());
            if (saleSign != null) {
                location = saleSign.getLocation();
            }
        }
        if (location != null && !location.getBlock().isEmpty()) {
            location.getBlock().setType(Material.AIR);
            SignUtil.resetSellData(claim);
            claim.getData().save();
            GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().ECONOMY_CLAIM_SALE_CANCELLED);
        }
    };
}
 
Example 2
Source File: LobbyListener.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void signRemoved(BlockBreakEvent event) {
	if (Util.get().isSpawnWorld(event.getBlock().getWorld())) {
		 Location blockLocation = event.getBlock().getLocation();
	        World w = blockLocation.getWorld();
	    	Block b = w.getBlockAt(blockLocation);
			if(b.getType() == Material.WALL_SIGN || b.getType() == SkyWarsReloaded.getNMS().getMaterial("SIGN_POST").getType()){
		    	Sign sign = (Sign) b.getState();
		    	Location loc = sign.getLocation();
		    	boolean removed = false;
		    	for (GameMap gMap : GameMap.getMaps()) {
		    		if (!removed) {
			    		removed = gMap.removeSign(loc);
		    		}
		    	}
		    	if (!removed) {
		    		removed = SkyWarsReloaded.getLB().removeLeaderSign(loc);
		    	}
		    	if (removed) {
			    	event.getPlayer().sendMessage(new Messaging.MessageFormatter().format("signs.remove"));
		    	}
			}
	}
}
 
Example 3
Source File: SignListener.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onPlayerInteract(PlayerInteractEvent e) {
	Player player = e.getPlayer();
   	if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
   		 if (e.getClickedBlock().getType() == Material.WALL_SIGN || e.getClickedBlock().getType() == SkyWarsReloaded.getNMS().getMaterial("SIGN_POST").getType()) {
   				Sign s = (Sign) e.getClickedBlock().getState();
   			    Location loc = s.getLocation();
   			    SWRServer server = SWRServer.getSign(loc);
   			    if (server != null) {
   			    	if (server.getMatchState().equals(MatchState.WAITINGSTART) && server.getPlayerCount() < server.getMaxPlayers()) {
   			    		server.setPlayerCount(server.getPlayerCount() + 1);
       			    	server.updateSigns();
   			    		SkyWarsReloaded.get().sendBungeeMsg(player, "Connect", server.getServerName());
   					}
   			    }
   		 }
   	}
}
 
Example 4
Source File: SignLogic.java    From uSkyBlock with GNU General Public License v3.0 6 votes vote down vote up
void addSign(Sign block, String[] lines, Chest chest) {
    Location loc = block.getLocation();
    ConfigurationSection signs = config.getConfigurationSection("signs");
    if (signs == null) {
        signs = config.createSection("signs");
    }
    String signLocation = LocationUtil.asKey(loc);
    ConfigurationSection signSection = signs.createSection(signLocation);
    signSection.set("location", LocationUtil.asString(loc));
    signSection.set("challenge", lines[1]);
    String chestLocation = LocationUtil.asString(chest.getLocation());
    signSection.set("chest", chestLocation);
    ConfigurationSection chests = config.getConfigurationSection("chests");
    if (chests == null) {
        chests = config.createSection("chests");
    }
    String chestPath = LocationUtil.asKey(chest.getLocation());
    List<String> signList = chests.getStringList(chestPath);
    if (!signList.contains(signLocation)) {
        signList.add(signLocation);
    }
    chests.set(chestPath, signList);
    saveAsync();
    updateSignsOnContainer(chest.getLocation());
}
 
Example 5
Source File: SignUpdater.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public SignHandle(Sign sign, Navigator.Connector connector) {
    this.location = sign.getLocation();
    this.material = sign.getMaterialData();
    this.connector = connector;

    hoverEntities = CacheUtils.newCache(
        description -> new NMSHacks.FakeArmorStand(this.location.getWorld(), description.toLegacyText())
    );

    connector.startObserving(observer);

    paint();

    logger.fine("Created " + this);
}
 
Example 6
Source File: SignListener.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
  public void signRemoved(BlockBreakEvent event) {
      Location blockLocation = event.getBlock().getLocation();
      World w = blockLocation.getWorld();
  	Block b = w.getBlockAt(blockLocation);
if(b.getType() == Material.WALL_SIGN || b.getType() == SkyWarsReloaded.getNMS().getMaterial("SIGN_POST").getType()){
   	Sign sign = (Sign) b.getState();
   	Location loc = sign.getLocation();
   	SWRServer server = SWRServer.getSign(loc);
   	if (server != null) {
   		server.removeSign(loc);
   		event.getPlayer().sendMessage(new Messaging.MessageFormatter().format("signs.remove"));
   	}
}
  }
 
Example 7
Source File: EconomyUtil.java    From GriefDefender with MIT License 4 votes vote down vote up
private Consumer<CommandSender> createRentCancelConfirmed(CommandSender src, Claim claim, Sign sign, boolean addDelinquent) {
    return confirm -> {
        if (!claim.getEconomyData().isForRent() && !claim.getEconomyData().isRented()) {
            return;
        }

        final Player player = (Player) src;
        boolean isRenter = false;
        for (UUID uuid : claim.getEconomyData().getRenters()) {
            if (player.getUniqueId().equals(uuid)) {
                isRenter = true;
                break;
            }
        }

        if (player.getUniqueId().equals(claim.getOwnerUniqueId()) || (claim.isAdminClaim() && !isRenter)) {
                Location location = null;
            if (sign != null) {
                location = sign.getLocation();
            } else {
                final Sign rentSign = SignUtil.getSign(((GDClaim) claim).getWorld(), claim.getEconomyData().getRentSignPosition());
                if (rentSign != null) {
                    location = rentSign.getLocation();
                }
            }
            if (location != null) {
                location.getBlock().setType(Material.AIR);
            }
            SignUtil.resetRentData(claim);
            claim.getData().save();
            GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().ECONOMY_CLAIM_RENT_CANCELLED);
        } else if (claim.getEconomyData().isRented()) {
            // reset sign
            claim.getEconomyData().setForRent(true);
            SignUtil.updateSignRentable(claim, sign);
            claim.getEconomyData().setRentSignPosition(null);
            claim.getEconomyData().getRenters().clear();
            claim.getEconomyData().setRentStartDate(null);
            if (addDelinquent) {
                claim.getEconomyData().getDelinquentRenters().add(player.getUniqueId());
            }
            claim.removeUserTrust(player.getUniqueId(), TrustTypes.NONE);
            claim.getData().save();
            final GDPermissionUser owner = PermissionHolderCache.getInstance().getOrCreateUser(claim.getOwnerUniqueId());
            boolean rentRestore = false;
            if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
                if (claim.isAdminClaim()) {
                    rentRestore = GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSchematicRestoreAdmin;
                } else {
                    rentRestore = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Boolean.class), owner == null ? GriefDefenderPlugin.DEFAULT_HOLDER : owner, Options.RENT_RESTORE, claim).booleanValue();
                }
            }
            if (rentRestore) {
                // expiration days keep is up
                // restore schematic and remove renter rights
                final ClaimSchematic schematic = claim.getSchematics().get("__rent__");
                if (schematic != null) {
                    if (schematic.apply()) {
                        if (owner != null && owner.getOnlinePlayer() != null) {
                            owner.getOnlinePlayer().sendMessage("Claim '" + ((GDClaim) claim).getFriendlyName() + "' has been restored.");
                        }
                    }
                }
            }
            GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().ECONOMY_CLAIM_RENT_CANCELLED);
        }
    };
}