mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 22:13:25 +01:00
Now "jobs.petpay" can be denied to do not get income for killing mobs with mypet
Fixes #951
This commit is contained in:
parent
ee21d95a43
commit
5abfc0bb55
@ -24,10 +24,10 @@ public class TitleManager {
|
|||||||
Title title = null;
|
Title title = null;
|
||||||
for (Title t : titles) {
|
for (Title t : titles) {
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
if (t.getLevelReq() <= level && (t.getJobName() == null || t.getJobName().equalsIgnoreCase(jobName)))
|
if (t.getLevelReq() <= level && t.getJobName().equalsIgnoreCase(jobName))
|
||||||
title = t;
|
title = t;
|
||||||
} else {
|
} else {
|
||||||
if (t.getLevelReq() <= level && t.getLevelReq() > title.getLevelReq() && (t.getJobName() == null || t.getJobName().equalsIgnoreCase(jobName)))
|
if (t.getLevelReq() <= level && t.getLevelReq() > title.getLevelReq() && t.getJobName().equalsIgnoreCase(jobName))
|
||||||
title = t;
|
title = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,11 +45,12 @@ public class TitleManager {
|
|||||||
ConfigReader c = null;
|
ConfigReader c = null;
|
||||||
try {
|
try {
|
||||||
c = new ConfigReader("titleConfig.yml");
|
c = new ConfigReader("titleConfig.yml");
|
||||||
} catch (Throwable e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (c == null)
|
if (c == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
c.copyDefaults(true);
|
c.copyDefaults(true);
|
||||||
|
|
||||||
c.header(Arrays.asList(
|
c.header(Arrays.asList(
|
||||||
@ -126,21 +127,20 @@ public class TitleManager {
|
|||||||
c.save();
|
c.save();
|
||||||
} else
|
} else
|
||||||
for (String titleKey : titleSection.getKeys(false)) {
|
for (String titleKey : titleSection.getKeys(false)) {
|
||||||
String jobName = null;
|
String jobName = "",
|
||||||
String titleName = titleSection.getString(titleKey + ".Name");
|
titleName = titleSection.getString(titleKey + ".Name", ""),
|
||||||
String titleShortName = titleSection.getString(titleKey + ".ShortName");
|
titleShortName = titleSection.getString(titleKey + ".ShortName", "");
|
||||||
CMIChatColor titleColor = CMIChatColor.getColor(titleSection.getString(titleKey + ".ChatColour", ""));
|
CMIChatColor titleColor = CMIChatColor.getColor(titleSection.getString(titleKey + ".ChatColour", ""));
|
||||||
int levelReq = titleSection.getInt(titleKey + ".levelReq", -1);
|
int levelReq = titleSection.getInt(titleKey + ".levelReq", -1);
|
||||||
|
|
||||||
if (titleSection.isString(titleKey + ".JobName"))
|
if (titleSection.isString(titleKey + ".JobName"))
|
||||||
jobName = titleSection.getString(titleKey + ".JobName");
|
jobName = titleSection.getString(titleKey + ".JobName");
|
||||||
|
|
||||||
if (titleName == null) {
|
if (titleName.isEmpty()) {
|
||||||
Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid Name property. Skipping!");
|
Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid Name property. Skipping!");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (titleShortName.isEmpty()) {
|
||||||
if (titleShortName == null) {
|
|
||||||
Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid ShortName property. Skipping!");
|
Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid ShortName property. Skipping!");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -688,7 +688,7 @@ public class JobsPlayer {
|
|||||||
|
|
||||||
if (method == DisplayMethod.FULL || method == DisplayMethod.JOB) {
|
if (method == DisplayMethod.FULL || method == DisplayMethod.JOB) {
|
||||||
if (gotTitle) {
|
if (gotTitle) {
|
||||||
builder.append(" ");
|
builder.append(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
String honorificpart = prog.getJob().getNameWithColor() + CMIChatColor.WHITE;
|
String honorificpart = prog.getJob().getNameWithColor() + CMIChatColor.WHITE;
|
||||||
|
@ -28,11 +28,10 @@ import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Title {
|
public class Title {
|
||||||
private String name = null;
|
|
||||||
private String shortName = null;
|
private String name = "", shortName = "", jobName = "";
|
||||||
private CMIChatColor color = CMIChatColor.WHITE;
|
private CMIChatColor color = CMIChatColor.WHITE;
|
||||||
private int levelReq = 0;
|
private int levelReq = 0;
|
||||||
private String jobName = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -55,11 +54,11 @@ public class Title {
|
|||||||
* @param jobName Job this title is made for
|
* @param jobName Job this title is made for
|
||||||
*/
|
*/
|
||||||
public Title(String name, String shortName, CMIChatColor color, int levelReq, String jobName) {
|
public Title(String name, String shortName, CMIChatColor color, int levelReq, String jobName) {
|
||||||
this.name = name;
|
this.name = name == null ? "" : name;
|
||||||
this.color = color;
|
this.color = color == null ? CMIChatColor.BLACK : color;
|
||||||
this.levelReq = levelReq;
|
this.levelReq = levelReq;
|
||||||
this.shortName = shortName;
|
this.shortName = shortName == null ? "" : shortName;
|
||||||
this.jobName = jobName;
|
this.jobName = jobName == null ? "" : jobName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,13 +18,7 @@
|
|||||||
|
|
||||||
package com.gamingmesh.jobs.listeners;
|
package com.gamingmesh.jobs.listeners;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.CMILib.ActionBarManager;
|
import com.gamingmesh.jobs.CMILib.*;
|
||||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
|
||||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
|
||||||
import com.gamingmesh.jobs.CMILib.CMIEntityType;
|
|
||||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
|
||||||
import com.gamingmesh.jobs.CMILib.ItemManager;
|
|
||||||
import com.gamingmesh.jobs.CMILib.Version;
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.actions.*;
|
import com.gamingmesh.jobs.actions.*;
|
||||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||||
@ -61,8 +55,15 @@ import org.bukkit.event.block.Action;
|
|||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.enchantment.EnchantItemEvent;
|
import org.bukkit.event.enchantment.EnchantItemEvent;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.EntityTameEvent;
|
||||||
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
import org.bukkit.event.entity.SlimeSplitEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||||
import org.bukkit.event.inventory.BrewEvent;
|
import org.bukkit.event.inventory.BrewEvent;
|
||||||
@ -85,6 +86,7 @@ import org.bukkit.inventory.StonecutterInventory;
|
|||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -1193,6 +1195,15 @@ public class JobsPaymentListener implements Listener {
|
|||||||
if (pDamager == null)
|
if (pDamager == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Prevent payment for killing mobs with mypet by denying permission
|
||||||
|
if (HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager(), null)) {
|
||||||
|
for (PermissionAttachmentInfo perm : pDamager.getEffectivePermissions()) {
|
||||||
|
if (perm.getPermission().equals("jobs.petpay") && !perm.getValue()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check if in creative
|
// check if in creative
|
||||||
if (!payIfCreative(pDamager))
|
if (!payIfCreative(pDamager))
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user