1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-02-08 16:31:37 +01:00

Petpay permission should now affect wolfs as tameable entity

This commit is contained in:
montlikadani 2020-11-21 12:11:34 +01:00
parent 1d58e4bd66
commit e4f2b40527
19 changed files with 64 additions and 81 deletions

View File

@ -1272,11 +1272,12 @@ public enum CMIMaterial {
}
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
ItemStack stack = new ItemStack(mat == null ? Material.STONE : mat);
ItemStack stack = new ItemStack(mat);
stack.setAmount(amount);
return stack;
}
ItemStack stack = new ItemStack(mat == null ? Material.STONE : mat, 1, (short) this.getLegacyData());
ItemStack stack = new ItemStack(mat, 1, (short) this.getLegacyData());
stack.setAmount(amount);
return stack;
}
@ -1293,12 +1294,12 @@ public enum CMIMaterial {
return new CMIItemStack(CMIMaterial.STONE);
}
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
CMIItemStack stack = new CMIItemStack(mat == null ? Material.STONE : mat);
CMIItemStack stack = new CMIItemStack(mat);
stack.setAmount(amount);
return stack;
}
ItemStack stack = new ItemStack(mat == null ? Material.STONE : mat, 1, (short) this.getLegacyData());
ItemStack stack = new ItemStack(mat, 1, (short) this.getLegacyData());
stack.setAmount(amount);
return new CMIItemStack(stack);
}

View File

