forked from TuxCoding/FastLogin
Declare nullable variants using jetbrains annotations
This commit is contained in:
@ -28,6 +28,7 @@ package com.github.games647.fastlogin.bukkit;
|
|||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PremiumPlaceholder extends PlaceholderExpansion {
|
public class PremiumPlaceholder extends PlaceholderExpansion {
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ public class PremiumPlaceholder extends PlaceholderExpansion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String onRequest(OfflinePlayer player, String identifier) {
|
public String onRequest(OfflinePlayer player, @NotNull String identifier) {
|
||||||
// player is null if offline
|
// player is null if offline
|
||||||
if (player != null && PLACEHOLDER_VARIABLE.equals(identifier)) {
|
if (player != null && PLACEHOLDER_VARIABLE.equals(identifier)) {
|
||||||
return plugin.getStatus(player.getUniqueId()).getReadableName();
|
return plugin.getStatus(player.getUniqueId()).getReadableName();
|
||||||
@ -50,7 +51,7 @@ public class PremiumPlaceholder extends PlaceholderExpansion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier() {
|
public @NotNull String getIdentifier() {
|
||||||
return plugin.getName();
|
return plugin.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,12 +61,12 @@ public class PremiumPlaceholder extends PlaceholderExpansion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAuthor() {
|
public @NotNull String getAuthor() {
|
||||||
return String.join(", ", plugin.getDescription().getAuthors());
|
return String.join(", ", plugin.getDescription().getAuthors());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersion() {
|
public @NotNull String getVersion() {
|
||||||
return plugin.getDescription().getVersion();
|
return plugin.getDescription().getVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import com.github.games647.fastlogin.core.StoredProfile;
|
|||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason;
|
import static com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason;
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ public class CrackedCommand extends ToggleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
onCrackedSelf(sender, command, args);
|
onCrackedSelf(sender, command, args);
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,17 +28,18 @@ package com.github.games647.fastlogin.bukkit.command;
|
|||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPremiumToggleEvent;
|
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPremiumToggleEvent;
|
||||||
import com.github.games647.fastlogin.core.StoredProfile;
|
import com.github.games647.fastlogin.core.StoredProfile;
|
||||||
|
import com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Let users activate fast login by command. This only be accessible if
|
* Let users activate fast login by command. This only be accessible if
|
||||||
* the user has access to it's account. So we can make sure that not another
|
* the user has access to its account. So we can make sure that not another
|
||||||
* person with a paid account and the same username can steal their account.
|
* person with a paid account and the same username can steal their account.
|
||||||
*/
|
*/
|
||||||
public class PremiumCommand extends ToggleCommand {
|
public class PremiumCommand extends ToggleCommand {
|
||||||
@ -48,7 +49,7 @@ public class PremiumCommand extends ToggleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
onPremiumSelf(sender, command, args);
|
onPremiumSelf(sender, command, args);
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,12 +47,12 @@ public abstract class ToggleCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean hasOtherPermission(CommandSender sender, Command cmd) {
|
protected boolean hasOtherPermission(CommandSender sender, Command cmd) {
|
||||||
if (!sender.hasPermission(cmd.getPermission() + ".other")) {
|
if (sender.hasPermission(cmd.getPermission() + ".other")) {
|
||||||
plugin.getCore().sendLocaleMessage("no-permission", sender);
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
plugin.getCore().sendLocaleMessage("no-permission", sender);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean forwardBungeeCommand(CommandSender sender, String target, boolean activate) {
|
protected boolean forwardBungeeCommand(CommandSender sender, String target, boolean activate) {
|
||||||
|
@ -31,6 +31,7 @@ import com.github.games647.fastlogin.core.shared.event.FastLoginAutoLoginEvent;
|
|||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class BukkitFastLoginAutoLoginEvent extends Event implements FastLoginAutoLoginEvent, Cancellable {
|
public class BukkitFastLoginAutoLoginEvent extends Event implements FastLoginAutoLoginEvent, Cancellable {
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ public class BukkitFastLoginAutoLoginEvent extends Event implements FastLoginAut
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import com.github.games647.fastlogin.core.shared.LoginSource;
|
|||||||
import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent;
|
import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class BukkitFastLoginPreLoginEvent extends Event implements FastLoginPreLoginEvent {
|
public class BukkitFastLoginPreLoginEvent extends Event implements FastLoginPreLoginEvent {
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ public class BukkitFastLoginPreLoginEvent extends Event implements FastLoginPreL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import com.github.games647.fastlogin.core.StoredProfile;
|
|||||||
import com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent;
|
import com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class BukkitFastLoginPremiumToggleEvent extends Event implements FastLoginPremiumToggleEvent {
|
public class BukkitFastLoginPremiumToggleEvent extends Event implements FastLoginPremiumToggleEvent {
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ public class BukkitFastLoginPremiumToggleEvent extends Event implements FastLogi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ import java.util.UUID;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for receiving messages from a BungeeCord instance.
|
* Responsible for receiving messages from a BungeeCord instance.
|
||||||
@ -57,7 +58,7 @@ public class BungeeListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
public void onPluginMessageReceived(@NotNull String channel, Player player, byte[] message) {
|
||||||
ByteArrayDataInput dataInput = ByteStreams.newDataInput(message);
|
ByteArrayDataInput dataInput = ByteStreams.newDataInput(message);
|
||||||
|
|
||||||
LoginActionMessage loginMessage = new LoginActionMessage();
|
LoginActionMessage loginMessage = new LoginActionMessage();
|
||||||
@ -67,7 +68,7 @@ public class BungeeListener implements PluginMessageListener {
|
|||||||
|
|
||||||
Player targetPlayer = player;
|
Player targetPlayer = player;
|
||||||
if (!loginMessage.getPlayerName().equals(player.getName())) {
|
if (!loginMessage.getPlayerName().equals(player.getName())) {
|
||||||
targetPlayer = Bukkit.getPlayerExact(loginMessage.getPlayerName());;
|
targetPlayer = Bukkit.getPlayerExact(loginMessage.getPlayerName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetPlayer == null) {
|
if (targetPlayer == null) {
|
||||||
|
@ -27,6 +27,7 @@ package com.github.games647.fastlogin.bungee.event;
|
|||||||
|
|
||||||
import com.github.games647.fastlogin.core.StoredProfile;
|
import com.github.games647.fastlogin.core.StoredProfile;
|
||||||
import com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent;
|
import com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent;
|
||||||
|
|
||||||
import net.md_5.bungee.api.plugin.Event;
|
import net.md_5.bungee.api.plugin.Event;
|
||||||
|
|
||||||
public class BungeeFastLoginPremiumToggleEvent extends Event implements FastLoginPremiumToggleEvent {
|
public class BungeeFastLoginPremiumToggleEvent extends Event implements FastLoginPremiumToggleEvent {
|
||||||
@ -45,7 +46,7 @@ public class BungeeFastLoginPremiumToggleEvent extends Event implements FastLogi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FastLoginPremiumToggleEvent.PremiumToggleReason getReason() {
|
public PremiumToggleReason getReason() {
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user