#help-development
1 messages · Page 2211 of 1
83.1% of people run above 1.16
1.8.8 people just want to click their left mouse button real fast.
Everything more complex is incomprehensible for them.
Well there’s block hitting
But that’s just spam left+right, not much of a difference
I like 1.8 combat because I panic like fuck and just hit random buttons.
I am a 1.8 combat enjoyer , but I am also an intellectual who installs a plugin
no, dont even fucking think about swearing
alright so does anyone have a fix to this #help-development message lmao
have you read general
swearing is fucking prohibited don't you dare
porhiniyted
why the fuck would you swear
no you can not fucking swear
||When used in moderation cursing is fine||
Check your EOF characters. Format the file before compiling.
fuck fuck fuck fuck fuck fuck fuck fuck fuck fuck fuck fuck fuck fuck fuck fuck
I actually typed each of those rather than copying and pasting lmao
lol

bollocks
(no ban pls)

like checks the .xml for EOF?
string
int
are you running an offline server
The problem occurs on a yml file. So i would start there.
GUI: {}
SETTINGS:
DO NOT DELETE:
==: org.swordofsouls.BUILDER.Backend.Settings
INPUT_TYPE: 0
and even with the same file switching to the pervious maven version fixes it
string are you making an offline server?
Format the file. Notepad++ has a feature for that.
Use a more object oriented approach pls
TimeUnit class go brrrrrrrr
formatted, same issue
private Instant endTime;
public void setTimeToPass(final Duration duration) {
this.endTime = Instant.now().plus(duration);
}
public boolean hasTimePassed() {
return Instant.now().isAfter(this.endTime);
}
why do you need to use modulo in that?
are you kidding me
this is a thing in java???
I literally wrote an entire fucking duration thing that does all of that
Since java 8 🌚
Setting a duration is as easy as:
x
setTimeToPass(Duration.ofSeconds(30));
or
setTimeToPass(Duration.ofDays(1));
or
setTimeToPass(Duration.ofMillis(6000));
etc
I find that more readable than using raw millis
More bug prone to the contrary
I once ran a thought experiment on how far you could abstract something away. And i ended up with
something called Atomos which was like 50 abstraction levels away from my starting point (Car)
lmao
There's no limit to how many abstraction layers you can have
The question is how many of them can be useful
Naaaaaa
More like gold if done correctly and solidly :3
Composition > Inheritance
I made a claim system but whenever a player claims land instead of getting the UUID in config file, I get this:
Which is a UUID. So...
Just serialize them as a String and deserialize them using UUID.fromString()
When I reload the plugins or open the server again I get errors
How did you serialize it
It cannot understand the extra part
7 is correct though
I forgot to add .fromString
Ty
There a way to know who crafted an item in the CraftItemEvent?
...how...?
getWhoClicked
I thinks this is exclusive to the InventoryClickEvent
CraftItemEvent extends that
Ah thought about the Prepare event
any clue how's this done?
Resource pack
well how is it sent in chat xd
Using Chinese and other obscure characters
huh
lol calling every foreign language's letters "obscure"
But the client knows what the gibberish means
And turns it into a cool looking texture
With the help of a resource pack
ok i can do the resource pack i just dont know how would i send it to a player
upload it somewhere. then use sendResourcePack
i dont get the question
in here he could use these textures in chat
the textures exist in the resource pack
in your resource pack you add a font. it looks like the normal font except that ä gets replaced with the spigot logo. now you send a message that contains ä and itll show the spigot logo.
i wonder if chinese servers use latin letters for custom textures and call those obscure lol
Lol
How can I rotate a block to be facing a certain direction w/o getBlockData
why without blockdata?
Don't seem to have that as a method
you should rephrase your quesiton to "how can I rotate a block in <version>" then
probably setData(...)
normally the one that's simply called "your-plugin-version.jar"
oh alright
unless that's not the file with the largest size
then you should check your pom and see what you have defined as finalName
Hmmm
So I'm attempting to set the direction of vines
Block vineBlock = b.getRelative(facing.getOppositeFace());
vineBlock.setType(Material.VINE, false);
Vine v = (Vine) vineBlock.getState();
v.setData();
I have the cardinal direction that I would like it to face
In the form of BlockFace
I'm receiving what should be an extremely simple error to fix but like I have no what's going on...
Caused by: java.lang.Error: Unresolved compilation problems:
The import me.screescree.SuperiorSteed.Utils cannot be resolved
Utils cannot be resolved
Utils cannot be resolved
at me.screescree.SuperiorSteed.SuperiorHorse.HorseEditor.HorseEditor.<init>(HorseEditor.java:14) ~[?:?]
at me.screescree.SuperiorSteed.Commands.SummonHorse.onCommand(SummonHorse.java:26) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
import not resolved
even though its right there
and my IDE says its fine
I literally didnt make any changes that has to do with the file structure
i just added a print statement and this happened
its a little hard to tell because of all the indents
why is this happening i didnt even do anything 😔
seems like your sources root is messed up
ok so I found that ```java
Vine v = (Vine) vineBlock.getState();
v.putOnFace(facing.getOppositeFace());
or why is the horse folder green and commands folder blue?
but how can I reapply this back to the block itself?
the green highlight is just saying the file is not staged in git
the commands folder is blue because vscode extension makes certain folders with certain names look nice
i even checked it in WinRar...
how can you have a jar file if it cant compile?
it does compile
i load the plugin
and then run a command that uses the HorseEditor.java file
then it throws an error
i'm literally using the same import line in every other file
could this be something?
[WARNING] IF-0.10.5.jar, superior-steed-1.0.jar define 1 overlapping resource:
[WARNING] - META-INF/MANIFEST.MF
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
no
you can ignore the warning about META-INF
you only need to care about the MANIFEST file if that actually contains something useful
for example if you wanna define a main class for a standalone app
idk never saw this error before
i just compiled it and loaded the plugin 50 times and now it works..
i didnt even
change anything
huh
im confused
i love programming
just get a proper IDE 😛
same for me sometimes using light mode
idk I also sometimes eat pizza with tuna and sometimes I rather eat another kind of pizza
sometimes i drive my car with the seat facing the other direction
hm I never tried that. it's probably illegal here
sometimes my knees bend backwards too
no
oh I found your base on alex's server and left a sign
lol
I've been busy
fair
thanks for remininding me though I'll hop on right now
welp im going to sleep
I live vscode but it's no good for plugins
👀 your take is bad so I will ignore it
RIP I was online the whole day but now its 4am and I gotta go to bed
lets do some stupid stuff in mc tomorrow
I will after summa school class
oki
all other opinions are invalid, vscode above all
you say this until you try to use kotlin 😆
ill make it work
at that point you might as well use notpad++ tbh
why does WHITE_DYE not exist
nvm i accidently imported NMS Material
is it possible to use a custom chat color on the display name of an item?
have you even tried it- yes
how do i do that
i havent really used custom chat colors before
but I heard you have to use TextComponent or something, which isn't an argument option for ItemMeta#setDisplayName
ItemMeta#setDisplayName(ChatColor.GREEN + "green.")
ItemMeta#setDisplayName(ChatColor.translateAlternateColorCodes("&a&lbold green."))
aw man
you can use hex on the display name
it just might not work in the inventory preview
you have to try it yourself
wdym
how does the display name work but inventory not
how would you even attempt a custom color
this takes a string not a TextComponent or whatever
oh okay
Hello
I am looking to spawn a falling block
But I just want for ex. a normal block to fall at a given location
How can I do that w/o MaterialData?
Hello, in this example, how are you getting the block to phase through the others?
Oh nvm I see, you are removing then readding
Is it possible to have the block phase through?
So I have a weird question. Does anyone know why Bukkit added a PluginClassLoader at all? What was the desired goal?
Well right, but that doesn't strictly require creating a new ClassLoader, you could simply load the jar and use the normal one.
U can check what it does yourself
I have eyes, that isn't the problem.
I'm trying to figure out what advantage this offers, and the best I can come up with doesn't seem to cover it.
What it seems to do is read the bytecode and redefine the classes contained within that plugin's jar, but I don't see why that would be advantageous.
am i tweakin or is there not a way to save a maven build to multiple directories
I don't think Maven's really designed to do that sort of stuff, it's pretty much just designed to build things. That's why people use things like Ant / Gradle on top of Maven.
You can specify an output directory, but I don't think you can do multiple.
give me a bit and I can answer the classloader question
No it is not implemented yet
Sound sound = Sound.values()[new Random().nextInt(Sound.values().length)];
EntityType entityType = EntityType.values()[new Random().nextInt(EntityType.values().length)];
event.getPlayer().playSound(entityType,sound,100,10);
is this correct way to produce sound when ever player breaks a block
https://pastecord.com/ihycawaguf.coffee
this is my full code
are there any libraries or similar out there that help with creating chest guis? having lots of problems trying to make my own implementation so i figured i might as well use someone elses code lmao
why are you passing entitytype into the sound?
InventoryGUI by phoenix616 is one I use quite often
entity and entitytype are not the same
i thought its asking which entity sound you want
there's a list of sounds
event.getPlayer() like this?
yes
Sound sound = Sound.values()[new Random().nextInt(Sound.values().length)];
what about this?
are you trying to get a random one
yea
that should be fine
Is there a way to check if a villager has a bed?
i dont think they have a hardcoded bed
So is there a way to what entity owns a bed?
only player probably
🥲
its not working
there are no errors in console
and other part of code is working
like spawning mobs
What are the best practices to organize commands?
Other then a giant if-else tree in the onCommand method
switch?
But if there is a tree of commands
It quickly turns into unmanagable mess
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.
I think there should be some design pattern for that
you can learn basics of java
is it possible to give armorstands some type of data that the player cant see? i just want it to be able to remove the armorstand with a command
well if you cant give time then how will you learn
if you will give atleast 1 hour a day then in 15 to 20 days you will know almost all basics of java and will be ready for spigot coding
Java can Run on anything
The question is whether the application written in Java can run
my old pc has 2gb ram and i was able to run java 8 on it lol
||but can it walk?
||
It can even Sneak
snek
No!
it was just a guess lol
i think you should download java 17 and not the latest version
Or Azul Zulu, But idk their page
Another alternative is Jetbrains runtime or DCVEM
and you will also need a IDE so i recommend Intelligi idia
I would Not Run Stock OpenJDK
I recommend eclipse since that is the only IDE I can help one with heh
but it is not much beginer friendly
Whatever, you should learn to use Java+Javac from the CLI first
you can use blueJ too😂
AI autocompletion?
?
Its a very old java software its just like notepad many beginers use it as they dont have to download jdk
not at all
no one usses it
Aha
idk why my school asks their students to use it
My school uses "Javaeditor"
blueJ is notepad with little better interface the only advatange is you can just click on new class and create it lol
Doesn't Run on Linux, so I just ignore their requests and use eclipse (but as of now sublime Text is the easier route)
for school projects i need to use blueJ since in school lab there is no eclipse
I wish i could do the same, blueJ is 10 times slower
I mean I do Not really Care, I have used Java for so Long that I can Develop without an IDE
from time to time I Troll my teachers and use plain old notepad
i am depandent on code recommndation so it becomes faster and if i have done a mistake it takes me a lot of time to figure it out
i have been learning java for 2to3 months now lol
I've been using it for 5 years now
Though I only really started going with it throughoutly 2 years ago when I also switched to eclipse
Just a meager 17
That is kinda a Young age to learn it at svhool
Though looking at my classmates, I'd Not recommend learning it through school If you are 18, they struggle incredibly. Though I am kinda to blame there given that I am probably accelerating the pace
i am at class 9 in class 8 java was taught at school and in class 9 students had the option to choose between commerce , PE and computer so i choosed computer
i dont depend on what school teaches i just search up the internet to learn new things and sometimes do small courses on udemy
Initially my mother taught me the basics - I was quick at forgetting them
Doing it yourself helps a lot
oh
yah if i was dependant on what school teaches i would be learnign how to add 2 variables
E.g. I would do stuff Like
while (bool == true); {
}
And be wondering why the Loop did Not loop
comparing a boolean with "true" is an interesting idea lol
Is it better to use xEntity instanceof Ghast or xEntity.getType() == EntityType.GHAST?
what is xEntity? is that part of XSeries or did you just happen to call a bukkit entity "xEntity"?
how is that pretty obvious? could also be that you meant XEntity
if you explicitly want to check if it's a ghast and nothing else, use the entity type. if you don't care whether it's a ghast or one of its hypothetical subclasses, uses instanceof
I wrote xEntity twice, like I could write someEntity, anEntity or entity. There's no possible way to mistake that, and considering the question it's even less possible :/
...
why cant u just write en or e or entity
But a hypothetical subclass is also EntityType.GHAST isn't it?
no
a Spider is instanceof Spider and has EntityType.SPIDER.
A CaveSpider for example extends Spider and hence is instanceof Spider and instanceof CaveSpider and has EntityType.CAVE_SPIDER. Enums are public static final constant fields and fields cannot "inherit another field" or similar
lol didn't know it was a problem naming an example variable the way I want and properly
Hm that's true
anyway it was a legitimate question to assume that your question had something to do with XENtity and I don't see why it's so funny to consider that I think this might have been the question. Better ask before giving a wrong answer
But if I have a public class superGhast extends Ghast
extending the NMS class
it should be from type Ghast no?
then you don't have any bukkit entity at all unless you explicitly create any
how can I get the CPS of a player?
measure them
NMS actually gives you a method named getBukkitEntity(), but will it still be considered type GHAST?
I use ghast as an example btw
that will return null if you don't have any bukkit entity IIRC
hmm nice to know
1 sec
it works like this. if you extend one of those "spawnable" classes instead of an abstract class, it will return a bukkit entity that's "the same" as the class you extend. so yeah if you do getBukkitEntity on your NMS Entity that extends Ghast, you'd end up with a bukkit Ghast
if you directly extend Entity or Monster or things like AbstractMinecart, you'll get an AssertionError
np
This CME is driving me nuts
at java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:649) ~[?:?]```
do not remove or add stuff while iterating in a for loop
either iterate over a copy of the map, or use a temp collection where you store the "to remove" or "to add" things, or use an iterator
I want to stop all trolls at once, I have
plugin.getTrollManager().getTrolltable().values().forEach(Troll::stopTroll);```
stoptroll does the following:
```java
public void safeRemoveTroll(UUID uuid) {
Set<Map.Entry<UUID, Troll>> entrySet = getTrolltable().entrySet();
Iterator<Map.Entry<UUID, Troll>> it = entrySet.iterator();
while (it.hasNext()) {
if(it.next().getKey().equals(uuid)) {
it.remove();
}
}
}```
show the full stacktrace pls
?paste
what's GuiManager line 152?
this
the forEach
what's "Troll.stopTroll" ?
It calls this method java plugin.getTrollManager().safeRemoveTroll(trolled);
so you loop over the values of the map and then create an iterator again of the same map and remove stuff from it
so you get a concurrentmodification
why do you need the forEach() if safeRemoveTroll iterates over it anyway?
the stopTroll() clears up stuff left behind by the troll, like blocks, etc.
that's why the safeRemoveTroll() is called after that in the stopTroll()
hm hard to say on how to improve this without the full code
all I can say is, do not remove stuff while iterating without iterator 😄
My basic idea was to get all active trolls (iterate through the HashMap) and stop one by one with an iterator
but as you said that would be a loop + an iterator = CME
NO looping with an iterator is fine
You can;t remove manually is all, use iterator#remove()
but they create an iterator inside a for loop
oh
because both methods are looping lol
yeah, iterator has to be outside
Iterator it = Map.getIterator();
while (it.hasNext()) {
Troll troll = it.next();
//do shit...
it.remove();
}```
Means I'd have to remove the method to remove it from the map from the stopTroll() itself I guess
?paste
Is there anything I can do to prevent the plugin from sending this message when it enables? https://paste.md-5.net/izozuhusiw.cs It is from MongoDB btw.
How can I add a ban by UUID? The only types for getBanList are name and IP
use name from teh enum, then addBan(uuid
How to drop an item in front of a player?
World#spawnItem
event.getWhoClicked().getWorld().dropItemNaturally(event.getWhoClicked().getEyeLocation(), event.getCursor()).setPickupDelay(40);
But how you can do it like in front of a player.
Since this works, but is not in front.
get the location of the eye. get the direction they are looking at, normalize that vector, and add it to the eye location
event.getWhoClicked().getWorld().dropItemNaturally(event.getWhoClicked().getEyeLocation().add(event.getWhoClicked().getEyeLocation().getDirection().normalize()), event.getCursor()).setPickupDelay(40);
Don't die, be alive!
Memory leaking coff coff.
public static Location getLocationInFrontOfPlayer(Player player) {
Location eye = player.getEyeLocation();
Vector facing = eye.getDirection();
return eye.add(facing.normalize());
}```
don't inline everything
^
if you need "event.getWhoClicked()" three times in one line, you're doing sth wrong lol
I don't think that calling the method getWhoClicked() stores a value in the garbage
I didn't say that it does. But this is unreadable and useless
?
I can read better with mine, since is more direct.
Do you know what memory leaking is?
xd
I think you don't know what it means
That isn’t a memory leak tho, so you know what it means?
Once with his code I store a value in a var, since it doesn't get deleted, it occups unuseful space.
Nope
A memory leak is when some memory on the heap cannot get cleared by the garbage collector even tho there is no reference to it
?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!
[WARNING] Unable to create attribute: null
i got this error when try to add attribute in my item
Mind sharing your code?
it is a local variable lol. it gets garbage collected
using variables != memory leak
Mhhh, go ahed.
memory leak = keeping references to objects you do not need anymore
And to make that var. global I've just to use "public" before the var to make it not local?
But ghost you have to understand garbage collection runs in waves, most "unused" stuff just stays there in the state of being enqueued for gc for some time before being swept up by the gc
no, you can;t set the scope inside a method
you cannot maky ANY variables public that are in a local scope
Java has a scope hierarchy system
that's the whole idea of local variables
Ok I redo the question.
https://pastebin.com/XXTUDQbw
my code here somebody help
How to make a var. global?
you make it a field
What's wrong?
there is no such term as "global" in java. you probably mean public fields
Use the attribute api given on ItemMeta
Since a var. is local, so is local to that class, you need to create a method to get that var.
No need to use nms this unnecessarily
it send this error why create attribute in my sword:[WARNING] Unable to create attribute: null
no. local to that current block of code. it's local to the current execution of the method and get's marked for GC as soon as the method finished running
wrong reply
a local var is local to teh method. if its at class level its a field
@vast raven
local variables are indeed fine to use lmao
you do not have to avoid them
you will have a very bad time if you try to "use as few vars as possible"
Right I failed, btw that is the concept, If I wanna get that var. out that part of code, how can I set the code?
That's what I've done so far.
you return it for example?
bruh what are you talking about wtf is var in the java?
a short name for "variable" i guess
Back on you, do you use NBTApi?
ye i have use some like NBTTagCompound. NBTTagList,...
Uh, didn't expect is even complicated to understand that var. equals variable.
well it's hard to understand because you misunderstood basic java concepts. you cannot for example "return a variable"
you can return objects or primitive values
but you cannot return "a variable"
Never said the word return.
ego is bad. Its the downfall of every bad dev.
you wanted to "store a local variable"
^ all local variables are stored on the stack anyway
If I wanna get that var. out that part of code, how can I set the code?
like what is that supposed to mean? "get that var. out of that part of code"? You mean "how can I return the object my var held?"
if not, no idea what you are talking about
Chill out, man I got a lesson from your mex.
I'm totally relaxed
Btw that's it what it would like the code now:
event.getWhoClicked().getWorld().dropItemNaturally(getLocationInFrontOfPlayer((Player) event.getWhoClicked()), event.getCursor()).setPickupDelay(40);
what does "mex" mean
Ok fine, I better shut up.
I think so too
By the way "mex." is messages.
https://pastecord.com/hyzupumibi.cs
This is my code and by this piece of code it should random mobs when ever player breaks a block and play random sound
everything is working but its not playing random sound
and there is no error
ping me if anyone knows
is the sound variable a proper sound?
wdym by this? :/
line 18
yea ig
Sound sound = Sound.values()[new Random().nextInt(Sound.values().length)];
its getting random sound
xD
i didnt know that ;-;
find out if you’re pregnant via minecraft sound
;-;
if the normal A' tone is 440 hz, and that would be 1.0, then 10 would be 450k Hz. Normal people can hear up to like 10-20k Hz
xD
too much math
it's just 440 x 2 ^ 10
yes :/
i HATE powers
i HATE WHOLE MATHS
maths lmfao
maths suck for me :()
why the s
how could one check if a player is in the whitelist using AsyncPlayerPreLoginEvent, would i just have to loop thru whitelisted players and check against name and/or uuid?
yep
h
why don't you just check if the Result of that event is KICK_WHITELIST ?
i believe they have a custom whitelist
bc im trying to do if server is full but player is whitelisted, let them in anyway
not using the default one
oh no im using vanilla /whitelist im just trying to use it as a bypass player limit
vol also?
yes
did you mute any soundcategories in your options?
add SoundCategory.MASTER to the playSound thing
that exists!?
still no sound
then what’s a players point in disabling sound if you can over right it
that's for the builtin things I guess
okay ig
like inside playSound or what?
yes
do you know how java works?
you cannot just insert it into any random no-args method
declaration: package: org.bukkit.entity, interface: Player
does vanilla /whitelist add <player> perform a profile lookup for accounts that havent joined before?
ah...
yes. if you do /whitelist add afwkugawfkugawfkuwaf then it says "user not found"
and I sent the javadocs and I'm sure your IDE also has auto completion / suggestions
and that it doesn't belong into the no-args method Event#getPlayer() is kinda obvious lol
yea i did this event.getPlayer().playSound(event.getPlayer(),sound,SoundCategory.MASTER,1,1);
time to pray
still not working
print out the sound
or use a fixed sound instead ofa random one
e.g. Sound.MUSIC_DISC_STAL
Or Just use ConcurrentHashMap
ok
that won't avoid ConcurrentModificationExceptions. It's just guaranteed to be thread safe
didnt work
The only issue is that they are using LinkedHashMap, which is a bit different from CHM
then your client is shitty, or youre using a weird resource pack, or whatever
;-;
oh you're right, didnt know
It is the truth; do Not try to hide from it
but i am not using any resource pack
and i am using official client
As in modded Vanilla client?
no
tfw i went to edit eula.txt and deleted "false" only to write "false" again
noooo
it literally says "optifine" in your screenshot
Then write a 100 Page Thesis on how this is Not modded
i thought you are saying that i am using mod in my server
Should be easy enough
No, we are talking about the client
Your Server needs to be modded in Order for your Plugin to work
-2935318891425991076
server needs to be modded how?
what
That being Said, Velocity, Paper or a Plugin you are using might have a Bug that prevents the behaviour you want
oh sry that was a seed for a world i just gend
The Bukkit API is Not and will never be the official modding API
Even If it was the closest of all APIs to be exactly that
But paper is Not owned by Mojang to what I know, so that does Not apply either
okay so should i install official jar?
except on thursdays
For the client yes
For the Server you should be using spigot since you are on the spigotmc discord
But really paper would do the Job Just as fine
ok
Still getting the issues?
Then what Code are you using?
oh right, getLoginResult is always ALLOWED in this event for no reason
player quit event?
https://pastecord.com/vykinysuqi.coffee
my full code
so id have to manually check if player_count >= player_max
maybe ur just deaf
;-;
Do you also Hear other music Discs?
are you using via versio nor any other weird stuff
i didnt tried
?jd-s
maybe get location of player
or something idk
via version 🥰😍
and play at location
okay lemme try
How can I check the player's cause of death from PlayerDeathEvent?
e.getCause?
Does not seem to exist
event.getPlayer().playSound(event.getPlayer().getLocation(),Sound.MUSIC_DISC_STAL,SoundCategory.MASTER,1,1)
SoundCategory.MASTER is a bit strange
Sure that it should Not be RECORDS?
2012 🗿
old code ontop
Oh the damage event is smart
I'll do that
custom desth even better than the normal one anyway
they actually wanna use random sounds. we just told them to use a specific sound now to test why it doesnt work at all
I would omit that parameter
yeah they only added it after I suggested that 😄
all I could think of is to try to use a location instead of entity as source
or to use the string soundname
did you set an api-version?
if you have the wrong api-version in plugin.yml the SOUND things probably use the wrong file name
also check your client log
it will tell you whats wrong with the sound
Not setting the API-version would yield a FieldNotFoundException or something along the lines of that
seems like they died anyway meanwhile
Hi! Does anybody know how could I create a separated inventory for each Inventories: option from my config?
Inventories:
'ExampleMenu':
Items:
- DIRT 32
- STONE 32
'TestMenu':
Items:
- DIAMOND 2
- COAL 8
loop over they keys of the "Inventories" configurationsection
getConfig().getConfigurationSection("Inventories").getKeys(false).forEach(name -> {
ConfigurationSection inv = getConfig().getConfigurationSection("Inventories." + name);
// do something
});
I tried this way, but it doesnt works and I know its s#itty
public class ItemsMenuCreator {
public ItemsListConfigFile itemsListConfig;
public ItemsMenu[] itemsMenu;
private int itemsMenuID;
private String itemsMenuName;
public ItemsMenuCreator() {
itemsListConfig = new ItemsListConfigFile(plugin);
itemsMenuID = itemsListConfig.getItemsListConfig().getInt("Inventories");
itemsMenuName = itemsListConfig.getItemsListConfig().getString("Inventories." + itemsMenuID + ".menu_name");
itemsMenu[itemsMenuID] = new ItemsMenu(itemsMenuName);
}
public void openInventory(Player player, int ID) {
player.openInventory(itemsMenu[ID].getInventory());
}
}
public class ItemsMenu implements InventoryHolder {
public String menuName;
public ItemsMenu(String itemsMenuName) {
menuName = itemsMenuName;
}
private final Inventory itemsMenuGui = Bukkit.createInventory(null, 36, "§7§oEditing " + menuName + " menu...");
@Override
public Inventory getInventory() {
return itemsMenuGui;
}
}
oohh
didnt work and now i am tired ;-;
.setName()?
if that exists
oh
if (p.getWorld().getName().equals(“aaa”))
anytime
.equals() compares two objects
it’s better to use iirc
if i remember correctly
mhm
.equals checks if the value is the same
== checks if it's the exact same object
@quaint mantle
If there are 2 scoreboard plugins on a server, which one will persist?
which one ever updates more frequently?
whichever sets teh scoreboard last
ok, thx
how do I add hex color support to my plug-in
I highly recommend using Minimessage
i’ll look at it,
archived?
the github
This project has been merged into adventure.
oh 🙈
import md5 ChatColor and it has hex color support
^^ that works too
However MiniMessage makes it much easier for both users and devs
included with the spigot dependency?
i’ll look into use minimessage in my next project 😛
ChatColor is included with Spigot
MiniMessage is included with Paper
is the future paper development 😵💫
Paper has some good API additions
Hello, I have a question : is it better to use json or database to save player's data ?
depends what data and how often it changes
for a system to save an inventory for example
I'd let the admin decide whether to use json or sqlite or mysql or whatever
for example a large server will probably prefer mysql. other people don't want to set that up just for your plugin so they'd rather use sqlite. and maybe some admins prefer to be able to directly edit those files and would like json instead
Okay, I understand what you want to say. And so what's the faster ?
depends. if the sql server is not on the same machine, then saving it via json is probably faster than sending sql stuff over the network. if it's on the same machine, then sql is definitely faster. but I wouldn't worry about it because you should do both database and file i/o async anyway
Faster to access or implement?
oh yeah good question lol
To acces and to implement because for my inventory system, it needs to implement in the database, when the player quits the server and to access when the player joins the survival world.
Different servers?
No, for the moment, it's only one server with differents worlds : a lobby, a survival world, a pvp box world...
Well mfnalex explained speed of access. To implement they are not much different other than json/yaml will be easier. sqlite simplest (of the databases) and lastly mysql
Storing inventories per player I'd not really recommend flat file
Its fine, but it can be messy
other event?
calling an event "p" is confusing lol
Okay, so I think i'll use mysql because my server has this one, and thank you very much for you help ! 🙂 And sorry for my English, I'm french. Have a good day 🙂
what are you trying to achieve?
I'm not sure what you mean by other/different event. Does this not work for you?
do you want to give them an item when they switch into the "aaa" world?
I think you have to write p.getPlayer().getWorld().getName().equals....
yeah getWorld() will never equal to a string
a World is not a String
then you have to use PlayerChangedWorldEvent
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerChangedWorldEvent.html if the player is not newly joining
and do not compare the world to a string, but compare the world's name to a string
1
agreed, the first one
Working with sockets, how can I check from with server the socket came from?
@hybrid spoke @flint coyote thanks guys :)
whoops didn't mean to answer you @mellow edge lol
xD
is there a way to change a function of a vanilla entity (not add a new one) in API without NMS
or at the very least, minimally
theres a very stupid part i need to change (just one line) but it's set explicitly in an entity fn no other way
nvm i noticed an extremely jank way to do it and its beautiful
thanks, also what do you mean with "new named itemstack"?
you mean the shown name of the item?
Is there anything I can do to prevent the plugin from sending this message when it enables? https://paste.md-5.net/izozuhusiw.cs It is from MongoDB btw.
@EventHandler
public void onJoin(PlayerJoinEvent p){
if(p.getPlayer().getWorld().getName().equals("aaa")) {
ItemStack item = new ItemStack(Material.RED_CONCRETE);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("name");
item.setItemMeta(meta);
p.getPlayer().getInventory().addItem(item);```
no need for a new event
you're welcome
Hey, sorry to bother you, I've selected the wrong minecraft version when starting to code my plugin, it was in 1.19 instead of 1.18.2, so I changed this line :
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>```
Which was previously on 1.19, so I replaced it with 1.18.2
But I still get this error when loading the plugin on the server :
did you change api-version in your plugin.yml
this the proper way to utilize the bukkit serializer?
i wrote this from my mind so idk xD
public static boolean serializeBukkitObjectToFile(Object obj, String str)
{
try
{
BukkitObjectOutputStream s = new BukkitObjectOutputStream(new FileOutputStream(str));
s.writeObject(obj);
s.flush();
s.close();
return true;
}
catch (Exception e)
{
e.printStackTrace();
}
return false;
}
public static Object deserializeBukkitObjectFromFile(String str)
{
try
{
BukkitObjectInputStream s = new BukkitObjectInputStream(new FileInputStream(str));
Object ret = s.readObject();
s.close();
return ret;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
public static byte[] serializeBukkitObjectToByteArray(Object obj)
{
try
{
ByteArrayOutputStream bStream = new ByteArrayOutputStream();
BukkitObjectOutputStream s = new BukkitObjectOutputStream(bStream);
s.writeObject(obj);
s.flush();
byte[] ret = bStream.toByteArray();
s.close();
return ret;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
public static Object deserializeBukkitObjectFromByteArray(byte[] obj)
{
try
{
BukkitObjectInputStream s = new BukkitObjectInputStream(new ByteArrayInputStream(obj));
Object ret = s.readObject();
s.close();
return ret;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
try with resources when
for me?
y
for auto closing them?
Yeah
Try with resources it better since it makes sure things get closed
cause the reader could if crashed cause a mem leak in this constellation
Yes
use java if (e.getPlayer().getWorld().getName().equals("aaa"))
insteadjava if(e.getPlayer().getWorld().equals("aaa"))
i mean item doesnt even exist at the point where you are trying to aadd it
e.getPlayer().getInventory().setItem(3, item);```
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.
where you writed it?
send all code
change world
@EventHandler
public void ChangeWorld(PlayerChangedWorldEvent e){
if (e.getPlayer().getWorld().getName().equals("aaa")){
e.getPlayer().getInventory().setItem(3, item);
ItemStack item = new ItemStack(Material.RED_CONCRETE);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.RED+"Are You Ready?");
item.setItemMeta(meta);
e.getPlayer().getInventory().setItem(3, item);
}
}```
np
how can that work as youre trying to access a not declared variable
wdym?
is there any way to get the NMS entity of a vehicle in VehicleMoveEvent? get & set velocity r just plain not doing what i need in api - need the DeltaMovement which it doesnt seem to correspond to
essentially trying to bypass a cap in minecart code using some jank but it's not working as it would if those were the same - seperate mod to customentity (no nms used here although seems necessary to do this)
I never understood how to exit splitscreen again - does someone know? lol
close the files
but that means I'd have to close like 20 files sometimes
there must be an easier way
aaah I found it
try ctrl shift + f12
right click on the bar and there is "Unsplit all"
is the only way to get NMS entity of a vehicle in a event to cast the bukkit entity to craftbukkit entity then gethandle
seems like a lot of steps
yes
Is there a way to disable spawning of specific animals per world natively? So without canceling the CreateSpawnEvent?
What's wrong with cancelling CreatureSpawnEvent?
wdym with natively?
Hey folks, how do I get a hold of a ResourceKey<DimensionManager>, I've got the DimensionManager itself, but can't find a way to wrap it in the ResourceKey
then bukkit keeps spawning and spawning resulting in a few hundred canceled events per sec and if some other plugins are listening on that aswell, they might execute some unecessary logic aswell
I dont think it does, not one which takes a single argument anyways (that is not MinecraftKey)
These are the ones I'm seeing:
public static <T> ResourceKey<T> a(ResourceKey<? extends IRegistry<T>> resourcekey, MinecraftKey minecraftkey) {
return a(resourcekey.c, minecraftkey);
}
public static <T> ResourceKey<IRegistry<T>> a(MinecraftKey minecraftkey) {
return a(IRegistry.b, minecraftkey);
}
private static <T> ResourceKey<T> a(MinecraftKey minecraftkey, MinecraftKey minecraftkey1) {
String s = minecraftkey + ":" + minecraftkey1;
return (ResourceKey<T>)a.computeIfAbsent(s, s1 -> new ResourceKey(paramMinecraftKey1, paramMinecraftKey2));
}
private ResourceKey(MinecraftKey minecraftkey, MinecraftKey minecraftkey1) {
this.b = minecraftkey;
this.c = minecraftkey1;
}
like tell the world while loading not to even try to spawn that kind of entity for example
my eyes
why don't you use mojang mappings
Havent converted to them yet, and I'm not sure (yet) how they go on backwards compatibility
satan is a big fan of you
hello, i'm a bit new to plugin development. if i want to give the player the mining fatigue effect when they are holding a wooden axe in their mainhand, how would i do that?
do you know how to listen for events ?
yeah
that gets tricky without ArmorEquipEvent
oh wait
main hand
mb
nooo
i was thinking at some inv click event smh
PlayerChangeHeldItemEvent or what its called
the one you sent will only be called when pressing F or whatever
declaration: package: org.bukkit.event.player, class: PlayerItemHeldEvent
Fired when a player changes their currently held item
that's probably the easiest and most reliable one
you little rascal
what!
so would i do something like this?
and then i check if the item matches what i want then i give the effect?
check the type yes
alright, gotcha
check if PlayerItemHeldEvent#getNewSlot() is the item you want the player to hold
what does getNewSlot mean? sorry i'm a bit confused haha
getNewSlot just returns the slot the player is now foccussed on
so if i just want to check the mainhand they player is holding currently, how would i utilize that? how do i check for the mainhand slot? because it isn't a fixed slot that i want to check, just whatever the player is holding in their mainhand at themoment
#getItemInMainHand()
yea actually u can just use that
Apart from worldedit, do any other major plugins use mca or nms to place blocks directly?
(not counting plugins that rely worldedit to do mca live edits for them).
(nms/mca-level block editing is a problem as it doesn't fire the relevant events)
alot of plugins utilize nms to set blocks i would imagine
uh oh 😦
That seems like a pain to detect without nms listeners
what events are you looking for
Anything that could possibly change/break/place any specific block
just place large amount of blocks in batches of no more than 1000, separated by a tick or two
so basically all of them
well using #setBlock doesnt fire events either
:L
still slow
@Override
public void setBlockFast(Block b, CompMaterial material, IBlockData blockData, boolean applyLights) {
WorldServer nmsWorld = ((CraftWorld) b.getWorld()).getHandle();
Chunk nmsChunk = nmsWorld.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
IBlockData ibd = blockData != null ? blockData : CraftMagicNumbers.getBlock(material.toMaterial()).getBlockData();
ChunkProviderServer chunkProvider = nmsWorld.getChunkProvider();
nmsChunk.setType(bp, ibd, false);
if (applyLights)
{
LightEngine engine = chunkProvider.getLightEngine();
engine.a(bp);
}
chunkProvider.flagDirty(bp);
}
something like this is way faster
a bit but it's easy and doesn't make much of a difference unless you're working with an enormous amount of blocks
At least with worldedit, the changes are detectable with their api.
With random plugins, its much harder to detect unless you compare the blocks against a database of expected values
well im afraid its hard to detect plugins changing blocks unless those plugins provide custom events for you
wait wrong thread
I was really hoping not to need to run an async block verifier
I think there is a way to listen with nms, but avoiding nms where possible is always nice
Although, mca-level changes are a massive pain to detect, even with nms
what do u even need this for.
about resource packs
:(
is it possible to add entries like this, and make calls to the new sprites?
{
"textures": [
"angry",
"minecraft:big_smoke_0"
]
}
custom model data
you mean particles?
Our behaviour depends on the material types of hundreds of thousands of different blocks at specific locations.
For performance reasons, we assume that blocks are what and where we think they are.
We verify our assumptions on block events, chunk loads, and restarts.
Still, nms and mca screw with that; players can abuse errant blocks before the next check occurs.
To completely fix that, we would effectively need to verify every block every tick, which is not viable.
We are currently planning on having an async process that checks stuff, but that still has potential for errant block abuse.
The goal with detecting nms or mca changes would be for dynamic verification behaviour (intensifying checks where and when they are needed)
its particles
How can I change the stack size of a custom item???
item.getAmount()?
wow that sounds like quite a pickle
The max size
the max stack size? you cannot
Ask papa @tender shard
ohh
He did a thing
get max stack size is a thing
you can only change the max stack size per MATERIAL
not per individual stack or anything
ty
u can
this, and this is also the reason why the stack size is hardcoded
as I said, its possible per material, not per itemstack https://github.com/JEFF-Media-GbR/StackResize
tbh i dont understand why the stacksize is hardcoded into the material instead of being a nbt flag
like damage
and literally anything else
because mojang didnt intend people to change it
Indeed... hoping to be able to have at least some way of doing it though.
Worldedit's API is sufficient to manage this for any plugin using worldedit for the operations.
As for anything that doesn't, idk... nms listeners might be needed.
A mca scanner might also be needed, but that sounds like a massive pain.
Mostly just wondering how big the issue is (i.e. how many major plugins do this sort of thing independently of worldedit)
If it is only a few dozen, hooking into relevant apis might be an easier approach than the listeners and scanners needed for a general solution
so what about custom sounds?...
can i call custom sounds from resource packs without overriding vanilla ones
xD
or isnt it worth the effort either
to attempt
it kinda sounds like ur gonna need to make sure any plugins that edits those blocks uses worldedit
I don't understand blockDamageEvent, what is a player "damaging" a block ?
oh the mining animation @tall dragon ?
because its not broken yet, they are just damagin it
bassically its called when the player starts mining a block
oooooh
any tutorial thats up to date?
thanks
Hey there. I can't use 1.16.3-R0.1-SNAPSHOT from spigot (NMS) mojang remapped
I ran the build tools but its not working and maven is throwing an error which is :
Cannot resolve org.spigotmc
1.16.3-R0.1-SNAPSHOT
there is no remapped for 1.16
also who the heck uses 1.16.3?
i could understand 1.16.5
but 1.16.3?
1.16.5 has remapped
tbh
I even agree with using the latest version of spigot
but im not the server owner so...
oh didnt know
are you sure? I tried 1.16.5 before 1.16.3 but got nothing
That might be an option, but would introduce more compatibility issues than I am comfortable with.
I feel that selective compatibility would be too much of a burden to place on our userbase.
I think the easiest solution is probably to natively support the big plugins, and deal with specific compatibility complaints as they come in.
I would need to somehow make a list of big plugins that use nms placement independently of worldedit though, which sounds like a massive pain.
Either that or try to make some general nms listener / mca scanner... which also sounds like a massive pain.
Might need to make a library of some sort for that.
Currently, we have somehow managed to avoid nms throughout our entire codebase
I don't want this to be the reason that forces us to use it.
No I was wrong 🙃
Skip the remapping
Join server
I just left a few minutes ago lol
I have to try something in a VM