Merge pull request #1 from NLthijs48/AreaShop-V1.1

AreaShop v1.1
This commit is contained in:
NLthijs48 2014-04-10 22:41:39 +02:00
commit f13534ae33
9 changed files with 1956 additions and 1509 deletions

View File

@ -16,6 +16,10 @@ debug: false
language: EN
## Maximum total amount of rents and buys together
maximumTotal: 1
## Enable Schematic saving and restoring in general
enableSchematics: true
## Maximum number of blocks to save to or restore from a .schemetic
maximumBlocks: 1000000
########## RENTING ##########
## The tag you have to write on the sign for renting a region
@ -41,6 +45,27 @@ flagsRented:
members: +%player%
greeting: '%region% is rented by %player% until %until%'
## Enable or disable saving and restoring for rents that don't have their individual option set
useRentRestore: false
## For the following events you can specify if you want to restore or save the region to a schematic
## After 'save:' or 'restore:' you enter the name of the file, %region% will be replaced by the region name (.schematic will be added automatically)
## If your regions are all the same size you could use just 1 file as the restore file, just enter a name without %region%
## Be carefull with these options, it could crash your server or destroy (parts of) your world if used wrong!
rentSchematicProfiles:
default:
created:
save: 'rent-%region%'
restore: ''
deleted:
save: ''
restore: 'rent-%region%'
rented:
save: ''
restore: ''
unrented:
save: ''
restore: 'rent-%region%'
########## BUYING ##########
## The tag you have to write on the sign for renting a region
buySign: '[buy]'
@ -61,4 +86,26 @@ flagsForSale:
## All region flags can be used + members, owners, priority and parent.
flagsSold:
members: +%player%
greeting: '%region% is bought by %player%'
greeting: '%region% is bought by %player%'
## Enable or disable saving and restoring for buys that don't have their individual option set
useBuyRestore: false
## For the following events you can specify if you want to restore or save the region to a schematic
## After 'save:' or 'restore:' you enter the name of the file, %region% will be replaced by the region name (.schematic will be added automatically)
## If your regions are all the same size you could use just 1 file as the restore file, just enter a name without %region%
## Be carefull with these options, it could crash your server or destroy (parts of) your world if used wrong!
## ('bought' and 'sold' are from the players perspective)
buySchematicProfiles:
default:
created:
save: 'buy-%region%'
restore: ''
deleted:
save: ''
restore: 'buy-%region%'
bought:
save: ''
restore: ''
sold:
save: ''
restore: 'buy-%region%'

View File

@ -19,7 +19,7 @@ rent-maximum: "You can't rent more than %0% region(s)"
rent-payError: "Something went wrong with paying, try again later"
rent-rented: "You rented %0% until %1%"
rent-extended: "You extended your rent of %0% until %1%"
rent-extend: "You can extend your rent by rightclicking the sign again or using /rs rent"
rent-extend: "You can extend your rent by rightclicking the sign again or using /as rent"
rent-lowMoneyExtend: "You don't have enough money to extend the rent (you have %0% and you need %1%)"
rent-lowMoneyRent: "You don't have enough money to rent this region (you have %0% and you need %1%)"
rent-someoneElse: "Someone else already rented this region"
@ -51,24 +51,18 @@ sell-soldYours: "Your region has been sold"
sell-noPermission: "You don't have permission to sell a region"
sell-noPermissionOther: "You don't have permission to sell another region"
rentsigns-updated: "All signs for renting have been updated"
rentsigns-notUpdated: "Not all signs have been updated, maybe reload fixes it"
rentsgins-noPermission: "You don't have permission to update all rentsigns"
rents-updated: "All signs and regions for renting have been updated"
rents-notUpdated: "Not all signs have been updated, maybe reload fixes it"
rents-noPermission: "You don't have permission to update all rent signs and regions"
buysigns-updated: "All signs for selling have been updated"
buysigns-notUpdated: "Not all signs have been updated, maybe reload fixes it"
buysigns-noPermission: "You don't have permission to update all buysigns"
rentregions-updated: "All renting regions have been updated"
rentregions-noPermission: "You don't have permission to update all renting regions"
buyregions-updated: "All buying regions have been updated"
buyregions-noPermission: "You don't have permission to update all buying regions"
buys-updated: "All signs and regions for selling have been updated"
buys-notUpdated: "Not all signs have been updated, maybe reload fixes it"
buys-noPermission: "You don't have permission to update all buy signs and regions"
reload-reloaded: "The config has been reloaded successfully"
reload-noPermission: "You don't have permission to reload the config"
info-help: "/rs info <all|rented|forrent|sold|forsale|player|region>"
info-help: "/as info <all|rented|forrent|sold|forsale|player|region>"
info-all-rents: "Regions registered for renting: %0%"
info-all-noRents: "There are no regions registered for renting"
info-all-buys: "Regions registered for buying: %0%"
@ -81,12 +75,12 @@ info-sold: "Sold regions: %0%"
info-noSold: "No regions are sold"
info-forsale: "Regions for sale: %0%"
info-noForsale: "All regions are sold"
info-playerHelp: "/rs info player <name>"
info-playerHelp: "/as info player <name>"
info-playerRents: "Regions rented by %0%: %1%"
info-playerNoRents: "%0% has not rented a region"
info-playerBuys: "Regions bought by %0%: %1%"
info-playerNoBuys: "%0% has not bought a region"
info-regionHelp: "/rs info region <name>"
info-regionHelp: "/as info region <name>"
info-regionNoRenting: "%0% is not registered for renting"
info-regionRenting: "&6Renting details for %0%"
info-regionRentedBy: "Rented by: %0% until %1%"
@ -98,6 +92,8 @@ info-regionBoughtBy: "Bought by: %0%"
info-regionSign: "Sign position: world=%0%, X=%1%, Y=%2%, Z=%3%"
info-regionPriceDuration: "Price: %0% for each %1%"
info-regionPrice: "Price: %0%"
info-regionRestore: "Restoring enabled: %0%"
info-regionRestoreProfile: "Restoring profile: %0%"
help-header: "Help page, commands that you can execute"
help-alias: "Command aliases: /areashop, /as"
@ -109,8 +105,32 @@ help-unrent: "&6/as unrent &7-&r Unrent a region"
help-unrentOwn: "&6/as unrent &7-&r Unrent your own region"
help-sell: "&6/as sell &7-&r Sell a region"
help-sellOwn: "&6/as sell &7-&r Sell your own region"
help-updaterentsigns: "&6/as updaterentsigns &7-&r Update all rent signs"
help-updatebuysigns: "&6/as updatebuysigns &7-&r Update all buy signs"
help-updaterentregions: "&6/as updaterentregions &7-&r Update all rent regions"
help-updatebuyregions: "&6/as updatebuyregions &7-&r Update all buy regions"
help-reload: "&6/as reload &7-&r Reload the config and languages"
help-updaterents: "&6/as updaterents &7-&r Update all rent signs and regions"
help-updatebuys: "&6/as updatebuys &7-&r Update all buy signs and regions"
help-reload: "&6/as reload &7-&r Reload the config and languages"
help-rentrestore: "&6/as rentrestore &7-&r Set the profile for restoring and on/off "
help-buyrestore: "&6/as buyrestore &7-&r Set the profile for restoring and on/off"
rentrestore-help: "/as rentrestore <region> <true|false|general> [profile]"
rentrestore-noPermission: "You don't have permission to change the restore settings of a rent"
rentrestore-notRegistered: "%0% is not registered as a rent"
rentrestore-invalidSetting: "'%0%' is not a valid state, should be true, false or general"
rentrestore-success: "Succesfully set the restore setting of %0% to '%1%'"
rentrestore-successProfile: "Succesfully set the restore setting of %0% to '%1%' and the profile to '%2%'"
buyrestore-help: "/as buyrestore <region> <true|false|general> [profile]"
buyrestore-noPermission: "You don't have permission to change the restore settings of a buy"
buyrestore-notRegistered: "%0% is not registered as a buy"
buyrestore-invalidSetting: "'%0%' is not a valid state, should be true, false or general"
buyrestore-success: "Succesfully set the restore setting of %0% to '%1%'"
buyrestore-successProfile: "Succesfully set the restore setting of %0% to '%1%' and the profile to '%2%'"

