Skip to content

Commit

Permalink
Lynx対応
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyaPeyaPeyang committed Dec 22, 2020
1 parent fe051b3 commit 5622a52
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 37 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ml.peya.plugins</groupId>
<artifactId>PeyangGreatBanManager</artifactId>
<version>0.2a</version>
<version>1.0</version>

<build>
<plugins>
Expand Down
81 changes: 45 additions & 36 deletions src/main/java/ml/peya/plugins/commands/CommandBans.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
package ml.peya.plugins.commands;

import ml.peya.api.BanSection;
import ml.peya.plugins.PeyangGreatBanManager;
import ml.peya.plugins.utils.ErrorMessageSender;
import ml.peya.plugins.utils.MessageEngine;
import ml.peya.plugins.utils.PlayerUtils;
import ml.peya.plugins.utils.TimeParser;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
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.scheduler.BukkitRunnable;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.IntStream;
import ml.peya.api.*;
import ml.peya.plugins.*;
import ml.peya.plugins.utils.*;
import net.md_5.bungee.api.chat.*;
import org.bukkit.*;
import org.bukkit.command.*;
import org.bukkit.scheduler.*;

import java.text.*;
import java.util.*;
import java.util.stream.*;

public class CommandBans implements CommandExecutor
{
Expand Down Expand Up @@ -70,8 +60,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (page == 0)
page = 1;

boolean lynx = args[0].equals("-a");
UUID player;
if (args[0].equals("-a"))
if (lynx)
player = PlayerUtils.getPlayerAllowOffline(args[1]);
else
player = PlayerUtils.getPlayerAllowOffline(args[0]);
Expand All @@ -90,7 +81,7 @@ public void run()
{
ArrayList<BanSection> sections = PeyangGreatBanManager.getAPI().getBans(player);
int count = 0;
int start = 10 * (finalPage - 1);
int start = 5 * (finalPage - 1);

String x = MessageEngine.get(
"message.bans.nm",
Expand All @@ -102,13 +93,14 @@ public void run()
}}
);

sender.sendMessage(x); //prefix
if (!lynx)
sender.sendMessage(x); //prefix

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

if (sections.size() == 0)
return;
for (int i = 0; i < start + 10; i++)
for (int i = 0; i < start + 5; i++)
{
count++;
if (i < start)
Expand All @@ -128,19 +120,36 @@ public void run()
ChatColor.RESET + ChatColor.YELLOW.toString() + " unbanned " + format.format(section.unbanned());
String unbr = !section.isUnbanned() ? "": ChatColor.ITALIC.toString() + ChatColor.WHITE + " " + section.unBanReason() + " ";

sender.sendMessage(
ChatColor.GOLD.toString() + (i + 1) + ". " +
type +
banned +
reason +
by(section.bannedBy()) +
forS +
unb +
unbr +
(section.isUnbanned() ? by(section.unBannedBy()): "")
);
if (!lynx)
sender.sendMessage(
ChatColor.GOLD.toString() + (i + 1) + ". " +
type +
banned +
reason +
by(section.bannedBy()) +
forS +
unb +
unbr +
(section.isUnbanned() ? by(section.unBannedBy()): "")
);
else
sender.sendMessage(
String.format( //reasonΩcancelledΩactiveΩlengthMilSecondsΩbannedByΩbannedDate
"[Lynx] %sΩ%bΩ%bΩ%dΩ%sΩ%d",
(section.hasStaff() ? "": "[WATCHDOG] ") +
section.getReason().replace("Ω", "ω"),
false,
section.isUnbanned(),
section.expire() == null ? null: section.expire().getTime(),
player.toString(),
section.banned().getTime()
)
);
}

if (lynx)
return;

ComponentBuilder builder = new ComponentBuilder(finalPage != 1 ? ChatColor.GOLD + "[<<]": "");
if (finalPage != 1)
builder.event(new ClickEvent(
Expand Down

0 comments on commit 5622a52

Please sign in to comment.