Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com>
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
Nassim Jahnke
2025-04-12 17:26:44 +02:00
parent 0767902699
commit f00727c57e
2092 changed files with 50551 additions and 48729 deletions

View File

@@ -15,6 +15,7 @@ import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
@@ -29,7 +30,7 @@ import java.util.zip.GZIPOutputStream;
/**
* bStats collects some data for plugin authors.
*
* Check out https://bStats.org/ to learn more about bStats!
* Check out https://bstats.org/ to learn more about bStats!
*/
public class Metrics {
@@ -41,7 +42,7 @@ public class Metrics {
public static final int B_STATS_VERSION = 1;
// The url to which the data is sent
private static final String URL = "https://bStats.org/submitData/server-implementation";
private static final String URL = "https://bstats.org/submitData/server-implementation";
// Should failed requests be logged?
private static boolean logFailedRequests = false;
@@ -223,7 +224,7 @@ public class Metrics {
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
gzip.write(str.getBytes("UTF-8"));
gzip.write(str.getBytes(StandardCharsets.UTF_8));
gzip.close();
return outputStream.toByteArray();
}

View File

@@ -1,7 +1,6 @@
package com.destroystokyo.paper;
import com.destroystokyo.paper.util.VersionFetcher;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
@@ -15,6 +14,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.stream.StreamSupport;
@@ -87,7 +87,7 @@ public class PaperVersionFetcher implements VersionFetcher {
try {
try (final BufferedReader reader = Resources.asCharSource(
URI.create("https://api.papermc.io/v2/projects/paper/versions/" + build.minecraftVersionId()).toURL(),
Charsets.UTF_8
StandardCharsets.UTF_8
).openBufferedStream()) {
final JsonObject json = new Gson().fromJson(reader, JsonObject.class);
final JsonArray builds = json.getAsJsonArray("builds");
@@ -112,7 +112,7 @@ public class PaperVersionFetcher implements VersionFetcher {
final HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.github.com/repos/%s/compare/%s...%s".formatted(repo, branch, hash)).toURL().openConnection();
connection.connect();
if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) return DISTANCE_UNKNOWN; // Unknown commit
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8))) {
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
final JsonObject obj = new Gson().fromJson(reader, JsonObject.class);
final String status = obj.get("status").getAsString();
return switch (status) {

View File

@@ -1,8 +1,9 @@
package com.destroystokyo.paper.entity;
import org.apache.commons.lang.Validate;
import com.google.common.base.Preconditions;
import org.bukkit.Location;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.util.CraftLocation;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Mob;
import javax.annotation.Nonnull;
@@ -31,77 +32,78 @@ public class PaperPathfinder implements com.destroystokyo.paper.entity.Pathfinde
@Override
public void stopPathfinding() {
entity.getNavigation().stop();
this.entity.getNavigation().stop();
}
@Override
public boolean hasPath() {
return entity.getNavigation().getPath() != null && !entity.getNavigation().getPath().isDone();
return this.entity.getNavigation().getPath() != null && !this.entity.getNavigation().getPath().isDone();
}
@Nullable
@Override
public PathResult getCurrentPath() {
Path path = entity.getNavigation().getPath();
Path path = this.entity.getNavigation().getPath();
return path != null && !path.isDone() ? new PaperPathResult(path) : null;
}
@Nullable
@Override
public PathResult findPath(Location loc) {
Validate.notNull(loc, "Location can not be null");
Path path = entity.getNavigation().createPath(loc.getX(), loc.getY(), loc.getZ(), 0);
Preconditions.checkArgument(loc != null, "Location can not be null");
Path path = this.entity.getNavigation().createPath(loc.getX(), loc.getY(), loc.getZ(), 0);
return path != null ? new PaperPathResult(path) : null;
}
@Nullable
@Override
public PathResult findPath(LivingEntity target) {
Validate.notNull(target, "Target can not be null");
Path path = entity.getNavigation().createPath(((CraftLivingEntity) target).getHandle(), 0);
Preconditions.checkArgument(target != null, "Target can not be null");
Path path = this.entity.getNavigation().createPath(((CraftLivingEntity) target).getHandle(), 0);
return path != null ? new PaperPathResult(path) : null;
}
@Override
public boolean moveTo(@Nonnull PathResult path, double speed) {
Validate.notNull(path, "PathResult can not be null");
Preconditions.checkArgument(path != null, "PathResult can not be null");
Path pathEntity = ((PaperPathResult) path).path;
return entity.getNavigation().moveTo(pathEntity, speed);
return this.entity.getNavigation().moveTo(pathEntity, speed);
}
@Override
public boolean canOpenDoors() {
return entity.getNavigation().pathFinder.nodeEvaluator.canOpenDoors();
return this.entity.getNavigation().pathFinder.nodeEvaluator.canOpenDoors();
}
@Override
public void setCanOpenDoors(boolean canOpenDoors) {
entity.getNavigation().pathFinder.nodeEvaluator.setCanOpenDoors(canOpenDoors);
this.entity.getNavigation().pathFinder.nodeEvaluator.setCanOpenDoors(canOpenDoors);
}
@Override
public boolean canPassDoors() {
return entity.getNavigation().pathFinder.nodeEvaluator.canPassDoors();
return this.entity.getNavigation().pathFinder.nodeEvaluator.canPassDoors();
}
@Override
public void setCanPassDoors(boolean canPassDoors) {
entity.getNavigation().pathFinder.nodeEvaluator.setCanPassDoors(canPassDoors);
this.entity.getNavigation().pathFinder.nodeEvaluator.setCanPassDoors(canPassDoors);
}
@Override
public boolean canFloat() {
return entity.getNavigation().pathFinder.nodeEvaluator.canFloat();
return this.entity.getNavigation().pathFinder.nodeEvaluator.canFloat();
}
@Override
public void setCanFloat(boolean canFloat) {
entity.getNavigation().pathFinder.nodeEvaluator.setCanFloat(canFloat);
this.entity.getNavigation().pathFinder.nodeEvaluator.setCanFloat(canFloat);
}
public class PaperPathResult implements com.destroystokyo.paper.entity.PaperPathfinder.PathResult {
private final Path path;
PaperPathResult(Path path) {
this.path = path;
}
@@ -109,40 +111,36 @@ public class PaperPathfinder implements com.destroystokyo.paper.entity.Pathfinde
@Nullable
@Override
public Location getFinalPoint() {
Node point = path.getEndNode();
return point != null ? toLoc(point) : null;
Node point = this.path.getEndNode();
return point != null ? CraftLocation.toBukkit(point, PaperPathfinder.this.entity.level()) : null;
}
@Override
public boolean canReachFinalPoint() {
return path.canReach();
return this.path.canReach();
}
@Override
public List<Location> getPoints() {
List<Location> points = new ArrayList<>();
for (Node point : path.nodes) {
points.add(toLoc(point));
for (Node point : this.path.nodes) {
points.add(CraftLocation.toBukkit(point, PaperPathfinder.this.entity.level()));
}
return points;
}
@Override
public int getNextPointIndex() {
return path.getNextNodeIndex();
return this.path.getNextNodeIndex();
}
@Nullable
@Override
public Location getNextPoint() {
if (path.isDone()) {
if (this.path.isDone()) {
return null;
}
return toLoc(path.nodes.get(path.getNextNodeIndex()));
return CraftLocation.toBukkit(this.path.nodes.get(this.path.getNextNodeIndex()), PaperPathfinder.this.entity.level());
}
}
private Location toLoc(Node point) {
return new Location(entity.level().getWorld(), point.x, point.y, point.z);
}
}

View File

@@ -3,6 +3,7 @@ package com.destroystokyo.paper.entity.ai;
import com.destroystokyo.paper.entity.RangedEntity;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import io.papermc.paper.entity.SchoolableFish;
import io.papermc.paper.util.ObfHelper;
import java.lang.reflect.Constructor;
import java.util.EnumSet;
@@ -10,120 +11,10 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.minecraft.world.entity.FlyingMob;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.ai.goal.Goal;
import net.minecraft.world.entity.ambient.AmbientCreature;
import net.minecraft.world.entity.animal.AbstractFish;
import net.minecraft.world.entity.animal.AbstractGolem;
import net.minecraft.world.entity.animal.AbstractSchoolingFish;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.animal.Pufferfish;
import net.minecraft.world.entity.animal.ShoulderRidingEntity;
import net.minecraft.world.entity.animal.SnowGolem;
import net.minecraft.world.entity.animal.WaterAnimal;
import net.minecraft.world.entity.animal.camel.Camel;
import net.minecraft.world.entity.animal.horse.AbstractChestedHorse;
import net.minecraft.world.entity.boss.wither.WitherBoss;
import net.minecraft.world.entity.monster.AbstractIllager;
import net.minecraft.world.entity.monster.EnderMan;
import net.minecraft.world.entity.monster.PatrollingMonster;
import net.minecraft.world.entity.monster.RangedAttackMob;
import net.minecraft.world.entity.monster.SpellcasterIllager;
import net.minecraft.world.entity.monster.ZombifiedPiglin;
import net.minecraft.world.entity.monster.breeze.Breeze;
import net.minecraft.world.entity.monster.piglin.AbstractPiglin;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.AbstractHorse;
import org.bukkit.entity.AbstractSkeleton;
import org.bukkit.entity.AbstractVillager;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Ambient;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Bee;
import org.bukkit.entity.Blaze;
import org.bukkit.entity.Cat;
import org.bukkit.entity.CaveSpider;
import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cod;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Dolphin;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Drowned;
import org.bukkit.entity.ElderGuardian;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Endermite;
import org.bukkit.entity.Evoker;
import org.bukkit.entity.Fish;
import org.bukkit.entity.Flying;
import org.bukkit.entity.Fox;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.Giant;
import org.bukkit.entity.Golem;
import org.bukkit.entity.Guardian;
import org.bukkit.entity.Hoglin;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Husk;
import org.bukkit.entity.Illager;
import org.bukkit.entity.Illusioner;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.Llama;
import org.bukkit.entity.MagmaCube;
import org.bukkit.entity.Mob;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Mule;
import org.bukkit.entity.MushroomCow;
import org.bukkit.entity.Ocelot;
import org.bukkit.entity.Panda;
import org.bukkit.entity.Parrot;
import org.bukkit.entity.Phantom;
import org.bukkit.entity.Pig;
import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Piglin;
import org.bukkit.entity.PiglinAbstract;
import org.bukkit.entity.PiglinBrute;
import org.bukkit.entity.Pillager;
import org.bukkit.entity.PolarBear;
import org.bukkit.entity.PufferFish;
import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Raider;
import org.bukkit.entity.Ravager;
import org.bukkit.entity.Salmon;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Shulker;
import org.bukkit.entity.Silverfish;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.SkeletonHorse;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Snowman;
import org.bukkit.entity.Spellcaster;
import org.bukkit.entity.Spider;
import org.bukkit.entity.Squid;
import org.bukkit.entity.Stray;
import org.bukkit.entity.Strider;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.TraderLlama;
import org.bukkit.entity.TropicalFish;
import org.bukkit.entity.Turtle;
import org.bukkit.entity.Vex;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Vindicator;
import org.bukkit.entity.WanderingTrader;
import org.bukkit.entity.WaterMob;
import org.bukkit.entity.Witch;
import org.bukkit.entity.Wither;
import org.bukkit.entity.WitherSkeleton;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.Zoglin;
import org.bukkit.entity.Zombie;
import org.bukkit.entity.ZombieHorse;
import org.bukkit.entity.ZombieVillager;
import org.bukkit.entity.*;
public class MobGoalHelper {
@@ -143,10 +34,13 @@ public class MobGoalHelper {
ignored.add("selector_2");
ignored.add("wrapped");
//<editor-fold defaultstate="collapsed" desc="bukkitMap Entities">
// Start generate - MobGoalHelper#bukkitMap
// @GeneratedFrom 1.21.5
bukkitMap.put(net.minecraft.world.entity.Mob.class, Mob.class);
bukkitMap.put(net.minecraft.world.entity.AgeableMob.class, Ageable.class);
bukkitMap.put(AmbientCreature.class, Ambient.class);
bukkitMap.put(Animal.class, Animals.class);
bukkitMap.put(net.minecraft.world.entity.ambient.AmbientCreature.class, Ambient.class);
bukkitMap.put(net.minecraft.world.entity.animal.Animal.class, Animals.class);
bukkitMap.put(net.minecraft.world.entity.ambient.Bat.class, Bat.class);
bukkitMap.put(net.minecraft.world.entity.animal.Bee.class, Bee.class);
bukkitMap.put(net.minecraft.world.entity.monster.Blaze.class, Blaze.class);
@@ -155,56 +49,56 @@ public class MobGoalHelper {
bukkitMap.put(net.minecraft.world.entity.animal.Chicken.class, Chicken.class);
bukkitMap.put(net.minecraft.world.entity.animal.Cod.class, Cod.class);
bukkitMap.put(net.minecraft.world.entity.animal.Cow.class, Cow.class);
bukkitMap.put(PathfinderMob.class, Creature.class);
bukkitMap.put(net.minecraft.world.entity.PathfinderMob.class, Creature.class);
bukkitMap.put(net.minecraft.world.entity.monster.Creeper.class, Creeper.class);
bukkitMap.put(net.minecraft.world.entity.animal.Dolphin.class, Dolphin.class);
bukkitMap.put(net.minecraft.world.entity.monster.Drowned.class, Drowned.class);
bukkitMap.put(net.minecraft.world.entity.boss.enderdragon.EnderDragon.class, EnderDragon.class);
bukkitMap.put(EnderMan.class, Enderman.class);
bukkitMap.put(net.minecraft.world.entity.monster.EnderMan.class, Enderman.class);
bukkitMap.put(net.minecraft.world.entity.monster.Endermite.class, Endermite.class);
bukkitMap.put(net.minecraft.world.entity.monster.Evoker.class, Evoker.class);
bukkitMap.put(AbstractFish.class, Fish.class);
bukkitMap.put(AbstractSchoolingFish.class, io.papermc.paper.entity.SchoolableFish.class);
bukkitMap.put(FlyingMob.class, Flying.class);
bukkitMap.put(net.minecraft.world.entity.animal.AbstractFish.class, Fish.class);
bukkitMap.put(net.minecraft.world.entity.animal.AbstractSchoolingFish.class, SchoolableFish.class);
bukkitMap.put(net.minecraft.world.entity.FlyingMob.class, Flying.class);
bukkitMap.put(net.minecraft.world.entity.animal.Fox.class, Fox.class);
bukkitMap.put(net.minecraft.world.entity.monster.Ghast.class, Ghast.class);
bukkitMap.put(net.minecraft.world.entity.monster.Giant.class, Giant.class);
bukkitMap.put(AbstractGolem.class, Golem.class);
bukkitMap.put(net.minecraft.world.entity.animal.AbstractGolem.class, Golem.class);
bukkitMap.put(net.minecraft.world.entity.monster.Guardian.class, Guardian.class);
bukkitMap.put(net.minecraft.world.entity.monster.ElderGuardian.class, ElderGuardian.class);
bukkitMap.put(net.minecraft.world.entity.animal.horse.Horse.class, Horse.class);
bukkitMap.put(net.minecraft.world.entity.animal.horse.AbstractHorse.class, AbstractHorse.class);
bukkitMap.put(AbstractChestedHorse.class, ChestedHorse.class);
bukkitMap.put(net.minecraft.world.entity.animal.horse.AbstractChestedHorse.class, ChestedHorse.class);
bukkitMap.put(net.minecraft.world.entity.animal.horse.Donkey.class, Donkey.class);
bukkitMap.put(net.minecraft.world.entity.animal.horse.Mule.class, Mule.class);
bukkitMap.put(net.minecraft.world.entity.animal.horse.SkeletonHorse.class, SkeletonHorse.class);
bukkitMap.put(net.minecraft.world.entity.animal.horse.ZombieHorse.class, ZombieHorse.class);
bukkitMap.put(Camel.class, org.bukkit.entity.Camel.class);
bukkitMap.put(AbstractIllager.class, Illager.class);
bukkitMap.put(net.minecraft.world.entity.animal.camel.Camel.class, Camel.class);
bukkitMap.put(net.minecraft.world.entity.monster.AbstractIllager.class, Illager.class);
bukkitMap.put(net.minecraft.world.entity.monster.Illusioner.class, Illusioner.class);
bukkitMap.put(SpellcasterIllager.class, Spellcaster.class);
bukkitMap.put(net.minecraft.world.entity.monster.SpellcasterIllager.class, Spellcaster.class);
bukkitMap.put(net.minecraft.world.entity.animal.IronGolem.class, IronGolem.class);
bukkitMap.put(net.minecraft.world.entity.animal.horse.Llama.class, Llama.class);
bukkitMap.put(net.minecraft.world.entity.animal.horse.TraderLlama.class, TraderLlama.class);
bukkitMap.put(net.minecraft.world.entity.monster.MagmaCube.class, MagmaCube.class);
bukkitMap.put(net.minecraft.world.entity.monster.Monster.class, Monster.class);
bukkitMap.put(PatrollingMonster.class, Raider.class); // close enough
bukkitMap.put(net.minecraft.world.entity.monster.PatrollingMonster.class, Raider.class);
bukkitMap.put(net.minecraft.world.entity.animal.MushroomCow.class, MushroomCow.class);
bukkitMap.put(net.minecraft.world.entity.animal.Ocelot.class, Ocelot.class);
bukkitMap.put(net.minecraft.world.entity.animal.Panda.class, Panda.class);
bukkitMap.put(net.minecraft.world.entity.animal.Parrot.class, Parrot.class);
bukkitMap.put(ShoulderRidingEntity.class, Parrot.class); // close enough
bukkitMap.put(net.minecraft.world.entity.animal.ShoulderRidingEntity.class, Parrot.class);
bukkitMap.put(net.minecraft.world.entity.monster.Phantom.class, Phantom.class);
bukkitMap.put(net.minecraft.world.entity.animal.Pig.class, Pig.class);
bukkitMap.put(ZombifiedPiglin.class, PigZombie.class);
bukkitMap.put(net.minecraft.world.entity.monster.ZombifiedPiglin.class, PigZombie.class);
bukkitMap.put(net.minecraft.world.entity.monster.Pillager.class, Pillager.class);
bukkitMap.put(net.minecraft.world.entity.animal.PolarBear.class, PolarBear.class);
bukkitMap.put(Pufferfish.class, PufferFish.class);
bukkitMap.put(net.minecraft.world.entity.animal.Pufferfish.class, PufferFish.class);
bukkitMap.put(net.minecraft.world.entity.animal.Rabbit.class, Rabbit.class);
bukkitMap.put(net.minecraft.world.entity.raid.Raider.class, Raider.class);
bukkitMap.put(net.minecraft.world.entity.monster.Ravager.class, Ravager.class);
bukkitMap.put(net.minecraft.world.entity.animal.Salmon.class, Salmon.class);
bukkitMap.put(net.minecraft.world.entity.animal.Sheep.class, Sheep.class);
bukkitMap.put(net.minecraft.world.entity.animal.sheep.Sheep.class, Sheep.class);
bukkitMap.put(net.minecraft.world.entity.monster.Shulker.class, Shulker.class);
bukkitMap.put(net.minecraft.world.entity.monster.Silverfish.class, Silverfish.class);
bukkitMap.put(net.minecraft.world.entity.monster.Skeleton.class, Skeleton.class);
@@ -212,10 +106,10 @@ public class MobGoalHelper {
bukkitMap.put(net.minecraft.world.entity.monster.Stray.class, Stray.class);
bukkitMap.put(net.minecraft.world.entity.monster.WitherSkeleton.class, WitherSkeleton.class);
bukkitMap.put(net.minecraft.world.entity.monster.Slime.class, Slime.class);
bukkitMap.put(SnowGolem.class, Snowman.class);
bukkitMap.put(net.minecraft.world.entity.animal.SnowGolem.class, Snowman.class);
bukkitMap.put(net.minecraft.world.entity.monster.Spider.class, Spider.class);
bukkitMap.put(net.minecraft.world.entity.animal.Squid.class, Squid.class);
bukkitMap.put(TamableAnimal.class, Tameable.class);
bukkitMap.put(net.minecraft.world.entity.TamableAnimal.class, Tameable.class);
bukkitMap.put(net.minecraft.world.entity.animal.TropicalFish.class, TropicalFish.class);
bukkitMap.put(net.minecraft.world.entity.animal.Turtle.class, Turtle.class);
bukkitMap.put(net.minecraft.world.entity.monster.Vex.class, Vex.class);
@@ -223,32 +117,35 @@ public class MobGoalHelper {
bukkitMap.put(net.minecraft.world.entity.npc.AbstractVillager.class, AbstractVillager.class);
bukkitMap.put(net.minecraft.world.entity.npc.WanderingTrader.class, WanderingTrader.class);
bukkitMap.put(net.minecraft.world.entity.monster.Vindicator.class, Vindicator.class);
bukkitMap.put(WaterAnimal.class, WaterMob.class);
bukkitMap.put(net.minecraft.world.entity.animal.WaterAnimal.class, WaterMob.class);
bukkitMap.put(net.minecraft.world.entity.monster.Witch.class, Witch.class);
bukkitMap.put(WitherBoss.class, Wither.class);
bukkitMap.put(net.minecraft.world.entity.animal.Wolf.class, Wolf.class);
bukkitMap.put(net.minecraft.world.entity.boss.wither.WitherBoss.class, Wither.class);
bukkitMap.put(net.minecraft.world.entity.animal.wolf.Wolf.class, Wolf.class);
bukkitMap.put(net.minecraft.world.entity.monster.Zombie.class, Zombie.class);
bukkitMap.put(net.minecraft.world.entity.monster.Husk.class, Husk.class);
bukkitMap.put(net.minecraft.world.entity.monster.ZombieVillager.class, ZombieVillager.class);
bukkitMap.put(net.minecraft.world.entity.monster.hoglin.Hoglin.class, Hoglin.class);
bukkitMap.put(net.minecraft.world.entity.monster.piglin.Piglin.class, Piglin.class);
bukkitMap.put(AbstractPiglin.class, PiglinAbstract.class);
bukkitMap.put(net.minecraft.world.entity.monster.piglin.AbstractPiglin.class, PiglinAbstract.class);
bukkitMap.put(net.minecraft.world.entity.monster.piglin.PiglinBrute.class, PiglinBrute.class);
bukkitMap.put(net.minecraft.world.entity.monster.Strider.class, Strider.class);
bukkitMap.put(net.minecraft.world.entity.monster.Zoglin.class, Zoglin.class);
bukkitMap.put(net.minecraft.world.entity.GlowSquid.class, org.bukkit.entity.GlowSquid.class);
bukkitMap.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, org.bukkit.entity.Axolotl.class);
bukkitMap.put(net.minecraft.world.entity.animal.goat.Goat.class, org.bukkit.entity.Goat.class);
bukkitMap.put(net.minecraft.world.entity.animal.frog.Frog.class, org.bukkit.entity.Frog.class);
bukkitMap.put(net.minecraft.world.entity.animal.frog.Tadpole.class, org.bukkit.entity.Tadpole.class);
bukkitMap.put(net.minecraft.world.entity.monster.warden.Warden.class, org.bukkit.entity.Warden.class);
bukkitMap.put(net.minecraft.world.entity.animal.allay.Allay.class, org.bukkit.entity.Allay.class);
bukkitMap.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, org.bukkit.entity.Sniffer.class);
bukkitMap.put(Breeze.class, org.bukkit.entity.Breeze.class);
bukkitMap.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, org.bukkit.entity.Armadillo.class);
bukkitMap.put(net.minecraft.world.entity.monster.Bogged.class, org.bukkit.entity.Bogged.class);
bukkitMap.put(net.minecraft.world.entity.monster.creaking.Creaking.class, org.bukkit.entity.Creaking.class);
bukkitMap.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, org.bukkit.entity.Squid.class); // close enough
bukkitMap.put(net.minecraft.world.entity.GlowSquid.class, GlowSquid.class);
bukkitMap.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, Axolotl.class);
bukkitMap.put(net.minecraft.world.entity.animal.goat.Goat.class, Goat.class);
bukkitMap.put(net.minecraft.world.entity.animal.frog.Frog.class, Frog.class);
bukkitMap.put(net.minecraft.world.entity.animal.frog.Tadpole.class, Tadpole.class);
bukkitMap.put(net.minecraft.world.entity.monster.warden.Warden.class, Warden.class);
bukkitMap.put(net.minecraft.world.entity.animal.allay.Allay.class, Allay.class);
bukkitMap.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, Sniffer.class);
bukkitMap.put(net.minecraft.world.entity.monster.breeze.Breeze.class, Breeze.class);
bukkitMap.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, Armadillo.class);
bukkitMap.put(net.minecraft.world.entity.monster.Bogged.class, Bogged.class);
bukkitMap.put(net.minecraft.world.entity.monster.creaking.Creaking.class, Creaking.class);
bukkitMap.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, Squid.class);
bukkitMap.put(net.minecraft.world.entity.animal.AbstractCow.class, AbstractCow.class);
// End generate - MobGoalHelper#bukkitMap
//</editor-fold>
}
public static String getUsableName(Class<?> clazz) {
@@ -267,7 +164,6 @@ public class MobGoalHelper {
name = cut;
}
}
name = name.replace("PathfinderGoal", "");
name = name.replace("TargetGoal", "");
name = name.replace("Goal", "");
StringBuilder sb = new StringBuilder();
@@ -365,7 +261,7 @@ public class MobGoalHelper {
}
}
}
throw new RuntimeException("Can't figure out applicable entity for mob goal " + goalClass); // maybe just return EntityInsentient?
throw new RuntimeException("Can't figure out applicable entity for mob goal " + goalClass); // maybe just return Mob?
});
}

