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,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)
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");

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: