#help-development
1 messages · Page 836 of 1
how
how do I allow aternos users to install my plugin?
you gotta submit it to their system and they will have to either accept or decline it
where can I send it?
last time I saw that feature, you had to make a server, select bukkit or paper as your server software, navigate to the "Plugins" section and there somewhere there is a button "Can't find a plugin?" or something like that
Enable the mock first
for it to be added I think I need 1k downloads
well, oof
what's your plugin?
an antibot and login/register
wow that's crazy
is this sarcastic?
appreciate it man
Cool plugin
I shall put this to the test when time's sweet embrace permits.
Poetry.
anyway, I'll add a bot attack detection algorithm today, since I had some issues with the AsyncPreLoginEvent
how will you test it, if I may ask?
just put it onto some testing server, join, check configs, maybe invite a few friends
i do i was afk at the time
?
thought so but he got me to fix it
you missed the fact of enchantment storage meta and you always set the cap instead of only setting when its higher
im p sure i fixed that like 2+ hours ago
kekw
outdated moment 
gotta change it in the prepare event too
Increaste the cap
Imagine player having netherite axe with sharpness 100 and with strength potions
I did the maths and it would require 1.000.000 sharpness 1 books to reach that
884.736 Sharpness 5 books
lol
why does AsyncPreLoginEvent return ALLOWED even if the player's join is disallowed because of a ban?
preLogin is before teh actual login so no ban has been checked yet
would anyone know why i can't inherit the ItemBuilder class? nothing inside of it is final, so im not sure where this error is coming from
in kotlin classes are final by default, you need to mark it as open (open for extension)
ah ok tyvm
does everything within it need to be open, or just the class itself?
the error doesnt go away but i can't tell if it's just an ide thing
Bytecode optimization
only the class needs to be open for it to be capable of extension
ah looks like an ide problem, restarting fixed the error
can I change the default unknown command message with bungeecord so I dont have to put a plugin on every single sub server?
hey, there can't be multiple players with the same name on the server right? Eg. Player1, playER1, plAYeR1
maby could work on cracked but I dont think it would work on online servers
Well, the UUID is the only really unique aspect of a player
I would not rely on the name being unique
Especially given that there are actually duplicate usernames out there, albeit being very rare
yes, so that would work? if I joined with Player1 and then playER1 would also be able to join?
I'll change my algorithm a bit to parse the parameter as a player and then compare their uuid
If you just want to select players from the arguments of a command, use bukkit's selector API
for everything else: what are you doing?
I've got a /teleport <player> command, and im checking if the command executor isn't the same as parameter name (args[0] takes in a player name)
So I should still check the UUID for that?
Yes
thanks, with that I should still pass in the UUID? xD
You will still need to check whether the player has selected itself, but that is just a simpe if (sender != entity)
how about this
You might also be able to do targetPlayer == player to upset quite a few people out there
targetPlayer.equals(player) is the best approach tho
I’d assume just returns null
thank you
works
making a teleport command is rather complicated
have to handle everything, what ifs
(teleport command with delay countdown)
Yeah, even the simplest of things become complicated when you do it properly at times
yes exactly xD
So how do you send a clickable message to the chat?
Player.Spigot::sendMessage
can someone help me check if a player is in a map from a spigot server?
im doing the map in bungee
?pmc
Redis is more effort to set up and more resource hungry for simpler projects. Bungee messaging however requires a player to be online, and there is no 100% promise that your message will be delivered, as with e.g. the player leaving
this isnt a simple project
Well, then redis is possibly better suited. You also have the benefit of being able to deal with the data on a separate thread, instead of the main thread, as with bungee messaging
Its fine, i mean u can just grab a nice redis container and get it all setup for u in principle
that is if you are using containers in the first place and know what you are doing. and it's already more than doing nothing :p
Yea, tho for anything manageable at a larger scale docker and kubernetes becomes almost an implied standard
public class CustomItemManager {
private final Plugin plugin;
private final Map<String, CustomItemListener> listenerMap;
private final Map<String, ItemStack> itemStackMap;
public CustomItemManager(Plugin plugin) {
this.plugin = plugin;
this.listenerMap = new HashMap<>();
this.itemStackMap = new HashMap<>();
}
}```
for these two hashmaps, should I find a way to combine them?
Not necessarily needed
they will both have the same keys
Then maybe yea
maybe I can combine them in like a CustomItemProvider?
Docker. Sure. Kubernetes. Overkill unless you need to really scale.
Well its not always to make it scale
Sometimes its just easier to manage and is convenient if you learnt it
Ofc if you’ve no interest in expanding your knowledge then yeah prob not sth u wna touch
What else would you need orchestration for, if not horizontal scaling? 🤔
Yeah this looks like you should create a new class for both.
What is the purpose of the ItemStack?
I mean sometimes you do it to automate installations and just if someone got a good setup of a service you can yoink it
so ive been in a little bit of a designing battle
But scaling is a key factor obviously
and it's basically the CustomItem
and then there's the implementation for the customitem which is the CustomItemListener
Max you could presumably bundle the two maps with some sort of record class
Or well their value objects
hm
Record(Listener, Item)
no ik
:>
Pair<L, R>
record does that
👀

Map.Entry<K,V> :3
yea
I kinda dont like where this is going
yes max
wdym
Packing non-data classes into a record just screams design issue to me.
Same goes for listeners in a map.
Yeah but that is just because ppl dont know "how to pass a value from one class to another"
And if they get it, they start passing around maps and come to us with impossibly convoluted exceptions
because everything is everywhere at all times.
Yeah, tho in this case a record would just act as a bundle/context object
I worked on a custom item api today
Just to mess around and see if I could actually learn something
can i see how u did ur system
But I just took inspiration from nms
like
The manager is still a thing
sounds like a good choice
I would have a few notes on this but i should def go to sleep 🙂
But using the PDC to map functionality to items is my approach as well.
I still have an abstraction layer on top that grabs the itemstack from the config based on the identifier and passes it on
I accept feedback
CustomItemManager#register(String referenceName, CustomItemConfig, CustomItemListener)
is this good
when was PDC introduced btw?
then to get custom items
the only thing which
idk if it's a bad or good idea
is that the configs will be references
wym by that lol
they're all mutable and you can edit them runtime
what is mutable?
the configs
The config data? Or the references to the configs themselves
TBh I've never seen the point in modifying and saving configs
both
they should be read-only imo
so like
This so much
yeaa go to sleep, gn sleep well :)
So like sure you can still have config values
public abstract class CustomItemConfig {
protected Material material;
protected String name;
protected List<String> lore;
protected boolean unbreakable;
That should just be an item builder
and instead of holding all the same fields you just hold meta and modify it
looks like an item builder to me
yes but it's very similiar to an item builder no?
things can extend it and have their own values like "int specialDamagePercentage"
Max have you by any chance read the items of effective java?
ive scimmed over it
I've only read like 25% of effective java and I've actually adjusted my code style around it a bit
Stuff like static .of methods
A lot of the design points illusion, I and smile point out sorta derive from effective java more or less
Now not everything but a lot of stuff
thing is it's like 600 pages
w
I'm ~150 in
does this make sense tho or nah
Haha yea, well u can find githubs with summaries
i just found the pdf on github
I dont like state inheritance
max can you read this real quick
i have it on my phone lol
but if u rly want it, sure that does work
real quick
Imma be at my grandma's house tomorrow
christmas?
am debating if I should code on my laptop or use it to read effective java
p much
Might just bring my driving school book and take notes
as I have my exam in a couple weeks

what course
it's literally just driving a car
I have some hours on the road, need to do this exam so I can sign up for more
Portugal :)
in us you can get your liscense at 16
well I'm 18
yo is there an event for when a player "leaves" a spectator target, as in when they shift out (without actually listening to the shift entity action)
great
But yeah I need to do this entire safety course so I can drive
ok maybe i will make the fields final lol
and I can sign up to 16 hours of driving before having to do an exam
Once I do the exam I need to do the remaining hours
Once I hit 32 hours I can sign up for a practical exam where I drive around
The fork that shall not be named does have some events for that
well fyi :>
is driving in ur place hard
I've got about 7-8 hours right now, my instructor's schedule is completely packed
in the US it's a lot easier
alright :3
yeah in the US it's super easy
Went on the highway in my last lesson and nearly crashed because mfs didn't let me merge lanes
there's really nothing hard about driving here lol
maybe unless you're city driving
So here is an export of my Mongo collection (kitData)
https://paste.md-5.net/iyeqimotek.json
I am having trouble after converting from using Bukkit YML configuration to store data, to MongoDB
So far i've spent 6 hours trying to make it work for Mongo (it works on saving this data, and renaming the kit tag, and removing the kit, even loading the kit works) The whole issue here is that when i call my #setUpKitEditorInv method that it won't refresh/update the inventory with the respected column of buttons.
It's very simple, when you save a kit a column of buttons (loadKit, renameKit, removeKit) buttons will be added below the saveKit button.
KitManager class methods:
https://paste.md-5.net/gevebitaha.coffeescript
KitListener (so you can understand how this is being used):
https://paste.md-5.net/jametakowo.java
MenuUtils (where i control the inventory and want to update/refresh) #setUpKitEditorInv is called in KitListener
https://paste.md-5.net/cotizogeze.java
Please help me, i don't know why this is giving me trouble, i've tried literally everything and I think it's about damn time i ask for some help on this
if(ItemStack.hasItemMeta && itemstack.getItemMeta().getDisplayName
The main thing I'm noticing is that all your code is quite coupled and hard to expand
Which in turn becomes hard to debug
Hmm, could you throw me any tips peer to peer?
How can i make it better to understand?
Im so frustrated i just want the MenuUtils to work correctly
Umm how do i make the variables for this.
im still new to this. not 100% sure on how to make variables
ItemStack item = new ItemStack(Material.YOUR_MAT);
oh wait
For your GUI you should follow a structure like this
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
I'd also go over the main problem areas and refactor them following this guide
Split your database logic up and return completablefutures for stuff
alr so. i have that for a crossbow. but the bug is whenever i click one. it duplicates
For your database, I'd make a KitLoadout object
It can just wrap all the params on the other methods but it helps to make the logic a bit simpler
how can i detect when a player sends a bungeecord command? Like any bungee command, but not any spigot command/chat message
And then you can do something like
public interface KitsStorage {
KitLoadout getLoadoutSync(UUID playerId, String loadoutId);
void saveLoadoutSync(UUID playerId, String loadoutId, KitLoadout loadout); // display name would be on the loadout object
default CompletableFuture<KitLoadout> getLoadoutAsync(UUID playerId, String loadoutId) { // You should override this and make sure the futures finish running on shutdown
return CompletableFuture.supplyAsync(() -> getLoadoutSync(playerId, loadoutId));
}
...
}
@quaint mantle
Sorry was reading the forum, im so overwhelmed. But im sure i'll be okay.
Which means you can do stuff like saveLoadoutAsync(...).thenRun(this::updateMenu)
Woow smmart
What class would implement this interface?
your mongo
and your yml reader
If you want to migrate you can read all the data from one and save to the other
I dont think ur understanding though, I eliminated the use of YML i am only using Mongo
Still it's a decent approach that lets you future-proof your stuff
Do you have time for a call? Im not 9 years old i swear. I just am having a lot of trouble understanding, and i've had it with staring at this code.
u should suggest what luckperms did with theirs
I think it's pretty nice how they handled their data
uH it's like 3am so I might be quiet
thats fine, ill add you
Give me like 15 mins
Sweet!
interface - StorageImplementation
class - handles async stuff and exceptions with the StorageImplementation
Yeah that's basically what we're doing here
so how do i make a right click event
Added you just ping me when you are ready
Listen to InventoryClickEvent and e.isRightClick() i think
@EventHandler
public void InventoryClick(InventoryClickEvent e){
}
alr
their u go that should help
can i change e to FireClick?
lol if you wanted to but its just a variable so it doesnt matter
Yeah i should, but i know e represents events in my code.
I mean yeah but do other people know that
yea im going to see if i can make a basic gun plugin
Great point
I believe in you
waiting for your ahh to join the call
discord about to disconnect me at any second now
Well u said 15 minutes, pardon self. Joing now
thanks, 2 things.
How do i cancel a crossbow shooting a arrow
and how do i make the particles shoot/damage
does anyone know why i can do if() thing; while() thing; but not catch() thing;
or create particles that do that i guess.
and the same with the else keyword
catch is for try statements. The correct thing is an else statement
for while statements instead of else its do
if (true) doSomething();
else doSomethingElse();
while (true) doSomethingForever();
try
throwAnException();
catch (Exception e)
handleException(e);
@wet breach this is what I mean
event.setCancelled(true)
also which button makes the crossbow shoot
I'm assuming you're new so you should learn how to find the event and register it yourself
the reason it works is because if is a statement and else is just another fancy way of doing if but allowing the if to just jump to a false boolean statement
try catch can only exist inside of a code block
because its purpose is to catch exceptions that arise
yea im new. im just trying to get a base system of code done for a plugin i want for some friends.
hm
@quaint mantle
yo illusion
what do u think of this
eh, try/catch is just terrible
@waxen plinthi am thinking of a new design lmk what u think of it
I think it would be nice if they had better ways to handle nullability and exceptions inline
so i got rid of passing itemstack completly
instead it's something maybe like this
like something to convert it to an Optional, or if you could do a prefix try? to turn something from fallible to nullable
I think switch (x) {
case throws Exception e -> …
}
could B cool
CustomItemManager#register(String referenceName, CustomItemConfig config, CustomItemListener itemImpl)
something maybe like this
But yeah Optional is also a bit limited, as its not as powerful as rust Option, Haskell Maybes or yk anything else thats properly addressing nullability
idk abt yall but i kinda like handling exceptions
yeah seems reasonable
it's good practice to, but java gives you pretty terrible tools for it
I think its also really hard to choose between null, exception and result objects at times, its not made easy to understand when to use what on a deep level
lol
yeah exactly
imagine java but no runtime exception
it was too late when null was baked into the language
Yeah
Well they want to address null partially with valhalla
Which is a step in the right direction
yk what this reminds me of
god I might need to make a jvm lang
when u get armor of an entity with bukkit it can return null
but if you set the armor of an entity u cant use null
if I could make elude target jvm that'd be sick
yeah there's a lot of inconsistencies like that
Well Max I firmly believe in minimizing the amount of null state, but null can be advantageous to exceptions as they’re way less resource intensive
ok
i wasn't even talking abt nulls
i was just wondering why java had syntax like that lol
what if I wanted to access the config in the impl
maybe I can pass in the manager within each event?
im pretty sure JDA does that
Java goofy
class FileConfigServiceTest {
@Test
void testExceptions_loadAndRegister() throws IOException {
ConfigService<TestConfig> configService = setUpNewConfigService();
assertDoesNotThrow( () -> configService.loadAndRegister(new ValidConfigWithObjects()) );
assertDoesNotThrow( () -> configService.loadAndRegister(new ValidConfigWithPrimitives()) );
assertThrows(IllegalStateException.class, () -> configService.loadAndRegister(new ValidConfigWithObjects()) ); // Loading an existing config.
assertThrows(IllegalStateException.class, () -> configService.loadAndRegister(new NotValidUnAnnotatedConfig()) );
}
@Test
void testFileContentIsCorrect_loadAndRegister() throws IOException {
FileConfigService<TestConfig> configService = setUpNewConfigService();
Gson gson = configService.getGson();
configService.loadAndRegister(new ValidConfigWithObjects());
configService.loadAndRegister(new ValidConfigWithPrimitives());
String contentOfConfigWithObjects = Files.readString(configService.getConfigFolderPath().resolve("ValidConfigWithObjects.json"));
String contentOfConfigWithPrimitives = Files.readString(configService.getConfigFolderPath().resolve("ValidConfigWithPrimitives.json"));
assertEquals(new ValidConfigWithObjects(), gson.fromJson(contentOfConfigWithObjects, ValidConfigWithObjects.class));
assertEquals(new ValidConfigWithPrimitives(), gson.fromJson(contentOfConfigWithPrimitives, ValidConfigWithPrimitives.class));
}
}
am i doing unit testing correctly
no
Your tests are arguably a bit too complicated almost
Or well not complicated
But like
You do a ton of shit in ur unit tests
yea
I reckon you could mock some of the logic
With…. mockito ⭐
first one is making sure it's throwing proper exceptions and second one makes sure the saved contents are correct
idk what mocking means
Hey can you please just send me those classes so i can have them as reference?
can someone explain how Gradients Work/ what they are and what an implementation would look lik
most of the resources I found on line just use AWT which really doesn't explain a lot as its abstracted behind API
You are simply performing a linear interpolation for each RGB color
In short, yes
You can have a gradient going over multiple colors in the spectrum
So you'd need to interpolate between each color for each character
For example, if you have 3 colors, you divide the string up in 3 parts
Bro what time is it for you
6:20am
Did you even sleep
yeah but how do you get the color transition effect
what sort of math is it
wtf is an interpolate lol
start + (end - start) * progress
ahhh
where I can ask for a price of how much it would cost me to make me a plugin from 0 of some minigame.
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
yes
hey guys
is this code good or a fail
`public class RightClick implements Listener {
@EventHandler
public void ClickEvent(InventoryClickEvent FireClick){
FireClick.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.WHITE + "M4A1");
FireClick.isRightClick();
FireClick.setCancelled(true);
}
}`
?tryandsee
ahhh I just realized xD
lmfao
?
?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.
https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
write some actual code yeah
it was ment to be.
wait so how do i check the meta data
?pdc moment
facts
so how would i make it so i can check metadata.
then find the display name and cancel event
im still new to this
i read the post
how do i create a tag tho. still new im not 100% sure and the code the guy showed i didn't fully understand
I know that, but I never knew why it is so, do you know why
Like why is it returning a clone and not directly the ItemMeta of the item
🤷♂️ I suppose the rational is you mass commit the changes to NBT, but that doesn't hold for Bukkit Item Stacks
hey yall, whenever i use this code to give a item. it doesn't show errors but instead everytime it gives you another crossbow when you try to remove one.
this is the code i used
`public class ClickEvent implements Listener {
@EventHandler
public void ClickEvent(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();
if (e.getView().getTitle().equalsIgnoreCase(ChatColor.RED + "Extreme Gun System"))
e.setCancelled(true);
if (e.getCurrentItem() == null){
return;
}
else if (e.getCurrentItem().getType().equals(Material.BOW))
if (e.getView().getTitle().equals(ChatColor.RED + "Extreme Gun System"));
player.closeInventory();
ItemStack arrowItemstack = new ItemStack(Material.ARROW, 1);
ItemStack item = new ItemStack(Material.CROSSBOW);
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(ChatColor.WHITE + "M4A1");
itemMeta.setUnbreakable(true);
CrossbowMeta meta = (CrossbowMeta) item.getItemMeta();
meta.addChargedProjectile(arrowItemstack);
itemMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
item.setItemMeta(itemMeta);
player.getInventory().addItem(item);
if(e.getClickedInventory().getHolder().equals(player)){
return;`
?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.
sorry if it does. but it gets the job done. so ima just test and make sure i got a baseline system backbone
Multiple issues:
- This isnt python. your if statements are totally wrong.
- Duplicate if statement: Checking if title is "Extreme Gun System" twice. Also equalsIgnoreCase doesnt need the chatcolor.
You arent evening removing a bow, so i dont understand why you expect it to be removen
It doesnt get the job done
your if statements make no sense
oh
so.
thats the issues
ima test 1 thing then take ya advice
wanna see if this wokrs
works*
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
this is how the if statements work in your case
the arrows show, what code gets executed if the if statement is successfull
the other code just runs without any if statement
the indent makes no sense
wait
the last if statement
doesnt execute anything
you might want to use {} more often.
i was going to do plugin in 1.20.1 and i was find paper-plugin.yml... what this
a little confusing
won't there be any bugs because of it?
?whereami
oh yea i 😅 forgot
Compiling Kotlin stuff with Maven and a lot of libraries is getting slower by the day lmao
And my pc isn't even bad
I might try to switch to gradle at some point, maybe that'll speed things up
Actually it's just the first compilation of the day that's slow. Doesn't make it less weird though but ok
java -DIReallyKnowWhatImDoingISwear -jar server.jar -nogui
SEVERE: D is not a recognized option
for flags id take a look at aikar flags docs
java -Xms1G -Xmx1G -Dlog4j2.formatMsgNoLookups=true -jar -DIReallyKnowWhatIAmDoingISwear "%p%" nogui
server.jar
its just my script that searches for the spigot jar to launch, so I don't have to change my script for server jar name changes
@echo off
if NOT exist "plugins" mkdir "plugins"
@echo Updating GroupManger...
copy /B/Y P:\eclipse2020-workspace\GroupManager\target\groupmanager.jar plugins
@echo Updating Regen...
copy /B/Y P:\eclipse2020-workspace\Regen\target\Regen.jar plugins
@echo Updating Planter...
copy /B/Y P:\eclipse2020-workspace\Planter\target\Planter.jar plugins
for /f "tokens=*" %%a in ('dir spigot*.jar /b') do set p=%%a
if defined p (
echo Starting Server... %p%
java -Xms1G -Xmx1G -Dlog4j2.formatMsgNoLookups=true -jar -DIReallyKnowWhatIAmDoingISwear "%p%" nogui
) else (
echo No Spigot found!
)
pause```
so I can drop whatever server jar in to test
im trying to do this https://wiki.helpch.at/piggys-barn/java/hot-swapping
and its giving the same error but with x instead of d
I've never done it but it sounds like you are tryign to add a launch command to the VM options
Debuggers are amazing
I don't know why a random error ocurred when I tried compiling maven and then just every spigot class got unrecognised in intellij:
mvn clean
nothing is working even clean will not fix it, I tried deleting .iml and .idea but still it gives me this error
also in other maven projects
what is start_server.command or start_server.bat
iont get where it is
It's in your server directory ig
in my project folder?
why are you not doing IDE as a local debug server?
how
option 3
ok
I fixed it by just deleting /.m2/org.spigotmc-api and then reinstalling it
I sure hope not
Can anyone advise on the best way to update countdowns in item lore for example you see it on auction house plugins, the lore updates dynamically every second? I creating runnables feels wrong for this especially if there’s a ton of items
You could have one runnable looping through all items but that doesn't sound very convinient either
Yeah sounds messy, trying to find a open source plugin that does it just to get an idea
If you store an item in a list and then add it to an inventory and update it in the list does it update it in the inventory or does add create a copy?
It should update
From what my java knowledge tells me
I can't remember if it's a copy or a reference
I can't either, but ig you could just try it or assume
I'd test it but I'm in bed and it's comfy.
Oh lol
For such cases I have vnc running on my laptop and on a vm too, so I can test things from my phone
I could do that. Idk if they already have the code for an AH they could just test it easily
im doing stuff with guis and i wanna get players input but anvilguis are limited to how much text you can have in them and chat wouldnt work for bungee, is there anything else?
book and quill?
You could use chat with bungee if you wanted to
any ideas?
You'd need a runnable
.
^^ this or just loop the inventory
Some actions do copy the item so it might be worth looping inventory
if the player does not interact with it, it stays, if he does, the one in the list is just a clone.
I learned this the hard way
Does it get cloned if you cancel the event?
that is something that i didnt try out
what i did to fix it is use
?pbd
?pdb
ah
?pdc
?pbc
yes
that
so i used persistentdataholder to give the item a UUID
and then looped trough the inventories to update
And that is why you don't embedd someone's webclient in your software.
really?
So long as it keeps workgi
I think they're making some changes to their client GUI
so they can no longer support older systems
why tf are you still on win7?
It's Elgar, he has a special right to
yep
Hello everyone,
I am searching for a way to let players from every version (maybe every 1.20.* version) connect to a spigot server with a plugin. I think I have to use packets, but I am not sure how... I do not want to rely on any other API than spigot / nms itself for security reasons.
I think I have to use packets
That is a ... rather optimistic guess
There were cases where Spigot MC plugins got compromised...
If you want to do it yourself you'll need to convert every packet yourself
Then build from source?
Yep...
Why every packet?
Because every packet has a use somewhere
I want to understand it myself and not just use a blackbox
You can always read the code yourself
I thought it might be something like a join packet and a server kick response or smth
It's like translating english to french. You need to be able to translate every word, not just "Hello", "Goodbye" and "Food"
Haa I really have NO overview about it, there are too many classes and I cannot just click through every single of those...
So, what if a player wants to break a block? Here too the packets have slightly changed over time. Even if it is just a change in IDs
Writing it yourself won't be much faster
OH soo you mean the protocols change with every version? that the client cannot recognise older/newer ones? that's a another problem then
Yeah?
I didn't know, then it is out of my matter xd
I thought there would be similiar / identical ones for basic things like login, because there isnt really much to change from version to version
They don't change drastically yes, but noticably enough that you can't just plug and play
Again it is much like french and english. Many words are the same, but over time those two languages diverged so much that they aren't compatible [though here my comparision falls apart because french is latin and english germanic, but you get the drill]
sad
yep, then I have to rely on people that already bothered with it
I really thought that it could be easy-going... seems like I have to use protocollib / viaversion... do you have any record on their performance on a server? are they raising cpu load or anything?
They're good enough
ok, thank you
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
they really are not
don't you dare use protocol lib
packet events is the way
but they still won't be able to process different client to server versions without via version
How would i go about making a specific item unmovable in the player's inventory?`This is my code currently but the event doesn't even get triggered
System.out.println("MOVED");
if (Objects.equals(CreateBoard.gameState, "RUNNING")) {
System.out.println(event.getItem());
if (Objects.equals(event.getItem(), PlaceVillageBlue.get())) {
event.setCancelled(true);
}
}
}```
Another option I tried was InventoryClickEvent which would be:
```public void InventoryClickEvent(InventoryClickEvent event) {
if (Objects.equals(CreateBoard.gameState, "RUNNING")) {
if (Objects.equals(event.getCurrentItem(), PlaceVillageBlue.get())) {
event.setCancelled(true);
System.out.println("Cancelled");
}
}
}```
Still, both options don't seem to work. The first doesn't get triggered and the second one makes the item duplicate itself when picked up and it's movable with shift-clicking and also hotkeying.
Anyone knows what I've done wrong?
can I change the default unknown command message with bungeecord so I dont have to put a plugin on every single sub server?
InventoryMoveItemEvent is for hoppers
when they transfer items
InventoryMoveItemEvent is fired by hoppers, not players.
You need to cancel the InventoryClickEvent and drop event.
Ah and keeping it on death
and DragEvent
Well this is covered by the click event
better safe than sorry
But cancelling InventoryClickEvent sometimes doesnÄt work
When?
That would probably be because the drag event is firing
When I shift-click it, it gets cancelled but after that I can just take it and nothing happens
Same with hotkey
Are you in creative
yes, why?
I havent cancelled this event in a year or so. Im pretty certain that cancelling the click event will completely the drag from being initiated.
Creative is client handled mostly
So there is an InventoryCreativeEvent to try
Yea, i jheard of it
ah yeah player inventory and creative mode
But otherwise creative breaks every inventory shit
That's a pain
since the BanList is not thread-safe, how can I asynchronously check whether a name is banned?
I cannot do it sync, since it's in the AsyncPreLoginEvent
and the PreLoginEvent is a menace to performance
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
so I guess blocking the User Authenticator thread is fine because a new one is created on each join?
Yeah you can load user related data there for example.
Or check if someone is banned. Why are you trying to access the BanList there in the first place?
I don't want to register the join attempt into my system if the user is banned
Can’t you even read off it?
what?
I mean, sure it may not be 100% up to date
Async reading
But usually even in a concurrent environment reading should be 100% fine
have any of you ever worked with HashMaps?
Yep
A bit dangerous, but as long as you aren't iterating it shouldn't be too bad
No, pls explain to me what it does
I’ve implemented a couple as well in java
This btw :)
Anyway I wasnt sure if you were talking about the existing banlist or ur own, custom one
You just may need to take a few precautions to make sure that you actually obtained the right entry in case the hashmap is getting rehashed when you obtained the value. But I think that should be rather easily possible in your case
If its ur custom one, then its pretty fine to just load relevant data in APPLE from ur database or so
*PS: BanList is not a HashMap
what?
yeah, and if you use concurrent hash map then you’re basically gucci ganging
1.20.2
Yeh the StoredUserList is backed by one. Doesnt mean you can infer thread (un)safety from it
Or you know, if the banlist is a singleton: Just sneakingly change the value of the map on the main thread via reflection or unsafe
so the 1% of all situations
Here is the main problem. Even reading might trigger a bulk operation.
This means reading cant be done async. (Which is usually the case for normal HashMaps)
yeeee
I knew I once found a problem with this
never actually got the error, but that doesn't mean it can't happen
Yeah then you need to read via reflection, at which point you might as well use reflection to make it thread-safe, at which point you might as well use your own banlist impl (probably possible I guess?)
implementing my own banlist is a piece of cake
but I wanna remain full compatibility with the bukkit one
Or just callMethodSync and read from the list on the main thread while blocking the login for a few millis
so I guess I'll just have to forcibly synchronize them
Well I was talking about also registering it to bukkit and substituting bukkit's banlist with it
btw, since a few big boys are already here
how can I intercept the incoming connections, even before the async pre login event?
Just inject your own list with a concurrent hashmap instead 🙂
oooo
But mah unsafe hackery
Yes. And then get the value of the map
In the handshake. But there is not a lot of useful information coming from there.
Or just dont use bukkits banlist at all
You probably need unsafe and not reflection though, given that it is a final field
And have ur own system
but how could I listen to it?
I only need the name and ip
You'll only get ip in the handshake iirc
Spigots earliest event is the AsyncPlayerPreloginEvent. Everything before that needs a packet listener or earlier interception on a proxy.
and the name in LoginStart?
I'll do the second one
or I'd do if I knew how to hook it up
can anyone lend a hand?
Isn't that AsyncPlayerPreloginEvent?
nope
when is that handled then?
I tested it
after the Encryption begin
so I think at the very end of the LOGIN phase
Technically you can look up name via uuid
is it sent in the handshake?
W mojang api?
my plugin aims at cracked servers
Ah
Well I still don’t get why you don’t just have your own banlist thingy
Why do u need to base it on bukkit
Just curious
to allow /unban and stuff to work
Oh, I mean you could just simply have ur own commands
I don't know whether it's better to
have it called sync via the bukkit scheduler
or override it with reflection
The callSyncMethod is a bit meh as its bound to the game tick loop
I tried that, but many people said they rather use Essentials and other command providers
Hmm, I see
I can add my own implementation since I already made a custom scheduler for bukkit
(or rather Paper)
but it'd still need to wait for the tick loop
If its sync, its pretty much bound to be following the game tick loop… yea
since that's how synchronization works
but a new thread is created on each user join
Thats right
blocking it shouldn't be a big problem
No it’s completely fine to block it
I mean else I really liked the others’ suggestions about injecting some CHM in it all
but yes, you could simply do that
CHM?
same thing
Lol yea
how do I add the connection interceptor?
like straight up a player requests to join
before the new thread is created
I believe u can prob inject the netty pipeline before it all happens
Or something along those lines
wouldn't it be still after the new thread is created?
also
how do I get their ip
Unsure
Doesnt APPLE have the ip stuff?
apple?
NICE
I know that
but that is WAAAAAY after the handshake
True
well the server already knows the user's address from the incoming connection
Wouldnt be very interesting for the server as TCP already has a source property, containing the sender address
but why would they even bother sending the server's ip?
how can I listen to that connection?
So the server knows from which sub-domain or proxy the client connected.
inject a handler onto the pipeline
I would probably use a packet library which already does this
Somewhere in the nms player class I assume
Handshake is a bit different as the there is no actual client yet
Ah right yeah
There you'd somewhere need to find the global pipeline of the server socket
MinecraftServer#getConnection() and there you can inject your handler into the channelfutures, stored in a field iirc
why on earth did you ping me of all people?
Quite the opposite. Though I have no experience at all with bungee, so I can only give you the advice that you just throw things at the wall and see what sticks
Do beware that not every spigot plugin can be migrated to bungee/velocity (if you make a new stack from scratch, I'd recommend going with velocity, it seems like the better option of the two. Though arguably noone will go away anytime soon)
Highly depends on what your plugin does.
Spigot is an actual game server. Bungeecord is just a proxy which routes packets from A to B.
They are fundamentally different from each other.
Basically, if a plugin interacts with the world - then it is better that it is done via bukkit, not bungee.
It says “illegal start of type”
that can probably be migrated to bungee - simply change the bukkit/spigot dependency to bungee and fix all the errors that are caused by doing so.
However, I recommend going with a solution that already exists and learning how to work with bungee some other way.
This... does IO on the main thread if im not mistake. Not sure if i would want that on my server.
Porting generally requires good knowledge of both the source system and the system you are targetting your port at
Then there is a 0% chance of you converting this to bungeecord.
This can be ported but it will lose some of its functionality.
Could u guys help me with this error? It says “illegal start of type” and if u want I can send a pic of the code
Just send the actual code
Sounds like a simple syntax problem. Send code plox
While I could help you with like the basic things (e.g. what is the substitution of X), it is a bit pointless of a learning exercise for you
What are those things u send to make the code into a grey box :0
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Especially since you will need to get accustomed to a codebase you have not written yourself. Ordinarily both a blessing and a curse, but for porting (especially between systems this different) it just is a curse compared to writing it yourself.
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.checkerframework.checker.units.qual.C;
import static org.bukkit.Bukkit.getLogger;
public class CommandExecutor implements org.bukkit.command.CommandExecutor {
@Override
public boolean oncommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("Test")) {
if(sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage(ChatColor.GREEN + "Success!");
} else {
getLogger().info( "This Command Must Be Ran By A Player");
}
}
return true;
}
return false;
} ```
In that case, just use something that already works. Programming is both easier (for people that already can do it well) and harder (for the laymen) than people expect
Which requires a very decent amount of coding experience.
As stated before: Spigot and Bungeecord are two completely different pieces of software that have very little in common.
And at what line is said error?
You are missing a closing bracket
so another 1 at the end will fix
Wait... no you have enough. Your return false; is just inside your class instead of your method.
so where should i put it?
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Just format your code and it should be obvious.
What IDE are you using.
maven
(For eclipse: Ctrl + A, Ctrl + Shift + F)
Since when is that an IDE?
IJ its Ctrl + Alt + L
i think im getting confuised
Yeah. Chances are something else does that already - especially for a problem this common
Maven is a buildtool. An IDE is the programm you write your code in - so Eclipse, IJ or VS:Code
Please don't tell me you've been using Notepad this whole time
i think i fixed the error but now i got 2 more im not familier with
me.tom.test.CommandExecutor is not abstract and does not override abstract method onCommand(org.bukkit.command.CommandSender,org.bukkit.command.Command,java.lang.String,java.lang.String[]) in org.bukkit.command.CommandExecutor
method does not override or implement a method from a supertype
Let your IDE resolve this. You didnt override the onCommand method properly.
i didnt see your message re right the code and now its fine 🙂
Is there by any chance a known bug, which makes the player see through instead of invisible when applying invisibility?
No
hey, i have an error telling me my world doesnt exist, even if it does.
here is the proof :
any idea?
its a single player world that was put here
that doesn't answer whether it's loaded
how can i load it then?
I deleted the jar on my project, I go to the lifestyle folder and compile but the jar file won’t remake its self
Could anyone help me?
if you're not already, best to just use a world manager
I deleted the .jar file so I’m trying to re compile it
like multiverse but I'm sure there is something better by now
what are you doing to recompile
run package
so if i put a world in my server files, i cant just enter it?
It worked thank you!
so how do i do it ? i dont want to use an other plugin
Load the world
bukkit.yml might have a way to load it
i asked how
Code
Do you have any documentation or smth on how to load worlds?
idk how
Use a WorldCreator and apply the folder of your world as a name
WorldCreator world = new WorldCreator(The name of the world);
Would this do it?
Ik I’m kinda in the middle on this convosation but I’m looking for a replacement of multiverse, what is a world creator?
and when i do that, what do i do with the worldCreator?
Bukkit.createWorld
but wont this create a NEW world?
I'm just wondering but
If I close the netty connection
It kicks the player out and only shows one kick out message
And if I do it on handshake it can't be spoofed with the disconnect packet
So is there no way to replace it?
Hello. We are looking for a MySQL money bridge, to save the vault eco balance to a database, and to be able to load that in a different server. Does anyone know such thing, or is anyone able to help me create this? I already found this one https://www.spigotmc.org/resources/ecobridge.94730/ but whenever someone is offline and gets money added, it doesnt save it to their data, so when they log back in it resets them to the old data
ive got the .jar file but when i put it in a server and star the server it apears red (isnt working) but idk why
it should throw an error then
usually like a giant piece of red text
on paper, its all white on spigot iirc
oh my bad
yes i found it
its having a fit about the server being ran on paper but the plugin being spigot, i thought they were cros compatible
this is the error
you didnt add the command to plugin.yml
i have
whats test.java line 11 and send ur plugin.yml
opps
it apears i have used diffrent names for the yml and the test.java line 11
silly me 😅
atleast i think its that
im gonna try it again
no its still not working
ill send that now
yml :
Land-Shop:
description: Opens The Land Shop Menu
test.java :
@Override
public void onEnable() {
// Plugin startup logic
this.getCommand("Land Shop").setExecutor(new MenuCommand());
@remote swallow
Does anyone happen to know why Minecraft custom item names infer that the text will be bold from one text to another (in the json form) when the first one is set to true, but ItemStacks don't, so cloning an item will remove the bold from the text parts that haven't set bold to true
ItemStacks also do
If you mean custom names
Because I don't really get what you're saying
If one text is given an attribute, the others will also get it unless reset or set to another
Not at all, I have this command:
/give @p iron_helmet{display:{Name:'[{"text":"Ar","italic":false,"bold":true,"color":"#d16736"},{"text":"madura de Bron","color":"#f28e50"},{"text":"ce"}]',Lore:...
and it colours the name the first way.
But when I do e.getCursor().clone() (and put the ItemStack wherever) I get it coloured the second way.
Edit: ItemStack(e.getCursor()) does not fix this issue either
Spigot or paper?
spigot api and paper server
repeat it on a spigot server
give me a sec
Hmm didn't know that
same happens
unexpected
/about output?
how do you read JMH benchmarks?
Benchmark Mode Cnt Score Error Units
RipComputer.testGradient sample 1068013 6.027 ± 0.038 us/op
RipComputer.testGradient:p0.00 sample 4.552 us/op
RipComputer.testGradient:p0.50 sample 5.472 us/op
RipComputer.testGradient:p0.90 sample 6.040 us/op
RipComputer.testGradient:p0.95 sample 7.896 us/op
RipComputer.testGradient:p0.99 sample 11.312 us/op
RipComputer.testGradient:p0.999 sample 74.240 us/op
RipComputer.testGradient:p0.9999 sample 723.351 us/op
RipComputer.testGradient:p1.00 sample 1460.224 us/op
e.g. what is Score mean, CNT etc
Depends on your benchmarking mode. Single shot? Average? Throughput?
SampleTime
@Fork(value = 1, warmups = 1)
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
Then it is the time measured for a single call on average with a random sampling strategy.
So 6.027 microseconds ber call with an median error of +/- 0.037 microseconds
(us/op = micro seconds per operation)
ahhh okay
Cnt is the Count. So how many samples there are.
what about score
mmk
p0.50 is the 50th percentile. So the worst 50%
p0.9999 is the 99.99th percentile. Showing the worst 0.001%
p1.00 is therefore the single worst measurement.
ohhh okay
so the goal would be not to have a large spread or is that kind of just inevitable
It depends on what you want to measure. Usually everything beyond the 99th percentile is disregarded as
there will always be outliers like random bit flips, other processes or quantum effects like random tunneling,
making a perfect run impossible.
If you want to measure the time complexity of a data structure or algorithm O -> n, then you need to
measure multiple times while increasing n, where n is ususaly the number of elements.
So for measuring
n=1 -> 2ms
n=10 -> 20ms
n=100 -> 200ms
...
you detect a linear increase in time, which means the measured algorithm is O(n)
For a (perfect) hashmap contains it should be constant
n=1 -> 2ms
n=10 -> 2ms
n=100 -> 2ms
...
Meaning O(1) as O is disjunct from n
lmao n!
The most common ones are [In decreasing performance]
O(1) constant time
O(log(n)) logarithmic time
O(n) linear time
O(n^2) quadratic time
O(e^n) exponential time
O(n!) factorial time
But there is actually an infinite combination of time complexities because algorithms can be chained.
thank you
O(n^n)
my favourite
any algorithm that works like that?
Probably
shit
Every python algo: n^infinity
honestly anything e^n and above probably shouldn't be used unless their is no alternatives
Its pretty much exponential time with e being directly coupled to n.
Recursion usually results in e^n pretty quickly. Combine it with O(n) as a base like a simple iteration and you got n^n
Cant think of anything concrete rn. Probably because its so bad.
Yeah big O notation disregards smaller details, but just denotes the general behavior of a function, like n^2 + 10 is still just n^2
Which is why also time complexity is just a good way of telling how an algorithm scales, if each operation takes 1 minute in an algorithm its gonna be slow even when n= 10 and O(n) for instance
Thinking Big O of bogo sort
could someone translate to english what this ConcurrentModificationException is
https://paste.md-5.net/itiwawixad.php
You cant iterate and delete stuff at the same time
Like
list.forEach((a) -> list.remove(a))
List list = new ArrayList();
for element in list:
list.remove(element)
``` some pseudocode
something like this you think could be causing the problem?
No in for scope
This code is mostly ran async
this is in onEnable
You cant randomly access other peoples api async and pray its thread safe...
Database lookup
Nothing in spigot is thread safe unless specifically stated
Spigot is spogit
so by how I understand ConcurrentModificationException happens when you try to delete a list element whilst looping through it?
Yes
Ok hmm I'll try to think of something to fix that
You should def refactor your code. Im seeing a metric ton of repeated code.
It will make it much easier to separate what can be done async and what can be done sync.
And helping is much more efficient.
I usually just have a second list, after looping I just do firstList.removeAll(listToRemove)
There are two approaches.
Iterating using .removeIf() or creating a second collection, adding elements and removing them after the iteration with .removeAll()
for those of yall who dont understand what the code is for: I need to check if a block is natural with coreprotect onBlockBreak, instead of opening a new thread for every block I queue them up and async loop through the queue every second

Isn’t there like some sort of callback or anything more reasonable you can do rather than polling it manually?