#help-development
1 messages · Page 450 of 1
Try making config yamlconfiguration instead
Alright so that should move it to the root dir in the jar
If refreshing doesnt work
Not quite
nah i have to make all the code of loading stuff
ive tried it before
what if i build with gradle?
(Im in vscode, btw)
Shouldn’t make a difference
Are you sure npe is for config?
[21:29:01 ERROR]: Error occurred while enabling Core v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
at volt.dev.vcore.Core.onEnable(Core.java:27) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[Spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [Spigot.jar:git-Spigot-21fe707-741a1bd]
is the config
I guess I'll install the plugin you sent on a server to see it in action. Could you elaborate what checks you are talking about?
I'd have expected that I can simply do
"Description of the field"
<player input>
or for lists:
"Description of the list"
<player input>
<player input>
<player input>
and I'd just collect all inputs of all pages and seperate by linebreaks.
Unless I take it one step further and put all fields in one book (one field per page, unless it's a list)
I'm pretty sure this means that you don't have your command in the plugin.yml
bc just passing a null value in the constructor shouldn't do much
IM GONNA KILL MYSELF
xd
The npe is in godcommand class
Config instance gets passed to it so no not necessarily
it isnt
yesterday i was getting the same error of npe on other plugin
there, appeared 3 times, in main, then class
i
I mean, the constructor can take null values, and if it shouldn't, it also will say that in the constructor/error
gg
Server tutorial doesnt work on latest. Havent updated it. Think last version it worked was 1.13
that's alright, I can downgrade
With book you would need to implement a bunch of checks. Like if they closed it early, put invalid inputs. Conversation api you can validate and if invalid data is there go back and say so. Also you can specify a keyword to end the conversation early and just toss the data away
Also with conversation api you can add explanations etc
As you go through the settings
Which you decide is ultimately up to you of course. I just think using a book is not the best for this
Does the conversation api utilize that clickable text in chat? I don't remember how it's called.
idk i never used vscode, just better than IntelliJ idea
You can use chat components with it if i recall
Of course. I'll give both a look and test what feels better for me and maybe ask a friend or 2
Chat components would be cool for going back and forward
Anyone know why im getting this error trying to build my build tools 1.19.3?
never seen that before
Me either, i was able to build fine on my macbook earlier
do you have weird maven environment variables defined from a previous install?
Not that im aware of
type set into a command prompt and share the results
this?
powershell maybe try Get-ChildItem Env:
hmm no idea
Just use git bash
I have always encountered problems with cmd
Let me try it in bash, iirc i got the same error the other day but didnt have a chance to look back at it as i had to leave for work.
Same error
buildtools is doing that automatically
Where would i do that at?
Try clearing buildtools directory
But issue seems to be with maven since it doesnt get to the actual building phase.
Generally nuking everything but the buildtools jar is my first step
Second step is panic
Lol
your java is kind of old (2021) maybe try updating it?
That's very rude. Maybe you're old >:(
lol, whats the default path for buildtools? I cant find it
MD and Java can both be old
It's where you downloaded it, D:/Downloads
that would make sense lol
Alright, give me a minute my downloads is still on a HDD so it takes forever
Alright, so iv deleted all the files i think are build tools in my downloads directory, but im still getting the same error.
https://i.imgur.com/ugLLZRy.png iv deleted these 5, these are the ones re generated
Try moving buildtools jar to its own directory
Next step would be to install maven and there is plenty of guides in how to do that
Anyways. Got work to do. Be back in like an hour or so
Bot moment, but i installed the latest java now i get this error: https://i.imgur.com/kIjiHCI.png
restart your pc
I just restarted it after removing all the old version and just installing the newest, i setup my Java_Home so that should be fine, but java --version still says can not be found
Just straight form the exe
How do I turn a Field object from clazz.getDeclaredField into a map? It's been a hot minute since I last looked at this
Exe from where
field.get(instance)
.get(
field.get(null) if static
instance of the object I am getting the field from right?
Yea
and I can just cast the output?
Yea
got it thanks
Cheers
Should i use netty to transfer some data?
(Between servers)
ngl the brain logic mojang has makes me want to eat glass
Most probably not
In what way?
To setup ur own sockets between servers?
For a public plugin or for a closed project?
project
Anyway im gonna predict this and say u need a message queue, use sth like redis or rabbitmq
I want to send a message to the server before connecting the player to it (something about like in what party it will appear)
there are other alternatives but those are the most common ones around here
Then i would suggest using Redis. More specifically topics.
As java framework Redisson. You can literally send data and receive data in 3 or 4 lines
For that you dont need messages in theory.
You can just write this data in a DB (blocking)
and read it when the player connects. Redis might
be still the better way.
Yeah well if he just needs a couple of bytes sent sth minimal like Jedis is fine
Since redisson is a bit bigger
Okay thanks 👍
Good luck
it's called the brain class because it's going to give me a brain aneurysm in about 5 minutes
@ivory sleet have you injected a channel handler (netty) in spigot before?
Im currently a bit lost. I got a duplex handler for outgoing packets working
but i cant seem to get incoming packets to work...
how there are no uncancelable behaviors in the brain system is beyond me
Yeah I have done it in the past
it's like i'm popping crazy pills
Lol magma
I think he’s having fun
I have been on this for over a week
I can't even write proper debug messages anymore
get acquainted with my shorts because you're about to huff them
Ah i just noticed the decouple method makes no sense. I need to remove my channel names ofc
But when testing both duplex handler only listen to outgoing packets...
Get the pipeline and invoke addBefore that’s how its supposed to be done
so yeah the only way to guarantee no overriding behaviors seems to be through lobotomizing the AI for as long as you don't want to get overriden
Thats what i thought... are there two connections for incoming and outgoing?
Wait im adding both after the default encoder
And both the incoming and outgoing encoder name is just "packet_handler" if i interpreted that right
yeah
the base name should be just that
Yea maybe try to use addBefore instead, also aren’t you having the same if statement twice?
Or am I just seeing things
One is for encoder name and the other for decoder.
In the case of bukkit, its the same
Ah I see
I just don't understand what mojang is thinking here
Hm and that makes both handlers be inserted after the default "packet_handler"
How is this even supposed to differentiate between incoming and outgoing packets?
they have a brain system, why is the brain not managing activities
why do they have ai classes for individual mob types but still hold key parts of the AI logic in entity classes
how come brains are simultaneously stupidly in-depth intricate systems but also don't actually manage important aspects of behavior
and I think u can use the same duplex handler for incoming and outgoing
how come entities go back to idle from combat after every single hit and idle manages part but not all of the combat pathfinding
did the guy that came up with the module system for brains get paid by the class he wrote?
no
after every single hit they do they enter a cooldown state
for the duration they are in idle
even if they keep following you around
because following is idle
So when they hit you they revert to idle
attack seems to be strictly the tick they hit you on except it also has some pathfinding logic somehow and also it's a per-entity implementation because obviously no two mobs in minecraft hit you quite the same way
states are for losers and priorities are for nerds, the brains use both and neither work in way that makes sense
all the priorities seem to be the same and the states will flip in ways that are hardcoded to each entity
I see why they haven’t updated the old entities
let me bring up the wisdom of the ancients if I can find it
It’s important to remember that when you start from scratch there is absolutely no reason to believe that you are going to do a better job than you did the first time.
Joel on software april 6th 2000 on the demise of netscape navigator
@lost matrix packet_handler might listen to both?
whilst encode encodes, decoder decodes (names)
I think
Yeah already on that track
So it may also terminate?
Hmm, yea idk much more but it wouldn’t be out of scope to think that it stops delegation
also this (maybe?)
(:
Yeah i found the problem. I appended my handlers after
[timeout, splitter, decompress, decoder, protocol_lib_inbound_interceptor, prepender, compress, encoder, protocol_lib_wire_packet_encoder, pe-encoder-grimac, packet_handler, DefaultChannelPipeline$TailContext#0]
the packet_handler which does not forward incoming packets. So at least the inbound listener needs to be
injected before the packet_handler
Oh look it’s protocollib and grimac
🥲
Protocollib twice for good measure
Yeah ive used one duplex handler now and it works like a charm.
https://gist.github.com/Flo0/5aa8849af8c50dfa365042d4fe52160c
Just had to prepend it to the packet_handler and implement both write and read
for my duplex handler. 👍
Very nice :>
that is hilarious, mojang has a method that just throws a CME if you use it
it can't ever actually work
what the hell
no wonder set aggressive does nothing
it's hardcoded to be set to aggressive on every tick
I would like to build a plug-in that uses nms and special source with maven
Sorry not maven
Already doing that just fine
With Jenkins
You need jenkins to run BuildTools
My initials thought was to have a job that runs build tools with —remapped
Okay yea so I did that
Works great
So that the remapped sources are in your local maven repo
But my plugin won’t build
Lemme send the error
[INFO] --- specialsource:1.2.4:remap (remap-obf) @ mcplanes ---
org.apache.maven.artifact.resolver.ArtifactNotFoundException: The following artifacts could not be resolved: org.spigotmc:minecraft-server:txt:maps-mojang:1.19-R0.1-SNAPSHOT (absent): org.spigotmc:minecraft-server:txt:maps-mojang:1.19-R0.1-SNAPSHOT was not found in https://repo.dmulloy2.net/repository/public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of dmulloy2-repo has elapsed or updates are forced
Make sure that --rev is used for exactly the version you define in your pom.xml
This looks like an old version to me
That might be it
org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT should be for the latest
Ah
So first of all I wasn’t using rev for build tools
So it was probably building 1.19.3
But also yes my Pom was just wrong
Since you put the version in the special source part twice
I changed it in one part but not in the other
Alright I’ll let you know if it builds
Create a property in your pom and insert it using {}
Thats what i do when using special sources
In the parent pom
<properties>
<java.version>17</java.version>
<spigot.version>1.19.4-R0.1-SNAPSHOT</spigot.version>
<velocity.version>3.1.1</velocity.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Then i use ${spigot.version} for the version everywhere
so fun fact if you clear behaviors on minecraft AI even using mojang methods it just throws a NPC
guess I'm trying a brain transplant instead
Oooh that makes sense
It built 👍
nice
I should pay more attention to IJ makros...
1.19.3-R2 NPC resources (request)
4 times, actually
you could, but why would you want to do that
Sure... You can use jni in every java application.
But you will break every other server with that for obvious reasons.
Imagine actually wanting to write cpp
sorry but I cannot imagine that
I would have to be drunk to be able to imagine it
at least when it comes to spigot plugins
Yeah i converted to Rust for my low-level projects. Cpp is a dumpster fire in comparison.
heh
i have a problem because in onCommand methods thinks that there are 2 arguments and its correct but onTabComplete method thinks its 3 arguments cause ther is double space between arg1 and arg2, why is that and how to fix it ?
isnt that still 2 args 🤔
just print args.length
its 2 args, even when the first arg is empty
as soonm as you press space it adds an empty arg
so space after the command, tab complete will show 1 arg but that arg will be empty
each arg fills as you type
does anyone know how this singleAmmo.setAmount(1) could cause an AssertionError: TRAP?
you are removing an item in the interact event
?
you are in teh shoot bow event
no?
its the only place a getConsumable() exisdts
oh
thats not an interact event
wait, i cant modify a clone of the consumable within the event?
why?
you should be able to, but thats what your TRAP error is saying
its an assertion failure
weird
ProjectileListener.java:90
yeah thats the setamount part
I'm going to guess yoru stack only had 1 in it?
i dont think that really matters since im setting it to 1 anyway
this error also doesnt occur consistently
Is there Material for light block? I can't find it in 1.17.1 or 1.19.3
isnt it just called LIGHT
declaration: package: org.bukkit, enum: Material
what version of spigot are you using in pom.xml
it also exists in 1,17 https://helpch.at/docs/1.17.1/org/bukkit/Material.html#LIGHT
declaration: package: org.bukkit, enum: Material
1.19.3
revalidate dependencies?
1 sec
does your TRAP error happen when using Spigot?
Invalidated Caches and it still doesn't find it.
Dependencies should not override anything
Did you import the correct material class?
Pretty sure. Used Material.valueOf("LIGHT") gave the material in the server, but it isn't showing in the ide
paper in this case
i mean i guess there was a chance for the consumable to be null by the time it gets to line 90 but that would cause a different exception
Does the astrolminiapi include org.bukkit
is there a way to change a players name / prefix above their head without the use of the scoreboard and preferably without the use of sending packages?
Only provided so it doesn't compile it
and it is 1.17.1 bukkit in it so it should show anyways
Checked info of Material and it says it uses 1.13 jar for Material. I switched to Spigot-API and it still uses 1.13 material.
Removed dependencies which are compiled in astrolminiapi and it still doesn't show.
edit: Doesn't show any netherite items too
Packets are necessary
But like, scoreboard can do it for u
W/O having to manually push packets
add this after the astrol mini pi```xml
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>Bukkit</artifactId>
</exclusion>
</exclusions>
Worked ty
Hey! Tell me why BukkitRunnable is not canceled? Did as it says here: https://www.spigotmc.org/threads/how-can-i-cancel-stop-the-bukkit-runnable.473424/
If you need a code, I will attach it (just don't write about early returns, etc.)
?paste the code
Ru the OP there?
Code:
Main:
public static BukkitTask prepare = null;
public static BukkitTask start = null;
EventManager:
https://paste.md-5.net/agocaweseb.cs
?
the cancel doesnt stop the current task iirc
That too
You should really try to split up all that logic, quite hard to read and maintain
Hmm.. how to stop the task?
?scheduling goes over it iirc
cancel it and return
Both inside and outside
Thank you both!
As epic said, cancel() will only deny future runs from being called
I will definitely get acquainted with it.
You’d have to use the return keyword to terminate the execution within run()
That’s good (:
Got it
maybe i'm being rly stupid but I'm trying to setup a basic plugin that makes a locked item in the hotbar run the command /menu from the player. Ive got it all working but the command. Currently when a player right clicks it just says in chat "menu". This is what i'm using for the perform command:
player.performCommand("menu");
anyone got any idea?
try /menu
okay then the command is invalid
it opens a menu
does the console say anything?
Hm, I'm using DeluxeMenu for the menu, do I need to link it directly?
nothing in console at all.
/menu isnt a registered command
Oh I see
use player.chat("/menu") instead
Alright ill try that out thank you
in the inventory iirc
but its kinda buggy
oh wait
im dumb
ignore what I said
idk about durability, I was talking about stack sizes
I was googling that and I did not find anything useful, so mby thats not even possible,
Thank you so much, it worked! 🙂
hi, is there an event for a block changing like being broken, placed, or changed like a redstone dust being powered?
an event for any changes that happen to a block?
kk ty
Block Break event
that only covers a player breaking it and probably nothing else though?
generally speaking, if i develop plugins designed for personal use only, is it poor practice to incorporate native code? ive written for myself a sophisticated iniparser lib in c++ and exported it to a multitude of languages incl java(couple of months ago the project v 1.0 finished)
nvm.
na that’s fine
Its not like native code is a bad practice
Its just that its often not needed
You can do this.
ItemStack itemname = new ItemStack(Material.ITEMNAME);
// Get the item meta and modify the max durability
ItemMeta meta = itemname.getItemMeta();
meta.setUnbreakable(true); // Make the item unbreakable```
itemname.setItemMeta(meta);
imajin go to bed
I dont want to make item unbreakable. I want to increase durability of item
You can't do that
Though you can simulate the effects by modifying the item damage event
You can always use setDurability()
lol
I know about this, but I want change MAX durability. This one
isnt there an attribute for that
Again you can't
Ehm well that’s not really possible
sorry miss you message. Sad thanks
You’d need client mods for that
just make a durability pdc tag
However you can make an item lose durability half of the times its supposed to lose durability, that way the item seems twice as durable
Or go with the op imajin strategy
(And then scale with actual durability)
Ye, the pdc tag sounds like solution. But still will need (not rly) to edit damge of item to show durability for player.
I can make item unbreakable and then just remove from inventory if pdc tag od durability is 0
Unbreakable removes the durability bar
Or you make the durability of the item the same percentage based of ur pdc durability
That way the scale remains untouched
not rly need durability bar probably. I was think about ezy way how to doit xD
Alr your choice :)
that was what Im thinking about
You got the idea now, just need to implement it accordingly
Yup
Don’t use longs I’d say btw
You can take advantage of the Instant class
it will because you will be able to write a cooldown system much easier
thanks guys for help. I was looking for nbt tag or just something I can change. I know damage can be changed but thats not enough.
Wait... there is not ntb tag for max dur?
Yeah I’m suggesting a robust and easy design by switching out an implementation detail
Map<String,Instant> map = …;
//set cooldown
String string, Duration cooldown
map.put(string, Instant.now().plus(cooldown))
//has cooldown
String string
var cooldown = map.get(string)
//null check
return Instant.now().isBefore(cooldown)
//remove cooldown
String string
return map.get(string)
//get cooldown
String string
var cooldown = map.get(string)
//null check
if has cooldown
return Duration.between(Instant.now(),cooldown)
else
return Duration.ZERO
you’d have sth like this
you should go update https://www.spigotmc.org/wiki/feature-command-cooldowns/ conclure
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
True
Its the same as System.currentTimeMillis()
but its more useful
Because it abstracts over just a long
Or well if you want to, you could go ahead and update it, you’re quite a capable dev afaik (:
i could
That’s one issue for sure :>
We didn’t even need to help you, you’re a capable problem solver (:
Send the entire class
thats what we call rubber ducking
But presumably you’ll have to create a variable somewhere to store some data, including the map


Hmm, that should only keep one map instance, no?
where private final
using a plain map instead of creating a cooldown object 🥲
Mind sending entire class?
Instant 😍
I think they might be reinserting the cooldown every time possibly.
you dont want to know how many students in my class dont know what access modifiers are
either that or they make everything public
you should send the entire class
when doing cooldowns, it's way easier to create one cooldown class, instead of throwing the logic into the actual listeners / commands - then you can reuse it everytime.
jd: https://hub.jeff-media.com/javadocs/jefflib/com/jeff_media/jefflib/data/Cooldown.html
class: https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/data/Cooldown.java
well you arent showing any code either
Looks good apart from that the ConcurrentHashMap is a tightly coupled implementation (:
Its needed to be able to remove elements while iterating 😦
use guava cache with expire after write
big brain
Is that done inside the class or is one of your dependencies doing that?
discord getting even more pay to win
I think i dont even need it anymore, so could switch to a normal map
ugh no syntax highlighting
Well mfnalex I thought you could maybe just have a public constructor that takes the map
The hasCooldown method removes the element when there is no cooldown anymore iirc
import java.time.Duration;
import java.time.Instant;
import java.util.Map;
import java.util.HashMap;
import java.util.UUID;
public class CooldownMap {
private final Map<UUID, Instant> map = new HashMap<>();
// Set cooldown
public void setCooldown(UUID key, Duration duration) {
map.put(key, Instant.now().plus(duration));
}
// Check if cooldown has expired
public boolean hasCooldown(UUID key) {
Instant cooldown = map.get(key);
return cooldown != null && Instant.now().isBefore(cooldown);
}
// Remove cooldown
public Instant removeCooldown(UUID key) {
return map.remove(key);
}
// Get remaining cooldown time
public Duration getRemainingCooldown(UUID key) {
Instant cooldown = map.get(key);
if (cooldown != null && Instant.now().isBefore(cooldown)) {
return Duration.between(Instant.now(), cooldown);
} else {
return Duration.ZERO;
}
}
}
``` i made chatgpt do it for me because i didnt wanna open an ide
Not sure though, i dont remember how it works, only on the phone rn
and insert some early returns there
And then for the other constructors that takes just the long supplier and time unit, maybe have some static factory methods for those instead? Being quite nitpicky, take this with a pinch of salt
looks awful
The class is good (:
Thx, yeah i just made it to avoid writing cooldown logic over and over again
Its not perfect lol
Haha all good
i still have the time stamp cooldown thing
i should update that
ill do it after editing the cooldowns wiki page
should i add it as another method or as main method
ill do another method
could cache Instant.now()
🥲
text editor
yeah but that means i can probably fuck it p
Real coders can code remotely by manually switching bits on the ssd with telekinesis
real coders write assembly
wait
shouldnt be talking about all the traumas i already got
what's the issue you're having?
Mfw fourteen is breathing assembly
nah i had the genius idea to start writing this in class
what all happens when im bored 🥺
Next month you be writing 4d gpu accelerated ai in quantum physics with assembly
“Just bored”
Real coders set the bits by hand by opening the ssd up 
Real coders wait for cosmic rays to flip the bits for them
Lol
Real coders have extreme social anxiety and hence are afraid to use discord
I must be the most fake coder to exist on this planet
its just your dog whos coding for you
Such a cute puppy
@EventHandler
private void onEvent(PrepareInventoryResultEvent event) {
ItemStack item = event.getResult();
if(item == null) {
Logger.log("null");
return;
}
ItemMeta meta = item.getItemMeta();
String name = meta.getDisplayName();
if(name.length() < 1) {
Logger.log("male");
return;
}
Logger.log(name);
Logger.log(TextFormatter.color(name));
meta.setDisplayName(TextFormatter.color(name));
item.setItemMeta(meta);
}```
why this code works on my local server but on my survival server does not?
color deosn't change but on my lcoal does
edit: this code just implements color does into anvil.
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Is there a dedicated discord for Bungeecord support or can I ask here?
Here
Is there any resource on how to preverse comments when using Configurations in Bungee plugins (on save)?
Whenever I set a new value and save the config, all my comments disappear
The problem is that your if statement here does not check if the sender is on a cooldown.
if (cooldown.get(sender.getName()) > System.currentTimeMillis())
To check if a sender is on cooldown, check if the result of sender-cooldown - now is > 0
final long now = System.currentTimeMillis();
final long remaining = cooldowns.getOrDefault(sender, now) - now;
if (remaining > 0) {
// sender on cooldown
return;
}
// Do code stuff
cooldowns.put(sender, now + 10_000); // put sender on a 10 second cooldown
Use getOrDefault instead of get to avoid an NPE when unboxing the boxed primitive from the map
Also, you should prefer early returning instead of nesting your if statements.

Hello I need to make a constant sound around one specific location. If I do playSound in a loop it would play millions instances of that sound. I want it to play only one instance of sound in a specific area, but this sound should be infinite. Is it possible?
You could use SnakeYaml, recent versions should be able to preserve comments
Just add a delay?
Add some debug stuff so you see whether the event gets called. Are you using the latest build of spigot on both servers?
no
That could be an option, yes.
Is there not any other option to preserve comments?
Using SnakeYAML returns a HashMap if I remember correctly and I’d prefer using a Configuration instead if possible
i added debug
.
Yes, SnakeYaml is a plain map. Bungees config classes are quite „simple“, and dont have all the features that Bukkit configs have
Yes it will work too but at first I need to find out the exact time this sound plays, also I should store the delay, and if I have a lot of places of this sound effect I would store the delay for everything... Is there the ultimate way of doing this?
Then show the output of /version of both servers
I will add the delay if there is no other way...
Do you know if I’m somehow able to cast the Map to a Configuration?
I'd look it up myself but I’m currently not at home, sorry ^^”
global: 3669-Spigot-454acb7-f150cfb (MC: 1.19.3)
local: git-Paper-448 (MC: 1.19.3)
you can just loop over the keys
public static MemoryConfiguration map2Config(Map<String,Object> map) {
MemoryConfiguration config = new MemoryConfiguration();
map.forEach(config::set);
return config;
}
tbh I don't really understand what you're trying to do
well you're using paper on your local server
I'm creating an invisible trap that can be noticed only because of the sound it makes. This sound can be for example creeper hiss and it should always play at the location of my trap
spigot generally doesn't let you use color codes in the console, for good reasons
color does not belong into console, with two exceptions:
warnings may be yellow
errors may be red
everything else is supposed to have the default color
well but you cannot know how long this sound takes. spigot can only tell the client "play sound XYZ" - that sound could be 2 seconds long, or 27 minutes - depending on the resource pack, etc.
You will HAVE to add a delay yourself
what you can however do is to stop the existing, already playing sound for players
Player#stopSound or sth
anyway, you will need a loop with a delay
Okay, thanks!
np
declaration: package: org.bukkit, interface: World
also, what does your color() method even do? you didnt include it in the code you sent, ig
for playing a sound at a specific location
yeah that's not the problem, they want to play the sound "continuosly"
or however that's written
they can do that but the issue is they are going to have to measure the time length of the sound as that isn't provided
and then once they know how long the sound is, they can just make a repeating task with that as a delay
for my JukeboxPlus plugin, I just have a config file where people can enter the amount of seconds that their songs take, in case they use custom songs
that is a user issue really that can't be controlled or factored in
well you can force players to use the server resource pack, and if that includes all the sounds they need, I think one would be fine
yeah if the server has a specific resource pack to be used lol
I think resource packs should be renamed to TurtlePack™
Why percent is 0?
short durability = data.get(new NamespacedKey(RoleJob.getPlugin(), "durability"), PersistentDataType.SHORT);
short maxDurability = data.get(new NamespacedKey(RoleJob.getPlugin(), "maxDurability"), PersistentDataType.SHORT);
short dmg = (short) e.getDamage();
int newDurability = durability-dmg;
data.set(new NamespacedKey(RoleJob.getPlugin(), "durability"), PersistentDataType.SHORT, (short) newDurability);
double percent = (int) newDurability/ (int)maxDurability;
p.sendMessage("percent: " + percent);
durability = 93 and maxDurability = 100
you are doing integer division
Because 93/100 is 0.93 and as an int, its 0
ye, but the precent is double
^ then ciel it and cast to int
so all number needs to be double?
that doesnt matter
it casts the whole expression
to double
if the max is 100, then division isn't needed here
which is an int at that point
max is 100 just for testing
double result = (double) first/ (double) second
also, to get the real percentage do double percent = ((double)newDurability / (double)maxDurability) * 100
i always love when intellij sees there are no uses, yet highlights the variable as if there were some
totally convenient
It gets worse with every update
the fact that it isn't fixed
in all places
yeah?
just like how its worded
Im okay with decimal number just making easy to see if is all corrcet
I also hate that it cannot find references in decompiled classes
otherwise it would have to decompile all your dependencies
No, i mean in the same file
oh
intellij is good but sometimes i wanna throw hands
Yeah maybe i should take a look at eclipse or nb again
I hear all these complaints with intellij and here I am with like no issues using netbeans XD
For example netbeans has an awesome gui debugger that is lacking completely in IJ
When I did school work with Swing I used NB for gui and IJ for the rest
having an uncontrollable desire to code in sublime text
So the solution is cast number witch are in calculation to double. Okey thanks.
soon NB will take over as the prominent IDE 😉
and eclipse is nervously standing there
or just make it a double to begin with
eclipse is also not bad, but their quickfixes are a joke sometimes
and the maven integration is shit
😛
haven't tried eclipse + gradle but tbh I dont hate myself, hence I don't use gradle voluntarily
hate* myself, not mate
ugh
"i don't mate myself" ok ok
Im not sure what do you mean
nothing you have in the code specifically needs to be a short or int
you could just make all them numbers doubles
and then no need or worry about casting
double maxDurability = data.get(new NamespacedKey(RoleJob.getPlugin(), "maxDurability"), PersistentDataType.SHORT);
I just made this
I'd much rather order a double shot than a single one
does that even work?
it would return a Short
you cannot just cast it
yep it does work
huh
yeah ik but I didnt knew it worked for other primitive types
this is mby best soultion 😄 its double that what I need for percentage calculation
oh hell ye
that's what eclipse imagines when it wants you to cast ItemStack to Player so you can use getDisplayName()
thats what people in my class do
ahah
and after clicking on "Add cast":
oh man goofy eclipse
Looks good to me
also looks good to javac
💀
however I don#t get it, eclipse should be able to see that ItemStack does not implement Player
I could understand it if ItemStack would be an interface - but it isnt
it's a regular class
Eclipse is just 1000 parallel universes ahead of you
It’s living in 3023 where ItemStack does implement Player
hm I wish it'd stick to the spigot version I declared in my pom though lol
I own at least 4 toilet seats
5 if one also counts the "stand-up toilet" as toilet seat lol
although that makes little sense
as one doesn't sit while standing up
so nvm
lol
You have a dedicated stand up toilet?
yes, in the bar in the basement
aight🙏 hehe yea its just that ive already written the library and it works good. since i write in a couple of languages including c, c++, c#, java etc and require an IniParser in almost all of them for config files ive once put alot of effort to write one lib that can be used by every language with the respective interfaces
don't tell me this compiles
ddamn chrome starts to break after leaving pc on for two days
prev time it crashed, it took down my whole system
Firefox >
whats the dmesg variant of windows again?
Yeah 10_000 is the same as 10000
So I am trying to make this inventory, the inventory works perfectly except for the items, im trying to use the setItem method to add my custom itemstack to it although it doesnt seem to be working,
My ItemStacks: https://pastebin.com/wPLdwwzc
My Inv creation: https://pastebin.com/KkFKr70P
Some code relating to adding the item in my onEnable Method: https://pastebin.com/J1kKULW2
Hi, is there any way to reference an item in an inventory for future changes or is it the case that once you set an item to an inventory you can't modify it anymore meaning you would need to find it in the inventory and replace it with a new ItemStack?
And is there any way to monitor interactions with bundles through spigot?
I assume it fires regular click events
yeah good call thx
What's your code look like now?
you're missing a return in the if statement.
in the block*
if (remaining > 0) {
ProxyServer.getInstance().getLogger().info("Sixth condition!");
String message = Everywhere.getColors(config.getString("AntiSpam.message"));
message = Everywhere.Replace(message, "{cooldown}", String.valueOf(intCooldown));
event.setCancelled(true);
sender.sendMessage(message);
// missing a return here
}
you are constantly refreshing the player's cooldown whenever they type the command without that return statement
if that's your problem, that return should fix it.
final long remaining = cooldown.getOrDefault(sender, now) - now; is returning the default
now
the one you provide
?paste yoru full class
sender is not a string
final long remaining = cooldown.getOrDefault(sender, now) - now;nneeds to be final long remaining = cooldown.getOrDefault(sender.getName(), now) - now;
try again with those changes
your if test is also invalid
once they have a cooldown if (remaining > 0) { is ALWAYS going to be true
you need if (remaining - now > 0) {
no
thats fine, but your if is wrong
you are adding in the map now + cooldown
soi it's always going to be a value greater than 0
?paste your current class
oh I see
you are subtracting it already
I didn;t see that
line 22 needs a return
yes
you could return or use else
it depends
if you can't early return, yes
?arrowcode, this should explain early returns of you have much nested ifs
OK that doesn't exist
Commas are the enemy
Alright ,
how do you kow?
you are accessing the config before calling saveDefaultConfig() in you ronEnable
ah
no clue if comments are retained on bungee
You should ask it
but not about bukkit.
Ask it anyway
is anyone here familiar with mongodb?
...
?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!
um, i was reading the mongodb manual for indexes.
and i am a bit confused on how to use it for sort orders.
?nohello
oh nvm this is basically nohello in a nutshell
embeds 😭
cafebabe you dumb bitch chat isn't infinitely high
so, if i have an index on (fieldA: -1, fieldB: -1, fieldC: -1), does doing a sort on (fieldB: -1) not use the index to get the sort order?
You can prevent the embed https://nohello.net/en/
yeah
Although the embed does help
oh I didn't notice xD true
please dont bury my question.
?cba
Pluggg#0001 definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.
although i wonder if anyone knows the answer.
maybe too niche of a question for this chat.
I'm sadly not too familiar with noSQL dbs
This works once without using a runTaskTimer. the generateChunkSquare method is a loop that looks at different chunks to generate them. When I put the runTaskTimer back, it doesn't work at all, and just freezes the server. It only runs one loop and gets stuck at generateChunkSquare. Any ideas?
I've used Mongo. Just don't understand the question
^
basically, lets say i do db.collection.createIndex(fieldA: 1, fieldB: 1, fieldC: 1, fieldD: 1); and try doing sort operation, db.collection.find({ <some predicate> }).sort(fieldC: 1); here, does the query use the index to retrieve the sort order?
does the runTaskTimer put this on a different thread?
no
No it's still on the main thread
there might be a logger to print to the console that might be more appropriate.
your job has to end. You can;t perform HUGE tasks and take up all server resources
running a timer means you are running it repeatedly
the task is generating chunks with a slow custom generator and it takes about 12 seconds
Yes I need to run it repeatedly
very slow
Is there a way I could make this happen? The goal with the runTaskTimer was so that 1 tick would pass for every time generateChunkSquare was called
?workdistro
yes
means he's a good contributor 🙂
He's who you go to when everyone gets stuck
haha, especially acf
He helped me with my other custom world gen issues because I couldnt find anyone that knew how to do what I was trying to do
How can I get the amount of a specific item in a players inventory.. for example, I want to check how many stone blocks with the lore "xd" and with certain tag and name or whatever like the specific itemstack and get the amount total (for example, if there are 2 full stacks, 128)
get the contents of the inventory, filter to only find items with your type and sum their amounts
i don't think there's a spigot built in methd
There is not
Not many can criticise 7smile7. I give him advice now and then but generally he's ahead of me.
Sadge
hmm yea I was gonna do that but I was looking for something faster
whatever
that shouldn't be slow imho
I mean
I have a method for it already
like
If ya want it
a one line or smthin
send it i'm curious
ill make my own
public static int getTotalAmount(Inventory inventory, ItemStack target) {
int amount = 0;
for (ItemStack item : inventory) {
if (item == null) {
continue;
}
if (item.isSimilar(target)) {
amount += item.getAmount();
}
}
return amount;
}
Muh cpu cycles
add air check to that null check
Compiler plugin to transform streams when?
Why tho
player.setVelocity(player.getEyeLocation().getDirection().normalize()
How i can made this slower
multiply by 0.5?
to not call isSimilar on an air item
.multiply <1
save that extra tiny bit of cpu
afer normalize?
yeah
wait a min, im trying to understand java better, if u use continue; it just breaks the loop and keeps going right?
or stops the loop
should be air
it goes to the next iterable item
ok
in the loop
alr
^
break breaks out of the loop
that makes more sense
This is the way
true
yeah
Hi im making a wanderer that spawns every week at monday, how can i run a task that every monday spawns the wanderer.
I have a check already for the spawn i just need to make the task run, without lagging the server
i usually exit my programs my tracking my cpu with my bare eyes, and when i see that everything is done, i slamdunk on my CPU so that it 100% stops the execution without any memory leaks
Just check for the current day in a task that runs at a required interval.
It won't lag the server
but the interval is?
If you just want it on monday checking every minute should be enough. If you need more precision you can also go for every second. Depends on your usecase.
Even every tick wouldn't lag the server but it still sounds unreasonable
perhaps a minute is better for precision yeah
If you wanna take it one step further you can do an async task for the time checking and then run a sync task on monday. But it's really not required for something as simple as that
||don't do this||
run a task every 1ms, check the System.currentTimeMillis(), if it's divisible by a number that symbolises a monday, execute
ScheduledExecutorService. Calculate time until Monday at server start and schedule the task.
Could do that
But what if the real world time chang- wait
can you do an example of how to use it?
it can be looked up with 3 words
"ScheduledExecutorService usage example"
Is there a decent book gui lib? I noticed that a lot of stuff is clientside and workarounding this is tedious
thanks
You can't even forceopen a writable_book...
yeah i think that's only available in like 1.8 lmao
Is it?
i did look it up a long time ago
that's just what i recall
it was moved from server side to client side later or smth
take this with a grain of salt
Big thanks to mojang for not giving us a decent text editor for larger texts in java.
is it writable
No it requires a WRITTEN_BOOK
yeah
which can not be changed
Why anvil?
I need them to type (possibly) infinitly long lists
ah shit
ok and how i can made it to not going higher? i mean the Y
Make them build the text in pixel art with blocks
TRUE
elaborate plz
You don’t want them to move up at all?
.setY(0)
yea
wait so ehm
^
You can’t chain that though
good, thanks
can I make an itemstack with like 100 items in it?
Yes
k
i think you can make as many items as you want, but at SOME point they will get clamped to [-128, 127]
not sure when exactly
im using for compressing blocks for a mining server
so like I make an itemstack and add items to it through then at end give player all the items
i recall having a bug where my item amount would get to -127 or -128 idr
so i just deduced that they get clamped to this interval at some point
simple question about this how can i test it if it works?
sysout the period you are scheduling for
you can use that to calculate when it will happen
@eternal oxide this workload distribution you sent feels quite a bit advanced for me. I'm trying to piece it together but I'm still a little confused
read it a few times. it's a good thing to get to grips with. Yes it is advanced
So I get the concept of the linear processing I think. It fills up the remaining time in the tick with what you want to do, but doesnt delay the tick.
So what if I wanted to generate a chunk, which I think would take 150ms with the generator Im using
No one's on the server when Im generating this btw
could you split up the generation? Are you actually creatign a proper chunk generator or a block populator?
Im using a plugin that is a generator. I am pretty sure its a real chunk generator
why is it so slow?
dont know
But it looks cool
Would the workload distribution 100% fix the issue of why the server freezes when this bit of code is in a runTaskTimer task?
try adding a longer delay between tasks. Give the server some time to catch up
when its in a tasktimer, it doesnt finish the generateChunkSquare method. It's fine when its not inside a task
If your task takes 150ms to run you should give at least 3 ticks between tasks
It never gets to that point
if each chunk is 150ms then it needs 3 ticks between each chunk gen
so I need to break up the loops into an individual task per chunk?
can I have a task inside a task?
you'd do better pushing your tasks to a queue
Any suggestions for an API to use for player heads? Thats not Headdatabase, or is it worth just buying it?
which is what the workdistro is really for
only process one chunk/task per 4 ticks
public static void startScheduler() {
Calendar with = Calendar.getInstance();
Map<Integer, Integer> dayToDelay = new HashMap<Integer, Integer>();
dayToDelay.put(Calendar.FRIDAY, 0); //2
dayToDelay.put(Calendar.SATURDAY, 0); //1
dayToDelay.put(Calendar.SUNDAY, 0);
dayToDelay.put(Calendar.MONDAY, 0); //6
dayToDelay.put(Calendar.TUESDAY, 0); //5
dayToDelay.put(Calendar.WEDNESDAY, 0); //4
dayToDelay.put(Calendar.THURSDAY, 0); //3
int dayOfWeek = with.get(Calendar.DAY_OF_WEEK);
int hour = with.get(Calendar.HOUR_OF_DAY);
int delayInDays = dayToDelay.get(dayOfWeek);
System.out.println("RUN");
int delayInHours = 0;
if(delayInDays == 6){
delayInHours = hour;
}else{
delayInHours = delayInDays*24+(24-hour);
}
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(new CheckUpdate(), delayInHours,
1, TimeUnit.MINUTES);
}
i tried starting it and the println works just fine but i really don't understand why it doesn't start the check
right. This is gonna take me forever to figure out. why did I have to pick something so complicated for my plugin lol. I think Im starting to realize why Ive never seen a server do this
🙂
can i made this particle to stay at where whey got spawned?
event.getPlayer().spawnParticle(Particle.CLOUD, event.getPlayer().getLocation(), 1, 0.1, 0.1, 0.1);
Do you mean it moves, or are you wantign it permanently in place?
Do I even need to have it in a task? If there isn't a task, I could just do it all in one tick. The server would be on one tick for tens of minutes if I wanted to generate a lot (maybe even hours). As long as the world is saving, wouldn't it be fine?
No the watchdog will think the server has crashed
||is it supported on 1.12.2?||
the generator plugin I use suppresses watchdog
For most particles
then you could just hammer it all out, I guess
yes it works, thanks.
Last time I tried doing a lot, it crashed after like 90*81 chunks and the memory was going up consistently. If I save it the world, will it clear that cache?
you could unload the chunks after generating/dsaving
also they are despawnin too fast, can i change that too?
particles have a fixed animation speed
and i can't change them?
no
ok then
hello i have a quick question for you guys how do i make a bow be able to damage endermen i have been testing a few stuff but cant figure it out this is my code so far
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR) {
ItemStack item = p.getInventory().getItemInMainHand();
if (item.getType() == Material.BOW && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(ChatColor.GOLD + "Terminator")) {
if (cooldownMap.containsKey(p)) {
long lastShotTime = cooldownMap.get(p);
if (System.currentTimeMillis() - lastShotTime < cooldownTime) {
plugin.getLogger().log(java.util.logging.Level.INFO, "Terminator cooldown " + p);
e.setCancelled(true);
return;
}
}
p.setItemInHand(item);
p.launchProjectile(Arrow.class);
cooldownMap.put(p, System.currentTimeMillis());
}
}
}```
im not sure if this run, but in theory should
Calendar with = Calendar.getInstance();
Map<Integer, Integer> dayToDelay = new HashMap<Integer, Integer>();
dayToDelay.put(Calendar.FRIDAY, 2);
dayToDelay.put(Calendar.SATURDAY, 1);
dayToDelay.put(Calendar.SUNDAY, 0);
dayToDelay.put(Calendar.MONDAY, 6);
dayToDelay.put(Calendar.TUESDAY, 5);
dayToDelay.put(Calendar.WEDNESDAY, 4);
dayToDelay.put(Calendar.THURSDAY, 3);
int dayOfWeek = with.get(DAY_OF_WEEK);
int delayInDays = dayToDelay.get(dayOfWeek);
System.out.println("Started Event");
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
service.scheduleAtFixedRate(() -> {
try {
checkUpdate();
} catch (ParseException e) {
throw new RuntimeException(e);
}
}, delayInDays, 7, TimeUnit.DAYS);
I wanted to ask you only for be sure
Any suggestions for API to get custom heads?
Can’t you just use spigot stuff
i would recommend this one
https://github.com/Arcaniax-Development/HeadDatabase-API
I think you can for player heads, but im not sure about custom ones
Ofc it does
Or r u looking for a texture index api like that one^
I guess like that, is it worth buying?
Use PlayerProfiles
Ok, ill try it again. I thought last time it wouldnt load bc i didnt have the plugin
There is probably a free variant on the market just as good, and ftr the api does not work without the plugin iirc
If you are on modern spigot there is an API for custom heads
By modern I mean like
1.17? 1.18?
yeah im using 1.19.3
You got the PlayerProfile API then
I think he is looking for an api that indexes textures based of searches also?
Ah
https://blog.jeff-media.com/creating-custom-heads-in-spigot-1-18-1/ ill just drop this here anyway just in case
Not entirely sure still what they really need 😅
Im looking to use this head, https://minecraft-heads.com/custom-heads/humans/28230-poseidon
I generally prefer using a UUID made from the string
But yeah jeffs tutorial will work
also can someone help me with this
Ok thank you
You must be pacient, if you want to your dont get lost. You should create a thread and wait until someone answer it
Because all people here are volunteers none getting paid for instant help
i know im not trying to be rude i was just asking
Hmm
oh my bad
Idk if cancelling the EntityTeleportEvent would be enough
wont that like cancel all the endermans teleports?
The reason why i reuse the same UUID is because creating a new PlayerProfile will result in a new file getting created
Ah
And i didnt want to have thousands of useless files
At least it did when i wrote that blog post. Maybe its different now, idk
@eternal oxide the memory goes up slowly even when I save the world. This will crash my server eventually. How do I prevent this? Im generating chunks btw
what's gc?
Garbage collection
but look at the slope of the lowest point. That's the issue
Yeah i see. Did it crash anytime, though?
Wait until/whether it actually crashes
Hm do you know where its coming from?
They are doing a bunch of worldgen stuff
Yes only one thing is happening. Im generating chunks. This gets called in different areas
Are you returning a new instance of your chunk generator instead of reusing the existing instance?
No. It's all in one tick. Not sure if that matters.
That's promising:
It's on area 41/100. Last time it crashed at 89
Getting chucks is an intensive operation
Are you trying to load worlds?
It's all in one world
In case of loading worlds you have to use a work distribuitor**
I probably should for this too, but if it works the way it is, I don't want to figure that out
Work distribuitors are used to fix the chunks generating lag, so then your server dont freeze or make tps going really down
Im fine with the tps being 0. It's pregenerating areas and no one would be on when this happens