Bug fixes
- Commented out WIP code which caused errors - Other fixes
|
@ -792,3 +792,25 @@ user global configuration and to define the default location to store repositori
|
||||||
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
|
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
|
||||||
EGit might behave differently since they see different configuration options.
|
EGit might behave differently since they see different configuration options.
|
||||||
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
|
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
|
||||||
|
!SESSION 2015-08-10 07:20:59.956 -----------------------------------------------
|
||||||
|
eclipse.buildId=M20130204-1200
|
||||||
|
java.version=1.8.0_45
|
||||||
|
java.vendor=Oracle Corporation
|
||||||
|
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=hu_HU
|
||||||
|
Framework arguments: -product org.eclipse.epp.package.jee.product
|
||||||
|
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
|
||||||
|
|
||||||
|
!ENTRY org.eclipse.egit.ui 2 0 2015-08-10 07:22:18.883
|
||||||
|
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level
|
||||||
|
Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory.
|
||||||
|
The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in
|
||||||
|
this system level configuration. The Git installation location can be configured on the
|
||||||
|
Team > Git > Configuration preference page's 'System Settings' tab.
|
||||||
|
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
|
||||||
|
|
||||||
|
!ENTRY org.eclipse.egit.ui 2 0 2015-08-10 07:22:18.926
|
||||||
|
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
|
||||||
|
user global configuration and to define the default location to store repositories: 'C:\Users\Norbi'. If this is
|
||||||
|
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
|
||||||
|
EGit might behave differently since they see different configuration options.
|
||||||
|
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
|
||||||
|
|
|
@ -0,0 +1,265 @@
|
||||||
|
package tk.sznp.thebuttonautoflair;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Commands implements CommandExecutor {
|
||||||
|
// This method is called, when somebody uses our command
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if(args.length<1)
|
||||||
|
return false;
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AllPlayers.get(player.getName()); //2015.08.08.
|
||||||
|
//if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
|
||||||
|
if(p.Flair==null)
|
||||||
|
{
|
||||||
|
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
switch(args[0].toLowerCase()) //toLowerCase: 2015.08.09.
|
||||||
|
{
|
||||||
|
case "accept":
|
||||||
|
{
|
||||||
|
if(p.IgnoredFlair)
|
||||||
|
p.IgnoredFlair=false; //2015.08.08.
|
||||||
|
if(!p.AcceptedFlair)
|
||||||
|
{
|
||||||
|
String flair=p.Flair; //2015.08.08.
|
||||||
|
//PluginMain.AppendPlayerDisplayFlairFinal(player, flair); //2015.07.20.
|
||||||
|
PluginMain.AppendPlayerDisplayFlair(p, player);
|
||||||
|
p.AcceptedFlair=true; //2015.08.08.
|
||||||
|
player.sendMessage("§6Your flair has been set:§r "+flair);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.sendMessage("§cYou already have this user's flair.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "ignore":
|
||||||
|
{
|
||||||
|
if(p.AcceptedFlair)
|
||||||
|
p.AcceptedFlair=false; //2015.08.08.
|
||||||
|
if(!p.IgnoredFlair)
|
||||||
|
{
|
||||||
|
p.IgnoredFlair=true;
|
||||||
|
//String flair=p.Flair; //2015.08.08.
|
||||||
|
//PluginMain.RemovePlayerDisplayFlairFinal(player, flair); //2015.07.20.
|
||||||
|
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.sendMessage("§cYou already ignored this request.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/*case "reload": //2015.07.20.
|
||||||
|
DoReload(player);
|
||||||
|
break;*/
|
||||||
|
case "admin": //2015.08.09.
|
||||||
|
DoAdmin(player, args);
|
||||||
|
break;
|
||||||
|
case "nonpresser": //2015.08.09.
|
||||||
|
if(!p.AcceptedFlair)
|
||||||
|
{
|
||||||
|
player.sendMessage("§cYou need to accept the flair first.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(p.FlairDecided)
|
||||||
|
{
|
||||||
|
player.sendMessage("§cYou have already set the flair type.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//p.Flair="§7(non-pr.)§r";
|
||||||
|
SetPlayerFlair(player, p, "§7(non-pr.)§r");
|
||||||
|
break;
|
||||||
|
case "cantpress": //2015.08.09.
|
||||||
|
if(!p.AcceptedFlair)
|
||||||
|
{
|
||||||
|
player.sendMessage("§cYou need to accept the flair first.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(p.FlairDecided)
|
||||||
|
{
|
||||||
|
player.sendMessage("§cYou have already set the flair type or your flair type is known.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//p.Flair="§r(can't press)§r";
|
||||||
|
SetPlayerFlair(player, p, "§r(can't pr.)§r");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/*if(args[0].toLowerCase()=="reload")
|
||||||
|
DoReload(null); //2015.07.20.*/
|
||||||
|
else if(args.length>0 && args[0].toLowerCase().equals("admin")) //2015.08.09.
|
||||||
|
{
|
||||||
|
DoAdmin(null, args); //2015.08.09.
|
||||||
|
return true; //2015.08.09.
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private static void DoReload(Player player)
|
||||||
|
{ //2015.07.20.
|
||||||
|
//if(player==null || player.isOp() || player.getName()=="NorbiPeti")
|
||||||
|
//{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File file=new File("autoflairconfig.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
PluginMain.LoadFiles(true); //2015.08.09.
|
||||||
|
for(Player p : PluginMain.GetPlayers())
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName());
|
||||||
|
if(mp.Flair!=null)
|
||||||
|
{
|
||||||
|
//String flair=mp.Flair;
|
||||||
|
//PluginMain.RemovePlayerDisplayFlairFinal(p, flair);
|
||||||
|
//PluginMain.AppendPlayerDisplayFlairFinal(p, flair);
|
||||||
|
PluginMain.AppendPlayerDisplayFlair(mp, p); //2015.08.09.
|
||||||
|
}
|
||||||
|
String msg="§6Note: The auto-flair plugin has been reloaded. You might need to wait 10s to have your flair.§r"; //2015.08.09.
|
||||||
|
p.sendMessage(msg); //2015.08.09.
|
||||||
|
}
|
||||||
|
//String msg="§6Reloaded config file.§r";
|
||||||
|
//SendMessage(player, msg); //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
if(player!=null)
|
||||||
|
player.sendMessage("§cAn error occured. See console for details.§r");
|
||||||
|
PluginMain.LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//player.sendMessage("§cYou need to be OP to use this command.§r");
|
||||||
|
}
|
||||||
|
private static Player ReloadPlayer; //2015.08.09.
|
||||||
|
private static void DoAdmin(Player player, String[] args)
|
||||||
|
{ //2015.08.09.
|
||||||
|
if(player==null || player.isOp() || player.getName()=="NorbiPeti")
|
||||||
|
{
|
||||||
|
//System.out.println("Args length: " + args.length);
|
||||||
|
if(args.length==1)
|
||||||
|
{
|
||||||
|
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save|setflair§r";
|
||||||
|
SendMessage(player, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//args[0] is "admin"
|
||||||
|
switch(args[1].toLowerCase())
|
||||||
|
{
|
||||||
|
case "reload":
|
||||||
|
ReloadPlayer=player; //2015.08.09.
|
||||||
|
SendMessage(player, "§6Make sure to save the current settings before you modify and reload them! Type /u admin confirm when done.§r");
|
||||||
|
break;
|
||||||
|
case "playerinfo":
|
||||||
|
DoPlayerInfo(player, args);
|
||||||
|
break;
|
||||||
|
case "getlasterror":
|
||||||
|
DoGetLastError(player, args);
|
||||||
|
case "confirm":
|
||||||
|
if(ReloadPlayer==player)
|
||||||
|
DoReload(player); //2015.08.09.
|
||||||
|
else
|
||||||
|
SendMessage(player, "§cYou need to do /u admin reload first.§r");
|
||||||
|
break;
|
||||||
|
case "save":
|
||||||
|
PluginMain.SaveFiles(); //2015.08.09.
|
||||||
|
SendMessage(player, "§6Saved files. Now you can edit them and reload if you want.§r");
|
||||||
|
break;
|
||||||
|
case "setflair":
|
||||||
|
DoSetFlair(player, args);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save|setflair§r";
|
||||||
|
SendMessage(player, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.sendMessage("§cYou need to be OP to use this command.§r");
|
||||||
|
}
|
||||||
|
private static void DoPlayerInfo(Player player, String[] args)
|
||||||
|
{ //2015.08.09.
|
||||||
|
//args[0] is "admin" - args[1] is "playerinfo"
|
||||||
|
if(args.length==2)
|
||||||
|
{
|
||||||
|
String message="§cUsage: /u admin playerinfo <player>§r";
|
||||||
|
SendMessage(player, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!MaybeOfflinePlayer.AllPlayers.containsKey(args[2]))
|
||||||
|
{
|
||||||
|
String message="§cPlayer not found: "+args[2]+"§r";
|
||||||
|
SendMessage(player, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MaybeOfflinePlayer p = MaybeOfflinePlayer.AllPlayers.get(args[2]);
|
||||||
|
SendMessage(player, "Player name: "+p.PlayerName);
|
||||||
|
SendMessage(player, "User flair: "+p.Flair);
|
||||||
|
SendMessage(player, "Username: "+p.UserName);
|
||||||
|
SendMessage(player, "Flair accepted: "+p.AcceptedFlair);
|
||||||
|
SendMessage(player, "Flair ignored: "+p.IgnoredFlair);
|
||||||
|
}
|
||||||
|
private static void SendMessage(Player player, String message)
|
||||||
|
{ //2015.08.09.
|
||||||
|
if(player==null)
|
||||||
|
System.out.println(message);
|
||||||
|
else
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
private static void DoGetLastError(Player player, String[] args)
|
||||||
|
{ //2015.08.09.
|
||||||
|
//args[0] is "admin" - args[1] is "getlasterror"
|
||||||
|
if(PluginMain.LastException!=null)
|
||||||
|
{
|
||||||
|
SendMessage(player, "Last error:");
|
||||||
|
SendMessage(player, PluginMain.LastException.toString());
|
||||||
|
PluginMain.LastException=null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SendMessage(player, "There were no exceptions.");
|
||||||
|
}
|
||||||
|
private static void SetPlayerFlair(Player player, MaybeOfflinePlayer targetplayer, String flair)
|
||||||
|
{ //2015.08.09.
|
||||||
|
flair=flair.replace('&', '§');
|
||||||
|
targetplayer.Flair=flair;
|
||||||
|
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.PlayerName))
|
||||||
|
{
|
||||||
|
SendMessage(player, "§cError removing previous custom flair!§r");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
File file=new File("customflairs.txt");
|
||||||
|
try {
|
||||||
|
BufferedWriter bw;
|
||||||
|
bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
|
bw.write(targetplayer.PlayerName+"\n");
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
PluginMain.LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
SendMessage(player, "§6The flair has been set. Player: "+targetplayer.PlayerName+" Flair: "+flair+"§r");
|
||||||
|
}
|
||||||
|
private static void DoSetFlair(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//args[0] is "admin" - args[1] is "setflair"
|
||||||
|
if(args.length<4)
|
||||||
|
{
|
||||||
|
SendMessage(player, "§cUsage: /u admin setflair <playername> <flair>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SetPlayerFlair(player, MaybeOfflinePlayer.AddPlayerIfNeeded(args[2]), args[3]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,425 @@
|
||||||
|
package tk.sznp.thebuttonautoflair;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||||
|
|
||||||
|
public class PluginMain extends JavaPlugin
|
||||||
|
{ //Translated to Java: 2015.07.15.
|
||||||
|
//A user, which flair isn't obtainable:
|
||||||
|
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
|
||||||
|
private static PluginMain Instance;
|
||||||
|
// Fired when plugin is first enabled
|
||||||
|
@Override
|
||||||
|
public void onEnable()
|
||||||
|
{
|
||||||
|
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
|
this.getCommand("u").setExecutor(new Commands());
|
||||||
|
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
|
||||||
|
Instance=this; //2015.08.08.
|
||||||
|
LoadFiles(false); //2015.08.09.
|
||||||
|
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
|
||||||
|
Thread t=new Thread(r);
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
Boolean stop=false;
|
||||||
|
// Fired when plugin is disabled
|
||||||
|
@Override
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
SaveFiles(); //2015.08.09.
|
||||||
|
stop=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ThreadMethod() //<-- 2015.07.16.
|
||||||
|
{
|
||||||
|
while(!stop)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
for(Object obj : json)
|
||||||
|
{
|
||||||
|
JSONObject item = (JSONObject)obj;
|
||||||
|
String author=item.getJSONObject("data").getString("author");
|
||||||
|
String ign=item.getJSONObject("data").getString("body");
|
||||||
|
int start = ign.indexOf("IGN:") + "IGN:".length();
|
||||||
|
if(start==-1)
|
||||||
|
continue; //2015.08.09.
|
||||||
|
int end = ign.indexOf(' ', start);
|
||||||
|
if (end == -1 || end == start)
|
||||||
|
end=ign.indexOf('\n', start); //2015.07.15.
|
||||||
|
if (end == -1 || end == start)
|
||||||
|
ign = ign.substring(start);
|
||||||
|
else
|
||||||
|
ign = ign.substring(start, end);
|
||||||
|
ign = ign.trim();
|
||||||
|
if(HasIGFlair(ign))
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
Thread.sleep(10);
|
||||||
|
} catch(InterruptedException ex) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
|
||||||
|
String flair;
|
||||||
|
if(flairdata.length > 1) //2015.07.15.
|
||||||
|
flair = flairdata[1];
|
||||||
|
else
|
||||||
|
flair="";
|
||||||
|
if (flair != "-1")
|
||||||
|
flair = flair + "s";
|
||||||
|
else
|
||||||
|
flair = "non-presser";
|
||||||
|
String flairclass;
|
||||||
|
if(flairdata.length>2)
|
||||||
|
flairclass = flairdata[2];
|
||||||
|
else
|
||||||
|
flairclass="unknown";
|
||||||
|
SetFlair(ign, flair, flairclass, author);
|
||||||
|
}
|
||||||
|
Thread.sleep(10000);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Exception LastException; //2015.08.09.
|
||||||
|
|
||||||
|
public String DownloadString(String urlstr) throws MalformedURLException, IOException
|
||||||
|
{
|
||||||
|
URL url = new URL(urlstr);
|
||||||
|
URLConnection con = url.openConnection();
|
||||||
|
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
|
||||||
|
InputStream in = con.getInputStream();
|
||||||
|
String encoding = con.getContentEncoding();
|
||||||
|
encoding = encoding == null ? "UTF-8" : encoding;
|
||||||
|
String body = IOUtils.toString(in, encoding);
|
||||||
|
in.close();
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> TownColors=new HashMap<String, String>(); //2015.07.20.
|
||||||
|
public Boolean HasIGFlair(String playername)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
|
return p.Flair!=null; //2015.08.08.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFlair(String playername, String text, String flairclass, String username)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
|
String finalflair;
|
||||||
|
p.FlairDecided=true;
|
||||||
|
switch(flairclass)
|
||||||
|
{
|
||||||
|
case "press-1":
|
||||||
|
finalflair="§c("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-2":
|
||||||
|
finalflair="§6("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-3":
|
||||||
|
finalflair="§e("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-4":
|
||||||
|
finalflair="§a("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-5":
|
||||||
|
finalflair="§9("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-6":
|
||||||
|
finalflair="§5("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "no-press":
|
||||||
|
finalflair="§7(non-pr.)§r";
|
||||||
|
break;
|
||||||
|
case "cheater":
|
||||||
|
finalflair="§5("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "cant-press": //2015.08.08.
|
||||||
|
finalflair="§r(can't press)§r";
|
||||||
|
break;
|
||||||
|
case "undecided": //2015.08.09.
|
||||||
|
p.FlairDecided=false;
|
||||||
|
finalflair="";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
finalflair="";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(finalflair.length()==0) //<-- 2015.07.20.
|
||||||
|
return;
|
||||||
|
p.Flair=finalflair; //2015.08.08.
|
||||||
|
p.UserName=username; //2015.08.08.
|
||||||
|
System.out.println("Added new flair to "+playername+": "+finalflair);
|
||||||
|
for(Player player : getServer().getOnlinePlayers()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(player.getName().equals(playername))
|
||||||
|
{
|
||||||
|
//AppendPlayerDisplayFlair(player, username, finalflair);
|
||||||
|
AppendPlayerDisplayFlair(p, player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetFlair(Player player)
|
||||||
|
{ //2015.07.16.
|
||||||
|
String flair=MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair; //2015.08.08.
|
||||||
|
return flair==null ? "" : flair;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
|
||||||
|
public static void AppendPlayerDisplayFlair(MaybeOfflinePlayer player, Player p) //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
|
||||||
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).IgnoredFlair)
|
||||||
|
return;
|
||||||
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).AcceptedFlair)
|
||||||
|
{
|
||||||
|
AppendPlayerDisplayFlairFinal(p, player.Flair); //2015.07.20.
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
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.
|
||||||
|
String color = GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on first capital letters
|
||||||
|
String[] colors = color.substring(1).split("§");
|
||||||
|
String displayname=player.getName(); //2015.08.08.
|
||||||
|
ArrayList<Integer> Positions=new ArrayList<>();
|
||||||
|
for(int i=0; i<displayname.length(); i++) {
|
||||||
|
if(Character.isUpperCase(displayname.charAt(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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetColorForTown(String townname)
|
||||||
|
{ //2015.07.20.
|
||||||
|
if(TownColors.containsKey(townname))
|
||||||
|
return TownColors.get(townname);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetPlayerTown(Player player)
|
||||||
|
{ //2015.07.20.
|
||||||
|
try {
|
||||||
|
Town town = WorldCoord.parseWorldCoord(player).getTownBlock().getTown(); //TODO
|
||||||
|
return town.getName();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public static void RemovePlayerDisplayFlairFinal(Player player, String flair)
|
||||||
|
{ //2015.07.20.
|
||||||
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=null; //2015.08.08.
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public static Collection<? extends Player> GetPlayers()
|
||||||
|
{
|
||||||
|
return Instance.getServer().getOnlinePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadFiles(boolean reload) //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
if(reload)
|
||||||
|
{ //2015.08.09.
|
||||||
|
System.out.println("Auto-flair plugin cleanup for reloading...");
|
||||||
|
MaybeOfflinePlayer.AllPlayers.clear();
|
||||||
|
TownColors.clear();
|
||||||
|
}
|
||||||
|
System.out.println("Loading files for auto-flair plugin..."); //2015.08.09.
|
||||||
|
try {
|
||||||
|
File file=new File("flairsaccepted.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
String name=line.replace("\n", "");
|
||||||
|
//System.out.println("Name: " + name);
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(name).AcceptedFlair=true; //2015.08.08.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("flairsignored.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
String name=line.replace("\n", "");
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(name).IgnoredFlair=true; //2015.08.08.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("autoflairconfig.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader(file));
|
||||||
|
String line;
|
||||||
|
while((line=br.readLine())!=null)
|
||||||
|
{
|
||||||
|
String[] s=line.split(" ");
|
||||||
|
TownColors.put(s[0], s[1]);
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("customflairs.txt"); //2015.08.09.
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader(file));
|
||||||
|
String line;
|
||||||
|
while((line=br.readLine())!=null)
|
||||||
|
{
|
||||||
|
String[] s=line.split(" ");
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(s[0]).Flair=s[1]; //2015.08.09.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
//throw new IOException("Test"); //2015.08.09.
|
||||||
|
System.out.println("Auto-flair plugin loaded files!");
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void SaveFiles() //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileWriter fw;
|
||||||
|
fw = new FileWriter("flairsaccepted.txt");
|
||||||
|
fw.close();
|
||||||
|
fw = new FileWriter("flairsignored.txt");
|
||||||
|
fw.close();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
File file=new File("flairsaccepted.txt");
|
||||||
|
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
|
||||||
|
for(MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(!player.AcceptedFlair)
|
||||||
|
continue; //2015.08.08.
|
||||||
|
bw.write(player.PlayerName+"\n");
|
||||||
|
}
|
||||||
|
bw.close();
|
||||||
|
file=new File("flairsignored.txt");
|
||||||
|
bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
|
for(MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(!player.IgnoredFlair)
|
||||||
|
continue; //2015.08.08.
|
||||||
|
bw.write(player.PlayerName+"\n");
|
||||||
|
}
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static boolean RemoveLineFromFile(String file, String line)
|
||||||
|
{ //2015.08.09.
|
||||||
|
File inputFile = new File(file);
|
||||||
|
File tempFile = new File("_temp.txt");
|
||||||
|
|
||||||
|
if(!inputFile.exists())
|
||||||
|
return true; //2015.08.10.
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
|
||||||
|
|
||||||
|
String lineToRemove = line;
|
||||||
|
String currentLine;
|
||||||
|
|
||||||
|
while((currentLine = reader.readLine()) != null) {
|
||||||
|
// trim newline when comparing with lineToRemove
|
||||||
|
String trimmedLine = currentLine.trim();
|
||||||
|
//if(trimmedLine.equals(lineToRemove)) continue;
|
||||||
|
if(trimmedLine.contains(lineToRemove)) continue; //2015.08.09.
|
||||||
|
writer.write(currentLine + System.getProperty("line.separator"));
|
||||||
|
}
|
||||||
|
writer.close();
|
||||||
|
reader.close();
|
||||||
|
return tempFile.renameTo(inputFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,426 @@
|
||||||
|
package tk.sznp.thebuttonautoflair;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||||
|
|
||||||
|
public class PluginMain extends JavaPlugin
|
||||||
|
{ //Translated to Java: 2015.07.15.
|
||||||
|
//A user, which flair isn't obtainable:
|
||||||
|
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
|
||||||
|
private static PluginMain Instance;
|
||||||
|
// Fired when plugin is first enabled
|
||||||
|
@Override
|
||||||
|
public void onEnable()
|
||||||
|
{
|
||||||
|
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
|
this.getCommand("u").setExecutor(new Commands());
|
||||||
|
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
|
||||||
|
Instance=this; //2015.08.08.
|
||||||
|
LoadFiles(false); //2015.08.09.
|
||||||
|
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
|
||||||
|
Thread t=new Thread(r);
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
Boolean stop=false;
|
||||||
|
// Fired when plugin is disabled
|
||||||
|
@Override
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
SaveFiles(); //2015.08.09.
|
||||||
|
stop=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ThreadMethod() //<-- 2015.07.16.
|
||||||
|
{
|
||||||
|
while(!stop)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
for(Object obj : json)
|
||||||
|
{
|
||||||
|
JSONObject item = (JSONObject)obj;
|
||||||
|
String author=item.getJSONObject("data").getString("author");
|
||||||
|
String ign=item.getJSONObject("data").getString("body");
|
||||||
|
int start = ign.indexOf("IGN:") + "IGN:".length();
|
||||||
|
if(start==-1)
|
||||||
|
continue; //2015.08.09.
|
||||||
|
int end = ign.indexOf(' ', start);
|
||||||
|
if (end == -1 || end == start)
|
||||||
|
end=ign.indexOf('\n', start); //2015.07.15.
|
||||||
|
if (end == -1 || end == start)
|
||||||
|
ign = ign.substring(start);
|
||||||
|
else
|
||||||
|
ign = ign.substring(start, end);
|
||||||
|
ign = ign.trim();
|
||||||
|
if(HasIGFlair(ign))
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
Thread.sleep(10);
|
||||||
|
} catch(InterruptedException ex) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
|
||||||
|
String flair;
|
||||||
|
if(flairdata.length > 1) //2015.07.15.
|
||||||
|
flair = flairdata[1];
|
||||||
|
else
|
||||||
|
flair="";
|
||||||
|
if (flair != "-1")
|
||||||
|
flair = flair + "s";
|
||||||
|
else
|
||||||
|
flair = "non-presser";
|
||||||
|
String flairclass;
|
||||||
|
if(flairdata.length>2)
|
||||||
|
flairclass = flairdata[2];
|
||||||
|
else
|
||||||
|
flairclass="unknown";
|
||||||
|
SetFlair(ign, flair, flairclass, author);
|
||||||
|
}
|
||||||
|
Thread.sleep(10000);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Exception LastException; //2015.08.09.
|
||||||
|
|
||||||
|
public String DownloadString(String urlstr) throws MalformedURLException, IOException
|
||||||
|
{
|
||||||
|
URL url = new URL(urlstr);
|
||||||
|
URLConnection con = url.openConnection();
|
||||||
|
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
|
||||||
|
InputStream in = con.getInputStream();
|
||||||
|
String encoding = con.getContentEncoding();
|
||||||
|
encoding = encoding == null ? "UTF-8" : encoding;
|
||||||
|
String body = IOUtils.toString(in, encoding);
|
||||||
|
in.close();
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> TownColors=new HashMap<String, String>(); //2015.07.20.
|
||||||
|
public Boolean HasIGFlair(String playername)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
|
return p.Flair!=null; //2015.08.08.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFlair(String playername, String text, String flairclass, String username)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
|
String finalflair;
|
||||||
|
p.FlairDecided=true;
|
||||||
|
switch(flairclass)
|
||||||
|
{
|
||||||
|
case "press-1":
|
||||||
|
finalflair="§c("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-2":
|
||||||
|
finalflair="§6("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-3":
|
||||||
|
finalflair="§e("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-4":
|
||||||
|
finalflair="§a("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-5":
|
||||||
|
finalflair="§9("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-6":
|
||||||
|
finalflair="§5("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "no-press":
|
||||||
|
finalflair="§7(non-pr.)§r";
|
||||||
|
break;
|
||||||
|
case "cheater":
|
||||||
|
finalflair="§5("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "cant-press": //2015.08.08.
|
||||||
|
finalflair="§r(can't press)§r";
|
||||||
|
break;
|
||||||
|
case "undecided": //2015.08.09.
|
||||||
|
p.FlairDecided=false;
|
||||||
|
finalflair="";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
finalflair="";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(finalflair.length()==0) //<-- 2015.07.20.
|
||||||
|
return;
|
||||||
|
p.Flair=finalflair; //2015.08.08.
|
||||||
|
p.UserName=username; //2015.08.08.
|
||||||
|
System.out.println("Added new flair to "+playername+": "+finalflair);
|
||||||
|
for(Player player : getServer().getOnlinePlayers()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(player.getName().equals(playername))
|
||||||
|
{
|
||||||
|
//AppendPlayerDisplayFlair(player, username, finalflair);
|
||||||
|
AppendPlayerDisplayFlair(p, player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetFlair(Player player)
|
||||||
|
{ //2015.07.16.
|
||||||
|
String flair=MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair; //2015.08.08.
|
||||||
|
return flair==null ? "" : flair;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
|
||||||
|
public static void AppendPlayerDisplayFlair(MaybeOfflinePlayer player, Player p) //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
|
||||||
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).IgnoredFlair)
|
||||||
|
return;
|
||||||
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).AcceptedFlair)
|
||||||
|
{
|
||||||
|
AppendPlayerDisplayFlairFinal(p, player.Flair); //2015.07.20.
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
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.
|
||||||
|
/*String color = GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on first capital letters
|
||||||
|
String[] colors = color.substring(1).split("§");
|
||||||
|
String displayname=player.getName(); //2015.08.08.
|
||||||
|
ArrayList<Integer> Positions=new ArrayList<>();
|
||||||
|
for(int i=0; i<displayname.length(); i++) {
|
||||||
|
if(Character.isUpperCase(displayname.charAt(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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetColorForTown(String townname)
|
||||||
|
{ //2015.07.20.
|
||||||
|
if(TownColors.containsKey(townname))
|
||||||
|
return TownColors.get(townname);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetPlayerTown(Player player)
|
||||||
|
{ //2015.07.20.
|
||||||
|
try {
|
||||||
|
Town town = WorldCoord.parseWorldCoord(player).getTownBlock().getTown(); //TODO
|
||||||
|
return town.getName();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public static void RemovePlayerDisplayFlairFinal(Player player, String flair)
|
||||||
|
{ //2015.07.20.
|
||||||
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=null; //2015.08.08.
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public static Collection<? extends Player> GetPlayers()
|
||||||
|
{
|
||||||
|
return Instance.getServer().getOnlinePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadFiles(boolean reload) //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
if(reload)
|
||||||
|
{ //2015.08.09.
|
||||||
|
System.out.println("Auto-flair plugin cleanup for reloading...");
|
||||||
|
MaybeOfflinePlayer.AllPlayers.clear();
|
||||||
|
TownColors.clear();
|
||||||
|
}
|
||||||
|
System.out.println("Loading files for auto-flair plugin..."); //2015.08.09.
|
||||||
|
try {
|
||||||
|
File file=new File("flairsaccepted.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
String name=line.replace("\n", "");
|
||||||
|
//System.out.println("Name: " + name);
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(name).AcceptedFlair=true; //2015.08.08.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("flairsignored.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
String name=line.replace("\n", "");
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(name).IgnoredFlair=true; //2015.08.08.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("autoflairconfig.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader(file));
|
||||||
|
String line;
|
||||||
|
while((line=br.readLine())!=null)
|
||||||
|
{
|
||||||
|
String[] s=line.split(" ");
|
||||||
|
if(s.length>=2) //<-- 2015.08.10.
|
||||||
|
TownColors.put(s[0], s[1]);
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("customflairs.txt"); //2015.08.09.
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader(file));
|
||||||
|
String line;
|
||||||
|
while((line=br.readLine())!=null)
|
||||||
|
{
|
||||||
|
String[] s=line.split(" ");
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(s[0]).Flair=s[1]; //2015.08.09.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
//throw new IOException("Test"); //2015.08.09.
|
||||||
|
System.out.println("Auto-flair plugin loaded files!");
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void SaveFiles() //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileWriter fw;
|
||||||
|
fw = new FileWriter("flairsaccepted.txt");
|
||||||
|
fw.close();
|
||||||
|
fw = new FileWriter("flairsignored.txt");
|
||||||
|
fw.close();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
File file=new File("flairsaccepted.txt");
|
||||||
|
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
|
||||||
|
for(MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(!player.AcceptedFlair)
|
||||||
|
continue; //2015.08.08.
|
||||||
|
bw.write(player.PlayerName+"\n");
|
||||||
|
}
|
||||||
|
bw.close();
|
||||||
|
file=new File("flairsignored.txt");
|
||||||
|
bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
|
for(MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(!player.IgnoredFlair)
|
||||||
|
continue; //2015.08.08.
|
||||||
|
bw.write(player.PlayerName+"\n");
|
||||||
|
}
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static boolean RemoveLineFromFile(String file, String line)
|
||||||
|
{ //2015.08.09.
|
||||||
|
File inputFile = new File(file);
|
||||||
|
File tempFile = new File("_temp.txt");
|
||||||
|
|
||||||
|
if(!inputFile.exists())
|
||||||
|
return true; //2015.08.10.
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
|
||||||
|
|
||||||
|
String lineToRemove = line;
|
||||||
|
String currentLine;
|
||||||
|
|
||||||
|
while((currentLine = reader.readLine()) != null) {
|
||||||
|
// trim newline when comparing with lineToRemove
|
||||||
|
String trimmedLine = currentLine.trim();
|
||||||
|
//if(trimmedLine.equals(lineToRemove)) continue;
|
||||||
|
if(trimmedLine.contains(lineToRemove)) continue; //2015.08.09.
|
||||||
|
writer.write(currentLine + System.getProperty("line.separator"));
|
||||||
|
}
|
||||||
|
writer.close();
|
||||||
|
reader.close();
|
||||||
|
return tempFile.renameTo(inputFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,427 @@
|
||||||
|
package tk.sznp.thebuttonautoflair;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||||
|
|
||||||
|
public class PluginMain extends JavaPlugin
|
||||||
|
{ //Translated to Java: 2015.07.15.
|
||||||
|
//A user, which flair isn't obtainable:
|
||||||
|
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
|
||||||
|
private static PluginMain Instance;
|
||||||
|
// Fired when plugin is first enabled
|
||||||
|
@Override
|
||||||
|
public void onEnable()
|
||||||
|
{
|
||||||
|
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
|
this.getCommand("u").setExecutor(new Commands());
|
||||||
|
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
|
||||||
|
Instance=this; //2015.08.08.
|
||||||
|
LoadFiles(false); //2015.08.09.
|
||||||
|
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
|
||||||
|
Thread t=new Thread(r);
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
Boolean stop=false;
|
||||||
|
// Fired when plugin is disabled
|
||||||
|
@Override
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
SaveFiles(); //2015.08.09.
|
||||||
|
stop=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ThreadMethod() //<-- 2015.07.16.
|
||||||
|
{
|
||||||
|
while(!stop)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
for(Object obj : json)
|
||||||
|
{
|
||||||
|
JSONObject item = (JSONObject)obj;
|
||||||
|
String author=item.getJSONObject("data").getString("author");
|
||||||
|
String ign=item.getJSONObject("data").getString("body");
|
||||||
|
int start = ign.indexOf("IGN:") + "IGN:".length();
|
||||||
|
if(start==-1)
|
||||||
|
continue; //2015.08.09.
|
||||||
|
int end = ign.indexOf(' ', start);
|
||||||
|
if (end == -1 || end == start)
|
||||||
|
end=ign.indexOf('\n', start); //2015.07.15.
|
||||||
|
if (end == -1 || end == start)
|
||||||
|
ign = ign.substring(start);
|
||||||
|
else
|
||||||
|
ign = ign.substring(start, end);
|
||||||
|
ign = ign.trim();
|
||||||
|
if(HasIGFlair(ign))
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
Thread.sleep(10);
|
||||||
|
} catch(InterruptedException ex) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
|
||||||
|
String flair;
|
||||||
|
if(flairdata.length > 1) //2015.07.15.
|
||||||
|
flair = flairdata[1];
|
||||||
|
else
|
||||||
|
flair="";
|
||||||
|
if (flair != "-1")
|
||||||
|
flair = flair + "s";
|
||||||
|
else
|
||||||
|
flair = "non-presser";
|
||||||
|
String flairclass;
|
||||||
|
if(flairdata.length>2)
|
||||||
|
flairclass = flairdata[2];
|
||||||
|
else
|
||||||
|
flairclass="unknown";
|
||||||
|
SetFlair(ign, flair, flairclass, author);
|
||||||
|
}
|
||||||
|
Thread.sleep(10000);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Exception LastException; //2015.08.09.
|
||||||
|
|
||||||
|
public String DownloadString(String urlstr) throws MalformedURLException, IOException
|
||||||
|
{
|
||||||
|
URL url = new URL(urlstr);
|
||||||
|
URLConnection con = url.openConnection();
|
||||||
|
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
|
||||||
|
InputStream in = con.getInputStream();
|
||||||
|
String encoding = con.getContentEncoding();
|
||||||
|
encoding = encoding == null ? "UTF-8" : encoding;
|
||||||
|
String body = IOUtils.toString(in, encoding);
|
||||||
|
in.close();
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> TownColors=new HashMap<String, String>(); //2015.07.20.
|
||||||
|
public Boolean HasIGFlair(String playername)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
|
return p.Flair!=null; //2015.08.08.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFlair(String playername, String text, String flairclass, String username)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
|
String finalflair;
|
||||||
|
p.FlairDecided=true;
|
||||||
|
switch(flairclass)
|
||||||
|
{
|
||||||
|
case "press-1":
|
||||||
|
finalflair="§c("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-2":
|
||||||
|
finalflair="§6("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-3":
|
||||||
|
finalflair="§e("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-4":
|
||||||
|
finalflair="§a("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-5":
|
||||||
|
finalflair="§9("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-6":
|
||||||
|
finalflair="§5("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "no-press":
|
||||||
|
finalflair="§7(non-pr.)§r";
|
||||||
|
break;
|
||||||
|
case "cheater":
|
||||||
|
finalflair="§5("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "cant-press": //2015.08.08.
|
||||||
|
finalflair="§r(can't press)§r";
|
||||||
|
break;
|
||||||
|
case "undecided": //2015.08.09.
|
||||||
|
p.FlairDecided=false;
|
||||||
|
finalflair="";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
finalflair="";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(finalflair.length()==0) //<-- 2015.07.20.
|
||||||
|
return;
|
||||||
|
p.Flair=finalflair; //2015.08.08.
|
||||||
|
p.UserName=username; //2015.08.08.
|
||||||
|
System.out.println("Added new flair to "+playername+": "+finalflair);
|
||||||
|
for(Player player : getServer().getOnlinePlayers()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(player.getName().equals(playername))
|
||||||
|
{
|
||||||
|
//AppendPlayerDisplayFlair(player, username, finalflair);
|
||||||
|
AppendPlayerDisplayFlair(p, player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetFlair(Player player)
|
||||||
|
{ //2015.07.16.
|
||||||
|
String flair=MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair; //2015.08.08.
|
||||||
|
return flair==null ? "" : flair;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
|
||||||
|
public static void AppendPlayerDisplayFlair(MaybeOfflinePlayer player, Player p) //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
|
||||||
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).IgnoredFlair)
|
||||||
|
return;
|
||||||
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).AcceptedFlair)
|
||||||
|
{
|
||||||
|
AppendPlayerDisplayFlairFinal(p, player.Flair); //2015.07.20.
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
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.
|
||||||
|
/*String color = GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on first capital letters
|
||||||
|
String[] colors = color.substring(1).split("§");
|
||||||
|
String displayname=player.getName(); //2015.08.08.
|
||||||
|
ArrayList<Integer> Positions=new ArrayList<>();
|
||||||
|
for(int i=0; i<displayname.length(); i++) {
|
||||||
|
if(Character.isUpperCase(displayname.charAt(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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetColorForTown(String townname)
|
||||||
|
{ //2015.07.20.
|
||||||
|
if(TownColors.containsKey(townname))
|
||||||
|
return TownColors.get(townname);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetPlayerTown(Player player)
|
||||||
|
{ //2015.07.20.
|
||||||
|
try {
|
||||||
|
Town town = WorldCoord.parseWorldCoord(player).getTownBlock().getTown(); //TODO
|
||||||
|
return town.getName();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public static void RemovePlayerDisplayFlairFinal(Player player, String flair)
|
||||||
|
{ //2015.07.20.
|
||||||
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=null; //2015.08.08.
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public static Collection<? extends Player> GetPlayers()
|
||||||
|
{
|
||||||
|
return Instance.getServer().getOnlinePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadFiles(boolean reload) //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
if(reload)
|
||||||
|
{ //2015.08.09.
|
||||||
|
System.out.println("Auto-flair plugin cleanup for reloading...");
|
||||||
|
MaybeOfflinePlayer.AllPlayers.clear();
|
||||||
|
TownColors.clear();
|
||||||
|
}
|
||||||
|
System.out.println("Loading files for auto-flair plugin..."); //2015.08.09.
|
||||||
|
try {
|
||||||
|
File file=new File("flairsaccepted.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
String name=line.replace("\n", "");
|
||||||
|
//System.out.println("Name: " + name);
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(name).AcceptedFlair=true; //2015.08.08.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("flairsignored.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
String name=line.replace("\n", "");
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(name).IgnoredFlair=true; //2015.08.08.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("autoflairconfig.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader(file));
|
||||||
|
String line;
|
||||||
|
while((line=br.readLine())!=null)
|
||||||
|
{
|
||||||
|
String[] s=line.split(" ");
|
||||||
|
if(s.length>=2) //<-- 2015.08.10.
|
||||||
|
TownColors.put(s[0], s[1]);
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("customflairs.txt"); //2015.08.09.
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader(file));
|
||||||
|
String line;
|
||||||
|
while((line=br.readLine())!=null)
|
||||||
|
{
|
||||||
|
String[] s=line.split(" ");
|
||||||
|
if(s.length>=2) //2015.08.10.
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(s[0]).Flair=s[1]; //2015.08.09.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
//throw new IOException("Test"); //2015.08.09.
|
||||||
|
System.out.println("Auto-flair plugin loaded files!");
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void SaveFiles() //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileWriter fw;
|
||||||
|
fw = new FileWriter("flairsaccepted.txt");
|
||||||
|
fw.close();
|
||||||
|
fw = new FileWriter("flairsignored.txt");
|
||||||
|
fw.close();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
File file=new File("flairsaccepted.txt");
|
||||||
|
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
|
||||||
|
for(MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(!player.AcceptedFlair)
|
||||||
|
continue; //2015.08.08.
|
||||||
|
bw.write(player.PlayerName+"\n");
|
||||||
|
}
|
||||||
|
bw.close();
|
||||||
|
file=new File("flairsignored.txt");
|
||||||
|
bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
|
for(MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(!player.IgnoredFlair)
|
||||||
|
continue; //2015.08.08.
|
||||||
|
bw.write(player.PlayerName+"\n");
|
||||||
|
}
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static boolean RemoveLineFromFile(String file, String line)
|
||||||
|
{ //2015.08.09.
|
||||||
|
File inputFile = new File(file);
|
||||||
|
File tempFile = new File("_temp.txt");
|
||||||
|
|
||||||
|
if(!inputFile.exists())
|
||||||
|
return true; //2015.08.10.
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
|
||||||
|
|
||||||
|
String lineToRemove = line;
|
||||||
|
String currentLine;
|
||||||
|
|
||||||
|
while((currentLine = reader.readLine()) != null) {
|
||||||
|
// trim newline when comparing with lineToRemove
|
||||||
|
String trimmedLine = currentLine.trim();
|
||||||
|
//if(trimmedLine.equals(lineToRemove)) continue;
|
||||||
|
if(trimmedLine.contains(lineToRemove)) continue; //2015.08.09.
|
||||||
|
writer.write(currentLine + System.getProperty("line.separator"));
|
||||||
|
}
|
||||||
|
writer.close();
|
||||||
|
reader.close();
|
||||||
|
return tempFile.renameTo(inputFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package tk.sznp.thebuttonautoflair;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
import de.inventivegames.TellRawAutoMessage.Reflection;
|
||||||
|
|
||||||
|
public class PlayerListener implements Listener
|
||||||
|
{ //2015.07.16.
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
Player p=event.getPlayer();
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName()); //2015.08.08.
|
||||||
|
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AllPlayers.get(p.getName()); //2015.08.08.
|
||||||
|
if(mp.Flair!=null)
|
||||||
|
PluginMain.AppendPlayerDisplayFlair(mp, p); //2015.08.09.
|
||||||
|
else
|
||||||
|
{ //2015.07.20.
|
||||||
|
String json="[\"\",{\"text\":\"§6Hi! If you'd like your flair displayed ingame, write your Minecraft name to \"},{\"text\":\"[this thread.]\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Click here to go to the Reddit thread§r\"}]}}}]";
|
||||||
|
sendRawMessage(p, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerLeave(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerChat(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer player = MaybeOfflinePlayer.AllPlayers.get(event.getPlayer().getName());
|
||||||
|
String flair=player.Flair; //2015.08.08.
|
||||||
|
if(flair==null || !player.AcceptedFlair)
|
||||||
|
flair=""; //2015.08.08.
|
||||||
|
String message=event.getMessage(); //2015.08.08.
|
||||||
|
/*for(Player p : PluginMain.GetPlayers())
|
||||||
|
{ //2015.08.08.
|
||||||
|
message.replaceAll(p.getName(), )
|
||||||
|
}*/
|
||||||
|
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<?> nmsPacketPlayOutChat = Reflection.getNMSClass("PacketPlayOutChat");
|
||||||
|
public static void sendRawMessage(Player player, String message)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
System.out.println("1");
|
||||||
|
Object handle = Reflection.getHandle(player);
|
||||||
|
System.out.println("2");
|
||||||
|
Object connection = Reflection.getField(handle.getClass(), "playerConnection").get(handle);
|
||||||
|
System.out.println("3");
|
||||||
|
Object serialized = Reflection.getMethod(nmsChatSerializer, "a", String.class).invoke(null, message);
|
||||||
|
System.out.println("4");
|
||||||
|
Object packet = nmsPacketPlayOutChat.getConstructor(Reflection.getNMSClass("IChatBaseComponent")).newInstance(serialized);
|
||||||
|
System.out.println("5");
|
||||||
|
Reflection.getMethod(connection.getClass(), "sendPacket").invoke(connection, packet);
|
||||||
|
System.out.println("6");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
PluginMain.LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,425 @@
|
||||||
|
package tk.sznp.thebuttonautoflair;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||||
|
|
||||||
|
public class PluginMain extends JavaPlugin
|
||||||
|
{ //Translated to Java: 2015.07.15.
|
||||||
|
//A user, which flair isn't obtainable:
|
||||||
|
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
|
||||||
|
private static PluginMain Instance;
|
||||||
|
// Fired when plugin is first enabled
|
||||||
|
@Override
|
||||||
|
public void onEnable()
|
||||||
|
{
|
||||||
|
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
|
this.getCommand("u").setExecutor(new Commands());
|
||||||
|
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
|
||||||
|
Instance=this; //2015.08.08.
|
||||||
|
LoadFiles(false); //2015.08.09.
|
||||||
|
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
|
||||||
|
Thread t=new Thread(r);
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
Boolean stop=false;
|
||||||
|
// Fired when plugin is disabled
|
||||||
|
@Override
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
SaveFiles(); //2015.08.09.
|
||||||
|
stop=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ThreadMethod() //<-- 2015.07.16.
|
||||||
|
{
|
||||||
|
while(!stop)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
for(Object obj : json)
|
||||||
|
{
|
||||||
|
JSONObject item = (JSONObject)obj;
|
||||||
|
String author=item.getJSONObject("data").getString("author");
|
||||||
|
String ign=item.getJSONObject("data").getString("body");
|
||||||
|
int start = ign.indexOf("IGN:") + "IGN:".length();
|
||||||
|
if(start==-1)
|
||||||
|
continue; //2015.08.09.
|
||||||
|
int end = ign.indexOf(' ', start);
|
||||||
|
if (end == -1 || end == start)
|
||||||
|
end=ign.indexOf('\n', start); //2015.07.15.
|
||||||
|
if (end == -1 || end == start)
|
||||||
|
ign = ign.substring(start);
|
||||||
|
else
|
||||||
|
ign = ign.substring(start, end);
|
||||||
|
ign = ign.trim();
|
||||||
|
if(HasIGFlair(ign))
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
Thread.sleep(10);
|
||||||
|
} catch(InterruptedException ex) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
|
||||||
|
String flair;
|
||||||
|
if(flairdata.length > 1) //2015.07.15.
|
||||||
|
flair = flairdata[1];
|
||||||
|
else
|
||||||
|
flair="";
|
||||||
|
if (flair != "-1")
|
||||||
|
flair = flair + "s";
|
||||||
|
else
|
||||||
|
flair = "non-presser";
|
||||||
|
String flairclass;
|
||||||
|
if(flairdata.length>2)
|
||||||
|
flairclass = flairdata[2];
|
||||||
|
else
|
||||||
|
flairclass="unknown";
|
||||||
|
SetFlair(ign, flair, flairclass, author);
|
||||||
|
}
|
||||||
|
Thread.sleep(10000);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Exception LastException; //2015.08.09.
|
||||||
|
|
||||||
|
public String DownloadString(String urlstr) throws MalformedURLException, IOException
|
||||||
|
{
|
||||||
|
URL url = new URL(urlstr);
|
||||||
|
URLConnection con = url.openConnection();
|
||||||
|
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
|
||||||
|
InputStream in = con.getInputStream();
|
||||||
|
String encoding = con.getContentEncoding();
|
||||||
|
encoding = encoding == null ? "UTF-8" : encoding;
|
||||||
|
String body = IOUtils.toString(in, encoding);
|
||||||
|
in.close();
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> TownColors=new HashMap<String, String>(); //2015.07.20.
|
||||||
|
public Boolean HasIGFlair(String playername)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
|
return p.Flair!=null; //2015.08.08.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFlair(String playername, String text, String flairclass, String username)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
|
String finalflair;
|
||||||
|
p.FlairDecided=true;
|
||||||
|
switch(flairclass)
|
||||||
|
{
|
||||||
|
case "press-1":
|
||||||
|
finalflair="§c("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-2":
|
||||||
|
finalflair="§6("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-3":
|
||||||
|
finalflair="§e("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-4":
|
||||||
|
finalflair="§a("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-5":
|
||||||
|
finalflair="§9("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-6":
|
||||||
|
finalflair="§5("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "no-press":
|
||||||
|
finalflair="§7(non-pr.)§r";
|
||||||
|
break;
|
||||||
|
case "cheater":
|
||||||
|
finalflair="§5("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "cant-press": //2015.08.08.
|
||||||
|
finalflair="§r(can't press)§r";
|
||||||
|
break;
|
||||||
|
case "undecided": //2015.08.09.
|
||||||
|
p.FlairDecided=false;
|
||||||
|
finalflair="";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
finalflair="";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(finalflair.length()==0) //<-- 2015.07.20.
|
||||||
|
return;
|
||||||
|
p.Flair=finalflair; //2015.08.08.
|
||||||
|
p.UserName=username; //2015.08.08.
|
||||||
|
System.out.println("Added new flair to "+playername+": "+finalflair);
|
||||||
|
for(Player player : getServer().getOnlinePlayers()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(player.getName().equals(playername))
|
||||||
|
{
|
||||||
|
//AppendPlayerDisplayFlair(player, username, finalflair);
|
||||||
|
AppendPlayerDisplayFlair(p, player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetFlair(Player player)
|
||||||
|
{ //2015.07.16.
|
||||||
|
String flair=MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair; //2015.08.08.
|
||||||
|
return flair==null ? "" : flair;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
|
||||||
|
public static void AppendPlayerDisplayFlair(MaybeOfflinePlayer player, Player p) //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
|
||||||
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).IgnoredFlair)
|
||||||
|
return;
|
||||||
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).AcceptedFlair)
|
||||||
|
{
|
||||||
|
AppendPlayerDisplayFlairFinal(p, player.Flair); //2015.07.20.
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
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.
|
||||||
|
/*String color = GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on first capital letters
|
||||||
|
String[] colors = color.substring(1).split("§");
|
||||||
|
String displayname=player.getName(); //2015.08.08.
|
||||||
|
ArrayList<Integer> Positions=new ArrayList<>();
|
||||||
|
for(int i=0; i<displayname.length(); i++) {
|
||||||
|
if(Character.isUpperCase(displayname.charAt(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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetColorForTown(String townname)
|
||||||
|
{ //2015.07.20.
|
||||||
|
if(TownColors.containsKey(townname))
|
||||||
|
return TownColors.get(townname);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetPlayerTown(Player player)
|
||||||
|
{ //2015.07.20.
|
||||||
|
try {
|
||||||
|
Town town = WorldCoord.parseWorldCoord(player).getTownBlock().getTown(); //TODO
|
||||||
|
return town.getName();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public static void RemovePlayerDisplayFlairFinal(Player player, String flair)
|
||||||
|
{ //2015.07.20.
|
||||||
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=null; //2015.08.08.
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public static Collection<? extends Player> GetPlayers()
|
||||||
|
{
|
||||||
|
return Instance.getServer().getOnlinePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadFiles(boolean reload) //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
if(reload)
|
||||||
|
{ //2015.08.09.
|
||||||
|
System.out.println("Auto-flair plugin cleanup for reloading...");
|
||||||
|
MaybeOfflinePlayer.AllPlayers.clear();
|
||||||
|
TownColors.clear();
|
||||||
|
}
|
||||||
|
System.out.println("Loading files for auto-flair plugin..."); //2015.08.09.
|
||||||
|
try {
|
||||||
|
File file=new File("flairsaccepted.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
String name=line.replace("\n", "");
|
||||||
|
//System.out.println("Name: " + name);
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(name).AcceptedFlair=true; //2015.08.08.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("flairsignored.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
String name=line.replace("\n", "");
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(name).IgnoredFlair=true; //2015.08.08.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("autoflairconfig.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader(file));
|
||||||
|
String line;
|
||||||
|
while((line=br.readLine())!=null)
|
||||||
|
{
|
||||||
|
String[] s=line.split(" ");
|
||||||
|
TownColors.put(s[0], s[1]);
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("customflairs.txt"); //2015.08.09.
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader(file));
|
||||||
|
String line;
|
||||||
|
while((line=br.readLine())!=null)
|
||||||
|
{
|
||||||
|
String[] s=line.split(" ");
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(s[0]).Flair=s[1]; //2015.08.09.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
//throw new IOException("Test"); //2015.08.09.
|
||||||
|
System.out.println("Auto-flair plugin loaded files!");
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void SaveFiles() //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileWriter fw;
|
||||||
|
fw = new FileWriter("flairsaccepted.txt");
|
||||||
|
fw.close();
|
||||||
|
fw = new FileWriter("flairsignored.txt");
|
||||||
|
fw.close();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
File file=new File("flairsaccepted.txt");
|
||||||
|
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
|
||||||
|
for(MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(!player.AcceptedFlair)
|
||||||
|
continue; //2015.08.08.
|
||||||
|
bw.write(player.PlayerName+"\n");
|
||||||
|
}
|
||||||
|
bw.close();
|
||||||
|
file=new File("flairsignored.txt");
|
||||||
|
bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
|
for(MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(!player.IgnoredFlair)
|
||||||
|
continue; //2015.08.08.
|
||||||
|
bw.write(player.PlayerName+"\n");
|
||||||
|
}
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static boolean RemoveLineFromFile(String file, String line)
|
||||||
|
{ //2015.08.09.
|
||||||
|
File inputFile = new File(file);
|
||||||
|
File tempFile = new File("_temp.txt");
|
||||||
|
|
||||||
|
if(!inputFile.exists())
|
||||||
|
return true; //2015.08.10.
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
|
||||||
|
|
||||||
|
String lineToRemove = line;
|
||||||
|
String currentLine;
|
||||||
|
|
||||||
|
while((currentLine = reader.readLine()) != null) {
|
||||||
|
// trim newline when comparing with lineToRemove
|
||||||
|
String trimmedLine = currentLine.trim();
|
||||||
|
//if(trimmedLine.equals(lineToRemove)) continue;
|
||||||
|
if(trimmedLine.contains(lineToRemove)) continue; //2015.08.09.
|
||||||
|
writer.write(currentLine + System.getProperty("line.separator"));
|
||||||
|
}
|
||||||
|
writer.close();
|
||||||
|
reader.close();
|
||||||
|
return tempFile.renameTo(inputFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,426 @@
|
||||||
|
package tk.sznp.thebuttonautoflair;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||||
|
|
||||||
|
public class PluginMain extends JavaPlugin
|
||||||
|
{ //Translated to Java: 2015.07.15.
|
||||||
|
//A user, which flair isn't obtainable:
|
||||||
|
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
|
||||||
|
private static PluginMain Instance;
|
||||||
|
// Fired when plugin is first enabled
|
||||||
|
@Override
|
||||||
|
public void onEnable()
|
||||||
|
{
|
||||||
|
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
|
this.getCommand("u").setExecutor(new Commands());
|
||||||
|
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
|
||||||
|
Instance=this; //2015.08.08.
|
||||||
|
LoadFiles(false); //2015.08.09.
|
||||||
|
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
|
||||||
|
Thread t=new Thread(r);
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
Boolean stop=false;
|
||||||
|
// Fired when plugin is disabled
|
||||||
|
@Override
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
SaveFiles(); //2015.08.09.
|
||||||
|
stop=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ThreadMethod() //<-- 2015.07.16.
|
||||||
|
{
|
||||||
|
while(!stop)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
for(Object obj : json)
|
||||||
|
{
|
||||||
|
JSONObject item = (JSONObject)obj;
|
||||||
|
String author=item.getJSONObject("data").getString("author");
|
||||||
|
String ign=item.getJSONObject("data").getString("body");
|
||||||
|
int start = ign.indexOf("IGN:") + "IGN:".length();
|
||||||
|
if(start==-1)
|
||||||
|
continue; //2015.08.09.
|
||||||
|
int end = ign.indexOf(' ', start);
|
||||||
|
if (end == -1 || end == start)
|
||||||
|
end=ign.indexOf('\n', start); //2015.07.15.
|
||||||
|
if (end == -1 || end == start)
|
||||||
|
ign = ign.substring(start);
|
||||||
|
else
|
||||||
|
ign = ign.substring(start, end);
|
||||||
|
ign = ign.trim();
|
||||||
|
if(HasIGFlair(ign))
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
Thread.sleep(10);
|
||||||
|
} catch(InterruptedException ex) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
|
||||||
|
String flair;
|
||||||
|
if(flairdata.length > 1) //2015.07.15.
|
||||||
|
flair = flairdata[1];
|
||||||
|
else
|
||||||
|
flair="";
|
||||||
|
if (flair != "-1")
|
||||||
|
flair = flair + "s";
|
||||||
|
else
|
||||||
|
flair = "non-presser";
|
||||||
|
String flairclass;
|
||||||
|
if(flairdata.length>2)
|
||||||
|
flairclass = flairdata[2];
|
||||||
|
else
|
||||||
|
flairclass="unknown";
|
||||||
|
SetFlair(ign, flair, flairclass, author);
|
||||||
|
}
|
||||||
|
Thread.sleep(10000);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Exception LastException; //2015.08.09.
|
||||||
|
|
||||||
|
public String DownloadString(String urlstr) throws MalformedURLException, IOException
|
||||||
|
{
|
||||||
|
URL url = new URL(urlstr);
|
||||||
|
URLConnection con = url.openConnection();
|
||||||
|
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
|
||||||
|
InputStream in = con.getInputStream();
|
||||||
|
String encoding = con.getContentEncoding();
|
||||||
|
encoding = encoding == null ? "UTF-8" : encoding;
|
||||||
|
String body = IOUtils.toString(in, encoding);
|
||||||
|
in.close();
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> TownColors=new HashMap<String, String>(); //2015.07.20.
|
||||||
|
public Boolean HasIGFlair(String playername)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
|
return p.Flair!=null; //2015.08.08.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFlair(String playername, String text, String flairclass, String username)
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
|
String finalflair;
|
||||||
|
p.FlairDecided=true;
|
||||||
|
switch(flairclass)
|
||||||
|
{
|
||||||
|
case "press-1":
|
||||||
|
finalflair="§c("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-2":
|
||||||
|
finalflair="§6("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-3":
|
||||||
|
finalflair="§e("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-4":
|
||||||
|
finalflair="§a("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-5":
|
||||||
|
finalflair="§9("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "press-6":
|
||||||
|
finalflair="§5("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "no-press":
|
||||||
|
finalflair="§7(non-pr.)§r";
|
||||||
|
break;
|
||||||
|
case "cheater":
|
||||||
|
finalflair="§5("+text+")§r";
|
||||||
|
break;
|
||||||
|
case "cant-press": //2015.08.08.
|
||||||
|
finalflair="§r(can't press)§r";
|
||||||
|
break;
|
||||||
|
case "undecided": //2015.08.09.
|
||||||
|
p.FlairDecided=false;
|
||||||
|
finalflair="";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
finalflair="";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(finalflair.length()==0) //<-- 2015.07.20.
|
||||||
|
return;
|
||||||
|
p.Flair=finalflair; //2015.08.08.
|
||||||
|
p.UserName=username; //2015.08.08.
|
||||||
|
System.out.println("Added new flair to "+playername+": "+finalflair);
|
||||||
|
for(Player player : getServer().getOnlinePlayers()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(player.getName().equals(playername))
|
||||||
|
{
|
||||||
|
//AppendPlayerDisplayFlair(player, username, finalflair);
|
||||||
|
AppendPlayerDisplayFlair(p, player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetFlair(Player player)
|
||||||
|
{ //2015.07.16.
|
||||||
|
String flair=MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair; //2015.08.08.
|
||||||
|
return flair==null ? "" : flair;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
|
||||||
|
public static void AppendPlayerDisplayFlair(MaybeOfflinePlayer player, Player p) //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
|
||||||
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).IgnoredFlair)
|
||||||
|
return;
|
||||||
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).AcceptedFlair)
|
||||||
|
{
|
||||||
|
AppendPlayerDisplayFlairFinal(p, player.Flair); //2015.07.20.
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
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.
|
||||||
|
/*String color = GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on first capital letters
|
||||||
|
String[] colors = color.substring(1).split("§");
|
||||||
|
String displayname=player.getName(); //2015.08.08.
|
||||||
|
ArrayList<Integer> Positions=new ArrayList<>();
|
||||||
|
for(int i=0; i<displayname.length(); i++) {
|
||||||
|
if(Character.isUpperCase(displayname.charAt(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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetColorForTown(String townname)
|
||||||
|
{ //2015.07.20.
|
||||||
|
if(TownColors.containsKey(townname))
|
||||||
|
return TownColors.get(townname);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetPlayerTown(Player player)
|
||||||
|
{ //2015.07.20.
|
||||||
|
try {
|
||||||
|
Town town = WorldCoord.parseWorldCoord(player).getTownBlock().getTown(); //TODO
|
||||||
|
return town.getName();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public static void RemovePlayerDisplayFlairFinal(Player player, String flair)
|
||||||
|
{ //2015.07.20.
|
||||||
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=null; //2015.08.08.
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public static Collection<? extends Player> GetPlayers()
|
||||||
|
{
|
||||||
|
return Instance.getServer().getOnlinePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadFiles(boolean reload) //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
if(reload)
|
||||||
|
{ //2015.08.09.
|
||||||
|
System.out.println("Auto-flair plugin cleanup for reloading...");
|
||||||
|
MaybeOfflinePlayer.AllPlayers.clear();
|
||||||
|
TownColors.clear();
|
||||||
|
}
|
||||||
|
System.out.println("Loading files for auto-flair plugin..."); //2015.08.09.
|
||||||
|
try {
|
||||||
|
File file=new File("flairsaccepted.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
String name=line.replace("\n", "");
|
||||||
|
//System.out.println("Name: " + name);
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(name).AcceptedFlair=true; //2015.08.08.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("flairsignored.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
String name=line.replace("\n", "");
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(name).IgnoredFlair=true; //2015.08.08.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("autoflairconfig.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader(file));
|
||||||
|
String line;
|
||||||
|
while((line=br.readLine())!=null)
|
||||||
|
{
|
||||||
|
String[] s=line.split(" ");
|
||||||
|
if(s.length>=2)
|
||||||
|
TownColors.put(s[0], s[1]);
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
file=new File("customflairs.txt"); //2015.08.09.
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
BufferedReader br=new BufferedReader(new FileReader(file));
|
||||||
|
String line;
|
||||||
|
while((line=br.readLine())!=null)
|
||||||
|
{
|
||||||
|
String[] s=line.split(" ");
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(s[0]).Flair=s[1]; //2015.08.09.
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
//throw new IOException("Test"); //2015.08.09.
|
||||||
|
System.out.println("Auto-flair plugin loaded files!");
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void SaveFiles() //<-- 2015.08.09.
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileWriter fw;
|
||||||
|
fw = new FileWriter("flairsaccepted.txt");
|
||||||
|
fw.close();
|
||||||
|
fw = new FileWriter("flairsignored.txt");
|
||||||
|
fw.close();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
File file=new File("flairsaccepted.txt");
|
||||||
|
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
|
||||||
|
for(MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(!player.AcceptedFlair)
|
||||||
|
continue; //2015.08.08.
|
||||||
|
bw.write(player.PlayerName+"\n");
|
||||||
|
}
|
||||||
|
bw.close();
|
||||||
|
file=new File("flairsignored.txt");
|
||||||
|
bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
|
for(MaybeOfflinePlayer player : MaybeOfflinePlayer.AllPlayers.values()) //<-- 2015.08.08.
|
||||||
|
{
|
||||||
|
if(!player.IgnoredFlair)
|
||||||
|
continue; //2015.08.08.
|
||||||
|
bw.write(player.PlayerName+"\n");
|
||||||
|
}
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static boolean RemoveLineFromFile(String file, String line)
|
||||||
|
{ //2015.08.09.
|
||||||
|
File inputFile = new File(file);
|
||||||
|
File tempFile = new File("_temp.txt");
|
||||||
|
|
||||||
|
if(!inputFile.exists())
|
||||||
|
return true; //2015.08.10.
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
|
||||||
|
|
||||||
|
String lineToRemove = line;
|
||||||
|
String currentLine;
|
||||||
|
|
||||||
|
while((currentLine = reader.readLine()) != null) {
|
||||||
|
// trim newline when comparing with lineToRemove
|
||||||
|
String trimmedLine = currentLine.trim();
|
||||||
|
//if(trimmedLine.equals(lineToRemove)) continue;
|
||||||
|
if(trimmedLine.contains(lineToRemove)) continue; //2015.08.09.
|
||||||
|
writer.write(currentLine + System.getProperty("line.separator"));
|
||||||
|
}
|
||||||
|
writer.close();
|
||||||
|
reader.close();
|
||||||
|
return tempFile.renameTo(inputFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,265 @@
|
||||||
|
package tk.sznp.thebuttonautoflair;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Commands implements CommandExecutor {
|
||||||
|
// This method is called, when somebody uses our command
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if(args.length<1)
|
||||||
|
return false;
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AllPlayers.get(player.getName()); //2015.08.08.
|
||||||
|
//if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
|
||||||
|
if(p.Flair==null)
|
||||||
|
{
|
||||||
|
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
switch(args[0].toLowerCase()) //toLowerCase: 2015.08.09.
|
||||||
|
{
|
||||||
|
case "accept":
|
||||||
|
{
|
||||||
|
if(p.IgnoredFlair)
|
||||||
|
p.IgnoredFlair=false; //2015.08.08.
|
||||||
|
if(!p.AcceptedFlair)
|
||||||
|
{
|
||||||
|
String flair=p.Flair; //2015.08.08.
|
||||||
|
//PluginMain.AppendPlayerDisplayFlairFinal(player, flair); //2015.07.20.
|
||||||
|
PluginMain.AppendPlayerDisplayFlair(p, player);
|
||||||
|
p.AcceptedFlair=true; //2015.08.08.
|
||||||
|
player.sendMessage("§6Your flair has been set:§r "+flair);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.sendMessage("§cYou already have this user's flair.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "ignore":
|
||||||
|
{
|
||||||
|
if(p.AcceptedFlair)
|
||||||
|
p.AcceptedFlair=false; //2015.08.08.
|
||||||
|
if(!p.IgnoredFlair)
|
||||||
|
{
|
||||||
|
p.IgnoredFlair=true;
|
||||||
|
//String flair=p.Flair; //2015.08.08.
|
||||||
|
//PluginMain.RemovePlayerDisplayFlairFinal(player, flair); //2015.07.20.
|
||||||
|
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.sendMessage("§cYou already ignored this request.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/*case "reload": //2015.07.20.
|
||||||
|
DoReload(player);
|
||||||
|
break;*/
|
||||||
|
case "admin": //2015.08.09.
|
||||||
|
DoAdmin(player, args);
|
||||||
|
break;
|
||||||
|
case "nonpresser": //2015.08.09.
|
||||||
|
if(!p.AcceptedFlair)
|
||||||
|
{
|
||||||
|
player.sendMessage("§cYou need to accept the flair first.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(p.FlairDecided)
|
||||||
|
{
|
||||||
|
player.sendMessage("§cYou have already set the flair type.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//p.Flair="§7(non-pr.)§r";
|
||||||
|
SetPlayerFlair(player, p, "§7(non-pr.)§r");
|
||||||
|
break;
|
||||||
|
case "cantpress": //2015.08.09.
|
||||||
|
if(!p.AcceptedFlair)
|
||||||
|
{
|
||||||
|
player.sendMessage("§cYou need to accept the flair first.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(p.FlairDecided)
|
||||||
|
{
|
||||||
|
player.sendMessage("§cYou have already set the flair type.§r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//p.Flair="§r(can't press)§r";
|
||||||
|
SetPlayerFlair(player, p, "§r(can't pr.)§r");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/*if(args[0].toLowerCase()=="reload")
|
||||||
|
DoReload(null); //2015.07.20.*/
|
||||||
|
else if(args.length>0 && args[0].toLowerCase().equals("admin")) //2015.08.09.
|
||||||
|
{
|
||||||
|
DoAdmin(null, args); //2015.08.09.
|
||||||
|
return true; //2015.08.09.
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private static void DoReload(Player player)
|
||||||
|
{ //2015.07.20.
|
||||||
|
//if(player==null || player.isOp() || player.getName()=="NorbiPeti")
|
||||||
|
//{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File file=new File("autoflairconfig.txt");
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
PluginMain.LoadFiles(true); //2015.08.09.
|
||||||
|
for(Player p : PluginMain.GetPlayers())
|
||||||
|
{
|
||||||
|
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName());
|
||||||
|
if(mp.Flair!=null)
|
||||||
|
{
|
||||||
|
//String flair=mp.Flair;
|
||||||
|
//PluginMain.RemovePlayerDisplayFlairFinal(p, flair);
|
||||||
|
//PluginMain.AppendPlayerDisplayFlairFinal(p, flair);
|
||||||
|
PluginMain.AppendPlayerDisplayFlair(mp, p); //2015.08.09.
|
||||||
|
}
|
||||||
|
String msg="§6Note: The auto-flair plugin has been reloaded. You might need to wait 10s to have your flair.§r"; //2015.08.09.
|
||||||
|
p.sendMessage(msg); //2015.08.09.
|
||||||
|
}
|
||||||
|
//String msg="§6Reloaded config file.§r";
|
||||||
|
//SendMessage(player, msg); //2015.08.09.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
if(player!=null)
|
||||||
|
player.sendMessage("§cAn error occured. See console for details.§r");
|
||||||
|
PluginMain.LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//player.sendMessage("§cYou need to be OP to use this command.§r");
|
||||||
|
}
|
||||||
|
private static Player ReloadPlayer; //2015.08.09.
|
||||||
|
private static void DoAdmin(Player player, String[] args)
|
||||||
|
{ //2015.08.09.
|
||||||
|
if(player==null || player.isOp() || player.getName()=="NorbiPeti")
|
||||||
|
{
|
||||||
|
//System.out.println("Args length: " + args.length);
|
||||||
|
if(args.length==1)
|
||||||
|
{
|
||||||
|
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save|setflair§r";
|
||||||
|
SendMessage(player, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//args[0] is "admin"
|
||||||
|
switch(args[1].toLowerCase())
|
||||||
|
{
|
||||||
|
case "reload":
|
||||||
|
ReloadPlayer=player; //2015.08.09.
|
||||||
|
SendMessage(player, "§6Make sure to save the current settings before you modify and reload them! Type /u admin confirm when done.§r");
|
||||||
|
break;
|
||||||
|
case "playerinfo":
|
||||||
|
DoPlayerInfo(player, args);
|
||||||
|
break;
|
||||||
|
case "getlasterror":
|
||||||
|
DoGetLastError(player, args);
|
||||||
|
case "confirm":
|
||||||
|
if(ReloadPlayer==player)
|
||||||
|
DoReload(player); //2015.08.09.
|
||||||
|
else
|
||||||
|
SendMessage(player, "§cYou need to do /u admin reload first.§r");
|
||||||
|
break;
|
||||||
|
case "save":
|
||||||
|
PluginMain.SaveFiles(); //2015.08.09.
|
||||||
|
SendMessage(player, "§6Saved files. Now you can edit them and reload if you want.§r");
|
||||||
|
break;
|
||||||
|
case "setflair":
|
||||||
|
DoSetFlair(player, args);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save|setflair§r";
|
||||||
|
SendMessage(player, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.sendMessage("§cYou need to be OP to use this command.§r");
|
||||||
|
}
|
||||||
|
private static void DoPlayerInfo(Player player, String[] args)
|
||||||
|
{ //2015.08.09.
|
||||||
|
//args[0] is "admin" - args[1] is "playerinfo"
|
||||||
|
if(args.length==2)
|
||||||
|
{
|
||||||
|
String message="§cUsage: /u admin playerinfo <player>§r";
|
||||||
|
SendMessage(player, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!MaybeOfflinePlayer.AllPlayers.containsKey(args[2]))
|
||||||
|
{
|
||||||
|
String message="§cPlayer not found: "+args[2]+"§r";
|
||||||
|
SendMessage(player, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MaybeOfflinePlayer p = MaybeOfflinePlayer.AllPlayers.get(args[2]);
|
||||||
|
SendMessage(player, "Player name: "+p.PlayerName);
|
||||||
|
SendMessage(player, "User flair: "+p.Flair);
|
||||||
|
SendMessage(player, "Username: "+p.UserName);
|
||||||
|
SendMessage(player, "Flair accepted: "+p.AcceptedFlair);
|
||||||
|
SendMessage(player, "Flair ignored: "+p.IgnoredFlair);
|
||||||
|
}
|
||||||
|
private static void SendMessage(Player player, String message)
|
||||||
|
{ //2015.08.09.
|
||||||
|
if(player==null)
|
||||||
|
System.out.println(message);
|
||||||
|
else
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
private static void DoGetLastError(Player player, String[] args)
|
||||||
|
{ //2015.08.09.
|
||||||
|
//args[0] is "admin" - args[1] is "getlasterror"
|
||||||
|
if(PluginMain.LastException!=null)
|
||||||
|
{
|
||||||
|
SendMessage(player, "Last error:");
|
||||||
|
SendMessage(player, PluginMain.LastException.toString());
|
||||||
|
PluginMain.LastException=null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SendMessage(player, "There were no exceptions.");
|
||||||
|
}
|
||||||
|
private static void SetPlayerFlair(Player player, MaybeOfflinePlayer targetplayer, String flair)
|
||||||
|
{ //2015.08.09.
|
||||||
|
flair=flair.replace('&', '§');
|
||||||
|
targetplayer.Flair=flair;
|
||||||
|
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.PlayerName))
|
||||||
|
{
|
||||||
|
SendMessage(player, "§cError removing previous custom flair!§r");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
File file=new File("customflairs.txt");
|
||||||
|
try {
|
||||||
|
BufferedWriter bw;
|
||||||
|
bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
|
bw.write(targetplayer.PlayerName+"\n");
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error!\n"+e);
|
||||||
|
PluginMain.LastException=e; //2015.08.09.
|
||||||
|
}
|
||||||
|
SendMessage(player, "§6The flair has been set. Player: "+targetplayer.PlayerName+" Flair: "+flair+"§r");
|
||||||
|
}
|
||||||
|
private static void DoSetFlair(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//args[0] is "admin" - args[1] is "setflair"
|
||||||
|
if(args.length<4)
|
||||||
|
{
|
||||||
|
SendMessage(player, "§cUsage: /u admin setflair <playername> <flair>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SetPlayerFlair(player, MaybeOfflinePlayer.AddPlayerIfNeeded(args[2]), args[3]);
|
||||||
|
}
|
||||||
|
}
|
BIN
.metadata/.plugins/org.eclipse.core.resources/.snap
Normal file
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="ASCII"?>
|
<?xml version="1.0" encoding="ASCII"?>
|
||||||
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_37VdISr0EeWsptewEJl0pA" elementId="org.eclipse.e4.legacy.ide.application" contributorURI="platform:/plugin/org.eclipse.ui.workbench" selectedElement="_37ZukCr0EeWsptewEJl0pA" bindingContexts="_37ZumSr0EeWsptewEJl0pA">
|
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_37VdISr0EeWsptewEJl0pA" elementId="org.eclipse.e4.legacy.ide.application" contributorURI="platform:/plugin/org.eclipse.ui.workbench" selectedElement="_37ZukCr0EeWsptewEJl0pA" bindingContexts="_37ZumSr0EeWsptewEJl0pA">
|
||||||
<tags>activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration</tags>
|
<tags>activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration</tags>
|
||||||
<children xsi:type="basic:TrimmedWindow" xmi:id="_37ZukCr0EeWsptewEJl0pA" elementId="IDEWindow" contributorURI="platform:/plugin/org.eclipse.ui.workbench" selectedElement="_422DICr0EeWsptewEJl0pA" x="358" y="3" width="1024" height="768">
|
<children xsi:type="basic:TrimmedWindow" xmi:id="_37ZukCr0EeWsptewEJl0pA" elementId="IDEWindow" contributorURI="platform:/plugin/org.eclipse.ui.workbench" selectedElement="_422DICr0EeWsptewEJl0pA" x="0" y="0" width="1024" height="768">
|
||||||
<tags>topLevel</tags>
|
<tags>topLevel</tags>
|
||||||
<tags>shellMaximized</tags>
|
<tags>shellMaximized</tags>
|
||||||
<children xsi:type="basic:PartSashContainer" xmi:id="_422DICr0EeWsptewEJl0pA" selectedElement="_422DISr0EeWsptewEJl0pA" horizontal="true">
|
<children xsi:type="basic:PartSashContainer" xmi:id="_422DICr0EeWsptewEJl0pA" selectedElement="_422DISr0EeWsptewEJl0pA" horizontal="true">
|
||||||
|
@ -240,13 +240,13 @@
|
||||||
<tags>org.eclipse.e4.primaryDataStack</tags>
|
<tags>org.eclipse.e4.primaryDataStack</tags>
|
||||||
<tags>EditorStack</tags>
|
<tags>EditorStack</tags>
|
||||||
<children xsi:type="basic:Part" xmi:id="_x5zFcC76EeWkOu0XsaZg2g" elementId="org.eclipse.e4.ui.compatibility.editor" contributionURI="bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor" label="PluginMain.java" iconURI="platform:/plugin/org.eclipse.jdt.ui/icons/full/obj16/jcu_obj.gif" tooltip="TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PluginMain.java" closeable="true">
|
<children xsi:type="basic:Part" xmi:id="_x5zFcC76EeWkOu0XsaZg2g" elementId="org.eclipse.e4.ui.compatibility.editor" contributionURI="bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor" label="PluginMain.java" iconURI="platform:/plugin/org.eclipse.jdt.ui/icons/full/obj16/jcu_obj.gif" tooltip="TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PluginMain.java" closeable="true">
|
||||||
<persistedState key="memento" value="<?xml version="1.0" encoding="UTF-8"?>
<editor id="org.eclipse.jdt.ui.CompilationUnitEditor">
<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PluginMain.java"/>
<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="2545" selectionTopPixel="570"/>
</editor>"/>
|
<persistedState key="memento" value="<?xml version="1.0" encoding="UTF-8"?>
<editor id="org.eclipse.jdt.ui.CompilationUnitEditor">
<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PluginMain.java"/>
<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="13069" selectionTopPixel="5523"/>
</editor>"/>
|
||||||
<tags>Editor</tags>
|
<tags>Editor</tags>
|
||||||
<tags>org.eclipse.jdt.ui.CompilationUnitEditor</tags>
|
<tags>org.eclipse.jdt.ui.CompilationUnitEditor</tags>
|
||||||
<tags>removeOnHide</tags>
|
<tags>removeOnHide</tags>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="basic:Part" xmi:id="_h4cFECuhEeWsptewEJl0pA" elementId="org.eclipse.e4.ui.compatibility.editor" contributionURI="bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor" label="Commands.java" iconURI="platform:/plugin/org.eclipse.jdt.ui/icons/full/obj16/jcu_obj.gif" tooltip="TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/Commands.java" closeable="true">
|
<children xsi:type="basic:Part" xmi:id="_h4cFECuhEeWsptewEJl0pA" elementId="org.eclipse.e4.ui.compatibility.editor" contributionURI="bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor" label="Commands.java" iconURI="platform:/plugin/org.eclipse.jdt.ui/icons/full/obj16/jcu_obj.gif" tooltip="TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/Commands.java" closeable="true">
|
||||||
<persistedState key="memento" value="<?xml version="1.0" encoding="UTF-8"?>
<editor id="org.eclipse.jdt.ui.CompilationUnitEditor">
<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/Commands.java"/>
<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="6299" selectionTopPixel="2343"/>
</editor>"/>
|
<persistedState key="memento" value="<?xml version="1.0" encoding="UTF-8"?>
<editor id="org.eclipse.jdt.ui.CompilationUnitEditor">
<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/Commands.java"/>
<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="3355" selectionTopPixel="1022"/>
</editor>"/>
|
||||||
<tags>Editor</tags>
|
<tags>Editor</tags>
|
||||||
<tags>org.eclipse.jdt.ui.CompilationUnitEditor</tags>
|
<tags>org.eclipse.jdt.ui.CompilationUnitEditor</tags>
|
||||||
<tags>removeOnHide</tags>
|
<tags>removeOnHide</tags>
|
||||||
|
@ -318,7 +318,7 @@
|
||||||
<tags>categoryTag:General</tags>
|
<tags>categoryTag:General</tags>
|
||||||
</sharedElements>
|
</sharedElements>
|
||||||
<sharedElements xsi:type="basic:Part" xmi:id="_77aAUCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.views.ProblemView" contributionURI="bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityView" label="Problems" iconURI="platform:/plugin/org.eclipse.ui.ide/icons/full/eview16/problems_view.gif" tooltip="0 errors, 2 warnings, 0 others" closeable="true">
|
<sharedElements xsi:type="basic:Part" xmi:id="_77aAUCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.views.ProblemView" contributionURI="bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityView" label="Problems" iconURI="platform:/plugin/org.eclipse.ui.ide/icons/full/eview16/problems_view.gif" tooltip="0 errors, 2 warnings, 0 others" closeable="true">
|
||||||
<persistedState key="memento" value="<?xml version="1.0" encoding="UTF-8"?>
<view PRIMARY_SORT_FIELD="org.eclipse.ui.ide.severityAndDescriptionField" categoryGroup="org.eclipse.ui.ide.severity" markerContentGenerator="org.eclipse.ui.ide.problemsGenerator" partName="Problems">
<expanded>
<category IMemento.internal.id="Errors"/>
<category IMemento.internal.id="Warnings (3 items)"/>
</expanded>
<columnWidths org.eclipse.ui.ide.locationField="90" org.eclipse.ui.ide.markerType="90" org.eclipse.ui.ide.pathField="120" org.eclipse.ui.ide.resourceField="90" org.eclipse.ui.ide.severityAndDescriptionField="300"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.severityAndDescriptionField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.resourceField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.pathField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.locationField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.markerType"/>
</view>"/>
|
<persistedState key="memento" value="<?xml version="1.0" encoding="UTF-8"?>
<view PRIMARY_SORT_FIELD="org.eclipse.ui.ide.severityAndDescriptionField" categoryGroup="org.eclipse.ui.ide.severity" markerContentGenerator="org.eclipse.ui.ide.problemsGenerator" partName="Problems">
<expanded>
<category IMemento.internal.id="Errors"/>
<category IMemento.internal.id="Warnings"/>
<category IMemento.internal.id="Warnings (4 items)"/>
</expanded>
<columnWidths org.eclipse.ui.ide.locationField="90" org.eclipse.ui.ide.markerType="90" org.eclipse.ui.ide.pathField="120" org.eclipse.ui.ide.resourceField="90" org.eclipse.ui.ide.severityAndDescriptionField="300"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.severityAndDescriptionField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.resourceField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.pathField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.locationField"/>
<visible IMemento.internal.id="org.eclipse.ui.ide.markerType"/>
</view>"/>
|
||||||
<tags>View</tags>
|
<tags>View</tags>
|
||||||
<tags>categoryTag:General</tags>
|
<tags>categoryTag:General</tags>
|
||||||
<menus xmi:id="_dGEOYCr1EeWsptewEJl0pA" elementId="org.eclipse.ui.views.ProblemView">
|
<menus xmi:id="_dGEOYCr1EeWsptewEJl0pA" elementId="org.eclipse.ui.views.ProblemView">
|
||||||
|
@ -420,18 +420,18 @@
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_6K2osCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.workbench.file">
|
<children xsi:type="menu:ToolBar" xmi:id="_6K2osCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.workbench.file">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMD_QD6DEeW1foNNhiR-Xw" elementId="new.group"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_HID7YEeWz3JF-N665Zw" elementId="new.group"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMEmUD6DEeW1foNNhiR-Xw" elementId="newWizardDropDown"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_uMD7YEeWz3JF-N665Zw" elementId="newWizardDropDown"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMFNYD6DEeW1foNNhiR-Xw" elementId="new.ext" visible="false"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_uMT7YEeWz3JF-N665Zw" elementId="new.ext" visible="false"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMFNYT6DEeW1foNNhiR-Xw" elementId="save.group" visible="false"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_uMj7YEeWz3JF-N665Zw" elementId="save.group" visible="false"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMFNYj6DEeW1foNNhiR-Xw" elementId="save"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_uMz7YEeWz3JF-N665Zw" elementId="save"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMFNYz6DEeW1foNNhiR-Xw" elementId="saveAll"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_uND7YEeWz3JF-N665Zw" elementId="saveAll"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMF0cD6DEeW1foNNhiR-Xw" elementId="save.ext" visible="false"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjAVQD7YEeWz3JF-N665Zw" elementId="save.ext" visible="false"/>
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_nMHCkD6DEeW1foNNhiR-Xw" iconURI="platform:/plugin/org.eclipse.ui/icons/full/etool16/print_edit.gif" tooltip="Print" command="_3_hZmSr0EeWsptewEJl0pA"/>
|
<children xsi:type="menu:HandledToolItem" xmi:id="_cjA8UD7YEeWz3JF-N665Zw" iconURI="platform:/plugin/org.eclipse.ui/icons/full/etool16/print_edit.gif" tooltip="Print" command="_3_hZmSr0EeWsptewEJl0pA"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMNwQD6DEeW1foNNhiR-Xw" elementId="print.ext" visible="false"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjEmsD7YEeWz3JF-N665Zw" elementId="print.ext" visible="false"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMOXUD6DEeW1foNNhiR-Xw" elementId="build.group"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjFNwD7YEeWz3JF-N665Zw" elementId="build.group"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMO-YD6DEeW1foNNhiR-Xw" elementId="build.ext" visible="false"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjFNwT7YEeWz3JF-N665Zw" elementId="build.ext" visible="false"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMO-YT6DEeW1foNNhiR-Xw" elementId="additions"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjFNwj7YEeWz3JF-N665Zw" elementId="additions"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_6K2osSr0EeWsptewEJl0pA" elementId="additions" toBeRendered="false">
|
<children xsi:type="menu:ToolBar" xmi:id="_6K2osSr0EeWsptewEJl0pA" elementId="additions" toBeRendered="false">
|
||||||
<tags>toolbarSeparator</tags>
|
<tags>toolbarSeparator</tags>
|
||||||
|
@ -439,38 +439,38 @@
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_dIOxkCr1EeWsptewEJl0pA" elementId="adt.actionSet.avdManager">
|
<children xsi:type="menu:ToolBar" xmi:id="_dIOxkCr1EeWsptewEJl0pA" elementId="adt.actionSet.avdManager">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXHYsD6DEeW1foNNhiR-Xw" elementId="android_project"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDhoYD7YEeWz3JF-N665Zw" elementId="android_project"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXH_wD6DEeW1foNNhiR-Xw" elementId="com.android.ide.eclipse.adt.ui.sdkmanager"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDi2gD7YEeWz3JF-N665Zw" elementId="com.android.ide.eclipse.adt.ui.sdkmanager"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXH_wT6DEeW1foNNhiR-Xw" elementId="com.android.ide.eclipse.adt.ui.avdmanager"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDi2gT7YEeWz3JF-N665Zw" elementId="com.android.ide.eclipse.adt.ui.avdmanager"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_Mv4F0C3kEeWvSKv3oe_gqg" elementId="org.eclipse.debug.ui.breakpointActionSet">
|
<children xsi:type="menu:ToolBar" xmi:id="_Mv4F0C3kEeWvSKv3oe_gqg" elementId="org.eclipse.debug.ui.breakpointActionSet">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXIm0D6DEeW1foNNhiR-Xw" elementId="breakpointGroup"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDi2gj7YEeWz3JF-N665Zw" elementId="breakpointGroup"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXJN4D6DEeW1foNNhiR-Xw" elementId="org.eclipse.debug.ui.actions.SkipAllBreakpoints"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDi2gz7YEeWz3JF-N665Zw" elementId="org.eclipse.debug.ui.actions.SkipAllBreakpoints"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_dI4R0Cr1EeWsptewEJl0pA" elementId="adt.actionSet.lint">
|
<children xsi:type="menu:ToolBar" xmi:id="_dI4R0Cr1EeWsptewEJl0pA" elementId="adt.actionSet.lint">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXJN4T6DEeW1foNNhiR-Xw" elementId="android_project"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDi2hD7YEeWz3JF-N665Zw" elementId="android_project"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXJ08D6DEeW1foNNhiR-Xw" elementId="com.android.ide.eclipse.adt.ui.lintrunner"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdkD7YEeWz3JF-N665Zw" elementId="com.android.ide.eclipse.adt.ui.lintrunner"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_dIyyQCr1EeWsptewEJl0pA" elementId="adt.actionSet.wizards">
|
<children xsi:type="menu:ToolBar" xmi:id="_dIyyQCr1EeWsptewEJl0pA" elementId="adt.actionSet.wizards">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXJ08T6DEeW1foNNhiR-Xw" elementId="android_project"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdkT7YEeWz3JF-N665Zw" elementId="android_project"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXJ08j6DEeW1foNNhiR-Xw" elementId="com.android.ide.eclipse.adt.wizards.actions.NewXmlFileAction"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdkj7YEeWz3JF-N665Zw" elementId="com.android.ide.eclipse.adt.wizards.actions.NewXmlFileAction"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_8zAWsCr0EeWsptewEJl0pA" elementId="org.eclipse.debug.ui.launchActionSet">
|
<children xsi:type="menu:ToolBar" xmi:id="_8zAWsCr0EeWsptewEJl0pA" elementId="org.eclipse.debug.ui.launchActionSet">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXJ08z6DEeW1foNNhiR-Xw" elementId="debug"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdkz7YEeWz3JF-N665Zw" elementId="debug"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXLDED6DEeW1foNNhiR-Xw" elementId="org.eclipse.debug.internal.ui.actions.DebugDropDownAction"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdlD7YEeWz3JF-N665Zw" elementId="org.eclipse.debug.internal.ui.actions.DebugDropDownAction"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXP7kD6DEeW1foNNhiR-Xw" elementId="org.eclipse.debug.internal.ui.actions.RunDropDownAction"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdlT7YEeWz3JF-N665Zw" elementId="org.eclipse.debug.internal.ui.actions.RunDropDownAction"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXQioD6DEeW1foNNhiR-Xw" elementId="org.eclipse.ui.externaltools.ExternalToolMenuDelegateToolbar"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEoD7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.externaltools.ExternalToolMenuDelegateToolbar"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_dG7xECr1EeWsptewEJl0pA" elementId="org.eclipse.jdt.ui.JavaElementCreationActionSet">
|
<children xsi:type="menu:ToolBar" xmi:id="_dG7xECr1EeWsptewEJl0pA" elementId="org.eclipse.jdt.ui.JavaElementCreationActionSet">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXQioT6DEeW1foNNhiR-Xw" elementId="JavaWizards"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEoT7YEeWz3JF-N665Zw" elementId="JavaWizards"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXQioj6DEeW1foNNhiR-Xw" elementId="org.eclipse.jdt.ui.actions.OpenProjectWizard"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEoj7YEeWz3JF-N665Zw" elementId="org.eclipse.jdt.ui.actions.OpenProjectWizard"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXQioz6DEeW1foNNhiR-Xw" elementId="org.eclipse.jdt.ui.actions.OpenPackageWizard"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEoz7YEeWz3JF-N665Zw" elementId="org.eclipse.jdt.ui.actions.OpenPackageWizard"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXRJsD6DEeW1foNNhiR-Xw" elementId="org.eclipse.jdt.ui.actions.NewTypeDropDown"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEpD7YEeWz3JF-N665Zw" elementId="org.eclipse.jdt.ui.actions.NewTypeDropDown"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_8voSkCr0EeWsptewEJl0pA" elementId="org.eclipse.jst.j2ee.J2eeMainActionSet" visible="false">
|
<children xsi:type="menu:ToolBar" xmi:id="_8voSkCr0EeWsptewEJl0pA" elementId="org.eclipse.jst.j2ee.J2eeMainActionSet" visible="false">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
|
@ -480,20 +480,20 @@
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_8xJVgCr0EeWsptewEJl0pA" elementId="org.eclipse.search.searchActionSet">
|
<children xsi:type="menu:ToolBar" xmi:id="_8xJVgCr0EeWsptewEJl0pA" elementId="org.eclipse.search.searchActionSet">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXRJsT6DEeW1foNNhiR-Xw" elementId="Search"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEpT7YEeWz3JF-N665Zw" elementId="Search"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXRJsj6DEeW1foNNhiR-Xw" elementId="openType"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrsD7YEeWz3JF-N665Zw" elementId="openType"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXRJsz6DEeW1foNNhiR-Xw" elementId="org.eclipse.mylyn.tasks.ui.openTask"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrsT7YEeWz3JF-N665Zw" elementId="org.eclipse.mylyn.tasks.ui.openTask"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXRwwD6DEeW1foNNhiR-Xw" elementId="org.eclipse.search.OpenSearchDialogPage"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrsj7YEeWz3JF-N665Zw" elementId="org.eclipse.search.OpenSearchDialogPage"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_Slo_UC3kEeWvSKv3oe_gqg" elementId="org.eclipse.ui.edit.text.actionSet.presentation">
|
<children xsi:type="menu:ToolBar" xmi:id="_Slo_UC3kEeWvSKv3oe_gqg" elementId="org.eclipse.ui.edit.text.actionSet.presentation">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pZ7lAD6DEeW1foNNhiR-Xw" elementId="Presentation"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_o5UKoD7YEeWz3JF-N665Zw" elementId="Presentation"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pZ7lAT6DEeW1foNNhiR-Xw" elementId="org.eclipse.jdt.ui.edit.text.java.toggleBreadcrumb"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_o5UKoT7YEeWz3JF-N665Zw" elementId="org.eclipse.jdt.ui.edit.text.java.toggleBreadcrumb"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pZ8zID6DEeW1foNNhiR-Xw" elementId="org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_o5UKoj7YEeWz3JF-N665Zw" elementId="org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pZ9aMD6DEeW1foNNhiR-Xw" elementId="org.eclipse.mylyn.java.ui.editor.folding.auto"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_o5UxsD7YEeWz3JF-N665Zw" elementId="org.eclipse.mylyn.java.ui.editor.folding.auto"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pZ9aMT6DEeW1foNNhiR-Xw" elementId="org.eclipse.ui.edit.text.toggleBlockSelectionMode"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_o5UxsT7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.toggleBlockSelectionMode"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pZ-BQD6DEeW1foNNhiR-Xw" elementId="org.eclipse.ui.edit.text.toggleShowWhitespaceCharacters"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_o5Uxsj7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.toggleShowWhitespaceCharacters"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_paAdgD6DEeW1foNNhiR-Xw" elementId="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_o5Uxsz7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_8wdZACr0EeWsptewEJl0pA" elementId="org.eclipse.wst.server.ui.internal.webbrowser.actionSet" visible="false">
|
<children xsi:type="menu:ToolBar" xmi:id="_8wdZACr0EeWsptewEJl0pA" elementId="org.eclipse.wst.server.ui.internal.webbrowser.actionSet" visible="false">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
|
@ -511,15 +511,15 @@
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_6LTUoCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.workbench.navigate">
|
<children xsi:type="menu:ToolBar" xmi:id="_6LTUoCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.workbench.navigate">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMPlcD6DEeW1foNNhiR-Xw" elementId="history.group"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjFNwz7YEeWz3JF-N665Zw" elementId="history.group"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMPlcT6DEeW1foNNhiR-Xw" elementId="group.application" visible="false"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjFNxD7YEeWz3JF-N665Zw" elementId="group.application" visible="false"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMPlcj6DEeW1foNNhiR-Xw" elementId="backardHistory"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjF00D7YEeWz3JF-N665Zw" elementId="backardHistory"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMQMgD6DEeW1foNNhiR-Xw" elementId="forwardHistory"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjF00T7YEeWz3JF-N665Zw" elementId="forwardHistory"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMRaoD6DEeW1foNNhiR-Xw" elementId="pin.group"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjF00j7YEeWz3JF-N665Zw" elementId="pin.group"/>
|
||||||
<children xsi:type="menu:HandledToolItem" xmi:id="_nMSBsD6DEeW1foNNhiR-Xw" iconURI="platform:/plugin/org.eclipse.ui/icons/full/etool16/pin_editor.gif" tooltip="Pin the current editor" enabled="false" command="_3_eWRCr0EeWsptewEJl0pA"/>
|
<children xsi:type="menu:HandledToolItem" xmi:id="_cjGb4D7YEeWz3JF-N665Zw" iconURI="platform:/plugin/org.eclipse.ui/icons/full/etool16/pin_editor.gif" tooltip="Pin the current editor" enabled="false" command="_3_eWRCr0EeWsptewEJl0pA"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXRwwT6DEeW1foNNhiR-Xw" elementId="org.eclipse.ui.edit.text.gotoNextAnnotation"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrsz7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.gotoNextAnnotation"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXRwwj6DEeW1foNNhiR-Xw" elementId="org.eclipse.ui.edit.text.gotoPreviousAnnotation"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrtD7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.gotoPreviousAnnotation"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nXSX0D6DEeW1foNNhiR-Xw" elementId="org.eclipse.ui.edit.text.gotoLastEditPosition"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrtT7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.gotoLastEditPosition"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_6LTUoSr0EeWsptewEJl0pA" elementId="group.editor" toBeRendered="false">
|
<children xsi:type="menu:ToolBar" xmi:id="_6LTUoSr0EeWsptewEJl0pA" elementId="group.editor" toBeRendered="false">
|
||||||
<tags>toolbarSeparator</tags>
|
<tags>toolbarSeparator</tags>
|
||||||
|
@ -531,8 +531,8 @@
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolBar" xmi:id="_6LT7sCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.workbench.help" visible="false">
|
<children xsi:type="menu:ToolBar" xmi:id="_6LT7sCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.workbench.help" visible="false">
|
||||||
<tags>Draggable</tags>
|
<tags>Draggable</tags>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMSowD6DEeW1foNNhiR-Xw" elementId="group.help"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjHC8D7YEeWz3JF-N665Zw" elementId="group.help"/>
|
||||||
<children xsi:type="menu:OpaqueToolItem" xmi:id="_nMSowT6DEeW1foNNhiR-Xw" elementId="group.application" visible="false"/>
|
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjHC8T7YEeWz3JF-N665Zw" elementId="group.application" visible="false"/>
|
||||||
</children>
|
</children>
|
||||||
<children xsi:type="menu:ToolControl" xmi:id="_61nc8Cr0EeWsptewEJl0pA" elementId="PerspectiveSpacer" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.LayoutModifierToolControl">
|
<children xsi:type="menu:ToolControl" xmi:id="_61nc8Cr0EeWsptewEJl0pA" elementId="PerspectiveSpacer" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.LayoutModifierToolControl">
|
||||||
<tags>stretch</tags>
|
<tags>stretch</tags>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
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
|
||||||
1508644233.index
|
3656756579.index
|
||||||
3089967703.index
|
3089967703.index
|
||||||
2674037006.index
|
2674037006.index
|
||||||
323251068.index
|
323251068.index
|
||||||
355369697.index
|
355369697.index
|
||||||
3716007315.index
|
|
||||||
1934142626.index
|
1934142626.index
|
||||||
|
3716007315.index
|
||||||
1045485630.index
|
1045485630.index
|
||||||
605290374.index
|
605290374.index
|
||||||
533208796.index
|
533208796.index
|
||||||
|
@ -22,5 +22,5 @@ INDEX VERSION 1.126+D:\Z - Norbi cucca\0 Projektek\TheButtonMCAutoFlairProto\Spi
|
||||||
3954291735.index
|
3954291735.index
|
||||||
994834796.index
|
994834796.index
|
||||||
3604769962.index
|
3604769962.index
|
||||||
|
1508644233.index
|
||||||
3045053200.index
|
3045053200.index
|
||||||
3656756579.index
|
|
||||||
|
|
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 478 B |
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 281 B After Width: | Height: | Size: 147 B |
Before Width: | Height: | Size: 194 B |
Before Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 238 B |
|
@ -10,4 +10,5 @@
|
||||||
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439117083199_7" label="Window Working Set" name="Aggregate for window 1439117083199"/>
|
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439117083199_7" label="Window Working Set" name="Aggregate for window 1439117083199"/>
|
||||||
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439146681639_8" label="Window Working Set" name="Aggregate for window 1439146681638"/>
|
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439146681639_8" label="Window Working Set" name="Aggregate for window 1439146681638"/>
|
||||||
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439153581866_9" label="Window Working Set" name="Aggregate for window 1439153581866"/>
|
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439153581866_9" label="Window Working Set" name="Aggregate for window 1439153581866"/>
|
||||||
|
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439184130737_10" label="Window Working Set" name="Aggregate for window 1439184130737"/>
|
||||||
</workingSetManager>
|
</workingSetManager>
|
|
@ -35,8 +35,8 @@ public class Commands implements CommandExecutor {
|
||||||
{
|
{
|
||||||
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.
|
||||||
PluginMain.AppendPlayerDisplayFlair(p, player);
|
|
||||||
p.AcceptedFlair=true; //2015.08.08.
|
p.AcceptedFlair=true; //2015.08.08.
|
||||||
|
PluginMain.AppendPlayerDisplayFlair(p, player);
|
||||||
player.sendMessage("§6Your flair has been set:§r "+flair);
|
player.sendMessage("§6Your flair has been set:§r "+flair);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -86,7 +86,7 @@ public class Commands implements CommandExecutor {
|
||||||
}
|
}
|
||||||
if(p.FlairDecided)
|
if(p.FlairDecided)
|
||||||
{
|
{
|
||||||
player.sendMessage("§cYou have already set the flair type.§r");
|
player.sendMessage("§cYou have already set the flair type or your flair type is known.§r");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//p.Flair="§r(can't press)§r";
|
//p.Flair="§r(can't press)§r";
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class PlayerListener implements Listener
|
||||||
PluginMain.AppendPlayerDisplayFlair(mp, p); //2015.08.09.
|
PluginMain.AppendPlayerDisplayFlair(mp, p); //2015.08.09.
|
||||||
else
|
else
|
||||||
{ //2015.07.20.
|
{ //2015.07.20.
|
||||||
String json="[\"\",{\"text\":\"§6Hi! If you'd like your flair displayed ingame, write your Minecraft name to \"},{\"text\":\"[this thread.]\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Click here to go to the Reddit thread§r\"}]}}}]";
|
String json="[\"\",{\"text\":\"§6Hi! If you'd like your flair displayed ingame, write your §6Minecraft name to \"},{\"text\":\"[this thread.]\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Click here to go to the Reddit thread§r\"}]}}}]";
|
||||||
sendRawMessage(p, json);
|
sendRawMessage(p, json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ public class PluginMain extends JavaPlugin
|
||||||
|
|
||||||
private static void AppendPlayerDisplayFlairFinal(Player player, String flair)
|
private static void AppendPlayerDisplayFlairFinal(Player player, String flair)
|
||||||
{ //2015.07.20.
|
{ //2015.07.20.
|
||||||
String color = GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on first capital letters
|
/*String color = GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on first capital letters
|
||||||
String[] colors = color.substring(1).split("§");
|
String[] colors = color.substring(1).split("§");
|
||||||
String displayname=player.getName(); //2015.08.08.
|
String displayname=player.getName(); //2015.08.08.
|
||||||
ArrayList<Integer> Positions=new ArrayList<>();
|
ArrayList<Integer> Positions=new ArrayList<>();
|
||||||
|
@ -255,7 +255,7 @@ public class PluginMain extends JavaPlugin
|
||||||
String substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
|
String substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
|
||||||
finalname+=substr;
|
finalname+=substr;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
|
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,8 @@ public class PluginMain extends JavaPlugin
|
||||||
while((line=br.readLine())!=null)
|
while((line=br.readLine())!=null)
|
||||||
{
|
{
|
||||||
String[] s=line.split(" ");
|
String[] s=line.split(" ");
|
||||||
TownColors.put(s[0], s[1]);
|
if(s.length>=2) //<-- 2015.08.10.
|
||||||
|
TownColors.put(s[0], s[1]);
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
}
|
}
|
||||||
|
@ -341,7 +342,8 @@ public class PluginMain extends JavaPlugin
|
||||||
while((line=br.readLine())!=null)
|
while((line=br.readLine())!=null)
|
||||||
{
|
{
|
||||||
String[] s=line.split(" ");
|
String[] s=line.split(" ");
|
||||||
MaybeOfflinePlayer.AddPlayerIfNeeded(s[0]).Flair=s[1]; //2015.08.09.
|
if(s.length>=2) //2015.08.10.
|
||||||
|
MaybeOfflinePlayer.AddPlayerIfNeeded(s[0]).Flair=s[1]; //2015.08.09.
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
}
|
}
|
||||||
|
@ -383,7 +385,7 @@ public class PluginMain extends JavaPlugin
|
||||||
{
|
{
|
||||||
if(!player.IgnoredFlair)
|
if(!player.IgnoredFlair)
|
||||||
continue; //2015.08.08.
|
continue; //2015.08.08.
|
||||||
bw.write(player.PlayerName+"\n");
|
bw.write(player.PlayerName+" "+player.Flair+"\n");
|
||||||
}
|
}
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|