mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 14:33:56 +01:00
SPIGOT-3491: Add option to bypass permissions in advancements
This commit is contained in:
parent
571760182f
commit
b5878783ad
@ -1,15 +1,47 @@
|
|||||||
--- a/net/minecraft/server/AdvancementRewards.java
|
--- a/net/minecraft/server/AdvancementRewards.java
|
||||||
+++ b/net/minecraft/server/AdvancementRewards.java
|
+++ b/net/minecraft/server/AdvancementRewards.java
|
||||||
@@ -98,7 +98,7 @@
|
@@ -66,7 +66,24 @@
|
||||||
}
|
CustomFunction customfunction = this.e.a(minecraftserver.aL());
|
||||||
|
|
||||||
public boolean getSendCommandFeedback() {
|
if (customfunction != null) {
|
||||||
- return minecraftserver.worldServer[0].getGameRules().getBoolean("commandBlockOutput");
|
- ICommandListener icommandlistener = new ICommandListener() {
|
||||||
+ return minecraftserver.worlds.get(0).getGameRules().getBoolean("commandBlockOutput"); // CraftBukkit
|
+ // CraftBukkit start
|
||||||
|
+ ICommandListener icommandlistener = new AdvancementCommandListener(entityplayer, minecraftserver);
|
||||||
|
+
|
||||||
|
+ minecraftserver.aL().a(customfunction, icommandlistener);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static class AdvancementCommandListener implements ICommandListener {
|
||||||
|
+
|
||||||
|
+ private final EntityPlayer entityplayer;
|
||||||
|
+ private final MinecraftServer minecraftserver;
|
||||||
|
+
|
||||||
|
+ public AdvancementCommandListener(EntityPlayer entityplayer, MinecraftServer minecraftserver) {
|
||||||
|
+ this.entityplayer = entityplayer;
|
||||||
|
+ this.minecraftserver = minecraftserver;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
public String getName() {
|
||||||
|
return entityplayer.getName();
|
||||||
}
|
}
|
||||||
|
@@ -108,12 +125,8 @@
|
||||||
|
public MinecraftServer C_() {
|
||||||
|
return entityplayer.C_();
|
||||||
|
}
|
||||||
|
- };
|
||||||
|
-
|
||||||
|
- minecraftserver.aL().a(customfunction, icommandlistener);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- }
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
|
||||||
public void a(CommandObjectiveExecutor.EnumCommandResult commandobjectiveexecutor_enumcommandresult, int i) {
|
public String toString() {
|
||||||
@@ -156,7 +156,7 @@
|
return "AdvancementRewards{experience=" + this.b + ", loot=" + Arrays.toString(this.c) + ", recipes=" + Arrays.toString(this.d) + ", function=" + this.e + '}';
|
||||||
|
@@ -156,7 +169,7 @@
|
||||||
return new AdvancementRewards(i, aminecraftkey, aminecraftkey1, customfunction_a);
|
return new AdvancementRewards(i, aminecraftkey, aminecraftkey1, customfunction_a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@
|
|||||||
+ }
|
+ }
|
||||||
+ String as[] = command.split(" ");
|
+ String as[] = command.split(" ");
|
||||||
+ as = VanillaCommandWrapper.dropFirstArgument(as);
|
+ as = VanillaCommandWrapper.dropFirstArgument(as);
|
||||||
+ if (!((VanillaCommandWrapper) commandBlockCommand).testPermission(bSender)) {
|
+ if (!sender.getWorld().getServer().getPermissionOverride(sender) && !((VanillaCommandWrapper) commandBlockCommand).testPermission(bSender)) {
|
||||||
+ return 0;
|
+ return 0;
|
||||||
+ }
|
+ }
|
||||||
+ return ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommand(bSender, sender, as);
|
+ return ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommand(bSender, sender, as);
|
||||||
|
@ -169,6 +169,7 @@ public final class CraftServer implements Server {
|
|||||||
private boolean printSaveWarning;
|
private boolean printSaveWarning;
|
||||||
private CraftIconCache icon;
|
private CraftIconCache icon;
|
||||||
private boolean overrideAllCommandBlockCommands = false;
|
private boolean overrideAllCommandBlockCommands = false;
|
||||||
|
private boolean unrestrictedAdvancements;
|
||||||
private final Pattern validUserPattern = Pattern.compile("^[a-zA-Z0-9_]{2,16}$");
|
private final Pattern validUserPattern = Pattern.compile("^[a-zA-Z0-9_]{2,16}$");
|
||||||
private final UUID invalidUserUUID = UUID.nameUUIDFromBytes("InvalidUsername".getBytes(Charsets.UTF_8));
|
private final UUID invalidUserUUID = UUID.nameUUIDFromBytes("InvalidUsername".getBytes(Charsets.UTF_8));
|
||||||
private final List<CraftPlayer> playerView;
|
private final List<CraftPlayer> playerView;
|
||||||
@ -247,6 +248,7 @@ public final class CraftServer implements Server {
|
|||||||
|
|
||||||
saveCommandsConfig();
|
saveCommandsConfig();
|
||||||
overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||||
|
unrestrictedAdvancements = commandsConfiguration.getBoolean("unrestricted-advancements");
|
||||||
pluginManager.useTimings(configuration.getBoolean("settings.plugin-profiling"));
|
pluginManager.useTimings(configuration.getBoolean("settings.plugin-profiling"));
|
||||||
monsterSpawn = configuration.getInt("spawn-limits.monsters");
|
monsterSpawn = configuration.getInt("spawn-limits.monsters");
|
||||||
animalSpawn = configuration.getInt("spawn-limits.animals");
|
animalSpawn = configuration.getInt("spawn-limits.animals");
|
||||||
@ -259,6 +261,10 @@ public final class CraftServer implements Server {
|
|||||||
loadIcon();
|
loadIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getPermissionOverride(ICommandListener listener) {
|
||||||
|
return unrestrictedAdvancements && listener instanceof AdvancementRewards.AdvancementCommandListener;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getCommandBlockOverride(String command) {
|
public boolean getCommandBlockOverride(String command) {
|
||||||
return overrideAllCommandBlockCommands || commandsConfiguration.getStringList("command-block-overrides").contains(command);
|
return overrideAllCommandBlockCommands || commandsConfiguration.getStringList("command-block-overrides").contains(command);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
# Bug tracker: http://www.spigotmc.org/go/bugs
|
# Bug tracker: http://www.spigotmc.org/go/bugs
|
||||||
|
|
||||||
command-block-overrides: []
|
command-block-overrides: []
|
||||||
|
unrestricted-advancements: false
|
||||||
aliases:
|
aliases:
|
||||||
icanhasbukkit:
|
icanhasbukkit:
|
||||||
- "version $1-"
|
- "version $1-"
|
||||||
|
Loading…
Reference in New Issue
Block a user