#development
1 messages · Page 25 of 1
fking
~
impressive how I never find the issues, but once I ask for help here, I 98% of the time find them
it's the rubber duck method
What was it returning? Just curious
Dont you need to get data first and then the uuid?
nothing
wdym
wth is a self-loop edge?
just an empty string?
ye it returns an empty string
doesn't return a nullpointer because it's inside a try/catch
uhm is it normal that the Vault api #getBalance() returns 0 while I have money in my account?
what could be the cause for such thing?
a number of things
do you have an economy plugin that provides Vault's economy service?
yes
funny part is that I use it in another class and it works
only difference is that I use a Player object instead of Offlineplayer in that class
can that be the cause?
it depends ™️
explain ™️
ideally it wouldn't
but it depends on the economy plugin and how it is subclassing vault
oh oof
I am using BetterEconomy rn for testing
happens the same with xconomy
no idea how I would fix this, since I assume #getPlayer() from an offlineplayer wouldn't work if they were offline
in that case it returns null
ye exactly, so if offlineplayer returns 0, how th will I get the player balance while they are offline 😭
¯_(ツ)_/¯
you use their uuid
which you can get their offlineplayer with a uuid
Bukkit#getOfflinePlayer(UUID)
ive used essentialsXEco and it returns the balance correctly, id assume its a problem with those economy plugins or something else
maybe the wrong offlineplayer object is being returned
see what the offlineplayers getname returns
its also possible that the players eco data is unloaded on player quit in the eco plugins youve tested with
which tbh is kinda weird
i know you can change the ascent value and the height on a custom font character to move it up or down, but is there a different way to print multiple consecutive lines than that? like so i don't have to create a variation of each character at different heights on the screen?
i would assume yes you can but im not sure how exactly, maybe theres a way to make a character force all other characters infront of it to line up with it
ive seen it done with moving all characters back or forward
print where?
What velocity do I need to set for a entity to make it move forward 1 block to the direction it’s facing
Well idk how you will choose a blocks direction (depending on the block used), but for players/entities it's just <Entity/Player>.setVelocity(<Entity/Player>.getLocation().getDirection().multiply(2)); or something like that. Not at PC atm.
action bar chat that part doesn't really have to be specific
that's probably done by just updating what is being sent, but that doesn't explain how to first show(render?) characters at different heights without having an individual texture for each height
what is the easiest way to get that marked block's location
using that armorstand
if you wanna get the location one block in front of the armor stand just get its location and then add to it its normalized direction
add what to it?
sec
Location newLocation = stand.getLocation().add(stand.getLocation().getDirection().normalize());
should be something like this
just get the stand and that'll give you the new location
sure let me try that
if you're trying to move the armor stand to that location you can just use .teleport btw
Don’t want to use teleport coz I want smooth movements also seems to be moving like 2-3 blocks but I want to make it move one block at a time
i just tested it it works fine. change getEyeLocation to getLocation
Its still 2 blocks
could you show your code? i've tested it and it works fine
Any improvement ideas for this?
https://github.com/Andre601/AdvancedServerList/pull/34
I use modrinth's API for version checking. This API route to be exact:
https://docs.modrinth.com/api-spec/#tag/versions/operation/getProjectVersions
I would make it check for updates every like 7 days (configurable?)
the server owner that I make plugins for only restarts their server when updating a plugin for example
I don't think that's worth it. I want to avoud some scheduled tasks or whatever.
ive almost finished my aote clone and now the last thing to do is to fix teleporting into a hole where the block directly and north and south are both solid
but im not exactly sure what the best method is
the particles is the teleport spot
im hoping that i could make it so that the paricle is on the floor just before the hole in the wall
Try adding .900 in the direction you want it. (Or .400 if you already centered it)
Anyone know if this is a vaild end to a json file?
https://cdn.discordapp.com/attachments/748395499765366905/1048859969027575868/image.png
I'm trying to use gson to serialize an object, but it doesn't appear to be serializing the entire thing and just cuts off after awhile
That image is not very helpful, can you just paste the JSON?
Are you missing a quote or something?
Yeah one second
Wait
that didnt work
It's hard to paste json since it has no line breaks
This is the best I can do
It looks like it's missing a quote and close bracket, but I'm not very familiar with json formatting.
I think there should be an option to save it with a different format
So that it looks better
https://cdn.discordapp.com/attachments/1032586375008104459/1048864068087316550/ss2.png
What velocity do I need to reach the specified block?
Probably 1
What should be the vector then?
End - start
k
still moves 2 to 3 blocks...
Can you post your code?
Vector oldVector = player.getLocation().toVector();
Vector newVector = new Location(player.getWorld(), Double.parseDouble(args[0]), Double.parseDouble(args[1]), Double.parseDouble(args[2])).toVector();
Vector finalVector = newVector.subtract(oldVector).normalize().multiply(2);
stand.setVelocity(finalVector);```
Why are you normalizing and multiplying by 2?
Make sure to apply an angle or the armorstand will slide less then you want (if there are blocks)
I have tried it without it as well, I have tried many methods
What happens when you do it without multiplying?
Same sht
Its faster when I multiply
That’s exactly what’s happening
Also the armorstand is stationery before setting the velocity
Wdym by angle?
45 degrees less or more depending what you want. (pitch)
Could also set its gravity to false then a time after set it back to true
The first location have 180 yaw and 0 pitch and I didn’t specify any yaw and pitch to the second location
Will it move with gravity set to false?
No
It still moves too far when not multiplying? Can you print out the vector?
It moves less than what I want when I don’t multiply
I just want the armor stand to move to a location which is specified
Without teleporting it
Teleport it 0.1 blocks up to remove friction then
Then move it
K let me try if that works
So Im assuming that I don’t need to multiply or normalize the vector. right?
Set pitch to 10
The pitch in first location or the second?
newVector.subtract(oldVector) of this
Nope
Then what
Just subtract
Thats what I meant
what do you mean by that
Get rid of the .normalize().multiply()
I did
So what happens now?
Turn that vector into a location set pitch to 10 then do the multiply
yes but not immediately
Yes it will, it starts from the ground
Multiply by 2?
He says to multiply an you say not to…
....
But just teleport it up a bit
K let me first try the teleporting method. If it doesn’t work then we can see
That's not how it works
You just do setVelocity
....
if(seat.getPassenger() != null) {
as.setVelocity(newLoc.toVector().subtract(loc.toVector()).multiply(1.8+cart.getCartSpeed()));
}else {
as.setVelocity(newLoc.toVector().subtract(loc.toVector()).multiply(.1));
}
```Here is some code from my rides plugin
You really don't need to multiply unless you are going far enough to need to into account air resistance
And even in that case it won't be accurate
Actually I might not be able to use your teleporting method coz I don’t think teleporting a entity works if it has passenger on it
I don’t think teleporting a entity works if it has passenger on it
nope
Does it work?
But isnt that what I said
Here I'll edit the message lol
K so it works
... "nope" it doesn't work
Bruhh
I must have missed where you said there was a passenger, sorry
Can't teleport an entity with a passenger
That’s exactly what I said
I edited the message.
Whatever
Is it possible to move a armor stand using nms. I found something related to it on spigot forums
with packets yes
You can also just unmount then mount it
public MoveArmorstand(Location loc, Player player, ArmorStand stand) {
double x = (loc.getX() * 32 - stand.getX() * 32) * 128;
double y = (loc.getY() * 32 - stand.getY() * 32) * 128;
double z = (loc.getZ() * 32 - stand.getZ() * 32) * 128;
stand.absMoveTo(loc.getX(), loc.getY(), loc.getZ());
ServerPlayerConnection playerConnection = ((CraftPlayer) player).getHandle().connection;
ClientboundMoveEntityPacket.Pos moveEntity = new ClientboundMoveEntityPacket.Pos(stand.getId(), (short) x, (short) y, (short) z, false);
playerConnection.send(moveEntity);
}
is that... a constructor... that sends... packets??
yeap lol
very true