@ -1291,11 +1291,10 @@ public class Jobs extends JavaPlugin {
if (limited)
return;
economy.pay(jPlayer, payment.getPayment());
JobProgression prog = jPlayer.getJobProgression(job);
int oldLevel = prog.getLevel();
if (gConfigManager.LoggingUse) {

View File

@ -370,15 +370,14 @@ public class Placeholder {
}
private static Job getJobFromValue(String value) {
Job j = null;
try {
int id = Integer.parseInt(value);
if (id > 0)
j = Jobs.getJobs().get(id - 1);
return Jobs.getJobs().get(id - 1);
} catch (Exception e) {
j = Jobs.getJob(value);
return Jobs.getJob(value);
}
return j;
return null;
}
private static String simplifyDouble(double value) {

View File

@ -64,8 +64,7 @@ public class jobsSign {
world = Bukkit.getWorld(worldName);
if (world == null)
return null;
loc = new Location(world, x, y, z);
return loc;
return loc = new Location(world, x, y, z);
}
public void setNumber(int number) {
@ -128,7 +127,7 @@ public class jobsSign {
if (world == null)
return;
this.setLoc(new Location(world, x, y, z));
setLoc(new Location(world, x, y, z));
}
public SignTopType getType() {
@ -140,9 +139,9 @@ public class jobsSign {
}
public String getIdentifier() {
if (this.getType() != SignTopType.toplist)
return this.getType().toString();
return this.jobName != null ? this.jobName + ":" + this.getType().toString() : this.getType().toString();
if (getType() != SignTopType.toplist)
return getType().toString();
return jobName != null ? jobName + ":" + getType().toString() : getType().toString();
}
public static String getIdentifier(Job job, SignTopType type) {

View File

@ -35,7 +35,7 @@ public class JobsCommands implements CommandExecutor {
private static final String packagePath = "com.gamingmesh.jobs.commands.list";
private final Map<String, Integer> CommandList = new HashMap<>();
private final Map<String, Integer> commandList = new HashMap<>();
protected Jobs plugin;
@ -44,7 +44,7 @@ public class JobsCommands implements CommandExecutor {
}
public Map<String, Integer> getCommands() {
return CommandList;
return commandList;
}
@Override
@ -160,7 +160,7 @@ public class JobsCommands implements CommandExecutor {
public Map<String, Integer> GetCommands(CommandSender sender) {
Map<String, Integer> temp = new HashMap<>();
for (Entry<String, Integer> cmd : CommandList.entrySet()) {
for (Entry<String, Integer> cmd : commandList.entrySet()) {
if (sender instanceof Player && !hasCommandPermission(sender, cmd.getKey()))
continue;
@ -189,7 +189,7 @@ public class JobsCommands implements CommandExecutor {
if (!met.isAnnotationPresent(JobCommand.class))
continue;
CommandList.put(oneClass.getKey(), met.getAnnotation(JobCommand.class).value());
commandList.put(oneClass.getKey(), met.getAnnotation(JobCommand.class).value());
break;
}
}
@ -312,7 +312,7 @@ public class JobsCommands implements CommandExecutor {
sender.sendMessage(one);
}
String t = type == "" ? "" : " " + type;
String t = type.isEmpty() ? "" : " " + type;
if (sender instanceof Player)
if (sender.getName().equalsIgnoreCase(player.getName()))
@ -337,12 +337,10 @@ public class JobsCommands implements CommandExecutor {
message.append(Jobs.getLanguage().getMessage("command.info.output." + type.getName().toLowerCase() + ".info"));
message.append(":\n");
int level = 1;
JobProgression prog = player.getJobProgression(job);
if (prog != null)
level = prog.getLevel();
int level = prog != null ? prog.getLevel() : 1;
int numjobs = player.getJobProgression().size();
List<JobInfo> jobInfo = job.getJobInfo(type);
for (JobInfo info : jobInfo) {

View File

@ -60,11 +60,11 @@ public class area implements Cmd {
return true;
}
if (wg && HookManager.getWorldGuardManager() != null) {
name = HookManager.getWorldGuardManager().getProtectedRegionByName(name).getId();
if (name == null) {
if (HookManager.getWorldGuardManager().getProtectedRegionByName(name) == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgDontExist"));
return true;
}
name = HookManager.getWorldGuardManager().getProtectedRegionByName(name).getId();
}
if (!wg)

View File

@ -43,7 +43,7 @@ public class leave implements Cmd {
Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
(long) (20 * Jobs.getGCManager().ConfirmExpiryTime));
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]",
job.getNameWithColor(), "[time]", Jobs.getGCManager().ConfirmExpiryTime));

View File

@ -38,7 +38,7 @@ public class leaveall implements Cmd {
Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
(long) (20 * Jobs.getGCManager().ConfirmExpiryTime));
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]",
Jobs.getGCManager().ConfirmExpiryTime));

View File

@ -52,10 +52,10 @@ public class limit implements Cmd {
if (!Jobs.getGCManager().getLimit(type).isEnabled())
continue;
PaymentData limit = JPlayer.getPaymentLimit();
if (limit.getLeftTime(type) <= 0)
limit.resetLimits(type);
if (limit.getLeftTime(type) <= 0)
limit.resetLimits(type);
if (limit.getLeftTime(type) > 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort(limit.getLeftTime(type))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "Limit",

View File

@ -15,8 +15,8 @@ import com.gamingmesh.jobs.container.DBAction;
public class BlockProtectionManager {
private HashMap<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> map = new HashMap<>();
private ConcurrentHashMap<World, ConcurrentHashMap<String, BlockProtection>> tempCache = new ConcurrentHashMap<>();
private final HashMap<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> map = new HashMap<>();
private final ConcurrentHashMap<World, ConcurrentHashMap<String, BlockProtection>> tempCache = new ConcurrentHashMap<>();
public HashMap<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> getMap() {
return map;

View File

@ -25,11 +25,9 @@ public class BossBarManager {
}
public synchronized void ShowJobProgression(final JobsPlayer player) {
if (Version.getCurrent().isLower(Version.v1_9_R1))
if (Version.getCurrent().isLower(Version.v1_9_R1) || player == null)
return;
if (player == null)
return;
for (JobProgression oneJob : player.getJobProgression()) {
if (oneJob.getLastExperience() != 0) {
ShowJobProgression(player, oneJob, oneJob.getLastExperience());
@ -39,28 +37,24 @@ public class BossBarManager {
}
public synchronized void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain) {
if (Version.getCurrent().isLower(Version.v1_9_R1))
if (Version.getCurrent().isLower(Version.v1_9_R1) || !Jobs.getGCManager().BossBarsMessageByDefault)
return;
String playerUUID = player.getPlayer().getUniqueId().toString();
if (!Jobs.getGCManager().BossBarsMessageByDefault)
return;
Boolean show = ToggleBarHandling.getBossBarToggle().getOrDefault(playerUUID, true);
Boolean show = ToggleBarHandling.getBossBarToggle().getOrDefault(player.getPlayer().getUniqueId().toString(), true);
if (!show)
return;
BossBar bar = null;
BossBarInfo OldOne = null;
BossBarInfo oldOne = null;
for (BossBarInfo one : player.getBossBarInfo()) {
if (!one.getJobName().equalsIgnoreCase(jobProg.getJob().getName()))
continue;
one.cancel();
bar = one.getBar();
OldOne = one;
break;
if (one.getJobName().equalsIgnoreCase(jobProg.getJob().getName())) {
one.cancel();
bar = one.getBar();
oldOne = one;
break;
}
}
NumberFormat formatter = new DecimalFormat("#0.00");
String gain = "";
@ -130,15 +124,15 @@ public class BossBarManager {
percentage = percentage > 1D ? 1D : percentage < 0 ? 0 : percentage;
bar.setProgress(percentage);
if (OldOne == null) {
if (oldOne == null) {
bar.addPlayer(player.getPlayer());
OldOne = new BossBarInfo(player.getName(), jobProg.getJob().getName(), bar);
player.getBossBarInfo().add(OldOne);
oldOne = new BossBarInfo(player.getName(), jobProg.getJob().getName(), bar);
player.getBossBarInfo().add(oldOne);
}
bar.setVisible(true);
OldOne.setId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
oldOne.setId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
for (BossBarInfo one : player.getBossBarInfo()) {

View File

@ -731,7 +731,7 @@ public class ConfigManager {
Long rejoinCd = jobSection.getLong("rejoinCooldown", 0L);
if (rejoinCd < 0L)
rejoinCd = 0L;
rejoinCd = rejoinCd * 1000L;
rejoinCd *= 1000L;
String jobShortName = jobSection.getString("shortname", null);
if (jobShortName == null) {

View File

@ -3,7 +3,6 @@ package com.gamingmesh.jobs.config;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map.Entry;
import org.bukkit.Chunk;
import org.bukkit.entity.Player;
@ -55,8 +54,8 @@ public class ExploreManager {
public int getSize() {
int i = 0;
for (Entry<String, ExploreRegion> one : this.getWorlds().entrySet()) {
i += one.getValue().getChunks().size();
for (ExploreRegion one : worlds.values()) {
i += one.getChunks().size();
}
return i;
}

View File

@ -92,13 +92,13 @@ public class GeneralConfigManager {
PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps,
BrowseUseNewLook, payExploringWhenGliding, disablePaymentIfMaxLevelReached, disablePaymentIfRiding,
boostedItemsInOffHand, preventCropResizePayment, payItemDurabilityLoss,
applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useBreederFinder = false,
applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useBreederFinder,
CancelCowMilking, fixAtMaxLevel, TitleChangeChat, TitleChangeActionBar, LevelChangeChat,
LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAccountChat,
EmptyServerAccountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, ShowActionNames,
DisableJoiningJobThroughGui, FireworkLevelupUse, UseRandom, UseFlicker, UseTrail, UsePerPermissionForLeaving,
EnableConfirmation, FilterHiddenPlayerFromTabComplete, jobsInfoOpensBrowse, MonsterDamageUse = false, useMaxPaymentCurve,
EnableConfirmation, FilterHiddenPlayerFromTabComplete, jobsInfoOpensBrowse, MonsterDamageUse, useMaxPaymentCurve,
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel,
BossBarEnabled, BossBarShowOnEachAction, BossBarsMessageByDefault, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,

View File

@ -367,7 +367,7 @@ public class NameTranslatorManager {
}
if (name == null) {
n = n + "-" + one.toString();
n += "-" + one.toString();
if (c.getC().isConfigurationSection("EntityList." + n)) {
name = c.getC().getString("EntityList." + n);
}
@ -381,7 +381,7 @@ public class NameTranslatorManager {
}
for (Enchantment one : Enchantment.values()) {
if (one == null || CMIEnchantment.getName(one) == null)
if (CMIEnchantment.getName(one) == null)
continue;
String name = Util.firstToUpperCase(CMIEnchantment.getName(one)).replace('_', ' ');

View File

@ -124,8 +124,7 @@ public class ScheduleManager {
}
public static String getWeekDay() {
Calendar c = Calendar.getInstance();
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
int dayOfWeek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
switch (dayOfWeek) {
case 2:
return "monday";

View File

@ -76,18 +76,11 @@ public class ShopManager {
}
private static int getPrevButtonSlot(int GuiSize, int page) {
int prev = -1;
if (page > 1)
prev = GuiSize - 9;
return prev;
return page > 1 ? GuiSize - 9 : -1;
}
private int getnextButtonSlot(int GuiSize, int page) {
int next = -1;
List<ShopItem> lsnext = getItemsByPage(page + 1);
if (!lsnext.isEmpty())
next = GuiSize - 1;
return next;
private int getNextButtonSlot(int GuiSize, int page) {
return !getItemsByPage(page + 1).isEmpty() ? GuiSize - 1 : -1;
}
public boolean openShopGui(Player player, Integer page) {
@ -284,7 +277,7 @@ public class ShopManager {
});
}
int nextSlot = getnextButtonSlot(GuiSize.getFields(), page);
int nextSlot = getNextButtonSlot(GuiSize.getFields(), page);
if (nextSlot != -1 && !getItemsByPage(page + 1).isEmpty()) {
meta.setDisplayName(Jobs.getLanguage().getMessage("command.help.output.nextPage"));
Item.setItemMeta(meta);

View File

@ -42,7 +42,7 @@ public class YmlMaker {
if (f != null)
try {
f.close();
} catch (Throwable e) {
} catch (IOException e) {
e.printStackTrace();
}
}

View File

@ -1201,10 +1201,12 @@ public class JobsPaymentListener implements Listener {
if (pDamager == null)
return;
// Prevent payment for killing mobs with mypet by denying permission
if (HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager(), null)) {
// Prevent payment for killing mobs with pet by denying permission
if ((HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager(), null))
|| (e.getDamager() instanceof Tameable && ((Tameable) e.getDamager()).isTamed() &&
((Tameable) e.getDamager()).getOwner() instanceof Player)) {
for (PermissionAttachmentInfo perm : pDamager.getEffectivePermissions()) {
if (perm.getPermission().equals("jobs.petpay") && !perm.getValue()) {
if ("jobs.petpay".equals(perm.getPermission()) && !perm.getValue()) {
return;
}
}