click messages
This commit is contained in:
1 parent
71da6d8bbe
commit
d5625aa599
5 files changed
+83
-24
No files matched your search
@@ -31,7 +31,7 @@ public class CommandReportExecutor implements CommandExecutor {
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (commandLabel.equalsIgnoreCase("report")) {
|
||||
if (plugin.isLastReportInCoolDown(p, true)) {
|
||||
if (plugin.getLastReportInCoolDown(p, true) != -1) {
|
||||
p.sendMessage(
|
||||
Staff.getREPORT_PREFIX() + ChatColor.RED + "Vous avez déjà fait un report il y a moins de "
|
||||
+ cooldownMinute + " minutes.");
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package fr.nessar;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.nessar.Menu.EditReport;
|
||||
import fr.nessar.Menu.ReportList;
|
||||
import fr.nessar.Menu.StaffList;
|
||||
|
||||
@@ -49,9 +51,51 @@ public class CommandStaffExecutor implements CommandExecutor {
|
||||
p.openInventory(new ReportList(plugin, p, 1, false, false, false, false).getInventory());
|
||||
return true;
|
||||
}
|
||||
} else if (commandLabel.equalsIgnoreCase("staff") && args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("editreport")) {
|
||||
if (!p.hasPermission(PREFIX_PERMISSION + "editreport")) {
|
||||
p.sendMessage(ChatColor.RED + permissionErrMessage());
|
||||
return true;
|
||||
}
|
||||
int t;
|
||||
try {
|
||||
t = Integer.parseInt(args[1]);
|
||||
} catch (Exception e) {
|
||||
p.sendMessage(Staff.getREPORT_PREFIX() + ChatColor.RED + "Le report n'est pas correct.");
|
||||
return false;
|
||||
}
|
||||
if (t < 0 || plugin.getReports().size() - 1 < t) {
|
||||
p.sendMessage(Staff.getREPORT_PREFIX() + ChatColor.RED + "Le report n'existe pas.");
|
||||
return false;
|
||||
}
|
||||
p.openInventory(new EditReport(plugin.getReports().get(t), t, plugin).getInventory());
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("cancelcooldown")) {
|
||||
if (!p.hasPermission(PREFIX_PERMISSION + "cancelcooldown")) {
|
||||
p.sendMessage(ChatColor.RED + permissionErrMessage());
|
||||
return true;
|
||||
}
|
||||
Player target = Bukkit.getPlayer(args[1]);
|
||||
if (target == null) {
|
||||
p.sendMessage(
|
||||
Staff.getREPORT_PREFIX() + ChatColor.RED + "Le joueur " + args[1] + " est introuvable.");
|
||||
return true;
|
||||
}
|
||||
int indexReport = plugin.getLastReportInCoolDown(target, true);
|
||||
int indexTicket = plugin.getLastReportInCoolDown(target, false);
|
||||
if (indexReport == -1 && indexTicket == -1) {
|
||||
p.sendMessage(Staff.getSTAFF_PREFIX() + ChatColor.RED + "Le joueur n'est pas en cooldown.");
|
||||
return true;
|
||||
}
|
||||
if (indexReport != -1)
|
||||
plugin.getReports().get(indexReport).setIgnoreCooldown(true);
|
||||
if (indexTicket != -1)
|
||||
plugin.getReports().get(indexTicket).setIgnoreCooldown(true);
|
||||
p.sendMessage(Staff.getSTAFF_PREFIX() + ChatColor.GREEN + "Le joueur n'est plus en cooldown.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
p.sendMessage(Staff.getSTAFF_PREFIX() + ChatColor.RED + "Mauvais usage de la commande."
|
||||
+ args.length);
|
||||
p.sendMessage(Staff.getSTAFF_PREFIX() + ChatColor.RED + "Mauvais usage de la commande." + args.length);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class CommandTicketExecutor implements CommandExecutor {
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (commandLabel.equalsIgnoreCase("ticket") && args.length >= 1) {
|
||||
if (plugin.isLastReportInCoolDown(p, false)) {
|
||||
if (plugin.getLastReportInCoolDown(p, false) != -1) {
|
||||
p.sendMessage(
|
||||
Staff.getREPORT_PREFIX() + ChatColor.RED + "Vous avez déjà fait un ticket il y a moins de "
|
||||
+ cooldownMinute + " minutes.");
|
||||
|
||||
+15
-12
@@ -88,27 +88,26 @@ public class Report {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TextComponent getChatMessage(int index) {
|
||||
public TextComponent[] getChatMessage(String before, int index) {
|
||||
String loreOneString = "";
|
||||
if (this.isReport())
|
||||
loreOneString += ChatColor.RED + "Report " + ChatColor.GRAY + "#" + index;
|
||||
else
|
||||
loreOneString += ChatColor.BLUE + "Ticket " + ChatColor.GRAY + "#" + index;
|
||||
for (String lore : this.getLore()) {
|
||||
loreOneString += lore + "\n";
|
||||
loreOneString += "\n" + lore;
|
||||
}
|
||||
TextComponent title = new TextComponent(before);
|
||||
TextComponent message = new TextComponent(
|
||||
(this.isTicket() ? ChatColor.BLUE + "Ticket " : ChatColor.RED + "Report ") + ChatColor.GRAY + "#"
|
||||
+ index);
|
||||
message.setHoverEvent(
|
||||
new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(loreOneString).create()));
|
||||
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "staff editreport " + index));
|
||||
return message;
|
||||
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/staff editreport " + index));
|
||||
TextComponent[] ret = { title, message };
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ["",{"text":"[","color":"gray"},{"text":"Report","color":"gold"},{"text":"]","color":"gray"},{"text":"
|
||||
// Nouveau ","color":"green"},{"text":"Report
|
||||
// ","color":"red","clickEvent":{"action":"run_command","value":"editreport
|
||||
// 1"},"hoverEvent":{"action":"show_text","value":"testing new
|
||||
// testnewnewtest"}},{"text":"#1","color":"gray","clickEvent":{"action":"run_command","value":"editreport
|
||||
// 1"},"hoverEvent":{"action":"show_text","value":"testing new
|
||||
// testnewnewtest"}}]
|
||||
public Report(Player reporter, Player reported, String reportReason, boolean report) {
|
||||
this(reporter, reported, reportReason, new Date().getTime(), report, ReportStatus.WAITING);
|
||||
}
|
||||
@@ -125,6 +124,10 @@ public class Report {
|
||||
return this.ignoreCoolDown;
|
||||
}
|
||||
|
||||
public void setIgnoreCooldown(boolean newStatus) {
|
||||
this.ignoreCoolDown = newStatus;
|
||||
}
|
||||
|
||||
public ReportStatus getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
@@ -150,7 +153,7 @@ public class Report {
|
||||
}
|
||||
|
||||
public boolean isInCooldown() {
|
||||
return !this.ignoreCoolDown && new Date().getTime() > this.reportTime + cooldownTime;
|
||||
return !this.ignoreCoolDown && new Date().getTime() < this.reportTime + cooldownTime;
|
||||
}
|
||||
|
||||
public String getReportReason() {
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import fr.nessar.Menu.Freeze;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
public class Staff extends JavaPlugin {
|
||||
@@ -131,6 +132,14 @@ public class Staff extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyStaff(TextComponent[] message) {
|
||||
for (OfflinePlayer offlinePlayer : staffList) {
|
||||
Player isOnline = Bukkit.getPlayer(offlinePlayer.getUniqueId());
|
||||
if (isOnline != null)
|
||||
isOnline.spigot().sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getNumberPlusZero(int time) {
|
||||
if (time < 10) {
|
||||
return "0" + time;
|
||||
@@ -238,8 +247,8 @@ public class Staff extends JavaPlugin {
|
||||
}
|
||||
reporter.sendMessage(Staff.getREPORT_PREFIX() + ChatColor.GREEN + "Votre report a bien été pris en compte !");
|
||||
this.reports.add(freshReport);
|
||||
this.notifyStaff(Staff.getREPORT_PREFIX() + ChatColor.GREEN + "Nouveau "
|
||||
+ freshReport.getChatMessage(this.reports.size() - 1)); // TODO
|
||||
this.notifyStaff(freshReport.getChatMessage(Staff.getREPORT_PREFIX() + ChatColor.GREEN + "Nouveau ",
|
||||
this.reports.size() - 1)); // TODO
|
||||
}
|
||||
|
||||
public void updateReport(int indexReportToUpdate, Report newReport, Player updater) {
|
||||
@@ -256,7 +265,9 @@ public class Staff extends JavaPlugin {
|
||||
this.reports.set(indexReportToUpdate, newReport);
|
||||
Player reporter = Bukkit.getPlayer(UUID.fromString(newReport.getReporter().getUniqueId()));
|
||||
if (reporter != null)
|
||||
reporter.sendMessage(Staff.getREPORT_PREFIX() + "Votre report a été actualisé"); // TODO
|
||||
reporter.spigot()
|
||||
.sendMessage(newReport.getChatMessage(Staff.getREPORT_PREFIX() + "Votre report a été actualisé: ",
|
||||
this.reports.size() - 1)); // TODO
|
||||
}
|
||||
|
||||
public void newTicket(Player reporter, String reportReason) {
|
||||
@@ -271,8 +282,8 @@ public class Staff extends JavaPlugin {
|
||||
}
|
||||
reporter.sendMessage(Staff.getREPORT_PREFIX() + ChatColor.GREEN + "Votre ticket a bien été pris en compte !");
|
||||
this.reports.add(freshTicket);
|
||||
this.notifyStaff(Staff.getREPORT_PREFIX() + ChatColor.GREEN + "Nouveau "
|
||||
+ freshTicket.getChatMessage((this.reports.size() - 1)).toLegacyText()); // TODO
|
||||
this.notifyStaff(freshTicket.getChatMessage(Staff.getREPORT_PREFIX() + ChatColor.GREEN + "Nouveau ",
|
||||
this.reports.size() - 1)); // TODO
|
||||
}
|
||||
|
||||
public static String getUrlDB() {
|
||||
@@ -283,13 +294,14 @@ public class Staff extends JavaPlugin {
|
||||
return this.reports.size();
|
||||
}
|
||||
|
||||
public boolean isLastReportInCoolDown(Player p, boolean report) {
|
||||
public int getLastReportInCoolDown(Player p, boolean report) {
|
||||
for (int i = reports.size() - 1; i > 0; i--) {
|
||||
if (reports.get(i).getReporter().getUniqueId().equals(p.getUniqueId().toString())
|
||||
&& reports.get(i).isReport() == report)
|
||||
return reports.get(i).isInCooldown();
|
||||
if (reports.get(i).isInCooldown())
|
||||
return i;
|
||||
}
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getNumberAtEndStr(String analyze) {
|
||||
|
||||
Reference in new issue
Block a user