#help-development
1 messages · Page 2071 of 1
You should be able to get the state of that block, cast it to whatever class your using (In this case Hopper) and setPowered(true) from there
How do i get and change block states
Block#getState()
Checks if its instance of Hopper
Hopper hopper = (Hopper) block.getState();
hopper.setPowered(true)
should work for any other redstone powered blocks
So... it just scans the entire world and checks for any hoppers?
Seems really resource intensive
How's it goin y'all!
Just ask your question 
Just started learning Java today. Successfully learned "HelloWorld"
Gratz
depends what you are doing, the code above doesn't scan the entire world. However if you want to do it when a chunk loads then it isn't very resource intensive especially if you get the chunksnapshot to look through the entire chunk for hopper coords
but now, if you already know the coords, then its a matter of checking to see if the chunk where those coords you have is loaded first
and then do your code thing
Is there a way to check when a dropped item is moved?
There’s no event for it, you’ll just have to keep track of what its location was and check every so often to see if it moved
Issue is doing that at scale
There’s no other way to do it
I could check when packets are fired for the item updating ig?
Only if there’s a player in range to see it move
The end goal is to track when item enter chunks
why do you need to track when an item enters a chunk?
Is this for dupe exploits?
doesn't really answer the question unless you are making a hopper interact on per chunk
Sorry I'll go into a bit more detail; I want to make hoppers that pickup all items inside of a chunk.
I'm trying to account for items that don't spawn inside of the chunk itself
You’re better off checking every item in the chunk once every x ticks
Chances are there won’t be that many items in each chunk
The problem is doing that in a survival server
What’s the problem with that?
That would have a large impact on performance no?
Right, but having 300+ hoppers that check every x would hurt performance?
Not really lol
really depends on how you code it
^
unless you have terrible hardware as it is
We’re talking fractions of fractions of fractions of a second
You don’t start to see real slowdowns until we’re talking about millions of iterations per tick
a simple hashmap is all you really need for this too, or a set
but probably better to go with a hashmap
how would checking everytime the item moves be any better?
hashmaps are generally easier to work with, plus if you have custom objects you can have those for the values
but I suppose a set works just fine
How are maps easier than sets
It wouldn't that's why I was trying to think of a better solution
We just gave you one
so you're just trying to pick up any item entity ever?
For each hopper, every x ticks check the dropped items in that chunk and do your thing
There won’t be any noticeable performance impact if you do it properly
if you're trying to do chunk-specific hoppers
make a map with the chunk and whatever storage device you want it to go to
I think I'll just check when an item spawns in, get the chunk, check if there's a valid hopper in that chunk, and make it grab all the dropped items in the chunk.
That won’t be amazing for your case where the item moves after spawning in though
There’s really no performance impact for doing it properly
it would get deleted though presumably
Why would it get deleted?
Alex is probably the one you should listen to 😛
they most likely have experience doing this sort of thing in a large scale fashion XD
hes trying to hopper it into somewhere
If an item spawns in and falls into some water and gets pushed into a new chunk that has a hopper, you’d want to know about that
But if you only check when items spawn in, you could have items that never get picked up
What I'm assuming is that he's trying to make chunks that pick up every item in them
You’re assuming incorrectly
PTSD from insane lag on clans from checking for obstructed clan spawns every so often 😅
The question was originally about detecting when items move into a new chunk
I see
Clans is the product of too many cooks in too little time building a monster
Lol
That codebase is a nightmare
I can imagine from when I've talked to timmie
Which is why I’m telling you how to do it properly
But yeah I'll probably go with that solution. Thanks Alex
No worries
Idk if I can ask a question here that's off-topic but, what's happened to mineplex?
Have there been any new developments of anything? I haven't kept up with things.
No pressure to answer or anything, I was just curious.
Java is still a thing though
Bedrock makes them a ton of money from what I've heard
Yeah
Marketplace + Kids
we're working on rebuilding the infrastructure
which is a massive undertaking
but that's getting close
Best of luck on that, Mineplex was a huge part of my childhood and I'd love to see it thrive again 😄
ayo gamers
how do ppl look at nms mappings do I have to pull out ye ol buildtools or somethin?
or is there some online thingymahjigory
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
I've never done nms and basically have borrowed code or examples for reflection so yea
im big dum
how do you remove all scores from an Objective
this is the only way i found
objective.unregister();
objective = mainScoreboard.registerNewObjective("deathCoords", "dummy", Utils.colorize("&c&oDeath Coords"));
but is it the most efficient?
@wet breach I'm still dum I just wanna see where things are n stuff like where NBTTagCompound was moved to
Unless I really have to set up a new maven project or somethin
Since were on the topic of NMS
How am I able to merge 2 NBTTagCompounds into each other? With this only the entity tag is added and theres not any other methods i notice that put compounds into
package path right
yea basically
net.minecraft.nbt.NBTTagCompound
getting a ClassNotFoundException with https://github.com/MLG-Fortress/PrettySimpleShop/blob/master/src/main/java/com/robomwm/prettysimpleshop/shop/ShopListener.java#L73
Interesting, its what im currently using but im not using reflection
tried adding nbt as I saw that in CraftItemStack but that was no dice
the proper name is net.minecraft.nbt.CompoundTag
basically everything has been moved out of n.m.s
the server packet now really only has "real" server stuff inside anymore
btw this is the data when checked in game, just doesnt add the ArmorItems field
CompoundTags can be merged using tag.merge(anotherTag)
i don't know what your "a" method is, but it's definitely not the merge(CompoundTag) method 😄
wait holdup
What the fuck is 0x20
Lowkey this is my first time im using NMS lmao am i supposed to be using the mapped version?
A space
yes 🙂
if you use remapped, you can simply recompile your code when a new version comes out and it'll still work
you won't have to change NBTCompoundTag.a(...) to NBTCompoundTag.c(...) on every new update
you can simply always use CompoundTag.merge(...)
By chance is there a blog for Gradle?
Im fine with switching to maven, just like gradle
hm I haven't seen one about gradle
there's definitely a special-source plugin for gradle too, but I have no idea how to declare that in gradle
you can also in theory manually run the remapping tool but that's a bit annoying
Yeah i couldnt find one either so i just decided to depend on the non mapped jar, but using mapped jar doesnt give that merge method but ill worry about it later and switch to maven once i get this working
here's the oraxen author trying to figure it out: https://www.spigotmc.org/threads/1-17-mappings-with-gradle.511184/
the very last post seems to have a working solution
but
it's extremely dirty and requires you to manually put the remapping tool into a folder
Yeah ill just switch to maven seems a lot easier, i cant be bothered trying to get all that working lmao
😄 yeah I guess that's indeed easier
Im just testing some things out as well, so im not even sure if im gonna keep using NMS however i did find the non mapped merge method gonna try that now
are you on 1.18.2?
yessir
yeah the method should indeed be called "a"
513:528:net.minecraft.nbt.CompoundTag merge(net.minecraft.nbt.CompoundTag) -> a
you can see the obfuscated names in the mappings file at <yourHomeDirectory>\.m2\repository\org\spigotmc\minecraft-server\1.18.2-R0.1-SNAPSHOT...-maps-mojang.txt
but as said, that method name will change on every new update so I'd really use mojang mappings instead
Yeah im gonna switch to maven rn and then retry this, ill come back when im done!
BuildTools should automtically install into my .m2 correct? Appears its not doing that for me as it tells the dependency could not be found?
Also tried just using 1.18.2 but same thing (Thats what build tools tells me it was saved under)
don't specify the api and the spigot jar
if you are going to depend on the spigot jar, you need to remove the api one, also you need the remapped jar and not just the server jar
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
I see so i need to run the remap objective with the SpecialSource plugin? Then run install-remapped-jar?
If so i keep getting The parameters 'srgIn' for goal net.md-5:specialsource-maven-plugin:1.2.2:remap are missing or invalid
Ive ran build tools already so im not entirely sure what the issue is here, maybe im just stupid but for some reason this just seems overly confusing
if you read the post from the link
it tells you how to setup your pom
to use the remapped jar
even tells you how to get the remapped jar too
if you don't already have it
ah i see i wasnt running it with --remapped my bad
Hello, i want to use BukkitRunnable, but when i define Core plugin; it's doesn't work, where do i need to define it in main ? But how ?
What do you mean by define Core plugin?
Your bukkit runnable needs a instance of your class extending JavaPlugin
Yes how can i define it to acces it everywhere ?
Okay thx i don't find it 😂
public static YourMainClass INSTANCE;
@Override
public void onEnable() {
INSTANCE = this;
}
public static void YourMainClass getInstance() {
return INSTANCE
}
You would basically create a static instance of YourMainClass (The one extending JavaPlugin) and then set its instance in the onEnable method of your plugin
From there you make another static getter for YourMainClass (Again, one extending JavaPlugin) and make it return your INSTANCE
I love you
Xd
Thanksss
public static void YourMainClass getInstance() {
return INSTANCE
}
In the onEnable ?
So in event its does work ?
Youll need to pass YourMainClass.getInstance() as the plugin argument for BukkitRunnable
naming conventions
Ok i test
wait yall dont make your instance variable INSTANCE
maaaan
yall weird
jkjk
you can make your INSTANCE -> instance if you like, typically naming conventions prefer you have your variables camelCased
But it wont effect functionality, just for better readability is all
?namingconventions
mmbruh
?conventions
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
WOW
W
bullshit
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
You fix my problem really thanks @noble lantern !
And for the commands the must opti is what one file / command or one file / categories of commands?
Can you reword that a little bit im confused
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Your asking how to put commands into plugins.yml orrrr?
?verify
example of how I do my commands
that works
Well its more down to preference
if I have a lot of commands, I generally organize them based on function
so like, if you have admin commands, I would put all the admin commands in their own package
player commands in another
however, I don't usually have a bunch of commands per-say
if you look at my example, it is actually sub-commands 🙂
technically only 1 single command in there
Oh okay
It's for security ?
no just organization purposes
most of my plugins or plugins I work on are open source
so organization is a bit important to let others easily find stuff
Interesting TileEntityMobSpawner isn't inside the remapped jar?
might have been renamed
or moved to a different spot
one of the two
it might be called BlockEntity instead
Seems so ill try with BlockEntity ty
Im looking to do a simple perm manager with groups, someone has doc to do it ?
?jd
you could also take a look at some permission plugins that are open source
LuckPerms, PermissionsX, GroupManager
all of those are open source
The most simple is groupmanager ?
indeed
Okay
doesn't include a lot of features that LuckPerms or PermissionsX does
but it is simple
hey why does my hex color code translator not work
Translator:
private final Pattern pattern = Pattern.compile("#([A-Fa-f0-9]){6}");
public String chatColor(String s) {
// Check if there is a hex in the string
Matcher match = pattern.matcher(s);
while (match.find()) {
String color = s.substring(match.start(), match.end());
System.out.println(color);
ChatColor hexColor = ChatColor.of(color);
System.out.println(hexColor+"w");
s = s.replace(color, hexColor+"s");
System.out.println(s);
match = pattern.matcher(s);
}
return s;
}
In console it shows me the right color (Color = #6B1A1A) however in chat it shows up as green. I'm using the net.md_5.bungee.api.ChatColor import
The images are attatched, the red is the console the green is the chat
console uses a different system then the ingame chat
console uses Jansi for console related things to include color
in game chat uses minecraft stuff
not sure if it will help you, but here is a color converter I did for consoles in case you need something for that 😛
cool ill look into that, is there any reason why this wouldn't work anymore?
https://www.youtube.com/watch?v=qthBRLx7zUA
Wooo 1.16 spigot! The big thing about this update was Hex color codes. In this video, I talk about how it works and code a great method for you to use in your plugins :)
Pattern: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
Need more help with this? Check out clip's tutorial on spigot: https://www.spigotmc.org/wiki/n...
Cuz I followed that
your pattern
has an extra ( after the hashtag
but you also need to ensure you are using the bungee api chatcolor
and not the bukkit chatcolor
yeah im using bungee
which is what I was saying with incorrect imports
but, yeah not sure why it wouldn't be working unless you need to use chatcomponent to do it, I normally don't mess with hex colors for chat
I just use simple colors XD
wait would using this in a chat component be the issue?
yeah I think it has something to do with the chat component cuz it works fine with normal messages
Well you found your problem 🙂
Sorry for being retarded today yall:
How would you save a CompoundTag to a SpawnerBlockEntity I've tried using
SpawnerBlockEntity#getSpawner()#load(CompoundTag)
and
SpawnerBlockEntity#load(CompoundTag)
(I didnt see any other methods for saving to a typeof BlockEntity)
And calling CraftCreatureSpawner#update(true) afterwards but none of the compound tags are saving to the Spawner?
you would have to write it directly to the chunk file
if you don't want to do that you could use PDC
?PDC
Yeah i tried PDC but the PDC container was null for it
?pdc
because PDC doesn't use nbt directly
but the game doesn't let you save custom nbt stuff unless you write to the region/chunk file directly
what do you mean it makes no sense?
So basically i would need to get the craft chunk and from there write any changes i need there? Interesting
isnt GroupManager like mega outdated lmao
the author of it is still active 😛
holy crap no way
and chats in here from time to time too
what a chad
@eternal oxide You have a fan
manuadd = manual user add
not sure how that is so difficult to understand
yeah that is his plugin
Does anyone know the formula to get the amount of xp (float) from a given level? E.g. convert 60 levels to xp value in float
levels 0-16 (experience 0 to 352)
sqrt(total + 9) - 3
levels 17-31 (experience 353 to 1507)
8.1 + sqrt(0.4 × (total - 195.975))
levels 32+ (experience 1508+)
18.056 + sqrt(0.222 × (total - 752.986))
float64 is a double just fyi
double is two floats
This is what mc uses for levels?
yes
it is the amount of experience
but knowing those formulas, you should be able to do the reverse to get the levels
right okay
updated the above to include related experience numbers
sweet thank you
Is there any methods for this via NMS, or would i have to serialize the chunk myself and save to the file there?
I read up online and read the WorldEditAPI can manage the saving of the chunk without having the need to do all of this?
Seems like awefully lot of work just to add a block to a spawner entitys head xD
depends what you are doing, I typically don't mess with NMS
I just know that the game doesn't automatically save custom stuff nor will it sometimes load custom stuff either
Custom entities are a prime example of this
this is because the game doesn't use your custom entity class when it spawns entities
entities technically die when a chunk unloads in case you are curious lol
ah i see
I know this was possible with the /blockdata command as basically what im trying to do
Is convert this command into code format to allow for a "block" to be added to a (entities) spawners head
and this does save on world unload/load which is weird
could probably just do it from the API side invoking the command
might be easier that way lol
shoot your right
hmm lemme convert this to the 1.18 command syntax i wanna try that now
Hey is there a way to add hex codes into the TextComponent HoverEvent
not sure if you can
you know what i hate myself for this
spent like all day learning nms and the command just works normally lmfao
the only downside of invoking the command is that the person needs to be opped if I recall
if your utility is for those opped anyways
then its all good
I could probably just call from ConsoleExecutor since it uses direct coords
could probably do that too
just some heads up in case you run into the issue that it doesn't work for other players 😛
I've a little question
If a speedhacker set his speed to 4 (so 0.4)
If this detect his speed hack ?
float speed = player.getWalkSpeed();
if ((speed > 0.3)) {
if (!player.hasPermission(SPEED_PERM)) {
player.kickPlayer(PREFIX + SPEED_HACK_MESSAGE);
}
}
Sounds good thanks for the help today frost i know i was sounding retarded asf most of today lmao
this is how you learn. NMS is probably the better method but sometimes it is acceptable to just do it the easy way 😛
Yeah i know damn well im not making a chunk serializer just to add a block to a armorstand spawners head lmao
tbh i could just rip the code from the MC /data command to
probably could
Uhm
Might be a little more complicated than that
but, in a sense yes but iirc speed hacks are a thing of the past
unless MC is allowing players to send theyre own speed modifiers now
there is some info on the minecraft wiki about how fast a player can run and walk. Just measure how fast they travel in a given time
So do you have a solution ?
^
tbf instead of kicking people you can just make a flag system that stores to a file and notifies admins with perms
this
and when you hop on if you get x flags you can decide what to do, if your online spectate the player in vanish
Yes i will do this but if this doesnt work usless
This is how we do things in rust 😛
yes you can make the chance lower, easiest way is heuristics. Problem with using heuristics is generating them
You can always fine tune things using your own hacked client too btw
Yep
if I ever get my primary HDD working again
maybe I will think about publishing my anti-cheat that works at the network level
20$ on spigot ez
it isn't something I can sell on spigot because it isn't a plugin
meh auto punishments are always iffy
most people wouldn't be even able to use it unless they had a router they can configure protocols into
Well you can always send you HDD to a data recovery center too but its costly
if thats whats wrong with it or if its just simple like discs are stuck
the board on it died
oh wtf
just need to replace that and it will work again 🙂
never seen that happen before you must of had that thing a long time
that is because I have a surge protector
surge protector gang
but the surge protector must have over loaded and didn't catch it in time
thus HDD died and nothing else
well, i use a laptop so it by default has that lmao
I mainly have a surge protector bc otherwise there's not enough outlets for all of my shit lol
should never hook 2 surge protectors together
this lmfao
surge protects have a certain amount of joules they will protect
Get your free wristband for early-access to the limited card pack sale 👉 https://bit.ly/3pTFkvr
My debut album "PARALLAX" is OUT NOW 👉 https://lnk.to/TFRPARALLAXYT
Listen to Infinite Power! here 👉 https://lnk.to/thefatratinfinitepower
Infinite Power! is copyright FREE on YouTube. Please credit the artists and link to this song.
Subscribe for ...
and they act as capacitors
if you hook 2 of them together, what will happen is that second one will kill the first one
but
and that second one will fry anything on that first one potentially
can I hook a surge protector into itself?
because the power will back feed
is that legal?
ah i only have my pc hooked into it
nothing else
yet
sure, but doubt it will be useful that way lmao
wym frost infinite power
This one trick makes electric companies MAD
y et nu werk?
ngl when i was like 9 i tried that and was disappointed it didnt work
when I would smoke the green stuff with some friends, it is hilarious when they think about this and suggest it without much thought to realize it doesn't work
IE make more biomes more scarce?
your friends must of been on a next level holy shit
fro did weed confirmed
I have never denied this either o.o
If this is what you mean toto, you can just listen to one of the chunk generation events and override it when a specific biome is being generated
but youll have to then generate those blocks yourself and terrain
probably for like 1.14
was lit
these updated versions of MC are a pain in terms of creating a generator
yeah i think the one i made it on was like 1.12 iirc
i never tried generating any actual terrain though
seems scary
im bad at math
I did make a plugin that generates piles of rocks though for a plugin i made
sec
i got pics iirc
ooh dats pretti
was like an adventure type game mode (Basically was remaking rust in MC)
that was my first ever map i made in uhh
that one map editor thingy
sweeet
one day I will get someone to use my color api
it technically compresses colors into ansi color codes lol
and accepts rgb and hex colors. It was made for a person who wanted it XD
but I haven't managed to have use for it for anything lmao
Hi!
I'm writing a Runnable running Async, that calls another Runnable as a Callback when it's finished, passing a Map<String, CustomClass> back to the main thread.
The intention of this is to load in a complex file asynchronously. So...
@Override
public void run() {
final Map<String, CustomClass> exampleMap = new HashMap();
// File is loaded in pesudocode:
// Loop through lines in file:
// <properties are read into variables a, b c and d>
// exampleMap.put(key, new CustomClass(a, b, c, d));
// Callback (this.plugin is passed into implementing Runnable class)
Bukkit.getScheduler().runTask(this.plugin, () -> this.plugin.callbackMethod(exampleMap));
}
// In the plugin main class:
public void callbackMethod(Map<String, CustomClass> exampleMap) {
this.exampleMap = exampleMap;
}
Is the main thread now free to read and write to the contents of exampleMap?
ngl i do wanna learn rgb colors cause that stuff seems cool
maybe ill implement it in my tinkers port
no, HashMap is not thread safe
if you want a thread safe hashmap use ConcurrentHashMap
also when loading data like this you should have a DataLoadedEvent and then handle anything from there after the runnables finished
That way your only loading things when its absolutely finished
However, you also shouldn't need 2 runnables to load a file either
regardless of how complex it is
mainly because there is utility methods in the NIO package of Java to handle such things from another thread super easily
for instance, if you memory mapped the file first, it will load super fast. Possibly even faster then your runnable there 😛
Funnily enough I just mentioned memory-mapping in #general
another thing too: Dont load every single players data on server start, youll run into issues on linux system because max file limit is 14k (not to mention the RAM youll use, oof)
Load data on AsyncPlayerJoinEvent (no need for runnable, and its blocking)
lol that is funny because I didn't look there yet when I just said it XD
and when player leaves unload said data
To correct this
Okay, so what I've gathered is that I change HashMap to ConcurrentHashMap.
This is not for loading Player data. It's for loading some user-specified information from a couple of different files.
I hear your suggestions to make this more efficient, however would the above now be considered thread safe?
On linux generally any one process is limited to 1024 file descriptors
the max file descriptor limit on linux is 65535
interesting the guy who came to me with his issue must of had his file limit set lower
But even then he had 70k unique players so it would of went over reguardless 😛
I'm a little confused here, by two Runnables I mean the implementing Runnable which actually loads the information and then a lambda that runs some callback.
depends on your custom class, but from looking at this piece of code yes
Sweet the custom class is for storage of some information
private final String name;
private CostumeHead head;
private CostumeBody body;
private int animationSpeed;
private final int[] movementSpeeds = new int[Costume.HOTBAR_SLOTS];
Where CostumeHead and CostumeBody are just enums
Only getters / setters
you can technically go higher
but in general that is the limits
Yeah indeed, you can set limit higher but at that point its likely a issue with the software because theres no need to have that many open files imo
unless your something like hypixel, but theyre on seperate machines so that solves that issue
I think on modern Linux OS's
you can go as high as 590k some odd File descriptors
but that doesn't mean a single process can make use of that many
single processes are limited to whatever the soft limit is set for and generally that default is still at 1024
Sorry to intrude again, but could you confirm for me that the custom class I posted is all good if it's just enums, ints and a String with getters/setters like shown?
Thanks man, really appreciate it 🙂
dam, is there anyway that I can add it to a straight up TextComponent?
sound like an Adventure thing
Ah so I went and looked you need to use the ComponentBuilder
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
jesus christ
sometimes i seriously question mojang
this took way too long to figure out
So i guess you cant have the ArmorItems inside the SPawnData field anymore, and it instead has to be in the entity field
all videos showed it beind outside that field, including this cool ass website: https://codecrafted.net/blockdesigner
so part of me wonders if my NMS was working and i was just putting it in the wrong field lmfao
quite possible
Ah so based on that I can’t dynamically set it huh? Like if I have a string with color codes and hex codes in it it wouldn’t work huh?
makes sense
you can use
LegacyComponentSerializer.legacy('&').serialize(yourColorCodes); // Use this in whatever component builder you want
I suggest caching the serializer
less code to write
(Event.getClickedInventory().getView().getTitle().equalsIgnoreCase(ChatColor.AQUA + "Customs Items" + ChatColor.BLUE + " Giver"))
Dont work, if someone has a solution :)
is there a good character limit to prevent text going off screen
Your using Event which is a reserved keyword for SpigotAPI
Shouldnt, it should automatically go to next line
Don't detect inventories by their name
HashMap
how
use InventoryHolders
file cache
yes
Store the File you want inside of a HashMap
and it stays cached in your HashMap
no libraries needed
just create a FileCache class with a HashMap object
oh so you want to store your cache to a file?
Event isn't a reserved keyword for spigot o.O
Are you sure? could of swore it was
Event is part of the Java API
however they are using it incorrectly regardless lol
Something like chronicles lib but that works on java 17 and doesn't use reflections on java.base
Or mapdb
What are you storing? Just custom classes?
Yes, custom classes
wellp not sure then
You could hash the json string but too much work imo, dont really see a need to store your cache anyways unless its player data or some type of data you want to store persistantly
Gson is fast wym? Unless you want to use the other lib
and serialize everything yourself
https://imgur.com/a/ZsBgxlw ehm I dont think it does
IE: I have my player data cached inside of a HashMap for my PlayerDataManager, and save it via these methods using gson serialization, you can easily do the same
Oh thats just your GUI size
its really dependent upon the client tbh
You cant get GUI size from client either, so no good way to handle it, you can try something like every 30 characters automatically add a newline, youll just have to do some testing yourself
hmm alright ty
Are you okay?
Hello my name is Dr. Mike. Do you feel a sudden urge to start and end your statements with an absolution?
right apart from that I also made this strange thing to split text every 30 chars are there like better options out there or should I stick to this java private List<String> parseWords(String sentence) { List<String> words = new ArrayList<String>(); String oldWords[] = sentence.split(" "); final int limit = 30; String currentSentence = ""; for(String word : oldWords) { if((currentSentence.length() + word.length() + 1) > limit) { words.add(currentSentence + " "); currentSentence = word + " "; } else { currentSentence = currentSentence + word + " "; } } if(words.size() == 0) { words.add(currentSentence); } else { if(!(words.get(words.size() - 1).equals(currentSentence))) { words.add(currentSentence); } } return words; }
sudden? The urge is always finally there
Yikes looks like a bad case of final abuse
hey at least im not using @NotNull everywhere like i used to
So you feel an urge to wrap your primitives so they can be final and changeable?
nah my primitives are rarely final
You can likely shorten it, but if it works it works
I use something like this for my discord bots and it looks okay
alright then ty
Java allows serializing objects into a file
not sure how much faster you want
Tho it needs to be dynamic
dynamic in what way?
I'm gonna use mapdb
you can store entire Java Class Objects into a file and then restore them so as long as they are serializable
Increasing/decresing data + to have hashing
can't get much more dynamic then that
so much work just slap it in a gson file
Mapdb
if you want
I am going to assume whatever problem you are having you are just increasing the complexity unnecessarily
I mean, if you want super fast, look into memory mapped files
can't get faster then ram
ram is insanely fast that even if you are not storing stuff efficiently you will still beat solid state drives XD
frostalf are you good with working with texture pack models by chance? Specifically making a item render as a block model?
I haven't done a recent test with memory mapping in regards to minecraft
for some reason mine just render as flat items
however the last time I conducted a test with someone, we could load something like 20million blocks of data in 6 seconds and save it in 3
so....I mean you have options lol
unfortunately no sorry. There are some people here somewhere that are though
sounds good ty ty
That's not off-heap
Gson is not atomic
Gson is slow
Gson doesn't really support hashing
Not really, I already did what I want, but mapdb doesn't use memory mapped files and then bytebuffers, only bytebuffers in a RandomAccessFile
public static void cacheKit() {
File f = dataFile;
FileConfiguration c = YamlConfiguration.loadConfiguration(f);
cachedKitArmor = ((List<ItemStack>) c.get("inventory.armor")).toArray(new ItemStack[0]);
cachedKitInventory = ((List<ItemStack>) c.get("inventory.content")).toArray(new ItemStack[0]);
}
It does the job, but RandomAccessFile it's limited to 2GB because of long typed possition and also isn't that fast
this is how i cache stuff into memory
Do that outside memory (off-heap)
😅
im not gonna cry about few kilobytes of data
How about thousands?
impossible
Possible with off-heap memory
too much overcomplicating
Again, I already did that
But Mapdb is limited to RandomFileAccess size, and Chronicles doesn't work on java 17 because of java encapsulation
where's the error in my code?
Language(final ConfigurationSection config) {
super();
for (final String key : config.getKeys(true)) {
if (config.isConfigurationSection(key)) continue;
final List<String> list;
https://jeff-media.com
if (config.isString(key)) {
list = Collections.singletonList(config.getString(key));
} else {
list = config.getStringList(key);
}
final Message message = new Message(list);
messages.put(key, message);
}
}
fun fact
that works
there is no error
it's totally fine to randomly insert hyperlinks into java code
no, for real
Hackers having fun time ey?
it's just interpreted as label with a following comment lol
yeah I was also a bit confused when I accidently discovered it
I accidently pasted a link into my code and didn't notice it for hours
then I wondered "why tf did this compile"
lmao
I always do that, I don't think it's unneccessary. it makes you stop reusing local variables by accident
aha! A fellow final user
final final? final!
hmm so im looking at this example https://gist.github.com/Mindgamesnl/b8d3540742fbddbe921a4fa587fa5daf but my trigger doesnt seem to be getting fired
yeah final is nice
final is satisfying
Also @NotNull and @Nullabe gang
only from annotations-java5
all other NotNull and Nullable break the javadocs
i used to use @NN so much it was getting unhealthy
my code is more or less ```java
public class MissionGUI implements InventoryHolder {
private MissionManager manager;
private Inventory inv = Bukkit.createInventory(null, 9, "Playable Missions");
private Player target;
public MissionGUI(MissionManager manager, Player player) {
this.manager = manager;
this.target = player;
this.setupInventory(player);
}
public Boolean trigger(ItemStack itemStack) {
System.out.println("TRIGGER");
if (itemStack.getType() == Material.EMERALD_BLOCK) {
target.sendMessage("No, you may not steal my fancy stuff. It is my only friend.");
//cancel the event
return true;
}
//dont cancel the event
return false;
}
private void setupInventory(Player player) {
// add items and open the inventory for the player
}
}```
btw this won't help you, but, you should not implement InventoryHolder yourself
Using them in APIs is good practice
it's not meant to be implemented by plugins
bruh
Outside of APIs is just bad
I scrolled up where someone checked an inventory by name and someone told him not to do that
and use inventory holders instead
eek
yeah it's fine and it'll work
but
it's not the best idea and you should much rather keep track of your created inventories and check them by ==
I also use InventoryHolders in most plugins
but once I read that in the javadocs, I stopped doing it in new plugins
well you never call the trigger() method, at least not here
Inventories should have UUIDs, change my mind
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
System.out.println("INVENTORY CLICK EVENT");
//filter out bad events
if (event.getInventory() == null
|| event.getCurrentItem() == null) return;
//check if the inventory is an instance of our menu
if (event.getInventory().getHolder() instanceof MissionGUI) {
//call teh function and hold its state
Boolean cancel = ((MissionGUI) event.getInventory().getHolder()).trigger(event.getCurrentItem());
//set the event cancelled based on the return state
event.setCancelled(cancel);
}
}```
and/or namespacedkeys
And/or creation cause
I have that too, I'm assuming its Boolean cancel = ((MissionGUI) event.getInventory().getHolder()).trigger(event.getCurrentItem());
add a debug statement like System.out.println() inside the instanceof if statement
basically replace this line //call teh function and hold its state with a debug output
good point
or just let us use inventory holders 😄
I mean, why not
it's been working fine for everyone since 10 years
Hey alex are you handy with resource packs by chance? Specifically making items render as 3d block models?
no, not really
I hate resource packs, they are so annoying to make lol
try putting it on a totem of undying, then see if it gets rendered in 3d when you die with a totem
hm no idea
yeah uhm so apparently its not an instance of MissionGUI
how do you create the inventory
oh
you sent the code
yes
you don't pass any inventoryholder to Bukkit.createInventory
you use null instead
ohh right
the example shows private Inventory inventory = Bukkit.createInventory(this, 6 * 9, "My menu"); I missed that
ty
np
yeah but wait
you can only use "this" if you create the inventory inside your inventory holder
yeah I am
tyty
why dont you just write 54 lol
I also do it like this, so you instantly see it's 6 rows^^
o
I'd rather have
2*9
3*9
4*9```
etc
instead of just 9, 18, 27, 36, 45, ...
lol
what way of client to server communication would you prefer for such a project: https://github.com/Luziferium/spotify-sessionary
IP over Avian Carriers
what does this actually do? I didn't really understand what it does exactly
syncing spotify sessions
the client syncs the spotify clients with the information given by the server
like "we all listen to this song at minute X now"
ah like watchtogether for spotify
pretty much
so either i go with websockets, a webservice or sockets. any recommendations and/or other than those 3?
@vagrant stratus good news
possibly buying a 3 bedroom, 2 bath, 2 car garage house 🙂
today
welcome to #help-development
this is just general chat for developers
ah well they will get the message either way 😛
but thanks for telling me though
as I didn't realize
too lazy to move the message lol
i just welcome him
stay here long enough and you might get jealous of a few people
<<
how many of those bedrooms are reserved for the cars?
Hello, got a problem with building my nms-dependend plugin via artifact.
Building this plugin in IntelliJ via build-button works fine. However, building it via artifact straight to the local server throws following error while running:
java.lang.ClassNotFoundException: net.minecraft.world.entity.decoration.ArmorStand
Seems almost like the remapping doesnt quite work right.
Do I have to do sth special to use mojang-mapping in combination with artifacts?
Edit: im using this version btw: 1.18.2-R0.1-SNAPSHOT
im jelous of you rn no cap
This methods broken on 1.18 
use maven to compile instead
and then read the post linked here
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
jelous
that post will tell you what your pom needs to use remappings
Im using maven: https://github.com/stitchinger/Piggyback
does someone know the "default" taskbar icon size on win 10/11? I included 32x32 and 64x64 but that looks weird
why are you using maven shade plugin if you have nothing you are shading?
you must obviously use maven to build if it's a maven project
Idk what shading is or does.... 😦
I just copied the poml stuff from the spigot website and changed the version number
Like I said, this works fine
if you want maven to copy the file to a specific location, that's no problem at all
or why do you want to use intellij to build?
But I want to build straight to local server, so I dont have to move the jar later
while true, also best to remove stuff not being used as well 😛
maven is capable of doing this
you just need to setup your pom accordingly to make it happen
maven could even cook bacon if he had arms
yeah probably lmao
Looks interesting. I try that
so what I linked is an example of how to have maven push your artifact you built to somewhere else
maven can use SSH too to do this, my pom uses ftp
that being said, you definitely should look into it and research it because it can do what you are wanting 🙂
@tender shard just some question since we've talked alot about it yesterday
serious thoughts on this?
public static void patchOpCommand()
{
try
{
Field mapField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
mapField.setAccessible(true);
SimpleCommandMap commandMap = (SimpleCommandMap) mapField.get(Bukkit.getServer());
Field cmdsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
cmdsField.setAccessible(true);
@SuppressWarnings("unchecked")
Map<String, Command> cmds = (Map<String, Command>) cmdsField.get(commandMap);
Command opCmd = new OpCommand("minecraft:op");
Command deopCmd = new DeopCommand("minecraft:deop");
cmds.replace("minecraft:op", opCmd);
cmds.replace("op", opCmd);
cmds.replace("minecraft:deop", deopCmd);
cmds.replace("deop", deopCmd);
cmdsField.set(commandMap, cmds);
mapField.setAccessible(false);
cmdsField.setAccessible(false);
}
catch (Exception e)
{
e.printStackTrace();
}
}
just smite me with it im not really happy with this method yet xD
screw it im using noteblocks now
I'd always separate the "logic" from "the intention", meaning I'd put this into a method called "patchCommands(String name, Command myCommand)". Then in onEnable, just call it for every command you wanna change
OpCommand and DeopCommand are copied from the ReloadCommand and then adapted to my needs
btw does this actually work?
yes
is the command name actually "minecraft:op"?
oh nio
the name is not revelant
the name is only relevant
when you do Command.getName()
thats whats then returned
I am pretty sure that the String in the commandmap is actually the namespace
ah yes
thats the command you call it with
but new Cmd("Name") is what you get when you do cmd.getName()
wait wait from what ive tested
cmds.replace("minecraft:op", opCmd);
the minecraft:op is what you when you call
/minecraft:op <player>
the new OpCommand("minecraft:op");
is what you get when you do
onCommand(...)
https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/CommandUtils.java lines 68+, I am ONLY using the plugin name for the string parameter
minecraft would be the namespace and op being the command name
mfn is correct here 🙂
it is no different then doing something like /essentials:op
essentials is the namespace as that is the name of the plugin that registered the command op
if i remove op only and not minecraft:op from the map
i can still call minecraft:op
so it's getCommand("minecraft:op")
as command
and only using "getCommand("op"))" should actually not work, I guess? no idea
just print out the command map before you do anything to it, then you know for sure
when i didnt remove the namespaced command
i was still able to make calls to it
to the vanilla implementation of the command
yes as said, I guess the map ONLY contains stuff like
"minecraft:op"
"angelchest:acreload"
etc
the string / map key is always "namespace:commandname"
simply print out the map 😄
sure
gonna iterate it
and just print it to console
i cant post the whole map here
[13:56:50] [Server thread/INFO]: Key: minecraft:op
[13:56:50] [Server thread/INFO]: Key: op
so the map contains both
namespaced and non namespaced versions of the command
hmm i came across a problem. what's wrong with this code?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
when i run this i get https://pastebin.com/JY4UTGnd
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
it seems that PDC doesn't work correctly with serialization
tbh the deeper i dig into minecraft
the more i ask myself how it glues itself together
xD
because youre right too
i wouldve as dev only worked with namespaces too
you CANNOT store something that looks like json in a string
and then create a non namespaced alias from the most relevant one
it's a bug in how PDC works
you'll have to base64 your stuff, or use a library so you can directly store string arrays
is it possible to be fixed later?
I doubt it
it's been the way since 1.14.1
https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/ use this if you wanna store string arrays, etc etc
btw i havent worked with synced multithreading at all in bukkit yet
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { Ranks.patchOpCommand(); } });
this ALWAYS calls AFTER the reload right
only worked with async threads so far
after the reload? wdym?
when this line is called from the onEnable() callback
because u cant get the map while reloading
u have to get it right after
the server fully loaded in
it'll run "as soon as possible" which, IIRC, is the next tick
so its not guranteed to run after reload?
ah kk
thats what i need
cause like
from my understanding the map gets cleared and refilled during a reload
means i can not get an instance from it onEnable()
people using /reload should expect things to break anyway, though
im trying to code it reload safe
also the bukkit commands are always already registered once your onEnable gets called
on the other hand its not relevant here if its a reload or a bootup
both wouldnt work
because the reference can be null
until the server loaded in
you can access the commandmap just fine in onEnable without a task
otherwise registering plugins in plugin.yml also wouldn't work
wdym? I simply change the commandmap in my onenable and it works fine
which means its either null from the beginning or overriden
for me the change didnt apply
and i got nullptr errors
I've never had that problem in angelchest 😮
do spigot developers know this bug?
yes
I've reported it
let me look for it
opened a year ago, still open
genrally speaking pdc to yaml is pretty fucked
it's "intentional behaviour"
tho tbf, item stack to yaml is a disgrace
smh that PR author could have done a better job
the easiest solution is to simply not store anything json-like as string but as byte[]
or as char[]
or we could have just not attempted to make PDC readable in yaml
could have just been nbt style
Yea could have just been snbt
but I mean who needs that anyways
item:
==: org.bukkit.inventory.ItemStack
v: 2586
type: CHEST
meta:
==: ItemMeta
meta-type: TILE_ENTITY
PublicBukkitValues:
nbtserialization:test: '["This contains","some json"]' # This breaks the NBT parser
blockMaterial: CHEST
who stores items in yaml when you could just serialize them to bytes
it's totally valid YAML, it's just the NBT parsing thing that's broken
people who want to let people change the values manually 😛
who stores them as bytes when they can just be objects 🙂
👀 the yaml format is definitely not the most user friendly to begin with
if you want peeps to configure items from a config, create your own format
could just run your own yaml parser
but then again people don't know yaml isn't an api but rather just a spec
Someone could just fix my shitty implementation of the nbt to yaml shit
the YAML works fine, it's the ItemStack deserialize methd that's broken
look into the mirror
I have an nbt lib you could probably use for that
it doesn't automatically convert to yaml
but lets you use NBT without hooking into NMS for it
I think your repo is offline
yep it is
it will be back up in like a month or two or whenever I switch my DNS to your repo MFN
since I keep forgetting you allowed me some space
btw ive got a question for a future project in a few weeks
whats in the spigot scope the best option to
update custom items
say i want to change their stats cause balance
but i want to iterate potential outdated items effectivly
i mean like
not on every inventory open event or so
I don't see any better way than to listen to
- PlayerJoinEvent and
- InventoryOpenEvent
after all people could store one of those items in a chest and then never access it again for 2 years
You could do the lore via outgoing packets so it updated automatically
But that will be jank in creative mode
if someone has creative, they probably don't need any custom items anyway
We do migration during like a 1 to 2 day maintenance period and do a chunky like full load of the world
with Blackjack and Thread.sleep and hookers?
while true
try
catch
sleep
repeat
hm
as fast as the code within takes to execute i guess
what if i grab the event when a player moves an item in the inventory
then check the item
and store a version number in the item in a PDC container
to compare it
about 7 to 8 speed units
I think I'll name my message api "Oyster Message"
everyone loves oysters
no
@wet breach @tender shard It is working now. Thank you very much guys.
I removed the shading-stuff from the poml and added this:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.1.0</version> <configuration> <outputDirectory>/Users/georg/Buildtools/plugins</outputDirectory> <finalName>MavenTest</finalName> </configuration> </plugin>
Btw the shading-stuff came from the intellij extension, which provides templates for minecraft plugins.
I mean, not eating it. just liking them as animal
hmm
the shading stuff doesn't hurt anyone though, you'll probably have to readd it later at some point 😄
i've never seen a living one
well there isnt really much more to see than the shell but still
glad you got it working. have fun 😄
it could be also dead
woah
is there a way to get the player who placed a block?
when someone steps on it
then no, unless you keep track of who placed what block yourself
that would be an option



