#help-development
1 messages · Page 609 of 1
25565 most likely isnt open with it then
see if anything shows up with sudo ufw status
I wonder if linux devs say sudo-code instead of pseudo-code
i did this
sudo ufw allow 25565
and now it says
v
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
25565 ALLOW IN Anywhere
25565 (v6) ALLOW IN Anywhere (v6)
sudo ufw reload
enjoy the port scanners btw
block known spam ASs
whitelist wont stop port scanners
ok so? they cant connect
ur console would get flooded
They still can query info about your server + add lag since packets are processed by the server
weirdos bruh how do i make it so they cant
fail2ban
whats fail2ban
how do i delete a world in linux
rmdir or rm doesnt work
got it 👍
no
we say super-user-do-code
acronyms are bloat to the dictionary
do you still say faq
faqu then
faq is bloat
hey, does anyone know how to make a player use a held item?
like even when the item is unusable?
PlayerInteractEvent and then check for right click
Hello, with custom npc how to execute a command to the player who clicks on it?
i mean, i want to simulate the right click, not check if it happened
otherwise it isnt an autofishing
exists a guide for this?
if i remember you need configure a regex for that not?
idk, havent had a reason to set it up yet lol
https://github.com/asifbacchus/fail2banUFW here is preconfigured for ufw
XD i remember a old case for a user spamming connection and pretty sure a plugin listening the joinevent make the server very slow (maybe was that.. many time since this)
nice i take a look.
you can't simulate a right click afaik
thouhg I suppose you could send a packet not sure how the client would respond to that though
maybe with nms?
probably only somethnig that can be done with packets if at all
There is a swing arm method.
You can fire your own interact event and there is a method to execute a command by the player. If thats what they mean.
oh probably what they mean
They can be used in a singular sense
Used to refer to the one previously mentioned or implied or Used to refer to the ones previously mentioned or implied
can the CompletableFuture be reused?
wdym by re-use
Hello, with custom npc how to execute a command to the player who clicks on it?
are you a developer?
Nope
maybe in #help-server specify the plugin? custom npc is pretty vague
its custom npc for jobs reborn
ask in their discord they probably have one
No
there's no need to ever "reuse" one anyways
they are single operations
nice image
I need to get a message from the proxy server before the command completes, can you recommend something?
I send the player's name to the proxy server and it returns the uuid to me, but it turns out that the uuid is returned after the command
And I need to use it in the command
?paste
show me the code
seems like you have flawed design
I wanna see what you're doing it
you can;t use it in the command, but you can send some trigger data in the request so when you get a response you can run the command you want
your response should contain whatever data you need to run the command
I'm thinking maybe they aren't using CompletableFuture's thenAccept correctly
nope, they are using messaging channels
oh Ic
why are you using future#get
you're halting the main thread
use thenAccept or whenComplete
I told him to use futures earlier before I saw he was using messagign channels, but he seems to have not understood about running off thread
I just tried it, there were private strings before
also more confusingly he only has one future per the entire command class
but they were always null because
running Future#get is a death sentence for the main thread if you're running a heavy operation you're freezing the entire server for however long it takes the operation to complete
everything has to run when the future is complete, nothing should run before bc it will be null
I'm a noob in multithreading)
what you shoudl be doing is sending the PMC requests, then listening for a response and doing whatever you need to do there. Let your command exit without taking any other action after sending the request
а что собственно ты пишешь?
Dw so are many others, but yeah you should learn about callbacks and why they are so useful when you play with concurrency
я имею ввиду о чем плагин
party between servers
I need to record in the database what the join request was so that the player can join later
thats fine
so i need to have uuid somehow
you do it when you get a reponse, OFF thread
you don't wait for a response
all your onCommand code should do is make sure the player is allowed to use the command and send your PMC request. Your onCommand should then exit. It's done its job.
ok, but how to collect it further?
in the response
your response should contain all the data you need to execute whatever code you want to run.
I finally figured out how to do it, thanks
most basic thing that i can do because math is not my best, im making a sort of economy and im adding buy what you can, and i need a way to sell to a player the max he can so if an item cost 100 and he has 500 in automatic the player will get 5 items and so in this way
english = cringe
int max = Math.round(UserManager.getTokens(player.getUniqueId()) / config.getLong(path + "cost")); so in this way?
non gendered languages go brrrrrrrrrrr
Does anyone know if BiomeProvider is supposed to be extended? Otherwise how do I control the biome generation using a worldcreator? I want to make a whole world one biome
Yeah you can extend it
Has anyone ever worked with lettuce (redis)? I need to set my charset to ASCII (I guess) but I can't find how.
For more context: It returns "\u003d" instead of "=" and It completely brokes NPC skins
I don;t use redis but unless you misconfigured somewhere it shoudl default to utf8, which is what you need
I don't see why you would intentionally want your charset to be ASCII
it is returning \\u003d or \u003d
I dont have any extra configuration regards to this thing, also there is no way (I can see) to change it.
yep, thats unicode, utf8
technically its also ASCII
I know they are same but the player skins are not loaded for some reason and I can't figure out why
?paste some code then
Oh I'm blind, sorry for the trouble. I forgot to wait some time before sending playerinforemove packet 🤦
Hello! I ran into some problems with trying to make an object of a class outside the package and when i try to use setters it doesnt work. Can somebody tell if has an interest to help thanks!
?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!
?notworking too
"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.
This is my explosion blockbreakevent class where i tried to initialize the TokensCommand class
?paste
And this is the TokensCommand class
And when i break blocks everything works except that it doesnt add anything to my tokens field
@fluid river ^ someone here needs a few lessons
i havent finished my oop lessons yet
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
not the pyramind of doom
Is anyone here familiar with maven? I never really liked using it or gradle either because it is always introducing problems before even writing any code but more and more libraries are requiring it so I kind of have no option
Error: ```
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project CustomBlockDataExample: Fatal error compiling
My pom.xml : <https://paste.md-5.net/akopoyegex.xml> i'm using spigot 1.16.5 hope that's not a problem
Intellij idea doesn't give any red errors in the pom.xml, even tried invalidate caches and restart
dm me
your maven-shade-plugin is horribly outdated
update it to 3.5.0
also what's all of this?
@tender shard what gpu do you have
remove the finalName, sourceDirectory, targetPath, and ${basedir} from the <directory>
rtx 2080 super on desktop, m2 max 30 cores on the macbook
What do you think about the RTX 4070? Should I get it?
idk
also what's the full error? you only posted one line, please show the complete maven output
It's literally 700€, this is 2 years of saving for me
it is one line though
here's the logs where it was downloading everything https://paste.md-5.net/bilunivota.cs
also I wish this is possible...
now try to compile
the CustomBlockData-Example repo compiles just fine btw
mvn package
I'm using this option, shouldn't it be the same?
yep, double click that
Is this or could it be malicious code? It's from a plugin that was sold to me.
https://paste.md-5.net/qosimohido.java
yes
one sec, I did invalidate caches and restart intellij (so the 3.5.0 red goes away)
how better to do operations with the database, asynchronously? And how to combine it with the main thread of bukkit?
you don't have to do that, just run mvn package and maven will download version 3.5.0
by the way, the finalName, sourceDirectory, targetPath, and ${basedir} were from the example repo you managed to clone and compile
there (double clicked the package)
wait nvm, let me try something okay nvm I accidentally forgot to change shadedPattern in pom but it still errors
click the uppermost entry in the list on the left, then you can copy/paste the full log
click this, then copy/paste the full log
Run "mvn clean package -X" then send the log again pls
it's not letting me upload it 😭 can I send as txt file?
You set the java version to 16.0.1
When I write "p.sendMessage()" it gets a strikethrough and hovering over it reads "Obsolete API is used." Can anyone tell me what the issue is or what I should use instead?
You are using paper API
yes
I didn't set it
is it in pom?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>``` (sorry for terrible indentation)
Thats the issue.
Uhhh
In your properties
Paper deprecates all the string thing
this? ```xml
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
What should I use instead?
change the {java.version} to just 16
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
spigot-api
groupid org.spigotmc
artifactid spigot-api
version 1.20.1-R0.1-SNAPSHOT
Thank you
well this was awkward but it worked, thanks ❤️
may I ask why what was with the finalName, sourceDirectory and targetPath?
also I'm not sure why but some weird file is put into my jar https://www.decompiler.com/jar/9fd54de090154fe0bd2499f6af983d64/CustomBlockDataExample.jar/dev/ribica/customblockdataexampleplugin/.java
Are there something like minecraft plugin development courses where i can learn more?
Well those were all the default values, its not needed to specify them. Your issue was that you used the old maven shade version which didnt support java 16, and then didnt run „clean“ after updating it - you also didnt specify java.version in your properties, so it used the java version environment variable, which was 16.0.1, which is not a valid option for maven.compiler.target and source
eh, didn't think maven would be so tricky in intellij
you can either use {java.version} and then declare that in your properties:
<properties>
<java.version>16</java.version>
or just directly use "16" or whatever in the maven-compiler-plugin configuraiton
Hard-coding it should be fine I assume
in the CustomBlockData-Example pom, I used ${java.version} but I also declared it in the properties:
yeah but you can also delete the <configuration> section as you already set it in properties through maven.compiler.target and source, so one of those is redundant - you can either remove the compiler <configuration> section, or remove the stuff from the <properties>
doesn't really matter which one you use
btw if you wanna change the output directory or final name, you should do that in the maven-jar-plugin's <configuration> and not directly inside <build>: https://blog.jeff-media.com/how-to-make-maven-automatically-put-your-plugins-jar-into-your-test-servers-plugins-folder/
Does anyone know if there's a way to get the highest block at a point excluding certain materials (in this case, barrier blocks)?
Do I need to just manually search
How to type || on uk keyboard
I have to google the symbol and copy it everytime I want to use it
yes. I'd just write a tiny method that takes a Predicate<Material> or sth so you can reuse it later
/**
* Returns the highest block at the given x/z coordinates, ignoring the given materials
*/
public static Block getHighestBlockAt(World world, int x, int z, Predicate<Material> ignoredMaterials) {
for(int y = world.getHighestBlockYAt(x, z); y >= world.getMinHeight(); y--) {
Block block = world.getBlockAt(x, y, z);
if(!ignoredMaterials.test(block.getType())) {
return block;
}
}
return null;
}
Ok, thank you!
that's 2 pipe symbols. the pipe symbol is right to the left shift key, probably you need to press Ctrl+Alt plus that key
or maybe shift + that key, idk
~
what the heck is this
its a gun
¬
~
when i press this
show a picture of your keyboard
my keyboard is us layout
but I like uk layout more
on windows
only diffrence is dolllar sign
you're gonna have a bad time if you use a different layout in windows than your keyboard is made for
that is the only problem
its literally shift + the key between shift and Z
US keyboards don't have a key between Z and shift
at least not the one shown on wikipedia
uk do 🙂
yeah but they got a US keyboard
yes
oh I saw him ask how to do it on uk keyboard
my windows layout is uk
yeah that also confused me. They set it to UK in windows but it's actually a US one lol
just add a US one too. you can switch in windows taskbar
should I then just stick to using plugin <configuration> instead of the properties maven.compiler.target ?
do it however you like. it's literally the same
unrelated but wasn't it alt+shift?
using the <configuration> is probably more straightforward
pretty sure they depricated it in properties
it's definitely Win+SPace for me, I just tried it
best to do it in plugin configuration
I remember it stopped workign at some point when just in properties
it's also still mentioned in the compile mojo docs
what do you wanna do?
spigot got API for per player header and footer, and the names can be changed with the display name
can we please return to this?
the last problem I'm facing is that plugin.yml isn't getting added into the jar
do I have to add something in pom?
I looked at this guide https://www.spigotmc.org/wiki/creating-a-plugin-with-maven-using-intellij-idea/#creating-plugin-yml and I created it in the exact same way
show a screenshot of your directory structure in IntelliJ pls
where is the plugin.yml
looks good. show pom.xml again pls
remove the whole includes part
If I give you the plugin, could you see if it is malware?
- you don't need a <includes> set, you wanna include everything from the resources folder
- if you wanna use an includes set, then you gotta specify the full path, or use the ant style:
Either <include>src/main/resources/plugin.yml
or
<include>**/plugin.yml
TL;DR: just do it like this
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
also note that there's no starting / in the directory
it's a relative path
why have you added a purpur jar manually
removed the includes, ran 'package', new jar still doesn't have plugin.yml (when I view it with 7zip) okay nevermind the forwardslash
no. why don't you ask the dude who sold it to you what that is?
anyway it's highly suspicous and I'd demand my money back lol
because purpur officially doesn't support "older versions" and I'm thinking they removed it from their maven repo (atleast mvn couldn't fetch it, saying it was not found) but I doubt i'll need it)
the way you didnt it wont work anyway
you added paperclip jar, not an actual purpur server jar
I want to make sure before doing it since in a few hours I have an event that I cannot cancel 😬
dang, it worked this was weird though
once again sorry for being terribly lost in this stuff
what do you mean?
np! I also found maven very confusing at first, especially since most tutorials do very bad stuff in their pom.xmls
paper (and its forks) distribute something call paperclip jars, they dont include any code thats on any repo, just instructions for the end server to download the patches and apply a binary patch
maven can pull it
send me the jar
may I ask what is it that makes maven make two jars (they are identical checksums)
shaded includes Libraries and Dependencies into the jar
If you do not have any Dependencies, it is the same
Extending character limit on a scoreboard with teams.
It doesnt have any purpose tbh
Isn'r it there to include deps?
The shade plugin copies the -shaded .jar to the normal ind
the normal jar also includes it
Huh? Last time I used maven it did not
bruh... I used this https://github.com/PurpurMC/Purpur/tree/ver/1.16.5#dependency-information
And had a second jar including everything
The YourPlugin-1.0.jar and YourPlugin-1.0-shaded.jar are the same. The original-YourPlugin-1.0.jar is the unshaded one
yeah, they changed maven info
Ohh sorry for the missinformation then
What is shading for again?
<dependency>
<groupId>org.purpurmc.purpur</groupId>
<artifactId>purpur-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<repository>
<id>purpurmc-snapshots</id>
<name>PurpurMC Repository</name>
<url>https://repo.purpurmc.org/snapshots</url>
</repository>
I think the reason is that you can specify a different identifier for the shaded one but it defaults to replacing the normal one
Including dependencies in your plugin. I.E copying required classes from other libraries.
Include libraries and stuff
Ah right
aren't deps (dependencies) things like spigot jar? it shouldn't get into the compiled jar though
Maven shade is like gradle‘s shadow
Well then im kind of correct?
Some shouldn't, some should
Spigot is a runtime dependency - your plugin expects it to already be there
CustomBlockData is a compile dependency - you gotta ship it yoursef
this is exactly what happened last time (copied both repository and dependency)
Run package
reload maven
is that why one puts <scope>provided</scope> in there?
otherwise you shade it
Yes
Yes. Spigot is already running (you dont have to include it), so you set it to „provided“
Its explained here (second headline) @silver robin https://blog.jeff-media.com/common-maven-questions/
okay I copied this before you edited and added the scope provided thing and now it included the whole purpur jar into my plugin but thanks
add the scope provided i missed
i forgot that reposilite doesnt care about stuff like that
and then clean build
I opened a ton of tabs already just from discussions here :/
now all I can hope that my pom won't break sometime in the future
Thanks again every one of you 😃
if it breaks, just ask here again lol
i was hesitant at first to use spigot discord server for such things but again if I were to ask general java people I thought they'd get as confused as me
anyone knows if this is normal? 60% on votifier? running 1.16.5 arclight
is there any reason you arent using nuvotifier
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
not for you guys
why not
no, its a server i joined as a dev, having some issues
made a profile and found that
im honestly not sure if thats just the normal ussage of votifier
but i dont think so?
feels like too much
idk how bad it was, check source code of both and check if nuvotifier adds something to counter it
I'm creating a custom UI using inventoryframework
and for some reason the library places some custom nbt data on items that i place in
making it non-stackable
how can I delete this nbt tag?
public class NBTIManager {
public static ItemStack cleanItemOfGuiTag(ItemStack item) {
try {
NBTItem nbtItem = new NBTItem(item);
nbtItem.removeKey("PublicBukkitValues");
return nbtItem.getItem();
} catch (Exception e) {
return item;
}
}
}
is what i use
i already asked the dev
hmm okay
wow that looks like not a good idea
that removes all pdc, be careful with that one
i thought there would be a better way
By the way, you're the author of CustomBlockData , right? Could I ask a question related to it in DMs?
just wipe all plugin's custom info on items = bad time
i call for a ban with that status message
hes right, be carefull
yes I am, and yes
is that a pdc though?
yes, its all the PDC
because if so can't i just use the pdc api
yes, you don't need anything extra
just create a namespaced key that matches the key in the nbt you have, so new NamespacedKey("classmmo", "if-uuid");
(NamespacedKey.fromString("classmmo:if-uuid"))
better use NamespacedKey.fromString
why is that better?
because the constructor is deprecated and tells you to NEVER use it, with 2(!!) exclamation marks
oh yeah, forgot spigot still has that deprecated for whatever reason
don't really understand why
TWO?
better stay the hell away from it
yeah lol
fromString is nullable which is annoying. so new is better for this imo (assuming it wasn't deprecated), cause that's even more annoying from a static analyzer perspective
well is the plugin name classmmo? if they created a custom key
is "classmmo" your plugin?
yes
byte array
byte array
im just looking at a profiler of my dev server and i feel like this probably isnt good
i just managed to crash it trying to profile my plugin
thats great
I mean that's just how memory works in Java
How can I read in Spigot 1.8.8 what color a wool is if I only have the ItemStack?
Wool MaterialData existed back then
but please, for the love of God, write against modern API
ah thx
I want to make a command that'll open up an Anvil GUI that has custom recipes
Right now I'm doing this with InventoryFramework but it's really scuffed because you're not meant to be placing items into the GUI
is there any alternative i can do
Hey, I have been struggling with an issue for a while and found no help or useful information online regarding the issue.
Whenever I try to make a copy of a sqlite file from the resource path to the plugins datafolder it gets corrupted(Only sqlite files no other file formats, it corrupts the encoding), no matter what copy method I try no matter what encoding I set it to it always gets corrupted.
Now for the funny part. It only happens when loading it as a plugin, the code works fine without issues no corruption when just running it as java code. It also does not matter if I create the file on plugin startup or any other time during the servers lifetime. it always gets corrupted. Did anyone run into similar issues before?
how are you copying it?
Currently using the nio Files.copy function, but I also tried manual binary copying and other methods I could find. Did not change anything, always worked on normal java and failed as a plugin
nm, when packaging (maven) you need to turn filtering off to package compressed files.
maybe the file's already broken inside your .jar
is it corrupted when you extract it with winrar etc?
it is, he filtered
oh my god... you are a lifesaver, I tested everything under the sun but did not even think about filtering
Anyone know why when this is only despawning the entity for one player online?
public void despawnHologram(Player player, Hologram hologram) throws InvocationTargetException {
List<Integer> holoIDs = hologram.getHoloIDs();
for (Integer holoID : holoIDs) {
PacketContainer metadata = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
metadata.getModifier().write(0, new IntArrayList(new int[]{holoID}));
ProtocolLibrary.getProtocolManager().sendServerPacket(player, metadata);
}
}
I'm sending the packet to all players, but it only actually deletes the hologram for one player
image illustration
can i create custom smithing table recipes
How can I enchant my wool for example in 1.8?
Enchant it with unbreakable 1
Hide enchants with hideflags
And how do I enchant?
ItemMeta
ah ok thx
I think ItemStack still allows doing enchantment operations
Let me ensure
Yeah, ItemStack itself can do it 👍🏻
No need to access the ItemMeta
But you’ll need the ItemMeta for the hideflags
Hello, I've got this error when reloading maven : org.spigotmc:spigot-api:jar:1.20.1-R0.1-20230709.090828-26 failed to transfer from https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigot-repo has elapsed or updates are forced. Original error: Could not transfer artifact org.spigotmc:spigot-api:jar:1.20.1-R0.1-20230709.090828-26 from/to spigot-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/): GET request of: org/spigotmc/spigot-api/1.20.1-R0.1-SNAPSHOT/spigot-api-1.20.1-R0.1-20230709.090828-26.jar from spigot-repo failedIt's perfectly working with 1.19.4, but not with 1.20.1
(working with 1.20 too)
mvn clean, mvn install
it just happened to me
thanks !
When someone can, I'd appreciate some help in #1127671319434109078
mvn clean package -U
-U updates snapshots
thanks 😄
Can I create custom smithing table recipes
And could I also create dynamic recipes, like a callback function that checks the ingredients and returns a new item
Sure
ofc
for that you'd have to manually listen to InventoryClickEvent
normal (registered) recipes are "static"
There’s also the PrepareItemSmithingEvent
oh yeah right. but it's PrepareSmithingEvent*
can you remove entries from a team while iterating on them?
I don't know if it returns a clone or not
and don't ?tas me
It's a clone
except the people who got banned lol
Yeah I also recognise most of you. But it would be strange if I wasn't able to
?paste
still that eclipse pfp
amazing
Can you tell me what my mistake is? The command /party invite executes without errors: https://paste.md-5.net/ebotinusen.java
fr
I used to have the ukranian recaf avatar for a while
yeah
its nostalgic seeing this chat
ive learnt csharp while i was gone from discord
and some dart
ill look into it thx
what kinda weird command framework is that? why does onCommand return a Command? o0
CommandAPICommand
Anyways. I require some help from the spigot hivemind:
I have an array of numbers (integers) (called the test array) that is freely resizeable. At any time, any number may only present within this array once.
Upon invocation of a method I have control over, exactly one number is added or removed from that array.
Then I also have multiple arrays of numbers (the witness arrays). These arrays are relatively constant and will rarely change (and if they do the aforementioned test array is empty). I have control over the method that would change these witness arrays.
The root question here is what data structure or algorithm would return me the witness arrays that contain the test array fully - though order of elements does not matter. Furthermore, the test array may contain more values than the witness array.
I don't think that's how you use CommandAPI...
It stops at future.get();
future.get blocks
this is very pointless
this.future.whenComplete(uuid -> {
//do whatever
}
your uuid will be null with the way you do it currently
thanks
No, but this is my only way to solve the problem
I don't think it's the only way 🤔
I can't think of anything else
AtomicReferences might be another way
Quickly, if you set an objective score to 0, does it show as 1 or is it ignored
I think it is shown as 0?
Yeah could also be that I am misremebering those
only issue is that it's only showing one of em
Okay yeah. It's 1 - X
wdym epic
Just get that resource pack that removes the numbers
That's not what I want lmao
I am just asking because some of the text is not showing
I set a team's score to zero to display that, but it's not showing so I was wondering if it started at 1 or zero
oh i thought you wanted to make them all 0
oh no
Yeah I think 0 doesn’t show by default
moving the setting to be at least 3
let's see if that fixes it
if it does then I know the issue ;)
I've been making simple mistakes today
like != instead !.equals
lmao
0 displays
Apparently not
#notAKotlinProblem
I think it just depends
it's possible you have too many lines?
I have 15 iirc
I recall it not being a problem with Presence
ur bad
where are MC screenshots saved? I forget
16 lines in total, going from 0 to 15, or is that too much
But I don't recall seeing 0 elsewhere either
%appdata%\.minecraft\screenshots
yep I got muscle mem for the mc directory
i rarely ever go there
mainy bc i dont use that .minecraft
i love discord making me reply to random things
Hello! Is it possible to store custom enums into an item's PDC? Currently I only store the int references to my enums, but I was wondering if I could store the enum itself
odd mines not there 😦
the entire enum?
Make custom adapter
Bad
I guess ?
?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.
blocks anyway
Who tf is using java cord
i dont see where this is, and use jda
When i use !whoIsOnline nothing is happening
That code isn't blocking
whenComplete wont block, im guessing you calling the future is blocking
Could you point me to a resource where I could learn about this?
https://www.spigotmc.org/threads/a-guide-to-1-14-persistentdataholder-api.371200/ scroll down to "Custom PersistentDataTypes and how to use them ?"
Great, thanks so much! 😄
Jda have it's own thread anyway
Different for websocket and events
Because it's executing from jda thread, just call .runTask from consumer
1 2 3 4 5 six even eight nine 10 eleven twlve 13 14 1five
Why does 1 get skipped though
That's a scoreboard on the right side yeah?
ye
I generate 15 teams, set them to be an empty unique id, and set their score
then when I want I just change prefix/suffix for no flicker
if you do something like bukkit.broadcastMessage(id) in the code where you create these teams, does it output 15 ids?
any exceptions?
or if you go in your console and do /scoreboard
and check there if there are 15 teams
it's not the main sb
0
OH?
nope
have you tried testing it with different ids?
eg.
11
12
13
14
15
then its probably just some bullshit hardcoded thing XD
What the fu-
ye
then use negative I guess? if it works
it depends on your code
when it comes to looping inserts you have to insure you account for the initial loop
otherwise you miss an insert at the beginning or sometimes at the end
because it doesn't loop that one last time
this is why ++i and i++ are a thing
Whenever a mob tries to spawn the server crashes without any errors. Does anyone know what is wrong?
https://paste.md-5.net/epixamicam.coffeescript
you are spawning a mob in the spawn event
that may do it yeah
infinite loop
@wet breach When I register the team I just set text on it to debug, no further setting
Line 1 is just not rendered
bet the error is a stack exception
yep overflow
mind showing the code?
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
// Allow tools and weapons to be placed in the smithing table (for custom upgrades)
if (!(event.getInventory() instanceof SmithingInventory)) {
return;
}
if (event.getSlot() == 1) {
event.setResult(Result.ALLOW);
}
}
I'm trying to allow players to put any tool or weapon inside a smithing table
This doesn't work, still only allows diamond tools
wdym i spawn a new mob and then i clear the original one
spawning a mob causes that event to run again
so its infinitely running with no condition to stop
the instant you call spawn, a new event is triggered. your event never gets to finish
and so on
oooohh
so you spawn the mob -> event runs your checks do its thing, removes entity, spawns another
and then it does it again
for (int i = 0; i < 15; i++) {
var team = scoreboard.registerNewTeam("test_team_" + i);
var id = "§r".repeat(i);
team.addEntry(id);
team.setPrefix("A");
objective.getScore(id).setScore(i);
}
how you stop it from doing that is add something to your custom entities to check for
so as to not remove them
this way, the next event is just ignored instead 😛
try changing it ++i
do i need to manually set the slot instead
well, you don't tell it what to do if its not slot 1
try adding an else statement to set result disallow?
why do i need to do that
i want to put any tool into the second slot
even if its not diamond
but I don't see where you check for the tools though 🤔
i havent implemented that part yet
right now im just trying to put any item
which doesnt work
you might need to use a custom inventory for it, not sure. Does the smithing table typically allow any tools?
then yeah going to need to use a custom inventory then most likely
ugh damnit
because it could be a client side thing not allowing it, not necessarily the server
I know when you register recipes with different items they work fine
Well, at least in the old table they did
well i need it to be dynamic tho
i need to read the properties of the tool
for the result item
You can still do that with a registered recipe
i can do that for smithing tables?
add a boolean field to your class
private boolean ignoreNextSpawn = false;
@EventHandler
public void onSpawn(EntitySpawnEvent event) {
if(ignoreNextSpawn) {
return;
}
// ...
ignoreNextSpawn = true;
event.getLocation().getWord().spawn(...);
ignoreNextSpawn = false;
}
and instead of calling entity.remove(), why don't you just cancel the spawn event?
Sure?
how exactly
How to register a recipe?
with a dynamic result
Same way you register crafting recipes, just with smithing instead
Use the event to change the result
which event
and the issue still stands that I can't put any tool inside the smithing table
PrepareSmithingEvent
wait so whats the purpose of registering the recipe
when i can just set the result inside that event
seems reasonable
I am not super familiar with the smithing stuff as I haven't really messed with it lol
I’m not familiar with the new smithing table
doesnt seem to work
Bukkit.addRecipe(
new SmithingRecipe(new NamespacedKey(this, "custom_smithing"), new ItemStack(Material.IRON_SWORD), new RecipeChoice.MaterialChoice(Material.IRON_SWORD), new RecipeChoice.MaterialChoice(Material.IRON_INGOT))
);
also i just realized
this smithingrecipe class is outdated
theres now three elements inside the table
lemme try that then
oh shit it works
Bukkit.addRecipe(
new SmithingTransformRecipe(
new NamespacedKey(this, "custom_smithing"),
new ItemStack(Material.IRON_SWORD),
new RecipeChoice.MaterialChoice(Material.AIR),
new RecipeChoice.MaterialChoice(Material.IRON_SWORD),
new RecipeChoice.MaterialChoice(Material.IRON_INGOT)
)
);
thank god
yeah, spigot doesn't tell you that SmithingRecipe constructors are useless, as instances of pure SmithingRecipe aren't recognized by the server
addRecipe returned false there probably
but yeah why are they 2 seperate recipes though
because there are 2 kinds of smithing recipes now
they have different behaviors
i dont see why they're split
yeah thats what i did
for the smithing template slot
they have different behaviors
Wait can’t we just make SmithingRecipe abstract then
well if you want to break API and probably ABI
I guess that would cause old plugins to explicitly throw an error, but that’s better than doing nothing imo
whats different i dont understand
they're both the same recipes, one just uses armor trim templates and the other uses upgrade template
if you use the trim one, and the stacks you input DON'T match trim pattern and trim material, it won't do anything
the template and addition ingredients
what needs to match
you can use any ore for the addition
and any smithing template
the only thing that won't work is if you use iron armor with an iron ingot addition or smthn
you also don't specify a result for trim recipes, hence it extending ComplexRecipe
hmm ok
i've never heard of ComplexRecipe before
could I perhaps use that for my own custom recipe instead too?
or do i have to use PrepareSmithingEvent
just completely out of curiosity
Oh ok
Should transform recipe use complexrecipe too though?
Because even though it always upgrades diamond to netherrite
It has to keep its enchants and nbt data
hey
I want to save a Object with SnakeYAML (the yml framework which is used in spigot)
But
ConfigurationSerializable
Ah there you already know the problem hahaha
PirateCraft: !!de.marvn.alphablock.alphawars.util.objects.Arena
declaration: package: org.bukkit.configuration.serialization, interface: ConfigurationSerializable
that should exsit still
I dont really understand how to use this
Should I implement this Interface into my Object?
ok wait
A constructor that accepts a single Map<String, Object>.
?
What should I exactly put into the constructor
yeah but can i choose a name by myself?
the name doesnt matter in a constructor
well that's not constructing the object. you need to populate the feidl from the map
you create a map from the fields in the serialize() method that interface has you implement
?learnjava moment
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
the problem is not that I dont know Java...The problem is that I have trouble understanding what you mean by populate
the list will have whatever contents you add in the serialize method
So you mean I should add every String for example into this map in my serialize method?
Anything you need to serialize, yes
And then you read it from the map in the constructor
public class MyCustomDataClass implements ConfigurationSerializable {
private final String name;
public MyCustomDataClass(String name) {
this.name = name;
}
public MyCustomDataClass(Map<String, Object> map) {
this.name = map.get("name");
}
public static MyCustomDataClass deserialize(Map<String, Object> map) {
return new MyCustomDataClass(map):
}
public static MyCustomDataClass valueOf(Map<String, Object> map) {
return new MyCustomDataClass(map):
}
@Override
public Map<String,Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("name", name);
return map;
}
}
The question is...If I try to read my stuff...Why Do I need a deserialize and a valueOf if I get the Object with #get
Oh there are several options
ahh
Didn’t know that
use eyes
Neat
Also hush I’ve never used ConfigurationSerializable
man just did all 3
Kek
same XD
ConfigurationSerializable is a bit gimmicky
looks ugly on yml
So I just make a constructor that takes a config section
Yeah it has the weird !!class to identify it
Yeah....Cant do anything...Need to save it somehow
And simply never have to impl a write method because all my YMLs are read-only :p
My cursed reflection config lib takes care of everything
Uhhh what if I have a List of Objects in my Object xD
same thing for them?
map.put("teams", teams);
my configs are kinda scuffed, I have an interface, then a class YamlWhatsverConfig that accepts a ConfigurationSection in the constructor, then the interface returns the values of ConfigurationSection#get…
Make sure the items in the list are ConfigurationSerializable
Just like that?
List itself is already serializable so ur good on that part
So I wouldnt have to serialize that? HashMap<String, Team> teams = new HashMap<>();
just make sure its vaulues are (configuration)Serializable
Yes Team for example does not implement that
team is gonna need serializing
Tbh sounds like a robust design
It is
Sounds like everything but scuffed
do I need the first constructer on the top?
Otherwise I would juist use valueOf
thank you for that
wait your talking to me or Dominick?
You
Yeah but fr tho, if I read code like that my eyes would be shining
whoevers listening
do it
The second Constructer wouldnt work cause this.name needs a String but you only get a plain Object
I mean the IDE would have a probl
cast it
https://github.com/Itzdlg/CPvP-Kits/tree/master/src/main/java/us/cpvp/kits/entities/configuration/kits @ivory sleet this is what I do
I remember this faction code base where all their data was grabbed from debugging logs, oh god, dont think code can get any worse than that
hmm ok
✨🔥
@young knoll wheres my eye blood
ok so
@Override
public Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("name", name);
map.put("maxPlayers", maxPlayers);
map.put("teams", teams);
map.put("bronzeSpawner", bronzeSpawner);
map.put("silverSpawner", silverSpawner);
map.put("goldSpawner", goldSpawner);
map.put("diamondSpawner", diamondSpawner);
map.put("emeraldSpawner", emeraldSpawner);
return map;
}```
Does this look good?
Is that how they want that?
as long as its a a map string object its happy
nice
public Arena(Map<String, Object> map) {
this.name = (String) map.get("name");
this.maxPlayers = (Integer) map.get("maxPlayers");
this.teams = (HashMap<String, Team>) map.get("teams");
this.bronzeSpawner = (List<Location>) map.get("bronzeSpawner");
this.silverSpawner = (List<Location>) map.get("silverSpawner");
this.goldSpawner = (List<Location>) map.get("goldSpawner");
this.diamondSpawner = (List<Location>) map.get("diamondSpawner");
this.emeraldSpawner = (List<Location>) map.get("emeraldSpawner");
}``` and this is my constructor
Looks good?
yep
ok and if i read that correctly I have to serialize it in my onEnable?
ConfigurationSerialization.registerClass(Arena.class)
probably
also you don't necessarily need to register it in onEnable I don't believe
if you find it better to stick it in a static block in the same class, that probably will work
static {
ConfigurationSerialization.registerClass(Arena.class)
}
I need to split a string, whilst keeping color codes intact, is there a known way to do this?

How do u split it?
Just using length right now, that's why it's happening
Like with String::split and pass a pattern?
var left = text.substring(0, Math.min(text.length(), 64));
var right = text.length() >= 64 ? text.substring(64) : "";
you could probably use indexOf, then loop all characters from then to indexOf, and build a new translatable string color code?
I mean instead of indexof you'd just use the second parameter of substring, but same idea
If there was only one code that'd be fine, but take like hex §x§f§f§f§f§f§f or §l§n§6
well I'm thinking if you have a string like &aHello &cWorld &b&lHahahahah &r&6Test (split) &cmwhaha, you'd end up with &a&c&b&l&r&6&cmwhahaha, and that should just apply the right ones, I think?
I figured
- if the last char is a color code, move it to right
- if two characters behind is a color code, move the last two chars to right
- try repeat two
You’d just wanna make sure the character after § is together with the § if its a valid chatcolor code character?
Oh shit yeah domi
Or is it important to have consecutive § pairs not split up?
Ah fuck it still shows that: " ==: de.marvn.alphablock.alphawars.util.objects.Arena"
I could just
indexOf('§r') (if it returns -1 I just use indexOf('§')) and just apply all existing color codes forward, thanks
Dw coll is cooking
in the middle of my data.yml
yeah that's why no one uses ConfigurationSerializable
it's the worst API in existance
But how should I then save my stuff?
manually write to ConfigurationSection
what should I use instead
database
damn...Never done something like that
any guide?
You’ve already seen my funny reflection config api
i hav?e
And my unfreezing registries
while this doesn't write, it does read. implementing write is simple since Yaml... has ConfigurationSection https://github.com/Itzdlg/CPvP-Kits/tree/master/src/main/java/us/cpvp/kits/entities/configuration/kits
but you most definitely have done this before
oh yeah that i ahte
it's literally just section.setInt("maxPlayers", team.maxPlayers) and so-forth
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/configuration/ConfigurationSection.html refer for set and read methods
and note that YamlConfiguration is also an instance of ConfigurationSection so if your data is at the root, it'll still work fine
So the interface holds the data types?
Switch Map<String,Object> to ConfigurationSection lmao
josh does ur config work off gson type adapters
Thats all
in my case yes, but you don't necessarily have to inplement it like that
you'd just change your constructor like Conclube said
Not my fault Mojang freezes the registries smh
No
why not
and should I keep the serializable method and implement ConfigurationSerializable?
^
ok
or just change it to
public ConfigurationSection serialize() {
…
}
just from when you attempt to build the object it's not like this:
(Arena) config.get("arena"), it's like this: new Arena(config.getSection("arena"))
Yeah
kind of like this:
public class Arena {
protected int maxPlayers;
public Arena(int maxPlayers) {
this.maxPlayers = maxPlayers;
}
public Arena(ConfigurationSection section) {
super(
section.getInt("maxPlayers")
);
}
public Arena(ConfigurationSection config, String key) {
return super(config.getSection(key)); /* even can do this, so getting becomes new Arena(config, "arena") */
}
public void write(ConfigurationSection section) {
section.setInt("maxPlayers", maxPlayers);
}
}
Because it ain’t json
its a superset
anyway im going to bed
josh thing of things i can do tomorrow
and dm them me
now im out
wait for what the write?
Cant i just save?
wdym
Testing this
(though going from last §r to not add too much, char limit is 64)
I currently save like this;
I prepare an Arena after some setup things and then i put it in my yml like this
getConfig().set(Cache.arena.getName(), Cache.arena);
Yeah, I mean its possible to return ConfigurationSection also, you’d just invoke MemoryConfiguration’s constructor and use it as a fresh map, but that looks good (just if they want it to be as similar as possible to before)
instead you'd save like Cache.arena.write(getConfig().getSection(Cache.arena.getName()))
this as well ^
But wouldnt you only save the name in that case?
I want to push the whole object containing everything
you're pushing the whole object
public void write(ConfigurationSection section) {
section.setInt("maxPlayers", maxPlayers);
}
that's what this does
you're giving it a new "section" in your config, like
data.yml
arenas:
nameOfArena: # getConfig().getSection(Cache.arena.getName()
maxPlayers: 5
and you'd write to that section using Cache.arena.write(getConfig().getSection(Cache.arena.getName()))
I only find getConfigurationSection
Is it also possible to have an empyy constructor instead of the first one?
why would you have an empty constructor
please don't tell me you're filling in the fields manually like this is C
technically yes you can have an empty constructor and access new Arena().maxPlayers = 5;, but that's a huge anti-pattern
I have to because those fields have to get filled after another after specific events
there's probably a better design, but yes you can
ok
though you need to replace super with this.maxPlayers
Marvin there are to designs you can have.
Either:
class Boo{
Boo(ConfigSection …){
}
ConfigSection …() {
}
}
or
class Doo {
void read(ConfigSection …){
}
void write(ConfigSection …){
}
}
One has 2 void methods, one has 0 void methods, choose one (the first one is if ur fields/variables in Boo.java can be re-assigned, the second one if they cant) mutability vs immutability.
super(..) to this(..)
Since I don’t know how ur data transfer (ur class that u wanna serialize) is used it is hard to say what would he the best choice here
what should I use in the section.getInt if the Object is a Location from SPigot?
?
yep
Call another constructor use the this keyword?
So like this currently if I dont have a constructer with all fields? java public Team (ConfigurationSection map) { this.spawnPoint = (Location) map.get("spawnPoint"); this.spawnBlock = (Location) map.get("spawnBlock"); }
Its possible
Yes i'm talking about it
Constructors and overriding them works similar to methods and when you override them
In fact almost identical
super. goes up to the superclass above, if the superclass did not do anything with the methods, it chains to the superclass of the superclass
same with constructors
Only difference is when you override a constructor you must call its super
Otherwise you’d get a lot null pointer exceptions
Thats too much info...Slowly please....My class currently looks like this:
public class Team {
public Team(){
}
public Team (ConfigurationSection map) {
this.spawnPoint = (Location) map.get("spawnPoint");
this.spawnBlock = (Location) map.get("spawnBlock");
}
protected Location spawnPoint;
protected Location spawnBlock;
public Location getSpawnPoint() {
return spawnPoint;
}
public void setSpawnPoint(Location spawnPoint) {
this.spawnPoint = spawnPoint;
}
public Location getSpawnBlock() {
return spawnBlock;
}
public void setSpawnBlock(Location spawnBlock) {
this.spawnBlock = spawnBlock;
}
public void write(ConfigurationSection section) {
section.set("spawnPoint", spawnPoint);
section.set("spawnBlock", spawnBlock);
}
}```
does that work?
Its bad
yes but it would work?
Yes
The constructor
why don't you use a builder pattern
wdym exactly?
though that one is a bit weird, I don't think I've ever seen a class accept a builder as a constructor parameter
typically the builder returns the constructor invocation
Ah you mean that
Yeah, I think it can be fine if you have a static factory method but else myea
Yeah I will build them like that afterwards...Thanks for remembering me..Havent thought of it
So what exactly should I change in this constructor
I'm trying to increment a weapon's attack damage
private void enhanceGear(ItemMeta meta, Attribute attribute, int level) {
Collection<AttributeModifier> modifiers = meta.getAttributeModifiers(attribute);
if (modifiers != null) {
for (AttributeModifier modifier : modifiers) {
if (modifier.getName().equals("smithingEnhancement")) {
meta.removeAttributeModifier(attribute, modifier);
}
}
}
meta.addAttributeModifier(attribute, new AttributeModifier("smithingEnhancement", level, AttributeModifier.Operation.ADD_NUMBER));
}
...
enhanceGear(meta, Attribute.GENERIC_ATTACK_DAMAGE, level);
Well you know how you hav setters
but then all of this shows up
Because of that, there is no real need to actually do anything in ur constructor
Instead I would go with another void method that reads from a configuration section
i cant follow
I want u to delete ur constructor in that class
Instead use a method to set the values of the fields from ur config
the empty one? probably not the one with the COnfiguration map
the empty one, yes
oh but wait 
conclube if he deletes that one then he can't do his weird design
oh I understand what you mean now
np man I will change to a build pattern
but first i want to try and see if it works
Yeah, I just thought that since the class itself is mutable by nature, the reads and writes should follow the pattern he chose initially

wait so as far as I understood
I just have my setter which gives the value to my var....And in my write method I manually do Config.set(Something.spawnPoint, spawnPoint) and this for each value?
I ve never worked with Serializing...I just wanted to write a MinecraftPlugin and save something....This is so complicated if you never done something with yml
Let me write a sample
for some reason this actually makes the sword weaker
i thought an attribute modifier would MODIFY the existing value
I am sorry for making you help me hahaha
thanks a lot man
how to get the uuid of the player if he is offline

