下面列出了org.bukkit.block.Sign#getLocation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
};
}
@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"));
}
}
}
}
@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());
}
}
}
}
}
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());
}
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);
}
@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"));
}
}
}
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);
}
};
}