mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-16 15:25:11 +01:00
Cleanup code, fix some small bugs
Most of these things have been found with help of Intellij IDEA, preferring it over Eclipse already
This commit is contained in:
parent
b04871c553
commit
872d81b0a9
3
.gitignore
vendored
3
.gitignore
vendored
@ -26,3 +26,6 @@ local.properties
|
|||||||
|
|
||||||
# PDT-specific
|
# PDT-specific
|
||||||
.buildpath
|
.buildpath
|
||||||
|
|
||||||
|
# IntelliJ IDEA
|
||||||
|
*.iml
|
@ -31,22 +31,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>nl.evolutioncoding</groupId>
|
|
||||||
<artifactId>areashop-worldguard-5</artifactId>
|
|
||||||
<version>WorldGuard-5</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>nl.evolutioncoding</groupId>
|
|
||||||
<artifactId>areashop-worldguard-6</artifactId>
|
|
||||||
<version>WorldGuard-6</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>nl.evolutioncoding</groupId>
|
<groupId>nl.evolutioncoding</groupId>
|
||||||
<artifactId>areashop-interface</artifactId>
|
<artifactId>areashop-interface</artifactId>
|
||||||
@ -55,22 +39,6 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>nl.evolutioncoding</groupId>
|
|
||||||
<artifactId>areashop-worldedit-5</artifactId>
|
|
||||||
<version>WorldEdit-5</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>nl.evolutioncoding</groupId>
|
|
||||||
<artifactId>areashop-worldedit-6</artifactId>
|
|
||||||
<version>WorldEdit-6</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
<artifactId>worldedit</artifactId>
|
<artifactId>worldedit</artifactId>
|
||||||
@ -148,9 +116,6 @@
|
|||||||
<goals>
|
<goals>
|
||||||
<goal>run</goal>
|
<goal>run</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
|
||||||
<target failonerror="false"></target>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
package nl.evolutioncoding.areashop;
|
package nl.evolutioncoding.areashop;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import java.math.RoundingMode;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import nl.evolutioncoding.areashop.Updater.UpdateResult;
|
import nl.evolutioncoding.areashop.Updater.UpdateResult;
|
||||||
import nl.evolutioncoding.areashop.Updater.UpdateType;
|
import nl.evolutioncoding.areashop.Updater.UpdateType;
|
||||||
@ -22,7 +17,6 @@ import nl.evolutioncoding.areashop.managers.FileManager;
|
|||||||
import nl.evolutioncoding.areashop.managers.LanguageManager;
|
import nl.evolutioncoding.areashop.managers.LanguageManager;
|
||||||
import nl.evolutioncoding.areashop.managers.SignLinkerManager;
|
import nl.evolutioncoding.areashop.managers.SignLinkerManager;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -35,8 +29,12 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import java.math.BigDecimal;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import java.math.RoundingMode;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main class for the AreaShop plugin
|
* Main class for the AreaShop plugin
|
||||||
@ -387,7 +385,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current chatPrefix
|
* Get the current chatPrefix
|
||||||
* @return
|
* @return The current chatPrefix
|
||||||
*/
|
*/
|
||||||
public String getChatPrefix() {
|
public String getChatPrefix() {
|
||||||
return chatprefix;
|
return chatprefix;
|
||||||
@ -694,7 +692,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
|
|||||||
|
|
||||||
/* Check if the suffix is one of these values */
|
/* Check if the suffix is one of these values */
|
||||||
String suffix = time.substring(time.indexOf(' ')+1, time.length());
|
String suffix = time.substring(time.indexOf(' ')+1, time.length());
|
||||||
ArrayList<String> identifiers = new ArrayList<String>();
|
ArrayList<String> identifiers = new ArrayList<>();
|
||||||
identifiers.addAll(this.getConfig().getStringList("seconds"));
|
identifiers.addAll(this.getConfig().getStringList("seconds"));
|
||||||
identifiers.addAll(this.getConfig().getStringList("minutes"));
|
identifiers.addAll(this.getConfig().getStringList("minutes"));
|
||||||
identifiers.addAll(this.getConfig().getStringList("hours"));
|
identifiers.addAll(this.getConfig().getStringList("hours"));
|
||||||
@ -727,19 +725,21 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
|
|||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTimeInMillis(0);
|
calendar.setTimeInMillis(0);
|
||||||
|
|
||||||
ArrayList<String> seconds = new ArrayList<String>(this.getConfig().getStringList("seconds"));
|
ArrayList<String> seconds = new ArrayList<>(this.getConfig().getStringList("seconds"));
|
||||||
ArrayList<String> minutes = new ArrayList<String>(this.getConfig().getStringList("minutes"));
|
ArrayList<String> minutes = new ArrayList<>(this.getConfig().getStringList("minutes"));
|
||||||
ArrayList<String> hours = new ArrayList<String>(this.getConfig().getStringList("hours"));
|
ArrayList<String> hours = new ArrayList<>(this.getConfig().getStringList("hours"));
|
||||||
ArrayList<String> days = new ArrayList<String>(this.getConfig().getStringList("days"));
|
ArrayList<String> days = new ArrayList<>(this.getConfig().getStringList("days"));
|
||||||
ArrayList<String> weeks = new ArrayList<String>(this.getConfig().getStringList("weeks"));
|
ArrayList<String> weeks = new ArrayList<>(this.getConfig().getStringList("weeks"));
|
||||||
ArrayList<String> months = new ArrayList<String>(this.getConfig().getStringList("months"));
|
ArrayList<String> months = new ArrayList<>(this.getConfig().getStringList("months"));
|
||||||
ArrayList<String> years = new ArrayList<String>(this.getConfig().getStringList("years"));
|
ArrayList<String> years = new ArrayList<>(this.getConfig().getStringList("years"));
|
||||||
|
|
||||||
String durationString = duration.substring(duration.indexOf(' ')+1, duration.length());
|
String durationString = duration.substring(duration.indexOf(' ')+1, duration.length());
|
||||||
int durationInt = 0;
|
int durationInt = 0;
|
||||||
try {
|
try {
|
||||||
durationInt = Integer.parseInt(duration.substring(0, duration.indexOf(' ')));
|
durationInt = Integer.parseInt(duration.substring(0, duration.indexOf(' ')));
|
||||||
} catch(NumberFormatException exception) {}
|
} catch(NumberFormatException exception) {
|
||||||
|
// No Number found, add zero
|
||||||
|
}
|
||||||
|
|
||||||
if(seconds.contains(durationString)) {
|
if(seconds.contains(durationString)) {
|
||||||
calendar.add(Calendar.SECOND, durationInt);
|
calendar.add(Calendar.SECOND, durationInt);
|
||||||
@ -874,18 +874,16 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
|
|||||||
* @return the name of the player
|
* @return the name of the player
|
||||||
*/
|
*/
|
||||||
public String toName(String uuid) {
|
public String toName(String uuid) {
|
||||||
if(uuid == null) {
|
String result = "";
|
||||||
return "";
|
if(uuid != null) {
|
||||||
} else {
|
|
||||||
UUID parsed = null;
|
|
||||||
try {
|
try {
|
||||||
parsed = UUID.fromString(uuid);
|
UUID parsed = UUID.fromString(uuid);
|
||||||
} catch(IllegalArgumentException e) {}
|
result = this.toName(parsed);
|
||||||
if(parsed == null) {
|
} catch(IllegalArgumentException e) {
|
||||||
return "";
|
// Incorrect UUID
|
||||||
}
|
}
|
||||||
return this.toName(parsed);
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Conversion to name by uuid object
|
* Conversion to name by uuid object
|
||||||
|
@ -34,23 +34,12 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.*;
|
||||||
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.Proxy;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
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.logging.Level;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
@ -628,7 +617,7 @@ public class Metrics {
|
|||||||
/**
|
/**
|
||||||
* The set of plotters that are contained within this graph
|
* The set of plotters that are contained within this graph
|
||||||
*/
|
*/
|
||||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
private final Set<Plotter> plotters = new LinkedHashSet<>();
|
||||||
|
|
||||||
private Graph(final String name) {
|
private Graph(final String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package nl.evolutioncoding.areashop;
|
package nl.evolutioncoding.areashop;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import java.util.Collection;
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
import java.util.List;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
import java.util.Set;
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionType;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionType;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -17,11 +16,10 @@ import org.bukkit.block.BlockFace;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import java.util.ArrayList;
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
import java.util.Collection;
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import java.util.List;
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
import java.util.Set;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
@ -55,7 +53,7 @@ public class Utils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a location from a map, reconstruction from the config values
|
* Create a location from a map, reconstruction from the config values
|
||||||
* @param map The map to reconstruct from
|
* @param config The config section to reconstruct from
|
||||||
* @return The location
|
* @return The location
|
||||||
*/
|
*/
|
||||||
public static Location configToLocation(ConfigurationSection config) {
|
public static Location configToLocation(ConfigurationSection config) {
|
||||||
@ -69,9 +67,9 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
Location result = new Location(
|
Location result = new Location(
|
||||||
Bukkit.getWorld(config.getString("world")),
|
Bukkit.getWorld(config.getString("world")),
|
||||||
(Double)config.getDouble("x"),
|
config.getDouble("x"),
|
||||||
(Double)config.getDouble("y"),
|
config.getDouble("y"),
|
||||||
(Double)config.getDouble("z"));
|
config.getDouble("z"));
|
||||||
if(config.isString("yaw") && config.isString("pitch")) {
|
if(config.isString("yaw") && config.isString("pitch")) {
|
||||||
result.setPitch(Float.parseFloat(config.getString("pitch")));
|
result.setPitch(Float.parseFloat(config.getString("pitch")));
|
||||||
result.setYaw(Float.parseFloat(config.getString("yaw")));
|
result.setYaw(Float.parseFloat(config.getString("yaw")));
|
||||||
@ -84,7 +82,7 @@ public class Utils {
|
|||||||
* @param input Collection of object which should be concatenated with comma's in between
|
* @param input Collection of object which should be concatenated with comma's in between
|
||||||
* @return Innput object concatenated with comma's in between
|
* @return Innput object concatenated with comma's in between
|
||||||
*/
|
*/
|
||||||
public static String createCommaSeparatedList(Collection<? extends Object> input) {
|
public static String createCommaSeparatedList(Collection<?> input) {
|
||||||
String result = "";
|
String result = "";
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for(Object object : input) {
|
for(Object object : input) {
|
||||||
@ -109,7 +107,8 @@ public class Utils {
|
|||||||
return milliseconds/50;
|
return milliseconds/50;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final BlockFace[] facings = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST };
|
private static final BlockFace[] facings = {BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the facing direction based on the yaw
|
* Get the facing direction based on the yaw
|
||||||
* @param yaw The horizontal angle that for example the player is looking
|
* @param yaw The horizontal angle that for example the player is looking
|
||||||
@ -128,7 +127,7 @@ public class Utils {
|
|||||||
* @return A list with all the AreaShop regions intersecting with the selection
|
* @return A list with all the AreaShop regions intersecting with the selection
|
||||||
*/
|
*/
|
||||||
public static List<GeneralRegion> getASRegionsInSelection(Selection selection) {
|
public static List<GeneralRegion> getASRegionsInSelection(Selection selection) {
|
||||||
ArrayList<GeneralRegion> result = new ArrayList<GeneralRegion>();
|
ArrayList<GeneralRegion> result = new ArrayList<>();
|
||||||
for(ProtectedRegion region : getWERegionsInSelection(selection)) {
|
for(ProtectedRegion region : getWERegionsInSelection(selection)) {
|
||||||
GeneralRegion asRegion = AreaShop.getInstance().getFileManager().getRegion(region.getId());
|
GeneralRegion asRegion = AreaShop.getInstance().getFileManager().getRegion(region.getId());
|
||||||
if(asRegion != null) {
|
if(asRegion != null) {
|
||||||
@ -156,7 +155,7 @@ public class Utils {
|
|||||||
// Get all regions inside or intersecting with the WorldEdit selection of the player
|
// Get all regions inside or intersecting with the WorldEdit selection of the player
|
||||||
World world = selection.getWorld();
|
World world = selection.getWorld();
|
||||||
RegionManager regionManager = AreaShop.getInstance().getWorldGuard().getRegionManager(world);
|
RegionManager regionManager = AreaShop.getInstance().getWorldGuard().getRegionManager(world);
|
||||||
ArrayList<ProtectedRegion> result = new ArrayList<ProtectedRegion>();
|
ArrayList<ProtectedRegion> result = new ArrayList<>();
|
||||||
Location selectionMin = selection.getMinimumPoint();
|
Location selectionMin = selection.getMinimumPoint();
|
||||||
Location selectionMax = selection.getMaximumPoint();
|
Location selectionMax = selection.getMaximumPoint();
|
||||||
for(ProtectedRegion region : regionManager.getRegions().values()) {
|
for(ProtectedRegion region : regionManager.getRegions().values()) {
|
||||||
@ -193,7 +192,7 @@ public class Utils {
|
|||||||
* @return empty list if no regions found, 1 member if 1 region is a priority, more if regions with the same priority
|
* @return empty list if no regions found, 1 member if 1 region is a priority, more if regions with the same priority
|
||||||
*/
|
*/
|
||||||
public static List<ProtectedRegion> getApplicableRegions(Location location) {
|
public static List<ProtectedRegion> getApplicableRegions(Location location) {
|
||||||
List<ProtectedRegion> result = new ArrayList<ProtectedRegion>();
|
List<ProtectedRegion> result = new ArrayList<>();
|
||||||
Set<ProtectedRegion> regions = AreaShop.getInstance().getWorldGuardHandler().getApplicableRegionsSet(location);
|
Set<ProtectedRegion> regions = AreaShop.getInstance().getWorldGuardHandler().getApplicableRegionsSet(location);
|
||||||
if(regions != null) {
|
if(regions != null) {
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
@ -219,14 +218,14 @@ public class Utils {
|
|||||||
|
|
||||||
// Methods to get the most important AreaShop regions at a certain location
|
// Methods to get the most important AreaShop regions at a certain location
|
||||||
public static List<RentRegion> getApplicableRentRegions(Location location) {
|
public static List<RentRegion> getApplicableRentRegions(Location location) {
|
||||||
List<RentRegion> result = new ArrayList<RentRegion>();
|
List<RentRegion> result = new ArrayList<>();
|
||||||
for(GeneralRegion region : getApplicableASRegions(location, RegionType.RENT)) {
|
for(GeneralRegion region : getApplicableASRegions(location, RegionType.RENT)) {
|
||||||
result.add((RentRegion)region);
|
result.add((RentRegion)region);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static List<BuyRegion> getApplicableBuyRegions(Location location) {
|
public static List<BuyRegion> getApplicableBuyRegions(Location location) {
|
||||||
List<BuyRegion> result = new ArrayList<BuyRegion>();
|
List<BuyRegion> result = new ArrayList<>();
|
||||||
for(GeneralRegion region : getApplicableASRegions(location, RegionType.BUY)) {
|
for(GeneralRegion region : getApplicableASRegions(location, RegionType.BUY)) {
|
||||||
result.add((BuyRegion)region);
|
result.add((BuyRegion)region);
|
||||||
}
|
}
|
||||||
@ -236,10 +235,10 @@ public class Utils {
|
|||||||
return getApplicableASRegions(location, null);
|
return getApplicableASRegions(location, null);
|
||||||
}
|
}
|
||||||
public static List<GeneralRegion> getApplicableASRegions(Location location, RegionType type) {
|
public static List<GeneralRegion> getApplicableASRegions(Location location, RegionType type) {
|
||||||
List<GeneralRegion> result = new ArrayList<GeneralRegion>();
|
List<GeneralRegion> result = new ArrayList<>();
|
||||||
Set<ProtectedRegion> regions = AreaShop.getInstance().getWorldGuardHandler().getApplicableRegionsSet(location);
|
Set<ProtectedRegion> regions = AreaShop.getInstance().getWorldGuardHandler().getApplicableRegionsSet(location);
|
||||||
if(regions != null) {
|
if(regions != null) {
|
||||||
List<GeneralRegion> candidates = new ArrayList<GeneralRegion>();
|
List<GeneralRegion> candidates = new ArrayList<>();
|
||||||
for(ProtectedRegion pr : regions) {
|
for(ProtectedRegion pr : regions) {
|
||||||
GeneralRegion region = AreaShop.getInstance().getFileManager().getRegion(pr.getId());
|
GeneralRegion region = AreaShop.getInstance().getFileManager().getRegion(pr.getId());
|
||||||
if(region != null && (
|
if(region != null && (
|
||||||
@ -262,7 +261,7 @@ public class Utils {
|
|||||||
if(region.getRegion().getPriority() > result.get(0).getRegion().getPriority()) {
|
if(region.getRegion().getPriority() > result.get(0).getRegion().getPriority()) {
|
||||||
result.clear();
|
result.clear();
|
||||||
result.add(region);
|
result.add(region);
|
||||||
} else if(region.getRegion().getParent() != null && region.getRegion().getParent().equals(result.get(0))) {
|
} else if(region.getRegion().getParent() != null && region.getRegion().getParent().equals(result.get(0).getRegion())) {
|
||||||
result.clear();
|
result.clear();
|
||||||
result.add(region);
|
result.add(region);
|
||||||
} else {
|
} else {
|
||||||
@ -271,7 +270,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ArrayList<GeneralRegion>(result);
|
return new ArrayList<>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
import java.util.List;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.managers.FileManager.AddResult;
|
import nl.evolutioncoding.areashop.managers.FileManager.AddResult;
|
||||||
@ -10,16 +9,14 @@ import nl.evolutioncoding.areashop.regions.BuyRegion;
|
|||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionEvent;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionEvent;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionType;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionType;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import java.util.ArrayList;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import java.util.List;
|
||||||
|
|
||||||
public class AddCommand extends CommandAreaShop {
|
public class AddCommand extends CommandAreaShop {
|
||||||
|
|
||||||
@ -41,7 +38,7 @@ public class AddCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, Command command, final String[] args) {
|
public void execute(final CommandSender sender, final String[] args) {
|
||||||
if( !sender.hasPermission("areashop.createrent")
|
if( !sender.hasPermission("areashop.createrent")
|
||||||
&& !sender.hasPermission("areashop.createrent.member")
|
&& !sender.hasPermission("areashop.createrent.member")
|
||||||
&& !sender.hasPermission("areashop.createrent.owner")
|
&& !sender.hasPermission("areashop.createrent.owner")
|
||||||
@ -57,8 +54,8 @@ public class AddCommand extends CommandAreaShop {
|
|||||||
plugin.message(sender, "add-help");
|
plugin.message(sender, "add-help");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<ProtectedRegion> regions = new ArrayList<ProtectedRegion>();
|
List<ProtectedRegion> regions = new ArrayList<>();
|
||||||
World world = null;
|
World world;
|
||||||
Player player = null;
|
Player player = null;
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
player = (Player)sender;
|
player = (Player)sender;
|
||||||
@ -116,10 +113,10 @@ public class AddCommand extends CommandAreaShop {
|
|||||||
AreaShop.debug("Starting add task with " + regions.size() + " regions");
|
AreaShop.debug("Starting add task with " + regions.size() + " regions");
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
private int current = 0;
|
private int current = 0;
|
||||||
private ArrayList<String> namesSuccess = new ArrayList<String>();
|
private ArrayList<String> namesSuccess = new ArrayList<>();
|
||||||
private ArrayList<String> namesAlready = new ArrayList<String>();
|
private ArrayList<String> namesAlready = new ArrayList<>();
|
||||||
private ArrayList<String> namesBlacklisted = new ArrayList<String>();
|
private ArrayList<String> namesBlacklisted = new ArrayList<>();
|
||||||
private ArrayList<String> namesNoPermission = new ArrayList<String>();
|
private ArrayList<String> namesNoPermission = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -129,7 +126,7 @@ public class AddCommand extends CommandAreaShop {
|
|||||||
// Determine if the player is an owner or member of the region
|
// Determine if the player is an owner or member of the region
|
||||||
boolean isMember = finalPlayer != null && plugin.getWorldGuardHandler().containsMember(region, finalPlayer.getUniqueId());
|
boolean isMember = finalPlayer != null && plugin.getWorldGuardHandler().containsMember(region, finalPlayer.getUniqueId());
|
||||||
boolean isOwner = finalPlayer != null && plugin.getWorldGuardHandler().containsMember(region, finalPlayer.getUniqueId());
|
boolean isOwner = finalPlayer != null && plugin.getWorldGuardHandler().containsMember(region, finalPlayer.getUniqueId());
|
||||||
String type = null;
|
String type;
|
||||||
if(isRent) {
|
if(isRent) {
|
||||||
type = "rent";
|
type = "rent";
|
||||||
} else {
|
} else {
|
||||||
@ -205,7 +202,7 @@ public class AddCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
if(sender.hasPermission("areashop.createrent")) {
|
if(sender.hasPermission("areashop.createrent")) {
|
||||||
result.add("rent");
|
result.add("rent");
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class AddfriendCommand extends CommandAreaShop {
|
public class AddfriendCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public AddfriendCommand(AreaShop plugin) {
|
public AddfriendCommand(AreaShop plugin) {
|
||||||
@ -38,7 +36,7 @@ public class AddfriendCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.addfriend") && !sender.hasPermission("areashop.addfriendall")) {
|
if(!sender.hasPermission("areashop.addfriend") && !sender.hasPermission("areashop.addfriendall")) {
|
||||||
plugin.message(sender, "addfriend-noPermission");
|
plugin.message(sender, "addfriend-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -49,7 +47,7 @@ public class AddfriendCommand extends CommandAreaShop {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneralRegion region = null;
|
GeneralRegion region;
|
||||||
if(args.length <= 2) {
|
if(args.length <= 2) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
// get the region by location
|
// get the region by location
|
||||||
@ -128,7 +126,7 @@ public class AddfriendCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||||
result.add(player.getName());
|
result.add(player.getName());
|
||||||
|
@ -1,22 +1,19 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.material.Sign;
|
import org.bukkit.material.Sign;
|
||||||
import org.bukkit.util.BlockIterator;
|
import org.bukkit.util.BlockIterator;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class AddsignCommand extends CommandAreaShop {
|
public class AddsignCommand extends CommandAreaShop {
|
||||||
|
|
||||||
@ -38,7 +35,7 @@ public class AddsignCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.addsign")) {
|
if(!sender.hasPermission("areashop.addsign")) {
|
||||||
plugin.message(sender, "addsign-noPermission");
|
plugin.message(sender, "addsign-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -63,7 +60,7 @@ public class AddsignCommand extends CommandAreaShop {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneralRegion region = null;
|
GeneralRegion region;
|
||||||
if(args.length > 1) {
|
if(args.length > 1) {
|
||||||
// Get region by argument
|
// Get region by argument
|
||||||
region = plugin.getFileManager().getRegion(args[1]);
|
region = plugin.getFileManager().getRegion(args[1]);
|
||||||
@ -110,7 +107,7 @@ public class AddsignCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result.addAll(plugin.getFileManager().getRegionNames());
|
result.addAll(plugin.getFileManager().getRegionNames());
|
||||||
} else if(toComplete == 3) {
|
} else if(toComplete == 3) {
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BuyCommand extends CommandAreaShop {
|
public class BuyCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public BuyCommand(AreaShop plugin) {
|
public BuyCommand(AreaShop plugin) {
|
||||||
@ -31,7 +29,7 @@ public class BuyCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.buy")) {
|
if(!sender.hasPermission("areashop.buy")) {
|
||||||
plugin.message(sender, "buy-noPermission");
|
plugin.message(sender, "buy-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -53,10 +51,8 @@ public class BuyCommand extends CommandAreaShop {
|
|||||||
List<BuyRegion> regions = Utils.getApplicableBuyRegions(((Player) sender).getLocation());
|
List<BuyRegion> regions = Utils.getApplicableBuyRegions(((Player) sender).getLocation());
|
||||||
if (regions.isEmpty()) {
|
if (regions.isEmpty()) {
|
||||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||||
return;
|
|
||||||
} else if (regions.size() > 1) {
|
} else if (regions.size() > 1) {
|
||||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
regions.get(0).buy(player);
|
regions.get(0).buy(player);
|
||||||
}
|
}
|
||||||
@ -65,7 +61,7 @@ public class BuyCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||||
if(!region.isSold()) {
|
if(!region.isSold()) {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for generalising command classes
|
* Abstract class for generalising command classes
|
||||||
*/
|
*/
|
||||||
@ -38,11 +38,13 @@ public abstract class CommandAreaShop {
|
|||||||
* @param start The already given start of the command
|
* @param start The already given start of the command
|
||||||
* @return A collection with all the possibilities for argument to complete
|
* @return A collection with all the possibilities for argument to complete
|
||||||
*/
|
*/
|
||||||
public abstract List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender);
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the argument that comes after the base command that this command reacts to
|
* Get the argument that comes after the base command that this command reacts to
|
||||||
* @return
|
* @return The string that should be in front of the command for this class to act
|
||||||
*/
|
*/
|
||||||
public abstract String getCommandStart();
|
public abstract String getCommandStart();
|
||||||
|
|
||||||
@ -56,10 +58,9 @@ public abstract class CommandAreaShop {
|
|||||||
/**
|
/**
|
||||||
* Execute a (sub)command if the conditions are met
|
* Execute a (sub)command if the conditions are met
|
||||||
* @param sender The commandSender that executed the command
|
* @param sender The commandSender that executed the command
|
||||||
* @param commandAreaShop The command that has been executed
|
|
||||||
* @param args The arguments that are given
|
* @param args The arguments that are given
|
||||||
*/
|
*/
|
||||||
public abstract void execute(CommandSender sender, Command command, String[] args);
|
public abstract void execute(CommandSender sender, String[] args);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class DelCommand extends CommandAreaShop {
|
public class DelCommand extends CommandAreaShop {
|
||||||
|
|
||||||
@ -35,7 +32,7 @@ public class DelCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if( !sender.hasPermission("areashop.destroybuy")
|
if( !sender.hasPermission("areashop.destroybuy")
|
||||||
&& !sender.hasPermission("areashop.destroybuy.landlord")
|
&& !sender.hasPermission("areashop.destroybuy.landlord")
|
||||||
|
|
||||||
@ -62,10 +59,10 @@ public class DelCommand extends CommandAreaShop {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Start removing the region that he has permission for
|
// Start removing the region that he has permission for
|
||||||
ArrayList<String> namesSuccess = new ArrayList<String>();
|
ArrayList<String> namesSuccess = new ArrayList<>();
|
||||||
ArrayList<String> namesFailed = new ArrayList<String>();
|
ArrayList<String> namesFailed = new ArrayList<>();
|
||||||
for(GeneralRegion region : regions) {
|
for(GeneralRegion region : regions) {
|
||||||
boolean isLandlord = sender instanceof Player && region.isLandlord(((Player)sender).getUniqueId());
|
boolean isLandlord = region.isLandlord(((Player)sender).getUniqueId());
|
||||||
if(region.isRentRegion()) {
|
if(region.isRentRegion()) {
|
||||||
if(!sender.hasPermission("areashop.destroyrent") && !(isLandlord && sender.hasPermission("areashop.destroyrent.landlord"))) {
|
if(!sender.hasPermission("areashop.destroyrent") && !(isLandlord && sender.hasPermission("areashop.destroyrent.landlord"))) {
|
||||||
namesFailed.add(region.getName());
|
namesFailed.add(region.getName());
|
||||||
@ -118,7 +115,7 @@ public class DelCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result = plugin.getFileManager().getRegionNames();
|
result = plugin.getFileManager().getRegionNames();
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class DelfriendCommand extends CommandAreaShop {
|
public class DelfriendCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public DelfriendCommand(AreaShop plugin) {
|
public DelfriendCommand(AreaShop plugin) {
|
||||||
@ -38,7 +36,7 @@ public class DelfriendCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.delfriend") && !sender.hasPermission("areashop.delfriendall")) {
|
if(!sender.hasPermission("areashop.delfriend") && !sender.hasPermission("areashop.delfriendall")) {
|
||||||
plugin.message(sender, "delfriend-noPermission");
|
plugin.message(sender, "delfriend-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -47,7 +45,7 @@ public class DelfriendCommand extends CommandAreaShop {
|
|||||||
plugin.message(sender, "delfriend-help");
|
plugin.message(sender, "delfriend-help");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GeneralRegion region = null;
|
GeneralRegion region;
|
||||||
if(args.length <= 2) {
|
if(args.length <= 2) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
// get the region by location
|
// get the region by location
|
||||||
@ -110,7 +108,7 @@ public class DelfriendCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||||
result.add(player.getName());
|
result.add(player.getName());
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.BlockIterator;
|
import org.bukkit.util.BlockIterator;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class DelsignCommand extends CommandAreaShop {
|
public class DelsignCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public DelsignCommand(AreaShop plugin) {
|
public DelsignCommand(AreaShop plugin) {
|
||||||
@ -33,7 +31,7 @@ public class DelsignCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.delsign")) {
|
if(!sender.hasPermission("areashop.delsign")) {
|
||||||
plugin.message(sender, "delsign-noPermission");
|
plugin.message(sender, "delsign-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -69,7 +67,7 @@ public class DelsignCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
return new ArrayList<String>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class FindCommand extends CommandAreaShop {
|
public class FindCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public FindCommand(AreaShop plugin) {
|
public FindCommand(AreaShop plugin) {
|
||||||
@ -33,7 +31,7 @@ public class FindCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.find")) {
|
if(!sender.hasPermission("areashop.find")) {
|
||||||
plugin.message(sender, "find-noPermission");
|
plugin.message(sender, "find-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -74,7 +72,7 @@ public class FindCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
if(args[1].equalsIgnoreCase("buy")) {
|
if(args[1].equalsIgnoreCase("buy")) {
|
||||||
List<BuyRegion> regions = plugin.getFileManager().getBuys();
|
List<BuyRegion> regions = plugin.getFileManager().getBuys();
|
||||||
List<BuyRegion> results = new ArrayList<BuyRegion>();
|
List<BuyRegion> results = new ArrayList<>();
|
||||||
for(BuyRegion region : regions) {
|
for(BuyRegion region : regions) {
|
||||||
if(!region.isSold()
|
if(!region.isSold()
|
||||||
&& ((region.getPrice() <= balance && !maxPriceSet) || (region.getPrice() <= maxPrice && maxPriceSet))
|
&& ((region.getPrice() <= balance && !maxPriceSet) || (region.getPrice() <= maxPrice && maxPriceSet))
|
||||||
@ -108,7 +106,7 @@ public class FindCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<RentRegion> regions = plugin.getFileManager().getRents();
|
List<RentRegion> regions = plugin.getFileManager().getRents();
|
||||||
List<RentRegion> results = new ArrayList<RentRegion>();
|
List<RentRegion> results = new ArrayList<>();
|
||||||
for(RentRegion region : regions) {
|
for(RentRegion region : regions) {
|
||||||
if(!region.isRented()
|
if(!region.isRented()
|
||||||
&& ((region.getPrice() <= balance && !maxPriceSet) || (region.getPrice() <= maxPrice && maxPriceSet))
|
&& ((region.getPrice() <= balance && !maxPriceSet) || (region.getPrice() <= maxPrice && maxPriceSet))
|
||||||
@ -146,7 +144,7 @@ public class FindCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result.add("buy");
|
result.add("buy");
|
||||||
result.add("rent");
|
result.add("rent");
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GroupaddCommand extends CommandAreaShop {
|
public class GroupaddCommand extends CommandAreaShop {
|
||||||
|
|
||||||
@ -34,7 +31,7 @@ public class GroupaddCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.groupadd")) {
|
if(!sender.hasPermission("areashop.groupadd")) {
|
||||||
plugin.message(sender, "groupadd-noPermission");
|
plugin.message(sender, "groupadd-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -64,9 +61,9 @@ public class GroupaddCommand extends CommandAreaShop {
|
|||||||
plugin.message(player, "cmd-noRegionsFound");
|
plugin.message(player, "cmd-noRegionsFound");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ArrayList<String> namesSuccess = new ArrayList<String>();
|
ArrayList<String> namesSuccess = new ArrayList<>();
|
||||||
ArrayList<String> namesFailed = new ArrayList<String>();
|
ArrayList<String> namesFailed = new ArrayList<>();
|
||||||
ArrayList<GeneralRegion> toUpdate = new ArrayList<GeneralRegion>();
|
ArrayList<GeneralRegion> toUpdate = new ArrayList<>();
|
||||||
for(GeneralRegion region : regions) {
|
for(GeneralRegion region : regions) {
|
||||||
if(group.addMember(region)) {
|
if(group.addMember(region)) {
|
||||||
namesSuccess.add(region.getName());
|
namesSuccess.add(region.getName());
|
||||||
@ -101,7 +98,7 @@ public class GroupaddCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result = plugin.getFileManager().getGroupNames();
|
result = plugin.getFileManager().getGroupNames();
|
||||||
} else if(toComplete == 3) {
|
} else if(toComplete == 3) {
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GroupdelCommand extends CommandAreaShop {
|
public class GroupdelCommand extends CommandAreaShop {
|
||||||
|
|
||||||
@ -34,7 +31,7 @@ public class GroupdelCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.groupdel")) {
|
if(!sender.hasPermission("areashop.groupdel")) {
|
||||||
plugin.message(sender, "groupdel-noPermission");
|
plugin.message(sender, "groupdel-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -64,9 +61,9 @@ public class GroupdelCommand extends CommandAreaShop {
|
|||||||
plugin.message(player, "cmd-noRegionsFound");
|
plugin.message(player, "cmd-noRegionsFound");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ArrayList<String> namesSuccess = new ArrayList<String>();
|
ArrayList<String> namesSuccess = new ArrayList<>();
|
||||||
ArrayList<String> namesFailed = new ArrayList<String>();
|
ArrayList<String> namesFailed = new ArrayList<>();
|
||||||
ArrayList<GeneralRegion> toUpdate = new ArrayList<GeneralRegion>();
|
ArrayList<GeneralRegion> toUpdate = new ArrayList<>();
|
||||||
for(GeneralRegion region : regions) {
|
for(GeneralRegion region : regions) {
|
||||||
if(group.removeMember(region)) {
|
if(group.removeMember(region)) {
|
||||||
namesSuccess.add(region.getName());
|
namesSuccess.add(region.getName());
|
||||||
@ -102,7 +99,7 @@ public class GroupdelCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result = plugin.getFileManager().getGroupNames();
|
result = plugin.getFileManager().getGroupNames();
|
||||||
} else if(toComplete == 3) {
|
} else if(toComplete == 3) {
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GroupinfoCommand extends CommandAreaShop {
|
public class GroupinfoCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public GroupinfoCommand(AreaShop plugin) {
|
public GroupinfoCommand(AreaShop plugin) {
|
||||||
@ -31,7 +29,7 @@ public class GroupinfoCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.groupinfo")) {
|
if(!sender.hasPermission("areashop.groupinfo")) {
|
||||||
plugin.message(sender, "groupinfo-noPermission");
|
plugin.message(sender, "groupinfo-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -55,7 +53,7 @@ public class GroupinfoCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result = plugin.getFileManager().getGroupNames();
|
result = plugin.getFileManager().getGroupNames();
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GrouplistCommand extends CommandAreaShop {
|
public class GrouplistCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public GrouplistCommand(AreaShop plugin) {
|
public GrouplistCommand(AreaShop plugin) {
|
||||||
@ -29,7 +27,7 @@ public class GrouplistCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.grouplist")) {
|
if(!sender.hasPermission("areashop.grouplist")) {
|
||||||
plugin.message(sender, "grouplist-noPermission");
|
plugin.message(sender, "grouplist-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -44,7 +42,7 @@ public class GrouplistCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
return new ArrayList<String>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class HelpCommand extends CommandAreaShop {
|
public class HelpCommand extends CommandAreaShop {
|
||||||
@ -28,14 +23,7 @@ public class HelpCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
plugin.getCommandManager().showHelp(sender);
|
plugin.getCommandManager().showHelp(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,19 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class InfoCommand extends CommandAreaShop {
|
public class InfoCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public InfoCommand(AreaShop plugin) {
|
public InfoCommand(AreaShop plugin) {
|
||||||
@ -50,7 +41,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
* @param keySomeFound The key of the message to display when some regions are found
|
* @param keySomeFound The key of the message to display when some regions are found
|
||||||
* @param keyNoneFound The key of the message to display when no regions are found
|
* @param keyNoneFound The key of the message to display when no regions are found
|
||||||
*/
|
*/
|
||||||
public void displayMessage(CommandSender sender, Set<? extends GeneralRegion> regions, RegionGroup filterGroup, String keySomeFound, String keyNoneFound) {
|
private void displayMessage(CommandSender sender, Set<? extends GeneralRegion> regions, RegionGroup filterGroup, String keySomeFound, String keyNoneFound) {
|
||||||
if(filterGroup != null) {
|
if(filterGroup != null) {
|
||||||
Iterator<? extends GeneralRegion> it = regions.iterator();
|
Iterator<? extends GeneralRegion> it = regions.iterator();
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
@ -68,7 +59,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.info")) {
|
if(!sender.hasPermission("areashop.info")) {
|
||||||
plugin.message(sender, "info-noPermission");
|
plugin.message(sender, "info-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -76,7 +67,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
if(args.length > 1 && args[1] != null) {
|
if(args.length > 1 && args[1] != null) {
|
||||||
// Get filter group (only used by some commands)
|
// Get filter group (only used by some commands)
|
||||||
RegionGroup filterGroup = null;
|
RegionGroup filterGroup = null;
|
||||||
Set<String> groupFilters = new HashSet<String>(Arrays.asList("all", "rented", "forrent", "sold", "forsale"));
|
Set<String> groupFilters = new HashSet<>(Arrays.asList("all", "rented", "forrent", "sold", "forsale"));
|
||||||
if(groupFilters.contains(args[0].toLowerCase())) {
|
if(groupFilters.contains(args[0].toLowerCase())) {
|
||||||
filterGroup = plugin.getFileManager().getGroup(args[2]);
|
filterGroup = plugin.getFileManager().getGroup(args[2]);
|
||||||
if(filterGroup == null) {
|
if(filterGroup == null) {
|
||||||
@ -96,7 +87,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
// Rented regions
|
// Rented regions
|
||||||
else if(args[1].equalsIgnoreCase("rented")) {
|
else if(args[1].equalsIgnoreCase("rented")) {
|
||||||
Set<GeneralRegion> regions = new TreeSet<GeneralRegion>();
|
Set<GeneralRegion> regions = new TreeSet<>();
|
||||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||||
if(region.isRented()) {
|
if(region.isRented()) {
|
||||||
regions.add(region);
|
regions.add(region);
|
||||||
@ -106,7 +97,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
// Forrent regions
|
// Forrent regions
|
||||||
else if(args[1].equalsIgnoreCase("forrent")) {
|
else if(args[1].equalsIgnoreCase("forrent")) {
|
||||||
Set<GeneralRegion> regions = new TreeSet<GeneralRegion>();
|
Set<GeneralRegion> regions = new TreeSet<>();
|
||||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||||
if(!region.isRented()) {
|
if(!region.isRented()) {
|
||||||
regions.add(region);
|
regions.add(region);
|
||||||
@ -116,7 +107,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
// Sold regions
|
// Sold regions
|
||||||
else if(args[1].equalsIgnoreCase("sold")) {
|
else if(args[1].equalsIgnoreCase("sold")) {
|
||||||
Set<GeneralRegion> regions = new TreeSet<GeneralRegion>();
|
Set<GeneralRegion> regions = new TreeSet<>();
|
||||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||||
if(region.isSold()) {
|
if(region.isSold()) {
|
||||||
regions.add(region);
|
regions.add(region);
|
||||||
@ -126,7 +117,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
// Forsale regions
|
// Forsale regions
|
||||||
else if(args[1].equalsIgnoreCase("forsale")) {
|
else if(args[1].equalsIgnoreCase("forsale")) {
|
||||||
Set<GeneralRegion> regions = new TreeSet<GeneralRegion>();
|
Set<GeneralRegion> regions = new TreeSet<>();
|
||||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||||
if(!region.isSold()) {
|
if(!region.isSold()) {
|
||||||
regions.add(region);
|
regions.add(region);
|
||||||
@ -138,7 +129,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
else if(args[1].equalsIgnoreCase("player")) {
|
else if(args[1].equalsIgnoreCase("player")) {
|
||||||
if(args.length > 2 && args[2] != null) {
|
if(args.length > 2 && args[2] != null) {
|
||||||
// Rents
|
// Rents
|
||||||
Set<GeneralRegion> regions = new TreeSet<GeneralRegion>();
|
Set<GeneralRegion> regions = new TreeSet<>();
|
||||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||||
if(region.isRented() && region.getPlayerName().equalsIgnoreCase(args[2])) {
|
if(region.isRented() && region.getPlayerName().equalsIgnoreCase(args[2])) {
|
||||||
regions.add(region);
|
regions.add(region);
|
||||||
@ -150,7 +141,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
plugin.message(sender, "info-playerRents", args[2], StringUtils.join(regions.iterator(), ", "));
|
plugin.message(sender, "info-playerRents", args[2], StringUtils.join(regions.iterator(), ", "));
|
||||||
}
|
}
|
||||||
// Buys
|
// Buys
|
||||||
regions = new TreeSet<GeneralRegion>();
|
regions = new TreeSet<>();
|
||||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||||
if(region.isSold() && region.getPlayerName().equalsIgnoreCase(args[2])) {
|
if(region.isSold() && region.getPlayerName().equalsIgnoreCase(args[2])) {
|
||||||
regions.add(region);
|
regions.add(region);
|
||||||
@ -243,7 +234,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
plugin.messageNoPrefix(sender, "info-regionTeleportAt", rent, teleport.getWorld().getName(), teleport.getBlockX(), teleport.getBlockY(), teleport.getBlockZ(), (int)teleport.getPitch(), (int)teleport.getYaw());
|
plugin.messageNoPrefix(sender, "info-regionTeleportAt", rent, teleport.getWorld().getName(), teleport.getBlockX(), teleport.getBlockY(), teleport.getBlockZ(), (int)teleport.getPitch(), (int)teleport.getYaw());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<String> signLocations = new ArrayList<String>();
|
List<String> signLocations = new ArrayList<>();
|
||||||
for(Location location : rent.getSignLocations()) {
|
for(Location location : rent.getSignLocations()) {
|
||||||
signLocations.add(plugin.getLanguageManager().getLang("info-regionSignLocation", location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
signLocations.add(plugin.getLanguageManager().getLang("info-regionSignLocation", location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||||
}
|
}
|
||||||
@ -302,7 +293,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
plugin.messageNoPrefix(sender, "info-regionTeleportAt", buy, teleport.getWorld().getName(), teleport.getBlockX(), teleport.getBlockY(), teleport.getBlockZ(), (int)teleport.getPitch(), (int)teleport.getYaw());
|
plugin.messageNoPrefix(sender, "info-regionTeleportAt", buy, teleport.getWorld().getName(), teleport.getBlockX(), teleport.getBlockY(), teleport.getBlockZ(), (int)teleport.getPitch(), (int)teleport.getYaw());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<String> signLocations = new ArrayList<String>();
|
List<String> signLocations = new ArrayList<>();
|
||||||
for(Location location : buy.getSignLocations()) {
|
for(Location location : buy.getSignLocations()) {
|
||||||
signLocations.add(plugin.getLanguageManager().getLang("info-regionSignLocation", location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
signLocations.add(plugin.getLanguageManager().getLang("info-regionSignLocation", location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||||
}
|
}
|
||||||
@ -336,7 +327,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
/* List of regions without a group */
|
/* List of regions without a group */
|
||||||
else if(args[1].equalsIgnoreCase("nogroup")) {
|
else if(args[1].equalsIgnoreCase("nogroup")) {
|
||||||
// Rental regions
|
// Rental regions
|
||||||
Set<String> rents = new TreeSet<String>(plugin.getFileManager().getRentNames());
|
Set<String> rents = new TreeSet<>(plugin.getFileManager().getRentNames());
|
||||||
for(RegionGroup group : plugin.getFileManager().getGroups()) {
|
for(RegionGroup group : plugin.getFileManager().getGroups()) {
|
||||||
rents.removeAll(group.getMembers());
|
rents.removeAll(group.getMembers());
|
||||||
}
|
}
|
||||||
@ -348,7 +339,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Buy regions
|
// Buy regions
|
||||||
Set<String> buys = new TreeSet<String>(plugin.getFileManager().getBuyNames());
|
Set<String> buys = new TreeSet<>(plugin.getFileManager().getBuyNames());
|
||||||
for(RegionGroup group : plugin.getFileManager().getGroups()) {
|
for(RegionGroup group : plugin.getFileManager().getGroups()) {
|
||||||
buys.removeAll(group.getMembers());
|
buys.removeAll(group.getMembers());
|
||||||
}
|
}
|
||||||
@ -388,7 +379,7 @@ public class InfoCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result.addAll(Arrays.asList("all", "rented", "forrent", "sold", "forsale", "player", "region", "nogroup"));
|
result.addAll(Arrays.asList("all", "rented", "forrent", "sold", "forsale", "player", "region", "nogroup"));
|
||||||
} else if(toComplete == 3) {
|
} else if(toComplete == 3) {
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class LinksignsCommand extends CommandAreaShop {
|
public class LinksignsCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public LinksignsCommand(AreaShop plugin) {
|
public LinksignsCommand(AreaShop plugin) {
|
||||||
@ -31,7 +29,7 @@ public class LinksignsCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.linksigns")) {
|
if(!sender.hasPermission("areashop.linksigns")) {
|
||||||
plugin.message(sender, "linksigns-noPermission");
|
plugin.message(sender, "linksigns-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -61,7 +59,7 @@ public class LinksignsCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result.addAll(plugin.getFileManager().getRegionNames());
|
result.addAll(plugin.getFileManager().getRegionNames());
|
||||||
} else if(toComplete == 3) {
|
} else if(toComplete == 3) {
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MeCommand extends CommandAreaShop {
|
public class MeCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public MeCommand(AreaShop plugin) {
|
public MeCommand(AreaShop plugin) {
|
||||||
@ -34,7 +30,7 @@ public class MeCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.me")) {
|
if(!sender.hasPermission("areashop.me")) {
|
||||||
plugin.message(sender, "me-noPermission");
|
plugin.message(sender, "me-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -45,13 +41,13 @@ public class MeCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
Player player = (Player)sender;
|
Player player = (Player)sender;
|
||||||
// Get the regions owned by the player
|
// Get the regions owned by the player
|
||||||
Set<RentRegion> rentRegions = new HashSet<RentRegion>();
|
Set<RentRegion> rentRegions = new HashSet<>();
|
||||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||||
if(region.isOwner(player)) {
|
if(region.isOwner(player)) {
|
||||||
rentRegions.add(region);
|
rentRegions.add(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<BuyRegion> buyRegions = new HashSet<BuyRegion>();
|
Set<BuyRegion> buyRegions = new HashSet<>();
|
||||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||||
if(region.isOwner(player)) {
|
if(region.isOwner(player)) {
|
||||||
buyRegions.add(region);
|
buyRegions.add(region);
|
||||||
@ -74,7 +70,7 @@ public class MeCommand extends CommandAreaShop {
|
|||||||
plugin.messageNoPrefix(player, "me-buyLine", region);
|
plugin.messageNoPrefix(player, "me-buyLine", region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<GeneralRegion> friendRegions = new HashSet<GeneralRegion>();
|
Set<GeneralRegion> friendRegions = new HashSet<>();
|
||||||
for(GeneralRegion region : plugin.getFileManager().getRegions()) {
|
for(GeneralRegion region : plugin.getFileManager().getRegions()) {
|
||||||
if(region.getFriends() != null && region.getFriends().contains(player.getUniqueId())) {
|
if(region.getFriends() != null && region.getFriends().contains(player.getUniqueId())) {
|
||||||
friendRegions.add(region);
|
friendRegions.add(region);
|
||||||
@ -90,13 +86,6 @@ public class MeCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
|
||||||
List<String> result = new ArrayList<String>();
|
|
||||||
// Nothing to complete
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class ReloadCommand extends CommandAreaShop {
|
public class ReloadCommand extends CommandAreaShop {
|
||||||
@ -28,7 +23,7 @@ public class ReloadCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(sender.hasPermission("areashop.reload")) {
|
if(sender.hasPermission("areashop.reload")) {
|
||||||
// Reload the configuration files and update all region flags/signs
|
// Reload the configuration files and update all region flags/signs
|
||||||
plugin.reload(sender);
|
plugin.reload(sender);
|
||||||
@ -36,11 +31,4 @@ public class ReloadCommand extends CommandAreaShop {
|
|||||||
plugin.message(sender, "reload-noPermission");
|
plugin.message(sender, "reload-noPermission");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class RentCommand extends CommandAreaShop {
|
public class RentCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public RentCommand(AreaShop plugin) {
|
public RentCommand(AreaShop plugin) {
|
||||||
@ -31,7 +29,7 @@ public class RentCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.rent")) {
|
if(!sender.hasPermission("areashop.rent")) {
|
||||||
plugin.message(sender, "rent-noPermission");
|
plugin.message(sender, "rent-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -53,10 +51,8 @@ public class RentCommand extends CommandAreaShop {
|
|||||||
List<RentRegion> regions = Utils.getApplicableRentRegions(((Player) sender).getLocation());
|
List<RentRegion> regions = Utils.getApplicableRentRegions(((Player) sender).getLocation());
|
||||||
if (regions.isEmpty()) {
|
if (regions.isEmpty()) {
|
||||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||||
return;
|
|
||||||
} else if (regions.size() > 1) {
|
} else if (regions.size() > 1) {
|
||||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
regions.get(0).rent(player);
|
regions.get(0).rent(player);
|
||||||
}
|
}
|
||||||
@ -65,7 +61,7 @@ public class RentCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||||
if(!region.isRented()) {
|
if(!region.isRented()) {
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ResellCommand extends CommandAreaShop {
|
public class ResellCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public ResellCommand(AreaShop plugin) {
|
public ResellCommand(AreaShop plugin) {
|
||||||
@ -33,7 +31,7 @@ public class ResellCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.resell") && !sender.hasPermission("areashop.resellall")) {
|
if(!sender.hasPermission("areashop.resell") && !sender.hasPermission("areashop.resellall")) {
|
||||||
plugin.message(sender, "resell-noPermissionOther");
|
plugin.message(sender, "resell-noPermissionOther");
|
||||||
return;
|
return;
|
||||||
@ -43,14 +41,14 @@ public class ResellCommand extends CommandAreaShop {
|
|||||||
plugin.message(sender, "resell-help");
|
plugin.message(sender, "resell-help");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double price = 0.0;
|
double price;
|
||||||
try {
|
try {
|
||||||
price = Double.parseDouble(args[1]);
|
price = Double.parseDouble(args[1]);
|
||||||
} catch(NumberFormatException e) {
|
} catch(NumberFormatException e) {
|
||||||
plugin.message(sender, "resell-wrongPrice", args[1]);
|
plugin.message(sender, "resell-wrongPrice", args[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BuyRegion buy = null;
|
BuyRegion buy;
|
||||||
if(args.length <= 2) {
|
if(args.length <= 2) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
// get the region by location
|
// get the region by location
|
||||||
@ -104,7 +102,7 @@ public class ResellCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 3) {
|
if(toComplete == 3) {
|
||||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||||
if(region.isSold() && !region.isInResellingMode()) {
|
if(region.isSold() && !region.isInResellingMode()) {
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
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.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionEvent;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionEvent;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SchematiceventCommand extends CommandAreaShop {
|
public class SchematiceventCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public SchematiceventCommand(AreaShop plugin) {
|
public SchematiceventCommand(AreaShop plugin) {
|
||||||
@ -32,7 +30,7 @@ public class SchematiceventCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.schematicevents")) {
|
if(!sender.hasPermission("areashop.schematicevents")) {
|
||||||
plugin.message(sender, "schemevent-noPermission");
|
plugin.message(sender, "schemevent-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -60,7 +58,7 @@ public class SchematiceventCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
// Check for a totally wrong event or a non matching event
|
// Check for a totally wrong event or a non matching event
|
||||||
if(exception) {
|
if(exception) {
|
||||||
ArrayList<String> values = new ArrayList<String>();
|
ArrayList<String> values = new ArrayList<>();
|
||||||
for(RegionEvent value : RegionEvent.values()) {
|
for(RegionEvent value : RegionEvent.values()) {
|
||||||
values.add(value.getValue().toLowerCase());
|
values.add(value.getValue().toLowerCase());
|
||||||
}
|
}
|
||||||
@ -74,7 +72,7 @@ public class SchematiceventCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result.addAll(plugin.getFileManager().getRegionNames());
|
result.addAll(plugin.getFileManager().getRegionNames());
|
||||||
} else if(toComplete == 3) {
|
} else if(toComplete == 3) {
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SellCommand extends CommandAreaShop {
|
public class SellCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public SellCommand(AreaShop plugin) {
|
public SellCommand(AreaShop plugin) {
|
||||||
@ -33,12 +31,12 @@ public class SellCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.sell") && !sender.hasPermission("areashop.sellown")) {
|
if(!sender.hasPermission("areashop.sell") && !sender.hasPermission("areashop.sellown")) {
|
||||||
plugin.message(sender, "sell-noPermission");
|
plugin.message(sender, "sell-noPermission");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BuyRegion buy = null;
|
BuyRegion buy;
|
||||||
if(args.length <= 1) {
|
if(args.length <= 1) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
// get the region by location
|
// get the region by location
|
||||||
@ -86,7 +84,7 @@ public class SellCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||||
if(region.isSold()) {
|
if(region.isSold()) {
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SetdurationCommand extends CommandAreaShop {
|
public class SetdurationCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public SetdurationCommand(AreaShop plugin) {
|
public SetdurationCommand(AreaShop plugin) {
|
||||||
@ -31,7 +29,7 @@ public class SetdurationCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.setduration") && (!sender.hasPermission("areashop.setduration.landlord") && sender instanceof Player)) {
|
if(!sender.hasPermission("areashop.setduration") && (!sender.hasPermission("areashop.setduration.landlord") && sender instanceof Player)) {
|
||||||
plugin.message(sender, "setduration-noPermission");
|
plugin.message(sender, "setduration-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -44,7 +42,7 @@ public class SetdurationCommand extends CommandAreaShop {
|
|||||||
if(args.length >= 2 && ("default".equalsIgnoreCase(args[1]) || "reset".equalsIgnoreCase(args[1]))) {
|
if(args.length >= 2 && ("default".equalsIgnoreCase(args[1]) || "reset".equalsIgnoreCase(args[1]))) {
|
||||||
regionArgument = 2;
|
regionArgument = 2;
|
||||||
}
|
}
|
||||||
RentRegion rent = null;
|
RentRegion rent;
|
||||||
if(args.length <= regionArgument) {
|
if(args.length <= regionArgument) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
// get the region by location
|
// get the region by location
|
||||||
@ -69,7 +67,7 @@ public class SetdurationCommand extends CommandAreaShop {
|
|||||||
plugin.message(sender, "setduration-notRegistered", args[regionArgument]);
|
plugin.message(sender, "setduration-notRegistered", args[regionArgument]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!sender.hasPermission("areashop.setduration") && !rent.isLandlord(((Player)sender).getUniqueId())) {
|
if(!sender.hasPermission("areashop.setduration") && !(sender instanceof Player && rent.isLandlord(((Player)sender).getUniqueId()))) {
|
||||||
plugin.message(sender, "setduration-noLandlord", rent);
|
plugin.message(sender, "setduration-noLandlord", rent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -98,7 +96,7 @@ public class SetdurationCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result = plugin.getFileManager().getRentNames();
|
result = plugin.getFileManager().getRentNames();
|
||||||
} else if(toComplete == 4) {
|
} else if(toComplete == 4) {
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SetlandlordCommand extends CommandAreaShop {
|
public class SetlandlordCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public SetlandlordCommand(AreaShop plugin) {
|
public SetlandlordCommand(AreaShop plugin) {
|
||||||
@ -33,7 +31,7 @@ public class SetlandlordCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.setlandlord")) {
|
if(!sender.hasPermission("areashop.setlandlord")) {
|
||||||
plugin.message(sender, "setlandlord-noPermission");
|
plugin.message(sender, "setlandlord-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -44,7 +42,7 @@ public class SetlandlordCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
|
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
|
||||||
GeneralRegion region = null;
|
GeneralRegion region;
|
||||||
if(args.length < 3) {
|
if(args.length < 3) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
// get the region by location
|
// get the region by location
|
||||||
@ -79,7 +77,7 @@ public class SetlandlordCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||||
result.add(player.getName());
|
result.add(player.getName());
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SetownerCommand extends CommandAreaShop {
|
public class SetownerCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public SetownerCommand(AreaShop plugin) {
|
public SetownerCommand(AreaShop plugin) {
|
||||||
@ -37,7 +35,7 @@ public class SetownerCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.setownerrent") && !sender.hasPermission("areashop.setownerbuy")) {
|
if(!sender.hasPermission("areashop.setownerrent") && !sender.hasPermission("areashop.setownerbuy")) {
|
||||||
plugin.message(sender, "setowner-noPermission");
|
plugin.message(sender, "setowner-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -131,7 +129,7 @@ public class SetownerCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||||
result.add(player.getName());
|
result.add(player.getName());
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SetpriceCommand extends CommandAreaShop {
|
public class SetpriceCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public SetpriceCommand(AreaShop plugin) {
|
public SetpriceCommand(AreaShop plugin) {
|
||||||
@ -33,7 +31,7 @@ public class SetpriceCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.setprice") && (!sender.hasPermission("areashop.setprice.landlord") && sender instanceof Player)) {
|
if(!sender.hasPermission("areashop.setprice") && (!sender.hasPermission("areashop.setprice.landlord") && sender instanceof Player)) {
|
||||||
plugin.message(sender, "setprice-noPermission");
|
plugin.message(sender, "setprice-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -42,7 +40,7 @@ public class SetpriceCommand extends CommandAreaShop {
|
|||||||
plugin.message(sender, "setprice-help");
|
plugin.message(sender, "setprice-help");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GeneralRegion region = null;
|
GeneralRegion region;
|
||||||
if(args.length < 3) {
|
if(args.length < 3) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
// get the region by location
|
// get the region by location
|
||||||
@ -67,7 +65,7 @@ public class SetpriceCommand extends CommandAreaShop {
|
|||||||
plugin.message(sender, "setprice-notRegistered", args[2]);
|
plugin.message(sender, "setprice-notRegistered", args[2]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!sender.hasPermission("areashop.setprice") && !region.isLandlord(((Player)sender).getUniqueId())) {
|
if(!sender.hasPermission("areashop.setprice") && !(sender instanceof Player && region.isLandlord(((Player)sender).getUniqueId()))) {
|
||||||
plugin.message(sender, "setprice-noLandlord", region);
|
plugin.message(sender, "setprice-noLandlord", region);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -82,7 +80,7 @@ public class SetpriceCommand extends CommandAreaShop {
|
|||||||
region.updateRegionFlags();
|
region.updateRegionFlags();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double price = 0.0;
|
double price;
|
||||||
try {
|
try {
|
||||||
price = Double.parseDouble(args[1]);
|
price = Double.parseDouble(args[1]);
|
||||||
} catch(NumberFormatException e) {
|
} catch(NumberFormatException e) {
|
||||||
@ -103,7 +101,7 @@ public class SetpriceCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 3) {
|
if(toComplete == 3) {
|
||||||
result = plugin.getFileManager().getRegionNames();
|
result = plugin.getFileManager().getRegionNames();
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SetrestoreCommand extends CommandAreaShop {
|
public class SetrestoreCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public SetrestoreCommand(AreaShop plugin) {
|
public SetrestoreCommand(AreaShop plugin) {
|
||||||
@ -29,7 +27,7 @@ public class SetrestoreCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.setrestore")) {
|
if(!sender.hasPermission("areashop.setrestore")) {
|
||||||
plugin.message(sender, "setrestore-noPermission");
|
plugin.message(sender, "setrestore-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -64,7 +62,7 @@ public class SetrestoreCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result = plugin.getFileManager().getRegionNames();
|
result = plugin.getFileManager().getRegionNames();
|
||||||
} else if(toComplete == 3) {
|
} else if(toComplete == 3) {
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SetteleportCommand extends CommandAreaShop {
|
public class SetteleportCommand extends CommandAreaShop {
|
||||||
|
|
||||||
@ -37,7 +34,7 @@ public class SetteleportCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.setteleport") && !sender.hasPermission("areashop.setteleportall")) {
|
if(!sender.hasPermission("areashop.setteleport") && !sender.hasPermission("areashop.setteleportall")) {
|
||||||
plugin.message(sender, "setteleport-noPermission");
|
plugin.message(sender, "setteleport-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -47,9 +44,8 @@ public class SetteleportCommand extends CommandAreaShop {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = (Player)sender;
|
Player player = (Player)sender;
|
||||||
GeneralRegion region = null;
|
GeneralRegion region;
|
||||||
if(args.length < 2) {
|
if(args.length < 2) {
|
||||||
if (sender instanceof Player) {
|
|
||||||
// get the region by location
|
// get the region by location
|
||||||
List<GeneralRegion> regions = Utils.getAllApplicableRegions(((Player)sender).getLocation());
|
List<GeneralRegion> regions = Utils.getAllApplicableRegions(((Player)sender).getLocation());
|
||||||
if(regions.isEmpty()) {
|
if(regions.isEmpty()) {
|
||||||
@ -61,15 +57,11 @@ public class SetteleportCommand extends CommandAreaShop {
|
|||||||
} else {
|
} else {
|
||||||
region = regions.get(0);
|
region = regions.get(0);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
region = plugin.getFileManager().getRegion(args[1]);
|
region = plugin.getFileManager().getRegion(args[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean owner = false;
|
boolean owner;
|
||||||
|
|
||||||
if(region == null) {
|
if(region == null) {
|
||||||
plugin.message(player, "setteleport-noRentOrBuy", args[1]);
|
plugin.message(player, "setteleport-noRentOrBuy", args[1]);
|
||||||
@ -104,7 +96,7 @@ public class SetteleportCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result.addAll(plugin.getFileManager().getRegionNames());
|
result.addAll(plugin.getFileManager().getRegionNames());
|
||||||
} else if(toComplete == 3) {
|
} else if(toComplete == 3) {
|
||||||
|
@ -1,26 +1,23 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import java.util.List;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionEvent;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionEvent;
|
||||||
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import java.util.ArrayList;
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import java.util.List;
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
|
||||||
|
|
||||||
public class StackCommand extends CommandAreaShop {
|
public class StackCommand extends CommandAreaShop {
|
||||||
|
|
||||||
@ -42,7 +39,7 @@ public class StackCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
// Check permission
|
// Check permission
|
||||||
if(!sender.hasPermission("areashop.stack")) {
|
if(!sender.hasPermission("areashop.stack")) {
|
||||||
plugin.message(sender, "stack-noPermission");
|
plugin.message(sender, "stack-noPermission");
|
||||||
@ -63,13 +60,15 @@ public class StackCommand extends CommandAreaShop {
|
|||||||
int tempAmount = -1;
|
int tempAmount = -1;
|
||||||
try {
|
try {
|
||||||
tempAmount = Integer.parseInt(args[1]);
|
tempAmount = Integer.parseInt(args[1]);
|
||||||
} catch(NumberFormatException e) {}
|
} catch(NumberFormatException e) {
|
||||||
|
// Incorrect number
|
||||||
|
}
|
||||||
if(tempAmount <= 0) {
|
if(tempAmount <= 0) {
|
||||||
plugin.message(player, "stack-wrongAmount", args[1]);
|
plugin.message(player, "stack-wrongAmount", args[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check gap
|
// Check gap
|
||||||
int gap = -1;
|
int gap;
|
||||||
try {
|
try {
|
||||||
gap = Integer.parseInt(args[2]);
|
gap = Integer.parseInt(args[2]);
|
||||||
} catch(NumberFormatException e) {
|
} catch(NumberFormatException e) {
|
||||||
@ -119,7 +118,7 @@ public class StackCommand extends CommandAreaShop {
|
|||||||
final boolean rentRegions = "rent".equalsIgnoreCase(args[4]);
|
final boolean rentRegions = "rent".equalsIgnoreCase(args[4]);
|
||||||
final int amount = tempAmount;
|
final int amount = tempAmount;
|
||||||
final RegionGroup finalGroup = group;
|
final RegionGroup finalGroup = group;
|
||||||
String type = null;
|
String type;
|
||||||
if(rentRegions) {
|
if(rentRegions) {
|
||||||
type = "rent";
|
type = "rent";
|
||||||
} else {
|
} else {
|
||||||
@ -206,7 +205,7 @@ public class StackCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(toComplete == 5) {
|
if(toComplete == 5) {
|
||||||
result.add("rent");
|
result.add("rent");
|
||||||
result.add("buy");
|
result.add("buy");
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class StopresellCommand extends CommandAreaShop {
|
public class StopresellCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public StopresellCommand(AreaShop plugin) {
|
public StopresellCommand(AreaShop plugin) {
|
||||||
@ -33,13 +31,13 @@ public class StopresellCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.stopresell") && !sender.hasPermission("areashop.stopresellall")) {
|
if(!sender.hasPermission("areashop.stopresell") && !sender.hasPermission("areashop.stopresellall")) {
|
||||||
plugin.message(sender, "stopresell-noPermissionOther");
|
plugin.message(sender, "stopresell-noPermissionOther");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuyRegion buy = null;
|
BuyRegion buy;
|
||||||
if(args.length <= 1) {
|
if(args.length <= 1) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
// get the region by location
|
// get the region by location
|
||||||
@ -93,7 +91,7 @@ public class StopresellCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||||
if(region.isSold() && region.isInResellingMode()) {
|
if(region.isSold() && region.isInResellingMode()) {
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TeleportCommand extends CommandAreaShop {
|
public class TeleportCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public TeleportCommand(AreaShop plugin) {
|
public TeleportCommand(AreaShop plugin) {
|
||||||
@ -32,7 +30,7 @@ public class TeleportCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.teleport") && !sender.hasPermission("areashop.teleportall") && !sender.hasPermission("areashop.teleportsign") && !sender.hasPermission("areashop.teleportsignall") && !sender.hasPermission("areashop.teleportfriend") && !sender.hasPermission("teleportfriendsign")) {
|
if(!sender.hasPermission("areashop.teleport") && !sender.hasPermission("areashop.teleportall") && !sender.hasPermission("areashop.teleportsign") && !sender.hasPermission("areashop.teleportsignall") && !sender.hasPermission("areashop.teleportfriend") && !sender.hasPermission("teleportfriendsign")) {
|
||||||
plugin.message(sender, "teleport-noPermission");
|
plugin.message(sender, "teleport-noPermission");
|
||||||
return;
|
return;
|
||||||
@ -61,7 +59,7 @@ public class TeleportCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
result.addAll(plugin.getFileManager().getRegionNames());
|
result.addAll(plugin.getFileManager().getRegionNames());
|
||||||
} else if(toComplete == 3) {
|
} else if(toComplete == 3) {
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class UnrentCommand extends CommandAreaShop {
|
public class UnrentCommand extends CommandAreaShop {
|
||||||
|
|
||||||
public UnrentCommand(AreaShop plugin) {
|
public UnrentCommand(AreaShop plugin) {
|
||||||
@ -33,12 +31,12 @@ public class UnrentCommand extends CommandAreaShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!sender.hasPermission("areashop.unrent") && !sender.hasPermission("areashop.unrentown")) {
|
if(!sender.hasPermission("areashop.unrent") && !sender.hasPermission("areashop.unrentown")) {
|
||||||
plugin.message(sender, "unrent-noPermission");
|
plugin.message(sender, "unrent-noPermission");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RentRegion rent = null;
|
RentRegion rent;
|
||||||
if(args.length <= 1) {
|
if(args.length <= 1) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
// get the region by location
|
// get the region by location
|
||||||
@ -86,7 +84,7 @@ public class UnrentCommand extends CommandAreaShop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
if(toComplete == 2) {
|
if(toComplete == 2) {
|
||||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||||
if(region.isRented()) {
|
if(region.isRented()) {
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package nl.evolutioncoding.areashop.exceptions;
|
|
||||||
|
|
||||||
public class RegionCreateException extends Exception {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public RegionCreateException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,12 +1,8 @@
|
|||||||
package nl.evolutioncoding.areashop.listeners;
|
package nl.evolutioncoding.areashop.listeners;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -17,12 +13,15 @@ import org.bukkit.event.player.PlayerLoginEvent.Result;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for placement of signs for this plugin
|
* Checks for placement of signs for this plugin
|
||||||
* @author NLThijs48
|
* @author NLThijs48
|
||||||
*/
|
*/
|
||||||
public final class PlayerLoginLogoutListener implements Listener {
|
public final class PlayerLoginLogoutListener implements Listener {
|
||||||
AreaShop plugin;
|
private AreaShop plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -76,7 +75,7 @@ public final class PlayerLoginLogoutListener implements Listener {
|
|||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 25, 25);
|
}.runTaskTimer(plugin, 25, 25);
|
||||||
// Check if the player has regions that use an old name of him and update them
|
// Check if the player has regions that use an old name of him and update them
|
||||||
final List<GeneralRegion> regions = new ArrayList<GeneralRegion>(plugin.getFileManager().getRegions());
|
final List<GeneralRegion> regions = new ArrayList<>(plugin.getFileManager().getRegions());
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
private int current = 0;
|
private int current = 0;
|
||||||
|
|
||||||
@ -130,7 +129,7 @@ public final class PlayerLoginLogoutListener implements Listener {
|
|||||||
* Update the last active time for all regions the player is owner off
|
* Update the last active time for all regions the player is owner off
|
||||||
* @param player The player to update the active times for
|
* @param player The player to update the active times for
|
||||||
*/
|
*/
|
||||||
public void updateLastActive(Player player) {
|
private void updateLastActive(Player player) {
|
||||||
for(GeneralRegion region : plugin.getFileManager().getRegions()) {
|
for(GeneralRegion region : plugin.getFileManager().getRegions()) {
|
||||||
if(region.isOwner(player)) {
|
if(region.isOwner(player)) {
|
||||||
region.updateLastActiveTime();
|
region.updateLastActiveTime();
|
||||||
|
@ -2,7 +2,6 @@ package nl.evolutioncoding.areashop.listeners;
|
|||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -17,7 +16,7 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
|||||||
* @author NLThijs48
|
* @author NLThijs48
|
||||||
*/
|
*/
|
||||||
public final class SignBreakListener implements Listener {
|
public final class SignBreakListener implements Listener {
|
||||||
AreaShop plugin;
|
private AreaShop plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -38,18 +37,18 @@ public final class SignBreakListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
/* Check if it is a sign */
|
// Check if it is a sign
|
||||||
if(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
|
if(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
|
||||||
/* Check if the rent sign is really the same as a saved rent */
|
// Check if the rent sign is really the same as a saved rent
|
||||||
GeneralRegion region = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
GeneralRegion region = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
||||||
if(region == null) {
|
if(region == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Remove the sign of the rental region if the player has permission */
|
// Remove the sign of the rental region if the player has permission
|
||||||
if(event.getPlayer().hasPermission("areashop.delsign")) {
|
if(event.getPlayer().hasPermission("areashop.delsign")) {
|
||||||
region.removeSign(block.getLocation());
|
region.removeSign(block.getLocation());
|
||||||
plugin.message(event.getPlayer(), "delsign-success", region.getName());
|
plugin.message(event.getPlayer(), "delsign-success", region.getName());
|
||||||
} else { /* Cancel the breaking of the sign */
|
} else { // Cancel the breaking of the sign
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
plugin.message(event.getPlayer(), "delsign-noPermission");
|
plugin.message(event.getPlayer(), "delsign-noPermission");
|
||||||
}
|
}
|
||||||
@ -70,7 +69,7 @@ public final class SignBreakListener implements Listener {
|
|||||||
Sign sign = (Sign)block.getState();
|
Sign sign = (Sign)block.getState();
|
||||||
Block attachedTo = block.getRelative(((org.bukkit.material.Sign)sign.getData()).getAttachedFace());
|
Block attachedTo = block.getRelative(((org.bukkit.material.Sign)sign.getData()).getAttachedFace());
|
||||||
if(attachedTo.getType() == Material.AIR){
|
if(attachedTo.getType() == Material.AIR){
|
||||||
/* Check if the rent sign is really the same as a saved rent */
|
// Check if the rent sign is really the same as a saved rent
|
||||||
final GeneralRegion region = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
final GeneralRegion region = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
||||||
if(region == null) {
|
if(region == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package nl.evolutioncoding.areashop.listeners;
|
package nl.evolutioncoding.areashop.listeners;
|
||||||
|
|
||||||
import java.util.List;
|
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;
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.managers.FileManager.AddResult;
|
import nl.evolutioncoding.areashop.managers.FileManager.AddResult;
|
||||||
@ -10,7 +12,6 @@ import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
|||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionEvent;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionEvent;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionType;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionType;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -19,17 +20,14 @@ import org.bukkit.event.block.SignChangeEvent;
|
|||||||
import org.bukkit.material.Sign;
|
import org.bukkit.material.Sign;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
import java.util.List;
|
||||||
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
|
* Checks for placement of signs for this plugin
|
||||||
* @author NLThijs48
|
* @author NLThijs48
|
||||||
*/
|
*/
|
||||||
public final class SignChangeListener implements Listener {
|
public final class SignChangeListener implements Listener {
|
||||||
AreaShop plugin;
|
private AreaShop plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -113,16 +111,12 @@ public final class SignChangeListener implements Listener {
|
|||||||
AddResult addResult = plugin.getFileManager().checkRegionAdd(player, regionManager.getRegion(secondLine), RegionType.RENT);
|
AddResult addResult = plugin.getFileManager().checkRegionAdd(player, regionManager.getRegion(secondLine), RegionType.RENT);
|
||||||
if(addResult == AddResult.BLACKLISTED) {
|
if(addResult == AddResult.BLACKLISTED) {
|
||||||
plugin.message(player, "setup-blacklisted", secondLine);
|
plugin.message(player, "setup-blacklisted", secondLine);
|
||||||
return;
|
|
||||||
} else if(addResult == AddResult.ALREADYADDED) {
|
} else if(addResult == AddResult.ALREADYADDED) {
|
||||||
plugin.message(player, "setup-alreadyRentSign");
|
plugin.message(player, "setup-alreadyRentSign");
|
||||||
return;
|
|
||||||
} else if(addResult == AddResult.NOPERMISSION) {
|
} else if(addResult == AddResult.NOPERMISSION) {
|
||||||
plugin.message(player, "setup-noPermission", secondLine);
|
plugin.message(player, "setup-noPermission", secondLine);
|
||||||
return;
|
|
||||||
} else if(thirdLine != null && thirdLine.length() != 0 && !plugin.checkTimeFormat(thirdLine)) {
|
} else if(thirdLine != null && thirdLine.length() != 0 && !plugin.checkTimeFormat(thirdLine)) {
|
||||||
plugin.message(player, "setup-wrongDuration");
|
plugin.message(player, "setup-wrongDuration");
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
double price = 0.0;
|
double price = 0.0;
|
||||||
if(priceSet) {
|
if(priceSet) {
|
||||||
@ -137,8 +131,8 @@ public final class SignChangeListener implements Listener {
|
|||||||
|
|
||||||
// Add rent to the FileManager
|
// Add rent to the FileManager
|
||||||
final RentRegion rent = new RentRegion(plugin, secondLine, event.getPlayer().getWorld());
|
final RentRegion rent = new RentRegion(plugin, secondLine, event.getPlayer().getWorld());
|
||||||
boolean isMember = player != null && plugin.getWorldGuardHandler().containsMember(rent.getRegion(), player.getUniqueId());
|
boolean isMember = plugin.getWorldGuardHandler().containsMember(rent.getRegion(), player.getUniqueId());
|
||||||
boolean isOwner = player != null && plugin.getWorldGuardHandler().containsOwner(rent.getRegion(), player.getUniqueId());
|
boolean isOwner = plugin.getWorldGuardHandler().containsOwner(rent.getRegion(), player.getUniqueId());
|
||||||
boolean landlord = (!player.hasPermission("areashop.createrent")
|
boolean landlord = (!player.hasPermission("areashop.createrent")
|
||||||
&& ((player.hasPermission("areashop.createrent.owner") && isOwner)
|
&& ((player.hasPermission("areashop.createrent.owner") && isOwner)
|
||||||
|| (player.hasPermission("areashop.createrent.member") && isMember)));
|
|| (player.hasPermission("areashop.createrent.member") && isMember)));
|
||||||
@ -187,6 +181,9 @@ public final class SignChangeListener implements Listener {
|
|||||||
|
|
||||||
// Get the regionManager for accessing regions
|
// Get the regionManager for accessing regions
|
||||||
RegionManager regionManager = plugin.getWorldGuard().getRegionManager(event.getPlayer().getWorld());
|
RegionManager regionManager = plugin.getWorldGuard().getRegionManager(event.getPlayer().getWorld());
|
||||||
|
if(regionManager == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the secondLine does not contain a name try to find the region by location
|
// If the secondLine does not contain a name try to find the region by location
|
||||||
if(secondLine == null || secondLine.length() == 0) {
|
if(secondLine == null || secondLine.length() == 0) {
|
||||||
@ -229,13 +226,10 @@ public final class SignChangeListener implements Listener {
|
|||||||
AddResult addResult = plugin.getFileManager().checkRegionAdd(player, region, RegionType.BUY);
|
AddResult addResult = plugin.getFileManager().checkRegionAdd(player, region, RegionType.BUY);
|
||||||
if(addResult == AddResult.BLACKLISTED) {
|
if(addResult == AddResult.BLACKLISTED) {
|
||||||
plugin.message(player, "setup-blacklisted", secondLine);
|
plugin.message(player, "setup-blacklisted", secondLine);
|
||||||
return;
|
|
||||||
} else if(addResult == AddResult.ALREADYADDED) {
|
} else if(addResult == AddResult.ALREADYADDED) {
|
||||||
plugin.message(player, "setup-alreadyRentSign");
|
plugin.message(player, "setup-alreadyRentSign");
|
||||||
return;
|
|
||||||
} else if(addResult == AddResult.NOPERMISSION) {
|
} else if(addResult == AddResult.NOPERMISSION) {
|
||||||
plugin.message(player, "setup-noPermission", secondLine);
|
plugin.message(player, "setup-noPermission", secondLine);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
double price = 0.0;
|
double price = 0.0;
|
||||||
if(priceSet) {
|
if(priceSet) {
|
||||||
@ -250,8 +244,8 @@ public final class SignChangeListener implements Listener {
|
|||||||
|
|
||||||
// Add buy to the FileManager
|
// Add buy to the FileManager
|
||||||
final BuyRegion buy = new BuyRegion(plugin, secondLine, event.getPlayer().getWorld());
|
final BuyRegion buy = new BuyRegion(plugin, secondLine, event.getPlayer().getWorld());
|
||||||
boolean isMember = player != null && plugin.getWorldGuardHandler().containsMember(buy.getRegion(), player.getUniqueId());
|
boolean isMember = plugin.getWorldGuardHandler().containsMember(buy.getRegion(), player.getUniqueId());
|
||||||
boolean isOwner = player != null && plugin.getWorldGuardHandler().containsOwner(buy.getRegion(), player.getUniqueId());
|
boolean isOwner = plugin.getWorldGuardHandler().containsOwner(buy.getRegion(), player.getUniqueId());
|
||||||
boolean landlord = (!player.hasPermission("areashop.createbuy")
|
boolean landlord = (!player.hasPermission("areashop.createbuy")
|
||||||
&& ((player.hasPermission("areashop.createbuy.owner") && isOwner)
|
&& ((player.hasPermission("areashop.createbuy.owner") && isOwner)
|
||||||
|| (player.hasPermission("areashop.createbuy.member") && isMember)));
|
|| (player.hasPermission("areashop.createbuy.member") && isMember)));
|
||||||
@ -279,7 +273,7 @@ public final class SignChangeListener implements Listener {
|
|||||||
|
|
||||||
// Set the flags for the region
|
// Set the flags for the region
|
||||||
buy.updateRegionFlags();
|
buy.updateRegionFlags();
|
||||||
plugin.message(player, "setup-buySuccess", regionManager.getRegion(secondLine).getId());
|
plugin.message(player, "setup-buySuccess", region.getId());
|
||||||
|
|
||||||
// Run commands
|
// Run commands
|
||||||
buy.runEventCommands(RegionEvent.CREATED, false);
|
buy.runEventCommands(RegionEvent.CREATED, false);
|
||||||
@ -295,7 +289,7 @@ public final class SignChangeListener implements Listener {
|
|||||||
String secondLine = event.getLine(1);
|
String secondLine = event.getLine(1);
|
||||||
String thirdLine = event.getLine(2);
|
String thirdLine = event.getLine(2);
|
||||||
|
|
||||||
GeneralRegion region = null;
|
GeneralRegion region;
|
||||||
if(secondLine != null && secondLine.length() != 0) {
|
if(secondLine != null && secondLine.length() != 0) {
|
||||||
// Get region by secondLine of the sign
|
// Get region by secondLine of the sign
|
||||||
region = plugin.getFileManager().getRegion(secondLine);
|
region = plugin.getFileManager().getRegion(secondLine);
|
||||||
|
@ -3,7 +3,6 @@ package nl.evolutioncoding.areashop.listeners;
|
|||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion.ClickType;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion.ClickType;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -14,7 +13,7 @@ import org.bukkit.event.block.Action;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
public class SignClickListener implements Listener {
|
public class SignClickListener implements Listener {
|
||||||
AreaShop plugin;
|
private AreaShop plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -34,10 +33,10 @@ public class SignClickListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
/* Check for clicking a sign and rightclicking */
|
// Check for clicking a sign and rightclicking
|
||||||
if((event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
if((event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||||
&& (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)) {
|
&& (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)) {
|
||||||
/* Check if the rent sign is really the same as a saved rent */
|
// Check if the rent sign is really the same as a saved rent
|
||||||
GeneralRegion result = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
GeneralRegion result = plugin.getFileManager().getRegionBySignLocation(block.getLocation());
|
||||||
if(result == null) {
|
if(result == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,44 +1,7 @@
|
|||||||
package nl.evolutioncoding.areashop.managers;
|
package nl.evolutioncoding.areashop.managers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.commands.AddCommand;
|
import nl.evolutioncoding.areashop.commands.*;
|
||||||
import nl.evolutioncoding.areashop.commands.AddfriendCommand;
|
|
||||||
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.DelfriendCommand;
|
|
||||||
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.LinksignsCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.MeCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.ReloadCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.RentCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.ResellCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.SchematiceventCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.SellCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.SetdurationCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.SetlandlordCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.SetownerCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.SetpriceCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.SetrestoreCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.SetteleportCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.StackCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.StopresellCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.TeleportCommand;
|
|
||||||
import nl.evolutioncoding.areashop.commands.UnrentCommand;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -46,9 +9,14 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
public class CommandManager implements CommandExecutor, TabCompleter {
|
public class CommandManager implements CommandExecutor, TabCompleter {
|
||||||
AreaShop plugin;
|
private AreaShop plugin;
|
||||||
ArrayList<CommandAreaShop> commands;
|
private ArrayList<CommandAreaShop> commands;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -56,7 +24,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
*/
|
*/
|
||||||
public CommandManager(AreaShop plugin) {
|
public CommandManager(AreaShop plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
commands = new ArrayList<CommandAreaShop>();
|
commands = new ArrayList<>();
|
||||||
commands.add(new HelpCommand(plugin));
|
commands.add(new HelpCommand(plugin));
|
||||||
commands.add(new RentCommand(plugin));
|
commands.add(new RentCommand(plugin));
|
||||||
commands.add(new UnrentCommand(plugin));
|
commands.add(new UnrentCommand(plugin));
|
||||||
@ -108,7 +76,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
*/
|
*/
|
||||||
public void showHelp(CommandSender target) {
|
public void showHelp(CommandSender target) {
|
||||||
/* Add all messages to a list */
|
/* Add all messages to a list */
|
||||||
ArrayList<String> messages = new ArrayList<String>();
|
ArrayList<String> messages = new ArrayList<>();
|
||||||
messages.add(plugin.getConfig().getString("chatPrefix") + plugin.getLanguageManager().getLang("help-header"));
|
messages.add(plugin.getConfig().getString("chatPrefix") + plugin.getLanguageManager().getLang("help-header"));
|
||||||
messages.add(plugin.getConfig().getString("chatPrefix") + plugin.getLanguageManager().getLang("help-alias"));
|
messages.add(plugin.getConfig().getString("chatPrefix") + plugin.getLanguageManager().getLang("help-alias"));
|
||||||
for(CommandAreaShop command : commands) {
|
for(CommandAreaShop command : commands) {
|
||||||
@ -137,7 +105,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
boolean executed = false;
|
boolean executed = false;
|
||||||
for(int i=0; i<commands.size() && !executed; i++) {
|
for(int i=0; i<commands.size() && !executed; i++) {
|
||||||
if(commands.get(i).canExecute(command, args)) {
|
if(commands.get(i).canExecute(command, args)) {
|
||||||
commands.get(i).execute(sender, command, args);
|
commands.get(i).execute(sender, args);
|
||||||
executed = true;
|
executed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +124,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
if(!sender.hasPermission("areashop.tabcomplete")) {
|
if(!sender.hasPermission("areashop.tabcomplete")) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -182,7 +150,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
// Filter and sort the results
|
// Filter and sort the results
|
||||||
if(result.size() > 0) {
|
if(result.size() > 0) {
|
||||||
SortedSet<String> set = new TreeSet<String>();
|
SortedSet<String> set = new TreeSet<>();
|
||||||
for(String suggestion : result) {
|
for(String suggestion : result) {
|
||||||
if(suggestion.toLowerCase().startsWith(toCompletePrefix)) {
|
if(suggestion.toLowerCase().startsWith(toCompletePrefix)) {
|
||||||
set.add(suggestion);
|
set.add(suggestion);
|
||||||
|
@ -1,24 +1,9 @@
|
|||||||
package nl.evolutioncoding.areashop.managers;
|
package nl.evolutioncoding.areashop.managers;
|
||||||
|
|
||||||
import java.io.File;
|
import com.google.common.base.Charsets;
|
||||||
import java.io.FileInputStream;
|
import com.google.common.io.Files;
|
||||||
import java.io.FileNotFoundException;
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
import java.io.FileOutputStream;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
import nl.evolutioncoding.areashop.regions.BuyRegion;
|
||||||
@ -27,29 +12,22 @@ import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionEvent;
|
|||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionType;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion.RegionType;
|
||||||
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
import nl.evolutioncoding.areashop.regions.RegionGroup;
|
||||||
import nl.evolutioncoding.areashop.regions.RentRegion;
|
import nl.evolutioncoding.areashop.regions.RentRegion;
|
||||||
|
import org.bukkit.*;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import java.io.*;
|
||||||
import com.google.common.io.Files;
|
import java.util.*;
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
import java.util.regex.Matcher;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class FileManager {
|
public class FileManager {
|
||||||
private static FileManager instance = null;
|
private static FileManager instance = null;
|
||||||
|
|
||||||
private AreaShop plugin = null;
|
private AreaShop plugin = null;
|
||||||
private ObjectInputStream input = null;
|
|
||||||
private ObjectOutputStream output = null;
|
|
||||||
private HashMap<String, GeneralRegion> regions = null;
|
private HashMap<String, GeneralRegion> regions = null;
|
||||||
private String regionsPath = null;
|
private String regionsPath = null;
|
||||||
private HashMap<String, RegionGroup> groups = null;
|
private HashMap<String, RegionGroup> groups = null;
|
||||||
@ -74,7 +52,8 @@ public class FileManager {
|
|||||||
SUCCESS("success");
|
SUCCESS("success");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
private AddResult(String value) {
|
|
||||||
|
AddResult(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
@ -84,22 +63,22 @@ public class FileManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor, initialize variabeles
|
* Constructor, initialize variabeles
|
||||||
* @param plugin
|
* @param plugin AreaShop
|
||||||
*/
|
*/
|
||||||
public FileManager(AreaShop plugin) {
|
public FileManager(AreaShop plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
regions = new HashMap<String, GeneralRegion>();
|
regions = new HashMap<>();
|
||||||
regionsPath = plugin.getDataFolder() + File.separator + AreaShop.regionsFolder;
|
regionsPath = plugin.getDataFolder() + File.separator + AreaShop.regionsFolder;
|
||||||
configPath = plugin.getDataFolder() + File.separator + "config.yml";
|
configPath = plugin.getDataFolder() + File.separator + "config.yml";
|
||||||
groups = new HashMap<String, RegionGroup>();
|
groups = new HashMap<>();
|
||||||
groupsPath = plugin.getDataFolder() + File.separator + AreaShop.groupsFile;
|
groupsPath = plugin.getDataFolder() + File.separator + AreaShop.groupsFile;
|
||||||
defaultPath = plugin.getDataFolder() + File.separator + AreaShop.defaultFile;
|
defaultPath = plugin.getDataFolder() + File.separator + AreaShop.defaultFile;
|
||||||
versionPath = plugin.getDataFolder().getPath() + File.separator + AreaShop.versionFile;
|
versionPath = plugin.getDataFolder().getPath() + File.separator + AreaShop.versionFile;
|
||||||
schemFolder = plugin.getDataFolder() + File.separator + AreaShop.schematicFolder;
|
schemFolder = plugin.getDataFolder() + File.separator + AreaShop.schematicFolder;
|
||||||
worldRegionsRequireSaving = new HashSet<String>();
|
worldRegionsRequireSaving = new HashSet<>();
|
||||||
File schemFile = new File(schemFolder);
|
File schemFile = new File(schemFolder);
|
||||||
if(!schemFile.exists()) {
|
if(!schemFile.exists() & !schemFile.mkdirs()) {
|
||||||
schemFile.mkdirs();
|
plugin.getLogger().warning("Could not create schematic files directory: " + schemFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
loadVersions();
|
loadVersions();
|
||||||
}
|
}
|
||||||
@ -161,7 +140,7 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<RentRegion> getRents() {
|
public List<RentRegion> getRents() {
|
||||||
List<RentRegion> result = new ArrayList<RentRegion>();
|
List<RentRegion> result = new ArrayList<>();
|
||||||
for(GeneralRegion region : regions.values()) {
|
for(GeneralRegion region : regions.values()) {
|
||||||
if(region.isRentRegion()) {
|
if(region.isRentRegion()) {
|
||||||
result.add((RentRegion)region);
|
result.add((RentRegion)region);
|
||||||
@ -171,7 +150,7 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<BuyRegion> getBuys() {
|
public List<BuyRegion> getBuys() {
|
||||||
List<BuyRegion> result = new ArrayList<BuyRegion>();
|
List<BuyRegion> result = new ArrayList<>();
|
||||||
for(GeneralRegion region : regions.values()) {
|
for(GeneralRegion region : regions.values()) {
|
||||||
if(region.isBuyRegion()) {
|
if(region.isBuyRegion()) {
|
||||||
result.add((BuyRegion)region);
|
result.add((BuyRegion)region);
|
||||||
@ -181,7 +160,7 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<GeneralRegion> getRegions() {
|
public List<GeneralRegion> getRegions() {
|
||||||
return new ArrayList<GeneralRegion>(regions.values());
|
return new ArrayList<>(regions.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,28 +168,28 @@ public class FileManager {
|
|||||||
* @return A String list with all the names
|
* @return A String list with all the names
|
||||||
*/
|
*/
|
||||||
public List<String> getBuyNames() {
|
public List<String> getBuyNames() {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
for(BuyRegion region : getBuys()) {
|
for(BuyRegion region : getBuys()) {
|
||||||
result.add(region.getName());
|
result.add(region.getName());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public List<String> getRentNames() {
|
public List<String> getRentNames() {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
for(RentRegion region : getRents()) {
|
for(RentRegion region : getRents()) {
|
||||||
result.add(region.getName());
|
result.add(region.getName());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public List<String> getRegionNames() {
|
public List<String> getRegionNames() {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
for(GeneralRegion region : getRegions()) {
|
for(GeneralRegion region : getRegions()) {
|
||||||
result.add(region.getName());
|
result.add(region.getName());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public List<String> getGroupNames() {
|
public List<String> getGroupNames() {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
for(RegionGroup group : getGroups()) {
|
for(RegionGroup group : getGroups()) {
|
||||||
result.add(group.getName());
|
result.add(group.getName());
|
||||||
}
|
}
|
||||||
@ -264,12 +243,8 @@ public class FileManager {
|
|||||||
public void addGroup(RegionGroup group) {
|
public void addGroup(RegionGroup group) {
|
||||||
groups.put(group.getName().toLowerCase(), group);
|
groups.put(group.getName().toLowerCase(), group);
|
||||||
String lowGroup = group.getName().toLowerCase();
|
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 + ".name", group.getName());
|
||||||
groupsConfig.set(lowGroup + ".priority", 0);
|
groupsConfig.set(lowGroup + ".priority", 0);
|
||||||
}
|
|
||||||
saveGroupsIsRequired();
|
saveGroupsIsRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +264,7 @@ public class FileManager {
|
|||||||
boolean isMember = player != null && plugin.getWorldGuardHandler().containsMember(region, player.getUniqueId());
|
boolean isMember = player != null && plugin.getWorldGuardHandler().containsMember(region, player.getUniqueId());
|
||||||
boolean isOwner = player != null && plugin.getWorldGuardHandler().containsOwner(region, player.getUniqueId());
|
boolean isOwner = player != null && plugin.getWorldGuardHandler().containsOwner(region, player.getUniqueId());
|
||||||
AreaShop.debug("checkRegionAdd: isOwner=" + isOwner + ", isMember=" + isMember);
|
AreaShop.debug("checkRegionAdd: isOwner=" + isOwner + ", isMember=" + isMember);
|
||||||
String typeString = null;
|
String typeString;
|
||||||
if(type == RegionType.RENT) {
|
if(type == RegionType.RENT) {
|
||||||
typeString = "rent";
|
typeString = "rent";
|
||||||
} else {
|
} else {
|
||||||
@ -341,7 +316,7 @@ public class FileManager {
|
|||||||
rent.resetRegionFlags();
|
rent.resetRegionFlags();
|
||||||
regions.remove(rent.getLowerCaseName());
|
regions.remove(rent.getLowerCaseName());
|
||||||
File file = new File(plugin.getDataFolder() + File.separator + AreaShop.regionsFolder + File.separator + rent.getLowerCaseName() + ".yml");
|
File file = new File(plugin.getDataFolder() + File.separator + AreaShop.regionsFolder + File.separator + rent.getLowerCaseName() + ".yml");
|
||||||
boolean deleted = true;
|
boolean deleted;
|
||||||
if(file.exists()) {
|
if(file.exists()) {
|
||||||
try {
|
try {
|
||||||
deleted = file.delete();
|
deleted = file.delete();
|
||||||
@ -376,7 +351,8 @@ public class FileManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a buy from the list
|
* Remove a buy from the list
|
||||||
* @param regionName
|
* @param buy The BuyRegion to remove
|
||||||
|
* @param giveMoneyBack true if money should be given back to the player, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean removeBuy(BuyRegion buy, boolean giveMoneyBack) {
|
public boolean removeBuy(BuyRegion buy, boolean giveMoneyBack) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
@ -405,7 +381,7 @@ public class FileManager {
|
|||||||
|
|
||||||
// Deleting the file
|
// Deleting the file
|
||||||
File file = new File(plugin.getDataFolder() + File.separator + AreaShop.regionsFolder + File.separator + buy.getLowerCaseName() + ".yml");
|
File file = new File(plugin.getDataFolder() + File.separator + AreaShop.regionsFolder + File.separator + buy.getLowerCaseName() + ".yml");
|
||||||
boolean deleted = true;
|
boolean deleted;
|
||||||
if(file.exists()) {
|
if(file.exists()) {
|
||||||
try {
|
try {
|
||||||
deleted = file.delete();
|
deleted = file.delete();
|
||||||
@ -439,7 +415,7 @@ public class FileManager {
|
|||||||
* Update all signs that need periodic updating
|
* Update all signs that need periodic updating
|
||||||
*/
|
*/
|
||||||
public void performPeriodicSignUpdate() {
|
public void performPeriodicSignUpdate() {
|
||||||
final List<RentRegion> regions = new ArrayList<RentRegion>(getRents());
|
final List<RentRegion> regions = new ArrayList<>(getRents());
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
private int current = 0;
|
private int current = 0;
|
||||||
|
|
||||||
@ -464,7 +440,7 @@ public class FileManager {
|
|||||||
* Send out rent expire warnings
|
* Send out rent expire warnings
|
||||||
*/
|
*/
|
||||||
public void sendRentExpireWarnings() {
|
public void sendRentExpireWarnings() {
|
||||||
final List<RentRegion> regions = new ArrayList<RentRegion>(getRents());
|
final List<RentRegion> regions = new ArrayList<>(getRents());
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
private int current = 0;
|
private int current = 0;
|
||||||
|
|
||||||
@ -485,11 +461,10 @@ public class FileManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update all rent signs
|
* Update all rent signs
|
||||||
* @return true if all signs are updated, otherwise false
|
|
||||||
* @param confirmationReceiver who needs to get the confirmation message, null if nobody
|
* @param confirmationReceiver who needs to get the confirmation message, null if nobody
|
||||||
*/
|
*/
|
||||||
public void updateRentSignsAndFlags(final CommandSender confirmationReceiver) {
|
public void updateRentSignsAndFlags(final CommandSender confirmationReceiver) {
|
||||||
final List<RentRegion> regions = new ArrayList<RentRegion>(getRents());
|
final List<RentRegion> regions = new ArrayList<>(getRents());
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
private int current = 0;
|
private int current = 0;
|
||||||
private boolean result = true;
|
private boolean result = true;
|
||||||
@ -518,11 +493,10 @@ public class FileManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update all buy signs
|
* Update all buy signs
|
||||||
* @return true if all signs are updated, otherwise false
|
|
||||||
* @param confirmationReceiver who needs to get the confirmation message, null if nobody
|
* @param confirmationReceiver who needs to get the confirmation message, null if nobody
|
||||||
*/
|
*/
|
||||||
public void updateBuySignsAndFlags(final CommandSender confirmationReceiver) {
|
public void updateBuySignsAndFlags(final CommandSender confirmationReceiver) {
|
||||||
final List<BuyRegion> regions = new ArrayList<BuyRegion>(getBuys());
|
final List<BuyRegion> regions = new ArrayList<>(getBuys());
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
private int current = 0;
|
private int current = 0;
|
||||||
private boolean result = true;
|
private boolean result = true;
|
||||||
@ -623,7 +597,7 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
this.saveWorldGuardRegions();
|
this.saveWorldGuardRegions();
|
||||||
|
|
||||||
final List<GeneralRegion> regions = new ArrayList<GeneralRegion>(getRegions());
|
final List<GeneralRegion> regions = new ArrayList<>(getRegions());
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
private int current = 0;
|
private int current = 0;
|
||||||
|
|
||||||
@ -718,7 +692,7 @@ public class FileManager {
|
|||||||
* Unrent regions that have no time left, regions to check per tick is in the config
|
* Unrent regions that have no time left, regions to check per tick is in the config
|
||||||
*/
|
*/
|
||||||
public void checkRents() {
|
public void checkRents() {
|
||||||
final List<RentRegion> regions = new ArrayList<RentRegion>(getRents());
|
final List<RentRegion> regions = new ArrayList<>(getRents());
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
private int current = 0;
|
private int current = 0;
|
||||||
|
|
||||||
@ -741,7 +715,7 @@ public class FileManager {
|
|||||||
* Check all regions and unrent/sell them if the player is inactive for too long
|
* Check all regions and unrent/sell them if the player is inactive for too long
|
||||||
*/
|
*/
|
||||||
public void checkForInactiveRegions() {
|
public void checkForInactiveRegions() {
|
||||||
final List<GeneralRegion> regions = new ArrayList<GeneralRegion>(getRegions());
|
final List<GeneralRegion> regions = new ArrayList<>(getRegions());
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
private int current = 0;
|
private int current = 0;
|
||||||
|
|
||||||
@ -770,7 +744,7 @@ public class FileManager {
|
|||||||
if(file.exists()) {
|
if(file.exists()) {
|
||||||
/* Load versions from the file */
|
/* Load versions from the file */
|
||||||
try {
|
try {
|
||||||
input = new ObjectInputStream(new FileInputStream(versionPath));
|
ObjectInputStream input = new ObjectInputStream(new FileInputStream(versionPath));
|
||||||
versions = (HashMap<String,Integer>)input.readObject();
|
versions = (HashMap<String,Integer>)input.readObject();
|
||||||
input.close();
|
input.close();
|
||||||
} catch (IOException | ClassNotFoundException | ClassCastException e) {
|
} catch (IOException | ClassNotFoundException | ClassCastException e) {
|
||||||
@ -779,7 +753,7 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(versions == null || versions.size() == 0) {
|
if(versions == null || versions.size() == 0) {
|
||||||
versions = new HashMap<String, Integer>();
|
versions = new HashMap<>();
|
||||||
versions.put(AreaShop.versionFiles, 0);
|
versions.put(AreaShop.versionFiles, 0);
|
||||||
this.saveVersions();
|
this.saveVersions();
|
||||||
}
|
}
|
||||||
@ -793,7 +767,7 @@ public class FileManager {
|
|||||||
plugin.getLogger().info("versions file created, this should happen only after installing or upgrading the plugin");
|
plugin.getLogger().info("versions file created, this should happen only after installing or upgrading the plugin");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
output = new ObjectOutputStream(new FileOutputStream(versionPath));
|
ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(versionPath));
|
||||||
output.writeObject(versions);
|
output.writeObject(versions);
|
||||||
output.close();
|
output.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -806,9 +780,8 @@ public class FileManager {
|
|||||||
* @return true if the files are loaded correctly, otherwise false
|
* @return true if the files are loaded correctly, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean loadFiles() {
|
public boolean loadFiles() {
|
||||||
boolean result = true;
|
|
||||||
// Load config.yml + add defaults from .jar
|
// Load config.yml + add defaults from .jar
|
||||||
result = result & loadConfigFile();
|
boolean result = loadConfigFile();
|
||||||
// Load default.yml + add defaults from .jar
|
// Load default.yml + add defaults from .jar
|
||||||
result = result & loadDefaultFile();
|
result = result & loadDefaultFile();
|
||||||
// Convert old formats to the latest (object saving to .yml saving)
|
// Convert old formats to the latest (object saving to .yml saving)
|
||||||
@ -832,13 +805,11 @@ public class FileManager {
|
|||||||
File defaultFile = new File(defaultPath);
|
File defaultFile = new File(defaultPath);
|
||||||
// Safe the file from the jar to disk if it does not exist
|
// Safe the file from the jar to disk if it does not exist
|
||||||
if(!defaultFile.exists()) {
|
if(!defaultFile.exists()) {
|
||||||
InputStream input = null;
|
try(
|
||||||
OutputStream output = null;
|
InputStream input = plugin.getResource(AreaShop.defaultFile);
|
||||||
try {
|
OutputStream output = new FileOutputStream(defaultFile)
|
||||||
input = plugin.getResource(AreaShop.defaultFile);
|
) {
|
||||||
output = new FileOutputStream(defaultFile);
|
int read;
|
||||||
|
|
||||||
int read = 0;
|
|
||||||
byte[] bytes = new byte[1024];
|
byte[] bytes = new byte[1024];
|
||||||
while ((read = input.read(bytes)) != -1) {
|
while ((read = input.read(bytes)) != -1) {
|
||||||
output.write(bytes, 0, read);
|
output.write(bytes, 0, read);
|
||||||
@ -847,43 +818,23 @@ public class FileManager {
|
|||||||
output.close();
|
output.close();
|
||||||
plugin.getLogger().info("File with default region settings has been saved, should only happen on first startup");
|
plugin.getLogger().info("File with default region settings has been saved, should only happen on first startup");
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
try {
|
plugin.getLogger().warning("Something went wrong saving the default region settings: " + defaultFile.getAbsolutePath());
|
||||||
input.close();
|
|
||||||
output.close();
|
|
||||||
} catch (IOException e1) {} catch (NullPointerException e2) {}
|
|
||||||
|
|
||||||
plugin.getLogger().warning("Something went wrong saving the default region settings: " + defaultFile.getPath());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Load default.yml from the plugin folder
|
// Load default.yml from the plugin folder, and as backup the default one
|
||||||
InputStreamReader reader = null;
|
try(
|
||||||
try {
|
InputStreamReader custom = new InputStreamReader(new FileInputStream(defaultFile), Charsets.UTF_8);
|
||||||
reader = new InputStreamReader(new FileInputStream(defaultFile), Charsets.UTF_8);
|
InputStreamReader normal = new InputStreamReader(plugin.getResource(AreaShop.defaultFile), Charsets.UTF_8)
|
||||||
} catch (FileNotFoundException e) {
|
) {
|
||||||
result = false;
|
defaultConfig = YamlConfiguration.loadConfiguration(custom);
|
||||||
}
|
|
||||||
if(reader != null) {
|
|
||||||
defaultConfig = YamlConfiguration.loadConfiguration(reader);
|
|
||||||
if(defaultConfig.getKeys(false).size() == 0) {
|
if(defaultConfig.getKeys(false).size() == 0) {
|
||||||
plugin.getLogger().warning("File 'default.yml' is empty, check for errors in the log.");
|
plugin.getLogger().warning("File 'default.yml' is empty, check for errors in the log.");
|
||||||
result = false;
|
result = false;
|
||||||
|
} else {
|
||||||
|
defaultConfig.addDefaults(YamlConfiguration.loadConfiguration(normal));
|
||||||
}
|
}
|
||||||
try {
|
} catch(IOException e) {
|
||||||
reader.close();
|
result = false;
|
||||||
} catch (IOException e) {}
|
|
||||||
}
|
|
||||||
if(result) {
|
|
||||||
// Addding the defaults from the normal file that is inside the jar is disabled, not nice when removing lines for things you don't want
|
|
||||||
InputStream inputStream = plugin.getResource(AreaShop.defaultFile);
|
|
||||||
if(inputStream != null) {
|
|
||||||
reader = new InputStreamReader(inputStream, Charsets.UTF_8);
|
|
||||||
}
|
|
||||||
if(reader != null) {
|
|
||||||
defaultConfig.addDefaults(YamlConfiguration.loadConfiguration(reader));
|
|
||||||
try {
|
|
||||||
reader.close();
|
|
||||||
} catch (IOException e) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -897,61 +848,39 @@ public class FileManager {
|
|||||||
File configFile = new File(configPath);
|
File configFile = new File(configPath);
|
||||||
// Safe the file from the jar to disk if it does not exist
|
// Safe the file from the jar to disk if it does not exist
|
||||||
if(!configFile.exists()) {
|
if(!configFile.exists()) {
|
||||||
InputStream input = null;
|
try(
|
||||||
OutputStream output = null;
|
InputStream input = plugin.getResource(AreaShop.configFile);
|
||||||
try {
|
OutputStream output = new FileOutputStream(configFile)
|
||||||
input = plugin.getResource(AreaShop.configFile);
|
) {
|
||||||
output = new FileOutputStream(configFile);
|
int read;
|
||||||
|
|
||||||
int read = 0;
|
|
||||||
byte[] bytes = new byte[1024];
|
byte[] bytes = new byte[1024];
|
||||||
while ((read = input.read(bytes)) != -1) {
|
while ((read = input.read(bytes)) != -1) {
|
||||||
output.write(bytes, 0, read);
|
output.write(bytes, 0, read);
|
||||||
}
|
}
|
||||||
input.close();
|
|
||||||
output.close();
|
|
||||||
plugin.getLogger().info("Default config file has been saved, should only happen on first startup");
|
plugin.getLogger().info("Default config file has been saved, should only happen on first startup");
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
try {
|
plugin.getLogger().warning("Something went wrong saving the config file: " + configFile.getAbsolutePath());
|
||||||
input.close();
|
|
||||||
output.close();
|
|
||||||
} catch (IOException e1) {} catch (NullPointerException e2) {}
|
|
||||||
plugin.getLogger().warning("Something went wrong saving the config file: " + configFile.getPath());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Load config.yml from the plugin folder
|
// Load config.yml from the plugin folder
|
||||||
InputStreamReader reader = null;
|
try(
|
||||||
try {
|
InputStreamReader custom = new InputStreamReader(new FileInputStream(configFile), Charsets.UTF_8);
|
||||||
reader = new InputStreamReader(new FileInputStream(configFile), Charsets.UTF_8);
|
InputStreamReader normal = new InputStreamReader(plugin.getResource(AreaShop.configFile), Charsets.UTF_8)
|
||||||
} catch (FileNotFoundException e) {
|
) {
|
||||||
result = false;
|
config = YamlConfiguration.loadConfiguration(custom);
|
||||||
}
|
|
||||||
if(reader != null) {
|
|
||||||
config = YamlConfiguration.loadConfiguration(reader);
|
|
||||||
if(config.getKeys(false).size() == 0) {
|
if(config.getKeys(false).size() == 0) {
|
||||||
plugin.getLogger().warning("File 'config.yml' is empty, check for errors in the log.");
|
plugin.getLogger().warning("File 'config.yml' is empty, check for errors in the log.");
|
||||||
result = false;
|
result = false;
|
||||||
}
|
} else {
|
||||||
try {
|
config.addDefaults(YamlConfiguration.loadConfiguration(normal));
|
||||||
reader.close();
|
|
||||||
} catch (IOException e) {}
|
|
||||||
}
|
|
||||||
if(result) {
|
|
||||||
// Add the values from the config.yml file inside of the .jar as defaults
|
|
||||||
InputStream inputStream = plugin.getResource(AreaShop.configFile);
|
|
||||||
if(inputStream != null) {
|
|
||||||
reader = new InputStreamReader(inputStream, Charsets.UTF_8);
|
|
||||||
}
|
|
||||||
if(reader != null) {
|
|
||||||
config.addDefaults(YamlConfiguration.loadConfiguration(reader));
|
|
||||||
try {
|
|
||||||
reader.close();
|
|
||||||
} catch (IOException e) {}
|
|
||||||
}
|
|
||||||
// Set the debug and chatprefix variables
|
// Set the debug and chatprefix variables
|
||||||
plugin.setDebug(this.getConfig().getBoolean("debug"));
|
plugin.setDebug(this.getConfig().getBoolean("debug"));
|
||||||
plugin.setChatprefix(this.getConfig().getString("chatPrefix"));
|
plugin.setChatprefix(this.getConfig().getString("chatPrefix"));
|
||||||
}
|
}
|
||||||
|
} catch(IOException e) {
|
||||||
|
plugin.getLogger().warning("Something went wrong while reading the config.yml file: " + configFile.getAbsolutePath());
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,16 +889,13 @@ public class FileManager {
|
|||||||
*/
|
*/
|
||||||
public void loadGroupsFile() {
|
public void loadGroupsFile() {
|
||||||
File groupFile = new File(groupsPath);
|
File groupFile = new File(groupsPath);
|
||||||
InputStreamReader reader = null;
|
|
||||||
if(groupFile.exists() && groupFile.isFile()) {
|
if(groupFile.exists() && groupFile.isFile()) {
|
||||||
try {
|
try(
|
||||||
reader = new InputStreamReader(new FileInputStream(groupFile), Charsets.UTF_8);
|
InputStreamReader reader = new InputStreamReader(new FileInputStream(groupFile), Charsets.UTF_8)
|
||||||
} catch (FileNotFoundException e) {}
|
) {
|
||||||
if(reader != null) {
|
|
||||||
groupsConfig = YamlConfiguration.loadConfiguration(reader);
|
groupsConfig = YamlConfiguration.loadConfiguration(reader);
|
||||||
try {
|
} catch(IOException e) {
|
||||||
reader.close();
|
plugin.getLogger().warning("Could not load groups.yml file: " + groupFile.getAbsolutePath());
|
||||||
} catch (IOException e) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(groupsConfig == null) {
|
if(groupsConfig == null) {
|
||||||
@ -988,23 +914,27 @@ public class FileManager {
|
|||||||
regions.clear();
|
regions.clear();
|
||||||
File file = new File(regionsPath);
|
File file = new File(regionsPath);
|
||||||
if(!file.exists()) {
|
if(!file.exists()) {
|
||||||
file.mkdirs();
|
if(!file.mkdirs()) {
|
||||||
|
plugin.getLogger().warning("Could not create region files directory: " + file.getAbsolutePath());
|
||||||
|
return;
|
||||||
|
}
|
||||||
plugin.setReady(true);
|
plugin.setReady(true);
|
||||||
} else if(file.isDirectory()) {
|
} else if(file.isDirectory()) {
|
||||||
File[] regionFiles = file.listFiles();
|
File[] regionFiles = file.listFiles();
|
||||||
|
if(regionFiles == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for(File regionFile : regionFiles) {
|
for(File regionFile : regionFiles) {
|
||||||
if(regionFile.exists() && regionFile.isFile()) {
|
if(regionFile.exists() && regionFile.isFile()) {
|
||||||
// Load the region file from disk in UTF8 mode
|
// Load the region file from disk in UTF8 mode
|
||||||
InputStreamReader reader = null;
|
YamlConfiguration config;
|
||||||
YamlConfiguration config = null;
|
try(
|
||||||
try {
|
InputStreamReader reader = new InputStreamReader(new FileInputStream(regionFile), Charsets.UTF_8)
|
||||||
reader = new InputStreamReader(new FileInputStream(regionFile), Charsets.UTF_8);
|
) {
|
||||||
} catch (FileNotFoundException e) {}
|
|
||||||
if(reader != null) {
|
|
||||||
config = YamlConfiguration.loadConfiguration(reader);
|
config = YamlConfiguration.loadConfiguration(reader);
|
||||||
try {
|
} catch(IOException e) {
|
||||||
reader.close();
|
plugin.getLogger().warning("Something went wrong reading region file: " + regionFile.getAbsolutePath());
|
||||||
} catch (IOException e) {}
|
continue;
|
||||||
}
|
}
|
||||||
// Construct the correct type of region
|
// Construct the correct type of region
|
||||||
if(RegionType.RENT.getValue().equals(config.getString("general.type"))) {
|
if(RegionType.RENT.getValue().equals(config.getString("general.type"))) {
|
||||||
@ -1020,9 +950,9 @@ public class FileManager {
|
|||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
List<GeneralRegion> noWorld = new ArrayList<GeneralRegion>();
|
List<GeneralRegion> noWorld = new ArrayList<>();
|
||||||
List<GeneralRegion> noRegion = new ArrayList<GeneralRegion>();
|
List<GeneralRegion> noRegion = new ArrayList<>();
|
||||||
List<GeneralRegion> incorrectDuration = new ArrayList<GeneralRegion>();
|
List<GeneralRegion> incorrectDuration = new ArrayList<>();
|
||||||
for(GeneralRegion region : AreaShop.getInstance().getFileManager().getRegions()) {
|
for(GeneralRegion region : AreaShop.getInstance().getFileManager().getRegions()) {
|
||||||
// Add broken regions to a list
|
// Add broken regions to a list
|
||||||
if(region != null) {
|
if(region != null) {
|
||||||
@ -1039,7 +969,7 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
// All files are loaded, print possible problems to the console
|
// All files are loaded, print possible problems to the console
|
||||||
if(!noRegion.isEmpty()) {
|
if(!noRegion.isEmpty()) {
|
||||||
List<String> noRegionNames = new ArrayList<String>();
|
List<String> noRegionNames = new ArrayList<>();
|
||||||
for(GeneralRegion region : noRegion) {
|
for(GeneralRegion region : noRegion) {
|
||||||
noRegionNames.add(region.getName());
|
noRegionNames.add(region.getName());
|
||||||
}
|
}
|
||||||
@ -1048,7 +978,7 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
boolean noWorldRegions = !noWorld.isEmpty();
|
boolean noWorldRegions = !noWorld.isEmpty();
|
||||||
while(!noWorld.isEmpty()) {
|
while(!noWorld.isEmpty()) {
|
||||||
List<GeneralRegion> toDisplay = new ArrayList<GeneralRegion>();
|
List<GeneralRegion> toDisplay = new ArrayList<>();
|
||||||
String missingWorld = noWorld.get(0).getWorldName();
|
String missingWorld = noWorld.get(0).getWorldName();
|
||||||
toDisplay.add(noWorld.get(0));
|
toDisplay.add(noWorld.get(0));
|
||||||
for(int i=1; i<noWorld.size(); i++) {
|
for(int i=1; i<noWorld.size(); i++) {
|
||||||
@ -1056,7 +986,7 @@ public class FileManager {
|
|||||||
toDisplay.add(noWorld.get(i));
|
toDisplay.add(noWorld.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<String> noWorldNames = new ArrayList<String>();
|
List<String> noWorldNames = new ArrayList<>();
|
||||||
for(GeneralRegion region : noRegion) {
|
for(GeneralRegion region : noRegion) {
|
||||||
noWorldNames.add(region.getName());
|
noWorldNames.add(region.getName());
|
||||||
}
|
}
|
||||||
@ -1067,7 +997,7 @@ public class FileManager {
|
|||||||
plugin.getLogger().warning("Remove these regions from AreaShop with '/as del' or load the world(s) on the server again.");
|
plugin.getLogger().warning("Remove these regions from AreaShop with '/as del' or load the world(s) on the server again.");
|
||||||
}
|
}
|
||||||
if(!incorrectDuration.isEmpty()) {
|
if(!incorrectDuration.isEmpty()) {
|
||||||
List<String> incorrectDurationNames = new ArrayList<String>();
|
List<String> incorrectDurationNames = new ArrayList<>();
|
||||||
for(GeneralRegion region : incorrectDuration) {
|
for(GeneralRegion region : incorrectDuration) {
|
||||||
incorrectDurationNames.add(region.getName());
|
incorrectDurationNames.add(region.getName());
|
||||||
}
|
}
|
||||||
@ -1105,8 +1035,8 @@ public class FileManager {
|
|||||||
boolean buyFileFound = false, rentFileFound = false;
|
boolean buyFileFound = false, rentFileFound = false;
|
||||||
if(rentFile.exists()) {
|
if(rentFile.exists()) {
|
||||||
rentFileFound = true;
|
rentFileFound = true;
|
||||||
if(!oldFolderFile.exists()) {
|
if(!oldFolderFile.exists() & !oldFolderFile.mkdirs()) {
|
||||||
oldFolderFile.mkdirs();
|
plugin.getLogger().warning("Could not create directory: " + oldFolderFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(versions.get("rents") == null) {
|
if(versions.get("rents") == null) {
|
||||||
@ -1124,8 +1054,12 @@ public class FileManager {
|
|||||||
// Delete the file if it is totally wrong
|
// Delete the file if it is totally wrong
|
||||||
if(rents == null) {
|
if(rents == null) {
|
||||||
try {
|
try {
|
||||||
rentFile.delete();
|
if(!rentFile.delete()) {
|
||||||
} catch(Exception e) {}
|
plugin.getLogger().warning("Could not delete file: " + rentFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
plugin.getLogger().warning("Could not delete file: " + rentFile.getAbsolutePath());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Move old file
|
// Move old file
|
||||||
try {
|
try {
|
||||||
@ -1135,25 +1069,25 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
// Check if conversion is needed
|
// Check if conversion is needed
|
||||||
if(versions.get("rents") < 1) {
|
if(versions.get("rents") < 1) {
|
||||||
/* Upgrade the rent to the latest version */
|
// Upgrade the rent to the latest version
|
||||||
if(versions.get("rents") < 0) {
|
if(versions.get("rents") < 0) {
|
||||||
for(String rentName : rents.keySet()) {
|
for(String rentName : rents.keySet()) {
|
||||||
HashMap<String,String> rent = rents.get(rentName);
|
HashMap<String,String> rent = rents.get(rentName);
|
||||||
/* Save the rentName in the hashmap and use a small caps rentName as key */
|
// Save the rentName in the hashmap and use a small caps rentName as key
|
||||||
if(rent.get("name") == null) {
|
if(rent.get("name") == null) {
|
||||||
rent.put("name", rentName);
|
rent.put("name", rentName);
|
||||||
rents.remove(rentName);
|
rents.remove(rentName);
|
||||||
rents.put(rentName.toLowerCase(), rent);
|
rents.put(rentName.toLowerCase(), rent);
|
||||||
}
|
}
|
||||||
/* Save the default setting for region restoring */
|
// Save the default setting for region restoring
|
||||||
if(rent.get("restore") == null) {
|
if(rent.get("restore") == null) {
|
||||||
rent.put("restore", "general");
|
rent.put("restore", "general");
|
||||||
}
|
}
|
||||||
/* Save the default setting for the region restore profile */
|
// Save the default setting for the region restore profile
|
||||||
if(rent.get("profile") == null) {
|
if(rent.get("profile") == null) {
|
||||||
rent.put("profile", "default");
|
rent.put("profile", "default");
|
||||||
}
|
}
|
||||||
/* Change to version 0 */
|
// Change to version 0
|
||||||
versions.put("rents", 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)");
|
plugin.getLogger().info(" Updated version of '" + buyPath + "' from -1 to 0 (switch to using lowercase region names, adding default schematic enabling and profile)");
|
||||||
@ -1167,7 +1101,7 @@ public class FileManager {
|
|||||||
rent.put("playeruuid", offlinePlayer.getUniqueId().toString());
|
rent.put("playeruuid", offlinePlayer.getUniqueId().toString());
|
||||||
rent.remove("player");
|
rent.remove("player");
|
||||||
}
|
}
|
||||||
/* Change version to 1 */
|
// Change version to 1
|
||||||
versions.put("rents", 1);
|
versions.put("rents", 1);
|
||||||
}
|
}
|
||||||
plugin.getLogger().info(" Updated version of '" + rentPath + "' from 0 to 1 (switch to UUID's for player identification)");
|
plugin.getLogger().info(" Updated version of '" + rentPath + "' from 0 to 1 (switch to UUID's for player identification)");
|
||||||
@ -1175,8 +1109,9 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
// Save rents to new format
|
// Save rents to new format
|
||||||
File regionsFile = new File(regionsPath);
|
File regionsFile = new File(regionsPath);
|
||||||
if(!regionsFile.exists()) {
|
if(!regionsFile.exists() & !regionsFile.mkdirs()) {
|
||||||
regionsFile.mkdirs();
|
plugin.getLogger().warning("Could not create directory: " + regionsFile.getAbsolutePath());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(HashMap<String, String> rent : rents.values()) {
|
for(HashMap<String, String> rent : rents.values()) {
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
@ -1224,8 +1159,9 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
if(buyFile.exists()) {
|
if(buyFile.exists()) {
|
||||||
buyFileFound = true;
|
buyFileFound = true;
|
||||||
if(!oldFolderFile.exists()) {
|
if(!oldFolderFile.exists() & !oldFolderFile.mkdirs()) {
|
||||||
oldFolderFile.mkdirs();
|
plugin.getLogger().warning("Could not create directory: " + oldFolderFile.getAbsolutePath());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(versions.get("buys") == null) {
|
if(versions.get("buys") == null) {
|
||||||
@ -1243,8 +1179,12 @@ public class FileManager {
|
|||||||
// Delete the file if it is totally wrong
|
// Delete the file if it is totally wrong
|
||||||
if(buys == null) {
|
if(buys == null) {
|
||||||
try {
|
try {
|
||||||
buyFile.delete();
|
if(!buyFile.delete()) {
|
||||||
} catch(Exception e) {}
|
plugin.getLogger().warning("Could not delete file: " + buyFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
plugin.getLogger().warning("Could not delete file: " + buyFile.getAbsolutePath());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Backup current file
|
// Backup current file
|
||||||
try {
|
try {
|
||||||
@ -1254,25 +1194,25 @@ public class FileManager {
|
|||||||
}
|
}
|
||||||
// Check if conversion is needed
|
// Check if conversion is needed
|
||||||
if(versions.get("buys") < 1) {
|
if(versions.get("buys") < 1) {
|
||||||
/* Upgrade the buy to the latest version */
|
// Upgrade the buy to the latest version
|
||||||
if(versions.get("buys") < 0) {
|
if(versions.get("buys") < 0) {
|
||||||
for(String buyName : buys.keySet()) {
|
for(String buyName : buys.keySet()) {
|
||||||
HashMap<String,String> buy = buys.get(buyName);
|
HashMap<String,String> buy = buys.get(buyName);
|
||||||
/* Save the buyName in the hashmap and use a small caps buyName as key */
|
// Save the buyName in the hashmap and use a small caps buyName as key
|
||||||
if(buy.get("name") == null) {
|
if(buy.get("name") == null) {
|
||||||
buy.put("name", buyName);
|
buy.put("name", buyName);
|
||||||
buys.remove(buyName);
|
buys.remove(buyName);
|
||||||
buys.put(buyName.toLowerCase(), buy);
|
buys.put(buyName.toLowerCase(), buy);
|
||||||
}
|
}
|
||||||
/* Save the default setting for region restoring */
|
// Save the default setting for region restoring
|
||||||
if(buy.get("restore") == null) {
|
if(buy.get("restore") == null) {
|
||||||
buy.put("restore", "general");
|
buy.put("restore", "general");
|
||||||
}
|
}
|
||||||
/* Save the default setting for the region restore profile */
|
// Save the default setting for the region restore profile
|
||||||
if(buy.get("profile") == null) {
|
if(buy.get("profile") == null) {
|
||||||
buy.put("profile", "default");
|
buy.put("profile", "default");
|
||||||
}
|
}
|
||||||
/* Change to version 0 */
|
// Change to version 0
|
||||||
versions.put("buys", 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)");
|
plugin.getLogger().info(" Updated version of '" + buyPath + "' from -1 to 0 (switch to using lowercase region names, adding default schematic enabling and profile)");
|
||||||
@ -1286,7 +1226,7 @@ public class FileManager {
|
|||||||
buy.put("playeruuid", offlinePlayer.getUniqueId().toString());
|
buy.put("playeruuid", offlinePlayer.getUniqueId().toString());
|
||||||
buy.remove("player");
|
buy.remove("player");
|
||||||
}
|
}
|
||||||
/* Change version to 1 */
|
// Change version to 1
|
||||||
versions.put("buys", 1);
|
versions.put("buys", 1);
|
||||||
}
|
}
|
||||||
plugin.getLogger().info(" Updated version of '" + buyPath + "' from 0 to 1 (switch to UUID's for player identification)");
|
plugin.getLogger().info(" Updated version of '" + buyPath + "' from 0 to 1 (switch to UUID's for player identification)");
|
||||||
@ -1295,8 +1235,8 @@ public class FileManager {
|
|||||||
|
|
||||||
// Save buys to new format
|
// Save buys to new format
|
||||||
File regionsFile = new File(regionsPath);
|
File regionsFile = new File(regionsPath);
|
||||||
if(!regionsFile.exists()) {
|
if(!regionsFile.exists() & !regionsFile.mkdirs()) {
|
||||||
regionsFile.mkdirs();
|
plugin.getLogger().warning("Could not create directory: " + regionsFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
for(HashMap<String, String> buy : buys.values()) {
|
for(HashMap<String, String> buy : buys.values()) {
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
@ -1342,14 +1282,20 @@ public class FileManager {
|
|||||||
// Separate try-catch blocks to try them all individually (don't stop after 1 has failed)
|
// Separate try-catch blocks to try them all individually (don't stop after 1 has failed)
|
||||||
try {
|
try {
|
||||||
Files.move(new File(rentPath + ".old"), new File(oldFolderPath + "rents.old"));
|
Files.move(new File(rentPath + ".old"), new File(oldFolderPath + "rents.old"));
|
||||||
} catch (Exception e) {}
|
} catch(Exception e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Files.move(new File(buyPath + ".old"), new File(oldFolderPath + "buys.old"));
|
Files.move(new File(buyPath + ".old"), new File(oldFolderPath + "buys.old"));
|
||||||
} catch (Exception e) {}
|
} catch(Exception e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
if(buyFileFound || rentFileFound) {
|
if(buyFileFound || rentFileFound) {
|
||||||
try {
|
try {
|
||||||
Files.move(new File(plugin.getDataFolder() + File.separator + "config.yml"), new File(oldFolderPath + "config.yml"));
|
Files.move(new File(plugin.getDataFolder() + File.separator + "config.yml"), new File(oldFolderPath + "config.yml"));
|
||||||
} catch (Exception e) {}
|
} catch(Exception e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Update versions file to 2
|
// Update versions file to 2
|
||||||
versions.put(AreaShop.versionFiles, 2);
|
versions.put(AreaShop.versionFiles, 2);
|
||||||
|
@ -1,24 +1,15 @@
|
|||||||
package nl.evolutioncoding.areashop.managers;
|
package nl.evolutioncoding.areashop.managers;
|
||||||
|
|
||||||
import java.io.File;
|
import com.google.common.base.Charsets;
|
||||||
import java.io.FileInputStream;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import java.io.FileNotFoundException;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
import java.io.FileOutputStream;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.*;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
|
|
||||||
public class LanguageManager {
|
public class LanguageManager {
|
||||||
private AreaShop plugin = null;
|
private AreaShop plugin = null;
|
||||||
private String languages[] = {"EN", "NL", "DE", "FR", "FI", "PL", "ZH_TW"};
|
private String languages[] = {"EN", "NL", "DE", "FR", "FI", "PL", "ZH_TW"};
|
||||||
@ -49,7 +40,10 @@ public class LanguageManager {
|
|||||||
File langFolder;
|
File langFolder;
|
||||||
langFolder = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder);
|
langFolder = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder);
|
||||||
if(!langFolder.exists()) {
|
if(!langFolder.exists()) {
|
||||||
langFolder.mkdirs();
|
if(!langFolder.mkdirs()) {
|
||||||
|
plugin.getLogger().warning("Could not create language directory: " + langFolder.getAbsolutePath());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the language files, overwrites if a file already exists */
|
/* Create the language files, overwrites if a file already exists */
|
||||||
@ -57,19 +51,17 @@ public class LanguageManager {
|
|||||||
/* files would not be used, when translating your own use another */
|
/* files would not be used, when translating your own use another */
|
||||||
/* file name as the default */
|
/* file name as the default */
|
||||||
File langFile;
|
File langFile;
|
||||||
for(int i=0; i<languages.length; i++) {
|
for(String language : languages) {
|
||||||
langFile = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + File.separator + languages[i] + ".yml");
|
langFile = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + File.separator + language + ".yml");
|
||||||
InputStream input = null;
|
try(
|
||||||
OutputStream output = null;
|
InputStream input = plugin.getResource(AreaShop.languageFolder + "/" + language + ".yml");
|
||||||
try {
|
OutputStream output = new FileOutputStream(langFile)
|
||||||
input = plugin.getResource(AreaShop.languageFolder + "/" + languages[i] + ".yml");
|
) {
|
||||||
if(input == null) {
|
if(input == null) {
|
||||||
plugin.getLogger().warning("Could not save default language to the '" + AreaShop.languageFolder + "' folder: " + languages[i] + ".yml");
|
plugin.getLogger().warning("Could not save default language to the '" + AreaShop.languageFolder + "' folder: " + language + ".yml");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
output = new FileOutputStream(langFile);
|
int read;
|
||||||
|
|
||||||
int read = 0;
|
|
||||||
byte[] bytes = new byte[1024];
|
byte[] bytes = new byte[1024];
|
||||||
while ((read = input.read(bytes)) != -1) {
|
while ((read = input.read(bytes)) != -1) {
|
||||||
output.write(bytes, 0, read);
|
output.write(bytes, 0, read);
|
||||||
@ -77,11 +69,6 @@ public class LanguageManager {
|
|||||||
input.close();
|
input.close();
|
||||||
output.close();
|
output.close();
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
try {
|
|
||||||
input.close();
|
|
||||||
output.close();
|
|
||||||
} catch (IOException e1) {} catch (NullPointerException e2) {}
|
|
||||||
|
|
||||||
plugin.getLogger().warning("Something went wrong saving a default language file: " + langFile.getPath());
|
plugin.getLogger().warning("Something went wrong saving a default language file: " + langFile.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,40 +83,41 @@ public class LanguageManager {
|
|||||||
Set<String> set;
|
Set<String> set;
|
||||||
YamlConfiguration ymlFile;
|
YamlConfiguration ymlFile;
|
||||||
|
|
||||||
/* Save the current language file to the HashMap */
|
// Save the current language file to the HashMap
|
||||||
currentLanguage = new HashMap<String, String>();
|
currentLanguage = new HashMap<>();
|
||||||
File file = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + File.separator + plugin.getConfig().getString("language") + ".yml");
|
File file = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + File.separator + plugin.getConfig().getString("language") + ".yml");
|
||||||
InputStreamReader reader = null;
|
|
||||||
try {
|
try(
|
||||||
reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8);
|
InputStreamReader reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8)
|
||||||
} catch (FileNotFoundException e1) {}
|
) {
|
||||||
if(reader != null) {
|
|
||||||
ymlFile = YamlConfiguration.loadConfiguration(reader);
|
ymlFile = YamlConfiguration.loadConfiguration(reader);
|
||||||
map = ymlFile.getValues(true);
|
map = ymlFile.getValues(true);
|
||||||
set = map.keySet();
|
set = map.keySet();
|
||||||
try {
|
|
||||||
for(String key : set) {
|
for(String key : set) {
|
||||||
|
if(map.get(key) instanceof String) {
|
||||||
currentLanguage.put(key, (String)map.get(key));
|
currentLanguage.put(key, (String)map.get(key));
|
||||||
}
|
}
|
||||||
} catch(ClassCastException e) {}
|
}
|
||||||
|
} catch(IOException e) {
|
||||||
|
plugin.getLogger().warning("Could not load set language file: " + file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save the default strings to the HashMap */
|
// Save the default strings to the HashMap
|
||||||
defaultLanguage = new HashMap<String, String>();
|
defaultLanguage = new HashMap<>();
|
||||||
File standard = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + "/" + languages[0]+ ".yml");
|
File standard = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + "/" + languages[0]+ ".yml");
|
||||||
InputStreamReader reader2 = null;
|
try(
|
||||||
try {
|
InputStreamReader reader = new InputStreamReader(new FileInputStream(standard), Charsets.UTF_8)
|
||||||
reader2 = new InputStreamReader(new FileInputStream(standard), Charsets.UTF_8);
|
) {
|
||||||
} catch (FileNotFoundException e1) {}
|
ymlFile = YamlConfiguration.loadConfiguration(reader);
|
||||||
if(reader2 != null) {
|
|
||||||
ymlFile = YamlConfiguration.loadConfiguration(reader2);
|
|
||||||
map = ymlFile.getValues(true);
|
map = ymlFile.getValues(true);
|
||||||
set = map.keySet();
|
set = map.keySet();
|
||||||
try {
|
|
||||||
for(String key : set) {
|
for(String key : set) {
|
||||||
|
if(map.get(key) instanceof String) {
|
||||||
defaultLanguage.put(key, (String)map.get(key));
|
defaultLanguage.put(key, (String)map.get(key));
|
||||||
}
|
}
|
||||||
} catch(ClassCastException e) {}
|
}
|
||||||
|
} catch(IOException e) {
|
||||||
|
plugin.getLogger().warning("Could not load default language file: " + file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,9 +128,9 @@ public class LanguageManager {
|
|||||||
* @return String The language string specified with the key
|
* @return String The language string specified with the key
|
||||||
*/
|
*/
|
||||||
public String getLang(String key, Object... params) {
|
public String getLang(String key, Object... params) {
|
||||||
String result = null;
|
String result;
|
||||||
|
|
||||||
/* Get the language string */
|
// Get the language string
|
||||||
if(currentLanguage.containsKey(key)) {
|
if(currentLanguage.containsKey(key)) {
|
||||||
result = currentLanguage.get(key);
|
result = currentLanguage.get(key);
|
||||||
} else {
|
} else {
|
||||||
@ -152,14 +140,14 @@ public class LanguageManager {
|
|||||||
if(result == null) {
|
if(result == null) {
|
||||||
plugin.getLogger().info("Wrong key for getting translation: " + key + ", please contact the author about this");
|
plugin.getLogger().info("Wrong key for getting translation: " + key + ", please contact the author about this");
|
||||||
} else {
|
} else {
|
||||||
/* Replace all tags like %0% and if given a GeneralRegion apply all replacements */
|
// Replace all tags like %0% and if given a GeneralRegion apply all replacements
|
||||||
int number=0;
|
int number=0;
|
||||||
for (int i=0; i<params.length; i++) {
|
for(Object param : params) {
|
||||||
if(params[i] != null) {
|
if(param != null) {
|
||||||
if(params[i] instanceof GeneralRegion) {
|
if(param instanceof GeneralRegion) {
|
||||||
result = ((GeneralRegion)params[i]).applyAllReplacements(result);
|
result = ((GeneralRegion)param).applyAllReplacements(result);
|
||||||
} else {
|
} else {
|
||||||
result = result.replace("%" + number + "%", params[i].toString());
|
result = result.replace("%" + number + "%", param.toString());
|
||||||
number++;
|
number++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
package nl.evolutioncoding.areashop.managers;
|
package nl.evolutioncoding.areashop.managers;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
import nl.evolutioncoding.areashop.regions.GeneralRegion;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -26,6 +18,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import org.bukkit.material.Sign;
|
import org.bukkit.material.Sign;
|
||||||
import org.bukkit.util.BlockIterator;
|
import org.bukkit.util.BlockIterator;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class SignLinkerManager implements Listener {
|
public class SignLinkerManager implements Listener {
|
||||||
private AreaShop plugin = null;
|
private AreaShop plugin = null;
|
||||||
private Map<UUID, SignLinker> signLinkers;
|
private Map<UUID, SignLinker> signLinkers;
|
||||||
@ -33,7 +27,7 @@ public class SignLinkerManager implements Listener {
|
|||||||
|
|
||||||
public SignLinkerManager(AreaShop plugin) {
|
public SignLinkerManager(AreaShop plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
signLinkers = new HashMap<UUID, SignLinker>();
|
signLinkers = new HashMap<>();
|
||||||
eventsRegistered = false;
|
eventsRegistered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +85,7 @@ public class SignLinkerManager implements Listener {
|
|||||||
linker.setRegion(regions.get(0));
|
linker.setRegion(regions.get(0));
|
||||||
return;
|
return;
|
||||||
} else if(regions.size() > 1) {
|
} else if(regions.size() > 1) {
|
||||||
Set<String> names = new HashSet<String>();
|
Set<String> names = new HashSet<>();
|
||||||
for(GeneralRegion region : regions) {
|
for(GeneralRegion region : regions) {
|
||||||
names.add(region.getName());
|
names.add(region.getName());
|
||||||
}
|
}
|
||||||
@ -102,7 +96,6 @@ public class SignLinkerManager implements Listener {
|
|||||||
}
|
}
|
||||||
// No regions found within the maximum range
|
// No regions found within the maximum range
|
||||||
plugin.message(player, "linksigns-noRegions");
|
plugin.message(player, "linksigns-noRegions");
|
||||||
return;
|
|
||||||
} else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
} else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
Block block = null;
|
Block block = null;
|
||||||
BlockIterator blockIterator = new BlockIterator(player, 100);
|
BlockIterator blockIterator = new BlockIterator(player, 100);
|
||||||
@ -124,9 +117,7 @@ public class SignLinkerManager implements Listener {
|
|||||||
}
|
}
|
||||||
Sign sign = (Sign)block.getState().getData();
|
Sign sign = (Sign)block.getState().getData();
|
||||||
linker.setSign(block.getLocation(), block.getType(), sign.getFacing());
|
linker.setSign(block.getLocation(), block.getType(), sign.getFacing());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +157,7 @@ public class SignLinkerManager implements Listener {
|
|||||||
if(!isComplete()) {
|
if(!isComplete()) {
|
||||||
plugin.message(linker, "linksigns-regionFound", region);
|
plugin.message(linker, "linksigns-regionFound", region);
|
||||||
}
|
}
|
||||||
finalize();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSign(Location location, Material type, BlockFace facing) {
|
public void setSign(Location location, Material type, BlockFace facing) {
|
||||||
@ -177,10 +168,10 @@ public class SignLinkerManager implements Listener {
|
|||||||
if(!isComplete()) {
|
if(!isComplete()) {
|
||||||
plugin.message(linker, "linksigns-signFound", location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
plugin.message(linker, "linksigns-signFound", location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
}
|
}
|
||||||
finalize();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finalize() {
|
public void finish() {
|
||||||
if(isComplete()) {
|
if(isComplete()) {
|
||||||
region.addSign(location, type, facing, profile);
|
region.addSign(location, type, facing, profile);
|
||||||
if(profile == null) {
|
if(profile == null) {
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
package nl.evolutioncoding.areashop.regions;
|
package nl.evolutioncoding.areashop.regions;
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.EconomyResponse;
|
import net.milkbowl.vault.economy.EconomyResponse;
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BuyRegion extends GeneralRegion {
|
public class BuyRegion extends GeneralRegion {
|
||||||
|
|
||||||
public BuyRegion(AreaShop plugin, YamlConfiguration config) {
|
public BuyRegion(AreaShop plugin, YamlConfiguration config) {
|
||||||
@ -48,7 +47,9 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
if(buyer != null) {
|
if(buyer != null) {
|
||||||
try {
|
try {
|
||||||
return UUID.fromString(buyer);
|
return UUID.fromString(buyer);
|
||||||
} catch(IllegalArgumentException e) {}
|
} catch(IllegalArgumentException e) {
|
||||||
|
// Incorrect UUID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -59,19 +60,11 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
* @return true if this player owns this region, otherwise false
|
* @return true if this player owns this region, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean isBuyer(Player player) {
|
public boolean isBuyer(Player player) {
|
||||||
if(player == null) {
|
return player != null && isBuyer(player.getUniqueId());
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return isBuyer(player.getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public boolean isBuyer(UUID player) {
|
public boolean isBuyer(UUID player) {
|
||||||
UUID buyer = getBuyer();
|
UUID buyer = getBuyer();
|
||||||
if(buyer == null || player == null) {
|
return !(buyer == null || player == null) && buyer.equals(player);
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return buyer.equals(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,7 +146,7 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the price of the region
|
* Change the price of the region
|
||||||
* @param price
|
* @param price The price to set this region to
|
||||||
*/
|
*/
|
||||||
public void setPrice(double price) {
|
public void setPrice(double price) {
|
||||||
setSetting("buy.price", price);
|
setSetting("buy.price", price);
|
||||||
@ -210,7 +203,7 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
@Override
|
@Override
|
||||||
public HashMap<String, Object> getSpecificReplacements() {
|
public HashMap<String, Object> getSpecificReplacements() {
|
||||||
// Fill the replacements map with things specific to a BuyRegion
|
// Fill the replacements map with things specific to a BuyRegion
|
||||||
HashMap<String, Object> result = new HashMap<String, Object>();
|
HashMap<String, Object> result = new HashMap<>();
|
||||||
result.put(AreaShop.tagPrice, getFormattedPrice());
|
result.put(AreaShop.tagPrice, getFormattedPrice());
|
||||||
result.put(AreaShop.tagRawPrice, getPrice());
|
result.put(AreaShop.tagRawPrice, getPrice());
|
||||||
result.put(AreaShop.tagPlayerName, getPlayerName());
|
result.put(AreaShop.tagPlayerName, getPlayerName());
|
||||||
@ -252,7 +245,7 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public boolean buy(Player player) {
|
public boolean buy(Player player) {
|
||||||
/* Check if the player has permission */
|
// Check if the player has permission
|
||||||
if(player.hasPermission("areashop.buy")) {
|
if(player.hasPermission("areashop.buy")) {
|
||||||
if(plugin.getEconomy() == null) {
|
if(plugin.getEconomy() == null) {
|
||||||
plugin.message(player, "general-noEconomy");
|
plugin.message(player, "general-noEconomy");
|
||||||
@ -305,13 +298,13 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the player has enough money */
|
// Check if the player has enough money
|
||||||
if((!isResell && plugin.getEconomy().has(player, getWorldName(), getPrice())) || (isResell && plugin.getEconomy().has(player, getWorldName(), getResellPrice()))) {
|
if((!isResell && plugin.getEconomy().has(player, getWorldName(), getPrice())) || (isResell && plugin.getEconomy().has(player, getWorldName(), getResellPrice()))) {
|
||||||
UUID oldOwner = getBuyer();
|
UUID oldOwner = getBuyer();
|
||||||
if(isResell && oldOwner != null) {
|
if(isResell && oldOwner != null) {
|
||||||
clearFriends();
|
clearFriends();
|
||||||
double resellPrice = getResellPrice();
|
double resellPrice = getResellPrice();
|
||||||
/* Transfer the money to the previous owner */
|
// Transfer the money to the previous owner
|
||||||
EconomyResponse r = plugin.getEconomy().withdrawPlayer(player, getWorldName(), getResellPrice());
|
EconomyResponse r = plugin.getEconomy().withdrawPlayer(player, getWorldName(), getResellPrice());
|
||||||
if(!r.transactionSuccess()) {
|
if(!r.transactionSuccess()) {
|
||||||
plugin.message(player, "buy-payError");
|
plugin.message(player, "buy-payError");
|
||||||
@ -322,11 +315,12 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
String oldOwnerName = getPlayerName();
|
String oldOwnerName = getPlayerName();
|
||||||
if(oldOwnerPlayer != null && oldOwnerPlayer.getName() != null) {
|
if(oldOwnerPlayer != null && oldOwnerPlayer.getName() != null) {
|
||||||
r = plugin.getEconomy().depositPlayer(oldOwnerPlayer, getWorldName(), getResellPrice());
|
r = plugin.getEconomy().depositPlayer(oldOwnerPlayer, getWorldName(), getResellPrice());
|
||||||
|
oldOwnerName = oldOwnerPlayer.getName();
|
||||||
} else if (oldOwnerName != null) {
|
} else if (oldOwnerName != null) {
|
||||||
r = plugin.getEconomy().depositPlayer(oldOwnerName, getWorldName(), getResellPrice());
|
r = plugin.getEconomy().depositPlayer(oldOwnerName, getWorldName(), getResellPrice());
|
||||||
}
|
}
|
||||||
if(r == null || !r.transactionSuccess()) {
|
if(r == null || !r.transactionSuccess()) {
|
||||||
plugin.getLogger().warning("Something went wrong with paying '" + oldOwnerPlayer.getName() + "' " + getFormattedPrice() + " for his resell of region " + getName() + " to " + player.getName());
|
plugin.getLogger().warning("Something went wrong with paying '" + oldOwnerName + "' " + getFormattedPrice() + " for his resell of region " + getName() + " to " + player.getName());
|
||||||
}
|
}
|
||||||
// Resell is done, disable that now
|
// Resell is done, disable that now
|
||||||
disableReselling();
|
disableReselling();
|
||||||
@ -342,12 +336,12 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
updateRegionFlags();
|
updateRegionFlags();
|
||||||
|
|
||||||
// Send message to the player
|
// Send message to the player
|
||||||
plugin.message(player, "buy-successResale", getName(), oldOwnerPlayer.getName());
|
plugin.message(player, "buy-successResale", getName(), oldOwnerName);
|
||||||
Player seller = Bukkit.getPlayer(oldOwner);
|
Player seller = Bukkit.getPlayer(oldOwner);
|
||||||
if(seller != null) {
|
if(seller != null) {
|
||||||
plugin.message(player, "buy-successSeller", getName(), getPlayerName(), resellPrice);
|
plugin.message(player, "buy-successSeller", getName(), getPlayerName(), resellPrice);
|
||||||
}
|
}
|
||||||
AreaShop.debug(player.getName() + " has bought region " + getName() + " for " + getFormattedPrice() + " from " + oldOwnerPlayer.getName());
|
AreaShop.debug(player.getName() + " has bought region " + getName() + " for " + getFormattedPrice() + " from " + oldOwnerName);
|
||||||
// Run commands
|
// Run commands
|
||||||
this.runEventCommands(RegionEvent.RESELL, false);
|
this.runEventCommands(RegionEvent.RESELL, false);
|
||||||
} else {
|
} else {
|
||||||
@ -363,7 +357,6 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
landlordPlayer = Bukkit.getOfflinePlayer(getLandlord());
|
landlordPlayer = Bukkit.getOfflinePlayer(getLandlord());
|
||||||
}
|
}
|
||||||
String landlordName = getLandlordName();
|
String landlordName = getLandlordName();
|
||||||
r = null;
|
|
||||||
if(landlordName != null) {
|
if(landlordName != null) {
|
||||||
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
||||||
r = plugin.getEconomy().depositPlayer(landlordPlayer, getWorldName(), getPrice());
|
r = plugin.getEconomy().depositPlayer(landlordPlayer, getWorldName(), getPrice());
|
||||||
@ -394,8 +387,8 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
/* Player has not enough money */
|
// Player has not enough money
|
||||||
String requiredMoney = "";
|
String requiredMoney;
|
||||||
if(isResell) {
|
if(isResell) {
|
||||||
requiredMoney = getFormattedResellPrice();
|
requiredMoney = getFormattedResellPrice();
|
||||||
} else {
|
} else {
|
||||||
@ -418,10 +411,13 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sell a buyed region, get part of the money back
|
* Sell a buyed region, get part of the money back
|
||||||
* @param regionName
|
* @param giveMoneyBack true if the player should be given money back, otherwise false
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void sell(boolean giveMoneyBack) {
|
public void sell(boolean giveMoneyBack) {
|
||||||
|
if(plugin.getEconomy() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Run commands
|
// Run commands
|
||||||
this.runEventCommands(RegionEvent.SOLD, true);
|
this.runEventCommands(RegionEvent.SOLD, true);
|
||||||
|
|
||||||
@ -435,7 +431,7 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
landlordPlayer = Bukkit.getOfflinePlayer(getLandlord());
|
landlordPlayer = Bukkit.getOfflinePlayer(getLandlord());
|
||||||
}
|
}
|
||||||
String landlordName = getLandlordName();
|
String landlordName = getLandlordName();
|
||||||
EconomyResponse r = null;
|
EconomyResponse r;
|
||||||
if(landlordName != null) {
|
if(landlordName != null) {
|
||||||
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
||||||
r = plugin.getEconomy().withdrawPlayer(landlordPlayer, getWorldName(), moneyBack);
|
r = plugin.getEconomy().withdrawPlayer(landlordPlayer, getWorldName(), moneyBack);
|
||||||
@ -453,7 +449,7 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
EconomyResponse response = null;
|
EconomyResponse response = null;
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
try {
|
try {
|
||||||
if(player != null && player.getName() != null) {
|
if(player.getName() != null) {
|
||||||
response = plugin.getEconomy().depositPlayer(player, getWorldName(), moneyBack);
|
response = plugin.getEconomy().depositPlayer(player, getWorldName(), moneyBack);
|
||||||
} else if(getPlayerName() != null) {
|
} else if(getPlayerName() != null) {
|
||||||
response = plugin.getEconomy().depositPlayer(getPlayerName(), getWorldName(), moneyBack);
|
response = plugin.getEconomy().depositPlayer(getPlayerName(), getWorldName(), moneyBack);
|
||||||
@ -471,13 +467,14 @@ public class BuyRegion extends GeneralRegion {
|
|||||||
|
|
||||||
// Update everything
|
// Update everything
|
||||||
handleSchematicEvent(RegionEvent.SOLD);
|
handleSchematicEvent(RegionEvent.SOLD);
|
||||||
updateRegionFlags(RegionState.FORSALE);
|
AreaShop.debug("friends before sell: " + getFriendNames().toString());
|
||||||
|
|
||||||
// Remove friends and the owner
|
// Remove friends and the owner
|
||||||
clearFriends();
|
clearFriends();
|
||||||
setBuyer(null);
|
setBuyer(null);
|
||||||
removeLastActiveTime();
|
removeLastActiveTime();
|
||||||
|
|
||||||
|
updateRegionFlags(RegionState.FORSALE);
|
||||||
updateSigns();
|
updateSigns();
|
||||||
// Run commands
|
// Run commands
|
||||||
this.runEventCommands(RegionEvent.SOLD, false);
|
this.runEventCommands(RegionEvent.SOLD, false);
|
||||||
|
@ -1,40 +1,5 @@
|
|||||||
package nl.evolutioncoding.areashop.regions;
|
package nl.evolutioncoding.areashop.regions;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
|
||||||
import nl.evolutioncoding.areashop.Utils;
|
|
||||||
import nl.evolutioncoding.areashop.interfaces.GeneralRegionInterface;
|
|
||||||
import nl.evolutioncoding.areashop.managers.FileManager;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.command.CommandException;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||||
@ -43,13 +8,35 @@ import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
|||||||
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
|
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException;
|
||||||
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
|
import nl.evolutioncoding.areashop.Utils;
|
||||||
|
import nl.evolutioncoding.areashop.interfaces.GeneralRegionInterface;
|
||||||
|
import nl.evolutioncoding.areashop.managers.FileManager;
|
||||||
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.command.CommandException;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public abstract class GeneralRegion implements GeneralRegionInterface, Comparable<GeneralRegion> {
|
public abstract class GeneralRegion implements GeneralRegionInterface, Comparable<GeneralRegion> {
|
||||||
protected YamlConfiguration config;
|
YamlConfiguration config;
|
||||||
private static ArrayList<Material> canSpawnIn = new ArrayList<Material>(Arrays.asList(Material.WOOD_DOOR, Material.WOODEN_DOOR, Material.SIGN_POST, Material.WALL_SIGN, Material.STONE_PLATE, Material.IRON_DOOR_BLOCK, Material.WOOD_PLATE, Material.TRAP_DOOR, Material.REDSTONE_LAMP_OFF, Material.REDSTONE_LAMP_ON, Material.DRAGON_EGG, Material.GOLD_PLATE, Material.IRON_PLATE));
|
private static ArrayList<Material> canSpawnIn = new ArrayList<>(Arrays.asList(Material.WOOD_DOOR, Material.WOODEN_DOOR, Material.SIGN_POST, Material.WALL_SIGN, Material.STONE_PLATE, Material.IRON_DOOR_BLOCK, Material.WOOD_PLATE, Material.TRAP_DOOR, Material.REDSTONE_LAMP_OFF, Material.REDSTONE_LAMP_ON, Material.DRAGON_EGG, Material.GOLD_PLATE, Material.IRON_PLATE));
|
||||||
private static ArrayList<Material> cannotSpawnOn = new ArrayList<Material>(Arrays.asList(Material.PISTON_EXTENSION, Material.PISTON_MOVING_PIECE, Material.SIGN_POST, Material.WALL_SIGN, Material.STONE_PLATE, Material.IRON_DOOR_BLOCK, Material.WOOD_PLATE, Material.TRAP_DOOR, Material.REDSTONE_LAMP_OFF, Material.REDSTONE_LAMP_ON, Material.CACTUS, Material.IRON_FENCE, Material.FENCE_GATE, Material.THIN_GLASS, Material.NETHER_FENCE, Material.DRAGON_EGG, Material.GOLD_PLATE, Material.IRON_PLATE, Material.STAINED_GLASS_PANE));
|
private static ArrayList<Material> cannotSpawnOn = new ArrayList<>(Arrays.asList(Material.PISTON_EXTENSION, Material.PISTON_MOVING_PIECE, Material.SIGN_POST, Material.WALL_SIGN, Material.STONE_PLATE, Material.IRON_DOOR_BLOCK, Material.WOOD_PLATE, Material.TRAP_DOOR, Material.REDSTONE_LAMP_OFF, Material.REDSTONE_LAMP_ON, Material.CACTUS, Material.IRON_FENCE, Material.FENCE_GATE, Material.THIN_GLASS, Material.NETHER_FENCE, Material.DRAGON_EGG, Material.GOLD_PLATE, Material.IRON_PLATE, Material.STAINED_GLASS_PANE));
|
||||||
private static ArrayList<Material> cannotSpawnBeside = new ArrayList<Material>(Arrays.asList(Material.LAVA, Material.STATIONARY_LAVA, Material.CACTUS));
|
private static ArrayList<Material> cannotSpawnBeside = new ArrayList<>(Arrays.asList(Material.LAVA, Material.STATIONARY_LAVA, Material.CACTUS));
|
||||||
protected AreaShop plugin = null;
|
AreaShop plugin = null;
|
||||||
private boolean saveRequired = false;
|
private boolean saveRequired = false;
|
||||||
private boolean deleted = false;
|
private boolean deleted = false;
|
||||||
|
|
||||||
@ -62,7 +49,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
BUY("buy");
|
BUY("buy");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
private RegionType(String value) {
|
|
||||||
|
RegionType(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
@ -82,7 +70,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
RESELL("resell");
|
RESELL("resell");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
private RegionEvent(String value) {
|
|
||||||
|
RegionEvent(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
@ -99,7 +88,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
RESELL("resell");
|
RESELL("resell");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
private RegionState(String value) {
|
|
||||||
|
RegionState(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
@ -115,7 +105,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
SHIFTLEFTCLICK("shiftLeftClick");
|
SHIFTLEFTCLICK("shiftLeftClick");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
private ClickType(String value) {
|
|
||||||
|
ClickType(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
@ -131,7 +122,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
EXTEND("extend");
|
EXTEND("extend");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
private LimitType(String value) {
|
|
||||||
|
LimitType(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
@ -139,12 +131,12 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeneralRegion(AreaShop plugin, YamlConfiguration config) {
|
GeneralRegion(AreaShop plugin, YamlConfiguration config) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected GeneralRegion(AreaShop plugin, String name, World world) {
|
GeneralRegion(AreaShop plugin, String name, World world) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
config = new YamlConfiguration();
|
config = new YamlConfiguration();
|
||||||
@ -161,8 +153,14 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
public abstract RegionType getType();
|
public abstract RegionType getType();
|
||||||
|
|
||||||
// Sorting by name
|
// Sorting by name
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare this region to another region by name
|
||||||
|
* @param o The region to compare to
|
||||||
|
* @return 0 if the names are the same, below zero if this region is earlier in the alphabet, otherwise above zero
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(GeneralRegion o) {
|
public int compareTo(@Nonnull GeneralRegion o) {
|
||||||
return getName().compareTo(o.getName());
|
return getName().compareTo(o.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +224,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
* @return A List with all sign locations
|
* @return A List with all sign locations
|
||||||
*/
|
*/
|
||||||
public List<Location> getSignLocations() {
|
public List<Location> getSignLocations() {
|
||||||
List<Location> result = new ArrayList<Location>();
|
List<Location> result = new ArrayList<>();
|
||||||
if(config.getConfigurationSection("general.signs") == null) {
|
if(config.getConfigurationSection("general.signs") == null) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -241,14 +239,14 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
* @return The teleport location, or null if not set
|
* @return The teleport location, or null if not set
|
||||||
*/
|
*/
|
||||||
public Location getTeleportLocation() {
|
public Location getTeleportLocation() {
|
||||||
Location result = null;
|
Location result;
|
||||||
result = Utils.configToLocation(config.getConfigurationSection("general.teleportLocation"));
|
result = Utils.configToLocation(config.getConfigurationSection("general.teleportLocation"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the region has been deleted
|
* Check if the region has been deleted
|
||||||
* @return
|
* @return true if the region has been deleted, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean isDeleted() {
|
public boolean isDeleted() {
|
||||||
return deleted;
|
return deleted;
|
||||||
@ -383,7 +381,9 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
if(landlord != null) {
|
if(landlord != null) {
|
||||||
try {
|
try {
|
||||||
return UUID.fromString(landlord);
|
return UUID.fromString(landlord);
|
||||||
} catch(IllegalArgumentException e) {}
|
} catch(IllegalArgumentException e) {
|
||||||
|
// Incorrect UUID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -413,8 +413,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
setSetting("general.landlord", landlord.toString());
|
setSetting("general.landlord", landlord.toString());
|
||||||
}
|
}
|
||||||
String properName = plugin.toName(landlord);
|
String properName = plugin.toName(landlord);
|
||||||
if(properName != null) {
|
if(properName == null) {
|
||||||
name = properName;
|
properName = name;
|
||||||
}
|
}
|
||||||
setSetting("general.landlordName", properName);
|
setSetting("general.landlordName", properName);
|
||||||
}
|
}
|
||||||
@ -486,7 +486,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
* @return A Set with all groups of this region
|
* @return A Set with all groups of this region
|
||||||
*/
|
*/
|
||||||
public Set<RegionGroup> getGroups() {
|
public Set<RegionGroup> getGroups() {
|
||||||
Set<RegionGroup> result = new HashSet<RegionGroup>();
|
Set<RegionGroup> result = new HashSet<>();
|
||||||
for(RegionGroup group : plugin.getFileManager().getGroups()) {
|
for(RegionGroup group : plugin.getFileManager().getGroups()) {
|
||||||
if(group.isMember(this)) {
|
if(group.isMember(this)) {
|
||||||
result.add(group);
|
result.add(group);
|
||||||
@ -500,7 +500,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
* @return A list of groups this region is part of
|
* @return A list of groups this region is part of
|
||||||
*/
|
*/
|
||||||
public List<String> getGroupNames() {
|
public List<String> getGroupNames() {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<>();
|
||||||
for(RegionGroup group : getGroups()) {
|
for(RegionGroup group : getGroups()) {
|
||||||
result.add(group.getName());
|
result.add(group.getName());
|
||||||
}
|
}
|
||||||
@ -634,9 +634,9 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
* @param player The UUID of the player to add
|
* @param player The UUID of the player to add
|
||||||
*/
|
*/
|
||||||
public void addFriend(UUID player) {
|
public void addFriend(UUID player) {
|
||||||
Set<String> friends = new HashSet<String>(config.getStringList("general.friends"));
|
Set<String> friends = new HashSet<>(config.getStringList("general.friends"));
|
||||||
friends.add(player.toString());
|
friends.add(player.toString());
|
||||||
List<String> list = new ArrayList<String>(friends);
|
List<String> list = new ArrayList<>(friends);
|
||||||
setSetting("general.friends", list);
|
setSetting("general.friends", list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,9 +645,9 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
* @param player The UUID of the player to delete
|
* @param player The UUID of the player to delete
|
||||||
*/
|
*/
|
||||||
public void deleteFriend(UUID player) {
|
public void deleteFriend(UUID player) {
|
||||||
Set<String> friends = new HashSet<String>(config.getStringList("general.friends"));
|
Set<String> friends = new HashSet<>(config.getStringList("general.friends"));
|
||||||
friends.remove(player.toString());
|
friends.remove(player.toString());
|
||||||
List<String> list = new ArrayList<String>(friends);
|
List<String> list = new ArrayList<>(friends);
|
||||||
if(list.isEmpty()) {
|
if(list.isEmpty()) {
|
||||||
setSetting("general.friends", null);
|
setSetting("general.friends", null);
|
||||||
} else {
|
} else {
|
||||||
@ -660,13 +660,11 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
* @return Friends added to this region
|
* @return Friends added to this region
|
||||||
*/
|
*/
|
||||||
public Set<UUID> getFriends() {
|
public Set<UUID> getFriends() {
|
||||||
HashSet<UUID> result = new HashSet<UUID>();
|
HashSet<UUID> result = new HashSet<>();
|
||||||
for(String friend : config.getStringList("general.friends")) {
|
for(String friend : config.getStringList("general.friends")) {
|
||||||
try {
|
try {
|
||||||
UUID id = UUID.fromString(friend);
|
UUID id = UUID.fromString(friend);
|
||||||
if(id != null) {
|
|
||||||
result.add(id);
|
result.add(id);
|
||||||
}
|
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
// Don't add it
|
// Don't add it
|
||||||
}
|
}
|
||||||
@ -679,7 +677,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
* @return Friends added to this region
|
* @return Friends added to this region
|
||||||
*/
|
*/
|
||||||
public Set<String> getFriendNames() {
|
public Set<String> getFriendNames() {
|
||||||
HashSet<String> result = new HashSet<String>();
|
HashSet<String> result = new HashSet<>();
|
||||||
for(UUID friend : getFriends()) {
|
for(UUID friend : getFriends()) {
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(friend);
|
OfflinePlayer player = Bukkit.getOfflinePlayer(friend);
|
||||||
if(player != null) {
|
if(player != null) {
|
||||||
@ -765,7 +763,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
* @return true if this region has a sign at the location, otherwise false
|
* @return true if this region has a sign at the location, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean isSignOfRegion(Location location) {
|
public boolean isSignOfRegion(Location location) {
|
||||||
Set<String> signs = null;
|
Set<String> signs;
|
||||||
if(config.getConfigurationSection("general.signs") == null) {
|
if(config.getConfigurationSection("general.signs") == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -785,14 +783,13 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a sign needs periodic updating
|
* Check if a sign needs periodic updating
|
||||||
* @param signName
|
* @return true if the signs of this region need periodic updating, otherwise false
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean needsPeriodicUpdating() {
|
public boolean needsPeriodicUpdating() {
|
||||||
if(isDeleted() || !isRentRegion()) {
|
if(isDeleted() || !isRentRegion()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<String> signs = new HashSet<String>();
|
Set<String> signs = new HashSet<>();
|
||||||
if(config.getConfigurationSection("general.signs") != null) {
|
if(config.getConfigurationSection("general.signs") != null) {
|
||||||
signs = config.getConfigurationSection("general.signs").getKeys(false);
|
signs = config.getConfigurationSection("general.signs").getKeys(false);
|
||||||
}
|
}
|
||||||
@ -804,7 +801,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
}
|
}
|
||||||
// Get the prefix
|
// Get the prefix
|
||||||
String prefix = "signProfiles." + profile + "." + getState().getValue().toLowerCase() + ".line";
|
String prefix = "signProfiles." + profile + "." + getState().getValue().toLowerCase() + ".line";
|
||||||
String line = null;
|
String line;
|
||||||
// Get the lines
|
// Get the lines
|
||||||
for(int i=1; i<5; i++) {
|
for(int i=1; i<5; i++) {
|
||||||
line = plugin.getConfig().getString(prefix + i);
|
line = plugin.getConfig().getString(prefix + i);
|
||||||
@ -835,8 +832,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
for(String sign : signs) {
|
for(String sign : signs) {
|
||||||
Location location = Utils.configToLocation(config.getConfigurationSection("general.signs." + sign + ".location"));
|
Location location = Utils.configToLocation(config.getConfigurationSection("general.signs." + sign + ".location"));
|
||||||
if(location == null) {
|
if(location == null) {
|
||||||
// TODO: Remove the sign if the location is wrong?
|
AreaShop.debug("Sign location incorrect region=" + getName() + ", signKey="+sign);
|
||||||
AreaShop.debug(" location null");
|
|
||||||
result = false;
|
result = false;
|
||||||
} else {
|
} else {
|
||||||
// Get the profile set in the config
|
// Get the profile set in the config
|
||||||
@ -863,7 +859,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
} else {
|
} else {
|
||||||
Sign signState = null;
|
Sign signState = null;
|
||||||
if(block.getType() != Material.WALL_SIGN && block.getType() != Material.SIGN_POST) {
|
if(block.getType() != Material.WALL_SIGN && block.getType() != Material.SIGN_POST) {
|
||||||
Material signType = null;
|
Material signType;
|
||||||
try {
|
try {
|
||||||
signType = Material.valueOf(config.getString("general.signs." + sign + ".signType"));
|
signType = Material.valueOf(config.getString("general.signs." + sign + ".signType"));
|
||||||
} catch(NullPointerException | IllegalArgumentException e) {
|
} catch(NullPointerException | IllegalArgumentException e) {
|
||||||
@ -932,10 +928,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Save all blocks in a region for restoring later
|
* Save all blocks in a region for restoring later
|
||||||
* @param regionName The name of the region
|
|
||||||
* @param world The world that it is in
|
|
||||||
* @param fileName The name of the file to save to (extension and folder will be added)
|
* @param fileName The name of the file to save to (extension and folder will be added)
|
||||||
* @return
|
* @return true if the region has been saved properly, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean saveRegionBlocks(String fileName) {
|
public boolean saveRegionBlocks(String fileName) {
|
||||||
// Check if the region is correct
|
// Check if the region is correct
|
||||||
@ -963,10 +957,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore all blocks in a region for restoring later
|
* Restore all blocks in a region for restoring later
|
||||||
* @param regionName The name of the region
|
|
||||||
* @param world The world that it is in
|
|
||||||
* @param fileName The name of the file to save to (extension and folder will be added)
|
* @param fileName The name of the file to save to (extension and folder will be added)
|
||||||
* @return
|
* @return true if the region has been restored properly, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean restoreRegionBlocks(String fileName) {
|
public boolean restoreRegionBlocks(String fileName) {
|
||||||
if(getRegion() == null) {
|
if(getRegion() == null) {
|
||||||
@ -1052,10 +1044,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the region flags/options to the values of a ConfigurationSection
|
* Set the region flags/options to the values of a ConfigurationSection
|
||||||
* @param player The player that does it
|
* @param flags The configuration settings to apply to the region
|
||||||
* @param region The region
|
* @return true if the flags have been set correctly, otherwise false
|
||||||
* @param flags
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
protected boolean setRegionFlags(ConfigurationSection flags) {
|
protected boolean setRegionFlags(ConfigurationSection flags) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
@ -1072,10 +1062,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
AreaShop.debug("Region '" + getName() + "' does not exist, setting flags failed");
|
AreaShop.debug("Region '" + getName() + "' does not exist, setting flags failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Iterator<String> it = flagNames.iterator();
|
|
||||||
// Loop through all flags that are set in the config
|
// Loop through all flags that are set in the config
|
||||||
while(it.hasNext()) {
|
for(String flagName : flagNames) {
|
||||||
String flagName = it.next();
|
|
||||||
String value = flags.getString(flagName);
|
String value = flags.getString(flagName);
|
||||||
value = applyAllReplacements(value);
|
value = applyAllReplacements(value);
|
||||||
// In the config normal Bukkit color codes are used, those only need to be translated on 5.X WorldGuard versions
|
// In the config normal Bukkit color codes are used, those only need to be translated on 5.X WorldGuard versions
|
||||||
@ -1129,7 +1117,6 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
region.setFlag(groupFlag, null);
|
region.setFlag(groupFlag, null);
|
||||||
}
|
}
|
||||||
//AreaShop.debug(" Flag " + flagName + " reset (+ possible group of flag)");
|
//AreaShop.debug(" Flag " + flagName + " reset (+ possible group of flag)");
|
||||||
continue;
|
|
||||||
} else {
|
} else {
|
||||||
if(groupFlag == null) {
|
if(groupFlag == null) {
|
||||||
flagSetting = value;
|
flagSetting = value;
|
||||||
@ -1178,7 +1165,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate the color codes you put in greeting/farwell messages to the weird color codes of WorldGuard
|
* Translate the color codes you put in greeting/farewell messages to the weird color codes of WorldGuard
|
||||||
* @param message The message where the color codes should be translated (this message has bukkit color codes)
|
* @param message The message where the color codes should be translated (this message has bukkit color codes)
|
||||||
* @return The string with the WorldGuard color codes
|
* @return The string with the WorldGuard color codes
|
||||||
*/
|
*/
|
||||||
@ -1241,8 +1228,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the teleport location of this region
|
* Set the teleport location of this region
|
||||||
* @param regionName
|
* @param location The location to set as teleport location
|
||||||
* @param location
|
|
||||||
*/
|
*/
|
||||||
public void setTeleport(Location location) {
|
public void setTeleport(Location location) {
|
||||||
if(location == null) {
|
if(location == null) {
|
||||||
@ -1256,12 +1242,11 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
/**
|
/**
|
||||||
* Teleport a player to the region
|
* Teleport a player to the region
|
||||||
* @param player Player that should be teleported
|
* @param player Player that should be teleported
|
||||||
* @param regionName The name of the region the player should be teleported to
|
|
||||||
* @param checkPermissions Set to true if teleport permissions should be checked, false otherwise
|
* @param checkPermissions Set to true if teleport permissions should be checked, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean teleportPlayer(Player player, boolean toSign, boolean checkPermissions) {
|
public boolean teleportPlayer(Player player, boolean toSign, boolean checkPermissions) {
|
||||||
int checked = 1;
|
int checked = 1;
|
||||||
boolean owner = false;
|
boolean owner;
|
||||||
boolean friend = getFriends().contains(player.getUniqueId());
|
boolean friend = getFriends().contains(player.getUniqueId());
|
||||||
Location startLocation = null;
|
Location startLocation = null;
|
||||||
ProtectedRegion region = getRegion();
|
ProtectedRegion region = getRegion();
|
||||||
@ -1440,7 +1425,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
west = west || !west;
|
west = west || !track;
|
||||||
|
|
||||||
// Top side
|
// Top side
|
||||||
track = false;
|
track = false;
|
||||||
@ -1606,7 +1591,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check all blocks around
|
// Check all blocks around
|
||||||
ArrayList<Material> around = new ArrayList<Material>(Arrays.asList(
|
ArrayList<Material> around = new ArrayList<>(Arrays.asList(
|
||||||
feet.getRelative(BlockFace.NORTH).getType(),
|
feet.getRelative(BlockFace.NORTH).getType(),
|
||||||
feet.getRelative(BlockFace.NORTH_EAST).getType(),
|
feet.getRelative(BlockFace.NORTH_EAST).getType(),
|
||||||
feet.getRelative(BlockFace.EAST).getType(),
|
feet.getRelative(BlockFace.EAST).getType(),
|
||||||
@ -1814,14 +1799,14 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
if(extend) {
|
if(extend) {
|
||||||
exclude = this;
|
exclude = this;
|
||||||
}
|
}
|
||||||
String typePath = null;
|
String typePath;
|
||||||
if(type == RegionType.RENT) {
|
if(type == RegionType.RENT) {
|
||||||
typePath = "rents";
|
typePath = "rents";
|
||||||
} else {
|
} else {
|
||||||
typePath = "buys";
|
typePath = "buys";
|
||||||
}
|
}
|
||||||
// Check all limitgroups the player has
|
// Check all limitgroups the player has
|
||||||
List<String> groups = new ArrayList<String>(plugin.getConfig().getConfigurationSection("limitGroups").getKeys(false));
|
List<String> groups = new ArrayList<>(plugin.getConfig().getConfigurationSection("limitGroups").getKeys(false));
|
||||||
while(!groups.isEmpty()) {
|
while(!groups.isEmpty()) {
|
||||||
String group = groups.get(0);
|
String group = groups.get(0);
|
||||||
if(player.hasPermission("areashop.limits." + group) && this.matchesLimitGroup(group)) {
|
if(player.hasPermission("areashop.limits." + group) && this.matchesLimitGroup(group)) {
|
||||||
@ -1829,7 +1814,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
int typeLimit = plugin.getConfig().getInt("limitGroups." + group + "."+typePath);
|
int typeLimit = plugin.getConfig().getInt("limitGroups." + group + "."+typePath);
|
||||||
//AreaShop.debug("typeLimitOther="+typeLimit+", typePath="+typePath);
|
//AreaShop.debug("typeLimitOther="+typeLimit+", typePath="+typePath);
|
||||||
int totalCurrent = hasRegionsInLimitGroup(player, group, plugin.getFileManager().getRegions(), exclude);
|
int totalCurrent = hasRegionsInLimitGroup(player, group, plugin.getFileManager().getRegions(), exclude);
|
||||||
int typeCurrent = 0;
|
int typeCurrent;
|
||||||
if(type == RegionType.RENT) {
|
if(type == RegionType.RENT) {
|
||||||
typeCurrent = hasRegionsInLimitGroup(player, group, plugin.getFileManager().getRents(), exclude);
|
typeCurrent = hasRegionsInLimitGroup(player, group, plugin.getFileManager().getRents(), exclude);
|
||||||
} else {
|
} else {
|
||||||
@ -1845,7 +1830,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
String typeHighestGroup = group;
|
String typeHighestGroup = group;
|
||||||
groups.remove(group);
|
groups.remove(group);
|
||||||
// Get the highest number from the groups of the same category
|
// Get the highest number from the groups of the same category
|
||||||
List<String> groupsCopy = new ArrayList<String>(groups);
|
List<String> groupsCopy = new ArrayList<>(groups);
|
||||||
for(String checkGroup : groupsCopy) {
|
for(String checkGroup : groupsCopy) {
|
||||||
if(player.hasPermission("areashop.limits." + checkGroup) && this.matchesLimitGroup(checkGroup)) {
|
if(player.hasPermission("areashop.limits." + checkGroup) && this.matchesLimitGroup(checkGroup)) {
|
||||||
if(limitGroupsOfSameCategory(group, checkGroup)) {
|
if(limitGroupsOfSameCategory(group, checkGroup)) {
|
||||||
@ -1871,7 +1856,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
}
|
}
|
||||||
// Check if the limits stop the player from buying the region
|
// Check if the limits stop the player from buying the region
|
||||||
if(typeCurrent >= typeLimit) {
|
if(typeCurrent >= typeLimit) {
|
||||||
LimitType limitType = null;
|
LimitType limitType;
|
||||||
if(type == RegionType.RENT) {
|
if(type == RegionType.RENT) {
|
||||||
if(extend) {
|
if(extend) {
|
||||||
limitType = LimitType.EXTEND;
|
limitType = LimitType.EXTEND;
|
||||||
@ -1944,17 +1929,15 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
}
|
}
|
||||||
List<String> firstWorlds = plugin.getConfig().getStringList("limitGroups." + firstGroup + ".worlds");
|
List<String> firstWorlds = plugin.getConfig().getStringList("limitGroups." + firstGroup + ".worlds");
|
||||||
List<String> secondWorlds = plugin.getConfig().getStringList("limitGroups." + secondGroup + ".worlds");
|
List<String> secondWorlds = plugin.getConfig().getStringList("limitGroups." + secondGroup + ".worlds");
|
||||||
if(!firstWorlds.containsAll(secondWorlds) || !secondWorlds.containsAll(firstWorlds)) {
|
return !(!firstWorlds.containsAll(secondWorlds) || !secondWorlds.containsAll(firstWorlds));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of regions a player has matching a certain limits group (config.yml > limitGroups)
|
* Get the amount of regions a player has matching a certain limits group (config.yml > limitGroups)
|
||||||
* @param player The player to check the amount for
|
* @param player The player to check the amount for
|
||||||
* @param limitGroup The group to check
|
* @param limitGroup The group to check
|
||||||
* @param buyRegions All the regions a player has bought or rented
|
* @param regions All the regions a player has bought or rented
|
||||||
|
* @param exclude Exclude this region from the count
|
||||||
* @return The number of regions that the player has bought or rented matching the limit group (worlds and groups filters)
|
* @return The number of regions that the player has bought or rented matching the limit group (worlds and groups filters)
|
||||||
*/
|
*/
|
||||||
public int hasRegionsInLimitGroup(Player player, String limitGroup, List<? extends GeneralRegion> regions, GeneralRegion exclude) {
|
public int hasRegionsInLimitGroup(Player player, String limitGroup, List<? extends GeneralRegion> regions, GeneralRegion exclude) {
|
||||||
@ -2034,7 +2017,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
}
|
}
|
||||||
command = applyAllReplacements(command);
|
command = applyAllReplacements(command);
|
||||||
|
|
||||||
boolean result = false;
|
boolean result;
|
||||||
String error = null;
|
String error = null;
|
||||||
String stacktrace = null;
|
String stacktrace = null;
|
||||||
try {
|
try {
|
||||||
@ -2059,7 +2042,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
if(error == null) {
|
if(error == null) {
|
||||||
AreaShop.debug("Command run, executor=" + sender.getName() + ", command=" + command + ", result=" + result);
|
AreaShop.debug("Command run, executor=" + sender.getName() + ", command=" + command + ", result=" + result);
|
||||||
} else {
|
} else {
|
||||||
AreaShop.debug("Command run, executor=" + sender.getName() + ", command=" + command + ", result=" + result + ", error=" + error + ", stacktrace:");
|
AreaShop.debug("Command run, executor=" + sender.getName() + ", command=" + command + ", error=" + error + ", stacktrace:");
|
||||||
AreaShop.debug(stacktrace);
|
AreaShop.debug(stacktrace);
|
||||||
AreaShop.debug("--- End of stacktrace ---");
|
AreaShop.debug("--- End of stacktrace ---");
|
||||||
}
|
}
|
||||||
@ -2105,7 +2088,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
}
|
}
|
||||||
// Run player commands if specified
|
// Run player commands if specified
|
||||||
String playerPath = "signProfiles." + profile + "." + getState().getValue().toLowerCase() + "." + clickType.getValue() + "Player";
|
String playerPath = "signProfiles." + profile + "." + getState().getValue().toLowerCase() + "." + clickType.getValue() + "Player";
|
||||||
List<String> playerCommands = new ArrayList<String>();
|
List<String> playerCommands = new ArrayList<>();
|
||||||
for(String command : plugin.getConfig().getStringList(playerPath)) {
|
for(String command : plugin.getConfig().getStringList(playerPath)) {
|
||||||
playerCommands.add(command.replace(AreaShop.tagClicker, clicker.getName()));
|
playerCommands.add(command.replace(AreaShop.tagClicker, clicker.getName()));
|
||||||
}
|
}
|
||||||
@ -2113,7 +2096,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
|||||||
|
|
||||||
// Run console commands if specified
|
// Run console commands if specified
|
||||||
String consolePath = "signProfiles." + profile + "." + getState().getValue().toLowerCase() + "." + clickType.getValue() + "Console";
|
String consolePath = "signProfiles." + profile + "." + getState().getValue().toLowerCase() + "." + clickType.getValue() + "Console";
|
||||||
List<String> consoleCommands = new ArrayList<String>();
|
List<String> consoleCommands = new ArrayList<>();
|
||||||
for(String command : plugin.getConfig().getStringList(consolePath)) {
|
for(String command : plugin.getConfig().getStringList(consolePath)) {
|
||||||
consoleCommands.add(command.replace(AreaShop.tagClicker, clicker.getName()));
|
consoleCommands.add(command.replace(AreaShop.tagClicker, clicker.getName()));
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package nl.evolutioncoding.areashop.regions;
|
package nl.evolutioncoding.areashop.regions;
|
||||||
|
|
||||||
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
|
|
||||||
public class RegionGroup {
|
public class RegionGroup {
|
||||||
|
|
||||||
private AreaShop plugin;
|
private AreaShop plugin;
|
||||||
@ -26,7 +25,7 @@ public class RegionGroup {
|
|||||||
// Delete duplicates
|
// Delete duplicates
|
||||||
List<String> members = getMembers();
|
List<String> members = getMembers();
|
||||||
int previousCount = members.size();
|
int previousCount = members.size();
|
||||||
List<String> newMembers = new ArrayList<String>();
|
List<String> newMembers = new ArrayList<>();
|
||||||
while(!members.isEmpty()) {
|
while(!members.isEmpty()) {
|
||||||
String member = members.remove(0);
|
String member = members.remove(0);
|
||||||
// If the region has been deleted also clean it from the group
|
// If the region has been deleted also clean it from the group
|
||||||
@ -90,7 +89,7 @@ public class RegionGroup {
|
|||||||
*/
|
*/
|
||||||
public List<String> getMembers() {
|
public List<String> getMembers() {
|
||||||
if(getSettings() == null || getSettings().getStringList("regions") == null) {
|
if(getSettings() == null || getSettings().getStringList("regions") == null) {
|
||||||
return new ArrayList<String>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
return getSettings().getStringList("regions");
|
return getSettings().getStringList("regions");
|
||||||
}
|
}
|
||||||
@ -100,7 +99,7 @@ public class RegionGroup {
|
|||||||
* @return A Set with all group members
|
* @return A Set with all group members
|
||||||
*/
|
*/
|
||||||
public Set<GeneralRegion> getMemberRegions() {
|
public Set<GeneralRegion> getMemberRegions() {
|
||||||
Set<GeneralRegion> result = new HashSet<GeneralRegion>();
|
Set<GeneralRegion> result = new HashSet<>();
|
||||||
for(String name : getMembers()) {
|
for(String name : getMembers()) {
|
||||||
result.add(plugin.getFileManager().getRegion(name));
|
result.add(plugin.getFileManager().getRegion(name));
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
package nl.evolutioncoding.areashop.regions;
|
package nl.evolutioncoding.areashop.regions;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.EconomyResponse;
|
import net.milkbowl.vault.economy.EconomyResponse;
|
||||||
import nl.evolutioncoding.areashop.AreaShop;
|
import nl.evolutioncoding.areashop.AreaShop;
|
||||||
import nl.evolutioncoding.areashop.exceptions.RegionCreateException;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -17,14 +9,19 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class RentRegion extends GeneralRegion {
|
public class RentRegion extends GeneralRegion {
|
||||||
private long warningsDoneUntil = Calendar.getInstance().getTimeInMillis();
|
private long warningsDoneUntil = Calendar.getInstance().getTimeInMillis();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param plugin The areashop plugin
|
* @param plugin The areashop plugin
|
||||||
* @param settings All settings of this region
|
* @param config All settings of this region
|
||||||
* @throws RegionCreateException
|
|
||||||
*/
|
*/
|
||||||
public RentRegion(AreaShop plugin, YamlConfiguration config) {
|
public RentRegion(AreaShop plugin, YamlConfiguration config) {
|
||||||
super(plugin, config);
|
super(plugin, config);
|
||||||
@ -63,7 +60,9 @@ public class RentRegion extends GeneralRegion {
|
|||||||
if(renter != null) {
|
if(renter != null) {
|
||||||
try {
|
try {
|
||||||
return UUID.fromString(renter);
|
return UUID.fromString(renter);
|
||||||
} catch(IllegalArgumentException e) {}
|
} catch(IllegalArgumentException e) {
|
||||||
|
// Incorrect UUID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -74,19 +73,11 @@ public class RentRegion extends GeneralRegion {
|
|||||||
* @return true if this player rents this region, otherwise false
|
* @return true if this player rents this region, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean isRenter(Player player) {
|
public boolean isRenter(Player player) {
|
||||||
if(player == null) {
|
return player != null && isRenter(player.getUniqueId());
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return isRenter(player.getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public boolean isRenter(UUID player) {
|
public boolean isRenter(UUID player) {
|
||||||
UUID renter = getRenter();
|
UUID renter = getRenter();
|
||||||
if(player == null || renter == null) {
|
return !(player == null || renter == null) && renter.equals(player);
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return renter.equals(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,7 +125,7 @@ public class RentRegion extends GeneralRegion {
|
|||||||
@Override
|
@Override
|
||||||
public HashMap<String, Object> getSpecificReplacements() {
|
public HashMap<String, Object> getSpecificReplacements() {
|
||||||
// Fill the replacements map with things specific to a RentRegion
|
// Fill the replacements map with things specific to a RentRegion
|
||||||
HashMap<String, Object> result = new HashMap<String, Object>();
|
HashMap<String, Object> result = new HashMap<>();
|
||||||
result.put(AreaShop.tagPrice, getFormattedPrice());
|
result.put(AreaShop.tagPrice, getFormattedPrice());
|
||||||
result.put(AreaShop.tagRawPrice, getPrice());
|
result.put(AreaShop.tagRawPrice, getPrice());
|
||||||
result.put(AreaShop.tagDuration, getDurationString());
|
result.put(AreaShop.tagDuration, getDurationString());
|
||||||
@ -187,7 +178,7 @@ public class RentRegion extends GeneralRegion {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the time until this region is rented (time from 1970 epoch)
|
* Get the time until this region is rented (time from 1970 epoch)
|
||||||
* @return
|
* @return The epoch time until which this region is rented
|
||||||
*/
|
*/
|
||||||
public long getRentedUntil() {
|
public long getRentedUntil() {
|
||||||
return getLongSetting("rent.rentedUntil");
|
return getLongSetting("rent.rentedUntil");
|
||||||
@ -275,7 +266,7 @@ public class RentRegion extends GeneralRegion {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the price of the region
|
* Change the price of the region
|
||||||
* @param price
|
* @param price The price of the region
|
||||||
*/
|
*/
|
||||||
public void setPrice(double price) {
|
public void setPrice(double price) {
|
||||||
setSetting("rent.price", price);
|
setSetting("rent.price", price);
|
||||||
@ -314,8 +305,7 @@ public class RentRegion extends GeneralRegion {
|
|||||||
double percentage = (getMoneyBackPercentage()) / 100.0;
|
double percentage = (getMoneyBackPercentage()) / 100.0;
|
||||||
Double timePeriod = (double) (getDuration());
|
Double timePeriod = (double) (getDuration());
|
||||||
double periods = timeLeft / timePeriod;
|
double periods = timeLeft / timePeriod;
|
||||||
double moneyBack = periods * getPrice() * percentage;
|
return periods * getPrice() * percentage;
|
||||||
return moneyBack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -391,17 +381,16 @@ public class RentRegion extends GeneralRegion {
|
|||||||
/**
|
/**
|
||||||
* Rent a region
|
* Rent a region
|
||||||
* @param player The player that wants to rent the 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
|
* @return true if it succeeded and false if not
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public boolean rent(Player player) {
|
public boolean rent(Player player) {
|
||||||
//Check if the player has permission
|
|
||||||
if(player.hasPermission("areashop.rent")) {
|
|
||||||
if(plugin.getEconomy() == null) {
|
if(plugin.getEconomy() == null) {
|
||||||
plugin.message(player, "general-noEconomy");
|
plugin.message(player, "general-noEconomy");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//Check if the player has permission
|
||||||
|
if(player.hasPermission("areashop.rent")) {
|
||||||
if(getWorld() == null) {
|
if(getWorld() == null) {
|
||||||
plugin.message(player, "general-noWorld", getWorldName());
|
plugin.message(player, "general-noWorld", getWorldName());
|
||||||
return false;
|
return false;
|
||||||
@ -429,9 +418,9 @@ public class RentRegion extends GeneralRegion {
|
|||||||
// Check region limits if this is not extending
|
// Check region limits if this is not extending
|
||||||
if(!(extend && config.getBoolean("allowRegionExtendsWhenAboveLimits"))) {
|
if(!(extend && config.getBoolean("allowRegionExtendsWhenAboveLimits"))) {
|
||||||
|
|
||||||
LimitResult limitResult = null;
|
LimitResult limitResult;
|
||||||
if(extend) {
|
if(extend) {
|
||||||
limitResult = this.limitsAllow(RegionType.RENT, player, extend);
|
limitResult = this.limitsAllow(RegionType.RENT, player, true);
|
||||||
} else {
|
} else {
|
||||||
limitResult = this.limitsAllow(RegionType.RENT, player);
|
limitResult = this.limitsAllow(RegionType.RENT, player);
|
||||||
}
|
}
|
||||||
@ -501,7 +490,6 @@ public class RentRegion extends GeneralRegion {
|
|||||||
landlordPlayer = Bukkit.getOfflinePlayer(getLandlord());
|
landlordPlayer = Bukkit.getOfflinePlayer(getLandlord());
|
||||||
}
|
}
|
||||||
String landlordName = getLandlordName();
|
String landlordName = getLandlordName();
|
||||||
r = null;
|
|
||||||
if(landlordName != null) {
|
if(landlordName != null) {
|
||||||
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
||||||
r = plugin.getEconomy().depositPlayer(landlordPlayer, getWorldName(), price);
|
r = plugin.getEconomy().depositPlayer(landlordPlayer, getWorldName(), price);
|
||||||
@ -586,10 +574,13 @@ public class RentRegion extends GeneralRegion {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unrent a region, reset to unrented
|
* Unrent a region, reset to unrented
|
||||||
* @param regionName Region that should be unrented
|
* @param giveMoneyBack true if money should be given back to the player, false otherwise
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void unRent(boolean giveMoneyBack) {
|
public void unRent(boolean giveMoneyBack) {
|
||||||
|
if(plugin.getEconomy() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Run commands
|
// Run commands
|
||||||
this.runEventCommands(RegionEvent.UNRENTED, true);
|
this.runEventCommands(RegionEvent.UNRENTED, true);
|
||||||
double moneyBack = getMoneyBackAmount();
|
double moneyBack = getMoneyBackAmount();
|
||||||
@ -600,7 +591,7 @@ public class RentRegion extends GeneralRegion {
|
|||||||
landlordPlayer = Bukkit.getOfflinePlayer(getLandlord());
|
landlordPlayer = Bukkit.getOfflinePlayer(getLandlord());
|
||||||
}
|
}
|
||||||
String landlordName = getLandlordName();
|
String landlordName = getLandlordName();
|
||||||
EconomyResponse r = null;
|
EconomyResponse r;
|
||||||
if(landlordName != null) {
|
if(landlordName != null) {
|
||||||
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
||||||
r = plugin.getEconomy().withdrawPlayer(landlordPlayer, getWorldName(), moneyBack);
|
r = plugin.getEconomy().withdrawPlayer(landlordPlayer, getWorldName(), moneyBack);
|
||||||
@ -618,7 +609,7 @@ public class RentRegion extends GeneralRegion {
|
|||||||
r = null;
|
r = null;
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
try {
|
try {
|
||||||
if(player != null && player.getName() != null) {
|
if(player.getName() != null) {
|
||||||
r = plugin.getEconomy().depositPlayer(player, getWorldName(), moneyBack);
|
r = plugin.getEconomy().depositPlayer(player, getWorldName(), moneyBack);
|
||||||
} else if(getPlayerName() != null) {
|
} else if(getPlayerName() != null) {
|
||||||
r = plugin.getEconomy().depositPlayer(getPlayerName(), getWorldName(), moneyBack);
|
r = plugin.getEconomy().depositPlayer(getPlayerName(), getWorldName(), moneyBack);
|
||||||
@ -626,7 +617,7 @@ public class RentRegion extends GeneralRegion {
|
|||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
if(error || r == null || !r.transactionSuccess() || error) {
|
if(error || r == null || !r.transactionSuccess()) {
|
||||||
plugin.getLogger().warning("Something went wrong with paying back to " + getPlayerName() + " money while unrenting region " + getName());
|
plugin.getLogger().warning("Something went wrong with paying back to " + getPlayerName() + " money while unrenting region " + getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -637,7 +628,6 @@ public class RentRegion extends GeneralRegion {
|
|||||||
|
|
||||||
// Update the signs and region flags
|
// Update the signs and region flags
|
||||||
handleSchematicEvent(RegionEvent.UNRENTED);
|
handleSchematicEvent(RegionEvent.UNRENTED);
|
||||||
updateRegionFlags(RegionState.FORRENT);
|
|
||||||
|
|
||||||
// Remove friends, the owner and renteduntil values
|
// Remove friends, the owner and renteduntil values
|
||||||
clearFriends();
|
clearFriends();
|
||||||
@ -646,6 +636,7 @@ public class RentRegion extends GeneralRegion {
|
|||||||
setTimesExtended(-1);
|
setTimesExtended(-1);
|
||||||
removeLastActiveTime();
|
removeLastActiveTime();
|
||||||
|
|
||||||
|
updateRegionFlags(RegionState.FORRENT);
|
||||||
updateSigns();
|
updateSigns();
|
||||||
// Run commands
|
// Run commands
|
||||||
this.runEventCommands(RegionEvent.UNRENTED, false);
|
this.runEventCommands(RegionEvent.UNRENTED, false);
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package nl.evolutioncoding.areashop.interfaces;
|
package nl.evolutioncoding.areashop.interfaces;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public interface AreaShopInterface {
|
public interface AreaShopInterface {
|
||||||
public void debugI(String message);
|
void debugI(String message);
|
||||||
public YamlConfiguration getConfig();
|
YamlConfiguration getConfig();
|
||||||
public WorldGuardPlugin getWorldGuard();
|
WorldGuardPlugin getWorldGuard();
|
||||||
public WorldEditPlugin getWorldEdit();
|
WorldEditPlugin getWorldEdit();
|
||||||
public Logger getLogger();
|
Logger getLogger();
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package nl.evolutioncoding.areashop.interfaces;
|
package nl.evolutioncoding.areashop.interfaces;
|
||||||
|
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|
||||||
|
|
||||||
public interface GeneralRegionInterface {
|
public interface GeneralRegionInterface {
|
||||||
public ProtectedRegion getRegion();
|
ProtectedRegion getRegion();
|
||||||
public String getName();
|
String getName();
|
||||||
public World getWorld();
|
World getWorld();
|
||||||
public String getWorldName();
|
String getWorldName();
|
||||||
public int getWidth();
|
int getWidth();
|
||||||
public int getDepth();
|
int getDepth();
|
||||||
public int getHeight();
|
int getHeight();
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
package nl.evolutioncoding.areashop.handlers;
|
package nl.evolutioncoding.areashop.handlers;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import nl.evolutioncoding.areashop.interfaces.AreaShopInterface;
|
|
||||||
import nl.evolutioncoding.areashop.interfaces.WorldGuardInterface;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
|
|
||||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import nl.evolutioncoding.areashop.interfaces.AreaShopInterface;
|
||||||
|
import nl.evolutioncoding.areashop.interfaces.WorldGuardInterface;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class WorldGuardHandler5 extends WorldGuardInterface {
|
public class WorldGuardHandler5 extends WorldGuardInterface {
|
||||||
|
|
||||||
@ -111,11 +109,7 @@ public class WorldGuardHandler5 extends WorldGuardInterface {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
String name = Bukkit.getOfflinePlayer(player).getName();
|
String name = Bukkit.getOfflinePlayer(player).getName();
|
||||||
if(name != null) {
|
return name != null && region.getMembers().contains(name);
|
||||||
return region.getMembers().contains(name);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,11 +119,7 @@ public class WorldGuardHandler5 extends WorldGuardInterface {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
String name = Bukkit.getOfflinePlayer(player).getName();
|
String name = Bukkit.getOfflinePlayer(player).getName();
|
||||||
if(name != null) {
|
return name != null && region.getOwners().contains(name);
|
||||||
return region.getOwners().contains(name);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user