Fixed comment parsing

This commit is contained in:
Norbi Peti 2015-08-10 20:22:29 +02:00
parent 82d6f40173
commit 691f247cc6
88 changed files with 1122 additions and 13564 deletions

View file

@ -814,3 +814,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
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.
!SESSION 2015-08-10 20:02:07.739 -----------------------------------------------
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 20:02:46.475
!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 20:02:46.519
!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.

Binary file not shown.

Binary file not shown.

View file

@ -1,264 +0,0 @@
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";
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";
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]);
}
}

View file

@ -1,264 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" 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;
}
}
}

View file

@ -1,260 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
}
}

View file

@ -1,259 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
}
}

View file

@ -1,260 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
s
}
}

View file

@ -1,260 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
}
}

View file

@ -1,255 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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 DoSetPlayerFlair(Player player, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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.getName()+"\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(player.getName()))
}
}

View file

@ -1,255 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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 DoSetrFlair(Player player, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" 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, )
}
}

View file

@ -1,263 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" 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>")
}
}
}

View file

@ -1,264 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" 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;
}
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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§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]);
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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§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]);
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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.getName()+"\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.getName()+" 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(player.getName()))
}
}

View file

@ -1,255 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
}

View file

@ -1,260 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
}
}

View file

@ -66,6 +66,7 @@ public class PluginMain extends JavaPlugin
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
System.out.println("Start: "+start);
if(start==-1)
continue; //2015.08.09.
int end = ign.indexOf(' ', start);
@ -214,7 +215,7 @@ public class PluginMain extends JavaPlugin
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 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<>();
@ -255,7 +256,7 @@ public class PluginMain extends JavaPlugin
String substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
finalname+=substr;
}
}
}*/
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
}
@ -276,10 +277,10 @@ public class PluginMain extends JavaPlugin
}
}
public static void RemovePlayerDisplayFlairFinal(Player player, String flair)
/*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()
{
@ -329,11 +330,12 @@ public class PluginMain extends JavaPlugin
while((line=br.readLine())!=null)
{
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();
}
file=new File("autoflairdecisions.txt"); //2015.08.09.
file=new File("customflairs.txt"); //2015.08.09.
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader(file));
@ -341,7 +343,8 @@ public class PluginMain extends JavaPlugin
while((line=br.readLine())!=null)
{
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();
}
@ -383,7 +386,7 @@ public class PluginMain extends JavaPlugin
{
if(!player.IgnoredFlair)
continue; //2015.08.08.
bw.write(player.PlayerName+"\n");
bw.write(player.PlayerName+" "+player.Flair+"\n");
}
bw.close();
} catch (IOException e) {
@ -391,19 +394,35 @@ public class PluginMain extends JavaPlugin
LastException=e; //2015.08.09.
}
}
public static void SetPlayerFlair(Player
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();, String flair)
public static boolean RemoveLineFromFile(String file, String line)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
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;
}
}

View file

@ -0,0 +1,431 @@
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();
System.out.println("Start: "+start);
if(start==-1+"IGN:".length()) //
continue; //2015.08.09.
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
System.out.println("End: "+end);
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
System.out.println("IGN: "+ign);
ign = ign.trim();
System.out.println("Trimmed IGN: "+ign);
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+" "+player.Flair+"\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;
}
}

View file

@ -1,259 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "playerinfo"
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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": //2015.08.09.
if(ReloadPlayer==player)
DoReload(player); //2015.08.09.
else
SendMessage(player, "§cYou need to do /u admin reload first.§r");
break;
case "save": //2015.08.09.
PluginMain.SaveFiles(); //2015.08.09.
SendMessage(player, "§6Saved files. Now you can edit them and reload if you want.§r");
break;
case "setflair": //2015.08.09.
DoSetFlair(player, args);
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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]);
}
}

View file

@ -1,259 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
}
}

View file

@ -1,255 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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]);
}
}

View file

@ -214,7 +214,7 @@ public class PluginMain extends JavaPlugin
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 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<>();
@ -255,7 +255,7 @@ public class PluginMain extends JavaPlugin
String substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
finalname+=substr;
}
}
}*/
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
}
@ -276,10 +276,10 @@ public class PluginMain extends JavaPlugin
}
}
public static void RemovePlayerDisplayFlairFinal(Player player, String flair)
/*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()
{
@ -329,11 +329,12 @@ public class PluginMain extends JavaPlugin
while((line=br.readLine())!=null)
{
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();
}
file=new File("autoflairdecisions.txt"); //2015.08.09.
file=new File("customflairs.txt"); //2015.08.09.
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader(file));
@ -341,7 +342,8 @@ public class PluginMain extends JavaPlugin
while((line=br.readLine())!=null)
{
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();
}
@ -383,7 +385,7 @@ public class PluginMain extends JavaPlugin
{
if(!player.IgnoredFlair)
continue; //2015.08.08.
bw.write(player.PlayerName+"\n");
bw.write(player.PlayerName+" "+player.Flair+"\n");
}
bw.close();
} catch (IOException e) {
@ -391,8 +393,35 @@ public class PluginMain extends JavaPlugin
LastException=e; //2015.08.09.
}
}
public static void SetPlayerFlair(Player player, String flair)
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;
}
}

View file

@ -1,263 +0,0 @@
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";
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";
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§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]);
}
}

View file

@ -66,16 +66,20 @@ public class PluginMain extends JavaPlugin
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
System.out.println("Start: "+start);
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.
System.out.println("End: "+end);
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
System.out.println("IGN: "+ign);
ign = ign.trim();
System.out.println("Trimmed IGN: "+ign);
if(HasIGFlair(ign))
continue;
try {
@ -214,7 +218,7 @@ public class PluginMain extends JavaPlugin
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 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<>();
@ -255,7 +259,7 @@ public class PluginMain extends JavaPlugin
String substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
finalname+=substr;
}
}
}*/
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
}
@ -276,10 +280,10 @@ public class PluginMain extends JavaPlugin
}
}
public static void RemovePlayerDisplayFlairFinal(Player player, String flair)
/*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()
{
@ -329,11 +333,12 @@ public class PluginMain extends JavaPlugin
while((line=br.readLine())!=null)
{
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();
}
file=new File("autoflairdecisions.txt"); //2015.08.09.
file=new File("customflairs.txt"); //2015.08.09.
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader(file));
@ -341,7 +346,8 @@ public class PluginMain extends JavaPlugin
while((line=br.readLine())!=null)
{
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();
}
@ -383,7 +389,7 @@ public class PluginMain extends JavaPlugin
{
if(!player.IgnoredFlair)
continue; //2015.08.08.
bw.write(player.PlayerName+"\n");
bw.write(player.PlayerName+" "+player.Flair+"\n");
}
bw.close();
} catch (IOException e) {
@ -391,10 +397,35 @@ public class PluginMain extends JavaPlugin
LastException=e; //2015.08.09.
}
}
public static void SetPlayerFlair(Player player, String flair)
public static boolean RemoveLineFromFile(String file, String line)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
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;
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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.getName()))
{
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.getName()+"\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.getName()+" 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(player.getName()))
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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]);
}
}

View file

@ -1,255 +0,0 @@
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 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";
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";
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§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":
SetFlair()
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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]);
}
}

View file

@ -1,7 +0,0 @@
name: TheButtonAutoFlair
main: tk.sznp.thebuttonautoflair.PluginMain
version: 1.0
commands:
u:
description: Auto-flair system. Accept or ignore flair.
usage: "&cUsage: /u accept|ignore&r"

View file

@ -1,263 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" 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>");
}
}
}

View file

@ -1,260 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
}
}

View file

@ -66,16 +66,20 @@ public class PluginMain extends JavaPlugin
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
System.out.println("Start: "+start);
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.
System.out.println("End: "+end);
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
System.out.println("IGN: "+ign);
ign = ign.trim();
System.out.println("Trimmed IGN: "+ign);
if(HasIGFlair(ign))
continue;
try {
@ -214,7 +218,7 @@ public class PluginMain extends JavaPlugin
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 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<>();
@ -255,7 +259,7 @@ public class PluginMain extends JavaPlugin
String substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
finalname+=substr;
}
}
}*/
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
}
@ -276,10 +280,10 @@ public class PluginMain extends JavaPlugin
}
}
public static void RemovePlayerDisplayFlairFinal(Player player, String flair)
/*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()
{
@ -329,11 +333,12 @@ public class PluginMain extends JavaPlugin
while((line=br.readLine())!=null)
{
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();
}
file=new File("autoflairdecisions.txt"); //2015.08.09.
file=new File("customflairs.txt"); //2015.08.09.
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader(file));
@ -341,7 +346,8 @@ public class PluginMain extends JavaPlugin
while((line=br.readLine())!=null)
{
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();
}
@ -383,7 +389,7 @@ public class PluginMain extends JavaPlugin
{
if(!player.IgnoredFlair)
continue; //2015.08.08.
bw.write(player.PlayerName+"\n");
bw.write(player.PlayerName+" "+player.Flair+"\n");
}
bw.close();
} catch (IOException e) {
@ -391,18 +397,35 @@ public class PluginMain extends JavaPlugin
LastException=e; //2015.08.09.
}
}
public static void SetPlayerFlair(Player player, String flair)
public static boolean RemoveLineFromFile(String file, String line)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
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 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;
}
}

View file

@ -1,255 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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 DoSetFlair(Player player, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
}

View file

@ -1,260 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
}
}

View file

@ -1,263 +0,0 @@
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";
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";
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]);
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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]);
}
}

View file

@ -0,0 +1,431 @@
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();
System.out.println("Start: "+start);
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.
System.out.println("End: "+end);
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
System.out.println("IGN: "+ign);
ign = ign.trim();
System.out.println("Trimmed IGN: "+start);
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+" "+player.Flair+"\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;
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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": //2015.08.09.
DoSetFlair(player, args);
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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]);
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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(player.getName()))
}
}

View file

@ -1,254 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
}

View file

@ -1,255 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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 DoSetFlair(Player player, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
}

View file

@ -1,399 +0,0 @@
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("autoflairdecisions.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 void SetPlayerFlair(Player player, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
}
}

View file

@ -1,264 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" 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;
}
}
}

View file

@ -1,260 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
}
}

View file

@ -1,263 +0,0 @@
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";
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";
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]);
}
}

View file

@ -1,263 +0,0 @@
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";
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";
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§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]);
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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]);
}
}

View file

@ -1,398 +0,0 @@
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("autoflairdecisions.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 void SetPlayerFlair(Player player, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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]);
}
}

View file

@ -1,260 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
}
}

View file

@ -1,259 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
}
}

View file

@ -1,263 +0,0 @@
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";
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";
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§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]);
}
}

View file

@ -1,263 +0,0 @@
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 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";
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";
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§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":
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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, Player targetplayer, String flair)
{ //2015.08.09.
flair=flair.replace('&', '§');
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getName()).Flair=flair;
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.getName()))
{
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.getName()+"\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.getName()+" Flair: "+flair+"§r");
}
private static void DoSetFlair(Player player, String args)
{
//args[0] is "admin" - args[1] is "setflair"
if(args.length()<4)
{
}
}
}

View file

@ -1,81 +0,0 @@
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();
//PluginMain.Players.add(p);
//event.getPlayer().setDisplayName(p.getDisplayName()+PluginMain.GetFlair(p));
//if(PluginMain.PlayerUserNames.containsKey(p.getName())) //<-- 2015.07.20.
if(MaybeOfflinePlayer.AllPlayers.containsKey(p.getName())) //<-- 2015.08.08.
//PluginMain.AppendPlayerDisplayFlair(p, PluginMain.PlayerUserNames.get(p.getName()), PluginMain.GetFlair(p));
{
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AllPlayers.get()
PluginMain.AppendPlayerDisplayFlair(player, p, flair)
}
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);
}
//System.out.println("Added player "+p.getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
/*for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName().equals(event.getPlayer().getName()))
{
PluginMain.Players.remove(player);
//System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}*/
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
//event.setFormat(event.getFormat().substring(0, event.getFormat().indexOf(">"))+"(test)> "+event.getMessage()); //2015.08.08.
String name;
event.setFormat(event.getFormat().substring(0, event.getFormat().indexOf(">"))+flair+"> "+event.getMessage()); //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();
}
}
}

