2016-07-17 03:10:43 +02:00
|
|
|
From ecf329a1fbe4583de3e4ec9f0e07004db9c960d6 Mon Sep 17 00:00:00 2001
|
2016-03-21 06:53:32 +01:00
|
|
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
|
|
Date: Mon, 21 Mar 2016 00:19:18 -0500
|
|
|
|
Subject: [PATCH] Support offline mode in whitelist command as well
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/CommandWhitelist.java b/src/main/java/net/minecraft/server/CommandWhitelist.java
|
2016-06-09 05:57:14 +02:00
|
|
|
index c74d1d2..0f4237d 100644
|
2016-03-21 06:53:32 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/CommandWhitelist.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/CommandWhitelist.java
|
2016-05-12 04:07:46 +02:00
|
|
|
@@ -44,24 +44,35 @@ public class CommandWhitelist extends CommandAbstract {
|
2016-03-21 06:53:32 +01:00
|
|
|
throw new ExceptionUsage("commands.whitelist.add.usage", new Object[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Handle offline mode as well
|
|
|
|
+ /*
|
|
|
|
gameprofile = minecraftserver.getUserCache().getProfile(astring[1]);
|
|
|
|
if (gameprofile == null) {
|
|
|
|
throw new CommandException("commands.whitelist.add.failed", new Object[] { astring[1]});
|
|
|
|
}
|
|
|
|
|
|
|
|
minecraftserver.getPlayerList().addWhitelist(gameprofile);
|
|
|
|
+ */
|
|
|
|
+ this.whitelist(minecraftserver, astring[1], true);
|
|
|
|
+ // Paper end
|
|
|
|
a(icommandlistener, (ICommand) this, "commands.whitelist.add.success", new Object[] { astring[1]});
|
2016-06-09 05:57:14 +02:00
|
|
|
} else if ("remove".equals(astring[0])) {
|
2016-03-21 06:53:32 +01:00
|
|
|
if (astring.length < 2) {
|
|
|
|
throw new ExceptionUsage("commands.whitelist.remove.usage", new Object[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Handle offline mode as well
|
|
|
|
+ /*
|
|
|
|
gameprofile = minecraftserver.getPlayerList().getWhitelist().a(astring[1]);
|
|
|
|
if (gameprofile == null) {
|
|
|
|
throw new CommandException("commands.whitelist.remove.failed", new Object[] { astring[1]});
|
|
|
|
}
|
|
|
|
|
|
|
|
minecraftserver.getPlayerList().removeWhitelist(gameprofile);
|
|
|
|
+
|
|
|
|
+ */
|
|
|
|
+ this.whitelist(minecraftserver, astring[1], false);
|
|
|
|
+ // Paper end
|
|
|
|
a(icommandlistener, (ICommand) this, "commands.whitelist.remove.success", new Object[] { astring[1]});
|
2016-06-09 05:57:14 +02:00
|
|
|
} else if ("reload".equals(astring[0])) {
|
2016-03-21 06:53:32 +01:00
|
|
|
minecraftserver.getPlayerList().reloadWhitelist();
|
2016-05-12 04:07:46 +02:00
|
|
|
@@ -89,4 +100,43 @@ public class CommandWhitelist extends CommandAbstract {
|
2016-03-31 02:50:23 +02:00
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2016-03-21 06:53:32 +01:00
|
|
|
}
|
|
|
|
+
|
2016-03-31 02:50:23 +02:00
|
|
|
+ // Paper start
|
2016-03-21 06:53:32 +01:00
|
|
|
+ /**
|
2016-03-31 02:50:23 +02:00
|
|
|
+ * Adds or removes a player from the game whitelist
|
2016-03-21 06:53:32 +01:00
|
|
|
+ *
|
|
|
|
+ * @param mcserver running instance of MinecraftServer
|
|
|
|
+ * @param playerName the player we're going to be whitelisting
|
|
|
|
+ * @param add whether we're adding or removing from the whitelist
|
|
|
|
+ */
|
|
|
|
+ private void whitelist(MinecraftServer mcserver, String playerName, boolean add) throws CommandException {
|
|
|
|
+ if (mcserver.getOnlineMode()) {
|
|
|
|
+ // The reason we essentially copy/pasta NMS code here is because the NMS online-only version
|
|
|
|
+ // is capable of providing feedback to the person running the command based on whether or
|
|
|
|
+ // not the player is a real online-mode account
|
|
|
|
+ GameProfile gameprofile = mcserver.getUserCache().getProfile(playerName);
|
|
|
|
+ if (gameprofile == null) {
|
|
|
|
+ if (add) {
|
|
|
|
+ throw new CommandException("commands.whitelist.add.failed", new Object[] { playerName});
|
|
|
|
+ } else {
|
|
|
|
+ throw new CommandException("commands.whitelist.remove.failed", new Object[] { playerName});
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (add) {
|
|
|
|
+ mcserver.getPlayerList().addWhitelist(gameprofile);
|
|
|
|
+ } else {
|
|
|
|
+ mcserver.getPlayerList().removeWhitelist(gameprofile);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // versus our offline version, which will always report success all of the time
|
|
|
|
+ org.bukkit.OfflinePlayer offlinePlayer = org.bukkit.Bukkit.getOfflinePlayer(playerName);
|
|
|
|
+ if (add) {
|
|
|
|
+ offlinePlayer.setWhitelisted(true);
|
|
|
|
+ } else {
|
|
|
|
+ offlinePlayer.setWhitelisted(false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2016-03-31 02:50:23 +02:00
|
|
|
+ // Paper end
|
2016-03-21 06:53:32 +01:00
|
|
|
}
|
|
|
|
--
|
2016-06-23 04:18:41 +02:00
|
|
|
2.9.0
|
2016-03-21 06:53:32 +01:00
|
|
|
|