1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-31 21:37:57 +01:00

Merge branch 'master' into bucket-entity-action

This commit is contained in:
FireML 2023-08-30 03:48:50 +01:00 committed by GitHub
commit 8a9a512130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 186 additions and 54 deletions

Binary file not shown.

Binary file not shown.

32
pom.xml
View File

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>Jobs</groupId> <groupId>Jobs</groupId>
<artifactId>jobs</artifactId> <artifactId>jobs</artifactId>
@ -10,6 +8,8 @@
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
@ -17,9 +17,9 @@
<dependency> <dependency>
<groupId>io.papermc.paper</groupId> <groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version> <version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.ow2.asm</groupId> <groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId> <artifactId>asm-commons</artifactId>
@ -80,12 +80,12 @@
<version>4.11.0</version> <version>4.11.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.lumine</groupId> <groupId>io.lumine</groupId>
<artifactId>Mythic-Dist</artifactId> <artifactId>Mythic-Dist</artifactId>
<version>5.1.0-SNAPSHOT</version> <version>5.1.0-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- WorldGuard old version --> <!-- WorldGuard old version -->
<dependency> <dependency>
<groupId>com.sk89q</groupId> <groupId>com.sk89q</groupId>
@ -200,12 +200,13 @@
<systemPath>${basedir}/libs/CMILib1.4.0.0.jar</systemPath> <systemPath>${basedir}/libs/CMILib1.4.0.0.jar</systemPath>
</dependency> </dependency>
<!-- WildStacker --> <!-- WildStacker -->
<dependency> <dependency>
<groupId>com.bgsoftware</groupId> <groupId>com.bgsoftware</groupId>
<artifactId>WildStackerAPI</artifactId> <artifactId>WildStackerAPI</artifactId>
<version>latest</version> <version>latest</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${basedir}/libs/WildStackerAPI-latest.jar</systemPath> <systemPath>${basedir}/libs/WildStackerAPI-2023.2.jar</systemPath>
</dependency> </dependency>
<!-- StackMob --> <!-- StackMob -->
<dependency> <dependency>
@ -275,20 +276,19 @@
<!-- Make a Jar --> <!-- Make a Jar -->
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version> <version>2.3.1</version>
<configuration> <configuration>
<outputDirectory>D:\MC\Server 1.20\plugins\</outputDirectory> <outputDirectory>D:\MC\Server 1.20\plugins\</outputDirectory>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -98,6 +98,7 @@ import com.gamingmesh.jobs.listeners.JobsPayment14Listener;
import com.gamingmesh.jobs.listeners.JobsPaymentListener; import com.gamingmesh.jobs.listeners.JobsPaymentListener;
import com.gamingmesh.jobs.listeners.PistonProtectionListener; import com.gamingmesh.jobs.listeners.PistonProtectionListener;
import com.gamingmesh.jobs.listeners.JobsPayment16Listener; import com.gamingmesh.jobs.listeners.JobsPayment16Listener;
import com.gamingmesh.jobs.listeners.PlayerSignEdit1_20Listeners;
import com.gamingmesh.jobs.selection.SelectionManager; import com.gamingmesh.jobs.selection.SelectionManager;
import com.gamingmesh.jobs.stuff.Loging; import com.gamingmesh.jobs.stuff.Loging;
import com.gamingmesh.jobs.stuff.TabComplete; import com.gamingmesh.jobs.stuff.TabComplete;
@ -155,7 +156,7 @@ public final class Jobs extends JavaPlugin {
private GuiManager guiManager; private GuiManager guiManager;
private static JobsDAO dao; private static JobsDAO dao;
private static List<Job> jobs; private static List<Job> jobs = new ArrayList<Job>();
private static Job noneJob; private static Job noneJob;
private static Map<Job, Integer> usedSlots = new WeakHashMap<>(); private static Map<Job, Integer> usedSlots = new WeakHashMap<>();
@ -799,6 +800,9 @@ public final class Jobs extends JavaPlugin {
pm.registerEvents(new JobsPayment16Listener(), getInstance()); pm.registerEvents(new JobsPayment16Listener(), getInstance());
} }
if (Version.isCurrentEqualOrHigher(Version.v1_20_R1)) {
pm.registerEvents(new PlayerSignEdit1_20Listeners(), getInstance());
}
if (getGCManager().useBlockProtection) { if (getGCManager().useBlockProtection) {
pm.registerEvents(new PistonProtectionListener(), getInstance()); pm.registerEvents(new PistonProtectionListener(), getInstance());
} }