View file

@ -1,265 +0,0 @@
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 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";
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";
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§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": //2015.08.09.
PluginMain.SaveFiles(); //2015.08.09.
SendMessage(player, "§6Saved files. Now you can edit them and reload if you want.§r");
break;
case "setflair": //2015.08.09.
DoSetFlair(player, args);
break;
default:
String message="§cUsage: /u admin reload|playerinfo|getlasterror|save§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]);
}
}

View file

@ -240,30 +240,36 @@
<tags>org.eclipse.e4.primaryDataStack</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">
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;editor id=&quot;org.eclipse.jdt.ui.CompilationUnitEditor&quot;>&#xD;&#xA;&lt;input factoryID=&quot;org.eclipse.ui.part.FileEditorInputFactory&quot; path=&quot;/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PluginMain.java&quot;/>&#xD;&#xA;&lt;editorState selectionHorizontalPixel=&quot;0&quot; selectionLength=&quot;0&quot; selectionOffset=&quot;13069&quot; selectionTopPixel=&quot;5523&quot;/>&#xD;&#xA;&lt;/editor>"/>
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;editor id=&quot;org.eclipse.jdt.ui.CompilationUnitEditor&quot;>&#xD;&#xA;&lt;input factoryID=&quot;org.eclipse.ui.part.FileEditorInputFactory&quot; path=&quot;/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PluginMain.java&quot;/>&#xD;&#xA;&lt;editorState selectionHorizontalPixel=&quot;0&quot; selectionLength=&quot;0&quot; selectionOffset=&quot;13846&quot; selectionTopPixel=&quot;5133&quot;/>&#xD;&#xA;&lt;/editor>"/>
<tags>Editor</tags>
<tags>org.eclipse.jdt.ui.CompilationUnitEditor</tags>
<tags>removeOnHide</tags>
</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">
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;editor id=&quot;org.eclipse.jdt.ui.CompilationUnitEditor&quot;>&#xD;&#xA;&lt;input factoryID=&quot;org.eclipse.ui.part.FileEditorInputFactory&quot; path=&quot;/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/Commands.java&quot;/>&#xD;&#xA;&lt;editorState selectionHorizontalPixel=&quot;0&quot; selectionLength=&quot;0&quot; selectionOffset=&quot;3355&quot; selectionTopPixel=&quot;1022&quot;/>&#xD;&#xA;&lt;/editor>"/>
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;editor id=&quot;org.eclipse.jdt.ui.CompilationUnitEditor&quot;>&#xD;&#xA;&lt;input factoryID=&quot;org.eclipse.ui.part.FileEditorInputFactory&quot; path=&quot;/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/Commands.java&quot;/>&#xD;&#xA;&lt;editorState selectionHorizontalPixel=&quot;0&quot; selectionLength=&quot;0&quot; selectionOffset=&quot;3629&quot; selectionTopPixel=&quot;978&quot;/>&#xD;&#xA;&lt;/editor>"/>
<tags>Editor</tags>
<tags>org.eclipse.jdt.ui.CompilationUnitEditor</tags>
<tags>removeOnHide</tags>
<tags>activeOnClose</tags>
</children>
<children xsi:type="basic:Part" xmi:id="_t4aYYD4IEeW_qLWp8BCh0w" elementId="org.eclipse.e4.ui.compatibility.editor" contributionURI="bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor" label="PlayerListener.java" iconURI="platform:/plugin/org.eclipse.jdt.ui/icons/full/obj16/jcu_obj.gif" tooltip="TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PlayerListener.java" closeable="true">
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;editor id=&quot;org.eclipse.jdt.ui.CompilationUnitEditor&quot;>&#xD;&#xA;&lt;input factoryID=&quot;org.eclipse.ui.part.FileEditorInputFactory&quot; path=&quot;/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PlayerListener.java&quot;/>&#xD;&#xA;&lt;editorState selectionHorizontalPixel=&quot;0&quot; selectionLength=&quot;5&quot; selectionOffset=&quot;2819&quot; selectionTopPixel=&quot;495&quot;/>&#xD;&#xA;&lt;/editor>"/>
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;editor id=&quot;org.eclipse.jdt.ui.CompilationUnitEditor&quot;>&#xD;&#xA;&lt;input factoryID=&quot;org.eclipse.ui.part.FileEditorInputFactory&quot; path=&quot;/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PlayerListener.java&quot;/>&#xD;&#xA;&lt;editorState selectionHorizontalPixel=&quot;311&quot; selectionLength=&quot;0&quot; selectionOffset=&quot;891&quot; selectionTopPixel=&quot;0&quot;/>&#xD;&#xA;&lt;/editor>"/>
<tags>Editor</tags>
<tags>org.eclipse.jdt.ui.CompilationUnitEditor</tags>
<tags>removeOnHide</tags>
</children>
<children xsi:type="basic:Part" xmi:id="_yopyED35EeW_qLWp8BCh0w" elementId="org.eclipse.e4.ui.compatibility.editor" contributionURI="bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor" label="MaybeOfflinePlayer.java" iconURI="platform:/plugin/org.eclipse.jdt.ui/icons/full/obj16/jcu_obj.gif" tooltip="TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/MaybeOfflinePlayer.java" closeable="true">
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;editor id=&quot;org.eclipse.jdt.ui.CompilationUnitEditor&quot;>&#xD;&#xA;&lt;input factoryID=&quot;org.eclipse.ui.part.FileEditorInputFactory&quot; path=&quot;/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/MaybeOfflinePlayer.java&quot;/>&#xD;&#xA;&lt;editorState selectionHorizontalPixel=&quot;0&quot; selectionLength=&quot;0&quot; selectionOffset=&quot;792&quot; selectionTopPixel=&quot;0&quot;/>&#xD;&#xA;&lt;/editor>"/>
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;editor id=&quot;org.eclipse.jdt.ui.CompilationUnitEditor&quot;>&#xD;&#xA;&lt;input factoryID=&quot;org.eclipse.ui.part.FileEditorInputFactory&quot; path=&quot;/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/MaybeOfflinePlayer.java&quot;/>&#xD;&#xA;&lt;editorState selectionHorizontalPixel=&quot;28&quot; selectionLength=&quot;0&quot; selectionOffset=&quot;400&quot; selectionTopPixel=&quot;0&quot;/>&#xD;&#xA;&lt;/editor>"/>
<tags>Editor</tags>
<tags>org.eclipse.jdt.ui.CompilationUnitEditor</tags>
<tags>removeOnHide</tags>
</children>
<children xsi:type="basic:Part" xmi:id="_6M0eED9tEeWFuKglk4EXxA" elementId="org.eclipse.e4.ui.compatibility.editor" contributionURI="bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor" label="plugin.yml" iconURI="platform:/plugin/org.eclipse.ui.editors/icons/full/obj16/file_obj.gif" tooltip="TheButtonAutoFlair/plugin.yml" closeable="true">
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;editor id=&quot;org.eclipse.ui.DefaultTextEditor&quot;>&#xD;&#xA;&lt;input factoryID=&quot;org.eclipse.ui.part.FileEditorInputFactory&quot; path=&quot;/TheButtonAutoFlair/plugin.yml&quot;/>&#xD;&#xA;&lt;editorState selectionHorizontalPixel=&quot;0&quot; selectionLength=&quot;0&quot; selectionOffset=&quot;220&quot; selectionTopPixel=&quot;0&quot;/>&#xD;&#xA;&lt;/editor>"/>
<tags>Editor</tags>
<tags>org.eclipse.ui.DefaultTextEditor</tags>
<tags>removeOnHide</tags>
</children>
</children>
</sharedElements>
<sharedElements xsi:type="basic:Part" xmi:id="_7E9ggCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.navigator.ProjectExplorer" contributionURI="bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityView" label="Project Explorer" iconURI="platform:/plugin/org.eclipse.ui.navigator.resources/icons/full/eview16/resource_persp.gif" tooltip="Workspace" closeable="true">
@ -318,7 +324,7 @@
<tags>categoryTag:General</tags>
</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">
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;view PRIMARY_SORT_FIELD=&quot;org.eclipse.ui.ide.severityAndDescriptionField&quot; categoryGroup=&quot;org.eclipse.ui.ide.severity&quot; markerContentGenerator=&quot;org.eclipse.ui.ide.problemsGenerator&quot; partName=&quot;Problems&quot;>&#xD;&#xA;&lt;expanded>&#xD;&#xA;&lt;category IMemento.internal.id=&quot;Errors&quot;/>&#xD;&#xA;&lt;category IMemento.internal.id=&quot;Warnings&quot;/>&#xD;&#xA;&lt;category IMemento.internal.id=&quot;Warnings (4 items)&quot;/>&#xD;&#xA;&lt;/expanded>&#xD;&#xA;&lt;columnWidths org.eclipse.ui.ide.locationField=&quot;90&quot; org.eclipse.ui.ide.markerType=&quot;90&quot; org.eclipse.ui.ide.pathField=&quot;120&quot; org.eclipse.ui.ide.resourceField=&quot;90&quot; org.eclipse.ui.ide.severityAndDescriptionField=&quot;300&quot;/>&#xD;&#xA;&lt;visible IMemento.internal.id=&quot;org.eclipse.ui.ide.severityAndDescriptionField&quot;/>&#xD;&#xA;&lt;visible IMemento.internal.id=&quot;org.eclipse.ui.ide.resourceField&quot;/>&#xD;&#xA;&lt;visible IMemento.internal.id=&quot;org.eclipse.ui.ide.pathField&quot;/>&#xD;&#xA;&lt;visible IMemento.internal.id=&quot;org.eclipse.ui.ide.locationField&quot;/>&#xD;&#xA;&lt;visible IMemento.internal.id=&quot;org.eclipse.ui.ide.markerType&quot;/>&#xD;&#xA;&lt;/view>"/>
<persistedState key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;view PRIMARY_SORT_FIELD=&quot;org.eclipse.ui.ide.severityAndDescriptionField&quot; categoryGroup=&quot;org.eclipse.ui.ide.severity&quot; markerContentGenerator=&quot;org.eclipse.ui.ide.problemsGenerator&quot; partName=&quot;Problems&quot;>&#xD;&#xA;&lt;expanded>&#xD;&#xA;&lt;category IMemento.internal.id=&quot;Errors&quot;/>&#xD;&#xA;&lt;category IMemento.internal.id=&quot;Warnings (2 items)&quot;/>&#xD;&#xA;&lt;/expanded>&#xD;&#xA;&lt;columnWidths org.eclipse.ui.ide.locationField=&quot;90&quot; org.eclipse.ui.ide.markerType=&quot;90&quot; org.eclipse.ui.ide.pathField=&quot;120&quot; org.eclipse.ui.ide.resourceField=&quot;90&quot; org.eclipse.ui.ide.severityAndDescriptionField=&quot;300&quot;/>&#xD;&#xA;&lt;visible IMemento.internal.id=&quot;org.eclipse.ui.ide.severityAndDescriptionField&quot;/>&#xD;&#xA;&lt;visible IMemento.internal.id=&quot;org.eclipse.ui.ide.resourceField&quot;/>&#xD;&#xA;&lt;visible IMemento.internal.id=&quot;org.eclipse.ui.ide.pathField&quot;/>&#xD;&#xA;&lt;visible IMemento.internal.id=&quot;org.eclipse.ui.ide.locationField&quot;/>&#xD;&#xA;&lt;visible IMemento.internal.id=&quot;org.eclipse.ui.ide.markerType&quot;/>&#xD;&#xA;&lt;/view>"/>
<tags>View</tags>
<tags>categoryTag:General</tags>
<menus xmi:id="_dGEOYCr1EeWsptewEJl0pA" elementId="org.eclipse.ui.views.ProblemView">
@ -420,18 +426,18 @@
</children>
<children xsi:type="menu:ToolBar" xmi:id="_6K2osCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.workbench.file">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_HID7YEeWz3JF-N665Zw" elementId="new.group"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_uMD7YEeWz3JF-N665Zw" elementId="newWizardDropDown"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_uMT7YEeWz3JF-N665Zw" elementId="new.ext" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_uMj7YEeWz3JF-N665Zw" elementId="save.group" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_uMz7YEeWz3JF-N665Zw" elementId="save"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_ci_uND7YEeWz3JF-N665Zw" elementId="saveAll"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjAVQD7YEeWz3JF-N665Zw" elementId="save.ext" visible="false"/>
<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="_cjEmsD7YEeWz3JF-N665Zw" elementId="print.ext" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjFNwD7YEeWz3JF-N665Zw" elementId="build.group"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjFNwT7YEeWz3JF-N665Zw" elementId="build.ext" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjFNwj7YEeWz3JF-N665Zw" elementId="additions"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEhc0D8fEeWFuKglk4EXxA" elementId="new.group"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEhc0T8fEeWFuKglk4EXxA" elementId="newWizardDropDown"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEiD4D8fEeWFuKglk4EXxA" elementId="new.ext" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEiD4T8fEeWFuKglk4EXxA" elementId="save.group" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEiD4j8fEeWFuKglk4EXxA" elementId="save"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEiq8D8fEeWFuKglk4EXxA" elementId="saveAll"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEiq8T8fEeWFuKglk4EXxA" elementId="save.ext" visible="false"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_pEj5ED8fEeWFuKglk4EXxA" iconURI="platform:/plugin/org.eclipse.ui/icons/full/etool16/print_edit.gif" tooltip="Print" command="_3_hZmSr0EeWsptewEJl0pA"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEoKgD8fEeWFuKglk4EXxA" elementId="print.ext" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEoKgT8fEeWFuKglk4EXxA" elementId="build.group"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEoKgj8fEeWFuKglk4EXxA" elementId="build.ext" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEoKgz8fEeWFuKglk4EXxA" elementId="additions"/>
</children>
<children xsi:type="menu:ToolBar" xmi:id="_6K2osSr0EeWsptewEJl0pA" elementId="additions" toBeRendered="false">
<tags>toolbarSeparator</tags>
@ -439,38 +445,38 @@
</children>
<children xsi:type="menu:ToolBar" xmi:id="_dIOxkCr1EeWsptewEJl0pA" elementId="adt.actionSet.avdManager">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDhoYD7YEeWz3JF-N665Zw" elementId="android_project"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDi2gD7YEeWz3JF-N665Zw" elementId="com.android.ide.eclipse.adt.ui.sdkmanager"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDi2gT7YEeWz3JF-N665Zw" elementId="com.android.ide.eclipse.adt.ui.avdmanager"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIf94D8fEeWFuKglk4EXxA" elementId="android_project"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIf94T8fEeWFuKglk4EXxA" elementId="com.android.ide.eclipse.adt.ui.sdkmanager"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIgk8D8fEeWFuKglk4EXxA" elementId="com.android.ide.eclipse.adt.ui.avdmanager"/>
</children>
<children xsi:type="menu:ToolBar" xmi:id="_Mv4F0C3kEeWvSKv3oe_gqg" elementId="org.eclipse.debug.ui.breakpointActionSet">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDi2gj7YEeWz3JF-N665Zw" elementId="breakpointGroup"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDi2gz7YEeWz3JF-N665Zw" elementId="org.eclipse.debug.ui.actions.SkipAllBreakpoints"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIgk8T8fEeWFuKglk4EXxA" elementId="breakpointGroup"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIgk8j8fEeWFuKglk4EXxA" elementId="org.eclipse.debug.ui.actions.SkipAllBreakpoints"/>
</children>
<children xsi:type="menu:ToolBar" xmi:id="_dI4R0Cr1EeWsptewEJl0pA" elementId="adt.actionSet.lint">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDi2hD7YEeWz3JF-N665Zw" elementId="android_project"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdkD7YEeWz3JF-N665Zw" elementId="com.android.ide.eclipse.adt.ui.lintrunner"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIgk8z8fEeWFuKglk4EXxA" elementId="android_project"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIgk9D8fEeWFuKglk4EXxA" elementId="com.android.ide.eclipse.adt.ui.lintrunner"/>
</children>
<children xsi:type="menu:ToolBar" xmi:id="_dIyyQCr1EeWsptewEJl0pA" elementId="adt.actionSet.wizards">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdkT7YEeWz3JF-N665Zw" elementId="android_project"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdkj7YEeWz3JF-N665Zw" elementId="com.android.ide.eclipse.adt.wizards.actions.NewXmlFileAction"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIhMAD8fEeWFuKglk4EXxA" elementId="android_project"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIhMAT8fEeWFuKglk4EXxA" elementId="com.android.ide.eclipse.adt.wizards.actions.NewXmlFileAction"/>
</children>
<children xsi:type="menu:ToolBar" xmi:id="_8zAWsCr0EeWsptewEJl0pA" elementId="org.eclipse.debug.ui.launchActionSet">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdkz7YEeWz3JF-N665Zw" elementId="debug"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdlD7YEeWz3JF-N665Zw" elementId="org.eclipse.debug.internal.ui.actions.DebugDropDownAction"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDjdlT7YEeWz3JF-N665Zw" elementId="org.eclipse.debug.internal.ui.actions.RunDropDownAction"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEoD7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.externaltools.ExternalToolMenuDelegateToolbar"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIhMAj8fEeWFuKglk4EXxA" elementId="debug"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIhzED8fEeWFuKglk4EXxA" elementId="org.eclipse.debug.internal.ui.actions.DebugDropDownAction"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIhzET8fEeWFuKglk4EXxA" elementId="org.eclipse.debug.internal.ui.actions.RunDropDownAction"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIhzEj8fEeWFuKglk4EXxA" elementId="org.eclipse.ui.externaltools.ExternalToolMenuDelegateToolbar"/>
</children>
<children xsi:type="menu:ToolBar" xmi:id="_dG7xECr1EeWsptewEJl0pA" elementId="org.eclipse.jdt.ui.JavaElementCreationActionSet">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEoT7YEeWz3JF-N665Zw" elementId="JavaWizards"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEoj7YEeWz3JF-N665Zw" elementId="org.eclipse.jdt.ui.actions.OpenProjectWizard"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEoz7YEeWz3JF-N665Zw" elementId="org.eclipse.jdt.ui.actions.OpenPackageWizard"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEpD7YEeWz3JF-N665Zw" elementId="org.eclipse.jdt.ui.actions.NewTypeDropDown"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIhzEz8fEeWFuKglk4EXxA" elementId="JavaWizards"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIhzFD8fEeWFuKglk4EXxA" elementId="org.eclipse.jdt.ui.actions.OpenProjectWizard"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIhzFT8fEeWFuKglk4EXxA" elementId="org.eclipse.jdt.ui.actions.OpenPackageWizard"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIiaID8fEeWFuKglk4EXxA" elementId="org.eclipse.jdt.ui.actions.NewTypeDropDown"/>
</children>
<children xsi:type="menu:ToolBar" xmi:id="_8voSkCr0EeWsptewEJl0pA" elementId="org.eclipse.jst.j2ee.J2eeMainActionSet" visible="false">
<tags>Draggable</tags>
@ -480,20 +486,20 @@
</children>
<children xsi:type="menu:ToolBar" xmi:id="_8xJVgCr0EeWsptewEJl0pA" elementId="org.eclipse.search.searchActionSet">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkEpT7YEeWz3JF-N665Zw" elementId="Search"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrsD7YEeWz3JF-N665Zw" elementId="openType"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrsT7YEeWz3JF-N665Zw" elementId="org.eclipse.mylyn.tasks.ui.openTask"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrsj7YEeWz3JF-N665Zw" elementId="org.eclipse.search.OpenSearchDialogPage"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIiaIT8fEeWFuKglk4EXxA" elementId="Search"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIiaIj8fEeWFuKglk4EXxA" elementId="openType"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIiaIz8fEeWFuKglk4EXxA" elementId="org.eclipse.mylyn.tasks.ui.openTask"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIiaJD8fEeWFuKglk4EXxA" elementId="org.eclipse.search.OpenSearchDialogPage"/>
</children>
<children xsi:type="menu:ToolBar" xmi:id="_Slo_UC3kEeWvSKv3oe_gqg" elementId="org.eclipse.ui.edit.text.actionSet.presentation">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_o5UKoD7YEeWz3JF-N665Zw" elementId="Presentation"/>
<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="_o5UKoj7YEeWz3JF-N665Zw" elementId="org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences"/>
<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="_o5UxsT7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.toggleBlockSelectionMode"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_o5Uxsj7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.toggleShowWhitespaceCharacters"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_o5Uxsz7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_wzFD8D8fEeWFuKglk4EXxA" elementId="Presentation"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_wzFrAD8fEeWFuKglk4EXxA" elementId="org.eclipse.jdt.ui.edit.text.java.toggleBreadcrumb"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_wzFrAT8fEeWFuKglk4EXxA" elementId="org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_wzFrAj8fEeWFuKglk4EXxA" elementId="org.eclipse.mylyn.java.ui.editor.folding.auto"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_wzFrAz8fEeWFuKglk4EXxA" elementId="org.eclipse.ui.edit.text.toggleBlockSelectionMode"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_wzFrBD8fEeWFuKglk4EXxA" elementId="org.eclipse.ui.edit.text.toggleShowWhitespaceCharacters"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_wzGSED8fEeWFuKglk4EXxA" elementId="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"/>
</children>
<children xsi:type="menu:ToolBar" xmi:id="_8wdZACr0EeWsptewEJl0pA" elementId="org.eclipse.wst.server.ui.internal.webbrowser.actionSet" visible="false">
<tags>Draggable</tags>
@ -511,15 +517,15 @@
</children>
<children xsi:type="menu:ToolBar" xmi:id="_6LTUoCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.workbench.navigate">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjFNwz7YEeWz3JF-N665Zw" elementId="history.group"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjFNxD7YEeWz3JF-N665Zw" elementId="group.application" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjF00D7YEeWz3JF-N665Zw" elementId="backardHistory"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjF00T7YEeWz3JF-N665Zw" elementId="forwardHistory"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjF00j7YEeWz3JF-N665Zw" elementId="pin.group"/>
<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="_dDkrsz7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.gotoNextAnnotation"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrtD7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.gotoPreviousAnnotation"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_dDkrtT7YEeWz3JF-N665Zw" elementId="org.eclipse.ui.edit.text.gotoLastEditPosition"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEoxkD8fEeWFuKglk4EXxA" elementId="history.group"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEoxkT8fEeWFuKglk4EXxA" elementId="group.application" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEoxkj8fEeWFuKglk4EXxA" elementId="backardHistory"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEpYoD8fEeWFuKglk4EXxA" elementId="forwardHistory"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEpYoT8fEeWFuKglk4EXxA" elementId="pin.group"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_pEpYoj8fEeWFuKglk4EXxA" 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="_pIiaJT8fEeWFuKglk4EXxA" elementId="org.eclipse.ui.edit.text.gotoNextAnnotation"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIjBMD8fEeWFuKglk4EXxA" elementId="org.eclipse.ui.edit.text.gotoPreviousAnnotation"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pIjBMT8fEeWFuKglk4EXxA" elementId="org.eclipse.ui.edit.text.gotoLastEditPosition"/>
</children>
<children xsi:type="menu:ToolBar" xmi:id="_6LTUoSr0EeWsptewEJl0pA" elementId="group.editor" toBeRendered="false">
<tags>toolbarSeparator</tags>
@ -531,8 +537,8 @@
</children>
<children xsi:type="menu:ToolBar" xmi:id="_6LT7sCr0EeWsptewEJl0pA" elementId="org.eclipse.ui.workbench.help" visible="false">
<tags>Draggable</tags>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjHC8D7YEeWz3JF-N665Zw" elementId="group.help"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_cjHC8T7YEeWz3JF-N665Zw" elementId="group.application" visible="false"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEp_sD8fEeWFuKglk4EXxA" elementId="group.help"/>
<children xsi:type="menu:OpaqueToolItem" xmi:id="_pEqmwD8fEeWFuKglk4EXxA" elementId="group.application" visible="false"/>
</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">
<tags>stretch</tags>