View File

@ -10,7 +10,7 @@
total-maximum: "Je kunt niet meer dan %0% gebied(en) in totaal huren en kopen"
cmd-onlyByPlayer: "Dit commando kan alleen door een speler uitgevoert worden"
cmd-notValid: "Dat commando is niet geldig , gebruik '/rs help' voor informatie"
cmd-notValid: "Dat commando is niet geldig , gebruik '/as help' voor informatie"
rent-regionNotRentable: "Dat gebied is niet beschikbaar om te huren"
rent-help: "/as rent <gebiednaam>"
@ -19,7 +19,7 @@ rent-maximum: "Je kunt niet meer dan %0% gebied(en) huren"
rent-payError: "Er is iets mis gegaan met betalen, probeer het later opnieuw"
rent-rented: "Je hebt %0% tot %1% gehuurd"
rent-extended: "Je hebt je huur van %0% verlengt tot %1%"
rent-extend: "Je kunt je huur verlengen door opnieuw op het bordje te klikken of gebruik te maken van /rs rent"
rent-extend: "Je kunt je huur verlengen door opnieuw op het bordje te klikken of gebruik te maken van /as rent"
rent-lowMoneyExtend: "Je hebt niet genoeg geld om de huur te verlengen (je hebt %0% van de %1%)"
rent-lowMoneyRent: "Je hebt niet genoeg geld om het gebied te huren (je hebt %0% van de %1%)"
rent-someoneElse: "Iemand anders heeft dit gebied al gehuurd"
@ -51,19 +51,13 @@ sell-soldYours: "Je gebied is verkocht"
sell-noPermission: "Je hebt geen toestemming om een gebied te verkopen"
sell-noPermissionOther: "Je hebt geen toestemming om een gebied van iemand anders te verkopen"
rentsigns-updated: "Alle bordjes voor de verhuur zijn geupdate"
rentsigns-notUpdated: "Niet alle bordjes zijn geupdate, een reload zou het op kunnen lossen"
rentsgins-noPermission: "Je hebt geen toestemming om alle verhuur bordjes te updaten"
rents-updated: "Alle borden en gebieden voor de verhuur zijn geupdate"
rents-notUpdated: "Niet alle borden zijn geupdate, een reload zou het op kunnen lossen"
rents-noPermission: "Je hebt geen toestemming om alle verhuur borden en gebieden te updaten"
buysigns-updated: "All bordjes voor de verkoop zijn geupdate"
buysigns-notUpdated: "Niet alle bordjes zijn geupdate, een reload zou het op kunnen lossen"
buysigns-noPermission: "Je hebt geen toestemming om alle verkoop bordjes te updaten"
rentregions-updated: "Alle verhuur gebieden zijn geupdate"
rentregions-noPermission: "Je hebt geen toestemming om de verhuur gebieden te updaten"
buyregions-updated: "Alle verkoop gebieden zijn geupdate"
buyregions-noPermission: "Je hebt geen toestemming om alle verkoop gebieden te updaten"
buys-updated: "Alle borden en gebieden voor de verkoop zijn geupdate"
buys-notUpdated: "Niet alle borden zijn geupdate, een reload zou het op kunnen lossen"
buys-noPermission: "Je hebt geen toestemming om alle verkoop borden en gebieden te updaten"
reload-reloaded: "De config is succesvol opnieuw ingeladen"
reload-noPermission: "Je hebt geen toestemming om de config opnieuw in te laden"
@ -81,12 +75,12 @@ info-sold: "Verkochte gebieden: %0%"
info-noSold: "Alle gebieden zijn verkocht"
info-forsale: "Gebieden te koop: %0%"
info-noForsale: "Alle gebieden zijn verkocht"
info-playerHelp: "/rs info player <naam>"
info-playerHelp: "/as info player <naam>"
info-playerRents: "Gebieden gehuurd door %0%: %1%"
info-playerNoRents: "%0% heeft geen gebied gehuurd"
info-playerBuys: "Gebieden gekocht door %0%: %1%"
info-playerNoBuys: "%0% heeft geen gebieden gekocht"
info-regionHelp: "/rs info region <naam>"
info-regionHelp: "/as info region <naam>"
info-regionNoRenting: "%0% is niet geregistreerd voor verhuur"
info-regionRenting: "&6Huur informatie voor %0%"
info-regionRentedBy: "Gehuurd door: %0% tot %1%"
@ -98,6 +92,8 @@ info-regionBoughtBy: "Gekocht door: %0%"
info-regionSign: "Plek van het bordje: wereld=%0%, X=%1%, Y=%2%, Z=%3%"
info-regionPriceDuration: "Prijs: %0% voor elke %1%"
info-regionPrice: "Prijs: %0%"
info-regionRestore: "Herstellen ingeschakeld: %0%"
info-regionRestoreProfile: "Herstel profiel: %0%"
help-header: "Help pagina, commando's die jij kunt uitvoeren"
help-alias: "Commando aliassen: /areashop, /as"
@ -109,8 +105,22 @@ help-unrent: "&6/as unrent &7-&r Stop de huur van een gebied"
help-unrentOwn: "&6/as unrent &7-&r Stop de huur van een eigen gebied"
help-sell: "&6/as sell &7-&r Verkoop een gebied"
help-sellOwn: "&6/as sell &7-&r Verkoop een eigen gebied"
help-updaterentsigns: "&6/as updaterentsigns &7-&r Update alle huur borden"
help-updatebuysigns: "&6/as updatebuysigns &7-&r Update alle koop borden"
help-updaterentregions: "&6/as updaterentregions &7-&r Update alle huur gebieden"
help-updatebuyregions: "&6/as updatebuyregions &7-&r Update alle koop gebieden"
help-reload: "&6/as reload &7-&r Herlaad de config en de taalbestanden"
help-updaterents: "&6/as updaterents &7-&r Update alle huur borden en gebieden"
help-updatebuys: "&6/as updatebuys &7-&r Update alle koop borden en gebieden"
help-reload: "&6/as reload &7-&r Herlaad de config en de taalbestanden"
help-rentrestore: "&6/as rentrestore &7-&r Laat dit huur gebied herstellen of niet"
help-buyrestore: "&6/as buyrestore &7-&r Laat dit koop gebied herstellen of niet"
rentrestore-help: "/as rentrestore <gebied> <true|false|general>"
rentrestore-noPermission: "Je hebt geen toestemming om herstel instellingen te veranderen bij een huur gebied"
rentrestore-notRegistered: "%0% is niet geregistreerd als een huur gebied"
rentrestore-invalidSetting: "'%0%' is geen goede optie, gebruik true, false of general"
rentrestore-success: "Succesvol de herstel optie gezet van %0% naar '%1%'"
rentrestore-successProfile: "Succesvol de herstel optie gezet van %0% naar '%1%' en het profiel naar '%2%'"
buyrestore-help: "/as buyrestore <gebied> <true|false|general>"
buyrestore-noPermission: "Je hebt geen toestemming om herstel instellingen te veranderen bij geen koop gebied"
buyrestore-notRegistered: "%0% is niet geregistreerd als een koop gebied"
buyrestore-invalidSetting: "'%0%' is geen goede optie, gebruik true, false of general
buyrestore-success: "Succesvol de herstel optie gezet van %0% naar '%1%'"
buyrestore-successProfile: "Succesvol de herstel optie gezet van %0% naar '%1%' en het profiel naar '%2%'"

