mirror of
https://github.com/md5sha256/AreaShop.git
synced 2026-11-06 17:32:43 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d254e17bb | ||
|
|
2098b9f4e3 | ||
|
|
95e3a4a120 | ||
|
|
9269279d44 | ||
|
|
d8fbeaf53a | ||
|
|
6886db8edc | ||
|
|
05df539189 | ||
|
|
f20c573b06 | ||
|
|
793e3dfd1b | ||
|
|
d7eff6c0df | ||
|
|
911115213f | ||
|
|
beeef8c757 | ||
|
|
60bdd50ab6 | ||
|
|
b5ba813410 | ||
|
|
7de0b34b3b | ||
|
|
b5077215ec | ||
|
|
98c45866a3 | ||
|
|
a96101519a | ||
|
|
fc18819a95 | ||
|
|
6dd0750bea | ||
|
|
36b73f57fd | ||
|
|
b111110251 | ||
|
|
555f648dfe | ||
|
|
4ac4c9ae35 | ||
|
|
97fe92588c | ||
|
|
8fc03b21f0 | ||
|
|
a74643d724 | ||
|
|
c309cbbbae | ||
|
|
73ceee6f27 | ||
|
|
9c57f434db | ||
|
|
f41e614d38 | ||
|
|
4fa1267971 | ||
|
|
e99ca02bcb | ||
|
|
3479bcd0d8 | ||
|
|
c0cd528f0e | ||
|
|
14f379f7c6 | ||
|
|
73c1f88d8c | ||
|
|
1bbca09fc6 | ||
|
|
8219269fbb | ||
|
|
bf283d52b6 | ||
|
|
def6005b92 | ||
|
|
62934ceab6 | ||
|
|
9124de9bb0 | ||
|
|
d5da1bb012 | ||
|
|
99d4cdb685 | ||
|
|
b3ea7f7e73 | ||
|
|
24ee8df215 | ||
|
|
63e8f10e20 | ||
|
|
7c03041ae1 | ||
|
|
fb03baf3ad | ||
|
|
c1ef15193c | ||
|
|
c1e89ef75e | ||
|
|
56a35d373b | ||
|
|
5aff3f1ce6 | ||
|
|
6a4b8f9d9a | ||
|
|
ef4b599897 | ||
|
|
a04b96d452 | ||
|
|
0728ce672d | ||
|
|
c42e1ccbe5 | ||
|
|
dfcd896cab | ||
|
|
69ee2d5c7f | ||
|
|
b42bb38e5f | ||
|
|
418b736fae | ||
|
|
bed4bbac23 | ||
|
|
f13534ae33 | ||
|
|
3b1522bad8 | ||
|
|
2995b59070 | ||
|
|
0e46f01150 |
No files matched your search
@@ -1,2 +0,0 @@
|
||||
/.project
|
||||
/.classpath
|
||||
@@ -1 +0,0 @@
|
||||
/org.eclipse.jdt.core.prefs
|
||||
@@ -1 +0,0 @@
|
||||
/nl
|
||||
+177
-47
@@ -2,63 +2,193 @@
|
||||
# config.yml of the AreaShop plugin #
|
||||
# This plugin has been created by NLThijs48 #
|
||||
# Check the server minecraft.go-craft.com #
|
||||
# and then the Prison server for a demo #
|
||||
# and then the Survival server for a demo #
|
||||
##############################################
|
||||
|
||||
########## GENERAL ##########
|
||||
## Chatprefix used for all messages in the chat
|
||||
## Chatprefix used for all messages in the chat. Also check the 'greeting' lines in the 'flagProfiles' section,
|
||||
## these also contain the prefix and you may want to change those to
|
||||
chatPrefix: '&2[AreaShop]&r '
|
||||
## The character used for the prices of regions, for the euro character use '%euro%'
|
||||
## The characters used for the prices of regions, will appear before the number, for the euro character use '%euro%'
|
||||
moneyCharacter: '$'
|
||||
## The characters used after a currency number, '%euro%' will become the euro character
|
||||
moneyCharacterAfter: ''
|
||||
## Enables / disables debug messages in the console, no need to change
|
||||
debug: false
|
||||
## The .yml language file that should be used, provided by this plugin: EN, NL
|
||||
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
|
||||
## Maximum number of locations the teleport function should check to find a safe spot
|
||||
maximumTries: 50000
|
||||
## Enable sending stats to http://mcstats.org/ (Metrics plugin)
|
||||
sendStats: true
|
||||
## Use colors when sending messages to console and log files
|
||||
useColorsInConsole: false
|
||||
## Post error messages in the console when a command run from the config fails (from the 'runCommands' section for example)
|
||||
postCommandErrors: true
|
||||
## Version of the config, do not change!
|
||||
version: 2.0.0
|
||||
## The different tags you can write on the sign to trigger the plugin
|
||||
signTags:
|
||||
## Tag for adding a rent region
|
||||
rent: '[rent]'
|
||||
## Tag for adding a buy region
|
||||
buy: '[buy]'
|
||||
## Tag for adding a sign to an existing region
|
||||
add: '[as]'
|
||||
## Configure the max total regions, max rent regions and max buy regions with different groups (-1 is unlimited)
|
||||
## Assign a group to players by giving them the permission 'areashop.limits.<group>'
|
||||
## Every player already has the group 'default' and ops have the unlimited group
|
||||
## If a player has multiple groups the highest numbers are used
|
||||
limitGroups:
|
||||
default:
|
||||
total: 1
|
||||
rents: 1
|
||||
buys: 1
|
||||
unlimited:
|
||||
total: -1
|
||||
rents: -1
|
||||
buys: -1
|
||||
## Below are profiles for the signs, you can assign profiles to regions
|
||||
## by setting 'general.signProfile' in default.yml, groups or individual regions
|
||||
signProfiles:
|
||||
default:
|
||||
## Below is the format for each sign state, the following tags can be used for signs and commands:
|
||||
## %region%, %player%, %uuid%, %price%, %duration%, %world%, %type%, %until%, %untilshort%
|
||||
## The following sections can be added for performing certain commands when the sign is clicked:
|
||||
## rightClickPlayer, rightClickConsole, shiftRightClickPlayer, shiftRightClickConsole,
|
||||
## leftClickPlayer, leftClickConsole, shiftLeftClickPlayer, shiftLeftClickConsole
|
||||
## Sections with 'Player' at the end will be run by the clicking player and 'Console' ones from the console
|
||||
forrent:
|
||||
line1: '&2&l[For Rent]'
|
||||
line2: '%region%'
|
||||
line3: '%duration%'
|
||||
line4: '%price%'
|
||||
rightClickPlayer:
|
||||
- 'as rent %region%'
|
||||
leftClickPlayer:
|
||||
- 'as info region %region%'
|
||||
rented:
|
||||
line1: '&4&l[Rented]'
|
||||
line2: '%region%'
|
||||
line3: '%player%'
|
||||
line4: '%untilshort%'
|
||||
rightClickPlayer:
|
||||
- 'as rent %region%'
|
||||
leftClickPlayer:
|
||||
- 'as info region %region%'
|
||||
shiftRightClickPlayer:
|
||||
- 'as unrent %region%'
|
||||
forsale:
|
||||
line1: '&2&l[For Sale]'
|
||||
line2: '%region%'
|
||||
line3: '%price%'
|
||||
line4:
|
||||
rightClickPlayer:
|
||||
- 'as buy %region%'
|
||||
leftClickPlayer:
|
||||
- 'as info region %region%'
|
||||
sold:
|
||||
line1: '&4&l[Sold]'
|
||||
line2: '%region%'
|
||||
line3: '%player%'
|
||||
line4:
|
||||
rightClickPlayer:
|
||||
- 'as buy %region%'
|
||||
leftClickPlayer:
|
||||
- 'as info region %region%'
|
||||
shiftRightClickPlayer:
|
||||
- 'as sell %region%'
|
||||
## Option to run certain commands when one of these events happen
|
||||
## Commands at a 'before' section will execute before the region details are changed in the AreaShop system
|
||||
## and before any other actions occurred (changing signs, saving/loading schematics, etc.),
|
||||
## the 'after' commands will be run when all changes are done.
|
||||
## After 'before' or 'after' you can create a list of commands (see example at the created event)
|
||||
eventCommandProfiles:
|
||||
default:
|
||||
created:
|
||||
before:
|
||||
after:
|
||||
## - "say An AreaShop region has been created: %region%"
|
||||
deleted:
|
||||
before:
|
||||
after:
|
||||
rented:
|
||||
before:
|
||||
after:
|
||||
extended:
|
||||
before:
|
||||
after:
|
||||
unrented:
|
||||
before:
|
||||
after:
|
||||
bought:
|
||||
before:
|
||||
after:
|
||||
sold:
|
||||
before:
|
||||
after:
|
||||
## 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)
|
||||
## %type% represents the type of the region, could be 'rent' or 'buy'
|
||||
## 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!
|
||||
schematicProfiles:
|
||||
default:
|
||||
created:
|
||||
save: '%type%-%region%'
|
||||
restore: ''
|
||||
deleted:
|
||||
save: ''
|
||||
restore: '%type%-%region%'
|
||||
rented:
|
||||
save: ''
|
||||
restore: ''
|
||||
unrented:
|
||||
save: ''
|
||||
restore: '%type%-%region%'
|
||||
bought:
|
||||
save: ''
|
||||
restore: ''
|
||||
sold:
|
||||
save: ''
|
||||
restore: '%type%-%region%'
|
||||
## Flag profiles to specify what flags should be set on the WorldGuard regions
|
||||
## All region flags can be used + members, owners, priority and parent.
|
||||
flagProfiles:
|
||||
default:
|
||||
forrent:
|
||||
members: -%player%
|
||||
greeting: '&2[AreaShop]&f %region% can be rented for %price% per %duration%'
|
||||
rented:
|
||||
members: +%player%
|
||||
greeting: '&2[AreaShop]&f %region% is rented by %player% until %until%'
|
||||
forsale:
|
||||
members: -%player%
|
||||
greeting: '&2[AreaShop]&f %region% can be bought for %price%'
|
||||
sold:
|
||||
members: +%player%
|
||||
greeting: '&2[AreaShop]&f %region% is bought by %player%'
|
||||
|
||||
|
||||
########## RENTING ##########
|
||||
## The tag you have to write on the sign for renting a region
|
||||
rentSign: '[rent]'
|
||||
## The line that should be placed on the sign when the region is not rented
|
||||
signRentable: '&2&l[For Rent]'
|
||||
## The line that should be placed on the sign when the region is rented
|
||||
signRented: '&4&l[Rented]'
|
||||
## How much regions a player can rent at the same time, -1 for not limited
|
||||
maximumRents: 1
|
||||
## The percentage of the renting price you get back if you unrent the region (price of time left will be multiplied by this/100)
|
||||
rentMoneyBack: 100
|
||||
## How much seconds between checking if renting has expired (don't put this to low)
|
||||
checkDelay: 60
|
||||
## Flags for the 'For Rent' regions, flags and options to apply when the region is not rented
|
||||
## All region flags can be used + members, owners, priority and parent.
|
||||
flagsForRent:
|
||||
members: -%player%
|
||||
greeting: '%region% can be rented for %price% per %duration%'
|
||||
## Flags for the 'Rented' regions, flags and options to apply when the region is rented
|
||||
## All region flags can be used + members, owners, priority and parent.
|
||||
flagsRented:
|
||||
members: +%player%
|
||||
greeting: '%region% is rented by %player% until %until%'
|
||||
## Timeformat to use on the signs, default is like '30-06 14:52', US format: 'MM-dd KK:mm a'
|
||||
## Search for 'java SimpleDateFormat' for more options and documentation
|
||||
timeFormatSign: 'dd-MM HH:mm'
|
||||
## Timeformat used in the chat, default is like '30 june 2014 14:52', US format: 'MMMMMMMMMMMMMMMMM dd yyyy KK:mm a'
|
||||
## Search for 'java SimpleDateFormat' for more options and documentation
|
||||
timeFormatChat: 'dd MMMMMMMMMMMMMMMMM yyyy HH:mm'
|
||||
## Time indicators, used for specifing rent duration on the signs
|
||||
## Be careful with deleting words, will break signs using those, adding is no problem
|
||||
minutes: [m, min, mins, minute, minutes, minuten, minuut]
|
||||
hours: [h, hour, hours, uur, uren]
|
||||
days: [d, day, days, dag, dagen]
|
||||
months: [M, month, months, maanden, maand]
|
||||
years: [y, year, years, jaar, jaren]
|
||||
|
||||
|
||||
########## BUYING ##########
|
||||
## The tag you have to write on the sign for renting a region
|
||||
buySign: '[buy]'
|
||||
## The line that should be placed on the sign when the region is not sold
|
||||
signBuyable: '&2&l[For Sale]'
|
||||
## The line that should be placed on the sign when the region is sold
|
||||
signBuyed: '&4&l[Sold]'
|
||||
## How much regions a player can buy at the same time, -1 for not limited
|
||||
maximumBuys: 1
|
||||
## The percentage of the buying price you get back if you sell the region
|
||||
buyMoneyBack: 100
|
||||
## Flags for the 'For Sale' regions, flags and options to apply when the region is for sale
|
||||
## All region flags can be used + members, owners, priority and parent.
|
||||
flagsForSale:
|
||||
members: -%player%
|
||||
greeting: '%region% can be bought for %price%'
|
||||
## Flags for the 'Sold' regions, flags and options to apply when the region is rented
|
||||
## All region flags can be used + members, owners, priority and parent.
|
||||
flagsSold:
|
||||
members: +%player%
|
||||
greeting: '%region% is bought by %player%'
|
||||
@@ -0,0 +1,40 @@
|
||||
### All settings below are default settings and can be overridden
|
||||
### by group settings or region settings (copy a section to a region or group and change them there)
|
||||
|
||||
########## GENERAL ##########
|
||||
general:
|
||||
## Set this to true to enable saving/restoring for regions as specified in the profile below, which is specified in the config
|
||||
enableRestore: false
|
||||
## The schematic profile as specified in the config
|
||||
schematicProfile: 'default'
|
||||
## The event commands profile as specified in the config
|
||||
eventCommandProfile: 'default'
|
||||
## The profile for the format of the sign as specified in the config
|
||||
signProfile: 'default'
|
||||
## The profile for the WorldGuard flags as specified in the config
|
||||
flagProfile: 'default'
|
||||
## The y location within the region to start searching for safe teleport spots (x and z will be in the middle of the region)
|
||||
## Possible values: bottom, middle, top
|
||||
teleportLocationY: bottom
|
||||
## If true the teleportation algorithm only allows telportation to inside the region, otherwise it will expand algorithm
|
||||
## a cube from the starting point to check for safe spots (then it could end outside the region)
|
||||
## If you set a teleport location outside of the region with /as settp then setting this to true breaks that teleport (players cannot use it)
|
||||
teleportIntoRegion: true
|
||||
|
||||
########## RENTING ##########
|
||||
rent:
|
||||
## The default price of a renting region
|
||||
price: 1000
|
||||
## The default duration of a renting region
|
||||
duration: '1 day'
|
||||
## The percentage of the renting price you get back if you unrent the region (price of time left will be multiplied by this/100)
|
||||
moneyBack: 100
|
||||
## Maximum number of extends a player can do (-1 for infinite, 0 for no extending)
|
||||
maxExtends: -1
|
||||
|
||||
########## BUYING ##########
|
||||
buy:
|
||||
## The default price of a buying region
|
||||
price: 1000
|
||||
## The percentage of the buying price you get back if you sell the region
|
||||
moneyBack: 100
|
||||
+252
-93
@@ -1,104 +1,23 @@
|
||||
###################################################
|
||||
# English language file for the AreaShop plugin #
|
||||
# Latest update: V2.0.2 #
|
||||
###################################################
|
||||
# Copy this file and change the strings to your #
|
||||
# favor. Then change the 'language' setting in #
|
||||
# the config to the filename (excluding .yml) #
|
||||
###################################################
|
||||
|
||||
########## Command strings
|
||||
########## General strings
|
||||
total-maximum: "You can't rent and buy more than %0% region(s) in total"
|
||||
|
||||
cmd-notValid: "That command is not valid, use '/as help' for info"
|
||||
cmd-onlyByPlayer: "This command can only be run by a player"
|
||||
cmd-weOnlyByPlayer: "Using a WorldEdit selection is only possible as a player, specify the region name as extra argument"
|
||||
cmd-noSelection: "You don't have a WorldEdit selection"
|
||||
cmd-noRegionsFound: "No regions registered in AreaShop are found in your selection"
|
||||
cmd-noWERegionsFound: "No WorldEdit regions intersecting your selection are found"
|
||||
|
||||
rent-regionNotRentable: "That region is not available for renting"
|
||||
rent-help: "/as rent <regionname>"
|
||||
rent-noPermission: "You don't have permission to rent a region"
|
||||
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-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"
|
||||
|
||||
buy-help: "/as buy <regionname>"
|
||||
buy-noPermission: "You don't have permission to buy a region"
|
||||
buy-notBuyable: "That region is not available for buying"
|
||||
buy-maximum: "You can't buy more than %0% region(s)"
|
||||
buy-payError: "Something went wrong with paying, try again later"
|
||||
buy-succes: "You succesfully bought %0%"
|
||||
buy-lowMoney: "You don't have enough money to buy this region (you have %0% and you need %1%)"
|
||||
buy-yours: "You already own this region"
|
||||
buy-someoneElse: "Someone else already bought this region"
|
||||
|
||||
unrent-help: "/as unrent <regionname>"
|
||||
unrent-noPermission: "You don't have permission to unrent a region"
|
||||
unrent-noPermissionOther: "You don't have permission to unrent another region"
|
||||
unrent-notRegistered: "The region can't be unrent because it is not registered for renting"
|
||||
unrent-notRented: "The region can't be unrent because it is not rented"
|
||||
unrent-unrented: "Your region has been unrented"
|
||||
unrent-other: "The region has been unrented for player %0%"
|
||||
unrent-expired: "Your rent of %0% has expired"
|
||||
|
||||
sell-help: "/as sell <regionname>"
|
||||
sell-notRegistered: "The region can't be selled because it is not registered for buying"
|
||||
sell-notBought: "The region can't be selled because it is not someone's property"
|
||||
sell-sold: "The region has been sold for player %0%"
|
||||
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"
|
||||
|
||||
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"
|
||||
|
||||
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-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%"
|
||||
info-all-noBuys: "There are no regions registered for buying"
|
||||
info-rented: "Rented regions: %0%"
|
||||
info-noRented: "No regions are rented"
|
||||
info-unrented: "Unrented regions: %0%"
|
||||
info-noUnrented: "All regions are rented"
|
||||
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-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-regionNoRenting: "%0% is not registered for renting"
|
||||
info-regionRenting: "&6Renting details for %0%"
|
||||
info-regionRentedBy: "Rented by: %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: %0%"
|
||||
info-regionSign: "Sign position: world=%0%, X=%1%, Y=%2%, Z=%3%"
|
||||
info-regionPriceDuration: "Price: %0% for each %1%"
|
||||
info-regionPrice: "Price: %0%"
|
||||
|
||||
########## Help command strings
|
||||
help-header: "Help page, commands that you can execute"
|
||||
help-alias: "Command aliases: /areashop, /as"
|
||||
help-help: "&6/as help &7-&r Shows this help page"
|
||||
@@ -109,8 +28,248 @@ 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-setrestore: "&6/as setrestore &7-&r Set the profile for restoring and on/off "
|
||||
help-setprice: "&6/as setprice &7-&r Change the price of a rent region"
|
||||
help-rentduration: "&6/as rentduration &7-&r Change the duration of a rent region"
|
||||
help-teleport: "&6/as tp &7-&r Teleport to your bought/rented regions"
|
||||
help-teleportAll: "&6/as tp &7-&r Teleport to a rent/buy region"
|
||||
help-setteleport: "&6/as settp &7-&r Set teleport position for bought/rented regions"
|
||||
help-setteleportAll: "&6/as settp &7-&r Set teleport position for a region"
|
||||
help-find: "&6/as find &7-&r Find an empty buy or rent"
|
||||
help-groupadd: "&6/as groupadd &7-&r Add a region to a group"
|
||||
help-groupdel: "&6/as groupdel &7-&r Delete a region from a group"
|
||||
help-grouplist: "&6/as grouplist &7-&r Display all groups currently registered"
|
||||
help-groupinfo: "&6/as groupinfo &7-&r Display information about a group"
|
||||
help-schemevent: "&6/as schemevent &7-&r Trigger a schematic event for a region"
|
||||
help-add: "&6/as add &7-&r Register a region as rent or buy"
|
||||
help-del: "&6/as del &7-&r Delete a registered region from AreaShop"
|
||||
help-addsign: "&6/as addsign &7-&r Add a sign to an existing region"
|
||||
help-delsign: "&6/as delsign &7-&r Delete the sign you are looking at"
|
||||
|
||||
############ Other command strings
|
||||
rent-help: "/as rent [regionname], the region you stand in will be used if not specified"
|
||||
rent-noPermission: "You don't have permission to rent a region"
|
||||
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 /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"
|
||||
rent-notRentable: "That region is not available for renting"
|
||||
rent-maxExtends: "You cannot extend this rent anymore (the maximum is %0% times), however after the rent is over you can rent this region again"
|
||||
|
||||
buy-help: "/as buy [regionname], the region you stand in will be used if not specified"
|
||||
buy-noPermission: "You don't have permission to buy a region"
|
||||
buy-notBuyable: "That region is not available for buying"
|
||||
buy-maximum: "You can't buy more than %0% region(s)"
|
||||
buy-payError: "Something went wrong with paying, try again later"
|
||||
buy-succes: "You succesfully bought %0%"
|
||||
buy-lowMoney: "You don't have enough money to buy this region (you have %0% and you need %1%)"
|
||||
buy-yours: "You already own this region"
|
||||
buy-someoneElse: "Someone else already bought this region"
|
||||
|
||||
unrent-help: "/as unrent [regionname], the region you stand in will be used if not specified"
|
||||
unrent-noPermission: "You don't have permission to unrent a region"
|
||||
unrent-noPermissionOther: "You don't have permission to unrent another region"
|
||||
unrent-notRegistered: "The region can't be unrent because it is not registered for renting"
|
||||
unrent-notRented: "The region can't be unrent because it is not rented"
|
||||
unrent-unrented: "Your region has been unrented"
|
||||
unrent-other: "The region has been unrented for player %0%"
|
||||
unrent-expired: "Your rent of %0% has expired"
|
||||
|
||||
sell-help: "/as sell [regionname], the region you stand in will be used if not specified"
|
||||
sell-notRegistered: "The region can't be selled because it is not registered for buying"
|
||||
sell-notBought: "The region can't be selled because it is not someone's property"
|
||||
sell-sold: "The region has been sold for player %0%"
|
||||
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"
|
||||
|
||||
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"
|
||||
|
||||
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: "/as info <all|rented|forrent|sold|forsale|player|region>"
|
||||
info-all-rents: "Regions registered for renting: &7%0%"
|
||||
info-all-noRents: "There are no regions registered for renting"
|
||||
info-all-buys: "Regions registered for buying: &7%0%"
|
||||
info-all-noBuys: "There are no regions registered for buying"
|
||||
info-rented: "Rented regions: &7%0%"
|
||||
info-noRented: "No regions are rented"
|
||||
info-unrented: "Unrented regions: &7%0%"
|
||||
info-noUnrented: "All regions are rented"
|
||||
info-sold: "Sold regions: &7%0%"
|
||||
info-noSold: "No regions are sold"
|
||||
info-forsale: "Regions for sale: &7%0%"
|
||||
info-noForsale: "All regions are sold"
|
||||
info-playerHelp: "/as info player <name>"
|
||||
info-playerRents: "Regions rented by %0%: &7%1%"
|
||||
info-playerNoRents: "%0% has not rented a region"
|
||||
info-playerBuys: "Regions bought by %0%: &7%1%"
|
||||
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-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-regionSignLocation: "&7(%0%, %1%, %2%, %3%)&r"
|
||||
info-regionNoSign: "There is no sign registered for this region"
|
||||
info-regionPriceDuration: "Price: &7%0% for each %1%"
|
||||
info-regionPrice: "Price: &7%0%"
|
||||
info-regionRestore: "Restoring enabled: &7%0%"
|
||||
info-regionRestoreProfile: "Restoring profile: &7%0%"
|
||||
info-regionTPLocation: "Teleport location: &7World=%0%, X=%1%, Y=%2%, Z=%3%, Pitch=%4%, Yaw=%5%"
|
||||
info-regionNoTP: "No teleport location set"
|
||||
info-regionNotExisting: "Region %0% is not registered"
|
||||
|
||||
setrestore-help: "/as setrestore <region> <true|false|general> [profile]"
|
||||
setrestore-noPermission: "You don't have permission to change the restore settings"
|
||||
setrestore-notRegistered: "%0% is not registered"
|
||||
setrestore-invalidSetting: "'%0%' is not a valid state, should be true, false or general"
|
||||
setrestore-success: "Succesfully set the restore setting of %0% to '%1%'"
|
||||
setrestore-successProfile: "Succesfully 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-help: "/as setprice <price> [region], the region you stand in will be used if not specified"
|
||||
setprice-notRegistered: "%0% is not registered in AreaShop"
|
||||
setprice-wrongPrice: "'%0%' is not a valid price"
|
||||
setprice-successRent: "Price of region %0% changed to %1% per %2%"
|
||||
setprice-successBuy: "Price of region %0% changed to %1%"
|
||||
|
||||
rentduration-noPermission: "You don't have permission to change the duration of a rent"
|
||||
rentduration-help: "/as rentduration <amount> <identifier> [region], the region you stand in will be used if not specified"
|
||||
rentduration-notRegistered: "%0% is not registered as a rent"
|
||||
rentduration-wrongAmount: "'%0%' is not a valid amount, use a whole number"
|
||||
rentduration-wrongFormat: "'%0%' is not a proper timeformat, check the documentation on Bukkit"
|
||||
rentduration-success: "Duration of region %0% changed to '%1%'"
|
||||
|
||||
setup-noRegion: "You did not specify a region on the second line"
|
||||
setup-wrongRegion: "The region you specified does not exist"
|
||||
setup-alreadyRentSign: "The region you specified already has a sign for renting"
|
||||
setup-alreadyBuySign: "The region you specified already has a sign for buying"
|
||||
setup-noDuration: "You did not specify how long the region can be rented, do this on the third line"
|
||||
setup-wrongDuration: "The time specified is not in the correct format, example: 1 day"
|
||||
setup-noPrice: "You did not specify the price on the fourth line"
|
||||
setup-wrongPrice: "You did not specify the price correctly, use a number only"
|
||||
setup-rentSuccess: "Renting of region %0% is setup correctly"
|
||||
setup-buySuccess: "Buying of region %0% is setup correctly"
|
||||
setup-noPermissionRent: "You don't have permission for setting up renting of regions"
|
||||
setup-noPermissionBuy: "You don't have permission for setting up buying of regions"
|
||||
setup-couldNotDetect: "Found multiple regions with the same priority and/or parent/child relation, specify one on the second line (2 of the regions that were found: %0% and %1%)"
|
||||
|
||||
destroy-noPermissionRent: "You don't have permission for destroying a sign for renting a region"
|
||||
destroy-noPermissionBuy: "You don't have permission for destroying a sign for buying a region"
|
||||
destroy-successRent: "Renting of %0% successfully removed"
|
||||
destroy-successBuy: "Buying of %0% successfully removed"
|
||||
|
||||
teleport-help: "/as tp <region> [sign]"
|
||||
teleport-noRentOrBuy: "Region '%0%' is not registered as rent or buy"
|
||||
teleport-noPermission: "You don't have permission to teleport to a region"
|
||||
teleport-noPermissionOther: "You don't have permission to teleport to region you do not own"
|
||||
teleport-success: "You teleported to %0%"
|
||||
teleport-noSafe: "No safe position found in region %0%, no spots in region left or maximum tries exceeded (%1%/%2%)"
|
||||
|
||||
setteleport-help: "/as settp [region] [reset], the region you stand in will be used if not specified"
|
||||
setteleport-noPermission: "You don't have permission to set the teleport location"
|
||||
setteleport-noPermissionAll: "You don't have permission to set the teleport location for a region you do not own"
|
||||
setteleport-noRentOrBuy: "Region '%0%' is not registered as rent or buy"
|
||||
setteleport-success: "Teleport location of %0% set"
|
||||
setteleport-notInside: "The location has to be inside the region"
|
||||
setteleport-reset: "Teleport location of %0% has been reset"
|
||||
|
||||
find-help: "/as find <buy|rent> [maxprice]"
|
||||
find-noPermission: "You don't have permission to teleport to signs, so you can't use find"
|
||||
find-success: "Found a %0% region: %1%, while searching with a max price of your balance: %2%"
|
||||
find-successMax: "Found a %0% region: %1%, while searching with a max price of %2%"
|
||||
find-wrongMaxPrice: "The specified maximum price is not a correct number: %0%"
|
||||
find-noneFound: "No %0% region found while searching with a max price of your balance: %1%"
|
||||
find-noneFoundMax: "No %0% region found while searching with a max price of %1%"
|
||||
|
||||
groupadd-help: "/as groupadd <group> [region], if no region specified all regions from your WorldEdit selection are used"
|
||||
groupadd-noPermission: "You don't have permission to add regions to groups"
|
||||
groupadd-noRegion: "The specified region is not registered: %0%"
|
||||
groupadd-success: "Region %0% has been added to group '%1%', this group now has %2% member(s)"
|
||||
groupadd-failed: "Region %0% is already a member of group '%1%'"
|
||||
groupadd-weSuccess: "Added to group %0%: &7%1%"
|
||||
groupadd-weFailed: "Were already in group %0%: &7%1%"
|
||||
|
||||
groupdel-help: "/as groupdel <group> [region], if no region specified all regions from your WorldEdit selection are used"
|
||||
groupdel-noPermission: "You don't have permission to remove regions from groups"
|
||||
groupdel-noRegion: "The specified region is not registered: %0%"
|
||||
groupdel-success: "Region %0% has been removed from group '%1%', this group now has %2% member(s)"
|
||||
groupdel-failed: "Region %0% is not a member of group '%1%'"
|
||||
groupdel-weSuccess: "Removed from group %0%: &7%1%"
|
||||
groupdel-weFailed: "Were not in group %0% anyway: &7%1%"
|
||||
|
||||
grouplist-noPermission: "You don't have permission to display the registered groups"
|
||||
grouplist-noGroups: "There are currently no groups registered"
|
||||
grouplist-success: "The following groups are registered: &7%0%"
|
||||
|
||||
groupinfo-help: "/as groupinfo <group>"
|
||||
groupinfo-noPermission: "You don't have permission to display information about a group"
|
||||
groupinfo-noGroup: "There is no group registered with the name '%0%', use /as grouplist to check groups"
|
||||
groupinfo-members: "The following regions are member of group %0%: &7%1%"
|
||||
groupinfo-noMembers: "Group %0% does not have any members"
|
||||
|
||||
schemevent-help: "/as schemevent <region> <created|deleted|rented|unrented|bought|sold>"
|
||||
schemevent-noRegion: "The specified region is not registered: %0%"
|
||||
schemevent-wrongEvent: "The specified event '%0%' does not exist, use one of the following: &7%1%"
|
||||
schemevent-success: "Event '%0%' has succesfully been triggered for region %1%"
|
||||
schemevent-noPermission: "You don't have permission to trigger schematic events"
|
||||
|
||||
add-help: "/as add <rent|buy> [region] [world]"
|
||||
add-noPermission: "You don't have permission to add a region to AreaShop"
|
||||
add-success: "Added as %0%: &7%1%"
|
||||
add-failed: "Already registered: &7%0%"
|
||||
add-specifyWorld: "Specify the world of the region when using from console"
|
||||
add-incorrectWorld: "World '%0%' not found, try again (case-sensitive)"
|
||||
add-noRegion: "Region '%0%' does not exist in this world"
|
||||
|
||||
del-noRegion: "Region '%0%' is not registered in AreaShop"
|
||||
del-noPermission: "You don't have permission to remove regions"
|
||||
del-success: "Removed regions: &7%0%"
|
||||
del-failed: "No permission to remove or not registered: &7%0%"
|
||||
|
||||
addsign-help: "/as addsign [region] [profile]"
|
||||
addsign-noSign: "You are not looking at a sign"
|
||||
addsign-noRegion: "Region '%0%' cannot be found"
|
||||
addsign-noRegions: "No region found around the sign position"
|
||||
addsign-couldNotDetect: "Found multiple regions around the sign, specify region as extra argument (2 of the regions that were found: %0% and %1%)"
|
||||
addsign-couldNotDetectSign: "Found multiple regions around the sign, specify region on the second line (2 of the regions that were found: %0% and %1%)"
|
||||
addsign-wrongProfile: "The specified profile does not exist, use one of the following (check config): &7%0%"
|
||||
addsign-success: "The sign has been added to %0%"
|
||||
addsign-successProfile: "The sign has been added to %0% with profile %1%"
|
||||
addsign-alreadyRegistered: "That sign is already registered for region %0%"
|
||||
addsign-noPermission: "You don't have permission to add a sign"
|
||||
|
||||
delsign-noSign: "You are not looking at a sign"
|
||||
delsign-noPermission: "You don't have permission to delete a sign"
|
||||
delsign-noRegion: "That sign does not belong to an AreaShop region"
|
||||
delsign-success: "The sign has been removed from region %0%"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
###################################################
|
||||
# French language file for the AreaShop plugin #
|
||||
# Latest update: V2.0.2 #
|
||||
###################################################
|
||||
# Copy this file and change the strings to your #
|
||||
# favor. Then change the 'language' setting in #
|
||||
# the config to the filename (excluding .yml) #
|
||||
###################################################
|
||||
|
||||
########## General strings
|
||||
total-maximum: "Vous ne pouvez pas acheter ou louer plus de %0% region(s) au total"
|
||||
|
||||
cmd-notValid: "Cette commande est incorrecte, utilisez '/as help' pour plus de détails"
|
||||
cmd-onlyByPlayer: "Cette commande ne peut être utilisé que par un joueur"
|
||||
cmd-weOnlyByPlayer: "Utiliser une séléction WorldEdit n'est possible qu'en tant que joueur. Spécifiez le nom de la région en argument supplémentaire."
|
||||
cmd-noSelection: "Vous n'avez pas de séléction WorldEdit"
|
||||
cmd-noRegionsFound: "Aucune région enregistré dans AreaShop n'a été trouvé dans votre séléction"
|
||||
cmd-noWERegionsFound: "Aucun région WorldEdit croisant votre séléction n'a été trouvé"
|
||||
|
||||
########## Help command strings
|
||||
help-header: "Pade d'aide, Commande que vous pouvez éxécuter"
|
||||
help-alias: "Alias des commandes: /areashop, /as"
|
||||
help-help: "&6/as help &7-&r Affiche la page d'aide"
|
||||
help-info: "&6/as info &7-&r Obtenir les infos sur les régions actuelles"
|
||||
help-rent: "&6/as rent &7-&r Louer une région, ou prolonger la location actuelle"
|
||||
help-buy: "&6/as buy &7-&r Acheter une région"
|
||||
help-unrent: "&6/as unrent &7-&r Dé-louer une région"
|
||||
help-unrentOwn: "&6/as unrent &7-&r Dé-louer votre propre région"
|
||||
help-sell: "&6/as sell &7-&r Vendre une région"
|
||||
help-sellOwn: "&6/as sell &7-&r Vendre votree propre région"
|
||||
help-updaterents: "&6/as updaterents &7-&r Mettre à jours toutes les pancartes et les régions louées."
|
||||
help-updatebuys: "&6/as updatebuys &7-&r Mettre à jours toutes les pancartes et les régions achetées"
|
||||
help-reload: "&6/as reload &7-&r Recharge les configs et langages"
|
||||
help-setrestore: "&6/as setrestore &7-&r Mettre le profil pour réstaurer à on/off"
|
||||
help-setprice: "&6/as setprice &7-&r Fixerle prix d'une région louée."
|
||||
help-rentduration: "&6/as rentduration &7-&r Changer la durée d'une région louée"
|
||||
help-teleport: "&6/as tp &7-&r Téléportation vers votre région acheté / louée"
|
||||
help-teleportAll: "&6/as tp &7-&r Téléportation vers une région louée / acheté"
|
||||
help-setteleport: "&6/as settp &7-&r Définie la position de téléportation pour la région louée / acheté"
|
||||
help-setteleportAll: "&6/as settp &7-&r Défini la position de téléportation pour une région"
|
||||
help-find: "&6/as find &7-&r trouve un achat ou une location vide"
|
||||
help-groupadd: "&6/as groupadd &7-&r Ajoute une région à un groupe"
|
||||
help-groupdel: "&6/as groupdel &7-&r Supprime une région d'un groupe"
|
||||
help-grouplist: "&6/as grouplist &7-&r Affiche tout les groupes enregistrés"
|
||||
help-groupinfo: "&6/as groupinfo &7-&r Affiche les informations d'un groupe"
|
||||
help-schemevent: "&6/as schemevent &7-&r Déclanche un évenement schématique d'une région"
|
||||
help-add: "&6/as add &7-&r Enregistre une région comme louée ou acheté"
|
||||
help-del: "&6/as del &7-&r Supprime une région enregistré dans AreaShop"
|
||||
help-addsign: "&6/as addsign &7-&r Ajoute une pancarte à une région existante"
|
||||
help-delsign: "&6/as delsign &7-&r Supprime la pancarte que vous regardez"
|
||||
|
||||
############ Other command strings
|
||||
rent-help: "/as rent [regionname], Si non spécifié, cible la région dans laquelle vous vous trouvez"
|
||||
rent-noPermission: "Vous n'avez pas la permission de louer une région"
|
||||
rent-maximum: "Vous ne pouvez pas louer plus de %0% région(s)"
|
||||
rent-payError: "Une erreur durant le paiement s'est produite. Essayez de nouveau plus tard"
|
||||
rent-rented: "Vous avez loué de %0% jusqu'à %1%"
|
||||
rent-extended: "Vous avez prolongé la location de %0% jusqu'à %1%"
|
||||
rent-extend: "Vous pouvez prolonger votre location avec un clic droit sur la pancarte, ou en utilisant /as rent"
|
||||
rent-lowMoneyExtend: "Vous n'avez pas assez d'argent pour prolonger la location. (Vous possédez %0% et devez payer %1%)"
|
||||
rent-lowMoneyRent: "Vous n'avez pas assez d'argent pour louer cette région. (Vous possédez %0% et devez payer %1%)"
|
||||
rent-someoneElse: "Quelqu'un d'autre a déjà louer cette région"
|
||||
rent-notRentable: "cette région n'est pas disponible à la location"
|
||||
rent-maxExtends: "Vous ne pouvez plus prolonger cette location. (Le maximum est de %0% fois). Mais lorsque la location sera terminé, vous pourrez louer de nouveau cette région"
|
||||
|
||||
buy-help: "/as buy [regionname], Si non spécifié, cible la région dans laquelle vous vous trouvez"
|
||||
buy-noPermission: "Vous n'avez pas la permission d'acheter une région"
|
||||
buy-notBuyable: "cette région n'est pas disponible à l'achat"
|
||||
buy-maximum: "Vous ne pouvez pas acheter plus de %0% région(s)"
|
||||
buy-payError: "Une erreur durant le paiement s'est produite. Essayez de nouveau plus tard"
|
||||
buy-succes: "Vous avez bien acheté %0%"
|
||||
buy-lowMoney: "Vous n'avez pas assez d'argent pour acheter cette région. (Vous possédez %0% et devez payer %1%)"
|
||||
buy-yours: "Vous avez déjà acheter cette région"
|
||||
buy-someoneElse: "Quelqu'un a déjà acheté cette région"
|
||||
|
||||
unrent-help: "/as unrent [regionname], Si non spécifié, cible la région dans laquelle vous vous trouvez"
|
||||
unrent-noPermission: "Vous n'avez pas la permission de dé-louer une région"
|
||||
unrent-noPermissionOther: "Vous n'avez pas la permission de délouer une autre région"
|
||||
unrent-notRegistered: "La région ne peut pas être dé-louée car elle n'est pas enregistré à la location"
|
||||
unrent-notRented: "La région ne peut pas être dé-louée car elle n'est pas loué"
|
||||
unrent-unrented: "Votre région a été dé-louée."
|
||||
unrent-other: "La région du joueur %0% a été dé-louée"
|
||||
unrent-expired: "Votre location de %0% a expiré"
|
||||
|
||||
sell-help: "/as sell [regionname], Si non spécifié, cible la région dans laquelle vous vous trouvez"
|
||||
sell-notRegistered: "la région ne peut pas être vendue car elle n'est pas enregistré comme acheté"
|
||||
sell-notBought: "La région ne peut pas être vendue car elle n'est pas la propriété de quelqu'un"
|
||||
sell-sold: "Cette région a été vendu au joueur %0%"
|
||||
sell-soldYours: "Votre région a été vendue"
|
||||
sell-noPermission: "Vous n'avez pas la permission de vendre une région"
|
||||
sell-noPermissionOther: "Vous n'avez pas la permission de vendre une autre région"
|
||||
|
||||
rents-updated: "Tout les panneaux et régions en location ont été mis à jour"
|
||||
rents-notUpdated: "Tout les panneaux n'ont pas été mis à jour. Recharger peut corriger le problème"
|
||||
rents-noPermission: "Vous n'avez pas la permission de mettre à jour les panneaux et régions en location"
|
||||
|
||||
buys-updated: "Tout les panneaux et régions en vente ont été mis à jour"
|
||||
buys-notUpdated: "Tout les panneaux n'ont pas été mis à jour. Recharger peut corriger le problème"
|
||||
buys-noPermission: "Vous n'avez pas la permission de mettre à jour les panneaux et régions en vente"
|
||||
|
||||
reload-reloaded: "La configuration a bien été rechargée"
|
||||
reload-noPermission: "Vous n'avez pas la permission de recharger la configuration"
|
||||
|
||||
info-help: "/as info <all|rented|forrent|sold|forsale|player|region>"
|
||||
info-all-rents: "Régions enregistrées en location: &7%0%"
|
||||
info-all-noRents: "Il n'y a pas de régions enregistrées en location"
|
||||
info-all-buys: "Régions enregistrées en vente: &7%0%"
|
||||
info-all-noBuys: "Il n'y a pas de régions enregistrées en achat"
|
||||
info-rented: "Régions louées: &7%0%"
|
||||
info-noRented: "Aucune régions louée"
|
||||
info-unrented: "régions non louées: &7%0%"
|
||||
info-noUnrented: "Toutes les régions sont louées"
|
||||
info-sold: "Régions vendues: &7%0%"
|
||||
info-noSold: "Aucune région n'est vendue"
|
||||
info-forsale: "Région en vente: &7%0%"
|
||||
info-noForsale: "Toutes les régions sont vendues"
|
||||
info-playerHelp: "/as info player <name>"
|
||||
info-playerRents: "Regions louées par %0%: &7%1%"
|
||||
info-playerNoRents: "%0% n'a de région louée"
|
||||
info-playerBuys: "Régions achetés par %0%: &7%1%"
|
||||
info-playerNoBuys: "%0% n'a pas acheté de région"
|
||||
info-regionHelp: "/as info region [name], Si non spécifié, cible la région dans laquelle vous vous trouvez"
|
||||
info-regionNoRenting: "%0% n'est pas enregistré pour la location"
|
||||
info-regionRenting: "&6Détails de location pour %0%:"
|
||||
info-regionRentedBy: "Louée par: &7%0% jusqu'au %1%"
|
||||
info-regionNotRented: "Actuellement non louée"
|
||||
info-regionBuying: "&6Détails d'achat pour %0%:"
|
||||
info-regionNoBuying: "%0% n'est pas enregistré à la vente"
|
||||
info-regionNotBought: "Actuellement non vendue"
|
||||
info-regionBoughtBy: "Acheté par: &7%0%"
|
||||
info-regionSign: "Panneau(x) de location(s): %0%"
|
||||
info-regionSignLocation: "&7(%0%, %1%, %2%, %3%)&r"
|
||||
info-regionNoSign: "Il n'y a pas de panneaux enregistré pour cette région"
|
||||
info-regionPriceDuration: "Prix: &7%0% pour chaque %1%"
|
||||
info-regionPrice: "Prix: &7%0%"
|
||||
info-regionRestore: "Réstauration activé: &7%0%"
|
||||
info-regionRestoreProfile: "profil de restauration: &7%0%"
|
||||
info-regionTPLocation: "lieu de téléportation: &7World=%0%, X=%1%, Y=%2%, Z=%3%, Pitch=%4%, Yaw=%5%"
|
||||
info-regionNoTP: "Aucun lieu de téléportation défini"
|
||||
info-regionNotExisting: "La région %0% n'est pas enregistrée"
|
||||
|
||||
setrestore-help: "/as setrestore <region> <true|false|general> [profile]"
|
||||
setrestore-noPermission: "Vous n'avez pas la permission de restaurer les paramètres"
|
||||
setrestore-notRegistered: "%0% n'est pas enregistré"
|
||||
setrestore-invalidSetting: "'%0%' est invalide. Doit être true, false ou general"
|
||||
setrestore-success: "Les paramètres ont bien été restauré de %0% à '%1%'"
|
||||
setrestore-successProfile: "Les paramètres ont bien été restauré de %0% à '%1%' et la profil à '%2%'"
|
||||
|
||||
setprice-noPermission: "Vous n'avez pas la permission de changer le prix d'une région"
|
||||
setprice-help: "/as setprice <price> [region], Si non spécifié, cible la région dans laquelle vous vous trouvez"
|
||||
setprice-notRegistered: "%0% n'est pas enregistré dans AreaShop"
|
||||
setprice-wrongPrice: "'%0%' n'est pas un rpix valide"
|
||||
setprice-successRent: "Prix de la région %0% changé de %1% à %2%"
|
||||
setprice-successBuy: "Pprix de la région %0% changé à %1%"
|
||||
|
||||
rentduration-noPermission: "Vous n'avez pas la permission de changer la durée d'une location"
|
||||
rentduration-help: "/as rentduration <amount> <identifier> [region], Si non spécifié, cible la région dans laquelle vous vous trouvez"
|
||||
rentduration-notRegistered: "%0% n'est pas enregistré comme location"
|
||||
rentduration-wrongAmount: "'%0%' n'est pas un montant valide, utilisez un nombre entier"
|
||||
rentduration-wrongFormat: "'%0%' n'est pas un format date correcte, regardez la documentation bukkit"
|
||||
rentduration-success: "Durée de la région %0% changé à '%1%'"
|
||||
|
||||
setup-noRegion: "Vous n'avez pas spécifié une région à la seconde ligne"
|
||||
setup-wrongRegion: "la région que vous avez spécifié n'existe pas"
|
||||
setup-alreadyRentSign: "La région que vous avez spécifiée possède déjà un panneau de location"
|
||||
setup-alreadyBuySign: "La région que vous avez spécifiée possède déjà un panneau de vente"
|
||||
setup-noDuration: "A la troisième ligne, vous n'avez pas spécifié la durée de location de la région"
|
||||
setup-wrongDuration: "Le temps spécifié n'est pas au bon format. Exemple: 1 day"
|
||||
setup-noPrice: "A la quatrième ligne, vous n'avez pas spécifié le prix"
|
||||
setup-wrongPrice: "Vous n'avez pas indiqué un prix correcte, utilisez un nombre entier"
|
||||
setup-rentSuccess: "La location de la région %0% est correctement configurée"
|
||||
setup-buySuccess: "L'achat de la région %0% est correctement configuré"
|
||||
setup-noPermissionRent: "Vous n'avez pas la permission de mettre en place la location de régions"
|
||||
setup-noPermissionBuy: "Vous n'avez pas la permission de mettre en place l'achat de régions"
|
||||
setup-couldNotDetect: "Multiples régions trouvées avec la même priorité et/ou parent/enfant relation. Spécifiez en un sur la deuxième ligne. (2 des régions trouvées: %0% et %1%)"
|
||||
|
||||
destroy-noPermissionRent: "Vous n'avez pas la permission de détruire le panneau de location d'une région"
|
||||
destroy-noPermissionBuy: "Vous n'avez pas la permission de détruire le panneau de vente d'une région"
|
||||
destroy-successRent: "Location de %0% supprimé"
|
||||
destroy-successBuy: "Achat de %0% supprimé"
|
||||
|
||||
teleport-help: "/as tp <region> [sign]"
|
||||
teleport-noRentOrBuy: "La région '%0%' n'est pas enregistré comme location ou achat"
|
||||
teleport-noPermission: "Vous n'avez pas la permission de vous téléporter dans une région"
|
||||
teleport-noPermissionOther: "Vous n'avez pas la permission de vous téléporter à une région qui ne vous appartient pas"
|
||||
teleport-success: "Vous avez été téléporté à %0%"
|
||||
teleport-noSafe: "Aucune position sécurisé trouvé dans la région %0%. Pas de point restant, ou tentatives maximales dépassées. (%1%/%2%)"
|
||||
|
||||
setteleport-help: "/as settp [region] [reset], Si non spécifié, cible la région dans laquelle vous vous trouvez"
|
||||
setteleport-noPermission: "Vous n'avez pas la permission de définir un point de téléportation"
|
||||
setteleport-noPermissionAll: "Vous n'avez pas la permission de définir un point de téléportation sur une région qui ne vous appartient pas"
|
||||
setteleport-noRentOrBuy: "La région '%0%' n'est pas enregistré comme location ou achat"
|
||||
setteleport-success: "Lieu de téléportation de %0% défini"
|
||||
setteleport-notInside: "Le lieu doit se trouver dans votre région"
|
||||
setteleport-reset: "le lieu de téléportation de %0% a été reset"
|
||||
|
||||
find-help: "/as find <buy|rent> [maxprice]"
|
||||
find-noPermission: "Vous n'avez pas la permission de vous téléporter à des panneaux. Vous ne pouvez donc pas utiliser find"
|
||||
find-success: "Trouvé %0% région: %1%, en recherchant avec le prix maximum de votre solde: %2%"
|
||||
find-successMax: "trouvé %0% région: %1%, en cherchant un prix maximum de %2%"
|
||||
find-wrongMaxPrice: "le prix maximum n'est pas un nombre valide: %0%"
|
||||
find-noneFound: "Aucune %0% région trouvée, en cherchant le prix maximum de votre solde: %1%"
|
||||
find-noneFoundMax: "Aucune %0% région trouvée en cherchant un prix maximum de %1%"
|
||||
|
||||
groupadd-help: "/as groupadd <group> [region], Si non spécifié, cible la région dans laquelle vous vous trouvez"
|
||||
groupadd-noPermission: "Vous n'avez pas la permission d'ajouter des régions aux groupes"
|
||||
groupadd-noRegion: "la région spécifiée n'est pas enregistré: %0%"
|
||||
groupadd-success: "La région %0% a été ajouté au groupe '%1%'. ce groupe a maintenant %2% membre(s)"
|
||||
groupadd-failed: "La région %0% est déjà membre du groupe '%1%'"
|
||||
groupadd-weSuccess: "Ajouté au groupe %0%: &7%1%"
|
||||
groupadd-weFailed: "Nous étions déjà dans le groupe %0%: &7%1%"
|
||||
|
||||
groupdel-help: "/as groupdel <group> [region], Si non spécifié, cible la région dans laquelle vous vous trouvez"
|
||||
groupdel-noPermission: "Vous n'avez pas la permission de supprimer des régions depuis les groupes"
|
||||
groupdel-noRegion: "La région spécifiée n'est pas enregistré: %0%"
|
||||
groupdel-success: "La région %0% a été supprimé du groupe '%1%', ce groupe a maintenant %2% membre(s)"
|
||||
groupdel-failed: "La région %0% n'est pas membre du groupe '%1%'"
|
||||
groupdel-weSuccess: "Supprimé du groupe %0%: &7%1%"
|
||||
groupdel-weFailed: "Nous ne sommes pas dans le groupe %0% de toute façon: &7%1%"
|
||||
|
||||
grouplist-noPermission: "Vous n'avez pas l'autorisation d'afficher les groupes enregistrés"
|
||||
grouplist-noGroups: "Il n'y a actuellement aucun groupe enregistré"
|
||||
grouplist-success: "les groupes suivants sont enregistrés: &7%0%"
|
||||
|
||||
groupinfo-help: "/as groupinfo <group>"
|
||||
groupinfo-noPermission: "Vous n'avez pas la permission d'afficher des informations sur un groupe"
|
||||
groupinfo-noGroup: "Il n'y a pas de groupe enregistré sous le nom '%0%', utilisez /as grouplist pour vérifier les groupes"
|
||||
groupinfo-members: "Les régions suivantes sont membres du groupe %0%: &7%1%"
|
||||
groupinfo-noMembers: "Le groupe %0% ne possède aucun membre"
|
||||
|
||||
schemevent-help: "/as schemevent <region> <created|deleted|rented|unrented|bought|sold>"
|
||||
schemevent-noRegion: "La région spécifiée n'est pas enregistré: %0%"
|
||||
schemevent-wrongEvent: "L'évent spécifié '%0%' n'existe pas, utilisez un des suivants: &7%1%"
|
||||
schemevent-success: "L'évent '%0%' a été déclenché pour la région %1%"
|
||||
schemevent-noPermission: "Vous n'avez pas la permission de déclencher des événements schématiques"
|
||||
|
||||
add-help: "/as add <rent|buy> [region] [world]"
|
||||
add-noPermission: "Vous n'avez pas la permission d'ajouter une région à AreaShop"
|
||||
add-success: "Ajouté comme %0%: &7%1%"
|
||||
add-failed: "Déjà enregistré: &7%0%"
|
||||
add-specifyWorld: "Spécifiez le monde de la région lors de l'utilisation de la console"
|
||||
add-incorrectWorld: "Le monde '%0%' est introuvable, essayez de nouveau (Attention à la casse)"
|
||||
add-noRegion: "La région '%0%' n'existe pas dans ce monde"
|
||||
|
||||
del-noRegion: "Le région '%0%' n'est pas enregistré à AreaShop"
|
||||
del-noPermission: "Vous n'avez pas la permission de supprimer des régions"
|
||||
del-success: "Régions supprimées: &7%0%"
|
||||
del-failed: "Pas de permission pour supprimer, ou pas enregistré: &7%0%"
|
||||
|
||||
addsign-help: "/as addsign [region] [profile]"
|
||||
addsign-noSign: "Vous ne regardez pas de panneau"
|
||||
addsign-noRegion: "La région '%0%' n'a pas été trouvé"
|
||||
addsign-noRegions: "Aucune région trouvé autour du panneau"
|
||||
addsign-couldNotDetect: "Plusieurs régions ont été trouvées à promixité du panneau. Spécifiez la région en argument supplémentaire. (2 des régions trouvées: %0% et %1%)"
|
||||
addsign-couldNotDetectSign: "Plusieurs régions ont été trouvées à proximité du panneau. Spécifiez la région à la deuxième ligne. (2 des régions trouvées: %0% et %1%)"
|
||||
addsign-wrongProfile: "le profil spécifié n'existe pas. utilisez un des suivants (vérifier la configuration): &7%0%"
|
||||
addsign-success: "Le panneau a été ajouté à %0%"
|
||||
addsign-successProfile: "Le panneau a été ajouté à %0% avec le profil %1%"
|
||||
addsign-alreadyRegistered: "Ce panneau a déjà été enregistré pour la région %0%"
|
||||
addsign-noPermission: "Vous n'avez pas la permission d'ajouter un panneau"
|
||||
|
||||
delsign-noSign: "Vous ne regardez pas un panneau"
|
||||
delsign-noPermission: "Vous n'avez pas la permission de supprimer un panneau"
|
||||
delsign-noRegion: "Ce signe n'appartient pas à une région AreaShop"
|
||||
delsign-success: "Ce panneau a été supprimé de la région %0%"
|
||||
+78
-21
@@ -1,5 +1,6 @@
|
||||
###################################################
|
||||
# Dutch language file for the AreaShop plugin #
|
||||
# Latest update: V1.2.1 #
|
||||
###################################################
|
||||
# Copy this file and change the strings to your #
|
||||
# favor. Then change the 'language' setting in #
|
||||
@@ -10,7 +11,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,10 +20,11 @@ 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"
|
||||
rent-notRentable: "Dat gebied is niet beschikbaar om te huren"
|
||||
|
||||
buy-help: "/as buy <gebiednaam>"
|
||||
buy-noPermission: "Je hebt geen toestemming om een gebied te kopen"
|
||||
@@ -51,19 +53,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 +77,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 +94,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 +107,67 @@ 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"
|
||||
help-rentprice: "&6/as rentprice &7-&r Verander de prijs van een huur gebied"
|
||||
help-buyprice: "&6/as buyprice &7-&r Verander de prijs van een koop gebied"
|
||||
help-rentduration: "&6/as rentduration &7-&r Verander de looptijd van een huur gebied"
|
||||
help-teleport: "&6/as tp &7-&r Teleporteer naar je gekochte/gehuurde gebieden"
|
||||
help-teleportAll: "&6/as tp &7-&r Teleporteer naar koop/huur gebieden"
|
||||
|
||||
rentrestore-help: "/as rentrestore <gebied> <true|false|general> [profiel]"
|
||||
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> [profiel]"
|
||||
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%'"
|
||||
|
||||
rentprice-noPermission: "Je hebt geen toestemming om de prijs van een huur gebied te veranderen"
|
||||
rentprice-help: "/as rentprice <gebied> <prijs>"
|
||||
rentprice-notRegistered: "%0% is niet geregistreerd als een huur gebied"
|
||||
rentprice-wrongPrice: "'%0%' is geen goede prijs"
|
||||
rentprice-success: "Prijs van gebied %0% is veranderd naar %1% per %2%"
|
||||
|
||||
buyprice-noPermission: "Je hebt geen toestemming om de prijs van een koop gebied te veranderen"
|
||||
buyprice-help: "/as buyprice <gebied> <prijs>"
|
||||
buyprice-notRegistered: "%0% is niet geregistreerd als koop gebied"
|
||||
buyprice-wrongPrice: "'%0%' is geen goede prijs"
|
||||
buyprice-success: "Prijs van gebied %0% is veranderd naar %1%"
|
||||
|
||||
rentduration-noPermission: "Je hebt geen toestemming om de looptijd van een huur gebied te veranderen"
|
||||
rentduration-help: "/as rentduration <gebied> <aantal> <soort>"
|
||||
rentduration-notRegistered: "%0% is niet geregistreerd als een huur gebied"
|
||||
rentduration-wrongPrice: "'%0%' is geen goede prijs, gebruik een geheel getal"
|
||||
rentduration-wrongFormat: "'%0%' is geen goed tijdformaat, bekijk de documentatie op Bukkit"
|
||||
rentduration-success: "Looptijd van gebeid %0% veranderd naar '%1%'"
|
||||
|
||||
setup-noRegion: "Je hebt geen gebied aangegeven op de tweede regel"
|
||||
setup-wrongRegion: "Het aangegeven gebied bestaat niet"
|
||||
setup-alreadyRentSign: "Het aangegeven gebied heeft al een bord voor huren"
|
||||
setup-alreadyBuySign: "Het aangegeven gebied heeft al een bord voor kopen"
|
||||
setup-noDuration: "Je hebt geen tijdsduur voor het huren aangegeven, zet dit op de derde regel"
|
||||
setup-wrongDuration: "De aangegeven tijdsduur is niet in het correcte formaat, voorbeeld: 1 dag"
|
||||
setup-noPrice: "Je hebt geen prijs aangegeven op de vierde regel"
|
||||
setup-wrongPrice: "Je hebt de prijs niet goed aangegeven, gebruik een nummer"
|
||||
setup-rentSuccess: "Huren van gebied %0% is goed opgezet"
|
||||
setup-buySuccess: "Kopen van gebied %0% is goed opgezet"
|
||||
setup-noPermissionRent: "Je hebt geen toestemming om huur gebieden op te zetten"
|
||||
setup-noPermissionBuy: "Je hebt geen toestemming om koop gebieden op te zetten"
|
||||
setup-couldNotDetect: "Meerdere gebieden gevonden met dezelfde prioriteit en/of parent/child relatie, geeft een specifieke aan op de tweede regel (2 van de gebieden die gevonden zijn: %0% en %1%)"
|
||||
|
||||
teleport-help: "/as tp <gebied> <aantal> <soort>"
|
||||
teleport-noRentOrBuy: "Gebied '%0%' is niet geregistreerd als koop of huur gebied"
|
||||
teleport-noPermission: "Je hebt geen toestemming om te teleporteren naar een gebied"
|
||||
teleport-noPermissionOther: "Je hebt geen toestemming om te teleporteren naar een gebied dat niet van jou is"
|
||||
teleport-success: "Je bent naar %0% geteleporteerd"
|
||||
teleport-noSafe: "Geen veilige plek gevonden in gebied %0%, verander het gebied of stel de teleporteer positie in"
|
||||
+90
-17
@@ -1,7 +1,8 @@
|
||||
name: AreaShop
|
||||
main: nl.evolutioncoding.AreaShop.AreaShop
|
||||
version: 1.0
|
||||
depend: [Vault, WorldGuard]
|
||||
version: 2.0.2
|
||||
depend: [Vault, WorldGuard, WorldEdit]
|
||||
softdepend: [Multiverse-Core]
|
||||
commands:
|
||||
AreaShop:
|
||||
description: For all commands use /as help
|
||||
@@ -11,7 +12,7 @@ commands:
|
||||
aliases: [as]
|
||||
permissions:
|
||||
areashop.*:
|
||||
description: Give access to all commands of RegionRent
|
||||
description: Give access to all commands of AreaShop
|
||||
children:
|
||||
areashop.help: true
|
||||
areashop.createrent: true
|
||||
@@ -22,11 +23,26 @@ 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.setrestore: true
|
||||
areashop.setprice: true
|
||||
areashop.rentduration: true
|
||||
areashop.teleportall: true
|
||||
areashop.setteleportall: true
|
||||
areashop.teleportsign: true
|
||||
areashop.tabcomplete: true
|
||||
areashop.setteleportoutsideregion: true
|
||||
areashop.find: true
|
||||
areashop.groupadd: true
|
||||
areashop.groupdel: true
|
||||
areashop.grouplist: true
|
||||
areashop.groupinfo: true
|
||||
areashop.limits.unlimited: true
|
||||
areashop.schematicevents: true
|
||||
areashop.addsign: true
|
||||
areashop.delsign: true
|
||||
areashop.help:
|
||||
description: Allows you to see the help pages
|
||||
default: true
|
||||
@@ -63,18 +79,75 @@ 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.setrestore:
|
||||
description: Allows you to change the restore settings
|
||||
default: op
|
||||
areashop.setprice:
|
||||
description: Allows you to change the price
|
||||
default: op
|
||||
areashop.rentduration:
|
||||
description: Allows you to change the duration of a rent
|
||||
default: op
|
||||
areashop.teleport:
|
||||
description: Teleport to your region
|
||||
default: true
|
||||
areashop.teleportall:
|
||||
description: Teleport to all regions
|
||||
default: true
|
||||
areashop.teleportsign:
|
||||
description: Teleport to signs of regions
|
||||
default: true
|
||||
areashop.setteleport:
|
||||
description: Set the teleport spot for your region
|
||||
default: true
|
||||
areashop.setteleportall:
|
||||
description: Set the teleport for other regions
|
||||
default: op
|
||||
areashop.setteleportoutsideregion:
|
||||
description: Set the teleport location outside the WorldGuard region
|
||||
default: op
|
||||
areashop.tabcomplete:
|
||||
description: Allows you to tabcomplete all commands (also where you dont have permission)
|
||||
default: op
|
||||
areashop.find:
|
||||
description: Allows you to teleport to a free region (/as find)
|
||||
default: true
|
||||
areashop.groupadd:
|
||||
description: Allows you to add regions to groups
|
||||
default: op
|
||||
areashop.groupdel:
|
||||
description: Allows you to delete regions from groups
|
||||
default: op
|
||||
areashop.grouplist:
|
||||
description: Allows you to list all the groups currently created
|
||||
default: op
|
||||
areashop.groupinfo:
|
||||
description: Allows you to display information about a group (all members)
|
||||
default: op
|
||||
areashop.rentextendbypass:
|
||||
description: Bypass the extend limit on rents
|
||||
default: op
|
||||
areashop.limits.default:
|
||||
description: Assign limits as set in the 'default' group in the 'limitGroups' section of the config
|
||||
default: not op
|
||||
areashop.limits.unlimited:
|
||||
description: Assign limits as set in the 'unlimited' group in the 'limitGroups' section of the config
|
||||
default: op
|
||||
areashop.schematicevents:
|
||||
description: Allows you to trigger schematic events for regions
|
||||
default: op
|
||||
areashop.addsign:
|
||||
description: Allows you to add signs to existing regions
|
||||
default: op
|
||||
areashop.delsign:
|
||||
description: Allows you to delete signs from existing regions
|
||||
default: op
|
||||
@@ -1,6 +1,8 @@
|
||||
package nl.evolutioncoding.AreaShop;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@@ -10,10 +12,12 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -22,52 +26,60 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
*/
|
||||
public final class AreaShop extends JavaPlugin {
|
||||
/* General variables */
|
||||
private static AreaShop instance = null;
|
||||
|
||||
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 CommandManager commandManager = null;
|
||||
private boolean configOk = false;
|
||||
private boolean debug = false;
|
||||
private String chatprefix = null;
|
||||
|
||||
/* Folder where the language files will be stored */
|
||||
public final String languageFolder = "lang";
|
||||
/* Folders and file names */
|
||||
public static final String languageFolder = "lang";
|
||||
public static final String schematicFolder = "schem";
|
||||
public static final String schematicExtension = ".schematic";
|
||||
public static final String regionsFolder = "regions";
|
||||
public static final String groupsFile = "groups.yml";
|
||||
public static final String defaultFile = "default.yml";
|
||||
public static final String versionFile = "versions";
|
||||
|
||||
/* Euro tag for in the config */
|
||||
public final String currencyEuro = "%euro%";
|
||||
public static final String currencyEuro = "%euro%";
|
||||
|
||||
/* Keys for adding things to the hashmap */
|
||||
public final String keyWorld = "world";
|
||||
public final String keyX = "x";
|
||||
public final String keyY = "y";
|
||||
public final String keyZ = "z";
|
||||
public final String keyDuration = "duration";
|
||||
public final String keyPrice = "price";
|
||||
public final String keyPlayer = "player";
|
||||
public final String keyRentedUntil = "rented";
|
||||
public final String keyName = "name";
|
||||
/* Constants for handling file versions */
|
||||
public static final String versionFiles = "files";
|
||||
public static final int versionFilesCurrent = 2;
|
||||
|
||||
/* Keys for replacing parts of flags */
|
||||
public final String tagPlayerName = "%player%";
|
||||
public final String tagRegionName = "%region%";
|
||||
public final String tagPrice = "%price%";
|
||||
public final String tagDuration = "%duration%";
|
||||
public final String tagRentedUntil = "%until%";
|
||||
|
||||
public static final String tagPlayerName = "%player%";
|
||||
public static final String tagPlayerUUID = "%uuid%";
|
||||
public static final String tagWorldName = "%world%";
|
||||
public static final String tagRegionName = "%region%";
|
||||
public static final String tagRegionType = "%type%";
|
||||
public static final String tagPrice = "%price%";
|
||||
public static final String tagDuration = "%duration%";
|
||||
public static final String tagRentedUntil = "%until%";
|
||||
public static final String tagRentedUntilShort = "%untilshort%";
|
||||
|
||||
public static AreaShop getInstance() {
|
||||
return AreaShop.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on start or reload of the server
|
||||
*/
|
||||
public void onEnable(){
|
||||
AreaShop.instance = this;
|
||||
boolean error = false;
|
||||
|
||||
/* Save a copy of the default config.yml if one is not present */
|
||||
this.saveDefaultConfig();
|
||||
|
||||
/* Check the config, loads default if errors */
|
||||
configOk = this.checkConfig();
|
||||
|
||||
debug = this.getConfig().getBoolean("debug");
|
||||
configOk = true;
|
||||
|
||||
/* Check if WorldGuard is present */
|
||||
Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
|
||||
@@ -76,6 +88,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);
|
||||
@@ -92,26 +113,36 @@ public final class AreaShop extends JavaPlugin {
|
||||
/* Save the chatPrefix */
|
||||
chatprefix = this.config().getString("chatPrefix");
|
||||
|
||||
/* Load all data from files */
|
||||
shopManager = new ShopManager(this);
|
||||
error = error & !shopManager.loadRents();
|
||||
shopManager.checkRents();
|
||||
error = error & !shopManager.loadBuys();
|
||||
/* Load all data from files and check versions */
|
||||
fileManager = new FileManager(this);
|
||||
error = error & !fileManager.loadFiles();
|
||||
fileManager.checkRents();
|
||||
|
||||
/* Save a copy of the default config.yml if one is not present */
|
||||
this.saveDefaultConfig();
|
||||
|
||||
if(error) {
|
||||
this.getLogger().info("The plugin has not started, fix the errors listed above");
|
||||
} else {
|
||||
/* Register the event listeners */
|
||||
// Register the event listeners
|
||||
this.getServer().getPluginManager().registerEvents(new SignChangeListener(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new SignBreakListener(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new RightClickListener(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new SignClickListener(this), this);
|
||||
|
||||
/* Start thread for checking renting */
|
||||
// Start thread for checking renting
|
||||
int checkDelay = Integer.parseInt(this.config().getString("checkDelay"))*20;
|
||||
new RentCheck(this).runTaskTimer(this, checkDelay, checkDelay);
|
||||
|
||||
/* Bind commands for this plugin */
|
||||
getCommand("AreaShop").setExecutor(new ShopCommands(this));
|
||||
// Bind commands for this plugin
|
||||
commandManager = new CommandManager(this);
|
||||
|
||||
// Enable Metrics if config allows it
|
||||
if(this.config().getBoolean("sendStats")) {
|
||||
this.startMetrics();
|
||||
}
|
||||
|
||||
// Register dynamic permission (things declared in config)
|
||||
registerDynamicPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -138,13 +169,29 @@ public final class AreaShop extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the WorldGuard plugin
|
||||
* @return WorldGuardPlugin
|
||||
* Function to get the WorldEdit plugin
|
||||
* @return WorldEditPlugin
|
||||
*/
|
||||
public WorldEditPlugin getWorldEdit() {
|
||||
return worldEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the LanguageManager
|
||||
* @return the LanguageManager
|
||||
*/
|
||||
public LanguageManager getLanguageManager() {
|
||||
return languageManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the CommandManager
|
||||
* @return the CommandManager
|
||||
*/
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the Vault plugin
|
||||
* @return Economy
|
||||
@@ -154,36 +201,70 @@ 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 getFileManager() {
|
||||
return fileManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register dynamic permissions controlled by config settings
|
||||
*/
|
||||
public void registerDynamicPermissions() {
|
||||
// Register limit groups of amount of regions a player can have
|
||||
for(String group : config().getConfigurationSection("limitGroups").getKeys(false)) {
|
||||
if(!"unlimited".equals(group) && !"default".equals(group)) {
|
||||
Permission perm = new Permission("areashop.limits." + group);
|
||||
Bukkit.getPluginManager().addPermission(perm);
|
||||
}
|
||||
}
|
||||
Bukkit.getPluginManager().recalculatePermissionDefaults(Bukkit.getPluginManager().getPermission("playerwarps.limits"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to send a message to a CommandSender, using chatprefix if it is a player
|
||||
* @param target The CommandSender you wan't to send the message to (e.g. a player)
|
||||
* @param key The key to get the translation
|
||||
* @param prefix Specify if the message should have a prefix
|
||||
* @param params The parameters to inject into the message string
|
||||
*/
|
||||
public void message(Object target, String key, Object... params) {
|
||||
public void configurableMessage(Object target, String key, boolean prefix, Object... params) {
|
||||
String langString = this.fixColors(languageManager.getLang(key, params));
|
||||
if(langString == null) {
|
||||
this.getLogger().info("Something is wrong with the language file, could not find key: " + key);
|
||||
} else if(langString.equals("")) {
|
||||
// Do nothing, message is disabled
|
||||
} else {
|
||||
if(target instanceof Player) {
|
||||
((Player)target).sendMessage(this.fixColors(chatprefix) + langString);
|
||||
if(prefix) {
|
||||
((Player)target).sendMessage(this.fixColors(chatprefix) + langString);
|
||||
} else {
|
||||
((Player)target).sendMessage(langString);
|
||||
}
|
||||
} else if(target instanceof CommandSender) {
|
||||
if(!config().getBoolean("useColorsInConsole")) {
|
||||
langString = ChatColor.stripColor(langString);
|
||||
}
|
||||
((CommandSender)target).sendMessage(langString);
|
||||
}
|
||||
else if(target instanceof Logger) {
|
||||
if(!config().getBoolean("useColorsInConsole")) {
|
||||
langString = ChatColor.stripColor(langString);
|
||||
}
|
||||
((Logger)target).info(langString);
|
||||
} else {
|
||||
langString = ChatColor.stripColor(langString);
|
||||
this.getLogger().info("Could not send message, target is wrong: " + langString);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void messageNoPrefix(Object target, String key, Object... params) {
|
||||
configurableMessage(target, key, false, params);
|
||||
}
|
||||
public void message(Object target, String key, Object... params) {
|
||||
configurableMessage(target, key, true, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert color and formatting codes to bukkit values
|
||||
@@ -206,13 +287,19 @@ public final class AreaShop extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currency character, fixes problems with euro character acting weird
|
||||
* @return Currency character
|
||||
* Format the currency amount with the characters before and after
|
||||
* @return Currency character format string
|
||||
* @param amount Amount of money to format
|
||||
*/
|
||||
public String getCurrencyCharacter() {
|
||||
String result = this.config().getString("moneyCharacter");
|
||||
result = result.replace(currencyEuro, "\u20ac");
|
||||
return result;
|
||||
public String formatCurrency(String amount) {
|
||||
String before = this.config().getString("moneyCharacter");
|
||||
before = before.replace(currencyEuro, "\u20ac");
|
||||
String after = this.config().getString("moneyCharacterAfter");
|
||||
after = after.replace(currencyEuro, "\u20ac");
|
||||
return before + amount + after;
|
||||
}
|
||||
public String formatCurrency(double amount) {
|
||||
return this.formatCurrency("" + amount);
|
||||
}
|
||||
|
||||
|
||||
@@ -237,195 +324,52 @@ public final class AreaShop extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the help page for the player
|
||||
* @param player The player to show the help to
|
||||
* Start the Metrics stats collection
|
||||
*/
|
||||
public void showHelp(CommandSender target) {
|
||||
/* Set up the list of messages to be sent */
|
||||
ArrayList<String> messages = new ArrayList<String>();
|
||||
messages.add(this.config().getString("chatPrefix") + languageManager.getLang("help-header"));
|
||||
messages.add(this.config().getString("chatPrefix") + languageManager.getLang("help-alias"));
|
||||
if(target.hasPermission("areashop.help")) {
|
||||
messages.add(languageManager.getLang("help-help"));
|
||||
private void startMetrics() {
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
} catch (IOException e) {
|
||||
AreaShop.debug("Could not start Metrics");
|
||||
}
|
||||
if(target.hasPermission("areashop.info")) {
|
||||
messages.add(languageManager.getLang("help-info"));
|
||||
}
|
||||
if(target.hasPermission("areashop.rent")) {
|
||||
messages.add(languageManager.getLang("help-rent"));
|
||||
}
|
||||
if(target.hasPermission("areashop.buy")) {
|
||||
messages.add(languageManager.getLang("help-buy"));
|
||||
}
|
||||
if(target.hasPermission("areashop.unrent")) {
|
||||
messages.add(languageManager.getLang("help-unrent"));
|
||||
} else if(target.hasPermission("areashop.unrentown")) {
|
||||
messages.add(languageManager.getLang("help-unrentOwn"));
|
||||
}
|
||||
if(target.hasPermission("areashop.sell")) {
|
||||
messages.add(languageManager.getLang("help-sell"));
|
||||
} 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.updatebuysigns")) {
|
||||
messages.add(languageManager.getLang("help-updatebuysigns"));
|
||||
}
|
||||
if(target.hasPermission("areashop.updaterentregions")) {
|
||||
messages.add(languageManager.getLang("help-updaterentregions"));
|
||||
}
|
||||
if(target.hasPermission("areashop.updatebuyregions")) {
|
||||
messages.add(languageManager.getLang("help-updatebuyregions"));
|
||||
}
|
||||
if(target.hasPermission("areashop.reload")) {
|
||||
messages.add(languageManager.getLang("help-reload"));
|
||||
}
|
||||
|
||||
/* Send them all */
|
||||
for(int i=0; i<messages.size(); i++) {
|
||||
target.sendMessage(this.fixColors(messages.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the config for errors, loads default config if they occur
|
||||
* Checks if the string is a correct time period
|
||||
* @param time String that has to be checked
|
||||
* @return true if format is correct, false if not
|
||||
*/
|
||||
public boolean checkConfig() {
|
||||
int error = 0;
|
||||
debug = this.getConfig().getString("debug").equalsIgnoreCase("true");
|
||||
|
||||
/* GENERAL */
|
||||
String chatPrefix = this.getConfig().getString("chatPrefix");
|
||||
if (chatPrefix.length() == 0) {
|
||||
this.getLogger().info("Config-Error: chatPrefix has length zero");
|
||||
error++;
|
||||
}
|
||||
String moneyCharacter = this.getCurrencyCharacter();
|
||||
if (moneyCharacter.length() > 14) {
|
||||
this.getLogger().info("Config-Error: moneyCharacter is longer than 14 characters");
|
||||
error++;
|
||||
}
|
||||
String maximumTotal = this.getConfig().getString("maximumTotal");
|
||||
try {
|
||||
int maximumTotalInt = Integer.parseInt(maximumTotal);
|
||||
if(maximumTotalInt < -1) {
|
||||
this.getLogger().info("Config-Error: maximumTotal must be -1 or higher");
|
||||
error++;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
this.getLogger().info("Config-Error: maximumTotal is not a valid number");
|
||||
error++;
|
||||
public boolean checkTimeFormat(String time) {
|
||||
/* Check if the string is not empty and check the length */
|
||||
if(time == null || time.length() <= 1 || time.indexOf(' ') == -1 || time.indexOf(' ') >= (time.length()-1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* RENTING */
|
||||
String rentSign = this.getConfig().getString("rentSign");
|
||||
if (rentSign.length() > 15) {
|
||||
this.getLogger().info("Config-Error: rentSign is too long, maximum length is 15 characters");
|
||||
error++;
|
||||
}
|
||||
String signRentable = this.getConfig().getString("signRentable");
|
||||
if (signRentable.length() > 15) {
|
||||
this.getLogger().info("Config-Error: signRentable is too long, maximum length is 15 characters");
|
||||
error++;
|
||||
}
|
||||
String signRented = this.getConfig().getString("signRented");
|
||||
if (signRented.length() > 15) {
|
||||
this.getLogger().info("Config-Error: signRented is too long, maximum length is 15 characters");
|
||||
error++;
|
||||
}
|
||||
String maximumRents = this.getConfig().getString("maximumRents");
|
||||
try {
|
||||
int maximumRentsInt = Integer.parseInt(maximumRents);
|
||||
if(maximumRentsInt < -1) {
|
||||
this.getLogger().info("Config-Error: maximumRents must be -1 or higher");
|
||||
error++;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
this.getLogger().info("Config-Error: maximumRents is not a valid number");
|
||||
error++;
|
||||
}
|
||||
String rentMoneyBack = this.getConfig().getString("rentMoneyBack");
|
||||
try {
|
||||
int rentMoneyBackInt = Integer.parseInt(rentMoneyBack);
|
||||
if(rentMoneyBackInt < 0 || rentMoneyBackInt > 100) {
|
||||
this.getLogger().info("Config-Error: rentMoneyBack must be between 0 and 100");
|
||||
error++;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
this.getLogger().info("Config-Error: rentMoneyBack is not a valid number");
|
||||
error++;
|
||||
}
|
||||
String checkDelay = this.getConfig().getString("checkDelay");
|
||||
try {
|
||||
int checkDelayInt = Integer.parseInt(checkDelay);
|
||||
if(checkDelayInt < 1) {
|
||||
this.getLogger().info("Config-Error: checkDelay can't be below 1");
|
||||
error++;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
this.getLogger().info("Config-Error: checkDelay is not a valid number");
|
||||
error++;
|
||||
/* Check if the suffix is one of these values */
|
||||
String suffix = time.substring(time.indexOf(' ')+1, time.length());
|
||||
ArrayList<String> identifiers = new ArrayList<String>();
|
||||
identifiers.addAll(this.config().getStringList("minutes"));
|
||||
identifiers.addAll(this.config().getStringList("hours"));
|
||||
identifiers.addAll(this.config().getStringList("days"));
|
||||
identifiers.addAll(this.config().getStringList("months"));
|
||||
identifiers.addAll(this.config().getStringList("years"));
|
||||
if(!identifiers.contains(suffix)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* BUYING */
|
||||
String buySign = this.getConfig().getString("buySign");
|
||||
if (buySign.length() > 15) {
|
||||
this.getLogger().info("Config-Error: buySign is too long, maximum length is 15 characters");
|
||||
error++;
|
||||
}
|
||||
String signBuyable = this.getConfig().getString("signBuyable");
|
||||
if (signBuyable.length() > 15) {
|
||||
this.getLogger().info("Config-Error: signBuyable is too long, maximum length is 15 characters");
|
||||
error++;
|
||||
}
|
||||
String signBuyed = this.getConfig().getString("signBuyed");
|
||||
if (signBuyed.length() > 15) {
|
||||
this.getLogger().info("Config-Error: signBuyed is too long, maximum length is 15 characters");
|
||||
error++;
|
||||
}
|
||||
String maximumBuys = this.getConfig().getString("maximumBuys");
|
||||
try {
|
||||
int maximumBuysInt = Integer.parseInt(maximumBuys);
|
||||
if(maximumBuysInt < -1) {
|
||||
this.getLogger().info("Config-Error: maximumBuys must be -1 or higher");
|
||||
error++;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
this.getLogger().info("Config-Error: maximumBuys is not a valid number");
|
||||
error++;
|
||||
}
|
||||
String buyMoneyBack = this.getConfig().getString("buyMoneyBack");
|
||||
try {
|
||||
int buyMoneyBackInt = Integer.parseInt(buyMoneyBack);
|
||||
if(buyMoneyBackInt < 0 || buyMoneyBackInt > 100) {
|
||||
this.getLogger().info("Config-Error: buyMoneyBack must be between 0 and 100");
|
||||
error++;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
this.getLogger().info("Config-Error: buyMoneyBack is not a valid number");
|
||||
error++;
|
||||
}
|
||||
|
||||
/* Load default config if errors have occurred */
|
||||
if (error > 0) {
|
||||
this.getLogger().info("The plugin has " + error + " error(s) in the config, default config will be used");
|
||||
}
|
||||
|
||||
/* return true if no errors, false if there are errors */
|
||||
return (error == 0);
|
||||
/* check if the part before the space is a number */
|
||||
String prefix = time.substring(0, (time.indexOf(' ')));
|
||||
return prefix.matches("\\d+");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an debug message to the console
|
||||
* @param message The message that should be printed to the console
|
||||
*/
|
||||
public void debug(String message) {
|
||||
if(this.debug) {
|
||||
this.getLogger().info("Debug: " + message);
|
||||
public static void debug(String message) {
|
||||
if(AreaShop.getInstance().debug) {
|
||||
AreaShop.getInstance().getLogger().info("Debug: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,10 +379,52 @@ public final class AreaShop extends JavaPlugin {
|
||||
public void reload() {
|
||||
this.saveDefaultConfig();
|
||||
this.reloadConfig();
|
||||
configOk = this.checkConfig();
|
||||
configOk = true;
|
||||
chatprefix = this.config().getString("chatPrefix");
|
||||
debug = this.getConfig().getBoolean("debug");
|
||||
languageManager = new LanguageManager(this);
|
||||
shopManager.checkRents();
|
||||
fileManager.loadFiles();
|
||||
fileManager.checkRents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion to name by uuid
|
||||
* @param uuid The uuid in string format
|
||||
* @return the name of the player
|
||||
*/
|
||||
public String toName(String uuid) {
|
||||
if(uuid == null) {
|
||||
return null;
|
||||
} else {
|
||||
return this.toName(UUID.fromString(uuid));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Conversion to name by uuid object
|
||||
* @param uuid The uuid in string format
|
||||
* @return the name of the player
|
||||
*/
|
||||
public String toName(UUID uuid) {
|
||||
if(uuid == null) {
|
||||
return null;
|
||||
} else {
|
||||
return Bukkit.getOfflinePlayer(uuid).getName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion from name to uuid
|
||||
* @param name The name of the player
|
||||
* @return The uuid of the player
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // Fake deprecation by Bukkit to inform developers, method will stay
|
||||
public String toUUID(String name) {
|
||||
if(name == null) {
|
||||
return null;
|
||||
} else {
|
||||
return Bukkit.getOfflinePlayer(name).getUniqueId().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
package nl.evolutioncoding.AreaShop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.commands.AddCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.AddsignCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.BuyCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.CommandAreaShop;
|
||||
import nl.evolutioncoding.AreaShop.commands.DelCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.DelsignCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.FindCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.GroupaddCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.GroupdelCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.GroupinfoCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.GrouplistCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.HelpCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.InfoCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.ReloadCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.RentCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.RentdurationCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.SchematiceventCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.SellCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.SetpriceCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.SetrestoreCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.SetteleportCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.TeleportCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.UnrentCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.UpdatebuysCommand;
|
||||
import nl.evolutioncoding.AreaShop.commands.UpdaterentsCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
AreaShop plugin;
|
||||
ArrayList<CommandAreaShop> commands;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param plugin The AreaShop plugin
|
||||
*/
|
||||
public CommandManager(AreaShop plugin) {
|
||||
this.plugin = plugin;
|
||||
commands = new ArrayList<CommandAreaShop>();
|
||||
commands.add(new HelpCommand(plugin));
|
||||
commands.add(new RentCommand(plugin));
|
||||
commands.add(new UnrentCommand(plugin));
|
||||
commands.add(new BuyCommand(plugin));
|
||||
commands.add(new SellCommand(plugin));
|
||||
commands.add(new InfoCommand(plugin));
|
||||
commands.add(new TeleportCommand(plugin));
|
||||
commands.add(new SetteleportCommand(plugin));
|
||||
commands.add(new FindCommand(plugin));
|
||||
commands.add(new UpdaterentsCommand(plugin));
|
||||
commands.add(new UpdatebuysCommand(plugin));
|
||||
commands.add(new SetrestoreCommand(plugin));
|
||||
commands.add(new SetpriceCommand(plugin));
|
||||
commands.add(new RentdurationCommand(plugin));
|
||||
commands.add(new ReloadCommand(plugin));
|
||||
commands.add(new GroupaddCommand(plugin));
|
||||
commands.add(new GroupdelCommand(plugin));
|
||||
commands.add(new GrouplistCommand(plugin));
|
||||
commands.add(new GroupinfoCommand(plugin));
|
||||
commands.add(new SchematiceventCommand(plugin));
|
||||
commands.add(new AddCommand(plugin));
|
||||
commands.add(new DelCommand(plugin));
|
||||
commands.add(new AddsignCommand(plugin));
|
||||
commands.add(new DelsignCommand(plugin));
|
||||
|
||||
/* Register commands in bukkit */
|
||||
plugin.getCommand("AreaShop").setExecutor(this);
|
||||
plugin.getCommand("AreaShop").setTabCompleter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list with AreaShop commands
|
||||
* @return The list with AreaShop commands
|
||||
*/
|
||||
public ArrayList<CommandAreaShop> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the help page for the CommandSender
|
||||
* @param target The CommandSender to show the help to
|
||||
*/
|
||||
public void showHelp(CommandSender target) {
|
||||
/* Add all messages to a list */
|
||||
ArrayList<String> messages = new ArrayList<String>();
|
||||
messages.add(plugin.config().getString("chatPrefix") + plugin.getLanguageManager().getLang("help-header"));
|
||||
messages.add(plugin.config().getString("chatPrefix") + plugin.getLanguageManager().getLang("help-alias"));
|
||||
for(CommandAreaShop command : commands) {
|
||||
String help = command.getHelp(target);
|
||||
if(help != null && help.length() != 0) {
|
||||
messages.add(help);
|
||||
}
|
||||
}
|
||||
|
||||
/* Send the messages to the target */
|
||||
for(String message : messages) {
|
||||
if(!plugin.config().getBoolean("useColorsInConsole") && !(target instanceof Player)) {
|
||||
target.sendMessage(ChatColor.stripColor(plugin.fixColors(message)));
|
||||
} else {
|
||||
target.sendMessage(plugin.fixColors(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
|
||||
boolean executed = false;
|
||||
for(int i=0; i<commands.size() && !executed; i++) {
|
||||
if(commands.get(i).canExecute(command, args)) {
|
||||
commands.get(i).execute(sender, command, args);
|
||||
executed = true;
|
||||
}
|
||||
}
|
||||
if(!executed && args.length == 0) {
|
||||
this.showHelp(sender);
|
||||
} else if(!executed && args.length > 0) {
|
||||
plugin.message(sender, "cmd-notValid");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(!sender.hasPermission("areashop.tabcomplete")) {
|
||||
return result;
|
||||
}
|
||||
int toCompleteNumber = args.length;
|
||||
String toCompletePrefix = args[args.length-1].toLowerCase();
|
||||
AreaShop.debug("toCompleteNumber=" + toCompleteNumber + ", toCompletePrefix=" + toCompletePrefix + ", length=" + toCompletePrefix.length());
|
||||
if(toCompleteNumber == 1) {
|
||||
for(CommandAreaShop c : commands) {
|
||||
String begin = c.getCommandStart();
|
||||
result.add(begin.substring(begin.indexOf(' ') +1));
|
||||
}
|
||||
} else {
|
||||
String[] start = new String[args.length];
|
||||
start[0] = command.getName();
|
||||
for(int i=1; i<args.length; i++) {
|
||||
start[i] = args[i-1];
|
||||
}
|
||||
for(CommandAreaShop c : commands) {
|
||||
if(c.canExecute(command, args)) {
|
||||
result = c.getTabCompleteList(toCompleteNumber, start);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Filter and sort the results
|
||||
if(result.size() > 0) {
|
||||
SortedSet<String> set = new TreeSet<String>();
|
||||
for(String suggestion : result) {
|
||||
if(suggestion.toLowerCase().startsWith(toCompletePrefix)) {
|
||||
set.add(suggestion);
|
||||
}
|
||||
}
|
||||
result.clear();
|
||||
result.addAll(set);
|
||||
}
|
||||
AreaShop.debug("Tabcomplete #" + toCompleteNumber + ", prefix="+ toCompletePrefix + ", result=" + result.toString());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package nl.evolutioncoding.AreaShop.Exceptions;
|
||||
|
||||
public class RegionCreateException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public RegionCreateException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,984 @@
|
||||
package nl.evolutioncoding.AreaShop;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.Exceptions.RegionCreateException;
|
||||
import nl.evolutioncoding.AreaShop.regions.BuyRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion.RegionEvent;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion.RegionType;
|
||||
import nl.evolutioncoding.AreaShop.regions.RegionGroup;
|
||||
import nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class FileManager {
|
||||
private static FileManager instance = null;
|
||||
|
||||
private AreaShop plugin = null;
|
||||
private ObjectInputStream input = null;
|
||||
private ObjectOutputStream output = null;
|
||||
private HashMap<String, GeneralRegion> regions = null;
|
||||
private String regionsPath = null;
|
||||
private HashMap<String, RegionGroup> groups = null;
|
||||
private String groupsPath = null;
|
||||
private YamlConfiguration groupsConfig = null;
|
||||
private String defaultPath = null;
|
||||
private YamlConfiguration defaultConfig = null;
|
||||
|
||||
private HashMap<String,Integer> versions = null;
|
||||
private String versionPath = null;
|
||||
private String schemFolder = null;
|
||||
|
||||
/**
|
||||
* Constructor, initialize variabeles
|
||||
* @param plugin
|
||||
*/
|
||||
public FileManager(AreaShop plugin) {
|
||||
this.plugin = plugin;
|
||||
regions = new HashMap<String, GeneralRegion>();
|
||||
regionsPath = plugin.getDataFolder() + File.separator + AreaShop.regionsFolder;
|
||||
groups = new HashMap<String, RegionGroup>();
|
||||
groupsPath = plugin.getDataFolder() + File.separator + AreaShop.groupsFile;
|
||||
defaultPath = plugin.getDataFolder() + File.separator + AreaShop.defaultFile;
|
||||
versionPath = plugin.getDataFolder().getPath() + File.separator + AreaShop.versionFile;
|
||||
schemFolder = plugin.getDataFolder() + File.separator + AreaShop.schematicFolder;
|
||||
File schemFile = new File(schemFolder);
|
||||
if(!schemFile.exists()) {
|
||||
schemFile.mkdirs();
|
||||
}
|
||||
loadVersions();
|
||||
}
|
||||
|
||||
public static FileManager getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new FileManager(AreaShop.getInstance());
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// GETTERS
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
public AreaShop getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public String getSchematicFolder() {
|
||||
return schemFolder;
|
||||
}
|
||||
|
||||
public RegionGroup getGroup(String name) {
|
||||
return groups.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public Collection<RegionGroup> getGroups() {
|
||||
return groups.values();
|
||||
}
|
||||
|
||||
public YamlConfiguration getDefaultSettings() {
|
||||
return defaultConfig;
|
||||
}
|
||||
|
||||
public GeneralRegion getRegion(String name) {
|
||||
return regions.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public RentRegion getRent(String name) {
|
||||
GeneralRegion region = regions.get(name.toLowerCase());
|
||||
if(region != null && region.isRentRegion()) {
|
||||
return (RentRegion)region;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BuyRegion getBuy(String name) {
|
||||
GeneralRegion region = regions.get(name.toLowerCase());
|
||||
if(region != null && region.isBuyRegion()) {
|
||||
return (BuyRegion)region;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<RentRegion> getRents() {
|
||||
List<RentRegion> result = new ArrayList<RentRegion>();
|
||||
for(GeneralRegion region : regions.values()) {
|
||||
if(region.isRentRegion()) {
|
||||
result.add((RentRegion)region);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<BuyRegion> getBuys() {
|
||||
List<BuyRegion> result = new ArrayList<BuyRegion>();
|
||||
for(GeneralRegion region : regions.values()) {
|
||||
if(region.isBuyRegion()) {
|
||||
result.add((BuyRegion)region);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<GeneralRegion> getRegions() {
|
||||
return new ArrayList<GeneralRegion>(regions.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of names of a certain group of things
|
||||
* @return A String list with all the names
|
||||
*/
|
||||
public List<String> getBuyNames() {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
for(BuyRegion region : getBuys()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<String> getRentNames() {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
for(RentRegion region : getRents()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<String> getRegionNames() {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
for(GeneralRegion region : getRegions()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<String> getGroupNames() {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
for(RegionGroup group : getGroups()) {
|
||||
result.add(group.getName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a rent to the list
|
||||
* @param regionName Name of the region that can be rented
|
||||
* @param rent Map containing all the info for a rent
|
||||
*/
|
||||
public void addRent(RentRegion rent) {
|
||||
if(rent == null) {
|
||||
AreaShop.debug("Tried adding a null rent!");
|
||||
}
|
||||
regions.put(rent.getName().toLowerCase(), rent);
|
||||
rent.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a buy to the list
|
||||
* @param regionName Name of the region that can be buyed
|
||||
* @param buy Map containing all the info for a buy
|
||||
*/
|
||||
public void addBuy(BuyRegion buy) {
|
||||
if(buy == null) {
|
||||
AreaShop.debug("Tried adding a null buy!");
|
||||
}
|
||||
regions.put(buy.getName().toLowerCase(), buy);
|
||||
buy.save();
|
||||
}
|
||||
|
||||
public void addGroup(RegionGroup group) {
|
||||
groups.put(group.getName().toLowerCase(), group);
|
||||
String lowGroup = group.getName().toLowerCase();
|
||||
ConfigurationSection result = groupsConfig.getConfigurationSection(lowGroup);
|
||||
if(result == null) {
|
||||
result = groupsConfig.createSection(lowGroup);
|
||||
groupsConfig.set(lowGroup + ".name", group.getName());
|
||||
groupsConfig.set(lowGroup + ".priority", 0);
|
||||
}
|
||||
saveGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a rent from the list
|
||||
* @param regionName
|
||||
*/
|
||||
public boolean removeRent(RentRegion rent, boolean giveMoneyBack) {
|
||||
boolean result = false;
|
||||
if(rent != null) {
|
||||
if(rent.isRented()) {
|
||||
rent.unRent(giveMoneyBack);
|
||||
}
|
||||
// Handle schematics and run commands
|
||||
rent.handleSchematicEvent(RegionEvent.DELETED);
|
||||
rent.runEventCommands(RegionEvent.DELETED, true);
|
||||
|
||||
/* Delete the sign and the variable */
|
||||
if(rent.getWorld() != null) {
|
||||
for(Location sign : rent.getSignLocations()) {
|
||||
sign.getBlock().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
RegionGroup[] groups = getGroups().toArray(new RegionGroup[getGroups().size()]);
|
||||
for(RegionGroup group : groups) {
|
||||
group.removeMember(rent);
|
||||
}
|
||||
rent.resetRegionFlags();
|
||||
regions.remove(rent.getLowerCaseName());
|
||||
File file = new File(plugin.getDataFolder() + File.separator + AreaShop.regionsFolder + File.separator + rent.getLowerCaseName() + ".yml");
|
||||
boolean deleted = true;
|
||||
try {
|
||||
deleted = file.delete();
|
||||
} catch(Exception e) {
|
||||
deleted = false;
|
||||
}
|
||||
if(!deleted) {
|
||||
plugin.getLogger().warning("File could not be deleted: " + file.toString());
|
||||
}
|
||||
|
||||
|
||||
result = true;
|
||||
|
||||
// Run commands
|
||||
rent.runEventCommands(RegionEvent.DELETED, false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a region by providing a location of the sign
|
||||
* @param location The locatin of the sign
|
||||
* @return The generalRegion that has a sign at this location
|
||||
*/
|
||||
public GeneralRegion getRegionBySignLocation(Location location) {
|
||||
for(GeneralRegion region : getRegions()) {
|
||||
if(region.isSignOfRegion(location)) {
|
||||
return region;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a buy from the list
|
||||
* @param regionName
|
||||
*/
|
||||
public boolean removeBuy(BuyRegion buy, boolean giveMoneyBack) {
|
||||
boolean result = false;
|
||||
if(buy != null) {
|
||||
if(buy.isSold()) {
|
||||
buy.sell(giveMoneyBack);
|
||||
}
|
||||
// Handle schematics and run commands
|
||||
buy.handleSchematicEvent(RegionEvent.DELETED);
|
||||
buy.runEventCommands(RegionEvent.DELETED, true);
|
||||
|
||||
// Delete the sign and the variable
|
||||
if(buy.getWorld() != null) {
|
||||
for(Location sign : buy.getSignLocations()) {
|
||||
sign.getBlock().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
regions.remove(buy.getLowerCaseName());
|
||||
buy.resetRegionFlags();
|
||||
|
||||
// Removing from groups
|
||||
for(RegionGroup group : getGroups()) {
|
||||
group.removeMember(buy);
|
||||
}
|
||||
|
||||
// Deleting the file
|
||||
File file = new File(plugin.getDataFolder() + File.separator + AreaShop.regionsFolder + File.separator + buy.getLowerCaseName() + ".yml");
|
||||
boolean deleted = true;
|
||||
try {
|
||||
deleted = file.delete();
|
||||
} catch(Exception e) {
|
||||
deleted = false;
|
||||
}
|
||||
if(!deleted) {
|
||||
plugin.getLogger().warning("File could not be deleted: " + file.toString());
|
||||
}
|
||||
|
||||
result = true;
|
||||
|
||||
// Run commands
|
||||
buy.runEventCommands(RegionEvent.DELETED, false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a group
|
||||
* @param group Group to remove
|
||||
*/
|
||||
public void removeGroup(RegionGroup group) {
|
||||
groups.remove(group.getLowerCaseName());
|
||||
groupsConfig.set(group.getLowerCaseName(), null);
|
||||
saveGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all rent signs
|
||||
* @return true if all signs are updated, otherwise false
|
||||
*/
|
||||
public boolean updateRentSigns() {
|
||||
boolean result = true;
|
||||
for(RentRegion rent : getRents()) {
|
||||
result = result & rent.updateSigns();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all buy signs
|
||||
* @return true if all signs are updated, otherwise false
|
||||
*/
|
||||
public boolean updateBuySigns() {
|
||||
boolean result = true;
|
||||
for(BuyRegion buy : getBuys()) {
|
||||
result = result & buy.updateSigns();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all regions registered for renting
|
||||
*/
|
||||
public void updateRentRegions() {
|
||||
for(RentRegion rent : getRents()) {
|
||||
rent.updateRegionFlags();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all regions registered for buying
|
||||
*/
|
||||
public void updateBuyRegions() {
|
||||
for(BuyRegion buy : getBuys()) {
|
||||
buy.updateRegionFlags();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveGroups() {
|
||||
try {
|
||||
groupsConfig.save(groupsPath);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("Groups file could not be saved: " + groupsPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save all region related files
|
||||
*/
|
||||
public void saveAll() {
|
||||
// Safe regions
|
||||
for(GeneralRegion region : getRegions()) {
|
||||
region.save();
|
||||
}
|
||||
|
||||
// Safe groups and default config
|
||||
this.saveGroups();
|
||||
try {
|
||||
defaultConfig.save(defaultPath);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("Default file could not be saved: " + defaultPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getRegionFolder() {
|
||||
return regionsPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unrent region that have no time left
|
||||
*/
|
||||
public void checkRents() {
|
||||
/* Check if regions and signs are still present */
|
||||
long now = Calendar.getInstance().getTimeInMillis();
|
||||
for(RentRegion rent : getRents()) {
|
||||
if(rent.isRented() && now > rent.getRentedUntil()) {
|
||||
/* Send message to the player if online */
|
||||
Player player = Bukkit.getPlayer(rent.getRenter());
|
||||
if(player != null) {
|
||||
plugin.message(player, "unrent-expired", rent.getName());
|
||||
}
|
||||
rent.unRent(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the file with the versions, used to check if the other files need conversion
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loadVersions() {
|
||||
File file = new File(versionPath);
|
||||
if(file.exists()) {
|
||||
/* Load versions from the file */
|
||||
try {
|
||||
input = new ObjectInputStream(new FileInputStream(versionPath));
|
||||
versions = (HashMap<String,Integer>)input.readObject();
|
||||
input.close();
|
||||
} catch (IOException | ClassNotFoundException | ClassCastException e) {
|
||||
plugin.getLogger().info("Error: Something went wrong reading file: " + versionPath);
|
||||
versions = null;
|
||||
}
|
||||
}
|
||||
if(versions == null || versions.size() == 0) {
|
||||
versions = new HashMap<String, Integer>();
|
||||
versions.put(AreaShop.versionFiles, 0);
|
||||
this.saveVersions();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the versions file to disk
|
||||
*/
|
||||
public void saveVersions() {
|
||||
if(!(new File(versionPath).exists())) {
|
||||
plugin.getLogger().info("versions file created, this should happen only after installing or upgrading the plugin");
|
||||
}
|
||||
try {
|
||||
output = new ObjectOutputStream(new FileOutputStream(versionPath));
|
||||
output.writeObject(versions);
|
||||
output.close();
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().info("File could not be saved: " + versionPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all files from disk
|
||||
* @return true
|
||||
*/
|
||||
public boolean loadFiles() {
|
||||
boolean result = false;
|
||||
|
||||
convertFiles();
|
||||
|
||||
// Load regions
|
||||
File file = new File(regionsPath);
|
||||
if(!file.exists()) {
|
||||
file.mkdirs();
|
||||
} else if(file.isDirectory()) {
|
||||
for(File region : file.listFiles()) {
|
||||
if(region.isFile()) {
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(region);
|
||||
if(RegionType.RENT.getValue().equals(config.getString("general.type"))) {
|
||||
try {
|
||||
RentRegion rent = new RentRegion(plugin, config);
|
||||
addRent(rent);
|
||||
} catch (RegionCreateException exception) {
|
||||
plugin.getLogger().warning(exception.getMessage());
|
||||
try {
|
||||
region.delete();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
} else if(RegionType.BUY.getValue().equals(config.getString("general.type"))) {
|
||||
try {
|
||||
BuyRegion buy = new BuyRegion(plugin, config);
|
||||
addBuy(buy);
|
||||
} catch (RegionCreateException exception) {
|
||||
// This prints out a message in the console that indicates why the region cannot be created
|
||||
plugin.getLogger().warning(exception.getMessage());
|
||||
// Catch all exeptions because it just has to try delete the region, if it fails it does not matter
|
||||
try {
|
||||
region.delete();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load groups
|
||||
File groupFile = new File(groupsPath);
|
||||
if(groupFile.exists() && groupFile.isFile()) {
|
||||
groupsConfig = YamlConfiguration.loadConfiguration(groupFile);
|
||||
} else {
|
||||
groupsConfig = new YamlConfiguration();
|
||||
}
|
||||
for(String groupName : groupsConfig.getKeys(false)) {
|
||||
RegionGroup group = new RegionGroup(plugin, groupName);
|
||||
groups.put(groupName, group);
|
||||
}
|
||||
|
||||
// Load default settings
|
||||
File defaultFile = new File(defaultPath);
|
||||
if(!defaultFile.exists()) {
|
||||
InputStream input = null;
|
||||
OutputStream output = null;
|
||||
try {
|
||||
input = plugin.getResource(AreaShop.defaultFile);
|
||||
output = new FileOutputStream(defaultFile);
|
||||
|
||||
int read = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
while ((read = input.read(bytes)) != -1) {
|
||||
output.write(bytes, 0, read);
|
||||
}
|
||||
input.close();
|
||||
output.close();
|
||||
plugin.getLogger().info("File with default region settings has been saved, should only happen the first time");
|
||||
} catch(IOException e) {
|
||||
try {
|
||||
input.close();
|
||||
output.close();
|
||||
} catch (IOException e1) {} catch (NullPointerException e2) {}
|
||||
|
||||
plugin.getLogger().warning("Something went wrong saving the default region settings: " + defaultFile.getPath());
|
||||
}
|
||||
}
|
||||
defaultConfig = YamlConfiguration.loadConfiguration(defaultFile);
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertFiles() {
|
||||
String rentPath = plugin.getDataFolder() + File.separator + "rents";
|
||||
String buyPath = plugin.getDataFolder() + File.separator + "buys";
|
||||
File rentFile = new File(rentPath);
|
||||
File buyFile = new File(buyPath);
|
||||
String oldFolderPath = plugin.getDataFolder() + File.separator + "#old" + File.separator;
|
||||
File oldFolderFile = new File(oldFolderPath);
|
||||
|
||||
// If the the files are already the current version
|
||||
if(versions.get(AreaShop.versionFiles) != null && versions.get(AreaShop.versionFiles) == AreaShop.versionFilesCurrent) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Conversion to a new version of the file format starts, could take some time");
|
||||
|
||||
// Convert old rent files
|
||||
if(rentFile.exists()) {
|
||||
if(!oldFolderFile.exists()) {
|
||||
oldFolderFile.mkdirs();
|
||||
}
|
||||
|
||||
if(versions.get("rents") == null) {
|
||||
versions.put("rents", -1);
|
||||
}
|
||||
|
||||
HashMap<String, HashMap<String, String>> rents = null;
|
||||
try {
|
||||
ObjectInputStream input = new ObjectInputStream(new FileInputStream(rentPath));
|
||||
rents = (HashMap<String,HashMap<String,String>>)input.readObject();
|
||||
input.close();
|
||||
} catch (IOException | ClassNotFoundException | ClassCastException e) {
|
||||
plugin.getLogger().warning(" Error: Something went wrong reading file: " + rentPath);
|
||||
}
|
||||
// Delete the file if it is totally wrong
|
||||
if(rents == null) {
|
||||
try {
|
||||
rentFile.delete();
|
||||
} catch(Exception e) {}
|
||||
} else {
|
||||
// Move old file
|
||||
try {
|
||||
Files.move(new File(rentPath), new File(oldFolderPath + "rents"));
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().info(" Could not create a backup of '" + rentPath + "', check the file permissions (conversion to next version continues)");
|
||||
}
|
||||
// Check if conversion is needed
|
||||
if(versions.get("rents") < 1) {
|
||||
/* Upgrade the rent to the latest version */
|
||||
if(versions.get("rents") < 0) {
|
||||
for(String rentName : rents.keySet()) {
|
||||
HashMap<String,String> rent = rents.get(rentName);
|
||||
/* Save the rentName in the hashmap and use a small caps rentName as key */
|
||||
if(rent.get("name") == null) {
|
||||
rent.put("name", rentName);
|
||||
rents.remove(rentName);
|
||||
rents.put(rentName.toLowerCase(), rent);
|
||||
}
|
||||
/* Save the default setting for region restoring */
|
||||
if(rent.get("restore") == null) {
|
||||
rent.put("restore", "general");
|
||||
}
|
||||
/* Save the default setting for the region restore profile */
|
||||
if(rent.get("profile") == null) {
|
||||
rent.put("profile", "default");
|
||||
}
|
||||
/* Change to version 0 */
|
||||
versions.put("rents", 0);
|
||||
}
|
||||
plugin.getLogger().info(" Updated version of '" + buyPath + "' from -1 to 0 (switch to using lowercase region names, adding default schematic enabling and profile)");
|
||||
}
|
||||
if(versions.get("rents") < 1) {
|
||||
for(String rentName : rents.keySet()) {
|
||||
HashMap<String,String> rent = rents.get(rentName);
|
||||
if(rent.get("player") != null) {
|
||||
@SuppressWarnings("deprecation") // Fake deprecation by Bukkit to inform developers, method will stay
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(rent.get("player"));
|
||||
rent.put("playeruuid", offlinePlayer.getUniqueId().toString());
|
||||
rent.remove("player");
|
||||
}
|
||||
/* Change version to 1 */
|
||||
versions.put("rents", 1);
|
||||
}
|
||||
plugin.getLogger().info(" Updated version of '" + rentPath + "' from 0 to 1 (switch to UUID's for player identification)");
|
||||
}
|
||||
}
|
||||
// Save rents to new format
|
||||
File regionsFile = new File(regionsPath);
|
||||
if(!regionsFile.exists()) {
|
||||
regionsFile.mkdirs();
|
||||
}
|
||||
for(HashMap<String, String> rent : rents.values()) {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.set("general.name", rent.get("name").toLowerCase());
|
||||
config.set("general.type", "rent");
|
||||
config.set("general.world", rent.get("world"));
|
||||
config.set("general.signs.0.location.world", rent.get("world"));
|
||||
config.set("general.signs.0.location.x", Double.parseDouble(rent.get("x")));
|
||||
config.set("general.signs.0.location.y", Double.parseDouble(rent.get("y")));
|
||||
config.set("general.signs.0.location.z", Double.parseDouble(rent.get("z")));
|
||||
config.set("rent.price", Double.parseDouble(rent.get("price")));
|
||||
config.set("rent.duration", rent.get("duration"));
|
||||
if(rent.get("restore") != null && !rent.get("restore").equals("general")) {
|
||||
config.set("general.enableRestore", rent.get("restore"));
|
||||
}
|
||||
if(rent.get("profile") != null && !rent.get("profile").equals("default")) {
|
||||
config.set("general.schematicProfile", rent.get("profile"));
|
||||
}
|
||||
if(rent.get("tpx") != null) {
|
||||
config.set("general.teleportLocation.world", rent.get("world"));
|
||||
config.set("general.teleportLocation.x", Double.parseDouble(rent.get("tpx")));
|
||||
config.set("general.teleportLocation.y", Double.parseDouble(rent.get("tpy")));
|
||||
config.set("general.teleportLocation.z", Double.parseDouble(rent.get("tpz")));
|
||||
config.set("general.teleportLocation.yaw", rent.get("tpyaw"));
|
||||
config.set("general.teleportLocation.pitch", rent.get("tppitch"));
|
||||
}
|
||||
if(rent.get("playeruuid") != null) {
|
||||
config.set("rent.renter", rent.get("playeruuid"));
|
||||
config.set("rent.rentedUntil", Long.parseLong(rent.get("rented")));
|
||||
}
|
||||
try {
|
||||
config.save(new File(regionsPath + File.separator + rent.get("name").toLowerCase() + ".yml"));
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning(" Error: Could not save region file while converting: " + regionsPath + File.separator + rent.get("name").toLowerCase() + ".yml");
|
||||
}
|
||||
}
|
||||
plugin.getLogger().info(" Updated rent regions to new .yml format (check the /regions folder)");
|
||||
}
|
||||
|
||||
// Change version number
|
||||
versions.remove("rents");
|
||||
versions.put(AreaShop.versionFiles, AreaShop.versionFilesCurrent);
|
||||
saveVersions();
|
||||
}
|
||||
|
||||
if(buyFile.exists()) {
|
||||
if(!oldFolderFile.exists()) {
|
||||
oldFolderFile.mkdirs();
|
||||
}
|
||||
|
||||
if(versions.get("buys") == null) {
|
||||
versions.put("buys", -1);
|
||||
}
|
||||
|
||||
HashMap<String, HashMap<String, String>> buys = null;
|
||||
try {
|
||||
ObjectInputStream input = new ObjectInputStream(new FileInputStream(buyPath));
|
||||
buys = (HashMap<String,HashMap<String,String>>)input.readObject();
|
||||
input.close();
|
||||
} catch (IOException | ClassNotFoundException | ClassCastException e) {
|
||||
plugin.getLogger().warning(" Error: Something went wrong reading file: " + buyPath);
|
||||
}
|
||||
// Delete the file if it is totally wrong
|
||||
if(buys == null) {
|
||||
try {
|
||||
buyFile.delete();
|
||||
} catch(Exception e) {}
|
||||
} else {
|
||||
// Backup current file
|
||||
try {
|
||||
Files.move(new File(buyPath), new File(oldFolderPath + "buys"));
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().info(" Could not create a backup of '" + buyPath + "', check the file permissions (conversion to next version continues)");
|
||||
}
|
||||
// Check if conversion is needed
|
||||
if(versions.get("buys") < 1) {
|
||||
/* Upgrade the buy to the latest version */
|
||||
if(versions.get("buys") < 0) {
|
||||
for(String buyName : buys.keySet()) {
|
||||
HashMap<String,String> buy = buys.get(buyName);
|
||||
/* Save the buyName in the hashmap and use a small caps buyName as key */
|
||||
if(buy.get("name") == null) {
|
||||
buy.put("name", buyName);
|
||||
buys.remove(buyName);
|
||||
buys.put(buyName.toLowerCase(), buy);
|
||||
}
|
||||
/* Save the default setting for region restoring */
|
||||
if(buy.get("restore") == null) {
|
||||
buy.put("restore", "general");
|
||||
}
|
||||
/* Save the default setting for the region restore profile */
|
||||
if(buy.get("profile") == null) {
|
||||
buy.put("profile", "default");
|
||||
}
|
||||
/* Change to version 0 */
|
||||
versions.put("buys", 0);
|
||||
}
|
||||
plugin.getLogger().info(" Updated version of '" + buyPath + "' from -1 to 0 (switch to using lowercase region names, adding default schematic enabling and profile)");
|
||||
}
|
||||
if(versions.get("buys") < 1) {
|
||||
for(String buyName : buys.keySet()) {
|
||||
HashMap<String,String> buy = buys.get(buyName);
|
||||
if(buy.get("player") != null) {
|
||||
@SuppressWarnings("deprecation") // Fake deprecation by Bukkit to inform developers, method will stay
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(buy.get("player"));
|
||||
buy.put("playeruuid", offlinePlayer.getUniqueId().toString());
|
||||
buy.remove("player");
|
||||
}
|
||||
/* Change version to 1 */
|
||||
versions.put("buys", 1);
|
||||
}
|
||||
plugin.getLogger().info(" Updated version of '" + buyPath + "' from 0 to 1 (switch to UUID's for player identification)");
|
||||
}
|
||||
}
|
||||
|
||||
// Save buys to new format
|
||||
File regionsFile = new File(regionsPath);
|
||||
if(!regionsFile.exists()) {
|
||||
regionsFile.mkdirs();
|
||||
}
|
||||
for(HashMap<String, String> buy : buys.values()) {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.set("general.name", buy.get("name").toLowerCase());
|
||||
config.set("general.type", "buy");
|
||||
config.set("general.world", buy.get("world"));
|
||||
config.set("general.signs.0.location.world", buy.get("world"));
|
||||
config.set("general.signs.0.location.x", Double.parseDouble(buy.get("x")));
|
||||
config.set("general.signs.0.location.y", Double.parseDouble(buy.get("y")));
|
||||
config.set("general.signs.0.location.z", Double.parseDouble(buy.get("z")));
|
||||
config.set("buy.price", Double.parseDouble(buy.get("price")));
|
||||
if(buy.get("restore") != null && !buy.get("restore").equals("general")) {
|
||||
config.set("general.enableRestore", buy.get("restore"));
|
||||
}
|
||||
if(buy.get("profile") != null && !buy.get("profile").equals("default")) {
|
||||
config.set("general.schematicProfile", buy.get("profile"));
|
||||
}
|
||||
if(buy.get("tpx") != null) {
|
||||
config.set("general.teleportLocation.world", buy.get("world"));
|
||||
config.set("general.teleportLocation.x", Double.parseDouble(buy.get("tpx")));
|
||||
config.set("general.teleportLocation.y", Double.parseDouble(buy.get("tpy")));
|
||||
config.set("general.teleportLocation.z", Double.parseDouble(buy.get("tpz")));
|
||||
config.set("general.teleportLocation.yaw", buy.get("tpyaw"));
|
||||
config.set("general.teleportLocation.pitch", buy.get("tppitch"));
|
||||
}
|
||||
if(buy.get("playeruuid") != null) {
|
||||
config.set("buy.buyer", buy.get("playeruuid"));
|
||||
}
|
||||
try {
|
||||
config.save(new File(regionsPath + File.separator + buy.get("name").toLowerCase() + ".yml"));
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning(" Error: Could not save region file while converting: " + regionsPath + File.separator + buy.get("name").toLowerCase() + ".yml");
|
||||
}
|
||||
}
|
||||
plugin.getLogger().info(" Updated buy regions to new .yml format (check the /regions folder)");
|
||||
}
|
||||
|
||||
// Change version number
|
||||
versions.remove("buys");
|
||||
versions.put(AreaShop.versionFiles, AreaShop.versionFilesCurrent);
|
||||
saveVersions();
|
||||
}
|
||||
|
||||
// Separate try-catch blocks to try them all individually (don't stop after 1 has failed)
|
||||
try {
|
||||
Files.move(new File(rentPath + ".old"), new File(oldFolderPath + "rents.old"));
|
||||
} catch (Exception e) {}
|
||||
try {
|
||||
Files.move(new File(buyPath + ".old"), new File(oldFolderPath + "buys.old"));
|
||||
} catch (Exception e) {}
|
||||
try {
|
||||
Files.move(new File(plugin.getDataFolder() + File.separator + "config.yml"), new File(oldFolderPath + "config.yml"));
|
||||
} catch (Exception e) {}
|
||||
|
||||
plugin.getLogger().info("Conversion to new version of the file format complete, this should not show up anymore next restart/reload");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings of a group
|
||||
* @param groupName Name of the group to get the settings from
|
||||
* @return The settings of the group
|
||||
*/
|
||||
public ConfigurationSection getGroupSettings(String groupName) {
|
||||
return groupsConfig.getConfigurationSection(groupName.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a setting for a group
|
||||
* @param group The group to set it for
|
||||
* @param path The path to set
|
||||
* @param setting The value to set
|
||||
*/
|
||||
public void setGroupSetting(RegionGroup group, String path, Object setting) {
|
||||
groupsConfig.set(group.getName().toLowerCase() + "." + path, setting);
|
||||
}
|
||||
|
||||
// UTILITIES
|
||||
/**
|
||||
* Get all AreaShop regions intersecting with a WorldEdit selection
|
||||
* @param selection The selection to check
|
||||
* @return A list with all the AreaShop regions intersecting with the selection
|
||||
*/
|
||||
public List<GeneralRegion> getASRegionsInSelection(Selection selection) {
|
||||
ArrayList<GeneralRegion> result = new ArrayList<GeneralRegion>();
|
||||
for(ProtectedRegion region : getWERegionsInSelection(selection)) {
|
||||
GeneralRegion asRegion = getRegion(region.getId());
|
||||
if(asRegion != null) {
|
||||
result.add(asRegion);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<GeneralRegion> getASRegionsByLocation(Location location) {
|
||||
Selection selection = new CuboidSelection(location.getWorld(), location, location);
|
||||
return getASRegionsInSelection(selection);
|
||||
}
|
||||
|
||||
public List<ProtectedRegion> getWERegionsInSelection(Selection selection) {
|
||||
// Get all regions inside or intersecting with the WorldEdit selection of the player
|
||||
World world = selection.getWorld();
|
||||
RegionManager regionManager = plugin.getWorldGuard().getRegionManager(world);
|
||||
ArrayList<ProtectedRegion> result = new ArrayList<ProtectedRegion>();
|
||||
Location selectionMin = selection.getMinimumPoint();
|
||||
Location selectionMax = selection.getMaximumPoint();
|
||||
for(ProtectedRegion region : regionManager.getRegions().values()) {
|
||||
BlockVector regionMin = region.getMinimumPoint();
|
||||
BlockVector regionMax = region.getMaximumPoint();
|
||||
if(
|
||||
( // x part, resolves to true if the selection and region overlap anywhere on the x-axis
|
||||
(regionMin.getBlockX() <= selectionMax.getBlockX() && regionMin.getBlockX() >= selectionMin.getBlockX())
|
||||
|| (regionMax.getBlockX() <= selectionMax.getBlockX() && regionMax.getBlockX() >= selectionMin.getBlockX())
|
||||
|| (selectionMin.getBlockX() >= regionMin.getBlockX() && selectionMin.getBlockX() <= regionMax.getBlockX())
|
||||
|| (selectionMax.getBlockX() >= regionMin.getBlockX() && selectionMax.getBlockX() <= regionMax.getBlockX())
|
||||
) && ( // Y part, resolves to true if the selection and region overlap anywhere on the y-axis
|
||||
(regionMin.getBlockY() <= selectionMax.getBlockY() && regionMin.getBlockY() >= selectionMin.getBlockY())
|
||||
|| (regionMax.getBlockY() <= selectionMax.getBlockY() && regionMax.getBlockY() >= selectionMin.getBlockY())
|
||||
|| (selectionMin.getBlockY() >= regionMin.getBlockY() && selectionMin.getBlockY() <= regionMax.getBlockY())
|
||||
|| (selectionMax.getBlockY() >= regionMin.getBlockY() && selectionMax.getBlockY() <= regionMax.getBlockY())
|
||||
) && ( // Z part, resolves to true if the selection and region overlap anywhere on the z-axis
|
||||
(regionMin.getBlockZ() <= selectionMax.getBlockZ() && regionMin.getBlockZ() >= selectionMin.getBlockZ())
|
||||
|| (regionMax.getBlockZ() <= selectionMax.getBlockZ() && regionMax.getBlockZ() >= selectionMin.getBlockZ())
|
||||
|| (selectionMin.getBlockZ() >= regionMin.getBlockZ() && selectionMin.getBlockZ() <= regionMax.getBlockZ())
|
||||
|| (selectionMax.getBlockZ() >= regionMin.getBlockZ() && selectionMax.getBlockZ() <= regionMax.getBlockZ())
|
||||
)
|
||||
) {
|
||||
result.add(region);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of regions around a location
|
||||
* - Returns highest priority, child instead of parent regions
|
||||
* @param location The location to check for regions
|
||||
* @return empty list if no regions found, 1 member if 1 region is a priority, more if regions with the same priority
|
||||
*/
|
||||
public List<ProtectedRegion> getApplicableRegions(Location location) {
|
||||
List<ProtectedRegion> result = new ArrayList<ProtectedRegion>();
|
||||
// If the secondLine does not contain a name try to find the region by location
|
||||
ApplicableRegionSet regions = plugin.getWorldGuard().getRegionManager(location.getWorld()).getApplicableRegions(location);
|
||||
if(regions != null) {
|
||||
boolean first = true;
|
||||
for(ProtectedRegion pr : regions) {
|
||||
if(first) {
|
||||
result.add(pr);
|
||||
first = false;
|
||||
} else {
|
||||
if(pr.getPriority() > result.get(0).getPriority()) {
|
||||
result.clear();
|
||||
result.add(pr);
|
||||
} else if(pr.getParent() != null && pr.getParent().equals(result.get(0))) {
|
||||
result.clear();
|
||||
result.add(pr);
|
||||
} else {
|
||||
result.add(pr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<GeneralRegion> getApplicalbeASRegions(Location location) {
|
||||
List<GeneralRegion> result = new ArrayList<GeneralRegion>();
|
||||
// If the secondLine does not contain a name try to find the region by location
|
||||
ApplicableRegionSet regions = plugin.getWorldGuard().getRegionManager(location.getWorld()).getApplicableRegions(location);
|
||||
if(regions != null) {
|
||||
List<GeneralRegion> candidates = new ArrayList<GeneralRegion>();
|
||||
for(ProtectedRegion pr : regions) {
|
||||
GeneralRegion region = getRegion(pr.getId());
|
||||
if(region != null) {
|
||||
candidates.add(region);
|
||||
}
|
||||
}
|
||||
boolean first = true;
|
||||
for(GeneralRegion region : candidates) {
|
||||
if(first) {
|
||||
result.add(region);
|
||||
first = false;
|
||||
} else {
|
||||
if(region.getRegion().getPriority() > result.get(0).getRegion().getPriority()) {
|
||||
result.clear();
|
||||
result.add(region);
|
||||
} else if(region.getRegion().getParent() != null && region.getRegion().getParent().equals(result.get(0))) {
|
||||
result.clear();
|
||||
result.add(region);
|
||||
} else {
|
||||
result.add(region);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package nl.evolutioncoding.AreaShop;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -11,9 +14,11 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
public class LanguageManager {
|
||||
private AreaShop plugin = null;
|
||||
private String languages[] = {"EN", "NL"};
|
||||
private String languages[] = {"EN", "NL", "FR"};
|
||||
private HashMap<String, String> currentLanguage, defaultLanguage;
|
||||
|
||||
/**
|
||||
@@ -36,7 +41,7 @@ public class LanguageManager {
|
||||
public void saveDefaults() {
|
||||
/* Create the language folder if it not exists */
|
||||
File langFolder;
|
||||
langFolder = new File(plugin.getDataFolder() + File.separator + plugin.languageFolder);
|
||||
langFolder = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder);
|
||||
if(!langFolder.exists()) {
|
||||
langFolder.mkdirs();
|
||||
}
|
||||
@@ -47,11 +52,11 @@ public class LanguageManager {
|
||||
/* file name as the default */
|
||||
File langFile;
|
||||
for(int i=0; i<languages.length; i++) {
|
||||
langFile = new File(plugin.getDataFolder() + File.separator + plugin.languageFolder + File.separator + languages[i] + ".yml");
|
||||
langFile = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + File.separator + languages[i] + ".yml");
|
||||
InputStream input = null;
|
||||
OutputStream output = null;
|
||||
try {
|
||||
input = plugin.getResource(plugin.languageFolder + "/" + languages[i] + ".yml");
|
||||
input = plugin.getResource(AreaShop.languageFolder + "/" + languages[i] + ".yml");
|
||||
output = new FileOutputStream(langFile);
|
||||
|
||||
int read = 0;
|
||||
@@ -83,30 +88,39 @@ public class LanguageManager {
|
||||
|
||||
/* Save the current language file to the HashMap */
|
||||
currentLanguage = new HashMap<String, String>();
|
||||
File file = new File(plugin.getDataFolder() + File.separator + plugin.languageFolder + File.separator + plugin.config().getString("language") + ".yml");
|
||||
ymlFile = YamlConfiguration.loadConfiguration(file);
|
||||
map = ymlFile.getValues(true);
|
||||
set = map.keySet();
|
||||
File file = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + File.separator + plugin.config().getString("language") + ".yml");
|
||||
InputStreamReader reader = null;
|
||||
try {
|
||||
for(String key : set) {
|
||||
currentLanguage.put(key, (String)map.get(key));
|
||||
}
|
||||
} catch(ClassCastException e) {}
|
||||
reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8);
|
||||
} catch (FileNotFoundException e1) {}
|
||||
if(reader != null) {
|
||||
ymlFile = YamlConfiguration.loadConfiguration(reader);
|
||||
map = ymlFile.getValues(true);
|
||||
set = map.keySet();
|
||||
try {
|
||||
for(String key : set) {
|
||||
currentLanguage.put(key, (String)map.get(key));
|
||||
}
|
||||
} catch(ClassCastException e) {}
|
||||
}
|
||||
|
||||
/* Save the default strings to the HashMap */
|
||||
defaultLanguage = new HashMap<String, String>();
|
||||
InputStream defConfigStream = plugin.getResource(plugin.languageFolder + "/" + plugin.config().getString("language") + ".yml");
|
||||
if (defConfigStream == null) {
|
||||
defConfigStream = plugin.getResource(plugin.languageFolder + "/" + languages[0]+ ".yml");
|
||||
}
|
||||
ymlFile = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
map = ymlFile.getValues(true);
|
||||
set = map.keySet();
|
||||
File standard = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + "/" + languages[0]+ ".yml");
|
||||
InputStreamReader reader2 = null;
|
||||
try {
|
||||
for(String key : set) {
|
||||
defaultLanguage.put(key, (String)map.get(key));
|
||||
}
|
||||
} catch(ClassCastException e) {}
|
||||
reader2 = new InputStreamReader(new FileInputStream(standard), Charsets.UTF_8);
|
||||
} catch (FileNotFoundException e1) {}
|
||||
if(reader2 != null) {
|
||||
ymlFile = YamlConfiguration.loadConfiguration(reader2);
|
||||
map = ymlFile.getValues(true);
|
||||
set = map.keySet();
|
||||
try {
|
||||
for(String key : set) {
|
||||
defaultLanguage.put(key, (String)map.get(key));
|
||||
}
|
||||
} catch(ClassCastException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,9 +142,11 @@ public class LanguageManager {
|
||||
if(result == null) {
|
||||
plugin.getLogger().info("Wrong key for getting translation: " + key);
|
||||
} else {
|
||||
/* Replace all tags, e.g. %1% */
|
||||
/* Replace all tags, e.g. %0% */
|
||||
for (int i=0; i<params.length; i++) {
|
||||
result = result.replace("%" + i + "%", params[i].toString());
|
||||
if(params[i] != null) {
|
||||
result = result.replace("%" + i + "%", params[i].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,759 @@
|
||||
/*
|
||||
* Copyright 2011-2013 Tyler Blair. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and contributors and should not be interpreted as representing official policies,
|
||||
* either expressed or implied, of anybody else.
|
||||
*/
|
||||
package nl.evolutioncoding.AreaShop;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
/**
|
||||
* The current revision number
|
||||
*/
|
||||
private final static int REVISION = 7;
|
||||
|
||||
/**
|
||||
* The base url of the metrics domain
|
||||
*/
|
||||
private static final String BASE_URL = "http://report.mcstats.org";
|
||||
|
||||
/**
|
||||
* The url used to report a server's status
|
||||
*/
|
||||
private static final String REPORT_URL = "/plugin/%s";
|
||||
|
||||
/**
|
||||
* Interval of time to ping (in minutes)
|
||||
*/
|
||||
private static final int PING_INTERVAL = 15;
|
||||
|
||||
/**
|
||||
* The plugin this metrics submits for
|
||||
*/
|
||||
private final Plugin plugin;
|
||||
|
||||
/**
|
||||
* All of the custom graphs to submit to metrics
|
||||
*/
|
||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final YamlConfiguration configuration;
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final File configurationFile;
|
||||
|
||||
/**
|
||||
* Unique server id
|
||||
*/
|
||||
private final String guid;
|
||||
|
||||
/**
|
||||
* Debug mode
|
||||
*/
|
||||
private final boolean debug;
|
||||
|
||||
/**
|
||||
* Lock for synchronization
|
||||
*/
|
||||
private final Object optOutLock = new Object();
|
||||
|
||||
/**
|
||||
* The scheduled task
|
||||
*/
|
||||
private volatile BukkitTask task = null;
|
||||
|
||||
public Metrics(final Plugin plugin) throws IOException {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
// load the config
|
||||
configurationFile = getConfigFile();
|
||||
configuration = YamlConfiguration.loadConfiguration(configurationFile);
|
||||
|
||||
// add some defaults
|
||||
configuration.addDefault("opt-out", false);
|
||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||
configuration.addDefault("debug", false);
|
||||
|
||||
// Do we need to create the file?
|
||||
if (configuration.get("guid", null) == null) {
|
||||
configuration.options().header("http://mcstats.org").copyDefaults(true);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Load the guid then
|
||||
guid = configuration.getString("guid");
|
||||
debug = configuration.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
|
||||
* website. Plotters can be added to the graph object returned.
|
||||
*
|
||||
* @param name The name of the graph
|
||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||
*/
|
||||
public Graph createGraph(final String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Graph name cannot be null");
|
||||
}
|
||||
|
||||
// Construct the graph object
|
||||
final Graph graph = new Graph(name);
|
||||
|
||||
// Now we can add our graph
|
||||
graphs.add(graph);
|
||||
|
||||
// and return back
|
||||
return graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend
|
||||
*
|
||||
* @param graph The name of the graph
|
||||
*/
|
||||
public void addGraph(final Graph graph) {
|
||||
if (graph == null) {
|
||||
throw new IllegalArgumentException("Graph cannot be null");
|
||||
}
|
||||
|
||||
graphs.add(graph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
|
||||
* initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
|
||||
* ticks.
|
||||
*
|
||||
* @return True if statistics measuring is running, otherwise false.
|
||||
*/
|
||||
public boolean start() {
|
||||
synchronized (optOutLock) {
|
||||
// Did we opt out?
|
||||
if (isOptOut()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is metrics already running?
|
||||
if (task != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Begin hitting the server with glorious data
|
||||
task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
|
||||
private boolean firstPost = true;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
// This has to be synchronized or it can collide with the disable method.
|
||||
synchronized (optOutLock) {
|
||||
// Disable Task, if it is running and the server owner decided to opt-out
|
||||
if (isOptOut() && task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
// Tell all plotters to stop gathering information.
|
||||
for (Graph graph : graphs) {
|
||||
graph.onOptOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We use the inverse of firstPost because if it is the first time we are posting,
|
||||
// it is not a interval ping, so it evaluates to FALSE
|
||||
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||
postPlugin(!firstPost);
|
||||
|
||||
// After the first post we set firstPost to false
|
||||
// Each post thereafter will be a ping
|
||||
firstPost = false;
|
||||
} catch (IOException e) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, PING_INTERVAL * 1200);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the server owner denied plugin metrics?
|
||||
*
|
||||
* @return true if metrics should be opted out of it
|
||||
*/
|
||||
public boolean isOptOut() {
|
||||
synchronized (optOutLock) {
|
||||
try {
|
||||
// Reload the metrics file
|
||||
configuration.load(getConfigFile());
|
||||
} catch (IOException ex) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return configuration.getBoolean("opt-out", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void enable() throws IOException {
|
||||
// This has to be synchronized or it can collide with the check in the task.
|
||||
synchronized (optOutLock) {
|
||||
// Check if the server owner has already set opt-out, if not, set it.
|
||||
if (isOptOut()) {
|
||||
configuration.set("opt-out", false);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Enable Task, if it is not running
|
||||
if (task == null) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void disable() throws IOException {
|
||||
// This has to be synchronized or it can collide with the check in the task.
|
||||
synchronized (optOutLock) {
|
||||
// Check if the server owner has already set opt-out, if not, set it.
|
||||
if (!isOptOut()) {
|
||||
configuration.set("opt-out", true);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Disable Task, if it is running
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the File object of the config file that should be used to store data such as the GUID and opt-out status
|
||||
*
|
||||
* @return the File object for the config file
|
||||
*/
|
||||
public File getConfigFile() {
|
||||
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
|
||||
// is to abuse the plugin object we already have
|
||||
// plugin.getDataFolder() => base/plugins/PluginA/
|
||||
// pluginsFolder => base/plugins/
|
||||
// The base is not necessarily relative to the startup directory.
|
||||
File pluginsFolder = plugin.getDataFolder().getParentFile();
|
||||
|
||||
// return => base/plugins/PluginMetrics/config.yml
|
||||
return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method that posts a plugin to the metrics website
|
||||
*/
|
||||
private void postPlugin(final boolean isPing) throws IOException {
|
||||
// Server software specific section
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
String pluginName = description.getName();
|
||||
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||
String pluginVersion = description.getVersion();
|
||||
String serverVersion = Bukkit.getVersion();
|
||||
int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
|
||||
|
||||
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||
|
||||
// Construct the post data
|
||||
StringBuilder json = new StringBuilder(1024);
|
||||
json.append('{');
|
||||
|
||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||
appendJSONPair(json, "guid", guid);
|
||||
appendJSONPair(json, "plugin_version", pluginVersion);
|
||||
appendJSONPair(json, "server_version", serverVersion);
|
||||
appendJSONPair(json, "players_online", Integer.toString(playersOnline));
|
||||
|
||||
// New data as of R6
|
||||
String osname = System.getProperty("os.name");
|
||||
String osarch = System.getProperty("os.arch");
|
||||
String osversion = System.getProperty("os.version");
|
||||
String java_version = System.getProperty("java.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
// normalize os arch .. amd64 -> x86_64
|
||||
if (osarch.equals("amd64")) {
|
||||
osarch = "x86_64";
|
||||
}
|
||||
|
||||
appendJSONPair(json, "osname", osname);
|
||||
appendJSONPair(json, "osarch", osarch);
|
||||
appendJSONPair(json, "osversion", osversion);
|
||||
appendJSONPair(json, "cores", Integer.toString(coreCount));
|
||||
appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0");
|
||||
appendJSONPair(json, "java_version", java_version);
|
||||
|
||||
// If we're pinging, append it
|
||||
if (isPing) {
|
||||
appendJSONPair(json, "ping", "1");
|
||||
}
|
||||
|
||||
if (graphs.size() > 0) {
|
||||
synchronized (graphs) {
|
||||
json.append(',');
|
||||
json.append('"');
|
||||
json.append("graphs");
|
||||
json.append('"');
|
||||
json.append(':');
|
||||
json.append('{');
|
||||
|
||||
boolean firstGraph = true;
|
||||
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Graph graph = iter.next();
|
||||
|
||||
StringBuilder graphJson = new StringBuilder();
|
||||
graphJson.append('{');
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
|
||||
}
|
||||
|
||||
graphJson.append('}');
|
||||
|
||||
if (!firstGraph) {
|
||||
json.append(',');
|
||||
}
|
||||
|
||||
json.append(escapeJSON(graph.getName()));
|
||||
json.append(':');
|
||||
json.append(graphJson);
|
||||
|
||||
firstGraph = false;
|
||||
}
|
||||
|
||||
json.append('}');
|
||||
}
|
||||
}
|
||||
|
||||
// close json
|
||||
json.append('}');
|
||||
|
||||
// Create the url
|
||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
|
||||
|
||||
// Connect to the website
|
||||
URLConnection connection;
|
||||
|
||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||
// It does not reroute POST requests so we need to go around it
|
||||
if (isMineshafterPresent()) {
|
||||
connection = url.openConnection(Proxy.NO_PROXY);
|
||||
} else {
|
||||
connection = url.openConnection();
|
||||
}
|
||||
|
||||
|
||||
byte[] uncompressed = json.toString().getBytes();
|
||||
byte[] compressed = gzip(json.toString());
|
||||
|
||||
// Headers
|
||||
connection.addRequestProperty("User-Agent", "MCStats/" + REVISION);
|
||||
connection.addRequestProperty("Content-Type", "application/json");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip");
|
||||
connection.addRequestProperty("Content-Length", Integer.toString(compressed.length));
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
|
||||
connection.setDoOutput(true);
|
||||
|
||||
if (debug) {
|
||||
System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
|
||||
}
|
||||
|
||||
// Write the data
|
||||
OutputStream os = connection.getOutputStream();
|
||||
os.write(compressed);
|
||||
os.flush();
|
||||
|
||||
// Now read the response
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String response = reader.readLine();
|
||||
|
||||
// close resources
|
||||
os.close();
|
||||
reader.close();
|
||||
|
||||
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
|
||||
if (response == null) {
|
||||
response = "null";
|
||||
} else if (response.startsWith("7")) {
|
||||
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
||||
}
|
||||
|
||||
throw new IOException(response);
|
||||
} else {
|
||||
// Is this the first update this hour?
|
||||
if (response.equals("1") || response.contains("This is your first update this hour")) {
|
||||
synchronized (graphs) {
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GZip compress a string of bytes
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static byte[] gzip(String input) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzos = null;
|
||||
|
||||
try {
|
||||
gzos = new GZIPOutputStream(baos);
|
||||
gzos.write(input.getBytes("UTF-8"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (gzos != null) try {
|
||||
gzos.close();
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||
*
|
||||
* @return true if mineshafter is installed on the server
|
||||
*/
|
||||
private boolean isMineshafterPresent() {
|
||||
try {
|
||||
Class.forName("mineshafter.MineServer");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a json encoded key/value pair to the given string builder.
|
||||
*
|
||||
* @param json
|
||||
* @param key
|
||||
* @param value
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
|
||||
boolean isValueNumeric = false;
|
||||
|
||||
try {
|
||||
if (value.equals("0") || !value.endsWith("0")) {
|
||||
Double.parseDouble(value);
|
||||
isValueNumeric = true;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
isValueNumeric = false;
|
||||
}
|
||||
|
||||
if (json.charAt(json.length() - 1) != '{') {
|
||||
json.append(',');
|
||||
}
|
||||
|
||||
json.append(escapeJSON(key));
|
||||
json.append(':');
|
||||
|
||||
if (isValueNumeric) {
|
||||
json.append(value);
|
||||
} else {
|
||||
json.append(escapeJSON(value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string to create a valid JSON string
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
private static String escapeJSON(String text) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append('"');
|
||||
for (int index = 0; index < text.length(); index++) {
|
||||
char chr = text.charAt(index);
|
||||
|
||||
switch (chr) {
|
||||
case '"':
|
||||
case '\\':
|
||||
builder.append('\\');
|
||||
builder.append(chr);
|
||||
break;
|
||||
case '\b':
|
||||
builder.append("\\b");
|
||||
break;
|
||||
case '\t':
|
||||
builder.append("\\t");
|
||||
break;
|
||||
case '\n':
|
||||
builder.append("\\n");
|
||||
break;
|
||||
case '\r':
|
||||
builder.append("\\r");
|
||||
break;
|
||||
default:
|
||||
if (chr < ' ') {
|
||||
String t = "000" + Integer.toHexString(chr);
|
||||
builder.append("\\u" + t.substring(t.length() - 4));
|
||||
} else {
|
||||
builder.append(chr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
builder.append('"');
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode text as UTF-8
|
||||
*
|
||||
* @param text the text to encode
|
||||
* @return the encoded text, as UTF-8
|
||||
*/
|
||||
private static String urlEncode(final String text) throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(text, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom graph on the website
|
||||
*/
|
||||
public static class Graph {
|
||||
|
||||
/**
|
||||
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
|
||||
* rejected
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The set of plotters that are contained within this graph
|
||||
*/
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||
|
||||
private Graph(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graph's name
|
||||
*
|
||||
* @return the Graph's name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a plotter to the graph, which will be used to plot entries
|
||||
*
|
||||
* @param plotter the plotter to add to the graph
|
||||
*/
|
||||
public void addPlotter(final Plotter plotter) {
|
||||
plotters.add(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plotter from the graph
|
||||
*
|
||||
* @param plotter the plotter to remove from the graph
|
||||
*/
|
||||
public void removePlotter(final Plotter plotter) {
|
||||
plotters.remove(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
*
|
||||
* @return an unmodifiable {@link java.util.Set} of the plotter objects
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
return Collections.unmodifiableSet(plotters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (!(object instanceof Graph)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Graph graph = (Graph) object;
|
||||
return graph.name.equals(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server owner decides to opt-out of BukkitMetrics while the server is running.
|
||||
*/
|
||||
protected void onOptOut() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to collect custom data for a plugin
|
||||
*/
|
||||
public static abstract class Plotter {
|
||||
|
||||
/**
|
||||
* The plot's name
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Construct a plotter with the default plot name
|
||||
*/
|
||||
public Plotter() {
|
||||
this("Default");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a plotter with a specific plot name
|
||||
*
|
||||
* @param name the name of the plotter to use, which will show up on the website
|
||||
*/
|
||||
public Plotter(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value for the plotted point. Since this function defers to an external function it may or may
|
||||
* not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
|
||||
* from any thread so care should be taken when accessing resources that need to be synchronized.
|
||||
*
|
||||
* @return the current value for the point to be plotted.
|
||||
*/
|
||||
public abstract int getValue();
|
||||
|
||||
/**
|
||||
* Get the column name for the plotted point
|
||||
*
|
||||
* @return the plotted point's column name
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the website graphs have been updated
|
||||
*/
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getColumnName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (!(object instanceof Plotter)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Plotter plotter = (Plotter) object;
|
||||
return plotter.name.equals(name) && plotter.getValue() == getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class RentCheck extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getShopManager().checkRents();
|
||||
plugin.getFileManager().checkRents();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package nl.evolutioncoding.AreaShop;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class RightClickListener implements Listener {
|
||||
AreaShop plugin;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param plugin The AreaShop plugin
|
||||
*/
|
||||
public RightClickListener(AreaShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player interacts
|
||||
* @param event The event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onRightClick(PlayerInteractEvent event) {
|
||||
Block block = event.getClickedBlock();
|
||||
/* Check for clicking a sign and rightclicking */
|
||||
if(event.getAction() == Action.RIGHT_CLICK_BLOCK && (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)) {
|
||||
/* Check if the rent sign is really the same as a saved rent */
|
||||
String regionName = ((Sign)(event.getClickedBlock().getState())).getLine(1);
|
||||
HashMap<String,String> rent = plugin.getShopManager().getRent(regionName);
|
||||
HashMap<String,String> buy = plugin.getShopManager().getBuy(regionName);
|
||||
|
||||
if(rent != null && block.getWorld().getName().equals(rent.get(plugin.keyWorld))
|
||||
&& rent.get(plugin.keyX).equals(String.valueOf(block.getX()))
|
||||
&& rent.get(plugin.keyY).equals(String.valueOf(block.getY()))
|
||||
&& rent.get(plugin.keyZ).equals(String.valueOf(block.getZ())) ) {
|
||||
|
||||
plugin.getShopManager().rent(event.getPlayer(), regionName);
|
||||
/* Cancel placing a block */
|
||||
event.setCancelled(true);
|
||||
|
||||
} else if(buy != null && block.getWorld().getName().equals(buy.get(plugin.keyWorld))
|
||||
&& buy.get(plugin.keyX).equals(String.valueOf(block.getX()))
|
||||
&& buy.get(plugin.keyY).equals(String.valueOf(block.getY()))
|
||||
&& buy.get(plugin.keyZ).equals(String.valueOf(block.getZ())) ) {
|
||||
|
||||
plugin.getShopManager().buy(event.getPlayer(), regionName);
|
||||
/* Cancel placing a block */
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,406 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,13 +1,15 @@
|
||||
package nl.evolutioncoding.AreaShop;
|
||||
|
||||
import java.util.HashMap;
|
||||
import nl.evolutioncoding.AreaShop.regions.BuyRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
@@ -36,37 +38,28 @@ public final class SignBreakListener implements Listener {
|
||||
Block block = event.getBlock();
|
||||
/* Check if it is a sign */
|
||||
if(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
|
||||
Sign sign = (Sign)(block.getState());
|
||||
/* Check if the rent sign is really the same as a saved rent */
|
||||
HashMap<String,String> rent = plugin.getShopManager().getRent(sign.getLine(1));
|
||||
HashMap<String,String> buy = plugin.getShopManager().getBuy(sign.getLine(1));
|
||||
if(rent != null && rent.get(plugin.keyWorld).equals(block.getWorld().getName())
|
||||
&& rent.get(plugin.keyX).equals(String.valueOf(block.getX()))
|
||||
&& rent.get(plugin.keyY).equals(String.valueOf(block.getY()))
|
||||
&& rent.get(plugin.keyZ).equals(String.valueOf(block.getZ())) ) {
|
||||
GeneralRegion region = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
||||
if(region == null) {
|
||||
return;
|
||||
}
|
||||
if(region.isRentRegion()) {
|
||||
/* Remove the rent if the player has permission */
|
||||
if(event.getPlayer().hasPermission("areashop.destroyrent")) {
|
||||
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");
|
||||
}
|
||||
plugin.getFileManager().removeRent((RentRegion)region, true);
|
||||
plugin.message(event.getPlayer(), "destroy-successRent", region.getName());
|
||||
} else { /* Cancel the breaking of the sign */
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(plugin.fixColors(plugin.config().getString("chatPrefix")) + "You don't have permission for destroying a sign for renting a region");
|
||||
plugin.message(event.getPlayer(), "destroy-noPermissionRent");
|
||||
}
|
||||
} else if(buy != null && buy.get(plugin.keyWorld).equals(block.getWorld().getName())
|
||||
&& buy.get(plugin.keyX).equals(String.valueOf(block.getX()))
|
||||
&& buy.get(plugin.keyY).equals(String.valueOf(block.getY()))
|
||||
&& buy.get(plugin.keyZ).equals(String.valueOf(block.getZ())) ) {
|
||||
} else if(region.isBuyRegion()) {
|
||||
/* Remove the buy if the player has permission */
|
||||
if(event.getPlayer().hasPermission("areashop.destroybuy")) {
|
||||
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");
|
||||
}
|
||||
plugin.getFileManager().removeBuy((BuyRegion)region, true);
|
||||
plugin.message(event.getPlayer(), "destroy-successBuy", region.getName());
|
||||
} else { /* Cancel the breaking of the sign */
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(plugin.fixColors(plugin.config().getString("chatPrefix")) + "You don't have permission for destroying a sign for buying a region");
|
||||
plugin.message(event.getPlayer(), "destroy-noPermissionBuy");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,27 +77,12 @@ public final class SignBreakListener implements Listener {
|
||||
Block attachedTo = block.getRelative(((org.bukkit.material.Sign)sign.getData()).getAttachedFace());
|
||||
if(attachedTo.getType() == Material.AIR){
|
||||
/* Check if the rent sign is really the same as a saved rent */
|
||||
HashMap<String,String> rent = plugin.getShopManager().getRent(sign.getLine(1));
|
||||
HashMap<String,String> buy = plugin.getShopManager().getBuy(sign.getLine(1));
|
||||
if(rent != null && rent.get(plugin.keyWorld).equals(block.getWorld().getName())
|
||||
&& rent.get(plugin.keyX).equals(String.valueOf(block.getX()))
|
||||
&& rent.get(plugin.keyY).equals(String.valueOf(block.getY()))
|
||||
&& rent.get(plugin.keyZ).equals(String.valueOf(block.getZ())) ) {
|
||||
/* Remove the rent */
|
||||
boolean result = plugin.getShopManager().removeRent(sign.getLine(1));
|
||||
if(result) {
|
||||
plugin.getLogger().info("Renting of region '" + sign.getLine(1) + "' has been removed by indirectly breaking the sign");
|
||||
}
|
||||
} else if(buy != null && buy.get(plugin.keyWorld).equals(block.getWorld().getName())
|
||||
&& buy.get(plugin.keyX).equals(String.valueOf(block.getX()))
|
||||
&& buy.get(plugin.keyY).equals(String.valueOf(block.getY()))
|
||||
&& buy.get(plugin.keyZ).equals(String.valueOf(block.getZ())) ) {
|
||||
/* Remove the buy */
|
||||
boolean result = plugin.getShopManager().removeBuy(sign.getLine(1));
|
||||
if(result) {
|
||||
plugin.getLogger().info("Buying of region '" + sign.getLine(1) + "' has been removed by indirectly breaking the sign");
|
||||
}
|
||||
GeneralRegion region = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
||||
if(region == null) {
|
||||
return;
|
||||
}
|
||||
region.removeSign(block.getLocation());
|
||||
plugin.getLogger().info("A sign of region " + region.getName() + " has been removed by indirectly breaking it (block below/behind is destroyed)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
package nl.evolutioncoding.AreaShop;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.regions.BuyRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion.RegionEvent;
|
||||
import nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.material.Sign;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
/**
|
||||
* Checks for placement of signs for this plugin
|
||||
@@ -16,11 +26,6 @@ import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
*/
|
||||
public final class SignChangeListener implements Listener {
|
||||
AreaShop plugin;
|
||||
String chatPrefix;
|
||||
String rentSign;
|
||||
String buySign;
|
||||
String signRentable;
|
||||
String signBuyable;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -28,11 +33,6 @@ public final class SignChangeListener implements Listener {
|
||||
*/
|
||||
public SignChangeListener(AreaShop plugin) {
|
||||
this.plugin = plugin;
|
||||
chatPrefix = plugin.fixColors(plugin.config().getString("chatPrefix"));
|
||||
rentSign = plugin.config().getString("rentSign");
|
||||
buySign = plugin.config().getString("buySign");
|
||||
signRentable = plugin.fixColors(plugin.config().getString("signRentable"));
|
||||
signBuyable = plugin.fixColors(plugin.config().getString("signBuyable"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,163 +43,248 @@ public final class SignChangeListener implements Listener {
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
/* Check if the sign is meant for this plugin */
|
||||
if(event.getLine(0).contains(rentSign)) {
|
||||
// Check if the sign is meant for this plugin
|
||||
if(event.getLine(0).contains(plugin.config().getString("signTags.rent"))) {
|
||||
if(!player.hasPermission("areashop.createrent")) {
|
||||
player.sendMessage(chatPrefix + "You don't have permission for setting up renting of regions");
|
||||
plugin.message(player, "setup-noPermissionRent");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Get the other lines */
|
||||
// Get the other lines
|
||||
String secondLine = event.getLine(1);
|
||||
String thirdLine = event.getLine(2);
|
||||
if(!thirdLine.equals("M")) {
|
||||
thirdLine = thirdLine.toLowerCase();
|
||||
}
|
||||
String fourthLine = event.getLine(3);
|
||||
|
||||
/* Get the regionManager for accessing regions */
|
||||
// Get the regionManager for accessing regions
|
||||
RegionManager regionManager = plugin.getWorldGuard().getRegionManager(event.getPlayer().getWorld());
|
||||
|
||||
/* check if all the lines are correct */
|
||||
|
||||
// If the secondLine does not contain a name try to find the region by location
|
||||
if(secondLine == null || secondLine.length() == 0) {
|
||||
player.sendMessage(chatPrefix + "You did not specify a region on the second line!");
|
||||
ApplicableRegionSet regions = regionManager.getApplicableRegions(event.getBlock().getLocation());
|
||||
if(regions != null) {
|
||||
boolean first = true;
|
||||
ProtectedRegion candidate = null;
|
||||
for(ProtectedRegion pr : regions) {
|
||||
if(first) {
|
||||
candidate = pr;
|
||||
first = false;
|
||||
} else {
|
||||
if(pr.getPriority() > candidate.getPriority()) {
|
||||
candidate = pr;
|
||||
} else if(pr.getParent() != null && pr.getParent().equals(candidate)) {
|
||||
candidate = pr;
|
||||
} else {
|
||||
plugin.message(player, "setup-couldNotDetect", candidate.getId(), pr.getId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(candidate != null) {
|
||||
secondLine = candidate.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean priceSet = fourthLine != null && fourthLine.length() != 0;
|
||||
boolean durationSet = thirdLine != null && thirdLine.length() != 0;
|
||||
// check if all the lines are correct
|
||||
if(secondLine == null || secondLine.length() == 0) {
|
||||
plugin.message(player, "setup-noRegion");
|
||||
return;
|
||||
} else if(regionManager.getRegion(secondLine) == null) {
|
||||
player.sendMessage(chatPrefix + "The region you specified does not exist!");
|
||||
plugin.message(player, "setup-wrongRegion");
|
||||
return;
|
||||
} else if(plugin.getShopManager().getRent(secondLine) != null) {
|
||||
player.sendMessage(chatPrefix + "The region you specified already has a sign for renting");
|
||||
} else if(plugin.getFileManager().getRent(secondLine) != null) {
|
||||
plugin.message(player, "setup-alreadyRentSign");
|
||||
return;
|
||||
} else if(thirdLine == null || thirdLine.length() == 0) {
|
||||
player.sendMessage(chatPrefix + "You did not specify how long the region can be rented, do this on the third line");
|
||||
return;
|
||||
} else if(!this.checkTimeFormat(thirdLine)) {
|
||||
player.sendMessage(chatPrefix + "The time specified is not in the correct format");
|
||||
return;
|
||||
} else if(fourthLine == null || fourthLine.length() == 0) {
|
||||
player.sendMessage(chatPrefix + "You did not specify how much the renting costs on the fourth line!");
|
||||
} else if(thirdLine != null && thirdLine.length() != 0 && !plugin.checkTimeFormat(thirdLine)) {
|
||||
plugin.message(player, "setup-wrongDuration");
|
||||
return;
|
||||
} else {
|
||||
/* Check the fourth line */
|
||||
try {
|
||||
Double.parseDouble(fourthLine);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(chatPrefix + "You did not specify the renting cost correctly, use a number only");
|
||||
return;
|
||||
double price = 0.0;
|
||||
if(priceSet) {
|
||||
// Check the fourth line
|
||||
try {
|
||||
price = Double.parseDouble(fourthLine);
|
||||
} catch (NumberFormatException e) {
|
||||
plugin.message(player, "setup-wrongPrice");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the first line to signRentable */
|
||||
event.setLine(0, signRentable);
|
||||
event.setLine(1, regionManager.getRegion(secondLine).getId());
|
||||
event.setLine(3, plugin.getCurrencyCharacter() + fourthLine);
|
||||
|
||||
/* Add rent to the ShopManager */
|
||||
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()));
|
||||
rent.put(plugin.keyY, String.valueOf(event.getBlock().getY()));
|
||||
rent.put(plugin.keyZ, String.valueOf(event.getBlock().getZ()));
|
||||
rent.put(plugin.keyDuration, thirdLine);
|
||||
rent.put(plugin.keyPrice, fourthLine);
|
||||
rent.put(plugin.keyName, regionManager.getRegion(secondLine).getId());
|
||||
plugin.getShopManager().addRent(secondLine, rent);
|
||||
|
||||
/* Set the flags for the region */
|
||||
plugin.getShopManager().setRegionFlags(secondLine, plugin.config().getConfigurationSection("flagsForRent"), true);
|
||||
// Add rent to the FileManager
|
||||
final RentRegion rent = new RentRegion(plugin, secondLine, event.getPlayer().getWorld());
|
||||
if(priceSet) {
|
||||
rent.setPrice(price);
|
||||
}
|
||||
if(durationSet) {
|
||||
rent.setDuration(thirdLine);
|
||||
}
|
||||
Sign sign = (Sign)event.getBlock().getState().getData();
|
||||
rent.addSign(event.getBlock().getLocation(), event.getBlock().getType(), sign.getFacing(), null);
|
||||
|
||||
player.sendMessage(chatPrefix + "Renting of the region is setup correctly");
|
||||
// Run commands
|
||||
rent.runEventCommands(RegionEvent.CREATED, true);
|
||||
|
||||
plugin.getFileManager().addRent(rent);
|
||||
rent.handleSchematicEvent(RegionEvent.CREATED);
|
||||
// Update the sign later because this event will do it first
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rent.updateSigns();
|
||||
}
|
||||
}.runTaskLater(plugin, 1);
|
||||
|
||||
// Set the flags for the region
|
||||
rent.updateRegionFlags();
|
||||
plugin.message(player, "setup-rentSuccess", rent.getName());
|
||||
// Run commands
|
||||
rent.runEventCommands(RegionEvent.CREATED, false);
|
||||
}
|
||||
} else if (event.getLine(0).contains(buySign)) {
|
||||
/* Check for permission */
|
||||
} else if (event.getLine(0).contains(plugin.config().getString("signTags.buy"))) {
|
||||
// Check for permission
|
||||
if(!player.hasPermission("areashop.createbuy")) {
|
||||
player.sendMessage(chatPrefix + "You don't have permission for setting up buying of regions");
|
||||
plugin.message(player, "setup-noPermissionBuy");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the other lines */
|
||||
// Get the other lines
|
||||
String secondLine = event.getLine(1);
|
||||
String thirdLine = event.getLine(2);
|
||||
|
||||
/* Get the regionManager for accessing regions */
|
||||
// Get the regionManager for accessing regions
|
||||
RegionManager regionManager = plugin.getWorldGuard().getRegionManager(event.getPlayer().getWorld());
|
||||
|
||||
/* Check if all the lines are correct */
|
||||
// If the secondLine does not contain a name try to find the region by location
|
||||
if(secondLine == null || secondLine.length() == 0) {
|
||||
player.sendMessage(chatPrefix + "You did not specify a region on the second line!");
|
||||
ApplicableRegionSet regions = regionManager.getApplicableRegions(event.getBlock().getLocation());
|
||||
if(regions != null) {
|
||||
boolean first = true;
|
||||
ProtectedRegion candidate = null;
|
||||
for(ProtectedRegion pr : regions) {
|
||||
if(first) {
|
||||
candidate = pr;
|
||||
first = false;
|
||||
} else {
|
||||
if(pr.getPriority() > candidate.getPriority()) {
|
||||
candidate = pr;
|
||||
} else if(pr.getParent() != null && pr.getParent().equals(candidate)) {
|
||||
candidate = pr;
|
||||
} else if(pr.getPriority() == candidate.getPriority()) {
|
||||
plugin.message(player, "setup-couldNotDetect", candidate.getId(), pr.getId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(candidate != null) {
|
||||
secondLine = candidate.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean priceSet = thirdLine != null && thirdLine.length() != 0;
|
||||
// Check if all the lines are correct
|
||||
if(secondLine == null || secondLine.length() == 0) {
|
||||
plugin.message(player, "setup-noRegion");
|
||||
return;
|
||||
} else if(regionManager.getRegion(secondLine) == null) {
|
||||
player.sendMessage(chatPrefix + "The region you specified does not exist!");
|
||||
plugin.message(player, "setup-wrongRegion");
|
||||
return;
|
||||
} else if(plugin.getShopManager().getBuy(secondLine) != null) {
|
||||
player.sendMessage(chatPrefix + "The region you specified already has a sign for buying");
|
||||
return;
|
||||
} else if(thirdLine == null || thirdLine.length() == 0) {
|
||||
player.sendMessage(chatPrefix + "You did not specify how much the buying costs on the fourth line!");
|
||||
} else if(plugin.getFileManager().getBuy(secondLine) != null) {
|
||||
plugin.message(player, "setup-alreadyBuySign");
|
||||
return;
|
||||
} else {
|
||||
/* Check the fourth line */
|
||||
try {
|
||||
Double.parseDouble(thirdLine);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(chatPrefix + "You did not specify the buying cost correctly, use a number only");
|
||||
double price = 0.0;
|
||||
if(priceSet) {
|
||||
// Check the fourth line
|
||||
try {
|
||||
price = Double.parseDouble(thirdLine);
|
||||
} catch (NumberFormatException e) {
|
||||
plugin.message(player, "setup-wrongPrice");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add buy to the FileManager
|
||||
final BuyRegion buy = new BuyRegion(plugin, secondLine, event.getPlayer().getWorld());
|
||||
if(priceSet) {
|
||||
buy.setPrice(price);
|
||||
}
|
||||
Sign sign = (Sign)event.getBlock().getState().getData();
|
||||
buy.addSign(event.getBlock().getLocation(), event.getBlock().getType(), sign.getFacing(), null);
|
||||
// Run commands
|
||||
buy.runEventCommands(RegionEvent.CREATED, true);
|
||||
|
||||
plugin.getFileManager().addBuy(buy);
|
||||
buy.handleSchematicEvent(RegionEvent.CREATED);
|
||||
// Update the sign later because this event will do it first
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
buy.updateSigns();
|
||||
}
|
||||
}.runTaskLater(plugin, 1);
|
||||
|
||||
// Set the flags for the region
|
||||
buy.updateRegionFlags();
|
||||
plugin.message(player, "setup-buySuccess", regionManager.getRegion(secondLine).getId());
|
||||
|
||||
// Run commands
|
||||
buy.runEventCommands(RegionEvent.CREATED, false);
|
||||
}
|
||||
} else if(event.getLine(0).contains(plugin.config().getString("signTags.add"))) {
|
||||
// Check for permission
|
||||
if(!player.hasPermission("areashop.addsign")) {
|
||||
plugin.message(player, "addsign-noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the other lines
|
||||
String secondLine = event.getLine(1);
|
||||
String thirdLine = event.getLine(2);
|
||||
|
||||
GeneralRegion region = null;
|
||||
if(secondLine != null && secondLine.length() != 0) {
|
||||
// Get region by secondLine of the sign
|
||||
region = plugin.getFileManager().getRegion(secondLine);
|
||||
if(region == null) {
|
||||
plugin.message(player, "addsign-noRegion", secondLine);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Get region by sign position
|
||||
List<GeneralRegion> regions = plugin.getFileManager().getASRegionsInSelection(new CuboidSelection(event.getBlock().getWorld(), event.getBlock().getLocation(), event.getBlock().getLocation()));
|
||||
if(regions.isEmpty()) {
|
||||
plugin.message(player, "addsign-noRegions");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
plugin.message(player, "addsign-couldNotDetectSign", regions.get(0).getName(), regions.get(1).getName());
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set the first line to signbuyable */
|
||||
event.setLine(0, signBuyable);
|
||||
event.setLine(1, regionManager.getRegion(secondLine).getId());
|
||||
event.setLine(2, plugin.getCurrencyCharacter() + thirdLine);
|
||||
|
||||
/* Add buy to the ShopManager */
|
||||
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()));
|
||||
buy.put(plugin.keyY, String.valueOf(event.getBlock().getY()));
|
||||
buy.put(plugin.keyZ, String.valueOf(event.getBlock().getZ()));
|
||||
buy.put(plugin.keyPrice, thirdLine);
|
||||
buy.put(plugin.keyName, regionManager.getRegion(secondLine).getId());
|
||||
plugin.getShopManager().addBuy(secondLine, buy);
|
||||
|
||||
/* Set the flags for the region */
|
||||
plugin.getShopManager().setRegionFlags(secondLine, plugin.config().getConfigurationSection("flagsForSale"), false);
|
||||
|
||||
player.sendMessage(chatPrefix + "Buying of the region is setup correctly");
|
||||
region = regions.get(0);
|
||||
}
|
||||
Sign sign = (Sign)event.getBlock().getState().getData();
|
||||
if(thirdLine == null || thirdLine.length() == 0) {
|
||||
region.addSign(event.getBlock().getLocation(), event.getBlock().getType(), sign.getFacing(), null);
|
||||
plugin.message(player, "addsign-success", region.getName());
|
||||
} else {
|
||||
region.addSign(event.getBlock().getLocation(), event.getBlock().getType(), sign.getFacing(), thirdLine);
|
||||
plugin.message(player, "addsign-successProfile", region.getName(), thirdLine);
|
||||
}
|
||||
region.save();
|
||||
|
||||
// Update the sign later because this event will do it first
|
||||
final GeneralRegion regionUpdate = region;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
regionUpdate.updateSigns();
|
||||
}
|
||||
}.runTaskLater(plugin, 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the string is a correct time period
|
||||
* @param time String that has to be checked
|
||||
* @return true if format is correct, false if not
|
||||
*/
|
||||
public boolean checkTimeFormat(String time) {
|
||||
/* Check if the string is not empty and check the length */
|
||||
if(time == null || time.length() <= 1 || time.indexOf(' ') == -1 || time.indexOf(' ') >= (time.length()-1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check if the suffix is one of these values */
|
||||
String[] timeValues = {"m","min","mins","minute","minutes","minuten","minuut",
|
||||
"h","hour","hours","uur","uren",
|
||||
"M", "month", "months","maanden","maand",
|
||||
"d","day","days","dag","dagen",
|
||||
"y","year","years","jaar","jaren"};
|
||||
String suffix = time.substring(time.indexOf(' ')+1, time.length());
|
||||
boolean result = false;
|
||||
for(int i=0; i<timeValues.length && !result; i++) {
|
||||
result = timeValues[i].equals(suffix);
|
||||
}
|
||||
if(!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check if the part before the space is a number */
|
||||
String prefix = time.substring(0, (time.indexOf(' ')));
|
||||
return prefix.matches("\\d+");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package nl.evolutioncoding.AreaShop;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion.ClickType;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class SignClickListener implements Listener {
|
||||
AreaShop plugin;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param plugin The AreaShop plugin
|
||||
*/
|
||||
public SignClickListener(AreaShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player interacts
|
||||
* @param event The event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onSignClick(PlayerInteractEvent event) {
|
||||
Block block = event.getClickedBlock();
|
||||
/* Check for clicking a sign and rightclicking */
|
||||
if( (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||
&& (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)) {
|
||||
/* Check if the rent sign is really the same as a saved rent */
|
||||
GeneralRegion result = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
||||
if(result == null) {
|
||||
return;
|
||||
}
|
||||
String signName = result.getSignName(block.getLocation());
|
||||
Player player = event.getPlayer();
|
||||
// Get the clicktype
|
||||
ClickType clickType = null;
|
||||
if(player.isSneaking() && event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
clickType = ClickType.SHIFTLEFTCLICK;
|
||||
} else if(!player.isSneaking() && event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
clickType = ClickType.LEFTCLICK;
|
||||
} else if(player.isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
clickType = ClickType.SHIFTRIGHTCLICK;
|
||||
} else if(!player.isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
clickType = ClickType.RIGHTCLICK;
|
||||
}
|
||||
// Run the commands
|
||||
boolean runned = result.runSignCommands(signName, player, clickType);
|
||||
// Only cancel event if at least one command has been executed
|
||||
event.setCancelled(runned);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package nl.evolutioncoding.AreaShop;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class Utils {
|
||||
|
||||
// Not used
|
||||
private Utils() {}
|
||||
|
||||
|
||||
/**
|
||||
* Create a map from a location, to save it in the config
|
||||
* @param location The location to transform
|
||||
* @return The map with the location values
|
||||
*/
|
||||
public static ConfigurationSection locationToConfig(Location location, boolean setPitchYaw) {
|
||||
if(location == null) {
|
||||
return null;
|
||||
}
|
||||
ConfigurationSection result = new YamlConfiguration();
|
||||
result.set("world", location.getWorld().getName());
|
||||
result.set("x", location.getX());
|
||||
result.set("y", location.getY());
|
||||
result.set("z", location.getZ());
|
||||
if(setPitchYaw) {
|
||||
result.set("yaw", Float.toString(location.getYaw()));
|
||||
result.set("pitch", Float.toString(location.getPitch()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static ConfigurationSection locationToConfig(Location location) {
|
||||
return locationToConfig(location, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a location from a map, reconstruction from the config values
|
||||
* @param map The map to reconstruct from
|
||||
* @return The location
|
||||
*/
|
||||
public static Location configToLocation(ConfigurationSection config) {
|
||||
if(config == null
|
||||
|| !config.isString("world")
|
||||
|| !config.isDouble("x")
|
||||
|| !config.isDouble("y")
|
||||
|| !config.isDouble("z")) {
|
||||
return null;
|
||||
}
|
||||
Location result = new Location(
|
||||
Bukkit.getWorld(config.getString("world")),
|
||||
(Double)config.getDouble("x"),
|
||||
(Double)config.getDouble("y"),
|
||||
(Double)config.getDouble("z"));
|
||||
if(config.isString("yaw") && config.isString("pitch")) {
|
||||
result.setPitch(Float.parseFloat(config.getString("pitch")));
|
||||
result.setYaw(Float.parseFloat(config.getString("yaw")));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String createCommaSeparatedList(Collection<? extends Object> input) {
|
||||
String result = "";
|
||||
boolean first = true;
|
||||
for(Object object : input) {
|
||||
if(first) {
|
||||
first = false;
|
||||
result += object.toString();
|
||||
} else {
|
||||
result += ", " + object.toString();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Utils;
|
||||
import nl.evolutioncoding.AreaShop.regions.BuyRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion.RegionEvent;
|
||||
import nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class AddCommand extends CommandAreaShop {
|
||||
|
||||
public AddCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop add";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.createrent") || target.hasPermission("areashop.createbuy")) {
|
||||
return plugin.getLanguageManager().getLang("help-add");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(args.length < 2 || args[1] == null || (!"rent".equals(args[1].toLowerCase()) && !"buy".equals(args[1].toLowerCase()))) {
|
||||
plugin.message(sender, "add-help");
|
||||
return;
|
||||
}
|
||||
boolean isRent = "rent".equals(args[1].toLowerCase());
|
||||
if((isRent && !sender.hasPermission("areashop.createrent")) || (!isRent && !sender.hasPermission("areashop.createbuy"))) {
|
||||
plugin.message(sender, "add-noPermission");
|
||||
return;
|
||||
}
|
||||
List<ProtectedRegion> regions = new ArrayList<ProtectedRegion>();
|
||||
World world = null;
|
||||
if(args.length == 2) {
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-weOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
Selection selection = plugin.getWorldEdit().getSelection(player);
|
||||
if(selection == null) {
|
||||
plugin.message(player, "cmd-noSelection");
|
||||
return;
|
||||
}
|
||||
world = selection.getWorld();
|
||||
regions = plugin.getFileManager().getWERegionsInSelection(selection);
|
||||
if(regions.size() == 0) {
|
||||
plugin.message(player, "cmd-noWERegionsFound");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(sender instanceof Player) {
|
||||
if(args.length == 4) {
|
||||
world = Bukkit.getWorld(args[3]);
|
||||
if(world == null) {
|
||||
plugin.message(sender, "add-incorrectWorld", args[3]);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
world = ((Player)sender).getWorld();
|
||||
}
|
||||
} else {
|
||||
if(args.length < 4) {
|
||||
plugin.message(sender, "add-specifyWorld");
|
||||
return;
|
||||
} else {
|
||||
world = Bukkit.getWorld(args[3]);
|
||||
if(world == null) {
|
||||
plugin.message(sender, "add-incorrectWorld", args[3]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
ProtectedRegion region = plugin.getWorldGuard().getRegionManager(world).getRegion(args[2]);
|
||||
if(region == null) {
|
||||
plugin.message(sender, "add-noRegion", args[2]);
|
||||
return;
|
||||
}
|
||||
regions.add(region);
|
||||
}
|
||||
|
||||
ArrayList<String> namesSuccess = new ArrayList<String>();
|
||||
ArrayList<String> namesFailed = new ArrayList<String>();
|
||||
for(ProtectedRegion region : regions) {
|
||||
GeneralRegion asRegion = plugin.getFileManager().getRegion(region.getId());
|
||||
if(asRegion != null) {
|
||||
namesFailed.add(region.getId());
|
||||
} else {
|
||||
namesSuccess.add(region.getId());
|
||||
if(isRent) {
|
||||
RentRegion rent = new RentRegion(plugin, region.getId(), world);
|
||||
// Run commands
|
||||
rent.runEventCommands(RegionEvent.CREATED, true);
|
||||
plugin.getFileManager().addRent(rent);
|
||||
rent.handleSchematicEvent(RegionEvent.CREATED);
|
||||
// Set the flags for the region
|
||||
rent.updateRegionFlags();
|
||||
// Run commands
|
||||
rent.runEventCommands(RegionEvent.CREATED, false);
|
||||
} else {
|
||||
BuyRegion buy = new BuyRegion(plugin, region.getId(), world);
|
||||
// Run commands
|
||||
buy.runEventCommands(RegionEvent.CREATED, true);
|
||||
|
||||
plugin.getFileManager().addBuy(buy);
|
||||
buy.handleSchematicEvent(RegionEvent.CREATED);
|
||||
// Set the flags for the region
|
||||
buy.updateRegionFlags();
|
||||
// Run commands
|
||||
buy.runEventCommands(RegionEvent.CREATED, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(namesSuccess.size() != 0) {
|
||||
plugin.message(sender, "add-success", args[1], Utils.createCommaSeparatedList(namesSuccess));
|
||||
}
|
||||
if(namesFailed.size() != 0) {
|
||||
plugin.message(sender, "add-failed", Utils.createCommaSeparatedList(namesFailed));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result.add("rent");
|
||||
result.add("buy");
|
||||
} else if(toComplete == 3) {
|
||||
// can't get the world so also can't get applicable regions
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Utils;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.material.Sign;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
|
||||
public class AddsignCommand extends CommandAreaShop {
|
||||
|
||||
public AddsignCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop addsign";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.addsign")) {
|
||||
return plugin.getLanguageManager().getLang("help-addsign");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
if(!player.hasPermission("areashop.addsign")) {
|
||||
plugin.message(sender, "addsign-noPermission");
|
||||
return;
|
||||
}
|
||||
// Get the sign
|
||||
Block block = null;
|
||||
BlockIterator blockIterator = new BlockIterator(player, 100);
|
||||
while(blockIterator.hasNext() && block == null) {
|
||||
Block next = blockIterator.next();
|
||||
if(next.getType() != Material.AIR) {
|
||||
block = next;
|
||||
}
|
||||
}
|
||||
if(block == null || !(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
|
||||
plugin.message(sender, "addsign-noSign");
|
||||
return;
|
||||
}
|
||||
|
||||
GeneralRegion region = null;
|
||||
if(args.length > 1) {
|
||||
// Get region by argument
|
||||
region = plugin.getFileManager().getRegion(args[1]);
|
||||
if(region == null) {
|
||||
plugin.message(sender, "addsign-noRegion", args[1]);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Get region by sign position
|
||||
List<GeneralRegion> regions = plugin.getFileManager().getASRegionsInSelection(new CuboidSelection(block.getWorld(), block.getLocation(), block.getLocation()));
|
||||
if(regions.isEmpty()) {
|
||||
plugin.message(sender, "addsign-noRegions");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
plugin.message(sender, "addsign-couldNotDetect", regions.get(0).getName(), regions.get(1).getName());
|
||||
return;
|
||||
}
|
||||
region = regions.get(0);
|
||||
}
|
||||
Sign sign = (Sign)block.getState().getData();
|
||||
String profile = null;
|
||||
if(args.length > 2) {
|
||||
profile = args[2];
|
||||
Set<String> profiles = plugin.config().getConfigurationSection("signProfiles").getKeys(false);
|
||||
if(!profiles.contains(profile)) {
|
||||
plugin.message(sender, "addsign-wrongProfile", Utils.createCommaSeparatedList(profiles));
|
||||
return;
|
||||
}
|
||||
}
|
||||
GeneralRegion signRegion = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
||||
if(signRegion != null) {
|
||||
plugin.message(sender, "addsign-alreadyRegistered", signRegion.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
region.addSign(block.getLocation(), block.getType(), sign.getFacing(), profile);
|
||||
if(profile == null) {
|
||||
plugin.message(sender, "addsign-success", region.getName());
|
||||
} else {
|
||||
plugin.message(sender, "addsign-successProfile", region.getName(), profile);
|
||||
}
|
||||
region.updateSigns();
|
||||
region.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
} else if(toComplete == 3) {
|
||||
result.addAll(plugin.config().getStringList("signProfiles"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
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;
|
||||
|
||||
public class BuyCommand extends CommandAreaShop {
|
||||
|
||||
public BuyCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop buy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.buy")) {
|
||||
return plugin.getLanguageManager().getLang("help-buy");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
if(args.length > 1 && args[1] != null) {
|
||||
BuyRegion region = plugin.getFileManager().getBuy(args[1]);
|
||||
if(region == null) {
|
||||
plugin.message(player, "buy-notBuyable");
|
||||
} else {
|
||||
region.buy(player);
|
||||
}
|
||||
} else {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = plugin.getFileManager().getApplicalbeASRegions(player.getLocation());
|
||||
if(regions.size() != 1) {
|
||||
plugin.message(sender, "buy-help");
|
||||
} else {
|
||||
if(!regions.get(0).isBuyRegion()) {
|
||||
plugin.message(sender, "buy-notBuyable");
|
||||
} else {
|
||||
((BuyRegion)regions.get(0)).buy(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* Abstract class for generalising command classes
|
||||
*/
|
||||
public abstract class CommandAreaShop {
|
||||
AreaShop plugin;
|
||||
|
||||
/**
|
||||
* Save the instance of the main plugin class
|
||||
* @param plugin The main plugin
|
||||
*/
|
||||
public CommandAreaShop(AreaShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean canExecute(Command command, String[] args) {
|
||||
String commandString = command.getName();
|
||||
for(String argument : args) {
|
||||
commandString += " " + argument;
|
||||
}
|
||||
if(commandString.length() > getCommandStart().length()) {
|
||||
return commandString.toLowerCase().startsWith(getCommandStart().toLowerCase() + " ");
|
||||
}
|
||||
return commandString.toLowerCase().startsWith(getCommandStart().toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of string to complete a command with (raw list, not matching ones not filtered out)
|
||||
* @param toComplete The number of the argument that has to be completed
|
||||
* @param start The already given start of the command
|
||||
* @return A collection with all the possibilities for argument to complete
|
||||
*/
|
||||
public abstract List<String> getTabCompleteList(int toComplete, String[] start);
|
||||
|
||||
/**
|
||||
* Get the argument that comes after the base command that this command reacts to
|
||||
* @return
|
||||
*/
|
||||
public abstract String getCommandStart();
|
||||
|
||||
/**
|
||||
* Returns the correct help string for the reciever
|
||||
* @param target The CommandSender that the help message is for
|
||||
* @return The help message according to the permissions of the reciever
|
||||
*/
|
||||
public abstract String getHelp(CommandSender target);
|
||||
|
||||
/**
|
||||
* Execute a (sub)command if the conditions are met
|
||||
* @param sender The commandSender that executed the command
|
||||
* @param commandAreaShop The command that has been executed
|
||||
* @param args The arguments that are given
|
||||
*/
|
||||
public abstract void execute(CommandSender sender, Command command, String[] args);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Utils;
|
||||
import nl.evolutioncoding.AreaShop.regions.BuyRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
|
||||
public class DelCommand extends CommandAreaShop {
|
||||
|
||||
public DelCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop del";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.destroyrent") || target.hasPermission("areashop.destroybuy")) {
|
||||
return plugin.getLanguageManager().getLang("help-del");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.destroybuy") && !sender.hasPermission("areashop.destroyrent")) {
|
||||
plugin.message(sender, "del-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2) {
|
||||
// Only players can have a selection
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-weOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
Selection selection = plugin.getWorldEdit().getSelection(player);
|
||||
if(selection == null) {
|
||||
plugin.message(player, "cmd-noSelection");
|
||||
return;
|
||||
}
|
||||
List<GeneralRegion> regions = plugin.getFileManager().getASRegionsInSelection(selection);
|
||||
if(regions == null || regions.size() == 0) {
|
||||
plugin.message(player, "cmd-noRegionsFound");
|
||||
return;
|
||||
}
|
||||
// Start removing the region that he has permission for
|
||||
ArrayList<String> namesSuccess = new ArrayList<String>();
|
||||
ArrayList<String> namesFailed = new ArrayList<String>();
|
||||
for(GeneralRegion region : regions) {
|
||||
if(region.isRentRegion()) {
|
||||
if(!sender.hasPermission("areashop.destroyrent")) {
|
||||
namesFailed.add(region.getName());
|
||||
} else {
|
||||
plugin.getFileManager().removeRent((RentRegion)region, true);
|
||||
namesSuccess.add(region.getName());
|
||||
}
|
||||
} else if(region.isBuyRegion()) {
|
||||
if(!sender.hasPermission("areashop.destroybuy")) {
|
||||
namesFailed.add(region.getName());
|
||||
} else {
|
||||
plugin.getFileManager().removeBuy((BuyRegion)region, true);
|
||||
namesSuccess.add(region.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
// send messages
|
||||
if(namesSuccess.size() != 0) {
|
||||
plugin.message(sender, "del-success", Utils.createCommaSeparatedList(namesSuccess));
|
||||
}
|
||||
if(namesFailed.size() != 0) {
|
||||
plugin.message(sender, "del-failed", Utils.createCommaSeparatedList(namesFailed));
|
||||
}
|
||||
} else {
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[1]);
|
||||
if(region == null) {
|
||||
plugin.message(sender, "del-noRegion", args[1]);
|
||||
return;
|
||||
}
|
||||
if(region.isRentRegion()) {
|
||||
/* Remove the rent if the player has permission */
|
||||
if(sender.hasPermission("areashop.destroyrent")) {
|
||||
plugin.getFileManager().removeRent((RentRegion)region, true);
|
||||
plugin.message(sender, "destroy-successRent", region.getName());
|
||||
} else {
|
||||
plugin.message(sender, "destroy-noPermissionRent");
|
||||
}
|
||||
} else if(region.isBuyRegion()) {
|
||||
/* Remove the buy if the player has permission */
|
||||
if(sender.hasPermission("areashop.destroybuy")) {
|
||||
plugin.getFileManager().removeBuy((BuyRegion)region, true);
|
||||
plugin.message(sender, "destroy-successBuy", region.getName());
|
||||
} else {
|
||||
plugin.message(sender, "destroy-noPermissionBuy");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result = plugin.getFileManager().getRegionNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
|
||||
public class DelsignCommand extends CommandAreaShop {
|
||||
|
||||
public DelsignCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop delsign";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.delsign")) {
|
||||
return plugin.getLanguageManager().getLang("help-delsign");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
if(!player.hasPermission("areashop.delsign")) {
|
||||
plugin.message(sender, "delsign-noPermission");
|
||||
return;
|
||||
}
|
||||
// Get the sign
|
||||
Block block = null;
|
||||
BlockIterator blockIterator = new BlockIterator(player, 100);
|
||||
while(blockIterator.hasNext() && block == null) {
|
||||
Block next = blockIterator.next();
|
||||
if(next.getType() != Material.AIR) {
|
||||
block = next;
|
||||
}
|
||||
}
|
||||
if(block == null || !(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
|
||||
plugin.message(sender, "delsign-noSign");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
||||
if(region == null) {
|
||||
plugin.message(sender, "delsign-noRegion");
|
||||
return;
|
||||
}
|
||||
plugin.message(sender, "delsign-success", region.getName());
|
||||
region.removeSign(block.getLocation());
|
||||
region.updateSigns();
|
||||
region.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.regions.BuyRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FindCommand extends CommandAreaShop {
|
||||
|
||||
public FindCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop find";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.find")) {
|
||||
return plugin.getLanguageManager().getLang("help-find");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.find")) {
|
||||
plugin.message(sender, "find-noPermission");
|
||||
return;
|
||||
}
|
||||
if (!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
if(args.length <= 1 || args[1] == null || (!args[1].equalsIgnoreCase("buy") && !args[1].equalsIgnoreCase("rent"))) {
|
||||
plugin.message(sender, "find-help");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
double balance = plugin.getEconomy().getBalance(player);
|
||||
double maxPrice = 0;
|
||||
boolean maxPriceSet = false;
|
||||
if(args.length == 3) {
|
||||
try {
|
||||
maxPrice = Double.parseDouble(args[2]);
|
||||
maxPriceSet = true;
|
||||
} catch(NumberFormatException e) {
|
||||
plugin.message(sender, "find-wrongMaxPrice", args[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("buy")) {
|
||||
List<BuyRegion> regions = plugin.getFileManager().getBuys();
|
||||
for(BuyRegion region : regions) {
|
||||
if(!region.isSold() && ((region.getPrice() <= balance && !maxPriceSet) || (region.getPrice() <= maxPrice && maxPriceSet))) {
|
||||
BigDecimal bigDecimal = new BigDecimal(balance);
|
||||
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
|
||||
balance = bigDecimal.doubleValue();
|
||||
if(maxPriceSet) {
|
||||
plugin.message(player, "find-successMax", "buy", region.getName(), maxPrice);
|
||||
} else {
|
||||
plugin.message(player, "find-success", "buy", region.getName(), balance);
|
||||
}
|
||||
region.teleportPlayer(player, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
BigDecimal bigDecimal = new BigDecimal(balance);
|
||||
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
|
||||
balance = bigDecimal.doubleValue();
|
||||
if(maxPriceSet) {
|
||||
plugin.message(player, "find-noneFound", "buy", maxPrice);
|
||||
} else {
|
||||
plugin.message(player, "find-noneFoundMax", "buy", balance);
|
||||
}
|
||||
} else {
|
||||
List<RentRegion> regions = plugin.getFileManager().getRents();
|
||||
for(RentRegion region : regions) {
|
||||
if(!region.isRented() && ((region.getPrice() <= balance && !maxPriceSet) || (region.getPrice() <= maxPrice && maxPriceSet))) {
|
||||
BigDecimal bigDecimal = new BigDecimal(balance);
|
||||
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
|
||||
balance = bigDecimal.doubleValue();
|
||||
if(maxPriceSet) {
|
||||
plugin.message(player, "find-successMax", "rent", region.getName(), maxPrice);
|
||||
} else {
|
||||
plugin.message(player, "find-success", "rent", region.getName(), balance);
|
||||
}
|
||||
region.teleportPlayer(player, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
BigDecimal bigDecimal = new BigDecimal(balance);
|
||||
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
|
||||
balance = bigDecimal.doubleValue();
|
||||
if(maxPriceSet) {
|
||||
plugin.message(player, "find-noneFound", "rent", maxPrice);
|
||||
} else {
|
||||
plugin.message(player, "find-noneFoundMax", "rent", balance);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result.add("buy");
|
||||
result.add("rent");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Utils;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.RegionGroup;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
|
||||
public class GroupaddCommand extends CommandAreaShop {
|
||||
|
||||
public GroupaddCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop groupadd";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.groupadd")) {
|
||||
return plugin.getLanguageManager().getLang("help-groupadd");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.groupadd")) {
|
||||
plugin.message(sender, "groupadd-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2 || args[1] == null) {
|
||||
plugin.message(sender, "groupadd-help");
|
||||
return;
|
||||
}
|
||||
RegionGroup group = plugin.getFileManager().getGroup(args[1]);
|
||||
if(group == null) {
|
||||
group = new RegionGroup(plugin, args[1]);
|
||||
plugin.getFileManager().addGroup(group);
|
||||
}
|
||||
if(args.length == 2) {
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-weOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
Selection selection = plugin.getWorldEdit().getSelection(player);
|
||||
if(selection == null) {
|
||||
plugin.message(player, "cmd-noSelection");
|
||||
return;
|
||||
}
|
||||
List<GeneralRegion> regions = plugin.getFileManager().getASRegionsInSelection(selection);
|
||||
if(regions.size() == 0) {
|
||||
plugin.message(player, "cmd-noRegionsFound");
|
||||
return;
|
||||
}
|
||||
ArrayList<String> namesSuccess = new ArrayList<String>();
|
||||
ArrayList<String> namesFailed = new ArrayList<String>();
|
||||
for(GeneralRegion region : regions) {
|
||||
if(group.addMember(region)) {
|
||||
namesSuccess.add(region.getName());
|
||||
} else {
|
||||
namesFailed.add(region.getName());
|
||||
}
|
||||
}
|
||||
if(namesSuccess.size() != 0) {
|
||||
plugin.message(player, "groupadd-weSuccess", group.getName(), Utils.createCommaSeparatedList(namesSuccess));
|
||||
}
|
||||
if(namesFailed.size() != 0) {
|
||||
plugin.message(player, "groupadd-weFailed", group.getName(), Utils.createCommaSeparatedList(namesFailed));
|
||||
}
|
||||
} else {
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[2]);
|
||||
if(region == null) {
|
||||
plugin.message(sender, "groupadd-noRegion", args[2]);
|
||||
return;
|
||||
}
|
||||
if(group.addMember(region)) {
|
||||
plugin.message(sender, "groupadd-success", region.getName(), group.getName(), group.getMembers().size());
|
||||
} else {
|
||||
plugin.message(sender, "groupadd-failed", region.getName(), group.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result = plugin.getFileManager().getGroupNames();
|
||||
} else if(toComplete == 3) {
|
||||
result = plugin.getFileManager().getRegionNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Utils;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.RegionGroup;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
|
||||
public class GroupdelCommand extends CommandAreaShop {
|
||||
|
||||
public GroupdelCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop groupdel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.groupdel")) {
|
||||
return plugin.getLanguageManager().getLang("help-groupdel");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.groupdel")) {
|
||||
plugin.message(sender, "groupdel-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2 || args[1] == null) {
|
||||
plugin.message(sender, "groupdel-help");
|
||||
return;
|
||||
}
|
||||
RegionGroup group = plugin.getFileManager().getGroup(args[1]);
|
||||
if(group == null) {
|
||||
group = new RegionGroup(plugin, args[1]);
|
||||
plugin.getFileManager().addGroup(group);
|
||||
}
|
||||
if(args.length == 2) {
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-weOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
Selection selection = plugin.getWorldEdit().getSelection(player);
|
||||
if(selection == null) {
|
||||
plugin.message(player, "cmd-noSelection");
|
||||
return;
|
||||
}
|
||||
List<GeneralRegion> regions = plugin.getFileManager().getASRegionsInSelection(selection);
|
||||
if(regions.size() == 0) {
|
||||
plugin.message(player, "cmd-noRegionsFound");
|
||||
return;
|
||||
}
|
||||
ArrayList<String> namesSuccess = new ArrayList<String>();
|
||||
ArrayList<String> namesFailed = new ArrayList<String>();
|
||||
for(GeneralRegion region : regions) {
|
||||
if(group.removeMember(region)) {
|
||||
namesSuccess.add(region.getName());
|
||||
} else {
|
||||
namesFailed.add(region.getName());
|
||||
}
|
||||
}
|
||||
if(namesSuccess.size() != 0) {
|
||||
plugin.message(player, "groupdel-weSuccess", group.getName(), Utils.createCommaSeparatedList(namesSuccess));
|
||||
}
|
||||
if(namesFailed.size() != 0) {
|
||||
plugin.message(player, "groupdel-weFailed", group.getName(), Utils.createCommaSeparatedList(namesFailed));
|
||||
}
|
||||
} else {
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[2]);
|
||||
if(region == null) {
|
||||
plugin.message(sender, "groupdel-noRegion", args[2]);
|
||||
return;
|
||||
}
|
||||
if(group.removeMember(region)) {
|
||||
plugin.message(sender, "groupdel-success", region.getName(), group.getName(), group.getMembers().size());
|
||||
} else {
|
||||
plugin.message(sender, "groupdel-failed", region.getName(), group.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result = plugin.getFileManager().getGroupNames();
|
||||
} else if(toComplete == 3) {
|
||||
result = plugin.getFileManager().getRegionNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Utils;
|
||||
import nl.evolutioncoding.AreaShop.regions.RegionGroup;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class GroupinfoCommand extends CommandAreaShop {
|
||||
|
||||
public GroupinfoCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop groupinfo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.groupinfo")) {
|
||||
return plugin.getLanguageManager().getLang("help-groupinfo");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.groupinfo")) {
|
||||
plugin.message(sender, "groupinfo-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2 || args[1] == null) {
|
||||
plugin.message(sender, "groupinfo-help");
|
||||
return;
|
||||
}
|
||||
RegionGroup group = plugin.getFileManager().getGroup(args[1]);
|
||||
if(group == null) {
|
||||
plugin.message(sender, "groupinfo-noGroup", args[1]);
|
||||
return;
|
||||
}
|
||||
List<String> members = group.getMembers();
|
||||
if(members.size() == 0) {
|
||||
plugin.message(sender, "groupinfo-noMembers", group.getName());
|
||||
} else {
|
||||
plugin.message(sender, "groupinfo-members", group.getName(), Utils.createCommaSeparatedList(members));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result = plugin.getFileManager().getGroupNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Utils;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class GrouplistCommand extends CommandAreaShop {
|
||||
|
||||
public GrouplistCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop grouplist";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.grouplist")) {
|
||||
return plugin.getLanguageManager().getLang("help-grouplist");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.grouplist")) {
|
||||
plugin.message(sender, "grouplist-noPermission");
|
||||
return;
|
||||
}
|
||||
List<String> groups = plugin.getFileManager().getGroupNames();
|
||||
if(groups.size() == 0) {
|
||||
plugin.message(sender, "grouplist-noGroups");
|
||||
} else {
|
||||
plugin.message(sender, "grouplist-success", Utils.createCommaSeparatedList(groups));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class HelpCommand extends CommandAreaShop {
|
||||
|
||||
public HelpCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop help";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.help")) {
|
||||
return plugin.getLanguageManager().getLang("help-help");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
plugin.getCommandManager().showHelp(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Utils;
|
||||
import nl.evolutioncoding.AreaShop.regions.BuyRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InfoCommand extends CommandAreaShop {
|
||||
|
||||
public InfoCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.info")) {
|
||||
return plugin.getLanguageManager().getLang("help-info");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(args.length > 1 && args[1] != null) {
|
||||
/* List of all regions */
|
||||
if(args[1].equalsIgnoreCase("all")) {
|
||||
String message = "";
|
||||
/* Message for rents */
|
||||
Iterator<RentRegion> itRent = plugin.getFileManager().getRents().iterator();
|
||||
if(itRent.hasNext()) {
|
||||
message = itRent.next().getName();
|
||||
while(itRent.hasNext()) {
|
||||
message += ", " + itRent.next().getName();
|
||||
}
|
||||
}
|
||||
if(message.equals("")) {
|
||||
plugin.message(sender, "info-all-noRents");
|
||||
} else {
|
||||
plugin.message(sender, "info-all-rents", message);
|
||||
}
|
||||
|
||||
/* Message for buys */
|
||||
message = "";
|
||||
Iterator<BuyRegion> itBuy = plugin.getFileManager().getBuys().iterator();
|
||||
if(itBuy.hasNext()) {
|
||||
message = itBuy.next().getName();
|
||||
while(itBuy.hasNext()) {
|
||||
message += ", " + itBuy.next().getName();
|
||||
}
|
||||
}
|
||||
if(message.equals("")) {
|
||||
plugin.message(sender, "info-all-noBuys");
|
||||
} else {
|
||||
plugin.message(sender, "info-all-buys", message);
|
||||
}
|
||||
}
|
||||
/* List of rented regions */
|
||||
else if(args[1].equalsIgnoreCase("rented")) {
|
||||
String message = "";
|
||||
Iterator<RentRegion> it = plugin.getFileManager().getRents().iterator();
|
||||
boolean first = true;
|
||||
while(it.hasNext()) {
|
||||
RentRegion next = it.next();
|
||||
if(next.isRented()) {
|
||||
if(!first) {
|
||||
message += ", " + next.getName();
|
||||
} else {
|
||||
first = false;
|
||||
message += next.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(message.equals("")) {
|
||||
plugin.message(sender, "info-noRented");
|
||||
} else {
|
||||
plugin.message(sender, "info-rented", message);
|
||||
}
|
||||
}
|
||||
/* List of unrented regions */
|
||||
else if(args[1].equalsIgnoreCase("forrent")) {
|
||||
String message = "";
|
||||
Iterator<RentRegion> it = plugin.getFileManager().getRents().iterator();
|
||||
boolean first = true;
|
||||
while(it.hasNext()) {
|
||||
RentRegion next = it.next();
|
||||
if(!next.isRented()) {
|
||||
if(!first) {
|
||||
message += ", " + next.getName();
|
||||
} else {
|
||||
first = false;
|
||||
message = next.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(message.equals("")) {
|
||||
plugin.message(sender, "info-noUnrented");
|
||||
} else {
|
||||
plugin.message(sender, "info-unrented", message);
|
||||
}
|
||||
} else if(args[1].equalsIgnoreCase("sold")) {
|
||||
String message = "";
|
||||
Iterator<BuyRegion> it = plugin.getFileManager().getBuys().iterator();
|
||||
boolean first = true;
|
||||
while(it.hasNext()) {
|
||||
BuyRegion next = it.next();
|
||||
if(next.isSold()) {
|
||||
if(!first) {
|
||||
message += ", ";
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
message += next.getName();
|
||||
}
|
||||
}
|
||||
if(message.equals("")) {
|
||||
plugin.message(sender, "info-noSold");
|
||||
} else {
|
||||
plugin.message(sender, "info-sold", message);
|
||||
}
|
||||
} else if(args[1].equalsIgnoreCase("forsale")) {
|
||||
String message = "";
|
||||
Iterator<BuyRegion> it = plugin.getFileManager().getBuys().iterator();
|
||||
boolean first = true;
|
||||
while(it.hasNext()) {
|
||||
BuyRegion next =it.next();
|
||||
if(!next.isSold()) {
|
||||
if(!first) {
|
||||
message += ", " + next.getName();
|
||||
} else {
|
||||
first = false;
|
||||
message = next.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
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<RentRegion> itRent = plugin.getFileManager().getRents().iterator();
|
||||
boolean first = true;
|
||||
while(itRent.hasNext()) {
|
||||
RentRegion next = itRent.next();
|
||||
if(next.isRented() && next.getPlayerName().equalsIgnoreCase(args[2])) {
|
||||
if(!first) {
|
||||
message += ", " + next.getName();
|
||||
} else {
|
||||
first = false;
|
||||
message = next.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(message.equals("")) {
|
||||
plugin.message(sender, "info-playerNoRents", args[2]);
|
||||
} else {
|
||||
plugin.message(sender, "info-playerRents", args[2], message);
|
||||
}
|
||||
|
||||
message = "";
|
||||
Iterator<BuyRegion> itBuy = plugin.getFileManager().getBuys().iterator();
|
||||
first = true;
|
||||
while(itBuy.hasNext()) {
|
||||
BuyRegion next = itBuy.next();
|
||||
if(next.isSold() && next.getPlayerName().equalsIgnoreCase(args[2])) {
|
||||
if(!first) {
|
||||
message += ", ";
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
message += next.getName();
|
||||
}
|
||||
}
|
||||
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 > 1) {
|
||||
RentRegion rent = null;
|
||||
BuyRegion buy = null;
|
||||
if(args.length > 2) {
|
||||
rent = plugin.getFileManager().getRent(args[2]);
|
||||
buy = plugin.getFileManager().getBuy(args[2]);
|
||||
} else {
|
||||
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, "info-regionHelp");
|
||||
return;
|
||||
} else {
|
||||
if(regions.get(0).isRentRegion()) {
|
||||
rent = (RentRegion)regions.get(0);
|
||||
} else if(regions.get(0).isBuyRegion()) {
|
||||
buy = (BuyRegion)regions.get(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "info-regionHelp");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(rent == null && buy == null) {
|
||||
plugin.message(sender, "info-regionNotExisting", args[2]);
|
||||
return;
|
||||
}
|
||||
if(rent != null) {
|
||||
plugin.message(sender, "info-regionRenting", rent.getName());
|
||||
List<String> signLocations = new ArrayList<String>();
|
||||
for(Location location : rent.getSignLocations()) {
|
||||
signLocations.add(plugin.getLanguageManager().getLang("info-regionSignLocation", location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||
}
|
||||
if(signLocations.isEmpty()) {
|
||||
plugin.message(sender, "info-regionNoSign");
|
||||
} else {
|
||||
plugin.message(sender, "info-regionSign", Utils.createCommaSeparatedList(signLocations));
|
||||
}
|
||||
plugin.message(sender, "info-regionPriceDuration", rent.getFormattedPrice(), rent.getDurationString());
|
||||
if(!rent.isRented()) {
|
||||
plugin.message(sender, "info-regionNotRented");
|
||||
} else {
|
||||
SimpleDateFormat dateFull = new SimpleDateFormat(plugin.config().getString("timeFormatChat"));
|
||||
plugin.message(sender, "info-regionRentedBy", rent.getPlayerName(), dateFull.format(rent.getRentedUntil()));
|
||||
}
|
||||
if(sender.hasPermission("areashop.rentrestore")) {
|
||||
plugin.message(sender, "info-regionRestore", rent.isRestoreEnabled());
|
||||
plugin.message(sender, "info-regionRestoreProfile", rent.getRestoreProfile());
|
||||
}
|
||||
if(sender.hasPermission("areashop.teleport")) {
|
||||
if(rent.getTeleportLocation() == null) {
|
||||
plugin.message(sender, "info-regionNoTP");
|
||||
} else {
|
||||
plugin.message(sender, "info-regionTPLocation", rent.getTeleportLocation().getWorld().getName(), rent.getTeleportLocation().getBlockX(), rent.getTeleportLocation().getBlockY(), rent.getTeleportLocation().getBlockZ(), rent.getTeleportLocation().getPitch(), rent.getTeleportLocation().getYaw());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(buy != null) {
|
||||
plugin.message(sender, "info-regionBuying", buy.getName());
|
||||
List<String> signLocations = new ArrayList<String>();
|
||||
for(Location location : buy.getSignLocations()) {
|
||||
signLocations.add(plugin.getLanguageManager().getLang("info-regionSignLocation", location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||
}
|
||||
if(signLocations.isEmpty()) {
|
||||
plugin.message(sender, "info-regionNoSign");
|
||||
} else {
|
||||
plugin.message(sender, "info-regionSign", Utils.createCommaSeparatedList(signLocations));
|
||||
}
|
||||
plugin.message(sender, "info-regionPrice", buy.getFormattedPrice());
|
||||
if(!buy.isSold()) {
|
||||
plugin.message(sender, "info-regionNotBought");
|
||||
} else {
|
||||
plugin.message(sender, "info-regionBoughtBy", buy.getPlayerName());
|
||||
}
|
||||
if(sender.hasPermission("areashop.buyrestore")) {
|
||||
plugin.message(sender, "info-regionRestore", buy.isRestoreEnabled());
|
||||
plugin.message(sender, "info-regionRestoreProfile", buy.getRestoreProfile());
|
||||
}
|
||||
if(sender.hasPermission("areashop.teleport")) {
|
||||
if(buy.getTeleportLocation() == null) {
|
||||
plugin.message(sender, "info-regionNoTP");
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "info-regionHelp");
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "info-help");
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "info-help");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a comma-space separated list from a collection of strings
|
||||
* @param list The collection with strings
|
||||
* @return A comma-space separated list of the strings in the collection
|
||||
*/
|
||||
public String createCommaString(Collection<String> list) {
|
||||
String result = "";
|
||||
boolean first = true;
|
||||
for(String part : list) {
|
||||
if(first) {
|
||||
result += part;
|
||||
first = false;
|
||||
} else {
|
||||
result += ", " + part;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result.addAll(Arrays.asList("all", "rented", "forrent", "sold", "forsale", "player", "region"));
|
||||
} else if(toComplete == 3) {
|
||||
if(start[2].equalsIgnoreCase("player")) {
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
result.add(player.getName());
|
||||
}
|
||||
} else if(start[2].equalsIgnoreCase("region")) {
|
||||
result.addAll(plugin.getFileManager().getBuyNames());
|
||||
result.addAll(plugin.getFileManager().getRentNames());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class ReloadCommand extends CommandAreaShop {
|
||||
|
||||
public ReloadCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.reload")) {
|
||||
return plugin.getLanguageManager().getLang("help-reload");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(sender.hasPermission("areashop.reload")) {
|
||||
plugin.reload();
|
||||
plugin.message(sender, "reload-reloaded");
|
||||
} else {
|
||||
plugin.message(sender, "reload-noPermission");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RentCommand extends CommandAreaShop {
|
||||
|
||||
public RentCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop rent";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.rent")) {
|
||||
return plugin.getLanguageManager().getLang("help-rent");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
if(args.length > 1 && args[1] != null) {
|
||||
RentRegion rent = plugin.getFileManager().getRent(args[1]);
|
||||
if(rent == null) {
|
||||
plugin.message(sender, "rent-notRentable");
|
||||
} else {
|
||||
rent.rent(player);
|
||||
}
|
||||
} else {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = plugin.getFileManager().getApplicalbeASRegions(player.getLocation());
|
||||
if(regions.size() != 1) {
|
||||
plugin.message(sender, "rent-help");
|
||||
} else {
|
||||
if(!regions.get(0).isRentRegion()) {
|
||||
plugin.message(sender, "rent-notRentable");
|
||||
} else {
|
||||
((RentRegion)regions.get(0)).rent(player);
|
||||
}
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||
if(!region.isRented()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RentdurationCommand extends CommandAreaShop {
|
||||
|
||||
public RentdurationCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop rentduration";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.rentduration")) {
|
||||
return plugin.getLanguageManager().getLang("help-rentduration");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.rentduration")) {
|
||||
plugin.message(sender, "rentduration-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 3 || args[1] == null || args[2] == null) {
|
||||
plugin.message(sender, "rentduration-help");
|
||||
return;
|
||||
}
|
||||
RentRegion rent = null;
|
||||
if(args.length <= 3) {
|
||||
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, "rentduration-help");
|
||||
return;
|
||||
} else {
|
||||
if(regions.get(0).isRentRegion()) {
|
||||
rent = (RentRegion)regions.get(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "rentduration-help");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
rent = plugin.getFileManager().getRent(args[3]);
|
||||
}
|
||||
if(rent == null) {
|
||||
plugin.message(sender, "rentduration-notRegistered", args[3]);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Integer.parseInt(args[1]);
|
||||
} catch(NumberFormatException e) {
|
||||
plugin.message(sender, "rentduration-wrongAmount", args[1]);
|
||||
return;
|
||||
}
|
||||
if(!plugin.checkTimeFormat(args[1] + " " + args[2])) {
|
||||
plugin.message(sender, "rentduration-wrongFormat", args[1]+" "+args[2]);
|
||||
return;
|
||||
}
|
||||
rent.setDuration(args[1]+" "+args[2]);
|
||||
rent.updateRegionFlags();
|
||||
rent.updateSigns();
|
||||
rent.save();
|
||||
plugin.message(sender, "rentduration-success", rent.getName(), rent.getDurationString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result = plugin.getFileManager().getRentNames();
|
||||
} else if(toComplete == 4) {
|
||||
result.addAll(plugin.config().getStringList("minutes"));
|
||||
result.addAll(plugin.config().getStringList("hours"));
|
||||
result.addAll(plugin.config().getStringList("days"));
|
||||
result.addAll(plugin.config().getStringList("months"));
|
||||
result.addAll(plugin.config().getStringList("years"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Utils;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion.RegionEvent;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class SchematiceventCommand extends CommandAreaShop {
|
||||
|
||||
public SchematiceventCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop schemevent";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.schematicevents")) {
|
||||
return plugin.getLanguageManager().getLang("help-schemevent");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.schematicevents")) {
|
||||
plugin.message(sender, "schemevent-noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length < 3 || args[1] == null || args[2] == null) {
|
||||
plugin.message(sender, "schemevent-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[1]);
|
||||
if(region == null) {
|
||||
plugin.message(sender, "schemevent-noRegion", args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
RegionEvent event = null;
|
||||
boolean exception = false;
|
||||
try {
|
||||
event = RegionEvent.valueOf(args[2].toUpperCase());
|
||||
} catch(IllegalArgumentException e) {
|
||||
exception = true;
|
||||
}
|
||||
// Check for a totally wrong event or a non matching event
|
||||
if(exception) {
|
||||
ArrayList<String> values = new ArrayList<String>();
|
||||
for(RegionEvent value : RegionEvent.values()) {
|
||||
values.add(value.getValue().toLowerCase());
|
||||
}
|
||||
plugin.message(sender, "schemevent-wrongEvent", args[2], Utils.createCommaSeparatedList(values));
|
||||
return;
|
||||
}
|
||||
region.handleSchematicEvent(event);
|
||||
plugin.message(sender, "schemevent-success", args[2], region.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
} else if(toComplete == 3) {
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(start[2]);
|
||||
if(region != null) {
|
||||
if(region.isRentRegion()) {
|
||||
result.addAll(Arrays.asList("created", "deleted", "rented", "unrented"));
|
||||
} else if(region.isBuyRegion()) {
|
||||
result.addAll(Arrays.asList("created", "deleted", "bought", "sold"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
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;
|
||||
|
||||
public class SellCommand extends CommandAreaShop {
|
||||
|
||||
public SellCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop sell";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.sell")) {
|
||||
return plugin.getLanguageManager().getLang("help-sell");
|
||||
} else if(target.hasPermission("areashop.sellown")) {
|
||||
plugin.getLanguageManager().getLang("help-sellOwn");
|
||||
}
|
||||
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, "sell-help");
|
||||
return;
|
||||
} else {
|
||||
if(regions.get(0).isBuyRegion()) {
|
||||
buy = (BuyRegion)regions.get(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "sell-help");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
buy = plugin.getFileManager().getBuy(args[1]);
|
||||
}
|
||||
if(buy == null) {
|
||||
plugin.message(sender, "sell-notRegistered");
|
||||
return;
|
||||
}
|
||||
if(!buy.isSold()) {
|
||||
plugin.message(sender, "sell-notBought");
|
||||
return;
|
||||
}
|
||||
if(sender.hasPermission("areashop.sell")) {
|
||||
plugin.message(sender, "sell-sold", buy.getPlayerName());
|
||||
buy.sell(true);
|
||||
} else {
|
||||
if(sender.hasPermission("areashop.sellown") && sender instanceof Player) {
|
||||
if(buy.getBuyer().equals(((Player)sender).getUniqueId())) {
|
||||
plugin.message(sender, "sell-soldYours");
|
||||
buy.sell(true);
|
||||
} else {
|
||||
plugin.message(sender, "sell-noPermissionOther");
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "sell-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()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
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 nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SetpriceCommand extends CommandAreaShop {
|
||||
|
||||
public SetpriceCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop setprice";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.setprice")) {
|
||||
return plugin.getLanguageManager().getLang("help-setprice");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.setprice")) {
|
||||
plugin.message(sender, "setprice-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2 || args[1] == null) {
|
||||
plugin.message(sender, "setprice-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region = null;
|
||||
if(args.length < 3) {
|
||||
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, "setprice-help");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "setprice-help");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
region = plugin.getFileManager().getRegion(args[2]);
|
||||
}
|
||||
if(region == null) {
|
||||
plugin.message(sender, "setprice-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
double price = 0.0;
|
||||
try {
|
||||
price = Double.parseDouble(args[1]);
|
||||
} catch(NumberFormatException e) {
|
||||
plugin.message(sender, "setprice-wrongPrice", args[1]);
|
||||
return;
|
||||
}
|
||||
if(region.isRentRegion()) {
|
||||
((RentRegion)region).setPrice(price);
|
||||
plugin.message(sender, "setprice-successRent", region.getName(), ((RentRegion)region).getFormattedPrice(), ((RentRegion)region).getDurationString());
|
||||
} else if(region.isBuyRegion()) {
|
||||
((BuyRegion)region).setPrice(price);
|
||||
plugin.message(sender, "setprice-successBuy", region.getName(), ((BuyRegion)region).getFormattedPrice());
|
||||
}
|
||||
region.updateSigns();
|
||||
region.updateRegionFlags();
|
||||
region.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result = plugin.getFileManager().getRegionNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class SetrestoreCommand extends CommandAreaShop {
|
||||
|
||||
public SetrestoreCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop setrestore";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.setrestore")) {
|
||||
return plugin.getLanguageManager().getLang("help-setrestore");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.setrestore")) {
|
||||
plugin.message(sender, "setrestore-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length <= 2 || args[1] == null || args[2] == null) {
|
||||
plugin.message(sender, "setrestore-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[1]);
|
||||
if(region == null) {
|
||||
plugin.message(sender, "setrestore-notRegistered", args[1]);
|
||||
return;
|
||||
}
|
||||
String value = null;
|
||||
if(args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("general")) {
|
||||
value = args[2].toLowerCase();
|
||||
} else {
|
||||
plugin.message(sender, "setrestore-invalidSetting", args[2]);
|
||||
return;
|
||||
}
|
||||
region.setRestoreSetting(value);
|
||||
if(args.length > 3) {
|
||||
region.setRestoreProfile(args[3]);
|
||||
plugin.message(sender, "setrestore-successProfile", region.getName(), value, args[3]);
|
||||
} else {
|
||||
plugin.message(sender, "setrestore-success", region.getName(), value);
|
||||
}
|
||||
region.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result = plugin.getFileManager().getRegionNames();
|
||||
} else if(toComplete == 3) {
|
||||
result.add("true");
|
||||
result.add("false");
|
||||
result.add("general");
|
||||
} else if(toComplete == 4) {
|
||||
result.addAll(plugin.config().getConfigurationSection("schematicProfiles").getKeys(false));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
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 nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class SetteleportCommand extends CommandAreaShop {
|
||||
|
||||
public SetteleportCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop settp";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.teleportall")) {
|
||||
return plugin.getLanguageManager().getLang("help-setteleportAll");
|
||||
} else if(target.hasPermission("areashop.teleport")) {
|
||||
return plugin.getLanguageManager().getLang("help-setteleport");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
plugin.message(sender, "onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
GeneralRegion region = null;
|
||||
if(args.length <= 1) {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = plugin.getFileManager().getApplicalbeASRegions(((Player)sender).getLocation());
|
||||
if(regions.size() != 1) {
|
||||
plugin.message(sender, "setteleport-help");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
region = plugin.getFileManager().getRegion(args[1]);
|
||||
}
|
||||
|
||||
boolean owner = false;
|
||||
|
||||
if(region == null) {
|
||||
plugin.message(player, "setteleport-noRentOrBuy", args[1]);
|
||||
return;
|
||||
}
|
||||
if(region.isRentRegion()) {
|
||||
owner = player.getUniqueId().equals(((RentRegion)region).getRenter());
|
||||
} else {
|
||||
owner = player.getUniqueId().equals(((BuyRegion)region).getBuyer());
|
||||
}
|
||||
if(!player.hasPermission("areashop.setteleport")) {
|
||||
plugin.message(player, "setteleport-noPermission");
|
||||
return;
|
||||
} else if(!owner && !player.hasPermission("areashop.setteleportall")) {
|
||||
plugin.message(player, "setteleport-noPermissionOther");
|
||||
return;
|
||||
}
|
||||
|
||||
ProtectedRegion wgRegion = region.getRegion();
|
||||
if(args.length > 2 && args[2] != null && (args[2].equalsIgnoreCase("reset") || args[2].equalsIgnoreCase("yes") || args[2].equalsIgnoreCase("true"))) {
|
||||
region.setTeleport(null);
|
||||
plugin.message(player, "setteleport-reset", region.getName());
|
||||
return;
|
||||
}
|
||||
if(!wgRegion.contains(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()) && !player.hasPermission(" areashop.setteleportoutsideregion")) {
|
||||
plugin.message(player, "setteleport-notInside", region.getName());
|
||||
return;
|
||||
}
|
||||
region.setTeleport(player.getLocation());
|
||||
plugin.message(player, "setteleport-success", region.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
} else if(toComplete == 3) {
|
||||
result.add("reset");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TeleportCommand extends CommandAreaShop {
|
||||
|
||||
public TeleportCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop tp";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.teleportall")) {
|
||||
return plugin.getLanguageManager().getLang("help-teleportAll");
|
||||
} else if(target.hasPermission("areashop.teleport")) {
|
||||
return plugin.getLanguageManager().getLang("help-teleport");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
if(args.length <= 1 || args[1] == null) {
|
||||
plugin.message(sender, "teleport-help");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[1]);
|
||||
if(region == null) {
|
||||
plugin.message(player, "teleport-noRentOrBuy", args[1]);
|
||||
return;
|
||||
}
|
||||
if(args.length >= 3 && (args[2].equalsIgnoreCase("sign") || args[2].equalsIgnoreCase("yes") || args[2].equalsIgnoreCase("true"))) {
|
||||
region.teleportPlayer(player, true);
|
||||
} else {
|
||||
region.teleportPlayer(player, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
} else if(toComplete == 3) {
|
||||
result.add("sign");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.regions.GeneralRegion;
|
||||
import nl.evolutioncoding.AreaShop.regions.RentRegion;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class UnrentCommand extends CommandAreaShop {
|
||||
|
||||
public UnrentCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop unrent";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.unrent")) {
|
||||
return plugin.getLanguageManager().getLang("help-unrent");
|
||||
} else if(target.hasPermission("areashop.unrentown")) {
|
||||
return plugin.getLanguageManager().getLang("help-unrentOwn");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
RentRegion rent = 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, "unrent-help");
|
||||
return;
|
||||
} else {
|
||||
if(regions.get(0).isRentRegion()) {
|
||||
rent = (RentRegion)regions.get(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "unrent-help");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
rent = plugin.getFileManager().getRent(args[1]);
|
||||
}
|
||||
if(rent == null) {
|
||||
plugin.message(sender, "unrent-notRegistered");
|
||||
return;
|
||||
}
|
||||
if(!rent.isRented()) {
|
||||
plugin.message(sender, "unrent-notRented");
|
||||
return;
|
||||
}
|
||||
if(sender.hasPermission("areashop.unrent")) {
|
||||
plugin.message(sender, "unrent-other", rent.getPlayerName());
|
||||
rent.unRent(true);
|
||||
} else {
|
||||
if(sender.hasPermission("areashop.unrentown") && sender instanceof Player) {
|
||||
if(rent.getRenter().equals(((Player)sender).getUniqueId())) {
|
||||
plugin.message(sender, "unrent-unrented");
|
||||
rent.unRent(true);
|
||||
} else {
|
||||
plugin.message(sender, "unrent-noPermissionOther");
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "unrent-noPermission");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
if(toComplete == 2) {
|
||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||
if(region.isRented()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class UpdatebuysCommand extends CommandAreaShop {
|
||||
|
||||
public UpdatebuysCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop updatebuys";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.updatebuys")) {
|
||||
return plugin.getLanguageManager().getLang("help-updatebuys");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.updatebuys")) {
|
||||
plugin.message(sender, "buys-noPermission");
|
||||
return;
|
||||
}
|
||||
boolean result = plugin.getFileManager().updateBuySigns();
|
||||
plugin.getFileManager().updateBuyRegions();
|
||||
if(result) {
|
||||
plugin.message(sender, "buys-updated");
|
||||
} else {
|
||||
plugin.message(sender, "buys-notUpdated");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package nl.evolutioncoding.AreaShop.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class UpdaterentsCommand extends CommandAreaShop {
|
||||
|
||||
public UpdaterentsCommand(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop updaterents";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.updaterents")) {
|
||||
return plugin.getLanguageManager().getLang("help-updaterents");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String[] args) {
|
||||
if(!sender.hasPermission("areashop.updaterents")) {
|
||||
plugin.message(sender, "rents-noPermission");
|
||||
return;
|
||||
}
|
||||
boolean result = plugin.getFileManager().updateRentSigns();
|
||||
plugin.getFileManager().updateRentRegions();
|
||||
if(result) {
|
||||
plugin.message(sender, "rents-updated");
|
||||
} else {
|
||||
plugin.message(sender, "rents-notUpdated");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
package nl.evolutioncoding.AreaShop.regions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Exceptions.RegionCreateException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BuyRegion extends GeneralRegion {
|
||||
|
||||
public BuyRegion(AreaShop plugin, YamlConfiguration config) throws RegionCreateException {
|
||||
super(plugin, config);
|
||||
}
|
||||
|
||||
public BuyRegion(AreaShop plugin, String name, World world) {
|
||||
super(plugin, name, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionType getType() {
|
||||
return RegionType.BUY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionState getState() {
|
||||
if(isSold()) {
|
||||
return RegionState.SOLD;
|
||||
} else {
|
||||
return RegionState.FORSALE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UUID of the owner of this region
|
||||
* @return The UUID of the owner of this region
|
||||
*/
|
||||
public UUID getBuyer() {
|
||||
String buyer = getStringSetting("buy.buyer");
|
||||
if(buyer != null) {
|
||||
try {
|
||||
return UUID.fromString(buyer);
|
||||
} catch(IllegalArgumentException e) {}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is the buyer of this region
|
||||
* @param player Player to check
|
||||
* @return true if this player owns this region, otherwise false
|
||||
*/
|
||||
public boolean isBuyer(Player player) {
|
||||
UUID buyer = getBuyer();
|
||||
if(buyer == null || player == null) {
|
||||
return false;
|
||||
} else {
|
||||
return buyer.equals(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the buyer of this region
|
||||
* @param buyer The UUID of the player that should be set as buyer
|
||||
*/
|
||||
public void setBuyer(UUID buyer) {
|
||||
if(buyer == null) {
|
||||
setSetting("buy.buyer", null);
|
||||
setSetting("buy.buyerName", null);
|
||||
} else {
|
||||
setSetting("buy.buyer", buyer.toString());
|
||||
setSetting("buy.buyerName", plugin.toName(buyer));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the player that owns this region
|
||||
* @return The name of the player that owns this region
|
||||
*/
|
||||
public String getPlayerName() {
|
||||
return plugin.toName(getBuyer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the region is sold
|
||||
* @return true if the region is sold, otherwise false
|
||||
*/
|
||||
public boolean isSold() {
|
||||
return getBuyer() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the price of the region
|
||||
* @return The price of the region
|
||||
*/
|
||||
public double getPrice() {
|
||||
return getDoubleSetting("buy.price");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted string of the price (includes prefix and suffix)
|
||||
* @return The formatted string of the price
|
||||
*/
|
||||
public String getFormattedPrice() {
|
||||
return plugin.formatCurrency(getPrice());
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the price of the region
|
||||
* @param price
|
||||
*/
|
||||
public void setPrice(double price) {
|
||||
setSetting("buy.price", price);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getSpecificReplacements() {
|
||||
// Fill the replacements map with things specific to a BuyRegion
|
||||
HashMap<String, Object> result = new HashMap<String, Object>();
|
||||
result.put(AreaShop.tagPrice, getFormattedPrice());
|
||||
result.put(AreaShop.tagPlayerName, getPlayerName());
|
||||
result.put(AreaShop.tagPlayerUUID, getBuyer());
|
||||
// TODO: Add more?
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Buy a region
|
||||
* @param player The player that wants to buy the region
|
||||
* @return true if it succeeded and false if not
|
||||
*/
|
||||
public boolean buy(Player player) {
|
||||
/* Check if the player has permission */
|
||||
if(player.hasPermission("areashop.buy")) {
|
||||
if(!isSold()) {
|
||||
// Check if the player can still buy
|
||||
int maximumBuys = getMaxBuyRegions(player);
|
||||
AreaShop.debug("maximumBuys=" + maximumBuys);
|
||||
if(getCurrentBuyRegions(player) >= maximumBuys) {
|
||||
plugin.message(player, "buy-maximum", maximumBuys);
|
||||
return false;
|
||||
}
|
||||
int maximumTotal = getMaxTotalRegions(player);
|
||||
if(getCurrentTotalRegions(player) >= maximumTotal) {
|
||||
plugin.message(player, "total-maximum", maximumTotal);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check if the player has enough money */
|
||||
if(plugin.getEconomy().has(player, getWorldName(), getPrice())) {
|
||||
|
||||
/* Substract the money from the players balance */
|
||||
EconomyResponse r = plugin.getEconomy().withdrawPlayer(player, getPrice());
|
||||
if(!r.transactionSuccess()) {
|
||||
plugin.message(player, "buy-payError");
|
||||
return false;
|
||||
}
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.BOUGHT, true);
|
||||
|
||||
/* Set the owner */
|
||||
setBuyer(player.getUniqueId());
|
||||
|
||||
/* Update everything */
|
||||
handleSchematicEvent(RegionEvent.BOUGHT);
|
||||
updateSigns();
|
||||
updateRegionFlags(RegionState.SOLD);
|
||||
|
||||
/* Send message to the player */
|
||||
plugin.message(player, "buy-succes", getName());
|
||||
AreaShop.debug(player.getName() + " has bought region " + getName() + " for " + getFormattedPrice());
|
||||
|
||||
this.save();
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.BOUGHT, false);
|
||||
return true;
|
||||
} else {
|
||||
/* Player has not enough money */
|
||||
plugin.message(player, "buy-lowMoney", plugin.formatCurrency(plugin.getEconomy().getBalance(player, getWorldName())), getFormattedPrice());
|
||||
}
|
||||
} else {
|
||||
if(player.getUniqueId().equals(getBuyer())) {
|
||||
plugin.message(player, "buy-yours");
|
||||
} else {
|
||||
plugin.message(player, "buy-someoneElse");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.message(player, "buy-noPermission");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sell a buyed region, get part of the money back
|
||||
* @param regionName
|
||||
*/
|
||||
public void sell(boolean giveMoneyBack) {
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.SOLD, true);
|
||||
|
||||
/* Give part of the buying price back */
|
||||
double percentage = getDoubleSetting("buy.moneyBack") / 100.0;
|
||||
double moneyBack = getPrice() * percentage;
|
||||
if(moneyBack > 0 && giveMoneyBack) {
|
||||
/* Give back the money */
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(getBuyer());
|
||||
if(player != null) {
|
||||
EconomyResponse r = null;
|
||||
boolean error = false;
|
||||
try {
|
||||
r = plugin.getEconomy().depositPlayer(Bukkit.getOfflinePlayer(getBuyer()), moneyBack);
|
||||
} catch(Exception e) {
|
||||
error = true;
|
||||
}
|
||||
if(error || r == null || !r.transactionSuccess()) {
|
||||
plugin.getLogger().info("Something went wrong with paying back money to " + getPlayerName() + " while selling region " + getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Debug message */
|
||||
AreaShop.debug(getPlayerName() + " has sold " + getName() + ", got " + plugin.formatCurrency(moneyBack) + " money back");
|
||||
|
||||
/* Update everything */
|
||||
handleSchematicEvent(RegionEvent.SOLD);
|
||||
updateRegionFlags(RegionState.FORSALE);
|
||||
|
||||
/* Remove the player */
|
||||
setBuyer(null);
|
||||
|
||||
updateSigns();
|
||||
|
||||
this.save();
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.SOLD, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,151 @@
|
||||
package nl.evolutioncoding.AreaShop.regions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class RegionGroup {
|
||||
|
||||
private AreaShop plugin;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Constructor, used when creating new groups or restoring them from groups.yml at server boot
|
||||
* @param plugin The AreaShop plugin
|
||||
* @param name Name of the group, has to be unique
|
||||
*/
|
||||
public RegionGroup(AreaShop plugin, String name) {
|
||||
this.plugin = plugin;
|
||||
this.name = name;
|
||||
setSetting("name", name);
|
||||
// Delete duplicates
|
||||
List<String> members = getMembers();
|
||||
List<String> newMembers = new ArrayList<String>();
|
||||
while(!members.isEmpty()) {
|
||||
String member = members.remove(0);
|
||||
// If the region has been deleted also clean it from the group
|
||||
if(plugin.getFileManager().getRegion(member) != null) {
|
||||
newMembers.add(member);
|
||||
}
|
||||
while(members.contains(member)) {
|
||||
members.remove(member);
|
||||
}
|
||||
}
|
||||
if(newMembers.size() != members.size()) {
|
||||
setSetting("regions", newMembers);
|
||||
save();
|
||||
}
|
||||
if(getMembers().size() == 0) {
|
||||
plugin.getFileManager().removeGroup(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a member to a group
|
||||
* @param region The region to add to the group (GeneralRegion or a subclass of it)
|
||||
* @return true if the region was not already added, otherwise false
|
||||
*/
|
||||
public boolean addMember(GeneralRegion region) {
|
||||
List<String> members = getMembers();
|
||||
if(members.contains(region.getLowerCaseName())) {
|
||||
return false;
|
||||
} else {
|
||||
members.add(region.getName());
|
||||
setSetting("regions", members);
|
||||
save();
|
||||
region.updateSigns();
|
||||
region.updateRegionFlags();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a member from the group
|
||||
* @param region The region to remove
|
||||
* @return true if the region was in the group before, otherwise false
|
||||
*/
|
||||
public boolean removeMember(GeneralRegion region) {
|
||||
List<String> members = getMembers();
|
||||
boolean result = isMember(region);
|
||||
members.remove(region.getName());
|
||||
if(members.isEmpty()) {
|
||||
plugin.getFileManager().removeGroup(this);
|
||||
} else {
|
||||
setSetting("regions", members);
|
||||
}
|
||||
save();
|
||||
region.updateSigns();
|
||||
region.updateRegionFlags();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all members of the group
|
||||
* @return A list with the names of all members of the group
|
||||
*/
|
||||
public List<String> getMembers() {
|
||||
if(getSettings() == null || getSettings().getStringList("regions") == null) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
return getSettings().getStringList("regions");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the group
|
||||
* @return The name of the group
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* Get the lowercase name of the group (used for getting the config etc)
|
||||
* @return The name of the group in lowercase
|
||||
*/
|
||||
public String getLowerCaseName() {
|
||||
return getName().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a region is member of the group
|
||||
* @param region Region to check
|
||||
* @return true if the region is in the group, otherwise false
|
||||
*/
|
||||
public boolean isMember(GeneralRegion region) {
|
||||
return getMembers().contains(region.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the priority of the group (higher overwrites)
|
||||
* @return The priority of the group
|
||||
*/
|
||||
public int getPriority() {
|
||||
return getSettings().getInt("priority");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configurationsection with the settings of this group
|
||||
* @return The ConfigurationSection with the settings of the group
|
||||
*/
|
||||
public ConfigurationSection getSettings() {
|
||||
return plugin.getFileManager().getGroupSettings(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a setting of this group
|
||||
* @param path The path to set
|
||||
* @param setting The value to set
|
||||
*/
|
||||
public void setSetting(String path, Object setting) {
|
||||
plugin.getFileManager().setGroupSetting(this, path, setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the group to disk (currently saves all groups because they are all in 1 file)
|
||||
*/
|
||||
public void save() {
|
||||
plugin.getFileManager().saveGroups();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
package nl.evolutioncoding.AreaShop.regions;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import nl.evolutioncoding.AreaShop.AreaShop;
|
||||
import nl.evolutioncoding.AreaShop.Exceptions.RegionCreateException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RentRegion extends GeneralRegion {
|
||||
/**
|
||||
* Constructor
|
||||
* @param plugin The areashop plugin
|
||||
* @param settings All settings of this region
|
||||
* @throws RegionCreateException
|
||||
*/
|
||||
public RentRegion(AreaShop plugin, YamlConfiguration config) throws RegionCreateException {
|
||||
super(plugin, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RentRegion
|
||||
* @param plugin The AreaShop plugin
|
||||
* @param name The name of the region (correct casing)
|
||||
* @param world The world of the WorldGuard region
|
||||
*/
|
||||
public RentRegion(AreaShop plugin, String name, World world) {
|
||||
super(plugin, name, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionType getType() {
|
||||
return RegionType.RENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionState getState() {
|
||||
if(isRented()) {
|
||||
return RegionState.RENTED;
|
||||
} else {
|
||||
return RegionState.FORRENT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UUID of the player renting the region
|
||||
* @return The UUID of the renter
|
||||
*/
|
||||
public UUID getRenter() {
|
||||
String renter = getStringSetting("rent.renter");
|
||||
if(renter != null) {
|
||||
try {
|
||||
return UUID.fromString(renter);
|
||||
} catch(IllegalArgumentException e) {}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is the renter of this region
|
||||
* @param player Player to check
|
||||
* @return true if this player rents this region, otherwise false
|
||||
*/
|
||||
public boolean isRenter(Player player) {
|
||||
UUID renter = getRenter();
|
||||
if(player == null || renter == null) {
|
||||
return false;
|
||||
} else {
|
||||
return renter.equals(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the renter of this region
|
||||
* @param renter The UUID of the player that should be set as the renter
|
||||
*/
|
||||
public void setRenter(UUID renter) {
|
||||
if(renter == null) {
|
||||
setSetting("rent.renter", null);
|
||||
setSetting("rent.renterName", null);
|
||||
} else {
|
||||
setSetting("rent.renter", renter.toString());
|
||||
setSetting("rent.renterName", plugin.toName(renter));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max number of extends of this region
|
||||
* @return -1 if infinite otherwise the maximum number
|
||||
*/
|
||||
public int getMaxExtends() {
|
||||
return getIntegerSetting("rent.maxExtends");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get how many times the rent has already been extended
|
||||
* @return The number of times extended
|
||||
*/
|
||||
public int getTimesExtended() {
|
||||
return config.getInt("rent.timesExtended");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of times the region has been extended
|
||||
* @param times The number of times the region has been extended
|
||||
*/
|
||||
public void setTimesExtended(int times) {
|
||||
if(times < 0) {
|
||||
config.set("rent.timesExtended", null);
|
||||
} else {
|
||||
config.set("rent.timesExtended", times);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getSpecificReplacements() {
|
||||
// Fill the replacements map with things specific to a RentRegion
|
||||
HashMap<String, Object> result = new HashMap<String, Object>();
|
||||
result.put(AreaShop.tagPrice, getFormattedPrice());
|
||||
result.put(AreaShop.tagDuration, getDurationString());
|
||||
result.put(AreaShop.tagPlayerName, getPlayerName());
|
||||
result.put(AreaShop.tagPlayerUUID, getRenter());
|
||||
SimpleDateFormat date = new SimpleDateFormat(plugin.config().getString("timeFormatChat"));
|
||||
String dateString = date.format(new Date(getRentedUntil()));
|
||||
result.put(AreaShop.tagRentedUntil, dateString);
|
||||
date = new SimpleDateFormat(plugin.config().getString("timeFormatSign"));
|
||||
dateString = date.format(new Date(getRentedUntil()));
|
||||
result.put(AreaShop.tagRentedUntilShort, dateString);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the region is rented
|
||||
* @return true if the region is rented, otherwise false
|
||||
*/
|
||||
public boolean isRented() {
|
||||
return getRenter() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the player renting this region
|
||||
* @return Name of the player renting this region
|
||||
*/
|
||||
public String getPlayerName() {
|
||||
return plugin.toName(getRenter());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time until this region is rented (time from 1970 epoch)
|
||||
* @return
|
||||
*/
|
||||
public long getRentedUntil() {
|
||||
return getLongSetting("rent.rentedUntil");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time until the region is rented (milliseconds from 1970, system time)
|
||||
* @param rentedUntil The time until the region is rented
|
||||
*/
|
||||
public void setRentedUntil(Long rentedUntil) {
|
||||
if(rentedUntil == null) {
|
||||
setSetting("rent.rentedUntil", null);
|
||||
} else {
|
||||
setSetting("rent.rentedUntil", rentedUntil);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the price of the region
|
||||
* @return The price of the region
|
||||
*/
|
||||
public double getPrice() {
|
||||
return getDoubleSetting("rent.price");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted string of the price (includes prefix and suffix)
|
||||
* @return The formatted string of the price
|
||||
*/
|
||||
public String getFormattedPrice() {
|
||||
return plugin.formatCurrency(getPrice());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the duration of 1 rent period
|
||||
* @return The duration in milliseconds of 1 rent period
|
||||
*/
|
||||
public long getDuration() {
|
||||
/* Get the time until the region will be rented */
|
||||
String duration = getDurationString();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(0);
|
||||
|
||||
ArrayList<String> minutes = new ArrayList<String>(plugin.config().getStringList("minutes"));
|
||||
ArrayList<String> hours = new ArrayList<String>(plugin.config().getStringList("hours"));
|
||||
ArrayList<String> days = new ArrayList<String>(plugin.config().getStringList("days"));
|
||||
ArrayList<String> months = new ArrayList<String>(plugin.config().getStringList("months"));
|
||||
ArrayList<String> years = new ArrayList<String>(plugin.config().getStringList("years"));
|
||||
|
||||
String durationString = duration.substring(duration.indexOf(' ')+1, duration.length());
|
||||
int durationInt = Integer.parseInt(duration.substring(0, duration.indexOf(' ')));
|
||||
|
||||
if(minutes.contains(durationString)) {
|
||||
calendar.add(Calendar.MINUTE, durationInt);
|
||||
} else if(hours.contains(durationString)) {
|
||||
calendar.add(Calendar.HOUR, durationInt);
|
||||
} else if(days.contains(durationString)) {
|
||||
calendar.add(Calendar.DAY_OF_MONTH, durationInt);
|
||||
} else if(months.contains(durationString)) {
|
||||
calendar.add(Calendar.MONTH, durationInt);
|
||||
} else if(years.contains(durationString)) {
|
||||
calendar.add(Calendar.YEAR, durationInt);
|
||||
}
|
||||
|
||||
return calendar.getTimeInMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the duration string, includes number<space>indentifier
|
||||
* @return The duration string
|
||||
*/
|
||||
public String getDurationString() {
|
||||
return getStringSetting("rent.duration");
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the price of the region
|
||||
* @param price
|
||||
*/
|
||||
public void setPrice(double price) {
|
||||
setSetting("rent.price", price);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the duration of the rent
|
||||
* @param duration The duration of the rent (as specified on the documentation pages)
|
||||
*/
|
||||
public void setDuration(String duration) {
|
||||
setSetting("rent.duration", duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rent a region
|
||||
* @param player The player that wants to rent the region
|
||||
* @param regionName The name of the region you want to rent
|
||||
* @return true if it succeeded and false if not
|
||||
*/
|
||||
public boolean rent(Player player) {
|
||||
/* Check if the player has permission */
|
||||
if(player.hasPermission("areashop.rent")) {
|
||||
boolean extend = false;
|
||||
if(getRenter() != null && player.getUniqueId().equals(getRenter())) {
|
||||
extend = true;
|
||||
}
|
||||
// Check if the region is available for renting or if the player wants to extend the rent
|
||||
if(!isRented() || extend) {
|
||||
if(!extend) {
|
||||
// Check if the player can still rent more regions
|
||||
int maximumRents = getMaxRentRegions(player);
|
||||
if(getCurrentRentRegions(player) >= maximumRents) {
|
||||
plugin.message(player, "rent-maximum", maximumRents);
|
||||
return false;
|
||||
}
|
||||
int maximumTotal = getMaxTotalRegions(player);
|
||||
if(getCurrentTotalRegions(player) >= maximumTotal) {
|
||||
plugin.message(player, "total-maximum", maximumTotal);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the player can still extend this rent
|
||||
if(extend && !player.hasPermission("areashop.rentextendbypass")) {
|
||||
if(getMaxExtends() >= 0 && getTimesExtended() >= getMaxExtends()) {
|
||||
plugin.message(player, "rent-maxExtends", getMaxExtends());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(plugin.getEconomy().has(player, getWorldName(), getPrice())) {
|
||||
/* Substract the money from the players balance */
|
||||
EconomyResponse r = plugin.getEconomy().withdrawPlayer(player, getPrice());
|
||||
if(!r.transactionSuccess()) {
|
||||
plugin.message(player, "rent-payError");
|
||||
return false;
|
||||
}
|
||||
if(!extend) {
|
||||
// Run commands
|
||||
runEventCommands(RegionEvent.RENTED, true);
|
||||
} else {
|
||||
// Run commands
|
||||
runEventCommands(RegionEvent.EXTENDED, true);
|
||||
}
|
||||
|
||||
/* Get the time until the region will be rented */
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if(extend) {
|
||||
calendar.setTimeInMillis(getRentedUntil());
|
||||
}
|
||||
calendar.setTimeInMillis(calendar.getTimeInMillis() + getDuration());
|
||||
|
||||
SimpleDateFormat dateFull = new SimpleDateFormat(plugin.config().getString("timeFormatChat"));
|
||||
|
||||
/* Add values to the rent and send it to FileManager */
|
||||
setRentedUntil(calendar.getTimeInMillis());
|
||||
setRenter(player.getUniqueId());
|
||||
|
||||
// Fire schematic event and updated times extended
|
||||
if(!extend) {
|
||||
this.handleSchematicEvent(RegionEvent.RENTED);
|
||||
setTimesExtended(0);
|
||||
} else {
|
||||
setTimesExtended(getTimesExtended() + 1);
|
||||
}
|
||||
|
||||
/* Change the sign and the region flags */
|
||||
updateSigns();
|
||||
updateRegionFlags(RegionState.RENTED);
|
||||
|
||||
/* Send message to the player */
|
||||
if(extend) {
|
||||
plugin.message(player, "rent-extended", getName(), dateFull.format(calendar.getTime()));
|
||||
} else {
|
||||
plugin.message(player, "rent-rented", getName(), dateFull.format(calendar.getTime()));
|
||||
plugin.message(player, "rent-extend");
|
||||
}
|
||||
AreaShop.debug(player.getName() + " has rented region " + getName() + " for " + getFormattedPrice() + " until " + dateFull.format(calendar.getTime()));
|
||||
|
||||
this.save();
|
||||
if(!extend) {
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.RENTED, false);
|
||||
} else {
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.EXTENDED, false);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
/* Player has not enough money */
|
||||
if(extend) {
|
||||
plugin.message(player, "rent-lowMoneyExtend", plugin.formatCurrency(plugin.getEconomy().getBalance(player, getWorldName())), getFormattedPrice());
|
||||
} else {
|
||||
plugin.message(player, "rent-lowMoneyRent", plugin.formatCurrency(plugin.getEconomy().getBalance(player, getWorldName())), getFormattedPrice());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.message(player, "rent-someoneElse");
|
||||
}
|
||||
} else {
|
||||
plugin.message(player, "rent-noPermission");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unrent a region, reset to unrented
|
||||
* @param regionName Region that should be unrented
|
||||
*/
|
||||
public void unRent(boolean giveMoneyBack) {
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.UNRENTED, true);
|
||||
/* Get the time until the region will be rented */
|
||||
Long currentTime = Calendar.getInstance().getTimeInMillis();
|
||||
Double timeLeft = (double) ((getRentedUntil() - currentTime));
|
||||
double percentage = (getDoubleSetting("rent.moneyBack")) / 100.0;
|
||||
|
||||
Double timePeriod = (double) (getDuration());
|
||||
double periods = timeLeft / timePeriod;
|
||||
double moneyBack = periods * getPrice() * percentage;
|
||||
if(moneyBack > 0 && giveMoneyBack) {
|
||||
/* Give back the money */
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(getRenter());
|
||||
if(player != null) {
|
||||
EconomyResponse r = null;
|
||||
boolean error = false;
|
||||
try {
|
||||
r = plugin.getEconomy().depositPlayer(Bukkit.getOfflinePlayer(getRenter()), moneyBack);
|
||||
} catch(Exception e) {
|
||||
error = true;
|
||||
}
|
||||
if(error || r == null || !r.transactionSuccess()) {
|
||||
plugin.getLogger().info("Something went wrong with paying back to " + getPlayerName() + " money while unrenting region " + getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Debug message */
|
||||
AreaShop.debug(getPlayerName() + " has unrented " + getName() + ", got " + plugin.formatCurrency(moneyBack) + " money back");
|
||||
|
||||
/* Update the signs and region flags */
|
||||
handleSchematicEvent(RegionEvent.UNRENTED);
|
||||
updateRegionFlags(RegionState.FORRENT);
|
||||
|
||||
/* Remove the player and renteduntil values */
|
||||
setRenter(null);
|
||||
setRentedUntil(null);
|
||||
setTimesExtended(-1);
|
||||
|
||||
updateSigns();
|
||||
|
||||
this.save();
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.UNRENTED, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#AreaShop
|
||||
|
||||
Check the documentation and download the plugin at http://dev.bukkit.org/bukkit-plugins/regionbuyandrent/
|
||||
|
||||
Note: The code on this repository will not show live progress on the plugin, but will only be updated when an update is released on Bukkit.
|
||||
|
||||
Latest update: http://dev.bukkit.org/bukkit-plugins/regionbuyandrent/files/13-area-shop-v2-0-1/
|
||||
Reference in new issue
Block a user