Merged master into spigot-1.20.2

This commit is contained in:
furplag 2023-10-30 01:44:45 +00:00
commit 37d53da83c
6 changed files with 53 additions and 92 deletions

View File

@ -1,13 +1,17 @@
package net.theprogrammersworld.herobrine.AI.cores;
import java.util.Objects;
import java.util.stream.Stream;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.block.sign.Side;
import org.bukkit.entity.Player;
import net.theprogrammersworld.herobrine.Herobrine;
import net.theprogrammersworld.herobrine.Support;
import net.theprogrammersworld.herobrine.AI.Core;
import net.theprogrammersworld.herobrine.AI.CoreResult;
@ -23,89 +27,53 @@ public class BuryPlayer extends Core {
public CoreResult CallCore(Object[] data) {
return FindPlace((Player) data[0]);
}
public CoreResult FindPlace(final Player player) {
if (Herobrine.getPluginCore().getSupport().checkBuild(player.getLocation())) {
final Location loc = player.getLocation();
if (isSolidBlock(
loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()).getType())
&& isSolidBlock(
loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY() - 2, loc.getBlockZ()).getType())
&& isSolidBlock(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ() - 1).getType())
&& isSolidBlock(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 2, loc.getBlockZ() - 1).getType())
&& isSolidBlock(
loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY() - 3, loc.getBlockZ()).getType())
&& isSolidBlock(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 3, loc.getBlockZ() - 1).getType())
&& isSolidBlock(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ() - 1).getType())
&& isSolidBlock(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 2, loc.getBlockZ() - 1).getType())
&& isSolidBlock(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ() - 2).getType())) {
if (Herobrine.getPluginCore().getSupport().checkBuild(
loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()).getLocation())
&& Herobrine.getPluginCore().getSupport().checkBuild(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 2, loc.getBlockZ()).getLocation())
&& Herobrine.getPluginCore().getSupport().checkBuild(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ() - 1).getLocation())
&& Herobrine.getPluginCore().getSupport().checkBuild(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 2, loc.getBlockZ() - 1).getLocation())
&& Herobrine.getPluginCore().getSupport().checkBuild(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 3, loc.getBlockZ()).getLocation())
&& Herobrine.getPluginCore().getSupport().checkBuild(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 3, loc.getBlockZ() - 1).getLocation())
&& Herobrine.getPluginCore().getSupport().checkBuild(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ() - 1).getLocation())
&& Herobrine.getPluginCore().getSupport().checkBuild(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 2, loc.getBlockZ() - 1).getLocation())
&& Herobrine.getPluginCore().getSupport().checkBuild(loc.getWorld()
.getBlockAt(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ() - 2).getLocation())) {
Bury(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), player);
return new CoreResult(true, player.getDisplayName() + " was buried by Herobrine.");
} else {
return new CoreResult(false, player.getDisplayName() + " is in a protected area and cannot be buried.");
}
String resultMessage = null;
if (!hasNoProtection(player.getLocation())) {
resultMessage = player.getDisplayName() + " is in a protected area and cannot be buried.";
} else if (!isEnableBuildTomb(player.getLocation())) {
resultMessage = player.getDisplayName() + " could not be buried because a good burial location could not be found.";
} else {
Bury(player);
}
} else {
return new CoreResult(false, player.getDisplayName()
+ " could not be buried because a good burial location could not be found.");
}
return new CoreResult(false,
player.getDisplayName() + " could not be buried because a good burial location could not be found.");
return new CoreResult(resultMessage == null, Objects.toString(resultMessage, player.getDisplayName() + " could not be buried because a good burial location could not be found."));
}
public void Bury(World world, int X, int Y, int Z, Player player) {
Location loc = new Location(world, X, Y, Z);
loc.getWorld().getBlockAt(X, Y - 1, Z).breakNaturally();
loc.getWorld().getBlockAt(X, Y - 2, Z).breakNaturally();
loc.getWorld().getBlockAt(X, Y - 3, Z).breakNaturally();
loc.getWorld().getBlockAt(X, Y - 1, Z - 1).breakNaturally();
loc.getWorld().getBlockAt(X, Y - 2, Z - 1).breakNaturally();
loc.getWorld().getBlockAt(X, Y - 3, Z - 1).breakNaturally();
player.teleport(new Location(world, X, Y - 3, Z));
RegenBlocks(world, X, Y, Z, player.getName());
public void Bury(Player player) {
Stream.of(
player.getLocation().clone().add(0, -1, 0),
player.getLocation().clone().add(0, -2, 0),
player.getLocation().clone().add(0, -3, 0),
player.getLocation().clone().add(0, -1, -1),
player.getLocation().clone().add(0, -2, -1),
player.getLocation().clone().add(0, -3, -1)
).map(Location::getBlock).forEach(Block::breakNaturally);
player.teleport(player.getLocation().clone().add(0, -3, 0));
Block signBlock = player.getLocation().clone().add(0, 3, -2).getBlock();
signBlock.setType(Material.OAK_SIGN);
((Sign) signBlock.getState()).getSide(Side.FRONT).setLine(1, player.getDisplayName());
((Sign) signBlock.getState()).update();
player.getLocation().clone().add(0, 2, 0).getBlock().setType(Material.STONE_BRICKS, false);
player.getLocation().clone().add(0, 2, -1).getBlock().setType(Material.STONE_BRICKS, false);
}
public void RegenBlocks(World world, int X, int Y, int Z, String playername) {
Location loc = new Location(world, X, Y, Z);
Location signloc = new Location(world, X, Y, Z - 2);
Block signblock = signloc.add(0, 0D, 0).getBlock();
signblock.setType(Material.OAK_SIGN);
Sign sign = (Sign) signblock.getState();
sign.setLine(1, playername);
sign.update();
loc.getWorld().getBlockAt(X, Y - 1, Z).setType(Material.STONE_BRICKS, false);
loc.getWorld().getBlockAt(X, Y - 1, Z - 1).setType(Material.STONE_BRICKS, false);
}
private boolean isSolidBlock(Material m) {
return m.isSolid();
}
private boolean hasNoProtection(final Location location) {
final Support support = Herobrine.getPluginCore().getSupport();
return location != null && Stream.of(location).flatMap((loc) -> Stream.of(/* @formatter:off */
loc,
loc.clone().add(0, -1, 0), loc.clone().add(0, -2, 0), loc.clone().add(0, -3, 0),
loc.clone().add(0, -1, -1), loc.clone().add(0, -2, -1), loc.clone().add(0, -3, -1),
loc.clone().add(0, -1, -2)
/* @formatter:on */)).allMatch(support::checkBuild);
}
private boolean isEnableBuildTomb(final Location location) {
return location != null && Stream.of(location).flatMap((loc) -> Stream.of(/* @formatter:off */
loc.clone().add(0, -1, 0), loc.clone().add(0, -2, 0), loc.clone().add(0, -3, 0),
loc.clone().add(0, -1, -1), loc.clone().add(0, -2, -1), loc.clone().add(0, -3, -1),
loc.clone().add(0, -1, -2)
/* @formatter:on */)).map(Location::getBlock).map(Block::getType).allMatch(Material::isSolid);
}
}

