Update for Spigot 1.19.3
This commit is contained in:
parent
508f32d57a
commit
29bf773fb6
@ -1,4 +1,4 @@
|
||||
val mc_version="1.19"
|
||||
val mc_version="1.19.3"
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
|
@ -2,20 +2,22 @@ package net.theprogrammersworld.herobrine.AI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.Action;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.Action;
|
||||
import net.theprogrammersworld.herobrine.Herobrine;
|
||||
import net.theprogrammersworld.herobrine.Utils;
|
||||
import net.theprogrammersworld.herobrine.AI.Core.CoreType;
|
||||
@ -213,10 +215,10 @@ public class AICore {
|
||||
Stop_RS();
|
||||
Stop_CG();
|
||||
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0), 0, -100.f, 0);
|
||||
|
||||
|
||||
nowloc.setYaw(1.f);
|
||||
nowloc.setPitch(1.f);
|
||||
|
||||
|
||||
Herobrine.getPluginCore().HerobrineNPC.moveTo(nowloc);
|
||||
CoreNow = CoreType.ANY;
|
||||
Herobrine.getPluginCore().getPathManager().setPath(null);
|
||||
@ -233,13 +235,13 @@ public class AICore {
|
||||
_ticks = 0;
|
||||
isTarget = false;
|
||||
Herobrine.HerobrineHP = Herobrine.HerobrineMaxHP;
|
||||
|
||||
|
||||
log.info("[Herobrine] Cancelled target.");
|
||||
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0), 0, -100.f, 0);
|
||||
|
||||
|
||||
nowloc.setYaw(1.f);
|
||||
nowloc.setPitch(1.f);
|
||||
|
||||
|
||||
Herobrine.getPluginCore().HerobrineNPC.moveTo(nowloc);
|
||||
CoreNow = CoreType.ANY;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() {
|
||||
@ -354,7 +356,7 @@ public class AICore {
|
||||
if (Utils.getRandomGen().nextBoolean()) {
|
||||
if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
|
||||
log.info("[Herobrine] Finding pyramid target...");
|
||||
|
||||
|
||||
Player player = Utils.getRandomPlayer();
|
||||
if (Herobrine.getPluginCore().getConfigDB().useWorlds.contains(player.getLocation().getWorld().getName())) {
|
||||
|
||||
@ -387,9 +389,9 @@ public class AICore {
|
||||
if (Utils.getRandomGen().nextBoolean()) {
|
||||
if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
|
||||
log.info("[Herobrine] Finding temple target...");
|
||||
|
||||
|
||||
Player player = Utils.getRandomPlayer();
|
||||
|
||||
|
||||
if (Herobrine.getPluginCore().getConfigDB().useWorlds.contains(player.getLocation().getWorld().getName())) {
|
||||
if (Utils.getRandomGen().nextBoolean()) {
|
||||
Object[] data = { player };
|
||||
@ -407,9 +409,9 @@ public class AICore {
|
||||
if (Herobrine.getPluginCore().getConfigDB().BuildStuff == true) {
|
||||
if (Utils.getRandomGen().nextBoolean()) {
|
||||
if (Bukkit.getServer().getOnlinePlayers().size() > 0) {
|
||||
|
||||
|
||||
Player player = Utils.getRandomPlayer();
|
||||
|
||||
|
||||
if (Herobrine.getPluginCore().getConfigDB().useWorlds
|
||||
.contains(player.getLocation().getWorld().getName())) {
|
||||
|
||||
@ -477,7 +479,7 @@ public class AICore {
|
||||
hbloc.getWorld().playEffect(hbloc, Effect.SMOKE, 80);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ploc.setY(-100);
|
||||
Herobrine.getPluginCore().HerobrineNPC.moveTo(ploc);
|
||||
|
||||
@ -671,7 +673,7 @@ public class AICore {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean toggleHerobrinePlayerVisibilityNoTeleport(Player p) {
|
||||
// Toggles the visibility of Herobrine for the given player. This function does not perform the "visibility activation teleport".
|
||||
// If an activiation teleport should be performed, returns true, otherwise, false.
|
||||
@ -679,26 +681,26 @@ public class AICore {
|
||||
if(playerCanSeeHerobrine && !visibilityList.contains(p)) {
|
||||
// If player p can see Herobrine but visibilty is not already enabled, then enable it.
|
||||
ServerPlayer pcon = ((CraftPlayer) p).getHandle();
|
||||
pcon.connection.send(new ClientboundPlayerInfoPacket(Action.ADD_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
|
||||
pcon.connection.send(new ClientboundPlayerInfoUpdatePacket(Action.ADD_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
|
||||
visibilityList.add(p);
|
||||
return true;
|
||||
}
|
||||
else if(!playerCanSeeHerobrine && visibilityList.contains(p)) {
|
||||
// If player p cannot see Herobrine but visibility is still enabled, then disable it.
|
||||
ServerPlayer pcon = ((CraftPlayer) p).getHandle();
|
||||
pcon.connection.send(new ClientboundPlayerInfoPacket(Action.REMOVE_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
|
||||
pcon.connection.send(new ClientboundPlayerInfoRemovePacket(List.of(p.getUniqueId())));
|
||||
visibilityList.remove(p);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void visibilityActivationTeleport() {
|
||||
// Makes Herobrine visible to players that should be able to see him by quickly teleporting him out of the map and back to where he previously was.
|
||||
Location original = Herobrine.getPluginCore().HerobrineNPC.getBukkitEntity().getLocation();
|
||||
Herobrine.getPluginCore().HerobrineNPC.getBukkitEntity().teleport(new Location(Bukkit.getServer().getWorlds().get(0), 0, -100, 0));
|
||||
Herobrine.getPluginCore().HerobrineNPC.getBukkitEntity().teleport(original);
|
||||
}
|
||||
|
||||
|
||||
public void toggleHerobrinePlayerVisibility(Player p) {
|
||||
// Toggles the visibility of Herobrine for the given player. Most of the work is passed off to toggleHerobrinePlayerVisibilityNoTeleport().
|
||||
if(toggleHerobrinePlayerVisibilityNoTeleport(p)) {
|
||||
|
@ -24,13 +24,14 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.theprogrammersworld.herobrine.AI.AICore;
|
||||
import net.theprogrammersworld.herobrine.AI.Core.CoreType;
|
||||
import net.theprogrammersworld.herobrine.AI.extensions.GraveyardWorld;
|
||||
@ -61,7 +62,7 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
public long HerobrineEntityID;
|
||||
public boolean isInitDone = false;
|
||||
private int pathUpdateINT = 0;
|
||||
|
||||
|
||||
public static String versionStr = "UNDEFINED";
|
||||
public static boolean isNPCDisabled = false;
|
||||
public static int HerobrineHP = 200;
|
||||
@ -77,12 +78,12 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
boolean continueWithEnable = true;
|
||||
|
||||
|
||||
// Check a server class name to determine if the plugin is compatible with the Spigot server version.
|
||||
// If it is not, print an error message and disable the plugin.
|
||||
if (continueWithEnable) {
|
||||
try {
|
||||
Class.forName("org.bukkit.craftbukkit.v1_19_R1.CraftArt");
|
||||
Class.forName("org.bukkit.craftbukkit.v1_19_R2.CraftArt");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "This version of Herobrine is not "
|
||||
+ "compatible with this server's Spigot version and will be disabled.");
|
||||
@ -90,7 +91,7 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (continueWithEnable) {
|
||||
// Custom Entity Injection
|
||||
if (!isNPCDisabled) {
|
||||
@ -104,20 +105,20 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
} else {
|
||||
log.warning("[Herobrine] Custom NPCs have been disabled due to an incompatibility error.");
|
||||
}
|
||||
|
||||
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onServerLoad(ServerLoadEvent event) {
|
||||
PluginDescriptionFile pdf = this.getDescription();
|
||||
versionStr = pdf.getVersion();
|
||||
|
||||
|
||||
isInitDone = true;
|
||||
|
||||
|
||||
Herobrine.pluginCore = this;
|
||||
|
||||
|
||||
this.configdb = new ConfigDB(log);
|
||||
|
||||
this.NPCman = new NPCCore(this);
|
||||
@ -136,15 +137,15 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
configdb.Reload();
|
||||
|
||||
// Graveyard World
|
||||
if (this.configdb.UseGraveyardWorld == true && Bukkit.getServer().getWorld(configdb.HerobrineWorldName) == null) {
|
||||
if (this.configdb.UseGraveyardWorld == true && Bukkit.getServer().getWorld(configdb.HerobrineWorldName) == null) {
|
||||
WorldCreator wc = new WorldCreator(configdb.HerobrineWorldName);
|
||||
wc.generateStructures(false);
|
||||
org.bukkit.WorldType type = org.bukkit.WorldType.FLAT;
|
||||
wc.type(type);
|
||||
wc.createWorld();
|
||||
|
||||
|
||||
GraveyardWorld.Create();
|
||||
|
||||
|
||||
/* Starting with Minecraft 1.18, the Y coordinate used for the flat world generated for Herobrine's Graveyard is -61 instead of 3.
|
||||
* This elevation change required graveyard generation as well as Herobrine and player location management to be shifted down to
|
||||
* accommodate it. This change is only applied to graveyard worlds generated on 1.18 or newer, however, and would cause graveyards
|
||||
@ -155,7 +156,7 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
configdb.graveyardYCoord = 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Spawn Herobrine
|
||||
Location nowloc = new Location((World) Bukkit.getServer().getWorlds().get(0), (float) 0, (float) -100,
|
||||
(float) 0);
|
||||
@ -164,7 +165,7 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
HerobrineSpawn(nowloc);
|
||||
|
||||
HerobrineNPC.setItemInHand(configdb.ItemInHand.getItemStack());
|
||||
|
||||
|
||||
getServer().getPluginManager().registerEvents(new EntityListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new BlockListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
|
||||
@ -219,7 +220,7 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
|
||||
// Support initialize
|
||||
this.support = new Support();
|
||||
|
||||
|
||||
// If the plugin configuration has updated checking turned on, start the thread responsible for performing the check.
|
||||
if(configdb.CheckForUpdates)
|
||||
new Thread(new UpdateScanner()).start();
|
||||
@ -296,11 +297,11 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
opCheck = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!configdb.AttackCreative && player.getGameMode() == GameMode.CREATIVE) {
|
||||
creativeCheck = false;
|
||||
}
|
||||
|
||||
|
||||
if (configdb.UseIgnorePermission && player.hasPermission("herobrine.ignore")) {
|
||||
ignoreCheck = false;
|
||||
}
|
||||
@ -308,14 +309,14 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
if (opCheck && creativeCheck && ignoreCheck) {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
if(sender == null){
|
||||
|
||||
if(sender == null){
|
||||
if (!opCheck)
|
||||
log.info("[Herobrine] " + player.getDisplayName() + " is an OP.");
|
||||
else if (!creativeCheck)
|
||||
log.info("[Herobrine] " + player.getDisplayName() + " is in creative mode.");
|
||||
else if (!ignoreCheck)
|
||||
log.info("[Herobrine] " + player.getDisplayName() + " has ignore permission.");
|
||||
log.info("[Herobrine] " + player.getDisplayName() + " has ignore permission.");
|
||||
}else{
|
||||
if (!opCheck)
|
||||
sender.sendMessage(ChatColor.RED + "[Herobrine] " + player.getDisplayName() + " is an OP.");
|
||||
@ -324,26 +325,26 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
else if (!ignoreCheck)
|
||||
sender.sendMessage(ChatColor.RED + "[Herobrine] " + player.getDisplayName() + " has ignore permission.");
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean canAttackPlayerNoMSG(Player player) {
|
||||
|
||||
|
||||
boolean opCheck = true;
|
||||
boolean creativeCheck = true;
|
||||
boolean ignoreCheck = true;
|
||||
|
||||
if (!configdb.AttackOP && player.isOp()) {
|
||||
opCheck = false;
|
||||
opCheck = false;
|
||||
}
|
||||
|
||||
|
||||
if (!configdb.AttackCreative && player.getGameMode() == GameMode.CREATIVE) {
|
||||
creativeCheck = false;
|
||||
}
|
||||
|
||||
|
||||
if (configdb.UseIgnorePermission && player.hasPermission("herobrine.ignore")) {
|
||||
ignoreCheck = false;
|
||||
}
|
||||
@ -363,35 +364,35 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
return "No";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static <T extends Entity> void addCustomEntity(String customName, EntityType.EntityFactory<T> _func, MobCategory enumCreatureType) {
|
||||
// Registers a custom entity. Adapted from https://www.spigotmc.org/threads/handling-custom-entity-registry-on-spigot-1-13.353426/#post-3447111
|
||||
// As of 1.18.2, this function was updated to unfreeze and freeze the entity registry when adding a new custom entity. Additionally, a conditional
|
||||
// check was added to prevent the plugin from crashing due to an attempt to add the same custom entity twice.
|
||||
if (!Registry.ENTITY_TYPE.getOptional(new ResourceLocation(customName)).isPresent()) {
|
||||
if (!BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(customName)).isPresent()) {
|
||||
unfreezeRegistry();
|
||||
EntityType.Builder<?> entity = EntityType.Builder.of(_func, enumCreatureType);
|
||||
entity.noSummon();
|
||||
Registry.register(Registry.ENTITY_TYPE, customName, entity.build(customName));
|
||||
Registry.ENTITY_TYPE.freeze();
|
||||
Registry.register(BuiltInRegistries.ENTITY_TYPE, customName, entity.build(customName));
|
||||
BuiltInRegistries.ENTITY_TYPE.freeze();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void unfreezeRegistry() {
|
||||
// As of 1.18.2, registries are frozen once NMS is done adding to them, so we have to do some super hacky things to add custom entities now.
|
||||
// Adapted from https://github.com/iSach/UltraCosmetics/blob/7f8bbfd2a540559888b89dae7eee4dec482ab7c9/v1_18_R2/src/main/java/be/isach/ultracosmetics/
|
||||
// v1_18_R2/customentities/CustomEntities.java#L75-L104
|
||||
// Obfuscated fields are from https://github.com/iSach/UltraCosmetics/blob/master/v1_19_R1/src/main/java/be/isach/ultracosmetics/v1_19_R1/ObfuscatedFields.java
|
||||
final String INTRUSIVE_HOLDER_CACHE = "cc";
|
||||
final String FROZEN = "ca";
|
||||
final String INTRUSIVE_HOLDER_CACHE = "m";
|
||||
final String FROZEN = "l";
|
||||
Class<?> registryClass = MappedRegistry.class;
|
||||
try {
|
||||
Field intrusiveHolderCache = registryClass.getDeclaredField(INTRUSIVE_HOLDER_CACHE);
|
||||
intrusiveHolderCache.setAccessible(true);
|
||||
intrusiveHolderCache.set(Registry.ENTITY_TYPE, new IdentityHashMap<EntityType<?>, Holder.Reference<EntityType<?>>>());
|
||||
intrusiveHolderCache.set(BuiltInRegistries.ENTITY_TYPE, new IdentityHashMap<EntityType<?>, Holder.Reference<EntityType<?>>>());
|
||||
Field frozen = registryClass.getDeclaredField(FROZEN);
|
||||
frozen.setAccessible(true);
|
||||
frozen.set(Registry.ENTITY_TYPE, false);
|
||||
frozen.set(BuiltInRegistries.ENTITY_TYPE, false);
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
|
@ -9,8 +9,8 @@ import net.theprogrammersworld.herobrine.NPC.NMS.NMSWorld;
|
||||
import net.theprogrammersworld.herobrine.NPC.Network.NetworkHandler;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
@ -19,7 +19,7 @@ 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, null);
|
||||
super(npcCore.getServer().getMCServer(), world.getWorldServer(), s);
|
||||
|
||||
this.setGameMode(GameType.SURVIVAL);
|
||||
|
||||
|
@ -12,10 +12,10 @@ import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
||||
|
||||
public class NMSServer {
|
||||
|
||||
public class NMSServer {
|
||||
|
||||
private static NMSServer ins;
|
||||
private MinecraftServer mcServer;
|
||||
private CraftServer cServer;
|
||||
|
@ -8,10 +8,10 @@ import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
||||
|
||||
public class NMSWorld {
|
||||
|
||||
|
||||
private CraftWorld cWorld;
|
||||
private ServerLevel wServer;
|
||||
|
||||
|
@ -5,7 +5,7 @@ import net.minecraft.network.protocol.Packet;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
@ -8,45 +8,45 @@ import org.bukkit.World;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
|
||||
public class EntityManager {
|
||||
|
||||
|
||||
private HashMap<Integer,CustomEntity> mobList = new HashMap<Integer,CustomEntity>();
|
||||
|
||||
|
||||
public void spawnCustomZombie(Location loc,MobType mbt){
|
||||
|
||||
|
||||
World world = loc.getWorld();
|
||||
net.minecraft.world.level.Level mcWorld = ((org.bukkit.craftbukkit.v1_19_R1.CraftWorld) world).getHandle();
|
||||
net.minecraft.world.level.Level mcWorld = ((org.bukkit.craftbukkit.v1_19_R2.CraftWorld) world).getHandle();
|
||||
CustomZombie zmb = new CustomZombie(mcWorld,loc,mbt);
|
||||
mcWorld.addFreshEntity(zmb, SpawnReason.CUSTOM);
|
||||
mobList.put(Integer.valueOf(zmb.getBukkitEntity().getEntityId()),zmb);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void spawnCustomSkeleton(Location loc,MobType mbt){
|
||||
|
||||
|
||||
World world = loc.getWorld();
|
||||
net.minecraft.world.level.Level mcWorld = ((org.bukkit.craftbukkit.v1_19_R1.CraftWorld) world).getHandle();
|
||||
net.minecraft.world.level.Level mcWorld = ((org.bukkit.craftbukkit.v1_19_R2.CraftWorld) world).getHandle();
|
||||
CustomSkeleton zmb = new CustomSkeleton(mcWorld,loc,mbt);
|
||||
mcWorld.addFreshEntity(zmb, SpawnReason.CUSTOM);
|
||||
mobList.put(Integer.valueOf(zmb.getBukkitEntity().getEntityId()), zmb);
|
||||
}
|
||||
|
||||
|
||||
public boolean isCustomMob(int id){
|
||||
return mobList.containsKey(Integer.valueOf(id));
|
||||
}
|
||||
|
||||
|
||||
public CustomEntity getHerobrineMobType(int id){
|
||||
return mobList.get(Integer.valueOf(id));
|
||||
}
|
||||
|
||||
|
||||
public void removeMob(int id){
|
||||
mobList.get(Integer.valueOf(id)).Kill();
|
||||
mobList.remove(Integer.valueOf(id));
|
||||
}
|
||||
|
||||
|
||||
public void removeAllMobs(){
|
||||
mobList.clear();
|
||||
}
|
||||
|
||||
|
||||
public void killAllMobs(){
|
||||
for(Map.Entry<Integer, CustomEntity> s : mobList.entrySet()){
|
||||
s.getValue().Kill();
|
||||
|
@ -1,30 +1,41 @@
|
||||
package net.theprogrammersworld.herobrine.listeners;
|
||||
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.Action;
|
||||
import net.theprogrammersworld.herobrine.AI.AICore;
|
||||
import net.theprogrammersworld.herobrine.AI.Core.CoreType;
|
||||
import net.theprogrammersworld.herobrine.Herobrine;
|
||||
import net.theprogrammersworld.herobrine.Utils;
|
||||
import net.theprogrammersworld.herobrine.misc.ItemName;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.Action;
|
||||
import net.theprogrammersworld.herobrine.Herobrine;
|
||||
import net.theprogrammersworld.herobrine.Utils;
|
||||
import net.theprogrammersworld.herobrine.AI.AICore;
|
||||
import net.theprogrammersworld.herobrine.AI.Core.CoreType;
|
||||
import net.theprogrammersworld.herobrine.misc.ItemName;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
private ArrayList<String> equalsLoreS = new ArrayList<String>();
|
||||
@ -43,14 +54,14 @@ public class PlayerListener implements Listener {
|
||||
equalsLoreA.add("Apple of Death");
|
||||
PluginCore = plugin;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
// If the persistent tab list entry for Herobrine is enabled, send an "add player" packet to the user on login.
|
||||
if(Herobrine.getPluginCore().getConfigDB().ShowInTabList)
|
||||
((CraftPlayer) event.getPlayer()).getHandle().connection.send(
|
||||
new ClientboundPlayerInfoPacket(Action.ADD_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
|
||||
|
||||
new ClientboundPlayerInfoUpdatePacket(Action.ADD_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
|
||||
|
||||
// Check if the user has a Graveyard cache. If they do, this means they are stuck in the Graveyard and
|
||||
// need teleported out.
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(PluginCore, new Runnable() {
|
||||
@ -68,7 +79,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
cache.close();
|
||||
String[] cacheData = cacheDataString.split("\n");
|
||||
|
||||
|
||||
// If the cacheData length is 4, then the cache is from a version of the plugin prior to 2.2.0 and only contains the
|
||||
// player's (X, Y, Z) coordinates and the world. Otherwise, the cache also contains the player's pitch and yaw. Parse
|
||||
// the data appropriately and teleport them.
|
||||
@ -89,7 +100,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}, 20L); // 20L = 1 sec
|
||||
|
||||
|
||||
// If a newer version of Herobrine is available and the player is an OP, display a message to the OP stating that a new version is available.
|
||||
if(Herobrine.getPluginCore().getConfigDB().newVersionFound && event.getPlayer().isOp())
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "A new version of Herobrine is available. To "
|
||||
@ -120,10 +131,10 @@ public class PlayerListener implements Listener {
|
||||
|
||||
} else if (ItemName.getLore(itemInHand).containsAll(equalsLoreA)
|
||||
&& PluginCore.getConfigDB().UseArtifactApple) {
|
||||
|
||||
|
||||
timestamp = System.currentTimeMillis() / 1000;
|
||||
canUse = false;
|
||||
|
||||
|
||||
if (PluginCore.PlayerApple.containsKey(event.getPlayer())) {
|
||||
if (PluginCore.PlayerApple.get(event.getPlayer()) < timestamp) {
|
||||
PluginCore.PlayerApple.remove(event.getPlayer());
|
||||
@ -269,7 +280,7 @@ public class PlayerListener implements Listener {
|
||||
&& herobrineLocation.getBlockX() < -PluginCore.getConfigDB().WalkingModeXRadius
|
||||
&& herobrineLocation.getBlockZ() > PluginCore.getConfigDB().WalkingModeZRadius
|
||||
&& herobrineLocation.getBlockZ() < -PluginCore.getConfigDB().WalkingModeZRadius) {
|
||||
|
||||
|
||||
PluginCore.getAICore().CancelTarget(CoreType.RANDOM_POSITION);
|
||||
PluginCore.HerobrineNPC.moveTo(new Location(Bukkit.getServer().getWorlds().get(0), 0, -20, 0));
|
||||
|
||||
@ -297,7 +308,7 @@ public class PlayerListener implements Listener {
|
||||
// Dynamically toggle Herobrine's visibility to players as a workaround to the persistent tab list entry if the persistent entry is disabled.
|
||||
if(!Herobrine.getPluginCore().getConfigDB().ShowInTabList)
|
||||
PluginCore.getAICore().toggleHerobrinePlayerVisibility(event.getPlayer());
|
||||
|
||||
|
||||
// Prevent player from moving when in Herobrine's Graveyard.
|
||||
if (event.getPlayer().getEntityId() != PluginCore.HerobrineEntityID) {
|
||||
if (event.getPlayer().getWorld() == Bukkit.getServer().getWorld(Herobrine.getPluginCore().getConfigDB().HerobrineWorldName)) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: Herobrine
|
||||
main: net.theprogrammersworld.herobrine.Herobrine
|
||||
version: 2.4.0
|
||||
version: 2.5.0-SNAPSHOT
|
||||
description: "Bring Herobrine to your Spigot-based Minecraft server!"
|
||||
website: https://www.theprogrammersworld.net
|
||||
api-version: 1.19
|
||||
|
Loading…
Reference in New Issue
Block a user