1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-16 13:11:19 +01:00

Initial Folia server support

This commit is contained in:
Zrips 2023-07-12 15:22:53 +03:00
parent d20e865cb0
commit 87d52d43b5
30 changed files with 203 additions and 176 deletions

Binary file not shown.

BIN
libs/CMILib1.4.0.0.jar Normal file

Binary file not shown.

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>Jobs</groupId> <groupId>Jobs</groupId>
<artifactId>jobs</artifactId> <artifactId>jobs</artifactId>
<version>5.1.3.0</version> <version>5.2.1.0</version>
<name>Jobs</name> <name>Jobs</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
@ -197,7 +197,7 @@
<artifactId>CMILib</artifactId> <artifactId>CMILib</artifactId>
<version>latest</version> <version>latest</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${basedir}/libs/CMILib1.2.4.5.jar</systemPath> <systemPath>${basedir}/libs/CMILib1.4.0.0.jar</systemPath>
</dependency> </dependency>
<!-- WildStacker --> <!-- WildStacker -->
<dependency> <dependency>

View File

@ -116,6 +116,7 @@ import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage; import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public final class Jobs extends JavaPlugin { public final class Jobs extends JavaPlugin {
@ -763,7 +764,7 @@ public final class Jobs extends JavaPlugin {
} }
// register economy // register economy
getServer().getScheduler().runTask(this, new HookEconomyTask(this)); CMIScheduler.get().runTask(new HookEconomyTask(this));
dao.loadBlockProtection(); dao.loadBlockProtection();
getExploreManager().load(); getExploreManager().load();

View File

@ -69,6 +69,7 @@ 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;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class PlayerManager { public class PlayerManager {
@ -731,7 +732,7 @@ public class PlayerManager {
} }
if (Jobs.getGCManager().FireworkLevelupUse && player != null) { if (Jobs.getGCManager().FireworkLevelupUse && player != null) {
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { CMIScheduler.get().runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!player.isOnline()) if (!player.isOnline())
@ -1064,7 +1065,6 @@ public class PlayerManager {
} }
} }
CMIDebug.d("get bonus item");
jitems.add(getJobsItemByNbt(item)); jitems.add(getJobsItemByNbt(item));
} }
} }
@ -1201,7 +1201,7 @@ public class PlayerManager {
if (!Jobs.getGCManager().AutoJobJoinUse || player == null || player.isOp()) if (!Jobs.getGCManager().AutoJobJoinUse || player == null || player.isOp())
return; return;
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { CMIScheduler.get().runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!player.isOnline()) if (!player.isOnline())

View File

@ -23,6 +23,7 @@ import com.gamingmesh.jobs.container.TopList;
import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class SignUtil { public class SignUtil {
@ -354,7 +355,7 @@ public class SignUtil {
if (directionFacing != null && !(loc.getBlock().getState() instanceof Skull)) if (directionFacing != null && !(loc.getBlock().getState() instanceof Skull))
loc.add(directionFacing.getOppositeFace().getModX(), 0, directionFacing.getOppositeFace().getModZ()); loc.add(directionFacing.getOppositeFace().getModX(), 0, directionFacing.getOppositeFace().getModZ());
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { CMIScheduler.get().runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!(loc.getBlock().getState() instanceof Skull)) if (!(loc.getBlock().getState() instanceof Skull))

View File

@ -19,6 +19,7 @@ import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class bp implements Cmd { public class bp implements Cmd {
@ -78,19 +79,20 @@ public class bp implements Cmd {
else else
Language.sendMessage(sender, "command.bp.output.found", "%amount%", changedBlocks.size()); Language.sendMessage(sender, "command.bp.output.found", "%amount%", changedBlocks.size());
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { if (!changedBlocks.isEmpty()) {
@Override Location bloc = changedBlocks.get(0).getLocation();
public void run() { CMIScheduler.get().runAtLocationLater(bloc, () -> {
if (Version.isCurrentEqualOrHigher(Version.v1_15_R1)) if (Version.isCurrentEqualOrHigher(Version.v1_15_R1)) {
for (Block one : changedBlocks) { for (Block one : changedBlocks) {
player.sendBlockChange(one.getLocation(), one.getBlockData()); player.sendBlockChange(one.getLocation(), one.getBlockData());
} }
else } else {
for (Block one : changedBlocks) { for (Block one : changedBlocks) {
player.sendBlockChange(one.getLocation(), one.getType(), one.getData()); player.sendBlockChange(one.getLocation(), one.getType(), one.getData());
} }
} }
}, 120L); }, 120L);
}
return true; return true;
} }

View File

@ -1,6 +1,5 @@
package com.gamingmesh.jobs.commands.list; package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -10,28 +9,29 @@ import com.gamingmesh.jobs.dao.JobsManager.DataBaseType;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class convert implements Cmd { public class convert implements Cmd {
@Override @Override
public Boolean perform(Jobs plugin, CommandSender sender, String[] args) { public Boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (sender instanceof Player) { if (sender instanceof Player) {
CMIMessages.sendMessage(sender, LC.info_FromConsole); CMIMessages.sendMessage(sender, LC.info_FromConsole);
return true; return true;
} }
if (args.length > 0) { if (args.length > 0) {
return false; return false;
} }
String from = Jobs.getDBManager().getDbType() == DataBaseType.SqLite ? "SQLite" : "MySQL"; String from = Jobs.getDBManager().getDbType() == DataBaseType.SqLite ? "SQLite" : "MySQL";
String to = Jobs.getDBManager().getDbType() == DataBaseType.SqLite ? "MySQL" : "SQLite"; String to = Jobs.getDBManager().getDbType() == DataBaseType.SqLite ? "MySQL" : "SQLite";
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { CMIScheduler.get().runTaskAsynchronously(() -> {
Jobs.convertDatabase(); Jobs.convertDatabase();
CMIMessages.consoleMessage("&eDatabase was converted from &2" + from + " &eto &2" + to + "&e!"); CMIMessages.consoleMessage("&eDatabase was converted from &2" + from + " &eto &2" + to + "&e!");
}); });
return true; return true;
} }
} }

View File

@ -19,6 +19,7 @@ import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.Sorting; import com.gamingmesh.jobs.stuff.Sorting;
import net.Zrips.CMILib.Time.CMITimeManager; import net.Zrips.CMILib.Time.CMITimeManager;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class glog implements Cmd { public class glog implements Cmd {
@ -28,7 +29,7 @@ public class glog implements Cmd {
return false; return false;
} }
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { CMIScheduler.get().runTaskAsynchronously(new Runnable() {
@Override @Override
public void run() { public void run() {
Map<LogAmounts, Double> unsortMap = new HashMap<>(); Map<LogAmounts, Double> unsortMap = new HashMap<>();

View File

@ -12,6 +12,7 @@ import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class leave implements Cmd { public class leave implements Cmd {
@ -44,7 +45,7 @@ public class leave implements Cmd {
if (!Util.LEAVECONFIRM.contains(uuid)) { if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid); Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid), CMIScheduler.get().runTaskLater(() -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime); 20 * Jobs.getGCManager().ConfirmExpiryTime);
Language.sendMessage(sender, "command.leave.confirmationNeed", "[jobname]", Language.sendMessage(sender, "command.leave.confirmationNeed", "[jobname]",

View File

@ -14,6 +14,7 @@ import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class leaveall implements Cmd { public class leaveall implements Cmd {
@ -39,7 +40,7 @@ public class leaveall implements Cmd {
if (!Util.LEAVECONFIRM.contains(uuid)) { if (!Util.LEAVECONFIRM.contains(uuid)) {
Util.LEAVECONFIRM.add(uuid); Util.LEAVECONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid), CMIScheduler.get().runTaskLater(() -> Util.LEAVECONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime); 20 * Jobs.getGCManager().ConfirmExpiryTime);
Language.sendMessage(pSender, "command.leaveall.confirmationNeed", "[time]", Language.sendMessage(pSender, "command.leaveall.confirmationNeed", "[time]",

View File

@ -56,7 +56,6 @@ public class limit implements Cmd {
PaymentData limit = JPlayer.getPaymentLimit(); PaymentData limit = JPlayer.getPaymentLimit();
if (limit.getLeftTime(type) <= 0) { if (limit.getLeftTime(type) <= 0) {
CMIDebug.d("reset", type);
limit.resetLimits(type); limit.resetLimits(type);
} }

View File

@ -16,6 +16,7 @@ import com.gamingmesh.jobs.economy.BufferedEconomy;
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.Version.Schedulers.CMIScheduler;
public class skipquest implements Cmd { public class skipquest implements Cmd {
@ -114,7 +115,7 @@ public class skipquest implements Cmd {
if (!Util.SKIPCONFIRM.contains(uuid)) { if (!Util.SKIPCONFIRM.contains(uuid)) {
Util.SKIPCONFIRM.add(uuid); Util.SKIPCONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.SKIPCONFIRM.remove(uuid), CMIScheduler.get().runTaskLater(() -> Util.SKIPCONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime); 20 * Jobs.getGCManager().ConfirmExpiryTime);
Language.sendMessage(sender, "command.skipquest.confirmationNeed", "[questName]", Language.sendMessage(sender, "command.skipquest.confirmationNeed", "[questName]",

View File

@ -13,6 +13,7 @@ import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage; import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Util.CMIVersionChecker; import net.Zrips.CMILib.Util.CMIVersionChecker;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
public class version implements Cmd { public class version implements Cmd {
@ -20,7 +21,7 @@ public class version implements Cmd {
@Override @Override
public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { public Boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { CMIScheduler.get().runTaskAsynchronously(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -62,7 +63,7 @@ public class version implements Cmd {
final String vault = preVault; final String vault = preVault;
final String vaultProvider = vProvider; final String vaultProvider = vProvider;
Bukkit.getScheduler().runTask(plugin, new Runnable() { CMIScheduler.get().runTask(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -16,6 +16,7 @@ import com.gamingmesh.jobs.container.DBAction;
import net.Zrips.CMILib.Container.CMIBlock; import net.Zrips.CMILib.Container.CMIBlock;
import net.Zrips.CMILib.Container.CMIBlock.Bisect; import net.Zrips.CMILib.Container.CMIBlock.Bisect;
import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class BlockProtectionManager { public class BlockProtectionManager {
@ -39,7 +40,7 @@ public class BlockProtectionManager {
} }
public void add(Block block, Integer cd) { public void add(Block block, Integer cd) {
if (cd == null || cd == 0) if (cd == null || cd == 0)
return; return;
@ -81,7 +82,7 @@ public class BlockProtectionManager {
if (time == null || time == 0) if (time == null || time == 0)
return null; return null;
String v = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ(); String v = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
HashMap<String, HashMap<String, HashMap<String, BlockProtection>>> regions = map.getOrDefault(loc.getWorld(), new HashMap<>()); HashMap<String, HashMap<String, HashMap<String, BlockProtection>>> regions = map.getOrDefault(loc.getWorld(), new HashMap<>());
@ -97,8 +98,8 @@ public class BlockProtectionManager {
Bp = new BlockProtection(DBAction.INSERT, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); Bp = new BlockProtection(DBAction.INSERT, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
else { else {
Bp.setAction(DBAction.UPDATE); Bp.setAction(DBAction.UPDATE);
if (Bp.getSchedId() > -1) if (Bp.getScheduler() != null)
Bukkit.getServer().getScheduler().cancelTask(Bp.getSchedId()); Bp.getScheduler().cancel();
} }
Bp.setPaid(paid); Bp.setPaid(paid);
@ -106,7 +107,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.setSchedId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Jobs.getInstance(), () -> { Bp.setScheduler(CMIScheduler.get().runTaskLater(() -> {
remove(loc); remove(loc);
}, (time - System.currentTimeMillis()) / 50)); }, (time - System.currentTimeMillis()) / 50));
@ -116,7 +117,7 @@ public class BlockProtectionManager {
map.put(loc.getWorld(), regions); map.put(loc.getWorld(), regions);
// Only saving into save cache if timer is higher than 5 minutes // Only saving into save cache if timer is higher than 5 minutes
if (cache && ((time - System.currentTimeMillis()) / 1000 > 60 * 5 || time < 0) ) if (cache && ((time - System.currentTimeMillis()) / 1000 > 60 * 5 || time < 0))
addToCache(loc, Bp); addToCache(loc, Bp);
return Bp; return Bp;
} }
@ -186,7 +187,7 @@ public class BlockProtectionManager {
world.remove(locToRegion(loc)); world.remove(locToRegion(loc));
return bp; return bp;
} }
public Long getTime(Block block) { public Long getTime(Block block) {
return getTime(block.getLocation()); return getTime(block.getLocation());

View File

@ -13,6 +13,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ToggleBarHandling; import com.gamingmesh.jobs.stuff.ToggleBarHandling;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class BossBarManager { public class BossBarManager {
@ -36,7 +37,7 @@ public class BossBarManager {
public void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain) { public void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain) {
if (Jobs.getGCManager().isBossBarAsync()) { if (Jobs.getGCManager().isBossBarAsync()) {
Bukkit.getScheduler().runTaskAsynchronously(Jobs.getInstance(), () -> ShowJobProgressionInTask(player, jobProg, expGain)); CMIScheduler.get().runTaskAsynchronously(() -> ShowJobProgressionInTask(player, jobProg, expGain));
} else { } else {
ShowJobProgressionInTask(player, jobProg, expGain); ShowJobProgressionInTask(player, jobProg, expGain);
} }
@ -139,7 +140,7 @@ public class BossBarManager {
bar.setVisible(true); bar.setVisible(true);
if (oldOne != null) if (oldOne != null)
oldOne.setId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { oldOne.setScheduler(CMIScheduler.get().runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
for (BossBarInfo one : player.getBossBarInfo()) { for (BossBarInfo one : player.getBossBarInfo()) {

View File

@ -10,7 +10,6 @@ import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.scheduler.BukkitTask;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.api.JobsScheduleStartEvent; import com.gamingmesh.jobs.api.JobsScheduleStartEvent;
@ -21,12 +20,14 @@ import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.Schedule; import com.gamingmesh.jobs.container.Schedule;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
import net.Zrips.CMILib.Version.Schedulers.CMITask;
public class ScheduleManager { public class ScheduleManager {
private Jobs plugin; private Jobs plugin;
private BukkitTask timer; private CMITask timer;
private YmlMaker jobSchedule; private YmlMaker jobSchedule;
public static final List<Schedule> BOOSTSCHEDULE = new ArrayList<>(); public static final List<Schedule> BOOSTSCHEDULE = new ArrayList<>();
@ -44,7 +45,7 @@ public class ScheduleManager {
return; return;
cancel(); cancel();
timer = Bukkit.getScheduler().runTaskTimer(plugin, this::scheduler, 20, 30 * 20L); timer = CMIScheduler.get().scheduleSyncRepeatingTask(this::scheduler, 20, 30 * 20L);
} }
public void cancel() { public void cancel() {

View File

@ -2,13 +2,15 @@ package com.gamingmesh.jobs.container;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.Zrips.CMILib.Version.Schedulers.CMITask;
public class BlockProtection { public class BlockProtection {
private static long pre = (int) (System.currentTimeMillis() / 10000000000L) * 10000000000L; private static long pre = (int) (System.currentTimeMillis() / 10000000000L) * 10000000000L;
private int id = -1; private int id = -1;
private int schedId = - 1; private CMITask scheduler = null;
private int time = -1; private int time = -1;
private int recorded = -1; private int recorded = -1;
private DBAction action; private DBAction action;
private boolean paid = false; private boolean paid = false;
@ -17,109 +19,109 @@ public class BlockProtection {
private int z = 0; private int z = 0;
public BlockProtection(Vector pos) { public BlockProtection(Vector pos) {
this(DBAction.INSERT, pos); this(DBAction.INSERT, pos);
} }
@Deprecated @Deprecated
public BlockProtection(DBAction action, Vector pos) { public BlockProtection(DBAction action, Vector pos) {
this(action, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); this(action, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
} }
public BlockProtection(DBAction action, int x, int y, int z) { public BlockProtection(DBAction action, int x, int y, int z) {
this.action = action; this.action = action;
if (action == DBAction.NONE) if (action == DBAction.NONE)
action = null; action = null;
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
} }
public long getTime() { public long getTime() {
return deconvert(time); return deconvert(time);
} }
private static int convert(long time) { private static int convert(long time) {
return time == -1L ? -1 : (int) ((time - pre) / 1000L); return time == -1L ? -1 : (int) ((time - pre) / 1000L);
} }
private static long deconvert(int time) { private static long deconvert(int time) {
return time == -1 ? -1 : (time * 1000L) + pre; return time == -1 ? -1 : (time * 1000L) + pre;
} }
public void setTime(long time) { public void setTime(long time) {
this.time = time == -1 ? -1 : convert(time); this.time = time == -1 ? -1 : convert(time);
this.recorded = convert(System.currentTimeMillis()); this.recorded = convert(System.currentTimeMillis());
} }
public DBAction getAction() { public DBAction getAction() {
return action == null ? DBAction.NONE : action; return action == null ? DBAction.NONE : action;
} }
public void setAction(DBAction action) { public void setAction(DBAction action) {
if (action == DBAction.NONE) if (action == DBAction.NONE)
action = null; action = null;
this.action = action; this.action = action;
} }
public long getRecorded() { public long getRecorded() {
return deconvert(recorded); return deconvert(recorded);
} }
public boolean isPaid() { public boolean isPaid() {
return paid; return paid;
} }
public void setPaid(boolean paid) { public void setPaid(boolean paid) {
this.paid = paid; this.paid = paid;
} }
public void setRecorded(long recorded) { public void setRecorded(long recorded) {
this.recorded = convert(recorded); this.recorded = convert(recorded);
} }
public int getId() { public int getId() {
return id; return id;
} }
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@Deprecated @Deprecated
public Vector getPos() { public Vector getPos() {
return new Vector(x, y, z); return new Vector(x, y, z);
} }
@Deprecated @Deprecated
public void setPos(Vector pos) { public void setPos(Vector pos) {
x = pos.getBlockX(); x = pos.getBlockX();
y = pos.getBlockY(); y = pos.getBlockY();
z = pos.getBlockZ(); z = pos.getBlockZ();
} }
public void setPos(int x, int y, int z) { public void setPos(int x, int y, int z) {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
} }
public int getX() { public int getX() {
return x; return x;
} }
public int getY() { public int getY() {
return y; return y;
} }
public int getZ() { public int getZ() {
return z; return z;
} }
public int getSchedId() { public CMITask getScheduler() {
return schedId; return scheduler;
} }
public void setSchedId(int schedId) { public void setScheduler(CMITask cmiTask) {
this.schedId = schedId; this.scheduler = cmiTask;
} }
} }

View File

@ -1,13 +1,14 @@
package com.gamingmesh.jobs.container; package com.gamingmesh.jobs.container;
import org.bukkit.Bukkit;
import org.bukkit.boss.BossBar; import org.bukkit.boss.BossBar;
import net.Zrips.CMILib.Version.Schedulers.CMITask;
public class BossBarInfo { public class BossBarInfo {
private String jobName; private String jobName;
private String PlayerName; private String PlayerName;
private BossBar bar; private BossBar bar;
private int id = -1; private CMITask scheduler = null;
public BossBarInfo(String PlayerName, String jobName, BossBar bar) { public BossBarInfo(String PlayerName, String jobName, BossBar bar) {
this.PlayerName = PlayerName; this.PlayerName = PlayerName;
@ -15,14 +16,14 @@ public class BossBarInfo {
this.bar = bar; this.bar = bar;
} }
public void setId(int id) { public void setScheduler(CMITask cmiTask) {
cancel(); cancel();
this.id = id; this.scheduler = cmiTask;
} }
public void cancel() { public void cancel() {
if (id != -1) if (scheduler != null)
Bukkit.getScheduler().cancelTask(this.id); scheduler.cancel();
} }
public String getPlayerName() { public String getPlayerName() {

View File

@ -232,13 +232,14 @@ public class Job {
e.printStackTrace(); e.printStackTrace();
} }
CMIDebug.d("Now", now, this.getName(), getTotalPlayers(), now == Double.POSITIVE_INFINITY);
if (now > Jobs.getGCManager().DynamicPaymentMaxBonus) if (now > Jobs.getGCManager().DynamicPaymentMaxBonus)
now = Jobs.getGCManager().DynamicPaymentMaxBonus; now = Jobs.getGCManager().DynamicPaymentMaxBonus;
if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty) if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty)
now = Jobs.getGCManager().DynamicPaymentMaxPenalty; now = Jobs.getGCManager().DynamicPaymentMaxPenalty;
if (Double.isNaN(now))
now = 0;
this.bonus = now; this.bonus = now;
} }
@ -309,6 +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

@ -47,6 +47,8 @@ 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;
import net.Zrips.CMILib.Time.CMITimeManager; import net.Zrips.CMILib.Time.CMITimeManager;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
import net.Zrips.CMILib.Version.Schedulers.CMITask;
public class JobsPlayer { public class JobsPlayer {
@ -1347,14 +1349,14 @@ public class JobsPlayer {
this.doneQuests = doneQuests; this.doneQuests = doneQuests;
} }
private Integer questSignUpdateShed; private CMITask questSignUpdateShed;
public void addDoneQuest(final Job job) { public void addDoneQuest(final Job job) {
doneQuests++; doneQuests++;
setSaved(false); setSaved(false);
if (questSignUpdateShed == null) { if (questSignUpdateShed == null) {
questSignUpdateShed = plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { questSignUpdateShed = CMIScheduler.get().runTaskLater(() -> {
Jobs.getSignUtil().signUpdate(job, SignTopType.questtoplist); Jobs.getSignUtil().signUpdate(job, SignTopType.questtoplist);
questSignUpdateShed = null; questSignUpdateShed = null;
}, Jobs.getGCManager().getSavePeriod() * 60 * 20L); }, Jobs.getGCManager().getSavePeriod() * 60 * 20L);

View File

@ -45,6 +45,7 @@ import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Time.CMITimeManager; import net.Zrips.CMILib.Time.CMITimeManager;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public abstract class JobsDAO { public abstract class JobsDAO {
@ -1016,7 +1017,7 @@ public abstract class JobsDAO {
public void triggerTableIdUpdate() { public void triggerTableIdUpdate() {
// Lets convert old fields // Lets convert old fields
if (!converted) { if (!converted) {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { CMIScheduler.get().runTaskLater(() -> {
CMIMessages.consoleMessage("&6[Jobs] Converting to new database format"); CMIMessages.consoleMessage("&6[Jobs] Converting to new database format");
convertID(); convertID();
CMIMessages.consoleMessage("&6[Jobs] Converted to new database format"); CMIMessages.consoleMessage("&6[Jobs] Converted to new database format");

View File

@ -38,6 +38,7 @@ import com.gamingmesh.jobs.tasks.BufferedPaymentTask;
import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class BufferedEconomy { public class BufferedEconomy {
@ -208,9 +209,9 @@ public class BufferedEconomy {
} }
if (Jobs.getGCManager().isEconomyAsync()) if (Jobs.getGCManager().isEconomyAsync())
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i); CMIScheduler.get().runLaterAsync(new BufferedPaymentTask(this, economy, payment), i);
else else
Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i); CMIScheduler.get().runTaskLater(new BufferedPaymentTask(this, economy, payment), i);
// Show players payment stuff // Show players payment stuff
showPayment(payment); showPayment(payment);

View File

@ -91,6 +91,7 @@ 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;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class JobsListener implements Listener { public class JobsListener implements Listener {
@ -170,7 +171,7 @@ public class JobsListener implements Listener {
if (!Jobs.getGCManager().MultiServerCompatability()) if (!Jobs.getGCManager().MultiServerCompatability())
Jobs.getPlayerManager().playerJoin(event.getPlayer()); Jobs.getPlayerManager().playerJoin(event.getPlayer());
else { else {
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Jobs.getPlayerManager().playerJoin(event.getPlayer()), 40L); CMIScheduler.get().runTaskLater(() -> Jobs.getPlayerManager().playerJoin(event.getPlayer()), 40L);
} }
} }
@ -317,7 +318,7 @@ public class JobsListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> signUtil.signUpdate(job, type), 1L); CMIScheduler.get().runTaskLater(() -> signUtil.signUpdate(job, type), 1L);
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -375,14 +376,14 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onCropGrown(final BlockGrowEvent event) { public void onCropGrown(final BlockGrowEvent event) {
if (Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) { if (Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) {
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Jobs.getBpManager().remove(event.getBlock()), 1L); CMIScheduler.get().runAtLocationLater(event.getBlock().getLocation(), () -> Jobs.getBpManager().remove(event.getBlock()), 1L);
} }
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTreeGrown(final StructureGrowEvent event) { public void onTreeGrown(final StructureGrowEvent event) {
if (!event.getBlocks().isEmpty() && Jobs.getGCManager().canPerformActionInWorld(event.getBlocks().get(0).getWorld())) { if (!event.getBlocks().isEmpty() && Jobs.getGCManager().canPerformActionInWorld(event.getBlocks().get(0).getWorld())) {
plugin.getServer().getScheduler().runTaskLater(plugin, () -> event.getBlocks().forEach(blockState -> Jobs.getBpManager().remove(blockState.getBlock())), 1L); CMIScheduler.get().runAtLocationLater(event.getBlocks().get(0).getLocation(), () -> event.getBlocks().forEach(blockState -> Jobs.getBpManager().remove(blockState.getBlock())), 1L);
} }
} }

View File

@ -133,6 +133,7 @@ import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Logs.CMIDebug; 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;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public final class JobsPaymentListener implements Listener { public final class JobsPaymentListener implements Listener {
@ -795,7 +796,7 @@ public final class JobsPaymentListener implements Listener {
preInv[i] = preInv[i].clone(); preInv[i] = preInv[i].clone();
} }
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { CMIScheduler.get().runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
final ItemStack[] postInv = player.getInventory().getContents(); final ItemStack[] postInv = player.getInventory().getContents();
@ -1315,7 +1316,7 @@ public final class JobsPaymentListener implements Listener {
// So lets remove meta in case some plugin removes entity in wrong way. // So lets remove meta in case some plugin removes entity in wrong way.
// Need to delay action for other function to properly check for existing meta data relating to this entity before clearing it out // Need to delay action for other function to properly check for existing meta data relating to this entity before clearing it out
// Longer delay is needed due to mob split event being fired few seconds after mob dies and not at same time // Longer delay is needed due to mob split event being fired few seconds after mob dies and not at same time
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { CMIScheduler.get().runTaskLater(() -> {
lVictim.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin); lVictim.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
}, 200L); }, 200L);
} catch (Throwable ignored) { } catch (Throwable ignored) {
@ -1839,7 +1840,7 @@ public final class JobsPaymentListener implements Listener {
// 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")))) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> 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

@ -13,53 +13,54 @@ import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public final class VersionChecker { public final class VersionChecker {
private Jobs plugin; private Jobs plugin;
public VersionChecker(Jobs plugin) { public VersionChecker(Jobs plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
public void VersionCheck(final Player player) { public void VersionCheck(final Player player) {
if (!Jobs.getGCManager().isShowNewVersion()) if (!Jobs.getGCManager().isShowNewVersion())
return; return;
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { CMIScheduler.get().runTaskAsynchronously(() -> {
String newVersion = getNewVersion(); String newVersion = getNewVersion();
if (newVersion == null) if (newVersion == null)
return; return;
int currentVersion = Integer.parseInt(plugin.getDescription().getVersion().replace(".", "")); int currentVersion = Integer.parseInt(plugin.getDescription().getVersion().replace(".", ""));
int newVer = Integer.parseInt(newVersion.replace(".", "")); int newVer = Integer.parseInt(newVersion.replace(".", ""));
if (newVer <= currentVersion || currentVersion >= newVer) if (newVer <= currentVersion || currentVersion >= newVer)
return; return;
List<String> msg = Arrays.asList( List<String> msg = Arrays.asList(
ChatColor.GREEN + "*********************** " + plugin.getDescription().getName() + " **************************", ChatColor.GREEN + "*********************** " + plugin.getDescription().getName() + " **************************",
ChatColor.GREEN + "* " + newVersion + " is now available! Your version: " + currentVersion, ChatColor.GREEN + "* " + newVersion + " is now available! Your version: " + currentVersion,
ChatColor.GREEN + "* " + ChatColor.DARK_GREEN + plugin.getDescription().getWebsite(), ChatColor.GREEN + "* " + ChatColor.DARK_GREEN + plugin.getDescription().getWebsite(),
ChatColor.GREEN + "************************************************************"); ChatColor.GREEN + "************************************************************");
for (String one : msg) for (String one : msg)
if (player != null) if (player != null)
player.sendMessage(one); player.sendMessage(one);
else else
CMIMessages.consoleMessage(one); CMIMessages.consoleMessage(one);
}); });
} }
public String getNewVersion() { public String getNewVersion() {
try { try {
URLConnection con = new URL("https://api.spigotmc.org/legacy/update.php?resource=4216").openConnection(); URLConnection con = new URL("https://api.spigotmc.org/legacy/update.php?resource=4216").openConnection();
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine(); String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
if (version.length() <= 8) if (version.length() <= 8)
return version; return version;
} catch (Throwable t) { } catch (Throwable t) {
CMIMessages.consoleMessage("&cFailed to check for " + plugin.getDescription().getName() + " update on spigot web page."); CMIMessages.consoleMessage("&cFailed to check for " + plugin.getDescription().getName() + " update on spigot web page.");
} }
return null; return null;
} }
} }

View File

@ -9,6 +9,8 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Util; import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class JobsChatEvent implements Listener { public class JobsChatEvent implements Listener {
@ -25,8 +27,7 @@ public class JobsChatEvent implements Listener {
final String msg = Util.getJobsEditorMap().remove(event.getPlayer().getUniqueId()); final String msg = Util.getJobsEditorMap().remove(event.getPlayer().getUniqueId());
if (msg != null) { if (msg != null) {
plugin.getServer().getScheduler().runTask(plugin, CMIScheduler.get().runTask(() -> event.getPlayer().performCommand(msg + event.getMessage()));
() -> event.getPlayer().performCommand(msg + event.getMessage()));
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -10,6 +10,7 @@ import com.gamingmesh.jobs.stuff.Util;
import io.papermc.paper.chat.ChatRenderer; import io.papermc.paper.chat.ChatRenderer;
import io.papermc.paper.event.player.AsyncChatEvent; import io.papermc.paper.event.player.AsyncChatEvent;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
import net.kyori.adventure.text.TextReplacementConfig; import net.kyori.adventure.text.TextReplacementConfig;
public final class KyoriChatEvent extends Complement2 implements Listener { public final class KyoriChatEvent extends Complement2 implements Listener {
@ -17,45 +18,44 @@ public final class KyoriChatEvent extends Complement2 implements Listener {
private Jobs plugin; private Jobs plugin;
public KyoriChatEvent(Jobs plugin) { public KyoriChatEvent(Jobs plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void asyncChatEvent(final AsyncChatEvent event) { public void asyncChatEvent(final AsyncChatEvent event) {
if (event.isCancelled() || Util.getJobsEditorMap().isEmpty()) if (event.isCancelled() || Util.getJobsEditorMap().isEmpty())
return; return;
final String msg = Util.getJobsEditorMap().remove(event.getPlayer().getUniqueId()); final String msg = Util.getJobsEditorMap().remove(event.getPlayer().getUniqueId());
if (msg != null) { if (msg != null) {
plugin.getServer().getScheduler().runTask(plugin, CMIScheduler.get().runTask(() -> event.getPlayer().performCommand(msg + serialize(event.message())));
() -> event.getPlayer().performCommand(msg + serialize(event.message()))); event.setCancelled(true);
event.setCancelled(true); }
}
} }
// Adding to chat prefix job name // Adding to chat prefix job name
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerChat(AsyncChatEvent event) { public void onPlayerChat(AsyncChatEvent event) {
if (!Jobs.getGCManager().getModifyChat()) if (!Jobs.getGCManager().getModifyChat())
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer()); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : ""; String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
if (honorific.equals(" ")) if (honorific.equals(" "))
honorific = ""; honorific = "";
// TODO displayName returns the player display name not the chat component from // TODO displayName returns the player display name not the chat component from
// chat plugins, like Essentials // chat plugins, like Essentials
// Now there is a parameter "player", so literally we need to add 800+ chat plugins // Now there is a parameter "player", so literally we need to add 800+ chat plugins
// to this plugin as dependency? // to this plugin as dependency?
// 3rd attempt: now we tried to use text replacement config builder to match the variable // 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 // result: instead of replacing the variable, now the chat message never been sent
//event.composer((player, displayName, msg) -> msg //event.composer((player, displayName, msg) -> msg
//.replaceText(TextReplacementConfig.builder().match("{jobs}").once().replacement(h).build())); //.replaceText(TextReplacementConfig.builder().match("{jobs}").once().replacement(h).build()));
event.message(ChatRenderer.defaultRenderer().render(event.getPlayer(), event.getPlayer().displayName(), event.message(), event.getPlayer()).replaceText(TextReplacementConfig.builder().match( event.message(ChatRenderer.defaultRenderer().render(event.getPlayer(), event.getPlayer().displayName(), event.message(), event.getPlayer()).replaceText(TextReplacementConfig.builder().match(
"\\{jobs\\}").replacement(honorific).build())); "\\{jobs\\}").replacement(honorific).build()));
// 4th attempt: composeChat -> doing nothing // 4th attempt: composeChat -> doing nothing
// event.message(ChatComposer.DEFAULT.composeChat(event.getPlayer(), event.getPlayer().displayName(), event.message()) // event.message(ChatComposer.DEFAULT.composeChat(event.getPlayer(), event.getPlayer().displayName(), event.message())
// .replaceText(TextReplacementConfig.builder().match("\\{jobs\\}").replacement(honorific).build())); // .replaceText(TextReplacementConfig.builder().match("\\{jobs\\}").replacement(honorific).build()));
} }
@ -63,22 +63,22 @@ public final class KyoriChatEvent extends Complement2 implements Listener {
// Changing chat prefix variable to job name // Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerChatLow(AsyncChatEvent event) { public void onPlayerChatLow(AsyncChatEvent event) {
onPlayerChatHigh(event); onPlayerChatHigh(event);
} }
// Changing chat prefix variable to job name // Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChatHigh(AsyncChatEvent event) { public void onPlayerChatHigh(AsyncChatEvent event) {
if (Jobs.getGCManager().getModifyChat()) if (Jobs.getGCManager().getModifyChat())
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer()); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : ""; String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
if (honorific.equals(" ")) if (honorific.equals(" "))
honorific = ""; honorific = "";
event.message(ChatRenderer.defaultRenderer().render(event.getPlayer(), event.getPlayer().displayName(), event.message(), event.getPlayer()).replaceText(TextReplacementConfig.builder().match( event.message(ChatRenderer.defaultRenderer().render(event.getPlayer(), event.getPlayer().displayName(), event.message(), event.getPlayer()).replaceText(TextReplacementConfig.builder().match(
"\\{jobs\\}").replacement(honorific).build())); "\\{jobs\\}").replacement(honorific).build()));
// event.message(ChatComposer.DEFAULT // event.message(ChatComposer.DEFAULT
// .composeChat(event.getPlayer(), event.getPlayer().displayName(), event.message()) // .composeChat(event.getPlayer(), event.getPlayer().displayName(), event.message())

View File

@ -24,6 +24,8 @@ import com.gamingmesh.jobs.economy.BufferedEconomy;
import com.gamingmesh.jobs.economy.BufferedPayment; import com.gamingmesh.jobs.economy.BufferedPayment;
import com.gamingmesh.jobs.economy.Economy; import com.gamingmesh.jobs.economy.Economy;
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
public class BufferedPaymentTask implements Runnable { public class BufferedPaymentTask implements Runnable {
private BufferedEconomy bufferedEconomy; private BufferedEconomy bufferedEconomy;
@ -41,7 +43,7 @@ public class BufferedPaymentTask implements Runnable {
double money = payment.get(CurrencyType.MONEY); double money = payment.get(CurrencyType.MONEY);
if (money > 0) { if (money > 0) {
if (Jobs.getGCManager().isEconomyAsync()) { if (Jobs.getGCManager().isEconomyAsync()) {
org.bukkit.Bukkit.getScheduler().runTaskAsynchronously(bufferedEconomy.getPlugin(), () -> economy.depositPlayer(payment.getOfflinePlayer(), money)); CMIScheduler.get().runTaskAsynchronously(() -> economy.depositPlayer(payment.getOfflinePlayer(), money));
} else { } else {
economy.depositPlayer(payment.getOfflinePlayer(), money); economy.depositPlayer(payment.getOfflinePlayer(), money);
} }

View File

@ -3,6 +3,7 @@ description: Jobs plugin for the BukkitAPI
main: com.gamingmesh.jobs.Jobs main: com.gamingmesh.jobs.Jobs
version: ${project.version} version: ${project.version}
api-version: "1.13" api-version: "1.13"
folia-supported: true
website: https://www.spigotmc.org/resources/4216/ website: https://www.spigotmc.org/resources/4216/
authors: [Zrips] authors: [Zrips]
contributors: [montlikadani] contributors: [montlikadani]