Bug fixes
- Fixed admin commands not working in certain cases - Fixed custom flair saving etc.
This commit is contained in:
parent
0d5ff3dc63
commit
bfb5b6875c
19 changed files with 42 additions and 31 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -23,12 +23,12 @@ public class Commands implements CommandExecutor {
|
||||||
return false;
|
return false;
|
||||||
MaybeOfflinePlayer p=MaybeOfflinePlayer.AllPlayers.get(player.getName()); //2015.08.08.
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AllPlayers.get(player.getName()); //2015.08.08.
|
||||||
//if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
|
//if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
|
||||||
if(p.Flair==null)
|
if(!p.CommentedOnReddit && !args[0].toLowerCase().equals("admin"))
|
||||||
{
|
{
|
||||||
player.sendMessage("§cError: You need to write your username to the reddit thread at /r/TheButtonMinecraft§r");
|
player.sendMessage("§cError: You need to write your username to the reddit thread at /r/TheButtonMinecraft§r");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!p.FlairRecognised)
|
if(!p.FlairRecognised && !args[0].toLowerCase().equals("admin"))
|
||||||
{ //2015.08.10.
|
{ //2015.08.10.
|
||||||
player.sendMessage("Sorry, but your flair isn't recorded. Please ask a mod to set it for you.");
|
player.sendMessage("Sorry, but your flair isn't recorded. Please ask a mod to set it for you.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -83,8 +83,7 @@ public class Commands implements CommandExecutor {
|
||||||
player.sendMessage("§cYou have already set the flair type.§r");
|
player.sendMessage("§cYou have already set the flair type.§r");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//p.Flair="§7(non-pr.)§r";
|
SetPlayerFlair(player, p, "§7(--s)§r");
|
||||||
SetPlayerFlair(player, p, "§7(non-pr.)§r");
|
|
||||||
break;
|
break;
|
||||||
case "cantpress": //2015.08.09.
|
case "cantpress": //2015.08.09.
|
||||||
if(!p.AcceptedFlair)
|
if(!p.AcceptedFlair)
|
||||||
|
@ -97,8 +96,7 @@ public class Commands implements CommandExecutor {
|
||||||
player.sendMessage("§cYou have already set the flair type or your flair type is known.§r");
|
player.sendMessage("§cYou have already set the flair type or your flair type is known.§r");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//p.Flair="§r(can't press)§r";
|
SetPlayerFlair(player, p, "§r(??s)§r");
|
||||||
SetPlayerFlair(player, p, "§r(can't pr.)§r");
|
|
||||||
break;
|
break;
|
||||||
case "opme": //2015.08.10.
|
case "opme": //2015.08.10.
|
||||||
player.sendMessage("It would be nice, isn't it?"); //Sometimes I'm bored too
|
player.sendMessage("It would be nice, isn't it?"); //Sometimes I'm bored too
|
||||||
|
@ -130,18 +128,14 @@ public class Commands implements CommandExecutor {
|
||||||
for(Player p : PluginMain.GetPlayers())
|
for(Player p : PluginMain.GetPlayers())
|
||||||
{
|
{
|
||||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName());
|
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName());
|
||||||
if(mp.Flair!=null)
|
//if(mp.Flair!=null)
|
||||||
|
if(mp.CommentedOnReddit)
|
||||||
{
|
{
|
||||||
//String flair=mp.Flair;
|
|
||||||
//PluginMain.RemovePlayerDisplayFlairFinal(p, flair);
|
|
||||||
//PluginMain.AppendPlayerDisplayFlairFinal(p, flair);
|
|
||||||
PluginMain.AppendPlayerDisplayFlair(mp, p); //2015.08.09.
|
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.
|
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.
|
p.sendMessage(msg); //2015.08.09.
|
||||||
}
|
}
|
||||||
//String msg="§6Reloaded config file.§r";
|
|
||||||
//SendMessage(player, msg); //2015.08.09.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
|
@ -158,7 +152,7 @@ public class Commands implements CommandExecutor {
|
||||||
private static Player ReloadPlayer; //2015.08.09.
|
private static Player ReloadPlayer; //2015.08.09.
|
||||||
private static void DoAdmin(Player player, String[] args)
|
private static void DoAdmin(Player player, String[] args)
|
||||||
{ //2015.08.09.
|
{ //2015.08.09.
|
||||||
if(player==null || player.isOp() || player.getName()=="NorbiPeti")
|
if(player==null || player.isOp() || player.getName().equals("NorbiPeti"))
|
||||||
{
|
{
|
||||||
//System.out.println("Args length: " + args.length);
|
//System.out.println("Args length: " + args.length);
|
||||||
if(args.length==1)
|
if(args.length==1)
|
||||||
|
@ -227,6 +221,8 @@ public class Commands implements CommandExecutor {
|
||||||
SendMessage(player, "Flair accepted: "+p.AcceptedFlair);
|
SendMessage(player, "Flair accepted: "+p.AcceptedFlair);
|
||||||
SendMessage(player, "Flair ignored: "+p.IgnoredFlair);
|
SendMessage(player, "Flair ignored: "+p.IgnoredFlair);
|
||||||
SendMessage(player, "Flair decided: "+p.FlairDecided);
|
SendMessage(player, "Flair decided: "+p.FlairDecided);
|
||||||
|
SendMessage(player, "Flair recognised: "+p.FlairRecognised);
|
||||||
|
SendMessage(player, "Commented on Reddit: "+p.CommentedOnReddit);
|
||||||
}
|
}
|
||||||
private static void SendMessage(Player player, String message)
|
private static void SendMessage(Player player, String message)
|
||||||
{ //2015.08.09.
|
{ //2015.08.09.
|
||||||
|
@ -251,6 +247,7 @@ public class Commands implements CommandExecutor {
|
||||||
{ //2015.08.09.
|
{ //2015.08.09.
|
||||||
flair=flair.replace('&', '§');
|
flair=flair.replace('&', '§');
|
||||||
targetplayer.Flair=flair;
|
targetplayer.Flair=flair;
|
||||||
|
targetplayer.CommentedOnReddit=true; //Or at least has a flair in some way
|
||||||
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.PlayerName))
|
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.PlayerName))
|
||||||
{
|
{
|
||||||
SendMessage(player, "§cError removing previous custom flair!§r");
|
SendMessage(player, "§cError removing previous custom flair!§r");
|
||||||
|
@ -260,7 +257,7 @@ public class Commands implements CommandExecutor {
|
||||||
try {
|
try {
|
||||||
BufferedWriter bw;
|
BufferedWriter bw;
|
||||||
bw = new BufferedWriter(new FileWriter(file, true));
|
bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
bw.write(targetplayer.PlayerName+"\n");
|
bw.write(targetplayer.PlayerName+targetplayer.Flair+"\n");
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Error!\n"+e);
|
System.out.println("Error!\n"+e);
|
||||||
|
|
|
@ -11,6 +11,7 @@ public class MaybeOfflinePlayer
|
||||||
public boolean IgnoredFlair;
|
public boolean IgnoredFlair;
|
||||||
public boolean FlairDecided; //2015.08.09.
|
public boolean FlairDecided; //2015.08.09.
|
||||||
public boolean FlairRecognised; //2015.08.10.
|
public boolean FlairRecognised; //2015.08.10.
|
||||||
|
public boolean CommentedOnReddit; //2015.08.10.
|
||||||
public static HashMap<String, MaybeOfflinePlayer> AllPlayers=new HashMap<>(); //2015.08.08.
|
public static HashMap<String, MaybeOfflinePlayer> AllPlayers=new HashMap<>(); //2015.08.08.
|
||||||
public static MaybeOfflinePlayer AddPlayerIfNeeded(String playername)
|
public static MaybeOfflinePlayer AddPlayerIfNeeded(String playername)
|
||||||
{
|
{
|
||||||
|
@ -18,6 +19,7 @@ public class MaybeOfflinePlayer
|
||||||
{
|
{
|
||||||
MaybeOfflinePlayer player=new MaybeOfflinePlayer();
|
MaybeOfflinePlayer player=new MaybeOfflinePlayer();
|
||||||
player.PlayerName=playername;
|
player.PlayerName=playername;
|
||||||
|
player.Flair=""; //2015.08.10.
|
||||||
AllPlayers.put(playername, player);
|
AllPlayers.put(playername, player);
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class PlayerListener implements Listener
|
||||||
Player p=event.getPlayer();
|
Player p=event.getPlayer();
|
||||||
MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName()); //2015.08.08.
|
MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName()); //2015.08.08.
|
||||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AllPlayers.get(p.getName()); //2015.08.08.
|
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AllPlayers.get(p.getName()); //2015.08.08.
|
||||||
if(mp.Flair!=null)
|
if(mp.CommentedOnReddit)
|
||||||
PluginMain.AppendPlayerDisplayFlair(mp, p); //2015.08.09.
|
PluginMain.AppendPlayerDisplayFlair(mp, p); //2015.08.09.
|
||||||
else
|
else
|
||||||
{ //2015.07.20.
|
{ //2015.07.20.
|
||||||
|
@ -36,8 +36,8 @@ public class PlayerListener implements Listener
|
||||||
{
|
{
|
||||||
MaybeOfflinePlayer player = MaybeOfflinePlayer.AllPlayers.get(event.getPlayer().getName());
|
MaybeOfflinePlayer player = MaybeOfflinePlayer.AllPlayers.get(event.getPlayer().getName());
|
||||||
String flair=player.Flair; //2015.08.08.
|
String flair=player.Flair; //2015.08.08.
|
||||||
if(flair==null || !player.AcceptedFlair)
|
if(player.IgnoredFlair)
|
||||||
flair=""; //2015.08.08.
|
flair="";
|
||||||
String message=event.getMessage(); //2015.08.08.
|
String message=event.getMessage(); //2015.08.08.
|
||||||
/*for(Player p : PluginMain.GetPlayers())
|
/*for(Player p : PluginMain.GetPlayers())
|
||||||
{ //2015.08.08.
|
{ //2015.08.08.
|
||||||
|
|
|
@ -133,7 +133,8 @@ public class PluginMain extends JavaPlugin
|
||||||
public Boolean HasIGFlair(String playername)
|
public Boolean HasIGFlair(String playername)
|
||||||
{
|
{
|
||||||
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(playername); //2015.08.08.
|
||||||
return p.Flair!=null; //2015.08.08.
|
//return p.Flair!=null; //2015.08.08.
|
||||||
|
return p.CommentedOnReddit; //2015.08.10.
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFlair(String playername, String text, String flairclass, String username)
|
public void SetFlair(String playername, String text, String flairclass, String username)
|
||||||
|
@ -163,13 +164,13 @@ public class PluginMain extends JavaPlugin
|
||||||
finalflair="§5("+text+")§r";
|
finalflair="§5("+text+")§r";
|
||||||
break;
|
break;
|
||||||
case "no-press":
|
case "no-press":
|
||||||
finalflair="§7(non-pr.)§r";
|
finalflair="§7(--s)§r";
|
||||||
break;
|
break;
|
||||||
case "cheater":
|
case "cheater":
|
||||||
finalflair="§5("+text+")§r";
|
finalflair="§5("+text+")§r";
|
||||||
break;
|
break;
|
||||||
case "cant-press": //2015.08.08.
|
case "cant-press": //2015.08.08.
|
||||||
finalflair="§r(can't press)§r";
|
finalflair="§r(??s)§r";
|
||||||
break;
|
break;
|
||||||
case "unknown":
|
case "unknown":
|
||||||
if(text.equals("-1")) //If true, only non-presser/can't press; if false, any flair
|
if(text.equals("-1")) //If true, only non-presser/can't press; if false, any flair
|
||||||
|
@ -186,6 +187,7 @@ public class PluginMain extends JavaPlugin
|
||||||
/*if(finalflair.length()==0) //<-- 2015.07.20.
|
/*if(finalflair.length()==0) //<-- 2015.07.20.
|
||||||
return;*/
|
return;*/
|
||||||
p.Flair=finalflair; //2015.08.08.
|
p.Flair=finalflair; //2015.08.08.
|
||||||
|
p.CommentedOnReddit=true; //2015.08.10.
|
||||||
p.UserName=username; //2015.08.08.
|
p.UserName=username; //2015.08.08.
|
||||||
if(finalflair.length()==0) //Just for the message
|
if(finalflair.length()==0) //Just for the message
|
||||||
finalflair="undecided";
|
finalflair="undecided";
|
||||||
|
@ -204,7 +206,8 @@ public class PluginMain extends JavaPlugin
|
||||||
public static String GetFlair(Player player)
|
public static String GetFlair(Player player)
|
||||||
{ //2015.07.16.
|
{ //2015.07.16.
|
||||||
String flair=MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair; //2015.08.08.
|
String flair=MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair; //2015.08.08.
|
||||||
return flair==null ? "" : flair;
|
//return flair==null ? "" : flair;
|
||||||
|
return flair; //2015.08.10.
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
|
//public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
|
||||||
|
@ -215,7 +218,7 @@ public class PluginMain extends JavaPlugin
|
||||||
return;
|
return;
|
||||||
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).AcceptedFlair)
|
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).AcceptedFlair)
|
||||||
{
|
{
|
||||||
AppendPlayerDisplayFlairFinal(p, player.Flair); //2015.07.20.
|
//AppendPlayerDisplayFlairFinal(p, player.Flair); //2015.07.20.
|
||||||
if(!player.FlairDecided)
|
if(!player.FlairDecided)
|
||||||
p.sendMessage("§9Your flair type is unknown. Are you a non-presser or a can't press? (/u nonpresser or /u cantpress)§r"); //2015.08.09.
|
p.sendMessage("§9Your flair type is unknown. Are you a non-presser or a can't press? (/u nonpresser or /u cantpress)§r"); //2015.08.09.
|
||||||
}
|
}
|
||||||
|
@ -223,9 +226,9 @@ public class PluginMain extends JavaPlugin
|
||||||
p.sendMessage("§9Are you Reddit user "+player.UserName+"?§r §6Type /u accept or /u ignore§r");
|
p.sendMessage("§9Are you Reddit user "+player.UserName+"?§r §6Type /u accept or /u ignore§r");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AppendPlayerDisplayFlairFinal(Player player, String flair)
|
/*private static void AppendPlayerDisplayFlairFinal(Player player, String flair)
|
||||||
{ //2015.07.20.
|
{ //2015.07.20.
|
||||||
/*String color = GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on first capital letters
|
*String color = GetColorForTown(GetPlayerTown(player)); //TO!DO: Multiple colors put on first capital letters
|
||||||
String[] colors = color.substring(1).split("§");
|
String[] colors = color.substring(1).split("§");
|
||||||
String displayname=player.getName(); //2015.08.08.
|
String displayname=player.getName(); //2015.08.08.
|
||||||
ArrayList<Integer> Positions=new ArrayList<>();
|
ArrayList<Integer> Positions=new ArrayList<>();
|
||||||
|
@ -266,9 +269,8 @@ public class PluginMain extends JavaPlugin
|
||||||
String substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
|
String substr="§"+colors[x++]+displayname.substring(pos, nextpos)+"§r";
|
||||||
finalname+=substr;
|
finalname+=substr;
|
||||||
}
|
}
|
||||||
}*/
|
}*
|
||||||
MaybeOfflinePlayer.AllPlayers.get(player.getName()).Flair=flair; //2015.08.08.
|
}*/
|
||||||
}
|
|
||||||
|
|
||||||
public static String GetColorForTown(String townname)
|
public static String GetColorForTown(String townname)
|
||||||
{ //2015.07.20.
|
{ //2015.07.20.
|
||||||
|
@ -354,7 +356,11 @@ public class PluginMain extends JavaPlugin
|
||||||
{
|
{
|
||||||
String[] s=line.split(" ");
|
String[] s=line.split(" ");
|
||||||
if(s.length>=2) //2015.08.10.
|
if(s.length>=2) //2015.08.10.
|
||||||
MaybeOfflinePlayer.AddPlayerIfNeeded(s[0]).Flair=s[1]; //2015.08.09.
|
{
|
||||||
|
MaybeOfflinePlayer p=MaybeOfflinePlayer.AddPlayerIfNeeded(s[0]);
|
||||||
|
p.Flair=s[1]; //2015.08.09.
|
||||||
|
p.CommentedOnReddit=true; //Kind of
|
||||||
|
}
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
}
|
}
|
||||||
|
@ -396,9 +402,9 @@ public class PluginMain extends JavaPlugin
|
||||||
{
|
{
|
||||||
if(!player.IgnoredFlair)
|
if(!player.IgnoredFlair)
|
||||||
continue; //2015.08.08.
|
continue; //2015.08.08.
|
||||||
bw.write(player.PlayerName+" "+player.Flair+"\n");
|
bw.write(player.PlayerName+"\n");
|
||||||
}
|
}
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Error!\n"+e);
|
System.out.println("Error!\n"+e);
|
||||||
LastException=e; //2015.08.09.
|
LastException=e; //2015.08.09.
|
||||||
|
@ -428,7 +434,13 @@ public class PluginMain extends JavaPlugin
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
reader.close();
|
reader.close();
|
||||||
return tempFile.renameTo(inputFile);
|
if(!tempFile.renameTo(inputFile))
|
||||||
|
{
|
||||||
|
inputFile.delete();
|
||||||
|
return tempFile.renameTo(inputFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Error!\n"+e);
|
System.out.println("Error!\n"+e);
|
||||||
LastException=e; //2015.08.09.
|
LastException=e; //2015.08.09.
|
||||||
|
|
Loading…
Reference in a new issue