mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 15:03:36 +01:00
Support for worldguard and restricted areas
This commit is contained in:
parent
c591f35671
commit
9940e9f3c6
11
pom.xml
11
pom.xml
@ -76,8 +76,19 @@
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${basedir}/libs/MythicMobs-4.1.0.jar</systemPath>
|
<systemPath>${basedir}/libs/MythicMobs-4.1.0.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- WorldGuard -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q</groupId>
|
||||||
|
<artifactId>worldguard</artifactId>
|
||||||
|
<version>6.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<!-- WorldGuard -->
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
|
</repository>
|
||||||
<!-- Spigot -->
|
<!-- Spigot -->
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
|
@ -37,6 +37,7 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.CmiItems.ItemManager;
|
import com.gamingmesh.jobs.CmiItems.ItemManager;
|
||||||
@ -46,6 +47,7 @@ import com.gamingmesh.jobs.MythicMobs.MythicMobInterface;
|
|||||||
import com.gamingmesh.jobs.MythicMobs.MythicMobs2;
|
import com.gamingmesh.jobs.MythicMobs.MythicMobs2;
|
||||||
import com.gamingmesh.jobs.MythicMobs.MythicMobs4;
|
import com.gamingmesh.jobs.MythicMobs.MythicMobs4;
|
||||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||||
|
import com.gamingmesh.jobs.WorldGuard.WorldGuardManager;
|
||||||
import com.gamingmesh.jobs.api.JobsExpGainEvent;
|
import com.gamingmesh.jobs.api.JobsExpGainEvent;
|
||||||
import com.gamingmesh.jobs.commands.JobsCommands;
|
import com.gamingmesh.jobs.commands.JobsCommands;
|
||||||
import com.gamingmesh.jobs.config.BlockProtectionManager;
|
import com.gamingmesh.jobs.config.BlockProtectionManager;
|
||||||
@ -119,6 +121,7 @@ public class Jobs extends JavaPlugin {
|
|||||||
|
|
||||||
private static MythicMobInterface MythicManager;
|
private static MythicMobInterface MythicManager;
|
||||||
private static MyPetManager myPetManager;
|
private static MyPetManager myPetManager;
|
||||||
|
private static WorldGuardManager worldGuardManager;
|
||||||
|
|
||||||
private static ConfigManager configManager;
|
private static ConfigManager configManager;
|
||||||
private static GeneralConfigManager GconfigManager;
|
private static GeneralConfigManager GconfigManager;
|
||||||
@ -177,6 +180,10 @@ public class Jobs extends JavaPlugin {
|
|||||||
return myPetManager;
|
return myPetManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WorldGuardManager getWorldGuardManager() {
|
||||||
|
return worldGuardManager;
|
||||||
|
}
|
||||||
|
|
||||||
public void setMythicManager() {
|
public void setMythicManager() {
|
||||||
try {
|
try {
|
||||||
Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI");
|
Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI");
|
||||||
@ -186,9 +193,20 @@ public class Jobs extends JavaPlugin {
|
|||||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
|
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
|
||||||
MythicManager = new MythicMobs4(this);
|
MythicManager = new MythicMobs4(this);
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (MythicManager != null)
|
||||||
|
consoleMsg("&e[Jobs] MythicMobs detected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean setWorldGuard() {
|
||||||
|
Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
|
if (plugin != null) {
|
||||||
|
worldGuardManager = new WorldGuardManager(this);
|
||||||
|
consoleMsg("&e[Jobs] WorldGuard detected.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MythicMobInterface getMythicManager() {
|
public static MythicMobInterface getMythicManager() {
|
||||||
@ -776,7 +794,8 @@ public class Jobs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setMyPetManager();
|
setMyPetManager();
|
||||||
|
setWorldGuard();
|
||||||
|
|
||||||
setMythicManager();
|
setMythicManager();
|
||||||
if (MythicManager != null && MythicManager.Check() && GconfigManager.MythicMobsEnabled) {
|
if (MythicManager != null && MythicManager.Check() && GconfigManager.MythicMobsEnabled) {
|
||||||
MythicManager.registerListener();
|
MythicManager.registerListener();
|
||||||
|
@ -53,7 +53,7 @@ public class MyPetManager {
|
|||||||
mp = MyPetApi.getPlayerManager();
|
mp = MyPetApi.getPlayerManager();
|
||||||
mppm = MyPetApi.getMyPetManager();
|
mppm = MyPetApi.getMyPetManager();
|
||||||
enabled = true;
|
enabled = true;
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MyPet was found - Enabling capabilities."));
|
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MyPet detected"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
6
src/main/java/com/gamingmesh/jobs/WorldGuard/.gitignore
vendored
Normal file
6
src/main/java/com/gamingmesh/jobs/WorldGuard/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/MythicMobs2Listener.class
|
||||||
|
/MythicMobsManager.class
|
||||||
|
/MythicMobInterface.class
|
||||||
|
/MythicMobs2.class
|
||||||
|
/MythicMobs4.class
|
||||||
|
/MythicMobs4Listener.class
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.gamingmesh.jobs.WorldGuard;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.container.RestrictedArea;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
public class WorldGuardManager {
|
||||||
|
|
||||||
|
private Jobs plugin;
|
||||||
|
WorldGuardPlugin wg;
|
||||||
|
|
||||||
|
public WorldGuardManager(Jobs plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
Plugin pl = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||||
|
if (pl != null && (pl instanceof WorldGuardPlugin)) {
|
||||||
|
wg = (WorldGuardPlugin) pl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RestrictedArea> getArea(Location loc) {
|
||||||
|
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
|
||||||
|
for (ProtectedRegion one : regions.getRegions()) {
|
||||||
|
if (!Jobs.getRestrictedAreaManager().isExist(one.getId()))
|
||||||
|
continue;
|
||||||
|
return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
||||||
|
}
|
||||||
|
return new ArrayList<RestrictedArea>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inArea(Location loc, String name) {
|
||||||
|
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
|
||||||
|
for (ProtectedRegion one : regions.getRegions()) {
|
||||||
|
if (!one.getId().equalsIgnoreCase(name))
|
||||||
|
continue;
|
||||||
|
if (!one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||||
|
continue;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNameByName(String name) {
|
||||||
|
for (World one : Bukkit.getWorlds()) {
|
||||||
|
Map<String, ProtectedRegion> regions = wg.getRegionContainer().get(one).getRegions();
|
||||||
|
for (Entry<String, ProtectedRegion> oneR : regions.entrySet()) {
|
||||||
|
if (!oneR.getKey().equalsIgnoreCase(name))
|
||||||
|
continue;
|
||||||
|
return oneR.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -13,6 +13,7 @@ import com.gamingmesh.jobs.commands.JobCommand;
|
|||||||
import com.gamingmesh.jobs.config.RestrictedAreaManager;
|
import com.gamingmesh.jobs.config.RestrictedAreaManager;
|
||||||
import com.gamingmesh.jobs.container.CuboidArea;
|
import com.gamingmesh.jobs.container.CuboidArea;
|
||||||
import com.gamingmesh.jobs.container.RestrictedArea;
|
import com.gamingmesh.jobs.container.RestrictedArea;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
|
|
||||||
public class area implements Cmd {
|
public class area implements Cmd {
|
||||||
|
|
||||||
@ -40,16 +41,35 @@ public class area implements Cmd {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Boolean wg = false;
|
||||||
|
|
||||||
|
if (name.startsWith("wg:")) {
|
||||||
|
wg = true;
|
||||||
|
name = name.substring("wg:".length(), name.length());
|
||||||
|
}
|
||||||
|
|
||||||
if (ra.isExist(name)) {
|
if (ra.isExist(name)) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.exist"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.exist"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Jobs.getSelectionManager().hasPlacedBoth(player)) {
|
if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select", "%tool%", Material.getMaterial(Jobs.getGCManager().getSelectionTooldID).name().toLowerCase()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select", "%tool%", Material.getMaterial(Jobs.getGCManager().getSelectionTooldID).name().toLowerCase()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ra.addNew(new RestrictedArea(name, Jobs.getSelectionManager().getSelectionCuboid(player), bonus), 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wg)
|
||||||
|
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));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.addedNew", "%bonus%", bonus));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -100,16 +120,22 @@ public class area implements Cmd {
|
|||||||
for (Entry<String, RestrictedArea> area : areas.entrySet()) {
|
for (Entry<String, RestrictedArea> area : areas.entrySet()) {
|
||||||
i++;
|
i++;
|
||||||
CuboidArea cuboid = area.getValue().getCuboidArea();
|
CuboidArea cuboid = area.getValue().getCuboidArea();
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.list", "%number%", i,
|
if (area.getValue().getWgName() == null) {
|
||||||
"%areaname%", area.getKey(),
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.list", "%number%", i,
|
||||||
"%worldname%", cuboid.getWorld().getName(),
|
"%areaname%", area.getKey(),
|
||||||
"%x1%", cuboid.getLowLoc().getBlockX(),
|
"%worldname%", cuboid.getWorld().getName(),
|
||||||
"%y1%", cuboid.getLowLoc().getBlockY(),
|
"%x1%", cuboid.getLowLoc().getBlockX(),
|
||||||
"%z1%", cuboid.getLowLoc().getBlockZ(),
|
"%y1%", cuboid.getLowLoc().getBlockY(),
|
||||||
"%x2%", cuboid.getHighLoc().getBlockX(),
|
"%z1%", cuboid.getLowLoc().getBlockZ(),
|
||||||
"%y2%", cuboid.getHighLoc().getBlockY(),
|
"%x2%", cuboid.getHighLoc().getBlockX(),
|
||||||
"%z2%", cuboid.getHighLoc().getBlockZ(),
|
"%y2%", cuboid.getHighLoc().getBlockY(),
|
||||||
"%bonus%", area.getValue().getMultiplier()));
|
"%z2%", cuboid.getHighLoc().getBlockZ(),
|
||||||
|
"%bonus%", area.getValue().getMultiplier()));
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgList", "%number%", i,
|
||||||
|
"%areaname%", area.getKey(),
|
||||||
|
"%bonus%", area.getValue().getMultiplier()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||||
return true;
|
return true;
|
||||||
@ -126,7 +152,7 @@ public class area implements Cmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -369,11 +369,12 @@ public class LanguageManager {
|
|||||||
|
|
||||||
c.get("command.area.help.info", "Modify restricted areas.");
|
c.get("command.area.help.info", "Modify restricted areas.");
|
||||||
c.get("command.area.help.args", "add/remove/info/list");
|
c.get("command.area.help.args", "add/remove/info/list");
|
||||||
c.get("command.area.help.addUsage", "&eUsage: &6/Jobs area add [areaName] [bonus]");
|
c.get("command.area.help.addUsage", "&eUsage: &6/Jobs area add [areaName/wg:worldGuardAreaName] [bonus]");
|
||||||
c.get("command.area.help.removeUsage", "&eUsage: &6/Jobs area remove [areaName]");
|
c.get("command.area.help.removeUsage", "&eUsage: &6/Jobs area remove [areaName]");
|
||||||
c.get("command.area.output.addedNew", "&eAdded new restricted area with &6%bonus% &ebonus");
|
c.get("command.area.output.addedNew", "&eAdded new restricted area with &6%bonus% &ebonus");
|
||||||
c.get("command.area.output.removed", "&eRemoved restricted area &6%name%");
|
c.get("command.area.output.removed", "&eRemoved restricted area &6%name%");
|
||||||
c.get("command.area.output.list", "&e%number%&a. &e%areaname% &e%worldname% (&a%x1%:%y1%:%z1%/&e%x2%:%y2%:%z2%) &6%bonus%");
|
c.get("command.area.output.list", "&e%number%&a. &e%areaname% &e%worldname% (&a%x1%:%y1%:%z1%/&e%x2%:%y2%:%z2%) &6%bonus%");
|
||||||
|
c.get("command.area.output.wgList", "&e%number%&a. WorldGuard: &e%areaname% &6%bonus%");
|
||||||
c.get("command.area.output.noAreas", "&eThere is no saved restricted areas");
|
c.get("command.area.output.noAreas", "&eThere is no saved restricted areas");
|
||||||
c.get("command.area.output.noAreasByLoc", "&eThere is no restricted areas in this location");
|
c.get("command.area.output.noAreasByLoc", "&eThere is no restricted areas in this location");
|
||||||
c.get("command.area.output.areaList", "&eRestricted areas by your location: &6%list%");
|
c.get("command.area.output.areaList", "&eRestricted areas by your location: &6%list%");
|
||||||
@ -382,6 +383,7 @@ public class LanguageManager {
|
|||||||
c.get("command.area.output.select", "&eSelect 2 points with selection tool (%tool%)");
|
c.get("command.area.output.select", "&eSelect 2 points with selection tool (%tool%)");
|
||||||
c.get("command.area.output.exist", "&eRestriction area by this name already exist");
|
c.get("command.area.output.exist", "&eRestriction area by this name already exist");
|
||||||
c.get("command.area.output.dontExist", "&eRestriction area by this name don't exist");
|
c.get("command.area.output.dontExist", "&eRestriction area by this name don't exist");
|
||||||
|
c.get("command.area.output.wgDontExist", "&eWorldGuard area by this name don't exist");
|
||||||
|
|
||||||
c.get("command.log.help.info", "Shows statistics.");
|
c.get("command.log.help.info", "Shows statistics.");
|
||||||
c.get("command.log.help.args", "[playername]");
|
c.get("command.log.help.args", "[playername]");
|
||||||
|
@ -46,10 +46,10 @@ public class RestrictedAreaManager {
|
|||||||
if (save)
|
if (save)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String name, boolean save) {
|
public void remove(String name, boolean save) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -57,8 +57,8 @@ public class RestrictedAreaManager {
|
|||||||
if (save)
|
if (save)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, RestrictedArea> getRestrictedAres(){
|
public HashMap<String, RestrictedArea> getRestrictedAres() {
|
||||||
return restrictedAreas;
|
return restrictedAreas;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,15 +72,21 @@ public class RestrictedAreaManager {
|
|||||||
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
||||||
String areaKey = area.getKey();
|
String areaKey = area.getKey();
|
||||||
CuboidArea cuboid = area.getValue().getCuboidArea();
|
CuboidArea cuboid = area.getValue().getCuboidArea();
|
||||||
conf.set("restrictedareas." + areaKey + ".world", cuboid.getWorld().getName());
|
|
||||||
conf.set("restrictedareas." + areaKey + ".multiplier", area.getValue().getMultiplier());
|
conf.set("restrictedareas." + areaKey + ".multiplier", area.getValue().getMultiplier());
|
||||||
conf.set("restrictedareas." + areaKey + ".point1.x", cuboid.getLowLoc().getBlockX());
|
|
||||||
conf.set("restrictedareas." + areaKey + ".point1.y", cuboid.getLowLoc().getBlockY());
|
if (area.getValue().getWgName() == null) {
|
||||||
conf.set("restrictedareas." + areaKey + ".point1.z", cuboid.getLowLoc().getBlockZ());
|
conf.set("restrictedareas." + areaKey + ".world", cuboid.getWorld().getName());
|
||||||
conf.set("restrictedareas." + areaKey + ".point2.x", cuboid.getHighLoc().getBlockX());
|
conf.set("restrictedareas." + areaKey + ".point1.x", cuboid.getLowLoc().getBlockX());
|
||||||
conf.set("restrictedareas." + areaKey + ".point2.y", cuboid.getHighLoc().getBlockY());
|
conf.set("restrictedareas." + areaKey + ".point1.y", cuboid.getLowLoc().getBlockY());
|
||||||
conf.set("restrictedareas." + areaKey + ".point2.z", cuboid.getHighLoc().getBlockZ());
|
conf.set("restrictedareas." + areaKey + ".point1.z", cuboid.getLowLoc().getBlockZ());
|
||||||
|
conf.set("restrictedareas." + areaKey + ".point2.x", cuboid.getHighLoc().getBlockX());
|
||||||
|
conf.set("restrictedareas." + areaKey + ".point2.y", cuboid.getHighLoc().getBlockY());
|
||||||
|
conf.set("restrictedareas." + areaKey + ".point2.z", cuboid.getHighLoc().getBlockZ());
|
||||||
|
} else
|
||||||
|
conf.set("restrictedareas." + areaKey + ".WG", true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
conf.save(f);
|
conf.save(f);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -96,9 +102,13 @@ public class RestrictedAreaManager {
|
|||||||
public synchronized double getRestrictedMultiplier(Player player) {
|
public synchronized double getRestrictedMultiplier(Player player) {
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return 0D;
|
return 0D;
|
||||||
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
for (RestrictedArea area : getRestrictedAreasByLoc(player.getLocation())) {
|
||||||
if (area.getValue().inRestrictedArea(player.getLocation()))
|
if (area.inRestrictedArea(player.getLocation()))
|
||||||
return area.getValue().getMultiplier();
|
return area.getMultiplier();
|
||||||
|
if (area.getWgName() != null && Jobs.getWorldGuardManager() != null && Jobs.getWorldGuardManager().inArea(player.getLocation(), area.getWgName())) {
|
||||||
|
return area.getMultiplier();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0D;
|
return 0D;
|
||||||
}
|
}
|
||||||
@ -109,6 +119,20 @@ public class RestrictedAreaManager {
|
|||||||
if (area.getValue().inRestrictedArea(loc))
|
if (area.getValue().inRestrictedArea(loc))
|
||||||
areas.add(area.getValue());
|
areas.add(area.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Jobs.getWorldGuardManager() != null) {
|
||||||
|
areas.addAll(Jobs.getWorldGuardManager().getArea(loc));
|
||||||
|
}
|
||||||
|
|
||||||
|
return areas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized List<RestrictedArea> getRestrictedAreasByName(String name) {
|
||||||
|
List<RestrictedArea> areas = new ArrayList<RestrictedArea>();
|
||||||
|
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
||||||
|
if (area.getKey().equalsIgnoreCase(name))
|
||||||
|
areas.add(area.getValue());
|
||||||
|
}
|
||||||
return areas;
|
return areas;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,17 +191,24 @@ public class RestrictedAreaManager {
|
|||||||
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
|
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
|
||||||
if (areaSection != null) {
|
if (areaSection != null) {
|
||||||
for (String areaKey : areaSection.getKeys(false)) {
|
for (String areaKey : areaSection.getKeys(false)) {
|
||||||
String worldName = conf.getString("restrictedareas." + areaKey + ".world");
|
|
||||||
double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier", 0.0);
|
double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier", 0.0);
|
||||||
World world = Bukkit.getServer().getWorld(worldName);
|
|
||||||
if (world == null)
|
|
||||||
continue;
|
|
||||||
Location point1 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point1.x", 0.0), conf.getDouble("restrictedareas." + areaKey
|
|
||||||
+ ".point1.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point1.z", 0.0));
|
|
||||||
|
|
||||||
Location point2 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point2.x", 0.0), conf.getDouble("restrictedareas." + areaKey
|
if (conf.isBoolean("restrictedareas." + areaKey + ".WG")) {
|
||||||
+ ".point2.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point2.z", 0.0));
|
RestrictedArea ar = new RestrictedArea(areaKey, areaKey, multiplier);
|
||||||
addNew(new RestrictedArea(areaKey, new CuboidArea(point1, point2), multiplier));
|
addNew(ar);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
String worldName = conf.getString("restrictedareas." + areaKey + ".world");
|
||||||
|
World world = Bukkit.getServer().getWorld(worldName);
|
||||||
|
if (world == null)
|
||||||
|
continue;
|
||||||
|
Location point1 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point1.x", 0.0), conf.getDouble("restrictedareas." + areaKey
|
||||||
|
+ ".point1.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point1.z", 0.0));
|
||||||
|
|
||||||
|
Location point2 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point2.x", 0.0), conf.getDouble("restrictedareas." + areaKey
|
||||||
|
+ ".point2.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point2.z", 0.0));
|
||||||
|
addNew(new RestrictedArea(areaKey, new CuboidArea(point1, point2), multiplier));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,12 +25,19 @@ public class RestrictedArea {
|
|||||||
private CuboidArea area;
|
private CuboidArea area;
|
||||||
private double multiplier;
|
private double multiplier;
|
||||||
private String name;
|
private String name;
|
||||||
|
private String wgName;
|
||||||
|
|
||||||
public RestrictedArea(String name, CuboidArea area, double multiplier) {
|
public RestrictedArea(String name, CuboidArea area, double multiplier) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.area = area;
|
this.area = area;
|
||||||
this.multiplier = multiplier;
|
this.multiplier = multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RestrictedArea(String name, String wgName, double multiplier) {
|
||||||
|
this.name = name;
|
||||||
|
this.wgName = wgName;
|
||||||
|
this.multiplier = multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
public CuboidArea getCuboidArea() {
|
public CuboidArea getCuboidArea() {
|
||||||
return this.area;
|
return this.area;
|
||||||
@ -52,8 +59,9 @@ public class RestrictedArea {
|
|||||||
* @return false - the location is outside the restricted area
|
* @return false - the location is outside the restricted area
|
||||||
*/
|
*/
|
||||||
public boolean inRestrictedArea(Location loc) {
|
public boolean inRestrictedArea(Location loc) {
|
||||||
if (loc == null)
|
if (loc == null || area == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!loc.getWorld().getName().equals(area.getWorld().getName()))
|
if (!loc.getWorld().getName().equals(area.getWorld().getName()))
|
||||||
return false;
|
return false;
|
||||||
if (area.getLowLoc().getBlockX() > loc.getBlockX())
|
if (area.getLowLoc().getBlockX() > loc.getBlockX())
|
||||||
@ -74,4 +82,12 @@ public class RestrictedArea {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getWgName() {
|
||||||
|
return wgName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWgName(String wgName) {
|
||||||
|
this.wgName = wgName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.gamingmesh.jobs.selection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import com.gamingmesh.jobs.container.CuboidArea;
|
import com.gamingmesh.jobs.container.CuboidArea;
|
||||||
@ -74,36 +73,4 @@ public class SelectionManager {
|
|||||||
playerLoc1.remove(player.getName());
|
playerLoc1.remove(player.getName());
|
||||||
playerLoc2.remove(player.getName());
|
playerLoc2.remove(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectChunk(Player player) {
|
|
||||||
Chunk chunk = player.getWorld().getChunkAt(player.getLocation());
|
|
||||||
int xcoord = chunk.getX() * 16;
|
|
||||||
int zcoord = chunk.getZ() * 16;
|
|
||||||
int ycoord = MIN_HEIGHT;
|
|
||||||
int xmax = xcoord + 15;
|
|
||||||
int zmax = zcoord + 15;
|
|
||||||
int ymax = player.getLocation().getWorld().getMaxHeight() - 1;
|
|
||||||
playerLoc1.put(player.getName(), new Location(player.getWorld(), xcoord, ycoord, zcoord));
|
|
||||||
playerLoc2.put(player.getName(), new Location(player.getWorld(), xmax, ymax, zmax));
|
|
||||||
player.sendMessage("msg");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean worldEdit(Player player) {
|
|
||||||
player.sendMessage("msg");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean worldEditUpdate(Player player) {
|
|
||||||
player.sendMessage("msg");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectBySize(Player player, int xsize, int ysize, int zsize) {
|
|
||||||
Location myloc = player.getLocation();
|
|
||||||
Location loc1 = new Location(myloc.getWorld(), myloc.getBlockX() + xsize, myloc.getBlockY() + ysize, myloc.getBlockZ() + zsize);
|
|
||||||
Location loc2 = new Location(myloc.getWorld(), myloc.getBlockX() - xsize, myloc.getBlockY() - ysize, myloc.getBlockZ() - zsize);
|
|
||||||
placeLoc1(player, loc1);
|
|
||||||
placeLoc2(player, loc2);
|
|
||||||
player.sendMessage("msg");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ main: com.gamingmesh.jobs.Jobs
|
|||||||
version: 3.9.3
|
version: 3.9.3
|
||||||
website: https://www.spigotmc.org/resources/jobs-reborn.4216/
|
website: https://www.spigotmc.org/resources/jobs-reborn.4216/
|
||||||
author: phrstbrn
|
author: phrstbrn
|
||||||
softdepend: [Vault, iConomy, MythicMobs, McMMO]
|
softdepend: [Vault, iConomy, MythicMobs, McMMO, WorldGuard]
|
||||||
commands:
|
commands:
|
||||||
jobs:
|
jobs:
|
||||||
description: Jobs
|
description: Jobs
|
||||||
|
Loading…
Reference in New Issue
Block a user