Added join date check when flair is unknown, implemented issue #3 and #4

This commit is contained in:
Norbi Peti 2015-12-31 17:50:43 +01:00
parent 29b3c8830a
commit d7be9fbe30
6 changed files with 26 additions and 11 deletions

Binary file not shown.

View file

@ -180,7 +180,7 @@ public class PlayerListener implements Listener { // 2015.07.16.
"(?i)" + Pattern.quote(p.getName()),
color
+ p.getName()
+ (greentext ? "§2"
+ (greentext ? "§a"
: player.CurrentChannel.DisplayName
.substring(0, 2)));
}
@ -212,7 +212,7 @@ public class PlayerListener implements Listener { // 2015.07.16.
message = message.replaceAll(
"(?i)" + Pattern.quote(nwithoutformatting),
n
+ (greentext ? "§2"
+ (greentext ? "§a"
: player.CurrentChannel.DisplayName
.substring(0, 2)));
}
@ -274,7 +274,7 @@ public class PlayerListener implements Listener { // 2015.07.16.
"#" + original,
String.format(
"\",\"color\":\"%s\"},{\"text\":\"#%s\",\"color\":\"blue\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://twitter.com/hashtag/%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Open on Twitter\",\"color\":\"blue\"}]}}},{\"text\":\"",
(greentext ? "dark_green"
(greentext ? "green"
: player.CurrentChannel.Color),
original, original));
@ -289,16 +289,16 @@ public class PlayerListener implements Listener { // 2015.07.16.
item,
String.format(
"\",\"color\":\"%s\"},{\"text\":\"%s\",\"color\":\"%s\",\"underlined\":\"true\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Open URL\",\"color\":\"blue\"}]}}},{\"text\":\"",
(greentext ? "dark_green"
(greentext ? "green"
: player.CurrentChannel.Color),
url, (greentext ? "dark_green"
url, (greentext ? "green"
: player.CurrentChannel.Color),
url));
} catch (MalformedURLException e) {
}
json.append(String.format("{\"text\":\"%s\",\"color\":\"%s\"}]",
finalstring, (greentext ? "dark_green"
finalstring, (greentext ? "green"
: player.CurrentChannel.Color)));
if (player.CurrentChannel.equals(Channel.TownChat)
|| player.CurrentChannel.equals(Channel.NationChat))
@ -661,11 +661,13 @@ public class PlayerListener implements Listener { // 2015.07.16.
private boolean ActiveF = false;
private int FCount = 0;
private MaybeOfflinePlayer FPlayer = null;
private Timer Ftimer;
public static int AlphaDeaths;
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
if (e.getEntity().getName().equals("Alpha_Bacca44"))
AlphaDeaths++;
if (!Minigames.plugin.pdata.getMinigamePlayer(e.getEntity())
.isInMinigame() && new Random().nextBoolean()) {
if (Ftimer != null)

View file

@ -100,7 +100,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
.getTownyUniverse();
Towns = new ArrayList<Town>(TU.getTownsMap().values());
Nations = new ArrayList<Nation>(TU.getNationsMap().values());
Runnable r = new Runnable() {
public void run() {
ThreadMethod();
@ -242,7 +242,8 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
break;
case "unknown":
if (text.equals("-1")) // If true, only non-presser/can't press; if
// false, any flair
// false, any flair (but we can still detect
// can't press)
{
try {
if (CheckForJoinDate(p)) {
@ -256,8 +257,18 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
e.printStackTrace();
}
} else {
p.FlairState = FlairStates.Commented; // Flair unknown
p.SetFlairColor(0);
try {
if (CheckForJoinDate(p)) {
p.FlairState = FlairStates.Commented; // Flair unknown
p.SetFlairColor(0);
} else {
p.SetFlair(0xf, "--");
}
} catch (Exception e) {
p.FlairState = FlairStates.Commented; // Flair unknown
p.SetFlairColor(0);
e.printStackTrace();
}
}
return;
default:
@ -324,6 +335,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
.getDouble("notificationpitch");
AnnounceTime = yc.getInt("announcetime");
AnnounceMessages.addAll(yc.getStringList("announcements"));
PlayerListener.AlphaDeaths = yc.getInt("alphadeaths");
}
System.out.println("The Button Minecraft plugin loaded files!");
} catch (IOException e) {
@ -345,6 +357,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
yc.set("notificationpitch", PlayerListener.NotificationPitch);
yc.set("announcetime", AnnounceTime);
yc.set("announcements", AnnounceMessages);
yc.set("alphadeaths", PlayerListener.AlphaDeaths);
yc.save(file);
System.out.println("The Button Minecraft plugin saved files!");
} catch (IOException e) {