mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-23 10:45:53 +01:00
Add the stopresell command, fix a bug with reselling
If you put your region into resell mode and then sold it to the server with /as sell, the next player buying the region would get an error or his region would be in reselling mode directly. Now this is fixed
This commit is contained in:
parent
9ea97fdb5d
commit
cbeffe9316
@ -145,6 +145,8 @@ signProfiles:
|
|||||||
- 'areashop buy %region%'
|
- 'areashop buy %region%'
|
||||||
leftClickPlayer:
|
leftClickPlayer:
|
||||||
- 'areashop info region %region%'
|
- 'areashop info region %region%'
|
||||||
|
shiftRightClickPlayer:
|
||||||
|
- 'areashop stopresell %region%'
|
||||||
sold:
|
sold:
|
||||||
line1: '&4&l[Sold]'
|
line1: '&4&l[Sold]'
|
||||||
line2: '%region%'
|
line2: '%region%'
|
||||||
|
11
lang/EN.yml
11
lang/EN.yml
@ -16,6 +16,7 @@ cmd-weOnlyByPlayer: "Using a WorldEdit selection is only possible as a player, s
|
|||||||
cmd-noSelection: "You don't have a WorldEdit selection"
|
cmd-noSelection: "You don't have a WorldEdit selection"
|
||||||
cmd-noRegionsFound: "No regions registered in AreaShop are found in your selection"
|
cmd-noRegionsFound: "No regions registered in AreaShop are found in your selection"
|
||||||
cmd-noWERegionsFound: "No WorldEdit regions intersecting your selection are found"
|
cmd-noWERegionsFound: "No WorldEdit regions intersecting your selection are found"
|
||||||
|
cmd-notRegistered: "%0% is not registered in AreaShop"
|
||||||
|
|
||||||
########## Help command strings
|
########## Help command strings
|
||||||
help-header: "Help page, commands that you can execute"
|
help-header: "Help page, commands that you can execute"
|
||||||
@ -52,6 +53,8 @@ help-me: "&6/as me &7-&r Check which regions you have (+expiration)"
|
|||||||
help-setowner: "&6/as setowner &7-&r Set region owner or extend the rent"
|
help-setowner: "&6/as setowner &7-&r Set region owner or extend the rent"
|
||||||
help-resell: "&6/as resell &7-&r Put one of your regions into resell mode"
|
help-resell: "&6/as resell &7-&r Put one of your regions into resell mode"
|
||||||
help-resellAll: "&6/as resell &7-&r Put a region into resell mode"
|
help-resellAll: "&6/as resell &7-&r Put a region into resell mode"
|
||||||
|
help-stopResell: "&6/as stopresell &7-&r Put your region back into sold mode"
|
||||||
|
help-stopResellAll: "&6/as stopresell &7-&r Put a region back into sold mode"
|
||||||
|
|
||||||
############ Other command strings
|
############ Other command strings
|
||||||
rent-help: "/as rent [regionname], the region you stand in will be used if not specified"
|
rent-help: "/as rent [regionname], the region you stand in will be used if not specified"
|
||||||
@ -310,6 +313,14 @@ resell-success: "%region% is successfully put into reselling mode for %resellpri
|
|||||||
resell-noPermission: "You don't have permission to set your region in reselling mode"
|
resell-noPermission: "You don't have permission to set your region in reselling mode"
|
||||||
resell-noPermissionOther: "You don't have permission to set regions in reselling mode"
|
resell-noPermissionOther: "You don't have permission to set regions in reselling mode"
|
||||||
|
|
||||||
|
stopResell-help: "/as stopResell [region], the region you stand in will be used if not specified"
|
||||||
|
stopResell-notRegistered: "%0% is not registered in AreaShop"
|
||||||
|
stopResell-noRegionFound: "No AreaShop region could be found at your location, try specifying the region as argument"
|
||||||
|
stopResell-notResell: "You can't stop reselling %region% because it is not in resell mode"
|
||||||
|
stopResell-success: "%region% is successfully put back into sold mode"
|
||||||
|
stopResell-noPermission: "You don't have permission to set your region back to sold mode"
|
||||||
|
stopResell-noPermissionOther: "You don't have permission to set regions back to sold mode"
|
||||||
|
|
||||||
############ Sign, greeting and other strings
|
############ Sign, greeting and other strings
|
||||||
timeleft-years: "%0% years"
|
timeleft-years: "%0% years"
|
||||||
timeleft-months: "%0% months"
|
timeleft-months: "%0% months"
|
||||||
|
@ -179,4 +179,10 @@ permissions:
|
|||||||
areashop.resellall:
|
areashop.resellall:
|
||||||
description: Allows you to set any region into selling mode
|
description: Allows you to set any region into selling mode
|
||||||
default: op
|
default: op
|
||||||
|
areashop.stopresell:
|
||||||
|
description: Allows you to set your region into normal mode if it is in sell mode
|
||||||
|
default: true
|
||||||
|
areashop.stopresellall:
|
||||||
|
description: Allows you to set any region into normal mode if it is in sell mode
|
||||||
|
default: op
|
||||||
|
|
@ -29,6 +29,7 @@ import nl.evolutioncoding.areashop.commands.SetownerCommand;
|
|||||||
import nl.evolutioncoding.areashop.commands.SetpriceCommand;
|
import nl.evolutioncoding.areashop.commands.SetpriceCommand;
|
||||||
import nl.evolutioncoding.areashop.commands.SetrestoreCommand;
|
import nl.evolutioncoding.areashop.commands.SetrestoreCommand;
|
||||||
import nl.evolutioncoding.areashop.commands.SetteleportCommand;
|
import nl.evolutioncoding.areashop.commands.SetteleportCommand;
|
||||||
|
import nl.evolutioncoding.areashop.commands.StopresellCommand;
|
||||||
import nl.evolutioncoding.areashop.commands.TeleportCommand;
|
import nl.evolutioncoding.areashop.commands.TeleportCommand;
|
||||||
import nl.evolutioncoding.areashop.commands.UnrentCommand;
|
import nl.evolutioncoding.areashop.commands.UnrentCommand;
|
||||||
import nl.evolutioncoding.areashop.commands.UpdatebuysCommand;
|
import nl.evolutioncoding.areashop.commands.UpdatebuysCommand;
|
||||||
@ -63,6 +64,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
commands.add(new SetteleportCommand(plugin));
|
commands.add(new SetteleportCommand(plugin));
|
||||||
commands.add(new FindCommand(plugin));
|
commands.add(new FindCommand(plugin));
|
||||||
commands.add(new ResellCommand(plugin));
|
commands.add(new ResellCommand(plugin));
|
||||||
|
commands.add(new StopresellCommand(plugin));
|
||||||
commands.add(new UpdaterentsCommand(plugin));
|
commands.add(new UpdaterentsCommand(plugin));
|
||||||
commands.add(new UpdatebuysCommand(plugin));
|
commands.add(new UpdatebuysCommand(plugin));
|
||||||
commands.add(new SetrestoreCommand(plugin));
|
commands.add(new SetrestoreCommand(plugin));
|
||||||
|
@ -14,7 +14,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.exceptions.RegionCreateException;
|
import nl.evolutioncoding.areashop.exceptions.RegionCreateException;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
|
@ -103,7 +103,7 @@ public class ResellCommand extends CommandAreaShop {
|
|||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
if(toComplete == 3) {
|
if(toComplete == 3) {
|
||||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||||
if(region.isSold()) {
|
if(region.isSold() && !region.isInResellingMode()) {
|
||||||
result.add(region.getName());
|
result.add(region.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
119
src/nl/evolutioncoding/areashop/commands/StopresellCommand.java
Normal file
119
src/nl/evolutioncoding/areashop/commands/StopresellCommand.java
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
// TODO ALL
|
||||||
|
public class StopresellCommand extends CommandAreaShop {
|
||||||
|
|
||||||
|
public StopresellCommand(AreaShop plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandStart() {
|
||||||
|
return "areashop stopresell";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp(CommandSender target) {
|
||||||
|
if(target.hasPermission("areashop.stopresell")) {
|
||||||
|
return plugin.getLanguageManager().getLang("help-stopResell");
|
||||||
|
} else if(target.hasPermission("areashop.stopresellall")) {
|
||||||
|
plugin.getLanguageManager().getLang("help-stopResellAll");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, Command command, String[] args) {
|
||||||
|
BuyRegion buy = null;
|
||||||
|
if(args.length <= 1) {
|
||||||
|
if(sender instanceof Player) {
|
||||||
|
// get the region by location
|
||||||
|
List<GeneralRegion> regions = plugin.getFileManager().getApplicalbeASRegions(((Player)sender).getLocation());
|
||||||
|
if(regions.size() != 1) {
|
||||||
|
plugin.message(sender, "stopResell-help");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if(regions.get(0).isBuyRegion()) {
|
||||||
|
buy = (BuyRegion)regions.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
plugin.message(sender, "stopResell-help");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
buy = plugin.getFileManager().getBuy(args[1]);
|
||||||
|
if(buy == null) {
|
||||||
|
plugin.message(sender, "stopResell-notRegistered", args[1]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(buy == null) {
|
||||||
|
plugin.message(sender, "stopResell-noRegionFound");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!buy.isInResellingMode()) {
|
||||||
|
plugin.message(sender, "stopResell-notResell", buy);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(sender.hasPermission("areashop.stopresellall")) {
|
||||||
|
buy.disableReselling();
|
||||||
|
buy.saveRequired();
|
||||||
|
plugin.message(sender, "stopResell-success", buy);
|
||||||
|
buy.updateSigns();
|
||||||
|
buy.updateRegionFlags();
|
||||||
|
} else if(sender.hasPermission("areashop.stopresell") && sender instanceof Player) {
|
||||||
|
if(buy.isOwner((Player)sender)) {
|
||||||
|
buy.disableReselling();
|
||||||
|
buy.saveRequired();
|
||||||
|
plugin.message(sender, "stopResell-success", buy);
|
||||||
|
buy.updateSigns();
|
||||||
|
buy.updateRegionFlags();
|
||||||
|
} else {
|
||||||
|
plugin.message(sender, "stopResell-noPermissionOther");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
plugin.message(sender, "stopResell-noPermission");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||||
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
if(toComplete == 2) {
|
||||||
|
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||||
|
if(region.isSold() && region.isInResellingMode()) {
|
||||||
|
result.add(region.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -222,8 +222,8 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
|
|
||||||
/* Check if the player has enough money */
|
/* Check if the player has enough money */
|
||||||
if(plugin.getEconomy().has(player, getWorldName(), getPrice())) {
|
if(plugin.getEconomy().has(player, getWorldName(), getPrice())) {
|
||||||
if(isResell) {
|
UUID oldOwner = getBuyer();
|
||||||
UUID oldOwner = getBuyer();
|
if(isResell && oldOwner != null) {
|
||||||
double resellPrice = getResellPrice();
|
double resellPrice = getResellPrice();
|
||||||
/* Transfer the money to the previous owner */
|
/* Transfer the money to the previous owner */
|
||||||
EconomyResponse r = plugin.getEconomy().withdrawPlayer(player, getWorldName(), getResellPrice());
|
EconomyResponse r = plugin.getEconomy().withdrawPlayer(player, getWorldName(), getResellPrice());
|
||||||
@ -312,6 +312,7 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
// Run commands
|
// Run commands
|
||||||
this.runEventCommands(RegionEvent.SOLD, true);
|
this.runEventCommands(RegionEvent.SOLD, true);
|
||||||
|
|
||||||
|
disableReselling();
|
||||||
/* Give part of the buying price back */
|
/* Give part of the buying price back */
|
||||||
double percentage = getDoubleSetting("buy.moneyBack") / 100.0;
|
double percentage = getDoubleSetting("buy.moneyBack") / 100.0;
|
||||||
double moneyBack = getPrice() * percentage;
|
double moneyBack = getPrice() * percentage;
|
||||||
|
Loading…
Reference in New Issue
Block a user