Fixes
- Fixed custom flair loading - Added colored name handling for nicknames - It will now remove nicknames on disconnect (so if the nickname gets changed, a relog will make the changes in name mentioning)
This commit is contained in:
parent
fc2ff7db1e
commit
36d98719a7
14 changed files with 797 additions and 735 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
INDEX VERSION 1.126+D:\Z - Norbi cucca\0 Projektek\TheButtonMCAutoFlairProto\Spigot plugin\.metadata\.plugins\org.eclipse.jdt.core
|
INDEX VERSION 1.126+D:\Z - Norbi cucca\0 Projektek\TheButtonMCAutoFlairProto\Spigot plugin\.metadata\.plugins\org.eclipse.jdt.core
|
||||||
3045053200.index
|
3656756579.index
|
||||||
3089967703.index
|
3089967703.index
|
||||||
2674037006.index
|
2674037006.index
|
||||||
323251068.index
|
323251068.index
|
||||||
|
@ -23,4 +23,4 @@ INDEX VERSION 1.126+D:\Z - Norbi cucca\0 Projektek\TheButtonMCAutoFlairProto\Spi
|
||||||
994834796.index
|
994834796.index
|
||||||
3604769962.index
|
3604769962.index
|
||||||
1508644233.index
|
1508644233.index
|
||||||
3656756579.index
|
3045053200.index
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -16,12 +16,14 @@ import java.net.URL;
|
||||||
public class Commands implements CommandExecutor {
|
public class Commands implements CommandExecutor {
|
||||||
// This method is called, when somebody uses our command
|
// This method is called, when somebody uses our command
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||||
|
String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
return false;
|
return false;
|
||||||
MaybeOfflinePlayer p = MaybeOfflinePlayer.AllPlayers.get(player.getName()); //2015.08.08.
|
MaybeOfflinePlayer p = MaybeOfflinePlayer.AllPlayers.get(player
|
||||||
|
.getName()); // 2015.08.08.
|
||||||
// if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
|
// if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
|
||||||
if (!p.CommentedOnReddit && !args[0].toLowerCase().equals("admin")) {
|
if (!p.CommentedOnReddit && !args[0].toLowerCase().equals("admin")) {
|
||||||
player.sendMessage("§cError: You need to write your username to the reddit thread at /r/TheButtonMinecraft§r");
|
player.sendMessage("§cError: You need to write your username to the reddit thread at /r/TheButtonMinecraft§r");
|
||||||
|
@ -31,6 +33,10 @@ public class Commands implements CommandExecutor {
|
||||||
player.sendMessage("Sorry, but your flair isn't recorded. Please ask a mod to set it for you.");
|
player.sendMessage("Sorry, but your flair isn't recorded. Please ask a mod to set it for you.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (!p.FlairDecided && !args[0].toLowerCase().equals("admin")) { // 2015.08.19.
|
||||||
|
player.sendMessage("Please select between /u nonpresser and /u cantpress");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
switch (args[0].toLowerCase()) // toLowerCase: 2015.08.09.
|
switch (args[0].toLowerCase()) // toLowerCase: 2015.08.09.
|
||||||
{
|
{
|
||||||
case "accept": {
|
case "accept": {
|
||||||
|
@ -38,7 +44,8 @@ public class Commands implements CommandExecutor {
|
||||||
p.IgnoredFlair = false; // 2015.08.08.
|
p.IgnoredFlair = false; // 2015.08.08.
|
||||||
if (!p.AcceptedFlair) {
|
if (!p.AcceptedFlair) {
|
||||||
String flair = p.Flair; // 2015.08.08.
|
String flair = p.Flair; // 2015.08.08.
|
||||||
//PluginMain.AppendPlayerDisplayFlairFinal(player, flair); //2015.07.20.
|
// PluginMain.AppendPlayerDisplayFlairFinal(player, flair);
|
||||||
|
// //2015.07.20.
|
||||||
p.AcceptedFlair = true; // 2015.08.08.
|
p.AcceptedFlair = true; // 2015.08.08.
|
||||||
PluginMain.AppendPlayerDisplayFlair(p, player);
|
PluginMain.AppendPlayerDisplayFlair(p, player);
|
||||||
player.sendMessage("§bYour flair has been set:§r " + flair);
|
player.sendMessage("§bYour flair has been set:§r " + flair);
|
||||||
|
@ -52,15 +59,16 @@ public class Commands implements CommandExecutor {
|
||||||
if (!p.IgnoredFlair) {
|
if (!p.IgnoredFlair) {
|
||||||
p.IgnoredFlair = true;
|
p.IgnoredFlair = true;
|
||||||
// String flair=p.Flair; //2015.08.08.
|
// String flair=p.Flair; //2015.08.08.
|
||||||
//PluginMain.RemovePlayerDisplayFlairFinal(player, flair); //2015.07.20.
|
// PluginMain.RemovePlayerDisplayFlairFinal(player, flair);
|
||||||
|
// //2015.07.20.
|
||||||
player.sendMessage("§bYou have ignored this request. You can still use /u accept though.§r");
|
player.sendMessage("§bYou have ignored this request. You can still use /u accept though.§r");
|
||||||
} else
|
} else
|
||||||
player.sendMessage("§cYou already ignored this request.§r");
|
player.sendMessage("§cYou already ignored this request.§r");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*case "reload": //2015.07.20.
|
/*
|
||||||
DoReload(player);
|
* case "reload": //2015.07.20. DoReload(player); break;
|
||||||
break;*/
|
*/
|
||||||
case "admin": // 2015.08.09.
|
case "admin": // 2015.08.09.
|
||||||
DoAdmin(player, args);
|
DoAdmin(player, args);
|
||||||
break;
|
break;
|
||||||
|
@ -87,15 +95,18 @@ public class Commands implements CommandExecutor {
|
||||||
SetPlayerFlair(player, p, "§r(??s)§r");
|
SetPlayerFlair(player, p, "§r(??s)§r");
|
||||||
break;
|
break;
|
||||||
case "opme": // 2015.08.10.
|
case "opme": // 2015.08.10.
|
||||||
player.sendMessage("It would be nice, isn't it?"); //Sometimes I'm bored too
|
player.sendMessage("It would be nice, isn't it?"); // Sometimes
|
||||||
|
// I'm bored
|
||||||
|
// too
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*if(args[0].toLowerCase()=="reload")
|
/*
|
||||||
DoReload(null); //2015.07.20.*/
|
* if(args[0].toLowerCase()=="reload") DoReload(null); //2015.07.20.
|
||||||
|
*/
|
||||||
else if (args.length > 0 && args[0].toLowerCase().equals("admin")) // 2015.08.09.
|
else if (args.length > 0 && args[0].toLowerCase().equals("admin")) // 2015.08.09.
|
||||||
{
|
{
|
||||||
DoAdmin(null, args); // 2015.08.09.
|
DoAdmin(null, args); // 2015.08.09.
|
||||||
|
@ -108,10 +119,12 @@ public class Commands implements CommandExecutor {
|
||||||
// if(player==null || player.isOp() || player.getName()=="NorbiPeti")
|
// if(player==null || player.isOp() || player.getName()=="NorbiPeti")
|
||||||
// {
|
// {
|
||||||
try {
|
try {
|
||||||
PluginMain.Console.sendMessage("§6-- Reloading The Button Minecraft plugin...§r");
|
PluginMain.Console
|
||||||
|
.sendMessage("§6-- Reloading The Button Minecraft plugin...§r");
|
||||||
PluginMain.LoadFiles(true); // 2015.08.09.
|
PluginMain.LoadFiles(true); // 2015.08.09.
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
for (Player p : PluginMain.GetPlayers()) {
|
||||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName());
|
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p
|
||||||
|
.getName());
|
||||||
// if(mp.Flair!=null)
|
// if(mp.Flair!=null)
|
||||||
if (mp.CommentedOnReddit) {
|
if (mp.CommentedOnReddit) {
|
||||||
PluginMain.AppendPlayerDisplayFlair(mp, p); // 2015.08.09.
|
PluginMain.AppendPlayerDisplayFlair(mp, p); // 2015.08.09.
|
||||||
|
@ -134,7 +147,8 @@ public class Commands implements CommandExecutor {
|
||||||
private static Player ReloadPlayer; // 2015.08.09.
|
private static Player ReloadPlayer; // 2015.08.09.
|
||||||
|
|
||||||
private static void DoAdmin(Player player, String[] args) { // 2015.08.09.
|
private static void DoAdmin(Player player, String[] args) { // 2015.08.09.
|
||||||
if (player == null || player.isOp() || player.getName().equals("NorbiPeti")) {
|
if (player == null || player.isOp()
|
||||||
|
|| player.getName().equals("NorbiPeti")) {
|
||||||
// System.out.println("Args length: " + args.length);
|
// System.out.println("Args length: " + args.length);
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String message = "§cUsage: /u admin reload|playerinfo|getlasterror|save|setflair|updateplugin§r";
|
String message = "§cUsage: /u admin reload|playerinfo|getlasterror|save|setflair|updateplugin§r";
|
||||||
|
@ -145,7 +159,9 @@ public class Commands implements CommandExecutor {
|
||||||
switch (args[1].toLowerCase()) {
|
switch (args[1].toLowerCase()) {
|
||||||
case "reload":
|
case "reload":
|
||||||
ReloadPlayer = player; // 2015.08.09.
|
ReloadPlayer = player; // 2015.08.09.
|
||||||
SendMessage(player, "§bMake sure to save the current settings before you modify and reload them! Type /u admin confirm when done.§r");
|
SendMessage(
|
||||||
|
player,
|
||||||
|
"§bMake sure to save the current settings before you modify and reload them! Type /u admin confirm when done.§r");
|
||||||
break;
|
break;
|
||||||
case "playerinfo":
|
case "playerinfo":
|
||||||
DoPlayerInfo(player, args);
|
DoPlayerInfo(player, args);
|
||||||
|
@ -157,11 +173,13 @@ public class Commands implements CommandExecutor {
|
||||||
if (ReloadPlayer == player)
|
if (ReloadPlayer == player)
|
||||||
DoReload(player); // 2015.08.09.
|
DoReload(player); // 2015.08.09.
|
||||||
else
|
else
|
||||||
SendMessage(player, "§cYou need to do /u admin reload first.§r");
|
SendMessage(player,
|
||||||
|
"§cYou need to do /u admin reload first.§r");
|
||||||
break;
|
break;
|
||||||
case "save":
|
case "save":
|
||||||
PluginMain.SaveFiles(); // 2015.08.09.
|
PluginMain.SaveFiles(); // 2015.08.09.
|
||||||
SendMessage(player, "§bSaved files. Now you can edit them and reload if you want.§r");
|
SendMessage(player,
|
||||||
|
"§bSaved files. Now you can edit them and reload if you want.§r");
|
||||||
break;
|
break;
|
||||||
case "setflair":
|
case "setflair":
|
||||||
DoSetFlair(player, args);
|
DoSetFlair(player, args);
|
||||||
|
@ -219,11 +237,14 @@ public class Commands implements CommandExecutor {
|
||||||
SendMessage(player, "There were no exceptions.");
|
SendMessage(player, "There were no exceptions.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetPlayerFlair(Player player, MaybeOfflinePlayer targetplayer, String flair) { //2015.08.09.
|
private static void SetPlayerFlair(Player player,
|
||||||
|
MaybeOfflinePlayer targetplayer, String flair) { // 2015.08.09.
|
||||||
flair = flair.replace('&', '§');
|
flair = flair.replace('&', '§');
|
||||||
targetplayer.Flair = flair;
|
targetplayer.Flair = flair;
|
||||||
targetplayer.CommentedOnReddit = true; //Or at least has a flair in some way
|
targetplayer.CommentedOnReddit = true; // Or at least has a flair in
|
||||||
if (!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.PlayerName)) {
|
// some way
|
||||||
|
if (!PluginMain.RemoveLineFromFile("customflairs.txt",
|
||||||
|
targetplayer.PlayerName)) {
|
||||||
SendMessage(player, "§cError removing previous custom flair!§r");
|
SendMessage(player, "§cError removing previous custom flair!§r");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -237,20 +258,24 @@ public class Commands implements CommandExecutor {
|
||||||
System.out.println("Error!\n" + e);
|
System.out.println("Error!\n" + e);
|
||||||
PluginMain.LastException = e; // 2015.08.09.
|
PluginMain.LastException = e; // 2015.08.09.
|
||||||
}
|
}
|
||||||
SendMessage(player, "§bThe flair has been set. Player: " + targetplayer.PlayerName + " Flair: " + flair + "§r");
|
SendMessage(player, "§bThe flair has been set. Player: "
|
||||||
|
+ targetplayer.PlayerName + " Flair: " + flair + "§r");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DoSetFlair(Player player, String[] args) {
|
private static void DoSetFlair(Player player, String[] args) {
|
||||||
// args[0] is "admin" - args[1] is "setflair"
|
// args[0] is "admin" - args[1] is "setflair"
|
||||||
if (args.length < 4) {
|
if (args.length < 4) {
|
||||||
SendMessage(player, "§cUsage: /u admin setflair <playername> <flair>");
|
SendMessage(player,
|
||||||
|
"§cUsage: /u admin setflair <playername> <flair>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args[3].charAt(0) != '&') {
|
if (args[3].charAt(0) != '&') {
|
||||||
SendMessage(player, "§cYou need to start the flair with a color code: &6(19s)&r");
|
SendMessage(player,
|
||||||
|
"§cYou need to start the flair with a color code: &6(19s)&r");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetPlayerFlair(player, MaybeOfflinePlayer.AddPlayerIfNeeded(args[2]), args[3]);
|
SetPlayerFlair(player, MaybeOfflinePlayer.AddPlayerIfNeeded(args[2]),
|
||||||
|
args[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DoUpdatePlugin(Player player) { // 2015.08.10.
|
private static void DoUpdatePlugin(Player player) { // 2015.08.10.
|
||||||
|
@ -258,8 +283,10 @@ public class Commands implements CommandExecutor {
|
||||||
System.out.println("Forced updating of Auto-Flair plugin.");
|
System.out.println("Forced updating of Auto-Flair plugin.");
|
||||||
URL url;
|
URL url;
|
||||||
try {
|
try {
|
||||||
url = new URL("https://github.com/NorbiPeti/thebuttonautoflairmc/raw/master/TheButtonAutoFlair.jar");
|
url = new URL(
|
||||||
FileUtils.copyURLToFile(url, new File("plugins/TheButtonAutoFlair.jar"));
|
"https://github.com/NorbiPeti/thebuttonautoflairmc/raw/master/TheButtonAutoFlair.jar");
|
||||||
|
FileUtils.copyURLToFile(url, new File(
|
||||||
|
"plugins/TheButtonAutoFlair.jar"));
|
||||||
SendMessage(player, "Updating done!");
|
SendMessage(player, "Updating done!");
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
System.out.println("Error!\n" + e);
|
System.out.println("Error!\n" + e);
|
||||||
|
|
|
@ -3,9 +3,6 @@ package tk.sznp.thebuttonautoflair;
|
||||||
import de.inventivegames.TellRawAutoMessage.Reflection;
|
import de.inventivegames.TellRawAutoMessage.Reflection;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -19,13 +16,11 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class PlayerListener implements Listener { // 2015.07.16.
|
public class PlayerListener implements Listener { // 2015.07.16.
|
||||||
public static HashMap<String, UUID> nicknames = new HashMap<>();
|
public static HashMap<String, UUID> nicknames = new HashMap<>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
@ -38,7 +33,6 @@ public class PlayerListener implements Listener { //2015.07.16.
|
||||||
sendRawMessage(p, json);
|
sendRawMessage(p, json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* NICKNAME LOGIC */
|
/* NICKNAME LOGIC */
|
||||||
|
|
||||||
UUID id = p.getUniqueId();
|
UUID id = p.getUniqueId();
|
||||||
|
@ -59,6 +53,16 @@ public class PlayerListener implements Listener { //2015.07.16.
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerLeave(PlayerQuitEvent event) {
|
public void onPlayerLeave(PlayerQuitEvent event) {
|
||||||
|
String deletenick = null;
|
||||||
|
for (String nickname : nicknames.keySet()) {
|
||||||
|
UUID uuid = nicknames.get(nickname);
|
||||||
|
if (event.getPlayer().getUniqueId().equals(uuid)) {
|
||||||
|
deletenick = nickname;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (deletenick != null)
|
||||||
|
nicknames.remove(deletenick);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String NotificationSound; // 2015.08.14.
|
public static String NotificationSound; // 2015.08.14.
|
||||||
|
@ -66,7 +70,8 @@ public class PlayerListener implements Listener { //2015.07.16.
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
MaybeOfflinePlayer player = MaybeOfflinePlayer.AllPlayers.get(event.getPlayer().getName());
|
MaybeOfflinePlayer player = MaybeOfflinePlayer.AllPlayers.get(event
|
||||||
|
.getPlayer().getName());
|
||||||
String flair = player.Flair; // 2015.08.08.
|
String flair = player.Flair; // 2015.08.08.
|
||||||
if (player.IgnoredFlair)
|
if (player.IgnoredFlair)
|
||||||
flair = "";
|
flair = "";
|
||||||
|
@ -77,44 +82,66 @@ public class PlayerListener implements Listener { //2015.07.16.
|
||||||
if (NotificationSound == null)
|
if (NotificationSound == null)
|
||||||
p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1.0f, 0.5f); // 2015.08.12.
|
p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1.0f, 0.5f); // 2015.08.12.
|
||||||
else
|
else
|
||||||
p.playSound(p.getLocation(), NotificationSound, 1.0f, NotificationPitch); //2015.08.14.
|
p.playSound(p.getLocation(), NotificationSound, 1.0f,
|
||||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName()); //2015.08.17.
|
NotificationPitch); // 2015.08.14.
|
||||||
|
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p
|
||||||
|
.getName()); // 2015.08.17.
|
||||||
|
if (mp.Flair.length() > 1)
|
||||||
color = mp.Flair.substring(0, 2);
|
color = mp.Flair.substring(0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message = message.replaceAll(p.getName(), color + p.getName()
|
||||||
message = message.replaceAll(p.getName(), color + p.getName() + "§r");
|
+ "§r");
|
||||||
}
|
}
|
||||||
for (String n : nicknames.keySet())
|
for (String n : nicknames.keySet()) {
|
||||||
{
|
|
||||||
String color = ""; //2015.08.17.
|
|
||||||
Player p = null;
|
Player p = null;
|
||||||
if (message.contains(n)) {
|
String nwithoutformatting = n;
|
||||||
|
int index;
|
||||||
|
// System.out.println("n: " + n);
|
||||||
|
while ((index = nwithoutformatting.indexOf('§')) != -1)
|
||||||
|
// if ((index = nwithoutformatting.indexOf('§')) != -1)
|
||||||
|
//{
|
||||||
|
nwithoutformatting = nwithoutformatting.replaceAll("§"
|
||||||
|
+ nwithoutformatting.charAt(index + 1), "");
|
||||||
|
// System.out.println("Index: "+index+" "+"CharAt(index+1): "+nwithoutformatting.charAt(index+1));
|
||||||
|
//}
|
||||||
|
System.out.println("nwithoutformatting: " + nwithoutformatting);
|
||||||
|
if (message.contains(nwithoutformatting)) {
|
||||||
p = Bukkit.getPlayer(nicknames.get(n));
|
p = Bukkit.getPlayer(nicknames.get(n));
|
||||||
if (NotificationSound == null)
|
if (NotificationSound == null)
|
||||||
p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1.0f, 0.5f); // 2015.08.12.
|
p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1.0f, 0.5f); // 2015.08.12.
|
||||||
else
|
else
|
||||||
p.playSound(p.getLocation(), NotificationSound, 1.0f, NotificationPitch); //2015.08.14.
|
p.playSound(p.getLocation(), NotificationSound, 1.0f,
|
||||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName()); //2015.08.17.
|
NotificationPitch); // 2015.08.14.
|
||||||
color = mp.Flair.substring(0, 2);
|
MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName()); // 2015.08.17.
|
||||||
|
}
|
||||||
|
if (p != null) {
|
||||||
|
message = message.replaceAll(nwithoutformatting, n);
|
||||||
}
|
}
|
||||||
if (p != null)
|
|
||||||
message = message.replaceAll(p.getName(), color + p.getName() + "§r");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setFormat(event.getFormat().substring(0, event.getFormat().indexOf(">")) + flair + "> " + message); //2015.08.08.
|
event.setFormat(event.getFormat().substring(0,
|
||||||
|
event.getFormat().indexOf(">"))
|
||||||
|
+ flair + "> " + message); // 2015.08.08.
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Class<?> nmsChatSerializer = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
private static Class<?> nmsChatSerializer = Reflection
|
||||||
private static Class<?> nmsPacketPlayOutChat = Reflection.getNMSClass("PacketPlayOutChat");
|
.getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||||
|
private static Class<?> nmsPacketPlayOutChat = Reflection
|
||||||
|
.getNMSClass("PacketPlayOutChat");
|
||||||
|
|
||||||
public static void sendRawMessage(Player player, String message) {
|
public static void sendRawMessage(Player player, String message) {
|
||||||
try {
|
try {
|
||||||
Object handle = Reflection.getHandle(player);
|
Object handle = Reflection.getHandle(player);
|
||||||
Object connection = Reflection.getField(handle.getClass(), "playerConnection").get(handle);
|
Object connection = Reflection.getField(handle.getClass(),
|
||||||
Object serialized = Reflection.getMethod(nmsChatSerializer, "a", String.class).invoke(null, message);
|
"playerConnection").get(handle);
|
||||||
Object packet = nmsPacketPlayOutChat.getConstructor(Reflection.getNMSClass("IChatBaseComponent")).newInstance(serialized);
|
Object serialized = Reflection.getMethod(nmsChatSerializer, "a",
|
||||||
Reflection.getMethod(connection.getClass(), "sendPacket").invoke(connection, packet);
|
String.class).invoke(null, message);
|
||||||
|
Object packet = nmsPacketPlayOutChat.getConstructor(
|
||||||
|
Reflection.getNMSClass("IChatBaseComponent")).newInstance(
|
||||||
|
serialized);
|
||||||
|
Reflection.getMethod(connection.getClass(), "sendPacket").invoke(
|
||||||
|
connection, packet);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PluginMain.LastException = e; // 2015.08.09.
|
PluginMain.LastException = e; // 2015.08.09.
|
||||||
|
@ -122,13 +149,16 @@ public class PlayerListener implements Listener { //2015.07.16.
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTabComplete(PlayerChatTabCompleteEvent e)
|
public void onTabComplete(PlayerChatTabCompleteEvent e) {
|
||||||
{
|
|
||||||
String name = e.getLastToken();
|
String name = e.getLastToken();
|
||||||
for(String nickname : nicknames.keySet())
|
for (String nickname : nicknames.keySet()) {
|
||||||
{
|
String nwithoutformatting = nickname;
|
||||||
if(nickname.startsWith(name))
|
int index;
|
||||||
e.getTabCompletions().add(nickname);
|
while ((index = nwithoutformatting.indexOf('§')) != -1)
|
||||||
|
nwithoutformatting = nwithoutformatting.replaceAll("§"
|
||||||
|
+ nwithoutformatting.charAt(index + 1), "");
|
||||||
|
if (nwithoutformatting.startsWith(name))
|
||||||
|
e.getTabCompletions().add(nwithoutformatting);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,11 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
System.out.println("The Button Minecraft server plugin by NorbiPeti");
|
System.out.println("The Button Minecraft server plugin by NorbiPeti");
|
||||||
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerListener(),
|
||||||
|
this);
|
||||||
this.getCommand("u").setExecutor(new Commands());
|
this.getCommand("u").setExecutor(new Commands());
|
||||||
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
|
this.getCommand("u").setUsage(
|
||||||
|
this.getCommand("u").getUsage().replace('&', '§'));
|
||||||
Instance = this; // 2015.08.08.
|
Instance = this; // 2015.08.08.
|
||||||
Console = this.getServer().getConsoleSender(); // 2015.08.12.
|
Console = this.getServer().getConsoleSender(); // 2015.08.12.
|
||||||
LoadFiles(false); // 2015.08.09.
|
LoadFiles(false); // 2015.08.09.
|
||||||
|
@ -57,10 +59,12 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
while (!stop) {
|
while (!stop) {
|
||||||
try {
|
try {
|
||||||
String body = DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
|
String body = DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
|
||||||
JSONArray json = new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
|
JSONArray json = new JSONArray(body).getJSONObject(1)
|
||||||
|
.getJSONObject("data").getJSONArray("children");
|
||||||
for (Object obj : json) {
|
for (Object obj : json) {
|
||||||
JSONObject item = (JSONObject) obj;
|
JSONObject item = (JSONObject) obj;
|
||||||
String author = item.getJSONObject("data").getString("author");
|
String author = item.getJSONObject("data").getString(
|
||||||
|
"author");
|
||||||
String ign = item.getJSONObject("data").getString("body");
|
String ign = item.getJSONObject("data").getString("body");
|
||||||
int start = ign.indexOf("IGN:") + "IGN:".length();
|
int start = ign.indexOf("IGN:") + "IGN:".length();
|
||||||
// System.out.println("Start: "+start);
|
// System.out.println("Start: "+start);
|
||||||
|
@ -84,7 +88,9 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
|
String[] flairdata = DownloadString(
|
||||||
|
"http://karmadecay.com/thebutton-data.php?users="
|
||||||
|
+ author).replace("\"", "").split(":");
|
||||||
String flair;
|
String flair;
|
||||||
if (flairdata.length > 1) // 2015.07.15.
|
if (flairdata.length > 1) // 2015.07.15.
|
||||||
flair = flairdata[1];
|
flair = flairdata[1];
|
||||||
|
@ -92,8 +98,9 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
flair = "";
|
flair = "";
|
||||||
if (flair != "-1")
|
if (flair != "-1")
|
||||||
flair = flair + "s";
|
flair = flair + "s";
|
||||||
/*else
|
/*
|
||||||
flair = "non-presser";*/
|
* else flair = "non-presser";
|
||||||
|
*/
|
||||||
String flairclass;
|
String flairclass;
|
||||||
if (flairdata.length > 2)
|
if (flairdata.length > 2)
|
||||||
flairclass = flairdata[2];
|
flairclass = flairdata[2];
|
||||||
|
@ -111,7 +118,8 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
|
|
||||||
public static Exception LastException; // 2015.08.09.
|
public static Exception LastException; // 2015.08.09.
|
||||||
|
|
||||||
public String DownloadString(String urlstr) throws MalformedURLException, IOException {
|
public String DownloadString(String urlstr) throws MalformedURLException,
|
||||||
|
IOException {
|
||||||
URL url = new URL(urlstr);
|
URL url = new URL(urlstr);
|
||||||
URLConnection con = url.openConnection();
|
URLConnection con = url.openConnection();
|
||||||
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
|
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
|
||||||
|
@ -131,7 +139,8 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
return p.CommentedOnReddit; // 2015.08.10.
|
return p.CommentedOnReddit; // 2015.08.10.
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFlair(String playername, String text, String flairclass, String username) {
|
public void SetFlair(String playername, String text, String flairclass,
|
||||||
|
String username) {
|
||||||
MaybeOfflinePlayer p = MaybeOfflinePlayer.AddPlayerIfNeeded(playername); // 2015.08.08.
|
MaybeOfflinePlayer p = MaybeOfflinePlayer.AddPlayerIfNeeded(playername); // 2015.08.08.
|
||||||
String finalflair;
|
String finalflair;
|
||||||
p.FlairDecided = true;
|
p.FlairDecided = true;
|
||||||
|
@ -165,7 +174,8 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
finalflair = "§r(??s)§r";
|
finalflair = "§r(??s)§r";
|
||||||
break;
|
break;
|
||||||
case "unknown":
|
case "unknown":
|
||||||
if (text.equals("-1")) //If true, only non-presser/can't press; if false, any flair
|
if (text.equals("-1")) // If true, only non-presser/can't press; if
|
||||||
|
// false, any flair
|
||||||
p.FlairDecided = false;
|
p.FlairDecided = false;
|
||||||
else
|
else
|
||||||
p.FlairRecognised = false;
|
p.FlairRecognised = false;
|
||||||
|
@ -176,13 +186,16 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
// break;
|
// break;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*if(finalflair.length()==0) //<-- 2015.07.20.
|
/*
|
||||||
return;*/
|
* if(finalflair.length()==0) //<-- 2015.07.20. return;
|
||||||
|
*/
|
||||||
p.Flair = finalflair; // 2015.08.08.
|
p.Flair = finalflair; // 2015.08.08.
|
||||||
p.CommentedOnReddit = true; // 2015.08.10.
|
p.CommentedOnReddit = true; // 2015.08.10.
|
||||||
p.UserName = username; // 2015.08.08.
|
p.UserName = username; // 2015.08.08.
|
||||||
/*if(finalflair.length()==0) //Just for the message
|
/*
|
||||||
finalflair="undecided";*/
|
* if(finalflair.length()==0) //Just for the message
|
||||||
|
* finalflair="undecided";
|
||||||
|
*/
|
||||||
// System.out.println("Added new flair to "+playername+": "+finalflair);
|
// System.out.println("Added new flair to "+playername+": "+finalflair);
|
||||||
for (Player player : getServer().getOnlinePlayers()) // <-- 2015.08.08.
|
for (Player player : getServer().getOnlinePlayers()) // <-- 2015.08.08.
|
||||||
{
|
{
|
||||||
|
@ -200,8 +213,10 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
return flair; // 2015.08.10.
|
return flair; // 2015.08.10.
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
|
// public static void AppendPlayerDisplayFlair(Player player, String
|
||||||
public static void AppendPlayerDisplayFlair(MaybeOfflinePlayer player, Player p) //<-- 2015.08.09.
|
// username, String flair)
|
||||||
|
public static void AppendPlayerDisplayFlair(MaybeOfflinePlayer player,
|
||||||
|
Player p) // <-- 2015.08.09.
|
||||||
{
|
{
|
||||||
|
|
||||||
if (MaybeOfflinePlayer.AllPlayers.get(p.getName()).IgnoredFlair)
|
if (MaybeOfflinePlayer.AllPlayers.get(p.getName()).IgnoredFlair)
|
||||||
|
@ -211,54 +226,31 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
if (!player.FlairDecided)
|
if (!player.FlairDecided)
|
||||||
p.sendMessage("§9Your flair type is unknown. Are you a non-presser or a can't press? (/u nonpresser or /u cantpress)§r"); // 2015.08.09.
|
p.sendMessage("§9Your flair type is unknown. Are you a non-presser or a can't press? (/u nonpresser or /u cantpress)§r"); // 2015.08.09.
|
||||||
} else
|
} else
|
||||||
p.sendMessage("§9Are you Reddit user " + player.UserName + "?§r §6Type /u accept or /u ignore§r");
|
p.sendMessage("§9Are you Reddit user " + player.UserName
|
||||||
|
+ "?§r §6Type /u accept or /u ignore§r");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private static void AppendPlayerDisplayFlairFinal(Player player, String flair)
|
/*
|
||||||
{ //2015.07.20.
|
* private static void AppendPlayerDisplayFlairFinal(Player player, String
|
||||||
*String color = GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on first capital letters
|
* flair) { //2015.07.20.String color =
|
||||||
String[] colors = color.substring(1).split("§");
|
* GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on
|
||||||
String displayname=player.getName(); //2015.08.08.
|
* first capital letters String[] colors = color.substring(1).split("§");
|
||||||
ArrayList<Integer> Positions=new ArrayList<>();
|
* String displayname=player.getName(); //2015.08.08. ArrayList<Integer>
|
||||||
for(int i=0; i<displayname.length(); i++) {
|
* Positions=new ArrayList<>(); for(int i=0; i<displayname.length(); i++) {
|
||||||
if(Character.isUpperCase(displayname.charAt(i))) {
|
* if(Character.isUpperCase(displayname.charAt(i))) { Positions.add(i); } }
|
||||||
Positions.add(i);
|
* String finalname=""; //TODO if(Positions.size()>=colors.length) { int
|
||||||
}
|
* x=0; for(int i=0; i<Positions.size(); i++) { int pos=Positions.get(i);
|
||||||
}
|
* int nextpos; if(i!=Positions.size()-1) nextpos=Positions.get(i+1); else
|
||||||
String finalname=""; //TODO
|
* nextpos=displayname.length(); String
|
||||||
if(Positions.size()>=colors.length)
|
* substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
|
||||||
{
|
* finalname+=substr; } } else { Positions.clear(); int
|
||||||
int x=0;
|
* unit=displayname.length()/colors.length; int x=0; for(int i=0;
|
||||||
for(int i=0; i<Positions.size(); i++)
|
* i<displayname.length()-unit; i+=unit) { int pos=i; int nextpos;
|
||||||
{
|
* if(i<displayname.length()-unit-unit) nextpos=i+unit; else
|
||||||
int pos=Positions.get(i);
|
* nextpos=displayname.length(); String
|
||||||
int nextpos;
|
* substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
|
||||||
if(i!=Positions.size()-1)
|
* finalname+=substr; } }* }
|
||||||
nextpos=Positions.get(i+1);
|
*/
|
||||||
else
|
|
||||||
nextpos=displayname.length();
|
|
||||||
String substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
|
|
||||||
finalname+=substr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Positions.clear();
|
|
||||||
int unit=displayname.length()/colors.length;
|
|
||||||
int x=0;
|
|
||||||
for(int i=0; i<displayname.length()-unit; i+=unit)
|
|
||||||
{
|
|
||||||
int pos=i;
|
|
||||||
int nextpos;
|
|
||||||
if(i<displayname.length()-unit-unit)
|
|
||||||
nextpos=i+unit;
|
|
||||||
else
|
|
||||||
nextpos=displayname.length();
|
|
||||||
String substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
|
|
||||||
finalname+=substr;
|
|
||||||
}
|
|
||||||
}*
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static String GetColorForTown(String townname) { // 2015.07.20.
|
public static String GetColorForTown(String townname) { // 2015.07.20.
|
||||||
if (TownColors.containsKey(townname))
|
if (TownColors.containsKey(townname))
|
||||||
|
@ -268,17 +260,20 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
|
|
||||||
public static String GetPlayerTown(Player player) { // 2015.07.20.
|
public static String GetPlayerTown(Player player) { // 2015.07.20.
|
||||||
try {
|
try {
|
||||||
Town town = WorldCoord.parseWorldCoord(player).getTownBlock().getTown(); //TODO
|
Town town = WorldCoord.parseWorldCoord(player).getTownBlock()
|
||||||
|
.getTown(); // TODO
|
||||||
return town.getName();
|
return town.getName();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static void RemovePlayerDisplayFlairFinal(Player player, String flair)
|
/*
|
||||||
{ //2015.07.20.
|
* public static void RemovePlayerDisplayFlairFinal(Player player, String
|
||||||
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=null; //2015.08.08.
|
* flair) { //2015.07.20.
|
||||||
}*/
|
* MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=null;
|
||||||
|
* //2015.08.08. }
|
||||||
|
*/
|
||||||
|
|
||||||
public static Collection<? extends Player> GetPlayers() {
|
public static Collection<? extends Player> GetPlayers() {
|
||||||
return Instance.getServer().getOnlinePlayers();
|
return Instance.getServer().getOnlinePlayers();
|
||||||
|
@ -287,7 +282,8 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
public static void LoadFiles(boolean reload) // <-- 2015.08.09.
|
public static void LoadFiles(boolean reload) // <-- 2015.08.09.
|
||||||
{
|
{
|
||||||
if (reload) { // 2015.08.09.
|
if (reload) { // 2015.08.09.
|
||||||
System.out.println("The Button Minecraft plugin cleanup for reloading...");
|
System.out
|
||||||
|
.println("The Button Minecraft plugin cleanup for reloading...");
|
||||||
MaybeOfflinePlayer.AllPlayers.clear();
|
MaybeOfflinePlayer.AllPlayers.clear();
|
||||||
TownColors.clear();
|
TownColors.clear();
|
||||||
}
|
}
|
||||||
|
@ -295,7 +291,8 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
try {
|
try {
|
||||||
File file = new File("flairsaccepted.txt");
|
File file = new File("flairsaccepted.txt");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
BufferedReader br = new BufferedReader(new FileReader("flairsaccepted.txt"));
|
BufferedReader br = new BufferedReader(new FileReader(
|
||||||
|
"flairsaccepted.txt"));
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
String name = line.replace("\n", "");
|
String name = line.replace("\n", "");
|
||||||
|
@ -306,7 +303,8 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
}
|
}
|
||||||
file = new File("flairsignored.txt");
|
file = new File("flairsignored.txt");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
BufferedReader br = new BufferedReader(new FileReader("flairsignored.txt"));
|
BufferedReader br = new BufferedReader(new FileReader(
|
||||||
|
"flairsignored.txt"));
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
String name = line.replace("\n", "");
|
String name = line.replace("\n", "");
|
||||||
|
@ -333,9 +331,12 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
String[] s = line.split(" ");
|
String[] s = line.split(" ");
|
||||||
if (s.length >= 2) // 2015.08.10.
|
if (s.length >= 2) // 2015.08.10.
|
||||||
{
|
{
|
||||||
MaybeOfflinePlayer p = MaybeOfflinePlayer.AddPlayerIfNeeded(s[0]);
|
MaybeOfflinePlayer p = MaybeOfflinePlayer
|
||||||
|
.AddPlayerIfNeeded(s[0]);
|
||||||
p.Flair = s[1]; // 2015.08.09.
|
p.Flair = s[1]; // 2015.08.09.
|
||||||
p.CommentedOnReddit = true; // Kind of
|
p.CommentedOnReddit = true; // Kind of
|
||||||
|
p.FlairDecided = true;
|
||||||
|
p.FlairRecognised = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
|
@ -372,7 +373,8 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
try {
|
try {
|
||||||
File file = new File("flairsaccepted.txt");
|
File file = new File("flairsaccepted.txt");
|
||||||
BufferedWriter bw = new BufferedWriter(new FileWriter(file, true));
|
BufferedWriter bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
for (MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
for (MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers
|
||||||
|
.values()) // <-- 2015.08.08.
|
||||||
{
|
{
|
||||||
if (!player.AcceptedFlair)
|
if (!player.AcceptedFlair)
|
||||||
continue; // 2015.08.08.
|
continue; // 2015.08.08.
|
||||||
|
@ -381,7 +383,8 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
bw.close();
|
bw.close();
|
||||||
file = new File("flairsignored.txt");
|
file = new File("flairsignored.txt");
|
||||||
bw = new BufferedWriter(new FileWriter(file, true));
|
bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
for (MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
for (MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers
|
||||||
|
.values()) // <-- 2015.08.08.
|
||||||
{
|
{
|
||||||
if (!player.IgnoredFlair)
|
if (!player.IgnoredFlair)
|
||||||
continue; // 2015.08.08.
|
continue; // 2015.08.08.
|
||||||
|
@ -402,7 +405,8 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
return true; // 2015.08.10.
|
return true; // 2015.08.10.
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
|
BufferedReader reader = new BufferedReader(
|
||||||
|
new FileReader(inputFile));
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
|
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
|
||||||
|
|
||||||
String lineToRemove = line;
|
String lineToRemove = line;
|
||||||
|
@ -411,7 +415,8 @@ public class PluginMain extends JavaPlugin { //Translated to Java: 2015.07.15.
|
||||||
while ((currentLine = reader.readLine()) != null) {
|
while ((currentLine = reader.readLine()) != null) {
|
||||||
// trim newline when comparing with lineToRemove
|
// trim newline when comparing with lineToRemove
|
||||||
String trimmedLine = currentLine.trim();
|
String trimmedLine = currentLine.trim();
|
||||||
if (trimmedLine.split(" ")[0].equals(lineToRemove)) continue; //2015.08.17.
|
if (trimmedLine.split(" ")[0].equals(lineToRemove))
|
||||||
|
continue; // 2015.08.17.
|
||||||
writer.write(currentLine + System.getProperty("line.separator"));
|
writer.write(currentLine + System.getProperty("line.separator"));
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
Loading…
Reference in a new issue