Set nophysics flag on setGameMode

This commit is contained in:
fullwall 2022-12-28 23:14:41 +08:00
parent cdb75dbc96
commit c11da48fc2
12 changed files with 77 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
@ -507,6 +508,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noclip = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
@ -514,6 +515,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noclip = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
@ -540,6 +541,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noclip = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
@ -541,6 +542,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noclip = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
@ -536,6 +537,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noclip = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
@ -546,6 +547,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noclip = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -8,6 +8,7 @@ import java.util.Map;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
@ -578,6 +579,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noclip = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -8,6 +8,7 @@ import java.util.Map;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
@ -585,6 +586,12 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noPhysics = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -8,6 +8,7 @@ import java.util.Map;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
@ -591,6 +592,12 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noPhysics = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -8,6 +8,7 @@ import java.util.Map;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
@ -616,6 +617,12 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
((CraftServer) Bukkit.getServer()).getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noPhysics = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
((CraftServer) Bukkit.getServer()).getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -353,7 +353,6 @@ public class NMSImpl implements NMSBridge {
@Override
public boolean addEntityToWorld(org.bukkit.entity.Entity entity, SpawnReason custom) {
int viewDistance = -1;
ChunkMap chunkMap = null;
try {
if (entity instanceof Player) {

View File

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
@ -497,6 +498,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public void setGameMode(GameMode mode) {
super.setGameMode(mode);
getHandle().noclip = mode == GameMode.SPECTATOR;
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);