Support offline mode from the whitelist command
Closes GH-79
Dieser Commit ist enthalten in:
Ursprung
ef3a9f1286
Commit
e2bbf2228d
@ -1,4 +1,4 @@
|
|||||||
From 5007d500210a0bf7fb1ec142b25e624acf4f7240 Mon Sep 17 00:00:00 2001
|
From c247bf9b0fb7799531e500d1ba852b887aa3e613 Mon Sep 17 00:00:00 2001
|
||||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||||
Date: Mon, 29 Feb 2016 21:09:10 -0600
|
Date: Mon, 29 Feb 2016 21:09:10 -0600
|
||||||
Subject: [PATCH] mc-dev imports
|
Subject: [PATCH] mc-dev imports
|
||||||
@ -4461,6 +4461,103 @@ index 0000000..871535c
|
|||||||
+ return !astring[0].equalsIgnoreCase("players") ? (astring[0].equalsIgnoreCase("teams") ? i == 2 : false) : (astring.length > 1 && astring[1].equalsIgnoreCase("operation") ? i == 2 || i == 5 : i == 2);
|
+ return !astring[0].equalsIgnoreCase("players") ? (astring[0].equalsIgnoreCase("teams") ? i == 2 : false) : (astring.length > 1 && astring[1].equalsIgnoreCase("operation") ? i == 2 || i == 5 : i == 2);
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/CommandWhitelist.java b/src/main/java/net/minecraft/server/CommandWhitelist.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..b52bf74
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/net/minecraft/server/CommandWhitelist.java
|
||||||
|
@@ -0,0 +1,91 @@
|
||||||
|
+package net.minecraft.server;
|
||||||
|
+
|
||||||
|
+import com.mojang.authlib.GameProfile;
|
||||||
|
+import java.util.Collections;
|
||||||
|
+import java.util.List;
|
||||||
|
+
|
||||||
|
+public class CommandWhitelist extends CommandAbstract {
|
||||||
|
+
|
||||||
|
+ public CommandWhitelist() {}
|
||||||
|
+
|
||||||
|
+ public String getCommand() {
|
||||||
|
+ return "whitelist";
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int a() {
|
||||||
|
+ return 3;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public String getUsage(ICommandListener icommandlistener) {
|
||||||
|
+ return "commands.whitelist.usage";
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void execute(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring) throws CommandException {
|
||||||
|
+ if (astring.length < 1) {
|
||||||
|
+ throw new ExceptionUsage("commands.whitelist.usage", new Object[0]);
|
||||||
|
+ } else {
|
||||||
|
+ if (astring[0].equals("on")) {
|
||||||
|
+ minecraftserver.getPlayerList().setHasWhitelist(true);
|
||||||
|
+ a(icommandlistener, (ICommand) this, "commands.whitelist.enabled", new Object[0]);
|
||||||
|
+ } else if (astring[0].equals("off")) {
|
||||||
|
+ minecraftserver.getPlayerList().setHasWhitelist(false);
|
||||||
|
+ a(icommandlistener, (ICommand) this, "commands.whitelist.disabled", new Object[0]);
|
||||||
|
+ } else if (astring[0].equals("list")) {
|
||||||
|
+ icommandlistener.sendMessage(new ChatMessage("commands.whitelist.list", new Object[] { Integer.valueOf(minecraftserver.getPlayerList().getWhitelisted().length), Integer.valueOf(minecraftserver.getPlayerList().getSeenPlayers().length)}));
|
||||||
|
+ String[] astring1 = minecraftserver.getPlayerList().getWhitelisted();
|
||||||
|
+
|
||||||
|
+ icommandlistener.sendMessage(new ChatComponentText(a((Object[]) astring1)));
|
||||||
|
+ } else {
|
||||||
|
+ GameProfile gameprofile;
|
||||||
|
+
|
||||||
|
+ if (astring[0].equals("add")) {
|
||||||
|
+ if (astring.length < 2) {
|
||||||
|
+ throw new ExceptionUsage("commands.whitelist.add.usage", new Object[0]);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ gameprofile = minecraftserver.getUserCache().getProfile(astring[1]);
|
||||||
|
+ if (gameprofile == null) {
|
||||||
|
+ throw new CommandException("commands.whitelist.add.failed", new Object[] { astring[1]});
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ minecraftserver.getPlayerList().addWhitelist(gameprofile);
|
||||||
|
+ a(icommandlistener, (ICommand) this, "commands.whitelist.add.success", new Object[] { astring[1]});
|
||||||
|
+ } else if (astring[0].equals("remove")) {
|
||||||
|
+ if (astring.length < 2) {
|
||||||
|
+ throw new ExceptionUsage("commands.whitelist.remove.usage", new Object[0]);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ 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);
|
||||||
|
+ a(icommandlistener, (ICommand) this, "commands.whitelist.remove.success", new Object[] { astring[1]});
|
||||||
|
+ } else if (astring[0].equals("reload")) {
|
||||||
|
+ minecraftserver.getPlayerList().reloadWhitelist();
|
||||||
|
+ a(icommandlistener, (ICommand) this, "commands.whitelist.reloaded", new Object[0]);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, BlockPosition blockposition) {
|
||||||
|
+ if (astring.length == 1) {
|
||||||
|
+ return a(astring, new String[] { "on", "off", "list", "add", "remove", "reload"});
|
||||||
|
+ } else {
|
||||||
|
+ if (astring.length == 2) {
|
||||||
|
+ if (astring[0].equals("remove")) {
|
||||||
|
+ return a(astring, minecraftserver.getPlayerList().getWhitelisted());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (astring[0].equals("add")) {
|
||||||
|
+ return a(astring, minecraftserver.getUserCache().a());
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return Collections.emptyList();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/server/EULA.java b/src/main/java/net/minecraft/server/EULA.java
|
diff --git a/src/main/java/net/minecraft/server/EULA.java b/src/main/java/net/minecraft/server/EULA.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..c872029
|
index 0000000..c872029
|
||||||
@ -5480,5 +5577,5 @@ index 0000000..2286c9e
|
|||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
--
|
--
|
||||||
2.7.3
|
2.7.4.windows.1
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
From 07c63522e8752c57ee46c2a7dfbde6d75c0dc12c Mon Sep 17 00:00:00 2001
|
From 47e641803ce55b26359768995f0790e66d013109 Mon Sep 17 00:00:00 2001
|
||||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||||
Date: Sun, 20 Mar 2016 19:40:51 -0500
|
Date: Sun, 20 Mar 2016 19:40:51 -0500
|
||||||
Subject: [PATCH] Only mark player as invulnerable if they're changing worlds
|
Subject: [PATCH] Only mark player as invulnerable if they're changing worlds
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||||
index 3902d4f..6ff0061 100644
|
index 3902d4f..efb88ef 100644
|
||||||
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||||
@@ -48,7 +48,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
@@ -48,7 +48,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||||
@ -13,7 +13,7 @@ index 3902d4f..6ff0061 100644
|
|||||||
private long ch = System.currentTimeMillis();
|
private long ch = System.currentTimeMillis();
|
||||||
private Entity ci = null;
|
private Entity ci = null;
|
||||||
- private boolean cj;
|
- private boolean cj;
|
||||||
+ protected boolean cj; // Paper - public -> protected
|
+ protected boolean cj; // Paper - private -> protected
|
||||||
private int containerCounter;
|
private int containerCounter;
|
||||||
public boolean f;
|
public boolean f;
|
||||||
public int ping;
|
public int ping;
|
||||||
|
@ -0,0 +1,98 @@
|
|||||||
|
From 49f713b4c216db30a4122429beb6143aa93547e2 Mon Sep 17 00:00:00 2001
|
||||||
|
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
|
||||||
|
index b52bf74..65a93ef 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/CommandWhitelist.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/CommandWhitelist.java
|
||||||
|
@@ -43,24 +45,35 @@ public class CommandWhitelist extends CommandAbstract {
|
||||||
|
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]});
|
||||||
|
} else if (astring[0].equals("remove")) {
|
||||||
|
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]});
|
||||||
|
} else if (astring[0].equals("reload")) {
|
||||||
|
minecraftserver.getPlayerList().reloadWhitelist();
|
||||||
|
@@ -88,4 +101,48 @@ public class CommandWhitelist extends CommandAbstract {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Paper - Adds or removes a player from the game whitelist
|
||||||
|
+ *
|
||||||
|
+ * @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);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Paper start - Fix decompiler error
|
||||||
|
+ @Override
|
||||||
|
+ public int compareTo(ICommand o) {
|
||||||
|
+ return a((ICommand) o);
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.7.4.windows.1
|
||||||
|
|
In neuem Issue referenzieren
Einen Benutzer sperren