mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 15:03:36 +01:00
Confirmation for leave commands should work
This commit is contained in:
parent
d4a2add86e
commit
0cef1e8dfd
@ -1,8 +1,5 @@
|
|||||||
package com.gamingmesh.jobs.commands.list;
|
package com.gamingmesh.jobs.commands.list;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -11,11 +8,10 @@ import com.gamingmesh.jobs.commands.Cmd;
|
|||||||
import com.gamingmesh.jobs.commands.JobCommand;
|
import com.gamingmesh.jobs.commands.JobCommand;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
import com.gamingmesh.jobs.stuff.Util;
|
||||||
|
|
||||||
public class leave implements Cmd {
|
public class leave implements Cmd {
|
||||||
|
|
||||||
private Set<CommandSender> confirm = new HashSet<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@JobCommand(800)
|
@JobCommand(800)
|
||||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||||
@ -28,7 +24,6 @@ public class leave implements Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player pSender = (Player) sender;
|
Player pSender = (Player) sender;
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
|
|
||||||
|
|
||||||
String jobName = args[0];
|
String jobName = args[0];
|
||||||
Job job = Jobs.getJob(jobName);
|
Job job = Jobs.getJob(jobName);
|
||||||
@ -38,16 +33,24 @@ public class leave implements Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Jobs.getGCManager().EnableConfirmation) {
|
if (Jobs.getGCManager().EnableConfirmation) {
|
||||||
if (!confirm.contains(pSender)) {
|
String uuid = pSender.getUniqueId().toString();
|
||||||
confirm.add(pSender);
|
|
||||||
org.bukkit.Bukkit.getScheduler().runTaskLater(plugin, () -> confirm.remove(pSender), 20 * Jobs.getGCManager().ConfirmExpiryTime);
|
if (!Util.confirmLeave.contains(uuid)) {
|
||||||
|
Util.confirmLeave.add(uuid);
|
||||||
|
|
||||||
|
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.confirmLeave.remove(uuid),
|
||||||
|
20 * Jobs.getGCManager().ConfirmExpiryTime);
|
||||||
|
|
||||||
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]", jobName,
|
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]", jobName,
|
||||||
"[time]", Jobs.getGCManager().ConfirmExpiryTime));
|
"[time]", Jobs.getGCManager().ConfirmExpiryTime));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
confirm.remove(pSender);
|
|
||||||
|
Util.confirmLeave.remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
|
||||||
|
|
||||||
if (Jobs.getPlayerManager().leaveJob(jPlayer, job))
|
if (Jobs.getPlayerManager().leaveJob(jPlayer, job))
|
||||||
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getChatColor() + job.getName()));
|
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getChatColor() + job.getName()));
|
||||||
else
|
else
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.gamingmesh.jobs.commands.list;
|
package com.gamingmesh.jobs.commands.list;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -12,11 +10,10 @@ import com.gamingmesh.jobs.commands.Cmd;
|
|||||||
import com.gamingmesh.jobs.commands.JobCommand;
|
import com.gamingmesh.jobs.commands.JobCommand;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
import com.gamingmesh.jobs.stuff.Util;
|
||||||
|
|
||||||
public class leaveall implements Cmd {
|
public class leaveall implements Cmd {
|
||||||
|
|
||||||
private Set<CommandSender> confirm = new HashSet<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@JobCommand(900)
|
@JobCommand(900)
|
||||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||||
@ -29,19 +26,26 @@ public class leaveall implements Cmd {
|
|||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
|
||||||
|
|
||||||
List<JobProgression> jobs = jPlayer.getJobProgression();
|
List<JobProgression> jobs = jPlayer.getJobProgression();
|
||||||
if (jobs.size() == 0) {
|
if (jobs.isEmpty()) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.error.nojobs"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.error.nojobs"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Jobs.getGCManager().EnableConfirmation) {
|
if (Jobs.getGCManager().EnableConfirmation) {
|
||||||
if (!confirm.contains(pSender)) {
|
String uuid = pSender.getUniqueId().toString();
|
||||||
confirm.add(pSender);
|
|
||||||
org.bukkit.Bukkit.getScheduler().runTaskLater(plugin, () -> confirm.remove(pSender), 20 * Jobs.getGCManager().ConfirmExpiryTime);
|
if (!Util.confirmLeave.contains(uuid)) {
|
||||||
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]", Jobs.getGCManager().ConfirmExpiryTime));
|
Util.confirmLeave.add(uuid);
|
||||||
|
|
||||||
|
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.confirmLeave.remove(uuid),
|
||||||
|
20 * Jobs.getGCManager().ConfirmExpiryTime);
|
||||||
|
|
||||||
|
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]",
|
||||||
|
Jobs.getGCManager().ConfirmExpiryTime));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
confirm.remove(pSender);
|
|
||||||
|
Util.confirmLeave.remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
|
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
|
||||||
|
@ -3,6 +3,7 @@ package com.gamingmesh.jobs.stuff;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@ -23,6 +24,7 @@ import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
|||||||
public class Util {
|
public class Util {
|
||||||
|
|
||||||
private static HashMap<UUID, String> jobsEditorMap = new HashMap<>();
|
private static HashMap<UUID, String> jobsEditorMap = new HashMap<>();
|
||||||
|
public static List<String> confirmLeave = new ArrayList<>();
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static ItemStack setEntityType(ItemStack is, EntityType type) throws IllegalArgumentException {
|
public static ItemStack setEntityType(ItemStack is, EntityType type) throws IllegalArgumentException {
|
||||||
|
@ -370,12 +370,16 @@ command:
|
|||||||
help:
|
help:
|
||||||
info: 'Elhagyja a megadott munkát.'
|
info: 'Elhagyja a megadott munkát.'
|
||||||
args: '[jobname]'
|
args: '[jobname]'
|
||||||
|
confirmationNeed: '&cBiztos vagy benne, hogy elhagyod a(z)&e [jobname]&c munkát? Írd be a parancsot újra&6 [time]
|
||||||
|
másodpercen belül, &chogy megerősítsd!'
|
||||||
success: '&cSikeresen elhagytad a(z)&7 %jobname%&c munkát!'
|
success: '&cSikeresen elhagytad a(z)&7 %jobname%&c munkát!'
|
||||||
leaveall:
|
leaveall:
|
||||||
help:
|
help:
|
||||||
info: 'Elhagyja az összes jelenlegi munkát.'
|
info: 'Elhagyja az összes jelenlegi munkát.'
|
||||||
error:
|
error:
|
||||||
nojobs: '&cNincs egyetlen munkád sem!'
|
nojobs: '&cNincs egyetlen munkád sem!'
|
||||||
|
confirmationNeed: '&cBiztos vagy benne, hogy elhagyod az összes munkát? Írd be a parancsot újra&6 [time]
|
||||||
|
másodpercen belül, &chogy megerősítsd!'
|
||||||
success: '&cElhagytad az összes munkát!'
|
success: '&cElhagytad az összes munkát!'
|
||||||
explored:
|
explored:
|
||||||
help:
|
help:
|
||||||
|
Loading…
Reference in New Issue
Block a user