1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

New command as resetquesttotal for reseting done quest counter

This commit is contained in:
Zrips 2022-02-11 17:18:51 +02:00
parent 03de00be6e
commit f53a32e35a
8 changed files with 95 additions and 12 deletions

View File

@ -116,6 +116,7 @@ import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Version.Version;
@ -165,7 +166,7 @@ public final class Jobs extends JavaPlugin {
public static LoadStatus status = LoadStatus.Good;
private static boolean hasLimitedItems = false;
private static boolean hasLimitedItems = false;
private static final int MAX_ENTRIES = 5;
public static final LinkedHashMap<UUID, FastPayment> FASTPAYMENT = new LinkedHashMap<UUID, FastPayment>(MAX_ENTRIES + 1, .75F, false) {
@ -1511,7 +1512,7 @@ public final class Jobs extends JavaPlugin {
rm.show(sender);
}
public static boolean hasLimitedItems() {
return hasLimitedItems;
}
public static boolean hasLimitedItems() {
return hasLimitedItems;
}
}

View File

@ -0,0 +1,58 @@
package com.gamingmesh.jobs.commands.list;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
public class resetquesttotal implements Cmd {
@Override
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length != 0 && args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "resetquesttotal");
return true;
}
if (args[0].equalsIgnoreCase("all")) {
for (Entry<UUID, JobsPlayer> pl : Jobs.getPlayerManager().getPlayersCache().entrySet()) {
pl.getValue().setDoneQuests(0);
}
Jobs.getJobsDAO().resetDoneQuests();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquesttotal.output.reseted", "%playername%", Jobs.getPlayerManager().getPlayersCache().size()));
return true;
}
JobsPlayer jPlayer = null;
Job job = null;
for (String one : args) {
if (job == null) {
job = Jobs.getJob(one);
if (job != null)
continue;
}
jPlayer = Jobs.getPlayerManager().getJobsPlayer(one);
}
if (jPlayer == null && sender instanceof Player)
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args.length > 0 ? args[0] : ""));
return true;
}
jPlayer.setDoneQuests(0);
jPlayer.setSaved(false);
jPlayer.save();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquesttotal.output.reseted", "%playername%", jPlayer.getName()));
return true;
}
}

View File

@ -214,6 +214,11 @@ public class LanguageManager {
Jobs.getGCManager().getCommandArgs().put("resetlimit", Arrays.asList("[playername]"));
c.get("command.resetlimit.output.reseted", "&ePayment limits have been reset for: &2%playername%");
c.get("command.resetquesttotal.help.info", "Resets a player's done quest counter");
c.get("command.resetquesttotal.help.args", "[playername]/all");
Jobs.getGCManager().getCommandArgs().put("resetquesttotal", Arrays.asList("[playername]%%all"));
c.get("command.resetquesttotal.output.reseted", "&eDone quests have been reset for: &2%playername%");
c.get("command.resetquest.help.info", "Resets a player's quest");
c.get("command.resetquest.help.args", "[playername] [jobname]");
Jobs.getGCManager().getCommandArgs().put("resetquest", Arrays.asList("[playername]", "[jobname]"));

View File

@ -1999,6 +1999,24 @@ public abstract class JobsDAO {
}
}
public void resetDoneQuests() {
JobsConnection conn = getConnection();
if (conn == null)
return;
PreparedStatement prest = null;
try {
prest = conn.prepareStatement("UPDATE `" + DBTables.UsersTable.getTableName() + "` SET `" + UserTableFields.donequests.getCollumn() + "` = ?;");
prest.setInt(1, 0);
prest.execute();
} catch (SQLException e) {
e.printStackTrace();
} finally {
close(prest);
}
}
private void insertPlayer(JobsPlayer player) {
JobsConnection conn = getConnection();
if (conn == null)

View File

@ -466,8 +466,9 @@ public class JobsListener implements Listener {
Chunk from = event.getFrom().getChunk();
Chunk to = event.getTo().getChunk();
if (from != to)
if (from != to) {
plugin.getServer().getPluginManager().callEvent(new JobsChunkChangeEvent(event.getPlayer(), from, to));
}
}
@EventHandler(ignoreCancelled = true)

View File

@ -77,7 +77,7 @@ public final class JobsPayment14Listener implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onCook(BlockCookEvent event) {
if (!(event.getBlock().getType() != Material.CAMPFIRE) || campPlayers.isEmpty())
if (event.getBlock().getType() != Material.CAMPFIRE || campPlayers.isEmpty())
return;
if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))

View File

@ -26,7 +26,6 @@ import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import com.bgsoftware.wildstacker.api.enums.StackSplit;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -90,6 +89,7 @@ import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.permissions.PermissionAttachmentInfo;
import com.bgsoftware.wildstacker.api.enums.StackSplit;
import com.gamingmesh.jobs.ItemBoostManager;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
@ -128,7 +128,6 @@ import net.Zrips.CMILib.Container.CMILocation;
import net.Zrips.CMILib.Entities.CMIEntityType;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Version.Version;
public final class JobsPaymentListener implements Listener {
@ -1775,6 +1774,7 @@ public final class JobsPaymentListener implements Listener {
@EventHandler(ignoreCancelled = true)
public void onExplore(JobsChunkChangeEvent event) {
if (!Jobs.getExplore().isExploreEnabled())
return;

View File

@ -8,8 +8,8 @@ import com.gamingmesh.jobs.Jobs;
public class Listener1_9 implements Listener {
@EventHandler
public void onPlayerHandSwap(PlayerSwapHandItemsEvent event) {
Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId());
}
@EventHandler
public void onPlayerHandSwap(PlayerSwapHandItemsEvent event) {
Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId());
}
}