#help-development
1 messages · Page 74 of 1
is there any chance that my nms 1.15 code will work for a 1.19 client with viaversion on a 1.15 server?
how to check that when they first type? xDD
Server code don't run on the client so yes
declaration: package: org.bukkit.event.player, class: AsyncPlayerChatEvent
this simple line does not work
public boolean getClass(boolean className){
return className;
}```
This is in the main class, I try to access it from another, and I can't? What am I doing wrong
Sorry if I sound stupid, it's early in the morning
?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.
package me.datoeb.gunpowdergoboom;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
public final class GunpowderGoBoom extends JavaPlugin implements Listener {
@Override
public void onEnable() {
recipeFurnace();
}
private void recipeFurnace() {
ItemStack result = new ItemStack(Material.TNT);
ItemMeta im = result.getItemMeta();
im.setDisplayName(ChatColor.GOLD + "Boom");
result.setItemMeta(im);
FurnaceRecipe recipe = new FurnaceRecipe(result, Material.GUNPOWDER);
recipe.setExperience(0);
getServer().addRecipe(recipe);
}
@EventHandler
public void onBurn(FurnaceBurnEvent e) {
System.out.print("Test");
}
}
would anyone care to explain why this doesnt work the recipe does exists but it doesnt print Test with the furnaceburnevent
Please learn Java before doing spigot
You didn't register your event
This used to work. And what do you mean? I have learnt it
No you haven't also it could have never worked before
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Since Java 17 removed the --illegal-access flag, is there any way to achieve the same thing now?
Sounds like xy, what are you trying to actually do?
Generally speaking we want to discourage use of reflection entirely and encourage API contributions instead
anyone know if it is possible to code a minecraft plugin with others (like change the same jar file when we code)
There have been attempts at IDE plugins for that, though I don't know of any that have survived
CodeWithMe in IntelliJ works fairly decent, but its only in IntelliJ. It is limited on what it can do to an extent
plot twist theyre using reflection for non mc stuff
gotta get those unsafe suns 😎
Seems there's one called CodeTogether as well which has extensions for Eclipse, IntelliJ, and VSCode
Saros was the long-standing pair-programming extension for a while but it died a little while ago
how do i kill entities in a 5 block radius of a location
for (Entity nearby : w.getNearbyEntities(furnaceBlock.getLocation(), 5,5,5)) {
nearby.setHealth(0);
}
doesnt work
CodeTogether is quite good, but it did have one issue where you couldn't see the Package explorer
probably fixed now though
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Damageable.html#damage(double) or https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Entity.html#remove()
declaration: package: org.bukkit.entity, interface: Damageable
declaration: package: org.bukkit.entity, interface: Entity
aight bet
i get that you cant use setHealth on a non LivingEntity but i was wondering how would i kill the entity since i cant use setHealth
@compact glen second one
I assume you don't know how to use a javadoc?
well ig so
Basically the link above shows that you can use remove() on your entity
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Check if it's a player/living entity then set hp or damage it
if it's not use remove()
aight
so yea i did that and it still says cannot find symbol at the setHealth(0) part
for (Entity entity : w.getNearbyEntities(furnaceBlock.getLocation(), 5,5,5)) {
if (entity.getType() == EntityType.PLAYER) {
entity.setHealth(0);
}
else {
entity.remove();
}
}
Cast entity to player
Just to be safe you can use an instanceof check instead
i tried using ChatColor. and using the translate alt code and typing in the codes myself, for some reason it keeps making my text go past the item tooltip border, any fix?
I dont know if I have ever actually seen that
my best guess would be the characters on the start/end of it
lore.add(ChatColor.translateAlternateColorCodes('&', "&6&l&kV&6&l LEGENDARY SPECIAL WEAPON &6&l&kV"));
Oh thats what it is
does it not count bold text?
i tried without bolding and it works
but bold text goes past
Thats a weird one lol
Someone else might have a solution, ive never seen an error like that
Maybe it's your client?
If you need to get these things when the player is not online then you probably shouldn't use the pdc for this
any fix
Are you using the normal MC launcher or smth else Kyrok?
I should say client rather than launcher
normal mc
maybe its glitching out with spaces? ill try to do it again with &r before every space
Try without the &k formatted text in it
kk
Thats my only guess tbh
MC version?
Native speakers, do I say "When a player gets teleported" or "When a player is teleported" ?
english is my first language and even I'm not sure
yeah I think the full sentence is needed
Well the full sentence is "Whether to play a sound when the player <word> teleported"
I'll use is than, thank you
The two are interchangeable
Good to know, I thought one would be "more correct" than the other
Yeah, anybody that speaks English isn't really going to be all that pedantic about it. Both are correct to me and I would use either one.
Choco do you mind if I DM you about a forums question or should I send an email?
Depends on the subject lol
name changes :/
If it can, should go as a report
Ah
I mean name change requests are offered to donors (even if it's just $10 or whatever the minimum is)
I know they are allowed in exceptional circumstances, just want clarity on the circumstance
And yes, donors
You can DM me for clarification that's fine, though the request would go in an email because I can't actually change your name
md's the only one that authorizes and performs name changes on the forums
dumb question
;p
oh really
Mhmm
there isn't any admins?
md's pretty much the only admin
thinkofdeath was the only other one but he's not been around since 1.8
Oh wow, I didn't realise. Well then I may as well send an email. Thanks
o/
1.8.8
I also don't know where I found this information a few days ago, because I can now only find information saying it's only available to donors ahah
how do i get the type of a dropped item
for example
if (entity instanceof item && item.itemtype == material.diamond) {}
there’s a method on item entity called getItemStack
oh alright tysm
Hey guys, I'm decently new to Spigot development. I code in C# for work and am picking up Java while developing so actual code isn't a big problem for me. Just wanted to get opinions on storing temporary data during the plugins runtime. I'm making a simple chat plugin and have setup msg and reply commands for players. Currently I hold a GUID, GUID hashmap instance during plugin runtime to track which player each player will reply to when they use the reply command. It works and all, but I can't help but think that if the plugin was run on a server with LOTS of players that the hashmap could chew up a bit of memory. Hashmaps are obviously more efficient than arrays but is storing temporary data like that better to do with temporary yml files so that the plugin isn't using as much memory? Or it doesn't matter that much? Or is there an even better way of holding data like that that I don't know of?
Nope, what you are doing is fine
So long as your reply isn;t rmembered between server boots
Yeah okay cool, cheers. It clears on restarts and is added to and removed from on player join and leave
Also, is it better practice to just read from config file whenever you need values or create class instances that hold config data so you can just inject those sections. I feel like the latter is cleaner, but it would use up unnecessary memory right?
read from Plugin#getConfig() it's held in memory
java.lang.NullPointerException: Cannot invoke "games.kingdoms.kingdoms.Kingdoms.getCommand(String)" because "this.plugin" is null
at games.kingdoms.kingdoms.economy.commands.CommandManager.setup(CommandManager.java:27) ~[?:?]
at games.kingdoms.kingdoms.Kingdoms.mongoDbStuff(Kingdoms.java:181) ~[?:?]
at games.kingdoms.kingdoms.Kingdoms.onEnable(Kingdoms.java:55) ~[?:?]```
Roger, thanks
will look for the important code to post in a special page in a sec
you didn;t add yoru command to your plugin.yml
ie whatever the link is for posting this stuff
No, not quite. It didn't even reach getCommand() yet. The plugin instance is null
whats the website to post code? or do we just do it in code blocks?
?PASTE
?paste
?paste
thanks
CommandManager class:
https://paste.md-5.net/vijufilafu.java
MongoDbStuff():
https://paste.md-5.net/damuyaqizu.cpp
onEnable():
https://paste.md-5.net/ukudalenoc.cpp
i think thats the most important stuff
Native speakers, is it Whether to play a sound when an action is successfull or successfully ?
As intelliJ wants to correct it to successfully
isn't it with 2 L?
no
Thanks! I got it wrong all the time than :(
I'm happy the only problems I'm facing rn is grammar stuff :d
bruh I even had it right the first time and changed it :c
asList isn’t modifiable I think
problems should have are
problem should be is
yeah not exactly sure what’s going on there lol
I want to say it is modifiable, but the size isn't adjustable so you can't add things to it
It's a weird internal List implementation
Makes sense
Yeah. Arrays#asList() is modifiable, but you can't add/remove from it. It's fixed-sized. Things like List#set() will work, or #replaceAll(), but if any operation changes the size of the backing array, you get an UnsupportedOperationException
They stupidly named that implementation ArrayList as well by the way, for some weird reason. FixedSizeArrayList would have been better
Thanks Choco:)
I can't figure out how to shade in mongodb to my plugin, everything I've found online wont work
cPlayer.getHandle().b.a(packet);``` How can I find out what makes these methods obfuscated? There was a website that helped you with this but apparently it is no longer available.
are you compiling with maven package
1s
how could I play a particle above a player, without apis?
I should be
I'm using compile output with an artifact
How do I compile a plugin with gradle? I've never used this lmao
are you not using the maven buttons in intellij
if you use intellij to compile as artifcat it won't run anything you have done with maven
No
thats why its not working
I made a config to start the server with the artifact
Is there a way I can fix it and still use that?
how would I get a random color for a particle?
make a list of colors and grab a random one
you could do a random int within a bound or use some random list selection method java has iirc
https://paste.md-5.net/jacomuzusa.bash Im getting this error when I do so
Figured it out, made the config run mvn compile -PotherOutputDir which does the same thing that my old artifact did
Thanks
I mean you could also just add the output directory your pom
but that works too
wait that didn't work lol
<configuration>
<finalName>${project.artifactId}</finalName>
<outputDirectory>${basedir}/../output</outputDirectory>
</configuration>
this is what I do in my shade plugin configuration
then your run maven package
and it outputs to the specified directory
note that it can be absolute path you don't need the env variables I used
no
works
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
That is in the pom
alright
love you
how could I keep my particle in a set offset
its in between 0 - 4
Just want it to be 4
yea
ty
probably should word this better
how could I put a particle above the players head?
depends on the particle, some just have natural offset
declaration: package: org.bukkit, interface: World
theres a heap of overloads for spawnParticle some with offset values
its the note particle
Hey, For obfuscation what classes do I need to exclude? I keep getting this
assuming you're obfuscating your own plugin right
I am
btw have a look at spigot guidelines for obfuscation if you plan on uploading it
theres a few rules
usually you dont have to exclude anything for it to work
which obufscation tool are oyu using
Proguard
Im not finding anything here
they all do the samething
Why obfuscate at all?
More optimized and paid plugin
optimized is hardly true
So just cause it's a premium resource?
Ya
As if obfuscation does anything to prevent your jar from being cracked lol.
its not obv fool proof but it deters people from doing it
Well I think if your plugin is undesirable that's more of a deterrent
If your plugin is worth stealing it's going to be
Ok... do you know how to fix the problem though?
The names of your class, method, and variable names does not deter me from pressing Ctrl + C, and Ctrl + V
I can still reupload your plugin just the same
I have a licensing system
And if you put in some sort of piracy check, it's as easy to remove as looking through the decompiled code. If someone has enough time, they can map your whole code as well. A lot of vanilla Minecraft is reverse engineered and mapped
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/builddata existed long before Mojang's mappings were published ;p
You have a licensing system that I bet can be bypassed easily
We'd probably have a lot more high quality plugins if people didn't worry about this stuff
Ok thats cool I am just asking if anyone knows how to solve the problem
a
I understand its easy to bypass just want to have it obfuscated though
Are you obfuscating a finished jar?
Yes
Isn't there a maven plugin for it?
Yes but I am using the jar version
guys
i forgot how to use the chunk persistent data to store data based on blocks 😭
whats a better way of doing this?
if (initialKeyValue instanceof ArrayList) {
new ListEditor(player, (ArrayList<Object>) initialKeyValue```
idk but I don't think that's actually allowed on premium resources?
Cast to ArrayList<?>
correct
But also
Do instanceof List and (List<?>) instead
I highly doubt you specifically need ArrayList
Don't be more specific with types than you need to be
It makes code more reusable
But what're you trying to do anyways?
config editor
it is
It's not
Maybe I am missing it but I dont see it in the rules
All resources must run directly from downloaded file without any manual installation steps or access to a specific server. This means that licensing systems of any form are prohibited. This also means that all applicable code must fail-safe in the event of (web) server error.```
I see I have seen many plugins use a DRM so thats surprising
Why wont this work: 0 errors
command /advertise:
permission: op
Permission message: "You may not use this command"
trigger:
set {_t} to a new text component from "&aClick the copy and past to copy the ad &6Here"
set click event of {_t} to click event to copy "/Join Jediboxs &l&6Join the community | &l&9Great staff | &l&9Updates every 1-2 days" to clipboard
send component {_t} to player
Permission message: is not a valid key
there is much about that which looks odd
I'll guess skript
skript go brrr
That's skbee right?
@native edge yeah that’s Skript, you should ask in the SkUnity discord
how do I play the player swing arm animation without using CraftPlayer?
swingMainHand
bit of a swing in the dark but does anyone have code to calculate status bar offset
so how do I check a cast?
public static <newType, oldType> ArrayList<newType> cast(ArrayList<oldType> list){
ArrayList<newType> newlyCastedArrayList = new ArrayList<newType>();
for(oldType listObject : list){
//Check cast
newlyCastedArrayList.add((newType)listObject);
}
return newlyCastedArrayList;
}```
if(object instanceof Class)
or Class.isAssignableFrom()
it's sorta hard with type erasure though
Maybe it might help if I show you how I am applying the method https://paste.md-5.net/fujihuvuha.cs
i might be wrong but i dont think you can check a type's class unless you have an instance of it
which you don't
which part are you referring to?
for your cast method
you might have to blind cast and just throw an exception
you can't do newType.getClass() unless you have an instance of newType
I probably just might need to read up on generics, then it should be obvious
yeah keep me updated i've had similar issues before aswell
yeah nasty casting
ArrayList cast isnt necessary right?
the outcome is the same as yours
yeah I'm still trying to figure out/find an alternative method or approach
Don't think theres any safe way of doing it tbh
makes me think that I need to reevaluate my code then
There is none. The only way you can cast every element is by providing more runtime type information like a Class<newType> parameter.
i mean you could have a try/catch for each element
na I need a completely different approach
or
You just need to hope that the list you are casting only contains elements which are of the target type. Or else this will get nasty.
You cant catch generic type casts
So essentially what I am doing is handling lists, the code starts off here
so it begins in the form of a wildcard arraylist
To my knowledge there isn't really another way?
Generalize it. Make it a List<?>
k
i mean, if its not for an api
it should be fine
i doubt you'll be putting weird types in the collection anyways
good ol @SupressWarnings
k, anyways then I pass it to my listeditor
that creates a whole bunch of guis
?paste
the code is quite messy https://paste.md-5.net/epuzeforek.coffeescript
Really really messy... you should never use a constructor like that
its such a pain though when you have so many fields you need to create
what can I do to tidy it up?
Nevermind I will just use the builder pattern
For this code I get different results.
YamlConfiguration config = new YamlConfiguration();
config.set("material", Material.STONE);
config.save("myfile.yml");
During test-time
material: !!org.bukkit.Material 'STONE'
During runtime
material: !!org.bukkit.Material
data: {}
Any ideas?
obviously that isn't all of the code
?paste
Well, it's pretty much the code that produces the file. One in a main-method the the other was tested for the plugins onEnable/onDisable context.
Or what else do you need?
Oh, I actually found what makes the difference. The test environment was 1.13 and the runtime 1.19.
When the test environment is 1.19 too the results are identical. Well, still strange this changed between the versions.
It isn't strange
code changes in the implementation of the server between versions
in this case Material was changed
Material isn't an enum in the latest version if I recall
where as in prior versions like your test environment it is
Oh. Yeah, this could explain the change in behavior.
Seem then like direct material serialization fails in the current version.
Because as you can see, the information that it was a stone before is lost.
Hi, just wondering if this code is neater than my previous code. New code: https://paste.md-5.net/kigohageyo.java Old code: https://paste.md-5.net/epuzeforek.coffeescript
Also I just realised I could have used @Getter and @Setter but its still the same thing
I might store it as a String then instead. Adds some code, but still seems to be the best workarround.
Thx for the help there.
If lombok is installed you can use their builder annotation
I'm what they call a manly programmer, hard sweat and torn ligaments must be achieved through manual labor.
Why did you talk about @Getter and @Setter then :p
Thats a big of an exaggeration, I honestly wasn't aware of that lol 😂
This is bugging me. Every time I try to call these methods it says its null.
Why are you doing String valueOf the file
Do i need to? Every time I dont it gives me an error
I doubt you have a file as a key in your config
no you right
I'm going to show you my config manager, Olivo, can you find some bad stuff in as well, thx
Utils for spigot development. Contribute to KyTDK/NeoUtils development by creating an account on GitHub.
i feel ashamed but im still getting a nullpointerexception with this guy
Does it say what's null
Also why is pConfigFile a class variable
It should be a local one
also also instead of naming it getpConfigFile name it getPlayerConfigFile
org.apache.maven.supersaiyan.SSJ.getpPc() my bad, the error was in another class. I'm testing code so its not final, i understand its sloppy to do that. also will do.
Wait what why are you using the maven package
no that was the error in the console
Whats wrong with that?
ofc
there are two different things
one is API
the other is impl
You'd want to only save Material.STONE.name()
and then Material.valueOf(name)
i feel like im missing some simple di method
hey, im following this guide right now: https://www.spigotmc.org/wiki/creating-a-plugin-with-maven-using-intellij-idea/ and my server says, the jre version the plugin has been compiled with is 62 but the server is 61. i compiled both with java 17 (openjdk), my server is running 1.18.1
heres the error: [plugin] has been compiled by a more recent version of the Java Runtime (class file version 62.0), this version of the Java Runtime only recognizes class file versions up to 61.0
Class major Version 62 corresponds to Java 18
what it is saying, the version of java you are using to run the server is older then the version of java used to compile the plugin
update the java version for the server
when i hit package it used /usr/lib/jvm/java-17-openjdk/bin/java and thats the exact same i use for the server
so DI is essentially using interfaces and passing instances through constructors?
yes
dude i was already typing
since people ask this over and over and over again, I wrote this tiny blog post for Spigot -> Mojang mappings https://blog.jeff-media.com/switching-from-spigot-mappings-to-mojang-mappings/
okay but what if I am too lazy to pass/inject the instance every time?
Unsupported Java detected (62.0). Only up to Java 17 is supported.
Any acceptable alternatives?
just change your maven java version: https://blog.jeff-media.com/common-maven-questions/ (see the lowest part in that post)
only other way would be to either have a method that is public that holds the instance or you use statics
like a singleton?
singleton is a way, but not something you want to always use
purpose of a singleton is when it isn't ok to have more then one instance and you want to ensure the best you can that there isn't a way for that to happen
So essentially this is the best method?
public class PluginName
{
private OtherClass otherClass;
@Override
public void onEnable()
{
otherClass = new OtherClass(this);
}
public OtherClass getOtherClass()
{
return otherClass;
}
}
public class OtherClass
{
private final PluginName plugin;
public OtherClass(PluginName plugin)
{
this.plugin = plugin;
}
public void doSomething()
{
Something something = plugin.getSomethingManager().getNewSomething();
something.something();
}
}
best method is whatever you decide really, we can only advise or tell you what would be more appropriate
DI is really only necessary if you intend to allow other plugins interface with it or if you have an API
otherwise it really doesn't matter all that much
well this is an API
then you want to stick with DI as much as possible then
alright
i already set it with xml <properties> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target> </properties>
but the method on the blog doesn't work, i just get errors that the plugin tag is unrecognized
the <plugin> tag has to be inside <plugins> ofc
but yeah, that works too, unless you overwrite this in an existing maven-compiler-plugin declaration. that's why I always suggest to declare it explicitly
also, the other person wasn't happy with the name ManagerManager, would Managers be more appropriate or just I dump them all in my main class?
is that the name of your class?
ManagerManager?
yes
if so, the reason being is that it isn't descriptive in what kind of manager it is
Its the manager of managers
the CEO
so dumping it in the main class would be less ideal?
but no, its still not working
i have made a bukkitrunnable to run some code 15s later, but the PlayerQuitEvent still kills me even though im not supposed to be in the hashmap anymore. https://pastebin.com/ihT42sD1
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@tender shard What are you doing here? https://github.com/JEFF-Media-GbR/JeffLib/blob/84c3a889e2f662915dd4e2f2aa2c8b74715d0e23/core/src/main/java/com/jeff_media/jefflib/JeffLib.java#L144
Avoid writing the same code over and over again - use JeffLib for your Spigot plugins! - JeffLib/JeffLib.java at 84c3a889e2f662915dd4e2f2aa2c8b74715d0e23 · JEFF-Media-GbR/JeffLib
using the properties to set the java version has been deprecated and maven doesn't use it anymore
you need to set it by using the maven compiler plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
however, this isn't your issue, your issue is that the java version you are using to run the server, is outdated
but you could just compile too for an older version
anyways, the above should work, make sure to do a clean build as well
returning the plugin instance. if it's not set, try to figure out what plugin called this method
it's only there for people who are lazy and don't do "JeffLib.init(this)" in their onLoad() or init block
and the 50 lines there are just to tell you exactly where you called a method that needed init
Ah, does .init have an advantage over overriding the onEnable in the main class?
the { } init block gets called immediately when your plugin instance gets created, and before it gets enabled
it basically gets called at the moment when all your fields get instantiated
so if you only set something in onEnable, then your class object is basically in some kinda "void" state until onEnable gets called
doesn't really matter in 99% of cases
it can be, but doesn't necessarily have to be
in fact doesn't even need to be the same program or language either
multithreading uses more than 1 processor, workload distribution doesn't need to use more than 1
this is incorrect
multi-threading refers to using multiple threads, what you are getting confused with is multi-coring
two different things
multi-threading is one of the easiest ways you could distribute a workload however it doesn't really work all that well on single core cpu's
exception there is if you have multiple CPU's which isn't the same as multi-core
Then multiple threads can work on one core?
yes
Whats the difference between multithreading and multi coring and workload distribution then?
multi-coring refers to being able to specifically target/utilize multiple cores
multi-threading just refers to being able to use or create more threads
world load distribution is just a concept or talks about concepts in how to break down your workload into smaller ones and how you can go about using or creating mechanisms to then work on those smaller bits instead of just having this one big task
however, since it isn't really something specific and more of a concept, what you decide to leverage is up to you. Hence why I said technically you don't have to use the same program it originated from or the same language
I see
multi-threading is a form of workload distribution
if done properly
hence why whoever you were arguing with associates it with multi-threading
however, multi-threading isn't necessary for workload distribution you could go with asynchronous tasks
asynchronous tasks would distribute the workload as well but those don't necessarily use or create threads to accomplish it
yo frostalf can you help understand why they create an instance in the main class? https://github.com/Burchard36/BurchAPI/blob/main/src/main/java/com/burchard36/api/BurchAPI.java
so you can use a static to get the main class
But thats not DI right?
How would you instead then make your main class accessible ?
by passing the instance?
how do you pass an instance of your class to something you don't know?
it is for others using their API to get the main class instance easily
But it uses the INSTANCE internally
also a bit handy for yourself too
its not, im using openjdk 17 for both building and running the server
I thought you couldn't do this?
then I guess the error is wrong and you are correct
The error says the compiled version is java 18
and you are using java 17
Which won't work
indeed, they're doing something wrong
don't take example from that
I have told you above how to fix it, obviously you could just compile for java 17 and told you how to make that happen
Okay I thought I was going crazy
or you could just upgrade java to java 18
they don't to have a static variable
and nothing to worry about
Don't use java 18, especially if its a public plugin, not enough servers use java 18
the variable isnt being used at all.
You can since you can do whatever you want with something you create, however sometimes DI isn't necessary depending on a classes purpose
its literally redundant
@wet breach look at the code, the variable is literally never used
also, when it comes with statics, since the main class never goes away a static for it is just fine
because it isn't for them
it is for the other people using the API
they use instance there
mhm, they're doing static abuse
it isn't even static abuse
it is though?
is the main class expected to go away?
they're using the static keyword, on a global state, to pass around the main class
Change tag above player name...
what?
the main class of a plugin will not magically disappear
Yes, and?
therefore using static for it is fine
What
i never said you shouldnt use static for it
they don't even have a getter for it
one of the problems with using static is that whatever you declare static, will never get GC'ed
http://0x0.st/o9sc.png again, i dont use java 18
But I was literally just told by multiple people that using static in my main class was a bad idea
it's just public static
since the main class will never get GC'ed anyways, using a static for it is fine
that's not the entire problem however
yes it is
Thats now my current understanding
the problem isnt in static
the problem is how they use it
e.g making the static variable public to gain access to it from other classes
which is called static abuse
that is one of the reasons for making it static
Generally don't reccomend using static over di in most cases but it's fine in quite a few cases imo
not in this case?
No
Yes
using the static keyword is 100% fine
except you dont make it public, and instead user a getter
Bruh want me to say singleton to make your happy
since bukkit classes are singletons, its fine for that
Not sure where you are getting in how it is being used is inappropriate o.O are you insisting that they create an entire method to just return the instance?
yes
that is dumb and a waste of resources
global state is usually not right, that's what most people think
an entire method, its not that much of a bother
no? how is it a waste..
because you are wasting space on the stack when you can just make it public like they have it in the main class
in this manner, the only thing on the stack is just the variable and not also an entire method
yeah that little used space will definitely make a huge difference
what advantage does making that a method have over how they are doing it?
if there is none, then I don't see how you are being very convincing it shouldn't be done that way
using "public static" for instances, is just against oop?
isn't it for security?
security against what?
Java allows functional programming. If Java was inherently against this, they wouldn't allow it
Generally yes methods like that are to make sure the singleton exists however you knowe that main class of the plugin Is there fully registered 100% of the time
Functional programming is sometimes necessary in java and is actually more optimal then OOP sometimes
Oop and functional work well together using fully one or the other Is inconvient imo
not in this case though?
glad you changed that word
explain how the method is more optimal
I already told you how it wasn't
Yea it definitely is we always know the main class is there or none of the code will even run
It will also never be discarded prior to the plugin disable
so in conclusion, i can just forget about di and whatever i just learnt
The reason it works for the main class is because bukkit already ensures there is ever only 1 instance of your main class
and just use public static for everything
Does anyone know what is wrong with my code?
Not what he is saying
I never said this
so as long as there is only one instance
i can do whatever?
I use di for My main outside of a few isolate cases
Generally I find it more readable and maintainable
pretty much?
My exception to this is Bukkit runnable and logging
just dont use static ezpz
but is there harm to use getters?
dependency injection all the way 💪
that is main reason for why statics shouldn't be used is because sometimes you can get in a state of the static no longer pointing at the appropriate instance, as well as statics don't get GC'ed
but if the class that the static is used for there will ever only be 1 instance and if that class will never go away
then the two downsides are a non-issue anyways
ic
also, the purpose of the class is important too
if it isn't important that your main class gets passed to it or whatever other class, then using a static is also ok as well
not all classes require DI
well ill use getters eitherway since it looks less ugly, even if it's not useful
singletons can be bad too
for what reason?
but you use singletons but static is used for them
which is odd since you were stating it isn't OOP
i didnt think static is the problem, i thought that using static without getters is
yes
otherwise you will have lazy singleton
I hate getters damn
Sometimes they are understandable for encapsulation and more control of the public/private
But when for small classes like Vector that should be straight forward and hold few data very irritating to write .getX() instead of .x
But u will say it's advised to design like this according to java
which isn't really something you want all the time
wdym irritating
thats no reason to hate them
you don't have to have getters
getters are necessary for everyone else not necessarily yourself although can be beneficial for yourself
as it makes more clear what it is you are getting
you could just call your getter x()
for everyone else, helps maintain a level of control on what it is you are allowing them to get 🙂
Well it's better but I'm still irritated to make a function call for stupid field access xs
there is a reason why vectors have getters
I get the reasons but sometimes I think it's overkill anyway
noone forces you to do so. I use public fields quite often
but dont tell anyone
Haha same
it's because they're inherented
BlockVector is a child of Vector
and perhaps for a specific child
you may need to override the getter
to ensure some conditions
e.g if u want the coordinates to never be negative or some thing
You can also ovveride the field and the field type...
Ah yeah nvm Ur write about this
what
Yeah I understand because of BlockVector the coordinates are ints
Whereas in Vector they are floats
Makes sense to put getters there yeah
I tried to clean up my code, obviously I'm not very good at this so be nice https://github.com/KyTDK/NeoUtils/blob/master/src/main/java/com/neomechanical/neoutils/NeoUtils.java
sometimes the getters are for convenience
in both classes
What api do you recommend spigot or sponge? Why?
the constructor accepts floats and ints and doubles
but then casts them to doubles
as far as i know
spigot
what
and use paper for your server
Wot?
wot bruv
Vot bra?
💪
Jokes aside
Spigot because I go no idea about sponge
Ok!
but on PNG, with no quality loss, its only 17kb
why is PNG so much smaller than jpg lol
sponge allows for plugins
and mods
but bukkit or its forks
don't work
on sponge servers
Yeah that's why I asked
it depends on your case
because png doesn't store as much detail as jpeg which is why jpeg is used for high definition images
though, sponge is less famous, afaik
because they keep changing their API constantly and they are not out of beta
I see
also can someone critique my api, I do appreciate the constructive criticism
uh oh
Yeah png is shitty for getting details, iirc the compression algo is lossy for png
PNG's two-stage LZW compression takes strings of bits contained in the image's data, then matches those longer sequences to accompanying short codes held in a dictionary (sometimes referred to as a codebook) that is stored within the image file. The result is a smaller file that maintains high quality
loseless you mean
Good for me that I learnt spigot
well
spigot for the win
maybe rename the getters
which?
instead of adventure()
it maintains high quality to an extent
use getAdventureInstance()
Yeah
or something like that
usually most getters start with "get"
or if theyre booleans, use "is"
if thats all you can find then I am happy
Oh wait, its the other way around, My bad
Does anyone know a way to create an explosion without destroying blocks
the Logger variable, i suggest you make it private
I would redo that
your instance can be null if the class hasn't been instantiated but is being accessed via the static
#help-development message
Can someone help me with that?
and since it can be null and not disabled, throwing that exception isn't quite right
How are you meant to know?
well how you know something is disabled is because they would get a error on their side that the method they are running is null because your plugin is disabled 😛
your plugin can't know that it itself is disabled since you know its not running
what are you saying? just warn?
I think the logic wasn't clear enough
there isn't anything to worry about when your plugin isn't running
so there is no need to check if its null?
if your plugin is somehow disabled, none of the code runs so I mean
what version do yall use nms in, and do you use mojang mappings or spigot mappings for it?
how is your plugin checking for something if none of the code is running because you know its disabled
This could work
fields?
ok I guess I have to go with an analogy on this one
ok what hes trying to say is
how does your computer know there is something wrong if it isn't on?
your whole plugin
wont even work
if its disabled
so nothing will be printed
meaning the getInstance() method wont even be in the stack
so essentially he is saying its an unnecessary check?
No, it is necessary
your warning message is somewhat unclear though
"disabled" is not really the right word
it isn't that isn't necessary, just throwing that exception and the resulting message is unncessary
i do think it's necessary, since what if the user forgot to initialize the lib?
Tried to access instance when the plugin was hadn't initialised yet, please make sure you extend Api in your main class!
damn we still on this? just use the service provider bukkit comes with or something
avoid static's altogether ezpz
we're not on that
I didn't say it wasn't necessary, I explained early on in how you can have a null and the plugin not be disabled
ah i misread what u said
I was just saying you won't have a case of the plugin being disabled and something ever being returned from that code 😛
"it isn't that isn't" this confused me a bit
yeah mis-typed and didn't bother fixing it
you are the only one to spot it
probably because im not native
.
did i just get a ghost ping or
I accidentally replied to you
And I'm just going to assume my new message will suffice
how do i detect a projectile/arrow launch event?
have you googled it?
declaration: package: org.bukkit.event.entity, class: ProjectileHitEvent
yes but how do i need to call the method with @EventHandler?
like java @EventHandler public void onIdk() {}
also wouldnt they want ProjectileLaunchEvent? lol
yeah that too lol
sorry I didn't really read their message
lmao
u missed one word out of that whole message
arguably the most important word besides projectile
smh
🤨
also u would do like
@EventHandler
void onProjectileLaunch(ProjectileLaunchEvent event) {
// do stuff
}```
ok thanks
forgot annotation woops
make sure the class the method is in implements like org.bukkit.event.Listener or whatever it is @blazing ocean and then register the class with the server pluginmanager
so like in main plugin class do getServer().getPluginManager().registerEvents(new YourEventListener(), this);
They would definitely benefit from some tutorials on the basics of Spigot API
reading the wiki rn
it depends
You can always perform mitigations, but there are indeed issues that cannot be fixed by the server
can i somehow make item wearable on head
Afaik setting the item as the helmet makes it wearable
If you wish to add the interactibility for it however you need to listen to the PlayerInteractEvent and act accordingly if the item is equipped
hwo do i do it
?jd-s
declaration: package: org.bukkit.inventory, interface: PlayerInventory
oh
but i want the player to be able to equip it(so he can drag and drop it to head armor slot)
that is a bit harder to do
As far as I know you need to emulate the behaviour but there is no clearly defined way of doing it
how to use minecrafts original border
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
how to ask
Hello, i have interesting math problem
first number is Y velicity before hit happen
second is right after
what is the formula of Y knockback?
can someone solve it?
-0,07 0,46
-0,15 0,42
-0,23 0,38
-0,3 0,34
-0,37 0,31
-0,44 0,27
-0,9 0,04
-0,96 0,01
-1,19 -0,09
-1,86 -0,43
-3,44 -1,22
This is a non-deterministic problem. Absolutely no correlation here.
where?
im pretty sure that task not even that difficult
Then why are you asking?
i bad at math
Between the first and second value and between every value pair. Those values are completely chaotic. This is not a math problem.
i just cant use any solvation form here
https://math.stackexchange.com/questions/11502/find-formula-from-values
but it looks the same isnt it?
Ok ill try it with extra emphasis:
This. Is. Not. A. Mathematical. Problem.
You would be better off feeding tens of thousands of those values into a neutral network, but thats still not a correct solution, and most likely won't work
Do you have a math trauma or sth?
its not chaotic, lower Y before, less amount of kb will be applyed after
What is your end goal here?
Hi, how a block under players feet falls like TNTRun? somebody can explain a little bit?
simulate exact Y knockback
For what?
for bot
Replace the block with a FallingBlock
on a move event?
Just approximate it then, does it need to be exact?
Whats the bot/npc for?
reduce practice
Sure. Or on a timer. Just play around with it.
i tried, it still looks different
So when is the velocity triggered?
wym?
I'm assuming you are applying the "calculated" velocity to the bot, when do you do this? Is it on hit, random?
Without having the values for previous = 0 it is a bit hard to plot anything
i still dont get what you mean, i apply Y velocity to Player every 10 ticks, it depends on current player velocity
i need it to be natural
Here. Only correlation i could find is
a(b) = b * c where c is about 0.5
Hey smile could you help me with managing DI in my projects, there are couple knowledge gaps on the correct way to do things relating to my commandManager
So its
yAfter = 0.5 + yBefore * 0.5
Actually not too keen atm
Bukkit.getWorld("world") returns null
any idea why?
does it? means that the world doesn’t exist or isn’t loaded
ou
use the WorldCreator to load / create worlds
that would also do it :)
#help-development message
Can someone help me with that?
The server sends knockback and the client applies that velocity immediately when it receives the velocity packet. I notice two interesting numbers in there: -0,07 is a gravity constant, 0.08 * 0.98 = 0.0784. 0.08 is gravity in mc and 0.98 is friction. 0,42 is a standard jump of a player. A jump may override y knockback velocity.
anyone know how to get player nbt (spigot 1.19)? cant find it anywhere
I know how to get item nbt but I need player nbt for the persistent data stuff
?pdc
oh.. I can just do player.getPersistentDataContainer()
I think I was drunk when I wrote this
it makes sense though
lol wat de fok
remove means remove from the drops. and after it was removed, it has to be removed from the list that contains the items to be removed lol
ho lee fuk
hey guys, whats something i can detect to open a creative inventory. that does not make sense so ill explain
I am making a op items pack
theres an item which u can use to activate creative (no player shall no, if they do, they get the creative item)
i dont want to give players creative, so I thought of opening the creative inventory when certain events happen
what can the event be, i thought of opening it when the player has X item in the off hand and Y item in the main hand
do u know something thats hard to guess but still possible
basically its an easter egg
you cannot open a creative inventory without giving them creative gamemode
Creative is almost completely client side
When does hypixel do it
they probably give you creative mode
build battle
They give you creative mode?
i m pretty sure its survival but creative inventory
should i make a custom inventory then
then they just send you a packet telling you you're in creative mode or sth
what makes you think its survival?
cuz i played it a few days ago
It’s 100% survical
how to send dat packet
ClientboundPlayerInfoPacket with Action.UPDATE_GAME_MODE
Making your own custom Inventory would be a mega pain in the ass
well there is a method to get the creative category of any given item
oh well phuck
this is the way to do it?
yeah and then listen to incoming ServerboundSetCreativeModeSlotPacket
Wouldnt sending the packet cause a lot of issues
that way you can detect items they click in their fake creative inv
They cant pick the items
how to listen to inc packets? is there an event?
oh fuck
you need a custom netty handler or you use PacketEvents library
ill just create an inventory which shows all the items in the game
except legacy materials
dont forget to check if isItem()
with pages and search as well
Why cant they actually have creative though?
otherwise it would show AIR, WATER etc too
cuz then they have godmode
Ah
i want them to still stay in survival and eat that fatass damage
as said, just send a packet telling them they are creative. then listen to ServerboundSetCreativeModeSlotPacket. Then you know the itemstack they clicked. then you send them back to survival
that's the easiest method by far and probably how this weird 1.8 server does it
Could you not do
event.getDrops().removeIf(ac.blacklistedItems::remove);```
lol
maybe, I had a ton of debug info in that before so it's a lambda
let me try it
Is there any way to restrict my class class to only be obtained from a certain classes getter?
Not sure what you mean exactly. You could do some access restrictions. e.g. a package-private constructor if you're constructing and returning a new instance
Or a private one if it's a nested class
As in can only be instantiated from one class?
yeah
Yeah just use an access modifier on the constructor
Then yeah. Classes in the same package, package-private constructor
so its a language manager but I only to be accessible from my ManagerHandler class
dirty solution: get the calling class in your contrusctor and throw an exception if it's not the class you want lol
That's disgusting, please don't do that
I like your style, implementing now
Wouldn't you have to throw an exception to do that? lol
ik lol
even better, throw multiple exceptions directly in the entry point of your plugin
to get the calling class?
ye
no plugin, no problem
no, you can just get the current stacktrace, or create e.g. a LinkageError without throwing it, bla bla
yeah I usually do it like this in the rare case where I need it https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/ClassUtils.java#L54
java is hell
why couldnt they make minecraft in python
Lmao python
or even better
If you want 2fps, sure
lmao
minecraft.sheeshhhhh
make minecraft with css
yes
There are some really impressive projects done completely in css
anyway so I am tryna make this simple cosmetic plugin and I need to store the current active cosmetic of the player (just a string as the name)
should I go ahead and burn my eyeballs and use MySQL or should I just go with Persistent Data Storage?
I have no experience with persistent data storage so I thought I should ask before using it
my first plugin used messaging channels as a database to the bungeecord server lol
yes, that's why its called PERSISTENT
xddd
it worked well tho lmao
ITS PERSISSTENTASDMANTNTT
yeah I think my brain needs some rest after that one @tender shard
otherwise it'd be called VolatileDataContainer 😛
trololololol
🤪
or even better
FuckYouContainer, whenever you try to add data, it just throws FuckYouException
essentially thats setting up mysql for the first time
fuck thats hot
- make it premium
send me jar
and sell it for 1million$ on spigotmc.org
md5 understands
yep
I think I'll stick to my current project for now
and die trying to make cosmetics work
or you could fork a cosmetic plugin?
cya guys after another 6 hour coding session full of lots of bugs and not so "lots" of progression
thats for plebs