mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
parent
afb07a69d4
commit
1b818f5d05
@ -1,5 +1,8 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -11,6 +14,8 @@ import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
public class leave implements Cmd {
|
||||
|
||||
private Set<CommandSender> confirm = new HashSet<>();
|
||||
|
||||
@Override
|
||||
@JobCommand(800)
|
||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||
@ -28,15 +33,26 @@ public class leave implements Cmd {
|
||||
String jobName = args[0];
|
||||
Job job = Jobs.getJob(jobName);
|
||||
if (job == null) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getChatColor() + job.getName()));
|
||||
} else
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
return true;
|
||||
if (Jobs.getGCManager().EnableConfirmation) {
|
||||
if (!confirm.contains(pSender)) {
|
||||
confirm.add(pSender);
|
||||
org.bukkit.Bukkit.getScheduler().runTaskLater(plugin, () -> confirm.remove(pSender), 20 * Jobs.getGCManager().ConfirmExpiryTime);
|
||||
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]", jobName,
|
||||
"[time]", Jobs.getGCManager().ConfirmExpiryTime));
|
||||
return true;
|
||||
}
|
||||
confirm.remove(pSender);
|
||||
}
|
||||
|
||||
if (Jobs.getPlayerManager().leaveJob(jPlayer, job))
|
||||
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getChatColor() + job.getName()));
|
||||
else
|
||||
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -13,6 +15,8 @@ import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
public class leaveall implements Cmd {
|
||||
|
||||
private Set<CommandSender> confirm = new HashSet<>();
|
||||
|
||||
@Override
|
||||
@JobCommand(900)
|
||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||
@ -30,6 +34,16 @@ public class leaveall implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().EnableConfirmation) {
|
||||
if (!confirm.contains(pSender)) {
|
||||
confirm.add(pSender);
|
||||
org.bukkit.Bukkit.getScheduler().runTaskLater(plugin, () -> confirm.remove(pSender), 20 * Jobs.getGCManager().ConfirmExpiryTime);
|
||||
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]", Jobs.getGCManager().ConfirmExpiryTime));
|
||||
return true;
|
||||
}
|
||||
confirm.remove(pSender);
|
||||
}
|
||||
|
||||
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.success"));
|
||||
return true;
|
||||
|
@ -163,6 +163,9 @@ public class GeneralConfigManager {
|
||||
|
||||
private boolean ShowNewVersion;
|
||||
|
||||
public boolean EnableConfirmation;
|
||||
public int ConfirmExpiryTime;
|
||||
|
||||
public HashMap<String, List<String>> getCommandArgs() {
|
||||
return commandArgs;
|
||||
}
|
||||
@ -922,6 +925,11 @@ public class GeneralConfigManager {
|
||||
// c.addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost?");
|
||||
// useGlobalBoostScheduler = c.get("Schedule.Boost.Enable", false);
|
||||
|
||||
c.addComment("JobsLeave.EnableConfirmation", "Allows to confirm the /jobs leave and leaveall commands, to confirm the leave.");
|
||||
EnableConfirmation = c.get("JobsLeave.EnableConfirmation", false);
|
||||
c.addComment("JobsLeave.ConfirmExpiryTime", "Specify the confirm expiry time.", "Time in seconds.");
|
||||
ConfirmExpiryTime = c.get("JobsLeave.ConfirmExpiryTime", 10);
|
||||
|
||||
c.save();
|
||||
}
|
||||
|
||||
|
@ -438,10 +438,12 @@ public class LanguageManager {
|
||||
c.get("command.leave.help.args", "[oldplayerjob]");
|
||||
Jobs.getGCManager().commandArgs.put("leave", Arrays.asList("[oldplayerjob]"));
|
||||
c.get("command.leave.success", "You have left the job %jobname%.");
|
||||
c.get("command.leave.confirmationNeed", "&cAre you sure you want to leave from&e [jobname]&c job? Type the command again within&6 [time] seconds &cto confirm!");
|
||||
|
||||
c.get("command.leaveall.help.info", "Leave all your jobs.");
|
||||
c.get("command.leaveall.error.nojobs", "You do not have any jobs to leave!");
|
||||
c.get("command.leaveall.success", "You have left all your jobs.");
|
||||
c.get("command.leaveall.confirmationNeed", "&cAre you sure you want to leave from all jobs? Type the command again within&6 [time] seconds &cto confirm!");
|
||||
|
||||
c.get("command.explored.help.info", "Check who visited this chunk");
|
||||
c.get("command.explored.error.noexplore", "No one visited this chunk");
|
||||
|
Loading…
Reference in New Issue
Block a user