Reworks '/as info region' command for buy regions and fixes a bug

'/as info region' for buy regions now also supports more info, like the
same way as it does for rent regions. Fixed a bug with signs, now they
will correctly keep their orientation when placed again after removal
(by for example schematics).
This commit is contained in:
Thijs Wiefferink 2014-12-03 23:43:24 +01:00
parent 5568ee240b
commit e719930364
6 changed files with 95 additions and 74 deletions

View File

@ -142,48 +142,38 @@ info-playerRents: "Regions rented by %0%: &7%1%"
info-playerNoRents: "%0% has not rented a region" info-playerNoRents: "%0% has not rented a region"
info-playerBuys: "Regions bought by %0%: &7%1%" info-playerBuys: "Regions bought by %0%: &7%1%"
info-playerNoBuys: "%0% has not bought a region" info-playerNoBuys: "%0% has not bought a region"
info-regionHelp: "/as info region [name], the region you stand in will be used if not specified" info-regionHelp: "/as info region [name], the region you stand in will be used if not specified"
info-regionHeaderRent: "&2Information about %region%:"
info-regionHeader: "&2Information about %region%:" info-regionHeaderBuy: "&2Information about %region%:"
info-regionFooterRent: ""
info-regionFooterBuy: ""
info-regionRented: "&2&l►&r Rented by %player% until: &7%until%" info-regionRented: "&2&l►&r Rented by %player% until: &7%until%"
info-regionBought: "&2&l►&r Bought by %player%"
info-regionExtending: "&2&l►&r Price to extend: &7%price% per %duration%" info-regionExtending: "&2&l►&r Price to extend: &7%price% per %duration%"
info-regionCanBeRented: "&2&l►&r Price to rent: &7%price% per %duration%" info-regionCanBeRented: "&2&l►&r Price to rent: &7%price% per %duration%"
info-regionCanBeBought: "&2&l►&r Price to buy: &7%price%"
info-regionFriends: "&2&l►&r Added friends: &7%friends%" info-regionFriends: "&2&l►&r Added friends: &7%friends%"
info-regionMoneyBackBuy: "&2&l►&r Selling payback: &7%moneyback% (%moneybackpercent%% of the price)" info-regionMoneyBackBuy: "&2&l►&r Selling payback: &7%moneyback% (%moneybackpercent%% of the price)"
info-regionMoneyBackRent: "&2&l►&r Unrenting payback &7%moneyback% (%moneybackpercent%% of the remaining time)" info-regionMoneyBackRent: "&2&l►&r Unrenting payback &7%moneyback% (%moneybackpercent%% of the remaining time)"
info-regionMaxExtends: "&2&l►&r Maximum times extending: &7%maxextends% time(s)" info-regionMaxExtends: "&2&l►&r Maximum number of extends: &7%maxextends% time(s)"
info-regionNoExtending: "&2&l►&r Rent cannot be extended" info-regionNoExtending: "&2&l►&r Rent cannot be extended"
info-regionExtendsLeft: "&2&l►&r Extending left: &7%extendsleft% time(s) out of %maxextends%" info-regionExtendsLeft: "&2&l►&r Extending left: &7%extendsleft% time(s) out of %maxextends%"
info-regionMaxRentTime: "&2&l►&r In advance renting: &7%maxrenttime% at maximum" info-regionMaxRentTime: "&2&l►&r In advance renting: &7%maxrenttime% at maximum"
info-regionNoTeleport: "&2&l►&r Teleport location not set%0%" info-regionNoTeleport: "&2&l►&r Teleport location not set%0%"
info-regionTeleportHint: " &7(use '/as settp' for a better spot)" info-regionTeleportHint: " &7(use '/as settp' for a better spot)"
info-regionTeleportAt: "&2&l►&r Teleport set at: &7(%0%, %1%, %2%, %3%), pitch: %4%, yaw: %5%" info-regionTeleportAt: "&2&l►&r Teleport set at: &7(%0%, %1%, %2%, %3%, pitch:%4%, yaw:%5%)"
info-regionSigns: "&2&l►&r Connected signs: &7%0%" info-regionSigns: "&2&l►&r Connected signs: &7%0%"
info-regionSignLocation: "&7(%0%, %1%, %2%, %3%)&r" info-regionSignLocation: "&7(%0%, %1%, %2%, %3%)&r"
info-regionGroups: "&2&l►&r Assigned groups: &7%0%" info-regionGroups: "&2&l►&r Assigned groups: &7%0%"
info-regionInactiveUnrent: "&2&l►&r Auto unrent after: &7%inactivetime% of inactivity by the player" info-regionInactiveUnrent: "&2&l►&r Auto unrent after: &7%inactivetime% of inactivity by the player"
info-regionRestrictedRegionRent: "&2&l►&r To rent it you need to be inside the region" info-regionInactiveSell: "&2&l►&r Auto sell after: &7%inactivetime% of inactivity by the player"
info-regionRestrictedWorldRent: "&2&l►&r To rent it you need to be inside world '%world%'" info-regionRestrictedRegionRent: "&2&l►&r To rent this region you need to be inside it"
info-regionRestrictedWorldRent: "&2&l►&r To rent this region you need to be inside world '%world%'"
info-regionRestrictedRegionBuy: "&2&l►&r To buy this region you need to be inside it"
info-regionRestrictedWorldBuy: "&2&l►&r To buy this region you need to be inside world '%world%'"
info-regionRestoringRent: "&2&l►&r Restoring is enabled &7(region will reset at unrent)%0%" info-regionRestoringRent: "&2&l►&r Restoring is enabled &7(region will reset at unrent)%0%"
info-regionRestoringBuy: "&2&l►&r Restoring is enabled &7(region will reset at sell)%0%"
info-regionRestoringProfile: " (profile: %0%)" info-regionRestoringProfile: " (profile: %0%)"
info-regionFooter: ""
info-regionNoRenting: "%0% is not registered for renting"
info-regionRenting: "&6Renting details for %0%:"
info-regionRentedBy: "Rented by: &7%0% until %1%"
info-regionNotRented: "Currently not rented"
info-regionBuying: "&6Buying details for %0%:"
info-regionNoBuying: "%0% is not registered for buying"
info-regionNotBought: "Currently not sold"
info-regionBoughtBy: "Bought by: &7%0%"
info-regionSign: "Sign location(s): %0%"
info-regionNoSign: "There is no sign registered for this region" info-regionNoSign: "There is no sign registered for this region"
info-regionPriceDuration: "Price: &7%0% for each %1%" info-regionPriceDuration: "Price: &7%0% for each %1%"
@ -198,8 +188,8 @@ setrestore-help: "/as setrestore <region> <true|false|general> [profile]"
setrestore-noPermission: "You don't have permission to change the restore settings" setrestore-noPermission: "You don't have permission to change the restore settings"
setrestore-notRegistered: "%0% is not registered" setrestore-notRegistered: "%0% is not registered"
setrestore-invalidSetting: "'%0%' is not a valid state, should be true, false or general" setrestore-invalidSetting: "'%0%' is not a valid state, should be true, false or general"
setrestore-success: "successfully set the restore setting of %0% to '%1%'" setrestore-success: "Successfully set the restore setting of %0% to '%1%'"
setrestore-successProfile: "successfully set the restore setting of %0% to '%1%' and the profile to '%2%'" setrestore-successProfile: "Successfully set the restore setting of %0% to '%1%' and the profile to '%2%'"
setprice-noPermission: "You don't have permission to change the price of a region" setprice-noPermission: "You don't have permission to change the price of a region"
setprice-help: "/as setprice <price> [region], the region you stand in will be used if not specified" setprice-help: "/as setprice <price> [region], the region you stand in will be used if not specified"

