mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-16 15:25:11 +01:00
Fix a bug with depositing to players that never joined
Paying to players that never visited before will now fallback to using a name instead of UUID towards Vault, which prevents problems (for players that never visited, such as server accounts, you cannot get the name from the UUID via Bukkit).
This commit is contained in:
parent
937db4620d
commit
93d5612513
@ -153,7 +153,7 @@ public class AddCommand extends CommandAreaShop {
|
||||
RentRegion rent = new RentRegion(plugin, region.getId(), finalWorld);
|
||||
// Set landlord
|
||||
if(landlord) {
|
||||
rent.setLandlord(finalPlayer.getUniqueId());
|
||||
rent.setLandlord(finalPlayer.getUniqueId(), finalPlayer.getName());
|
||||
}
|
||||
// Run commands
|
||||
rent.runEventCommands(RegionEvent.CREATED, true);
|
||||
@ -167,7 +167,7 @@ public class AddCommand extends CommandAreaShop {
|
||||
BuyRegion buy = new BuyRegion(plugin, region.getId(), finalWorld);
|
||||
// Set landlord
|
||||
if(landlord) {
|
||||
buy.setLandlord(finalPlayer.getUniqueId());
|
||||
buy.setLandlord(finalPlayer.getUniqueId(), finalPlayer.getName());
|
||||
}
|
||||
// Run commands
|
||||
buy.runEventCommands(RegionEvent.CREATED, true);
|
||||
|
@ -81,7 +81,7 @@ public class AddfriendCommand extends CommandAreaShop {
|
||||
return;
|
||||
}
|
||||
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(!friend.hasPlayedBefore()) {
|
||||
if(friend.getLastPlayed() == 0) {
|
||||
plugin.message(sender, "addfriend-notVisited", args[1]);
|
||||
return;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class SetlandlordCommand extends CommandAreaShop {
|
||||
plugin.message(player, "setlandlord-noRegion", args[2]);
|
||||
return;
|
||||
}
|
||||
region.setLandlord(player.getUniqueId());
|
||||
region.setLandlord(player.getUniqueId(), args[1]);
|
||||
String playerName = player.getName();
|
||||
if(playerName.isEmpty()) {
|
||||
playerName = args[1];
|
||||
|
@ -144,7 +144,7 @@ public final class SignChangeListener implements Listener {
|
||||
|| (player.hasPermission("areashop.createrent.member") && isMember)));
|
||||
|
||||
if(landlord) {
|
||||
rent.setLandlord(player.getUniqueId());
|
||||
rent.setLandlord(player.getUniqueId(), player.getName());
|
||||
}
|
||||
if(priceSet) {
|
||||
rent.setPrice(price);
|
||||
@ -257,7 +257,7 @@ public final class SignChangeListener implements Listener {
|
||||
|| (player.hasPermission("areashop.createbuy.member") && isMember)));
|
||||
|
||||
if(landlord) {
|
||||
buy.setLandlord(player.getUniqueId());
|
||||
buy.setLandlord(player.getUniqueId(), player.getName());
|
||||
}
|
||||
if(priceSet) {
|
||||
buy.setPrice(price);
|
||||
|
@ -21,7 +21,7 @@ import com.google.common.base.Charsets;
|
||||
|
||||
public class LanguageManager {
|
||||
private AreaShop plugin = null;
|
||||
private String languages[] = {"EN", "ZH_TW", "NL", "FI", "FR", "DE", "PL"};
|
||||
private String languages[] = {"EN", "NL", "FI", "DE", "FR", "PL", "ZH_TW"};
|
||||
private HashMap<String, String> currentLanguage, defaultLanguage;
|
||||
|
||||
/**
|
||||
|
@ -250,6 +250,7 @@ public class BuyRegion extends GeneralRegion {
|
||||
* @param player The player that wants to buy the region
|
||||
* @return true if it succeeded and false if not
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean buy(Player player) {
|
||||
/* Check if the player has permission */
|
||||
if(player.hasPermission("areashop.buy")) {
|
||||
@ -307,7 +308,11 @@ public class BuyRegion extends GeneralRegion {
|
||||
}
|
||||
OfflinePlayer oldOwnerPlayer = Bukkit.getOfflinePlayer(oldOwner);
|
||||
if(oldOwnerPlayer != null) {
|
||||
r = plugin.getEconomy().depositPlayer(oldOwnerPlayer, getWorldName(), getResellPrice());
|
||||
if(oldOwnerPlayer.getName() == null) {
|
||||
r = plugin.getEconomy().depositPlayer(getPlayerName(), getWorldName(), getResellPrice());
|
||||
} else {
|
||||
r = plugin.getEconomy().depositPlayer(oldOwnerPlayer, getWorldName(), getResellPrice());
|
||||
}
|
||||
if(!r.transactionSuccess()) {
|
||||
plugin.getLogger().warning("Something went wrong with paying '" + oldOwnerPlayer.getName() + "' " + getFormattedPrice() + " for his resell of region " + getName() + " to " + player.getName());
|
||||
}
|
||||
@ -344,7 +349,11 @@ public class BuyRegion extends GeneralRegion {
|
||||
if(getLandlord() != null) {
|
||||
OfflinePlayer landlord = Bukkit.getOfflinePlayer(getLandlord());
|
||||
if(landlord != null) {
|
||||
r = plugin.getEconomy().depositPlayer(landlord, getWorldName(), getPrice());
|
||||
if(landlord.getName() == null) {
|
||||
r = plugin.getEconomy().depositPlayer(getLandlordName(), getWorldName(), getPrice());
|
||||
} else {
|
||||
r = plugin.getEconomy().depositPlayer(landlord, getWorldName(), getPrice());
|
||||
}
|
||||
if(!r.transactionSuccess()) {
|
||||
plugin.getLogger().warning("Something went wrong with paying '" + landlord.getName() + "' " + getFormattedPrice() + " for his sell of region " + getName() + " to " + player.getName());
|
||||
}
|
||||
@ -395,6 +404,7 @@ public class BuyRegion extends GeneralRegion {
|
||||
* Sell a buyed region, get part of the money back
|
||||
* @param regionName
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void sell(boolean giveMoneyBack) {
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.SOLD, true);
|
||||
@ -409,7 +419,11 @@ public class BuyRegion extends GeneralRegion {
|
||||
EconomyResponse response = null;
|
||||
boolean error = false;
|
||||
try {
|
||||
response = plugin.getEconomy().depositPlayer(Bukkit.getOfflinePlayer(getBuyer()), getWorldName(), moneyBack);
|
||||
if(player.getName() == null) {
|
||||
response = plugin.getEconomy().depositPlayer(getPlayerName(), getWorldName(), moneyBack);
|
||||
} else {
|
||||
response = plugin.getEconomy().depositPlayer(player, getWorldName(), moneyBack);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
error = true;
|
||||
}
|
||||
|
@ -355,13 +355,17 @@ public abstract class GeneralRegion implements GeneralRegionInterface {
|
||||
* Set the landlord of this region (the player that receives all revenue of this region)
|
||||
* @param landlord The UUID of the player that should be set as landlord
|
||||
*/
|
||||
public void setLandlord(UUID landlord) {
|
||||
public void setLandlord(UUID landlord, String name) {
|
||||
if(landlord == null) {
|
||||
setSetting("general.landlord", null);
|
||||
setSetting("general.landlordName", null);
|
||||
} else {
|
||||
setSetting("general.landlord", landlord.toString());
|
||||
setSetting("general.landlordName", plugin.toName(landlord));
|
||||
String properName = plugin.toName(landlord);
|
||||
if(properName != null) {
|
||||
name = properName;
|
||||
}
|
||||
setSetting("general.landlordName", properName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,6 +394,7 @@ public class RentRegion extends GeneralRegion {
|
||||
* @param regionName The name of the region you want to rent
|
||||
* @return true if it succeeded and false if not
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean rent(Player player) {
|
||||
/* Check if the player has permission */
|
||||
if(player.hasPermission("areashop.rent")) {
|
||||
@ -476,7 +477,13 @@ public class RentRegion extends GeneralRegion {
|
||||
if(getLandlord() != null) {
|
||||
OfflinePlayer landlord = Bukkit.getOfflinePlayer(getLandlord());
|
||||
if(landlord != null) {
|
||||
r = plugin.getEconomy().depositPlayer(landlord, getWorldName(), getPrice());
|
||||
// If the landlord has no player.dat file anymore, then getName() returns null,
|
||||
// therefor we deposit the money by the old cached name instead
|
||||
if(landlord.getName() == null) {
|
||||
r = plugin.getEconomy().depositPlayer(getLandlordName(), getWorldName(), getPrice());
|
||||
} else {
|
||||
r = plugin.getEconomy().depositPlayer(landlord, getWorldName(), getPrice());
|
||||
}
|
||||
if(!r.transactionSuccess()) {
|
||||
plugin.getLogger().warning("Something went wrong with paying '" + landlord.getName() + "' " + getFormattedPrice() + " for his rent of region " + getName() + " to " + player.getName());
|
||||
}
|
||||
@ -551,6 +558,7 @@ public class RentRegion extends GeneralRegion {
|
||||
* Unrent a region, reset to unrented
|
||||
* @param regionName Region that should be unrented
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void unRent(boolean giveMoneyBack) {
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.UNRENTED, true);
|
||||
@ -562,7 +570,11 @@ public class RentRegion extends GeneralRegion {
|
||||
EconomyResponse r = null;
|
||||
boolean error = false;
|
||||
try {
|
||||
r = plugin.getEconomy().depositPlayer(Bukkit.getOfflinePlayer(getRenter()), getWorldName(), moneyBack);
|
||||
if(player.getName() == null) {
|
||||
r = plugin.getEconomy().depositPlayer(getPlayerName(), getWorldName(), moneyBack);
|
||||
} else {
|
||||
r = plugin.getEconomy().depositPlayer(player, getWorldName(), moneyBack);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
error = true;
|
||||
}
|
||||
|
@ -79,8 +79,8 @@ hours: [h, hour, hours, uur, uren]
|
||||
days: [d, day, days, dag, dagen]
|
||||
months: [M, month, months, maanden, maand]
|
||||
years: [y, year, years, jaar, jaren]
|
||||
|
||||
|
||||
|
||||
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
# │ PERMISSION GROUPS: Assigned by giving players certain permissions │
|
||||
# └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
@ -97,7 +97,7 @@ limitGroups:
|
||||
rents: 1
|
||||
buys: 1
|
||||
|
||||
|
||||
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
# │ PROFILES: Assigned in general (default.yml), for a group (groups.yml) or individually (<region>.yml) │
|
||||
# └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
@ -291,8 +291,8 @@ expirationWarningProfiles:
|
||||
"5 minutes":
|
||||
warnPlayer: true
|
||||
commands:
|
||||
|
||||
|
||||
|
||||
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
# │ LIMITS AND TIMINGS: Options for limits and the frequencies for certain functions (be very careful with these!) │
|
||||
# └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
@ -347,17 +347,4 @@ nameupdate:
|
||||
## Timings for adding regions to AreaShop ('/as stack')
|
||||
adding:
|
||||
## Number of regions to add per tick
|
||||
regionsPerTick: 2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
regionsPerTick: 2
|
@ -74,16 +74,4 @@ buy:
|
||||
moneyBack: 100
|
||||
## Automatically sell the region after the specified number of minutes between the last login time of the buyer and the current time
|
||||
## -1 mean never, 1440 is one day, 43200 is one month, 525600 is one year
|
||||
inactiveTimeUntilSell: -1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inactiveTimeUntilSell: -1
|
@ -1,6 +1,7 @@
|
||||
name: AreaShop
|
||||
main: nl.evolutioncoding.areashop.AreaShop
|
||||
version: ${project.version}
|
||||
description: "Selling and renting WorldGuard regions to your players, highly configurable."
|
||||
depend: [Vault, WorldGuard, WorldEdit]
|
||||
softdepend: [Multiverse-Core]
|
||||
author: NLThijs48
|
||||
|
Loading…
Reference in New Issue
Block a user