mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-27 04:35:43 +01:00
Adds the code from version 2.0.1
This commit is contained in:
parent
b3ea7f7e73
commit
6886db8edc
@ -20,6 +20,8 @@ language: EN
|
||||
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
|
||||
@ -28,9 +30,6 @@ useColorsInConsole: false
|
||||
postCommandErrors: true
|
||||
## Version of the config, do not change!
|
||||
version: 2.0.0
|
||||
## 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
|
||||
## The different tags you can write on the sign to trigger the plugin
|
||||
signTags:
|
||||
## Tag for adding a rent region
|
||||
|
@ -13,29 +13,13 @@ general:
|
||||
signProfile: 'default'
|
||||
## The profile for the WorldGuard flags as specified in the config
|
||||
flagProfile: 'default'
|
||||
runCommands:
|
||||
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:
|
||||
## 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:
|
||||
|
@ -153,7 +153,7 @@ 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 <region> <amount> <identifier>"
|
||||
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"
|
||||
@ -183,7 +183,7 @@ 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%, change the region or set position yourself"
|
||||
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"
|
||||
@ -231,6 +231,7 @@ schemevent-help: "/as schemevent <region> <created|deleted|rented|unrented|bough
|
||||
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"
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: AreaShop
|
||||
main: nl.evolutioncoding.AreaShop.AreaShop
|
||||
version: 2.0.0
|
||||
version: 2.0.1
|
||||
depend: [Vault, WorldGuard, WorldEdit]
|
||||
softdepend: [Multiverse-Core]
|
||||
commands:
|
||||
|
@ -50,7 +50,7 @@ public class BuyCommand extends CommandAreaShop {
|
||||
if(regions.size() != 1) {
|
||||
plugin.message(sender, "buy-help");
|
||||
} else {
|
||||
if(!regions.get(0).isRentRegion()) {
|
||||
if(!regions.get(0).isBuyRegion()) {
|
||||
plugin.message(sender, "buy-notBuyable");
|
||||
} else {
|
||||
((BuyRegion)regions.get(0)).buy(player);
|
||||
|
@ -55,6 +55,7 @@ public class RentCommand extends CommandAreaShop {
|
||||
} else {
|
||||
((RentRegion)regions.get(0)).rent(player);
|
||||
}
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,12 @@ 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 {
|
||||
|
||||
@ -34,26 +36,45 @@ public class RentdurationCommand extends CommandAreaShop {
|
||||
plugin.message(sender, "rentduration-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 4 || args[1] == null || args[2] == null || args[3] == null) {
|
||||
if(args.length < 3 || args[1] == null || args[2] == null) {
|
||||
plugin.message(sender, "rentduration-help");
|
||||
return;
|
||||
}
|
||||
RentRegion rent = plugin.getFileManager().getRent(args[1]);
|
||||
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[1]);
|
||||
plugin.message(sender, "rentduration-notRegistered", args[3]);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Integer.parseInt(args[2]);
|
||||
Integer.parseInt(args[1]);
|
||||
} catch(NumberFormatException e) {
|
||||
plugin.message(sender, "rentduration-wrongAmount", args[2]);
|
||||
plugin.message(sender, "rentduration-wrongAmount", args[1]);
|
||||
return;
|
||||
}
|
||||
if(!plugin.checkTimeFormat(args[2] + " " + args[3])) {
|
||||
plugin.message(sender, "rentduration-wrongFormat", args[2]+" "+args[3]);
|
||||
if(!plugin.checkTimeFormat(args[1] + " " + args[2])) {
|
||||
plugin.message(sender, "rentduration-wrongFormat", args[1]+" "+args[2]);
|
||||
return;
|
||||
}
|
||||
rent.setDuration(args[2]+" "+args[3]);
|
||||
rent.setDuration(args[1]+" "+args[2]);
|
||||
rent.updateRegionFlags();
|
||||
rent.updateSigns();
|
||||
rent.save();
|
||||
|
@ -33,6 +33,11 @@ public class SchematiceventCommand extends CommandAreaShop {
|
||||
|
||||
@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;
|
||||
|
@ -856,7 +856,8 @@ public abstract class GeneralRegion {
|
||||
if(region != null) {
|
||||
// Set to block in the middle, y configured in the config
|
||||
Vector middle = Vector.getMidpoint(region.getMaximumPoint(), region.getMinimumPoint());
|
||||
String configSetting = plugin.config().getString("teleportLocationY");
|
||||
String configSetting = getStringSetting("general.teleportLocationY");
|
||||
AreaShop.debug("teleportLocationY = " + configSetting);
|
||||
if("bottom".equalsIgnoreCase(configSetting)) {
|
||||
middle = middle.setY(region.getMinimumPoint().getBlockY());
|
||||
} else if("top".equalsIgnoreCase(configSetting)) {
|
||||
@ -869,6 +870,10 @@ public abstract class GeneralRegion {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean insideRegion = getBooleanSetting("general.teleportIntoRegion");
|
||||
AreaShop.debug("insideRegion = " + insideRegion);
|
||||
int maxTries = plugin.config().getInt("maximumTries");
|
||||
AreaShop.debug("maxTries = " + maxTries);
|
||||
|
||||
// set location in the center of the block
|
||||
startLocation.setX(startLocation.getBlockX() + 0.5);
|
||||
@ -878,18 +883,26 @@ public abstract class GeneralRegion {
|
||||
// radius around that (until no block in the region is found at all cube sides)
|
||||
Location saveLocation = startLocation;
|
||||
int radius = 1;
|
||||
boolean done = isSave(saveLocation);
|
||||
boolean blocksInRegion = region.contains(startLocation.getBlockX(), startLocation.getBlockY(), startLocation.getBlockZ());
|
||||
boolean done = isSave(saveLocation) && ((blocksInRegion && insideRegion) || (!insideRegion));
|
||||
boolean north=false, east=false, south=false, west=false, top=false, bottom=false;
|
||||
boolean track;
|
||||
while(!done) {
|
||||
while(((blocksInRegion && insideRegion) || (!insideRegion)) && !done) {
|
||||
blocksInRegion = false;
|
||||
// North side
|
||||
track = false;
|
||||
for(int x=-radius+1; x<=radius && !done && !north; x++) {
|
||||
for(int y=-radius+1; y<radius && !done; y++) {
|
||||
saveLocation = startLocation.clone().add(x, y, -radius);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if(saveLocation.getBlockY()>256 || saveLocation.getBlockY()<0) {
|
||||
continue;
|
||||
}
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
north = north || !track;
|
||||
@ -899,9 +912,15 @@ public abstract class GeneralRegion {
|
||||
for(int z=-radius+1; z<=radius && !done && !east; z++) {
|
||||
for(int y=-radius+1; y<radius && !done; y++) {
|
||||
saveLocation = startLocation.clone().add(radius, y, z);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if(saveLocation.getBlockY()>256 || saveLocation.getBlockY()<0) {
|
||||
continue;
|
||||
}
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
east = east || !track;
|
||||
@ -911,9 +930,15 @@ public abstract class GeneralRegion {
|
||||
for(int x=radius-1; x>=-radius && !done && !south; x--) {
|
||||
for(int y=-radius+1; y<radius && !done; y++) {
|
||||
saveLocation = startLocation.clone().add(x, y, radius);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if(saveLocation.getBlockY()>256 || saveLocation.getBlockY()<0) {
|
||||
continue;
|
||||
}
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
south = south || !track;
|
||||
@ -923,50 +948,74 @@ public abstract class GeneralRegion {
|
||||
for(int z=radius-1; z>=-radius && !done && !west; z--) {
|
||||
for(int y=-radius+1; y<radius && !done; y++) {
|
||||
saveLocation = startLocation.clone().add(-radius, y, z);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if(saveLocation.getBlockY()>256 || saveLocation.getBlockY()<0) {
|
||||
continue;
|
||||
}
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
west = west || !track;
|
||||
west = west || !west;
|
||||
|
||||
// Top side
|
||||
track = false;
|
||||
// Middle block of the top
|
||||
if((startLocation.getBlockY() + radius) > 256) {
|
||||
top = true;
|
||||
}
|
||||
if(!done && !top) {
|
||||
saveLocation = startLocation.clone().add(0, radius, 0);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
for(int r=1; r<=radius && !done && !top; r++) {
|
||||
// North
|
||||
for(int x=-r+1; x<=r && !done; x++) {
|
||||
saveLocation = startLocation.clone().add(x, radius, -r);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
// East
|
||||
for(int z=-r+1; z<=r && !done; z++) {
|
||||
saveLocation = startLocation.clone().add(r, radius, z);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
// South side
|
||||
for(int x=r-1; x>=-r && !done; x--) {
|
||||
saveLocation = startLocation.clone().add(x, radius, r);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
// West side
|
||||
for(int z=r-1; z>=-r && !done; z--) {
|
||||
saveLocation = startLocation.clone().add(-r, radius, z);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
top = top || !track;
|
||||
@ -974,40 +1023,58 @@ public abstract class GeneralRegion {
|
||||
// Bottom side
|
||||
track = false;
|
||||
// Middle block of the bottom
|
||||
if(startLocation.getBlockY() - radius < 0) {
|
||||
bottom = true;
|
||||
}
|
||||
if(!done && !bottom) {
|
||||
saveLocation = startLocation.clone().add(0, -radius, 0);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
for(int r=1; r<=radius && !done && !bottom; r++) {
|
||||
// North
|
||||
for(int x=-r+1; x<=r && !done; x++) {
|
||||
saveLocation = startLocation.clone().add(x, -radius, -r);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
// East
|
||||
for(int z=-r+1; z<=r && !done; z++) {
|
||||
saveLocation = startLocation.clone().add(r, -radius, z);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
// South side
|
||||
for(int x=r-1; x>=-r && !done; x--) {
|
||||
saveLocation = startLocation.clone().add(x, -radius, r);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
// West side
|
||||
for(int z=r-1; z>=-r && !done; z--) {
|
||||
saveLocation = startLocation.clone().add(-r, -radius, z);
|
||||
done = isSave(saveLocation);
|
||||
track = true;
|
||||
checked++;
|
||||
if((insideRegion && region.contains(saveLocation.getBlockX(), saveLocation.getBlockY(), saveLocation.getBlockZ())) || !insideRegion) {
|
||||
checked++;
|
||||
done = isSave(saveLocation) || checked > maxTries;
|
||||
blocksInRegion = true;
|
||||
track = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
bottom = bottom || !track;
|
||||
@ -1015,14 +1082,14 @@ public abstract class GeneralRegion {
|
||||
// Increase cube radius
|
||||
radius++;
|
||||
}
|
||||
if(done) {
|
||||
if(done && isSave(saveLocation)) {
|
||||
plugin.message(player, "teleport-success", getName());
|
||||
player.teleport(saveLocation);
|
||||
AreaShop.debug("Found location: " + saveLocation.toString() + " Tries: " + checked);
|
||||
AreaShop.debug("Found location: " + saveLocation.toString() + " Tries: " + (checked-1));
|
||||
return true;
|
||||
} else {
|
||||
plugin.message(player, "teleport-noSafe", getName());
|
||||
AreaShop.debug("No location found, checked " + checked + " spots");
|
||||
plugin.message(player, "teleport-noSafe", getName(), checked-1, maxTries);
|
||||
AreaShop.debug("No location found, checked " + (checked-1) + " spots of max " + maxTries);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user