Have one for spawn, teleport, move, remove and name visibility.
😵💫 😵💫 😵💫 😵💫 😵💫 😵💫 😵💫 😵💫 😵💫 😵💫 😵💫 😵💫
wait until you find about methods
😭
they are a real game changer
true
they can have different names as well btw
They can even have the same name!
It was mimicking the actual packet names (or use case) while also sending the packets 😉
constructors are meant for data initialisation, not what you are doing 
^^ constructors should never have side effects
the pinnacle of object oriented programming
this is how i write code
Max max = new Max(i, j);
int k = max.result();
perfection
LMFAO!
...?
no this is how you write code ```
idc sadjas(sdajaskd)
{ sdnjnaslkd (jdasjdl)
lnaskdaksdnklasd
} NLLASKDk
askdlaslkdl
HAHAHA
xDDD
ROFL*
lemme fix the formatting ```
idc sadjas(sdajaskd)
;;;;{
;;sdnjnaslkd (jdasjdl)
;;;;;lnaskdaksdnklasd
} NLLASKDk
;;;;;;;askdlaslkdl
imagine using spaces to indent
hey everyone, a long while back a programmer coded me a minecraft plugin. the minecraft version it was coded for was 1.8,9, I still have the source code and have the plugin open in IntelliJ. How do i update the version to 1.19.2
what errors does it have on 1.19?
i actually didnt run them yet
should i and see the log errors?
dont you have to set something in the coding to make the server be able to take the plugin
many plugins work fine on latest
sometimes
Sounds won't convert itself to latest though for example
ok ill go ahead and try
i have 4 plugins so should i run all at once or one at a time
all
ok so i was planning to run all this through a free aternos server
but they dont take custom plugins
to upload
any suggestions?
for server hosting websites that are free or cheap that i can upload plugins onto
@frigid crater
Click your windows key and type cmd, press enter (open command prompt)
Put ```bat
java -version
java version "1.8.0_351"
Java(TM) SE Runtime Environment (build 1.8.0_351-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.351-b10, mixed mode)
oof
if you want you can host the server on your own pc
you'll have to install java but that's it
do i need to port forward
nope
well no if you don't port forward
i mean this as just a test server to see if the plugin works
oh true
or does it require 2 players?
also doesnt my computer have java already
oh?
so do i download the new version on the website or can i update it through the one i have
you can download it from https://adoptium.net/
Latest LTS Release
@frigid crater in the installation process make sure to enable "Put on PATH"
or whatever its on
something something PATH environment variables
add to path?
yeah there should be an option
i cant put ss in here
i installed it
I just did a fresh install of windows and hadn't installed java yet, thank you lmao
🥲 🥲 🥲
woah all new
@frigid crater did you see this option?
or ig if you installed it already we can set it manually if it didn't set itself
close command prompt and then reopen it with the same java -version command
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)
oh nice
then download #304 (latest) from https://papermc.io/downloads and put that into like a folder named "Server"
done
now do cd C:\Users\CoolUser\Downloads\Server for example (cd means change directory) in command prompt
if the path has a space in it then you'll need to wrap it with ""
C:\Users "Dylan Nabeth">cd C:\Users"Dylan Nabeth"\Downloads\Server
The system cannot find the path specified.
cd "C:\Users\Dylan Nabeth\Downloads\Server"
theres a slash before dylan
discord isnt showing it
oh wrap the entire thing with "?
or just the part with the space
'"C:\Users\Dylan Nabeth\Downloads\Server"' is not recognized as an internal or external command,
operable program or batch file.
put cd before
C:\Users\Dylan Nabeth>cd "C:\Users\Dylan Nabeth\Downloads\Server"
The system cannot find the path specified.
try cd Downloads
then cd Server
make sure the Server folder exists in Downloads
XC:\Users\Dylan Nabeth>cd Downloads
C:\Users\Dylan Nabeth\Downloads>cd Server
The system cannot find the path specified.
ohhh shit
i put it on my dekstop
my bad
ok were good now what
@dusky harness ?
then download #304 (latest) from https://papermc.io/downloads and put that jar into that Server folder
did
then in command prompt run java -jar paper-304.jar (or whatever the jar name is)
it should error saying that you have to accept the eula
and then you have to go to eula.txt and change false to true
then make a plugins folder and put the plugins in there that you want to test and run the java -jar command again
in mc, connect with the IP set as localhost
Error: Unable to access jarfile paper-304.jar
we good
[19:34:51 INFO]: Building unoptimized datafixer
[19:34:52 ERROR]: Failed to load properties from file: server.properties
[19:34:52 WARN]: Failed to load eula.txt
[19:34:52 INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
all normal?
@dusky harness ran into issues i think
did you set eula to true?
if so run java -jar paper-304.jar (or whatever the jar name is)
which error?
what command did you run?
java -jar paper-304.jar
well with the right name
paper-1.19.2-304
wait no sorry
wait yeah sorry
i have no idea what i did lemme retart'
C:\Users\Dylan Nabeth\Desktop\Server>java -jar paper-1.19.2-304
Error: Unable to access jarfile paper-1.19.2-304
yeah so i cant run that command and doing java -jar gives me that long error in pastebin
ok wait
fixed it
ok im in!!!
how do i give myself perms @dusky harness
in command prompt run op YourUsername
oh that window is the console
yeah
show me logs/latest.log
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
is that the entire log?
yep
did i send the wrong this
I guess make sure the jars are in the right folder
nono
thats from the white screen titled "Mineraft Server"
was i supposed to send the cmd prompt
no i think its fine
im looking at the cmd prompt and its the same
if you go in the Server folder and open up the plugins folder its all there?
?imgur
You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/upload to upload images/screenshots.
You can also use a screenshot service like gyazo or jinx and post those links here.
id rather not upload to imgur
im sorry
is my server even spigot
or is it vanilla
should be spigot/paper
you started the server after uploading the plugins into the plugins folder
right
yes
fuck
not the source
maybe
use the actual plugin
can i make a jar from the source?
shouldn't you have the jar already?
i have to find it
i stripped these off my old pc
how do i turn them into jar files
IntelliJ is what i use
IntelliJ only helps you edit the code - building the plugin still requires running the commands of the build tool (or a button in IntelliJ which just runs the commands)
can you show me a screenshot of the project structure?
you can DM me
hmmm
either I'd just put it in #1047749266921230407 (and say that you have the source code) as I don't have the time to fix it for you
so maybe someone else is able to
i want to fix it myself i just need to know how
i have a string ("hello %test==cool% gamer %wow% omg") and i want to extract the %test==cool% part without knowing what cool actually is
ive gotten this far:
final Matcher matcher = Pattern.compile("%test==.*%").matcher("hello %test==cool% gamer %wow% omg");
final String match = matcher.group();
```but the issue comes in with `%wow%`; instead of `match` returning `%test==cool%`, it returns `%test==cool% gamer %wow%`, because of the `.*` in the regex
how can i fix this? *ping if reply*
i think i fixed it by changing the regex to "%test==.*?%" (added ?)
Had hopefully a quick question.
Is it possible to use the API to parse a placeholder from another plugin in my code
%test=[^%]+% maybe this, [^%] means "anything but %" so it will stop at the first %
That's the point of papi
I know that, but I am trying to find a way to parse the placeholder from another plugin and hadn't seen anything about it. I might have just missed it, but I was trying to find something like String parsed = PlaceholderAPI.parse(%some-placeholder-here%);
Its not a big issue, Just was curious
setPlaceholders() @crisp oar
Ah alright.
The name threw me off.
I should have read it, but had thought that setting it would be to make them not to parse them.
Thanks for that
The ? worked, thank you though!
any react experts round here?
my home gets rendered multiple times
hence the buggy looking text
why on earth are u using jquery
what do u use
not jquery
What is the reason for this response
probably your message
"specifically, will there be any complications with backend functions like sending obfuscated tasks to the kernel"
what in gods name are you doing to need this in a minecraft plugin
What does it even mean
How does one send obfuscated tasks to the kernel
What is the obvious answer here?
I dread to think
Allow me to help you then I guess.. lol
I suppose the obvious way is that you just mean syscalls but you're describing it in a really unnecessarily complicated way
its a rootkit.
what is?
He's trying to make a backdoored plugin thats able to access the server system rather then just its partition.
What does that have to do with deluxemenus
🤷 Haven't figured that out yet lol
Has any of the newer java versions made Arrays comparable yet?
Ex;```java
Object[] chunkCoordintes = new Object[] {"world", 1, 1};
Object[] checkCoordinates = new Object[] {"world", 1, 1};
System.out().println("Match: "+(chunkCoordinates == checkCoordinates));
Damn trying to removed the need for a few lists and comparison methods.
Arrays.equals is a thing
Thought it returned the same?
🤦
It would be nice if arrays overwrote equals and hashcode but I doubt that will ever happen because it will break a ton of existing code
Let me test cause I think it was said before and still didn't work
java 2
Found my method (for doubles)```java
public boolean doesDoubleArrayMatch(double[] array1, double[] array2) {
if(array1 == null || array2 == null)
return false;
if(array1.length != array2.length)
return false;
for(int i = 0; i < array1.length; i++)
if(array1[i] != array2[i]) return false;
return true;
}
rofl
yeah it's been there for years lol
with overrides for all the primitives so that method really isnt necessary
Would have been good to know back then xD
doesnt jebrains suggest to use Arrays#equals just like it suggest Arrays#toString ?
unfortunately not
😦
What do you mean? SQL GC is the best idea of the century
i prefer the latter actually
Deluxemenus rootkit is gonna change the world
Maybe
But SQL GC will change the universe
Just imagine it
A GC
Written in SQL
Unbeatable idea
If I run World.loadChunk(0,0), what is the best event to check when this chunk has become modifiable? ChunkLoadEvent, EntitiesLoadEvent or something else?
Probably ChunkLoadEvent
^^ but just reminding you of this in case you weren't aware
This method will keep the specified chunk loaded until one of the unload methods is manually called. Callers are advised to instead use getChunkAt which will only temporarily load the requested chunk.
When was that added?
And how long is temporarily? lol Would I still be able to run code in ChunkEvent if using that method?
I only use spigot.
i would imagine it's undefined and just dependant on the server settings
okay... the fact that it's documented that way doesnt mean the method won't also behave that way on spigot
it's also present on spigot 1.19 so it's not a paper-exclusive thing
Well spigot doesn't say that so
yes it does
d;World#loadChunk
void loadChunk(@NotNull Chunk chunk)```
Loads the specified Chunk.
This method will keep the specified chunk loaded until one of the unload methods is manually called. Callers are advised to instead use getChunkAt which will only temporarily load the requested chunk.
chunk - The chunk to load
^
The javadocs only display the first few worlds on the top part LOL
Ah thats why lol
Hello im new but could i use ItemStack#hashCode() to identify an itemstack (the hashCode will never change even when i stop the server etc ... ? ). For example when i right click i check the hashCode
No
NO*
Use nbt, pdc. Hashcode is not meant for that
ok ty
Hello its me again, what if the lore of my item change every click ? the NBTTagCompound will be different each click. The itemStacks dont have something unique special for this itemstack ?
Item stacks dont have anything uniquely identifiable by default
check for a nbt tag set by you
generate a uuid yourself, set it, and then save it somewhere
depends on your use case
or something similar
Quick question: If I have an empty folder where a Server will be created, can I just create an empty .properties file and just put online-mode and port in there, or will that get overridden once the server is created, same question for the spigot.yml
with reflection, are you supposed to cache the Class.forName result too?
or just the getMethod, getField, etc
I think that you don't have to cache it but im making sure
it's better if you do
No worries
Quick question, am I able to disable the response on this? (As in, prevent it from sending the empty line).
(Context: Conversation API)
/**
* Gets the text to display to the user when this prompt is first
* presented.
*
* @param context Context information about the conversation.
* @return The text to display.
*/
@Override
public @NotNull String getPromptText(@NotNull ConversationContext context) {
return "";
}
Not from what I know, and it doesnt accept null
Actual scam
After all it is an api made when, 2013? And probabily not updated since then 😬
Cuz dont feel so good
I can see that
you dont feel good because you're using jquery
if it has the same filename it'll be overwritten
Actually it didn't, it just appends the missing config fields to it
I'd like to start using the Guilds plugin, but I'm not sure if it has everything I need. I imagine a plugin that works like a clan. Players have bases that they can expand, modify, etc. It would be ideal if they had something to protect. Then I don't know if the plugin has a base label (like with WE) to indicate its area. This could be used to let guild members know when someone is approaching them so they can possibly prepare to defend their base. I would like to make clan wars in one world, where I would limit its size via the worldborder.
I'm trying to store the uuids of a few entities upon spawning and trying to remove those entities when the plugin loads up using their uuids but it seems to not work. What is a better way to do this?
Aren’t plugins loaded before the world is even loaded?
Thanks it finally works now
Didn’t even know that event existed
it's relatively new iirc
Any chance?
@edgy lintel use dms to discuss with them
dude you deleted my message 💀
its a copypasta 💀
Ok
Is EntityDismountEvent broken or something coz for some reason it fires this event even when I add a passenger to a entity.
Also does VehicleEnterEvent fires for Zombies?
Yes
majority of the vehicle events works with regular entities
I tested it and it doesn’t work for zombie
What are you exactly doing ?
new BukkitRunnable() {
@Override
public void run() {
if (manager.getPlayersInBus().size() > 0) {
for (UUID uuid : manager.getPlayersInBus()) {
Player player = Bukkit.getPlayer(uuid);
if (player == null) {
manager.getPlayersInBus().remove(uuid);
manager.getBusByPlayer().remove(uuid);
continue;
}
if (!player.isOnline()) {
manager.getPlayersInBus().remove(uuid);
manager.getBusByPlayer().remove(uuid);
continue;
}
if (player.getVehicle() == null) {
manager.getPlayersInBus().remove(uuid);
manager.getBusByPlayer().remove(uuid);
player.sendMessage(SUCCESS_LEAVE);
}
}
}
}
}.runTaskTimer(plugin, 0L, 20L);
}```
what could be causing this error
manager.getBusByPlayer().remove(uuid); modifies a list you're currently iterating
thats a hashmap
Fixed it
new BukkitRunnable() {
@Override
public void run() {
if (manager.getPlayersInBus().size() > 0) {
for (int i = 0; i < manager.getPlayersInBus().size(); i++) {
UUID uuid = manager.getPlayersInBus().get(i);
Player player = Bukkit.getPlayer(uuid);
if (player == null) {
manager.getPlayersInBus().remove(uuid);
manager.getBusByPlayer().remove(uuid);
continue;
}
if (!player.isOnline()) {
manager.getPlayersInBus().remove(uuid);
manager.getBusByPlayer().remove(uuid);
continue;
}
if (player.getVehicle() == null) {
manager.getPlayersInBus().remove(uuid);
manager.getBusByPlayer().remove(uuid);
player.sendMessage(SUCCESS_LEAVE);
}
}
}
}
}.runTaskTimer(plugin, 0L, 20L);
}```
Is there any built-in method to convert a EulerAngle to a Vector? Or do I have to do it myself / how would I do it?
Feedback wanted: https://github.com/Andre601/AdvancedServerList/pull/36
Wouldn't a getScheduler().tunTaskTimer(...) be a bit cleaner? It afaik would allow to get rid of this entire public void run override stuff for a simple lambda or smth
its possible they are unaware that exxists
intellij 😌
what does intellij have to do with any of that lol
anyone know how i can replace ${version} in plugin.yml with the version from build.gradle.kts for a test jar?
this is what i have to replace ${version} in the main jar and to create the test jar:```kts
tasks {
// Replace version in plugin.yml
processResources {
inputs.property("version", project.version)
filesMatching("**/plugin.yml") {
expand("version" to project.version)
}
}
// Create test JAR
assemble {
dependsOn("testJar")
}
register<Jar>("testJar") {
archiveClassifier.set("test")
from(sourceSets["test"].output)
}
}
ping if reply
it tells you that you can make it a lambda
(for this)
not for BukkitRunnable, it's not a functional interface
oh I misread it then 🥲
yeah I guess he probably doesn't know about Bukkit.getScheduler
try pluginVersion
instead of version
im like 10% sure that regular version didn't work when i tried
it shouldn't make a difference
so long as it matches what is in the file with what you replace in the build script
ill check my code but just wanted to say that while i bring it up
like for all that matters I could have it say ${giant-grandpa-ear-hair}
👀
Any tips to start learning kotlin?
ping me with some code 👍
nono its working fine for the main module
i just need it to also work for test
I have none, I wanna figure out if it's worth the pain and suffering
huh
oh 🥲
uh
I'll send you the painful code xD
ow why does kotlin docs not have dark mode
Once I have some
Unacceptable
use dark reader
that makes sense
kotlin bad
:O
💀 💀 💀 💀 💀
Joke btw
i'm too good for kotlin

