Skip to content

Commit

Permalink
Update to 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Jun 9, 2023
1 parent 1fed6a9 commit 3249126
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Fancy Npcs
A simple NPC plugin for minecraft servers using [packets](https://wiki.vg/Protocol)

**Only for minecraft server version 1.19.4**<br>
**Only for minecraft server version 1.20**<br>
_Using [paper](https://papermc.io/downloads) is highly recommended_

## Get the plugin
Expand Down
8 changes: 6 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "de.oliver"
version = "1.1.6-beta1"
version = "1.2.0-rc1"
description = "NPC plugin"

java {
Expand All @@ -20,7 +20,7 @@ repositories{
}

dependencies {
paperweight.paperDevBundle("1.19.4-R0.1-SNAPSHOT")
paperweight.paperDevBundle("1.20-R0.1-SNAPSHOT")
implementation("de.oliver:FancyLib:1.0.2")
}

Expand Down Expand Up @@ -57,6 +57,10 @@ tasks {
}
}

runServer{
minecraftVersion("1.20")
}

// Configure reobfJar to run when invoking the build task
assemble {
dependsOn(reobfJar)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/oliver/fancynpcs/FancyNpcs.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
import net.minecraft.server.dedicated.DedicatedServer;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

public class FancyNpcs extends JavaPlugin {

public static final String SUPPORTED_VERSION = "1.19.4";
public static final String SUPPORTED_VERSION = "1.20";

private static FancyNpcs instance;
private final FancyScheduler scheduler;
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/de/oliver/fancynpcs/Npc.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import net.minecraft.world.scores.Team;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;

import java.util.*;
Expand Down Expand Up @@ -128,7 +128,8 @@ public void create() {
npc = new ServerPlayer(minecraftServer, serverLevel, new GameProfile(gameProfile.getId(), ""));
((ServerPlayer) npc).gameProfile = gameProfile;
} else {
npc = type.create(serverLevel);
EntityType.EntityFactory factory = (EntityType.EntityFactory) ReflectionUtils.getValue(type, "bA"); // EntityType.factory
npc = factory.create(type, serverLevel);
}
}

Expand All @@ -138,7 +139,7 @@ private void spawn(ServerPlayer serverPlayer) {
return;
}

if (!location.getWorld().getName().equalsIgnoreCase(serverPlayer.getLevel().getWorld().getName())) {
if (!location.getWorld().getName().equalsIgnoreCase(serverPlayer.level().getWorld().getName())) {
return;
}

Expand Down Expand Up @@ -199,12 +200,6 @@ private void spawn(ServerPlayer serverPlayer) {
packets.add(addEntityPacket);
}


if (npc instanceof ServerPlayer) {
// Enable second layer of skin (https://wiki.vg/Entity_metadata#Player)
npc.getEntityData().set(net.minecraft.world.entity.player.Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40));
}

npc.setGlowingTag(glowing);

if (equipment != null && equipment.size() > 0) {
Expand All @@ -221,6 +216,11 @@ private void spawn(ServerPlayer serverPlayer) {
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(packets);
serverPlayer.connection.send(bundlePacket);

if (npc instanceof ServerPlayer) {
// Enable second layer of skin (https://wiki.vg/Entity_metadata#Player)
npc.getEntityData().set(net.minecraft.world.entity.player.Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40));
}

refreshEntityData(serverPlayer);

if (spawnEntity && location != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/oliver/fancynpcs/NpcManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;

import java.io.File;
import java.io.IOException;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/oliver/fancynpcs/PacketReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import net.minecraft.network.protocol.game.ServerboundInteractPacket;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;

import java.util.List;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/de/oliver/fancynpcs/commands/NpcCMD.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -612,7 +612,6 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
npc.removeForAll();
npc.create();
npc.spawnForAll();
npc.spawnForAll();
MessageHelper.success(sender, "Updated entity type");
} else {
MessageHelper.error(sender, "Modification has been cancelled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import de.oliver.fancynpcs.Npc;
import net.minecraft.server.level.ServerPlayer;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: FancyNpcs
main: de.oliver.fancynpcs.FancyNpcs
author: OliverHD
version: 1.1.6-beta1
version: 1.2.0-rc1
api-version: 1.19
load: POSTWORLD
folia-supported: true
Expand Down

0 comments on commit 3249126

Please sign in to comment.