#help-development
1 messages · Page 429 of 1
uh oh
My plugin is giving me an error when i type the command. How do i fix it?
Main: https://paste.md-5.net/nefomakiba.java
error: https://paste.md-5.net/ikejoseseq.bash
uhh wha
Caused by: java.lang.NullPointerException: Cannot read field "active" because "this.enderman" is null
How do you represent long in config?
I cant find the way of representing them
wdym u just put ur long value into the config
just as a literal?
mynumber: 3
Its giving an cast exception
because your using int or something
what config framework do you even use?
what ur doing? getLong?
Spigot vanilla
dont use a raw get
yes
that returns an onbject ah wait thats no fileconfiguration
it looks you just use a Map<String,Object>
Yes its configuration serikliazable
check if it's an int, if yes cast it to int
ig getLong gets a Number and calls ::longValue
well its a raw map
Thats how config seriazable works
((Number) map.get("whatever")).longValue()
''How do i fix it''
?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.
Maybe this is the causing the issue
long myLong = Long.parseLong(String.valueOf(map.get("myLong")));
your enderman is null
it's probably an Integer so you can't just cast it
do not access members of null references
how do i make it not null
?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.
public void onInteract(PlayerInteractEvent event){
event.getItem().setType(Material.AIR);
}
Can someone explain why this does NOT remove the item in my hand?
im not in creative
yourcock.erect() nullpointererror /s
That’d work better on chloe
true
this is gonna be fun 💀
Looks gine to me
What thats?
minedustry source
It's a game
this game
Eww Windows
tell that my bios update that doesnt like linux
looks like the attempt to change the color of a app bar terribly failed
Yes.
Minedustry is Multiplayer by any chance? or should I revert to Terraria
Mindustry can be multiplayer
Is it popular though?
It is rather popular
much better
Chances are you played the classic version years ago on android
I might did
Why the Eclipse brother
did u seriously do all that to change the color of the top bar thing?
looks like factorio
There are like 5 "big" games written in java: Minecraft, OSRS, Mindustry, Project Zomboid and Starmade.
I'll leave out most of the fringe primarily android games since there are many of them.
💀
Is there a officer problem?
Dude use Arch or Mint, like seriously any other Linux Distro or Windows/Mac sucks
i dont even recognize the name of half of those
wait you use arch btw ?
Nah I use Mint
LOL my friends are like this
Come on, you have heard about old school runescape
hi chat
well yes
Dude, like Eclipse is like... what a dinosaurs app now days?
that is pretty subjective
mint 💀
Project Zomboid and Starmade are rather fringe though but still notable enough to award the list
Eclipse does what it must and for that I applaud it
but i dont know osrs or starmade
real
But can you use Gradle?
Yes
i use gradle cli anyway
Groovy
for the most part
Don't kotlin me
OSRS is old school runescape
you rule
how do i go in subfolders in config
i never said i know acronyms lol
Heh
WINE
STOP THE WINE TALK
WINE is not an emulator
It does the job though
yessir
It processes all Windows'es apps
tru
that is a translation layer
Was about to say that
CSGO and CS2 will be source runned
fps ⬇️
but youll have reflections
bruh no exiting condition, overflow of stack incoming
nvm bad joke
Run 2.4Ghz runners on any system while playing CSGO, you'll cry to mommy
Never heard about that one
Why intelliJ?
VI IMPROVEd
auto completions
Yeah, and apply that same argument to eclipse
Breakpoints
i call that GNU Emacs
Eclipse has that too
Gnome**
Everythign you mentioned Eclipse has
what
I heard eclipse even has the better debugging support
the fuck u mean gnome
Breakpoints, auto completions
aren't those like... part of every ide
Not on app connection no
Some can some don't
VS Code users be like: :unhappy_face:
He's clearly never used Eclipse. He's just parroting what he's heard.
VSC has break points
I used to use Eclipse for the long run actually
Oi
5 years of my coding was in there
when ur ide is a web browser
vsc is not ide
it is
So you mean attaching to other processes?
yup
Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.
debugger is not a part of a text editor
;-;
21 lts?
Yeü
This Java update shit is now dreading me
yeß?
ζ͜͡Yes
Ye5
I'm german and the ü and s keys are notoriously close to each other
Lemme move over that Internal Combustion loving country
Hey, by 2030 we only sell electric cars
Ya'll rejected that law
no theyre not
Germany was the only country in the EU to reject it
On the other hand our trains will only have a unified timetable by 2070
Heh 😏
Internal Combustion>>>EV
Change my mind.
No.
if you mean ü and ß you would be right but the s is on the other damn side of the keyboard
this is gonna be interesting
this was deliberate geol
(I actually wanted to press the enter key which is the key next to the key next to ü - so I just made the joke of wanting to press s, which is at the opposite side of the keyboard)
ah
why do they even need that?
truth be told, every day I consider as "how" and "why"
too many if statements
in such a nested way
could use a sql case here
I like moats
its better than before bruh
maybe have return unix or windows if the case
Root beer moat
It isn't.
looks better
oh no code gore help
Then you have an issue with the definition of better
Does that really have to be turnary lol
something more readable means better for me
cleaner would be nicer
hmm when you close an unbuffered Writer, it will be flushed right, or are there no guarantees?
depends on the Writer impl
its probably time to use lombok now
cuz im looking at a few hundred public fields rn
is there something wrong with using org.bukkit.event.inventory.PrepareSmithingEvent?
No?
Event Class: https://paste.md-5.net/wiyitojesa.java
i know my naming isn't perfect
i shall fix that later
Is that the experimental table
just figuring things out
That does not answer the question
Idk if the event works for that one yet
i shall try PrepareAnvilEvent
🤦♂️
that is smithingtable code nvm
i were being dumb
i wanted to work with anvils lol
where was the Fi thingo from?
file thingie
just working on getting the Items in PreSmithing with Anvil
well building is entity actually
second only has to match one
He inverted the result so this looks correct to me
yep
building.liquids? Core.bundle.get("bar.liquid")? what the heck is that lmao
not my code at least
Something something DeMorgan iirc
man using so much generics that i cant figure out what the actual type is 🤔
he also made his own version of the java functional interfaces aaaaaaaaa
show
Tha fk is "Cons2"
literally a consumer
So a BiConsumer
Didn't spigot remake some of the function interfaces
Bootleg fastutils?
always fun when i change smth in one place, that error goes away but 5 others show up :(
maybe thats why he decided to use raw types 🥹
this not a thing?
ah wait i need ?
You need to define the constraints earlier
public <T extends Number> void yourMethod(Class<T> clazz) { }
ah got it
me trying to figure out the exact type needed, i currently have ObjectMap<Class<?>, Cons2<? extends Building, Integer>> lol
43 unchecked cast warnings now
isnt there a way to do private final <T> ObjectMap<Class<T>, Cons2<? extends Building, T>>?
private final <T, B extends Building> ObjectMap<Class<T>, Cons2<B, T>>
@round finch not sure this is helpful but you can use InventoryClickEvent and check if the clicked inventory is instanceof SmithingInventory
I thought you wanted to define a method
ah nope
For fields the type is concrete
i did this
if(e.getInventory().getItem(0) == null ) return;
if(e.getInventory().getItem(1) == null ) return;
if(e.getInventory().getItem(2) == null ) return;
no issue
ig i better make that field not public and write a method that casts it 💀
If unknown then ObjectMap<Class<?>, Cons2<? extends Building, ?>>
But then it needs to be strongly encapsulated. Unsafe casts are needed
You should never make any field public...
alright cool
Well thats my cue, gotta go to sleep because if have 8h of classes tomorrow 🥲
bae
2x 4h
Woooof
i actually have 2 but im not going to be 4 hours away to follow 2 hours that dont teach me anything
The history of watermelons
oh 4 hours after eachother sucks
the max we have is 3 hours networking after eachother
How to make bratwurst
anyways is there a dif between ? and Object as generic params?
or does ? mean that no assumption can be made about the type and Object that everything will match?
I mean Object is just object, and because every class in java inherites Object, means you can put basically anything
end effect is basically same
i mean you also if you have method for example
public void foo(List<Object> smth) {...}
public static void main(String[] args) {
List<?> smth2 = ...;
foo(smth2); // will not work
}
because ? might not be Object, even if its impossible in pratcice
How can I create an Item Frame at a specific location?
How can I get the direction of a chest?
?jd-spigot
then I resize Minecraft it does PrepareAnvilEvent with Items in the anvil
huh? woah
i didn't know this about the viewer
verty
Object is just a type
? means any type
? extends T means as long as the type is a derivative or T itself its fine
? super T means as long as the type is an antiderivative or T itself its fine
this is why you often when writing higher ordered methods use wildcards
void takeSupplier(Supplier<? extends Animal> supplier)
here the type Supplier<Dog> (suppose Dog extends Animal)) is acceptable
since it doesn't matter, as long as we know the supplier will yield an instance of Animal when calling get()
this is also why
void takeConsumer(Consumer<? super Dog> consumer)
here we use super since a Consumer<Animal> should be fine as it doesn't really use any methods from a Dog derivative type
how do I check if player can repair on Anvil?
and if not... is it possible to bypass that?
i will just getResult i think..
ah i forgot there won't be result cus no trigger
i wanna be able to combine that
i were wrong it does trigger event interesting
When downloading plugins on spigotmc I got a 403 error, anyone know why?
Try to change your user agent. Cloudflare could also be blocking your requests. You could use spiget for downloading them
It's also possible that the resource is payed
Spiget is only for free ones I believe
Or it's using an external link
It is iirc, we do have detection for that in our library not sure if they used it
External links handled, GitHub’s handled
We do have to download 200k plugins or more though
why would you be downloading that many
We have to index every single plugin on spigot and it’s data
you have to do that because?
Building a plug-in
o.O
We have to download every single plugin ever on spigot
We got all the .jar files out of the 108.9k plugins out rn or so
It’s rough man
We gotta support every main plugin distributor out there rn
Who is "we"?
Spigotmc is coded, but I’m making a plug-in system to cover other websites
We as the plug-in team
"The plug-in team" for what?
For a “plugin package manager” plugin
So why do you need the .jar files themselves?
you mean the spigot resource page? or google?
We need to save the sha256 so we can recognize any plugin
Wdym?
Not sure if your talking to me or not
Ohhh
idk why people would need that as a plugin, most server hosts supply a plugin browser
All from in game, automatic updates, malware checking, installing and enabling without restart etc
Never used a host like that
I meant I’m making a system that can download from Hangar, Modrinth, curseforge, possibly Ore, etc not just spigotmc
can't you just index all the files and redirect downloads to spigot's cdn?
How would you handle premium plugins, deleted stuff
Not to mention dozens of old version of plugins.
We index “id:name” currently
Dev builds.
We are gonna support every single version on spigotmc, we will cover 90% of plugins a server has that’s not custom made
Even if it’s old
I'd imagine there are far more efficient ways to achieve what you're wanting to do rather than downloading every single plugin across all platforms?
I am sure there is, can’t really think of one rn
We have to store the sha256 so we can support multiple stores
We are just storing it in a database and using a rest api
- Search with Google.
- Download from the original source.
- Profit!
How are we going to search for 500k plugins though
500k different builds atleast, not sure how many individual plugins we will support
Are you actually distributing the plugins? i.e., people are downloading your copies?
We are downloading inside of our plugin from spigotmc currently
We are getting the download link from spiget, if it’s external then we calculate how to download from there
We support direct downloads and GitHub ontop of spigotmc
We have a method to manually put a download link thougu
You're providing a service? A plugin catalog? Where do the users ultimately download from? Your servers?
I'm guessing it's this based on his status https://www.spigotmc.org/resources/plugin-portal.108700/
From what I can get, he's downloading each plugin to get a shasum in order to prevent them listing the same plugin several times
so I'd imagine that they download each jar, grab the shasum store it (along with the download url and whatever else) and then delete it off
Will also let us recognize already downloaded plugins, our current plugin has a few bugs but we remade it in kotlin, made a library, updated the rest api etc and we are releasing that tomorrow
then when someone requests for a plugin to be installed onto their server, it uses their database to fetch a download url (such as from github, spigot cdn etc) and downloads it to the server
yep
Pretty close yea
OK. I don't really see the point, but good luck.
Shasum isn’t in the current version sadly
I mean I guess updating from in game is nice
Developers who want to deploy a server fast for testing, server owners who want to download plugins safely and reliably, anyone who wants auto updating plugins, etc
Enabling plugins at runtime though is gonna break 500 things
And ty!
Will be a config setting
Some plugins will be manually disabled like plugmanx does, never really had much issues with reloading a single plugin
What if that plugin has worldgen
most of us only need like 2 plugins for dev stuff
What if it has active dependants
Semi rare
theres hundreds of plugins which depend on others
Isn’t the second most downloaded plugin on spigot worldedit
hard to say
World gen is something we can’t combat
Which has a ton of dependants
kinda pointless if you ask me
you prettty much have to read the plugin.yml before installing you are gonna have people get errors
Like dependency’s in plugin.yml or another form of dependant
Plugin.yml
Oh thank you for the idea, we could check for dependency’s in there too
What does world edit require?
We are planning on supporting dependency’s eventually though
server owners who want to download plugins safely
They won't use a third-party.
What happens when your software picks up a malicious plugin. Or someone creates a plugin named Multiverse-Core with malware and your system indexes it?
solution: code better
Spigotmc scans for malware
wug
We are going to have a anti malware system once we support other websites
No they absolutely do not.
^^
We will go through looking for duplicate names
What? I heard lots of people say they do
spigotmc doesn't scan for malware lol, optic does but he's only one guy
Can he not scan the entire storage
no
There have been hundreds of plugins with malware hosted on Sipgot.
he does it the same way you do it, download a hundred+ plugins with spiget, then use his custom resource to scan
We will be scanning for malware soon though
Ah so it’s quite slow I would assume
We will have virustotal api integration, we will add our own custom back door protection ontop of that
I really see no benefit of indexing and downloading every single plugin over just pointing to spigot cdn
How are we meant to get all plugins for tab complete?
Oh you mean
We need to recognize already downloaded plugins
Solution: don’t
I feel like tab completing 100k plus entities will make brigadier very unhappy
We have it already coded, we are scanning right now
Nope
Also
it can be done async but ye
It will show maybe 3k max, we won’t show tab compete for the first 3 letters
Not all 100k resources are plugins either
"lifesteal- 300000 possible matches found"
Lol
does anyone know if it is possible to make a PR for the Spigot repo?
Yes
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
there it is
?stash
?contributing
fly in on his kangaroo
can confirm he flew to visit me after I signed the CLA
thanks!
No matter the version, server fork, or situation
can i get the max of enchantment level there is safe to enchant?
Isn’t there a getMaxLevel
What
Anyone a fix for this https://pastebin.com/u83Czf5s if so please help
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.
org.bukkit.command.CommandException: Cannot execute command 'discord' in plugin MoonSimple vv1 - plugin is disabled. at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_19_R3.CraftServer.dispatchCommand(CraftServer.java:906) ~[paper-1.19.4.jar:git-Paper-468] at org.bukkit.craftbukkit.v1_19_R3.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.4.jar:git-Paper-468] at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.4.jar:?] at net.minecraft.commands.Commands.performCommand(Commands.java:322) ~[?:?] at net.minecraft.commands.Commands.performCommand(Commands.java:306) ~[?:?] at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2280) ~[?:?] at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2240) ~[?:?] at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?] at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?] at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.4.jar:git-Paper-468] at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?] at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?] at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.4.jar:git-Paper-468] at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.19.4.jar:git-Paper-468] at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?] at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1318) ~[paper-1.19.4.jar:git-Paper-468] at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1311) ~[paper-1.19.4.jar:git-Paper-468] at net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:114) ~[?:?] at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1427) ~[paper-1.19.4.jar:git-Paper-468] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[paper-1.19.4.jar:git-Paper-468] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[paper-1.19.4.jar:git-Paper-468] at java.lang.Thread.run(Thread.java:833) ~[?:?]
this is the error
Logs are clear this the code why it isnt working
public final class MoonSimple extends JavaPlugin implements CommandExecutor, Listener {
public class GravityBlocks extends JavaPlugin implements Listener, CommandExecutor {
why 2 extends JavaPlugin
making 2 plugins in 1?
hehe
Ah ggs
or is this 2 plugins in 1 post?
,
i feel kinda dumb i can't figure out the canEnchantItem method
how would i do the check?
Guys how can I do that , if a player accepts a request from a player , if the player accepts it , that player who has accepted and the one who sent it can not 'attack?
If Enchantment.canEnchantItem(myItem)
Cannot make a static reference to the non-static method canEnchantItem(ItemStack) from the type Enchantment
nvm lol sleepy brain
Thank you much Coll
Fixed thank you
when I use block.setType(Material.WHITE_SHULKER_BOX); how would I change the direction it's facing?
What encoding do I even use for section?
Shulker boxes are Directional https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/Directional.html
It's probably a bit better to create the block data and set it instead of the material
block.setBlockData(Material.WHITE_SHULKER_BOX.createBlockData(blockData -> {
((Directional) blockData).setFacing(BlockFace.EAST);
}));
(you can cache that BlockData if it's not dependent on some local variable if you want)
ur a life saver tysm!
Why would my IJ be crashing instantly when trying to install a project to my local repo
Completely frozen
Third time
what is going on
In the spigot repo, if I want to replace this
public void removeVehicle() {
if (this.vehicle != null) {
Entity entity = this.vehicle;
this.vehicle = null;
if (!entity.removePassenger(this)) this.vehicle = entity; // CraftBukkit
}
}
with something like this
public boolean removeVehicle() {
if (this.vehicle != null) {
Entity entity = this.vehicle;
this.vehicle = null;
if (!entity.removePassenger(this)) {
this.vehicle = entity; // CraftBukkit
return false;
};
return true;
}
return false;
}
what's the best min-diff way to do that?
better to compile a plugin for java 16 or java 17?
latest
Use Java 17 then.
yeah
I'm trying to get the description of something inside of something that is inside a list in a configuration. That probably didn't make sense, but here's a code to explain it:
people:
names:
joe:
desc: "joe is joe"
alex:
desc: "alex is alex"
I basically want the description of Joe. How can I get that?
getString("people.names.joe.desc")
whats getKeys
something you dont need
just use getString
with the path being people.names.joe.desc
Forgot to remove the getkeys from the copy/paste 😛
what do I feel like I tried this before and it did "nope" to me
because you made a typo?
Then show code
or because your data file isnt consistent enough
What kinda weird question is that?
.you should ask for the LOWEST version
Compile for the lowest version you want to support
Hey,
Does anyone know what I need to change in the dependencies of a bungeecord plugin when when I want to create a plugin for 1.8.8?
that depends on what you already have in your dependencies
latest bungeecord works fine even for your outdated mc version
so just upgrade your bungeecord dependency to latest, and there you go
how to check for an empty slot in inventory? if I need to do it in a cycle, then I need to check for null or for Material.AIR?
yes
lol
How can I check the water level of a cauldron, since trying to look into it the methods needed seem to all be deprecated?
cast the cauldron's blockdata to Levelled
For breakfast should I do a fry up or have a sandwitch?
mfnalex yes.
only WATER_CAULDRONS and SNOW_CAULDRONS are levelled though, lava cauldrons are not
well I thought they asked whether they should check both
items in an inventory are nulalble, but sometimes they also return Material.AIR so I would always check both lol
to keep it interesting
public static void forEachNonNullItemInInventory(Inventory inventory, Consumer<ItemStack> consumer) {
for(ItemStack item : inventory) {
if(item == null) continue;
if(item.getAmount() == 0) continue;
consumer.accept(item);
}
}
can't hurt to double check it
yeah because this would be sooooo much better as instance method, right
actually it'd be pretty stupid to not make this method static
What then?
not everything static is bad
?jd-s
then you check the javadocs for Levelled and see that you can get the Level using getLevel()
Ah, thanks
imagine having to do this lol```java
new ChatColor().translateAlternateColorCodes(...);
lmfao
"oh mah gawd, STATIC, you must suck at programming"
bruh
i thought about rewriting this whole class, nah man
this class is 2000 lines and dude did made all his fields public :)
lombok moment
just replace
public (.*)\s+(.*)(\s+=\s+.*)?;
with
@Getter private $1 $2$3;
should work for both normal fields and fields with a value
then move all the calls to that getter 💀
you can also select all the fields, Refactor -> Refactor this -> Encapsulate
then check "Use accessors even when field is accessible" or set the field's visibility to private
yea lmao
javadocs are great bruh
How can I reduce the durability of a tool?
Since ItemStack#getDurability and ItemStack#setDurability are depricated
damageable interface or something
honestly i prefer the old api
declaration: package: org.bukkit.inventory.meta, interface: Damageable
Cheers!
be sure to import org.bukkit.inventory.meta.Damageable and not org.bukkit.entity.Damageable
what the
How do I get back the ItemStack from the damageable?
you cast the meta to damageable then set the meta on the stack
literally when is java gonna get a @Delegated without lombok 😭
references are fancy pointers
an alias is auto& x = c
or something that looks like tat
cmon bruh
must i really cast a BiConsumer<?, ?> to a BiConsumer<Object, Object> bruh
does this even make sense, building for java 8 but using java 16 features?
how would that even work
idk i dont use gradle
Some new features can still be compiled to java 8 compatible bytecode
pretty sure Eclipse would bitch about that
im just getting an error
I've never seen maven accept anythign but the same source/target
uhh what i just changed it
probably didn;t clean
I would recommend making use of toolchains instead for Java versioning
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
A little nicer
target can be higher than source in maven at least, but the other way around doesn't work
uhh that gradle file has 39 warnings so id rather not touch it
I think you can do some groovy-syntax stuff too with java.toolchain.languageVersion = JavaLanguageVersion.of(17)
But I'm no Groovy expert
what's the difference?
lmao beats me. I just know that toolchains are newer
lol ok
stuff writing 4000 images to the compiled version 💀
and after i executed the clean task, still same error
The advantage is that Gradle can handle any inconsistencies across JDK versions in how exactly the JVM encodes the vendor information.
So basically you can also set which vendor you want to use
vendor = JvmVendorSpec.ADOPTIUM
ah here maybe
I'm sure there are some other things you can do with toolchains though
i have no clue how to fix this error, i thought i change the version everywhere
what do we have now bruh
even though i add the --add-exports the package is not visible
Oh boys:
I have 2 identical arrays:
(when converted into strings:)
[[IRON_INGOT], [IRON_INGOT], [IRON_INGOT], [IRON_INGOT], [null], [IRON_INGOT], [null], [null], [null]]
and
[[IRON_INGOT], [IRON_INGOT], [IRON_INGOT], [IRON_INGOT], [null], [IRON_INGOT], [null], [null], [null]]
But for what ever reason, the first array != the second array and it's fuckign everything up
its something with annotations
How is it you're comparing them?
if top == bottom
If it's an array of arrays you'll want Arrays.deepEquals()
(because that string looks like an array of arrays)
wdym does not export it, i added the --export
Bro wtf are you working on? lmao
Yeah, of?
TDG?
dunno what that means
Tower defense game?
ye
I have no idea why they feel compelled to use com.sun packages. Those are JDK internals
i have no clue why everyone is using gradle either
I wouldn't say "everyone"
I use maven because it does everything I need and I've no reason to use anything else.
according to some websites, over 78% of java devs use maven, gradle is at 38%
i use maven cuz i dont understand gradle kek
you do realize that you can use both right?
overlap
nonono
That's impossible
Trust
all my forks use gradle and i add them to my maven project
what bothers me are the 38 warnings in the build.gradle file
now update gradle and the 38 warnings will turn into 117 errors
oh those are errors actually
💀
time to add more module exports then ig
error: package com.sun.tools.javac.code is not visible wdym i added '--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED'
this is hilarious but it is also true
uhh the code yes
sometimes I think gradle was meant as a joke but some people didnt get it so they started to use it
myes
hm at least I dont remember doing that
stuff also tells me to use tasks.register instead of task
Anyone have trouble with updating Minecraft? It gets to 60% then drops down to 40% then stutters up to 50% and crashes.
works fine for me using MultiMC on macOS and win 11
Hmm k will try rebooting. I wasn't sure if there's a cache I should clear or somethig
listOfEnchants = Arrays.stream(Enchantment.values())
.map(e -> e.toString())
.map(e-> {
return e.substring(e.indexOf(',')+2,e.length()-1);
})
.toList();
contains ARROW_DAMAGE
BUT
Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(strings[0].toLowerCase(Locale.ENGLISH)));
is null if i stuff ARROW_DAMAGE in as argument. why, and how do i fix it?
the string 'infinty' works despite not existing in the enchantment enum???????
gen things seems to be gone
Is there a way to prevent particles like the totem one from falling to the ground? Changing the speed does not influence this unfortunately
nope
theres only a max speed value
which makes it not fly away randomly
classes gone bruh
hello I am trying to disable the spawn of wither skeleton on my pvpfaction 1.8.8 server, but I can't find how to do it, can help me ?
listen to EntitySpawnEvent, cancel it if it's a wither skeleton
bruh always the same thing, but i added in my build.gradle and gradle.properties
@EventHandler
public void onWitherSkeletonSpawn(EntitySpawnEvent event) {
if(event.getEntityType() == EntityType.WITHER_SKELETON) {
event.setCancelled(true);
}
}
tbh I would just stick to java 8 and stop worrying about module shit lol
i need newer api
Hey, all! Is there a standard or well-known plugin api that makes creating flicker-proof dynamic scoreboards easy? Or perhaps a standard way? I've researched for days and can't figure it out.
FastBoard
you can use my code for this from hypixel dues repo https://github.com/fodded
I should look into scoreboards
wouldnt instanceof be better here?
thank you!
why?
both will work fine
Either works. instanceof will account for subtypes of wither skeletons though
There aren't any currently but maybe in the future
custom entities
hm
in that case
if something extends the nms classes would instanceof still catch it?
yeah but custom entities will always have to return an existing EntityType anway, so they'd also just return EntityType.WITHER_SKELETON
but yeah instanceof would be better in case there would suddenly be any "subtypes" of wither skeletons, that's true
is EntityType immutable?
it's an enum
lol
ah thatd do it
As a one liner this could be changed to
@EventHandler(ignoreCancelled = true)
public void onWitherSkeletonSpawn(EntitySpawnEvent event) {
event.setCancelled(event.getEntityType() == EntityType.WITHER_SKELETON);
}
NOOOO
that is ugly
I understand you're doing ignoreCancelled which is great but if there's any possibility where you can call setCancelled(false), don't do it
Why?
I mean, by default that's the even behaviour
you dont want to uncancel previously cancelled event
It's a bad habit to get into because you'll inevitably end up un-cancelling some other listener
Again, in this case you're ignoring cancelled events so it's not an issue
but it's a bad habit
if you like oneliners, I wrote a death chest plugin in 5 lines of code https://github.com/GodCipher/the-cipher-project/blob/master/src/main/java/we/are/project/cipher/AngelChestListener.java
no shit, lol
wow
Understood
I had this in mind that's why I added the ignoreCancelled
in this case you're ignoring cancelled events so it's not an issue
but it's a bad habit
Oh, thats beautifull
Is that what you call it? lol
Just look at it, everything is in one line, you don't need to scroll to read
It's amazing ❤️
(obviously I'm joking)
the rules for that repo were "max 3 semicolons per line, max 35 lines per contributor"
imports and package declarations not counted
lmao same error in ij
The chat system in minecraft. Does it propgate to everyone in the world or just people nearby?
default chat sends to everyone in the server im 90% sure
Can I interrupt it via using a listener and cancelling the event?
yeah sure
Thank you
this was 100% wrote spread out then shrunk
If he wrote that originally like that instead of shrinking it then he would be psychopath
No one in their right mind would ever write code like that
well I wrote it exactly like that, just with more newlines
Is there any ORM for Java which allow you manage SQL and NoSQL as model, so them you dont care about what db they use
So them you can code being independent from their storage
sun code be like: values.head.fst.name.table.names.value
He? I dont using sun
Good. Don't. If you're using a com.sun package you're already doing something wrong
well i nearly fixed my errors
only need access to sun.reflect.annotation package
exporting a package from system module jdk.compiler is not allowed with --release smh
and doing '--add-modules=jdk.unsupported' still says error: package sun.reflect.annotation is not visible import sun.reflect.annotation.AnnotationParser; ^ (package sun.reflect.annotation is declared in module java.base, which does not export it to the unnamed module)
How can i launch an entity exactly X blocks up?
Exactly? I don't think anybody has a direct 1:1 mapping
Okay, so ill jsut have to try around?
Yeah pretty much
Launch a minimum, maximum, and in between, then try to determine a formula for that
Unless you're only launching a very specific # of blocks, in which case yeah just toy around until you get the number you want
the gravity is 13b/s^2 according to google, i guess one could turn that into b/ticks^2 and then calculate the needed velocity or sth
Or you can put in random numbers and hope it works 
minecraft gravity in regards to earths
is approximately 4g's
players will accelerate at 32m/s^2
yeah it's more like 1.33 G
why 32? it's 13 blocks/second^2
Are you telling me bedrock players have less gravity
math is weird
Wait what’s javas gravity
https://www.minecraftforum.net/forums/minecraft-java-edition/discussion/123865-acceleration-of-gravity-in-minecraft-science here they claim it's 23.31m/s^2
Okay, folks, I just did a little science experiment in Minecraft, and I want some help. Today, we are going to find out the universal constant for the accele...
but it's also from 2011
no its 32m/s^2
with terminal velocity being 78.4 m/s
in blocks per tick
for the first one its 0.08 blocks/tick^2
terminal velocity at 3.92 blocks/tick
and the drag 0.02
it is also in java edition minecraft
it depends on which way you are determining it
spherical vs flat plane
Can someone possibly do a code review of this? https://github.com/JSH32/DiscordLink/
I've been trying to get my plugin to support multi platform so i've split spigot and core into separate modules. Providing spigot implementations and my own annotation based command framework which is read and registered using brigadier/commandapi
(it is in a not completed state)
yeah no thats not how it works. send us some pieces to code review. commits, prs, whatever. not a whole ass project
Yeah i should've linked the command system since thats the stuff i actually need taken a look at
and could be for bedrock lol
but I am pretty sure both are relatively the same though
since bedrock borrowed some numbers from java edition
like the acceleration for players
Example of command: https://github.com/JSH32/DiscordLink/blob/master/core/src/main/java/com/github/jsh32/discordlink/core/commands/CommandLink.java
Command implementation: https://github.com/JSH32/DiscordLink/blob/master/spigot/src/main/java/com/github/jsh32/discordlink/spigot/SpigotCommand.java
Command framework: https://github.com/JSH32/DiscordLink/tree/master/core/src/main/java/com/github/jsh32/discordlink/core/framework/command
is there a command alternative for mvn clean build in gradle?
not sure if that is also the same in bedrock but again wouldn't surprise me if it was
gradlew clean build
also seems I am slightly off, 3g's
you should work on the method complexity
however knowing all that
you could launch an entity or player exactly however many blocks
if you know how to work out the math 🙂
I will say
I got these as differences in velocity per second
its easier to launch a player or entity straight up as opposed to other angles
hi.
there is drag on entities and players. For Players its 0.02
this question might be out of place for this server and channel but actually nvm.
not sure how you figure launching an entity or player straight up isn't easier o.O
bruh i needed
Is there a way to have a villager that is not aware look at a player when they right click on them?
is it?
43 problems in my build.gradle but thats something else
not sure how i came up with 0.08 then
that is the blocks/tick^2
which is correct in what you got
if you convert it to m/s^2 its 32
yeah DEFAULT_BASE_GRAVITY in LivingEntity is 0.08 b/t^2 so it's indeed 32b/s^2
GPT says ```java
public void launchPlayerAtTarget(Player player, Location target) {
// Calculate the direction vector from player's position to target
Vector direction = target.toVector().subtract(player.getLocation().toVector()).normalize();
// Calculate the horizontal distance to the target
double distance = Math.sqrt(Math.pow(target.getX() - player.getLocation().getX(), 2) + Math.pow(target.getZ() - player.getLocation().getZ(), 2));
// Calculate the vertical distance to the target
double heightDifference = target.getY() - player.getLocation().getY();
// Calculate the initial velocity needed to reach the target
double initialVelocity = Math.sqrt((2 * 9.81 * (heightDifference + 0.5 * distance * Math.tan(Math.toRadians(45)))) / Math.sin(Math.toRadians(45)));
// Calculate the x and z components of the velocity vector
double x = direction.getX() * initialVelocity;
double z = direction.getZ() * initialVelocity;
// Calculate the y component of the velocity vector
double y = initialVelocity * Math.sin(Math.toRadians(45)) - 0.5 * 9.81 * Math.pow(distance / (initialVelocity * Math.cos(Math.toRadians(45))), 2);
// Set the player's velocity to the calculated velocity vector
player.setVelocity(new Vector(x, y, z));
}
🐧
seems legit
doesnt work
copied it 1:1 but it's quite off
provide a small upwards velocity (vy > 0) to hopefuly avoid the issue of sliding on the initial block
How do i change my java version to 17 in the pom.xml?
😳
<java.version>1.8</java.version>
``` Do i change this to 1.17?
Alright so I am cancelling EntityRegainHealthEvent to implement my own regen system, but the player still loses food as if he was regenerating.
What event handles the player losing food when low hp?
When i try to build with 1.17 it tells me this:
ty
why was it at 1.8 before then?
That worked thanks :D
you are not wrong in calling it 1.17
it is technically correct
however, in code and how the version is derived it is actually 17
Oracle dropped the 1, because like minecraft there isn't going to be a version 2
well if there is, it won't be the same as we know it right now
Basically: Oracle make ooga booga change for no reason, everyone adjust to ooga booga change, just like minecrafts versioning when everyone expected 2.0
the change wasn't arbitrary
2.0? Wdym
it has always been a thing to omit the 1 when referring to java versions
so java 1.8 is also known as java 8
same with 1.7 being 7
Yeah, after minecraft 1.9 people kinda expected 2.0, not 1.10
if anything minecraft followed suit of java
Nobody expected that o0
Why would 2.0 come after 1.9?
People def expected that to a degree
Idk maybe people who dont know what major/minor/patch versioning is expected it
very many people expected minecraft to at some point have a version 2
however mojang already stated that there won't be a version 2 with the current game
Yeah but why should that point be exactly 1.10
not without a major revamp of verything
How can I detect wether a player is losing hunger from moving around or from being low hp?
because people weren't sure if mojang was going to have a version with 2 digits after the decimal unlike the 1 there has been
you don't
certain packets have expected sizes and if they are larger then that, there is something wrong or malformed about it
however for some others, the network code should automatically break up the information to fit into multiple packets automatically
did they really forget to add an select all thing, there are like 100 fields 💀
F
also alex your regex public (.*)\s+(.*)(\s+=\s+.*)?; also matches methods
public\s+(@)*.*; seems to select public fields but i cannot figure out how to replace it
lol
All external API calls by the plugin should be wrapping in a thread. Is the BukkitRunnable the correct class to use for that?
wdym by external api calls
My plugin calls an external API server but without doing it in a task is can be blocking.
public void launchPlayerAtTarget(Player player, Location target) {
// Calculate the direction vector from player's position to target
Vector direction = target.toVector().subtract(player.getLocation().toVector()).normalize();
// Calculate the horizontal distance to the target
double distance = Math.sqrt(Math.pow(target.getX() - player.getLocation().getX(), 2) + Math.pow(target.getZ() - player.getLocation().getZ(), 2));
// Calculate the vertical distance to the target
double heightDifference = target.getY() - player.getLocation().getY();
// Calculate the initial velocity needed to reach the target
double initialVelocity = Math.sqrt((2 * 9.81 * (heightDifference + 0.5 * distance * Math.tan(Math.toRadians(45)))) / Math.sin(Math.toRadians(45)));
// Calculate the x and z components of the velocity vector
double x = direction.getX() * initialVelocity;
double z = direction.getZ() * initialVelocity;
// Calculate the y component of the velocity vector
double y = initialVelocity * Math.sin(Math.toRadians(45)) - 0.5 * 9.81 * Math.pow(distance / (initialVelocity * Math.cos(Math.toRadians(45))), 2) + heightDifference;
// Set the player's velocity to the calculated velocity vector
player.setVelocity(new Vector(x, y, z));
}
maybe? this also has an upwards angle of 45
i think its the block slide
call it async with scheduler then
everything is blocking, depends on how much blocking it is
idk how many of you guys have used rust but Actix actors are pretty nice, I think C# has orleans too, not sure if java has one
It's not always a repeating call. It's player initiated
you can still run singular tasks async with it
Here, even more updated. Default launch angle is 45 and if there is a wall in the way it calculates to hop over it
kk any different then using BukkitRunnable? Sorry to ask I'm' picking up from a previous engineer and he used it.
There's one task that runs a lot to pull a message queue
pretty much the same thing
btw since that code is GPT generated, i have no idea why the hardcoded 9.81 is present. I assume its just standard gravity acceleration?
Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.
Just confirming this means anything internal to Bukkit and not external API's
that's the earth's gravity lol
minecraft gravity is accurate to earth lmao /s
depends, you can literally jump one meter in minecraft
yeah
i can jump one meter in real life if i try hard enough
well... many things in bukkit are safe for async, e.g. using CHunkSnapshots
now it's going 45° into the other direction
Kk this doesn't really do much within the Bukkit except send chat messages to and from players.
The one that takes a while is the API call that loads a list of NPC Villagers into the Config file. The response on that request has thrown a warning that it's taking too many ticks
Replace this line:
double launchAngle = Math.toDegrees(Math.atan((initialVelocity * initialVelocity + Math.sqrt(initialVelocity * initialVelocity * initialVelocity * initialVelocity - 9.81 * (9.81 * distance * distance + 2 * heightDifference * initialVelocity * initialVelocity))) / (9.81 * distance)));
With this line:
double launchAngle = -Math.toDegrees(Math.atan((initialVelocity * initialVelocity + Math.sqrt(initialVelocity * initialVelocity * initialVelocity * initialVelocity - 9.81 * (9.81 * distance * distance + 2 * heightDifference * initialVelocity * initialVelocity))) / (9.81 * distance)));
💀
shocked if it works
what should i use to make a list that puts things in a defined order?
where is that supposed to be? the code from your previous message doesn't have that two lines like you sent them
nvm change launchangle to ```
double launchAngle = Math.toDegrees(Math.atan((initialVelocity * initialVelocity + Math.sqrt(initialVelocity * initialVelocity * initialVelocity * initialVelocity - 2 * 9.81 * (heightDifference + distance * Math.tan(Math.toRadians(45))))) / (9.81 * distance)));
uhh a list already keeps order
guys who have a kind soul, help. you can make me a plugin radiation (you need to choose a world in which there will be a radiation strength from 1 to 9)
something like this: /red [world] [power].
power 1 = 1 damage in 60 seconds
power 2 = damage in 60 seconds and so on
ah cmon not again
thats dude s using some kinda of self written library that i dont like
pls ping me or write in private messages
yeah but i want to define the way it sorts
I asked chatgpt, here you go. Probably shouldn't ask for people to make stuff for you but im bored and messing with AI
TreeSet with a custom comparator
Don't ask me how to run it either
How can I make a block not drop anything when broken?
this is pretty smart
man then wrote his own annotation processor to make it behave like a record but i believe it supports getters too
Generates ""value types"" classes that are packed into integer primitives of the most aproppriate size.
* It would be nice if Java didn't make crazy hacks like this necessary.```
lol
How can I make a block not drop anything when broken?
Many ways
Well thank you for this conclusive and helpful answer!
Oh this is pretty cool
Literally just regular byte representation of data. Quite literally a C struct
Could ya like, open
dunno how i would use it anyways
Two different evengs
Can be used
Well
Three or more if paper is also included
BlockBreakEvent and BlockDropEvent is probably what you are looking for
Yes
I am aware of that
But considering all of the information i've found has proven to be incorrect I'd love to hear an actually working solution
?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.
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
What do you want, my empty BlockBreakEvent?
For gods sake
Some people just choose to be difficult
Either listen for the BlockBreakEvent cancel it and set the block to air.
OR
Listen for the BlockDropItemEvent and remove the blocks from the list. (BlockDropItemEvent#getItems())
Cheers
uhh
So uh, wanna hear a fun fact. When I cancel the BlockBreakEvent the block still drops it' drops (even though it does cancel the event properly).
I'd imagine BlockDropItemEvent is called first then or something
BlockBreakEvent has a method to set it to not drop items
labels 😭
It doesn't work
Do you have other plugins running
looking at the internal code, im wondering why they dont use registries like minecraft does
?nocode