View File

@ -332,7 +332,7 @@ public class Metrics {
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
String pluginVersion = description.getVersion(); String pluginVersion = description.getVersion();
String serverVersion = Bukkit.getVersion(); String serverVersion = Bukkit.getVersion();
int playersOnline = Bukkit.getServer().getOnlinePlayers().size(); int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
// END server software specific section -- all code below does not use any code outside of this class / Java // END server software specific section -- all code below does not use any code outside of this class / Java

View File

@ -88,7 +88,7 @@ public class FindCommand extends CommandAreaShop {
} else { } else {
plugin.message(player, "find-success", "buy", region.getName(), balance, onlyInGroup); plugin.message(player, "find-success", "buy", region.getName(), balance, onlyInGroup);
} }
region.teleportPlayer(player, true); region.teleportPlayer(player, true, false);
return; return;
} }
} }
@ -123,7 +123,7 @@ public class FindCommand extends CommandAreaShop {
} else { } else {
plugin.message(player, "find-success", "rent", region.getName(), balance, onlyInGroup); plugin.message(player, "find-success", "rent", region.getName(), balance, onlyInGroup);
} }
region.teleportPlayer(player, true); region.teleportPlayer(player, true, false);
return; return;
} }
} }

View File

@ -239,7 +239,7 @@ public class InfoCommand extends CommandAreaShop {
} }
if(rent != null) { if(rent != null) {
plugin.message(sender, "info-regionHeader", rent); plugin.message(sender, "info-regionHeaderRent", rent);
if(rent.isRented()) { if(rent.isRented()) {
plugin.messageNoPrefix(sender, "info-regionRented", rent); plugin.messageNoPrefix(sender, "info-regionRented", rent);
plugin.messageNoPrefix(sender, "info-regionExtending", rent); plugin.messageNoPrefix(sender, "info-regionExtending", rent);
@ -287,13 +287,6 @@ public class InfoCommand extends CommandAreaShop {
if(sender.hasPermission("areashop.groupinfo") && !rent.getGroupNames().isEmpty()) { if(sender.hasPermission("areashop.groupinfo") && !rent.getGroupNames().isEmpty()) {
plugin.messageNoPrefix(sender, "info-regionGroups", Utils.createCommaSeparatedList(rent.getGroupNames())); plugin.messageNoPrefix(sender, "info-regionGroups", Utils.createCommaSeparatedList(rent.getGroupNames()));
} }
if(!rent.isRented()) {
if(rent.restrictedToRegion()) {
plugin.messageNoPrefix(sender, "info-regionRestrictedRegionRent", rent);
} else if(rent.restrictedToWorld()) {
plugin.messageNoPrefix(sender, "info-regionRestrictedWorldRent", rent);
}
}
if(rent.isRestoreEnabled()) { if(rent.isRestoreEnabled()) {
if(sender.hasPermission("areashop.setrestore")) { if(sender.hasPermission("areashop.setrestore")) {
plugin.messageNoPrefix(sender, "info-regionRestoringRent", rent, plugin.getLanguageManager().getLang("info-regionRestoringProfile", rent.getRestoreProfile())); plugin.messageNoPrefix(sender, "info-regionRestoringRent", rent, plugin.getLanguageManager().getLang("info-regionRestoringProfile", rent.getRestoreProfile()));
@ -301,35 +294,65 @@ public class InfoCommand extends CommandAreaShop {
plugin.messageNoPrefix(sender, "info-regionRestoringRent", rent, ""); plugin.messageNoPrefix(sender, "info-regionRestoringRent", rent, "");
} }
} }
plugin.messageNoPrefix(sender, "info-regionFooter", rent); if(!rent.isRented()) {
if(rent.restrictedToRegion()) {
plugin.messageNoPrefix(sender, "info-regionRestrictedRegionRent", rent);
} else if(rent.restrictedToWorld()) {
plugin.messageNoPrefix(sender, "info-regionRestrictedWorldRent", rent);
}
}
plugin.messageNoPrefix(sender, "info-regionFooterRent", rent);
} else if(buy != null) { } else if(buy != null) {
plugin.message(sender, "info-regionBuying", buy.getName()); plugin.message(sender, "info-regionHeaderBuy", buy);
if(buy.isSold()) {
plugin.messageNoPrefix(sender, "info-regionBought", buy);
plugin.messageNoPrefix(sender, "info-regionMoneyBackBuy", buy);
if(!buy.getFriendNames().isEmpty()) {
plugin.messageNoPrefix(sender, "info-regionFriends", buy);
}
} else {
plugin.messageNoPrefix(sender, "info-regionCanBeBought", buy);
}
if(buy.getInactiveTimeUntilSell() != -1) {
plugin.messageNoPrefix(sender, "info-regionInactiveSell", buy);
}
if(sender.hasPermission("areashop.teleport") || sender.hasPermission("areashop.teleportall")) {
Location teleport = buy.getTeleportLocation();
if(teleport == null) {
if(buy.isSold()) {
plugin.messageNoPrefix(sender, "info-regionNoTeleport", buy, plugin.getLanguageManager().getLang("info-regionTeleportHint", buy));
} else {
plugin.messageNoPrefix(sender, "info-regionNoTeleport", buy, "");
}
} else {
plugin.messageNoPrefix(sender, "info-regionTeleportAt", buy, teleport.getWorld().getName(), teleport.getBlockX(), teleport.getBlockY(), teleport.getBlockZ(), (int)teleport.getPitch(), (int)teleport.getYaw());
}
}
List<String> signLocations = new ArrayList<String>(); List<String> signLocations = new ArrayList<String>();
for(Location location : buy.getSignLocations()) { for(Location location : buy.getSignLocations()) {
signLocations.add(plugin.getLanguageManager().getLang("info-regionSignLocation", location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ())); signLocations.add(plugin.getLanguageManager().getLang("info-regionSignLocation", location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()));
} }
if(signLocations.isEmpty()) { if(!signLocations.isEmpty()) {
plugin.message(sender, "info-regionNoSign"); plugin.messageNoPrefix(sender, "info-regionSigns", Utils.createCommaSeparatedList(signLocations));
} else {
plugin.message(sender, "info-regionSign", Utils.createCommaSeparatedList(signLocations));
} }
plugin.message(sender, "info-regionPrice", buy.getFormattedPrice()); if(sender.hasPermission("areashop.groupinfo") && !buy.getGroupNames().isEmpty()) {
if(!buy.isSold()) { plugin.messageNoPrefix(sender, "info-regionGroups", Utils.createCommaSeparatedList(buy.getGroupNames()));
plugin.message(sender, "info-regionNotBought");
} else {
plugin.message(sender, "info-regionBoughtBy", buy.getPlayerName());
} }
if(sender.hasPermission("areashop.buyrestore")) { if(buy.isRestoreEnabled()) {
plugin.message(sender, "info-regionRestore", buy.isRestoreEnabled()); if(sender.hasPermission("areashop.setrestore")) {
plugin.message(sender, "info-regionRestoreProfile", buy.getRestoreProfile()); plugin.messageNoPrefix(sender, "info-regionRestoringBuy", buy, plugin.getLanguageManager().getLang("info-regionRestoringProfile", buy.getRestoreProfile()));
}
if(sender.hasPermission("areashop.teleport")) {
if(buy.getTeleportLocation() == null) {
plugin.message(sender, "info-regionNoTP");
} else { } else {
plugin.message(sender, "info-regionTPLocation", buy.getTeleportLocation().getWorld().toString(), buy.getTeleportLocation().getBlockX(), buy.getTeleportLocation().getBlockY(), buy.getTeleportLocation().getBlockZ(), buy.getTeleportLocation().getPitch(), buy.getTeleportLocation().getYaw()); plugin.messageNoPrefix(sender, "info-regionRestoringBuy", buy, "");
} }
} }
if(!buy.isSold()) {
if(buy.restrictedToRegion()) {
plugin.messageNoPrefix(sender, "info-regionRestrictedRegionBuy", buy);
} else if(buy.restrictedToWorld()) {
plugin.messageNoPrefix(sender, "info-regionRestrictedWorldBuy", buy);
}
}
plugin.messageNoPrefix(sender, "info-regionFooterBuy", buy);
} }
} else { } else {
plugin.message(sender, "info-regionHelp"); plugin.message(sender, "info-regionHelp");

View File

@ -202,6 +202,7 @@ public class BuyRegion extends GeneralRegion {
result.put(AreaShop.tagPlayerName, getPlayerName()); result.put(AreaShop.tagPlayerName, getPlayerName());
result.put(AreaShop.tagPlayerUUID, getBuyer()); result.put(AreaShop.tagPlayerUUID, getBuyer());
result.put(AreaShop.tagResellPrice, getFormattedResellPrice()); result.put(AreaShop.tagResellPrice, getFormattedResellPrice());
result.put(AreaShop.tagMoneyBackAmount, getFormattedMoneyBackAmount());
double moneyBackPercent = getMoneyBackPercentage(); double moneyBackPercent = getMoneyBackPercentage();
if((moneyBackPercent%1.0) == 0.0) { if((moneyBackPercent%1.0) == 0.0) {
result.put(AreaShop.tagMoneyBackPercentage, (int)moneyBackPercent); result.put(AreaShop.tagMoneyBackPercentage, (int)moneyBackPercent);

View File

@ -714,7 +714,6 @@ public abstract class GeneralRegion {
signType = null; signType = null;
} }
if(signType != Material.WALL_SIGN && signType != Material.SIGN_POST) { if(signType != Material.WALL_SIGN && signType != Material.SIGN_POST) {
block.setType(Material.AIR);
AreaShop.debug(" setting sign failed"); AreaShop.debug(" setting sign failed");
continue; continue;
} }
@ -723,7 +722,7 @@ public abstract class GeneralRegion {
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)signState.getData(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign)signState.getData();
BlockFace signFace; BlockFace signFace;
try { try {
signFace = BlockFace.valueOf(config.getString("general.signs." + sign + ".signType")); signFace = BlockFace.valueOf(config.getString("general.signs." + sign + ".facing"));
} catch(NullPointerException | IllegalArgumentException e) { } catch(NullPointerException | IllegalArgumentException e) {
signFace = null; signFace = null;
} }
@ -732,7 +731,9 @@ public abstract class GeneralRegion {
signState.setData(signData); signState.setData(signData);
} }
} }
signState = (Sign)block.getState(); if(signState == null) {
signState = (Sign)block.getState();
}
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)signState.getData(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign)signState.getData();
if(!config.isString("general.signs." + sign + ".signType")) { if(!config.isString("general.signs." + sign + ".signType")) {
config.set("general.signs." + sign + ".signType", signState.getType().toString()); config.set("general.signs." + sign + ".signType", signState.getType().toString());
@ -1175,8 +1176,9 @@ public abstract class GeneralRegion {
* Teleport a player to the region * Teleport a player to the region
* @param player Player that should be teleported * @param player Player that should be teleported
* @param regionName The name of the region the player should be teleported to * @param regionName The name of the region the player should be teleported to
* @param checkPermissions Set to true if teleport permissions should be checked, false otherwise
*/ */
public boolean teleportPlayer(Player player, boolean toSign) { public boolean teleportPlayer(Player player, boolean toSign, boolean checkPermissions) {
int checked = 1; int checked = 1;
boolean owner = false; boolean owner = false;
Location startLocation = null; Location startLocation = null;
@ -1192,19 +1194,21 @@ public abstract class GeneralRegion {
|| !toSign && !owner && !player.hasPermission("areashop.teleportall")) { || !toSign && !owner && !player.hasPermission("areashop.teleportall")) {
toSign = true; toSign = true;
} }
// Check permissions if(checkPermissions) {
if(owner && !player.hasPermission("areashop.teleport") && !toSign) { // Check permissions
plugin.message(player, "teleport-noPermission"); if(owner && !player.hasPermission("areashop.teleport") && !toSign) {
return false; plugin.message(player, "teleport-noPermission");
} else if(!owner && !player.hasPermission("areashop.teleportall") && !toSign) { return false;
plugin.message(player, "teleport-noPermissionOther"); } else if(!owner && !player.hasPermission("areashop.teleportall") && !toSign) {
return false; plugin.message(player, "teleport-noPermissionOther");
} else if(owner && !player.hasPermission("areashop.teleportsign") && toSign) { return false;
plugin.message(player, "teleport-noPermissionSign"); } else if(owner && !player.hasPermission("areashop.teleportsign") && toSign) {
return false; plugin.message(player, "teleport-noPermissionSign");
} else if(!owner && !player.hasPermission("areashop.teleportsignall") && toSign) { return false;
plugin.message(player, "teleport-noPermissionOtherSign"); } else if(!owner && !player.hasPermission("areashop.teleportsignall") && toSign) {
return false; plugin.message(player, "teleport-noPermissionOtherSign");
return false;
}
} }
if(toSign) { if(toSign) {
@ -1474,8 +1478,11 @@ public abstract class GeneralRegion {
return false; return false;
} }
} }
public boolean teleportPlayer(Player player, boolean toSign) {
return teleportPlayer(player, toSign, true);
}
public boolean teleportPlayer(Player player) { public boolean teleportPlayer(Player player) {
return teleportPlayer(player, false); return teleportPlayer(player, false, true);
} }
/** /**