View File

@ -582,7 +582,8 @@ public class Placeholder {
return convert(true); return convert(true);
case maxjobs: case maxjobs:
return Integer.toString(Jobs.getPlayerManager().getMaxJobs(user)); int max = Jobs.getPlayerManager().getMaxJobs(user);
return Integer.toString(max == -1 ? 99 : max);
default: default:
break; break;

View File

@ -63,9 +63,9 @@ import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.stuff.Util; import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Container.CMINumber;
import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.NBT.CMINBT; import net.Zrips.CMILib.NBT.CMINBT;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
@ -488,10 +488,10 @@ public class PlayerManager {
Jobs.getSignUtil().updateAllSign(job); Jobs.getSignUtil().updateAllSign(job);
job.updateTotalPlayers(); job.updateTotalPlayers();
jPlayer.maxJobsEquation = getMaxJobs(jPlayer); jPlayer.maxJobsEquation = CMINumber.clamp(getMaxJobs(jPlayer), 0, 9999);
// Removing from cached item boost for recalculation // Removing from cached item boost for recalculation
cache.remove(jPlayer.getUniqueId()); cache.remove(jPlayer.getUniqueId());
} }
private static void performCommandsOnLeave(JobsPlayer jPlayer, Job job) { private static void performCommandsOnLeave(JobsPlayer jPlayer, Job job) {
@ -533,10 +533,10 @@ public class PlayerManager {
Jobs.getSignUtil().updateAllSign(job); Jobs.getSignUtil().updateAllSign(job);
job.updateTotalPlayers(); job.updateTotalPlayers();
// Removing from cached item boost for recalculation // Removing from cached item boost for recalculation
cache.remove(jPlayer.getUniqueId()); cache.remove(jPlayer.getUniqueId());
return true; return true;
} }
@ -931,7 +931,8 @@ public class PlayerManager {
* @return true if the player is under the given jobs size * @return true if the player is under the given jobs size
*/ */
public boolean getJobsLimit(JobsPlayer jPlayer, short currentCount) { public boolean getJobsLimit(JobsPlayer jPlayer, short currentCount) {
return getMaxJobs(jPlayer) > currentCount; int max = getMaxJobs(jPlayer);
return max == -1 ? true : max > currentCount;
} }
/** /**
@ -1064,7 +1065,7 @@ public class PlayerManager {
continue; continue;
} }
} }
jitems.add(getJobsItemByNbt(item)); jitems.add(getJobsItemByNbt(item));
} }
} }
@ -1214,11 +1215,11 @@ public class PlayerManager {
int playerMaxJobs = getMaxJobs(jPlayer); int playerMaxJobs = getMaxJobs(jPlayer);
int playerCurrentJobs = jPlayer.progression.size(); int playerCurrentJobs = jPlayer.progression.size();
if (playerMaxJobs <= 0 || playerCurrentJobs >= playerMaxJobs) if (playerMaxJobs == 0 || playerMaxJobs != -1 && playerCurrentJobs >= playerMaxJobs)
return; return;
for (Job one : Jobs.getJobs()) { for (Job one : Jobs.getJobs()) {
if (jPlayer.progression.size() >= playerMaxJobs) if (playerMaxJobs != -1 && jPlayer.progression.size() >= playerMaxJobs)
return; return;
if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots()) if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots())

View File

@ -103,6 +103,7 @@ public class give implements Cmd {
default: default:
break; break;
} }
return true; return true;
} }
} }

View File

@ -1,5 +1,7 @@
package com.gamingmesh.jobs.commands.list; package com.gamingmesh.jobs.commands.list;
import java.text.DecimalFormat;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,7 +13,6 @@ import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.i18n.Language; import com.gamingmesh.jobs.i18n.Language;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Time.CMITimeManager; import net.Zrips.CMILib.Time.CMITimeManager;
@ -38,7 +39,7 @@ public class limit implements Cmd {
} }
if (disabled) { if (disabled) {
Language.sendMessage(sender,"command.limit.output.notenabled"); Language.sendMessage(sender, "command.limit.output.notenabled");
return true; return true;
} }
@ -64,7 +65,7 @@ public class limit implements Cmd {
Language.sendMessage(sender, "command.limit.output." + typeName + "time", "%time%", CMITimeManager.to24hourShort(limit.getLeftTime(type))); Language.sendMessage(sender, "command.limit.output." + typeName + "time", "%time%", CMITimeManager.to24hourShort(limit.getLeftTime(type)));
Language.sendMessage(sender, "command.limit.output." + typeName + "Limit", Language.sendMessage(sender, "command.limit.output." + typeName + "Limit",
"%current%", (int) (limit.getAmount(type) * 100) / 100D, "%current%", new DecimalFormat("##.##").format(limit.getAmount(type)),
"%total%", JPlayer.getLimit(type)); "%total%", JPlayer.getLimit(type));
} }
} }

View File

@ -46,7 +46,8 @@ public class transfer implements Cmd {
"%newjobname%", newjob.getDisplayName()); "%newjobname%", newjob.getDisplayName());
} }
Language.sendMessage(sender, "general.admin.success"); Language.sendMessage(sender, "general.admin.success");
} } else
Language.sendMessage(sender, "general.admin.error");
} catch (Exception e) { } catch (Exception e) {
Language.sendMessage(sender, "general.admin.error"); Language.sendMessage(sender, "general.admin.error");
} }

View File

@ -4,7 +4,6 @@ import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -107,7 +106,7 @@ public class BlockProtectionManager {
// If timer is under 2 hours, we can run scheduler to remove it when time comes // If timer is under 2 hours, we can run scheduler to remove it when time comes
if (time > -1 && (time - System.currentTimeMillis()) / 1000 < 60 * 60 * 2) if (time > -1 && (time - System.currentTimeMillis()) / 1000 < 60 * 60 * 2)
Bp.setScheduler(CMIScheduler.get().runTaskLater(() -> { Bp.setScheduler(CMIScheduler.get().runAtLocationLater(loc, () -> {
remove(loc); remove(loc);
}, (time - System.currentTimeMillis()) / 50)); }, (time - System.currentTimeMillis()) / 50));

View File

@ -28,7 +28,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -1572,6 +1572,8 @@ public class ConfigManager {
return job; return job;
} }
} }
return null; return null;
} }

View File

@ -45,6 +45,7 @@ import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
@ -110,7 +111,7 @@ public class GeneralConfigManager {
DisabledWorldsUse, UseAsWhiteListWorldList, MythicMobsEnabled, DisabledWorldsUse, UseAsWhiteListWorldList, MythicMobsEnabled,
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false, LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false,
payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false, preventShopItemEnchanting; payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false, preventShopItemEnchanting;
public boolean jobsshopenabled; public boolean jobsshopenabled;
public boolean DailyQuestsEnabled; public boolean DailyQuestsEnabled;
@ -272,11 +273,24 @@ public class GeneralConfigManager {
// Load locale // Load locale
Jobs.getLanguageManager().load(); Jobs.getLanguageManager().load();
// title settings // title settings
Jobs.getTitleManager().load(); try {
Jobs.getTitleManager().load();
} catch (Throwable e) {
e.printStackTrace();
}
// restricted areas // restricted areas
Jobs.getRestrictedAreaManager().load(); try {
Jobs.getRestrictedAreaManager().load();
} catch (Throwable e) {
e.printStackTrace();
}
// restricted blocks // restricted blocks
Jobs.getRestrictedBlockManager().load(); try {
Jobs.getRestrictedBlockManager().load();
} catch (Throwable e) {
e.printStackTrace();
}
// Item/Block/mobs name list // Item/Block/mobs name list
Jobs.getNameTranslatorManager().load(); Jobs.getNameTranslatorManager().load();
// signs information // signs information
@ -425,7 +439,7 @@ public class GeneralConfigManager {
c.addComment("DailyQuests.Enabled", "Enables or disables daily quests"); c.addComment("DailyQuests.Enabled", "Enables or disables daily quests");
DailyQuestsEnabled = c.get("DailyQuests.Enabled", true); DailyQuestsEnabled = c.get("DailyQuests.Enabled", true);
c.addComment("DailyQuests.ResetTime", "Defines time in 24hour format when we want to give out new daily quests", c.addComment("DailyQuests.ResetTime", "Defines time in 24hour format when we want to give out new daily quests",
"Any daily quests given before reset will be invalid and new ones will be given out"); "Any daily quests given before reset will be invalid and new ones will be given out");
ResetTimeHour = c.get("DailyQuests.ResetTime.Hour", 4); ResetTimeHour = c.get("DailyQuests.ResetTime.Hour", 4);
@ -442,7 +456,7 @@ public class GeneralConfigManager {
"For this to work, the player needs to get a new job for the timer to start.", "Counting in hours"); "For this to work, the player needs to get a new job for the timer to start.", "Counting in hours");
jobExpiryTime = c.get("JobExpirationTime", 0); jobExpiryTime = c.get("JobExpirationTime", 0);
c.addComment("max-jobs", "Maximum number of jobs a player can join.", "Use 0 for no maximum", "Keep in mind that jobs.max.[amount] will bypass this setting"); c.addComment("max-jobs", "Maximum number of jobs a player can join.", "Use -1 to disable limitations", "Keep in mind that jobs.max.[amount] will bypass this setting");
maxJobs = c.get("max-jobs", 3); maxJobs = c.get("max-jobs", 3);
c.addComment("disable-payment-if-max-level-reached", "Disabling the payment if the user reached the maximum level of a job."); c.addComment("disable-payment-if-max-level-reached", "Disabling the payment if the user reached the maximum level of a job.");
@ -456,7 +470,7 @@ public class GeneralConfigManager {
c.addComment("prevent-shop-item-enchanting", "Prevent players to enchant items from the shop in the anvil with enchanted books"); c.addComment("prevent-shop-item-enchanting", "Prevent players to enchant items from the shop in the anvil with enchanted books");
preventShopItemEnchanting = c.get("prevent-shop-item-enchanting", true); preventShopItemEnchanting = c.get("prevent-shop-item-enchanting", true);
c.addComment("jobs-shop-enabled", "Enables or disables jobs shop"); c.addComment("jobs-shop-enabled", "Enables or disables jobs shop");
jobsshopenabled = c.get("jobs-shop-enabled", true); jobsshopenabled = c.get("jobs-shop-enabled", true);

View File

@ -580,7 +580,7 @@ public class LanguageManager {
c.get("command.transfer.help.info", "Transfer a player's job from an old job to a new job."); c.get("command.transfer.help.info", "Transfer a player's job from an old job to a new job.");
c.get("command.transfer.help.args", "[playername] [oldjob] [newjob]"); c.get("command.transfer.help.args", "[playername] [oldjob] [newjob]");
Jobs.getGCManager().getCommandArgs().put("transfer", Arrays.asList("[playername]", "[oldjob]", "[newjob]")); Jobs.getGCManager().getCommandArgs().put("transfer", Arrays.asList("[playername]", "[oldjob]", "[newjob]"));
c.get("command.transfer.output.target", "You have been transferred from %oldjobname% to %newjobname%."); c.get("command.transfer.output.target", "&fYou have been transferred from %oldjobname% &fto %newjobname%.");
c.get("command.promote.help.info", "Promote the player X levels in a job."); c.get("command.promote.help.info", "Promote the player X levels in a job.");
c.get("command.promote.help.args", "[playername] [jobname] [levels] (-cmd)"); c.get("command.promote.help.args", "[playername] [jobname] [levels] (-cmd)");

View File

@ -237,7 +237,7 @@ public class Job {
if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty) if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty)
now = Jobs.getGCManager().DynamicPaymentMaxPenalty; now = Jobs.getGCManager().DynamicPaymentMaxPenalty;
if (Double.isNaN(now)) if (Double.isNaN(now))
now = 0; now = 0;
@ -310,7 +310,7 @@ public class Job {
}; };
String shortActionName = CMIMaterial.getGeneralMaterialName(action.getName()); String shortActionName = CMIMaterial.getGeneralMaterialName(action.getName());
for (JobInfo info : getJobInfo(action.getType())) { for (JobInfo info : getJobInfo(action.getType())) {
if (condition.test(info, action)) { if (condition.test(info, action)) {
if (!info.isInLevelRange(level)) { if (!info.isInLevelRange(level)) {

View File

@ -43,6 +43,7 @@ import com.gamingmesh.jobs.economy.PaymentData;
import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.CMINumber;
import net.Zrips.CMILib.Equations.Parser; import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Logs.CMIDebug;
@ -442,7 +443,7 @@ public class JobsPlayer {
Parser eq = Jobs.getGCManager().getLimit(type).getMaxEquation(); Parser eq = Jobs.getGCManager().getLimit(type).getMaxEquation();
eq.setVariable("totallevel", getTotalLevels()); eq.setVariable("totallevel", getTotalLevels());
maxJobsEquation = Jobs.getPlayerManager().getMaxJobs(this); maxJobsEquation = CMINumber.clamp(Jobs.getPlayerManager().getMaxJobs(this), 0, 9999);
limits.put(type, (int) eq.getValue()); limits.put(type, (int) eq.getValue());
setSaved(false); setSaved(false);
} }

View File

@ -328,10 +328,10 @@ public class JobsListener implements Listener {
String line1 = CMIChatColor.stripColor(plugin.getComplement().getLine(event, 1)); String line1 = CMIChatColor.stripColor(plugin.getComplement().getLine(event, 1));
if (CMIChatColor.stripColor(plugin.getComplement().getLine(event, 0)) if (CMIChatColor.stripColor(plugin.getComplement().getLine(event, 0)).equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))) && !line1.equalsIgnoreCase(
.equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))) && !line1.equalsIgnoreCase("toplist")) "toplist")) {
event.setLine(0, convert(Jobs.getLanguage().getMessage("signs.topline"))); event.setLine(0, convert(Jobs.getLanguage().getMessage("signs.topline")));
else } else
return; return;
if (!event.getPlayer().hasPermission("jobs.command.signs")) { if (!event.getPlayer().hasPermission("jobs.command.signs")) {

View File

@ -789,7 +789,7 @@ public final class JobsPaymentListener implements Listener {
// HACK! The API doesn't allow us to easily determine the resulting number of // HACK! The API doesn't allow us to easily determine the resulting number of
// crafted items, so we're forced to compare the inventory before and after. // crafted items, so we're forced to compare the inventory before and after.
private void schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack, final ActionType type) { public static void schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack, final ActionType type) {
final ItemStack[] preInv = player.getInventory().getContents(); final ItemStack[] preInv = player.getInventory().getContents();
// Clone the array. The content may (was for me) be mutable. // Clone the array. The content may (was for me) be mutable.
for (int i = 0; i < preInv.length; i++) { for (int i = 0; i < preInv.length; i++) {
@ -822,7 +822,7 @@ public final class JobsPaymentListener implements Listener {
}, 1); }, 1);
} }
private static boolean hasItems(ItemStack stack) { public static boolean hasItems(ItemStack stack) {
return stack != null && stack.getAmount() > 0; return stack != null && stack.getAmount() > 0;
} }
@ -838,7 +838,7 @@ public final class JobsPaymentListener implements Listener {
Objects.equal(a.getEnchantments(), b.getEnchantments()); Objects.equal(a.getEnchantments(), b.getEnchantments());
} }
private static boolean isStackSumLegal(ItemStack a, ItemStack b) { public static boolean isStackSumLegal(ItemStack a, ItemStack b) {
// See if we can create a new item stack with the combined elements of a and b // See if we can create a new item stack with the combined elements of a and b
if (a == null || b == null) if (a == null || b == null)
return true;// Treat null as an empty stack return true;// Treat null as an empty stack
@ -1602,6 +1602,9 @@ public final class JobsPaymentListener implements Listener {
if (!Jobs.getGCManager().useBreederFinder || !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().useBreederFinder || !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
if (event.getEntity().getType().equals(EntityType.TURTLE))
CMIDebug.d(event.getSpawnReason());
if (!event.getSpawnReason().toString().equalsIgnoreCase("BREEDING") && !event.getSpawnReason().toString().equalsIgnoreCase("EGG")) if (!event.getSpawnReason().toString().equalsIgnoreCase("BREEDING") && !event.getSpawnReason().toString().equalsIgnoreCase("EGG"))
return; return;
@ -1840,7 +1843,7 @@ public final class JobsPaymentListener implements Listener {
// either it's version 1.13+ and we're trying to strip a normal log like oak, // either it's version 1.13+ and we're trying to strip a normal log like oak,
// or it's 1.16+ and we're trying to strip a fungi like warped stem // or it's 1.16+ and we're trying to strip a fungi like warped stem
if ((Version.isCurrentEqualOrHigher(Version.v1_13_R1) && (block.getType().toString().endsWith("_LOG") || block.getType().toString().endsWith("_WOOD"))) || if ((Version.isCurrentEqualOrHigher(Version.v1_13_R1) && (block.getType().toString().endsWith("_LOG") || block.getType().toString().endsWith("_WOOD"))) ||
(Version.isCurrentEqualOrHigher(Version.v1_16_R1) && (block.getType().toString().endsWith("_STEM") || block.getType().toString().endsWith("_HYPHAE")))) { (Version.isCurrentEqualOrHigher(Version.v1_16_R1) && (block.getType().toString().endsWith("_STEM") || block.getType().toString().endsWith("_HYPHAE")))) {
CMIScheduler.get().runTaskLater(() -> Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.STRIPLOGS), block), 1); CMIScheduler.get().runTaskLater(() -> Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.STRIPLOGS), block), 1);
} }
} }

View File

@ -0,0 +1,97 @@
package com.gamingmesh.jobs.listeners;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.block.sign.SignSide;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.inventory.SmithItemEvent;
import org.bukkit.event.player.PlayerSignOpenEvent;
import org.bukkit.event.player.PlayerSignOpenEvent.Cause;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.actions.ItemActionInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobsPlayer;
import net.Zrips.CMILib.Colors.CMIChatColor;
public class PlayerSignEdit1_20Listeners implements Listener {
public PlayerSignEdit1_20Listeners() {
}
Set<UUID> signEditCache = new HashSet<UUID>();
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerSignOpenEvent(PlayerSignOpenEvent event) {
if (!event.getCause().equals(Cause.INTERACT))
return;
SignSide side = event.getSign().getSide(event.getSide());
if (!event.getPlayer().hasPermission("jobs.command.signs") && CMIChatColor.stripColor(side.getLine(0)).equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline")))) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryCraft(SmithItemEvent event) {
// If event is nothing or place, do nothing
switch (event.getAction()) {
case NOTHING:
case PLACE_ONE:
case PLACE_ALL:
case PLACE_SOME:
return;
default:
break;
}
if (event.getSlotType() != SlotType.CRAFTING)
return;
if (!event.isLeftClick() && !event.isRightClick())
return;
if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
return;
if (!(event.getWhoClicked() instanceof Player))
return;
Player player = (Player) event.getWhoClicked();
//Check if inventory is full and using shift click, possible money dupping fix
if (player.getInventory().firstEmpty() == -1 && event.isShiftClick()) {
player.sendMessage(Jobs.getLanguage().getMessage("message.crafting.fullinventory"));
return;
}
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
return;
// check if player is riding
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
return;
// check if in creative
if (!JobsPaymentListener.payIfCreative(player))
return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return;
Jobs.action(jPlayer, new ItemActionInfo(event.getInventory().getResult(), ActionType.CRAFT));
}
}

View File

@ -3,6 +3,7 @@ package com.gamingmesh.jobs.stuff;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
@ -63,6 +64,12 @@ public final class Util {
return blocks; return blocks;
} }
private final static DecimalFormat dcf = new DecimalFormat("##.##");
public static String format2Decimals(double number) {
return dcf.format(number);
}
public static String getRealType(Entity entity) { public static String getRealType(Entity entity) {
if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) { if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) {
return entity.getType().name(); return entity.getType().name();