aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0065-Disable-Scoreboards-for-non-players-by-default.patch
blob: c1b5b26b688c13cc253bfafaa898de221a5b437d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
From e974cc2dc77b8e3ca057231ad712724603872f56 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 8 Mar 2016 23:25:45 -0500
Subject: [PATCH] Disable Scoreboards for non players by default

Entities collision is checking for scoreboards setting.
This is very heavy to do map lookups for every collision to check
this setting.

So avoid looking up scoreboards and short circuit to the "not on a team"
logic which is most likely to be true.

diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index b241c0380d..a4c94845b8 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -242,4 +242,9 @@ public class PaperWorldConfig {
     private void disableTeleportationSuffocationCheck() {
         disableTeleportationSuffocationCheck = getBoolean("disable-teleportation-suffocation-check", false);
     }
+
+    public boolean nonPlayerEntitiesOnScoreboards = false;
+    private void nonPlayerEntitiesOnScoreboards() {
+        nonPlayerEntitiesOnScoreboards = getBoolean("allow-non-player-entities-on-scoreboards", false);
+    }
 }
diff --git a/src/main/java/net/minecraft/server/CommandScoreboard.java b/src/main/java/net/minecraft/server/CommandScoreboard.java
index ec9a87239a..b08274d933 100644
--- a/src/main/java/net/minecraft/server/CommandScoreboard.java
+++ b/src/main/java/net/minecraft/server/CommandScoreboard.java
@@ -492,6 +492,7 @@ public class CommandScoreboard extends CommandAbstract {
 
                     while (iterator.hasNext()) {
                         Entity entity = (Entity) iterator.next();
+                        if (!entity.world.paperConfig.nonPlayerEntitiesOnScoreboards && !(entity instanceof EntityHuman)) { continue; } // Paper
                         String s2 = f(minecraftserver, icommandlistener, entity.bn());
 
                         if (scoreboard.addPlayerToTeam(s2, s)) {
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 9d6e684d26..a03a809d61 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -2128,6 +2128,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
 
     @Nullable
     public ScoreboardTeamBase aY() {
+        if (!this.world.paperConfig.nonPlayerEntitiesOnScoreboards && !(this instanceof EntityHuman)) { return null; } // Paper
         return this.world.getScoreboard().getPlayerTeam(this.bn());
     }
 
-- 
2.18.0