Added API with documentation, renamed player class

This commit is contained in:
Norbi Peti 2016-07-01 16:54:21 +02:00
parent b6bf563b4b
commit fb869c7662
14 changed files with 127 additions and 77 deletions

View file

@ -0,0 +1,52 @@
package io.github.norbipeti.thebuttonmcchat;
import io.github.norbipeti.thebuttonmcchat.commands.CommandCaller;
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin.PlayerInfoCommand;
public class API {
/**
* <p>
* This method adds a command, adding it to help for example.
* </p>
* <p>
* The command must be registered in the caller plugin's plugin.yml.
* Otherwise the plugin will output a messsage to console.
* </p>
*
* @param plugin
* The caller plugin
* @param cmd
* The command to add
*/
public void AddCommand(Plugin plugin, TBMCCommandBase cmd) {
CommandCaller.AddCommand(plugin, cmd);
}
/**
* <p>
* Add player information for {@link PlayerInfoCommand}. Only mods can see
* the given information.
* </p>
*
* @param player
* @param infoline
*/
public void AddPlayerInfoForMods(TBMCPlayer player, String infoline) {
// TODO
}
/**
* <p>
* Add player information for hover text at {@link ChatProcessing}. Every
* online player can see the given information.
* </p>
*
* @param player
* @param infoline
*/
public void AddPlayerInfoForHover(TBMCPlayer player, String infoline) {
// TODO
}
}

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
package io.github.norbipeti.thebuttonmcchat.commands; package io.github.norbipeti.thebuttonmcchat.commands;
import io.github.norbipeti.thebuttonmcchat.MaybeOfflinePlayer; import io.github.norbipeti.thebuttonmcchat.TBMCPlayer;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -21,7 +21,7 @@ public final class ChatonlyCommand extends TBMCCommandBase {
@Override @Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) { public boolean OnCommand(CommandSender sender, String alias, String[] args) {
Player player=(Player)sender; Player player=(Player)sender;
MaybeOfflinePlayer p = MaybeOfflinePlayer.AllPlayers.get(player TBMCPlayer p = TBMCPlayer.AllPlayers.get(player
.getUniqueId()); .getUniqueId());
p.ChatOnly = true; p.ChatOnly = true;
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);

View file

@ -33,26 +33,18 @@ public class CommandCaller implements CommandExecutor {
public static void RegisterCommands(PluginMain plugin) { public static void RegisterCommands(PluginMain plugin) {
if (instance != null) { if (instance != null) {
new Exception("Only one instance of CommandCaller is allowed") new Exception("Only one instance of CommandCaller is allowed").printStackTrace();
.printStackTrace();
return; return;
} }
System.out.println("Registering commands..."); System.out.println("Registering commands...");
CommandCaller cc = new CommandCaller(); if (instance == null)
instance = cc; instance = new CommandCaller();
Reflections rf = new Reflections( Reflections rf = new Reflections(
new ConfigurationBuilder() new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader(plugin.getClass().getClassLoader()))
.setUrls( .addClassLoader(plugin.getClass().getClassLoader()).addScanners(new SubTypesScanner())
ClasspathHelper.forClassLoader(plugin .filterInputsBy((String pkg) -> pkg.contains("io.github.norbipeti.thebuttonmcchat.commands")));
.getClass().getClassLoader())) Set<Class<? extends TBMCCommandBase>> cmds = rf.getSubTypesOf(TBMCCommandBase.class);
.addClassLoader(plugin.getClass().getClassLoader())
.addScanners(new SubTypesScanner())
.filterInputsBy(
(String pkg) -> pkg
.contains("io.github.norbipeti.thebuttonmcchat.commands")));
Set<Class<? extends TBMCCommandBase>> cmds = rf
.getSubTypesOf(TBMCCommandBase.class);
for (Class<? extends TBMCCommandBase> cmd : cmds) { for (Class<? extends TBMCCommandBase> cmd : cmds) {
try { try {
if (Modifier.isAbstract(cmd.getModifiers())) if (Modifier.isAbstract(cmd.getModifiers()))
@ -63,8 +55,7 @@ public class CommandCaller implements CommandExecutor {
{ {
PluginCommand pc = plugin.getCommand(c.GetCommandPath()); PluginCommand pc = plugin.getCommand(c.GetCommandPath());
if (pc == null) if (pc == null)
new Exception("Can't find top-level command: " new Exception("Can't find top-level command: " + c.GetCommandPath()).printStackTrace();
+ c.GetCommandPath()).printStackTrace();
else else
pc.setExecutor(cc); pc.setExecutor(cc);
} }
@ -76,9 +67,22 @@ public class CommandCaller implements CommandExecutor {
} }
} }
public static void AddCommand(Plugin plugin, TBMCCommandBase cmd) {
if (instance == null)
instance = new CommandCaller();
commands.put(cmd.GetCommandPath(), cmd);
if (!c.GetCommandPath().contains("/")) // Top-level command
{
PluginCommand pc = plugin.getCommand(cmd.GetCommandPath());
if (pc == null)
new Exception("Can't find top-level command: " + c.GetCommandPath()).printStackTrace();
else
pc.setExecutor(instance);
}
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
String alias, String[] args) {
String path = command.getName(); String path = command.getName();
for (String arg : args) for (String arg : args)
path += "/" + arg; path += "/" + arg;
@ -92,20 +96,15 @@ public class CommandCaller implements CommandExecutor {
if (cmd == null) { if (cmd == null) {
sender.sendMessage("§cInternal error: Command not registered to CommandCaller"); sender.sendMessage("§cInternal error: Command not registered to CommandCaller");
if (sender != Bukkit.getConsoleSender()) if (sender != Bukkit.getConsoleSender())
Bukkit.getConsoleSender() Bukkit.getConsoleSender().sendMessage("§cInternal error: Command not registered to CommandCaller");
.sendMessage(
"§cInternal error: Command not registered to CommandCaller");
return true; return true;
} }
if (cmd.GetPlayerOnly() && sender == Bukkit.getConsoleSender()) { if (cmd.GetPlayerOnly() && sender == Bukkit.getConsoleSender()) {
sender.sendMessage("§cOnly ingame players can use this command."); sender.sendMessage("§cOnly ingame players can use this command.");
return true; return true;
} }
if (!cmd.OnCommand( if (!cmd.OnCommand(sender, alias,
sender, (args.length > 0 ? Arrays.copyOfRange(args, args.length - argc, args.length) : args)))
alias,
(args.length > 0 ? Arrays.copyOfRange(args, args.length - argc,
args.length) : args)))
sender.sendMessage(cmd.GetHelpText(alias)); sender.sendMessage(cmd.GetHelpText(alias));
return true; return true;
} }
@ -115,8 +114,7 @@ public class CommandCaller implements CommandExecutor {
cmds.add("§6---- Subcommands ----"); cmds.add("§6---- Subcommands ----");
for (TBMCCommandBase cmd : CommandCaller.GetCommands().values()) { for (TBMCCommandBase cmd : CommandCaller.GetCommands().values()) {
if (cmd.GetCommandPath().startsWith(command.GetCommandPath() + "/")) { if (cmd.GetCommandPath().startsWith(command.GetCommandPath() + "/")) {
int ind = cmd.GetCommandPath().indexOf('/', int ind = cmd.GetCommandPath().indexOf('/', command.GetCommandPath().length() + 2);
command.GetCommandPath().length() + 2);
if (ind >= 0) if (ind >= 0)
continue; continue;
cmds.add(cmd.GetCommandPath().replace('/', ' ')); cmds.add(cmd.GetCommandPath().replace('/', ' '));

View file

@ -1,6 +1,6 @@
package io.github.norbipeti.thebuttonmcchat.commands; package io.github.norbipeti.thebuttonmcchat.commands;
import io.github.norbipeti.thebuttonmcchat.MaybeOfflinePlayer; import io.github.norbipeti.thebuttonmcchat.TBMCPlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,12 +21,12 @@ public final class OOCCommand extends TBMCCommandBase {
if (args.length == 0) { if (args.length == 0) {
return false; return false;
} else { } else {
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = false; TBMCPlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = false;
String message = ""; String message = "";
for (String arg : args) for (String arg : args)
message += arg + " "; message += arg + " ";
player.chat(message.substring(0, message.length() - 1)); player.chat(message.substring(0, message.length() - 1));
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = true; TBMCPlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = true;
} }
return true; return true;
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin; package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin;
import io.github.norbipeti.thebuttonmcchat.MaybeOfflinePlayer; import io.github.norbipeti.thebuttonmcchat.TBMCPlayer;
import io.github.norbipeti.thebuttonmcchat.PluginMain; import io.github.norbipeti.thebuttonmcchat.PluginMain;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -25,7 +25,7 @@ public class ConfirmCommand extends AdminCommandBase {
PluginMain.LoadFiles(true); PluginMain.LoadFiles(true);
// TODO: Add players online // TODO: Add players online
for (Player p : PluginMain.GetPlayers()) for (Player p : PluginMain.GetPlayers())
MaybeOfflinePlayer.AddPlayerIfNeeded(p.getUniqueId()); TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId());
if (sender != PluginMain.Console) if (sender != PluginMain.Console)
PluginMain.Console.sendMessage("§6-- Reloading done!§r"); PluginMain.Console.sendMessage("§6-- Reloading done!§r");
sender.sendMessage("§6-- Reloading done!§r"); sender.sendMessage("§6-- Reloading done!§r");

View file

@ -1,6 +1,6 @@
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin; package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin;
import io.github.norbipeti.thebuttonmcchat.MaybeOfflinePlayer; import io.github.norbipeti.thebuttonmcchat.TBMCPlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -20,7 +20,7 @@ public class PlayerInfoCommand extends AdminCommandBase {
if (args.length == 0) { if (args.length == 0) {
return false; return false;
} }
MaybeOfflinePlayer p = MaybeOfflinePlayer.GetFromName(args[0]); TBMCPlayer p = TBMCPlayer.GetFromName(args[0]);
if (p == null) { if (p == null) {
sender.sendMessage("§cPlayer not found: " + args[0] sender.sendMessage("§cPlayer not found: " + args[0]
+ " - Currently only online players can be viewed§r"); + " - Currently only online players can be viewed§r");

View file

@ -1,7 +1,7 @@
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin; package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin;
import io.github.norbipeti.thebuttonmcchat.FlairStates; import io.github.norbipeti.thebuttonmcchat.FlairStates;
import io.github.norbipeti.thebuttonmcchat.MaybeOfflinePlayer; import io.github.norbipeti.thebuttonmcchat.TBMCPlayer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -32,11 +32,11 @@ public class SetFlairCommand extends AdminCommandBase {
} }
short flairtime = 0x00; short flairtime = 0x00;
if (args[1].equalsIgnoreCase("non-presser")) if (args[1].equalsIgnoreCase("non-presser"))
flairtime = MaybeOfflinePlayer.FlairTimeNonPresser; flairtime = TBMCPlayer.FlairTimeNonPresser;
else if (args[1].equalsIgnoreCase("cant-press")) else if (args[1].equalsIgnoreCase("cant-press"))
flairtime = MaybeOfflinePlayer.FlairTimeCantPress; flairtime = TBMCPlayer.FlairTimeCantPress;
else if (args[1].equalsIgnoreCase("none")) else if (args[1].equalsIgnoreCase("none"))
flairtime = MaybeOfflinePlayer.FlairTimeNone; flairtime = TBMCPlayer.FlairTimeNone;
else { else {
try { try {
flairtime = Short.parseShort(args[1]); 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."); sender.sendMessage("§cUnknown value for cheater parameter. Run without args to see usage.");
return true; return true;
} }
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p TBMCPlayer mp = TBMCPlayer.AddPlayerIfNeeded(p
.getUniqueId()); .getUniqueId());
mp.SetFlair(flairtime, cheater); mp.SetFlair(flairtime, cheater);
mp.FlairState = FlairStates.Accepted; mp.FlairState = FlairStates.Accepted;