diff --git a/.idea/modules/com.github.fernthedev.FernAPI.iml b/.idea/modules/com.github.fernthedev.FernAPI.iml deleted file mode 100644 index 83c96fd..0000000 --- a/.idea/modules/com.github.fernthedev.FernAPI.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/com.github.fernthedev.FernAPI.main.iml b/.idea/modules/com.github.fernthedev.FernAPI.main.iml index 8a82126..172873f 100644 --- a/.idea/modules/com.github.fernthedev.FernAPI.main.iml +++ b/.idea/modules/com.github.fernthedev.FernAPI.main.iml @@ -24,55 +24,57 @@ + + + + + + + + - - - - + - + + + + + - - - - - + + + + + + - + + - - + + + - - - - - - - - - + + - - - - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/com.github.fernthedev.FernAPI.test.iml b/.idea/modules/com.github.fernthedev.FernAPI.test.iml deleted file mode 100644 index e2f068a..0000000 --- a/.idea/modules/com.github.fernthedev.FernAPI.test.iml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/java/com/github/fernthedev/fernapi/server/bungee/player/BungeeFPlayer.java b/src/main/java/com/github/fernthedev/fernapi/server/bungee/player/BungeeFPlayer.java index 25563f4..85fe620 100644 --- a/src/main/java/com/github/fernthedev/fernapi/server/bungee/player/BungeeFPlayer.java +++ b/src/main/java/com/github/fernthedev/fernapi/server/bungee/player/BungeeFPlayer.java @@ -1,8 +1,8 @@ package com.github.fernthedev.fernapi.server.bungee.player; -import com.github.fernthedev.fernapi.universal.data.chat.BaseMessage; import com.github.fernthedev.fernapi.universal.api.IFPlayer; -import lombok.Getter; +import com.github.fernthedev.fernapi.universal.data.chat.BaseMessage; +import lombok.NonNull; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.*; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -10,13 +10,10 @@ import java.net.InetSocketAddress; import java.util.Collection; -public class BungeeFPlayer extends IFPlayer { - @Getter - private ProxiedPlayer player; +public class BungeeFPlayer extends IFPlayer { public BungeeFPlayer(ProxiedPlayer player) { - super(player.getName(),player.getUniqueId()); - this.player = player; + super(player == null ? null : player.getName(),player == null ? null : player.getUniqueId(), player); } /** @@ -53,8 +50,12 @@ public Collection getPermissions() { } @Override - public void sendMessage(BaseMessage baseMessage) { - TextComponent fullMessage = new TextComponent(ChatColor.translateAlternateColorCodes('&',baseMessage.getParentText())); + public void sendMessage(@NonNull BaseMessage baseMessage) { + String text = baseMessage.getParentText(); + + if (text == null) text = ""; + + TextComponent fullMessage = new TextComponent(ChatColor.translateAlternateColorCodes('&', baseMessage.getParentText())); if (baseMessage.getExtra() != null) { for(BaseMessage be : baseMessage.getExtra()) { diff --git a/src/main/java/com/github/fernthedev/fernapi/server/spigot/player/SpigotFPlayer.java b/src/main/java/com/github/fernthedev/fernapi/server/spigot/player/SpigotFPlayer.java index c600572..82c6b1e 100644 --- a/src/main/java/com/github/fernthedev/fernapi/server/spigot/player/SpigotFPlayer.java +++ b/src/main/java/com/github/fernthedev/fernapi/server/spigot/player/SpigotFPlayer.java @@ -2,9 +2,8 @@ import com.github.fernthedev.fernapi.server.spigot.pluginhandlers.VaultHandler; import com.github.fernthedev.fernapi.universal.Universal; -import com.github.fernthedev.fernapi.universal.data.chat.BaseMessage; import com.github.fernthedev.fernapi.universal.api.IFPlayer; -import lombok.Getter; +import com.github.fernthedev.fernapi.universal.data.chat.BaseMessage; import net.md_5.bungee.api.chat.*; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -18,13 +17,10 @@ import java.util.HashMap; import java.util.UUID; -public class SpigotFPlayer extends IFPlayer { - @Getter - private Player player; +public class SpigotFPlayer extends IFPlayer { public SpigotFPlayer(Player player) { - super(player.getName(),player.getUniqueId()); - this.player = player; + super(player == null ? null : player.getName(),player == null ? null : player.getUniqueId(), player); } /** diff --git a/src/main/java/com/github/fernthedev/fernapi/server/sponge/player/SpongeFPlayer.java b/src/main/java/com/github/fernthedev/fernapi/server/sponge/player/SpongeFPlayer.java index 26fc791..d173d13 100644 --- a/src/main/java/com/github/fernthedev/fernapi/server/sponge/player/SpongeFPlayer.java +++ b/src/main/java/com/github/fernthedev/fernapi/server/sponge/player/SpongeFPlayer.java @@ -17,8 +17,7 @@ import java.net.URL; import java.util.Collection; -public class SpongeFPlayer extends IFPlayer { - private Player player; +public class SpongeFPlayer extends IFPlayer { public SpongeFPlayer(Player player) { this.player = player; diff --git a/src/main/java/com/github/fernthedev/fernapi/server/velocity/player/VelocityFPlayer.java b/src/main/java/com/github/fernthedev/fernapi/server/velocity/player/VelocityFPlayer.java index 864489f..aa33450 100644 --- a/src/main/java/com/github/fernthedev/fernapi/server/velocity/player/VelocityFPlayer.java +++ b/src/main/java/com/github/fernthedev/fernapi/server/velocity/player/VelocityFPlayer.java @@ -1,10 +1,9 @@ package com.github.fernthedev.fernapi.server.velocity.player; +import com.github.fernthedev.fernapi.universal.api.IFPlayer; import com.github.fernthedev.fernapi.universal.data.chat.BaseMessage; import com.github.fernthedev.fernapi.universal.data.chat.ChatColor; -import com.github.fernthedev.fernapi.universal.api.IFPlayer; import com.velocitypowered.api.proxy.Player; -import lombok.Getter; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; @@ -12,13 +11,10 @@ import java.net.InetSocketAddress; import java.util.Collection; -public class VelocityFPlayer extends IFPlayer{ - @Getter - private Player player; +public class VelocityFPlayer extends IFPlayer { public VelocityFPlayer(Player player) { - super(player.getUsername(), player.getUniqueId()); - this.player = player; + super(player == null ? null : player.getUsername(),player == null ? null : player.getUniqueId(), player); } /** diff --git a/src/main/java/com/github/fernthedev/fernapi/universal/api/IFPlayer.java b/src/main/java/com/github/fernthedev/fernapi/universal/api/IFPlayer.java index 7d4b488..b96573d 100644 --- a/src/main/java/com/github/fernthedev/fernapi/universal/api/IFPlayer.java +++ b/src/main/java/com/github/fernthedev/fernapi/universal/api/IFPlayer.java @@ -9,12 +9,15 @@ @AllArgsConstructor @Getter -public abstract class IFPlayer implements CommandSender { +public abstract class IFPlayer implements CommandSender { @Getter - String name = null; + protected String name = null; @Getter - UUID uuid = null; + protected UUID uuid = null; + + @Getter + protected T player; public IFPlayer() {} @@ -25,4 +28,16 @@ public IFPlayer() {} public abstract long getPing(); public abstract String getCurrentServerName(); + + /** + * Returns true if all data is null + * If player is null but name and uuid aren't, this returns false + * @return + */ + public boolean isNull() { + boolean isPlayer = player == null; // Player must be null + boolean isDataNull = name == null || uuid == null; // Name and UUID both must be null + + return isPlayer && isDataNull; + } } diff --git a/src/main/java/com/github/fernthedev/fernapi/universal/data/JSONPlayer.java b/src/main/java/com/github/fernthedev/fernapi/universal/data/JSONPlayer.java index 080fb7e..c76c77f 100644 --- a/src/main/java/com/github/fernthedev/fernapi/universal/data/JSONPlayer.java +++ b/src/main/java/com/github/fernthedev/fernapi/universal/data/JSONPlayer.java @@ -11,10 +11,10 @@ @Getter @NoArgsConstructor -public class JSONPlayer extends IFPlayer { +public class JSONPlayer extends IFPlayer { public JSONPlayer(String name, UUID uuid) { - super(name,uuid); + super(name, uuid, null); } /**