#help-development
1 messages · Page 1860 of 1
Anyone? Still getting same issue.
Bruh I cant get it to compile and am too lazy, Can someone compile for me and i will send u like $5, dm
Should just be able to cancel the event
What you trying to Compile?
I updated the API it calls to for this https://github.com/FoldedLettuce/Hyper-Minecraft-Auth
Fr just need to compile exactly whats on it github into a jar
Just click the spigot link and download?
no no no, Thats an out of date download
I hired someone to make the og plugin and lost his contact, I was able to update API myself as its fr just changing from "V4" to "V6"
I stopped using the spigot build thing. I’ve just been downloading the spigot jar then creating the bat file to run it
You can look up what the bat file should look like
Just need someone who can recompile it for me and will gladly throw you like $5.
I just don't know how to, Don't understand the guide, and am honestly too lazy to 😂
What IDE r u using @quaint mantle
Is it maven or Gradle?
no clue
I just want to honestly have someone compile it for me and i will pay u
Does it have a pom.xml or a build.Gradle
none
I would but I’m not on pc :/
You can look at the github with the source https://github.com/FoldedLettuce/Hyper-Minecraft-Auth
You want someone to give you a fish rather than learn how to fish?
I would but I’m not home
You can observe the code and learn from it
Honestly never gonna have to update it for a while, It would still be working right now but they changed the endpoint. No real interest in learning java.
Bet just shoot me a dm
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
How can I make a horse completely uncontrollable?
I'm adding custom controlling behavior but it's somewhat conflicting
Even after overriding its ControllerMove, it still walks and stops weirdly
not sure how to answer that
if you don't want the game to control the horse, disable its AI and then use your code to make it move how you want it to?
Even after removing all custom and manual control, it still acts weirdly
it could be more of a client side thing then a server side thing
Odd, I'm using the same exact code to control other entities and it works
most other entities are not by default ridable either
I might have to make a lockable movement controller 🤔
it could be that the client is sending packets as if its the player making it move but really its not. I would have to look more in the code, but this could be the reason you are having a hard time keeping it from moving
heyo, im new to the server and have been really interested in coding plugins. ik u guys probably get annoyed by all the newbies lol, but i have basic java knowledge. i figured hey, why not practice my coding through something that i enjoy playing!
ive watched several tutorials, looked through the api, went to the spigot website, but i cant seem to grasp any of it... more of me just looking at a blank project with the spigot library referenced
What have you tried so far?
does anyone have any tutorials for beginners?
i made a small plugin that says "hi!" when i enter the command "hello" as op
I have three
block shuffle, i know it already exists, but i would like to make my own version with a few tweaks and stuff
then one where if any of the players in a multiplayer world die, all of the players die. like a hardcore thing kinda
and the other one was you explode if you're touching grass
block shuffle
just because something already exists doesn't mean you can't attempt to make one yourself
yeah:)
I don't entirely remember what block shuffle is
i can give u a brief description
Wasn't it that thing where each block had its own drop?
Stand on the specified block or die.
yup
It's gets faster every new block
Ideally we want something simple to start with
would the explosion one be simpler?
Simplicity is up to you.
the lag, i assume, would be insane no?
Not necessarily
hmm okay
getting info on the players
where are they standing? on what type of block?
Isn't that a bit easier to handle when a player moves across blocks?
Doing that on a timer seems wasteful
that is true'
But make sure it only checks when a player moves across blocks
so every time a player moves, check what new block it's on
Otherwise you'll waste performance checking blocks multiple times
yeah
okok
easiest way to do block shuffle is to first design a way to set the playing field or boundaries of the game. Once you know the boundaries you know all the blocks in said boundary. Then depending on you want to make the game floor, you keep a list of all the approved blocks allowed to create the floor. You would hold this in a map so you can reference it. Then its just a matter of randomly choosing in that list the blocks that players need to stand on or not stand on and then check all players in the field which blocks they are on. As the game goes through you just remove from your map the blocks in the game. All the rest of the code will just be to either add some features or block players from cheating like being able to place a block XD
This guy barely knows what a listener is, let's not get into minigames :)
lol
@EventHandler
public void onMove(PlayerMoveEvent e) {
if(e.getTo().getBlockX() == e.getFrom().getBlockX() && e.getTo().getBlockZ() == e.getFrom().getBlockZ()) return; // if the player hasn't moved from the block it won't run the code below.
Player p = e.getPlayer();
Location l = p.getLocation();
if(l.clone().subtract(0,1,0).getBlock().getType() == Material.GRASS_BLOCK) {
// l.getWorld().spawnExplosion()
}
}
```written on my phone, pseudo code.
how do i get the dimention a player is in
yeah, i can do System.out.println pretty easily tho haha
Yapper, we're trying to help someone, not spoonfeed
dimension is just the world. So Player.getWorld()
oh thx
You help in your way I'll help in mine. Some people learn from reading code.
thanks, but honestly i have no idea what im looking at lol
also your code doesn't account for falling into grass
so i'd unfortunately be copy pasting
But still
while you want to be helpful in that way @stone sinew it is probably first best that we get them on a path to learning the basics/fundamentals first before showing code like that since they are new, very new.
Pseudo code****
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Have a read, let me know if you don't understand anything in specific
Method name and what event is being accessed. PlayerMoveEvent
Checking if the player has moved to a different block via x and z coords. You can add y coord too but others will just complain that it's missing instead of just adding it lol
Setting variables for player and their location
Checking the block below the player if it's a grass block.
Spawn an explosion.
so if i do event.getPlayer.getWorld.getName it'll return overworld, nether, or end
Not quite, it will return the world name. World type is different
World.getEnvironment().name()
ok thx
it will return which ever world the player is in correct
getName() is if you need the name of the world, getWorld() if you need that world's object
?jd
if you need to look at some java docs where you can search
if (nbtFile != null && backupNbtFile != null && temporarySwapFile != null) {
temporarySwapFile.delete();
backupNbtFile.save();
if (!backupNbtFile.getFile().renameTo(temporarySwapFile)) {
throw new IOException("Failed to rename backup NBT file.");
}
if (!nbtFile.getFile().renameTo(backupNbtFile.getFile())) {
throw new IOException("Failed to rename base file to backup file.");
}
if (!temporarySwapFile.renameTo(nbtFile.getFile())) {
throw new IOException("Failed to rename temporary file to base file.");
}
temporarySwapFile.delete();
}
Is this a good way to swap two files? I've had issues that nbtFile can get corrupted, and I think this way swapping the two files should fix that. Or is this bad?
NBTFiles depending which ones can become corrupted when you assume it is not being used
alright dude
that makes a little more sense
@echo basalt so i read it through, makes sense
this is what im thinking.
set up the listener for PlayerMoveEvent()
best way to do swaps is to not delete anything. Instead just copy and rename
this way, if something goes wrong and needs to be corrected outside of the application, the files are there to do so
nvm not sure haha
not too far off
you will need that event for sure
but there will be others you need too. You can put multiple event methods into a single listener just fyi however you can also have multiple listener classes to organize code easily 🙂
Which web-hosting application for Ubuntu would be recommended?
...Apache2, NGINX, or a better alternative to the both?
i prefer NGINX
Apache2 or Nginx. Either or is fine just mainly down to preference unless there is something very specific you need from one or the other
but apache is easier to start with imo
man i wish i understood what that meant
Well I am just deleting the temp file after it has already been renamed again, otherwise I'd always have to have 3 files
technically you should always have them anyways. Backup of the original, file that is intended to be used and then final file. If you don't want it like that, I mean that is fine it is your plugin. Just pointing out that from a SysAdmin perspective is super handy and nice when needing to do something out of the application it is technically possible/doable because all the files are there.
More annoying when the application needs to create said files, but it is the thing failing XD
if this is just a personal project, I mean do whatever but if its a public plugin or something intended for others then probably best you look into that
Yeah sure, I know what you mean
I was more or less just trying to replicate what minecraft does with its level.dat
it also only has level.dat and level.dat_old
and iirc it also just has a temp file it deletes
I think this should fix the file corruption issue anyway, even if it's not 100% the best solution
can any of u vc? i feel like i can learn a lot better like that
i have no idea what i can do in return, maybe i could cashapp u like 20 bucks? idk
I made a plugin with Spigot API 1.18.1 will it support 1.18 as well as older versions?
Hello I am trying to add bstats into my plugin. Just a question, should the name of the plugin i give in bstats.org and the name in my plugin.yml be same?
I had made a plugin for spigot that disables the "Illegal characters in chat" message, now it's saying "illegal characters in chat (charcode)," is the latter from bungeecord?
are you running a bungee server?
If it worked prior to installing bungee its gonna be on bungee's end then
ok then
?
Thanks no wonder why its not updating
Should just have to define it in the metrics class (whatever id it is)
I have a null pointer in here and I cant seem to find it
public class OneRingUse implements Listener {
@EventHandler
public void RingPickup(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (event.getAction() != Action.LEFT_CLICK_AIR & event.getAction() != Action.LEFT_CLICK_BLOCK & event.getAction() == Action.RIGHT_CLICK_AIR) {
if (player.getItemInHand().hasItemMeta() & player.getItemInHand().getItemMeta().hasLore() & event.getPlayer().getItemInHand().getItemMeta().getLore().contains(ChatColor.WHITE + "The Precious")) {
player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 25*20, 0));
}
}
}
}
well the npe will tell you the line
if I had to guess getItemInHand is null, only one I can guess that
I thought getItemINhand couldnt be bull since it would return air?
oh wait thats type
nvm
One more question. Should i always code in the latest spigot api?
how do I know what minecraft versions my plugin supports
Not sure if this is the right place to ask but I'll preface this with I am pretty new to Java and spigot coding but i've been leaning over the last year how this all works. I'm working on upgrading an old plugin to work with 1.18 but it uses alot of NBT reflection methods instead of NMS directly and so alot of console errors are occurring. It was originally coded for 1.13 if that helps. Also, would it matter if I am coding in Java 16 in intelliJ or should I force it to use java 17 to compile? I already had to change an async task to a main thread task since getEntities won't work on an async task anymore. DM me if you can help 🙂 Thanks.
Does anyone know why this issue is happening? The key set inside of the log file is XXX because it's my gpg private key.
i dun like to download those lol
why would you build 1.8 lol
to get the nms
for both programming and running a server: Yes
jdk is what i meant
the latest jdk includes more stuff than say 1.8
like the String#repeat method
i like the most
records
so basically there is no downside to using the latest jdk besides a small size increase
But that also probably comes with a small performance increase
^
*when running the server
For development there is not much of a benefit.
Unless you are speaking about compiler optimizations
and more methods?
I assume the compiler has also gotten smarter
it has
string + string + string wasnt optimized pre 1.7
try {
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "setlevel "+k.getName()+" "+level;
Bukkit.getServer().dispatchCommand(console, command);
}catch (NullPointerException exception){
System.out.println(Bukkit.getConsoleSender());
System.out.println("setLevel "+k.getName()+" "+level);
}```
This (every time), is printing out
```org.bukkit.craftbukkit.v1_8_R3.command.ColouredConsoleSender@199de05a
02.01 15:30:02 [Server] INFO setLevel Yoursole 24```
instead of running the command. This is because FOR SOME REASON it is throwing a nullpointerexception, but like - as you can see im printing out both components and neither are null.
this is the error if it isnt caught:
02.01 15:34:00 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:152) ~[patched.jar:git-PaperSpigot-"4c7641d19"]
02.01 15:34:00 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:666) ~[patched.jar:git-PaperSpigot-"4c7641d19"]
02.01 15:34:03 [Server] INFO at me.yoursole.kitpvp.Kits.Archer.entityDamageEntity(Archer.java:274) ~[?:?]
02.01 15:34:03 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_292]
02.01 15:34:03 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_292]
02.01 15:34:03 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_292]
02.01 15:34:03 [Server] INFO at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_292]
02.01 15:34:03 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[patched.jar:git-PaperSpigot-"4c7641d19"]
02.01 15:34:03 [Server] INFO ... 23 more```
line 274 where it says the error is is this line:
Not spigot, also 1.8
Bukkit.getServer().dispatchCommand(console, command); ```
😬
That’s paper
class is the same tho
the ConsoleCommandSender
which is what im having an issue with
its the same class with the same implementation
?paste the error
^
What line is Archer.java 274
Bukkit.getServer().dispatchCommand(console, command);
and like i said
neither console or command are null
because
this```java
try {
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "setlevel "+k.getName()+" "+level;
Bukkit.getServer().dispatchCommand(console, command);
}catch (NullPointerException exception){
System.out.println(Bukkit.getConsoleSender());
System.out.println("setLevel "+k.getName()+" "+level);
}```
prints
02.01 15:30:02 [Server] INFO setLevel Yoursole 24```
which shows both are certainly not null
lmao
@young knoll
yea
its working perfectly fine
for everything else
also it wouldnt throw null would it?
Then run it on modern java to get the better stacktrace
Which will actually tell you what’s null
I assume setlevel is a registered command
That may be it
Does anyone here know how the hell permission nodes work? (Creating them)
Explain
If you have a certain permission nopde then you can type a certain command
If you don't have the permission node then you can't
what’s the best way to continuously perform a task if a player is not within a specific region of a block. There could potentially be many of these blocks. This also integrates with world guard regions if that makes things easier (I am currently using flag changes but I don’t want to create lots of regions)
Look at the wiki page for plugin.yml
All permission stuff is there
Does minecraft support RGBA for color codes? Or is it strictly RGB.
does anyone have a resource for understanding how .spawnParticle works
in terms of the parameters and their meaning
hello how can i do so if an event is triggered in one class it calls an event in another class
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Here's a pretty good resource.
https://www.spigotmc.org/threads/comprehensive-particle-spawning-guide-1-13-1-18.343001/
ive seen this one but unfortunately it doesnt have what i need
its like
i want to make an implosion effect
so i guess have particles travel in from a point
and then i have a method to create a circle of particles, but i want them to shoot out from their starting point
is there a way to spawn them with vectors or something with the offset?
Perhaps this one is more aligned with what you want.
https://www.spigotmc.org/threads/rotating-particle-effects.166854/
somewhat, but the thing i need wouldnt need more than one call if something like that exists
i feel like if theres a way to manipulate the offsets then i can do it
Thought so, but just wanted to make sure. Do you know of a way to get a darker or lighter value from RGB while still maintaining the original color? Or if there is a simple way to calculate it?
IIRC, there are only a couple particles that have the ability to move from one point to another. The VIBRATION particle is one of them, but is still a mystery to me.
Otherwise, you'd have to spawn multiple particles and have them despawn at the time the next particle appears.
whats vibration even
Vibration is a particle that came with 1.17. The skulk sensor uses it.
is there player inventory update event?
fires when made changes to player inventory? pickup/drop/get item in chest/commands
anyone?
InventoryClickEvent?
doesnt fire when pickup/commands
There's the PlayerPickupItemEvent, but what do you mean by commands?
Well creative mode has it's own event. InventoryCreativeEvent as for a give command, I'm not aware of any event that fires for that.
checking player inventory every tick works just fine, who needs efficiency anyways...
.
@quaint mantle I thought you wanted to call a method. I misread
why do you want to call an event in another class?
if i were you i'd create a method and put the code there, and if one of the events called, run the said method
yeah i will try that
thanks
well the first two are similar, the last one is different
the first two, one takes a Runnable as an argument the other takes a Consumer
nvm im so dumb
Thank you, I made the permission nodes work but when someone who doesn't have permission to the command tries to type it it show up as white like you can type it, (The command won't actually work tho) How would I change this?
Did you set the commands permission in the plugin.yml
Yes
Because iirc that should stop players from seeing it as well
If not you can remove it in the PlayerCommandSendEvent
Could I do this in LuckPerms?
Do what
See the permission part of commands https://www.spigotmc.org/wiki/plugin-yml/#commands
It does state “This permission node can be used to determine if a user should be able to see this command.”
Does anyone here unload and delete minigame worlds? I get these errors and afaik spigot doesn't have a way (at least rn) to tell minecraft to stop trying to save these deleted worlds
My next step is making like worlds that never really get deleted until shutdown of the server. Which would be annoying and I'd basically have a huge amount of files creating over time
Bukkit#unloadWorld
Yes
some minigames require modifying the terrain, easy way to allow that and reset easily is to have a master world that gets copied, loaded and then ultimately deleted afterwards 🙂
I still don't get it
I'm using this but still it tries to save the world later on
How can I reload my plugin,Not all server
Whats wrong with this code -
// triggers when a player vanishes and is online
public void onVanish(PlayerHideEvent event) {
Bukkit.getPluginManager().callEvent(onPlayerLeave());
}```
I'm getting this error -
```'onPlayerLeave(org.bukkit.event.player.PlayerQuitEvent)' in 'com.beans.simplejoinmessages.events.joinEvent' cannot be applied to '()'```
and idk what that means. help pls
I can't found reload in PluginManger
You can disable the plugin then enable it
no parameters?
dunno
But disenable isn't let the plugin close?
that's gonna be the worst thing ever lol
What do you mean?
Does the plugin being disabled cause the enable to not be executed?
Yes, the plugin will be disabled if the enable cause error
I still really don't get it, Please help
?jd
what why?
as long as you handle stuff appropriately in onEnable to initialize properly it shouldn't be an issue doing it this way o.o
I can't use this in Apart from main class
How can I solve this problem?
package command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class command implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
this.getPluginLoader().disablePlugin(this);
this.getPluginLoader().enablePlugin(this);
return false;
}
}
How to change /login password without being logged in on the UserLogin Plugin
Connect to the database and change the proper values.
Have you registered the command in the main class?
You'll probably have to contact the owner of the server. I doubt that the plugin creator would leave a way for members to reset their password without being logged in.
public void onEnable() {
this.getCommand("et reload").setExecutor(new command());
console(ChatColor.AQUA+"[Spigot-ExpTech] Spigot_ExpTech Loading! Version: "+vername);
}
Can I import main class to command class then do reload in main class?
Your command should be a single nospace string.
this.getCommand("et reload").setExecutor(new command());
should be
this.getCommand("et").setExecutor(new command());
Then in your plugin.yml, make sure you have et as one of the commands.
name: Spigot-ExpTech
version: 22w01-pre1
author: whes1015
main: Spigot_ExpTech_whes1015.whes1015
commands:
et reload:
description: reload ExpTech Plugin
usage: /et reload
permission: exptech.admin
so I can use any command with space?
Well, that could work in theory, but it's definitely unconventional. Usually people only put the base command in their plugin.yml and handle the subcommand logic in the command class.
I'd recommend changing it to just et and update your code accordingly.
got it
I'm not sure what that is.
this isnt even related to help server, nor the help dev, so please dont ask it here
I can’t operate any instances related to the server, these don’t seem to be in the command class
From what I can find it's a flag used in your startup script. I have no clue what it's purpose is or the functionality it provides. Could you explain why you need it?
Wdym?
?
What do you mean in your last post? I was confused interpreting it.
There isn't server optins after this.
I am new to java,Sorry
Again, wdym by server options? Are you referring to the tab completions? Or something else?
this.getPluginLoader().enablePlugin(this);
It's error without main class
Oh
You need to pass an instance of your main class (that extends JavaPlugin) as the parameter for #enablePlugin().
You can pass an instance with Dependency Injection.
Your code is trying to enable the plugin with a command class instead of your main class which extends JavaPlugin.
That's why it would work in your Main class, but not any other.
Because the this keyword refers to the class command. (In that context)
Also your class names should be UpperCamelCase.
How to solve it
!
package command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import Spigot_ExpTech_whes1015.*;
public class command implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
this.getPluginLoader().disablePlugin(this);
this.getPluginLoader().enablePlugin(this);
return false;
}
}
Dependency Injection or you can use the static plugin getter from JavaPlugin.
Just di
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Dependency Injection is the way to go for commands, but if you have enums or something that can't take in constructor parameters, you could use JavaPlugin#getPlugin(Class<T> clazz)
you shouldnt use plugin in enums or any other static context 🙂
Really? Cause I do that so I can replace variables in my configs. For instance, I have a Messages enum that contains all the message paths in my lang file. Once I get the path, I replace things like %prefix% and return the fixed string. This way I don't have to repeat myself constantly. This isn't possible without that instance though.
Is there any example?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Yes. Enums for configs is not a good idea. At the first place, enums should not have any mutable state. At the second place, enums are in static context, while plugins and configurations arent. I would recommend you to separate responsibilities - make your enum to just hold keys and create a config class.
Config config = new Config(plugin, file);
String value = config.getString(MyEnum.PREFIX);
https://github.com/A248/DazzleConf
I'd suggest using this library if you want type-safe configs, it has pretty interesting concepts
uhhh nice stuff there
[16:40:12] [Server thread/ERROR]: Error occurred while enabling Spigot-ExpTech v22w01-pre1 (Is it up to date?)
java.lang.IllegalArgumentException: Plugin already initialized!
package command;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public class command extends JavaPlugin implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
console(ChatColor.RED+" "+sender);
console(ChatColor.RED+" "+command);
console(ChatColor.RED+" "+label);
console(ChatColor.RED+" "+args);
this.getPluginLoader().disablePlugin(this);
this.getPluginLoader().enablePlugin(this);
return false;
}
public void console(String data){
Bukkit.getConsoleSender().sendMessage(data);
}
}
Only ONE class can extend JavaPlugin
Please learn java
read the di link you've been given multiple times
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
how do I know how many hunger food gives
i think nms has all those values ^^
nms?
net.minecraft(.server)
Hey 🙂 I have trouble using the onLoad method...
I tried ` @Override
public void onLoad(){
}`
But it seems to not work
public void onEnable()
you want to use this method for what ?
I'm using the NBT Api
And I need to inject it on onLoad method
But I'm gonna try with onEnable
u mean on plugin startup?
onLoad() happens before onEnable() and there is some things unavailable from the onLoad() depending when that happens. Most of the time that happens during server startup. Generally you are fine and will want to use onEnable().
"Please enable it during onLoad with NBTInjector.inject(); if you are using it!"
That's what the plugin says
idk, just try it onEnable
And it looks like it's not working on the onEnable method
any errors in log ?
de.tr7zw.nbtapi.NbtApiException: The NBTInjector has not been enabled!
You need to call 'NBTInjector.inject()' during the Method 'onLoad' of your Plugin! Check the Wiki/Pluginpage for more information!
did you add a depend in plugin-yml ?
Yes, only the NBTAPI
right version ?
Yes sir
if you use inject onLoad ... can you send your log ?
Like onEnable
onLoad is onEnable but running earlier
Override it
it works the same way as onEnable()
just note that it might be running when no worlds are loaded
just you can't make use of everything in onLoad() typically. If you need to use it, then do so lol
there is nothing special with onLoad --- it just gets called before onEnable
Well there are a few critical timing differences, so you can't substitute it
It's not working, I still have the error in console
@Override public void onLoad(){ NBTInjector.inject(); }
error ?
de.tr7zw.nbtapi.NbtApiException: The NBTInjector has not been enabled! You need to call 'NBTInjector.inject()' during the Method 'onLoad' of your Plugin! Check the Wiki/Pluginpage for more information!
I'd check their API docs honestly
you could debug the onLoad (with System.out) and check if gets called
depends on what he did ... if he has 2 JavaPlugin extended ^^ xD
Yeah, but honestly it not getting called is unlikely except if the old revision is still there
Oh I feel stupid
Important note regarding Tiles/Entities Starting with 1.14+ you can use the getPersistentDataContainer() (for NBT(Tile)-Entity's) to save custom tags. This replaces the now mentioned NBT-Injector.
how can i take as paramter only objects that are instance of class with specific annotation present?
for what do you need this ?
public void method(@NotNull Object o) is the de-facto standard way, but it is not enforced by javac and is also not enforced by the JVM
scheduler.scheduleSyncRepeatingTask(plugin, () -> {
Collection<? extends Player> onlinePlayers = plugin.getServer().getOnlinePlayers();
for (Player player : onlinePlayers) {
System.out.println(player.getPlayerListName());
}
}, 20L, 0L);
```smh instead of this running every second, it runs every tick...
As far as I know there is no real way of knowing whether an object is annotated, except if you know that the class the object comes from is annotated
20 is delay and 0 is time between runs
you should use 0 for delay and 20 for time between run
oh ok
?jd
The javadocs are your friend
yes, ive read them, but I thought it was delay after running each task
and period i have no idea what its for
delay the ticks to wait before running the task for the first time
period the ticks to wait between runs
ofcourse im blind
me writing javadocs goes brr
I stopped writing javadocs for my own projects after realising that noone is going to use them and that I spend far too much time with them
code which javadocs can look so big while there is actually not much code
i hate writing explanations at all ... xD
And sometimes there is no code attached at all:
/**
* Obtains the name of the color-independent texture.
*<br/>
* This method used to return a {@link NotNull} value, however
* this was an error as the only class implementing this interface can indeed return null values here.
* A null value should be treated as no no-col texture, but this does not mean that {@link #getTextureName()}
* is not applicable.
*
* @return The texture name that is independent of color
*/
public @Nullable String getColorlessTextureName();
Well, actually it is most of the time. I only really bother writing javadocs in interfaces as I always expose the API via interfaces
Yes, it's the same method actually
i just saw that
A HashSet is a glorified HashMap
yes. Contains Key is fast enough
and can a hashmap contains duplicated key value pairs?
ah it cant
i was looking for a boolean method like HashSet#add
but in a hashmap
if you need something to store a Key with more then 1 value you kan use a MultiMap
https://cdn.discordapp.com/attachments/825713160988262470/926931314588926012/unknown.png
why does this show up when i try to run my server with my plugin
I prefer my Map<K, List<V>> instead
Do you have a plugin.yml in your plugin jar?
?stash
ehh does Map#put returns the old value if there is one and overwrites it?
or null if nothing was mapped to that key
yes
That is the API contract. If you do not want to overwrite, you can use #putIfAbsent
so i could check for presence with put(key, value) != null?
yes, though beware that it overwrites the old value
Though if you allow for null values things might change by a bit
i get this error when i load the plugin, can anyone help?
public class RankExpireEvent implements Listener {
private TWCore TWCore;
public RankExpireEvent(TWCore TWCore, LuckPerms api) {
this.TWCore = TWCore;
EventBus eventBus = api.getEventBus();
eventBus.subscribe(this, NodeRemoveEvent.class, this::onUserExpire);
}
private void onUserExpire(NodeRemoveEvent e){
String name = e.getTarget().getFriendlyName() + " ";
String rankName = e.getNode().getKey() + " ";
Player p = (Player) e.getTarget();
p.sendMessage(TWCore.prefix + ChatColor.LIGHT_PURPLE + name + ChatColor.GRAY + "the rank" + ChatColor.AQUA + rankName + ChatColor.GRAY + "expired.");
}
}``` this is the code
tried asking on the luckperms ds server but no one answered lol
Try eventBus.subscribe(TWCore, NodeRemoveEvent.class, this::onUserExpire); instead
Also, you really shouldn't name your variables like classes
So TWCore becomes tWCore at worst
i changed but i get this
Does e.getEntity() (e is an EntityDamageEvent) get the victim?
impossible
that method cannot know that RankExpireEvent exists
let alone have an instance of it
wait now it works
Read the API docs next time, I feel like you can easily avoid this problem
How can I fix this
i get another error, but thank you!
How do you build the plugin? Via mvn package or gradlew build or something else entirely?
gradle
So you don't use CLI at all?
that means that the plugin.yml is invalid, show the rest of the error then
import it 😐
wdym
Also include craftbukkit and not only net.minecraft in your build?
i am a noob btw
There should be something under https://cdn.discordapp.com/attachments/825713160988262470/926931314588926012/unknown.png
when I import it what do I type after import
no
that was it
send your plugin.yml then
Makes sense given that the code that throws the exception is
jar = new JarFile(file);
JarEntry entry = jar.getJarEntry("plugin.yml");
if (entry == null) {
throw new InvalidDescriptionException(new FileNotFoundException("Jar does not contain plugin.yml"));
}
?paste i mean
so this time spigot does not lie, there really is no plugin.yml
Which means that the way you are building the plugin is incorrect
(could also point to a nonstandard build.gradle)
Could you show your pom.xml or build.gradle file?
ok
Trying to make custom damage system, what is wrong here? (No error is logged, but the event isn't run)```java
public class EntityDamage implements Listener {
public void onEntityDamage(EntityDamageByEntityEvent e) {
if (!(e.getDamager() instanceof Player) || e.getEntity() instanceof Player || !(e.getEntity() instanceof LivingEntity)) {
return;
}
e.setCancelled(true);
Player player = (Player) e.getDamager();
LivingEntity reciever = (LivingEntity) e.getEntity();
PlayerStats stats = Main.instance.playersStats.get(player);
float unroundedDamage = stats.totalStrength/5;
int damage = Math.round(unroundedDamage);
reciever.damage(damage);
}
}
name: NewItemplugin
version: 1.0
main: newitemplugin.newitemplugin.NewItemplugin
api-version: 1.17
commands:
givewand:
description: Gives our custom item to the player.
usage: /<command>
That miencraft-server artifactId is a bit sus
odd that looks fine
But I do not know enough 1.18 NMS to know a bit more
spigot-api with 1.14 but minecraft-server? and 1.17 then ?
As I said before, the plugin.yml literally does not exist. which means that something is excluding it in the build
^ this should do the job
so what do i do + this is my first making a plugin so pls help me
Unzip your plugin jar
are you using maven or gradle?
gradle
gradle
ok then?
Then check if the plugin.yml is present, that should narrow it down a bit more
any gradle stuff/plugins that could be excluding the plugin.yml fomr the jar?
where do i find it
in your project root dir
okay, then you are not using gradle and you are using the builtin intelliJ build feature (or JDT)
Which would explain it
plugins {
id 'java'
}
group = 'NewItemplugin'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
}
def targetJavaVersion = 16
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
so?
Ok I did the java -jar BuildTools.jar --rev 1.14.4 --remapped then what do I do
You are talking to me or?
yes, mojang mappings are a relatively new thing and it's only really since 1.17 that they are employed
so 1.14.4 won't work with it?
What do I do?
correct, though you will have the god forsaken spigot mappings at your disposal then
I think I will just change the version and do it again
Wdym
just some preemptive assumptions that ended up being wrong
Ok so what do I do?
wait maybe I found a solution but another problem appeared
You cannot have interop between 1.14 spigot mapped spigot and the 1.17 mojang mapped vanilla server
Can someone help me
I sadly have not enough gradle knowledge to address your issue, removing the processResources task might help, but that would be a bodge
Do you have the file in the right spot
all roads go to maven
What does that mean?
in the end you will get fed up with gradle and just move to maven because there if something works, it tends to work for a long time
Btw I made it maven but it had the same error
that is highly interesting
how do i convert array of strings to array of objects? (no loop)
String[] sarr = new String[] {};
Object[] oarr = (Object[]) sarr;
the cast is actually redundant
it don't work as i want, it still throws array type mismatch exception when i add object of another type
i want object array to hold multiple types to invoke method with arguments
then you'd need System.arrayCopy
will this return true?
no different than return isMuted;
or will it only return true if it was able to change ismuted to true?
it is also an assignment, so I am not sure if it returns the new value
But it could very well return the old value which honestly makes more sense
it prints true if it was false before
as yes an assignment
back, so is there a solution to this or should I just change the version
two times true
how can i check if a player is mining a block?
Do you know someone that can help me
Could you send us your jar?
Sure
im dying
I think I will just change my version to the latest
geol
Yeah, you are using IntelliJ / Eclipse JDT to build the jar
Use Gradle (./gradlew build or gradlew.bat build) to build the jar
wdym
Should I use 1.17 or 1.18?
1.17 is EOL on almost all plattforms
hello?
So should I use the newest version 1.18?
Ideally yes
ok
where do i use it?
PlayerInteractEvent?
not sure how well it fares with 0-tick breaking
there's only left-click block, the closest i can think of
CLI? IntelliJ and Eclipse have dedicated ways of automating it for you, but the risk is too high that you do it wrong
Should I use a newer one?
Use 17
So I recommend using the terminal to build the artifacts
ok
Java 16 is also a favourite of mine
but given that 1.18 is J17 only it does not matter
ok what write in the terminal?
hi
how to install world edit and world gourd in spigot server
./gradlew build on linux or mac and gradlew.bat on windows
intellij has built in gradle / maven support
So I will just download 17 not 16
on right corner
The chance is too great that they will use the wrong build feature
what do i do?
how to install world edit and world gourd in spigot server
./gradlew.bat build then, windows shell is highly confusing
I think the LEFT_CLICK_BLOCK is the best you can do
it would only fire once though
when exactly does it need to be fired?
the ./ are important
when a player is breaking a block
it needs to fire multiple times
oh let me try
before, after or while?
while
you need to execute it while your pwd is in your project directory
Then sorry, I think that is handled by the client but not too sure
There is no event for it though
I deleted java 8 and downloaded java 17 also changed the path and it still detects java 8 how
you need to replace your environment variables (including, but not limited to java_home)
Yeah I did that
What's the output of java --version?
Also make sure you restart cmd prompt
Ok got it fixed
wdym
?
Basically you need to change your directory (via cd) until you are (as per pwd) in your project directory. I'd just recommend to execute the aforementioned command in the intelliJ terminal
how?
Just use IntelliJ's builtin terminal you use the first time, explaining you the cornerstone of MS-DOS is a bit too much
took me 15 minutes to make this equation
return isMuted != (isMuted = flag);
🥵
instead of writing 4 lines..
Are you really calling that method that often that it makes sense to have it not branched
it doesnt make sense shh
instead of making a mute and unmute method 🥺
As I said beware the ./
But the JIT compile time! \s
idk
wait a moment
🙄
does LEFT_CLICK_BLOCK fire multiple times when in adv mode and breaking a block?
could be, but I doubt it
wait it does
the more we know
how can i make a player able to mine blocks with adventure mode?
what is adventure mode again? when you die you cant respawn?
thats hardcore
No, you can't mine blocks you cannot mine
oh
adventure is where you have to have a block whitelisted to mine it
uhh i dont know about that
basically realistic survival mode
survival mode when you cant break anything nice
geol?
but you can set blocks people can mine
Assuming you built the jar, it should be located under the build/libs folder
thank you so much it worked
get rid of that org.spigotmc:minecraft-server depend if you haven't already
How can I do that
by removing it from you pom.xml. If you already did that then I cannot really help you further with the information I have right now
Its only Enderman
this is a new project now I have this in pom.xml
So what can I do
hey does anyone know what the name of the start mining block and stop mining block packets are?
?
?
?
?jd
now, does anyone have a packets tutorial?
you what?
uhhh how the hell will that help?
i need a tutorial to understand the code
does anyone have a packets tutorial?
uhh is checking if a user is banned from a chatchannel something to do for the channel or the user?
what do you mean?
is that a responsibility for the user or for the channel?
to check if a user is banned
probably wanna code that on the channel
channels are the ones responsible for hooking wit hthe backend db to see who's banned or not
i assume you mean what class you want to code this on
[13:40:24] [Server thread/ERROR]: Could not load 'plugins/CandyLinks-1.0.0-shaded.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:186) ~[patched_1.17.1.jar:git-Paper-400]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:158) ~[patched_1.17.1.jar:git-Paper-400]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:419) ~[patched_1.17.1.jar:git-Paper-400]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:287) ~[patched_1.17.1.jar:git-Paper-400]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1220) ~[patched_1.17.1.jar:git-Paper-400]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-400]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.util.zip.ZipException: zip END header not found
at java.util.zip.ZipFile$Source.findEND(ZipFile.java:1469) ~[?:?]
at java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1477) ~[?:?]
at java.util.zip.ZipFile$Source.<init>(ZipFile.java:1315) ~[?:?]
at java.util.zip.ZipFile$Source.get(ZipFile.java:1277) ~[?:?]
at java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709) ~[?:?]
at java.util.zip.ZipFile.<init>(ZipFile.java:243) ~[?:?]
at java.util.zip.ZipFile.<init>(ZipFile.java:172) ~[?:?]
at java.util.jar.JarFile.<init>(JarFile.java:347) ~[?:?]
at java.util.jar.JarFile.<init>(JarFile.java:318) ~[?:?]
at java.util.jar.JarFile.<init>(JarFile.java:284) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:174) ~[patched_1.17.1.jar:git-Paper-400]
... 6 more
Plugin.yml
name: CandyLinks
version: 1.0.0
api-version: 1.16
main: com.candynw.sync.Main
author: Quzack
commands:
link:
description: Sync your discord and minecraft
usage: /<command>
unlink:
description: Unlink your discord and minecraft account
usage: /<command>
yes
strange, recompile your plugin?
?paste the full error
What's wrong with the plugin.yml, it was working fine.
so, does anyone have a packets tutorial?
recompile your plugin
Nvm I’m blind
Alright.
missing spaces before account
nm, thats discord formatting
Caused by: java.util.zip.ZipException: zip END header not found
would point towards the Jar being corrupted
or the classloader being closed, but I doubt that
Has anyone worked with 1.18 NMS for advancements? I'm really struggling with it and all I want is to display toast notifications. Here's the code I'm working with.
https://paste.md-5.net/asuhuqicun.java
where is your problem ?
Line 75 is where I'm getting an NPE.
hmm your creating an advancementprogress but not set smth ... you just get smth instead
you probably need to use "update" first
Well that got rid of the NPE, but I'm still not getting the toast.
how can I display a line under an npc's name?
i guess by using scoreboard packets but i can't figure it out
probs invisible armorstands, idk
Scoreboard scoreboard = ((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle();
PacketUtils.playPacket(new PacketPlayOutScoreboardScore(
new ScoreboardScore(
scoreboard,
new ScoreboardObjective(scoreboard, "health", new ScoreboardBaseCriteria("health")),
player.getName()
)
), Bukkit.getOnlinePlayers().toArray(new Player[0]));
``` this was my attempt on a player
if (ResultSet#next) will that get the first row if you only call it once?
public static void playPacket(@NotNull Packet<? extends PacketListener> packet, @NotNull Entity... entities) {
Entity[] var2 = entities;
int var3 = entities.length;
for(int var4 = 0; var4 < var3; ++var4) {
Entity e = var2[var4];
if (e instanceof Player) {
Player player = (Player)e;
EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
entityPlayer.playerConnection.sendPacket(packet);
}
}
}
``` this is the playpacket method i use
it could work but the line would be above the entity
also i dont want to spawn extra unneeded entities
ah
A ResultSet cursor is initially positioned before the first row;
The armorstand can be spawned via packets
There is none
You need to figure it out by yourself by looking at the source
Question, how could I get all the bossbars that a player has active ?
Im trying:
for (Iterator<KeyedBossBar> it = Bukkit.getBossBars(); it.hasNext(); ) {
BossBar bar = it.next();
bar.removeAll();
}
But that isnt working.
That will only work for keyed boss bars
So I've got the advancement showing up in the menu, but it's not marked as completed. Which is odd
In basics:
Class<?> craftPlayerClass = ReflectionUtil.getBukkitClass("entity.CraftPlayer");
Object entityPlayer = ReflectionUtil.invokeMethod(craftPlayerClass, player, "getHandle");
Object playerConnection = ReflectionUtil.getObject(entityPlayer, "b");
Class<?> packetClass = ReflectionUtil.getMinecraftClass("network.protocol.Packet");
// Construct your packet
ReflectionUtil.invokeMethod(playerConnection, "sendPacket", new Class<?>[] { packetClass }, new Object[] { packetPlayOutPlayerInfoRemovePlayer });
Ah yeah didnt even notice that <KeyBossBar>whoops
I have a question, can it be that the spigot remapping is broken? Failed to create remapped artifact, project main artifact does not exist.
Mine? Still works for 1.18 😄
Well that part will
But all the fields and methods inside entityplayer have changed
They want to listen for packets, even worse
Since they used to be spigot mapped, now they aren’t
Yup, so I have switches everywhere 😂
My reflection library has a getMajorVersion(), so I have different implementations for >= 1.18 and =< 1.17, etc
I pointed them to Protocollib, should be a lot better for someone with next to no experience
I can agree with that
Any way to get all of them, especially the custom made ones that uses the bukkit api ?
nms very better
meh, nms is a hell to include
protocollib code is a NIGHTMARE
Even better is just adding to the API
i mean, sources
I'm curious, how accepting is the spigot api of this?
i've made a cool class to create packet armor stands in 1.8
like, I'd love to remove all NMS code from my source, and PR it all into Spigot
it works fine after many mental breakdowns
I’m suddenly tempted to look into writing an advancement API
Packets are not api and they never will be 😘
how can i get the targeted block of a player?
getTargetBlock
Correct. But there could be better designed ways. E.g. I use NMS to edit the GameProfile of a Player, this could be added to the Bukkit API I'd say
but I'm not sure if it should be
my enchantment is not registering when I craft an item and I have no clue why java ItemStack is = new ItemStack(Material.GOLDEN_HOE); ItemMeta isMeta = is.getItemMeta(); isMeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD + "Gun"); is.addUnsafeEnchantment(Enchantment.DURABILITY, 20);
I know spigot has a very basic advancement API
Paper has player profile api 😎
That works with raw json strings
Paper does, Bukkit does not, so no use there
are you readding the itemmeta at some point again to the item ?
You are adding it to the item and then overriding it with setItemMeta
Add it to the meta
i hope spigot will die one day
Could also add support for sending toasts with an advancement API
A library for that certainly would be a nice to have, even better to add it to the Spigot API itself
and thus noone does it
They do
I'd be more than happy to 🙂
They just keep it to themselves
I love tinkering with reflection and such
No reflection
if it'd be part of spigot itself not yeah
but as an outside library I'd use reflection to allow backwards compat with e.g 1.17 and 1.16
srry I took so long to respond but thank you :)
I mean you’re always welcome to make outside APIs
It’d be nice if we didn’t have 5000 separate ones thought :p
how can i get the field of a packetevent?
get PacketContainer, pick a structure modifier and read a field with it
a what
how do i sync a texture to my item?
what texture?
so how exactly do i read the field from the packetcontainer?
Still need help with advancement NMS. I've got the Advancement showing up in the menu, but for some reason it's not granted to the player. Is it possible that the impossible trigger changed functionality? This code should have automatically granted them this advancement.
https://paste.md-5.net/firugatico.java
It’s a shame there isn’t just a packet for the toasts
I've been thinking, why is https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/util/io/BukkitObjectInputStream.java#51 using a dedicated method for creating the IO Exception with a cause and why does it use Throwable#initCause instead of passing the cause through the constructor? Is it just legacy java compat or is there something else going on?
so how do i get a value of a field from a packetcontainer?
Probably the wrong place to ask given that BukkitObjectInputStream was last modified in early 2013
I try to get a scoreboard from the scoreboard manager, but then it throws a NullPointerException, because the scoreboard manager is null.
Here is the error:
[15:46:43 ERROR]: Could not load 'plugins\Plugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.ExceptionInInitializerError
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:157) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:421) ~[paper-1.18.1.jar:git-Paper-71]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:285) ~[paper-1.18.1.jar:git-Paper-71]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1202) ~[paper-1.18.1.jar:git-Paper-71]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-71]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:467) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:71) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 7 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.scoreboard.ScoreboardManager.getNewScoreboard()" because "at.theduggy.plugin.Main.scoreboardManager" is null
at at.theduggy.plugin.Main.<clinit>(Main.java:41) ~[Plugin.jar:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:467) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:71) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 7 more
What should i do?
Get a structure modifier for type of field you need and read by index
Geol yeah that looks weird
the worlds are not yet loaded, you can only access the scoreboard manager after worlds are loaded for some reason
So the fact that Bukkit#getScoreboardManager is annotated as @NotNull is a lie under paper
Surprise surprise
spigot correctly annotates it as a @Nullable
Which confused me
but good to know that the javadocs do not lie
Now I also have the urge to fix that weird IO Exception stuff
so like container.getIntegers().getValues().get(0);?
How can i wait till the worlds are loaded
onEnable is usually after world load
yeah
Unless you are using load: STARTUP
Ok thanks
the constructor and the onLoad method are called before world load
I always forget onLoad exists
however it is a bit useless given that you cannot even register event listeners in it
I tryed this and became the same error
OH
You aren't using Bukkit#getScoreboardManager
You never set at.theduggy.plugin.Main.scoreboardManager, should be a trivial "initialize the field" stuff
Yes i do. I first make a variable scoreboradManager and than i get a new scoreboard from it
is getting one row from a db a heavy operation?
I mean
Regardless of number of rows it’s still a database call
Which can take an indeterminate amount of time
hmm i understand
Specially if the database isn’t local
I set it to Bukkit.getScoreboardmanager
perhaps you set it too early?
hey, for getting an int from a packet field, do i use container.getIntegers().getValues().get(0);?
I set it in onEnable() after i saved the config
this is interesting
@quaint mantle so what would i use for the packet location?
You use getIntegers.read
why do people use @FunctionalInterface
However, the compiler will treat any interface meeting the definition of a functional interface as a functional interface regardless of whether or not a FunctionalInterface annotation is present on the interface declaration
and for packet location?
Ok, so update. I'm dumb and wasn't actually granting the advancement to the player. I got confused and was using the wrong mapping. However, even though I fixed that, I'm still not getting the advancement to go through.
Is there any event that fires if two players walks repeatedly back and forth infront of each other?
Highly doubt it. Pretty sure you'd have to make something to detect that.
because Java treats @FunctionalInterface in a way that enforces the requirements of a functional interface on an interface. So basically type checking at compile time. People use them for the same reason they use @NotNull or @Nullable
Cuz of lambdas :D
This is the new project using 1.18 and this is the pom.xml, is it already removed?
I have never used nms really so stop bothering me
Change that scope tag to provided.
If you are trying to use nms, wrong artifactid
Also, have you ran buildtools for 1.18?
Change artifactId to just spigot
ok
Btw if you have run buildtools
You dont need the remote repo
ok
btw
you should always use the remapped .jar
when accessing NMS
otherwise you will get fucked by every update
I am making a plugin where if u right click a specific item it will fire an arrow but so far the arrow is not launching java if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) { Location loc = e.getPlayer().getEyeLocation(); Vector v = loc.toVector(); e.getPlayer().launchProjectile(Arrow.class, v); }
I mean, if you are using craftbukkit
it does launch. but you are using the location as vector, that makes no sense whatsoever
You will still get fucked every update
why would ANYONE use craftbukkit instead of spigot though?
so don't use craftbukkit lmao
To get handles?
you didnt get my point
so should I get the direction and use that for the vector?
spigot remapped will save you from getting fucked on every update
and spigot also includes craftbukkit
no, e.g. use a vector of 0,1,0 to fire the arrow upwards
but cb packages still mutate between versions
Ok so even by using the remapped jar
oh ok
because god knows why
The obfuscation is still different across versions right
so? i didn't say remapped will make your plugin update-proof, I only said using obfuscated mappings fucks you even more
only some of the package names
yes
yea, that's why remapping exists. to avoid this
I dun see remapping avoiding anything
Just making things readable, maybe that is a restriction of maven
okay then you probably just don't understand what it does
it renames all the methods and classes to the name that mojang themselves use
and those of course do NOT change every update
they are consistent
I know that, but it doesnt help in obfuscation process.
I have no idea what you are talking about
how would I make it go the direction the player is facing?
yeah that involves some math 😄 and I am bad at math
same lol
wait
Player.getEyeLocation().getDirection()
maybe you will also have to normalize() it
yes, that should be used as the vector
ok
Ok so now assume you have a program written using the remapped version, this program cannot be obfuscated by the same specialsource version anyways.
I stil l don't get what you mean
Is there something that when I push to github, it will automatically build and put it into Releases?
so use the special source version for your mc version?
My library works on all versions between 1.16.0 and 1.18.1, and I am using remapped for both 1.17 and 1.18 without problems
only had to change one line between 1.17 and 1.18
without remapping, I would have had to change hundreds of lines
Ah ok
oh my bad, I only use 1.18 remapped
but yeah you can just have one maven module per NMS version
Yea i know
and every one uses the matching special sauce thingy
like this right? java Vector v = e.getPlayer().getEyeLocation().getDirection().normalize();
I just wasnt sure why you advocate for the use of remapped when it doesnt really matter.