mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
parent
cf55d7fbd7
commit
9c0787c03d
11
pom.xml
11
pom.xml
@ -52,7 +52,7 @@
|
||||
</dependency>
|
||||
<!-- Vault -->
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
@ -206,11 +206,6 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<!-- Vault -->
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
</repository>
|
||||
<!-- MythicMobs -->
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
@ -220,7 +215,7 @@
|
||||
<!-- WorldGuard & WorldEdit -->
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
@ -234,7 +229,7 @@
|
||||
<!-- PlaceholderAPI -->
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<!-- MyPet -->
|
||||
<!--<repository>
|
||||
|
@ -74,7 +74,7 @@ public enum CMIEnchantment {
|
||||
}
|
||||
} catch (Exception | Error e) {
|
||||
try {
|
||||
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
if (one.getKey().toString().split(":", 2)[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
enchantment = one;
|
||||
break;
|
||||
}
|
||||
@ -104,7 +104,7 @@ public enum CMIEnchantment {
|
||||
}
|
||||
} catch (Exception | Error e) {
|
||||
try {
|
||||
if (one.getKey().toString().split(":")[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
if (one.getKey().toString().split(":", 2)[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
enchantment = one;
|
||||
break en;
|
||||
}
|
||||
@ -160,7 +160,7 @@ public enum CMIEnchantment {
|
||||
if (map.isEmpty())
|
||||
fillUpMap();
|
||||
|
||||
name = name.contains(":") ? name.split(":")[0] : name.contains("-") ? name.split("-")[0] : name;
|
||||
name = name.contains(":") ? name.split(":", 2)[0] : name.contains("-") ? name.split("-", 2)[0] : name;
|
||||
name = name.toLowerCase().replace("_", "");
|
||||
return map.get(name);
|
||||
}
|
||||
@ -168,7 +168,7 @@ public enum CMIEnchantment {
|
||||
public static Enchantment getEnchantment(String name) {
|
||||
if (map.isEmpty())
|
||||
fillUpMap();
|
||||
name = name.contains(":") ? name.split(":")[0] : name.contains("-") ? name.split("-")[0] : name;
|
||||
name = name.contains(":") ? name.split(":", 2)[0] : name.contains("-") ? name.split("-", 2)[0] : name;
|
||||
name = name.toLowerCase().replace("_", "");
|
||||
|
||||
CMIEnchantment ec = map.get(name);
|
||||
|
@ -1366,9 +1366,10 @@ public enum CMIMaterial {
|
||||
id = id.replaceAll("_| |minecraft:", "").toLowerCase();
|
||||
|
||||
if (id.contains(":")) {
|
||||
String[] split = id.split(":", 2);
|
||||
try {
|
||||
Integer ids = Integer.parseInt(id.split(":")[0]);
|
||||
Integer data = Integer.parseInt(id.split(":")[1]);
|
||||
Integer ids = Integer.parseInt(split[0]);
|
||||
Integer data = Integer.parseInt(split[1]);
|
||||
if (ids <= 0)
|
||||
return CMIMaterial.NONE;
|
||||
return get(ids, data);
|
||||
@ -1376,8 +1377,8 @@ public enum CMIMaterial {
|
||||
}
|
||||
|
||||
try {
|
||||
Integer data = Integer.parseInt(id.split(":")[1]);
|
||||
id = id.split(":")[0];
|
||||
Integer data = Integer.parseInt(split[1]);
|
||||
id = split[0];
|
||||
CMIMaterial mat = ItemManager.byName.get(id + ":" + data);
|
||||
if (mat != null) {
|
||||
return mat;
|
||||
|
@ -726,7 +726,7 @@ public class Jobs extends JavaPlugin {
|
||||
|
||||
boolean kyoriSupported = false;
|
||||
try {
|
||||
Class.forName("net.kyori.adventure.text.Component");
|
||||
Class.forName("net.kyori.adventure.text.serializer.plain.PlainComponentSerializer");
|
||||
kyoriSupported = true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
@ -980,8 +980,8 @@ public class Jobs extends JavaPlugin {
|
||||
if (jobinfo == null)
|
||||
return;
|
||||
|
||||
Double income = jobinfo.getIncome(1, numjobs, jPlayer.maxJobsEquation);
|
||||
Double pointAmount = jobinfo.getPoints(1, numjobs, jPlayer.maxJobsEquation);
|
||||
double income = jobinfo.getIncome(1, numjobs, jPlayer.maxJobsEquation);
|
||||
double pointAmount = jobinfo.getPoints(1, numjobs, jPlayer.maxJobsEquation);
|
||||
|
||||
if (income == 0D && pointAmount == 0D)
|
||||
return;
|
||||
|
@ -230,12 +230,15 @@ public class PermissionHandler {
|
||||
public void registerPermissions() {
|
||||
PluginManager pm = plugin.getServer().getPluginManager();
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
if (pm.getPermission("jobs.world." + world.getName().toLowerCase()) == null)
|
||||
pm.addPermission(new Permission("jobs.world." + world.getName().toLowerCase(), PermissionDefault.TRUE));
|
||||
String worldName = world.getName().toLowerCase();
|
||||
if (pm.getPermission("jobs.world." + worldName) == null)
|
||||
pm.addPermission(new Permission("jobs.world." + worldName, PermissionDefault.TRUE));
|
||||
}
|
||||
|
||||
for (Job job : Jobs.getJobs()) {
|
||||
if (pm.getPermission("jobs.join." + job.getName().toLowerCase()) == null)
|
||||
pm.addPermission(new Permission("jobs.join." + job.getName().toLowerCase(), PermissionDefault.TRUE));
|
||||
String jobName = job.getName().toLowerCase();
|
||||
if (pm.getPermission("jobs.join." + jobName) == null)
|
||||
pm.addPermission(new Permission("jobs.join." + jobName, PermissionDefault.TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1146,7 +1146,7 @@ public class PlayerManager {
|
||||
}
|
||||
|
||||
public void autoJoinJobs(final Player player) {
|
||||
if (player == null || player.isOp() || !Jobs.getGCManager().AutoJobJoinUse)
|
||||
if (!Jobs.getGCManager().AutoJobJoinUse || player == null || player.isOp())
|
||||
return;
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@ -1160,14 +1160,15 @@ public class PlayerManager {
|
||||
return;
|
||||
|
||||
int confMaxJobs = Jobs.getGCManager().getMaxJobs();
|
||||
short playerMaxJobs = (short) jPlayer.getJobProgression().size();
|
||||
|
||||
if (confMaxJobs > 0 && playerMaxJobs >= confMaxJobs && !getJobsLimit(jPlayer, playerMaxJobs))
|
||||
return;
|
||||
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots())
|
||||
continue;
|
||||
|
||||
short playerMaxJobs = (short) jPlayer.getJobProgression().size();
|
||||
if (confMaxJobs > 0 && playerMaxJobs >= confMaxJobs && !getJobsLimit(jPlayer, playerMaxJobs))
|
||||
break;
|
||||
|
||||
if (!jPlayer.isInJob(one) && player.hasPermission("jobs.autojoin." + one.getName().toLowerCase()))
|
||||
joinJob(jPlayer, one);
|
||||
}
|
||||
|
@ -64,21 +64,22 @@ public class ExploreManager {
|
||||
return i;
|
||||
}
|
||||
|
||||
public ExploreRespond ChunkRespond(Player player, Chunk chunk) {
|
||||
return ChunkRespond(Jobs.getPlayerManager().getJobsPlayer(player).getUserId(), chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
public ExploreRespond chunkRespond(Player player, Chunk chunk) {
|
||||
return chunkRespond(Jobs.getPlayerManager().getJobsPlayer(player).getUserId(), chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
public ExploreRespond ChunkRespond(int playerId, Chunk chunk) {
|
||||
return ChunkRespond(playerId, chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
public ExploreRespond chunkRespond(int playerId, Chunk chunk) {
|
||||
return chunkRespond(playerId, chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
public ExploreRespond ChunkRespond(int playerId, String world, int x, int z) {
|
||||
public ExploreRespond chunkRespond(int playerId, String world, int x, int z) {
|
||||
ExploreRegion eRegions = worlds.get(world);
|
||||
if (eRegions == null) {
|
||||
int RegionX = (int) Math.floor(x / 32D);
|
||||
int RegionZ = (int) Math.floor(z / 32D);
|
||||
eRegions = new ExploreRegion(RegionX, RegionZ);
|
||||
}
|
||||
|
||||
ExploreChunk chunk = eRegions.getChunk(x, z);
|
||||
if (chunk == null)
|
||||
chunk = new ExploreChunk();
|
||||
|
@ -108,10 +108,6 @@ public class ShopManager {
|
||||
gui.setInvSize(guiSize);
|
||||
gui.setTitle(Jobs.getLanguage().getMessage("command.shop.info.title"));
|
||||
|
||||
// String title = Jobs.getLanguage().getMessage("command.shop.info.title");
|
||||
// if (title.length() > 32)
|
||||
// title = title.substring(0, 30) + "..";
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
|
||||
PlayerPoints pointsInfo = jPlayer.getPointsData();
|
||||
@ -119,8 +115,6 @@ public class ShopManager {
|
||||
if (pointsInfo != null)
|
||||
points = (int) (pointsInfo.getCurrentPoints() * 100.0) / 100.0;
|
||||
|
||||
// Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title);
|
||||
|
||||
for (int i = 0; i < ls.size(); i++) {
|
||||
ShopItem item = ls.get(i);
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
@ -167,7 +167,7 @@ public class Job {
|
||||
}
|
||||
|
||||
public boolean isSame(Job job) {
|
||||
return job != null && (fullName.equalsIgnoreCase(job.getName()) || id == job.getId());
|
||||
return job != null && (id == job.getId() || fullName.equalsIgnoreCase(job.getName()));
|
||||
}
|
||||
|
||||
public int getTotalPlayers() {
|
||||
@ -200,8 +200,10 @@ public class Job {
|
||||
double now = eq.getValue();
|
||||
if (now > Jobs.getGCManager().DynamicPaymentMaxBonus)
|
||||
now = Jobs.getGCManager().DynamicPaymentMaxBonus;
|
||||
if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty * -1)
|
||||
now = Jobs.getGCManager().DynamicPaymentMaxPenalty * -1;
|
||||
|
||||
double maxPenalty = Jobs.getGCManager().DynamicPaymentMaxPenalty * -1;
|
||||
if (now < maxPenalty)
|
||||
now = maxPenalty;
|
||||
|
||||
this.bonus = (now / 100D);
|
||||
}
|
||||
@ -258,8 +260,8 @@ public class Job {
|
||||
public JobInfo getJobInfo(ActionInfo action, int level) {
|
||||
BiPredicate<JobInfo, ActionInfo> condition = (jobInfo, actionInfo) -> {
|
||||
if (actionInfo instanceof PotionItemActionInfo) {
|
||||
return jobInfo.getName().equalsIgnoreCase(((PotionItemActionInfo) action).getNameWithSub()) ||
|
||||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(((PotionItemActionInfo) action).getNameWithSub());
|
||||
String subName = ((PotionItemActionInfo) action).getNameWithSub();
|
||||
return jobInfo.getName().equalsIgnoreCase(subName) || (jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(subName);
|
||||
}
|
||||
|
||||
return jobInfo.getName().equalsIgnoreCase(action.getNameWithSub()) ||
|
||||
|
@ -1183,21 +1183,21 @@ public class JobsPlayer {
|
||||
|
||||
for (String one : qprog.split(";:;")) {
|
||||
try {
|
||||
String jname = one.split(":")[0];
|
||||
String jname = one.split(":", 2)[0];
|
||||
Job job = Jobs.getJob(jname);
|
||||
if (job == null)
|
||||
continue;
|
||||
|
||||
one = one.substring(jname.length() + 1);
|
||||
|
||||
String qname = one.split(":")[0];
|
||||
String qname = one.split(":", 2)[0];
|
||||
Quest quest = job.getQuest(qname);
|
||||
if (quest == null)
|
||||
continue;
|
||||
|
||||
one = one.substring(qname.length() + 1);
|
||||
|
||||
String longS = one.split(":")[0];
|
||||
String longS = one.split(":", 2)[0];
|
||||
long validUntil = Long.parseLong(longS);
|
||||
one = one.substring(longS.length() + 1);
|
||||
|
||||
@ -1216,7 +1216,7 @@ public class JobsPlayer {
|
||||
}
|
||||
|
||||
for (String oneA : one.split(":;:")) {
|
||||
String prog = oneA.split(";")[0];
|
||||
String prog = oneA.split(";", 2)[0];
|
||||
ActionType action = ActionType.getByName(prog);
|
||||
if (action == null || oneA.length() < prog.length() + 1)
|
||||
continue;
|
||||
@ -1227,14 +1227,14 @@ public class JobsPlayer {
|
||||
|
||||
oneA = oneA.substring(prog.length() + 1);
|
||||
|
||||
String target = oneA.split(";")[0];
|
||||
String target = oneA.split(";", 2)[0];
|
||||
QuestObjective obj = old.get(target);
|
||||
if (obj == null)
|
||||
continue;
|
||||
|
||||
oneA = oneA.substring(target.length() + 1);
|
||||
|
||||
qp.setAmountDone(obj, Integer.parseInt(oneA.split(";")[0]));
|
||||
qp.setAmountDone(obj, Integer.parseInt(oneA.split(";", 2)[0]));
|
||||
}
|
||||
|
||||
if (qp.isCompleted())
|
||||
|
@ -533,19 +533,18 @@ public class JobsListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void playerInteractEvent(PlayerInteractEvent event) {
|
||||
Action action = event.getAction();
|
||||
if (action == Action.PHYSICAL)
|
||||
if (event.getAction() == Action.PHYSICAL)
|
||||
return;
|
||||
|
||||
if (action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK)
|
||||
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
ArmorTypes newArmorType = ArmorTypes.matchType(event.getItem());
|
||||
if (newArmorType == null)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerInventory inv = player.getInventory();
|
||||
PlayerInventory inv = event.getPlayer().getInventory();
|
||||
|
||||
if (newArmorType == ArmorTypes.HELMET &&
|
||||
inv.getHelmet() == null ||
|
||||
(newArmorType == ArmorTypes.CHESTPLATE || newArmorType == ArmorTypes.ELYTRA) &&
|
||||
@ -554,15 +553,14 @@ public class JobsListener implements Listener {
|
||||
inv.getLeggings() == null ||
|
||||
newArmorType == ArmorTypes.BOOTS &&
|
||||
inv.getBoots() == null) {
|
||||
JobsArmorChangeEvent armorEquipEvent = new JobsArmorChangeEvent(player, EquipMethod.HOTBAR, ArmorTypes.matchType(event.getItem()), null, event
|
||||
JobsArmorChangeEvent armorEquipEvent = new JobsArmorChangeEvent(event.getPlayer(), EquipMethod.HOTBAR, ArmorTypes.matchType(event.getItem()), null, event
|
||||
.getItem());
|
||||
plugin.getServer().getPluginManager().callEvent(armorEquipEvent);
|
||||
if (armorEquipEvent.isCancelled()) {
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
event.getPlayer().updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -379,14 +379,14 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (!payIfCreative(player))
|
||||
return;
|
||||
|
||||
// check if player is riding
|
||||
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (!payIfCreative(player))
|
||||
return;
|
||||
|
||||
// Remove block owner ships
|
||||
plugin.getBlockOwnerShips().forEach(os -> os.remove(block));
|
||||
|
||||
@ -408,14 +408,12 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!payForItemDurabilityLoss(player))
|
||||
return;
|
||||
|
||||
// Protection for block break with silktouch
|
||||
ItemStack item = Jobs.getNms().getItemInMainHand(player);
|
||||
if (item.getType() != Material.AIR) {
|
||||
// Protection for block break with silktouch
|
||||
if (Jobs.getGCManager().useSilkTouchProtection) {
|
||||
for (Enchantment one : item.getEnchantments().keySet()) {
|
||||
if (CMIEnchantment.get(one) == CMIEnchantment.SILK_TOUCH && Jobs.getBpManager().isInBp(block)) {
|
||||
return;
|
||||
}
|
||||
if (Jobs.getGCManager().useSilkTouchProtection && item.getType() != Material.AIR) {
|
||||
for (Enchantment one : item.getEnchantments().keySet()) {
|
||||
if (CMIEnchantment.get(one) == CMIEnchantment.SILK_TOUCH && Jobs.getBpManager().isInBp(block)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -434,12 +432,16 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
// check to make sure you can build
|
||||
if (!event.canBuild())
|
||||
return;
|
||||
|
||||
// A tool should not trigger a BlockPlaceEvent (fixes stripping logs bug #940)
|
||||
if (CMIMaterial.get(event.getItemInHand().getType()).isTool())
|
||||
return;
|
||||
|
||||
// check to make sure you can build
|
||||
if (!event.canBuild())
|
||||
Player player = event.getPlayer();
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
Block block = event.getBlock();
|
||||
@ -447,14 +449,14 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld()))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_12_R1)
|
||||
&& ItemManager.getItem(event.getItemInHand()).isSimilar(CMIMaterial.BONE_MEAL.newCMIItemStack()))
|
||||
return;
|
||||
|
||||
// check if player is riding
|
||||
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (!payIfCreative(player))
|
||||
return;
|
||||
@ -462,10 +464,6 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// check if player is riding
|
||||
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
||||
return;
|
||||
|
||||
Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new BlockActionInfo(block, ActionType.PLACE), block);
|
||||
}
|
||||
|
||||
@ -566,9 +564,6 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryCraft(CraftItemEvent event) {
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
|
||||
return;
|
||||
|
||||
// If event is nothing or place, do nothing
|
||||
switch (event.getAction()) {
|
||||
case NOTHING:
|
||||
@ -583,6 +578,12 @@ public class JobsPaymentListener implements Listener {
|
||||
if (event.getSlotType() != SlotType.RESULT)
|
||||
return;
|
||||
|
||||
if (!event.isLeftClick() && !event.isRightClick())
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
|
||||
return;
|
||||
|
||||
ItemStack resultStack = event.getRecipe().getResult();
|
||||
|
||||
if (!(event.getWhoClicked() instanceof Player))
|
||||
@ -603,9 +604,6 @@ public class JobsPaymentListener implements Listener {
|
||||
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
||||
return;
|
||||
|
||||
if (!event.isLeftClick() && !event.isRightClick())
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (!payIfCreative(player))
|
||||
return;
|
||||
@ -1083,7 +1081,7 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByPlayer(EntityDamageEvent event) {
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()) || !Jobs.getGCManager().MonsterDamageUse)
|
||||
if (!Jobs.getGCManager().MonsterDamageUse || !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
Entity ent = event.getEntity();
|
||||
@ -1098,14 +1096,12 @@ public class JobsPaymentListener implements Listener {
|
||||
if (damage > s)
|
||||
damage = s;
|
||||
|
||||
if (Jobs.getGCManager().MonsterDamageUse) {
|
||||
UUID entUUID = ent.getUniqueId();
|
||||
Double damageDealt = damageDealtByPlayers.getIfPresent(entUUID);
|
||||
if (damageDealt != null) {
|
||||
damageDealtByPlayers.put(entUUID, damageDealt + damage);
|
||||
} else {
|
||||
damageDealtByPlayers.put(entUUID, 0.0);
|
||||
}
|
||||
UUID entUUID = ent.getUniqueId();
|
||||
Double damageDealt = damageDealtByPlayers.getIfPresent(entUUID);
|
||||
if (damageDealt != null) {
|
||||
damageDealtByPlayers.put(entUUID, damageDealt + damage);
|
||||
} else {
|
||||
damageDealtByPlayers.put(entUUID, damage);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1116,13 +1112,12 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
Entity ent = event.getEntity();
|
||||
UUID entUUID = ent.getUniqueId();
|
||||
Entity damager = event.getDamager();
|
||||
if (ent instanceof org.bukkit.entity.EnderCrystal && damager instanceof Player) {
|
||||
if (ent instanceof org.bukkit.entity.EnderCrystal && event.getDamager() instanceof Player) {
|
||||
punchedEndCrystals.put(entUUID, ent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(damager instanceof Projectile) || !(ent instanceof Damageable))
|
||||
if (!Jobs.getGCManager().MonsterDamageUse || !(event.getDamager() instanceof Projectile) || !(ent instanceof Damageable))
|
||||
return;
|
||||
|
||||
double damage = event.getFinalDamage();
|
||||
@ -1131,12 +1126,12 @@ public class JobsPaymentListener implements Listener {
|
||||
if (damage > s)
|
||||
damage = s;
|
||||
|
||||
if (Jobs.getGCManager().MonsterDamageUse && ((Projectile) damager).getShooter() instanceof Player) {
|
||||
if (((Projectile) event.getDamager()).getShooter() instanceof Player) {
|
||||
Double damageDealt = damageDealtByPlayers.getIfPresent(entUUID);
|
||||
if (damageDealt != null) {
|
||||
damageDealtByPlayers.put(entUUID, damageDealt + damage);
|
||||
} else {
|
||||
damageDealtByPlayers.put(entUUID, 0.0);
|
||||
damageDealtByPlayers.put(entUUID, damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1278,12 +1273,9 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if (event.getSpawnReason() == SpawnReason.SPAWNER || event.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
|
||||
LivingEntity creature = event.getEntity();
|
||||
creature.setMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), new FixedMetadataValue(plugin, true));
|
||||
if ((event.getSpawnReason() == SpawnReason.SPAWNER || event.getSpawnReason() == SpawnReason.SPAWNER_EGG)
|
||||
&& Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) {
|
||||
event.getEntity().setMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1437,11 +1429,10 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCreatureBreed(CreatureSpawnEvent event) {
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()) || !Jobs.getGCManager().useBreederFinder)
|
||||
if (!Jobs.getGCManager().useBreederFinder || !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
SpawnReason reason = event.getSpawnReason();
|
||||
if (!reason.toString().equalsIgnoreCase("BREEDING") && !reason.toString().equalsIgnoreCase("EGG"))
|
||||
if (!event.getSpawnReason().toString().equalsIgnoreCase("BREEDING") && !event.getSpawnReason().toString().equalsIgnoreCase("EGG"))
|
||||
return;
|
||||
|
||||
LivingEntity animal = event.getEntity();
|
||||
@ -1478,15 +1469,12 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerEat(FoodLevelChangeEvent event) {
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof Player) || event.getEntity().hasMetadata("NPC")
|
||||
|| event.getFoodLevel() <= ((Player) event.getEntity()).getFoodLevel())
|
||||
if (!(event.getEntity() instanceof Player) || !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())
|
||||
|| event.getEntity().hasMetadata("NPC"))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
if (!player.isOnline())
|
||||
if (!player.isOnline() || event.getFoodLevel() <= player.getFoodLevel())
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
@ -1703,11 +1691,11 @@ public class JobsPaymentListener implements Listener {
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
ExploreRespond respond = Jobs.getExplore().ChunkRespond(jPlayer.getUserId(), event.getNewChunk());
|
||||
ExploreRespond respond = Jobs.getExplore().chunkRespond(jPlayer.getUserId(), event.getNewChunk());
|
||||
if (!respond.isNewChunk())
|
||||
return;
|
||||
|
||||
Jobs.action(jPlayer, new ExploreActionInfo(String.valueOf(respond.getCount()), ActionType.EXPLORE));
|
||||
Jobs.action(jPlayer, new ExploreActionInfo(Integer.toString(respond.getCount()), ActionType.EXPLORE));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -1743,7 +1731,8 @@ public class JobsPaymentListener implements Listener {
|
||||
return true;
|
||||
|
||||
for (Entry<Enchantment, Integer> oneG : got.entrySet()) {
|
||||
if (!hand.getEnchantments().containsKey(oneG.getKey()) || hand.getEnchantments().get(oneG.getKey()).equals(oneG.getValue()))
|
||||
Map<Enchantment, Integer> map = hand.getEnchantments();
|
||||
if (!map.containsKey(oneG.getKey()) || map.get(oneG.getKey()).equals(oneG.getValue()))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ public class PistonProtectionListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockMove(BlockPistonExtendEvent event) {
|
||||
if (event.isCancelled() || !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())
|
||||
|| !Jobs.getGCManager().useBlockProtection)
|
||||
if (!Jobs.getGCManager().useBlockProtection || event.isCancelled()
|
||||
|| !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
BlockFace dir = event.getDirection();
|
||||
@ -39,8 +39,8 @@ public class PistonProtectionListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockRetractMove(BlockPistonRetractEvent event) {
|
||||
if (event.isCancelled() || !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())
|
||||
|| !Jobs.getGCManager().useBlockProtection)
|
||||
if (!Jobs.getGCManager().useBlockProtection || event.isCancelled()
|
||||
|| !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
BlockFace dir = event.getDirection();
|
||||
|
@ -27,8 +27,9 @@ public class ToggleBarHandling {
|
||||
|
||||
if (section != null) {
|
||||
for (String one : section.getKeys(false)) {
|
||||
if (!section.getBoolean(one)) {
|
||||
bossBarToggle.put(one, section.getBoolean(one));
|
||||
boolean boo = section.getBoolean(one);
|
||||
if (!boo) {
|
||||
bossBarToggle.put(one, boo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -39,8 +40,9 @@ public class ToggleBarHandling {
|
||||
|
||||
if (section != null) {
|
||||
for (String one : section.getKeys(false)) {
|
||||
if (!section.getBoolean(one)) {
|
||||
actionBarToggle.put(one, section.getBoolean(one));
|
||||
boolean boo = section.getBoolean(one);
|
||||
if (!boo) {
|
||||
actionBarToggle.put(one, boo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
|
||||
public final class KyoriChatEvent extends Complement2 implements Listener {
|
||||
|
||||
@ -48,11 +49,10 @@ public final class KyoriChatEvent extends Complement2 implements Listener {
|
||||
// chat plugins, like Essentials
|
||||
// Now there is a parameter "player", so literally we need to add 800+ chat plugins
|
||||
// to this plugin as dependency?
|
||||
event.composer((player, displayName, msg) -> {
|
||||
String newMessage = serialize(msg);
|
||||
newMessage = newMessage.replace("{jobs}", h);
|
||||
return deserialize(newMessage);
|
||||
});
|
||||
// 3rd attempt: now we tried to use text replacement config builder to match the variable
|
||||
// result: instead of replacing the variable, now the chat message never been sent
|
||||
event.composer((player, displayName, msg) -> msg
|
||||
.replaceText(TextReplacementConfig.builder().match("{jobs}").once().replacement(h).build()));
|
||||
}
|
||||
|
||||
// Changing chat prefix variable to job name
|
||||
@ -73,10 +73,7 @@ public final class KyoriChatEvent extends Complement2 implements Listener {
|
||||
honorific = "";
|
||||
|
||||
final String h = honorific;
|
||||
event.composer((player, displayName, msg) -> {
|
||||
String newMessage = serialize(msg);
|
||||
newMessage = newMessage.replace("{jobs}", h);
|
||||
return deserialize(newMessage);
|
||||
});
|
||||
event.composer((player, displayName, msg) -> msg
|
||||
.replaceText(TextReplacementConfig.builder().match("{jobs}").once().replacement(h).build()));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user