1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +01:00

Fix for boonus issue when bonus is null

This commit is contained in:
Zrips 2017-01-15 20:43:56 +02:00
parent d518b0b8a8
commit 14423470ac
15 changed files with 213 additions and 95 deletions

View File

@ -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/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/worldedit-bukkit-6.1.1-SNAPSHOT-dist.jar"/>
<classpathentry kind="output" path=""/>
</classpath>

View File

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Jobs"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<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"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
<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_RUN_BUILD_KINDS" value="full,incremental,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Jobs}"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Jobs"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<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"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
<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_RUN_BUILD_KINDS" value="full,incremental,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Jobs}"/>
</launchConfiguration>

View File

@ -79,6 +79,7 @@ import com.gamingmesh.jobs.listeners.JobsPaymentListener;
import com.gamingmesh.jobs.listeners.McMMOlistener;
import com.gamingmesh.jobs.listeners.MythicMobsListener;
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
import com.gamingmesh.jobs.selection.SelectionManager;
import com.gamingmesh.jobs.stuff.ActionBar;
import com.gamingmesh.jobs.stuff.JobsClassLoader;
import com.gamingmesh.jobs.stuff.Loging;
@ -139,6 +140,8 @@ public class Jobs extends JavaPlugin {
private static ActionBar actionbar;
private boolean running = false;
protected static SelectionManager smanager;
public void setMcMMOlistener() {
McMMOlistener = new McMMOlistener(this);
}
@ -514,7 +517,7 @@ public class Jobs extends JavaPlugin {
paymentThread.shutdown();
paymentThread = null;
}
smanager = new SelectionManager();
if (dao != null) {
dao.closeConnections();
}
@ -1148,4 +1151,8 @@ public class Jobs extends JavaPlugin {
public static void consoleMsg(String msg) {
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
}
public static SelectionManager getSelectionManager() {
return smanager;
}
}

View File

@ -53,9 +53,7 @@ import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.dao.JobsDAOData;
import com.gamingmesh.jobs.economy.PointsData;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.PerformCommands;
import com.gamingmesh.jobs.stuff.Perm;
public class PlayerManager {
// private Map<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
@ -188,7 +186,6 @@ public class PlayerManager {
} else {
jPlayer.onDisconnect();
}
Jobs.getJobsDAO().updateSeen(jPlayer);
}
/**
@ -762,21 +759,25 @@ public class PlayerManager {
if (ent != null && ent instanceof Tameable) {
Tameable t = (Tameable) ent;
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())) {
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) {
Double mount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force);
if (mount != null)
boost.add(BoostOf.PetPay, new BoostMultiplier().add(mount));
mount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force);
if (mount != null)
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(mount));
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force);
if (amount != null)
boost.add(BoostOf.PetPay, new BoostMultiplier().add(amount));
amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force);
if (amount != null)
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount));
}
boost.add(BoostOf.Permission, Jobs.getPlayerManager().getBoost(player, prog, force));

View File

@ -8,3 +8,4 @@
/JobsPaymentEvent.class
/JobsChunkChangeEvent.class
/JobsExpGainEvent.class
/JobsAreaSelectionEvent.class

View File

@ -54,3 +54,4 @@
/bp.class
/entitylist.class
/iteminfo.class
/area.class

View File

@ -6,13 +6,11 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.PlayerManager.BoostOf;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.Boost;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
public class bonus implements Cmd {

View File

@ -69,6 +69,7 @@ public class GeneralConfigManager {
public boolean PaymentMethodsMoney;
public boolean PaymentMethodsPoints;
public boolean PaymentMethodsExp;
public int getSelectionTooldID;
// Limits
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.");
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",
"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");
@ -859,4 +862,8 @@ public class GeneralConfigManager {
public synchronized void startSqlite() {
Jobs.setDAO(JobsDAOSQLite.initialize(plugin));
}
public int getSelectionTooldID() {
return getSelectionTooldID;
}
}

View File

@ -3,6 +3,9 @@ package com.gamingmesh.jobs.config;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -12,12 +15,13 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.CuboidArea;
import com.gamingmesh.jobs.container.RestrictedArea;
import com.gamingmesh.jobs.stuff.ChatColor;
public class RestrictedAreaManager {
protected ArrayList<RestrictedArea> restrictedAreas = new ArrayList<RestrictedArea>();
protected HashMap<String, RestrictedArea> restrictedAreas = new HashMap<String, RestrictedArea>();
private Jobs plugin;
@ -25,32 +29,75 @@ public class RestrictedAreaManager {
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
* @param player
* @return - the multiplier
*/
public synchronized double getRestrictedMultiplier(Player player) {
for (RestrictedArea area : restrictedAreas) {
if (area.inRestrictedArea(player))
return area.getMultiplier();
if (player == null)
return 0D;
for (Entry<String, RestrictedArea> area : restrictedAreas.entrySet()) {
if (area.getValue().inRestrictedArea(player.getLocation()))
return area.getValue().getMultiplier();
}
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(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(" y: 100").append(System.getProperty("line.separator"))
.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());
ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas");
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
+ ".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!");
try {
conf.save(f);
} catch (IOException e) {

View File

@ -44,3 +44,4 @@
/Boost.class
/CurrencyType.class
/CurrencyLimit.class
/CuboidArea.class

View File

@ -612,6 +612,7 @@ public class JobsPlayer {
dao.saveLog(this);
dao.savePoints(this);
dao.recordPlayersLimits(this);
dao.updateSeen(this);
setSaved(true);
}
// }

View File

@ -19,34 +19,30 @@
package com.gamingmesh.jobs.container;
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 {
private Location location1;
private Location location2;
private CuboidArea area;
private double multiplier;
private String name;
public RestrictedArea(Location location1, Location location2, double multiplier) {
this.location1 = location1;
this.location2 = location2;
public RestrictedArea(String name, CuboidArea area, double multiplier) {
this.name = name;
this.area = area;
this.multiplier = multiplier;
}
public CuboidArea getCuboidArea() {
return this.area;
}
/**
* The multipler for the restricted area
* @return - the multipler for this restricted area
*/
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 false - the location is outside the restricted area
*/
public boolean inRestrictedArea(Player player) {
if (player == null)
public boolean inRestrictedArea(Location loc) {
if (loc == null)
return false;
if (isBetween(player.getLocation().getX(), this.location1.getX(), this.location2.getX()) &&
isBetween(player.getLocation().getY(), this.location1.getY(), this.location2.getY()) &&
isBetween(player.getLocation().getZ(), this.location1.getZ(), this.location2.getZ()) &&
this.location1.getWorld().equals(player.getLocation().getWorld()) &&
this.location2.getWorld().equals(player.getLocation().getWorld())) {
return true;
}
return false;
if (!loc.getWorld().getName().equals(area.getWorld().getName()))
return false;
if (area.getLowLoc().getBlockX() > loc.getBlockX())
return false;
if (area.getHighLoc().getBlockX() < loc.getBlockX())
return false;
if (area.getLowLoc().getBlockZ() > loc.getBlockZ())
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;
}
/**
* Function check if number is between bounds
* @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;
public String getName() {
return name;
}
}

View File

@ -928,8 +928,7 @@ public abstract class JobsDAO {
return;
PreparedStatement prest = null;
try {
prest = conn.prepareStatement("UPDATE `" + prefix
+ "jobs` SET `level` = ?, `experience` = ? WHERE `userid` = ? AND `job` = ?;");
prest = conn.prepareStatement("UPDATE `" + prefix + "jobs` SET `level` = ?, `experience` = ? WHERE `userid` = ? AND `job` = ?;");
for (JobProgression progression : player.getJobProgression()) {
prest.setInt(1, progression.getLevel());
prest.setInt(2, (int) progression.getExperience());

View File

@ -28,7 +28,9 @@ import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
@ -60,6 +62,7 @@ import org.bukkit.plugin.PluginManager;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.Gui.GuiInfoList;
import com.gamingmesh.jobs.api.JobsAreaSelectionEvent;
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobLimitedItems;
@ -74,6 +77,50 @@ public class JobsListener implements Listener {
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)
public void onShopClick(InventoryClickEvent event) {
if (Jobs.getShopManager().GuiList.isEmpty())

View File

@ -3,7 +3,7 @@ description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.Jobs
version: 3.7.7
author: phrstbrn
softdepend: [Vault, iConomy, MythicMobs, McMMO]
softdepend: [Vault, iConomy, MythicMobs, McMMO, WorldEdit]
commands:
jobs:
description: Jobs