#help-development
1 messages · Page 2055 of 1
how do i import worlds?
probably wanna look at world creator
but i got the world as a folder
I just noticed I need the class instance
its just not imported
to return them in PersistentDataType#getComplexType
@valid solstice can i be honest
if you wanna work with vectors
go learn how to do it on paper first
math!
because if u dont really understand what ur doing its not going to work anyway
physical paper
yes, physical
math is good
learning vectors is 1 week of your time
can you even make a parallel vector?
Because the bukkit vector is only x,y,z but does not include any xoff, yoff, zoff and stuff like that
vector is just an array of weights which can then produce one weight/line in any direction
right
can be different things
but in essence yes
xoff?
an array with the size of n
offsets?
xOffset
yeah if ur talking about any world space just all the dimensions
and if its a multidimensional array its called matrix
what would that do in a vector
yea i've already learnt the basic concepts of vector
multiplication, cross multiplaction, dot product etc..
but u didnt learn what u need
cause im 100% sure
that this is basic school material
for higher degrees
i just didnt pay good attention i guess
🤣
if i make a listener and the register events with getServer().getPluginManager().registerEvents(), can i delete the listener later in the process?
like wont it cause errors or stuff
oh thanks
i was looking for an unregister function but couldnt find it
in the PluginManager at least
How else are you going to create a parallel vector?
btw dumb question of mine, PDC is just a wrapper class for nms tags right?
Depends, but mostly yes
yes and no
well thats two vectors, position and rotation right
whats the no part of it
for the example that you cannot access vanilla NBT tags
yea
PDC can only access NBT tags that were also created using PDC
but bukkit vector only support x y z
how does pdc store chunk info
but like putting pdc keys is in the backend accessing nms methods right?
in the region file
yes
kk
?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!
i know but in physics you dont have a 2 * 3 component vector right
if you want to describe an object you use two
ive never heard of vector offsets
how do i teleport to other worlds?
Block o = event.getBlock();
x.remove(o.getX());
y.remove(o.getY());
z.remove(o.getZ());
plugin.getConfig().set("x", x);
plugin.getConfig().set("y", y);
plugin.getConfig().set("z", z);
plugin.saveConfig();
Well the vector offset that I mean is mostly just the origin point of the vector
player.teleport(new Location(world, x, y, z))
i can't remove xyz when it remove it have errors help
ur trying to remove individual coords from a block?
is there a way to teleport in minecraft?
me?
as a command
yeah
u
well how
oooh you mean through commands tp to other world
yes
idk
sure i make an arraylist but when i using x.remove it have errors
tp to another world
mh okay then i will just create my own command for this
thanks orbyfied for helping
u can code one
what error
the bukkit method always takes the targetworld as a param
you need to give more information
and not write 10 messages after eachother inbetween other conversations
need more info of the type of error
The execute command supports this
the code
give us the stack trace
Not sure what the syntax is, but I certainly know that execute supports cross-world tp @dapper ether
i hate to run commands via a dummy command sender xD
feels so messy
seems like one of the lists is null
@errant narwhal
Caused by: java.lang.ArrayIndexOutOfBoundsException
y.add(a.getY());
z.add(a.getZ());
plugin.getConfig().set("x", x);
plugin.getConfig().set("y", y);
plugin.getConfig().set("z", z);
plugin.saveConfig();
```i was add the list before
the mem address hes pointing to is null
^
ignore what i said
my arraylist was integer bro
i dont think u get me bro
about change this to long?
u remove the .getX()'st list entry
not the first find
with that value
u need to
list.remove(list.find(.getX()))
something like that
ok
dont forget the guard clauses
bro it said not found "find"
its list.indexOf(...)
tbh i always use maps whenever the order is irellevant
working very well with ini files
after all
whats a good way to record short clips of a specific part of the screen as a video
i see people sending quick videos here always
but i need to open obs and then focus it and then record it and then send it
microsofts built in recording software?
ctrl windows R or so
and then ur in the xbox game menu
from there u can start recordings
i have a better gpu: the intel uhd integrated graphics 680
i think most ppl nowadays use nvidias recoder
which makes sense since u need to control the gpu anyway
makes sense that the manufacturer offers a software for it
ok so im having weird behaviour with this code:
InventoryAction action = event.getAction();
switch (action) {
case HOTBAR_SWAP:
case PLACE_ALL:
case PLACE_SOME:
case PLACE_ONE:
case DROP_ALL_SLOT:
case DROP_ONE_SLOT:
event.setCancelled(true);
return;
}
ItemStack cursor = event.getCurrentItem();
if (cursor == null) return;
inv.setItem(slot, cursor.asQuantity(1));
if (event.getClick().isRightClick()) {
cursor.setAmount(64);
}
event.setCursor(cursor);
it seems like it always places one back
into the inventory
while im only clicking once
how can i prevent this?
should i cancel the event and set the cursor?
ah ok
it does what ur telling it to xD
so
u set it only once as quantity 1
and then u adjust the itemstack to Q64
but never apply it to the slot
i mean im clicking to pick up an item but then i set the cursor and it places it back
nah but i dont need 64 iin the slot
i want 64 in my hand when i right click
just get the itemslot of the cursor and set the item to it
the bukkit api is too big needa check it myself although ill do some rl tasks first
Am I stupid or is this a MockBukkit bug?
@Test
void testItemStack() {
final NamespacedKey key = getKey("itemStack");
final ItemStack itemStack = new ItemStack(Material.DIAMOND_ORE);
player.getPersistentDataContainer().set(key, DataType.ITEM_STACK, itemStack);
final ItemStack savedItemStack = player.getPersistentDataContainer().get(key, DataType.ITEM_STACK);
assert itemStack.equals(savedItemStack);
}
[16:40:19 SEVERE]: Could not call method 'public static org.bukkit.inventory.ItemStack org.bukkit.inventory.ItemStack.deserialize(java.util.Map)' of class org.bukkit.inventory.ItemStack for deserialization
[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.732 s <<< FAILURE! - in com.jeff_media.morepersistentdatatypes.AllTests
[ERROR] com.jeff_media.morepersistentdatatypes.AllTests.testItemStack Time elapsed: 0.031 s <<< ERROR!
java.io.IOException: Failed to deserialize object
at com.jeff_media.morepersistentdatatypes.AllTests.testItemStack(AllTests.java:81)
Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because the return value of "org.bukkit.configuration.serialization.ConfigurationSerialization.deserializeObject(java.util.Map)" is null
at com.jeff_media.morepersistentdatatypes.AllTests.testItemStack(AllTests.java:81)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] AllTests.testItemStack:81 » IO Failed to deserialize object
is ItemStack serializable?
this is what its doing now
in theory yes
ofc
testing world lmfao
ur new itemstack instance is missing the quantity param
so ur calling a different constructor
might be the problem idk
wdym? new ItemStack(...) creates a stack with amount 1
also the error message is clearly about the deserialization and not about creating an itemstack 😛
well not neccesseary
if it got scrambled during serialization
it obv cant be deserialized
so you want to tell me that ItemStack's that were created using new ItemStack(Material) cannot be deserialized again? Because I 100% doubt that
idk it just peaked out
!paste
every item stack has a quantity
?paste
so i dont think thats it
wait
ur not passing an instance to the key either
try to use this as 0st param
@tender shard
wdym? an instance to the key?
Please help me,
I am saving UUIDs in a configuration file and can read them from the config but when I'm reloading the server then it fales to load the config and I'm getting a huge error. This is my error: https://paste.md-5.net/gosugixunu.rb
to identify the plugin the key belongs to
bruh if anything except the serialization was a problem, then I would have gotten another error message
save the UUID as string
getConfig().set("something",myUuid.toString())
then load it again using
UUID.fromString(getConfig().getString("something"));
I'll try that
is anyone else trying to use github with intellij that could answer this? how do i share an intellij project into an existing repo?
Is there another way to get an enchantment without using Enchantment#getByKey?
into an existing repo, that might be a bit complicated
No, I want to convert e.g SHARPNESS to Enchantment.DAMAGE_ALL
you'll have to force push your stuff since the histories are unrelated. it would be a way better idea to just create a new repository
alright
new to github as well so i’m not familiar with really what a repo is
but a new repo for each project seems a bit much to me ig
a repository is like "your project". someone can clone (= "download") it, make changes on their PC, and then submit and push ("=upload") it. However git doesn't allow you to upload stuff if you haven't downloaded it from the same repository, in very easy words
I'd just click on VCS -> Share on GitHub and create a new repo
it is a "database" for changes made to files
just do this and it'll work 😄
but i was just trying to make a repo for my entire minecraft server to have all of its resources inside of it
but that’s not conventional from what i gather
I read the Javadoc and getByName is deprecated, back to getByKey
you can do that of course but you can't just "upload" stuff to it. you have to clone the repo, add the stuff locally, then commit and push your changes
i see, ok
lol
destroy the entire repository
Oh yeah I could probably do that
"wdym there's a merge conflict"
deletes everything
"there fuk u now there's not"
lol
My biggest fear is that I accidentally commit a merge conflict without git noticing
well reverting stuff is easy though 😄
it never prevents you from commiting a merge conflict
(although I don't know how it works in CLI - I can only revert commits with IntelliJ or github's website lol)
yeah but it highlights it though right?
I usually ammend
committing conflicts is no problem, pushing them though requires to resolve the conflicts
I only rely on syntax errors to detect merge conflicts
ah
That was working but now if(MyClass.getUUID == p.getUniqueId()) is not working anymore
oh boy
yes, you must use equals() instead of ==
what's the different?
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.
There's a new blog post for you alex
git status will still say that there is a conflict even if you resolved it - you can still git add no matter whether it was resolved
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Difference between == and .equals()
yeah why not lol
thanks
Perhaps with the advent of primitive objects this issue might get resolved
Or perhaps even worsened
my understanding was just that .equals could be overloaded
TL;DR: If we both buy the same tshirt, our tshirts are equals() but they aren't ==. although they look identical, they are two different objects
Probably latter
cuz java’s pissy and wont let you operator overload
😮
== checks if it's the exact same tshirt, equals() checks if they are the same size, have the same print, are equally dirty, etc etc
because equals() is a method right?
overlaoded? It can be overriden of course
yeah I'm still at the beginning
by default, equals() does the same as ==. But almost every proper class overrides equals() to compare the contents of the objects instead of just "is this the exact the same object"
so == is about memory addresses??
yes
wow
if you look at new Object().equals(), you'll see that it also only does ==
that’s strange
but now check what new ItemStack().equals() does
here's the equals() of UUID:
/**
* Compares this object to the specified object. The result is {@code
* true} if and only if the argument is not {@code null}, is a {@code UUID}
* object, has the same variant, and contains the same value, bit for bit,
* as this {@code UUID}.
*
* @param obj
* The object to be compared
*
* @return {@code true} if the objects are the same; {@code false}
* otherwise
*/
@Override
public boolean equals(Object obj) {
if ((null == obj) || (obj.getClass() != UUID.class))
return false;
UUID id = (UUID)obj;
return (mostSigBits == id.mostSigBits &&
leastSigBits == id.leastSigBits);
}
sheesh
it's a mess
it simply compares whether the internal values (mostSigBits and leastSigBits) are equal, and if yes, two UUIDs are also considered equals() even if they are actually two different objects. but obviously both represent the same UUID so they are equals()
fr
it clones the item meta once or twice and noone has bothered to fix it
Not even the paper team
At this point I'm afraid to fix it myself
lol
Does it? Seems like it just checks the amount and then checks isSimilar
?stash
Does someone know how I can remove all those @ NotNull annotations from the generated javadocs? it looks like a mess
also they somehow appear twice in the description of each method
lmao
Appearing twice is a known bug
what in the world
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/inventory/ItemStack.java#290 calls getItemMeta, which clones the meta
thus an .isSimilar call clones the item meta 4 times
now this is big brained 
NNY talked about this ages ago, there is at least one PR that fixed this
miss that man
but is that actually a problem?
I mean okay it's not nice but I'd rather see pull requests for new features instead of fixing stuff that's been working fine since 10 years 😄
imagine doing this with a shulker box full of fully written books. not sure if performance would be tanking but it could be
i have a question how can i make a compass for manhunt that can track a player? can someone help me with that pls?
that's true but I've never seen any problems regarding it anyway
declaration: package: org.bukkit.inventory.meta, interface: CompassMeta
I know that getItemMeta is a pretty expensive call either way - I improved the performance of my CE plugin drastically by removing/caching these calls
You can use CompassMeta#setLodestone(Location)
okay thx
doesnt that only work if there is a Lodestone at that location or something
I highly doubt that
since it takes a Location and not a block
and that location could be in an unloaded chunk
I doubt that it actually loads the chunk just to check if there is actually a lodestone
but I also haven't tried it
Yes, you'd need to call setLodestoneTacked(false) or something like that
no, true
no, false
whut

UwU
true means that there is a lodestone at that block - which is false
you're right
^
Gets if this compass is tracking a specific lodestone. If true the compass will only work if there is a lodestone at the tracked location.
false means that there is not a lodestone at that block
mirrors the nms ig
makes sense, NMS is always weird
It also confused me, but thankfully someone was fast to explain my mistake to me
D:
Whoa, why so swedophobic?

what a goofy word
Bruh move to Ukraine
Meh Canada is a pretty big disaster rn
I quite like my country, but man I wish the public transportation was better
I'm freezing
Hey,
I have a schematic file.
I want it to be placed evenly spaced inside a newly generated void world.
Any idea how I can do this?
I have no idea about custom world generators
we had a 5 day summer lol
don't say anything against the deutsche bahn! they perfected the art of always being too late if you're in a hurry
this ~30 minute drive takes around 1.5 hours with public transportation
yeah we too, I got totally sunburnt the last days but today it's cold again >.<
yeah but who wants to go to Lützelbach anyway
I sadly live there
geol
RIP :<


Okay, apparently the getItemMeta call serves a purpose
I mean it makes sense that you'd have to call it twice
well my thought was that you could just go with the meta field, but CraftItemStack overrides the getItemMeta method to not make use of the meta field
I have an issue
so my plugin works perfectly on my server but on another server, it doesnt work
both are paper 1.18.1
Add some debug messages
?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.
how does it not work?
it doesnt even show up on the other server
any exceptions?
its just a simple teleport command
Did you even copy the file?
yeah
So you call a simple teleport command as not working?
I've seen uploads fail to server hosts before. Try deleting the jar and uploading it again if you're using a host
there are 3 commands
/c
/s
/tpme
/c and /s show up but not the teleport command
but it does work on my personal servr
tried already
But /tpme works?
yeah it does
Do you have the perms for the command?
Sure? try to op yourself anyways
Gotta make a list of hosting providers to avoid
my server
And what happens if you use the cmd anyways?
unknown command
k 1 sec
What is the output of /pl?
I'm assuming it's not loaded
how to make summoned falling blocks not fall?
disable physics
and that is how?
setGravity(false)
oh
ty
Yeah I'm an idiot
log please
Yeah, then log
alright
im not the owner
but i did ask the owner, he is gonna send soon
Might want to remove that since it contains your ips
[11:49:50] [Server thread/ERROR]: Ambiguous plugin name `Prestige' for files `plugins/Prestige (2).jar' and `plugins/Prestige (1).jar' in `plugins'
here you have it, the plugin is loading an outdated version
ah
so they added two versions?
yes, but only one is loaded I assume
whether that is really the cause is up in the air, but it explains it
I was going to assume an outdated version but having 2 is most likely the issue
was PacketPlayOutChat removed? if yes what should i replace it with
/summon falling_block{NoGravity:1b} i think
ah you were already answered
Is it item of material {material} or item of {material}?
Yes, I'm asking grammar questions in a minecraft dev server
make a sentence of that
Item metadata cannot be get for item of ${}
basically it has to error if no item meta could be resolved/get
[11:34:20 WARN]: java.lang.RuntimeException: Failed to find NMS class: PacketPlayOutChat
[11:34:20 WARN]: at ProtocolLib(58).jar//com.comphenix.protocol.utility.MinecraftReflection.lambda$getMinecraftClass$1(MinecraftReflection.java:2079)
[11:34:20 WARN]: at java.base/java.util.Optional.orElseThrow(Optional.java:403)
[11:34:20 WARN]: at ProtocolLib(58).jar//com.comphenix.protocol.utility.MinecraftReflection.getMinecraftClass(MinecraftReflection.java:2079)
[11:34:20 WARN]: at OverlordMsgRemover-1.0.jar//com.github.kaspiandev.overlordmsgremover.OverlordMsgRemover.loadNMS(OverlordMsgRemover.java:135)
[11:34:20 WARN]: at OverlordMsgRemover-1.0.jar//com.github.kaspiandev.overlordmsgremover.OverlordMsgRemover.onEnable(OverlordMsgRemover.java:62)
[11:34:20 WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
[11:34:20 WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370)
[11:34:20 WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:501)
[11:34:20 WARN]: at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:559)
[11:34:20 WARN]: at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:473)
[11:34:20 WARN]: at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:669)
[11:34:20 WARN]: at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:436)
[11:34:20 WARN]: at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:352)
[11:34:20 WARN]: at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1179)
[11:34:20 WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:320)
[11:34:20 WARN]: at java.base/java.lang.Thread.run(Thread.java:833)
this is the error i get
any ideas why?
whats at your OverlordMsgRemover class line 135?
(this.posField = MinecraftReflection.getMinecraftClass("PacketPlayOutChat").getDeclaredField("pos")).setAccessible(true);
that didnt work
idk then
never used protocollib
same o.o
also is it normal for Kotlin plugins to be 7+ MB
yes
it is normal
why is it so much bigger?
because you're shading stuff?
does World#getHighestBlock also get the highest block of player placed blocks?
- read the docs
- try it and see
it just says "Returns Highest non-empty block"
does this include player placed? idk
Hey,
I have a schematic file.
I want it to be placed evenly spaced inside a newly generated void world.
Any idea how I can do this?
I have no idea about custom world generators
did not work sadly 😦
public void createPlayerInDatabase(UUID uuid, String name) {
try {
PreparedStatement statement = plugin.getConnection()
.prepareStatement("SELECT * FROM villagerPark_players WHERE UUID=?");
statement.setString(1, uuid.toString());
ResultSet result = statement.executeQuery();
if (!result.next()) {
PreparedStatement statement2 = plugin.getConnection()
.prepareStatement("INSERT INTO villagerPark_players (UUID, NAME, ECO, STREAK) VALUES (?, ?, ?, ?)");
statement2.setString(1, uuid.toString());
statement2.setString(2, name);
statement2.setInt(3, 0);
statement2.setInt(4, 0);
statement2.executeUpdate();
}
}
catch (SQLException e) {
e.printStackTrace();
}
anyone know why this is not working? the uuid and name are valid
and there is absolutely NO errors
(also the database table is valid and the connection is successful)
*the issue is that it is not inserting new players into the table
could someone help me figure this one out?
The packet name changed IN 1.18. IIRC it’s something along the lines of ClientboundChatPacket.
close the statement too
try with resources
shit wrong ping
When I run a command and get the player, everything works, but when I add nms, it triesto get the nms class and can't find it anymore.
What can I do?
Is it possible that it comes from this:
[19:23:41 ERROR]: [STDERR] [org.bukkit.craftbukkit.v1_18_R2.legacy.CraftLegacy] Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
Can you explain a little more or provide the code that you are having this issue with? Just adding NMS to your project shouldn’t change anything. You’d have to import something for it to grab the wrong type.
[12:24:25 WARN]: java.lang.RuntimeException: Failed to find NMS class: ClientboundChatPacket
[12:24:25 WARN]: at ProtocolLib(58).jar//com.comphenix.protocol.utility.MinecraftReflection.lambda$getMinecraftClass$1(MinecraftReflection.java:2079)
[12:24:25 WARN]: at java.base/java.util.Optional.orElseThrow(Optional.java:403)
[12:24:25 WARN]: at ProtocolLib(58).jar//com.comphenix.protocol.utility.MinecraftReflection.getMinecraftClass(MinecraftReflection.java:2079)
[12:24:25 WARN]: at OverlordMsgRemover-1.0.jar//com.github.kaspiandev.overlordmsgremover.OverlordMsgRemover.loadNMS(OverlordMsgRemover.java:135)
[12:24:25 WARN]: at OverlordMsgRemover-1.0.jar//com.github.kaspiandev.overlordmsgremover.OverlordMsgRemover.onEnable(OverlordMsgRemover.java:62)
[12:24:25 WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
[12:24:25 WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370)
[12:24:25 WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:501)
[12:24:25 WARN]: at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:559)
[12:24:25 WARN]: at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:473)
[12:24:25 WARN]: at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:669)
[12:24:25 WARN]: at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:436)
[12:24:25 WARN]: at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:352)
[12:24:25 WARN]: at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1179)
[12:24:25 WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:320)
[12:24:25 WARN]: at java.base/java.lang.Thread.run(Thread.java:833)
i still get this
No, that’s something that spigot does if ANY plugin that you are using does t provide a api-version flag in the plugin.yml.
package at.theduggy.projekt;
import at.theduggy.projekt.Animation.Animation;
import at.theduggy.projekt.npc.NPC;
import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Random;
import java.util.UUID;
public class TestParticleCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
org.bukkit.entity.Player player = (org.bukkit.entity.Player) sender;
NPC npc = new NPC(player.getLocation(), UUID.randomUUID(), new Random(1000).nextInt(), "Typ");
return false;
}
}
What’s the issue here? There is no NMS code in that class.
whats line 23
^
NPC npc = new NPC(player.getLocation(), UUID.randomUUID(), new Random(1000).nextInt(), "Typ");
So a dependency issue.
?paste
How are you managing your plugin? Maven, Gradle, manually?
This is the code of the class:
https://paste.md-5.net/usijuquzok.java
Maven
Ok, now we have NMS code. Can you ?paste your stacktrace
@kind hatch
Yes
https://paste.md-5.net/vejaqiyemo.bash
unchecked casting i love it
is it getting remapped properly
I know that it is the player its just a test command
What’s line 20 of the TestParticleCommand class?
29.03 17:30:40 [Server] SEVERE java.sql.SQLException: Before start of result set
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.result.ResultSetImpl.checkRowPos(ResultSetImpl.java:517)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.result.ResultSetImpl.getObject(ResultSetImpl.java:1314)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.result.ResultSetImpl.getInt(ResultSetImpl.java:822)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.result.ResultSetImpl.getInt(ResultSetImpl.java:843)
29.03 17:30:40 [Server] SEVERE at com.wonkypigs.villagerpark.commands.giveEco.execute(giveEco.java:35)
29.03 17:30:40 [Server] SEVERE at net.md_5.bungee.api.plugin.PluginManager.dispatchCommand(PluginManager.java:207)
29.03 17:30:40 [Server] SEVERE at net.md_5.bungee.api.plugin.PluginManager.dispatchCommand(PluginManager.java:157)
29.03 17:30:40 [Server] SEVERE at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:74)
29.03 17:30:40 [Server] SEVERE at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
anyone know why this is happening?
here is line 35
statement.setInt(1, playerEcoAmount.getInt("ECO") + Integer.parseInt(args[1]));
the current database value for the column "ECO" for the player is 0 (integer) and it is not able to add 1 to it?
It was that. It changed cause I delete to unused mebers
are you concatenating two ints?
somethings not lining up with the error and the command code
So how can I do that?
uh wut
i figured out previous error, now i get this
isnt when you put a + between 2 integers, adding them?
playerEcoAmount.getInt("ECO") + Integer.parseInt(args[1])
yeah, they are both integers
in the stacktrace ur command was erroring bc of a noclass error but the command code u sent doesnt reference that class at all @manic furnace
If that method returns an int, then yes you are.
I know
is the stacktrace older than the commands current code
no
ClassCastException. Have you tried wrapping the string in that class? Or what are you doing with your code?
uh sorry i dont quite understand
well whats the error about then
do you wanna see my pretty code maybe?
Yes
Is there any common cause for a softdepend to load after the plugin?
You spelt the name wrong
not it, definitely
here is the full code
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
try{
PreparedStatement check = plugin.getConnection()
.prepareStatement("SELECT ECO FROM villagerPark_players WHERE NAME=?");
check.setString(1, target.getName());
ResultSet playerEcoAmount = check.executeQuery();
PreparedStatement statement = plugin.getConnection()
.prepareStatement("UPDATE villagerPark_players SET ECO=? WHERE NAME=?");
statement.setInt(1, playerEcoAmount.getInt("ECO") + Integer.parseInt(args[1]));
statement.setString(2, target.getName());
statement.executeUpdate();
}
catch (SQLException e) {
e.printStackTrace();
Is there any way to disable the vanilla ender pearl cooldown?
probably I think
well I did it once with skript...
but what I actually did was add throw cooldown to snowballs
not sure about disabling it
Is the current Spigot-Version 1.18.2-R0.1-SNAPSHOT?
If you can add it to any item you could probably set it to 0 and that would semi disable it
Thank you guys
Well you don’t do any validation. (At least it’s not shown here) args[1] may not be an integer. Also refer to this: https://stackoverflow.com/a/8826326
I see a way to do so by simulating the throwing of an enderpearl rather than actually throwing one
PlayerInteractEvent
check if enderpearl
than throw one with code and cancel the throwing of one so two aren't thrown
this is my amazing code
?
yes it is
Ok
static block meh
I just checked google, Integer.parseInt(args[1]) is changing args[1] from a string to an integer.
What I am not so sure about is if playerEcoAmount.getInt("ECO") is the right way to get the integer from the ECO column.
any sql experts in the chat?
is that a spigot event? @onyx fjord otherwise you forgot the @EventHandler
its a protocollib event
how do i give a player a permission?
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Is this correct for 1.18.2 mojang mappings?
why does my getInstance().getDataFolder() equal to serverpath\plugins\{pluginname}\plugins\{pluginname}\
it shouldnt
isnt that what it's supposed to do?
whait wha plugins/name/plugins/name
its creating a very weird director structure
ik
ive fixed it now nevermind
i had a function that did this File folder = new File(getInstance().getDataFolder(), folderPath);
and i passed another getInstance().getDataFolder() as a argument
HashMap<UUID, PermissionAttachment> permissions = new PlayerConnection(plugin).getPermissions();
if (permissions.containsKey(player.getUniqueId())) {
PermissionAttachment attachment = permissions.get(player.getUniqueId());
attachment.setPermission(name, value);
}
}``` wuld this work
could u at least show me line of code that does that
its kinda problematic for me to find that
how can I auto complete a certain argument in a command with names of all online players?
public void setPermission(Player player, String name, Boolean value) {
Map<UUID, PermissionAttachment> permissions = new PlayerConnection(plugin).getPermissions();
permissions.computeIfAbsent(player.getUniqueId(), a -> attachment.setPermission(name, value));
}```
nice
try {
message = (String) this.plugin.getMessageMethod().invoke(chat.getHandle(), new Object[0]);
hash = ((message != null) ? message.hashCode() : -1);
}
i never got lambdas
this is the line 39
reflection goes brr
where did yuou get attachment from lol
yeah
could u explain?
wait my code isnt workin
invoking methods and guessing what will happen after that can be a pain
-.-
does someone know why Player#isOnGround is deprecated? Because the explanation makes no sense, neither CraftPlayer nor CraftHumanEntity override that method
The client controls if they're on the ground iirc
yes that's what the docs say
but from what I see, it uses the method from CraftEntity which uses some math to check it
CraftEntity calls the NMS entity isOnGround
I always just use it anyways lol
NMS Player doesn't have any isOnGround so it also uses the NMS entity one
and checks whether one is on the ground by some collisions etc
so I doubt that what the docs say is true
Maybe Player had its own implementation at some point and then they fixed it and forgot to remove the docs?
Seems unlikely but idk
well the whole impementation was ever only in NMS
I assume it can be spoofed by the client somehow. Maybe that's changed
so maybe mojang just changed it and noone at spigot noticed
Maybe, I have no clue.
yeah I'll just also use the deprecated method lol
i'm trying to make milk not remove potion effects
would checking EntityPotionEffectEvent.Cause milk and then cancelling the event suffice?
uhh show code
does someone know how can I listen to incoming packets WITHOUT protocollib or similar?
wireshark
github doesnt seem to give a fuck about the formatting colors
uhh whats wrong with that
@tardy delta I recommend
making a Database interface
with stuff like close connect etc
and a storage interface
with stuff related to your actual storage
like loadUser()
then a class called SQLStorage implements Database, Storage
yeah
cuz this looks pretty uh
weird imo
why does init throw SQLException
why SQL?
why not something else
you have a design problem here probably
Inserting in mongo be like db.insert(object) 
because it initializes the tables
not all storages throw SQLException
thats a database interface
not a storage one
so my YMLConfig implements Storage e.g
im only using h2 and mysql
will throw SQLException?
so mye basically the interface is redundant
I dont care (doesnt matter)
you want your project to be flexible
so you change add features without breaking code
i can add features without breaking things
you prob need to learn ISP
just add a new method to the storage interface and make it implement
(SOLID)
- Interface Segregation Principle: It states that “do not force any client
to implement an interface which is irrelevant to them“. Here you should
prefer many client interfaces rather than one general interface and
each interface should have a specific responsibility.
youre having one general interface with 2 responsibilites
there should be 2
one Storage and the second Database
Database for interacting with the database, e.g disconnect(), connect()
Storage for getting stuff like user data
like void createHome(Home home) throws SQLException;
too
would still have to implement both interfaces so makes no difference
createHome should be in Storage, not in database
It does
better design
you will find ur project being a huge mess if you just "no difference, just design"
ask yourself
is it normal for a createHome function to throw SQLException
why doesnt it throw MongoDBException if that ever existed
It shouldnt be specific
Maybe you cant control that
but stuff are mixed
how should i handle throwing exception then?
I mean for me
just an throws Exception instead of specific SQLException?
then you cant print the stacktrace
atm the delegating storage is handling exceptions by giving them to the future
and the things that need it handle it in the way they want
I would return an 1 if an error occured
I personally just use some kind of Result type
and log an error message
look at the homecommand#createHome for example
and 0 for success.etc
rust 😉
Ye :)
i would return an int instead of having throws SQLException inside of a Storage interface
a storage can be something that doesnt use sql at all
so it doesnt make sense
well im not going to use things that are not a database
im not sure if mongo is actually a database or what it is
doesnt matter
make your design flexible
u dont know what happens later
how would i detect if someone breaks a block and what the block is?? i tried the harvest event thing and it dodmt work
BlockBreakEvent
that isnt a thing
if those database method should return an int, that would work for all void methods but the others arent going to work
gl returning a Future<Kingdom, Integer>
oh i was looking in player events LOL
and pairs go brr
thx
hmmm
then
a Storage<StorageType Enum>
maybe
actually nvm
alr its fine if u cant control that
its not that much of a deal
ahh you cant construct an enum value during runtime like in rust
that would be the thing
but breaking ISP sucks
i wouldve done smth like
StorageType.SQL.getException()
would return a sql exception
in rust i would have done
enum StorageResult<T> {
Ok(T t),
Err()
}```
even storing the exception in the err constant
from where would that come?
the enum
i mean from where does the exception come?
ur method that throws SQLException
so the enum holds a storage inside
i would have store the enum constant which im working with somewhere
bcs on compiletime i dont know with what storage im working
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
if(block.getType() == Material.DIAMOND_ORE) {
player.sendMessage("mine diamonds");
}
}```
it doesnt do anything
i did
in my main class in the enabling function is this
getServer().getPluginManager().registerEvents(new events(), this);```
in my events
```java
public class events implements Listener {
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
if(block.getType() == Material.DIAMOND_ORE) {
player.sendMessage("amogus");
}
}
}```
amogus != funny
thats the problem?
no
ok
something else
make a sendMessage at the start of the event just to see if it’s registering
then work from there
(also you should really change that class name)
What is a good way to approach this?
I have one class, ItemManager, but the paths to the item directory is hardcoded into a variable
But I want to change this
My ItemManager does too much atm
This is the class: https://sourceb.in/OJ9RKQjKvL
I was thinking of some kind of ConfigManager class
ooh Kotlin, hot
Also uh
You don't need to use stream in Kotlin
In fact
You shouldn't
Because Kotlin has sequence
(or whatever it's called)
doesnt work
yeah it does
Oh wait it's a FileTreeWalk
val itemFiles = file.walkBottomUp()
.filter { it.name.endsWith(".json") }```
are you sure your plugin is loading at all?
yes i have another event
Which is a sequence of files
FileTreeWalk implements/extends Sequence<File>
are there any errors in console
no
Also
File has an extension property called extension
Which is just the file extension
So you can do it.extension == "json"
this is loading
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.sendMessage("plugin loaded");
}```
(Even then, Path is preferable to File in modern Java)
wym by path?
so that works?
How would I read from that?
It was introduced in like, Java 7 as a replacement to some of the classes in java.io
It mainly exists as it more accurately represents filesystem paths
ye
and there are no errors in console when you place a block?
no
break*
java.nio.Path is to java.io.File sort of like how java.time.LocalDate is to java.util.Date
val itemsPath = "$dataFolder/items"
val path = Path(itemsPath);
if(!path.exists()) {
plugin.logger.info("$itemsPath does not exist, creating directory")
path.parent.createDirectories();
path.createFile();
return;
}```So this is the better version?
Or is path.parent.createDirectores() not needed?
Oh no you absolutely need to make sure parents exist in nio
It's a little more strict
Ah alright
But yeah that looks good
What is the Path equivalent of walkBottomUp()?
?
Kotlin has no walk extension method, you'd have to use java.nio.Files#walk
Which you'd then have to either:
A. Use the stream it returns (which sucks bc Kotlin's type-safety doesn't work with streams)
B. Convert the stream to a sequence via toSequence
so basically
Files.walk(path).toSequence()
toSequence dosn't exist, do you mean asSequence?
Yeah I've used it for a while
Oh wait
Okay so createFile I think would actually create an empty file
Rather than a directory
Yeah
btw I should mention
You don't have to check that the directory is empty
A forEach with no elements will just do nothing
is there an easy method to convert e.g. a Short[] to short[] ?
for loop
yeah I mean a generic method
:)
that works for all wrapper classes
You'll just have to write your own
I just want an message to show the person the directory is empty
Fair enough
btw should I use semicolons in Kotlin?
no
Kotlin's semicolons add nothing
Oh btw you should return in that empty check
Like after printing the "directory is empty" warning, you should return
Otherwise, there's a useless forEach and then it gives a misleading "loaded successfully" print
Also this would be a good idea
I actually recommend using a lib for this though
Like perhaps RedLib
I need to use a JSON serializer though
But guessing by this code, how long do you think I have been coding in Kotlin for?
pretty sure there’s a util for it in one of the spigot dependencies
Ehh JSON isn't the best format for configs
I just find it more readable
?
Hmm
I'd say you're like, relatively new. Not so new that you've never had experience with Java, but new enough that you've not gotten used to Kotlin's additional utilities.
I have been using Java for like 2 months and Kotlin for like...3 days?
Sounds about right
Uhh maybe, but you should probably just use the online docs
alright
^
the online tutorials are really nice
Kotlin's docs are a little confusing at times but they're not that bad
What are the concepts you have to know
List is an interface
if you are not talking about kotlin
arraylist is an implementation of it
Nah this is Kotlin
meh
- Array represents a Java array, and is a fixed-size collection of values.
- List is an immutable list, meaning it cannot be changed.
- ArrayList is part of Java's standard library, but afaik you shouldn't really use it in Kotlin.
a decent way i learned kotlin was just googling anything i hadn’t seen before in java
Or actually
especially the keywords since there was a lot of those
ArrayList is an implementation of MutableList
But it's not necessary to specifically use the ArrayList type
Since mutableListOf exists
tailrec
Anyone has an idea how I can fix this generation?
I want it to generate barriers at y level 201
lol
it’s pretty weird going from java where keywords are used pretty conservatively to where’s a keyword for anything you can think of
what are you doing to create them
how can i send more than 1 line action bar?
sending more than one action bar just replaces the other one
how can i make appear more line action bars?
\n only makes a strange code
doesn't work
Because I have no idea how custom World Generators work, I thought this would do the trick:
@Override
public void generateBedrock(WorldInfo worldInfo, Random random, int x, int z, ChunkData chunkData) {
for (int iX = x; iX < x + 16; iX++)
for (int iZ = z; iZ < z + 16; iZ++)
chunkData.setBlock(iX, 201, iZ, Material.BARRIER);
}
(I disabled every generation type except bedrock)
Actionbars only have one line as far as I'm aware
so the problem is just that there’s one row where barriers aren’t being made?
The problem is a different one.
The patches of barriers are getting smaller and smaller until no barriers are generated
change the material and send a screenshot
You can clearly see it in the video though? 🤔
what video
seems like it might be something with however the generateBedrock method works, or that some math is done wrong
I also tested it with the other methods, like generateSurface
That one
you could try just listening to chunkloadevent and then do it there
show us the chunks
Sure, just wait a second, please
Does anyone have any idea how to delay plugin unload until my JSON file gets saved?
public void save(Object data, String fileName) {
}
ObjectMapper mapper = new ObjectMapper();
File file = new File(plugin.getDataFolder(), fileName);
try {
if (!file.exists()) {
file.createNewFile();
}
// Writing to a file
mapper.writeValue(file, data);
} catch (IOException e) {
e.printStackTrace();
}
When I run this inside onDisable(), it throws exception
prob cant
So how am I supposed to do the save 😄
By doing it on update rather than when the server is shutting down
Updates are very frequent...
It is frequent + I must do it so I will be 100% sure that it gets saved on unload
Which would delete a few minutes of updates occasionally, because it doesn't save while shutting down 🤔
It is list of holograms and if some will be missing, it will not get re-added after restart
yea
Here you go:
https://streamable.com/kpx9a1
depends what you mean by unload
onDisable
yes
both?
so either you lag out the entire server by doing it on sync
or you send it to another thread if for example just the plugin gets disabled but the server still runs
he is doing it sync
but its still not working
oh thought its a "how do i do it"
That does not work... Getting exception "Tried to start thread while plugin disabled"
update it every few minutes
But maybe it is not the problem of plugin unloading before it gets saved?
java.lang.VerifyError: (class: org/codehaus/jackson/impl/JsonGeneratorBase, method: getOutputContext signature: ()Lorg/codehaus/jackson/JsonStreamContext;) Wrong return type in function
at org.codehaus.jackson.JsonFactory._createUTF8JsonGenerator(JsonFactory.java:865) ~[CustomDropHead-1.0.0.jar:?]
at org.codehaus.jackson.JsonFactory.createJsonGenerator(JsonFactory.java:755) ~[CustomDropHead-1.0.0.jar:?]
at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:2048) ~[CustomDropHead-1.0.0.jar:?]
at me.baterka.drophead.utils.JsonDataStorage.save(JsonDataStorage.java:31) ~[CustomDropHead-1.0.0.jar:?]
Thats not a way for me...
Thats maybe additional protection against crashes so you not loose everything
But when server properly calls onDisable, it must get saved...
Note that it works for interval saves
So it is not data problem
where is #generateBedrock being called?
Well, I guess everytime a chunk is being generated?
It's not being called manually by me
ChunkGenerator#generateBedrock
ah, my bad. thought because of the description https://hub.spigotmc.org/javadocs/spigot/org/bukkit/generator/ChunkGenerator.html#generateBedrock(org.bukkit.generator.WorldInfo,java.util.Random,int,int,org.bukkit.generator.ChunkGenerator.ChunkData)
so i bet its because of the coordinates. try to not use the given x and z, try to use the min and max x and z
try to not use the given x and z, try to use the min and max x and z
Not sure what you mean by that 🤔
I mean... Without using the provided x and z, I don't know which chunk the server want to render?
Okay, nevermind, I'm just stupid.
It's not about coordinates
Me and someone I know were arguing about how flawed java is because of it not having null safety
and that NPEs are a major problem
He ended up finishing it with "Eh, I'm not gonna argue further. One day you'll understand, if you're ever going to work as a programmer professionally", So I thought maybe I'm missing something
I had the opinion of NPEs not being a major problem if you have logic and design
he had the opposite
Hey guys, does world.rayTrace() return null if there's no collisions, or will just getEntity() / getBlock() return null?
I have a method ```java
<M extends Map<K,V>,K,V> stuff(Supplier<M> supplier, PersistentDataType<?,K> keyType, PersistentDataType<?,V> valueType);
Does someone know if I can somehow get the class the supplier supplies? So basically something like supplier.getClass().getGenericType() or sth like that
nope
check the javadocs
the closest ray trace hit result with either a block or an entity, or null if there is no hit
M gets erased to Object so nah
I hate type erasure
type erasure crinch