View File

@ -8,6 +8,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.block.sign.Side;
import net.theprogrammersworld.herobrine.Herobrine;
import net.theprogrammersworld.herobrine.Utils;
@ -87,8 +88,7 @@ public class Signs extends Core {
BlockData blockData = sign.getBlockData();
((Directional) blockData).setFacing(BlockChanger.getPlayerBlockFace(ploc));
sign.setBlockData(blockData);
sign.setLine(1, Herobrine.getPluginCore().getConfigDB().useSignMessages.get(randmsg));
sign.getSide(Side.FRONT).setLine(1, Herobrine.getPluginCore().getConfigDB().useSignMessages.get(randmsg));
sign.update();
}
}

View File

@ -19,8 +19,8 @@ public class HumanEntity extends ServerPlayer {
private CraftPlayer cplayer = null;
public HumanEntity(final NPCCore npcCore, final NMSWorld world, final GameProfile s) {
super(npcCore.getServer().getMCServer(), world.getWorldServer(), s, ClientInformation.createDefault());
public HumanEntity(final NPCCore npcCore, final NMSWorld world, final GameProfile gameProfile) {
super(npcCore.getServer().getMCServer(), world.getWorldServer(), gameProfile, ClientInformation.createDefault());
this.setGameMode(GameType.SURVIVAL);

View File

@ -42,7 +42,6 @@ public class NPCCore {
Property textures = new Property("textures",
"eyJ0aW1lc3RhbXAiOjE0MjE0ODczMzk3MTMsInByb2ZpbGVJZCI6ImY4NGM2YTc5MGE0ZTQ1ZTA4NzliY2Q0OWViZDRjNGUyIiwicHJvZmlsZU5hbWUiOiJIZXJvYnJpbmUiLCJpc1B1YmxpYyI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzk4YjdjYTNjN2QzMTRhNjFhYmVkOGZjMThkNzk3ZmMzMGI2ZWZjODQ0NTQyNWM0ZTI1MDk5N2U1MmU2Y2IifX19",
"Edb1R3vm2NHUGyTPaOdXNQY9p5/Ez4xButUGY3tNKIJAzjJM5nQNrq54qyFhSZFVwIP6aM4Ivqmdb2AamXNeN0KgaaU/C514N+cUZNWdW5iiycPytfh7a6EsWXV4hCC9B2FoLkbXuxs/KAbKORtwNfFhQupAsmn9yP00e2c3ZQmS18LWwFg0vzFqvp4HvzJHqY/cTqUxdlSFDrQe/4rATe6Yx6v4zbZN2sHbSL+8AwlDDuP2Xr4SS6f8nABOxjSTlWMn6bToAYiymD+KUPoO0kQJ0Uw/pVXgWHYjQeM4BYf/FAxe8Bf1cP8S7VKueULkOxqIjXAp85uqKkU7dR/s4M4yHm6fhCOCLSMv6hi5ewTaFNYyhK+NXPftFqHcOxA1LbrjOe6NyphF/2FI79n90hagxJpWwNPz3/8I5rnGbYwBZPTsTnD8PszgQTNuWSuvZwGIXPIp9zb90xuU7g7VNWjzPVoOHfRNExEs7Dn9pG8CIA/m/a8koWW3pkbP/AMMWnwgHCr/peGdvF5fN+hJwVdpbfC9sJfzGwA7AgXG/6yqhl1U7YAp/aCVM9bZ94sav+kQghvN41jqOwy4F4i/swc7R4Fx2w5HFxVY3j7FChG7iuhqjUclm79YNhTG0lBQLiZbN5FmC9QgrNHRKlzgSZrXHWoG3YXFSqfn4J+Om9w=");
profile.getProperties().put(textures.name(), textures);
return profile;

View File

@ -11,12 +11,6 @@ public class NetworkCore extends Connection {
super(PacketFlow.SERVERBOUND);
channel = new EmbeddedChannel();
}
@Override public void setListener(PacketListener packetListener) {}
@Override
public void tick() {
}
@Override public void tick() {}
}

View File

@ -1,6 +1,6 @@
name: Herobrine
main: net.theprogrammersworld.herobrine.Herobrine
version: 2.4.4-SNAPSHOT
version: 2.5.1-SNAPSHOT
description: "Bring Herobrine to your Spigot-based Minecraft server!"
website: https://www.theprogrammersworld.net
api-version: '1.20'