#help-development
1 messages · Page 512 of 1
I want full integer priority
Obviously I will use Integer.MAX_VALUE because I’m important
inb4 hundreds of plugins break
lol
but yes it should
never
Tell my wife, she doesn't agree with you.
as long as nms exists it should be fine
just replace all the default ones with the custom one 🙂
can't go wrong there
Hang on imma discuss with MD about removing NMS in 1.20
Yeah just use the API for everything
With blackjack...
I don’t care if there is no api for it, use it anyway
Hello. I'm working on building a paintball plugin with different paintball minigames and I'm wondering if anyone would be interested in testing some things out with me tonight. Send me a DM 😄 Thank you so much. Any amount of time is appreciated. And afterwards, if you're interested in the project, I'll be looking for server staff too 😄
I'm trying to use this code from github in my plugin to copy and paste blocks. It throws a bunch of errors, like the things aren't being initialized correctly, and I'm not sure why.
https://github.com/TheGaming999/BlockChanger
?paste
Yeah indeed we decided to go with a packet solution instead.
There isn’t an event for when the crystal grows?
Nope
There aren't any errors in the startup log
We can implement that
wym "we"
Yeah
I'll make a jira request ig
Technically if it gets accepted into spigot it goes accepted in all forks too right?
Spam ping Choco to do it
Like they all build from spigot
Yes
Do I feel like making a PR right now is my question
👀
I don't think it's that complicated I've just never made a spigot pr myself and don't have the time available
I am interested in seeing how it would look though
Because I see a lot of .patches stuff going around and I'm interested in learning more just so busy lately
Sadly you can’t view PRs unless you have signed the CLA
I am too scared to work with patch files
seems just like I have to code java with 0 ide support
smh
wtf xD
I just rememered this, wasn't gonna go turn on a server just to get the version
spigot is all patch files, bukkit and craftbukkit are real classes
craftbukkit also has some nms patches
ohhhhh
yeah you'd probably edit a patch file for craftbukkit
That's interesting
cb is all impl of bukkit
Don't really know how that works cfully just yet
my second pr is gonna go crazy
I'ma have to edit a patch file
what for lol
It's actually no PRs on bukkit
How much testing is done on this before they get accepted?
Depends on complexity
Is it gameplay testing? Or just testcases?
In this case probably just gameplay
look at you being fancy
I assume you know this but you don't edit patch files directly
yeah I decided I'd do some jira issues
You will break things
really? I didn't know that
thats why I did not want to touch them
Apply the patches, make your changes to the actual class in your IDE
$5 pp f&f first person to submit the pr for adding amethyst to BlockGrowEvent
And then rebuild the patches
just make sure to not commit nms to stash
If you do it tonight coll I'll send you 10 🙂
you can buy nitro with that
I don't think I am allowed to take payment XD
Consider it a donation
i'm pretty sure it'd be against CLA I'd have to read over it again
donate to spigot :3
I'd do it, but I have no clue
where tf
Amethyst shits are
and I'm also binge watching Great Pretender rn
oh no you s hould sign your life away to MD5 though
its worth
yeah right lol
I see nothing in the CLA about payment
Coll see if it's allowed, if it is, I'll give you it for the pr. gtg for now
I think if md allowed payments for features, it would set a precedent.
Which I doubt he wants btw
In the CLA there's nothing about it either
it'll get done eventually
"eventually"
you made a jira report right
Yup
Oh
I know it will be done eventually
Amethyst is kinda weird
But since I do want it now is why I am offering, otherwise I would just wait
Still something that benefits anyone else using spigot and forks
I just don't have the time to go through all the learning process + cla + whatever is needed to do it myself at the moment.
dont need to learn anything for an api addition
just need to wait a day for md to inhale all your infomation
what makes amethyst so special
Well
it makes noise
Each growth state of a crystal is a new block
and breeds allays
Also the crystals themselves don't control growth
The block they are growing on does
Tf
get good?
I'm trying to use this code from github in my plugin to copy and paste blocks. It throws a bunch of errors, like the things aren't being initialized correctly, and I'm not sure why.
https://github.com/TheGaming999/BlockChanger
This is the error message:
https://paste.md-5.net/ugomicigik.bash
It's one java file, so I just copy and pasted it. Is there something I need to do to get it to work?
So uhh
This is a bit awkward but
The BlockSpreadEvent does in fact fire each time the amethyst grows
@regal scaffold
Wut
3 people tested it
It only fires when it goes to a different block not size
The size is a different block
Seriously? So blockspreadevent fires every time it grows to one of the stages
In the same location
Yes
How did 3 people test this and all say it didn’t
small_amethyst_bud, medium_amethyst_bud, large_amethyst_bud, and amethyst_cluster
Yeah
working on a new minigame system 
Gonna do more testing ig
I can show you the code I used
@EventHandler
public void onSpread(BlockSpreadEvent event) {
if (event.getNewState().getBlockData() instanceof AmethystCluster) {
Bukkit.broadcastMessage(event.getNewState().getBlockData().toString());
}
}
You would imagine that we ruled it out before deciding on packets
Output
No problem
Send pp
Idk if you can close the issue yourself, but you can edit/comment on it
Yeah I will when I get back home
I'm trying to use this code from github in my plugin to copy and paste blocks. It throws a bunch of errors, like the things aren't being initialized correctly, and I'm not sure why.
https://github.com/TheGaming999/BlockChanger
This is the error message:
https://paste.md-5.net/ugomicigik.bash
It's one java file, so I just copy and pasted it. Is there something I need to do to get it to work?
I'm looking at all the different licenses and what they mean and I was wondering if someone could clear something up for me. Let's say that I posted a free plugin with a public repo, I want to allow people to use and modify it for both private and commercial use but not redistribute it but rather contribute to the original. Is this possible, is there a license for it, do people do this in general?
No matter the license pretty much no one is going to contribute back.
Granted they aren’t likely to redistribute a modified version
Unless the original version becomes abandoned
No clue where to ask this but to post premium plugins you need 80 posts, what does posts mean? Like forum comments etc?
I believe it’s basically any post on the site
I think it matches the “messages” stat on your profile
do you know anything about my question a few messages up? thanks
That sucks, i never use the forum because i have no use for it.
I think the automatic update messages for plugins even count
Not too sure, it may not support 1.19.4
hm.. do you know a solution?
?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.
learning java is the solution? lol
obviously you don't know it
so yes, the solution is to learn java so you can fix whatever problem it has
damn you're always salty as fuck
point?
its not being salty
shhh
its expecting you to know the basics of java before interacting with an API
I wanted to see their response
so I could point out that it seemed like they came here to have someone fix their problem for them
instead of them putting in the effort
of all people, it is hilarious they chose to attempt to insult me as well 😛
It's called 'I'm not gonna sugarcoat it'
oh looks like they chose the wrong time to insult someone
seems they awoken the rest of the spigoteers
Try again at 04:00 UTC
well its only evening for me
perfect timing it seems
but I think im unable to code rn
idk if im actually able to think with this amount rn
that is alright, the person here doesn't require your coding abilities 🙂
is there a way to set an itemstack's switch duration? (like the duration when u switch to an axe)
drunk coding is not very high quality coding
you mean the delay?
yeah
doubt it, that is a client side thing
how about using nms
not sure how that helps with client side thing
*crit things
there's a lower limit
but yeah that's just attack speed on the nbt
you can't make it instant, I tried
that might be what im looking for thanks
trying to increase it lol
I didn't realize this is what they were talking about lol
yeah sorry lol
just get the meta and apply an attribute modifier
to like
decrease the speed
Im not trying to insult you, sorry. But telling me to learn java is less than helpful
but its the solutiuon
its frank and to the point
learn java and you won't have stupid issues
heyo, im playing with sqlite and read online that i could create databases if i tried to make a connection and none was found, so im trying to do that, but im getting an issue: java.sql.SQLException: path to 'C:/sqlite/db/C:\Users\...\plugins\FlareHeroes\players.db': 'C:\sqlite' does not exist. anyone know what's up? here's my method:
String url = "jdbc:sqlite:C:/sqlite/db/" + plugin.getDataFolder().getAbsolutePath() + "\\players.db";
try (Connection connection = DriverManager.getConnection(url)) {
if (connection != null) {
System.out.println("The driver name is " + connection.getMetaData().getDriverName());
}
} catch (SQLException e) {
e.printStackTrace();
}
}```
you need to create the file
basically
You're doing C:/sqlite/db/C:/Users/.../plugins
either remove the C:/sqlite/db/ or replace your getAbsolutePath with getName
you are in the spigot/java development help channel, so it is assumed you know to some degree java/programming. If you do not, then you are in the wrong channel for help on your issue. You attempted to just use something in your project and it didn't work, but the solution is to modify where it is now wrong to work with modern versions. This requires learning java, but if you don't want to learn java that is fine, but still in the wrong place then for help and instead may want to look to the services section on the forums
I don't doubt someone here could update it for you, but you would have been better off asking for that then instead of asking for help on something you don't know and making it seem like you would put in the work to fix it.
man y'all arguing over some BS
I am not even arguing
the project's outdated, just open a github issue and hope the author helps you out
It's not a basic issue like an NPE, you'd need to know a fair bit about nms in order to update this project
thanks! I'll just use bukkits setBlock method for now because I havent learned much about nms yet
there is not much of a performance difference between NMS and bukkit's setblock
plus the pain you have to go through to keep the NMS up to date isn't worth it
Thanks! thats good to know
not gonna ping but if you see this, thanks a lot
It's ok to ping
i have an interface for enchants and i want it to have a method handle() that takes in a number of different events so that when i implement it into a class i could use whatever event i want. i tried doing this with generics but couldnt figure it out anyone know how to do it?
idk if im understanding what you need but Event is an abstract class that all events extend you can take that in
i figured it out
public <T extends Event> void handle(T e) {
if (!(e instanceof StartMiningEvent)) return;
StartMiningEvent startMiningEvent = (StartMiningEvent) e;
startMiningEvent.setSpeed(MiningUtils.calculateSpeedWithEfficiency(startMiningEvent.getPlayer()));
}```
ended up with this
What is T adding
How to set an entity scale?
like their size? p sure u need modded to do that
ie. Fabric with Pehkui
I want to set an Armor stand size
I make holograms using it. If its size is 0, then player can not touch it.
setVisible(false) player still can touch
and makes them cannot interact other blocks behind
setMarker
Ohh, thank you!
I just use something like this in my minigame lib
where would i start with trying to load a jar file from a direct download link onto the class loader so i could use it, somewhat like the libraries feature
how do I synx CraftBukkit and Bukkit repositories on stash
wat
all of the new pr's are just erroring
waht is synx
like even after applying patches
I'm getting a shit ton of errors
wtf is PlayerExpCooldownChangeEvent
its giving me an error
could be my cache
no bukkit isn't in my cachewt
f
no TNTPrimeEvent nor PlayerExpCooldownChangeEvent
wtf
r u looking at the right branch
was my cached bukkit version
it was outdated
F
is there a method to change a player's attack reach
Nop that's client sided
what do I use now that ItemMeta#setDisplayName is deprecated?
This is spigot
Not paper
oh
makes sense why I thought it wasn't deprecated before
alright to the paper server I go
You can kinda do it by listening to when the player left clicks and doing a ray trace to get an entity they may have been looking at, but if they’re lagging it will be weird
i might give it a shot
ur on paper, so use ItemMeta#displayName :v
Component.text("the thing", NamedTextColor.RED) for basic text
you can simulate stuff
It works pretty well for the most part
thx man
does anyone know about ACF and could give me a hand with a problem im having?
i basically want this command: /aar (arenaID) set (option)
where arenaID has to autocomplete to a given list that for now is defined this like
manager.getCommandCompletions().registerCompletion("arenasIDS", c -> {
Collection<String> list = new ArrayList<>();
list.add("1");
list.add("2");
list.add("3");
return list;
});
and option should have a set of subcommands like this
an arena has:
- id --
- name --
.. set name "new name"
- display_name (deafult arena.name)
.. set dname "new display name"
this are some of my notes so far http://pastie.org/p/4JFLEj5QH4LGyKw9lrUpUh
Just ask away
i managed to get a subcommand to work like this /aar (arenaID option) but its not what im looking for since options where autocompleting with arena ids
this is a "solution" i found but i was wondering if theres something better and cleaner http://pastie.org/p/7LksUmUfnFOK6C21b2401H
http://pastie.org/p/50PsDF0g9pPVM30yYyh9PR this is another solution but it uses the syntax ``/aar arena set name (arenaID) (name)
found out i can just use gettargetentity and attack
https://github.com/aikar/commands/issues/392 if anyone could give a hand i would appreciate it
Hi, im having an issues with my code for paginable but i tried everthing and doesn't work fine, the out of bound is caused by the register item that has only 1 item
Code Paginable: https://sourceb.in/ZlXUuiWBCc
Code: https://sourceb.in/yamxs6BnEa
Error:
java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
at java.util.ArrayList$SubList.get(ArrayList.java:1149) ~[?:?]
at net.rosamei.alixapi.guis.gui.PaginableInventory.setPage(PaginableInventory.java:100) ~[AlixAnimations-1.0.jar:?]
at net.rosamei.alixanimations.gui.AnimationsList.registerItems(AnimationsList.java:59) ~[AlixAnimations-1.0.jar:?]
at net.rosamei.alixapi.guis.gui.InventoryConstructor.open(InventoryConstructor.java:80) ~[AlixAnimations-1.0.jar:?]
at net.rosamei.alixanimations.gui.MainGui.lambda$registerItems$1(MainGui.java:49) ~[AlixAnimations-1.0.jar:?]
at net.rosamei.alixapi.guis.gui.InventoryConstructor.handleListener(InventoryConstructor.java:70) ~[AlixAnimations-1.0.jar:?]
how would i get a LivingEntity's main hand item (i forgot)
LivingEntity#getEquipment()
EntityEquipment#getItemInMainHand() (returns a copy of that item)
np
anyone knows how to get the "name" of a http status code in php?`
e.g. 200 -> ok"
401 -> "unauthorized" etc
You can use the http_response_code() function in PHP to get the HTTP status code name. This function will cause PHP to match and apply a Reason Phrase from a list of Reason Phrases that are hard-coded into the PHP source code¹.
Here is an example:
<?php
http_response_code(404);
echo "The error code is " . http_response_code();
?>
This will output:
The error code is 404 Not Found
I hope this helps! Let me know if you have any other questions.
Source: Conversation with Bing, 14/05/2023
(1) PHP: http_response_code - Manual. https://www.php.net/manual/en/function.http-response-code.php.
(2) php - How do I get the HTTP Status Code from an Exception thrown in .... https://stackoverflow.com/questions/63297586/how-do-i-get-the-http-status-code-from-an-exception-thrown-in-laravel.
(3) How do I get PHP errors to display? - Stack Overflow. https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display.
I am currently integrating some logic in App/Exceptions/Handler.php. I would like to be able to access the HTTP Status Code on the $exception variable:
public function report(Throwable $exception)
...
according to the docs, that only returns an int or bool, not the name
Huh
Oh well
I don't want to hardcode them
Guess ur making ur own function like this then
I want to do sth like "get_http_status_code_name(404)"
Apparently it is because the codes suck ass and the error should be in the payload
I mean, I already got it hardcoded, but that's so ugly, I thought I can avoid it
Guess not
sad
java spring just has this
that's nice but I'm using PHP, not spring 😄
basically I just want to have a generic error page where I can throw in whatever http code, so I only need one file for all the ErrorDocuments in apache
using intl_error_name also just returns [BOGUS UErrorCode]
yeah I'll just keep sticking with hardcoding the status codes, and hardcoding the most common explanatins
lmao yeah this is not exaaaactly how it was supposed to work
Using IPv6 I see
Where's my HTTP response code 418?
is there anyone except kacper who still doesn't use it lol
first I need to get it working at all lol
maybe something like
(code >= 200 && code <300) -> success
...
(code >= 500 && code < 600) -> server error
...```
unless you want for each code a custom error msg
the issue is that apache's ErrorDocument directive only allows a file but I cannot pass any get parameters
what the fuck?
oh no i dont understand this stuff lol , i only done this with javascript
sth like this but I don't get it to work lol
ive never seen PHP's security landing page
someone knows a fix?
you shoudl be looping the length of items not slots
you are running out of items before you run out of slots
the slots are the usable ones
you only have one item
yes i have only one
yes
if there is only one item, what do you think happens when you ask for the next item for the next slot?
line 100
if(icons.size() < length){
for(int x = 0; x < icons.size(); x++) {
Icon icon = icons.get(x);
int slot = paginableSlots[x];
super.icons[slot] = icon;
setItem(icon, slot);
}
}
so in theory this should fix this if i put it up the code that works for multiple
did the getsrver method in bungee cord get depreciated (https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/) as its not showing up
Hmm?
Not showing up in game or in the docs
I don't think any channel has been removed
when i do this.getserver() in bungee it just doesnt know what to do with it
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
whats wrong with this?
I can do this ``` for (ServerInfo info : getProxy().getServers()){
}```
plugin has no getServer method, never has
But if it gives me warning about not being able to use that while looping over the servers
this.getProxy().
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "iso:chat");
this.getServer().getMessenger().registerIncomingPluginChannel(this, "iso:chat", this);
for (ServerInfo info : getProxy().getServers()){
}
getProxy().registerChannel( "iso:chat" );
getProxy().getPluginManager().registerListener(this, new ChatPluginMessageListener());
}```
Gradle and that version also need the oss.sonatype.org repo
Or y know, update
You can't use bungee and Bukkit in the same plugin class
Its static. ProxyServer.getServers()
You need one for proxy and one for server
This seems like you're trying to mix two
so i just need to add this in repos? maven { url 'https://oss.sonatype.org'}
huh discord sent it weird way
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Totally confused
thanks
Are you writing a bungee plugin or spigot plugin
It's unclear since your code uses methods from both
https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/ I was using this as a guide so is this the correct place to register a chat channel in bungee
the loop ignore that
I was playing with it
This is bungee not spigot
What's the messenger stuff in your paste
Bungee has no messenger
@charred blaze do what you did but with the url I gave
The wiki is outdated and gradle keeps breaking it's config
Ah so i need to register this at the spigot level?
it worked
https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/ thats confusing then
Thanks
That wiki seems to only have spigot code
You only need spigot code for the inbuilt plugin channels
?pmc
how can i check for the status of a bungecoord server
- [Sat 12:03:45 ERROR Minecraft] Could not pass event PlayerMoveEvent to SimpleScore v3.12.2
java.lang.RuntimeException: An internal error occured.
at ProtocolLib.jar//com.comphenix.protocol.reflect.accessors.DefaultConstrutorAccessor.invoke(DefaultConstrutorAccessor.java:22)
at ProtocolLib.jar//com.comphenix.protocol.injector.StructureCache.lambda$newPacket$0(StructureCache.java:75)
at ProtocolLib.jar//com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:83)
at ProtocolLib.jar//com.comphenix.protocol.injector.StructureCache.newPacket(StructureCache.java:95)
at ProtocolLib.jar//com.comphenix.protocol.events.PacketContainer.<init>(PacketContainer.java:130)
at SimpleScore-3.12.2.jar//com.r4g3baby.simplescore.scoreboard.handlers.ProtocolScoreboard.createScoreboard$lambda-0(ProtocolScoreboard.kt:27)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at SimpleScore-3.12.2.jar//com.r4g3baby.simplescore.scoreboard.handlers.ProtocolScoreboard.createScoreboard(ProtocolScoreboard.kt:26)
at SimpleScore-3.12.2.jar//com.r4g3baby.simplescore.scoreboard.ScoreboardManager.updateScoreboardState$SimpleScore(ScoreboardManager.kt:89)
at SimpleScore-3.12.2.jar//com.r4g3baby.simplescore.scoreboard.listeners.PlayerListener.onPlayerMove(PlayerListener.kt:43)
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor267.execute(Unknown Source)
at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77)
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)```
I am getting this error
Someone help
?whereami
paper
?paste
Is there any way to have basically, a open hashmap, where the UUID is a key, and the value, does this work?:
private Map<UUID, UUID> myHashMap = new HashMap<UUID, UUID>()
is there a cleaner way to write it?
Because there is only one thing in the map, I wanted to reset varibles after a event but people here said I should use a hash map instead
use a Set<UUID>
there is two varibles, player1 and player2, now both of them are hash maps
does player1 reference players 2?
No, both are seprate
It isnt recommended to reset varibles right? like, for events I add to the varibles and then unset it
reset?
make it null
what?
there is no reason for you to do it, java gc exists
I was thinking about reloading my class for spigot
that resets all the varibles, and stuff like that
if you make a new instance it's all new
no
gc is automatically invoked, its not something you have to worry about
you are throwing words at your screen and hoping some make sense
if I can get gc to reset my varibles when i need to, then it would be easy, listen, idk what happens, something in my script just does not work after you run it the first time
I cant make it dumber than "im trying to reset my class"
then stop asking random questions and show some code so we can tell you where you went wrong
?paste
We don;t need "dumb" we need precise
You asked, enjoy looking:
https://paste.md-5.net/yigaloxudu.java
lmao
variables plz
Oh, ignore thta, i mispelt
Just now when I was about to make a hashset
why you sent code which wont even compile
so this code doesn;t compile at all then
What?
I just created that now, ima delete it, regardless, my issue still stands
private HashMap<UUID, YourValueType> yourHashMap = new HashMap<UUID, YourValueType>();, seems you just drop random things you find on internet
ok now tell us what you expect to happen and what actually happens
I was following a video
I'm sorry but you were not following well
Well I was hoping that the signs and the players would reset, seems one becomes null, and one stays as it was previously, so the next person that clicks the sign is sent to the arena by themselves
see the video then talk, lmao. I kinda forgot who made the vid, but I think I get how they work.
line 144 woudl throw massive errors. Impossible to compile if (Bukkit.getPlayer(firstPlayer) == player || Bukkit.getPlayer(SecondPlayer) == player) {
you don't even have a second player variable
ok so you are trying to start a battle between two players, when they have both clicked a sign the battle starts.
Hint: my issue isnt a compilation issue lol.
Yes
the battle should only be between these two players?
yes
ok create a record with two UUIDs
record Battle(UUID playerOne, UUID playerTwo) {}```
you can put that at the bottom of your class so it's only accessible from this class
in this class you add a Set<Battle> currentBattles = new HashSet<>();
What would be in that?
when you get two players you create a new Battle passing their UUIDs
oo battles
Then put that into the Set
when a player dies you check the Set for a Battle matching the playerOne and playerTwo
that way the battle continues until one kills the other
deaths by mob or accident will be ignored
I got NoSuchFieldException: knownCommands from the code below
But what problems with that?
Object result = getPrivateField(Bukkit.getPluginManager(), "commandMap");
SimpleCommandMap commandMap = (SimpleCommandMap) result;
Object map = getPrivateField(commandMap, "knownCommands");
@SuppressWarnings("unchecked")
HashMap<String, Command> knownCommands = (HashMap<String, Command>) map;
So I put all the code into that? except the class identifiers
smthin like that?
dk what getPrivateField does, but its protected field, not private
so ?
I recommend you throw all that code away
show your getPrivateField method, we cant know how are you getting field
getPrivateField(Object object, String field)
Class<?> clazz = object.getClass();
Field objectField = clazz.getDeclaredField(field);
objectField.setAccessible(true);
Object result = objectField.get(object);
objectField.setAccessible(false);
return result;
Well there are some things I need, like, assigning armor and stuff, anyways, one thing at a time, ima try that record thing
noone actually sets smth back to not accessible
For my original code, not the class I just sent you, there are multiple events, you tolld me to add record Battle(UUID playerOne, UUID playerTwo) {} at the bottom of my main class, should the brackets in case all the code including events, im assuming no
no
Yep
Because setAccessible just overrides a flag for that particular AccessibleObject instance
I do :[
So its completely useless
Fields not being immutable :(
Ohh I see. But are there any problems if we don't set it back to false after use? Because I see people always set it back to false.
Na
Its useless practice
It can be good if u lend the accessible object to some other class where the original state is needed to be known
But like
Meh
Just do another reflective access at that point
whats it supposed to contain
all of you code is too much of a mess to be useable
Yup exactly that
im wondering how much work they'll have to remove all that old securitymanager code 
So wait, whats the point of using record in the first place
and hash with it
you have classes with annotated EventHandler methods but the class doesn't extend anything. You have Fields all over with no rhyme nor reason for having them/
aaa
There are multiple other features in battle i havnt listed
Callback hell incoming
none of the code you have posted would even compile
Wait, but what is the reason you don't make it public back? Make us easy to remove commands. Why if people still be able to use reflection to do that job?
every parameter put into it is sent to THIS and is final

wondering how much warnings there are
Its just the second player bit
@rigid otter
I restored the varible and ran build
no seriously, none of the code you have posted would even compile
if someone were to use getDeclaredField again it wouldn’t matter whether u used setAccessible(false) again
What? I just litterally ran build on it
not on the code you posted in the pastes you didn't
Ok, ill post the one that will compile
that code looks worse than the code of my fellow students
?paste
Who u talking to
Its just a glorified immutable hashmap if u wanna be realistic lol
you
isnt that what records are?
close, that code will not compile either
They’re immutable transparent data carrier by definition
Well thanks... 💀
theres room for improvement
meaning, no hidden data, no field reassignment
the hell?? do you mean compile as in it wont build
there is always room for improvement, no matter how good you are
I said to use a record as you are setting up a Battle between two players. It will only be between those two players and only ends when one of them kills the other
perfect job for a record
Ye almost
So how do I end a record?
you don't. It's a data container, thats all
so, when there is a new battle, a new record gets created
so you are having the players click the same sign to setup a battle?
does the record contain any code? or events?
two diffrent signs
[Player1] and [Player2]
why two signs?
The owners of the server requested
im not complaining tho
So how do you know who is entering a battle? are there only two signs or more?
So player 1 clicks a sign, if player 2 has not clicked, a varible is set with player 1's uuid and the signs text changes, and gets locked, when player 2 clicks the other sign, it checks if player 1 has already been set, if it has, it starts.
I know it isnt that good of a method, setting varibles
The easiest way is to have a record (let's say Battle) making reference to two players (p1 and p2), you could add two booleans (p1Ready p2Ready) false by default. And when p1 click the p1 sign, just set it to true
Same for p2
And each time you change p1Ready or p2Ready, check if both are true : if it is the case then start the game
Wait so what goes in "record"
Record Battle:
- p1 : Player
- p2 : Player
- p1Ready : Boolean
- p2Ready : Boolean
- setReady(Player)
setReady ?
A record is pretty much a POJO but will automatically fill getter and setters for you
If you're not familiar just make a POJO
I thought records were immutable
I wasa told to make a record
Ah
setReady will change the readiness state of players, and meanwhile check if both players are ready
idk, my issue is I need to reset player 1 and 2 + the signs upon the battle ending
So its the main function w both the players
Then add the signs to variables in the Battle object
So records are glorified hashmaps and objects?
bbefore I sleep
Forget records
The class i have rn is a POJO, and it aint really resetting properly
Records are POJO with automatically generated getter (and setters), but it's an abstract definition of course
Wdym by resetting ?
Why should it go back to null?
one pllayer is always loaded in the system, so if I were to click on any sign, it will just load me in the arena
thinking i am player 1 and player 2
No they are not
because it hasnt forgotten me from last time
Record components by definition must be immutable
Which is against the definition of a pojo
Set back booleans to false, and player 1 player 2 to null will work
seems ironic, my issue is resetting varibles, and a record automattically makes all inputs final
I tried that, did you see my code?
Yes that’s the point of it
I'll just check that
Idk how I feel about records
The point of using a record is so you can have more than one battle at a time. You delete the record when one finishes
Since they don’t match the naming scheme I usually use
nothing ever needs to change in a battle so a record is perfect
Only one battle can occur at a time in the arena, but being able to create and destroy a object, essentially reverting it back to its state before a battle would work perfectly
Fluent naming
Create methods like "resetBattle", "startBattle", etc. Your code is hard to read 🤣
I could use a pojo, but records are more compact
It goes against classic convention that all functions must be verbs
I assumed you were doing more than one battle as you are messing with HashMaps
Records are not meant for your usage, don't use then
js hehe
It was recomendded to me
here
I wanted to re-register a class with spigot to reset my values
and people said use a hash map

shouldve asked md5 to add :kekw:
We need more emojis
instead of 
In your case : you want one battle. So keep your structure, just add the methods I told you.
PS: don't forget to check events if the player disconnect ect
bro two people here are telling me diffrent things, ill try a pojo, and if my data needs to be immutable ill just make it final, but it makes no sense to make it fina;
bruh discord
Oh i tried
you did?
Ive suggested a lot of things mye
That's because they misunderstood your assignment
Hostile takeover!
hashmap class's could work, I could delete the class in the hashmap after thhe battle
maybe hes just a big uwu boy and thats why he let me add 
Conclure becomes the new owner of the spigot discord
I’ll get the torches and pitchforks
wanna set some new rules
Lmao coll
So, have the key of a hashset be the uuids of player 1, and player 2, maybe two items, one with the value of player 1 and 1 with 2, because either player1 or 2 could triggerr it, the value will be the class in which the main code will run, and when the battle finishes, the onDeath event will see who won, get UUID and clear that instance fron the hashset
should I use hashset or hashmap?
Oh wait, hashmap
since im having a key
go to minestom and there are record conventions everywhere
Meanwhile the spigot component methods are all in a .spigot() class
@topaz atlas Duel class is the class you need to creating, and DuelManager the one you need to use for more than one battle at a time
Both are kinda meh
who even thought about making a Player#Spigot class
They can’t
cmon man be a lil more original
You can’t have a getCustomName() for both String and Component
getCustomNameComponent()
Yes but that’s ugly
ok, ill try and make this structure for my code
strings are the best
customName();
Okay paper
minestom
Choco also didn’t want to use customName() because it’s also kinda gross
And it steps on papers toes
booo
I mean u have sendRichMessage in paper tho for instance
💀
which takes a String
Blasphemy!
🥺
you should have both methods imo
Also the fact that paper deprecated string methods is a big thing people dislike
if you want to send a raw string message, gotta wrap it in a component, nah man
So yeah spigot isn’t going to do that
Why can’t java just allow multiple methods with the same name and different return type
Smh my head
Literally trash language
what will it do if you ignore the return value
Quantum state
Next question
only way i use components now
Why do you hate yourself
also kinda nice for resourcepack messages
did you just steal elgarls sentence
It’s a reference
He didn’t invent the reference
I believe paper has said we should just use adventure

i may not see u face to face irl after this, but thats it
hmm
https://sourceb.in/w7LBUF5j9p im so confused if i run the code in the start only pick the first but the other are not loaded and with the for() in a command detect all of them
conclure wants to see me irl now
Why not
i... said the complete oppoSITE
BACK IN MY DAY all we had were strings
stockholm in fact 🙂
i can give you a const char*
Ooo
BACK IN MY DAY all we had were holes in cards
Wait you live in Stockholm
Omg do you work for Mojang?!?!?!?1
Hey, is there a better way than:
- Stop your minecraft server
- Compile your plugin
- Restart your server
For every changes you make and want to test?
/reload
Compile while you stop, time saver
place your plugin in the plugins/update folder and reload
So I still need to manually change the version in pom?
me
passing my plugin over ftp already takes long enough
Gimme your windows version
windows always complains about locks
lol
Or just run your server through ide, you will also have a nice debugger 🙂
Works on 11 too
Try harder
Hit that ctrl C at least 5 times
true bill gates
Yo did you also work at Microsoft and Valve?
Well source is in the name
It has to be open source
What’s next you’re gonna tell me OpenAI isn’t open?
x)
ProfitableAi
Sveden
How could i like fuse my plugins into one?
Okay thanks
shadow jar 👀
gradle \👀
won't work due to the plugin.yml
Oh yeah
birb
Hello do you have any idea for sync a discord channel with my plugin pls
you would have to describe in want context you want to sync
For being using for logs like when a player kill another send a message in a channel
Just use webhooks
They should be pretty easy to figure out since almost every malware out here sends their payload via discord webhooks
didnt like it
Is it possible to change the default welcoming message
like with this event : PlayerJoinEvent, i am now broadcasting the message i want to send
but cant i just like replace the default or smth like that
oh yeah my bad
bing is a piece of shit change my mind
I am attempting to give a player a random item every 15 seconds, but the runnable causes a fetal error
Code: https://pastebin.com/ZJ8ge1gy
Error: https://pastebin.com/0SvPm2jR
oh
what does your checkMaterial do?
lemme check
and getRandomMaterial
public static boolean checkMaterial(Material material) {
if(materialList.isEmpty()) {
List<String> items = new ArrayList<>(Main.getConf().getStringList("blacklistedItems"));
for(String item : items) {
materialList.add(Material.getMaterial(item));
}
}
public static Material getRandomMaterial() { return Material.values()[NumberUtils.randomInt(0, Material.values().length-1)]; }
idk, I could do that
anyone?
its part of this
oh hell cache Material.values() pls
that constructs a new array of a few thousand materials
how does one cache?
store it in a static final variable
okay
I thought java already cached enum values
it does not
Wack
https://stackoverflow.com/a/19304225 this answer is good though
like this?
static final Material[] materials = Material.values();
public static Material getRandomMaterial() {
return materials[NumberUtils.randomInt(0, materials.length-1)];
}```
or
wait
Yes
public static Material getRandomMaterial() {
Material[] materials = EnumSet.allOf(Material.class);
return materials[NumberUtils.randomInt(0, materials.length-1)];
}
Also iirc don't you not want that -1
Unless NumberUtils.randomInt is upper bounds inclusive
as long as you dont make that enumset on every invocation
smh i miss local static from c++
Yeah don't do this
It remakes the set every time
better cache that
just curious, what does NumberUtils.randomInt(0, materials.length-1) do
i just want to see
not required
If I were you
Well numberutils comes from a library I use, and the owner of the library made this
So I'd assume it is
Note that Enum#values() is an expensive operation as it creates a new copy each time you call it. You might want to cache it
I would avoid treating Material as an Enum
required? no.
enumset uses the same underlying array
so not required for what you're intending it to be required for, either
What else am I caching?
you are not willing to create a new heap allocated set and copy 10000 materials in it on every invocation
how would that even compile? an EnumSet is not an array
Discord compiles it
actually that enumset stores a long[] but same thing
Discord doesn't have a compiler
its a bit vector
I know lmao, just typed on my phone, tried to find an excuse
I would stick with static final Material[] materials = Material.values();
I just need a random item
How can i change chat format?
Then yeah this looks good
Ah so an Item
Hold on
private static final Material[] MATERIALS;
static {
MATERIALS = Arrays.stream(Material.values()).filter(Material::isItem /* Only use obtainable items */).toArray(Material[]::new);
}
public static Material getRandomMaterial() {
return MATERIALS[ThreadLocalRandom.current().nextInt(MATERIALS.length)];
}
this is how I'd do it
ofc one could e.g. change isItem to isBlock to only allow placable blocks, etc
lol
depending on what you need it for, you should ONLY consider materials where isItem is true, or where isBlock is true
private static final Material[] MATERIALS;
private static final Material[] BLOCK_MATERIALS;
static {
MATERIALS = Arrays.stream(Material.values()).filter(Material::isItem /* Only use obtainable items */).toArray(Material[]::new);
BLOCK_MATERIALS = Arrays.stream(Material.values()).filter(Material::isBlock /* Only use placeable blocks */).toArray(Material[]::new);
}
public static Material getRandomMaterial() {
return MATERIALS[ThreadLocalRandom.current().nextInt(MATERIALS.length)];
}
public static Material getRandomBlockMaterial() {
return BLOCK_MATERIALS[ThreadLocalRandom.current().nextInt(BLOCK_MATERIALS.length)];
}
That's the way
avoid the usage of EnumSets and EnumMaps for Materials
.
AsyncPlayerChatEvent, use setFormat
String format = "'%2$s' is what %1$s said";
e.g. would be 'hi' is what mfnalex said
the javadocs hurt my head, but they help sometimes
The default bukkit save is causing too much lag on my PaperMC 1.19 server, is there any alternative
bruh
auto-save
is that material update smth similar to this?
https://github.com/Minestom/Minestom/blob/e0427a36f3a5e36714530344ad0ec793e240079f/src/autogenerated/java/net/minestom/server/item/Materials.java#L7
Tried, its not that
How do you consider the save to be "laggy" ?
well ye its an interface
This also goes for biomes, attributes, sounds, potion effect types, entity types, fluids, and art
its soo confusing
kinda sucks that you cant longer use a switch then
Materials, and every other enum that implements "Keyed" will soon be similar to the Enchantment class
Something in the code is probably looping infinitely, but I am unsure of what.
I'm getting the same error and the runnable, so it wasn't the runnable itsself, it was the code within
https://pastebin.com/UHSt1AN1 > code
https://pastebin.com/0SvPm2jR > error
like this, instead of an enum
i want my own ways to implement switch alike behaviour now
ye i cannot see that
Just apply ACC_ENUM
that bytecode?
It basically converts all enums to classes
you just have to use
switch (material) {
case Material.SOMETHING ->
}
And splits material in half
ah class descriptor
Yeah. Just do compile-time transformation of artifacts where you readd the ACC_ENUM flag
still cant use an switch in the source code then
It's cursed beyond belief but should work
A lot of it is getting converted by spigot
Only issue is that you cannot use EnumSets and EnumMaps - but switch-on-enum should work because the compiler only looks for ACC_ENUM - but not for java.lang.Enum
You can use the sets
You shouldn't use them, but you can
Well you'd need to write a dedicated gradle plugin for that
to integrate with the compiler huh
That would only be possible with some runtime ASM
gradle WOOOOOO
You can't do that with maven as far as I know (I have looked into doing something very similar previously)
There is runtime ASM
im wondering why, in 2023 we are still using xml
Why don't you just get a random material from your config file material list ?
but if you then look at gradle i understand it completely
XML is not that bad. I'd rather have that than json for pom files
Honestly, groovy is a lot better once you spend the time to understand gradle.
But you really need to write two or three gradle plugins in java beforehand
its setup kind of dumb
Cause as now you're getting a random material from all items while it's not in your list....
/**
* The "I can't believe it works" map.
* It replaces every EnumMap with the ImposterEnumMap and uses a HasMap instead of an object array.
* Used so that plugins which use an EnumMap still work.
*
* @deprecated only for legacy use, do not use
*/
I think it's supposed to ensure the random material isn't on the item blacklist
I didn't want to say that
Then remove the "!" in the while loop
this was made quite awhile ago
Aw, they went the lazy route
And rename your method to "isBlacklisted"
HasMap
I thought that might be the issue, but I haven't slept in 24 hours so I wasn't sure if my brain is working
you deserve a night, you'll earn some time
A crash dummy to use, instead of the old enums which matured to Abstracthood or Interfacehood and the baby enums which are still growing.
Enums grow up
I didn't sleep cause I'd lose motivation to work on this, this is the most productive I've been in a long time
sleep is for the weak
So coffee instead
I have coffee
thats what i tell myself every night and then wake up thinking what im doing with my life
Everything else than ristretto is not what we call coffee
I think that then feel sad when I wake up at 2pm
It does though
getting up at 7am for college smh
knowing that i will waste another 8 hours of my life
You could simply filter blacklisted materials out when you make the original array
