Bug fixes
- Fixed admin commands not working in certain cases - Fixed custom flair saving etc.
This commit is contained in:
parent
543e7c3d7e
commit
c075ef890a
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;
|
||||
MaybeOfflinePlayer p=MaybeOfflinePlayer.AllPlayers.get(player.getName()); //2015.08.08.
|
||||
//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");
|
||||
return true;
|
||||
}
|
||||
if(!p.FlairRecognised)
|
||||
if(!p.FlairRecognised && !args[0].toLowerCase().equals("admin"))
|
||||
{ //2015.08.10.
|
||||
player.sendMessage("Sorry, but your flair isn't recorded. Please ask a mod to set it for you.");
|
||||
return true;
|
||||
|
@ -83,8 +83,7 @@ public class Commands implements CommandExecutor {
|
|||
player.sendMessage("§cYou have already set the flair type.§r");
|
||||
break;
|
||||
}
|
||||
//p.Flair="§7(non-pr.)§r";
|
||||
SetPlayerFlair(player, p, "§7(non-pr.)§r");
|
||||
SetPlayerFlair(player, p, "§7(--s)§r");
|
||||
break;
|
||||
case "cantpress": //2015.08.09.
|
||||
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");
|
||||
break;
|
||||
}
|
||||
//p.Flair="§r(can't press)§r";
|
||||
SetPlayerFlair(player, p, "§r(can't pr.)§r");
|
||||
SetPlayerFlair(player, p, "§r(??s)§r");
|
||||
break;
|
||||
case "opme": //2015.08.10.
|
||||
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())
|
||||
{
|
||||
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.
|
||||
}
|
||||
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)
|
||||
|
@ -158,7 +152,7 @@ public class Commands implements CommandExecutor {
|
|||
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")
|
||||
if(player==null || player.isOp() || player.getName().equals("NorbiPeti"))
|
||||
{
|
||||
//System.out.println("Args length: " + args.length);
|
||||
if(args.length==1)
|
||||
|
@ -227,6 +221,8 @@ public class Commands implements CommandExecutor {
|
|||
SendMessage(player, "Flair accepted: "+p.AcceptedFlair);
|
||||
SendMessage(player, "Flair ignored: "+p.IgnoredFlair);
|
||||
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)
|
||||
{ //2015.08.09.
|
||||
|
@ -251,6 +247,7 @@ public class Commands implements CommandExecutor {
|
|||
{ //2015.08.09.
|
||||
flair=flair.replace('&', '§');
|
||||
targetplayer.Flair=flair;
|
||||
targetplayer.CommentedOnReddit=true; //Or at least has a flair in some way
|
||||
if(!PluginMain.RemoveLineFromFile("customflairs.txt", targetplayer.PlayerName))
|
||||
{
|
||||
SendMessage(player, "§cError removing previous custom flair!§r");
|
||||
|
@ -260,7 +257,7 @@ public class Commands implements CommandExecutor {
|
|||
try {
|
||||
BufferedWriter bw;
|
||||
bw = new BufferedWriter(new FileWriter(file, true));
|
||||
bw.write(targetplayer.PlayerName+"\n");
|
||||
bw.write(targetplayer.PlayerName+targetplayer.Flair+"\n");
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error!\n"+e);
|
||||
|
|
|
@ -11,6 +11,7 @@ public class MaybeOfflinePlayer
|
|||
public boolean IgnoredFlair;
|
||||
public boolean FlairDecided; //2015.08.09.
|
||||
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 MaybeOfflinePlayer AddPlayerIfNeeded(String playername)
|
||||
{
|
||||
|
@ -18,6 +19,7 @@ public class MaybeOfflinePlayer
|
|||
{
|
||||
MaybeOfflinePlayer player=new MaybeOfflinePlayer();
|
||||
player.PlayerName=playername;
|
||||
player.Flair=""; //2015.08.10.
|
||||
AllPlayers.put(playername, player);
|
||||
return player;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class PlayerListener implements Listener
|
|||
Player p=event.getPlayer();
|
||||
MaybeOfflinePlayer.AddPlayerIfNeeded(p.getName()); //2015.08.08.
|
||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AllPlayers.get(p.getName()); //2015.08.08.
|
||||
if(mp.Flair!=null)
|
||||
if(mp.CommentedOnReddit)
|
||||
PluginMain.AppendPlayerDisplayFlair(mp, p); //2015.08.09.
|
||||
else
|
||||
{ //2015.07.20.
|
||||
|
@ -36,8 +36,8 @@ public class PlayerListener implements Listener
|
|||
{
|
||||
MaybeOfflinePlayer player = MaybeOfflinePlayer.AllPlayers.get(event.getPlayer().getName());
|
||||
String flair=player.Flair; //2015.08.08.
|
||||
if(flair==null || !player.AcceptedFlair)
|
||||
flair=""; //2015.08.08.
|
||||
if(player.IgnoredFlair)
|
||||
flair="";
|
||||
String message=event.getMessage(); //2015.08.08.
|
||||
/*for(Player p : PluginMain.GetPlayers())
|
||||
{ //2015.08.08.
|
||||
|
|
|
@ -133,7 +133,8 @@ public class PluginMain extends JavaPlugin
|
|||
public Boolean HasIGFlair(String playername)
|
||||
{
|
||||
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)
|
||||
|
@ -163,13 +164,13 @@ public class PluginMain extends JavaPlugin
|
|||
finalflair="§5("+text+")§r";
|
||||
break;
|
||||
case "no-press":
|
||||
finalflair="§7(non-pr.)§r";
|
||||
finalflair="§7(--s)§r";
|
||||
break;
|
||||
case "cheater":
|
||||
finalflair="§5("+text+")§r";
|
||||
break;
|
||||
case "cant-press": //2015.08.08.
|
||||
finalflair="§r(can't press)§r";
|
||||
finalflair="§r(??s)§r";
|
||||
break;
|
||||
case "unknown":
|
||||
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.
|
||||
return;*/
|
||||
p.Flair=finalflair; //2015.08.08.
|
||||
p.CommentedOnReddit=true; //2015.08.10.
|
||||
p.UserName=username; //2015.08.08.
|
||||
if(finalflair.length()==0) //Just for the message
|
||||
finalflair="undecided";
|
||||
|
@ -204,7 +206,8 @@ public class PluginMain extends JavaPlugin
|
|||
public static String GetFlair(Player player)
|
||||
{ //2015.07.16.
|
||||
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)
|
||||
|
@ -215,7 +218,7 @@ public class PluginMain extends JavaPlugin
|
|||
return;
|
||||
if(MaybeOfflinePlayer.AllPlayers.get(p.getName()).AcceptedFlair)
|
||||
{
|
||||
AppendPlayerDisplayFlairFinal(p, player.Flair); //2015.07.20.
|
||||
//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.
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
private static void AppendPlayerDisplayFlairFinal(Player player, String flair)
|
||||
/*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<>();
|
||||
|
@ -266,9 +269,8 @@ 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.
|
||||
}
|
||||
}*
|
||||
}*/
|
||||
|
||||
public static String GetColorForTown(String townname)
|
||||
{ //2015.07.20.
|
||||
|
@ -354,7 +356,11 @@ public class PluginMain extends JavaPlugin
|
|||
{
|
||||
String[] s=line.split(" ");
|
||||
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();
|
||||
}
|
||||
|
@ -396,9 +402,9 @@ public class PluginMain extends JavaPlugin
|
|||
{
|
||||
if(!player.IgnoredFlair)
|
||||
continue; //2015.08.08.
|
||||
bw.write(player.PlayerName+" "+player.Flair+"\n");
|
||||
bw.write(player.PlayerName+"\n");
|
||||
}
|
||||
bw.close();
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error!\n"+e);
|
||||
LastException=e; //2015.08.09.
|
||||
|
@ -428,7 +434,13 @@ public class PluginMain extends JavaPlugin
|
|||
}
|
||||
writer.close();
|
||||
reader.close();
|
||||
return tempFile.renameTo(inputFile);
|
||||
if(!tempFile.renameTo(inputFile))
|
||||
{
|
||||
inputFile.delete();
|
||||
return tempFile.renameTo(inputFile);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error!\n"+e);
|
||||
LastException=e; //2015.08.09.
|
||||
|
|
Loading…
Reference in a new issue