?di
Dependency Injection
Dependency Injection is a way of providing objects with the objects they need ("dependencies"). This is usually done with a constructor, but can also be done for individual methods
Read more here: https://en.m.wikipedia.org/wiki/Dependency_injection
Dependency Injection in Java:
https://paste.helpch.at/yijawupoju.java
Dependency Injection in Kotlin:
https://paste.helpch.at/esogakutod.kt
here's an example
lol
wow it uses Main
I thought that was bad to use as the main class name
i mean it's not going to break your program kind of bad
it's more like, this is unideal and you may have a problem with that in the future and it does not make sense for a plugin
kind of bad
Oh wait can it actually lead to problems?
I thought it was like a convention kind of thing
like naming conventions
yea i used to use main and it was fineeeeeeeeee
(Main) getPlugin("blah")
oh
is that for me
but your class is also called main but you need to fqn it but you forgot and cce aaaaaaaaaaa
it's for @jade wave
also wait what the hell did it do to wikipedia
bruh why does it look so much better
that should just be the main layout
u can collapse categories that is so useful
do u know how to fix my thing? :)
I don't unfortunately
you may be able to get away with doing withType<ProcessResources> { ... as opposed to just processResources { ...
that worked!
altho im being screamed at:
'org.gradle.language.jvm.tasks.ProcessResources' is declared in unstable package 'org.gradle.language.jvm.tasks' marked with @Incubating
ok ill tell it to shut up
now i dont have to have a completely separate set-up to test my api 
how to make the identifier like this? namelist_player_# # replace with number
@Override
public String onPlaceholderRequest(Player player, String identifier) {
if (identifier.equals("player_#")) {
do i like substring and check last char?
yeah
or a "future-proof" (and ignores case) method is to do ```java
String[] split = identifier.split("_");
if (split[0].equalsIgnoreCase("player")) {
if (split.length < 2) {
return null;
}
int num;
try {
num = Integer.parseInt(split[1]);
} catch (NumberFormatException ex) {
ex.printStackTrace();
return null;
}
// do stuff with num
}
or you can just keep it simple and do ```java
if (identifier.equals("player_#")) {
int num = Integer.parseInt(identifier.substring(7));
}
your choice 😃
alright thankyou
Just saying this would error as you're checking the length after attempting to get the string from the array
the result array always has at least 1 element iirc
i might be wrong though
If the string doesn't originally contain an _ I don't think it creates an array. I think it nulls doesn't it?
only 1 way to find out
gimme a sec
oh it returns an empty array
none of us were right 🥲
wait
lemme see actually
👍
nvm it returns an array of size 1
i put in "" and it returned [] so I thought at first that meant empty array
It would still output array index out of bounds right?
no, because i check the length
that it's at least 2
Oh ok. Maybe I'm thinking of something else then.
possibly
🤷
You learn new things every day 
Maybe a shot in the dark, but anyone know what could be wrong here? https://github.com/PikaMug/Quests/issues/2042
Get them to run /papi dump when the server is running and the issue is happening and ask them to send the generated link. Also ask them to check at the same time if /papi parse me %player_name% returns the player name or returns back just %player_name%
So, what new careers are ya'll picking?
We aren't even needed for debugging anymore
But who is going to debug the chat ai?
It will debug itself
professional clown
Good thing I'm already very good at that so I will get a job pretty easily
Same
I'll ask it how to cook meth.
java: getDurability() in org.bukkit.inventory.ItemStack has been deprecated
what does this mean
i have three warnings like that
deprecated means do not use soon to be removed
if you wanna get durability get it from ItemMeta
specifically Damageable
so ((Damageable) ItemStack.getItemMeta()).getDamage()
ofcourse do your checks before casting
fixed that but now when building the maven file into a jar i get "Unsupported class file major version 61"
what version of minecraft are you attempting to build?
1.19.2
im converting it from 1.8 to 1.19.2
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev.magicmq</groupId>
<artifactId>captcha</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Captcha</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.magicmq</groupId>
<artifactId>rappu</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<defaultGoal>clean package</defaultGoal>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<finalName>${project.name}-${project.version}</finalName>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>${project.name}-${project.version}</finalName>
<relocations>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>dev.magicmq.captcha.libs.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>dev.magicmq.rappu</pattern>
<shadedPattern>dev.magicmq.captcha.libs.rappu</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
</project>````
thats my pom
omg
how do i collapse that
that sounds like youre building it using java 18 or higher instead of java 17
are you using intellij?
yes
in project structure what language version does it say its using?
temurin 17
afaik your supposed to do clean package
where
create a maven configuration and in the command box put clean package
wish i knew how xD
see on the toolbar theres like a green triangle pointing right and theres a massive box woth a tiny arround on the right?
yes
same error shows up
nvm
maven clean?
cleaned
packaged again and same error
change maven shade from 3.2.3 to 3.2.4
dm
😮
[INFO] --- maven-shade-plugin:3.2.4:shade (shade) @ captcha ---
[INFO] Including dev.magicmq:rappu:jar:1.6-SNAPSHOT in the shaded jar.
[INFO] Including com.zaxxer:HikariCP:jar:3.4.1 in the shaded jar.
[INFO] Including org.slf4j:slf4j-api:jar:1.7.25 in the shaded jar.```
thats more detail on the shade
331 doesnt read
turns red
maybe its 3.3.1-SNAPSHOT
actually apparently 3.4.1 is latest for maven shade
i ersonslly still use 3.2.4 just cus i never updated and it support java 14 like my plugin needed at the time, i dont remember when i last of if i actually every did compile native java 17
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
maven shade not found
@proud pebble how do i download the latest shade
check dm
yeah
i updated to 3.3.0
now its giving me errors in console
[01:55:41 ERROR]: Error occurred while disabling Captcha v1.0-SNAPSHOT (Is it up to date?)
[01:58:20 ERROR]: Ambiguous plugin name Captcha' for files plugins\Captcha-1.0-SNAPSHOT.jar' and plugins\captcha-1.0-SNAPSHOT-shaded.jar' in plugins'
[01:58:20 ERROR]: [STDERR] [org.bukkit.craftbukkit.v1_19_R1.legacy.CraftLegacy] Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
[01:58:27 ERROR]: [dev.magicmq.captcha.libs.hikari.pool.HikariPool] captcha-rappu-hikari - Exception during pool initialization.
also the build gave me 3 jar files
Is there a good way to "mark" a custom item so that you can later check if the held item is let's say a special sword or a normal sword?
keep only one file
pdc
1 sec the dev is working with me rn
Cool, thanks. I thought I had to use NBT tags but it seems like you have to use NMS for that. I hope this is easier, I'll check it out 👍
It is pretty easy and it saves data between restarts 👍
just use captch-1.0-snapshot.jar
dont use the shaded one
the dev decided to just fix the plugin for me himself xD
Thanks for your input
Anyone know the reasoning for java.lang.IllegalStateException: Cannot move entity off-main, it semes to be more of a paper thing but 
seems to happen when teleporting an entity
consider not doing it off the server thread?

The rice fields
I made a freeze plugin that freezes you when you get hit by a bow but when you unfreeze it spams the message, any idea why?
public void onPlayerMove(PlayerMoveEvent e){
if(frozenPlayers.contains(e.getPlayer())){
e.setCancelled(true);
new BukkitRunnable() {
@Override
public void run(){
frozenPlayers.remove(e.getPlayer());
e.setCancelled(false);
e.getPlayer().sendMessage(ChatColors.chat("&aYou are now unfrozen!"));
}
}.runTaskLater(plugin, 100);
}
}``` (It only spams it when you try move when you're frozen then when you get unfrozen it spams the message)
look at the code, it is pretty obvious why that happens
How would I fix that
Don't put it in playermoveevent. When you freeze the player, run the runnable?
WELCOME TO THE KORM FIELDS
How to specify the dragon's head in the DeluxeMenus?
hi, i have 2 strings, hello_there_super_cool and wow_epic
i want to replace the _ with . using regex, how can i do that?
to avoid xyz problem:
full string: new AnnoyingMessage(plugin, "error_invalid_argument")
error_invalid_argument is different for every instance, im using intellij replace regex (supports captures groups)
i need all the _ in the keys (error_invalid_argument) to be replaced with .
_ as the search and \. as the replacement?
yes
but i cant just do _ as the regex cause then every single _ in my code will be replaced
i have something like this:
new AnnoyingMessage\(plugin, "(?:([^_]+)_*)*"\)
but the problem is that the capture group only returns the last match
so new AnnoyingMessage(plugin, "error_invalid_argument") will have $1 return argument
ig i could do new AnnoyingMessage\(plugin, "([^_]+)_([^_]+)"\) for keys that only have one _, and then use new AnnoyingMessage\(plugin, "([^_]+)_([^_]+)_([^_]+)"\) for keys that have 2 _, and so on
made some adjustments: new AnnoyingMessage\(plugin, "([^_.]+?)_([^_.]+?)"\) and it worked :) (i used new AnnoyingMessage(plugin, "$1.$2") for the replace string)
I'm quite new at programming, I'm wondering if a function like this is good enough. It's intended to work with both positive and negative values:
public void changeLevel(int levels)
{
// Guard clause: Level cannot be higher than maxLevel.
if (level + levels > maxLevel)
{
level = maxLevel;
return;
}
// Guard clause: Level cannot be lower than 0.
if (level + levels < 0)
{
level = 0;
return;
}
level = level + levels;
}
Unchecked cast: 'java.lang.Object' to 'java.util.Collection<java.lang.String>'
how can i fix this? i tried googling, but the problem is that i dont know what type of collectionsuggestionsObjectis, so i cant loop thru(Collection<?>) suggestionsObjectand add to a new collection
final Object suggestionsObject = onTabComplete(sender);
final Collection<String> suggestions;
if (suggestionsObject instanceof Collection) {
suggestions = (Collection<String>) suggestionsObject; // <--- WARNING HERE
} else if (suggestionsObject instanceof TabCompleteType) {
suggestions = ((TabCompleteType) suggestionsObject).getFunction().apply(sender);
} else {
return Collections.emptyList();
}```
easy solution = you cant
hard solution = lots of refactoring to make things generic so you never need Object/Collection<?>
🙃
unchecked casts are gonna be inevitable at some point down the line tho
i would suggest that returning Object is a bad idea
if you can help it
idk how to get around it
@Nullable
default Object onTabComplete(@NotNull AnnoyingSender sender) {
return null;
}```
can either return a collection or TabCompleteType:
enum TabCompleteType {
ONLINE_PLAYERS(sender -> AnnoyingUtility.getOnlinePlayerNames()),
OFFLINE_PLAYERS(sender -> AnnoyingUtility.getOfflinePlayerNames()),
WORLDS(sender -> AnnoyingUtility.getWorldNames()),
BOOLEAN(sender -> Arrays.asList("true", "false"));
private final Function<AnnoyingSender, Collection<String>> function;
@Contract(pure = true)
TabCompleteType(Function<AnnoyingSender, Collection<String>> function) {
this.function = function;
}
@Contract(pure = true)
public Function<AnnoyingSender, Collection<String>> getFunction() {
return function;
}
}```
i tried having 2 onTabComplete methods, but it doesnt work since they both have the same arguments
i think i got around it
after getting suggestions, i loop thru them to filter, so i just check if suggestion is string when filtering:
// Get suggestions
final Object suggestionsObject = onTabComplete(sender);
final Collection<?> suggestions;
if (suggestionsObject instanceof Collection) {
suggestions = (Collection<?>) suggestionsObject;
} else if (suggestionsObject instanceof TabCompleteType) {
suggestions = ((TabCompleteType) suggestionsObject).getFunction().apply(sender);
} else {
return Collections.emptyList();
}
// Filter suggestions
final List<String> results = new ArrayList<>();
for (final Object suggestion : suggestions) {
if (!(suggestion instanceof String)) continue;
final String suggestionString = (String) suggestion;
if (suggestionString.toLowerCase().startsWith(args[args.length - 1].toLowerCase())) results.add(suggestionString);
}
return results;```
is there a better way to do this?
An interface is the obvious one that springs to mind
Or in java 16, sealed class + records to replicate an ADT which will keep your type safety
using java 8 so interface it is ig
sad
But yeah interface which your enum and a class wrapping a collection both implement
oh and then the interface has a method to return a collection<string>?
Yes, taking the sender as an argument
Alternatively, just make onTabComplete always return the Function<AnnoyingSender, Blah> and just use ignored -> collection for when you don't care about the sender
but then if you think about the design more, why do you even have 2 separate functions? just make onTabComplete return a Collection all the time. if you want some pre-set completions, just make them static methods
ye i was thinking about that, but it's just a ton more user-friendly to use a enum
is it really?
either type either type
return TabCompleteType.ONLINE_PLAYERS; vs return Completions.onlinePlayers();
seems exactly the same to me
ok ye imma just do that actually too much pain
KISS
my ass
:O

ban ban ban

hell, it seems like your TabCompleteType entries don't even need the sender
ye they dont but i had it there in-case i added some in the future that needed it
future-proof
future-complicating
what nooooooo
at least u didnt point out that all the tab complete types are just static methods
theres nothing inherently wrong with that
static is fine as long as you're not mutating things or (arguably) pulling dependencies out of nowhere
no ik but u were telling me to just have the user use static methods lmao
yeye and the enum was already doing that so the enum was basically just an alias to the static methods 💀
yeah i did say that lol
oh
.
if you want some pre-set completions, just make them static methods
heh
Hey, I was wondering, is it possible to join a server with same Premium account? Is there a way like changing the UUID of first player? Can you @mention me for the answer? Thanks
Is there now a Source Code dor Deluxemenues?
no
there isnt a public source code, but there is a private one that i assume is only owned by the deluxemenus devs
🤦 why does minecraft use byte when you set a boolean
Annoying because now my boolean turns into a byte and my getTag methods will return a byte instead of a boolean and error. sigh
Because thats what booleans are?
technically aren't booleans a bit?
but since java can't store them it's represented as a byte since it's the smallest datatype
Yeah but on return of a NBTTag it returns as byte rather then true or false. So broke shit and had to debug for a few hours lol
i assume there's like a getBoolean method though
there is but since putBoolean makes it a byte my methods weren't checking for that
therefor it is your fault D:
never said it wasn't lol
Annoying because now my boolean turns into a byte and my getTag methods will return a byte instead of a boolean and error. sigh
never had this issue come up before so never noticed
hi i need help with some dependency importing thingy magicy stuff
so i have a method in my api that accepts TextChannel as an argument, TextChannel is from discordsrv
the api imports discordsrv (not shadow bc if i shadow it includes like 30 other things, and some cant be excluded cause they weird), but the plugin using the api doesnt import discordsrv
when i try to use a method with the same name as the other one, it doesnt build:
class file for github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel not found
public void send(@NotNull TextChannel channel) {
DiscordUtil.sendMessage(channel, ChatColor.stripColor(getMessage()));
}
public void send(@NotNull CommandSender sender) {
send(new AnnoyingSender(sender));
}```these r the 2 methods, im using the 2nd one in my plugin, but the 1st one is causing the error since the plugin doesnt import/compile discordsrv (even tho im not technically using the first method)
are you trying to relocate discord's srv relocation of JDA?
no
i just want a plugin using my api to be able to use send(CommandSender) without needing to import discordsrv
oh shoot you made discordsrv?
omg what no??
that was me
can you rewrite it in haskell please or at least make haskell api using ffi
YES!
working on it
I have actually done the latter before
but it's awful
and needs JNI
so literally triples development time
oh wait nvm lol
do u know how to fix? :(
JavaHaskell3 with Panama FF&MI when
soon
but not that soon
because it is a painful experience tbh
even getting 2 stub files to compile is irritating
anyone?
this is another reason why you should be publishing your api as a maven artifact rather than just a jar file
the easy fix is just depend on discordsrv too
but if your api used a proper publishing system it could expose dsrv as a transitive dependency and it'd be added automatically
it does... it uses jitpack :/
the jar file is just for server owners
okay are you actually depending on it with maven?
not maven ew, gradle
add the java-library plugin and use compileOnlyApi for discordsrv
what does that do?
didnt work, still getting:
class file for github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel not found
in my plugin thats using my api
i made it use jar file to test
and also because that should be a bump version anyway
...
what would that not work
this is another reason why you should be publishing your api as a maven artifact rather than just a jar file
jar files do not hold dependency information
r u sure this will work? i dont wanna make a release and it no work
it's already not working
hardly gonna get worse
also
you dont have to make a release
oh true
💀
all jar files contain is classes, resources and possibly a manifest which usually gives you no information
Could not find com.discordsrv:discordsrv:1.26.0.
probably need to add the repo
i think there's some way of making repositories transitive too but idk what it is
ughhhhh
is there no other way?
.
i tried googling but i couldnt find anything :(
okay
i can do absolutely nothing with that information
but it is literally 1 line to add the repo so hardly a big issue
2 :(
its just annoying cause not all my plugins r ever gonna touch the send(TextChannel) method
only 1 of my plugins currently do actually
ill just remove the method actually, it only runs one line which can be easily done by the plugin, just unfortunate
make a separate optional module then
whats that?
a "subproject" that can have different dependencies
https://github.com/knightzmc/mittenlib that's what i do
then you only add the dependencies you want
@cinder forum lol

but if the plugin doesnt have the discordsrv dependency, it cant use send(AnnoyingSender)
separate optional module
you have a base with the no-dependency stuff, and another module for the dsrv stuff
would that mean 2 separate AnnoyingMessages?
no?
Modernity
look at this
😠
yeah i love buzzwords
core module has all the base stuff, the papi module has papi-specific stuff, papi module depends on core module
if you only want base stuff, only depend on core module. if you want both, depend on both
simple
but the different modules wouldnt have different classes
only a different method inside of a class that everything else is the same in
yeah thats not really gonna be possible without some hacks
hacks that are not really worth the hassle imo
ok
also hacks that i would not know how to do before you ask
wow bad programmer (jk)
bm do you use rust 🥺
no
If you really want to you can use a Map<MessageType, MessageSender> or something like that, then just register them in the discord module
So then you would do
public void send(@NotNull TextChannel channel, SomeObject messageType) {
messageSenders.get(messageType).send(yourCommandSender, yourMessage)
DiscordUtil.sendMessage(channel, ChatColor.stripColor(getMessage()));
}
i dont understand so im going to pretend u didnt say anything
or just use inheritance
That too
base class only has send(CommandSender)
override and add send(TextChannel) or whatever
yea i was thinking about doing that
but it'd ruin consistency and just be weird
How would that work though if they wanted to send a TextChannel?
easiest way of doing it
In their base module
you wouldnt
yea u just wouldnt be able to
I don't think I understand what you want then lol
if you're only depending on the base module then discordsrv isnt even on the classpath
a send(TextChannel) method that can be used by plugins that have discordsrv imported
if they dont have discordsrv imported, they wouldnt even be able to use send(TextChannel)
What class is send in?
AnnoyingMessage
Can you link the project?
Where is AnnoyingMessage being sent from?
Are you creating a new one each time you send it?
no im creating a new one for each message