View File

@@ -7,14 +7,14 @@ import org.bukkit.entity.Mob;
/**
* Wraps vanilla in api
*/
public class PaperVanillaGoal<T extends Mob> implements VanillaGoal<T> {
public class PaperGoal<T extends Mob> implements com.destroystokyo.paper.entity.ai.Goal<T> {
private final Goal handle;
private final GoalKey<T> key;
private final EnumSet<GoalType> types;
public PaperVanillaGoal(Goal handle) {
public PaperGoal(Goal handle) {
this.handle = handle;
this.key = MobGoalHelper.getKey(handle.getClass());
this.types = MobGoalHelper.vanillaToPaper(handle);

View File

@@ -20,8 +20,8 @@ public class PaperMobGoals implements MobGoals {
CraftMob craftMob = (CraftMob) mob;
net.minecraft.world.entity.ai.goal.Goal mojangGoal;
if (goal instanceof PaperVanillaGoal vanillaGoal) {
mojangGoal = vanillaGoal.getHandle();
if (goal instanceof PaperGoal<?> paperGoal) {
mojangGoal = paperGoal.getHandle();
} else {
mojangGoal = new PaperCustomGoal<>(goal);
}
@@ -34,8 +34,8 @@ public class PaperMobGoals implements MobGoals {
CraftMob craftMob = (CraftMob) mob;
if (goal instanceof PaperCustomGoal) {
getHandle(craftMob, goal.getTypes()).removeGoal((net.minecraft.world.entity.ai.goal.Goal) goal);
} else if (goal instanceof PaperVanillaGoal) {
getHandle(craftMob, goal.getTypes()).removeGoal(((PaperVanillaGoal<?>) goal).getHandle());
} else if (goal instanceof PaperGoal) {
getHandle(craftMob, goal.getTypes()).removeGoal(((PaperGoal<?>) goal).getHandle());
} else {
List<net.minecraft.world.entity.ai.goal.Goal> toRemove = new LinkedList<>();
for (WrappedGoal item : getHandle(craftMob, goal.getTypes()).getAvailableGoals()) {
@@ -127,7 +127,7 @@ public class PaperMobGoals implements MobGoals {
//noinspection unchecked
goals.add(((PaperCustomGoal<T>) item.getGoal()).getHandle());
} else {
goals.add(item.getGoal().asPaperVanillaGoal());
goals.add(item.getGoal().asPaperGoal());
}
}
return goals;
@@ -150,7 +150,7 @@ public class PaperMobGoals implements MobGoals {
//noinspection unchecked
goals.add(((PaperCustomGoal<T>) item.getGoal()).getHandle());
} else {
goals.add(item.getGoal().asPaperVanillaGoal());
goals.add(item.getGoal().asPaperGoal());
}
}
}
@@ -178,7 +178,7 @@ public class PaperMobGoals implements MobGoals {
//noinspection unchecked
goals.add(((PaperCustomGoal<T>) item.getGoal()).getHandle());
} else {
goals.add(item.getGoal().asPaperVanillaGoal());
goals.add(item.getGoal().asPaperGoal());
}
});
return goals;
@@ -201,7 +201,7 @@ public class PaperMobGoals implements MobGoals {
//noinspection unchecked
goals.add(((PaperCustomGoal<T>) item.getGoal()).getHandle());
} else {
goals.add(item.getGoal().asPaperVanillaGoal());
goals.add(item.getGoal().asPaperGoal());
}
});
}

View File

@@ -5,12 +5,13 @@ import io.papermc.paper.configuration.type.DurationOrDisabled;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import net.minecraft.core.UUIDUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.RandomizableContainer;
import net.minecraft.world.entity.vehicle.ContainerEntity;
import org.bukkit.entity.Player;
@@ -164,30 +165,25 @@ public class PaperLootableInventoryData {
private static final String LOOTED_PLAYERS = "lootedPlayers";
public void loadNbt(final CompoundTag base) {
if (!base.contains(ROOT, Tag.TAG_COMPOUND)) {
final Optional<CompoundTag> compOpt = base.getCompound(ROOT);
if (compOpt.isEmpty()) {
return;
}
final CompoundTag comp = base.getCompound(ROOT);
if (comp.contains(LAST_FILL)) {
this.lastFill = comp.getLong(LAST_FILL);
CompoundTag comp = compOpt.get();
this.lastFill = comp.getLongOr(LAST_FILL, -1);
this.nextRefill = comp.getLongOr(NEXT_REFILL, -1);
this.numRefills = comp.getIntOr(NUM_REFILLS, 0);
final ListTag list = comp.getListOrEmpty(LOOTED_PLAYERS);
final int size = list.size();
if (size > 0) {
this.lootedPlayers = new HashMap<>(list.size());
}
if (comp.contains(NEXT_REFILL)) {
this.nextRefill = comp.getLong(NEXT_REFILL);
}
if (comp.contains(NUM_REFILLS)) {
this.numRefills = comp.getInt(NUM_REFILLS);
}
if (comp.contains(LOOTED_PLAYERS, Tag.TAG_LIST)) {
final ListTag list = comp.getList(LOOTED_PLAYERS, Tag.TAG_COMPOUND);
final int size = list.size();
if (size > 0) {
this.lootedPlayers = new HashMap<>(list.size());
}
for (int i = 0; i < size; i++) {
final CompoundTag cmp = list.getCompound(i);
this.lootedPlayers.put(cmp.getUUID("UUID"), cmp.getLong("Time"));
}
for (int i = 0; i < size; i++) {
list.getCompound(i).ifPresent(tag -> {
tag.read("UUID", UUIDUtil.CODEC).ifPresent(uuid -> {
this.lootedPlayers.put(uuid, tag.getLongOr("Time", 0));
});
});
}
}
@@ -206,7 +202,7 @@ public class PaperLootableInventoryData {
final ListTag list = new ListTag();
for (final Map.Entry<UUID, Long> entry : this.lootedPlayers.entrySet()) {
final CompoundTag cmp = new CompoundTag();
cmp.putUUID("UUID", entry.getKey());
cmp.store("UUID", UUIDUtil.CODEC, entry.getKey());
cmp.putLong("Time", entry.getValue());
list.add(cmp);
}

View File

@@ -3,7 +3,6 @@ package com.destroystokyo.paper.profile;
import com.google.common.base.Preconditions;
import com.mojang.authlib.yggdrasil.ProfileResult;
import io.papermc.paper.configuration.GlobalConfiguration;
import com.google.common.base.Charsets;
import com.google.common.collect.Iterables;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
@@ -14,7 +13,6 @@ import net.minecraft.server.players.GameProfileCache;
import net.minecraft.util.StringUtil;
import net.minecraft.world.item.component.ResolvableProfile;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.craftbukkit.configuration.ConfigSerializationUtil;
import org.bukkit.craftbukkit.entity.CraftPlayer;
@@ -25,6 +23,7 @@ import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.CompletableFuture;
@@ -47,7 +46,7 @@ public class CraftPlayerProfile implements PlayerProfile, SharedPlayerProfile {
}
public CraftPlayerProfile(GameProfile profile) {
Validate.notNull(profile, "GameProfile cannot be null!");
Preconditions.checkArgument(profile != null, "GameProfile cannot be null!");
this.profile = profile;
}
@@ -222,7 +221,7 @@ public class CraftPlayerProfile implements PlayerProfile, SharedPlayerProfile {
profile = lookupUUID ? userCache.get(name).orElse(null) : userCache.getProfileIfCached(name);
} else {
// Make an OfflinePlayer using an offline mode UUID since the name has no profile
profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name);
profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)), name);
}
if (profile != null) {
// if old has it, assume its newer, so overwrite, else use cached if it was set and ours wasn't

View File

@@ -30,7 +30,7 @@ public class PaperMinecraftSessionService extends YggdrasilMinecraftSessionServi
return result;
}
@Override @io.papermc.paper.annotation.DoNotUse @Deprecated
@Override @Deprecated
public @Nullable ProfileResult fetchProfile(final UUID profileId, final boolean requireSecure) {
return super.fetchProfile(profileId, requireSecure);
}