View File

@ -1,7 +1,7 @@
name: AreaShop
main: nl.evolutioncoding.AreaShop.AreaShop
version: 1.0
depend: [Vault, WorldGuard]
version: 1.1
depend: [Vault, WorldGuard, WorldEdit]
commands:
AreaShop:
description: For all commands use /as help
@ -22,11 +22,11 @@ permissions:
areashop.buy: true
areashop.unrent: true
areashop.info: true
areashop.updaterentsigns: true
areashop.updatebuysigns: true
areashop.updaterentregions: true
areashop.updatebuyregions: true
areashop.updaterents: true
areashop.updatebuys: true
areashop.reload: true
areashop.rentrestore: true
areashop.buyrestore: true
areashop.help:
description: Allows you to see the help pages
default: true
@ -63,18 +63,18 @@ permissions:
areashop.info:
description: Allows you check the status of regions and players
default: true
areashop.updaterentsigns:
description: Allows you to update all rent signs
areashop.updaterents:
description: Allows you to update all rent signs and regions
default: op
areashop.updatebuysigns:
description: Allows you to update all buy signs
default: op
areashop.updaterentregions:
description: Allows you to update all rent regions
default: op
areashop.updatebuyregions:
description: Allows you to update all buy regions
areashop.updatebuys:
description: Allows you to update all buy signs and regions
default: op
areashop.reload:
description: Allows you to reload the config
default: op
areashop.rentrestore:
description: Allows you to change the restore settings of a rent
default: op
areashop.buyrestore:
description: Allows you to change the restore settings of a buy
default: op

View File

