File tree Expand file tree Collapse file tree 14 files changed +22
-40
lines changed
src/main/java/de/pascalpex/pexnpc Expand file tree Collapse file tree 14 files changed +22
-40
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ PexNPC offers a few advantages over some other NPC plugins:
1111- Lightweight and small in file size
1212- Fast updates for new Minecraft versions. Most of the time, the updates arrive at the same day as the Paper API does
1313
14- Please note, that this plugin only supports the latest version of Minecraft. Older versions may or may not work.
14+ Please note that this plugin only supports the latest version of Minecraft. Older versions may or may not work.
1515## Building
1616```
1717./gradlew build
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ repositories {
1616}
1717
1818dependencies {
19- testImplementation(platform(" org.junit:junit-bom:5.12.2 " ))
19+ testImplementation(platform(" org.junit:junit-bom:5.13.0 " ))
2020 testImplementation(" org.junit.jupiter:junit-jupiter" )
2121 compileOnly(" me.clip:placeholderapi:2.11.6" )
2222 paperweight.paperDevBundle(" 1.21.5-R0.1-SNAPSHOT" )
Original file line number Diff line number Diff line change 1717
1818import java .util .ArrayList ;
1919import java .util .List ;
20- import java .util .logging .Level ;
2120import java .util .logging .Logger ;
2221
2322public class PexNPC extends JavaPlugin {
@@ -53,11 +52,7 @@ public void onEnable() {
5352 loadAllNPCs ();
5453
5554 for (Player player : Bukkit .getOnlinePlayers ()) {
56- try {
57- packetReader .inject (player );
58- } catch (NoSuchFieldException | IllegalAccessException e ) {
59- logger .log (Level .SEVERE , "Could not inject the PacketReader!" );
60- }
55+ packetReader .inject (player );
6156 }
6257
6358 // Listeners
@@ -137,12 +132,8 @@ public void reload() {
137132 this .getServer ().getMessenger ().registerOutgoingPluginChannel (this , "BungeeCord" );
138133
139134 for (Player player : Bukkit .getOnlinePlayers ()) {
140- try {
141- packetReader .uninject (player );
142- packetReader .inject (player );
143- } catch (NoSuchFieldException | IllegalAccessException e ) {
144- logger .log (Level .SEVERE , "Could not inject the PacketReader!" );
145- }
135+ packetReader .uninject (player );
136+ packetReader .inject (player );
146137 }
147138
148139 NPCClickListener .inspectors .clear ();
Original file line number Diff line number Diff line change 22
33import io .papermc .paper .plugin .loader .PluginClasspathBuilder ;
44import io .papermc .paper .plugin .loader .PluginLoader ;
5+ import org .jetbrains .annotations .NotNull ;
56
67public class PexNPCLoader implements PluginLoader {
78 @ Override
8- public void classloader (PluginClasspathBuilder pluginClasspathBuilder ) {
9+ public void classloader (@ NotNull PluginClasspathBuilder pluginClasspathBuilder ) {
910
1011 }
1112}
Original file line number Diff line number Diff line change 33import com .mojang .brigadier .Command ;
44import com .mojang .brigadier .arguments .StringArgumentType ;
55import com .mojang .brigadier .context .CommandContext ;
6- import com .mojang .brigadier .exceptions .CommandSyntaxException ;
76import de .pascalpex .pexnpc .PexNPC ;
87import de .pascalpex .pexnpc .files .NPCData ;
98import de .pascalpex .pexnpc .npc .NPC ;
1817
1918public class CreateSubcommand implements Command <CommandSourceStack > {
2019 @ Override
21- public int run (CommandContext <CommandSourceStack > context ) throws CommandSyntaxException {
20+ public int run (CommandContext <CommandSourceStack > context ) {
2221 CommandSender sender = context .getSource ().getSender ();
2322 Entity executor = context .getSource ().getExecutor ();
2423
Original file line number Diff line number Diff line change 22
33import com .mojang .brigadier .Command ;
44import com .mojang .brigadier .context .CommandContext ;
5- import com .mojang .brigadier .exceptions .CommandSyntaxException ;
65import de .pascalpex .pexnpc .events .listener .NPCClickListener ;
76import de .pascalpex .pexnpc .util .MessageHandler ;
87import io .papermc .paper .command .brigadier .CommandSourceStack ;
1413
1514public class InspectSubcommand implements Command <CommandSourceStack > {
1615 @ Override
17- public int run (CommandContext <CommandSourceStack > context ) throws CommandSyntaxException {
16+ public int run (CommandContext <CommandSourceStack > context ) {
1817 CommandSender sender = context .getSource ().getSender ();
1918 Entity executor = context .getSource ().getExecutor ();
2019
Original file line number Diff line number Diff line change 22
33import com .mojang .brigadier .Command ;
44import com .mojang .brigadier .context .CommandContext ;
5- import com .mojang .brigadier .exceptions .CommandSyntaxException ;
65import de .pascalpex .pexnpc .PexNPC ;
76import de .pascalpex .pexnpc .util .MessageHandler ;
87import io .papermc .paper .command .brigadier .CommandSourceStack ;
98import org .bukkit .command .CommandSender ;
109
1110public class ReloadSubcommand implements Command <CommandSourceStack > {
1211 @ Override
13- public int run (CommandContext <CommandSourceStack > context ) throws CommandSyntaxException {
12+ public int run (CommandContext <CommandSourceStack > context ) {
1413 CommandSender sender = context .getSource ().getSender ();
1514
1615 PexNPC .getInstance ().reload ();
Original file line number Diff line number Diff line change 1818public class PacketReader {
1919
2020 Channel channel ;
21- public static Map <UUID , Channel > channels = new HashMap <>();
22- public static Map <UUID , Boolean > clicking = new HashMap <>();
21+ public static final Map <UUID , Channel > channels = new HashMap <>();
22+ public static final Map <UUID , Boolean > clicking = new HashMap <>();
2323
2424 private static final String PACKET_INJECTOR_NAME = "PacketInjector" ;
2525
26- public void inject (Player player ) throws NoSuchFieldException , IllegalAccessException {
26+ public void inject (Player player ) {
2727 CraftPlayer craftPlayer = (CraftPlayer ) player ;
2828 ServerGamePacketListenerImpl serverConnection = craftPlayer .getHandle ().connection ;
2929 channel = serverConnection .connection .channel ;
Original file line number Diff line number Diff line change 1010import org .bukkit .event .Listener ;
1111import org .bukkit .event .player .PlayerJoinEvent ;
1212
13- import java .util .logging .Level ;
14-
1513public class JoinEventListener implements Listener {
1614
1715 @ EventHandler (priority = EventPriority .HIGHEST )
@@ -24,11 +22,7 @@ public void onJoin(PlayerJoinEvent event) {
2422 }
2523
2624 PacketReader reader = new PacketReader ();
27- try {
28- reader .inject (player );
29- } catch (NoSuchFieldException | IllegalAccessException e ) {
30- PexNPC .logger ().log (Level .SEVERE , "Could not inject the PacketReader!" );
31- }
25+ reader .inject (player );
3226 NPCSender .sendNpcsToPlayer (player );
3327 }
3428
Original file line number Diff line number Diff line change 1212
1313public class Config {
1414
15- public static File configFile = new File ("plugins/PexNPC" , "config.yml" );
16- public static FileConfiguration config = YamlConfiguration .loadConfiguration (configFile );
15+ public static final File configFile = new File ("plugins/PexNPC" , "config.yml" );
16+ public static final FileConfiguration config = YamlConfiguration .loadConfiguration (configFile );
1717
1818 public static void load () {
1919 try {
You can’t perform that action at this time.
0 commit comments