#help-development
1 messages ยท Page 2108 of 1
cancel the entity damage event
if I recall it right, armorstands are entities
once placed
Yes
how do I add an item to the players inventory?
declaration: package: org.bukkit.inventory, interface: Inventory
How so?
I dont understand that most times when you try to do ItemStack events. I cant figure out how to make it so it ads an item to the world or player
I had to go through tons of expirements on how to figure it out
Javadoc tells you all you need
does Entity#leaveVehicle() trigger EntityDismountEvent?
Probably
Hey so im having a bit of an issue with crafting, I have this crafting recipe, and I have all the custom items in my inventory however it still shows up as red, even the iron bars. Any thoughts?
does anyone know how coreprotect saves data? it logs pretty much anything that any player does and the server doesn't explode somehow
Pretty sure it uses database?
look up the source
i'm not smart enough to read and understand advanced code
its nothing special
cache -> go async -> push to database
Then you're going the opposite way ig
when learning about canceling right click block action when rightclicking my custom item in hand i learned that it always prefers block action when righclicking(such as door open) over right click item action(such as eating), but if you sneak it prefers your item instead and eats food even when looking at item like doors. I shall definitely try to implement my item right click action the same way too to be in par with vanilla
just thought to share this finding, maybe everyone already knows it and i am just a food but ๐
I have it set to exact match if it matters, however for it to check that the items are what they say they are I had to create a crafting event to handle it all, Iโm not sure why. With shapeless crafting it works great, no need for a crafting event however there is still the issue of the red squares for my shapeless crafting as well
Any help would be greatly appreciated
i have the same problem in one of my plugins
they said it is a spigot bug
question , to detect if a player breaks a wheat seed, is the block just a wheat_seed
(like that if (blockType == WHEAT))
or is the wheat seed just the item?
.
Hello, I have a question, how could I do so that when I enter a specific chunk, a message would come out only once? It's that every time the character moves through the chunk, the message appears. Thanks
so
i know a way
u there?
make a hashmap of player, boolean and whenever the player enters set their value to true, and when they leave, set it to false
when they move inside the chunk and their value is false, it means that they're just moving into the chunk for the first time
you can send the message then
or even just a list of players
But for example, I saved the claim chunk into a database, I get the chunk where the player is, but I can't see how to insert a boolean so that it is only the first time it enters.
Who?
Why Not hashset?
alright so you have a list of players
on the move event
if they move into your chunk
check if they are inside the list
if not - then they've entered the chunk for the first time
you can send your message and then add them to that list
if they move and they aren't in your chunk, but inside the list
remove them
does a wither potion exist
I think I was able to fix it with getTo and getFrom event
Why Not hashset?
Generally I myself Just Store the Last chunk a Player stood in - If it changes send the Message otherwise not
I completely forgot about that lmao
I swear that with every Month that Passes discord needs more and more Network capacity. Seems that my 16 kb/s connection doesn't suffice for discord at all anymore
Just took a meager 6 minutes to send that message ๐ซ
And do you know what the event is so that mobs don't spawn in a specific chunk?
and what is the method to know the spawn and not that they do not spawn in that chunk?
oh its okay,
How can I get the chunk where the mobs spawn?
Thanks!
Hw would i code a placeholderapi extension that will use another plugin's placeholder, but if it returns null it will return a blank string
basically the plugin has a placeholder that gives nullpointerexceptions if the player does nt have a suffix. Can i make an extension with my own placeholder that either returns "" if the plugin placeholder returns null?
idk if i explained that well
hey, I am just getting "ERROR null" on the commands ive created and im not able to figure out why. Where can i send my code to get help with it?
I am very new to coding so that does not tell me much, im sorry ๐
copy paste what console says
๐ฅท
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.
25.04 11:46:39 [Server] INFO Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1 25.04 11:46:39 [Server] INFO at com.cradlenetwork.CradleHeaddrops.Commands.SoulHunterCommands.onCommand(SoulHunterCommands.java:55) ~[CradleHeaddrops.jar:?]
im guessing it comes from me trying to use args.lenght
ive used args.lenght to check if there isn't any further args and i dont know if thats the right way to do it or if ive just used the wrong numbers
show us the code
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.
the main
the command i tried to execute https://pastebin.com/7aHPb3kF
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.
you dont, thats the problem
do you mean that the else-statement on row 91 should be an if(args.lenght == 1) ?
its in line 55. there you never check for the length of your args
you instantly try to get the args at index 1 and 2 if the sender have the required perms
ah okay, makes sense. Im guessing i add so it has to be a lenght of 3 there?
if i understand it correctly
Changed a few things but now im getting this error Caused by: java.lang.IllegalArgumentException: Item cannot be null im guessing there is something wrong with the item i created
You can cancel the event.
?paste
wait
plottwist, you didn't. its null
Does anyone know how can I change player base strength? with minecraft commands
yea, so it says that the item doesnt exist right? But there is one, so im guessing something is wrong with the item-class
you're trying to add a null ItemStack to an inventory
how hard is it?
also you're using static for itemstacks
is this the api help or..?
yes
?ask then
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!
https://paste.md-5.net/zifehinifo.sql what is this?
Caused by: java.lang.NullPointerException: Cannot invoke "com.mojang.datafixers.util.Either.left()" because "either" is null
at net.minecraft.server.level.PlayerChunkMap.lambda$2(PlayerChunkMap.java:312) ~[spigot-1.17.jar:3170-Spigot-a483d2c-ec116f6]
at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642) ~[?:?]
... 14 more
an NPE
i have a inventory it has some items but im wondering if the ending item is 36 or 35
i assume its 35 bcs i started with 0
when i start the server it does that
35
alr thx
Hey fellas, I know this aint much about spigot/minecraft, but I swear this is for a spigot plugin im making, would anyone know of a way to check if a servers socket connection went down? Cause I can check on the clients side if the server went down, that part works just fine, but on the server side I cant check if the client disconnected. Im using sockets, any ideas on what I can do?
connect to any ip and see if it works
how do I capture block right click events like door open, button press, etc?
just ping google or something
PlayerInteractEvent
not client as in a player, client as in a program
read from it
200 clients can connect to 1 server
but the server might not know what client to connect to
I've tried, but all that does is keep the socket open cause nothing else works until a client sends data
the client can detect when the socket closes, but not vise versa
the socket will keep open but it will return null
well, depends on what read is used
a BufferedInputStream ๐จ
by the name of it, does it also capture righ click events on entities?
so use the https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html#read-- method and check for -1
Thank you, now I can move forward with my work
I feel so stupid those names are so literal, yet i was looking for like BlockRightClick, BlockUse, BlockInteract event.
๐ฑ
Ima take a look if I actually do get something back, hold up
holy smokes, I can detect when a client disconnects! Thank you mate ๐
@EventHandler
public void onPlayerUse(final PlayerInteractEvent event) {
if (event.getPlayer().isOp() && event.getAction().isLeftClick() && event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.PAPER)) {
TeleportScroll.makeScroll(event.getPlayer().getInventory().getItemInMainHand());
} else if (event.getAction().isRightClick()) {
if (event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.PAPER)) {
TeleportScroll.useScroll(event.getPlayer());
event.setCancelled(true);
} else if (event.getPlayer().isOp() && event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.STICK)) {
App.config.set("spawn.world", event.getPlayer().getWorld().getName());
App.config.set("spawn.x", event.getPlayer().getLocation().getX());
App.config.set("spawn.y", event.getPlayer().getLocation().getY());
App.config.set("spawn.z", event.getPlayer().getLocation().getZ());
App.config.set("spawn.yaw", event.getPlayer().getLocation().getYaw());
App.config.set("spawn.pitch", event.getPlayer().getLocation().getPitch());
event.getPlayer().showTitle(Title.title(Component.text(""), Component.text("New world spawn set!")));
App.plugin.saveConfig();
}
}
}
Can someone explain me how if i click some block that has interaction event it calls not just useScroll but also makeScroll if I only right click?
I am confussion
Dont suggest using read
As the server wont be able to process packets then
Just try with available()
AAlso playerdisconnectevent is a thing
like if I interact with something in game it calls the code that i specify that only runs on leftClick
this is too confussing
Sorry for late reply. I understand so far that the itemstack im loading is null and i know that is not possible. So im not supposed to have the itemstack as static. I get errors if i dont have it as static. I'm sorry if i dont totally understand, I'm kinda new to coding
nah, this will false positive easily
yea, i got that. But am i just supposed to have it as not static or how do i fix it?
I only mentioned static as it's somewhat bad practice to abuse it
It's meant for constant values and such, not really for accessibility
one thing you might be doing is loading the static items after the command
is there a way for me to make it load before the command then? Or should i just move the item into the same class as the command instead of having it in a separate one?
well I haven't had a look at the class where you hold the item
should i send it?
idk you tell me
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.
what is wrong there?
ive justed the right spellings, the only thing i can think of is that i use ItemMeta istead of like BookMeta, but couldnt find anything that was setBookMeta
wrong order?
you set meta on item, then wipe out item
im guessing that should fix it
try it
will do
lmao, this aint about a player client, all about a literal other server being a client to a main server, thank you either way
you need to set its velocity to 0
how?
well setVelocity takes a vector
new Vector
๐ฅฃ
think of a vector as a 3d point
which indicates relative movement to something
in case of velocities, that movement is measured in blocks per second
You can also convert locations to vectors, which will be relative to 0
Here's a very basic example of a vector
YESSSSSSSSSS
YESSSSSSSSSS
:D
Vector upVelocity = new Vector(0, 10, 0);
LivingEntity entity = ...;
entity.setVelocity(upVelocity);
in this case, the entity will have its velocity set to a very high Y level
setVelocity(new Vector())
meaning it will fly up
make sure you are using teh Bukkit Vector
try delaying it by a tick
i have
another
question
how to prevent
lot of items
from
stacking
itself
ItemMergeEvent
you can have more than one word per line
wow i didnt knew
he's probably trying to do effects like these
it did not fix it sadly
nop
sadge
Why did it die far before it actually hit something
Or is that just the angle
ppretty sure the velocity check matched the grass plant
0xFF0000 is an integer
if i do Integer.valueOf("0xFF0000");
will it return int 0xFF0000 ?
basic raytrace that accounts for gravity
try Integer.parseInt("0xFF0000", 16)
not sure if that's a thing in java 8
but you need to say what base(8, 10, 16) it is on
a base 16 right?
yea
thanks
how to import yml file
google "spigot custom config files"
can I put a limit on how much xp a furnace can store? I'm trying to limit the cactus farm xp glitch for my server
destroys the economy in my server
You can listen for the BlockExpEvent and change the amount of exp dropped https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockExpEvent.html
Yeah I just found it in the spigot API xDDD
Hey all, I'm making a plugin with intelliJ, and I'm wondering if i can directly update the .jar file in the plugins folder instead of stopping the server, going to the target folder, copying the jar, pasting it in the plugins folder after deleting the old one, and starting the server
Once you made the artifact you can direct the intellij to go a custom output folder, in my case I did it to my own test server
File -> Project Settings -> Artifacts and you'll have this one
are u using maven, gradle, or a plain java project?
Is there a way to cast Block from the event to the furnace itself?
not the block but its state
Maven
I need to check the last used recipe to make sure it's result is the one i'm looking for
A way to get it through it's state?
I cant find "Project settings"
Project Structure, my bad
You can add a new one clicking the plus and just ok
plus->Jar->From Modules....->Ok
Yeah, then you can change the output folder
To build you go to build->Arctifacts->Build
isn't that for building with intellij ??
Ye
who in their right mind uses intellij build
How can I use it if that's the case?
the maven jar plugin has a configurable option to change the output location
How can I specify the outputDirectory only for packaging a jar?
http://maven.apache.org/plugins/maven-jar-plugin/jar-mojo.html this shows all parameters, but how can I set them in the commandline ...
I would suggest putting this in its own profile
to not always run it
but that is the gist of it
which is what I'm using
any other IDE will fail (if you plan to host this on github)
Ah, well, I don't, but thank you for the heads up
tracking this in git also requires you to actively push the intellij configuration fiels for it
then there is the disadvantage of just ignoring other maven build configuration (e.g. shade)
but eeek, if ya wanna use intellij building, I guess go ahead ๐
Hey, i have a problem with that my command does not show up in the tab-completion ingame. Do anyone know why?
You need to "register" tab completion separately
Ohk
I think the event is onTabComplete
anyone know why this isn't working?
As far as I can see the only character I have which isn't in the possible characters is a backslash
but then how am I meant to create a world in a specific place?
cause any path will always have a backslah
you don't
worlds live in the world container
which is by default the root folder of the server
Anyone knows what this error is and how to fix it exactly? I'm new to using switch
https://i.imgur.com/qHt0qPP.png
you can however, provide your own name to the world creator
tho, obviously this depends on your FS
as any normal human would run their production on a linux machine, you'd need to use / there
I see
good to at least have wsl
so can I not create a world anywhere except in the root folder?
well, you can supply a name and a namespaced key
iirc the name is used for folder resolution
do you have an example of how to do that?
In a few of my projects, but I'm not at home to look at them
could u show me how to do this?
https://i.imgur.com/iEG5XMR.png isnt this the correct way to do it?
how does that let me create a a world in new directory
I mean, eh
the WorldCreator class has a constructor that takes both the name and a namespaced key
That doesn't look like what I did from what I remember, but my plugins were made in 1.16 and older
that looks fine. Are you sure you have the pemission to execute the command ?
What does the namespaced key do?
im op on the server and im guessing this is correct https://i.imgur.com/FLkVn6G.png
(the one that is false has nothing with any command to do)
I mean it is more related to what permissions you defined on the command definition in the plugin.yml
ah, but like, im able to execute the command on the server. I just dont get it as a suggestion in any way
are you running java 17 ?
https://github.com/PaperMC/Paper/issues/6936#issuecomment-979713795 might be of interest to you
?
I don't see a constructor for that either
;-;
well rip you
so no way I can create worlds in a place which isn't the root dir??
how am I meant to organise worlds >_>
Having all the worlds for all minigame in the root dir is stupid
well just run in linux :5head:
WSL ๐
There's surely a way around it which doesn't involve that
and edit it?
won't it then create the world in the wrong place?
if i enter the name without backslashes
Well don't create the world before you edit it
yeah
won't the name test be during the createWorld function tho?
I'll test it now
yeah I can create a WorldCreator with a name w/ backslashes
so editing the name using reflection before running the createWorld() function won't help
๐ค maybe ? lol
but idk what that would get you
unless you do some very very ugly shenanigans with the name getter
lol
Anyone got any ideas?
What is the best way to save objects like Location and ItemStack to a MySQL database?
Maybe store the string representation for how it serializes in yaml?
Yes string needed. But if I call the serialize method it returns a map
https://gist.github.com/graywolf336/8153678 Here they use Base64
man i hate this feeling when u know you can finish that project
but at the same time, you're burned out because of it
BukkitObjectOutputStream
yea im using Java 17 and thanks. Im not really sure how to fix it though. Do i update my JDK or? Because im using a host for the server i cant really add flags
If you can I believe Java 18 fixed that
how to fcking fix this
so annoying
i can't run test server
properly because of this
it hangs for like 5 mins
before the initialization starts
thats a long startup script
ill try it and we'll see
smaller than my-
than what?
๐
it sadly didn't fix it. Any other ideas?
Anyway to save a world in a sub folder??
Yeh, I am big dum dum
nah its fine, but that wont work ๐
@eternal night found the answer
using forward slashes
instead of back slashes
I think you suggested that but I think that was in relation to Linux
or just File.separator if you want to be able to use it on linux and windows
Or any operating system.
but Bukkit.createWorld() was kicking up a fit
cause it only takes forward slashes
and not back slashed which is the file separator on windows
so I now have to replace the file separator with a forward slash when passing it to the world creator
but it gets even more complicated because if the file separator is a backslash then I have to add 4 backslashes
Anyway I can limit the CPU% my server uses?
Every time I launch it is maxes out my CPU
give it a little less ram
no not inherently
pretty sure it's on default allocation anyway, so 1GB I think?
something like that
actually looks like 2gb
smh just came to the conclusion that you cant really change it much
look at some tutorial on youtube
thats just syntax
.component(EventItemBehaviourComponent::new,
(item, ibc) -> ibc.adapter()
// define a behaviour handler for our item
.behaviour(ItemInteraction.class, interaction ->
interaction.getEvent().getPlayer().sendMessage(interaction.getState().toString()))
)
``` should probably introduce an alias for this
whas that?
for adding behaviour to custom items
all that does is send the item state in chat
when a player uses it
wanted to use mixins to call the events
but its not possible i think
so now im just forwarding bukkit events through my own event bus
crazy stuff
which is abstracted away by the behaviour component lmao

overcomplicated]
for me yes
nah but i could have users do everything manually
like register listeners
and get the item state from the nbt tag
and shit
but i dont want that
This guy is very impressive
one character
also k is easier to type than z
z is all the way on the bottom left
its hard bruh
yeah but clazz is more standardised lol
idc
im not going around changing the like 50 variables and fields
for some stupid standard
also i ahvent commited the new changes yet
so you wont be able to find the code i sent
hmm, this kinda just seems like a big ol wrapper around bukkit
abstracting abstraction
i wanted to do mixins
for calling events
but i couldnt
also it has custom crafting api which is fast
and epic
yes
Mixins as in?
thing is with mixins is that u are in the shit with regards to nms
injecting into nms code ig
like code injection into nms methods
or any method
really
So not as in spongepowered mixins?
You can
yeah u can
You can with ignite or other 3rd party applications
yeah but id like to stay away from 3rd party applications
i use one additional dependency which is zl-zip or something because i couldnt get zipping to work
Well you can just code it yourself, it's just a couple of dozen classes
How can you not get zipping to work? It's pretty easy
Sure, it's a bit complicated at first but pretty easy after that
but minecraft wasnt loading the resource pack
Oh that issue
i meant like any external application
i worded it incorrectly
where can i find ignite
As far as I know, you can redefine classes at runtime, so it might also be possible to do it without some kind of bootstrap
Mixin is nice and all, but I prefer raw ASM
i mean i could use that too
as i only want to invoke methods
could just insert some INVOKE myMethod somewhere
doesnt paper generate method executors
because i have asm in my project
through paperweight
I have a Stream<Byte>. Does anyone know an easier to convert it to a byte[] than this?
byte[] array = Arrays.stream(string).mapToInt(Byte::parseByte).collect(ByteArrayOutputStream::new, new ObjIntConsumer<ByteArrayOutputStream>() {
@Override
public void accept(ByteArrayOutputStream byteArrayOutputStream, int value) {
byteArrayOutputStream.write((byte) value);
}
}, new BiConsumer<ByteArrayOutputStream, ByteArrayOutputStream>() {
@Override
public void accept(ByteArrayOutputStream byteArrayOutputStream, ByteArrayOutputStream byteArrayOutputStream2) {
byteArrayOutputStream.write(byteArrayOutputStream2.toByteArray(), 0, byteArrayOutputStream2.size());
}
}).toByteArray();
(Yes obv I could turn the anon classes to lambdas, that's not what I mean with "easier")
I think so to some degree
so theres some kind of asm going on
at least defining classes
but thats not hard
you can do that with a simple classloader
Collectors.toList()?
yea
if it wasn't for streams I probably might have a performant and semi-elegant solution but otherwise I'd say that this may just as well be good enough
Though you might just as well be able to work with a single ByteArrayOutputStream and use an iterator at the end of the stream
Hello i was wondering if its possible to get a piece of code from a list of string. For example
strings:
- p.sendMessage("hello");
- p.setVelocity(new Vector(0,10,0);
- p.sendMessage("Fly to the moon!);
trying to execute code at runtime from strings?
that would be pretty complicated and probably involve java agents
im thinking of skript now
You could look at recaf and see how it does it
But that would require a JDK and worst of all a library that is prone to break
.toArray();
or am i missing smth
as that sounds too simple
byte[] array = new byte[string.size()];
for (int i = 0; i < array.length; i++) {
array[i] = Byte.parseByte(string.get(i));
}
Much, much nicer solution if string is a List<String> that doesn't use Streams however
byte[]::new doesnโt work?
Byte.parseByte
byte[] bytes = ArrayUtils.toPrimitive(byteArray);
Oh god, you don't have to do everything with streams do you
map it lol
@tender shard
streams are nice
yes, but from time to time horribly inefficent
Hey, does anyone know of a tutorial on how to make custom recipe plugins/inventory & chest GUI plugins? I'm new to plugin development but have about 4 months Java experience.
is there an event that encompasses every possible Material change of a block? Or is it completely impossible to find out if a block has been replaced without a physics update?
Most stream-based solutions rely on ByteArrayOutputStream or an ArrayList
i like the way rust implemented their iterators (basically streams) it just compiles to the same code as regular for loops
Which means that you will have an oversized array in the end and then clone it
Plus for list-based solutions it will internally be represented as Byte[], not byte[]
thx
no, generics don't work for primitive types
of course but it's an array
it's a byte array actually
So yes, it might work
However it would require that java is smart enough to automatically unbox the bytes
exactly, so the array type is a primitive
I'll just use ArrayUtils ๐
Supplier<byte[]> is actually valid
looks meh
Also fun fact: @Nullable byte[] will not compile if you have any reasonably good IDE
tbh, scratch this question. Does anyone just have like, some general resources on getting started? Lmao
The proper way would be byte @Nullable [] which looks cursed AF but that is java
Generally you'll want to use a library like InventoryGUI or InventoryFramework
Doing it by hand is generally not advisable because there is a rather unignorable chance of you introducing exploits due to not having carefully tested it enough
ik that but
Oh rad, are these just free open source bases I can work off of ?
libs
Yep those are open source and work kinda like bukkit
If you use maven or gradle it isn't much of a stretch to change your code to use them
What are some basic practice "plugins" to make before I start trying to get into developing my own stuff?
dam so basically theres nothing I can do to fix it?
java.lang.NumberFormatException: Value out of range. Value:"11000010" Radix:2
at java.lang.Byte.parseByte(Byte.java:151)
at
erm wtf, why? that's definitely not outside of the allowed range
Or is it better to just jump straight in
it is out of range
194 > 127
that's because it's signed
You may want to parse an unsigned byte
there is a method for that but I think you know that
hm
but it makes no sense
I am literally converting a byte to a string
then convert it back and now it's out of range
lol
That is because your toString method probably is unsigned
case BYTE_ARRAY: {
StringBuilder result = new StringBuilder();
for (byte b : string.getBytes(StandardCharsets.UTF_8)) {
result.append(String.format("%8s", Integer.toBinaryString(b /*& 0xFF*/)).replace(' ','0'));
}
return result.toString();
}
I tried it both with the & 0xFF and without
why
yeah, toBinaryString is unsigned
hm I'll try parseUnsignedInt
uint8_t
I want to unload a world as soon as it loads
to generate the world file
do I need to do it like this?
or can I just immediately call Bukkit.unloadWorld() after creating the world
the latter, most likely
to wait for it to finish loading
it already has
yeah but the server takes time to create the files and actually build the world
and it's all done synchronously
oh right
I assumed world building would be an async thing
since it's an I/O operation
if only
that's inefficient >_>
what the fuck
Why
io != async
sometimes it needs to be sync
I assumed it would be async cause building a world is gonna take a while so would make sense to do async so other server operations wouldn't have to wait on it's completion
but yeah just do it synchronous does load in the world files
what if a player enters the world
when only a portion of it is loaded
and he breaks a block for example
what will happen to the broken block?
Well presumably if you tried to teleport somebody into a world which hasn't finished loading then it would throw an error
yes but this is Bukkit where you can make multiple worlds >_>
there is even an onWorldEvent
so you could detect when a world had finished loading
presumably
just cant get one off the top of my head rn
you could make the world create async if you want
if youโre concerned about performance
oh?
yeah I mean it would be good
cause I'll be loading / unloading worlds a lot
making minigames and a world is created every time a minigame starts
just generate is async and add a callback for when it finishes
so if I'm running it all on one server that would be rough if everying froze every time a server loads
this won't break anything?
There isn't any reason I can't load it asyn or smmin?
I'm gonna have to look up how to do async as I've never done it before
it definitely will break stuff
as far as i remember
the last time i saw someone building a world in bukkit forums
If you're making a minigame server you can work with Minestom :)
doesnโt when iโve done it
oh cool you've done before
yea
you got code I could look at?
i just use a bukkit runnable for all the creation
mk
and then execute a callback for when it finishes
prettty much just wrap your current code in a runnable
๐
well
youre gonna do the creation manually?
with nms?
how do I implement the call back?
could use Futures?
I feel like this would be an appropriate time to use them
i used completable futures for it
could you show me?
I'm not very experienced with Futures, I've got an idea of how they work but seeing an implementation if you've got one would be helpful
ty
im planning on recoding it
why not?
minecraft just aint like dat
doesn't seem particularly convincing >_>
try it out then
no?
not if you run it asynchronousโฆ
createWorld(WorldCreator) def isnโt Thread safe Iirc ๐ค
it isnt
lol
thats why people have to do it manually with nms
and its such a pain to do
i wouldnt bother trying
works for me ยฏ_(ใ)_/ยฏ
didnโt do it with nms either
Hello, is there an event for when a totem is activated for the player?
it Runs when the Entity gets Resurrected
and the Totem Resurrects Entities on Activated
so i Think yes
Ah it worked, thank you so much
How to compare ItemStack on 1.12
idk read the docs
equals or isSimilar are the given methods you may use
And what about if i dont have the item stack?
then what the hell are you comparing
I just kno the display name and lore
sounds hard to compare it if you dont have it
then compare those two things?
Objects.equals(lore1,lore2) and same goes for the name, altho you might wanna use equalsIgnoreCase depending on how strict you want to be
Oh ok, because i was getting NPE when doing:
ItemHandler#getItem(display)
And i checked the event display name and its was not null
Whats ItemHandler?
My class that contains the Set<ItemStack> and the ItemStack getItem()
lol
love sarcasm
when you're 10 years old nothing is sarcasm
ARE u help or not
no, i am sergei
is there a way to set a nbt to a block that isn't a TileState block such as a chest?
learn to read
chest is a tile entity
but no there's no way otherwise
Ig you could use the pdc chunks provide
my english is bad
no worries
what is this
Im getting this Cannot invoke "org.bukkit.block.BlockFace.getOppositeFace()" because "this.mainFace" is null exception when constructing a new BlockIterator but Im not able to identify exactly when its going to be thrown
at org.bukkit.util.BlockIterator.<init>(BlockIterator.java:139) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
yeah but how can i use Chunk class to add nbt to a single block?
should i like set a persistant data that contains block location and then add the data i need?
I mean just map the block relatively and then of course you'd have to check for BlockBreakEvent
ye
debugging
hello deotime
hi
thanks @feral socket
You can do it manually, but my library as sergei linked already includes a tool for that
I mean regex to some extent
is there a way of checking if an item is of type tool?
most of the useful stuff isnt in there :(
yeah nothing there that is of use. I guess i could create an if statement with all the tools in it
or an enumset with all the tool materials in
Yeah I can do that. seems better than a long if statement
use a normal hash set
material still is an enum >_<
(subject to change) in the conceivable future, enum registries are gonna be substituted
what does that mean
sleep sight :#
would anyone know how i could embed a clickable link into chat using kyori minimessage?
oh wait this is spigot
sry
anyone on here familiar with lamp at all
trying to set up my command, but keep getting dispatch errors because of null references when registering dependencies
https://paste.md-5.net/bijocimeye.coffeescript
[18:14:23] [Server thread/WARN]: java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.file.FileConfiguration.getInt(String)" because "this.config" is null
?paste
guys why when i type a % in PlayerChatEvent it literally breaks everything?
I mean the event.setFormat()
What is it
e.setFormat("%s %s", playerName, playerMessage);
playerMessage should be event.getMessage() right?
And I have to put the format I want in the first argument right?
Like
e.setFormat("&c%s ยป &f%s", playerName, playerMessage);
e.setFormat("%s >> %s", playerName, playerMessage);
would be Burchard37 >> Hey!
O okay
olaaaay
nah its just how setFormat of that event works
ok thanks u
Yeah only the latter arguments aren't needed, they're automatic
You're just setting the format is all
First %s is the display name, second %s is the message
i knew i was forgetting something about that ty
?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!
BoundingBox for a minigame arenaโs region, is it a good idea to use it?
u could use world borders
Does anyone understand github-pages by chance?
I'm trying to build a website from my directories /docs folder here: https://github.com/Burchard36/BurchAPI/tree/main/docs
And i have this for my pages configuration for the project in the image below:
The issue is, when visiting that website, i just get redirected to to a page that is the Home of my wiki page: https://burchard36.github.io/BurchAPI/ Would anyone know why this is or am i doing this all wrong? Or is it just a caching issue as i just did upload this
okay nvm
caching issue
just loaded now, nvm
how do i set a yaml thin like
shop:
Blocks:
grass: 18
Pvp:
Sword: 19
potions:
etc
using config.set
What are you trying to achieve here?
Change one of the values? Add another section to the list? Remove a section?
no im trying to make the file with the default configurations
Like, writing it to disk when the plugin loads? Or?
Well if that is your config.yml, you can just use JavaPlugin#getConfig(). Otherwise, you will need to create an instance of FileConfiguration and instantiate it with YamlConfiguration#loadConfiguration()
Static method 'getConfig()' in 'com.aspectx.fixmc.fixmcshopgui.FixmcShopGui' cannot override instance method 'getConfig()' in 'org.bukkit.plugin.java.JavaPlugin'
i tried removing static but this shows up Non-static method 'getConfig()' cannot be referenced from a static context
Well... yea that makes sense. What's your code look like? Because you shouldn't need to use static for most things.
public FileConfiguration getConfig() {
return shopConfig;
}
FileConfiguration config;
public static Inventory inv;
public categoryGui(String Category) {
inv = Bukkit.createInventory(this, 54, Category + "Shop");
init(Category);
config = FixmcShopGui.getConfig();
}
Well you're trying to call a method from the class FixmcShopGui that isn't static. Ideally that should be an instance of that class, not the class itself.
so your saying FixmcShopGui fixmc = new FixmcShopGui()?
That's one way, but I don't think it'll work as your main class is actually a Singleton. So instead, you'd want to use dependency injection. It's really easy. You just pass an instance of whatever class you need, in this case, your main class, in the constructor of whatever class needs access to it.
alr
is it possible to make a horse run over to another horse and attack it?
(is it possible to control a mob's AI to run to a specific location)
(and is it possible to make a passive mob attack another mob "genuinely", without having the server cause damage and push the entity back)
org.bukkit.command.CommandException: Cannot execute command 'shop' in plugin FixmcShopGui v0.1 - plugin is disabled.
[04:11:41 ERROR]: null
org.bukkit.command.CommandException: Cannot execute command 'shop' in plugin FixmcShopGui v0.1 - plugin is disabled.
:/
what is that?
:/
anyone else got this error?
what is nms lol
net.minecraft.server
net.moose.socks
nice.mu.stache
i cant fix this
why's your plugin disabled
are you disabling it anywhere in your plugin manually?
Your console should tell you why.
look at your console
scroll up to before the server started up
where it's enabling all the plugins
you should see some type of error related to your plugin
[04:23:58 ERROR]: Error occurred while enabling FixmcShopGui v0.1 (Is it up to date?)
java.lang.IllegalArgumentException: The embedded resource 'shop.yml' cannot be found in plugins/ShopGui-0.1.jar
Well, that's one issue, but I don't think that would disable the plugin. Would it?
What are you using to compile your jar?
i assume it cant find shop.yml
wdym
Maven, Gradle, manually?
i think its maven im not very sure
Well do you have a pom.xml anywhere in your project?
yes in the root folder
Do you have the <resources> section in your <build> section?
If not, add this in your build section.
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
Alright, what about the <plugins> section. What do you have in there?
in the plugins component theres 2 plugin and a resource
no nvm the resource is outside the plugins
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Well, you probably don't need the shade plugin unless you are including other classes/libraries that you have to be present in your jar.
The compile plugin should be enough.
Remove the shade plugin yes.
alr
Also, how are you compiling your jar? Are you using the commands or using the default build button?
yes
button
Then you might want to set a <defaultGoal> flag in your build section.
<defaultGoal>clean package</defaultGoal>
At the very top of the section
what does that do
It changes the behavior of the build button to follow those commands instead of the default.
ok
so how do i fix the error
[04:37:47 ERROR]: Error occurred while enabling FixmcShopGui v0.1 (Is it up to date?)
java.lang.IllegalArgumentException: The embedded resource 'shop.yml' cannot be found in plugins/ShopGui-0.1.jar
in /resources you don't have a shop.yml file there
Recompile your jar and see if that file now exists within.
oh wait ongoing convo nvm ignore me
That could be it too.
I assume you are using saveResource
You need a file named whatever you called it in saveResource in this folder here
ooo ic
[04:48:57 ERROR]: Error occurred while enabling FixmcShopGui v0.1 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.file.FileConfiguration.load(java.io.File)" because "com.aspectx.fixmc.fixmcshopgui.FixmcShopGui.shopConfig" is null
at com.aspectx.fixmc.fixmcshopgui.FixmcShopGui.createCustomConfig(FixmcShopGui.java:44) ~[ShopGui-0.1.jar:?]
at com.aspectx.fixmc.fixmcshopgui.FixmcShopGui.onEnable(FixmcShopGui.java:24) ~[ShopGui-0.1.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-408]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-408]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Paper-408]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) ~[patched_1.17.1.jar:git-Paper-408]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) ~[patched_1.17.1.jar:git-Paper-408]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:733) ~[patched_1.17.1.jar:git-Paper-408]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:317) ~[patched_1.17.1.jar:git-Paper-408]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1220) ~[patched_1.17.1.jar:git-Paper-408]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-408]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Where did you load shopConfig?
FixmcShopGui fixmcShopGui = new FixmcShopGui();
FileConfiguration config = fixmcShopGui.getConfig();
That's now how that works. Since you aren't working in the config.yml, you have to do things manually.
// Get the YAML file you want to work with.
File shopFile = new File("<path to shop file>")
// Load the file into FileConfiguration so you can use all of those sweet sweet internal methods.
FileConfiguration shopConfig = YamlConfiguration.loadConfiguration(shopFile);
// Get what you need from that file.
int value = shopConfig.getInteger("path.to.your.integer");
You'll probably want to keep that instance accessible for ease of use, but that's how you are supposed to work with other YAML files that aren't the built in config.yml.
NOTE: You could use this method to override the #getConfig() functionality, but it's not necessary unless you want full control over all files.
How would I make the classes in red accessible to the classes in dark blue but at the same time not accessible by anything outside of the command package (Eg the teal)
I'm wanting to do this to prevent end-users from initializing something that they shouldn't do/have access to, the exceptions here are just an example
Would i have to move packages around, or is there a way to do this with my current package scheme
I saw multiple different things online, but not any real clear solutions besides making some type of Factory for these classes, or just said its not really possible
do you know what the definition of insanity is? It's doing the same thing over and over again and getting different results
you could come up with a way to do it through protected
it's pretty easy and essentially made for this
you'd have to move the classes to be in the same package or in a package above the blue ones
you would have to restructure
Don't you mean package-private?
protected isn't applicable for (top-level) classes.
It does have the same effect with the addition of allowing access by subclasses of a type.
I guess it sort of depends on what exactly about those classes needs to be isolated
Also
Those look like exceptions
...why would you reduce access to exceptions?
Like, if they're part of the API then you should allow consumers of the API to catch them.
read the last part, those were just an example
If you don't want them to be catchable, you should define that as part of docs/extend from Error, which effectively says "Do not catch."
Oh I see.
Yeah I missed that, nevermind.
oc exceptions donut steel
Yeah seems like only way to really do it is move classes around
reflections 
For the Exceptions, I just didn't want anyone to throw new types of those exceptions
Managed to do it by making a public Factory class, with protected methods and making the CommandInjector extend the Factory class
I would like to imagine that you're somehow selling access to throwing those exceptions by doing paid api calls at $0.05 a call
i managed to resolve most other issues managing protected
Eg i didnt want anyone else using the Api interface, made it package private
And for ApiSettings i made its constructor protected
not a bad idea
adding that now
everytime you initialize a class for the Api, 5 cents per initialization
just find a way to host these calls remotely then make sure you charge every time they call it through account balance or something
and then donate 50% of it to spigot so you dont get banned
or even better find a way to link it to one of those phone hotlines that can charge you extra cash
api support
LMAO
instead of docs
that way anyone with a phone can call the exception and you can collect
i spent a lot of time on javadocs today, guess ill convert it to paid access
and you can literally call a phone number to get the exception too which is a plus
yes just literally call the exception
Nah just steal they're money, charge they're card directly 5 cents each transaction