View file

@ -1,11 +1,11 @@
INDEX VERSION 1.126+D:\Z - Norbi cucca\0 Projektek\TheButtonMCAutoFlairProto\Spigot plugin\.metadata\.plugins\org.eclipse.jdt.core
3656756579.index
3045053200.index
3089967703.index
2674037006.index
323251068.index
355369697.index
1934142626.index
3716007315.index
1934142626.index
1045485630.index
605290374.index
533208796.index
@ -23,4 +23,4 @@ INDEX VERSION 1.126+D:\Z - Norbi cucca\0 Projektek\TheButtonMCAutoFlairProto\Spi
994834796.index
3604769962.index
1508644233.index
3045053200.index
3656756579.index

View file

@ -3,7 +3,6 @@
<fullyQualifiedTypeName name="java.io.Console"/>
<fullyQualifiedTypeName name="java.net.URLEncoder"/>
<fullyQualifiedTypeName name="java.nio.charset.StandardCharsets"/>
<fullyQualifiedTypeName name="java.net.URL"/>
<fullyQualifiedTypeName name="java.io.InputStream"/>
<fullyQualifiedTypeName name="java.net.URLConnection"/>
<fullyQualifiedTypeName name="java.net.MalformedURLException"/>
@ -59,4 +58,6 @@
<fullyQualifiedTypeName name="net.ess3.api.IEssentials"/>
<fullyQualifiedTypeName name="net.ess3.api.IUser"/>
<fullyQualifiedTypeName name="tk.sznp.thebuttonautoflair.MaybeOfflinePlayer"/>
<fullyQualifiedTypeName name="org.apache.commons.io.FileUtils"/>
<fullyQualifiedTypeName name="java.net.URL"/>
</qualifiedTypeNameHistroy>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

View file

@ -11,4 +11,5 @@
<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="1439184130737_10" label="Window Working Set" name="Aggregate for window 1439184130737"/>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1439229760994_11" label="Window Working Set" name="Aggregate for window 1439229760993"/>
</workingSetManager>

Binary file not shown.

View file

@ -66,16 +66,20 @@ public class PluginMain extends JavaPlugin
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
if(start==-1)
System.out.println("Start: "+start);
if(start==-1+"IGN:".length()) //+length: 2015.08.10.
continue; //2015.08.09.
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
System.out.println("End: "+end);
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
System.out.println("IGN: "+ign);
ign = ign.trim();
System.out.println("Trimmed IGN: "+ign);
if(HasIGFlair(ign))
continue;
try {