#help-development
1 messages Β· Page 914 of 1
did you guys know, if(event.getEntity() instanceof final Player p) you can put final in advanced instanceof?
anyone knows a open-source nodejs server to create and upload my plugins (so people can use my plugins API)
like nexus, a little bit more simple
Player.hideEntity
What exactly is an "open-source nodejs server" to you?
You mean like a rest-endpoint? Because node has an http server builtin.
But then i wonder: Why do you want to suffer with an nodejs backend?
nexus but simpler: reposilite
(why nodejs?)
Ah he wants to create a maven repo
Ok. Then i completely dont understand why nodejs...
yea thats what it is called
no
i thought its better
im having a hard time using spigot with reactivemongo. reactivemongo uses akka which is having a lot of issues with spigot using its own classloader for plugins... it cant find any of its own classes or resources
does anybody know if its possible to create a world that doesn't save at all, I've been looking at the server files and from what I've seen it looks like I'll have to modify the server code
thanks
also i've a Host which it supports PHP and NodeJS only
then you can't use reposilite nor nexus. but you don't need any of that, you can also just use (S)FTP directly with maven. a maven repo is basically just a directory layout
Have you tried loading ReactiveMongo via the plugin.yml instead of shading it into your plugin?
If that doesnt work then you need to make akka aware of the parent classloader of your JavaPlugin.
im not shading it
so just uploading my plugin into folders like maven repos does?
You need to dig into akkas resources and find out π
i already thought about loading my db class through the system class loader in a bootstrap sort of javaplugin instance, but that would be crazy work
no, maven does that automatically. just use ftps://user@whatever (or whatever protocol it supports) instead of https:// for the repo, then run mvn deploy
theres probably nothing for that. the docs are terrible btw, im gonna take a look at the source
CDI frameworks are notoriously buggy with spigots classloader
thanks
i will probably have to do this
oh nvm this is the wrong class lmao i didnt look at the package name
Akka is a toolkit for building highly concurrent, distributed, and resilient message-driven applications for Java and Scala.
Thats gonna be a pain. gl
what class loader even has access to the resources inside plugin jars?
might be able to do something with the context class loader
thread.setcontextclassloader or something like that
thread.currentthread
https://github.com/akka/akka/blob/main/akka-actor/src/main/scala/akka/actor/ActorSystem.scala#L270 theres definitely an option to supply a custom class loader it seems like
but im not sure if i even have access to it considering im using reactivemongo and it handles all of the stuff
A "BRB gotta set fire to an orfanage"
2s later
B "BRB gotta save some orphans from a fire"
agreed
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
anyone knows why Entity#isValid is returning false when an entity is in the overworld?
did it get removed
yes
then that is correct
but when i spawn it in other dimensions it works correctly
#isValid will return false after calling #remove
you can't just spawn it in a different dimension 
i spawn it when i shift, the entity instantly disapear if i am in the overworld but in other dimensions it spawns correctly
Some spawn chunks will be kept loaded. This prevents the entity from being unloaded which keeps it valid.
If an entity is unloaded then its invalid, no matter where it was before.
You have some plugin or gamerule which prevents your mobs from spawning in your overworld then.
i don't have other plugin and i haven't touch anything from the overworld
oh wtf, i deleted the world and now it works
this is awkward
Hey, does someone know how to edit player nametag in 1.9.4 i tried some protocollib thing but doesn't work
Could somebody help me? I am trying to commit a bunch of files to my repository but I don't really know how to...
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1363/overview
I don't want to manually commit over 30 files line by line in the web browser...
These tutorials in ?contribute are really old and don't really help, I am really stuck
I already tested the changes in a dev server of craftbukkit over an hour ago with the changes and it works. I would like to contribute...
From what I understood, I have to commit the changes (childs of BlockState) to my CraftBukkit repository
why does intellij tell me there is a typo in a word but doesnt tell me what the typo is?
it may not have caught up with its bg tasks and is showing an old typo
idk I just use git kraken and click add all on all the CB files
just make sure you don't accidently commit NMS 
Because IntelliJ isn't very good at spelling either
(I asked the IDE btw if you're curious how I know)
okay, intellij is always trolling me it tells me something might be null but it doesnt tell me how it knows that
Probably cuz it'd break OCP if it told you
@echo basalt can I get confirmation on this?? ^
π
wsup
well IntelliJ keeps not telling him where errors are and I'm pretty sure if it did it'd violate OCP so
probably why no?
why would IJ violate ocp
where did the OCP hurt you
@inner mulch can you check over my plugin to make sure it follows OCP
yes send me source
okay
I've gotta friend you because I don't want anyone leaking my source (My code is really good)
okay
no, however, after founding CabernetMC My attitude on open source has definitely changed
my sponsors expect Enterprise code from CabernetMC developers which would only be impeded by FOSS
@echo basalt Certified best OCP
yet another title to add to the core developer of CabernetMC
cabernetmc looking more and more stacked
we are looking for other contributors don't be affraid to jump off a sinking ship


What does ocp stand for
open close principle
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
@molten hearth sorry went home last night and just fell asleep lmao
I think it was you that needed help
All good lol and yeah it was
it is not possible to use String ColorUp = color.toUpperCase(); in a Chatcolor.ColorUp but is there a work around
what are you trying to do
get the name of a colour?
no theres a function like func(arg1, arg2, arg3, Color) and basically i need to take the color argument and use that in the Chatcolor.Color
what?
no what are you trying to do
explain exactly
rn you are just explaining an xy problem
oh mb
Trying to take a argument (img 1) and use that in the function so the code run when compressOres to change the color of the name using compressedIngot.getItemMeta().setDisplayName(ChatColor.Color+ name);
so you want to get the colour of the name and apply it to the ingot output am i right?
No i want to use a color that is set
use the enum then
instead of taking a string colour take a ChatColor as the variable
then you can just do color + name instead of parsing it
yeah
just color
Alright im back from school
Welcome back
How can I make the player drop a specific item in their inventory?
Right, I need to force them to drop an armor piece, even if it has curse of binding
from their inventory or add an itemstack to their inventory?
read my previous msg
no
just do
color + name
that would just be doing like 3 extra steps to get to the same palce
How can I give the item velocity in the direction?
player.getLocation().getDirection() will get you a vector in the player's looking direction, pass that to item.setVelocity()
Maybe multiply it by like 0.25 or something
ok sounds good
I'm so glad I actually understand what a rotation vector is
I had no idea what it was 2 weeks ago
Where can I find the code for the player.dropItem(true); method?
I basically wanna replicate it
I also need to check if that itemstack is null in the armor slot before spawning in the item
to prevent any race conditions from occuring
Is there a way to get a list with all similar items for Material or Block? Like all woodtype doors, all colors glass etc
Likely something with Registries
Tags
CraftPlayer calls NMS' drop item method, implementation is under EntityPlayer (or ServerPlayer if you're using Mojmaps)
It mostly delegates to the super implementation though and then just appends some stat tracking, so EntityHuman's drop() method is more interesting
Thanks I figured it out
why is this always false?
if (!m.getPersistentDataContainer().has(dangerKey, PersistentDataType.INTEGER)) {
how are you setting it
For debugging purposes, I am printing out each step, checking if it's ran
and I never see "a"
ok i fixed it
but now it's duping the armor pieces
Did you rm from inventory
I dont know how to get the armor index
this is not a great help, as it doesn't work
it removed it from the... hotbar?
Yeah spigot maps the slots different
Those are protocol slots
Use Entity#getEquipment#setWhatever
ah
the vintage 36 + method
Every damn time I do inventory stuff, it's ALWAYS the 36 + method
Yeah, Bukkit doesn't expose those protocol numbers anywhere
Just makes more sense to reference numerical slots in the order that items are actually added to your inventory
no, it's just basic inventory stuff, happens to me all the time modding on the client side
:p
choco, what velocity do they apply to the item on player.dropItem(true); method?
how could i spawn a vertical circle?
in what form?
particles i supose, by now i just want to get the location points
its like doing a normal circle but cos is z and sin is y ?
or i am not really understanding this
You likely aren't
like usually when doing a circle it is horizontal
but i want it to be vertical to put it behind a player direction
Will this apply an x % damage buff to the damage?
event.setDamage(event.getDamage() + (event.getDamage() * (items.getDouble("Damage Buff") / 100d * dangerInt)));
I believe it changes when expanding and contracting
I think you can just tell it to contract a tiny fraction of a block over a super long period
yeah by making it shrink/grow or not you can change it between pale green/red/light blue
that's basically hardcoded
could probably make it shrink and grow by .01 blocks a time
i mean you can make it change 0.001 blocks in 9 quintillion milliseconds xD
Idk what about when it ends
Yeah I'll figure it out
I thought Player#teleport automatically loads chunks in the area and also... the world?
Also how do you check if world is loaded and how to do you load it
I think you can only do the integer limit
it takes a long
a long schnitzel
So if you look at the console error it stops loading at SpartanHub blah blah blah and im the dev of that could someoen help, if you need the code its @ https://github.com/Pazore/SpartanHub/
@echo basalt
I think u can help
ik u have experience
no clue why you're creating an instance of CC but I suspect your database stuff is hanging
It seems to load fine though
Just add debug messages every other line and you'll be fine
(and no, I'm not the only person that can help you, don't ping or DM me )
bro i started bukkit like 2 mo ago
bro i started work like 1 hour ago
Wdym add debug messages
idk how to fix
ASHIU(ASD
ill js resend
So if you look at the console error it stops loading at SpartanHub blah blah blah and im the dev of that could someoen help, if you need the code its @ https://github.com/Pazore/SpartanHub/

@echo basalt you have modelengine 4 right
yeah
why can't my plugin (Rythm) find Vault
Vault is not an economy service. It just provides an economy API for other plugins to implement
weird request but can you send me a single file from some random single bone you might have from a resource pack generated with it because I'm like 95% sure that minecraft doesn't have a feature I could really use right now but that 5% makes me wonder if rewriting the entire thing is actually needed
I just need to check if there is a display property for display entities that seemingly no one documented
i'm trying to make my own economy for Vault
or if it's not documented because it doesn't exist
so that other plugins can hook into Vault and use it
Then why are you trying to get the existing economy if that's the case?
You need to implement the economy class and register it yourself
that's hella niche
yeah I know
You want the model file or what?
I was in the middle or writing a post on spigot about it but I already kinda know that there's probably only two people who even know what this is about
I just need the rsp output, you can send a whole one if you don't mind, but really I just need the equivalent of a single bone
I am working with books, and I'd like to get a clone of the book. I don't want to edit the information or any attribute of the given book, but I want an exact copy of all of its attributes. When I do something like this, the item gets deleted from the player's inventory. How can I get an exact copy of the item stack without editing the itemstack itself?
ItemStack proposalBook = e.getCurrentItem().clone();
yes
Getting and cloning the item shouldn't cause an issue
Now keep in mind the cursor & currentItem fields are before the click and not the end result
No clue what you're trying to do exactly, might be XY issue
idk, I'll just make a book class to store the information I need. Probably a cleaner implementation anyway
wont name book obv
no lol
I'm using raw nms to intercept a LoginInStart packet. But when the users of my plugin use Geyser, suddenly it cannot find that packet. Shouldn't Geyser keep compatibility with native mechanisms?
I doubt geyser does login logic packets
Isn't it a plugin that allows bedrock players on java?
It does
But still login logic is eh
Geyser most likely just fakes a player and a connection instead of faking the whole login process
It translates packets
Β―_(γ)_/Β―
So why doesn't it fake the packet?
That's illogical
Others can rely on those mechanics
it's nms you can't rely on it
Ofc you can
interesting
It seems like geyser runs its own server thing
When it receives a request it processes it and creates a tcp session o_o
I need to learn more ab netty
hi, what should i use to use numbers more than the max possible
for custom player data so if they have like 8 with another 20 0's
How can I add a ClickEvent to a kick message?
right i'm going a little insane here, why does getServer().getIp() return the servername π
uwu-1 JOINABLE Purpur 25567 weirdly enough i didn't set the listen address to Purpur
getServer().getIp() + ".com" 
lmfao
nah i'm using it to build an InetSocketAddress
but seriously, am i being stupid or is spigot being stupid because this should be working fine
private final InetSocketAddress address = new InetSocketAddress(getServer().getIp(), getServer().getPort());
...oh my god was i replacing the jar in my velocity server..
i was. jesus christ i'm too tired for this π
[servman-spigot] fuck it gamers we ball
[servman-spigot] inetsock info:
[servman-spigot] 127.0.0.1
[servman-spigot] 25567
btw if anyone here wants me to oss this plugin i'm more than happy to, it's a small part of my network that took like half an hour to make lmao. it automatically registers servers with velocity & provides velocity/spigot events for you to hook into
if it's longer than a long, then you've probably done something wrong lmfao
and a long is the 64-bit signed integer limit, so you won't really be able to get any higher than it.
how much 0's does long have
check the link i sent
Stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
18 zero's
a nonillion has 30 zero's and i see some servers with it
is it just virtual?
or they use some custom data types
probably custom data types
because long is the 64bit limit, you can't really get any higher
unless you can store unsigned numbers in java, which i'm not too sure on.
yeah from what i'm seeing you can't store unsigned ints, it's just not a data type in java. you can ofc make it though
For some reason when this code executes, the currentItem visually disappears for the user. They are clicking on it from their inventory while in a custom gui. Is this a common / known thing- or am I just royally messing something up?
if(e.getCurrentItem().getType() == Material.WRITTEN_BOOK){
ItemStack givenBook = e.getCurrentItem();
BookMeta book_meta = (BookMeta) givenBook.getItemMeta();
}
2nd option
how do i kick them using that component?
iirc player#kickPlayer()
could be wrong, check javadocs
thanks
i don't think you're able to make kick messages with clickable text
because there isn't anything in the API to kick/ban that supports TextComponent
Nah SURELY there is
Nah, they use BigDecimal or similar
how can i serialize it to json?
why would you need to do that lmfao
If you use paper, yes https://jd.papermc.io/paper/1.20/org/bukkit/entity/Player.html#kick(net.kyori.adventure.text.Component) otherwise no
(you should be using paper anyway imo)
but yes you can serialise it to JSON
use Jackson or Gson
i'd recommend Jackson since it's pretty simple
but they both work the same
yeah. god i hate NMS so much
I use the spigot api but the server is paper
na
are you building with gradle or maven, i'll send over how to do it
why not
alright fime
You cannot say that tho
whats the link
At least not here
google it
that's stupid imo but fair
na
well i can't really send the link here can i
i can't send links to what md5 probably considers a competitor
I tested it in isolation, and I found out that it was me closing the inventory shortly after it- so something like this would 1-1 replicate the issue I'm having. When the inventory closes, the book disappears (but only visually). Is there any way to prevent this?
if(e.getCurrentItem().getType() == Material.WRITTEN_BOOK){
ItemStack givenBook = e.getCurrentItem();
BookMeta book_meta = (BookMeta) givenBook.getItemMeta();
e.setCancelled(true)
p.closeInventory()
}
player.updateInventory perhaps
Its generally the other people on here that will complain heh
documentation said that it generally shouldn't be used in plugins lol
i added the api now what
lmfao
they've sent you the javadocs man
but it doesn;t appear
refresh your ide
or clear intellij's cache if you're using it. intellij can be a bit weird with that
player.kick(Component.text("Hello World")); for example
translatable components my beloved
real
shame I gotta write my own scoreboard and hologram plugins 
oh my god i am actually so sorry for your loss
but hey it's neat to have a self translating server
i had to use NMS to try to bypass stupid character limits for my sb plugin
and never actually got around to doing it
gotta translate the whole network, new maps, sounds and menus by sunday
"YoU dOnT hAvE aNy SeRvErS cOnFiGurEd" yeah that's the point mate
not saying that
just that I can't bother adding more work to my already busy schedule
no i'm talking about my proxy
ah
fair
whats best way for guis? like making slots and the click events
instead of using tons of classes
for events/making/opening
Pretty sure you can just google inventory gui api
google inventory gui api ? huh google has a spigot api ?
You can also bing it
I myself am a fan of Phoenix616's InventoryGUI lib
can i have link
i've seen someone using like java gui.addButton()... // some stuff (code for slot) -> e.setCancelled(true) // it cancels click event
https://github.com/Phoenix616/InventoryGui idk, googling my phrase would be quicker
is it some api or built in
External API, as stated previously
Though I think given your experience you'll be confused regardless of what way you'll go with; I'm afraid
uh why i can't send screenshots lol
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
or verify
i think its redempt.redlib.inventorygui.InventoryGUI;
from imports
yea it is
got it, it looks quite easy to use
quick question
do i always need to download the plugin of the API i need?
Depends if the API can run without the plugin (which for most things is the case). Just shade the API into your build or put it as a library in the plugin.yml
@worthy star
This method was previously synchronous and now I have made it asynchronous
public static CompletableFuture<String> convertText(String text, Player player) {
String option = HSPM4.selectedOption(player);
if(option.equals(HSPM4.getDefaultOption())) {
return CompletableFuture.completedFuture(text);
}
CompletableFuture<String> translationFuture;
if(option.equals("Modify")) {
translationFuture = asyncTranslate(player, text, "es");
return translationFuture;
}
if(option.equals("Modify2")) {
translationFuture = asyncTranslate(player, text, "en");
return translationFuture;
}
return CompletableFuture.completedFuture(text);
}```
Now I get an error in all the classes in which I implement it, I have tried everything and I don't know how to solve it
```java
String text = Utils.readJsonField(json,"text");
json = json.replace(text, Utils.convertText(text,event.getPlayer()));```
`Cannot resolve method 'replace(String, CompletableFuture<String>)`
How can I fix this?
You can;t just "make it async" like that
yea a String is not the same as CompletableFuture<String>
Okey I understand, so, how i can correctly make it async?
First you need to understand Async
You can not "wait" for a response from something which is Async
So you can't imediately get a response for your replace call.
You need to Async the whole thing
so it runs off thread and processes the result when finished
okay
and
Couldn't I implement thenAccept to replace the text when the translation is ready?
String text = Utils.readJsonField(json, "text");
CompletableFuture<String> translationFuture = Utils.convertText(text, event.getPlayer());
translationFuture.thenAccept(translatedText -> {
json = json.replace(text, translatedText);
});```
is string replace thread safe 
lets hope that only gets called from one place
should be alright, I mean the only thing is that it may not be atomic what he does, and well, if the variable isnβt volatile then rip
5 places
in parallel?
actually not too much of an issue cuz its fully replaced, string is immutable
What I tried to say
But like
var = var.update
That may not be atomic
which can be a bit of an issue
Intellij is saying to me that Variable used in lambda expression should be final or effectively final
And i think that text isn't getting the right value
I just want to serialize a HashMap<String, Set<String>> using gson... i can't find shit online and it just writes nothing to the files. also no error, nothing.
I'm at a point where I would even accept some sort of spoon feeding if it solves that ._.
I think you should be able to use a type token
yeah you might
if its truly just a Map<String,Set<String>>
right, yeah... i tried that but i was too stupid, but i have an idea now
Would this be the correct type?
Type type = new TypeToken<Map<String, Set<String>>>() {}.getType();
I think so yea
How does ur entire code look like
nevermind i'm stupid
It works?
yeah, after i changed changing the FileWriter as a try-with-resources statement instead of creating a filewriter instance in the toJson-call
I'm not exactly certain WHY this made it work bc usually IJ would warn me if this is an issue but welp
whatever
thanks anyway :D
even works without the TypeAdapter lmao what
Which is best to create a Custom Player instance, abstract the class or a new player class with a provided player at the constructor?
That should be βleveragingβ the nested collection support
Yeah that's why I was confused that it didn't work immediately.
But why was the try-with-resources the issue????
Am I not understanding basic java?
Hard to tell w/o the code
You shoudl not be trying to instance Player
emm, I instance a player to get it idk
uhm, why
Just make a data class with the player id
Keep things separate
Sounds like you don;t understand what "Instanced" means
I mean, If i extend the class with custom method, In every events the player is provided I can use that easily
kotlin extension methods π
Do not extend Player. Create your own data holder based upon their UUID
public class MyPlayerData {
private final UUID playerId;
private MyPlayerData(UUID playerId) {
this.playerId = playerId;
}
public static MyPlayerData create(Player player) {
Preconditions.checkArgument(player);
return MyPlayerData.create(player.getUniqueId());
}
public static MyPlayerData create(UUID playerId) {
Preconditions.checkArgument(playerId);
return new MyPlayerData(playerId);
}
public Player getPlayer() {
return Bukkit.getPlayer(this.playerId);
}
}
type deal
What advantages we have with that?
static T x(Player p, β¦) {β¦} :)
API shoudl not be extended and Player is volatile.
It's just simple non-hacky code
Hi, looking for some help on code structure.
I currently have a wrapper for entities that contains data such as stacksize, dropped items, etc. for a mob stacking plugin. I want to make it so that on a creature spawner event, it checks if the spawner entity has a pdc entry, if so, when the spawn event occurs to add the mobs spawned to an existing stacked mob if there is one within a certain range. Wondering if creating a static list in the mob wrapper and adding all of my stacked mobs into that list, then iterating over that on the spawn event to see if there are any stacked mobs within a certain range is the correct way to go about it, or if there is a more efficient way to do this. Thanks
i mean its all just syntax sugar
The static factory methods can be bypassed but they're nice to haves
yea almost
In a perfect world the static factory methods would be package private and you'd have all your data flow through your manager class
I never thought about it this way. I war recently wondering how I could "extend" the player data. This is convenient
is there a way to see if a player leaves a book?
What would be the formula to sync current real life time with the ingame
uh
Need to get the ticks..
1 tick is 20ms. no?
isnt a mc day 20 minutes or smth
1 tick is 50ms
oh 50?
1/20
So the formula is something like
1 irl day = 24 * 60 * 60 * 20 ticks
So then you can come up with a ratio
i day is 86400 secobds
yeah
everyone should know that
public static final int HOURS_IN_DAY = 24;
public static final int MINUTES_IN_DAY = HOURS_IN_DAY * 60;
public static final int SECONDS_IN_DAY = MINUTES_IN_DAY * 60;
public static final int TICKS_IN_DAY = SECONDS_IN_DAY * 20;
We could also come up with some inverse ratios
Or some different measurements that might help us
I mean if there are 24k ticks in an mc day and a real day has 24h, then all you need to do is take the real time and multiply it by a thousand.
is it good practice btw to use public constants instead of getters and setters?
Those are not interchangeable
Which part of the time
Thanks
only for
uhm
shit what are they called
the term for string, int, double, boolean etc etc
primitive types
In a perfect scenario you have a day elapsed %
that you just multiply by TICKS_IN_DAY
Doesnt matter what object.
Constants are always public static final and need to be immutable.
Getters are useful in an inheritance context
what if only static
Cant multiply real time by anything... cant multiply hours.. minutes.. seconds.. nothing. I could divide the current seconds and come up with some ratio for mc ticks but its kinda complicated
okay then i meant to drop the setters. whoops
It really isn't
So short answer is yes, it's good practice?
Let's use some alternative measures
How do you calculate a ratio
1/whatever
β¨ percentage β¨
What even is your goal? Syncing up Minecraft with RT?
public static final int TICKS_IN_HOUR = 1000; // 24000 ticks in a day / 24 hours in a day
public static final int TICKS_IN_MINUTE = TICKS_IN_HOUR / 60; // These are lossy operations. You might want to divide by 60.0
public static final int TICKS_IN_SECOND = TICKS_IN_MINUTE / 60; // This is not TPS
public static int getWorldTicks(int hours, int minutes, int seconds) {
return (hours * TICKS_IN_HOUR) +
(minutes * TICKS_IN_MINUTE) +
(seconds * TICKS_IN_SECOND);
}
sumn like this
Alrightt
Seconds is not going to be accurate as it's below 1
it's ab 16.6 ticks per minute
you might want to use doubles
and just round
Solution which uses as little magic numbers as possible:
public static final long TICKS_IN_MC_DAY = 24000;
public static final long SECONDS_IN_A_DAY = Duration.of(1, ChronoUnit.DAYS).getSeconds();
private long getElapsedSecondsOfCurrentDay() {
LocalTime currentTime = LocalTime.now();
LocalTime midnight = LocalTime.MIDNIGHT;
return ChronoUnit.SECONDS.between(midnight, currentTime);
}
public int getLocalTimeInTicks() {
long elapsedSeconds = getElapsedSecondsOfCurrentDay();
return (int) (elapsedSeconds * (TICKS_IN_MC_DAY / SECONDS_IN_A_DAY));
}

I'm too sleep deprived to use one of the time apis
this sleeping every other day thing is messing me up
Irregular sleeping schedules can lead to depression. Be careful my guy.
I'm aware
I live my work life in phases
Sometimes they're a little extreme
in january I was broke and made like 600 bucks the entire month so I said "fuck it imma start working more than 15-20 hours a week" and now I'm doing 60+
is there any way to let mob spawners spawn hostile mobs during day time?
pair that with me having obsession problems
and the result is me sleeping 30 minutes every other day
or like I did yesterday, sleeping 30 minutes for 3 days in a row and passing out for 14 hours
I dont think thats possible with the API. Looks like you would need nms for it.
any pointers to help me get started?
actually i might just have a runnable that controls spawning
net.minecraft.world.level.block.entity.SpawnerBlockEntity
Does somebody know how redisson locks work on Detail? Or provide a ressource?
All you do is get a lock with a name and then lock it.
Other people wont be able to ack that lock until you relase it.
It follows the java lock specification and works exactly like other locks.
no
gah darn it
particle displays when π
So i can only lock the entirity of redid?
No Single looks?
locks
Nope you can only lock a single lock which has a name as his identifier
So i cannot lock specific objects?
You can lock only locks. If you want to lock an object then you need to make sure it only gets changed by someone that has the lock.
Uh i dont think i can understand locks
Maybe try using a normal lock first in a terminal java application.
Spawn 4 threads which all do something to your object and synchronize it using a lock.
a good rule of thumb I use is just think of multi-server interactions like multi-threading but high latency
I end up using locks and thinking of concurrency issues a lot more often
how can i make colored messages in console?
Try getConsoleSender
use ConsoleCommandSender
Be careful with color in logs. They become hard to read
yesterday I learned that minecraft color codes have stupidly simple colors
&k isn't really translatable and I cant bother looking up the minimsg equivalent so copilot did it
ahh MiniMessage
my beloved <3
I'm converting everything to minimsg and dont want to lose legacy compat
its <obfuscated>
anyone know if EntityEquipment is pass by reference?
that did it
if i do spawnedMob.getEquipment().clear(); will this clear the mob's armour
Yes as it returns EntityEquipment which is backed by the inventory
btw getLocalTimeInTicks() always returns 0
So theres something wrong
XD
why is it always 0
fixed it.
Why does it not clear the "Interact with spawn egg" part when i set the lore?
think i found a solution hold up
for some reason that part comes under HIDE_POTION_EFFECTS item flag
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); fixes it
weird
did they change something in commands for 1.20.4?
whenever i add a command to my code the plugins starts sending errors
show
getCommand("inventory").setExecutor(new InventoryCmd()); here i register the cmd
and
show your plugin.yml
public void openGui(Player p) {
InventoryGUI gui = new InventoryGUI(Bukkit.createInventory(null, 27, Component.text("Inventory.")));
ItemButton diamond = ItemButton.create(new ItemBuilder(Material.DIAMOND)
.setName("Best Diamond"), e -> {
e.setCancelled(true);
});
gui.addButton(1, diamond);
gui.open(p);
}``` and here is the code i use
quick code, im just learning the api
even if i try something else
name: Inventory
version: '${project.version}'
main: me.hothifa.inventory.Inventory
api-version: '1.20'
commands:
inventory:
description: "Lets open some inventories."```
btw you can use the yml format in discord for that, not java
also yeah just send the error
i can't send error
why?
it says error while uploading
?paste
or may it be because i use plugman instead of restarting?
Sometimes it breaks
Yeah plugman fucked it up
at com.rylinaux.plugman.util.BukkitCommandWrap.wrap(BukkitCommandWrap.java:92) ~[PlugManX.jar:?]
ight
Is there any way I can trace an "Internal Exception: java.lang.reflect.InvocationTargetException" from the client? I can't see any trace in either log. And it happens when modifying (creating from scratch) a clientbound packet
What packet are you modifying and how?
(TICKS_IN_MC_DAY / SECONDS_IN_A_DAY) this needs to be a double calculation instead. Pretty sure thats the problem.
hi
hi
nerds
hi
It's "ClientboundContainerSetContentPacket" but it worked before so I have no clue what's wrong now. I am just reading the content of the notnull list and putting it into a new notnull list, basically changing an item for another one if it exists. "new ClientboundContainerSetContentPacket(p.containerId, p.stateId, items, carriedItem)" and I send this instead of the original with the ChannelDuplexHandler write (or read idk right now hahah)
write*
you were right
anyways, if you literally send the same values, does it work?
you mean with new Clientb...(p.containerId, p.stateId, p.items, p.carriedItem)? or without modifying anything
same values not working
will look through the commits but I don't remember changing anything from the handler
so there's something else happening, did you check the client logs?
yep literally this and no more logs displayed
[12:29:02] [Render thread/INFO]: Connecting to 127.0.0.1, 25565
[12:29:04] [Render thread/WARN]: Client disconnected with reason: Internal Exception: java.lang.reflect.InvocationTargetException
World#getNearbyEntities should return all the entities within the range right? for some reason my code is only detecting a zombie within the range when my player is outside of the range, when my player is inside the range it only returns me
Show your code
damn
for (Entity entity : spawnerBlock.getWorld().getNearbyEntities(spawnerBlock.getLocation(), 8, 8, 8))
I don't know tbh
Your spawnerBlock is not where you think it is
This code is inside a class that gets given the spawnerblock when its placed
it should be where i think it is
dw hahah will definetly find it. Is it possible that there are extra packets in the original packet?
gfetNearbyEntities will never fail to return ALL relevant entities, UNLESS a chunk is not loaded or you did it on ChunkLoad, but before Entities are loaded
probably, try log it?
its inside a runnable that is started when the block is placed
spawnerBlock is where it is supposed to be, just checked
nope no extras
okay mb
it was another packet listener
Do you make sure the chunk is loaded while you check?
is it not loaded if im standing inside the chunk?
are your runnables running async?
no
my boy is running EpikSpicottChinaEditionv69420
?nocode
Itβs hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
void startRunnable(){
new BukkitRunnable() {
@Override
public void run() {
if (stopRunning) {this.cancel(); return;}
PersistentDataContainer pdc = spawnerBlock.getPersistentDataContainer();
Bukkit.broadcastMessage("Starting entity check");
YMob mobFound = null;
for (Entity en : spawnerBlock.getWorld().getNearbyEntities(spawnerBlock.getLocation(), 8, 8, 8)) { // Nearby mobs
if (!(en instanceof LivingEntity entity)) continue;
for (YMob mob : YMob.mobs) {
if (!mob.entity.equals(entity)) return; // Mob is stacked
Bukkit.broadcastMessage("Found mob");
int spawnedEntityAmount = pdc.get(Keys.SPAWNER_DATA_KEY, PersistentDataType.TAG_CONTAINER).get(Keys.SPAWNER_DATA_AMOUNT_KEY, PersistentDataType.INTEGER);
mob.addEntityToStack(spawnedEntityAmount);
mobFound = mob;
}
}
if (mobFound == null){
Bukkit.broadcastMessage("Spawning new mob");
Location spawnerLocation = spawnerBlock.getLocation();
Random r = new Random();
LivingEntity spawnedMob = (LivingEntity) spawnerBlock.getWorld().spawnEntity(spawnerLocation.add(r.nextInt(-3, 4), 0, r.nextInt(-3, 4)), spawnerBlock.getSpawnedType());
spawnedMob.getEquipment().clear();
new YMob((LivingEntity) spawnedMob, pdc.get(Keys.SPAWNER_DATA_KEY, PersistentDataType.TAG_CONTAINER)
.get(Keys.SPAWNER_DATA_AMOUNT_KEY, PersistentDataType.INTEGER));
}
}
}.runTaskTimer(Main.INSTANCE, 0, 60);
}
public YSpawner(CreatureSpawner spawner){
this.spawnerBlock = spawner;
spawners.add(this);
startRunnable();
}
this class is initialized on blockplace event
spawnerBlock isn't the issue
it is, if the location isn't accurate
i checked, and it's the right location
Ok, how do you know this is not detecting mobs?
or that it's detecting a Player when they are outside the range?
i broadcasted the "en" value inside the for loop, and it only came up with my player's name
the issue is that it's only detecting my player when both my character and the mob im trying to detect is inside the range, the intended function happens when i leave the range
Your spawned mob will not have a PDC entry btwq so your code will blow up with an NPE on the .get
ah the PDC is on teh spawner?
yes
its a pdc of a container that contains an entity type and how much of the entity to spawn each iteration
I don;t see you excluding players in your for loop
don't really need to do i? if (!mob.entity.equals(entity)) return;
my player is never going to be a YMob
I just tested it out again, placed the spawner and it spawned the mob but wasn't adding to the stack, then i left the range and came back in and now it is adding to the stack
you never add your spawned YMob to YMobs.mobs
it does in the constructor
ok
public YMob(LivingEntity _entity, int startingSize){
this.entity = _entity;
this.stackSize = startingSize;
entity.setAI(false);
entity.setCustomNameVisible(true);
String type = entity.getType().toString();
entity.setCustomName(Main.translate("&b"+stackSize+"x &c"+type.substring(0,1)+type.substring(1).toLowerCase()));
mobs.add(this);
}
is mobs static?
public π°
This line if (!mob.entity.equals(entity)) return; // Mob is stacked needs to be a continue
else as soon as it sees the player, or ANY other entity your loop stops
yea ur right
anything which is not one of your tracked mobs exits the loop
what a mistake
yea thanks for the help mate
np
Also, rather than looping over your YMobs you coudl just do mobFound = YMobs.get(en)
cheers bro
what like <Entity, YMob>?
or with a LIst call indexOf(en) then if no -1 get the index
is -1 when it isnt part of the list?
so java if (YMobs.indexOf(en) > -1) { mobFound = Ymobs.get(Ymobs.indexOf(en))
you could improve that too
a Map would be easier
entity, YMob
or you could ignore me and continue as you are as it's working π
what would be better than even tracking spawned mobs, is adding a PDC to the spawned mob
do you clean up your YMObs on death?
ok
don't really plan to make them long-term for lag and all
@EventHandler(ignoreCancelled = true)
public void onPotionSplash(PotionSplashEvent event) {
System.out.println(23);
if (!(event.getEntity() instanceof Player)) {
return;
}
System.out.println(24);
im getting 23 when dropping splash potions
isnt event.getEntity the entity who threw it?
you should be able to do .getEntity().getShooter()
This works but the sun in-game is at the sunset area already when it's like 13PM in real life.
So I though it's because .. Half a day has already passed so in-game also half a day has passed, but in-game, half a day means "from sunrise to sunset"
I would actually need to tell the game, when the sunrise starts and when the sunset ends, which is far more complicated..
So it's not so simple afterall
Quite a lot of work
I could divide the calculated ticks by 2, which would result in halfing the value and the sun would return to... the sky? But I'm not sure how this would work during the night. Because when the night starts, and ticks are at its max world value... the sun would probably jump at sunrise, actually don't know
Just subtract the offset
I mean you can just subtract 6000 and then floormod
Hmmm
So in scheduler, I update the world time and the sign every 5 seconds.
This is what I have:
long timeInTicks = getWorldTicks(localDateTime.getHour(), localDateTime.getMinute(), localDateTime.getSecond());
Then at the end I just do -6000 ? Where do I floormod?
That? xD
timeInTicks = (timeInTicks - 6000) % 24000;
Math.floorMod
Soooo thatt?
Math.floorMod(timeInTicks, 24000)
what's the first and 2nd value supposed to be
Yeah that looks good
did you subtract the 6000?
yea
one sec
If I use floormod the entire scheduler stops working and can't do anything, can't even Bukkit#broadcastMessage anywhere in the code entire project is bugged right now lol
Works now, but nothing has changed. it's the same as it was,.... There is some weird stuff happening.
So I do floormod and broadcastMessage right after and nothing prints out, and yet the code after gets executed as if nothing happened..
NEVERMIND, was exporting the plugin in wrong directory ...... COME ONNNNN
anyone got an good idea how to prevent afk fishing?
we're testing with mover, checker and some more, but all of them are not very effective =/
surprise them with some chat trivia
if they are afk then they won't be able to answer
oof
after a certain amount of time in one place start replacing all catch with cobblestone
but this does not prevent them from auto moving with some scripts or something =/
i thought the trivia will be an try, maybe
Many players (like myself) totally ignore chat when playing
should be also an option of booth ...
present them with a sign to solve a captcha :^)
oh that would be funny
would it be an option if an player fishs some time, the player will be teleportet to an "afk room" where they need to solve an captcha? if they got the captcha in time, he will get teleported back, if not, he will got send to hub or got kicked
I'd probably just stop them catching anything if they fish in teh same 4-5 block area for x amount of time
what even is the issue what afk fishers
Spawn a TNT at the player that will only be diffused if they move a substantial distance from it, and if they don't, destroy their house with an intercontinental ballistic missile
ideal
would be an option...
Yeah not bad
Also viable
Though I'd stick to a weapon of mass destruction. But that's just me
so, anyone knows an plattform to ask for devs that they can code this? (yea, money inclusive, i know)
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
That generally works; some other methods of vanilla transport (minecarts, water, etc.) could be accounted for too; but given that the fishing rope will snap after some distance no biggie to be had here
Either this or HelpChat
you can ask somebody on bukkit, maybe some bored ass will do it lmfao
The bukkit forums are quite dead, no?
I'd assume
probably
the first one is just straight up a hungergames one
send an request in helpchat, maybe this helps
Hey
If you change the weather in the world, to eg.: rain, will it ACTUALLY rain in the biomes that.. allow rain?
How about snow?
If I change the weather to snow, will it snow in biomes that typically allow the snow weather.. or will it snow everywhere, in all biomes, including unloaded chunks, how does this work?
any biome says what weather should there be, if theres an snowy biome, it snows, if not, it rains
unloaded chunks arent affected
it doesn't rain in biomes such as savannas and deserts
it's determined by the biome temperature from what I remember
i love the part where you can place an empty cauldron in a desert while it's "raining" and the cauldron will still fill up with water
or did they fix that? that was a fun bug
yea, that's what i mean with the biomes says if snow, rain or whatever
a good way to get water in a desert if you couldn't find any
that sounds like the kind of bug that console players would abuse in some 2018 or something lmao
Think about it the storms in minecraft are impressive no matter the weather it always spans all 300,000,000 * 300,000,000 meters of the world
Which means it's super storm or no storm wild weather patterns
Imagine if weather was programmed as a moving noise map
smart :))
hi , i have a bit of problem with json?
so iam trying to have my json file to look like this :
but now in the loadAllLevels , nothing is being loaded / added to cache map ..
here not being sent : any idea why?
am i doing somth wrong?
in LevelManager :
private final Gson gson = new
GsonBuilder().setPrettyPrinting()
.serializeNulls().registerTypeAdapter(LevelWrapper.class, new LevelWrapperAdapter()).create();
the endsWith(".json") will always be true because that's what you entered in the file constructor
yeah that entire if check can be removed
ok removed.
and getName only gives you the file name, not the whole path, so that's gonna be false for the second check as well
the whole if looked.....
removed the check
iffy
added few checks it seems that LevelReader is null somehow xD
i mean LevelWrapper
I think your file access is incorrect, no?
plugindatafolder//Level.json?
new File(plugin.getDataFolder(), "Level.json") would be the correct way to do it rather than concatenating and hoping it separates correctly
alright let me try ..
ig you could try printing what the jsonElement is inside the deserialize method to see what gson truly read
Btw it's a good idea to use File.separator instead of / to ensure that it works on all systems
"yes"
Emily enters the chat
Why I can't get Block???
I m using spigot with mojang deobfuscated maps vesrion 1.18.2
i k what's wrong , it was a type in the deserlizer xd
because not a lot is under the net.minecraft.server package anymore
You're also probably looking for Blocks not Block
The actual class is net.minecraft.world.level.block.Blocks iirc
When i do this:
rocketShip.centerBlock.addPassenger(player);
It teleports the player but it does not "seat" the player correctly. Is there a reason on why this could be happening?
Thank you, I didn't know it
So, I have a strange problem: when I try to use player.chat("string"); I get either an error saying
AsyncNativeChatEvent may only be triggered asynchronously. (in the case I run it in a normal bukkit runnable)
AsyncPlayerChatEvent may only be triggered synchronously. (in the case I run it in an asynchronous bukkit runnable)
anyone got a solution?
What is AsyncNativeChatEvent
Not Spigot
ruff
Sounds like you've got a bug in whatever software you're running
?paste your full error/stacktrace
kk ty
Show, I came up with this
try {
Field field = net.minecraft.world.level.block.Blocks.class.getDeclaredField("strength");
field.setAccessible(true);
// Check if the field is of type float
if (field.getType() == float.class) {
field.setFloat(Blocks.DIAMOND_ORE, 50.0F);
} else {
System.out.println("Field is not of type float");
}
} catch (NoSuchFieldException e) {
System.out.println("Field not found: " + e.getMessage());
} catch (IllegalAccessException e) {
System.out.println("Illegal access: " + e.getMessage());
}
and I get
Field not found: strength
I think this happens beacuse it s private, any ideas???
It's not called strength during runtime
Is it possible to define an api-version of 1.20 in the plugin.yml, but make the plugin still support lower versions?
Spigot now automatically disables the plugin if the server version is <1.20
what would the point of that be
thats not a normal thing
I guess I just don't understand what the "api-version" is for
thats a setting in bukkit or spigot .yml
What do you mean?
that isnt an offical thing
spigot did not add that
that is just a setting for end users
If you want to support lower versions then set it to the lower version api
the minimum being 1.13
guys i tried splitting my interfaces up so i dont have one big one of which i dont even use all methods, is there a clean way of designing my code intented to accept many interfaces? I dont really like the idea of object instanceof myInterface every time i check for one method or something.
depends on what the context is
like what method and were is it used
It's hard to say without more information
generally though avoiding instanceof checks is a good idea
i have one object that accepts "dataloaders", some like sql require to have entries in a table and some dataloader do not, when loading data i'd need to check if its a sql loader to acces the createEntry Method
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous usernames, global display names, and server...
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
sounds like you're not abstracting enough
maybe, maybe not depends on what the other data loaders are
but I assume that they also have some save method
yes
then:
save:
SQLDataLoader.save() -> createEntry
NonSQLDataLoader.save() -> do something else
dont do it async
i guess i can i do it like iam just scared that im gonna forget
Forget what?
forget adding the entry code
cuz there is no method asking me for it
but i guess im gonna remember now
doesn't compile
i will do it this way now but how does interface segregation work when using it without spamming instanceof?
interface Storage { void save(); }
class SqlStorage implements Storage { public void save() { ... sql save logic } }
class MongoStorage implements Storage { public void save() { ... mongo save logic } }
^^
i know im gonna use it like this
no need to instanceof
but hwo does it work in cases where a 2nd method is needed
what second method?
if you add a method to the interface and not into a class, it should fail to compile iirc
idk for example addentry
what epic said
you just add the method to the interface and implement it in the implementations
interface -> load, addentry <- dead when using mongodb only for sql
if i really wanted to split it up and really do need it in some other case how would that work? instanceof spam?
ideally you should have all the same methods
they just might end up doing different things internally
okay but in cases where its not possible?
why would different storage types have different exposed methods?
it's abstract
load user, save user, load item info, etc
bro guys im talking about a case where its needed
the implementation takes care of the details
a theoretical case
that case should not be needed
that's why you'd design it like that, in a good way
so, in the case that your code is bad, then yeah
interface storage
class sql implements storage { storage methods, non storage/interface methdods }
ik
armorStand.setRotation(stand.getLocation().getYaw(), stand.getLocation().getPitch());```
i have 2 armorstands, armorStand and stand, im crating a new armorstand with the same rotation as stand thats called armorStand, but the rotation isn't the same as stand when i use the code above, its off by quite a lot and idk why this is happening
i debug by sending the yaw of both stands
```[17:50:33 INFO]: x: -65.24243
[17:50:33 INFO]: y: 294.75757```
and they arnt similar at all.. so this doesnt make any sense
Is location the location of the first armorstand as well?
location is the location of the 1st armorstand but 10 is added to the x and z
A Location already has pitch and jaw. So if you simply clone the first armorstands location and add 10 to x and z, then the spawned armostand should have the same rotation as well.
im using
```for (Offset offset : offsetArmorStandHashMap.keySet()) {
ArmorStand stand = offsetArmorStandHashMap.get(offset);
Location newLocation = location.clone();
newLocation.add(offset.x, offset.y, offset.z);
ArmorStand armorStand = (ArmorStand) location.getWorld().spawnEntity(newLocation, EntityType.ARMOR_STAND);
armorStand.setRotation(stand.getLocation().getYaw(), stand.getLocation().getPitch());
Bukkit.broadcastMessage("x: " + armorStand.getLocation().getYaw());
Bukkit.broadcastMessage("y: " + stand.getLocation().getYaw());
}```
to spawn armorstands around a central location with offset in relation to the center (i kinda tried to generalize it when i explained the original problem above so it would be easier to understand) but i want to clone stand to a different location, so i need to get the yaw/pitch still for the new armorstand
if i clone the location and dont modify the yaw/pitch, the armorstands have no rotation
Do you want to spawn ArmorStands in a circle with all of them looking into the center?
no i have a list of armorstand with an offset attatched to each of them, then the player can select a center location and the armorstand will spawn in relation to the center so they keep their distance from each other if that makes sense
location is the central location that the player defines
Try this:
Location original = armorStand.getLocation();
for (Offset offset : offsetArmorStandHashMap.keySet()) {
ArmorStand stand = offsetArmorStandHashMap.get(offset);
Location newLocation = location.clone();
newLocation.setDirection(original.getDirection());
ArmorStand armorStand = (ArmorStand) location.getWorld().spawnEntity(newLocation, EntityType.ARMOR_STAND);
Bukkit.broadcastMessage("x: " + armorStand.getLocation().getYaw());
Bukkit.broadcastMessage("y: " + stand.getLocation().getYaw());
}
uhh how would i get armorStand.getLocation() before its initialized
i assume original is cupose to be the center?
Im honestly a bit confused by the structure.
Why do you need key:value access with the offset being the key.
But yeah.
for (Offset offset : offsetArmorStandHashMap.keySet()) {
ArmorStand stand = offsetArmorStandHashMap.get(offset);
Location newLocation = stand.getLocation().add(offset.x, offset.y, offset.z);
ArmorStand armorStand = (ArmorStand) location.getWorld().spawnEntity(newLocation, EntityType.ARMOR_STAND);
Bukkit.broadcastMessage("x: " + armorStand.getLocation().getYaw());
Bukkit.broadcastMessage("y: " + stand.getLocation().getYaw());
}
