Renamed to ChatPlayer

This commit is contained in:
Norbi Peti 2016-07-16 23:55:36 +02:00
parent fc2267d43f
commit 13ec4e43ad
25 changed files with 129 additions and 89 deletions

View file

@ -11,7 +11,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
public class TBMCPlayer {
public class ChatPlayer {
public String PlayerName;
public String UserName;
public List<String> UserNames;
@ -37,11 +37,11 @@ public class TBMCPlayer {
public UUID UUID;
public static HashMap<UUID, TBMCPlayer> AllPlayers = new HashMap<>();
public static HashMap<UUID, ChatPlayer> AllPlayers = new HashMap<>();
public static TBMCPlayer AddPlayerIfNeeded(UUID uuid) {
public static ChatPlayer AddPlayerIfNeeded(UUID uuid) {
if (!AllPlayers.containsKey(uuid)) {
TBMCPlayer player = new TBMCPlayer();
ChatPlayer player = new ChatPlayer();
player.UUID = uuid;
player.FlairTime = FlairTimeNone;
player.FlairState = FlairStates.NoComment;
@ -59,7 +59,7 @@ public class TBMCPlayer {
ConfigurationSection cs = yc.getConfigurationSection("players");
for (String key : cs.getKeys(false)) {
ConfigurationSection cs2 = cs.getConfigurationSection(key);
TBMCPlayer mp = AddPlayerIfNeeded(java.util.UUID
ChatPlayer mp = AddPlayerIfNeeded(java.util.UUID
.fromString(cs2.getString("uuid")));
mp.UserName = cs2.getString("username");
String tmp = cs2.getString("flairtime");
@ -84,7 +84,7 @@ public class TBMCPlayer {
public static void Save(YamlConfiguration yc) {
ConfigurationSection cs = yc.createSection("players");
for (TBMCPlayer mp : TBMCPlayer.AllPlayers.values()) {
for (ChatPlayer mp : ChatPlayer.AllPlayers.values()) {
ConfigurationSection cs2 = cs.createSection(mp.UUID.toString());
cs2.set("playername", mp.PlayerName);
cs2.set("username", mp.UserName);
@ -98,7 +98,7 @@ public class TBMCPlayer {
}
}
public static TBMCPlayer GetFromName(String name) {
public static ChatPlayer GetFromName(String name) {
Player p = Bukkit.getPlayer(name);
if (p != null)
return AllPlayers.get(p.getUniqueId());
@ -162,7 +162,7 @@ public class TBMCPlayer {
return FlairTime;
}
public static TBMCPlayer GetFromPlayer(Player p) {
return TBMCPlayer.AllPlayers.get(p.getUniqueId());
public static ChatPlayer GetFromPlayer(Player p) {
return ChatPlayer.AllPlayers.get(p.getUniqueId());
}
}

View file

@ -30,9 +30,9 @@ public class ChatProcessing {
if (player != null && PlayerListener.essentials.getUser(player).isMuted())
return true;
TBMCPlayer mp = null;
ChatPlayer mp = null;
if (player != null) {
mp = TBMCPlayer.AllPlayers.get(player.getUniqueId());
mp = ChatPlayer.AllPlayers.get(player.getUniqueId());
if (message.equalsIgnoreCase("F")) {
if (!mp.PressedF && PlayerListener.ActiveF) {
PlayerListener.FCount++;
@ -109,7 +109,7 @@ public class ChatProcessing {
System.out.println("Error: Can't find player " + match + " but it was reported as online.");
return false;
}
TBMCPlayer mpp = TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId());
ChatPlayer mpp = ChatPlayer.AddPlayerIfNeeded(p.getUniqueId());
if (PlayerListener.NotificationSound == null)
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO:
// Airhorn
@ -143,7 +143,7 @@ public class ChatProcessing {
"Error: Can't find player " + match + " but it was reported as online.");
return false;
}
TBMCPlayer mpp = TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId());
ChatPlayer mpp = ChatPlayer.AddPlayerIfNeeded(p.getUniqueId());
if (PlayerListener.NotificationSound == null)
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO:
// Airhorn

View file

@ -7,6 +7,6 @@ public abstract class PlayerJoinTimerTask extends TimerTask {
@Override
public abstract void run();
public TBMCPlayer mp;
public ChatPlayer mp;
}

View file

@ -66,7 +66,7 @@ public class PlayerListener implements Listener {
if (essentials == null)
essentials = ((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"));
final Player p = event.getPlayer();
TBMCPlayer mp = TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId());
ChatPlayer mp = ChatPlayer.AddPlayerIfNeeded(p.getUniqueId());
if (!mp.FlairState.equals(FlairStates.NoComment)) {
PluginMain.ConfirmUserMessage(mp);
Timer timer = new Timer();
@ -80,7 +80,7 @@ public class PlayerListener implements Listener {
timer.schedule(tt, 1000);
} else {
if (mp.GetFlairTime() == 0x00)
mp.SetFlair(TBMCPlayer.FlairTimeNone);
mp.SetFlair(ChatPlayer.FlairTimeNone);
Timer timer = new Timer();
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
@Override
@ -227,7 +227,7 @@ public class PlayerListener implements Listener {
if (event.getMessage().length() < 2)
return;
int index = event.getMessage().indexOf(" ");
TBMCPlayer mp = TBMCPlayer.AllPlayers.get(event.getPlayer().getUniqueId());
ChatPlayer mp = ChatPlayer.AllPlayers.get(event.getPlayer().getUniqueId());
String cmd = "";
if (index == -1) {
cmd = event.getMessage().substring(1);
@ -468,7 +468,7 @@ public class PlayerListener implements Listener {
static boolean ActiveF = false;
static int FCount = 0;
static TBMCPlayer FPlayer = null;
static ChatPlayer FPlayer = null;
private Timer Ftimer;
public static int AlphaDeaths;
@ -486,10 +486,10 @@ public class PlayerListener implements Listener {
Ftimer.cancel();
ActiveF = true;
FCount = 0;
FPlayer = TBMCPlayer.AllPlayers.get(e.getEntity().getUniqueId());
FPlayer = ChatPlayer.AllPlayers.get(e.getEntity().getUniqueId());
FPlayer.FDeaths++;
for (Player p : PluginMain.GetPlayers()) {
TBMCPlayer mp = TBMCPlayer.AllPlayers.get(p.getUniqueId());
ChatPlayer mp = ChatPlayer.AllPlayers.get(p.getUniqueId());
mp.PressedF = false;
p.sendMessage("§bPress F to pay respects.§r");
}
@ -579,7 +579,7 @@ public class PlayerListener implements Listener {
});
}
TBMCPlayer mp = TBMCPlayer.GetFromPlayer(e.getPlayer());
ChatPlayer mp = ChatPlayer.GetFromPlayer(e.getPlayer());
if (mp.ChatOnly)
e.setCancelled(true);
}
@ -603,7 +603,7 @@ public class PlayerListener implements Listener {
* "§cYou are not allowed to teleport to/from No Mans Land."); }
*/
if (TBMCPlayer.GetFromPlayer(e.getPlayer()).ChatOnly) {
if (ChatPlayer.GetFromPlayer(e.getPlayer()).ChatOnly) {
e.setCancelled(true);
e.getPlayer().sendMessage("§cYou are not allowed to teleport while in chat-only mode.");
}

View file

@ -156,7 +156,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
else
ign = ign.substring(start, end);
ign = ign.trim();
TBMCPlayer mp = TBMCPlayer.GetFromName(ign);
ChatPlayer mp = ChatPlayer.GetFromName(ign);
if (mp == null)
continue;
if (!JoinedBefore(mp, 2015, 6, 5))
@ -185,7 +185,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
}
}
public void DownloadFlair(TBMCPlayer mp)
public void DownloadFlair(ChatPlayer mp)
throws MalformedURLException, IOException {
String[] flairdata = DownloadString(
"http://karmadecay.com/thebutton-data.php?users=" + mp.UserName)
@ -218,7 +218,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
return body;
}
private void SetFlair(TBMCPlayer p, String text, String flairclass,
private void SetFlair(ChatPlayer p, String text, String flairclass,
String username) {
p.UserName = username;
p.FlairState = FlairStates.Recognised;
@ -233,26 +233,26 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
{
try {
if (CheckForJoinDate(p)) {
p.SetFlair(TBMCPlayer.FlairTimeNonPresser);
p.SetFlair(ChatPlayer.FlairTimeNonPresser);
} else {
p.SetFlair(TBMCPlayer.FlairTimeCantPress);
p.SetFlair(ChatPlayer.FlairTimeCantPress);
}
} catch (Exception e) {
p.FlairState = FlairStates.Commented; // Flair unknown
p.SetFlair(TBMCPlayer.FlairTimeNone);
p.SetFlair(ChatPlayer.FlairTimeNone);
e.printStackTrace();
}
} else {
try {
if (CheckForJoinDate(p)) {
p.FlairState = FlairStates.Commented; // Flair unknown
p.SetFlair(TBMCPlayer.FlairTimeNone);
p.SetFlair(ChatPlayer.FlairTimeNone);
} else {
p.SetFlair(TBMCPlayer.FlairTimeCantPress);
p.SetFlair(ChatPlayer.FlairTimeCantPress);
}
} catch (Exception e) {
p.FlairState = FlairStates.Commented; // Flair unknown
p.SetFlair(TBMCPlayer.FlairTimeNone);
p.SetFlair(ChatPlayer.FlairTimeNone);
e.printStackTrace();
}
}
@ -263,12 +263,12 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
p.SetFlair(Short.parseShort(text));
}
public static boolean CheckForJoinDate(TBMCPlayer mp)
public static boolean CheckForJoinDate(ChatPlayer mp)
throws Exception {
return JoinedBefore(mp, 2015, 4, 1);
}
public static boolean JoinedBefore(TBMCPlayer mp, int year,
public static boolean JoinedBefore(ChatPlayer mp, int year,
int month, int day) throws Exception {
URL url = new URL("https://www.reddit.com/u/" + mp.UserName);
URLConnection con = url.openConnection();
@ -288,7 +288,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
.setDate(year, month, day).build().getTime());
}
public static void ConfirmUserMessage(TBMCPlayer mp) {
public static void ConfirmUserMessage(ChatPlayer mp) {
Player p = Bukkit.getPlayer(mp.UUID);
if (mp.FlairState.equals(FlairStates.Commented) && p != null)
if (mp.UserNames.size() > 1)
@ -307,7 +307,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
public static void LoadFiles(boolean reload) {
if (reload) {
System.out.println("TBMC chat plugin cleanup for reloading...");
TBMCPlayer.AllPlayers.clear();
ChatPlayer.AllPlayers.clear();
AnnounceMessages.clear();
}
System.out.println("Loading files for TBMC chat plugin...");
@ -316,7 +316,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
if (file.exists()) {
YamlConfiguration yc = new YamlConfiguration();
yc.load(file);
TBMCPlayer.Load(yc);
ChatPlayer.Load(yc);
PlayerListener.NotificationSound = yc
.getString("notificationsound");
PlayerListener.NotificationPitch = yc
@ -340,7 +340,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
try {
File file = new File("thebuttonmc.yml");
YamlConfiguration yc = new YamlConfiguration();
TBMCPlayer.Save(yc);
ChatPlayer.Save(yc);
yc.set("notificationsound", PlayerListener.NotificationSound);
yc.set("notificationpitch", PlayerListener.NotificationPitch);
yc.set("announcetime", AnnounceTime);

View file

@ -35,7 +35,7 @@ public class TBMCChatAPI {
* @param player
* @param infoline
*/
public void AddPlayerInfoForMods(TBMCPlayer player, String infoline) {
public void AddPlayerInfoForMods(ChatPlayer player, String infoline) {
// TODO
}
@ -48,12 +48,7 @@ public class TBMCChatAPI {
* @param player
* @param infoline
*/
public void AddPlayerInfoForHover(TBMCPlayer player, String infoline) {
public void AddPlayerInfoForHover(ChatPlayer player, String infoline) {
// TODO
}
public TBMCPlayer GetPlayer(Player player) //TODO: Move to the bucket
{ //TODO: Enable offline playerinfo
}
}

View file

@ -4,7 +4,7 @@ import org.bukkit.GameMode;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import buttondevteam.thebuttonmcchat.TBMCPlayer;
import buttondevteam.thebuttonmcchat.ChatPlayer;
public final class ChatonlyCommand extends TBMCCommandBase {
@ -21,7 +21,7 @@ public final class ChatonlyCommand extends TBMCCommandBase {
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
Player player=(Player)sender;
TBMCPlayer p = TBMCPlayer.AllPlayers.get(player
ChatPlayer p = ChatPlayer.AllPlayers.get(player
.getUniqueId());
p.ChatOnly = true;
player.setGameMode(GameMode.SPECTATOR);
@ -39,4 +39,9 @@ public final class ChatonlyCommand extends TBMCCommandBase {
return false;
}
@Override
public boolean GetModOnly() {
return false;
}
}

View file

@ -11,6 +11,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.reflections.Reflections;
@ -101,7 +102,11 @@ public class CommandCaller implements CommandExecutor {
Bukkit.getConsoleSender().sendMessage("§cInternal error: Command not registered to CommandCaller");
return true;
}
if (cmd.GetPlayerOnly() && sender == Bukkit.getConsoleSender()) {
if (cmd.GetModOnly() && PluginMain.permission.has(sender, "tbmc.admin")) {
sender.sendMessage("§cYou need to be a mod to use this command.");
return true;
}
if (cmd.GetPlayerOnly() && !(sender instanceof Player)) {
sender.sendMessage("§cOnly ingame players can use this command.");
return true;
}

View file

@ -39,4 +39,9 @@ public class MWikiCommand extends TBMCCommandBase {
return false;
}
@Override
public boolean GetModOnly() {
return false;
}
}

View file

@ -3,7 +3,7 @@ package buttondevteam.thebuttonmcchat.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import buttondevteam.thebuttonmcchat.TBMCPlayer;
import buttondevteam.thebuttonmcchat.ChatPlayer;
public final class OOCCommand extends TBMCCommandBase {
@ -21,12 +21,12 @@ public final class OOCCommand extends TBMCCommandBase {
if (args.length == 0) {
return false;
} else {
TBMCPlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = false;
ChatPlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = false;
String message = "";
for (String arg : args)
message += arg + " ";
player.chat(message.substring(0, message.length() - 1));
TBMCPlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = true;
ChatPlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = true;
}
return true;
}
@ -41,4 +41,9 @@ public final class OOCCommand extends TBMCCommandBase {
return true;
}
@Override
public boolean GetModOnly() {
return false;
}
}

View file

@ -9,10 +9,11 @@ public abstract class TBMCCommandBase {
public abstract String[] GetHelpText(String alias);
public abstract boolean OnCommand(CommandSender sender, String alias,
String[] args);
public abstract boolean OnCommand(CommandSender sender, String alias, String[] args);
public abstract String GetCommandPath();
public abstract boolean GetPlayerOnly();
public abstract boolean GetModOnly();
}

View file

@ -15,8 +15,7 @@ public final class UnlolCommand extends TBMCCommandBase {
@Override
public String[] GetHelpText(String alias) {
return new String[] {
"§6---- Unlol/unlaugh ----",
return new String[] { "§6---- Unlol/unlaugh ----",
"This command is based on a joke between NorbiPeti and Ghostise",
"It will make anyone saying one of the recognized laugh strings blind for a few seconds",
"Note that you can only unlaugh laughs that weren't unlaughed before" };
@ -26,13 +25,11 @@ public final class UnlolCommand extends TBMCCommandBase {
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
if (Lastlol != null) {
if (Lastlol instanceof Player)
((Player) Lastlol).addPotionEffect(new PotionEffect(
PotionEffectType.BLINDNESS, 10 * 20, 5, false, false));
String msg = (sender instanceof Player ? ((Player) sender)
.getDisplayName() : sender.getName())
((Player) Lastlol)
.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10 * 20, 5, false, false));
String msg = (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName())
+ (Lastlolornot ? " unlolled " : " unlaughed ")
+ (Lastlol instanceof Player ? ((Player) Lastlol)
.getDisplayName() : Lastlol.getName());
+ (Lastlol instanceof Player ? ((Player) Lastlol).getDisplayName() : Lastlol.getName());
for (Player pl : PluginMain.GetPlayers())
pl.sendMessage(msg);
Bukkit.getServer().getConsoleSender().sendMessage(msg);
@ -51,4 +48,8 @@ public final class UnlolCommand extends TBMCCommandBase {
return false;
}
@Override
public boolean GetModOnly() {
return false;
}
}

View file

@ -34,4 +34,8 @@ public class YeehawCommand extends TBMCCommandBase {
return false;
}
@Override
public boolean GetModOnly() {
return false;
}
}

View file

@ -25,4 +25,8 @@ public abstract class AppendTextCommandBase extends TBMCCommandBase {
return false;
}
@Override
public boolean GetModOnly() {
return false;
}
}

View file

@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
import buttondevteam.thebuttonmcchat.FlairStates;
import buttondevteam.thebuttonmcchat.PlayerJoinTimerTask;
import buttondevteam.thebuttonmcchat.PluginMain;
import buttondevteam.thebuttonmcchat.TBMCPlayer;
import buttondevteam.thebuttonmcchat.ChatPlayer;
public class AcceptCommand extends UCommandBase {
@ -22,7 +22,7 @@ public class AcceptCommand extends UCommandBase {
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
final Player player = (Player) sender;
TBMCPlayer p = TBMCPlayer.GetFromPlayer(player);
ChatPlayer p = ChatPlayer.GetFromPlayer(player);
if (args.length < 1 && p.UserNames.size() > 1) {
player.sendMessage("§9Multiple users commented your name. §bPlease pick one using /u accept <username>");
StringBuilder sb = new StringBuilder();

View file

@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
import buttondevteam.thebuttonmcchat.ChatFormatter;
import buttondevteam.thebuttonmcchat.PluginMain;
import buttondevteam.thebuttonmcchat.TBMCPlayer;
import buttondevteam.thebuttonmcchat.ChatPlayer;
public class CCommand extends UCommandBase {
@ -19,7 +19,7 @@ public class CCommand extends UCommandBase {
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
Player player = (Player) sender;
TBMCPlayer p = TBMCPlayer.AddPlayerIfNeeded(player
ChatPlayer p = ChatPlayer.AddPlayerIfNeeded(player
.getUniqueId());
if (args.length < 1) {
if (PluginMain.permission.has(player, "tbmc.rainbow")) {

View file

@ -4,7 +4,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import buttondevteam.thebuttonmcchat.FlairStates;
import buttondevteam.thebuttonmcchat.TBMCPlayer;
import buttondevteam.thebuttonmcchat.ChatPlayer;
public final class IgnoreCommand extends UCommandBase {
@ -19,7 +19,7 @@ public final class IgnoreCommand extends UCommandBase {
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
final Player player = (Player) sender;
TBMCPlayer p = TBMCPlayer.GetFromPlayer(player);
ChatPlayer p = ChatPlayer.GetFromPlayer(player);
if (p.FlairState.equals(FlairStates.Accepted)) {
player.sendMessage("§cYou can only ignore the \"write yoőu rname in the thread\" message.");
return true;
@ -30,7 +30,7 @@ public final class IgnoreCommand extends UCommandBase {
}
if (!p.FlairState.equals(FlairStates.Ignored)) {
p.FlairState = FlairStates.Ignored;
p.SetFlair(TBMCPlayer.FlairTimeNone);
p.SetFlair(ChatPlayer.FlairTimeNone);
p.UserName = "";
player.sendMessage("§bYou have ignored the message. You can still use /u accept to get a flair.§r");
} else

View file

@ -2,7 +2,7 @@ package buttondevteam.thebuttonmcchat.commands.ucmds;
import org.bukkit.command.CommandSender;
import buttondevteam.thebuttonmcchat.TBMCPlayer;
import buttondevteam.thebuttonmcchat.ChatPlayer;
public class NameCommand extends UCommandBase {
@ -19,7 +19,7 @@ public class NameCommand extends UCommandBase {
if (args.length == 1) {
return false;
}
TBMCPlayer mp = TBMCPlayer.GetFromName(args[1]);
ChatPlayer mp = ChatPlayer.GetFromName(args[1]);
if (mp == null) {
sender.sendMessage("§cUnknown user (player has to be online): "
+ args[1]);

View file

@ -27,4 +27,8 @@ public final class UCommand extends TBMCCommandBase {
return false;
}
@Override
public boolean GetModOnly() {
return false;
}
}

View file

@ -17,4 +17,9 @@ public abstract class UCommandBase extends TBMCCommandBase {
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
return false;
}
}

View file

@ -26,4 +26,9 @@ public final class AdminCommand extends UCommandBase {
public boolean GetPlayerOnly() {
return false;
}
@Override
public boolean GetModOnly() {
return true;
}
}

View file

@ -4,7 +4,8 @@ import buttondevteam.thebuttonmcchat.commands.ucmds.UCommandBase;
public abstract class AdminCommandBase extends UCommandBase {
public abstract String[] GetHelpText(String alias); //TODO: Require permission
public abstract String[] GetHelpText(String alias); // TODO: Require
// permission
@Override
public String GetUCommandPath() {
@ -18,4 +19,8 @@ public abstract class AdminCommandBase extends UCommandBase {
public abstract String GetAdminCommandPath();
@Override
public boolean GetModOnly() {
return true;
}
}

View file

@ -4,7 +4,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import buttondevteam.thebuttonmcchat.PluginMain;
import buttondevteam.thebuttonmcchat.TBMCPlayer;
import buttondevteam.thebuttonmcchat.ChatPlayer;
public class ConfirmCommand extends AdminCommandBase {
@ -25,7 +25,7 @@ public class ConfirmCommand extends AdminCommandBase {
PluginMain.LoadFiles(true);
// TODO: Add players online
for (Player p : PluginMain.GetPlayers())
TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId());
ChatPlayer.AddPlayerIfNeeded(p.getUniqueId());
if (sender != PluginMain.Console)
PluginMain.Console.sendMessage("§6-- Reloading done!§r");
sender.sendMessage("§6-- Reloading done!§r");

View file

@ -2,38 +2,34 @@ package buttondevteam.thebuttonmcchat.commands.ucmds.admin;
import org.bukkit.command.CommandSender;
import buttondevteam.thebuttonmcchat.TBMCPlayer;
import buttondevteam.thebuttonmcchat.ChatPlayer;
public class PlayerInfoCommand extends AdminCommandBase {
@Override
public String[] GetHelpText(String alias) {
return new String[] {
"§6---- Player info ----",
return new String[] { "§6---- Player info ----",
"Shows some info about the player's flair, Reddit username(s) and other data known by the plugin",
"Usage: /u admin playerinfo <player>" };
}
@Override
public boolean OnCommand(CommandSender sender, String alias,
String[] args) {
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
if (args.length == 0) {
return false;
}
TBMCPlayer p = TBMCPlayer.GetFromName(args[0]);
ChatPlayer p = ChatPlayer.GetFromName(args[0]);
if (p == null) {
sender.sendMessage("§cPlayer not found: " + args[0]
+ " - Currently only online players can be viewed§r");
sender.sendMessage("§cPlayer not found: " + args[0] + "§r");
return true;
}
StringBuilder sb = new StringBuilder();
sb.append("§6Usernames:");
for (String username : p.UserNames)
sb.append(" ").append(username);
sender.sendMessage(new String[] { "Player name: " + p.PlayerName,
"User flair: " + p.GetFormattedFlair(),
"Username: " + p.UserName, "Flair state: " + p.FlairState,
sb.toString(), "FCount: " + p.FCount, "FDeaths: " + p.FDeaths });
sender.sendMessage(new String[] { "Player name: " + p.PlayerName, "User flair: " + p.GetFormattedFlair(),
"Username: " + p.UserName, "Flair state: " + p.FlairState, sb.toString(), "FCount: " + p.FCount,
"FDeaths: " + p.FDeaths });
return true;
}

View file

@ -5,7 +5,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import buttondevteam.thebuttonmcchat.FlairStates;
import buttondevteam.thebuttonmcchat.TBMCPlayer;
import buttondevteam.thebuttonmcchat.ChatPlayer;
public class SetFlairCommand extends AdminCommandBase {
@ -32,11 +32,11 @@ public class SetFlairCommand extends AdminCommandBase {
}
short flairtime = 0x00;
if (args[1].equalsIgnoreCase("non-presser"))
flairtime = TBMCPlayer.FlairTimeNonPresser;
flairtime = ChatPlayer.FlairTimeNonPresser;
else if (args[1].equalsIgnoreCase("cant-press"))
flairtime = TBMCPlayer.FlairTimeCantPress;
flairtime = ChatPlayer.FlairTimeCantPress;
else if (args[1].equalsIgnoreCase("none"))
flairtime = TBMCPlayer.FlairTimeNone;
flairtime = ChatPlayer.FlairTimeNone;
else {
try {
flairtime = Short.parseShort(args[1]);
@ -54,7 +54,7 @@ public class SetFlairCommand extends AdminCommandBase {
sender.sendMessage("§cUnknown value for cheater parameter. Run without args to see usage.");
return true;
}
TBMCPlayer mp = TBMCPlayer.AddPlayerIfNeeded(p
ChatPlayer mp = ChatPlayer.AddPlayerIfNeeded(p
.getUniqueId());
mp.SetFlair(flairtime, cheater);
mp.FlairState = FlairStates.Accepted;