mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-06 07:21:26 +01:00
payment for exploring map
This commit is contained in:
parent
19f9175072
commit
f5f62f26b4
@ -20,15 +20,19 @@ package com.gamingmesh.jobs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -46,6 +50,8 @@ import com.gamingmesh.jobs.economy.Economy;
|
||||
import com.gamingmesh.jobs.economy.PaymentData;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.Explore;
|
||||
import com.gamingmesh.jobs.stuff.JobsClassLoader;
|
||||
import com.gamingmesh.jobs.stuff.Loging;
|
||||
import com.gamingmesh.jobs.stuff.Scboard;
|
||||
@ -61,6 +67,7 @@ public class Jobs {
|
||||
private static SignUtil signManager = new SignUtil();
|
||||
private static Scboard scboardManager = new Scboard();
|
||||
private static ScheduleUtil scheduleManager = new ScheduleUtil();
|
||||
private static Explore exploreManager = new Explore();
|
||||
|
||||
private static Logger pLogger;
|
||||
private static File dataFolder;
|
||||
@ -103,6 +110,14 @@ public class Jobs {
|
||||
scheduleManager = new ScheduleUtil(plugin);
|
||||
}
|
||||
|
||||
public static Explore getExplore() {
|
||||
return exploreManager;
|
||||
}
|
||||
|
||||
public static void setExplore() {
|
||||
exploreManager = new Explore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns scoreboard manager
|
||||
* @return the scoreboard manager
|
||||
@ -537,23 +552,53 @@ public class Jobs {
|
||||
// Item boost check
|
||||
Double itemMoneyBoost = 0.0;
|
||||
Double itemExpBoost = 0.0;
|
||||
if (item != null)
|
||||
if (item != null) {
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
String name = null;
|
||||
List<String> lore = new ArrayList<String>();
|
||||
|
||||
if (item.hasItemMeta()) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta.hasDisplayName() && meta.hasLore())
|
||||
for (JobItems oneItem : prog.getJob().getItems()) {
|
||||
if (oneItem.getId() != item.getTypeId())
|
||||
continue;
|
||||
if (!ChatColor.translateAlternateColorCodes('&', oneItem.getName()).equalsIgnoreCase(meta.getDisplayName()))
|
||||
continue;
|
||||
if (!oneItem.getLore().equals(meta.getLore()))
|
||||
continue;
|
||||
itemMoneyBoost = ((income * oneItem.getMoneyBoost()) - income);
|
||||
itemExpBoost = ((exp * oneItem.getExpBoost()) - exp);
|
||||
break;
|
||||
}
|
||||
if (meta.hasDisplayName())
|
||||
name = meta.getDisplayName();
|
||||
if (meta.hasLore())
|
||||
lore = meta.getLore();
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> enchants = item.getEnchantments();
|
||||
|
||||
main: for (JobItems oneItem : prog.getJob().getItems()) {
|
||||
if (oneItem.getId() != item.getTypeId())
|
||||
continue;
|
||||
|
||||
if (oneItem.getName() != null && name != null)
|
||||
if (!org.bukkit.ChatColor.translateAlternateColorCodes('&', oneItem.getName()).equalsIgnoreCase(name))
|
||||
continue;
|
||||
|
||||
for (String onelore : oneItem.getLore()) {
|
||||
if (lore.size() == 0 || !lore.contains(onelore))
|
||||
continue main;
|
||||
}
|
||||
|
||||
for (Entry<Enchantment, Integer> oneE : enchants.entrySet()) {
|
||||
if (oneItem.getenchants().containsKey(oneE.getKey())) {
|
||||
if (oneItem.getenchants().get(oneE.getKey()) < oneE.getValue()) {
|
||||
continue main;
|
||||
}
|
||||
} else
|
||||
continue main;
|
||||
}
|
||||
|
||||
itemMoneyBoost = ((income * oneItem.getMoneyBoost()) - income);
|
||||
itemExpBoost = ((exp * oneItem.getExpBoost()) - exp);
|
||||
|
||||
Debug.D("boost");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Armor boost check
|
||||
Double armorMoneyBoost = 0.0;
|
||||
Double armorExpBoost = 0.0;
|
||||
|
@ -109,6 +109,7 @@ public class JobsPlugin extends JavaPlugin {
|
||||
Jobs.setScboard(this);
|
||||
Jobs.setSchedule(this);
|
||||
Jobs.setLanguage(this);
|
||||
Jobs.setExplore();
|
||||
|
||||
Jobs.setPluginLogger(getLogger());
|
||||
|
||||
@ -162,11 +163,14 @@ public class JobsPlugin extends JavaPlugin {
|
||||
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||
console.sendMessage(message);
|
||||
Jobs.getLanguage().reload(ConfigManager.getJobsConfiguration().getLocale());
|
||||
|
||||
Jobs.getJobsDAO().loadExplore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
GuiTools.CloseInventories();
|
||||
Jobs.getJobsDAO().saveExplore();
|
||||
Jobs.shutdown();
|
||||
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &2Plugin has been disabled succesfully.");
|
||||
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||
|
2
com/gamingmesh/jobs/actions/.gitignore
vendored
2
com/gamingmesh/jobs/actions/.gitignore
vendored
@ -5,3 +5,5 @@
|
||||
/EnchantActionInfo.class
|
||||
/CustomKillInfo.class
|
||||
/MMKillInfo.class
|
||||
/WxploreActionInfo.class
|
||||
/ExploreActionInfo.class
|
||||
|
42
com/gamingmesh/jobs/actions/ExploreActionInfo.java
Normal file
42
com/gamingmesh/jobs/actions/ExploreActionInfo.java
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Jobs Plugin for Bukkit
|
||||
* Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.gamingmesh.jobs.actions;
|
||||
|
||||
import com.gamingmesh.jobs.container.ActionInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.BaseActionInfo;
|
||||
|
||||
public class ExploreActionInfo extends BaseActionInfo implements ActionInfo {
|
||||
private String place;
|
||||
|
||||
public ExploreActionInfo(String place, ActionType type) {
|
||||
super(type);
|
||||
this.place = place;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return place;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameWithSub() {
|
||||
return getName();
|
||||
}
|
||||
}
|
1
com/gamingmesh/jobs/api/.gitignore
vendored
1
com/gamingmesh/jobs/api/.gitignore
vendored
@ -6,3 +6,4 @@
|
||||
/JobsLeaveEvent.class
|
||||
/JobsLevelUpEvent.class
|
||||
/JobsPaymentEvent.class
|
||||
/JobsChunkChangeEvent.class
|
||||
|
49
com/gamingmesh/jobs/api/JobsChunkChangeEvent.java
Normal file
49
com/gamingmesh/jobs/api/JobsChunkChangeEvent.java
Normal file
@ -0,0 +1,49 @@
|
||||
package com.gamingmesh.jobs.api;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public final class JobsChunkChangeEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private Chunk oldChunk;
|
||||
private Chunk newChunk;
|
||||
private boolean cancelled;
|
||||
|
||||
public JobsChunkChangeEvent(Player player, Chunk oldChunk, Chunk newChunk) {
|
||||
this.player = player;
|
||||
this.oldChunk = oldChunk;
|
||||
this.newChunk = newChunk;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public Chunk getOldChunk() {
|
||||
return this.oldChunk;
|
||||
}
|
||||
|
||||
public Chunk getNewChunk() {
|
||||
return this.newChunk;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1532,7 +1532,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
.replace("%username%", one.getKey().getUsername())
|
||||
.replace("%number%", String.valueOf(count))
|
||||
.replace("%action%", info.getAction())
|
||||
.replace("%item%", one.getKey().getItemName().replace(":0", "").toLowerCase())
|
||||
.replace("%item%", one.getKey().getItemName().replace(":0", "").replace("_", " ").toLowerCase())
|
||||
.replace("%qty%", String.valueOf(one.getKey().getCount()))
|
||||
.replace("%money%", String.valueOf(one.getKey().getMoney()))
|
||||
.replace("%exp%", String.valueOf(one.getKey().getExp()));
|
||||
|
@ -23,6 +23,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
@ -43,6 +44,7 @@ import com.gamingmesh.jobs.container.JobCommands;
|
||||
import com.gamingmesh.jobs.container.JobConditions;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobLimitedItems;
|
||||
import com.gamingmesh.jobs.container.JobPermission;
|
||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
@ -285,17 +287,34 @@ public class JobConfig {
|
||||
continue;
|
||||
}
|
||||
int id = itemSection.getInt("id");
|
||||
String name = itemSection.getString("name");
|
||||
|
||||
String name = null;
|
||||
if (itemSection.isString("name"))
|
||||
name = itemSection.getString("name");
|
||||
|
||||
List<String> lore = new ArrayList<String>();
|
||||
for (String eachLine : itemSection.getStringList("lore")) {
|
||||
lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine));
|
||||
}
|
||||
if (itemSection.getStringList("lore") != null)
|
||||
for (String eachLine : itemSection.getStringList("lore")) {
|
||||
lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine));
|
||||
}
|
||||
|
||||
List<String> enchants = new ArrayList<String>();
|
||||
HashMap<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
|
||||
if (itemSection.getStringList("enchants") != null)
|
||||
for (String eachLine : itemSection.getStringList("enchants")) {
|
||||
enchants.add(eachLine);
|
||||
|
||||
if (!eachLine.contains("="))
|
||||
continue;
|
||||
|
||||
Enchantment ench = Enchantment.getByName(eachLine.split("=")[0]);
|
||||
Integer level = -1;
|
||||
try {
|
||||
level = Integer.parseInt(eachLine.split("=")[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ench != null && level != -1)
|
||||
enchants.put(ench, level);
|
||||
}
|
||||
|
||||
Double moneyBoost = itemSection.getDouble("moneyBoost");
|
||||
@ -304,8 +323,57 @@ public class JobConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// Limited Items
|
||||
ArrayList<JobLimitedItems> jobLimitedItems = new ArrayList<JobLimitedItems>();
|
||||
ConfigurationSection LimitedItemsSection = jobSection.getConfigurationSection("limitedItems");
|
||||
if (LimitedItemsSection != null) {
|
||||
for (String itemKey : LimitedItemsSection.getKeys(false)) {
|
||||
ConfigurationSection itemSection = LimitedItemsSection.getConfigurationSection(itemKey);
|
||||
|
||||
String node = itemKey.toLowerCase();
|
||||
if (itemSection == null) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid item key " + itemKey + "!");
|
||||
continue;
|
||||
}
|
||||
int id = itemSection.getInt("id");
|
||||
|
||||
String name = null;
|
||||
if (itemSection.isString("name"))
|
||||
name = itemSection.getString("name");
|
||||
|
||||
List<String> lore = new ArrayList<String>();
|
||||
if (itemSection.getStringList("lore") != null)
|
||||
for (String eachLine : itemSection.getStringList("lore")) {
|
||||
lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine));
|
||||
}
|
||||
|
||||
HashMap<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
|
||||
if (itemSection.getStringList("enchants") != null)
|
||||
for (String eachLine : itemSection.getStringList("enchants")) {
|
||||
|
||||
if (!eachLine.contains("="))
|
||||
continue;
|
||||
|
||||
Enchantment ench = Enchantment.getByName(eachLine.split("=")[0]);
|
||||
Integer level = -1;
|
||||
try {
|
||||
level = Integer.parseInt(eachLine.split("=")[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ench != null && level != -1)
|
||||
enchants.put(ench, level);
|
||||
}
|
||||
|
||||
int level = itemSection.getInt("level");
|
||||
|
||||
jobLimitedItems.add(new JobLimitedItems(node, id, name, lore, enchants, level));
|
||||
}
|
||||
}
|
||||
|
||||
Job job = new Job(jobName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand,
|
||||
jobConditions, jobItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem);
|
||||
jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem);
|
||||
|
||||
for (ActionType actionType : ActionType.values()) {
|
||||
ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName());
|
||||
@ -347,6 +415,9 @@ public class JobConfig {
|
||||
}
|
||||
}
|
||||
|
||||
if (actionType == ActionType.EXPLORE)
|
||||
material = null;
|
||||
|
||||
if (material != null) {
|
||||
// Break and Place actions MUST be blocks
|
||||
if (actionType == ActionType.BREAK || actionType == ActionType.PLACE) {
|
||||
@ -422,6 +493,17 @@ public class JobConfig {
|
||||
type = myKey;
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) {
|
||||
type = myKey;
|
||||
} else if (actionType == ActionType.EXPLORE) {
|
||||
type = myKey;
|
||||
int amount = 10;
|
||||
try {
|
||||
amount = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!");
|
||||
continue;
|
||||
}
|
||||
Jobs.getExplore().setExploreEnabled();
|
||||
Jobs.getExplore().setPlayerAmount(amount + 1);
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
|
@ -62,6 +62,7 @@ public class JobsConfiguration {
|
||||
protected boolean isBroadcastingSkillups;
|
||||
protected boolean isBroadcastingLevelups;
|
||||
protected boolean payInCreative;
|
||||
protected boolean payExploringWhenFlying;
|
||||
protected boolean addXpPlayer;
|
||||
protected boolean hideJobsWithoutPermission;
|
||||
protected int maxJobs;
|
||||
@ -171,6 +172,15 @@ public class JobsConfiguration {
|
||||
public synchronized boolean payInCreative() {
|
||||
return payInCreative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that tells if the player should be paid while exploring and flying
|
||||
* @return true - pay
|
||||
* @return false - do not
|
||||
*/
|
||||
public synchronized boolean payExploringWhenFlying() {
|
||||
return payExploringWhenFlying;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return the title for a given level
|
||||
@ -379,7 +389,7 @@ public class JobsConfiguration {
|
||||
"Theroticali this should work without issues, but if you havving some, just disable",
|
||||
"But then you can feal some small (100-200ms) lag spikes while performings some jobs commands");
|
||||
LocalOfflinePlayersData = getBoolean("Optimizations.UseLocalOfflinePlayersData", true, config, writer);
|
||||
|
||||
|
||||
writer.addComment("Logging.Use", "With this set to true all players jobs actions will be logged to database for easy to see statistics",
|
||||
"This is still in development and in feature it will expand");
|
||||
LoggingUse = getBoolean("Logging.Use", false, config, writer);
|
||||
@ -414,6 +424,9 @@ public class JobsConfiguration {
|
||||
|
||||
writer.addComment("enable-pay-creative", "Option to allow payment to be made in creative mode");
|
||||
payInCreative = getBoolean("enable-pay-creative", false, config, writer);
|
||||
|
||||
writer.addComment("enable-pay-for-exploring-when-flying", "Option to allow payment to be made for exploring when player flyies");
|
||||
payExploringWhenFlying = getBoolean("enable-pay-for-exploring-when-flying", false, config, writer);
|
||||
|
||||
writer.addComment("add-xp-player", "Adds the Jobs xp recieved to the player's Minecraft XP bar");
|
||||
addXpPlayer = getBoolean("add-xp-player", false, config, writer);
|
||||
@ -1206,6 +1219,7 @@ public class JobsConfiguration {
|
||||
languages.add("cs");
|
||||
languages.add("fr");
|
||||
languages.add("ru");
|
||||
languages.add("cz");
|
||||
|
||||
for (String lang : languages) {
|
||||
YmlMaker langFile = new YmlMaker((JavaPlugin) plugin, "locale" + File.separator + "messages_" + lang + ".yml");
|
||||
@ -1230,6 +1244,7 @@ public class JobsConfiguration {
|
||||
conf.options().copyDefaults(true);
|
||||
|
||||
GetConfigString("economy.error.nomoney", "Sorry, no money left in national bank!", writer, conf, true);
|
||||
GetConfigString("limitedItem.error.levelup", "&cYou need to levelup in [jobname] to use this item!", writer, conf, true);
|
||||
|
||||
GetConfigString("command.moneyboost.help.info", "Boosts Money gain for all players", writer, conf, true);
|
||||
GetConfigString("command.moneyboost.help.args", "[jobname] [rate]", writer, conf, true);
|
||||
@ -1340,6 +1355,8 @@ public class JobsConfiguration {
|
||||
GetConfigString("command.info.output.milk.none", "%jobname% does not get money from milking cows.", writer, conf, true);
|
||||
GetConfigString("command.info.output.shear.info", "Shear", writer, conf, true);
|
||||
GetConfigString("command.info.output.shear.none", "%jobname% does not get money from shearing sheeps.", writer, conf, true);
|
||||
GetConfigString("command.info.output.explore.info", "Explore", writer, conf, true);
|
||||
GetConfigString("command.info.output.explore.none", "%jobname% does not get money from exploring.", writer, conf, true);
|
||||
GetConfigString("command.info.output.custom-kill.info", "Custom kill", writer, conf, true);
|
||||
GetConfigString("command.info.output.custom-kill.none", "%jobname% does not get money from custom player kills.", writer, conf, true);
|
||||
|
||||
|
4
com/gamingmesh/jobs/container/.gitignore
vendored
4
com/gamingmesh/jobs/container/.gitignore
vendored
@ -21,3 +21,7 @@
|
||||
/Log.class
|
||||
/LogAmounts.class
|
||||
/JobConditions.class
|
||||
/JobLimitedItems.class
|
||||
/ExploreRegion.class
|
||||
/ExploreChunk.class
|
||||
/ExploreWorld.class
|
||||
|
@ -34,6 +34,7 @@ public enum ActionType {
|
||||
DYE("Dye"),
|
||||
SHEAR("Shear"),
|
||||
MILK("Milk"),
|
||||
EXPLORE("Explore"),
|
||||
CUSTOMKILL("custom-kill");
|
||||
|
||||
private String name;
|
||||
|
59
com/gamingmesh/jobs/container/ExploreChunk.java
Normal file
59
com/gamingmesh/jobs/container/ExploreChunk.java
Normal file
@ -0,0 +1,59 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
|
||||
public class ExploreChunk {
|
||||
|
||||
int x;
|
||||
int z;
|
||||
List<String> playerNames = new ArrayList<String>();
|
||||
boolean isNewChunk = true;
|
||||
|
||||
public ExploreChunk(String playerName, int x, int z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.playerNames.add(playerName);
|
||||
}
|
||||
|
||||
public ExploreRespond addPlayer(String playerName) {
|
||||
boolean newChunk = false;
|
||||
if (!playerNames.contains(playerName)) {
|
||||
playerNames.add(playerName);
|
||||
newChunk = true;
|
||||
}
|
||||
if (playerNames.size() > Jobs.getExplore().getPlayerAmount())
|
||||
playerNames.remove(0);
|
||||
return new ExploreRespond(playerNames.size(), newChunk);
|
||||
}
|
||||
|
||||
public boolean isAlreadyVisited(String playerName) {
|
||||
return playerNames.contains(playerName);
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.playerNames.size();
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public List<String> getPlayers() {
|
||||
return this.playerNames;
|
||||
}
|
||||
|
||||
public boolean isNew() {
|
||||
return this.isNewChunk;
|
||||
}
|
||||
|
||||
public void setOldChunk() {
|
||||
isNewChunk = false;
|
||||
}
|
||||
}
|
29
com/gamingmesh/jobs/container/ExploreRegion.java
Normal file
29
com/gamingmesh/jobs/container/ExploreRegion.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExploreRegion {
|
||||
|
||||
int x;
|
||||
int z;
|
||||
List<ExploreChunk> chunks = new ArrayList<ExploreChunk>();
|
||||
|
||||
public ExploreRegion(int x, int z, List<ExploreChunk> chunks) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public ExploreRegion(int x, int z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void addChunk(ExploreChunk chunk) {
|
||||
chunks.add(chunk);
|
||||
}
|
||||
|
||||
public List<ExploreChunk> getChunks() {
|
||||
return chunks;
|
||||
}
|
||||
}
|
20
com/gamingmesh/jobs/container/ExploreRespond.java
Normal file
20
com/gamingmesh/jobs/container/ExploreRespond.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
public class ExploreRespond {
|
||||
|
||||
int count;
|
||||
boolean newChunk = false;
|
||||
|
||||
public ExploreRespond(int count, boolean newChunk) {
|
||||
this.count = count;
|
||||
this.newChunk = newChunk;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public boolean isNewChunk() {
|
||||
return this.newChunk;
|
||||
}
|
||||
}
|
@ -32,326 +32,341 @@ import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
|
||||
public class Job {
|
||||
// job info
|
||||
private EnumMap<ActionType, List<JobInfo>> jobInfo = new EnumMap<ActionType, List<JobInfo>>(ActionType.class);
|
||||
// permissions
|
||||
private List<JobPermission> jobPermissions;
|
||||
// commands
|
||||
private List<JobCommands> jobCommands;
|
||||
// conditions
|
||||
private List<JobConditions> jobConditions;
|
||||
// items
|
||||
private List<JobItems> jobItems;
|
||||
// job name
|
||||
private String jobName;
|
||||
// job short name (for use in multiple jobs)
|
||||
private String jobShortName;
|
||||
// short description of the job
|
||||
private String description;
|
||||
// job chat colour
|
||||
private ChatColor jobColour;
|
||||
// job leveling equation
|
||||
private Parser maxExpEquation;
|
||||
// display method
|
||||
private DisplayMethod displayMethod;
|
||||
// max level
|
||||
private int maxLevel;
|
||||
// vip max level
|
||||
private int vipmaxLevel = 0;
|
||||
// max number of people allowed with this job on the server.
|
||||
private Integer maxSlots;
|
||||
// Commands to be performed on player job join
|
||||
private List<String> CmdOnJoin = new ArrayList<String>();
|
||||
// Commands to be performed on player job leave
|
||||
private List<String> CmdOnLeave = new ArrayList<String>();
|
||||
// Item for GUI
|
||||
private ItemStack GUIitem;
|
||||
// job info
|
||||
private EnumMap<ActionType, List<JobInfo>> jobInfo = new EnumMap<ActionType, List<JobInfo>>(ActionType.class);
|
||||
// permissions
|
||||
private List<JobPermission> jobPermissions;
|
||||
// commands
|
||||
private List<JobCommands> jobCommands;
|
||||
// conditions
|
||||
private List<JobConditions> jobConditions;
|
||||
// items
|
||||
private List<JobItems> jobItems;
|
||||
// limited items
|
||||
private List<JobLimitedItems> jobLimitedItems;
|
||||
// job name
|
||||
private String jobName;
|
||||
// job short name (for use in multiple jobs)
|
||||
private String jobShortName;
|
||||
// short description of the job
|
||||
private String description;
|
||||
// job chat colour
|
||||
private ChatColor jobColour;
|
||||
// job leveling equation
|
||||
private Parser maxExpEquation;
|
||||
// display method
|
||||
private DisplayMethod displayMethod;
|
||||
// max level
|
||||
private int maxLevel;
|
||||
// vip max level
|
||||
private int vipmaxLevel = 0;
|
||||
// max number of people allowed with this job on the server.
|
||||
private Integer maxSlots;
|
||||
// Commands to be performed on player job join
|
||||
private List<String> CmdOnJoin = new ArrayList<String>();
|
||||
// Commands to be performed on player job leave
|
||||
private List<String> CmdOnLeave = new ArrayList<String>();
|
||||
// Item for GUI
|
||||
private ItemStack GUIitem;
|
||||
|
||||
private int totalPlayers = -1;
|
||||
private double bonus = 0.0;
|
||||
private int totalPlayers = -1;
|
||||
private double bonus = 0.0;
|
||||
|
||||
private double ExpBoost = 1.0;
|
||||
private double ExpBoost = 1.0;
|
||||
|
||||
private double MoneyBoost = 1.0;
|
||||
private double MoneyBoost = 1.0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param jobName - the name of the job
|
||||
* @param jobShortName - the shortened version of the name of the job.
|
||||
* @param description - a short description of the job.
|
||||
* @param jobColour - the colour of the job title as displayed in chat.
|
||||
* @param maxExpEquation - the equation by which the exp needed to level up is calculated
|
||||
* @param displayMethod - the display method for this job.
|
||||
* @param maxLevel - the maximum level allowed (null for no max level)
|
||||
* @param vipmaxLevel - the maximum vip level allowed (null for no max level)
|
||||
* @param maxSlots - the maximum number of people allowed to have this job at one time (null for no limits)
|
||||
* @param jobPermissions - permissions gained for having the job
|
||||
* @param jobCommands - commands to perform on levelup
|
||||
* @param jobItems - items with boost
|
||||
* @param CmdOnJoin - commands performed on player join
|
||||
* @param CmdOnLeave - commands performed on player leave
|
||||
* @param jobConditions - jobs conditions
|
||||
*/
|
||||
public Job(String jobName, String jobShortName, String description, ChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel, int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, List<JobItems> jobItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem) {
|
||||
this.jobName = jobName;
|
||||
this.jobShortName = jobShortName;
|
||||
this.description = description;
|
||||
this.jobColour = jobColour;
|
||||
this.maxExpEquation = maxExpEquation;
|
||||
this.displayMethod = displayMethod;
|
||||
this.maxLevel = maxLevel;
|
||||
this.vipmaxLevel = vipmaxLevel;
|
||||
this.maxSlots = maxSlots;
|
||||
this.jobPermissions = jobPermissions;
|
||||
this.jobCommands = jobCommands;
|
||||
this.jobConditions = jobConditions;
|
||||
this.jobItems = jobItems;
|
||||
this.CmdOnJoin = CmdOnJoin;
|
||||
this.CmdOnLeave = CmdOnLeave;
|
||||
this.GUIitem = GUIitem;
|
||||
/**
|
||||
* Constructor
|
||||
* @param jobName - the name of the job
|
||||
* @param jobShortName - the shortened version of the name of the job.
|
||||
* @param description - a short description of the job.
|
||||
* @param jobColour - the colour of the job title as displayed in chat.
|
||||
* @param maxExpEquation - the equation by which the exp needed to level up is calculated
|
||||
* @param displayMethod - the display method for this job.
|
||||
* @param maxLevel - the maximum level allowed (null for no max level)
|
||||
* @param vipmaxLevel - the maximum vip level allowed (null for no max level)
|
||||
* @param maxSlots - the maximum number of people allowed to have this job at one time (null for no limits)
|
||||
* @param jobPermissions - permissions gained for having the job
|
||||
* @param jobCommands - commands to perform on levelup
|
||||
* @param jobItems - items with boost
|
||||
* @param jobLimitedItems - limited items by lvl
|
||||
* @param CmdOnJoin - commands performed on player join
|
||||
* @param CmdOnLeave - commands performed on player leave
|
||||
* @param jobConditions - jobs conditions
|
||||
*/
|
||||
public Job(String jobName, String jobShortName, String description, ChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
|
||||
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, List<JobItems> jobItems,
|
||||
List<JobLimitedItems> jobLimitedItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem) {
|
||||
this.jobName = jobName;
|
||||
this.jobShortName = jobShortName;
|
||||
this.description = description;
|
||||
this.jobColour = jobColour;
|
||||
this.maxExpEquation = maxExpEquation;
|
||||
this.displayMethod = displayMethod;
|
||||
this.maxLevel = maxLevel;
|
||||
this.vipmaxLevel = vipmaxLevel;
|
||||
this.maxSlots = maxSlots;
|
||||
this.jobPermissions = jobPermissions;
|
||||
this.jobCommands = jobCommands;
|
||||
this.jobConditions = jobConditions;
|
||||
this.jobItems = jobItems;
|
||||
this.jobLimitedItems = jobLimitedItems;
|
||||
this.CmdOnJoin = CmdOnJoin;
|
||||
this.CmdOnLeave = CmdOnLeave;
|
||||
this.GUIitem = GUIitem;
|
||||
}
|
||||
|
||||
public void setMoneyBoost(double amount) {
|
||||
this.MoneyBoost = amount;
|
||||
}
|
||||
|
||||
public double getMoneyBoost() {
|
||||
return this.MoneyBoost;
|
||||
}
|
||||
|
||||
public void setExpBoost(double amount) {
|
||||
this.ExpBoost = amount;
|
||||
}
|
||||
|
||||
public double getExpBoost() {
|
||||
return this.ExpBoost;
|
||||
}
|
||||
|
||||
public int getTotalPlayers() {
|
||||
if (this.totalPlayers == -1) {
|
||||
this.totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(this.jobName);
|
||||
updateBonus();
|
||||
}
|
||||
return this.totalPlayers;
|
||||
}
|
||||
|
||||
public void setMoneyBoost(double amount) {
|
||||
this.MoneyBoost = amount;
|
||||
}
|
||||
|
||||
public double getMoneyBoost() {
|
||||
return this.MoneyBoost;
|
||||
}
|
||||
|
||||
public void setExpBoost(double amount) {
|
||||
this.ExpBoost = amount;
|
||||
}
|
||||
|
||||
public double getExpBoost() {
|
||||
return this.ExpBoost;
|
||||
}
|
||||
|
||||
public int getTotalPlayers() {
|
||||
if (this.totalPlayers == -1) {
|
||||
this.totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(this.jobName);
|
||||
updateBonus();
|
||||
}
|
||||
return this.totalPlayers;
|
||||
}
|
||||
public void updateTotalPlayers() {
|
||||
this.totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(this.jobName);
|
||||
updateBonus();
|
||||
}
|
||||
|
||||
public void updateTotalPlayers() {
|
||||
this.totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(this.jobName);
|
||||
updateBonus();
|
||||
public void updateBonus() {
|
||||
if (!ConfigManager.getJobsConfiguration().useDynamicPayment)
|
||||
return;
|
||||
Parser eq = ConfigManager.getJobsConfiguration().DynamicPaymentEquation;
|
||||
eq.setVariable("totalworkers", Jobs.getJobsDAO().getTotalPlayers());
|
||||
eq.setVariable("totaljobs", Jobs.getJobs().size());
|
||||
eq.setVariable("jobstotalplayers", getTotalPlayers());
|
||||
|
||||
double now = eq.getValue();
|
||||
if (now > ConfigManager.getJobsConfiguration().DynamicPaymentMaxBonus)
|
||||
now = ConfigManager.getJobsConfiguration().DynamicPaymentMaxBonus;
|
||||
if (now < ConfigManager.getJobsConfiguration().DynamicPaymentMaxPenalty * -1)
|
||||
now = ConfigManager.getJobsConfiguration().DynamicPaymentMaxPenalty * -1;
|
||||
this.bonus = now;
|
||||
}
|
||||
|
||||
public double getBonus() {
|
||||
if (this.bonus == 0.0)
|
||||
updateBonus();
|
||||
return this.bonus;
|
||||
}
|
||||
|
||||
public List<String> getCmdOnJoin() {
|
||||
return this.CmdOnJoin;
|
||||
}
|
||||
|
||||
public List<String> getCmdOnLeave() {
|
||||
return this.CmdOnLeave;
|
||||
}
|
||||
|
||||
public ItemStack getGuiItem() {
|
||||
return this.GUIitem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets job info for action type
|
||||
* @param type - The action type
|
||||
* @param info - the job info
|
||||
*/
|
||||
public void setJobInfo(ActionType type, List<JobInfo> info) {
|
||||
jobInfo.put(type, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the job info for the particular type
|
||||
* @param type - The action type
|
||||
* @return Job info list
|
||||
*/
|
||||
|
||||
public List<JobInfo> getJobInfo(ActionType type) {
|
||||
return Collections.unmodifiableList(jobInfo.get(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the job info list
|
||||
* @return Job info list
|
||||
*/
|
||||
|
||||
public EnumMap<ActionType, List<JobInfo>> getJobInfoList() {
|
||||
return jobInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the income for an action
|
||||
* @param action - The action info
|
||||
* @param level - players job level
|
||||
* @param numjobs - number of jobs for the player
|
||||
* @return the income received for performing action
|
||||
*/
|
||||
|
||||
public Double getIncome(ActionInfo action, int level, int numjobs) {
|
||||
List<JobInfo> jobInfo = getJobInfo(action.getType());
|
||||
for (JobInfo info : jobInfo) {
|
||||
if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub())) {
|
||||
return info.getIncome(level, numjobs);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateBonus() {
|
||||
if (!ConfigManager.getJobsConfiguration().useDynamicPayment)
|
||||
return;
|
||||
Parser eq = ConfigManager.getJobsConfiguration().DynamicPaymentEquation;
|
||||
eq.setVariable("totalworkers", Jobs.getJobsDAO().getTotalPlayers());
|
||||
eq.setVariable("totaljobs", Jobs.getJobs().size());
|
||||
eq.setVariable("jobstotalplayers", getTotalPlayers());
|
||||
/**
|
||||
* Function to get the income for an action
|
||||
* @param action - The action info
|
||||
* @param level - players job level
|
||||
* @param numjobs - number of jobs for the player
|
||||
* @return the income received for performing action
|
||||
*/
|
||||
|
||||
double now = eq.getValue();
|
||||
if (now > ConfigManager.getJobsConfiguration().DynamicPaymentMaxBonus)
|
||||
now = ConfigManager.getJobsConfiguration().DynamicPaymentMaxBonus;
|
||||
if (now < ConfigManager.getJobsConfiguration().DynamicPaymentMaxPenalty * -1)
|
||||
now = ConfigManager.getJobsConfiguration().DynamicPaymentMaxPenalty * -1;
|
||||
this.bonus = now;
|
||||
public Double getExperience(ActionInfo action, int level, int numjobs) {
|
||||
List<JobInfo> jobInfo = getJobInfo(action.getType());
|
||||
for (JobInfo info : jobInfo) {
|
||||
if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub()))
|
||||
return info.getExperience(level, numjobs);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public double getBonus() {
|
||||
if (this.bonus == 0.0)
|
||||
updateBonus();
|
||||
return this.bonus;
|
||||
/**
|
||||
* Get the job name
|
||||
* @return the job name
|
||||
*/
|
||||
public String getName() {
|
||||
return jobName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shortened version of the jobName
|
||||
* @return the shortened version of the jobName
|
||||
*/
|
||||
public String getShortName() {
|
||||
return jobShortName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description
|
||||
* @return description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Color of the job for chat
|
||||
* @return the Color of the job for chat
|
||||
*/
|
||||
public ChatColor getChatColor() {
|
||||
return jobColour;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MaxExpEquation of the job
|
||||
* @return the MaxExpEquation of the job
|
||||
*/
|
||||
public Parser getMaxExpEquation() {
|
||||
return maxExpEquation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return the appropriate max exp for this level
|
||||
* @param level - current level
|
||||
* @return the correct max exp for this level
|
||||
*/
|
||||
public double getMaxExp(Map<String, Double> param) {
|
||||
for (Map.Entry<String, Double> temp : param.entrySet()) {
|
||||
maxExpEquation.setVariable(temp.getKey(), temp.getValue());
|
||||
}
|
||||
return maxExpEquation.getValue();
|
||||
}
|
||||
|
||||
public List<String> getCmdOnJoin() {
|
||||
return this.CmdOnJoin;
|
||||
}
|
||||
/**
|
||||
* Function to get the display method
|
||||
* @return the display method
|
||||
*/
|
||||
public DisplayMethod getDisplayMethod() {
|
||||
return displayMethod;
|
||||
}
|
||||
|
||||
public List<String> getCmdOnLeave() {
|
||||
return this.CmdOnLeave;
|
||||
}
|
||||
/**
|
||||
* Function to return the maximum level
|
||||
* @return the max level
|
||||
* @return null - no max level
|
||||
*/
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public ItemStack getGuiItem() {
|
||||
return this.GUIitem;
|
||||
}
|
||||
/**
|
||||
* Function to return the maximum level
|
||||
* @return the max level
|
||||
* @return null - no max level
|
||||
*/
|
||||
public int getVipMaxLevel() {
|
||||
return vipmaxLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets job info for action type
|
||||
* @param type - The action type
|
||||
* @param info - the job info
|
||||
*/
|
||||
public void setJobInfo(ActionType type, List<JobInfo> info) {
|
||||
jobInfo.put(type, info);
|
||||
}
|
||||
/**
|
||||
* Function to return the maximum slots
|
||||
* @return the max slots
|
||||
* @return null - no max slots
|
||||
*/
|
||||
public Integer getMaxSlots() {
|
||||
return maxSlots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the job info for the particular type
|
||||
* @param type - The action type
|
||||
* @return Job info list
|
||||
*/
|
||||
/**
|
||||
* Get the permission nodes for this job
|
||||
* @return Permissions for this job
|
||||
*/
|
||||
public List<JobPermission> getPermissions() {
|
||||
return Collections.unmodifiableList(jobPermissions);
|
||||
}
|
||||
|
||||
public List<JobInfo> getJobInfo(ActionType type) {
|
||||
return Collections.unmodifiableList(jobInfo.get(type));
|
||||
}
|
||||
/**
|
||||
* Get the command nodes for this job
|
||||
* @return Commands for this job
|
||||
*/
|
||||
public List<JobCommands> getCommands() {
|
||||
return Collections.unmodifiableList(jobCommands);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the job info list
|
||||
* @return Job info list
|
||||
*/
|
||||
/**
|
||||
* Get the conditions for this job
|
||||
* @return Conditions for this job
|
||||
*/
|
||||
public List<JobConditions> getConditions() {
|
||||
return Collections.unmodifiableList(jobConditions);
|
||||
}
|
||||
|
||||
public EnumMap<ActionType, List<JobInfo>> getJobInfoList() {
|
||||
return jobInfo;
|
||||
}
|
||||
/**
|
||||
* Get the item nodes for this job
|
||||
* @return Items for this job
|
||||
*/
|
||||
public List<JobItems> getItems() {
|
||||
return Collections.unmodifiableList(jobItems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the income for an action
|
||||
* @param action - The action info
|
||||
* @param level - players job level
|
||||
* @param numjobs - number of jobs for the player
|
||||
* @return the income received for performing action
|
||||
*/
|
||||
|
||||
public Double getIncome(ActionInfo action, int level, int numjobs) {
|
||||
List<JobInfo> jobInfo = getJobInfo(action.getType());
|
||||
for (JobInfo info : jobInfo) {
|
||||
if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub())) {
|
||||
return info.getIncome(level, numjobs);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the income for an action
|
||||
* @param action - The action info
|
||||
* @param level - players job level
|
||||
* @param numjobs - number of jobs for the player
|
||||
* @return the income received for performing action
|
||||
*/
|
||||
|
||||
public Double getExperience(ActionInfo action, int level, int numjobs) {
|
||||
List<JobInfo> jobInfo = getJobInfo(action.getType());
|
||||
for (JobInfo info : jobInfo) {
|
||||
if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub()))
|
||||
return info.getExperience(level, numjobs);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the job name
|
||||
* @return the job name
|
||||
*/
|
||||
public String getName() {
|
||||
return jobName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shortened version of the jobName
|
||||
* @return the shortened version of the jobName
|
||||
*/
|
||||
public String getShortName() {
|
||||
return jobShortName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description
|
||||
* @return description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Color of the job for chat
|
||||
* @return the Color of the job for chat
|
||||
*/
|
||||
public ChatColor getChatColor() {
|
||||
return jobColour;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MaxExpEquation of the job
|
||||
* @return the MaxExpEquation of the job
|
||||
*/
|
||||
public Parser getMaxExpEquation() {
|
||||
return maxExpEquation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return the appropriate max exp for this level
|
||||
* @param level - current level
|
||||
* @return the correct max exp for this level
|
||||
*/
|
||||
public double getMaxExp(Map<String, Double> param) {
|
||||
for (Map.Entry<String, Double> temp : param.entrySet()) {
|
||||
maxExpEquation.setVariable(temp.getKey(), temp.getValue());
|
||||
}
|
||||
return maxExpEquation.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the display method
|
||||
* @return the display method
|
||||
*/
|
||||
public DisplayMethod getDisplayMethod() {
|
||||
return displayMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return the maximum level
|
||||
* @return the max level
|
||||
* @return null - no max level
|
||||
*/
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return the maximum level
|
||||
* @return the max level
|
||||
* @return null - no max level
|
||||
*/
|
||||
public int getVipMaxLevel() {
|
||||
return vipmaxLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return the maximum slots
|
||||
* @return the max slots
|
||||
* @return null - no max slots
|
||||
*/
|
||||
public Integer getMaxSlots() {
|
||||
return maxSlots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permission nodes for this job
|
||||
* @return Permissions for this job
|
||||
*/
|
||||
public List<JobPermission> getPermissions() {
|
||||
return Collections.unmodifiableList(jobPermissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the command nodes for this job
|
||||
* @return Commands for this job
|
||||
*/
|
||||
public List<JobCommands> getCommands() {
|
||||
return Collections.unmodifiableList(jobCommands);
|
||||
}
|
||||
/**
|
||||
* Get the conditions for this job
|
||||
* @return Conditions for this job
|
||||
*/
|
||||
public List<JobConditions> getConditions() {
|
||||
return Collections.unmodifiableList(jobConditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item nodes for this job
|
||||
* @return Items for this job
|
||||
*/
|
||||
public List<JobItems> getItems() {
|
||||
return Collections.unmodifiableList(jobItems);
|
||||
}
|
||||
/**
|
||||
* Get the limited item nodes for this job
|
||||
* @return Limited items for this job
|
||||
*/
|
||||
public List<JobLimitedItems> getLimitedItems() {
|
||||
return Collections.unmodifiableList(jobLimitedItems);
|
||||
}
|
||||
}
|
||||
|
@ -18,18 +18,21 @@
|
||||
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
public class JobItems {
|
||||
private String node;
|
||||
private int id;
|
||||
private String name;
|
||||
private List<String> lore;
|
||||
private List<String> enchants;
|
||||
private HashMap<Enchantment, Integer> enchants;
|
||||
private Double moneyBoost;
|
||||
private Double expBoost;
|
||||
|
||||
public JobItems(String node, int id, String name, List<String> lore, List<String> enchants, double moneyBoost, double expBoost) {
|
||||
public JobItems(String node, int id, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, double moneyBoost, double expBoost) {
|
||||
this.node = node;
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
@ -55,7 +58,7 @@ public class JobItems {
|
||||
return this.lore;
|
||||
}
|
||||
|
||||
public List<String> getenchants() {
|
||||
public HashMap<Enchantment, Integer> getenchants() {
|
||||
return this.enchants;
|
||||
}
|
||||
|
||||
|
65
com/gamingmesh/jobs/container/JobLimitedItems.java
Normal file
65
com/gamingmesh/jobs/container/JobLimitedItems.java
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Jobs Plugin for Bukkit
|
||||
* Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
public class JobLimitedItems {
|
||||
private String node;
|
||||
private int id;
|
||||
private String name;
|
||||
private List<String> lore;
|
||||
private HashMap<Enchantment, Integer> enchants;
|
||||
private int level;
|
||||
|
||||
public JobLimitedItems(String node, int id, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, int level) {
|
||||
this.node = node;
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lore = lore;
|
||||
this.enchants = enchants;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
return this.node;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public List<String> getLore() {
|
||||
return this.lore;
|
||||
}
|
||||
|
||||
public HashMap<Enchantment, Integer> getenchants() {
|
||||
return this.enchants;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
}
|
@ -37,6 +37,8 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.JobsPlugin;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.Convert;
|
||||
import com.gamingmesh.jobs.container.ExploreChunk;
|
||||
import com.gamingmesh.jobs.container.ExploreRegion;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
@ -98,7 +100,10 @@ public abstract class JobsDAO {
|
||||
if (version <= 6)
|
||||
checkUpdate7();
|
||||
|
||||
version = 7;
|
||||
// creating explore database
|
||||
checkUpdate8();
|
||||
|
||||
version = 8;
|
||||
} finally {
|
||||
updateSchemaVersion(version);
|
||||
}
|
||||
@ -118,6 +123,8 @@ public abstract class JobsDAO {
|
||||
|
||||
protected abstract void checkUpdate7() throws SQLException;
|
||||
|
||||
protected abstract void checkUpdate8() throws SQLException;
|
||||
|
||||
/**
|
||||
* Gets the database prefix
|
||||
* @return the prefix
|
||||
@ -732,6 +739,65 @@ public abstract class JobsDAO {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save player-explore information
|
||||
* @param jobexplore - the information getting saved
|
||||
*/
|
||||
public synchronized void saveExplore() {
|
||||
if (!Jobs.getExplore().isExploreEnabled())
|
||||
return;
|
||||
|
||||
JobsConnection conn = getConnection();
|
||||
if (conn == null)
|
||||
return;
|
||||
try {
|
||||
PreparedStatement prest = conn.prepareStatement("TRUNCATE TABLE `" + prefix + "explore`;");
|
||||
prest.execute();
|
||||
prest.close();
|
||||
|
||||
PreparedStatement prest2 = conn.prepareStatement("INSERT INTO `" + prefix + "explore` (`worldname`, `chunkX`, `chunkZ`, `playerName`) VALUES (?, ?, ?, ?);");
|
||||
for (Entry<String, ExploreRegion> worlds : Jobs.getExplore().getWorlds().entrySet()) {
|
||||
for (ExploreChunk oneChunk : worlds.getValue().getChunks()) {
|
||||
for (String oneuser : oneChunk.getPlayers()) {
|
||||
prest2.setString(1, worlds.getKey());
|
||||
prest2.setInt(2, oneChunk.getX());
|
||||
prest2.setInt(3, oneChunk.getZ());
|
||||
prest2.setString(4, oneuser);
|
||||
prest2.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
prest2.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save player-explore information
|
||||
* @param jobexplore - the information getting saved
|
||||
*/
|
||||
public synchronized void loadExplore() {
|
||||
if (!Jobs.getExplore().isExploreEnabled())
|
||||
return;
|
||||
|
||||
JobsConnection conn = getConnection();
|
||||
if (conn == null)
|
||||
return;
|
||||
try {
|
||||
|
||||
PreparedStatement prest = conn.prepareStatement("SELECT * FROM `" + prefix + "explore`;");
|
||||
ResultSet res = prest.executeQuery();
|
||||
while (res.next()) {
|
||||
Jobs.getExplore().ChunkRespond(res.getString("playerName"), res.getString("worldname"), res.getInt("chunkX"), res.getInt("chunkZ"));
|
||||
}
|
||||
res.close();
|
||||
prest.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save player-job information
|
||||
* @param jobInfo - the information getting saved
|
||||
|
@ -431,4 +431,39 @@ public class JobsDAOMySQL extends JobsDAO {
|
||||
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;");
|
||||
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void checkUpdate8() throws SQLException {
|
||||
JobsConnection conn = getConnection();
|
||||
if (conn == null) {
|
||||
Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to MySQL!");
|
||||
return;
|
||||
}
|
||||
PreparedStatement prest = null;
|
||||
int rows = 0;
|
||||
try {
|
||||
// Check for jobs table
|
||||
prest = conn.prepareStatement("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = ? AND table_name = ?;");
|
||||
prest.setString(1, database);
|
||||
prest.setString(2, getPrefix() + "explore");
|
||||
ResultSet res = prest.executeQuery();
|
||||
if (res.next()) {
|
||||
rows = res.getInt(1);
|
||||
}
|
||||
} finally {
|
||||
if (prest != null) {
|
||||
try {
|
||||
prest.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (rows == 0)
|
||||
executeSQL("CREATE TABLE `" + getPrefix()
|
||||
+ "explore` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `worldname` varchar(64), `chunkX` int, `chunkZ` int, `playerName` varchar(32));");
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -411,4 +411,37 @@ public class JobsDAOSQLite extends JobsDAO {
|
||||
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void checkUpdate8() throws SQLException {
|
||||
JobsConnection conn = getConnection();
|
||||
if (conn == null) {
|
||||
Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to MySQL!");
|
||||
return;
|
||||
}
|
||||
PreparedStatement prest = null;
|
||||
int rows = 0;
|
||||
try {
|
||||
// Check for jobs table
|
||||
prest = conn.prepareStatement("SELECT COUNT(*) FROM sqlite_master WHERE name = ?;");
|
||||
prest.setString(1, getPrefix() + "explore");
|
||||
ResultSet res = prest.executeQuery();
|
||||
if (res.next()) {
|
||||
rows = res.getInt(1);
|
||||
}
|
||||
} finally {
|
||||
if (prest != null) {
|
||||
try {
|
||||
prest.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (rows == 0)
|
||||
executeSQL("CREATE TABLE `" + getPrefix()
|
||||
+ "explore` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `worldname` varchar(64), `chunkX` int, `chunkZ` int, `playerName` varchar(32));");
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
com/gamingmesh/jobs/listeners/.gitignore
vendored
2
com/gamingmesh/jobs/listeners/.gitignore
vendored
@ -8,3 +8,5 @@
|
||||
/JobsPaymentListener$2.class
|
||||
/MythicMobsListener.class
|
||||
/JobsListener$2.class
|
||||
/JobsListener$3.class
|
||||
/JobsListener$4.class
|
||||
|
@ -18,15 +18,21 @@
|
||||
|
||||
package com.gamingmesh.jobs.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -43,8 +49,11 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@ -53,10 +62,14 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.JobsPlugin;
|
||||
import com.gamingmesh.jobs.Gui.GuiInfoList;
|
||||
import com.gamingmesh.jobs.Gui.GuiTools;
|
||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobLimitedItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
|
||||
public class JobsListener implements Listener {
|
||||
@ -473,4 +486,89 @@ public class JobsListener implements Listener {
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onLimitedItemInteract(PlayerInteractEvent event) {
|
||||
|
||||
Player player = (Player) event.getPlayer();
|
||||
|
||||
ItemStack iih = player.getItemInHand();
|
||||
|
||||
if (iih == null)
|
||||
return;
|
||||
|
||||
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
|
||||
if (JPlayer == null)
|
||||
return;
|
||||
|
||||
List<JobProgression> prog = JPlayer.getJobProgression();
|
||||
|
||||
String name = null;
|
||||
List<String> lore = new ArrayList<String>();
|
||||
|
||||
Map<Enchantment, Integer> enchants = iih.getEnchantments();
|
||||
|
||||
if (iih.hasItemMeta()) {
|
||||
ItemMeta meta = iih.getItemMeta();
|
||||
if (meta.hasDisplayName())
|
||||
name = meta.getDisplayName();
|
||||
if (meta.hasLore())
|
||||
lore = meta.getLore();
|
||||
}
|
||||
|
||||
String meinOk = null;
|
||||
|
||||
mein: for (JobProgression one : prog) {
|
||||
second: for (JobLimitedItems oneItem : one.getJob().getLimitedItems()) {
|
||||
|
||||
if (oneItem.getId() != iih.getTypeId())
|
||||
continue;
|
||||
|
||||
meinOk = one.getJob().getName();
|
||||
|
||||
if (oneItem.getName() != null && name != null)
|
||||
if (!org.bukkit.ChatColor.translateAlternateColorCodes('&', oneItem.getName()).equalsIgnoreCase(name))
|
||||
continue;
|
||||
|
||||
if (one.getLevel() < oneItem.getLevel())
|
||||
continue;
|
||||
|
||||
for (Entry<Enchantment, Integer> oneE : enchants.entrySet()) {
|
||||
if (oneItem.getenchants().containsKey(oneE.getKey())) {
|
||||
if (oneItem.getenchants().get(oneE.getKey()) < oneE.getValue()) {
|
||||
continue second;
|
||||
}
|
||||
} else
|
||||
continue second;
|
||||
}
|
||||
for (String onelore : oneItem.getLore()) {
|
||||
if (!lore.contains(onelore))
|
||||
continue second;
|
||||
}
|
||||
meinOk = null;
|
||||
break mein;
|
||||
}
|
||||
}
|
||||
|
||||
if (meinOk != null) {
|
||||
event.setCancelled(true);
|
||||
ActionBar.send(player, Language.getDefaultMessage("limitedItem.error.levelup").replace("[jobname]", meinOk));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkChangeMove(PlayerMoveEvent event) {
|
||||
|
||||
Chunk from = event.getFrom().getChunk();
|
||||
Chunk to = event.getTo().getChunk();
|
||||
|
||||
if (from == to)
|
||||
return;
|
||||
|
||||
JobsChunkChangeEvent jobsChunkChangeEvent = new JobsChunkChangeEvent(event.getPlayer(), from, to);
|
||||
Bukkit.getServer().getPluginManager().callEvent(jobsChunkChangeEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,9 +71,12 @@ import com.gamingmesh.jobs.actions.BlockActionInfo;
|
||||
import com.gamingmesh.jobs.actions.CustomKillInfo;
|
||||
import com.gamingmesh.jobs.actions.EnchantActionInfo;
|
||||
import com.gamingmesh.jobs.actions.EntityActionInfo;
|
||||
import com.gamingmesh.jobs.actions.ExploreActionInfo;
|
||||
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.ExploreRespond;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
@ -324,7 +327,7 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
|
||||
// Item in hand
|
||||
ItemStack item = player.getItemInHand().hasItemMeta() ? player.getItemInHand() : null;
|
||||
ItemStack item = player.getItemInHand();
|
||||
|
||||
// Protection for block break with silktouch
|
||||
if (ConfigManager.getJobsConfiguration().useSilkTouchProtection && item != null)
|
||||
@ -1054,4 +1057,50 @@ public class JobsPaymentListener implements Listener {
|
||||
block.setMetadata(brewingOwnerMetadata, new FixedMetadataValue(plugin, event.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onExplore(JobsChunkChangeEvent event) {
|
||||
|
||||
if (!Jobs.getExplore().isExploreEnabled())
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getPlayer();
|
||||
|
||||
if (!ConfigManager.getJobsConfiguration().payExploringWhenFlying())
|
||||
return;
|
||||
|
||||
ExploreRespond respond = Jobs.getExplore().ChunkRespond(event.getPlayer(), event.getNewChunk());
|
||||
|
||||
if (!respond.isNewChunk())
|
||||
return;
|
||||
|
||||
// make sure plugin is enabled
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
|
||||
return;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// restricted area multiplier
|
||||
double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
|
||||
|
||||
// Item in hand
|
||||
ItemStack item = player.getItemInHand();
|
||||
|
||||
// Wearing armor
|
||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
Jobs.action(jPlayer, new ExploreActionInfo(String.valueOf(respond.getCount()), ActionType.EXPLORE), multiplier, item, armor);
|
||||
}
|
||||
}
|
||||
|
1
com/gamingmesh/jobs/stuff/.gitignore
vendored
1
com/gamingmesh/jobs/stuff/.gitignore
vendored
@ -28,3 +28,4 @@
|
||||
/ScheduleUtil$2.class
|
||||
/OfflinePlayerList.class
|
||||
/OfflinePlayerList$1.class
|
||||
/Explore.class
|
||||
|
83
com/gamingmesh/jobs/stuff/Explore.java
Normal file
83
com/gamingmesh/jobs/stuff/Explore.java
Normal file
@ -0,0 +1,83 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.ExploreChunk;
|
||||
import com.gamingmesh.jobs.container.ExploreRegion;
|
||||
import com.gamingmesh.jobs.container.ExploreRespond;
|
||||
|
||||
public class Explore {
|
||||
|
||||
private HashMap<String, ExploreRegion> worlds = new HashMap<String, ExploreRegion>();
|
||||
private boolean exploreEnabled = false;
|
||||
private int playerAmount = 1;
|
||||
|
||||
public Explore() {
|
||||
}
|
||||
|
||||
public int getPlayerAmount() {
|
||||
return this.playerAmount;
|
||||
}
|
||||
|
||||
public void setPlayerAmount(int amount) {
|
||||
if (this.playerAmount < amount)
|
||||
this.playerAmount = amount;
|
||||
}
|
||||
|
||||
public boolean isExploreEnabled() {
|
||||
return this.exploreEnabled;
|
||||
}
|
||||
|
||||
public void setExploreEnabled() {
|
||||
this.exploreEnabled = true;
|
||||
Jobs.getJobsDAO().loadExplore();
|
||||
}
|
||||
|
||||
public HashMap<String, ExploreRegion> getWorlds() {
|
||||
return worlds;
|
||||
}
|
||||
|
||||
public ExploreRespond ChunkRespond(Player player, Chunk chunk) {
|
||||
return ChunkRespond(player.getName(), chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
public ExploreRespond ChunkRespond(String player, String worldName, int x, int z) {
|
||||
|
||||
int ChunkX = x;
|
||||
int ChunkZ = z;
|
||||
|
||||
int RegionX = (int) Math.floor(ChunkX / 32D);
|
||||
int RegionZ = (int) Math.floor(ChunkZ / 32D);
|
||||
|
||||
if (!worlds.containsKey(worldName)) {
|
||||
ExploreChunk eChunk = new ExploreChunk(player, ChunkX, ChunkZ);
|
||||
ExploreRegion eRegion = new ExploreRegion(RegionX, RegionZ);
|
||||
eRegion.addChunk(eChunk);
|
||||
worlds.put(worldName, eRegion);
|
||||
return new ExploreRespond(eChunk.getCount(), true);
|
||||
} else {
|
||||
ExploreRegion eRegion = worlds.get(worldName);
|
||||
ExploreChunk eChunk = null;
|
||||
for (ExploreChunk one : eRegion.getChunks()) {
|
||||
if (one.getX() != ChunkX)
|
||||
continue;
|
||||
if (one.getZ() != ChunkZ)
|
||||
continue;
|
||||
eChunk = one;
|
||||
break;
|
||||
}
|
||||
|
||||
if (eChunk == null) {
|
||||
eChunk = new ExploreChunk(player, ChunkX, ChunkZ);
|
||||
eRegion.addChunk(eChunk);
|
||||
return new ExploreRespond(eChunk.getCount(), true);
|
||||
} else {
|
||||
return eChunk.addPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +1,38 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class GiveItem {
|
||||
public static boolean GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List<String> lore, List<String> enchants) {
|
||||
@SuppressWarnings("deprecation")
|
||||
ItemStack itemStack = new ItemStack(Material.getMaterial(id), qty, (short) meta);
|
||||
ItemMeta ItemMeta = itemStack.getItemMeta();
|
||||
if (lore != null) {
|
||||
List<String> TranslatedLore = new ArrayList<String>();
|
||||
for (String oneLore : lore) {
|
||||
TranslatedLore.add(ChatColor.translateAlternateColorCodes('&', oneLore.replace("[player]", player.getName())));
|
||||
}
|
||||
ItemMeta.setLore(TranslatedLore);
|
||||
}
|
||||
if (enchants != null)
|
||||
for (String OneEnchant : enchants) {
|
||||
ItemMeta.addEnchant(Enchantment.getByName(OneEnchant.split("=")[0]), Integer.parseInt(OneEnchant.split("=")[1]), true);
|
||||
}
|
||||
if (name != null)
|
||||
ItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
itemStack.setItemMeta(ItemMeta);
|
||||
player.getInventory().addItem(itemStack);
|
||||
player.getPlayer().updateInventory();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class GiveItem {
|
||||
public static boolean GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List<String> lore, HashMap<Enchantment, Integer> hashMap) {
|
||||
@SuppressWarnings("deprecation")
|
||||
ItemStack itemStack = new ItemStack(Material.getMaterial(id), qty, (short) meta);
|
||||
ItemMeta ItemMeta = itemStack.getItemMeta();
|
||||
|
||||
if (lore != null) {
|
||||
List<String> TranslatedLore = new ArrayList<String>();
|
||||
for (String oneLore : lore) {
|
||||
TranslatedLore.add(ChatColor.translateAlternateColorCodes('&', oneLore.replace("[player]", player.getName())));
|
||||
}
|
||||
ItemMeta.setLore(TranslatedLore);
|
||||
}
|
||||
for (Entry<Enchantment, Integer> OneEnchant : hashMap.entrySet()) {
|
||||
ItemMeta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true);
|
||||
}
|
||||
if (name != null)
|
||||
ItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
itemStack.setItemMeta(ItemMeta);
|
||||
player.getInventory().addItem(itemStack);
|
||||
player.getPlayer().updateInventory();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ public class TranslateName {
|
||||
break;
|
||||
case CUSTOMKILL:
|
||||
case MMKILL:
|
||||
case EXPLORE:
|
||||
break;
|
||||
case SHEAR:
|
||||
for (NameList one : ConfigManager.getJobsConfiguration().ListOfColors) {
|
||||
|
@ -293,6 +293,24 @@ Jobs:
|
||||
REDSTONE:
|
||||
income: 5.0
|
||||
experience: 3.0
|
||||
# Explore options. Each number represents players number in exploring that chunk
|
||||
# 1 means that player is first in this chunk, 2 is second and so on, so you can give money not only for first player ho discovers that chunk
|
||||
Explore:
|
||||
1:
|
||||
income: 5.0
|
||||
experience: 5.0
|
||||
2:
|
||||
income: 2.5
|
||||
experience: 2.5
|
||||
3:
|
||||
income: 1.0
|
||||
experience: 1.0
|
||||
4:
|
||||
income: 0.5
|
||||
experience: 0.5
|
||||
5:
|
||||
income: 0.1
|
||||
experience: 0.1
|
||||
# permissions granted for joining class
|
||||
permissions:
|
||||
# example node
|
||||
@ -363,6 +381,25 @@ Jobs:
|
||||
- '&710% bonus XP'
|
||||
moneyBoost: 1.1
|
||||
expBoost: 1.1
|
||||
# Limit item use to jobs level
|
||||
limitedItems:
|
||||
# Just name, dont have any impact
|
||||
firstOne:
|
||||
# Tool/Weapon id. Works for any interact action.
|
||||
id: 278
|
||||
# Level of this job player can start using this item
|
||||
level: 5
|
||||
# (optional) Items name, option to use color codes
|
||||
name: '&8Miner Pickaxe'
|
||||
# (optional) Item lore, again can come with color codes
|
||||
lore:
|
||||
- '&eBobs pick'
|
||||
- '&710% bonus XP'
|
||||
# (optional) Item enchantments, all enchantment names can be found https://hub.spigotmc.org/javadocs/spigot/org/bukkit/enchantments/Enchantment.html
|
||||
# enchant level can inrease with jobs level to give best RPG experiance
|
||||
enchants:
|
||||
- DAMAGE_ALL=1
|
||||
- FIRE_ASPECT=1
|
||||
cmd-on-join:
|
||||
- 'msg [name] Thx for joining this job!'
|
||||
- 'msg [name] Now start working and get money from [jobname] job!'
|
||||
|
230
locale/messages_cz.yml
Normal file
230
locale/messages_cz.yml
Normal file
@ -0,0 +1,230 @@
|
||||
economy:
|
||||
error:
|
||||
nomoney: Nedostatek financi!
|
||||
command:
|
||||
boost:
|
||||
help:
|
||||
info: Zvysuje Exp/Vydelek pro vsechny hrace.
|
||||
args: '[JmenoPrace] [Hodnota]'
|
||||
output:
|
||||
allreset: Vsechny exp/vydelky BOOST byly vypnuty.
|
||||
jobsboostreset: BOOST pro %jobname% byl vypnut.
|
||||
nothingtoreset: Neni nic, co by se dalo vypnout.
|
||||
boostalladded: BOOST hodnoty %boost% byly povoleny pro vsechny prace.
|
||||
boostadded: BOOST hodnoty &e%boost% &abyly povoleny pro praci &e%jobname%!
|
||||
infostats: '&c-----> &aExp/Vydelky x%boost% je/jsou zapnute&c <-------'
|
||||
convert:
|
||||
help:
|
||||
info: Prevede data z jednoho zpusobu databaze na jiny. Pokud práve pouzivate SQLite, bude preveden na MySQL a naopak.
|
||||
args: ''
|
||||
limit:
|
||||
help:
|
||||
info: Vypise limit vydelku praci.
|
||||
args: ''
|
||||
output:
|
||||
lefttime: '&eZbyvajici cas do resetovani limitu vydelku: &2%hour% &ehour &2%min% &emin &2%sec%
|
||||
&esec'
|
||||
moneylimit: '&eLimit vydelku: &2%money%&e/&2%totalmoney%'
|
||||
reachedlimit: '&4Dosahl/a jsi limitu vydelku v danem case!'
|
||||
reachedlimit2: '&eLimit zjistis prikazem &2/jobs limit'
|
||||
notenabled: '&eLimit vydelku neni zapnuty.'
|
||||
admin:
|
||||
error: Doslo k chybe v prikazu.
|
||||
success: Prikaz byl proveden dle rozkazu.
|
||||
error:
|
||||
job: 'Prace, kterou sis vybral/a, neexistuje.'
|
||||
permission: Nemas povoleni na tuto akci.
|
||||
help:
|
||||
output:
|
||||
info: Napis /jobs [prikaz] ? pro vice informaci.
|
||||
usage: 'Pouziti: %usage%'
|
||||
stats:
|
||||
help:
|
||||
info: 'Vypise level v pracech, ve kterych jsi zamestnany(a).'
|
||||
args: '[JmenoHrace]'
|
||||
error:
|
||||
nojob: 'Nejdrive se prihlas do nejake prace.'
|
||||
output: 'lvl%joblevel% %jobname% : %jobxp%/%jobmaxxp% xp'
|
||||
archive:
|
||||
help:
|
||||
info: Vypise vsechny prace ulozene v archivu podle uzivatele.
|
||||
args: '[JmenoHrace]'
|
||||
error:
|
||||
nojob: Nejsou zadne ulozene prace.
|
||||
output: lvl %joblevel% (%getbackjoblevel%) %jobname%
|
||||
give:
|
||||
help:
|
||||
info: Da item podle nazvu prace a nazvu kategorie. Jmeno Hrace neni povinny udaj.
|
||||
args: '[JmenoHrace] [JmenoPrace] [JmenoItemu]'
|
||||
output:
|
||||
notonline: '&4Hrac [%playername%] neni online!'
|
||||
noitem: '&4Nelze najit item s timto jmenem!'
|
||||
info:
|
||||
help:
|
||||
title: '&2*** &ePrace&2 ***'
|
||||
info: Vypise vysi vydelku prace k dane akci.
|
||||
args: '[JmenoPrace] [akce]'
|
||||
actions: '&ePlatne akce jsou: &f%actions%'
|
||||
max: ' - &emax level:&f '
|
||||
material: '&7%material%'
|
||||
output:
|
||||
break:
|
||||
info: Breaknuti
|
||||
none: '%jobname% vydelava penize za breaknuti bloku.'
|
||||
place:
|
||||
info: Polozeni
|
||||
none: '%jobname% vydelava penize za polozeni bloku.'
|
||||
kill:
|
||||
info: Zabijeni
|
||||
none: '%jobname% vydelava penize za zabijeni monster.'
|
||||
fish:
|
||||
info: Rybareni
|
||||
none: '%jobname% vydelava penize za rybarení.'
|
||||
craft:
|
||||
info: Craft
|
||||
none: '%jobname% vydelava penize za craftení vecí.'
|
||||
smelt:
|
||||
info: Peceni
|
||||
none: '%jobname% vydelava penize za pecení v peci.'
|
||||
brew:
|
||||
info: Vareni
|
||||
none: '%jobname% vydelava penize za vareni lektvaru.'
|
||||
enchant:
|
||||
info: Ocarovani
|
||||
none: '%jobname% vydelava penize za ocarovávání/enchant itemu.'
|
||||
repair:
|
||||
info: Opravovani
|
||||
none: '%jobname% vydelava penize za opravování predmetu.'
|
||||
breed:
|
||||
info: Farmareni
|
||||
none: '%jobname% vydelava penize za farmareni.'
|
||||
tame:
|
||||
info: Ochocovani
|
||||
none: '%jobname% vydelava penize za ochocovani zvirat.'
|
||||
playerinfo:
|
||||
help:
|
||||
info: Vypise vysi vydelku prace k dane akci urciteho hrace.
|
||||
args: '[JmenoHrace] [JmenoPrace] [akce]'
|
||||
join:
|
||||
help:
|
||||
info: Zamestnas se do prace.
|
||||
args: '[JmenoPrace]'
|
||||
error:
|
||||
alreadyin: Uz pracujes jako %jobname%.
|
||||
fullslots: Nemuzes se zamestnat do prace %jobname%, nejsou zde zadna volna mista.
|
||||
maxjobs: Dosahl/a jsi maxima povolenych praci.
|
||||
success: Zamestnal/a ses jako %jobname%.
|
||||
leave:
|
||||
help:
|
||||
info: Opustis danou praci.
|
||||
args: '[JmenoPrace]'
|
||||
success: Opustil/a jsi praci %jobname%.
|
||||
leaveall:
|
||||
help:
|
||||
info: Opustis vsechny svoje prace
|
||||
error:
|
||||
nojobs: Nemas zadne prace, ktere by jsi mohl/a opustit.
|
||||
success: Opustil/a jsi vsechny sve prace.
|
||||
browse:
|
||||
help:
|
||||
info: Seznam dostupnych praci
|
||||
error:
|
||||
nojobs: 'Nejsou zadne prace, ve kterych by jsi mohl/a byt zamestnan/a.'
|
||||
output:
|
||||
header: 'Mas povoleni na zamestnani v techto pracech:'
|
||||
footer: Pro více info napis /jobs info [JmenoPrace]
|
||||
fire:
|
||||
help:
|
||||
info: Vykopne hrace z dane prace.
|
||||
args: '[JmenoHrace] [JmenoPrace]'
|
||||
error:
|
||||
nojob: Hrac neni zamestnan jako %jobname%.
|
||||
output:
|
||||
target: Byl/a jsi vyhozen/a z prace %jobname%.
|
||||
fireall:
|
||||
help:
|
||||
info: Vykopne hrace ze vsech prací.
|
||||
args: '[JmenoHrace]'
|
||||
error:
|
||||
nojobs: Hrac nema zadne prace, ze kterych by mohl byt vykopnut.
|
||||
output:
|
||||
target: Byl/a jsi vykopnut/a ze vsech prací.
|
||||
employ:
|
||||
help:
|
||||
info: Zamestna hrace do prace.
|
||||
args: '[JmenoHrace] [JmenoPrace]'
|
||||
error:
|
||||
alreadyin: Hrac uz pracuje jako %jobname%.
|
||||
output:
|
||||
target: Byl/a jsi zamestnan/a jako %jobname%.
|
||||
top:
|
||||
help:
|
||||
info: '&eZobrazi &aTop 10 &ehracu dle praci.'
|
||||
args: '[JmenoPrace]'
|
||||
error:
|
||||
nojob: Nelze najit zadnou praci s timto jmenem.
|
||||
output:
|
||||
topline: '&aTop&e 10 &ehracu pro praci &6%jobname%'
|
||||
list: '&e%number%&a. &e%playername% &alvl &e%level% &as&e %exp% &aexp'
|
||||
transfer:
|
||||
help:
|
||||
info: Prevede danou praci hrace ze stare práce do nove.
|
||||
args: '[JmenoHrace] [StaraPrace] [NovaPrace]'
|
||||
output:
|
||||
target: Byl/a jsi presunut/a z prace %oldjobname% do %newjobname%.
|
||||
promote:
|
||||
help:
|
||||
info: Prida hraci levely do dane prace.
|
||||
args: '[JmenoHrace] [JmenoPrace] [levely]'
|
||||
output:
|
||||
target: Bylo ti pridano %levelsgained% levelu v praci %jobname%.
|
||||
demote:
|
||||
help:
|
||||
info: Odebere hraci levely z dane prace.
|
||||
args: '[JmenoHrace] [JmenoPrace] [levely]'
|
||||
output:
|
||||
target: Bylo ti odebrano %levelslost% levelu v praci %jobname%.
|
||||
grantxp:
|
||||
help:
|
||||
info: Prida hraci zkusenosti do dane prace.
|
||||
args: '[JmenoHrace] [JmenoPrace] [xp]'
|
||||
output:
|
||||
target: Dostal/a jsi %xpgained% zkusenosti v praci %jobname%.
|
||||
removexp:
|
||||
help:
|
||||
info: Odstrani hraci zkusenosti z dane prace.
|
||||
args: '[JmenoHrace] [JmenoPrace] [xp]'
|
||||
output:
|
||||
target: Ztratil/a jsi %xplost% zkusenosti v praci %jobname%.
|
||||
reload:
|
||||
help:
|
||||
info: Reloadne konfiguraci.
|
||||
toggle:
|
||||
help:
|
||||
info: Zapina/Vypina vypis vydelku na panelu akci.
|
||||
output:
|
||||
paid: '&a+ &a&l[amount]&a$'
|
||||
'on': '&aVypis: &aZAPNUTO'
|
||||
'off': '&aVypis: &cVYPNUTO'
|
||||
message:
|
||||
skillup:
|
||||
broadcast: '%playername% byl/a povysen/a na %titlename% %jobname%.'
|
||||
nobroadcast: Gratulujeme, byl/a jsi povysen/a na %titlename% %jobname%.
|
||||
levelup:
|
||||
broadcast: '%playername% dosahl/a levelu %joblevel% v praci %jobname%.'
|
||||
nobroadcast: Dosahl/a jsi levelu %joblevel% v praci %jobname%.
|
||||
crafting:
|
||||
fullinventory: Mas plny inventar!
|
||||
signs:
|
||||
cantcreate: '&4Nemuzes vytvorit tuto cedulku!'
|
||||
topline: '&e[Jobs]'
|
||||
secondline:
|
||||
join: '&2Join'
|
||||
leave: '&4Leave'
|
||||
toggle: '&eToggle'
|
||||
top: '&eTop'
|
||||
browse: '&eBrowse'
|
||||
stats: '&eStats'
|
||||
limit: '&eLimit'
|
||||
info: '&eInfo'
|
||||
archive: '&eArchive'
|
@ -1,7 +1,7 @@
|
||||
name: Jobs
|
||||
description: Jobs Plugin for the BukkitAPI
|
||||
main: com.gamingmesh.jobs.JobsPlugin
|
||||
version: 2.56.0
|
||||
version: 2.58.0
|
||||
author: phrstbrn
|
||||
softdepend: [Vault, CoreProtect, MythicMobs, McMMO]
|
||||
commands:
|
||||
|
Loading…
Reference in New Issue
Block a user