2018-07-23 10:39:55 +02:00
|
|
|
From 71beda67b3983f467674f9b2b65a54e9199fda7a Mon Sep 17 00:00:00 2001
|
2017-07-28 05:39:31 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Mon, 3 Jul 2017 18:11:34 -0500
|
|
|
|
Subject: [PATCH] ProfileWhitelistVerifyEvent
|
|
|
|
|
|
|
|
Fires when the server is validating if a player is whitelisted.
|
|
|
|
|
|
|
|
Allows you to do dynamic whitelisting and change of kick message
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java
|
|
|
|
new file mode 100644
|
2018-01-19 06:12:03 +01:00
|
|
|
index 00000000..662e79e3
|
2017-07-28 05:39:31 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java
|
2018-01-19 06:12:03 +01:00
|
|
|
@@ -0,0 +1,120 @@
|
2017-07-28 05:39:31 +02:00
|
|
|
+/*
|
|
|
|
+ * Copyright (c) 2017 - Daniel Ennis (Aikar) - MIT License
|
|
|
|
+ *
|
|
|
|
+ * Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
+ * a copy of this software and associated documentation files (the
|
|
|
|
+ * "Software"), to deal in the Software without restriction, including
|
|
|
|
+ * without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
+ * distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
+ * permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
+ * the following conditions:
|
|
|
|
+ *
|
|
|
|
+ * The above copyright notice and this permission notice shall be
|
|
|
|
+ * included in all copies or substantial portions of the Software.
|
|
|
|
+ *
|
|
|
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+package com.destroystokyo.paper.event.profile;
|
|
|
|
+
|
2018-01-19 06:12:03 +01:00
|
|
|
+import com.destroystokyo.paper.profile.PlayerProfile;
|
2017-07-28 05:39:31 +02:00
|
|
|
+import com.mojang.authlib.GameProfile;
|
|
|
|
+import org.bukkit.event.Event;
|
|
|
|
+import org.bukkit.event.HandlerList;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Fires when the server needs to verify if a player is whitelisted.
|
|
|
|
+ *
|
|
|
|
+ * Plugins may override/control the servers whitelist with this event,
|
|
|
|
+ * and dynamically change the kick message.
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+public class ProfileWhitelistVerifyEvent extends Event {
|
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
2018-01-19 06:12:03 +01:00
|
|
|
+ private final PlayerProfile profile;
|
2017-07-28 05:39:31 +02:00
|
|
|
+ private final boolean whitelistEnabled;
|
|
|
|
+ private boolean whitelisted;
|
|
|
|
+ private final boolean isOp;
|
|
|
|
+ private String kickMessage;
|
|
|
|
+
|
2018-01-19 06:12:03 +01:00
|
|
|
+ public ProfileWhitelistVerifyEvent(final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, String kickMessage) {
|
2017-07-28 05:39:31 +02:00
|
|
|
+ this.profile = profile;
|
|
|
|
+ this.whitelistEnabled = whitelistEnabled;
|
|
|
|
+ this.whitelisted = whitelisted;
|
|
|
|
+ this.isOp = isOp;
|
|
|
|
+ this.kickMessage = kickMessage;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the currently planned message to send to the user if they are not whitelisted
|
|
|
|
+ */
|
|
|
|
+ public String getKickMessage() {
|
|
|
|
+ return kickMessage;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param kickMessage The message to send to the player on kick if not whitelisted. May set to null to use the server configured default
|
|
|
|
+ */
|
|
|
|
+ public void setKickMessage(String kickMessage) {
|
|
|
|
+ this.kickMessage = kickMessage;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The gameprofile of the player trying to connect
|
2018-01-19 06:12:03 +01:00
|
|
|
+ * @deprecated Will be removed in 1.13, use #{@link #getPlayerProfile()}
|
2017-07-28 05:39:31 +02:00
|
|
|
+ */
|
2018-01-19 06:12:03 +01:00
|
|
|
+ @Deprecated
|
2017-07-28 05:39:31 +02:00
|
|
|
+ public GameProfile getProfile() {
|
2018-01-19 06:12:03 +01:00
|
|
|
+ return profile.getGameProfile();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return The profile of the player trying to connect
|
|
|
|
+ */
|
|
|
|
+ public PlayerProfile getPlayerProfile() {
|
2017-07-28 05:39:31 +02:00
|
|
|
+ return profile;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Whether the player is whitelisted to play on this server (whitelist may be off is why its true)
|
|
|
|
+ */
|
|
|
|
+ public boolean isWhitelisted() {
|
|
|
|
+ return whitelisted;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Changes the players whitelisted state. false will deny the login
|
|
|
|
+ */
|
|
|
|
+ public void setWhitelisted(boolean whitelisted) {
|
|
|
|
+ this.whitelisted = whitelisted;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns if the player obtained whitelist status by having op
|
|
|
|
+ */
|
|
|
|
+ public boolean isOp() {
|
|
|
|
+ return isOp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns if the server even has whitelist on
|
|
|
|
+ */
|
|
|
|
+ public boolean isWhitelistEnabled() {
|
|
|
|
+ return whitelistEnabled;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
--
|
2018-07-15 03:53:17 +02:00
|
|
|
2.18.0
|
2017-07-28 05:39:31 +02:00
|
|
|
|