1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

Minor config changes

- Fix jobs.* permission does not work correctly
- Fix potion item main hand
- Removed IConomy support
- Fixing drink job event (not working)...
This commit is contained in:
montlikadani 2018-09-28 19:38:00 +02:00
parent ebc6c99dc2
commit 36d4eded68
14 changed files with 47 additions and 147 deletions

Binary file not shown.

View File

@ -26,7 +26,6 @@ import org.bukkit.plugin.RegisteredServiceProvider;
import com.gamingmesh.jobs.economy.BlackholeEconomy;
import com.gamingmesh.jobs.economy.VaultEconomy;
import com.gamingmesh.jobs.economy.IConomy6Adapter;
public class HookEconomyTask implements Runnable {
private Jobs plugin;
@ -41,17 +40,12 @@ public class HookEconomyTask implements Runnable {
if (setVault())
return;
if (setIConomy())
return;
// no Economy found
Jobs.setEconomy(this.plugin, new BlackholeEconomy());
Bukkit.getServer().getLogger().severe("==================== " + this.plugin.getDescription().getName() + " ====================");
Bukkit.getServer().getLogger().severe("Vault or Iconomy is required by this plugin for economy support!");
Bukkit.getServer().getLogger().severe("Vault is required by this plugin for economy support!");
Bukkit.getServer().getLogger().severe("Please install them first!");
Bukkit.getServer().getLogger().severe("You can find the latest versions here:");
Bukkit.getServer().getLogger().severe("https://dev.bukkit.org/projects/vault/");
Bukkit.getServer().getLogger().severe("https://dev.bukkit.org/projects/iconomy-7/");
Bukkit.getServer().getLogger().severe("https://www.spigotmc.org/resources/vault.34315/");
Bukkit.getServer().getLogger().severe("==============================================");
}
@ -61,7 +55,7 @@ public class HookEconomyTask implements Runnable {
if (eco == null)
return false;
RegisteredServiceProvider<Economy> provider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
RegisteredServiceProvider<Economy> provider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (provider == null)
return false;
@ -74,21 +68,4 @@ public class HookEconomyTask implements Runnable {
return true;
}
private boolean setIConomy() {
Plugin p = Bukkit.getServer().getPluginManager().getPlugin("iConomy");
if (p == null)
return false;
try {
Jobs.setEconomy(this.plugin, new IConomy6Adapter((com.iCo6.iConomy) p));
} catch (Exception e) {
Jobs.consoleMsg("&e[" + this.plugin.getDescription().getName() + "] UNKNOWN iConomy version.");
return false;
}
Jobs.consoleMsg("&e[" + this.plugin.getDescription().getName() + "] Successfully linked with iConomy! Version: " + p.getDescription().getVersion());
return true;
}
}

View File

@ -1139,7 +1139,7 @@ public class Jobs extends JavaPlugin {
}
private static boolean isBpOk(JobsPlayer player, ActionInfo info, Block block, boolean inform) {
if (block == null || !getGCManager().useBlockProtection)
if (block == null || !GconfigManager.useBlockProtection)
return true;
if (info.getType() == ActionType.BREAK) {
@ -1164,16 +1164,16 @@ public class Jobs extends JavaPlugin {
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
if (inform) {
if (player.canGetPaid(info))
getActionBar().send(player.getPlayer(), getLanguage().getMessage("message.blocktimer", "[time]", sec));
actionbar.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
}
return false;
}
BpManager.add(block, cd);
if ((cd == null || cd == 0) && getGCManager().useGlobalTimer) {
BpManager.add(block, getGCManager().globalblocktimer);
if ((cd == null || cd == 0) && GconfigManager.useGlobalTimer) {
BpManager.add(block, GconfigManager.globalblocktimer);
}
} else if (getGCManager().useGlobalTimer) {
BpManager.add(block, getGCManager().globalblocktimer);
} else if (GconfigManager.useGlobalTimer) {
BpManager.add(block, GconfigManager.globalblocktimer);
}
} else if (info.getType() == ActionType.PLACE) {
BlockProtection bp = BpManager.getBp(block.getLocation());
@ -1190,7 +1190,7 @@ public class Jobs extends JavaPlugin {
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
if (inform) {
if (player.canGetPaid(info))
getActionBar().send(player.getPlayer(), getLanguage().getMessage("message.blocktimer", "[time]", sec));
actionbar.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
}
BpManager.add(block, cd);
return false;
@ -1296,9 +1296,9 @@ public class Jobs extends JavaPlugin {
if (!inform)
return false;
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("general.error.permission"), "&2" + perm);
rm.add(lManager.getMessage("general.error.permission"), "&2" + perm);
rm.show((Player) sender);
sendMessage(Bukkit.getServer().getConsoleSender(), Jobs.getLanguage().getMessage("general.error.permission"));
sendMessage(Bukkit.getServer().getConsoleSender(), lManager.getMessage("general.error.permission"));
return false;
}
return true;
@ -1329,10 +1329,10 @@ public class Jobs extends JavaPlugin {
Prevpage = CurrentPage > 1 ? Prevpage : CurrentPage;
RawMessage rm = new RawMessage();
rm.add((CurrentPage > 1 ? Jobs.getLanguage().getMessage("command.help.output.prevPage") : Jobs.getLanguage().getMessage("command.help.output.prevPageOff")),
rm.add((CurrentPage > 1 ? lManager.getMessage("command.help.output.prevPage") : lManager.getMessage("command.help.output.prevPageOff")),
CurrentPage > 1 ? "<<<" : null, CurrentPage > 1 ? cmd + " " + pagePrefix + Prevpage : null);
rm.add(Jobs.getLanguage().getMessage("command.help.output.pageCount", "[current]", CurrentPage, "[total]", pageCount));
rm.add(pageCount > CurrentPage ? Jobs.getLanguage().getMessage("command.help.output.nextPage") : Jobs.getLanguage().getMessage("command.help.output.nextPageOff"),
rm.add(lManager.getMessage("command.help.output.pageCount", "[current]", CurrentPage, "[total]", pageCount));
rm.add(pageCount > CurrentPage ? lManager.getMessage("command.help.output.nextPage") : lManager.getMessage("command.help.output.nextPageOff"),
pageCount > CurrentPage ? ">>>" : null, pageCount > CurrentPage ? cmd + " " + pagePrefix + NextPage : null);
if (pageCount != 0)
rm.show(sender);

View File

@ -25,16 +25,16 @@ import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.BaseActionInfo;
public class PotionDrinkInfo extends BaseActionInfo implements ActionInfo {
private String potion;
private PotionType potion;
public PotionDrinkInfo(String potion, ActionType type) {
public PotionDrinkInfo(PotionType potion, ActionType type) {
super(type);
this.potion = potion;
}
@Override
public String getName() {
return PotionType.valueOf(potion).name();
return potion.name();
}
@Override

View File

@ -445,7 +445,7 @@ public class ConfigManager {
String jobShortName = jobSection.getString("shortname", null);
if (jobShortName == null) {
Jobs.getPluginLogger().warning("Job " + jobKey + " is missing the shortname property. Skipping job!");
Jobs.getPluginLogger().warning("Job " + jobKey + " is missing the shortname property. Skipping job!");
continue;
}
@ -467,7 +467,7 @@ public class ConfigManager {
color = ChatColor.matchColor(jobSection.getString("ChatColour", ""));
if (color == null) {
color = ChatColor.WHITE;
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!");
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!");
}
}

View File

@ -431,10 +431,10 @@ public class GeneralConfigManager {
// c.get("mysql-database", "minecraft");
// c.get("mysql-table-prefix", "jobs_");
c.getW().addComment("save-period", "How often in minutes you want it to save. This must be a non-zero number");
c.getW().addComment("save-period", "How often in minutes you want it to save. This must be a non-zero number");
c.get("save-period", 10);
if (c.getC().getInt("save-period") <= 0) {
Jobs.getPluginLogger().severe("Save period must be greater than 0! Defaulting to 10 minutes!");
Jobs.getPluginLogger().severe("Save period must be greater than 0! Defaulting to 10 minutes!");
c.getC().set("save-period", 10);
}
savePeriod = c.getC().getInt("save-period");
@ -445,9 +445,10 @@ public class GeneralConfigManager {
saveOnDisconnect = c.get("save-on-disconnect", false);
c.getW().addComment("selectionTool", "Tool used when selecting bounds for restricted area");
getSelectionTooldID = c.get("selectionTool", 294);
if (CMIMaterial.get(Jobs.getGCManager().getSelectionTooldID) == null)
getSelectionTooldID = 294;
if (CMIMaterial.get(getSelectionTooldID) == null)
getSelectionTooldID = 294;
else
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",
@ -548,13 +549,11 @@ public class GeneralConfigManager {
c.getW().addComment("add-xp-player", "Adds the Jobs xp recieved to the player's Minecraft XP bar");
addXpPlayer = c.get("add-xp-player", false);
c.getW().addComment("modify-chat",
"Modifys chat to add chat titles. If you're using a chat manager, you may add the tag {jobs} to your chat format and disable this.");
modifyChat = c.get("modify-chat", true);
modifyChatPrefix = c.get("modify-chat-prefix", "&c[", true);
modifyChatSuffix = c.get("modify-chat-suffix", "&c]&r", true);
modifyChatSeparator = c.get("modify-chat-separator", " ", true);
c.getW().addComment("modify-chat", "Modifys chat to add chat titles. If you're using a chat manager, you may add the tag {jobs} to your chat format and disable this.");
modifyChat = c.get("modify-chat.use", true);
modifyChatPrefix = c.get("modify-chat.prefix", "&c[", true);
modifyChatSuffix = c.get("modify-chat.suffix", "&c]&r", true);
modifyChatSeparator = c.get("modify-chat.separator", " ", true);
c.getW().addComment("UseCustomNames", "Do you want to use custom item/block/mob/enchant/color names",
"With this set to true names like Stone:1 will be translated to Granite", "Name list is in TranslatableWords.yml file");
@ -638,7 +637,7 @@ public class GeneralConfigManager {
// Money limit
CurrencyLimit limit = new CurrencyLimit();
c.getW().addComment("Economy.Limit.Money", "Money gain limit", "With this enabled, players will be limited how much they can make in defined time",
"Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
"Time in seconds: 60 = 1 min, 3600 = 1 hour, 86400 = 24 hours");
limit.setEnabled(c.get("Economy.Limit.Money.Use", false));
List<CurrencyType> list = new ArrayList<>();
c.getW().addComment("Economy.Limit.Money.StopWithExp", "Do you want to stop money gain when exp limit reached?");
@ -663,7 +662,7 @@ public class GeneralConfigManager {
Jobs.getPluginLogger().warning("MoneyLimit has an invalid value. Disabling money limit!");
limit.setEnabled(false);
}
c.getW().addComment("Economy.Limit.Money.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
c.getW().addComment("Economy.Limit.Money.TimeLimit", "Time in seconds: 60 = 1 min, 3600 = 1 hour, 86400 = 24 hours");
limit.setTimeLimit(c.get("Economy.Limit.Money.TimeLimit", 3600));
c.getW().addComment("Economy.Limit.Money.AnnouncementDelay", "Delay between announcements about reached money limit",
"Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying");
@ -697,7 +696,7 @@ public class GeneralConfigManager {
Jobs.getPluginLogger().warning("PointLimit has an invalid value. Disabling money limit!");
limit.setEnabled(false);
}
c.getW().addComment("Economy.Limit.Point.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
c.getW().addComment("Economy.Limit.Point.TimeLimit", "Time in seconds: 60 = 1 min, 3600 = 1 hour, 86400 = 24 hours");
limit.setTimeLimit(c.get("Economy.Limit.Point.TimeLimit", 3600));
c.getW().addComment("Economy.Limit.Point.AnnouncementDelay", "Delay between announcements about reached limit",
"Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying");
@ -708,7 +707,7 @@ public class GeneralConfigManager {
limit = new CurrencyLimit();
list = new ArrayList<>();
c.getW().addComment("Economy.Limit.Exp", "Exp gain limit", "With this enabled, players will be limited how much they can get in defined time",
"Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
"Time in seconds: 60 = 1 min, 3600 = 1 hour, 86400 = 24 hours");
limit.setEnabled(c.get("Economy.Limit.Exp.Use", false));
c.getW().addComment("Economy.Limit.Exp.StopWithMoney", "Do you want to stop exp gain when money limit reached?");
if (c.get("Economy.Limit.Exp.StopWithMoney", false))
@ -717,7 +716,7 @@ public class GeneralConfigManager {
if (c.get("Economy.Limit.Exp.StopWithPoint", false))
list.add(CurrencyType.POINTS);
limit.setStopWith(list);
c.getW().addComment("Economy.Limit.Exp.Limit", "Equation to calculate max money limit. Option to use totallevel to include players total amount of current jobs",
c.getW().addComment("Economy.Limit.Exp.Limit", "Equation to calculate max money limit. Option to use total level to include players total amount of current jobs",
"You can always use simple number to set exp limit",
"Default equation is: 5000+5000*(totallevel/100), this will add 1% from 5000 for each level player have",
"So player with 2 jobs with level 15 and 22 will have 6850 limit");
@ -731,7 +730,7 @@ public class GeneralConfigManager {
Jobs.getPluginLogger().warning("ExpLimit has an invalid value. Disabling money limit!");
limit.setEnabled(false);
}
c.getW().addComment("Economy.Limit.Exp.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
c.getW().addComment("Economy.Limit.Exp.TimeLimit", "Time in seconds: 60 = 1 min, 3600 = 1 hour, 86400 = 24 hours");
limit.setTimeLimit(c.get("Economy.Limit.Exp.TimeLimit", 3600));
c.getW().addComment("Economy.Limit.Exp.AnnouncementDelay", "Delay between announcements about reached Exp limit",
"Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying");

View File

@ -23,7 +23,7 @@ public class LanguageManager {
this.plugin = plugin;
}
List<String> languages = new ArrayList<>();
private List<String> languages = new ArrayList<>();
public List<String> getLanguages() {
return languages;
@ -367,6 +367,8 @@ public class LanguageManager {
c.get("command.info.output.fish.none", "%jobname% does not get money from fishing.");
c.get("command.info.output.craft.info", "Craft");
c.get("command.info.output.craft.none", "%jobname% does not get money from crafting.");
c.get("command.info.output.drink.info", "Drink");
c.get("command.info.output.drink.none", "%jobname% does not get money for drinking.");
c.get("command.info.output.smelt.info", "Smelt");
c.get("command.info.output.smelt.none", "%jobname% does not get money from smelting.");
c.get("command.info.output.brew.info", "Brew");

View File

@ -1,75 +0,0 @@
package com.gamingmesh.jobs.economy;
import org.bukkit.OfflinePlayer;
import com.iCo6.iConomy;
import com.iCo6.system.Accounts;
public class IConomy6Adapter implements Economy {
iConomy icon;
public IConomy6Adapter(iConomy icon) {
this.icon = icon;
}
public double getBalance(String playerName) {
checkExist(playerName);
return new Accounts().get(playerName).getHoldings().getBalance();
}
@Override
public boolean hasMoney(OfflinePlayer offlinePlayer, double amount) {
return hasMoney(offlinePlayer.getName(), amount);
}
@Override
public boolean hasMoney(String PlayerName, double amount) {
checkExist(PlayerName);
double holdings = this.getBalance(PlayerName);
if (holdings >= amount) {
return true;
}
return false;
}
@Override
public boolean depositPlayer(String PlayerName, double amount) {
checkExist(PlayerName);
new Accounts().get(PlayerName).getHoldings().add(amount);
return true;
}
@Override
public boolean depositPlayer(OfflinePlayer offlinePlayer, double amount) {
return depositPlayer(offlinePlayer.getName(), amount);
}
@Override
public boolean withdrawPlayer(String playerName, double amount) {
checkExist(playerName);
if (this.hasMoney(playerName, amount)) {
new Accounts().get(playerName).getHoldings().subtract(amount);
return true;
}
return false;
}
@Override
public boolean withdrawPlayer(OfflinePlayer offlinePlayer, double amount) {
return withdrawPlayer(offlinePlayer.getName(), amount);
}
@Override
public String format(double money) {
return iConomy.format(money);
}
private static void checkExist(String playerName) {
Accounts acc = new Accounts();
if (!acc.exists(playerName)) {
acc.create(playerName);
}
}
}

View File

@ -1520,16 +1520,13 @@ public class JobsPaymentListener implements Listener {
if (!Jobs.getPermissionHandler().hasWorldPermission(p, p.getLocation().getWorld().getName()))
return;
// Item in hand
ItemStack item = p.getItemInHand();
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(p);
if (jPlayer == null)
return;
// Player drinking a potion
if (item.getType().equals(CMIMaterial.get(Material.POTION).isPotion()))
Jobs.action(jPlayer, new PotionDrinkInfo(String.valueOf(CMIMaterial.get(Material.POTION).isPotion()), ActionType.DRINK));
if (event.getItem().getType().equals(CMIMaterial.get(Material.POTION).isPotion()))
Jobs.action(jPlayer, new PotionDrinkInfo(org.bukkit.potion.PotionType.valueOf(CMIMaterial.get(Material.POTION).name()), ActionType.DRINK));
}
@EventHandler

View File

@ -2,9 +2,7 @@ package com.gamingmesh.jobs.nmsUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

View File

@ -2,9 +2,7 @@ package com.gamingmesh.jobs.nmsUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

View File

@ -2,9 +2,7 @@ package com.gamingmesh.jobs.nmsUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Guardian;

View File

@ -281,6 +281,9 @@ command:
craft:
info: '&eBarkácsol'
none: '%jobname% nem kap pénzt, ha barkácsol.'
drink:
info: '&eMegiszik'
none: '%jobname% nem kap pénzt, ha iszik.'
smelt:
info: '&eOlvaszt'
none: '%jobname% nem kap pénzt, ha olvaszt.'

View File

@ -16,6 +16,9 @@ permissions:
description: Grants access to all Jobs commands
children:
jobs.admin: true
jobs.autojoin.*: true
jobs.use: true
jobs.command.*: true
jobs.autojoin.*:
default: false
jobs.admin: