mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
New command as resetquesttotal for reseting done quest counter
This commit is contained in:
parent
03de00be6e
commit
f53a32e35a
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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]"));
|
||||
|
@ -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)
|
||||
|
@ -466,9 +466,10 @@ 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)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
|
@ -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()))
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user