mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
Fix for boonus issue when bonus is null
This commit is contained in:
parent
d518b0b8a8
commit
14423470ac
@ -8,5 +8,6 @@
|
|||||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/CheckMyInventory/lib/spigot-1.11.jar"/>
|
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/CheckMyInventory/lib/spigot-1.11.jar"/>
|
||||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-2.1.8.jar"/>
|
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-2.1.8.jar"/>
|
||||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Residence/lib/iConomy7.0.6.jar"/>
|
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Residence/lib/iConomy7.0.6.jar"/>
|
||||||
|
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Residence/lib/worldedit-bukkit-6.1.1-SNAPSHOT-dist.jar"/>
|
||||||
<classpathentry kind="output" path=""/>
|
<classpathentry kind="output" path=""/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
<listEntry value="/Jobs"/>
|
<listEntry value="/Jobs"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="4"/>
|
<listEntry value="4"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Jobs"/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Jobs"/>
|
||||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/Jobs/com/gamingmesh/jobs/build.xml}"/>
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/Jobs/com/gamingmesh/jobs/build.xml}"/>
|
||||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
|
||||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Jobs}"/>
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Jobs}"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
@ -79,6 +79,7 @@ import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
|||||||
import com.gamingmesh.jobs.listeners.McMMOlistener;
|
import com.gamingmesh.jobs.listeners.McMMOlistener;
|
||||||
import com.gamingmesh.jobs.listeners.MythicMobsListener;
|
import com.gamingmesh.jobs.listeners.MythicMobsListener;
|
||||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||||
|
import com.gamingmesh.jobs.selection.SelectionManager;
|
||||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||||
import com.gamingmesh.jobs.stuff.JobsClassLoader;
|
import com.gamingmesh.jobs.stuff.JobsClassLoader;
|
||||||
import com.gamingmesh.jobs.stuff.Loging;
|
import com.gamingmesh.jobs.stuff.Loging;
|
||||||
@ -139,6 +140,8 @@ public class Jobs extends JavaPlugin {
|
|||||||
private static ActionBar actionbar;
|
private static ActionBar actionbar;
|
||||||
private boolean running = false;
|
private boolean running = false;
|
||||||
|
|
||||||
|
protected static SelectionManager smanager;
|
||||||
|
|
||||||
public void setMcMMOlistener() {
|
public void setMcMMOlistener() {
|
||||||
McMMOlistener = new McMMOlistener(this);
|
McMMOlistener = new McMMOlistener(this);
|
||||||
}
|
}
|
||||||
@ -514,7 +517,7 @@ public class Jobs extends JavaPlugin {
|
|||||||
paymentThread.shutdown();
|
paymentThread.shutdown();
|
||||||
paymentThread = null;
|
paymentThread = null;
|
||||||
}
|
}
|
||||||
|
smanager = new SelectionManager();
|
||||||
if (dao != null) {
|
if (dao != null) {
|
||||||
dao.closeConnections();
|
dao.closeConnections();
|
||||||
}
|
}
|
||||||
@ -1148,4 +1151,8 @@ public class Jobs extends JavaPlugin {
|
|||||||
public static void consoleMsg(String msg) {
|
public static void consoleMsg(String msg) {
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SelectionManager getSelectionManager() {
|
||||||
|
return smanager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,7 @@ import com.gamingmesh.jobs.dao.JobsDAO;
|
|||||||
import com.gamingmesh.jobs.dao.JobsDAOData;
|
import com.gamingmesh.jobs.dao.JobsDAOData;
|
||||||
import com.gamingmesh.jobs.economy.PointsData;
|
import com.gamingmesh.jobs.economy.PointsData;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
import com.gamingmesh.jobs.stuff.PerformCommands;
|
import com.gamingmesh.jobs.stuff.PerformCommands;
|
||||||
import com.gamingmesh.jobs.stuff.Perm;
|
|
||||||
|
|
||||||
public class PlayerManager {
|
public class PlayerManager {
|
||||||
// private Map<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
|
// private Map<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
|
||||||
@ -188,7 +186,6 @@ public class PlayerManager {
|
|||||||
} else {
|
} else {
|
||||||
jPlayer.onDisconnect();
|
jPlayer.onDisconnect();
|
||||||
}
|
}
|
||||||
Jobs.getJobsDAO().updateSeen(jPlayer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -762,21 +759,25 @@ public class PlayerManager {
|
|||||||
if (ent != null && ent instanceof Tameable) {
|
if (ent != null && ent instanceof Tameable) {
|
||||||
Tameable t = (Tameable) ent;
|
Tameable t = (Tameable) ent;
|
||||||
if (t.isTamed() && t.getOwner() instanceof Player) {
|
if (t.isTamed() && t.getOwner() instanceof Player) {
|
||||||
boost.add(BoostOf.PetPay, new BoostMultiplier().add(Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay")));
|
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay");
|
||||||
|
if (amount != null)
|
||||||
|
boost.add(BoostOf.PetPay, new BoostMultiplier().add(amount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (victim != null && victim.hasMetadata(this.getMobSpawnerMetadata())) {
|
if (victim != null && victim.hasMetadata(this.getMobSpawnerMetadata())) {
|
||||||
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner")));
|
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner");
|
||||||
|
if (amount != null)
|
||||||
|
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getall) {
|
if (getall) {
|
||||||
Double mount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force);
|
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force);
|
||||||
if (mount != null)
|
if (amount != null)
|
||||||
boost.add(BoostOf.PetPay, new BoostMultiplier().add(mount));
|
boost.add(BoostOf.PetPay, new BoostMultiplier().add(amount));
|
||||||
mount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force);
|
amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force);
|
||||||
if (mount != null)
|
if (amount != null)
|
||||||
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(mount));
|
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
boost.add(BoostOf.Permission, Jobs.getPlayerManager().getBoost(player, prog, force));
|
boost.add(BoostOf.Permission, Jobs.getPlayerManager().getBoost(player, prog, force));
|
||||||
|
1
com/gamingmesh/jobs/api/.gitignore
vendored
1
com/gamingmesh/jobs/api/.gitignore
vendored
@ -8,3 +8,4 @@
|
|||||||
/JobsPaymentEvent.class
|
/JobsPaymentEvent.class
|
||||||
/JobsChunkChangeEvent.class
|
/JobsChunkChangeEvent.class
|
||||||
/JobsExpGainEvent.class
|
/JobsExpGainEvent.class
|
||||||
|
/JobsAreaSelectionEvent.class
|
||||||
|
1
com/gamingmesh/jobs/commands/list/.gitignore
vendored
1
com/gamingmesh/jobs/commands/list/.gitignore
vendored
@ -54,3 +54,4 @@
|
|||||||
/bp.class
|
/bp.class
|
||||||
/entitylist.class
|
/entitylist.class
|
||||||
/iteminfo.class
|
/iteminfo.class
|
||||||
|
/area.class
|
||||||
|
@ -6,13 +6,11 @@ import com.gamingmesh.jobs.Jobs;
|
|||||||
import com.gamingmesh.jobs.PlayerManager.BoostOf;
|
import com.gamingmesh.jobs.PlayerManager.BoostOf;
|
||||||
import com.gamingmesh.jobs.commands.Cmd;
|
import com.gamingmesh.jobs.commands.Cmd;
|
||||||
import com.gamingmesh.jobs.commands.JobCommand;
|
import com.gamingmesh.jobs.commands.JobCommand;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
|
||||||
import com.gamingmesh.jobs.container.Boost;
|
import com.gamingmesh.jobs.container.Boost;
|
||||||
import com.gamingmesh.jobs.container.CurrencyType;
|
import com.gamingmesh.jobs.container.CurrencyType;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
|
|
||||||
public class bonus implements Cmd {
|
public class bonus implements Cmd {
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ public class GeneralConfigManager {
|
|||||||
public boolean PaymentMethodsMoney;
|
public boolean PaymentMethodsMoney;
|
||||||
public boolean PaymentMethodsPoints;
|
public boolean PaymentMethodsPoints;
|
||||||
public boolean PaymentMethodsExp;
|
public boolean PaymentMethodsExp;
|
||||||
|
public int getSelectionTooldID;
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
public HashMap<CurrencyType, CurrencyLimit> currencyLimitUse = new HashMap<CurrencyType, CurrencyLimit>();
|
public HashMap<CurrencyType, CurrencyLimit> currencyLimitUse = new HashMap<CurrencyType, CurrencyLimit>();
|
||||||
@ -413,6 +414,8 @@ public class GeneralConfigManager {
|
|||||||
"Only enable this if you have a multi-server setup, or have a really good reason for enabling this.", "Turning this on will decrease database performance.");
|
"Only enable this if you have a multi-server setup, or have a really good reason for enabling this.", "Turning this on will decrease database performance.");
|
||||||
saveOnDisconnect = c.get("save-on-disconnect", false);
|
saveOnDisconnect = c.get("save-on-disconnect", false);
|
||||||
|
|
||||||
|
getSelectionTooldID = c.get("selectionTool", 294);
|
||||||
|
|
||||||
c.getW().addComment("MultiServerCompatability", "Enable if you are using one data base for multiple servers across bungee network",
|
c.getW().addComment("MultiServerCompatability", "Enable if you are using one data base for multiple servers across bungee network",
|
||||||
"This will force to load players data every time he is logging in to have most up to date data instead of having preloaded data",
|
"This will force to load players data every time he is logging in to have most up to date data instead of having preloaded data",
|
||||||
"This will enable automaticaly save-on-disconnect feature");
|
"This will enable automaticaly save-on-disconnect feature");
|
||||||
@ -859,4 +862,8 @@ public class GeneralConfigManager {
|
|||||||
public synchronized void startSqlite() {
|
public synchronized void startSqlite() {
|
||||||
Jobs.setDAO(JobsDAOSQLite.initialize(plugin));
|
Jobs.setDAO(JobsDAOSQLite.initialize(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSelectionTooldID() {
|
||||||
|
return getSelectionTooldID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ package com.gamingmesh.jobs.config;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -12,12 +15,13 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.container.CuboidArea;
|
||||||
import com.gamingmesh.jobs.container.RestrictedArea;
|
import com.gamingmesh.jobs.container.RestrictedArea;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
|
|
||||||
public class RestrictedAreaManager {
|
public class RestrictedAreaManager {
|
||||||
|
|
||||||
protected ArrayList<RestrictedArea> restrictedAreas = new ArrayList<RestrictedArea>();
|
protected HashMap<String, RestrictedArea> restrictedAreas = new HashMap<String, RestrictedArea>();
|
||||||
|
|
||||||
private Jobs plugin;
|
private Jobs plugin;
|
||||||
|
|
||||||
@ -25,32 +29,75 @@ public class RestrictedAreaManager {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isExist(String name) {
|
||||||
|
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
||||||
|
if (area.getKey().equalsIgnoreCase(name))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNew(RestrictedArea ra) {
|
||||||
|
addNew(ra, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNew(RestrictedArea ra, boolean save) {
|
||||||
|
restrictedAreas.put(ra.getName(), ra);
|
||||||
|
if (save)
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void save() {
|
||||||
|
File f = new File(plugin.getDataFolder(), "restrictedAreas.yml");
|
||||||
|
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||||
|
conf.options().indent(2);
|
||||||
|
conf.options().copyDefaults(true);
|
||||||
|
StringBuilder header = new StringBuilder();
|
||||||
|
header = addHeader(header);
|
||||||
|
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
||||||
|
String areaKey = area.getKey();
|
||||||
|
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 + ".point1.x", cuboid.getLowLoc().getBlockX());
|
||||||
|
conf.set("restrictedareas." + areaKey + ".point1.y", cuboid.getLowLoc().getBlockY());
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
conf.save(f);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the area multiplier for the player
|
* Gets the area multiplier for the player
|
||||||
* @param player
|
* @param player
|
||||||
* @return - the multiplier
|
* @return - the multiplier
|
||||||
*/
|
*/
|
||||||
public synchronized double getRestrictedMultiplier(Player player) {
|
public synchronized double getRestrictedMultiplier(Player player) {
|
||||||
for (RestrictedArea area : restrictedAreas) {
|
if (player == null)
|
||||||
if (area.inRestrictedArea(player))
|
return 0D;
|
||||||
return area.getMultiplier();
|
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
||||||
|
if (area.getValue().inRestrictedArea(player.getLocation()))
|
||||||
|
return area.getValue().getMultiplier();
|
||||||
}
|
}
|
||||||
return 0D;
|
return 0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to load the restricted areas configuration
|
|
||||||
*
|
|
||||||
* loads from Jobs/restrictedAreas.yml
|
|
||||||
*/
|
|
||||||
public synchronized void load() {
|
|
||||||
this.restrictedAreas.clear();
|
|
||||||
File f = new File(plugin.getDataFolder(), "restrictedAreas.yml");
|
|
||||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
|
||||||
conf.options().indent(2);
|
|
||||||
conf.options().copyDefaults(true);
|
|
||||||
StringBuilder header = new StringBuilder();
|
|
||||||
|
|
||||||
|
public synchronized List<RestrictedArea> getRestrictedAreasByLoc(Location loc) {
|
||||||
|
List<RestrictedArea> areas = new ArrayList<RestrictedArea>();
|
||||||
|
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
|
||||||
|
if (area.getValue().inRestrictedArea(loc))
|
||||||
|
areas.add(area.getValue());
|
||||||
|
}
|
||||||
|
return areas;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringBuilder addHeader(StringBuilder header) {
|
||||||
header.append("Restricted area configuration");
|
header.append("Restricted area configuration");
|
||||||
header.append(System.getProperty("line.separator"))
|
header.append(System.getProperty("line.separator"))
|
||||||
.append(System.getProperty("line.separator"))
|
.append(System.getProperty("line.separator"))
|
||||||
@ -82,6 +129,24 @@ public class RestrictedAreaManager {
|
|||||||
.append(" x: -150").append(System.getProperty("line.separator"))
|
.append(" x: -150").append(System.getProperty("line.separator"))
|
||||||
.append(" y: 100").append(System.getProperty("line.separator"))
|
.append(" y: 100").append(System.getProperty("line.separator"))
|
||||||
.append(" z: -150");
|
.append(" z: -150");
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to load the restricted areas configuration
|
||||||
|
*
|
||||||
|
* loads from Jobs/restrictedAreas.yml
|
||||||
|
*/
|
||||||
|
public synchronized void load() {
|
||||||
|
this.restrictedAreas.clear();
|
||||||
|
File f = new File(plugin.getDataFolder(), "restrictedAreas.yml");
|
||||||
|
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||||
|
conf.options().indent(2);
|
||||||
|
conf.options().copyDefaults(true);
|
||||||
|
StringBuilder header = new StringBuilder();
|
||||||
|
|
||||||
|
header = addHeader(header);
|
||||||
|
|
||||||
conf.options().header(header.toString());
|
conf.options().header(header.toString());
|
||||||
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
|
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
|
||||||
if (areaSection != null) {
|
if (areaSection != null) {
|
||||||
@ -96,13 +161,12 @@ public class RestrictedAreaManager {
|
|||||||
|
|
||||||
Location point2 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point2.x", 0.0), conf.getDouble("restrictedareas." + areaKey
|
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));
|
+ ".point2.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point2.z", 0.0));
|
||||||
this.restrictedAreas.add(new RestrictedArea(point1, point2, multiplier));
|
addNew(new RestrictedArea(areaKey, new CuboidArea(point1, point2), multiplier));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + restrictedAreas.size() + " restricted areas!");
|
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + restrictedAreas.size() + " restricted areas!");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
conf.save(f);
|
conf.save(f);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
1
com/gamingmesh/jobs/container/.gitignore
vendored
1
com/gamingmesh/jobs/container/.gitignore
vendored
@ -44,3 +44,4 @@
|
|||||||
/Boost.class
|
/Boost.class
|
||||||
/CurrencyType.class
|
/CurrencyType.class
|
||||||
/CurrencyLimit.class
|
/CurrencyLimit.class
|
||||||
|
/CuboidArea.class
|
||||||
|
@ -612,6 +612,7 @@ public class JobsPlayer {
|
|||||||
dao.saveLog(this);
|
dao.saveLog(this);
|
||||||
dao.savePoints(this);
|
dao.savePoints(this);
|
||||||
dao.recordPlayersLimits(this);
|
dao.recordPlayersLimits(this);
|
||||||
|
dao.updateSeen(this);
|
||||||
setSaved(true);
|
setSaved(true);
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
|
@ -19,34 +19,30 @@
|
|||||||
package com.gamingmesh.jobs.container;
|
package com.gamingmesh.jobs.container;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Restricted Area Class
|
|
||||||
*
|
|
||||||
* Holds data pertaining to restricted areas on the server
|
|
||||||
* @author Zak Ford <zak.j.ford@gmail.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class RestrictedArea {
|
public class RestrictedArea {
|
||||||
|
|
||||||
private Location location1;
|
private CuboidArea area;
|
||||||
private Location location2;
|
|
||||||
private double multiplier;
|
private double multiplier;
|
||||||
|
private String name;
|
||||||
|
|
||||||
public RestrictedArea(Location location1, Location location2, double multiplier) {
|
public RestrictedArea(String name, CuboidArea area, double multiplier) {
|
||||||
this.location1 = location1;
|
this.name = name;
|
||||||
this.location2 = location2;
|
this.area = area;
|
||||||
this.multiplier = multiplier;
|
this.multiplier = multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CuboidArea getCuboidArea() {
|
||||||
|
return this.area;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The multipler for the restricted area
|
* The multipler for the restricted area
|
||||||
* @return - the multipler for this restricted area
|
* @return - the multipler for this restricted area
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public double getMultiplier() {
|
public double getMultiplier() {
|
||||||
return this.multiplier - 1;
|
return this.multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,33 +51,27 @@ public class RestrictedArea {
|
|||||||
* @return true - the location is inside the restricted area
|
* @return true - the location is inside the restricted area
|
||||||
* @return false - the location is outside the restricted area
|
* @return false - the location is outside the restricted area
|
||||||
*/
|
*/
|
||||||
public boolean inRestrictedArea(Player player) {
|
public boolean inRestrictedArea(Location loc) {
|
||||||
if (player == null)
|
if (loc == null)
|
||||||
return false;
|
return false;
|
||||||
if (isBetween(player.getLocation().getX(), this.location1.getX(), this.location2.getX()) &&
|
if (!loc.getWorld().getName().equals(area.getWorld().getName()))
|
||||||
isBetween(player.getLocation().getY(), this.location1.getY(), this.location2.getY()) &&
|
return false;
|
||||||
isBetween(player.getLocation().getZ(), this.location1.getZ(), this.location2.getZ()) &&
|
if (area.getLowLoc().getBlockX() > loc.getBlockX())
|
||||||
this.location1.getWorld().equals(player.getLocation().getWorld()) &&
|
return false;
|
||||||
this.location2.getWorld().equals(player.getLocation().getWorld())) {
|
if (area.getHighLoc().getBlockX() < loc.getBlockX())
|
||||||
return true;
|
return false;
|
||||||
}
|
if (area.getLowLoc().getBlockZ() > loc.getBlockZ())
|
||||||
return false;
|
return false;
|
||||||
|
if (area.getHighLoc().getBlockZ() < loc.getBlockZ())
|
||||||
|
return false;
|
||||||
|
if (area.getLowLoc().getBlockY() > loc.getBlockY())
|
||||||
|
return false;
|
||||||
|
if (area.getHighLoc().getBlockY() < loc.getBlockY())
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String getName() {
|
||||||
* Function check if number is between bounds
|
return name;
|
||||||
* @param number - the number to be checked
|
|
||||||
* @param bound1 - the first bound
|
|
||||||
* @param bound2 - the second bound
|
|
||||||
* @return true - number is between bounds
|
|
||||||
* @return false - number is out of bounds
|
|
||||||
*/
|
|
||||||
private static boolean isBetween(double number, double bound1, double bound2) {
|
|
||||||
if (bound1 < bound2 && number > bound1 && number < bound2) {
|
|
||||||
return true;
|
|
||||||
} else if (bound1 > bound2 && number < bound1 && number > bound2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -928,8 +928,7 @@ public abstract class JobsDAO {
|
|||||||
return;
|
return;
|
||||||
PreparedStatement prest = null;
|
PreparedStatement prest = null;
|
||||||
try {
|
try {
|
||||||
prest = conn.prepareStatement("UPDATE `" + prefix
|
prest = conn.prepareStatement("UPDATE `" + prefix + "jobs` SET `level` = ?, `experience` = ? WHERE `userid` = ? AND `job` = ?;");
|
||||||
+ "jobs` SET `level` = ?, `experience` = ? WHERE `userid` = ? AND `job` = ?;");
|
|
||||||
for (JobProgression progression : player.getJobProgression()) {
|
for (JobProgression progression : player.getJobProgression()) {
|
||||||
prest.setInt(1, progression.getLevel());
|
prest.setInt(1, progression.getLevel());
|
||||||
prest.setInt(2, (int) progression.getExperience());
|
prest.setInt(2, (int) progression.getExperience());
|
||||||
|
@ -28,7 +28,9 @@ import java.util.regex.Pattern;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -60,6 +62,7 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.Gui.GuiInfoList;
|
import com.gamingmesh.jobs.Gui.GuiInfoList;
|
||||||
|
import com.gamingmesh.jobs.api.JobsAreaSelectionEvent;
|
||||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.container.JobLimitedItems;
|
import com.gamingmesh.jobs.container.JobLimitedItems;
|
||||||
@ -74,6 +77,50 @@ public class JobsListener implements Listener {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
|
public void onSelection(PlayerInteractEvent event) {
|
||||||
|
if (event.getPlayer() == null)
|
||||||
|
return;
|
||||||
|
//disabling plugin in world
|
||||||
|
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
|
||||||
|
return;
|
||||||
|
if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||||
|
return;
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
||||||
|
if (iih == null || iih.getType() == Material.AIR)
|
||||||
|
return;
|
||||||
|
int heldItemId = iih.getTypeId();
|
||||||
|
if (heldItemId != Jobs.getGCManager().getSelectionTooldID())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!player.hasPermission("jobs.selectarea"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (player.getGameMode() == GameMode.CREATIVE)
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
Jobs.getSelectionManager().placeLoc1(player, loc);
|
||||||
|
player.sendMessage("Selected: " + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ());
|
||||||
|
event.setCancelled(true);
|
||||||
|
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
Jobs.getSelectionManager().placeLoc2(player, loc);
|
||||||
|
player.sendMessage("Selected: " + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ());
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Jobs.getSelectionManager().hasPlacedBoth(player)) {
|
||||||
|
JobsAreaSelectionEvent jobsAreaSelectionEvent = new JobsAreaSelectionEvent(event.getPlayer(), Jobs.getSelectionManager().getSelectionCuboid(player));
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(jobsAreaSelectionEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onShopClick(InventoryClickEvent event) {
|
public void onShopClick(InventoryClickEvent event) {
|
||||||
if (Jobs.getShopManager().GuiList.isEmpty())
|
if (Jobs.getShopManager().GuiList.isEmpty())
|
||||||
|
@ -3,7 +3,7 @@ description: Jobs Plugin for the BukkitAPI
|
|||||||
main: com.gamingmesh.jobs.Jobs
|
main: com.gamingmesh.jobs.Jobs
|
||||||
version: 3.7.7
|
version: 3.7.7
|
||||||
author: phrstbrn
|
author: phrstbrn
|
||||||
softdepend: [Vault, iConomy, MythicMobs, McMMO]
|
softdepend: [Vault, iConomy, MythicMobs, McMMO, WorldEdit]
|
||||||
commands:
|
commands:
|
||||||
jobs:
|
jobs:
|
||||||
description: Jobs
|
description: Jobs
|
||||||
|
Loading…
Reference in New Issue
Block a user