mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-12 18:31:32 +01:00
Now supports WorldGuard 7.0.0
- Added a placeholder %jobs_user_archived_jobs% to show the archived jobs for the user. - Fix file saving problem when removed the restricted area - /jobs area command now works
This commit is contained in:
parent
753ecefb10
commit
06538ed4e6
18
pom.xml
18
pom.xml
@ -68,12 +68,28 @@
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${basedir}/libs/MythicMobs-4.5.5.jar</systemPath>
|
<systemPath>${basedir}/libs/MythicMobs-4.5.5.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- WorldGuard -->
|
<!-- WorldGuard old version -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
<artifactId>worldguard</artifactId>
|
<artifactId>worldguard</artifactId>
|
||||||
<version>6.1</version>
|
<version>6.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- WorldGuard new version -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-legacy</artifactId>
|
||||||
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>bukkit-classloader-check</artifactId>
|
||||||
|
<groupId>org.sk89q.bukkit</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<!-- WorldEdit -->
|
<!-- WorldEdit -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldedit</groupId>
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
|
@ -42,6 +42,7 @@ public class Placeholder {
|
|||||||
user_joinedjobcount,
|
user_joinedjobcount,
|
||||||
user_points,
|
user_points,
|
||||||
user_total_points,
|
user_total_points,
|
||||||
|
user_archived_jobs,
|
||||||
user_boost_$1_$2("jname/number", "money/exp/points"),
|
user_boost_$1_$2("jname/number", "money/exp/points"),
|
||||||
user_isin_$1("jname/number"),
|
user_isin_$1("jname/number"),
|
||||||
user_canjoin_$1("jname/number"),
|
user_canjoin_$1("jname/number"),
|
||||||
@ -74,9 +75,6 @@ public class Placeholder {
|
|||||||
private ChatFilterRule rule = null;
|
private ChatFilterRule rule = null;
|
||||||
private boolean hidden = false;
|
private boolean hidden = false;
|
||||||
|
|
||||||
JobsPlaceHolders() {
|
|
||||||
}
|
|
||||||
|
|
||||||
JobsPlaceHolders(String... vars) {
|
JobsPlaceHolders(String... vars) {
|
||||||
Matcher matcher = numericalRule.getMatcher(this.toString());
|
Matcher matcher = numericalRule.getMatcher(this.toString());
|
||||||
if (matcher != null) {
|
if (matcher != null) {
|
||||||
@ -383,33 +381,35 @@ public class Placeholder {
|
|||||||
if (user != null) {
|
if (user != null) {
|
||||||
switch (placeHolder) {
|
switch (placeHolder) {
|
||||||
case user_id:
|
case user_id:
|
||||||
return String.valueOf(user.getUserId());
|
return Integer.toString(user.getUserId());
|
||||||
case user_bstandcount:
|
case user_bstandcount:
|
||||||
return String.valueOf(user.getBrewingStandCount());
|
return Integer.toString(user.getBrewingStandCount());
|
||||||
case user_maxbstandcount:
|
case user_maxbstandcount:
|
||||||
return String.valueOf(user.getMaxBrewingStandsAllowed());
|
return Integer.toString(user.getMaxBrewingStandsAllowed());
|
||||||
case user_furncount:
|
case user_furncount:
|
||||||
return String.valueOf(user.getFurnaceCount());
|
return Integer.toString(user.getFurnaceCount());
|
||||||
case user_maxfurncount:
|
case user_maxfurncount:
|
||||||
return String.valueOf(user.getMaxFurnacesAllowed());
|
return Integer.toString(user.getMaxFurnacesAllowed());
|
||||||
case user_doneq:
|
case user_doneq:
|
||||||
return String.valueOf(user.getDoneQuests());
|
return Integer.toString(user.getDoneQuests());
|
||||||
case user_seen:
|
case user_seen:
|
||||||
return TimeManage.to24hourShort(System.currentTimeMillis() - user.getSeen());
|
return TimeManage.to24hourShort(System.currentTimeMillis() - user.getSeen());
|
||||||
case user_totallevels:
|
case user_totallevels:
|
||||||
return String.valueOf(user.getTotalLevels());
|
return Integer.toString(user.getTotalLevels());
|
||||||
case user_points:
|
case user_points:
|
||||||
PlayerPoints pointInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(user.getPlayerUUID());
|
PlayerPoints pointInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(user.getPlayerUUID());
|
||||||
return String.valueOf(pointInfo.getCurrentPoints());
|
return Double.toString(pointInfo.getCurrentPoints());
|
||||||
case user_total_points:
|
case user_total_points:
|
||||||
pointInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(user.getPlayerUUID());
|
pointInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(user.getPlayerUUID());
|
||||||
return String.valueOf(pointInfo.getTotalPoints());
|
return Double.toString(pointInfo.getTotalPoints());
|
||||||
case user_issaved:
|
case user_issaved:
|
||||||
return convert(user.isSaved());
|
return convert(user.isSaved());
|
||||||
case user_displayhonorific:
|
case user_displayhonorific:
|
||||||
return String.valueOf(user.getDisplayHonorific());
|
return user.getDisplayHonorific();
|
||||||
case user_joinedjobcount:
|
case user_joinedjobcount:
|
||||||
return String.valueOf(user.getJobProgression().size());
|
return Integer.toString(user.getJobProgression().size());
|
||||||
|
case user_archived_jobs:
|
||||||
|
return Integer.toString(user.getArchivedJobs().getArchivedJobs().size());
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -422,21 +422,21 @@ public class Placeholder {
|
|||||||
switch (placeHolder) {
|
switch (placeHolder) {
|
||||||
case limit_$1:
|
case limit_$1:
|
||||||
CurrencyType t = CurrencyType.getByName(vals.get(0));
|
CurrencyType t = CurrencyType.getByName(vals.get(0));
|
||||||
return String.valueOf(user.getLimit(t));
|
return Integer.toString(user.getLimit(t));
|
||||||
case plimit_$1:
|
case plimit_$1:
|
||||||
t = CurrencyType.getByName(vals.get(0));
|
t = CurrencyType.getByName(vals.get(0));
|
||||||
return String.valueOf(user.getPaymentLimit().GetAmount(t));
|
return Double.toString(user.getPaymentLimit().GetAmount(t));
|
||||||
case plimit_tleft_$1:
|
case plimit_tleft_$1:
|
||||||
t = CurrencyType.getByName(vals.get(0));
|
t = CurrencyType.getByName(vals.get(0));
|
||||||
return TimeManage.to24hourShort(user.getPaymentLimit().GetLeftTime(t));
|
return TimeManage.to24hourShort(user.getPaymentLimit().GetLeftTime(t));
|
||||||
case user_jlevel_$1:
|
case user_jlevel_$1:
|
||||||
return j == null ? "" : String.valueOf(j.getLevel());
|
return j == null ? "" : Integer.toString(j.getLevel());
|
||||||
case user_jexp_$1:
|
case user_jexp_$1:
|
||||||
return j == null ? "" : String.valueOf(j.getExperience());
|
return j == null ? "" : Double.toString(j.getExperience());
|
||||||
case user_jmaxexp_$1:
|
case user_jmaxexp_$1:
|
||||||
return j == null ? "" : String.valueOf(j.getMaxExperience());
|
return j == null ? "" : Integer.toString(j.getMaxExperience());
|
||||||
case user_jmaxlvl_$1:
|
case user_jmaxlvl_$1:
|
||||||
return j == null ? "" : String.valueOf(j.getJob().getMaxLevel(user));
|
return j == null ? "" : Integer.toString(j.getJob().getMaxLevel(user));
|
||||||
case user_boost_$1_$2:
|
case user_boost_$1_$2:
|
||||||
if (vals.size() < 2)
|
if (vals.size() < 2)
|
||||||
return "";
|
return "";
|
||||||
@ -451,7 +451,7 @@ public class Placeholder {
|
|||||||
case maxjobs:
|
case maxjobs:
|
||||||
Double max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max");
|
Double max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max");
|
||||||
max = max == null ? Jobs.getGCManager().getMaxJobs() : max;
|
max = max == null ? Jobs.getGCManager().getMaxJobs() : max;
|
||||||
return String.valueOf(max);
|
return Double.toString(max);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -517,17 +517,17 @@ public class Placeholder {
|
|||||||
case description_$1:
|
case description_$1:
|
||||||
return jo.getDescription();
|
return jo.getDescription();
|
||||||
case maxdailyq_$1:
|
case maxdailyq_$1:
|
||||||
return String.valueOf(jo.getMaxDailyQuests());
|
return Integer.toString(jo.getMaxDailyQuests());
|
||||||
case maxlvl_$1:
|
case maxlvl_$1:
|
||||||
return String.valueOf(jo.getMaxLevel());
|
return Integer.toString(jo.getMaxLevel());
|
||||||
case maxviplvl_$1:
|
case maxviplvl_$1:
|
||||||
return String.valueOf(jo.getVipMaxLevel());
|
return Integer.toString(jo.getVipMaxLevel());
|
||||||
case bonus_$1:
|
case bonus_$1:
|
||||||
return String.valueOf(jo.getBonus());
|
return Double.toString(jo.getBonus());
|
||||||
case totalplayers_$1:
|
case totalplayers_$1:
|
||||||
return String.valueOf(jo.getTotalPlayers());
|
return Integer.toString(jo.getTotalPlayers());
|
||||||
case maxslots_$1:
|
case maxslots_$1:
|
||||||
return String.valueOf(jo.getMaxSlots());
|
return Integer.toString(jo.getMaxSlots());
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -536,13 +536,13 @@ public class Placeholder {
|
|||||||
// Global placeholders
|
// Global placeholders
|
||||||
switch (placeHolder) {
|
switch (placeHolder) {
|
||||||
case maxjobs:
|
case maxjobs:
|
||||||
return String.valueOf(Jobs.getGCManager().getMaxJobs());
|
return Integer.toString(Jobs.getGCManager().getMaxJobs());
|
||||||
case total_workers:
|
case total_workers:
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Job one : Jobs.getJobs()) {
|
for (Job one : Jobs.getJobs()) {
|
||||||
count += one.getTotalPlayers();
|
count += one.getTotalPlayers();
|
||||||
}
|
}
|
||||||
return String.valueOf(count);
|
return Integer.toString(count);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -12,28 +12,46 @@ import org.bukkit.plugin.Plugin;
|
|||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.container.RestrictedArea;
|
import com.gamingmesh.jobs.container.RestrictedArea;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
|
|
||||||
public class WorldGuardManager {
|
public class WorldGuardManager {
|
||||||
|
|
||||||
private WorldGuardPlugin wg;
|
private WorldGuardPlugin wg;
|
||||||
|
private boolean useOld = false;
|
||||||
|
|
||||||
public WorldGuardManager() {
|
public WorldGuardManager() {
|
||||||
Plugin pl = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
Plugin pl = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||||
if (pl != null && (pl instanceof WorldGuardPlugin)) {
|
if (pl != null && (pl instanceof WorldGuardPlugin)) {
|
||||||
wg = (WorldGuardPlugin) pl;
|
if (wg != null && wg.getDescription().getVersion().equals("6.1")) {
|
||||||
|
wg = (WorldGuardPlugin) pl;
|
||||||
|
useOld = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RestrictedArea> getArea(Location loc) {
|
public List<RestrictedArea> getArea(Location loc) {
|
||||||
try {
|
try {
|
||||||
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
|
if (useOld) {
|
||||||
for (ProtectedRegion one : regions.getRegions()) {
|
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
|
||||||
if (!Jobs.getRestrictedAreaManager().isExist(one.getId()))
|
for (ProtectedRegion one : regions.getRegions()) {
|
||||||
continue;
|
if (!Jobs.getRestrictedAreaManager().isExist(one.getId()))
|
||||||
return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
continue;
|
||||||
|
return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
|
||||||
|
for (ProtectedRegion one : regions.getRegions().values()) {
|
||||||
|
if (!Jobs.getRestrictedAreaManager().isExist(one.getId()))
|
||||||
|
continue;
|
||||||
|
return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
}
|
}
|
||||||
@ -41,20 +59,38 @@ public class WorldGuardManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean inArea(Location loc, String name) {
|
public boolean inArea(Location loc, String name) {
|
||||||
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
|
if (useOld) {
|
||||||
for (ProtectedRegion one : regions.getRegions()) {
|
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
|
||||||
if (!one.getId().equalsIgnoreCase(name))
|
for (ProtectedRegion one : regions.getRegions()) {
|
||||||
continue;
|
if (!one.getId().equalsIgnoreCase(name))
|
||||||
if (!one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
continue;
|
||||||
continue;
|
if (!one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||||
return true;
|
continue;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
|
||||||
|
for (ProtectedRegion one : regions.getRegions().values()) {
|
||||||
|
if (!one.getId().equalsIgnoreCase(name))
|
||||||
|
continue;
|
||||||
|
if (!one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||||
|
continue;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNameByName(String name) {
|
public String getNameByName(String name) {
|
||||||
for (World one : Bukkit.getWorlds()) {
|
for (World one : Bukkit.getWorlds()) {
|
||||||
Map<String, ProtectedRegion> regions = wg.getRegionContainer().get(one).getRegions();
|
Map<String, ProtectedRegion> regions = null;
|
||||||
|
if (useOld) {
|
||||||
|
regions = wg.getRegionContainer().get(one).getRegions();
|
||||||
|
} else {
|
||||||
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
regions = container.get(BukkitAdapter.adapt(one)).getRegions();
|
||||||
|
}
|
||||||
for (Entry<String, ProtectedRegion> oneR : regions.entrySet()) {
|
for (Entry<String, ProtectedRegion> oneR : regions.entrySet()) {
|
||||||
if (!oneR.getKey().equalsIgnoreCase(name))
|
if (!oneR.getKey().equalsIgnoreCase(name))
|
||||||
continue;
|
continue;
|
||||||
|
@ -26,63 +26,70 @@ public class area implements Cmd {
|
|||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (args.length == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
|
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
|
||||||
|
|
||||||
if (args.length == 3 && args[0].equalsIgnoreCase("add") && player.hasPermission("jobs.area.add")) {
|
if (args.length == 3) {
|
||||||
String name = args[1];
|
if (args[0].equalsIgnoreCase("add")) {
|
||||||
double bonus = 0D;
|
if (!Jobs.hasPermission(player, "jobs.area.add", true))
|
||||||
try {
|
return true;
|
||||||
bonus = Double.parseDouble(args[2]);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Boolean wg = false;
|
|
||||||
|
|
||||||
if (name.startsWith("wg:")) {
|
String name = args[1];
|
||||||
wg = true;
|
double bonus = 0D;
|
||||||
name = name.substring("wg:".length(), name.length());
|
try {
|
||||||
}
|
bonus = Double.parseDouble(args[2]);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean wg = false;
|
||||||
|
|
||||||
if (ra.isExist(name)) {
|
if (name.startsWith("wg:")) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.exist"));
|
wg = true;
|
||||||
return true;
|
name = name.substring("wg:".length(), name.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) {
|
if (ra.isExist(name)) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select", "%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getName()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.exist"));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wg && Jobs.getWorldGuardManager() != null) {
|
|
||||||
name = Jobs.getWorldGuardManager().getNameByName(name);
|
|
||||||
if (name == null) {
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgDontExist"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!wg)
|
if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) {
|
||||||
ra.addNew(new RestrictedArea(name, Jobs.getSelectionManager().getSelectionCuboid(player), bonus), true);
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select", "%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getName()));
|
||||||
else
|
return true;
|
||||||
ra.addNew(new RestrictedArea(name, name, bonus), true);
|
}
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.addedNew", "%bonus%", bonus));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2 && args[0].equalsIgnoreCase("remove") && player.hasPermission("jobs.area.remove")) {
|
if (wg && Jobs.getWorldGuardManager() != null) {
|
||||||
String name = args[1];
|
name = Jobs.getWorldGuardManager().getNameByName(name);
|
||||||
|
if (name == null) {
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgDontExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!ra.isExist(name)) {
|
if (!wg)
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.dontExist"));
|
ra.addNew(new RestrictedArea(name, Jobs.getSelectionManager().getSelectionCuboid(player), bonus), true);
|
||||||
|
else
|
||||||
|
ra.addNew(new RestrictedArea(name, name, bonus), true);
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.addedNew", "%bonus%", bonus));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ra.remove(name, true);
|
if (args.length == 2) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.removed", "%name%", name));
|
if (args[0].equalsIgnoreCase("remove")) {
|
||||||
return true;
|
if (!Jobs.hasPermission(player, "jobs.area.remove", true))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
String name = args[1];
|
||||||
|
|
||||||
|
if (!ra.isExist(name)) {
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.dontExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ra.remove(name);
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.removed", "%name%", name));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 1 && args[0].equalsIgnoreCase("info")) {
|
if (args.length == 1 && args[0].equalsIgnoreCase("info")) {
|
||||||
@ -139,11 +146,12 @@ public class area implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 0) {
|
||||||
if (args[0].equalsIgnoreCase("add")) {
|
if (args[0].equalsIgnoreCase("add")) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.help.addUsage"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.help.addUsage"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("remove")) {
|
if (args[0].equalsIgnoreCase("remove")) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.help.removeUsage"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.help.removeUsage"));
|
||||||
return true;
|
return true;
|
||||||
|
@ -40,15 +40,27 @@ public class RestrictedAreaManager {
|
|||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String name, boolean save) {
|
public void remove(String name) {
|
||||||
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
||||||
if (area.getKey().equalsIgnoreCase(name)) {
|
if (area.getKey().equalsIgnoreCase(name)) {
|
||||||
restrictedAreas.remove(area.getKey());
|
restrictedAreas.remove(area.getKey());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (save)
|
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
|
||||||
save();
|
if (f.exists()) {
|
||||||
|
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||||
|
conf.options().indent(2);
|
||||||
|
conf.options().copyDefaults(true);
|
||||||
|
StringBuilder header = new StringBuilder();
|
||||||
|
header = addHeader(header);
|
||||||
|
conf.set("restrictedareas." + name, null);
|
||||||
|
try {
|
||||||
|
conf.save(f);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, RestrictedArea> getRestrictedAres() {
|
public HashMap<String, RestrictedArea> getRestrictedAres() {
|
||||||
@ -98,9 +110,8 @@ public class RestrictedAreaManager {
|
|||||||
for (RestrictedArea area : getRestrictedAreasByLoc(player.getLocation())) {
|
for (RestrictedArea area : getRestrictedAreasByLoc(player.getLocation())) {
|
||||||
if (area.inRestrictedArea(player.getLocation()))
|
if (area.inRestrictedArea(player.getLocation()))
|
||||||
return area.getMultiplier();
|
return area.getMultiplier();
|
||||||
if (area.getWgName() != null && Jobs.getWorldGuardManager() != null && Jobs.getWorldGuardManager().inArea(player.getLocation(), area.getWgName())) {
|
if (area.getWgName() != null && Jobs.getWorldGuardManager() != null && Jobs.getWorldGuardManager().inArea(player.getLocation(), area.getWgName()))
|
||||||
return area.getMultiplier();
|
return area.getMultiplier();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0D;
|
return 0D;
|
||||||
@ -113,9 +124,8 @@ public class RestrictedAreaManager {
|
|||||||
areas.add(area.getValue());
|
areas.add(area.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Jobs.getWorldGuardManager() != null) {
|
if (Jobs.getWorldGuardManager() != null)
|
||||||
areas.addAll(Jobs.getWorldGuardManager().getArea(loc));
|
areas.addAll(Jobs.getWorldGuardManager().getArea(loc));
|
||||||
}
|
|
||||||
|
|
||||||
return areas;
|
return areas;
|
||||||
}
|
}
|
||||||
@ -171,7 +181,7 @@ public class RestrictedAreaManager {
|
|||||||
* loads from Jobs/restrictedAreas.yml
|
* loads from Jobs/restrictedAreas.yml
|
||||||
*/
|
*/
|
||||||
public synchronized void load() {
|
public synchronized void load() {
|
||||||
this.restrictedAreas.clear();
|
restrictedAreas.clear();
|
||||||
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
|
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
|
||||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||||
conf.options().indent(2);
|
conf.options().indent(2);
|
||||||
@ -186,10 +196,9 @@ public class RestrictedAreaManager {
|
|||||||
for (String areaKey : areaSection.getKeys(false)) {
|
for (String areaKey : areaSection.getKeys(false)) {
|
||||||
double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier", 0.0);
|
double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier", 0.0);
|
||||||
|
|
||||||
if (conf.isBoolean("restrictedareas." + areaKey + ".WG")) {
|
if (conf.isBoolean("restrictedareas." + areaKey + ".WG"))
|
||||||
RestrictedArea ar = new RestrictedArea(areaKey, areaKey, multiplier);
|
addNew(new RestrictedArea(areaKey, areaKey, multiplier));
|
||||||
addNew(ar);
|
else {
|
||||||
} else {
|
|
||||||
|
|
||||||
String worldName = conf.getString("restrictedareas." + areaKey + ".world");
|
String worldName = conf.getString("restrictedareas." + areaKey + ".world");
|
||||||
World world = Bukkit.getServer().getWorld(worldName);
|
World world = Bukkit.getServer().getWorld(worldName);
|
||||||
@ -205,7 +214,7 @@ public class RestrictedAreaManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (restrictedAreas.size() != 0)
|
if (restrictedAreas.size() > 0)
|
||||||
Jobs.consoleMsg("&e[Jobs] Loaded " + restrictedAreas.size() + " restricted areas!");
|
Jobs.consoleMsg("&e[Jobs] Loaded " + restrictedAreas.size() + " restricted areas!");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user