Some things
Some fixes and @ someone are days old. The FTopComomand is weeks old.
This commit is contained in:
parent
91e44c20c2
commit
4340a50789
5 changed files with 411 additions and 420 deletions
5
pom.xml
5
pom.xml
|
@ -51,11 +51,6 @@
|
||||||
<include>org.javassist:javassist</include>
|
<include>org.javassist:javassist</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<pluginExecution>
|
|
||||||
<action>
|
|
||||||
<execute />
|
|
||||||
</action>
|
|
||||||
</pluginExecution>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
|
@ -1,5 +1,32 @@
|
||||||
package buttondevteam.chat;
|
package buttondevteam.chat;
|
||||||
|
|
||||||
|
import buttondevteam.chat.commands.UnlolCommand;
|
||||||
|
import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
|
||||||
|
import buttondevteam.chat.formatting.ChatFormatter;
|
||||||
|
import buttondevteam.chat.formatting.TellrawEvent;
|
||||||
|
import buttondevteam.chat.formatting.TellrawPart;
|
||||||
|
import buttondevteam.chat.formatting.TellrawSerializer;
|
||||||
|
import buttondevteam.chat.listener.PlayerListener;
|
||||||
|
import buttondevteam.lib.TBMCChatEvent;
|
||||||
|
import buttondevteam.lib.TBMCChatEventBase;
|
||||||
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
|
import buttondevteam.lib.chat.*;
|
||||||
|
import buttondevteam.lib.player.ChromaGamerBase;
|
||||||
|
import buttondevteam.lib.player.TBMCPlayer;
|
||||||
|
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||||
|
import lombok.val;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -8,33 +35,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scoreboard.Objective;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
|
|
||||||
import buttondevteam.chat.commands.UnlolCommand;
|
|
||||||
import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
|
|
||||||
import buttondevteam.chat.formatting.*;
|
|
||||||
import buttondevteam.lib.TBMCChatEvent;
|
|
||||||
import buttondevteam.lib.TBMCChatEventBase;
|
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
|
||||||
import buttondevteam.lib.chat.Channel;
|
|
||||||
import buttondevteam.lib.chat.TellrawSerializableEnum;
|
|
||||||
import buttondevteam.lib.player.TBMCPlayer;
|
|
||||||
import buttondevteam.lib.player.TBMCPlayerBase;
|
|
||||||
import lombok.val;
|
|
||||||
import buttondevteam.chat.listener.PlayerListener;
|
|
||||||
import buttondevteam.lib.chat.*;
|
|
||||||
|
|
||||||
public class ChatProcessing {
|
public class ChatProcessing {
|
||||||
private static final Pattern NULL_MENTION_PATTERN = Pattern.compile("null");
|
private static final Pattern NULL_MENTION_PATTERN = Pattern.compile("null");
|
||||||
private static final Pattern CYAN_PATTERN = Pattern.compile("cyan");
|
private static final Pattern CYAN_PATTERN = Pattern.compile("cyan");
|
||||||
|
@ -43,13 +43,14 @@ public class ChatProcessing {
|
||||||
private static final Pattern HASHTAG_PATTERN = Pattern.compile("#(\\w+)");
|
private static final Pattern HASHTAG_PATTERN = Pattern.compile("#(\\w+)");
|
||||||
private static final Pattern URL_PATTERN = Pattern.compile("(http[\\w:/?=$\\-_.+!*'(),]+)");
|
private static final Pattern URL_PATTERN = Pattern.compile("(http[\\w:/?=$\\-_.+!*'(),]+)");
|
||||||
private static final Pattern ENTIRE_MESSAGE_PATTERN = Pattern.compile(".+");
|
private static final Pattern ENTIRE_MESSAGE_PATTERN = Pattern.compile(".+");
|
||||||
private static final Pattern UNDERLINED_PATTERN = Pattern.compile("\\_");
|
private static final Pattern UNDERLINED_PATTERN = Pattern.compile("_");
|
||||||
private static final Pattern ITALIC_PATTERN = Pattern.compile("\\*");
|
private static final Pattern ITALIC_PATTERN = Pattern.compile("\\*");
|
||||||
private static final Pattern BOLD_PATTERN = Pattern.compile("\\*\\*");
|
private static final Pattern BOLD_PATTERN = Pattern.compile("\\*\\*");
|
||||||
private static final Pattern CODE_PATTERN = Pattern.compile("`");
|
private static final Pattern CODE_PATTERN = Pattern.compile("`");
|
||||||
private static final Pattern MASKED_LINK_PATTERN = Pattern.compile("\\[([^\\[\\]])\\]\\(([^\\(\\)])\\)");
|
private static final Pattern MASKED_LINK_PATTERN = Pattern.compile("\\[([^\\[\\]])\\]\\(([^()])\\)");
|
||||||
private static final Color[] RainbowPresserColors = new Color[] { Color.Red, Color.Gold, Color.Yellow, Color.Green,
|
private static final Pattern SOMEONE_PATTERN = Pattern.compile("@someone"); //TODO
|
||||||
Color.Blue, Color.DarkPurple };
|
private static final Color[] RainbowPresserColors = new Color[]{Color.Red, Color.Gold, Color.Yellow, Color.Green,
|
||||||
|
Color.Blue, Color.DarkPurple};
|
||||||
private static boolean pingedconsole = false;
|
private static boolean pingedconsole = false;
|
||||||
|
|
||||||
public static final ChatFormatter ESCAPE_FORMATTER = ChatFormatter.builder().regex(ESCAPE_PATTERN).build();
|
public static final ChatFormatter ESCAPE_FORMATTER = ChatFormatter.builder().regex(ESCAPE_PATTERN).build();
|
||||||
|
@ -183,8 +184,7 @@ public class ChatProcessing {
|
||||||
}
|
}
|
||||||
|
|
||||||
static String toJson(TellrawPart json) {
|
static String toJson(TellrawPart json) {
|
||||||
String jsonstr = gson.toJson(json);
|
return gson.toJson(json);
|
||||||
return jsonstr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static TellrawPart createTellraw(CommandSender sender, String message, Player player, ChatPlayer mp,
|
static TellrawPart createTellraw(CommandSender sender, String message, Player player, ChatPlayer mp,
|
||||||
|
@ -202,49 +202,11 @@ public class ChatProcessing {
|
||||||
+ "Copy message").setColor(Color.Blue)))
|
+ "Copy message").setColor(Color.Blue)))
|
||||||
.setClickEvent(TellrawEvent.create(TellrawEvent.ClickAction.SUGGEST_COMMAND, message)));
|
.setClickEvent(TellrawEvent.create(TellrawEvent.ClickAction.SUGGEST_COMMAND, message)));
|
||||||
json.addExtra(new TellrawPart(" <"));
|
json.addExtra(new TellrawPart(" <"));
|
||||||
json.addExtra(
|
TellrawPart hovertp = new TellrawPart("");
|
||||||
new TellrawPart(
|
if (mp != null)
|
||||||
getSenderName(
|
hovertp.addExtra(new TellrawPart(mp.getInfo(ChromaGamerBase.InfoTarget.MCHover)));
|
||||||
sender, player))
|
json.addExtra(new TellrawPart(getSenderName(sender, player))
|
||||||
.setHoverEvent(
|
.setHoverEvent(TellrawEvent.create(TellrawEvent.HoverAction.SHOW_TEXT, hovertp)));
|
||||||
TellrawEvent
|
|
||||||
.create(TellrawEvent.HoverAction.SHOW_TEXT,
|
|
||||||
new TellrawPart("")
|
|
||||||
.addExtra(new TellrawPart(String.format(
|
|
||||||
"Flair: %s",
|
|
||||||
(mp != null ? mp.GetFormattedFlair()
|
|
||||||
: "-"))))
|
|
||||||
.addExtra(new TellrawPart(String.format(
|
|
||||||
"\nPlayername: %s\n",
|
|
||||||
(player != null ? player.getName()
|
|
||||||
: sender.getName())))
|
|
||||||
.setColor(Color.Aqua))
|
|
||||||
.addExtra(new TellrawPart(String.format(
|
|
||||||
"World: %s\n",
|
|
||||||
(player != null
|
|
||||||
? player.getWorld().getName()
|
|
||||||
: "-"))))
|
|
||||||
.addExtra(new TellrawPart(String.format(
|
|
||||||
"Respect: %s%s%s",
|
|
||||||
(mp != null ? (mp.FCount().get()
|
|
||||||
/ (double) mp.FDeaths().get())
|
|
||||||
: "Infinite"),
|
|
||||||
(mp != null
|
|
||||||
&& mp.UserName().get() != null
|
|
||||||
&& !mp.UserName().get()
|
|
||||||
.isEmpty()
|
|
||||||
? "\nUserName: "
|
|
||||||
+ mp.UserName()
|
|
||||||
.get()
|
|
||||||
: ""),
|
|
||||||
(mp != null && mp.PlayerName().get()
|
|
||||||
.equals("\nAlpha_Bacca44")
|
|
||||||
? "\nDeaths: "
|
|
||||||
+ PlayerListener.AlphaDeaths
|
|
||||||
: ""))))
|
|
||||||
.addExtra(new TellrawPart(
|
|
||||||
"\nFor more, do /u info "
|
|
||||||
+ sender.getName())))));
|
|
||||||
json.addExtra(new TellrawPart("> "));
|
json.addExtra(new TellrawPart("> "));
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
@ -284,9 +246,8 @@ public class ChatProcessing {
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getChannelID(Channel channel, CommandSender sender) {
|
static String getChannelID(Channel channel, CommandSender sender) {
|
||||||
final String channelidentifier = ("[" + (sender instanceof IDiscordSender ? "d|" : "") + channel.DisplayName)
|
return ("[" + (sender instanceof IDiscordSender ? "§bD§r|" : "") + channel.DisplayName)
|
||||||
+ "]";
|
+ "]";
|
||||||
return channelidentifier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ArrayList<ChatFormatter> addFormatters(Color colormode) {
|
static ArrayList<ChatFormatter> addFormatters(Color colormode) {
|
||||||
|
@ -368,7 +329,7 @@ public class ChatProcessing {
|
||||||
|
|
||||||
String msg = message.toLowerCase();
|
String msg = message.toLowerCase();
|
||||||
val lld = new UnlolCommand.LastlolData(sender, event, System.nanoTime());
|
val lld = new UnlolCommand.LastlolData(sender, event, System.nanoTime());
|
||||||
boolean add = false;
|
boolean add;
|
||||||
if (add = msg.contains("lol"))
|
if (add = msg.contains("lol"))
|
||||||
lld.setLolornot(true);
|
lld.setLolornot(true);
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1,9 +1,28 @@
|
||||||
package buttondevteam.chat;
|
package buttondevteam.chat;
|
||||||
|
|
||||||
|
import buttondevteam.chat.commands.YeehawCommand;
|
||||||
|
import buttondevteam.chat.commands.ucmds.TownColorCommand;
|
||||||
|
import buttondevteam.chat.listener.PlayerListener;
|
||||||
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
|
import buttondevteam.lib.chat.Channel;
|
||||||
|
import buttondevteam.lib.chat.Channel.RecipientTestResult;
|
||||||
|
import buttondevteam.lib.chat.Color;
|
||||||
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
|
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
|
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||||
|
import com.palmergames.bukkit.towny.object.Nation;
|
||||||
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||||
|
import lombok.val;
|
||||||
import net.milkbowl.vault.chat.Chat;
|
import net.milkbowl.vault.chat.Chat;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
@ -17,45 +36,15 @@ import org.dynmap.towny.DynmapTownyPlugin;
|
||||||
import org.htmlcleaner.HtmlCleaner;
|
import org.htmlcleaner.HtmlCleaner;
|
||||||
import org.htmlcleaner.TagNode;
|
import org.htmlcleaner.TagNode;
|
||||||
|
|
||||||
import buttondevteam.chat.commands.YeehawCommand;
|
import java.io.File;
|
||||||
import buttondevteam.chat.commands.ucmds.TownColorCommand;
|
import java.io.IOException;
|
||||||
import buttondevteam.chat.listener.PlayerListener;
|
import java.io.InputStream;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
|
||||||
import buttondevteam.lib.chat.Channel;
|
|
||||||
import buttondevteam.lib.chat.Color;
|
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
|
||||||
import buttondevteam.lib.chat.Channel.RecipientTestResult;
|
|
||||||
import buttondevteam.lib.player.TBMCPlayerBase;
|
|
||||||
import lombok.val;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.object.Nation;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
|
||||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.lang.String;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -120,9 +109,8 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
setTownColor(dtp, entry.getKey(), entry.getValue());
|
setTownColor(dtp, entry.getKey(), entry.getValue());
|
||||||
});
|
});
|
||||||
|
|
||||||
setupChat();
|
if (!setupChat() || !setupEconomy() || !setupPermissions())
|
||||||
setupEconomy();
|
getLogger().warning("Failed to set up chat or economy or permissions!");
|
||||||
setupPermissions();
|
|
||||||
|
|
||||||
new Thread(this::FlairGetterThreadMethod).start();
|
new Thread(this::FlairGetterThreadMethod).start();
|
||||||
new Thread(new AnnouncerThread()).start();
|
new Thread(new AnnouncerThread()).start();
|
||||||
|
@ -296,17 +284,18 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
yc.load(file);
|
yc.load(file);
|
||||||
PlayerListener.NotificationSound = yc.getString("notificationsound");
|
PlayerListener.NotificationSound = yc.getString("notificationsound");
|
||||||
PlayerListener.NotificationPitch = yc.getDouble("notificationpitch");
|
PlayerListener.NotificationPitch = yc.getDouble("notificationpitch");
|
||||||
AnnounceTime = yc.getInt("announcetime");
|
AnnounceTime = yc.getInt("announcetime", 15 * 60 * 1000);
|
||||||
AnnounceMessages.addAll(yc.getStringList("announcements"));
|
AnnounceMessages.addAll(yc.getStringList("announcements"));
|
||||||
PlayerListener.AlphaDeaths = yc.getInt("alphadeaths");
|
PlayerListener.AlphaDeaths = yc.getInt("alphadeaths");
|
||||||
val cs = yc.getConfigurationSection("towncolors");
|
val cs = yc.getConfigurationSection("towncolors");
|
||||||
if (cs != null)
|
if (cs != null)
|
||||||
TownColors.putAll(cs.getValues(true).entrySet().stream()
|
TownColors.putAll(cs.getValues(true).entrySet().stream()
|
||||||
.collect(Collectors.toMap(k -> k.getKey(), v -> ((List<String>) v.getValue()).stream()
|
.collect(Collectors.toMap(Map.Entry::getKey, v -> ((List<String>) v.getValue()).stream()
|
||||||
.map(c -> Color.valueOf(c)).toArray(Color[]::new))));
|
.map(Color::valueOf).toArray(Color[]::new))));
|
||||||
TownColorCommand.ColorCount = (byte) yc.getInt("towncolorcount", 1);
|
TownColorCommand.ColorCount = (byte) yc.getInt("towncolorcount", 1);
|
||||||
}
|
|
||||||
PluginMain.Instance.getLogger().info("Loaded files!");
|
PluginMain.Instance.getLogger().info("Loaded files!");
|
||||||
|
} else
|
||||||
|
PluginMain.Instance.getLogger().info("No files to load, first run probably.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
TBMCCoreAPI.SendException("Error while loading chat files!", e);
|
TBMCCoreAPI.SendException("Error while loading chat files!", e);
|
||||||
}
|
}
|
||||||
|
@ -323,7 +312,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
yc.set("announcements", AnnounceMessages);
|
yc.set("announcements", AnnounceMessages);
|
||||||
yc.set("alphadeaths", PlayerListener.AlphaDeaths);
|
yc.set("alphadeaths", PlayerListener.AlphaDeaths);
|
||||||
yc.createSection("towncolors", TownColors.entrySet().stream().collect(Collectors.toMap(k -> k.getKey(),
|
yc.createSection("towncolors", TownColors.entrySet().stream().collect(Collectors.toMap(k -> k.getKey(),
|
||||||
v -> Arrays.stream(v.getValue()).map(c -> c.toString()).toArray(String[]::new))));
|
v -> Arrays.stream(v.getValue()).map(Enum::toString).toArray(String[]::new))));
|
||||||
yc.set("towncolorcount", TownColorCommand.ColorCount);
|
yc.set("towncolorcount", TownColorCommand.ColorCount);
|
||||||
yc.save(file);
|
yc.save(file);
|
||||||
PluginMain.Instance.getLogger().info("Saved files!");
|
PluginMain.Instance.getLogger().info("Saved files!");
|
||||||
|
|
43
src/main/java/buttondevteam/chat/commands/FTopCommand.java
Normal file
43
src/main/java/buttondevteam/chat/commands/FTopCommand.java
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package buttondevteam.chat.commands;
|
||||||
|
|
||||||
|
import buttondevteam.chat.ChatPlayer;
|
||||||
|
import buttondevteam.lib.chat.CommandClass;
|
||||||
|
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||||
|
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@CommandClass
|
||||||
|
public class FTopCommand extends TBMCCommandBase {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] GetHelpText(String arg0) {
|
||||||
|
return new String[]{ //
|
||||||
|
"§6---- F Top ----", //
|
||||||
|
"Shows the respect leaderboard" //
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private final File playerdir = new File(TBMCPlayerBase.TBMC_PLAYERS_DIR);
|
||||||
|
private ChatPlayer[] cached;
|
||||||
|
private long lastcache = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean OnCommand(CommandSender arg0, String arg1, String[] arg2) {
|
||||||
|
if (cached == null || lastcache < System.nanoTime() - 60000000000L) { // 1m - (no guarantees of nanoTime's relation to 0, so we need the null check too)
|
||||||
|
cached = Arrays.stream(playerdir.listFiles())
|
||||||
|
.map(f -> TBMCPlayerBase.getPlayer(
|
||||||
|
UUID.fromString(f.getName().substring(0, f.getName().length() - 4)), ChatPlayer.class))
|
||||||
|
.sorted((cp1, cp2) -> Float.compare((float) cp2.FCount().get() / (float) cp2.FDeaths().get(),
|
||||||
|
(float) cp1.FCount().get() / (float) cp1.FDeaths().get()))
|
||||||
|
.toArray(ChatPlayer[]::new); // TODO: Properly implement getting all players
|
||||||
|
lastcache = System.nanoTime();
|
||||||
|
}
|
||||||
|
Arrays.stream(cached).limit(10);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,37 +1,40 @@
|
||||||
package buttondevteam.chat.listener;
|
package buttondevteam.chat.listener;
|
||||||
|
|
||||||
import java.util.*;
|
import buttondevteam.chat.ChatPlayer;
|
||||||
import java.util.Map.Entry;
|
import buttondevteam.chat.ChatProcessing;
|
||||||
import java.util.function.Consumer;
|
import buttondevteam.chat.PluginMain;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.*;
|
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.event.player.*;
|
|
||||||
import org.bukkit.event.server.ServerCommandEvent;
|
|
||||||
import org.bukkit.help.HelpTopic;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import buttondevteam.chat.*;
|
|
||||||
import buttondevteam.lib.TBMCChatEvent;
|
import buttondevteam.lib.TBMCChatEvent;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.chat.Channel;
|
import buttondevteam.lib.chat.Channel;
|
||||||
import buttondevteam.lib.chat.ChatChannelRegisterEvent;
|
import buttondevteam.lib.chat.ChatChannelRegisterEvent;
|
||||||
import buttondevteam.lib.chat.ChatRoom;
|
import buttondevteam.lib.chat.ChatRoom;
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
|
import buttondevteam.lib.player.ChromaGamerBase.InfoTarget;
|
||||||
import buttondevteam.lib.player.TBMCPlayer;
|
import buttondevteam.lib.player.TBMCPlayer;
|
||||||
import buttondevteam.lib.player.TBMCPlayerGetInfoEvent;
|
import buttondevteam.lib.player.TBMCPlayerGetInfoEvent;
|
||||||
import net.ess3.api.events.NickChangeEvent;
|
|
||||||
import buttondevteam.lib.player.ChromaGamerBase.InfoTarget;
|
|
||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.vexsoftware.votifier.model.Vote;
|
import com.vexsoftware.votifier.model.Vote;
|
||||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||||
|
import net.ess3.api.events.NickChangeEvent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.player.*;
|
||||||
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
|
import org.bukkit.help.HelpTopic;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
/**
|
/**
|
||||||
|
@ -199,7 +202,7 @@ public class PlayerListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void onVotifierEvent(VotifierEvent event) {
|
public void onVotifierEvent(VotifierEvent event) { //TODO: Move to teh Core eh
|
||||||
Vote vote = event.getVote();
|
Vote vote = event.getVote();
|
||||||
PluginMain.Instance.getLogger().info("Vote: " + vote);
|
PluginMain.Instance.getLogger().info("Vote: " + vote);
|
||||||
org.bukkit.OfflinePlayer op = Bukkit.getOfflinePlayer(vote.getUsername());
|
org.bukkit.OfflinePlayer op = Bukkit.getOfflinePlayer(vote.getUsername());
|
||||||
|
|
Loading…
Reference in a new issue