Skip to content

Commit ac3079d

Browse files
committed
2.8.1, MC 1.20.2, debug cleanup, readme cleanup, nms helper cleanup
1 parent a2d2c58 commit ac3079d

4 files changed

Lines changed: 14 additions & 31 deletions

File tree

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ Sentinel NPCs: Combat NPCs for Spigot!
1818
* [Integrating Your Plugin With Sentinel](#Integrating-Your-Plugin-With-Sentinel)
1919
* [Need help using Sentinel?](#need-help-using-sentinel-try-one-of-these-places)
2020
* [Dependencies](#Dependencies)
21-
* [Sentry user?](#Sentry-user?)
22-
* [Update Warnings](#Update-Warnings)
2321
* [License](#licensing-pre-note)
2422

2523
![AnimatedSentinel](https://i.imgur.com/VDwTzrs.gif)
2624

27-
**Version 2.8.0**: Compatible with Spigot 1.8.8 through 1.20.1 (Primarily targeted at 1.20.1) - see 'Common Issues' section below if on older supported versions)
25+
**Version 2.8.1**: Compatible with Spigot 1.8.8 through 1.20.2 (Primarily targeted at 1.20.2) - see 'Common Issues' section below if on older supported versions)
2826

2927
### Downloads
3028

@@ -346,7 +344,7 @@ If you're building a separate plugin you would like to integrate into Sentinel,
346344
<dependency>
347345
<groupId>org.mcmonkey</groupId>
348346
<artifactId>sentinel</artifactId>
349-
<version>2.8.0-SNAPSHOT</version>
347+
<version>2.8.1-SNAPSHOT</version>
350348
<type>jar</type>
351349
<scope>provided</scope>
352350
<exclusions>

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<groupId>org.mcmonkey</groupId>
88
<artifactId>sentinel</artifactId>
99
<packaging>jar</packaging>
10-
<version>2.8.0-SNAPSHOT</version>
10+
<version>2.8.1-SNAPSHOT</version>
1111
<name>Sentinel</name>
1212
<description>Combat NPCs for Spigot</description>
1313

1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16-
<bukkit.version>1.20.1-R0.1-SNAPSHOT</bukkit.version>
17-
<citizens.version>2.0.32-SNAPSHOT</citizens.version>
16+
<bukkit.version>1.20.2-R0.1-SNAPSHOT</bukkit.version>
17+
<citizens.version>2.0.33-SNAPSHOT</citizens.version>
1818
<BUILD_NUMBER>Unknown</BUILD_NUMBER>
1919
</properties>
2020

src/main/java/org/mcmonkey/sentinel/targeting/SentinelTargetingHelper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ public void processAvoidance() {
281281
}
282282
}
283283
else {
284-
if (SentinelPlugin.debugMe) {
285-
sentinel.debug("I have nowhere to run!");
286-
}
284+
sentinel.debug("I have nowhere to run!");
287285
}
288286
}
289287

@@ -293,10 +291,12 @@ public void processAvoidance() {
293291
public Location findBestRunSpot() {
294292
if (sentinel.avoidReturnPoint != null
295293
&& sentinel.avoidReturnPoint.getWorld().equals(getLivingEntity().getWorld())) {
294+
sentinel.debug("I have an avoid return point, I'll go there");
296295
return sentinel.avoidReturnPoint.clone();
297296
}
298297
Location pos = sentinel.getGuardZone();
299298
if (!pos.getWorld().equals(getLivingEntity().getWorld())) {
299+
sentinel.debug("Run spot out-of-world, must teleport away!");
300300
// Emergency corrective measures...
301301
getNPC().getNavigator().cancelNavigation();
302302
Bukkit.getScheduler().scheduleSyncDelayedTask(SentinelPlugin.instance, () -> getLivingEntity().teleport(sentinel.getGuardZone()), 1);
@@ -312,14 +312,14 @@ public Location findBestRunSpot() {
312312
}
313313
}
314314
if (closestThreat == null) {
315+
sentinel.debug("No threats in range, actually I won't run away");
315316
return null;
316317
}
317318
if (threatRangeSquared >= sentinel.avoidRange * sentinel.avoidRange) {
318-
if (SentinelPlugin.debugMe) {
319-
sentinel.debug("Threats are getting close... holding my post.");
320-
}
319+
sentinel.debug("Threats are getting close... holding my post.");
321320
return pos.clone();
322321
}
322+
sentinel.debug("I'll just pick a direction to run in I guess...");
323323
return runDirection(pos);
324324
}
325325

src/main/java/org/mcmonkey/sentinel/utilities/SentinelNMSHelper.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
public class SentinelNMSHelper {
1515

16-
public static MethodHandle CRAFTENTITY_GETHANDLE, NMSENTITY_WORLDGETTER, NMSWORLD_BROADCASTENTITYEFFECT, NMSENTITY_GETDATAWATCHER, DATWATCHER_SET, LIVINGENTITY_ATTACKSTRENGTHTICKS;
16+
public static MethodHandle CRAFTENTITY_GETHANDLE, NMSENTITY_WORLDGETTER, NMSWORLD_BROADCASTENTITYEFFECT, NMSENTITY_GETDATAWATCHER, DATWATCHER_SET;
1717

1818
public static Object ENTITYENDERMAN_DATAWATCHER_ANGRY;
1919

@@ -27,8 +27,6 @@ public static void init() {
2727
}
2828
// Will be like "org.bukkit.craftbukkit.v1_16_R3"
2929
String bukkitPackageName = Bukkit.getServer().getClass().getPackage().getName();
30-
// Should be like "v1_16_R3"
31-
String packageVersion = bukkitPackageName.substring(bukkitPackageName.lastIndexOf('.') + 1);
3230
Class craftEntity = Class.forName(bukkitPackageName + ".entity.CraftEntity");
3331
CRAFTENTITY_GETHANDLE = NMS.getMethodHandle(craftEntity, "getHandle", true);
3432
Class nmsEntity, nmsWorld, nmsDataWatcher, nmsDataWatcherObject, nmsEntityEnderman, nmsHuman, nmsLivingEntity;
@@ -40,43 +38,30 @@ public static void init() {
4038
nmsDataWatcher = Class.forName("net.minecraft.network.syncher.DataWatcher"); // SynchedEntityData
4139
nmsDataWatcherObject = Class.forName("net.minecraft.network.syncher.DataWatcherObject"); // EntityDataAccessor
4240
nmsEntityEnderman = Class.forName("net.minecraft.world.entity.monster.EntityEnderman");
43-
nmsLivingEntity = Class.forName("net.minecraft.world.entity.EntityLiving");
44-
String attackStrengthField = null;
45-
boolean isCompat = false;
4641
if (SentinelVersionCompat.v1_20 && !SentinelVersionCompat.vFuture) { // 1.20 names
47-
// https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.20
42+
// https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.20.2
4843
endermanAngryField = "bV"; // net.minecraft.world.entity.monster.EnderMan#DATA_CREEPY
49-
attackStrengthField = "aQ"; // net.minecraft.world.entity.LivingEntity#attackStrengthTicker
5044
broadcastEffectMethod = "a"; // net.minecraft.world.level.Level#broadcastEntityEvent(Entity,byte)
5145
dataWatcherSet = "a"; // net.minecraft.network.syncher.SynchedEntityData#set
52-
isCompat = true;
5346
}
5447
else if (SentinelVersionCompat.v1_19 && !SentinelVersionCompat.v1_20) { // 1.19.4 names
5548
// https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.19.4
5649
endermanAngryField = "bU"; // net.minecraft.world.entity.monster.EnderMan#DATA_CREEPY
57-
attackStrengthField = "aO"; // net.minecraft.world.entity.LivingEntity#attackStrengthTicker
5850
broadcastEffectMethod = "a"; // net.minecraft.world.level.Level#broadcastEntityEvent(Entity,byte)
5951
dataWatcherSet = "b"; // net.minecraft.network.syncher.SynchedEntityData#set
60-
isCompat = true;
6152
}
6253
else if (SentinelVersionCompat.v1_18 && !SentinelVersionCompat.v1_19) { // 1.18 names
6354
// https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.18.2
6455
endermanAngryField = "bX"; // net.minecraft.world.entity.monster.EnderMan#DATA_CREEPY
65-
attackStrengthField = "aQ"; // net.minecraft.world.entity.LivingEntity#attackStrengthTicker
6656
broadcastEffectMethod = "a"; // net.minecraft.world.level.Level#broadcastEntityEvent(Entity,byte)
6757
dataWatcherSet = "b"; // net.minecraft.network.syncher.SynchedEntityData#set
68-
isCompat = true;
6958
}
7059
else if (!SentinelVersionCompat.v1_18) { // 1.17 names
7160
endermanAngryField = "bV"; // EnderMan#DATA_CREEPY
72-
attackStrengthField = "aQ"; // LivingEntity#attackStrengthTicker
73-
isCompat = true;
74-
}
75-
if (isCompat) {
76-
LIVINGENTITY_ATTACKSTRENGTHTICKS = NMS.getSetter(nmsLivingEntity, attackStrengthField);
7761
}
7862
}
7963
else { // 1.12 through 1.16 - Original Spigot NMS versioned mappings
64+
String packageVersion = bukkitPackageName.substring(bukkitPackageName.lastIndexOf('.') + 1); // Should be like "v1_16_R3"
8065
String nmsPackageName = "net.minecraft.server." + packageVersion;
8166
nmsEntity = Class.forName(nmsPackageName + ".Entity");
8267
nmsWorld = Class.forName(nmsPackageName + ".World");

0 commit comments

Comments
 (0)