2016-09-08 14:23:44 +00:00
|
|
|
package buttondevteam.chat;
|
2016-06-22 23:09:49 +00:00
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Location;
|
2016-08-22 12:29:34 +00:00
|
|
|
import org.bukkit.OfflinePlayer;
|
2016-06-22 23:09:49 +00:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-08-22 17:39:31 +00:00
|
|
|
import buttondevteam.bucket.core.TBMCPlayer;
|
2016-09-08 14:27:45 +00:00
|
|
|
import buttondevteam.chat.formatting.ChatFormatter;
|
2016-08-22 12:29:34 +00:00
|
|
|
|
|
|
|
public class ChatPlayer extends TBMCPlayer {
|
2016-06-22 23:09:49 +00:00
|
|
|
public String UserName;
|
|
|
|
public List<String> UserNames;
|
|
|
|
private short FlairTime;
|
|
|
|
public FlairStates FlairState;
|
|
|
|
public boolean RPMode = true;
|
|
|
|
public boolean PressedF;
|
|
|
|
public Location SavedLocation;
|
|
|
|
public boolean Working;
|
|
|
|
// public int Tables = 10;
|
|
|
|
public Channel CurrentChannel = Channel.GlobalChat;
|
|
|
|
public int FCount;
|
|
|
|
public boolean SendingLink = false;
|
|
|
|
public int FDeaths;
|
|
|
|
public boolean RainbowPresserColorMode = false;
|
2016-06-28 22:45:04 +00:00
|
|
|
public ChatFormatter.Color OtherColorMode = null;
|
2016-06-22 23:09:49 +00:00
|
|
|
public boolean ChatOnly = false;
|
|
|
|
public boolean FlairCheater = false;
|
|
|
|
public int LoginWarningCount = 0;
|
|
|
|
public static final short FlairTimeNonPresser = -1;
|
|
|
|
public static final short FlairTimeCantPress = -2;
|
|
|
|
public static final short FlairTimeNone = -3;
|
|
|
|
|
2016-07-17 00:26:53 +00:00
|
|
|
public static HashMap<UUID, ChatPlayer> OnlinePlayers = new HashMap<>();
|
2016-06-22 23:09:49 +00:00
|
|
|
|
2016-08-22 12:29:34 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2016-07-16 21:55:36 +00:00
|
|
|
public static ChatPlayer GetFromName(String name) {
|
2016-08-22 12:29:34 +00:00
|
|
|
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
|
2016-08-22 14:17:09 +00:00
|
|
|
if (p != null) {
|
|
|
|
if (!ChatPlayer.OnlinePlayers.containsKey(p.getUniqueId())) {
|
|
|
|
TBMCPlayer player = TBMCPlayer.LoadPlayer(p);
|
|
|
|
if (player == null) {
|
|
|
|
Bukkit.getServer().getLogger()
|
|
|
|
.warning("Can't load player " + p.getUniqueId() + " - " + p.getName());
|
|
|
|
return null;
|
|
|
|
}
|
2016-09-30 11:22:39 +00:00
|
|
|
return ChatPlayer.OnlinePlayers.get(player.UUID);
|
2016-08-22 14:17:09 +00:00
|
|
|
}
|
|
|
|
return ChatPlayer.OnlinePlayers.get(p.getUniqueId());
|
|
|
|
} else
|
2016-06-22 23:09:49 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String GetFormattedFlair() {
|
|
|
|
if (FlairTime == FlairTimeCantPress)
|
|
|
|
return String.format("§r(--s)§r");
|
|
|
|
if (FlairTime == FlairTimeNonPresser)
|
|
|
|
return String.format("§7(--s)§r");
|
|
|
|
if (FlairTime == FlairTimeNone)
|
|
|
|
return "";
|
|
|
|
return String.format("§%x(%ss)§r", GetFlairColor(), FlairTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetFlair(short time) {
|
|
|
|
FlairTime = time;
|
|
|
|
FlairUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetFlair(short time, boolean cheater) {
|
|
|
|
FlairTime = time;
|
|
|
|
FlairCheater = cheater;
|
|
|
|
FlairUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void FlairUpdate() {
|
|
|
|
|
|
|
|
// Flairs from Command Block The Button - Teams
|
|
|
|
// PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard().getTeams().add()
|
|
|
|
Player p = Bukkit.getPlayer(UUID);
|
2016-08-22 14:17:09 +00:00
|
|
|
if (p != null)
|
|
|
|
p.setPlayerListName(String.format("%s%s", p.getName(), GetFormattedFlair()));
|
2016-06-22 23:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public short GetFlairColor() {
|
|
|
|
if (FlairCheater)
|
|
|
|
return 0x5;
|
|
|
|
if (FlairTime == -1)
|
|
|
|
return 0x7;
|
|
|
|
else if (FlairTime == -2)
|
|
|
|
return 0xf;
|
|
|
|
else if (FlairTime <= 60 && FlairTime >= 52)
|
|
|
|
return 0x5;
|
|
|
|
else if (FlairTime <= 51 && FlairTime >= 42)
|
|
|
|
return 0x9;
|
|
|
|
else if (FlairTime <= 41 && FlairTime >= 32)
|
|
|
|
return 0xa;
|
|
|
|
else if (FlairTime <= 31 && FlairTime >= 22)
|
|
|
|
return 0xe;
|
|
|
|
else if (FlairTime <= 21 && FlairTime >= 11)
|
|
|
|
return 0x6;
|
|
|
|
else if (FlairTime <= 11 && FlairTime >= 0)
|
|
|
|
return 0xc;
|
|
|
|
return 0xf;
|
|
|
|
}
|
|
|
|
|
|
|
|
public short GetFlairTime() {
|
|
|
|
return FlairTime;
|
|
|
|
}
|
|
|
|
|
2016-07-16 21:55:36 +00:00
|
|
|
public static ChatPlayer GetFromPlayer(Player p) {
|
2016-07-17 00:26:53 +00:00
|
|
|
return ChatPlayer.OnlinePlayers.get(p.getUniqueId());
|
2016-06-22 23:09:49 +00:00
|
|
|
}
|
|
|
|
}
|