@ -14,6 +14,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
/**
@ -23,15 +24,18 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
public final class AreaShop extends JavaPlugin {
/* General variables */
private WorldGuardPlugin worldGuard = null;
private WorldEditPlugin worldEdit = null;
private Economy economy = null;
private ShopManager shopManager = null;
private FileManager fileManager = null;
private LanguageManager languageManager = null;
private boolean configOk = false;
private boolean debug = false;
private String chatprefix = null;
/* Folder where the language files will be stored */
/* Folders where the files will be stored */
public final String languageFolder = "lang";
public final String schematicFolder = "schem";
public final String schematicExtension = ".schematic";
/* Euro tag for in the config */
public final String currencyEuro = "%euro%";
@ -46,6 +50,8 @@ public final class AreaShop extends JavaPlugin {
public final String keyPlayer = "player";
public final String keyRentedUntil = "rented";
public final String keyName = "name";
public final String keyRestore = "restore";
public final String keySchemProfile = "profile";
/* Keys for replacing parts of flags */
public final String tagPlayerName = "%player%";
@ -54,6 +60,22 @@ public final class AreaShop extends JavaPlugin {
public final String tagDuration = "%duration%";
public final String tagRentedUntil = "%until%";
/* Enum for type of event */
public enum RegionEventType {
CREATED("Created"),
DELETED("Deleted"),
BOUGHT("Bought"),
SOLD("Sold");
private final String value;
private RegionEventType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
/**
@ -76,6 +98,15 @@ public final class AreaShop extends JavaPlugin {
} else {
worldGuard = (WorldGuardPlugin)plugin;
}
/* Check if WorldEdit is present */
plugin = getServer().getPluginManager().getPlugin("WorldEdit");
if (plugin == null || !(plugin instanceof WorldEditPlugin)) {
this.getLogger().info("Error: WorldEdit plugin is not present or has not loaded correctly");
error = true;
} else {
worldEdit = (WorldEditPlugin)plugin;
}
/* Check if Vault is present */
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
@ -93,10 +124,10 @@ public final class AreaShop extends JavaPlugin {
chatprefix = this.config().getString("chatPrefix");
/* Load all data from files */
shopManager = new ShopManager(this);
error = error & !shopManager.loadRents();
shopManager.checkRents();
error = error & !shopManager.loadBuys();
fileManager = new FileManager(this);
error = error & !fileManager.loadRents();
fileManager.checkRents();
error = error & !fileManager.loadBuys();
if(error) {
this.getLogger().info("The plugin has not started, fix the errors listed above");
@ -111,7 +142,7 @@ public final class AreaShop extends JavaPlugin {
new RentCheck(this).runTaskTimer(this, checkDelay, checkDelay);
/* Bind commands for this plugin */
getCommand("AreaShop").setExecutor(new ShopCommands(this));
getCommand("AreaShop").setExecutor(new CommandManager(this));
}
}
@ -123,7 +154,7 @@ public final class AreaShop extends JavaPlugin {
/* set variables to null to prevent memory leaks */
worldGuard = null;
economy = null;
shopManager = null;
fileManager = null;
languageManager = null;
configOk = false;
debug = false;
@ -137,6 +168,14 @@ public final class AreaShop extends JavaPlugin {
return worldGuard;
}
/**
* Function to get the WorldEdit plugin
* @return WorldEditPlugin
*/
public WorldEditPlugin getWorldEdit() {
return worldEdit;
}
/**
* Function to get the WorldGuard plugin
* @return WorldGuardPlugin
@ -154,11 +193,11 @@ public final class AreaShop extends JavaPlugin {
}
/**
* Method to get the ShopManager
* @return The shopManager
* Method to get the FileManager
* @return The fileManager
*/
public ShopManager getShopManager() {
return shopManager;
public FileManager getShopManager() {
return fileManager;
}
/**
@ -267,17 +306,17 @@ public final class AreaShop extends JavaPlugin {
} else if(target.hasPermission("areashop.sellown")) {
messages.add(languageManager.getLang("help-sellOwn"));
}
if(target.hasPermission("areashop.updaterentsigns")) {
messages.add(languageManager.getLang("help-updaterentsigns"));
if(target.hasPermission("areashop.updaterents")) {
messages.add(languageManager.getLang("help-updaterents"));
}
if(target.hasPermission("areashop.updatebuysigns")) {
messages.add(languageManager.getLang("help-updatebuysigns"));
if(target.hasPermission("areashop.updatebuys")) {
messages.add(languageManager.getLang("help-updatebuys"));
}
if(target.hasPermission("areashop.updaterentregions")) {
messages.add(languageManager.getLang("help-updaterentregions"));
if(target.hasPermission("areashop.setrentrestore")) {
messages.add(languageManager.getLang("help-rentrestore"));
}
if(target.hasPermission("areashop.updatebuyregions")) {
messages.add(languageManager.getLang("help-updatebuyregions"));
if(target.hasPermission("areashop.setbuyrestore")) {
messages.add(languageManager.getLang("help-buyrestore"));
}
if(target.hasPermission("areashop.reload")) {
messages.add(languageManager.getLang("help-reload"));
@ -438,7 +477,7 @@ public final class AreaShop extends JavaPlugin {
configOk = this.checkConfig();
chatprefix = this.config().getString("chatPrefix");
languageManager = new LanguageManager(this);
shopManager.checkRents();
fileManager.checkRents();
}
}

View File

@ -1,406 +1,471 @@
package nl.evolutioncoding.AreaShop;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ShopCommands implements CommandExecutor {
AreaShop plugin;
/**
* Constructor
* @param plugin The AreaShop plugin
*/
public ShopCommands(AreaShop plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
if(command.getName().equalsIgnoreCase("AreaShop")) {
ShopManager shopManager = plugin.getShopManager();
/* Commands with 1 argument or more */
if(args.length > 0 && args[0] != null) {
/* Help command */
if(args[0].equalsIgnoreCase("help")) {
plugin.showHelp(sender);
}
/* Renting command */
else if(args[0].equalsIgnoreCase("rent")) {
if (!(sender instanceof Player)) {
plugin.message(sender, "onlyByPlayer");
return true;
}
Player player = (Player)sender;
if(args.length > 1 && args[1] != null) {
shopManager.rent(player, args[1]);
} else {
plugin.message(sender, "rent-help");
}
}
/* Buying command */
else if(args[0].equalsIgnoreCase("buy")) {
if (!(sender instanceof Player)) {
plugin.message(sender, "onlyByPlayer");
return true;
}
Player player = (Player)sender;
if(args.length > 1 && args[1] != null) {
shopManager.buy(player, args[1]);
} else {
plugin.message(player, "buy-help");
}
}
/* Info command */
else if(args[0].equalsIgnoreCase("info")) {
if(args.length > 1 && args[1] != null) {
if(args[1].equalsIgnoreCase("all")) {
String message = "";
/* Message for rents */
Iterator<String> it = shopManager.getRents().keySet().iterator();
if(it.hasNext()) {
message = shopManager.getRent(it.next()).get(plugin.keyName);
while(it.hasNext()) {
message += ", " + shopManager.getRent(it.next()).get(plugin.keyName);
}
}
if(message.equals("")) {
plugin.message(sender, "info-all-noRents");
} else {
plugin.message(sender, "info-all-rents", message);
}
/* Message for buys */
it = shopManager.getBuys().keySet().iterator();
if(it.hasNext()) {
message = shopManager.getBuy(it.next()).get(plugin.keyName);
while(it.hasNext()) {
message += ", " + shopManager.getBuy(it.next()).get(plugin.keyName);
}
}
if(message.equals("")) {
plugin.message(sender, "info-all-noBuys");
} else {
plugin.message(sender, "info-all-buys", message);
}
}
else if(args[1].equalsIgnoreCase("rented")) {
String message = "";
Iterator<String> it = shopManager.getRents().keySet().iterator();
boolean first = true;
while(it.hasNext()) {
String next = shopManager.getRent(it.next()).get(plugin.keyName);
if(shopManager.getRent(next).get(plugin.keyPlayer) != null) {
if(!first) {
message += ", " + next;
} else {
first = false;
message = next;
}
}
}
if(message.equals("")) {
plugin.message(sender, "info-noRented");
} else {
plugin.message(sender, "info-rented", message);
}
} else if(args[1].equalsIgnoreCase("forrent")) {
String message = "";
Iterator<String> it = shopManager.getRents().keySet().iterator();
boolean first = true;
while(it.hasNext()) {
String next = shopManager.getRent(it.next()).get(plugin.keyName);
if(shopManager.getRent(next).get(plugin.keyPlayer) == null) {
if(!first) {
message += ", " + next;
} else {
first = false;
message = next;
}
}
}
if(message.equals("")) {
plugin.message(sender, "info-noUnrented");
} else {
plugin.message(sender, "info-unrented", message);
}
} else if(args[1].equalsIgnoreCase("sold")) {
String message = "";
Iterator<String> it = shopManager.getBuys().keySet().iterator();
boolean first = true;
while(it.hasNext()) {
String next = shopManager.getBuy(it.next()).get(plugin.keyName);
if(shopManager.getBuy(next).get(plugin.keyPlayer) != null) {
if(!first) {
message += ", ";
} else {
first = false;
}
message += next;
}
}
if(message.equals("")) {
plugin.message(sender, "info-noSold");
} else {
plugin.message(sender, "info-sold", message);
}
} else if(args[1].equalsIgnoreCase("forsale")) {
String message = "";
Iterator<String> it = shopManager.getBuys().keySet().iterator();
boolean first = true;
while(it.hasNext()) {
String next = shopManager.getBuy(it.next()).get(plugin.keyName);
if(shopManager.getBuy(next).get(plugin.keyPlayer) == null) {
if(!first) {
message += ", " + next;
} else {
first = false;
message = next;
}
}
}
if(message.equals("")) {
plugin.message(sender, "info-noForsale");
} else {
plugin.message(sender, "info-forsale", message);
}
} else if(args[1].equalsIgnoreCase("player")) {
if(args.length > 2 && args[2] != null) {
String message = "";
Iterator<String> it = shopManager.getRents().keySet().iterator();
boolean first = true;
while(it.hasNext()) {
String next = shopManager.getRent(it.next()).get(plugin.keyName);
if(shopManager.getRent(next).get(plugin.keyPlayer) != null && shopManager.getRent(next).get(plugin.keyPlayer).equalsIgnoreCase(args[2])) {
if(!first) {
message += ", " + next;
} else {
first = false;
message = next;
}
}
}
if(message.equals("")) {
plugin.message(sender, "info-playerNoRents", args[2]);
} else {
plugin.message(sender, "info-playerRents", args[2], message);
}
message = "";
it = shopManager.getBuys().keySet().iterator();
first = true;
while(it.hasNext()) {
String next = shopManager.getBuy(it.next()).get(plugin.keyName);
if(shopManager.getBuy(next).get(plugin.keyPlayer) != null && shopManager.getBuy(next).get(plugin.keyPlayer).equalsIgnoreCase(args[2])) {
if(!first) {
message += ", ";
} else {
first = false;
}
message += next;
}
}
if(message.equals("")) {
plugin.message(sender, "info-playerNoBuys", args[2]);
} else {
plugin.message(sender, "info-playerBuys", args[2], message);
}
} else {
plugin.message(sender, "info-playerHelp");
}
} else if(args[1].equalsIgnoreCase("region")) {
if(args.length > 2 && args[2] != null) {
HashMap<String,String> rent = shopManager.getRent(args[2]);
HashMap<String,String> buy = shopManager.getBuy(args[2]);
if(rent == null) {
plugin.message(sender, "info-regionRenting", args[2]);
plugin.message(sender, "info-regionNoRenting", args[2]);
} else {
plugin.message(sender, "info-regionRenting", rent.get(plugin.keyName));
plugin.message(sender, "info-regionSign", rent.get(plugin.keyWorld), rent.get(plugin.keyX), rent.get(plugin.keyY), rent.get(plugin.keyZ));
plugin.message(sender, "info-regionPriceDuration", plugin.getCurrencyCharacter() + rent.get(plugin.keyPrice), rent.get(plugin.keyDuration));
if(rent.get(plugin.keyPlayer) == null) {
plugin.message(sender, "info-regionNotRented");
} else {
SimpleDateFormat dateFull = new SimpleDateFormat("dd MMMMMMMMMMMMMMMMM yyyy HH:mm");
plugin.message(sender, "info-regionRentedBy", rent.get(plugin.keyPlayer), dateFull.format(Long.parseLong(rent.get(plugin.keyRentedUntil))));
}
}
if(buy == null) {
plugin.message(sender, "info-regionBuying", args[2]);
plugin.message(sender, "info-regionNoBuying", args[2]);
} else {
plugin.message(sender, "info-regionBuying", buy.get(plugin.keyName));
plugin.message(sender, "info-regionSign", buy.get(plugin.keyWorld), buy.get(plugin.keyX), buy.get(plugin.keyY), buy.get(plugin.keyZ));
plugin.message(sender, "info-regionPrice", plugin.getCurrencyCharacter() + buy.get(plugin.keyPrice));
if(buy.get(plugin.keyPlayer) == null) {
plugin.message(sender, "info-regionNotBought");
} else {
plugin.message(sender, "info-regionBoughtBy", buy.get(plugin.keyPlayer));
}
}
} else {
plugin.message(sender, "info-regionHelp");
}
} else {
plugin.message(sender, "info-help");
}
} else {
plugin.message(sender, "info-help");
}
}
/* Unrenting command */
else if(args[0].equalsIgnoreCase("unrent")) {
if(args.length > 1 && args[1] != null) {
HashMap<String,String> rent = shopManager.getRent(args[1]);
if(rent == null) {
plugin.message(sender, "unrent-notRegistered");
} else {
if(rent.get(plugin.keyPlayer) == null) {
plugin.message(sender, "unrent-notRented");
} else {
if(sender.hasPermission("areashop.unrent")) {
plugin.message(sender, "unrent-other", rent.get(plugin.keyPlayer));
shopManager.unRent(args[1]);
} else {
if(sender.hasPermission("areashop.unrentown")) {
if(rent.get(plugin.keyPlayer).equals(sender.getName())) {
plugin.message(sender, "unrent-unrented");
shopManager.unRent(args[1]);
} else {
plugin.message(sender, "unrent-noPermissionOther");
}
} else {
plugin.message(sender, "unrent-noPermission");
}
}
}
}
} else {
plugin.message(sender, "unrent-help");
}
}
/* Selling command */
else if(args[0].equalsIgnoreCase("sell")) {
if(args.length > 1 && args[1] != null) {
HashMap<String,String> buy = shopManager.getBuy(args[1]);
if(buy == null) {
plugin.message(sender, "sell-notRegistered");
} else {
if(buy.get(plugin.keyPlayer) == null) {
plugin.message(sender, "sell-notBought");
} else {
if(sender.hasPermission("areashop.sell")) {
plugin.message(sender, "sell-sold", buy.get(plugin.keyPlayer));
shopManager.unBuy(args[1]);
} else {
if(sender.hasPermission("areashop.sellown")) {
if(buy.get(plugin.keyPlayer).equals(sender.getName())) {
plugin.message(sender, "sell-soldYours");
shopManager.unBuy(args[1]);
} else {
plugin.message(sender, "sell-noPermissionOther");
}
} else {
plugin.message(sender, "sell-noPermission");
}
}
}
}
} else {
plugin.message(sender, "sell-help");
}
}
/* UpdateRentSigns command */
else if(args[0].equalsIgnoreCase("updaterentsigns")) {
if(sender.hasPermission("areashop.updaterentsigns")) {
boolean result = plugin.getShopManager().updateRentSigns();
if(result) {
plugin.message(sender, "rentsigns-updated");
} else {
plugin.message(sender, "rentsigns-notUpdated");
}
} else {
plugin.message(sender, "rentsigns-noPermission");
}
}
/* UpdateBuySigns command */
else if(args[0].equalsIgnoreCase("updatebuysigns")) {
if(sender.hasPermission("areashop.updatebuysigns")) {
boolean result = plugin.getShopManager().updateBuySigns();
if(result) {
plugin.message(sender, "buysigns-updated");
} else {
plugin.message(sender, "buysigns-notUpdated");
}
} else {
plugin.message(sender, "buysigns-noPermission");
}
}
/* updaterentregions command */
else if(args[0].equalsIgnoreCase("updaterentregions")) {
if(sender.hasPermission("areashop.updaterentregions")) {
plugin.getShopManager().updateRentRegions();
plugin.message(sender, "rentregions-updated");
} else {
plugin.message(sender, "rentregions-noPermission");
}
}
/* updatebuyregions command */
else if(args[0].equalsIgnoreCase("updatebuyregions")) {
if(sender.hasPermission("areashop.updatebuyregions")) {
plugin.getShopManager().updateBuyRegions();
plugin.message(sender, "buyregions-updated");
} else {
plugin.message(sender, "buyregions-noPermission");
}
}
/* reload command */
else if(args[0].equalsIgnoreCase("reload")) {
if(sender.hasPermission("areashop.reload")) {
plugin.reload();
plugin.message(sender, "reload-reloaded");
} else {
plugin.message(sender, "reload-noPermission");
}
}
/* Not a valid command */
else {
plugin.message(sender, "cmd-notValid");
}
} else {
plugin.showHelp(sender);
}
return true;
}
return false;
}
}
package nl.evolutioncoding.AreaShop;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandManager implements CommandExecutor {
AreaShop plugin;
/**
* Constructor
* @param plugin The AreaShop plugin
*/
public CommandManager(AreaShop plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
if(command.getName().equalsIgnoreCase("AreaShop")) {
FileManager fileManager = plugin.getShopManager();
/* Commands with 1 argument or more */
if(args.length > 0 && args[0] != null) {
/* Help command */
if(args[0].equalsIgnoreCase("help")) {
plugin.showHelp(sender);
}
/* Renting command */
else if(args[0].equalsIgnoreCase("rent")) {
if (!(sender instanceof Player)) {
plugin.message(sender, "onlyByPlayer");
return true;
}
Player player = (Player)sender;
if(args.length > 1 && args[1] != null) {
fileManager.rent(player, args[1]);
} else {
plugin.message(sender, "rent-help");
}
}
/* Buying command */
else if(args[0].equalsIgnoreCase("buy")) {
if (!(sender instanceof Player)) {
plugin.message(sender, "onlyByPlayer");
return true;
}
Player player = (Player)sender;
if(args.length > 1 && args[1] != null) {
fileManager.buy(player, args[1]);
} else {
plugin.message(player, "buy-help");
}
}
/* Info command */
else if(args[0].equalsIgnoreCase("info")) {
if(args.length > 1 && args[1] != null) {
if(args[1].equalsIgnoreCase("all")) {
String message = "";
/* Message for rents */
Iterator<String> it = fileManager.getRents().keySet().iterator();
if(it.hasNext()) {
message = fileManager.getRent(it.next()).get(plugin.keyName);
while(it.hasNext()) {
message += ", " + fileManager.getRent(it.next()).get(plugin.keyName);
}
}
if(message.equals("")) {
plugin.message(sender, "info-all-noRents");
} else {
plugin.message(sender, "info-all-rents", message);
}
/* Message for buys */
it = fileManager.getBuys().keySet().iterator();
if(it.hasNext()) {
message = fileManager.getBuy(it.next()).get(plugin.keyName);
while(it.hasNext()) {
message += ", " + fileManager.getBuy(it.next()).get(plugin.keyName);
}
}
if(message.equals("")) {
plugin.message(sender, "info-all-noBuys");
} else {
plugin.message(sender, "info-all-buys", message);
}
}
else if(args[1].equalsIgnoreCase("rented")) {
String message = "";
Iterator<String> it = fileManager.getRents().keySet().iterator();
boolean first = true;
while(it.hasNext()) {
String next = fileManager.getRent(it.next()).get(plugin.keyName);
if(fileManager.getRent(next).get(plugin.keyPlayer) != null) {
if(!first) {
message += ", " + next;
} else {
first = false;
message = next;
}
}
}
if(message.equals("")) {
plugin.message(sender, "info-noRented");
} else {
plugin.message(sender, "info-rented", message);
}
} else if(args[1].equalsIgnoreCase("forrent")) {
String message = "";
Iterator<String> it = fileManager.getRents().keySet().iterator();
boolean first = true;
while(it.hasNext()) {
String next = fileManager.getRent(it.next()).get(plugin.keyName);
if(fileManager.getRent(next).get(plugin.keyPlayer) == null) {
if(!first) {
message += ", " + next;
} else {
first = false;
message = next;
}
}
}
if(message.equals("")) {
plugin.message(sender, "info-noUnrented");
} else {
plugin.message(sender, "info-unrented", message);
}
} else if(args[1].equalsIgnoreCase("sold")) {
String message = "";
Iterator<String> it = fileManager.getBuys().keySet().iterator();
boolean first = true;
while(it.hasNext()) {
String next = fileManager.getBuy(it.next()).get(plugin.keyName);
if(fileManager.getBuy(next).get(plugin.keyPlayer) != null) {
if(!first) {
message += ", ";
} else {
first = false;
}
message += next;
}
}
if(message.equals("")) {
plugin.message(sender, "info-noSold");
} else {
plugin.message(sender, "info-sold", message);
}
} else if(args[1].equalsIgnoreCase("forsale")) {
String message = "";
Iterator<String> it = fileManager.getBuys().keySet().iterator();
boolean first = true;
while(it.hasNext()) {
String next = fileManager.getBuy(it.next()).get(plugin.keyName);
if(fileManager.getBuy(next).get(plugin.keyPlayer) == null) {
if(!first) {
message += ", " + next;
} else {
first = false;
message = next;
}
}
}
if(message.equals("")) {
plugin.message(sender, "info-noForsale");
} else {
plugin.message(sender, "info-forsale", message);
}
} else if(args[1].equalsIgnoreCase("player")) {
if(args.length > 2 && args[2] != null) {
String message = "";
Iterator<String> it = fileManager.getRents().keySet().iterator();
boolean first = true;
while(it.hasNext()) {
String next = fileManager.getRent(it.next()).get(plugin.keyName);
if(fileManager.getRent(next).get(plugin.keyPlayer) != null && fileManager.getRent(next).get(plugin.keyPlayer).equalsIgnoreCase(args[2])) {
if(!first) {
message += ", " + next;
} else {
first = false;
message = next;
}
}
}
if(message.equals("")) {
plugin.message(sender, "info-playerNoRents", args[2]);
} else {
plugin.message(sender, "info-playerRents", args[2], message);
}
message = "";
it = fileManager.getBuys().keySet().iterator();
first = true;
while(it.hasNext()) {
String next = fileManager.getBuy(it.next()).get(plugin.keyName);
if(fileManager.getBuy(next).get(plugin.keyPlayer) != null && fileManager.getBuy(next).get(plugin.keyPlayer).equalsIgnoreCase(args[2])) {
if(!first) {
message += ", ";
} else {
first = false;
}
message += next;
}
}
if(message.equals("")) {
plugin.message(sender, "info-playerNoBuys", args[2]);
} else {
plugin.message(sender, "info-playerBuys", args[2], message);
}
} else {
plugin.message(sender, "info-playerHelp");
}
} else if(args[1].equalsIgnoreCase("region")) {
if(args.length > 2 && args[2] != null) {
HashMap<String,String> rent = fileManager.getRent(args[2]);
HashMap<String,String> buy = fileManager.getBuy(args[2]);
if(rent == null) {
plugin.message(sender, "info-regionRenting", args[2]);
plugin.message(sender, "info-regionNoRenting", args[2]);
} else {
plugin.message(sender, "info-regionRenting", rent.get(plugin.keyName));
plugin.message(sender, "info-regionSign", rent.get(plugin.keyWorld), rent.get(plugin.keyX), rent.get(plugin.keyY), rent.get(plugin.keyZ));
plugin.message(sender, "info-regionPriceDuration", plugin.getCurrencyCharacter() + rent.get(plugin.keyPrice), rent.get(plugin.keyDuration));
if(rent.get(plugin.keyPlayer) == null) {
plugin.message(sender, "info-regionNotRented");
} else {
SimpleDateFormat dateFull = new SimpleDateFormat("dd MMMMMMMMMMMMMMMMM yyyy HH:mm");
plugin.message(sender, "info-regionRentedBy", rent.get(plugin.keyPlayer), dateFull.format(Long.parseLong(rent.get(plugin.keyRentedUntil))));
}
if(sender.hasPermission("areashop.rentrestore")) {
plugin.message(sender, "info-regionRestore", rent.get(plugin.keyRestore));
plugin.message(sender, "info-regionRestoreProfile", rent.get(plugin.keySchemProfile));
}
}
if(buy == null) {
plugin.message(sender, "info-regionBuying", args[2]);
plugin.message(sender, "info-regionNoBuying", args[2]);
} else {
plugin.message(sender, "info-regionBuying", buy.get(plugin.keyName));
plugin.message(sender, "info-regionSign", buy.get(plugin.keyWorld), buy.get(plugin.keyX), buy.get(plugin.keyY), buy.get(plugin.keyZ));
plugin.message(sender, "info-regionPrice", plugin.getCurrencyCharacter() + buy.get(plugin.keyPrice));
if(buy.get(plugin.keyPlayer) == null) {
plugin.message(sender, "info-regionNotBought");
} else {
plugin.message(sender, "info-regionBoughtBy", buy.get(plugin.keyPlayer));
}
if(sender.hasPermission("areashop.buyrestore")) {
plugin.message(sender, "info-regionRestore", buy.get(plugin.keyRestore));
plugin.message(sender, "info-regionRestoreProfile", buy.get(plugin.keySchemProfile));
}
}
} else {
plugin.message(sender, "info-regionHelp");
}
} else {
plugin.message(sender, "info-help");
}
} else {
plugin.message(sender, "info-help");
}
}
/* Unrenting command */
else if(args[0].equalsIgnoreCase("unrent")) {
if(args.length > 1 && args[1] != null) {
HashMap<String,String> rent = fileManager.getRent(args[1]);
if(rent == null) {
plugin.message(sender, "unrent-notRegistered");
} else {
if(rent.get(plugin.keyPlayer) == null) {
plugin.message(sender, "unrent-notRented");
} else {
if(sender.hasPermission("areashop.unrent")) {
plugin.message(sender, "unrent-other", rent.get(plugin.keyPlayer));
fileManager.unRent(args[1]);
} else {
if(sender.hasPermission("areashop.unrentown")) {
if(rent.get(plugin.keyPlayer).equals(sender.getName())) {
plugin.message(sender, "unrent-unrented");
fileManager.unRent(args[1]);
} else {
plugin.message(sender, "unrent-noPermissionOther");
}
} else {
plugin.message(sender, "unrent-noPermission");
}
}
}
}
} else {
plugin.message(sender, "unrent-help");
}
}
/* Selling command */
else if(args[0].equalsIgnoreCase("sell")) {
if(args.length > 1 && args[1] != null) {
HashMap<String,String> buy = fileManager.getBuy(args[1]);
if(buy == null) {
plugin.message(sender, "sell-notRegistered");
} else {
if(buy.get(plugin.keyPlayer) == null) {
plugin.message(sender, "sell-notBought");
} else {
if(sender.hasPermission("areashop.sell")) {
plugin.message(sender, "sell-sold", buy.get(plugin.keyPlayer));
fileManager.unBuy(args[1]);
} else {
if(sender.hasPermission("areashop.sellown")) {
if(buy.get(plugin.keyPlayer).equals(sender.getName())) {
plugin.message(sender, "sell-soldYours");
fileManager.unBuy(args[1]);
} else {
plugin.message(sender, "sell-noPermissionOther");
}
} else {
plugin.message(sender, "sell-noPermission");
}
}
}
}
} else {
plugin.message(sender, "sell-help");
}
}
/* UpdateRents command */
else if(args[0].equalsIgnoreCase("updaterents")) {
if(sender.hasPermission("areashop.updaterents")) {
boolean result = plugin.getShopManager().updateRentSigns();
plugin.getShopManager().updateRentRegions();
if(result) {
plugin.message(sender, "rents-updated");
} else {
plugin.message(sender, "rents-notUpdated");
}
} else {
plugin.message(sender, "rents-noPermission");
}
}
/* UpdateBuys command */
else if(args[0].equalsIgnoreCase("updatebuys")) {
if(sender.hasPermission("areashop.updatebuys")) {
boolean result = plugin.getShopManager().updateBuySigns();
if(result) {
plugin.message(sender, "buys-updated");
} else {
plugin.message(sender, "buys-notUpdated");
}
} else {
plugin.message(sender, "buys-noPermission");
}
}
/* setRentRestore command*/
else if(args[0].equalsIgnoreCase("rentrestore")) {
if(sender.hasPermission("areashop.rentrestore")) {
if(args.length > 2 && args[1] != null && args[2] != null) {
HashMap<String,String> rent = fileManager.getRent(args[1]);
if(rent == null) {
plugin.message(sender, "rentrestore-notRegistered", args[1]);
} else {
String value = null;
if(args[2].equalsIgnoreCase("true")) {
rent.put(plugin.keyRestore, "true");
value = "true";
} else if(args[2].equalsIgnoreCase("false")) {
rent.put(plugin.keyRestore, "false");
value = "false";
} else if(args[2].equalsIgnoreCase("general")) {
rent.put(plugin.keyRestore, "general");
value = "general";
} else {
plugin.message(sender, "rentrestore-invalidSetting", args[2]);
}
if(value != null) {
if(args.length > 3) {
rent.put(plugin.keySchemProfile, args[3]);
plugin.message(sender, "rentrestore-successProfile", rent.get(plugin.keyName), value, args[3]);
} else {
plugin.message(sender, "rentrestore-success", rent.get(plugin.keyName), value);
}
fileManager.saveRents();
}
}
} else {
plugin.message(sender, "rentrestore-help");
}
} else {
plugin.message(sender, "rentrestore-noPermission");
}
}
/* setBuyRestore command*/
else if(args[0].equalsIgnoreCase("buyrestore")) {
if(sender.hasPermission("areashop.buyrestore")) {
if(args.length > 2 && args[1] != null && args[2] != null) {
HashMap<String,String> buy = fileManager.getBuy(args[1]);
if(buy == null) {
plugin.message(sender, "buyrestore-notRegistered", args[1]);
} else {
String value = null;
if(args[2].equalsIgnoreCase("true")) {
buy.put(plugin.keyRestore, "true");
value = "true";
} else if(args[2].equalsIgnoreCase("false")) {
buy.put(plugin.keyRestore, "false");
value = "false";
} else if(args[2].equalsIgnoreCase("general")) {
buy.put(plugin.keyRestore, "general");
value = "general";
} else {
plugin.message(sender, "buyrestore-invalidSetting", args[2]);
}
if(value != null) {
if(args.length > 3) {
buy.put(plugin.keySchemProfile, args[3]);
plugin.message(sender, "buyrestore-successProfile", buy.get(plugin.keyName), value, args[3]);
} else {
plugin.message(sender, "buyrestore-success", buy.get(plugin.keyName), value);
}
fileManager.saveBuys();
}
}
} else {
plugin.message(sender, "buyrestore-help");
}
} else {
plugin.message(sender, "buyrestore-noPermission");
}
}
/* reload command */
else if(args[0].equalsIgnoreCase("reload")) {
if(sender.hasPermission("areashop.reload")) {
plugin.reload();
plugin.message(sender, "reload-reloaded");
} else {
plugin.message(sender, "reload-noPermission");
}
}
/* Not a valid command */
else {
plugin.message(sender, "cmd-notValid");
}
} else {
plugin.showHelp(sender);
}
return true;
}
return false;
}
}

View File

@ -2,6 +2,8 @@ package nl.evolutioncoding.AreaShop;
import java.util.HashMap;
import nl.evolutioncoding.AreaShop.AreaShop.RegionEventType;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
@ -46,7 +48,9 @@ public final class SignBreakListener implements Listener {
&& rent.get(plugin.keyZ).equals(String.valueOf(block.getZ())) ) {
/* Remove the rent if the player has permission */
if(event.getPlayer().hasPermission("areashop.destroyrent")) {
plugin.getShopManager().handleSchematicEvent(sign.getLine(1), true, RegionEventType.DELETED);
boolean result = plugin.getShopManager().removeRent(sign.getLine(1));
if(result) {
event.getPlayer().sendMessage(plugin.fixColors(plugin.config().getString("chatPrefix")) + "Renting of the region succesfully removed");
}
@ -60,6 +64,7 @@ public final class SignBreakListener implements Listener {
&& buy.get(plugin.keyZ).equals(String.valueOf(block.getZ())) ) {
/* Remove the buy if the player has permission */
if(event.getPlayer().hasPermission("areashop.destroybuy")) {
plugin.getShopManager().handleSchematicEvent(sign.getLine(1), false, RegionEventType.DELETED);
boolean result = plugin.getShopManager().removeBuy(sign.getLine(1));
if(result) {
event.getPlayer().sendMessage(plugin.fixColors(plugin.config().getString("chatPrefix")) + "Buying of the region succesfully removed");

View File

@ -2,6 +2,8 @@ package nl.evolutioncoding.AreaShop;
import java.util.HashMap;
import nl.evolutioncoding.AreaShop.AreaShop.RegionEventType;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.EventHandler;
@ -95,7 +97,7 @@ public final class SignChangeListener implements Listener {
event.setLine(1, regionManager.getRegion(secondLine).getId());
event.setLine(3, plugin.getCurrencyCharacter() + fourthLine);
/* Add rent to the ShopManager */
/* Add rent to the FileManager */
HashMap<String,String> rent = new HashMap<String,String>();
rent.put(plugin.keyWorld, event.getBlock().getWorld().getName());
rent.put(plugin.keyX, String.valueOf(event.getBlock().getX()));
@ -104,7 +106,11 @@ public final class SignChangeListener implements Listener {
rent.put(plugin.keyDuration, thirdLine);
rent.put(plugin.keyPrice, fourthLine);
rent.put(plugin.keyName, regionManager.getRegion(secondLine).getId());
rent.put(plugin.keyRestore, "general");
rent.put(plugin.keySchemProfile, "default");
plugin.getShopManager().addRent(secondLine, rent);
plugin.getShopManager().handleSchematicEvent(secondLine, true, RegionEventType.CREATED);
/* Set the flags for the region */
plugin.getShopManager().setRegionFlags(secondLine, plugin.config().getConfigurationSection("flagsForRent"), true);
@ -152,7 +158,7 @@ public final class SignChangeListener implements Listener {
event.setLine(1, regionManager.getRegion(secondLine).getId());
event.setLine(2, plugin.getCurrencyCharacter() + thirdLine);
/* Add buy to the ShopManager */
/* Add buy to the FileManager */
HashMap<String,String> buy = new HashMap<String,String>();
buy.put(plugin.keyWorld, event.getBlock().getWorld().getName());
buy.put(plugin.keyX, String.valueOf(event.getBlock().getX()));
@ -160,7 +166,11 @@ public final class SignChangeListener implements Listener {
buy.put(plugin.keyZ, String.valueOf(event.getBlock().getZ()));
buy.put(plugin.keyPrice, thirdLine);
buy.put(plugin.keyName, regionManager.getRegion(secondLine).getId());
buy.put(plugin.keyRestore, "general");
buy.put(plugin.keySchemProfile, "default");
plugin.getShopManager().addBuy(secondLine, buy);
plugin.getShopManager().handleSchematicEvent(secondLine, false, RegionEventType.CREATED);
/* Set the flags for the region */
plugin.getShopManager().setRegionFlags(secondLine, plugin.config().getConfigurationSection("flagsForSale"), false);