#help-development
1 messages ¡ Page 737 of 1
At which point you wouldn't care about cents.
Both of these have a hefty performance penalty
hence work fine
I must be ill too
Integer-only economies are probably best suited for performance.
This was my early attempt inspired a lot by Sponge, but I want to revisit this and redesign at least slightly. I just never got around to it
https://paste.md-5.net/ehijeqobip.diff
You don't need great precision for mc economy
main issue I come accross when comitting is trying to work with current implementation
I told you as someone who known someone that worked many years with Banks as backend developer, and first thing he told me Java fucks up when working banking numbers
But you do need big decimals for size
sadly banks dont have that functional requirement
but yes that would be lovely
Banks run on integers
I was told best lang for Baking is around C++ or even Golang
What do you think BigDecimal is?
That should be covered within doubles i think?
yesnt
Yes, perhaps not 32-bit ints, but still ints
more complicated than just some ints
yeah banks fight is around C++ or Golang as i said before
why tf would you use anything other than cobol for banking
myeah its just that using doubles is bug prone due to the fact of precision
like if you're dealing with real money cobol is an absolute
Beyond 64 bits you have issues with CAS.
Beyond 256 bits CAS is very difficult
Beyond 512 bits CAS is impossible without locking.
Guys where should i put my gist in ?, Is there something like resources ?
Its called adopting technologies and modernity, no one would like to code on fucking cobol
i should say more bug prone
Maybe as a spigot posts
yes but banks have special ways of doing CAS
not just a regular cas instruction
can someone help me find the spigot 1.20.1 api please
You have to build it using spigot BuildTools
how do i do that?
Spigot has a post where they explain you how to use them, let me find it
?buildtools
But in the real world I have to agree that floating point numbers are not well suited, but fixed-point numbers should be perfectly fine in a base-10 system
As far as I have been taught Banks store data as BCD which is cringe but oh well.
don't need bt for api
got it where do i put it
just add the dependency to maven / gradle or whatever you use
if you use vanilla java dependency management đ but you need to build buildtools and add the api jar to your classpath
Maven đ
You must be taking about Graven** đ¤ đ¤¨
yeah and tbf a lot of banks just run on cobol spaghetti
silly
But I mean BCDs are just another way of representing integers, just happens to not be the standard two's-complement system I know and love.
what
its not like you cant use anything else
and in fact there have been a lot of attempts to migrate from cobol
true but cobol provides great precision :P though nobody uses it anymore so migrating just makes sense
I guarentee its nearly impossible to find cobol developers to employ
one of my work projects got commissioned to migrate from cobol, that was just direct excruciating pain
yeah
and well most cobol code bases dont have all the nice coding practices applied
so
its just spaghetti
I have no clue what that is supposed to do. If a is 0 it returns 0, if a is 1 it returns ~0 (and vice-versa), if a is 2 it returns ~0 ^ 1, if a is 3 it returns ~0 ^ 2, if a is 4 it returns ~0 ^ 3, if a is 5 it returns ~0 ^ 4.
Okay I think I see a pattern, but what is it's use?
two compliment is weird cuz you can have -0 iirc
I always thought of two's complement as a way to store integers in a binary fashion
Ah, it defines how negative and positive values are stored. Your function just does x = -a
Yay we have a Thread: https://www.spigotmc.org/threads/how-to-develop-an-minecraft-anti-cheat.621673/
Is anyone aware of tools for drawing "UML" sequence diagrams that either have extremely lax rules or are not UML-compliant? I'm kinda at the point where I almost consider doing it myself.
More specifically I am asking for UML tools that don't have this kind of garbage (it's not just Papyrus that has this so obviously it is specced, somehow.)
(What's funny is that if I was to reverse the object initialization order it would look usable, but at that point I'd get scolded by my teachers for doing it right-to-left instead of left-to-right)
Hey, I'm trying to figure out how to spawn a player NPC using NMS in 1.20.2,
I'm getting a Nullexception on this line
playerConnection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, npc));
java.lang.NullPointerException: Cannot invoke "net.minecraft.server.network.PlayerConnection.l()" because "player.c" is null
at net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket$Entry.<init>(ClientboundPlayerInfoUpdatePacket.java:185) ~[?:?]
at net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket$Entry.<init>(ClientboundPlayerInfoUpdatePacket.java:182) ~[?:?]
at net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.<init>(ClientboundPlayerInfoUpdatePacket.java:30) ~[paper-1.20.2.jar:git-Paper-207]
at live.mcmafia.mcmafia.managers.PacketManager.spawnNPC(PacketManager.java:47) ~[MCMafia-1.0-SNAPSHOT-remapped.jar:?]
at live.mcmafia.mcmafia.commands.MafiaCommand.onCommand(MafiaCommand.java:52) ~[MCMafia-1.0-SNAPSHOT-remapped.jar:?]
Could anyone help me out?
The NPC's connection is null
so it hasnt been spawned into the world?
ServerPlayer npc = new ServerPlayer(minecraftServer, serverLevel, gameProfile, clientInformation);
I feel like there may be some problems with the client information, I wasnt really sure what it was so I grabbed it like this
ClientInformation clientInformation = serverPlayer.clientInformation();
I think youâll have to set the connection to something
You can probably make a dummy connection
theres multi errors in my code help pls
Nothing looks like it is Null, đ¤
Output of npc.toString()
EntityPlayer['Mafia'/15, uuid='ffa8f542-a7ff-44cb-a78e-ee4634fa47cf', l='ServerLevel[world]', x=0.00, y=0.00, z=0.00, cpos=[0, 0], tl=0, v=false](Mafia at 0.0,0.0,0.0)
Output of serverPlayer1.toString()
EntityPlayer['Silverrzz'/14, uuid='b112991d-06f2-48bf-944b-f936c1056685', l='ServerLevel[world]', x=0.34, y=0.00, z=0.55, cpos=[0, 0], tl=2718933, v=true](Silverrzz at 0.33928129748421054,0.0,0.5471839256635685)
Output of playerConnection.toString()
net.minecraft.server.network.PlayerConnection@111f5163
ServerPlayer npc = new ServerPlayer(minecraftServer, serverLevel, gameProfile, clientInformation);
npc.setPos(x,y,z);
//broadcast npc to server
MCMafia.getInstance().getServer().broadcastMessage(npc.toString());
ServerPlayer serverPlayer1 = ((CraftPlayer) player).getHandle();
MCMafia.getInstance().getServer().broadcastMessage(serverPlayer1.toString());
ServerGamePacketListenerImpl playerConnection = serverPlayer1.connection;
MCMafia.getInstance().getServer().broadcastMessage(playerConnection.toString());
playerConnection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, npc));
Okay but what about the NPCs connection
would that be npc.connection?
Yes
Can someone help me pls
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I have no idea how to fix these issues
So there is no solution to the issue ?
i have no idea
legitimately ask your question
I would suggest learning Java after trying to create something. Its like university, we can expect to understand all the topics without first learning the theory and simplest one
i have leant a bit and this isnt my script
What script? Im too confused
oh you mean code*
yes
Right, so far i wouldnt code
Unless i learn Java and well learned, not like most that learn it while trying to code
can i show it to you
?paste
nvm its alr
do you know java
how do I get the id of an itemstack? for example "5:1" pls tag
Oh no itâs 1.8
They don't
They've just copy pasted code from somewhere and want you to spoonfeed them until it's in a working state
wdym
no I am in 1.20
they dont have ids now
What do you need the id for
They were basically removed 7 versions ago
oh
So what do I use instead?
for example in a config were the user should add some items
ok ty
Combined with Material.matchMaterial
does anyone know a list with all material names? like "RED_WOOL", ..
is it possible to make a npc strafe / have player like fighting movement
?jd check the material enum
Ignore the stuff with the legacy prefix
Is org.bukkit.block instantiated when a chunk is loaded, or when a block is accessed such as world#getBlockAt() ?
Ok thanks
So if I did something like ```
HashMap<Block, Class> hashmap = new HashMap<>();
Hashmap.put(world.getBlockAt(loc), var)
then
```Class var = hashmap.get(world.getBlockAt(sameLoc))```
It would return null?
Wut
Do you have any reason to use block as a key
You can just use the location
Or even convert that further into a vector, but youâll lose the world
Would anyone who is better at understanding technical conversation help me with this thread?
https://www.spigotmc.org/threads/create-fake-player-1-20-2.621480/
I'm having the same issue discribed where I cant use the ClientboundPlayerInfoUpdatePacket to add my fake player because the entry uses the method player.connection.getLatency()
and since a fake player does not have a connection, it errors
They talk about a fix here, but I dont quite understand
Looks like one option is using reflection to set the connection
I got it! I feel like I cheated slightly xD
I set the npc connection to the players connection it was being shown to
appears to have worked
Another option appears to be using a different constructor for the packet
Isnât the location instantiated when accessed as well? I need to access a value tied to a block in a hashmap, but I need to put the value and key (block / location / whatever) in when the chunk is loaded, and access it any time. (I canât use a persistent data container in a block for my application)
Yes but the block contains more data
I also donât know if it has a proper hashcode impl
I cant imagine that this code would be breaking whole legacy colors*. So far i think why didnt they use regex?
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) {
char[] b = textToTranslate.toCharArray();
for(int i = 0; i < b.length - 1; ++i) {
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) {
b[i] = 167;
b[i + 1] = Character.toLowerCase(b[i + 1]);
}
}
return new String(b);
}```
If I want to remove a specific amount of items from a players inventory (eg: 128 cobblestone, 32 oak logs) what's the best approach? This information is stored in a map, given that 128 exceeds the max stack size for cobblestone.
I would use removeItem and just pass all the stacks
Didn't realise I can pass multiple itemstacks to that method. I assume I'd have to turn 128 cobblestone into two itemstacks of 64 and pass them both in?
I think you might just be able to pass a stack of 128 cobble
anyone have proguard rules for plugins
Can I remove block with packets? Cannot find a way to do. Or just get rid of MC animation at the end of my edited animation true packets.
just remove block? or just wdym idk
I need that to call block break event as well so... if the block is in region or just something
I mean is all good, but the animation at the end is not looking good xD
It doesn't look like an animation, it just looks like you are animating your own, then do nothing, so since you are holding the pickaxe it just normally breaks the block
declaration: package: org.bukkit.block, interface: Block
I just assumed if the animation will goes to the end it will break the block, then my bad.
This will not call BlockBreakEvent
đ¤ˇââď¸
Then I will just need change status here I guess.. https://wiki.vg/index.php?title=Protocol&oldid=16091#Player_Digging but this Is packet send by player... idk how to change that đ
call it yourself then
nah, just created custom block breaking system and need to break that blokck xD
idk why Im finding other solution but I was thinking about that too xD
easiest you can go
probably ye, but can I somehow change fake recive packet? Just then I can send PlayerDigType.
no idea what you mean
nop tried that already
I need recive this packet https://wiki.vg/index.php?title=Protocol&oldid=16091#Player_Digging with status 2.
that should break block and call event right?
Just call the event yourself?
Itâs not really that hard
probably will go that way for now, but I should edit that packet
idk how with protocol lib
?
Why tho?
if I tired break fire or just something what is one click it will broke my code because break time is 0
I am taking security steps, I am not selling this plugin
Arenât you already keeping track of the time?
https://www.spigotmc.org/wiki/spigot-rules/#:~:text=Obfuscation designed to crash inspection,not add meaningful security anyway. Just follow the rules
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
nwm, its working fine now lol. I changed code cople of times allready
Uhm actually proguard is allowed
I didnât say it was not?
So then why are u linking the rules
You literally asked about obfuscation rules
nbo
i asked for proguard rules
like this if anyone has a setup for spiogt plugins
its like a set of guidelines for the obuscator to know what to obuscate and stuff
Just google it surely someone has posted it i guess.
hmm if player did not stop mining after event is cancelled is not using my block breaking system anymore.. thats why I looked for that solution
Ah
gonna googleit xD
Hey, quick question, Java related. Two different instances of a class should have different hashcodes, right?
Only if the contents are different
Im having a weird problem, im not the best at java but, there it goes.
Im creating a new instance of a Custom class that i have via command
if(strings.length == 1){
ZooFeeAnimal animal = ZooFeeAvailableEntityTypes.valueOf(strings[0]).label;
animal.Spawn(p.getLocation());
animal.setSex(sex);
}
This is the ZooFeeAvailableEntityTypes
public enum ZooFeeAvailableEntityTypes {
COW(new ZooCow(ZooAges.Baby, ZooSex.Male)),
GOAT(new ZooGoat(ZooAges.Baby, ZooSex.Male)),
BUNNY(new ZooBunny(ZooAges.Baby, ZooSex.Male)),
AXOLOTL(new ZooAxolotl(ZooAges.Baby, ZooSex.Male)),
PIG(new ZooPig(ZooAges.Baby, ZooSex.Male));
public final ZooFeeAnimal label;
ZooFeeAvailableEntityTypes(ZooFeeAnimal label) {
this.label = label;
}
}```
Right after spawn im adding the instance of that class to a static List in the main plugin class. Like this
```java
ZooFee.AllAnimals.add(this);
After that im runnin a scheduler on the Main class of the plugin to check the Growt possibilities for each one
public void TryGrow(){
for (ZooFeeAnimal a : AllAnimals){
a.checkOnGrowth();
}
}
Thing is, every single type of animal is getting the same Age even i spawn a new one
Sorry for the long question
Notes: Every animal has different entities and every entity is insine the ZooFeeAnimal as a referece. Every class from the same animal in AllAnimals share the same hashcode (I dont know why)
Data should not be the same, because i have a reference of the new Entity inside the ZooFeeAnimal class
Did you override the hashcode method
Nope
Thats the weird thing
After i spawn a new cow it spawns with the same age as the first cow
But if you check the ZooFeeAvailableEntityTypes im always creating a new instance
I donât see you always creating a new instance
COW(new ZooCow(ZooAges.Baby, ZooSex.Male))
So, im not creating a new cow instance?
ZooCow*
Sorry, im not too experienced on Java
You are
But just the one
And every time you reference that enum constant you get the same instance
I see
so the problem is the enum?
Maybe not the best way to get a new instance of a class
But i dont really want to check for each class when i use the command
You can use a supplier/function
In your case looks like you want a BiFunction
Takes 2 arguments and returns a type
I'd just make a supplier
So i just change the COW(new ZooCow(ZooAges.Baby, ZooSex.Male)) for a Suppliert?
Supplier*
Yes
COW(ZooCow::new) this gives me a "Cannot resolve constructor"
anyone have suggestions for a clean way to support sqlite and mysql
without having to do stuff like this
if (Config.MYSQL.ENABLED) {
createPlayersTableQuery = """
CREATE TABLE IF NOT EXISTS `Players` (
`uuid` BINARY(16) PRIMARY KEY,
`mmoClass` INTEGER,
`secondaryMmoClass` INTEGER,
`statPoints` INTEGER NOT NULL DEFAULT 0
""" + statFieldString + ");";
}
else {
createPlayersTableQuery = """
CREATE TABLE IF NOT EXISTS "Players" (
"uuid" TEXT,
"mmoClass" INTEGER,
"secondaryMmoClass" INTEGER,
"statPoints" INTEGER NOT NULL DEFAULT 0
""" + statFieldString.replace("`", "\"") + ", PRIMARY KEY(\"uuid\"));";
Make an interface with all the methods you need
Then a class for MySQL and one for SQLite
That implement it
?jd-s for me
Which part of Bukkit/Spigot checks for the Java version?
I'm trying to disable spigot's Java version check so I can use Java 21 on spigot 1.16.5.
Anyone with experience with world edit? Im looking for a way to get all the blocks in a schematic then after that send block change packets according to the blocks
Or do you need the already loaded in-memory representation
who has a list of exceptions that are usually set when checking whether a file is saved? Don't want to use a generic exeption
PS: Paper has a jvm startup parameter for this
-DPaper.IgnoreJavaVersion=true
IOException
there is more
For example?
FileNotFoundException
SecurityException
IllegalArgumentException
nsupportedOperationException
DirectoryNotEmptyException
ileAlreadyExistsException
AccessDeniedException
FileLockInterruptionException
FileSystemException
and which ones are not covered?
Here is everything thats covered
oh cool
IllegalArgumentException. But if this happens then you did something wrong in your code.
This and NullpointerException should never be caught.
Just use IOException for IO
Depends if you need it to fail the current stack or not.
If its a critical exception then you can forward it to a RuntimeException.
You could also just print the stack trace of the IOException and properly handle it...
this
Hi I have a question about Command Block target selectors.
How would I use the Bukkit API to implement selectors, especially @p, myself? Like, which API is useful for it.
I read on: https://hub.spigotmc.org/jira/si/jira.issueviews:issue-html/SPIGOT-4295/SPIGOT-4295.html
that md_5 said "Again, @p can easily be done by plugins. Bukkit already provides API specifically for this purpose"
I am aware of the CommandHook plugin, but currently it does not yet work for 1.20.2, so I was wondering how to not be dependent on it.
Thank you in advance for the help! đ
What API should I use?
declaration: package: org.bukkit, class: Bukkit
Thanks!
Is it more efficient to trigger redstone signals of blocks via plugin loop or redstone loop?
Like for example, switching the redstone lamp on/off every second
Probably via a plugin as a redstone loop needs a few more elements and code just needs a single block.
But in the grand scheme the activation doesnt really matter. The size of the redstone network is what
impacts the performance the most.
then use java 11
0 reason to use java 11 
đ¤Ł
if you want to support dead versions, go with java 8
OpenJ9 is a strange move
Thanks!
Doesn't work with 1.16.5
Welp, no java 21 for you then. Unless you fork.
Patch*
How can I run build tools without redownloading everything?
I could try pasting the new main before it finishes.
Theres a wiki and a flag for it
Question: Which Main do I have to modify to make BuildTools compile it with that Main?
Wasn't -DIknowWhatIAmDoingISwear for that?
Ah okay
It bypasses spigot version check
Figured as much
Why does this exist?
if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L);
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -28);
if (buildDate.before(deadline.getTime())) {
System.err.println("*** Error, this build is outdated ***");
System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***");
System.err.println("*** Server will start in 20 seconds ***");
Thread.sleep(TimeUnit.SECONDS.toMillis(20));
}
}```
^
It returns false.
Because it is an EOL version?
Then itâs being bypassed
Yeah thatâs how Md disables the outdated delay for the final release for a given version
How can I compile spigot from IntelliJ?
Java is not C !!!!111!!11elf!!!!elf!!!11
I've done it.
Step 1: run buildtools
mvn package something
I would have cloned the repos from the stash...
If there is a pom there is a mvn package
Iâd just run buildtools with the flag to not pull from remote
I wish I knew there was such flag.
Itâs on the wiki
I want to ask,
How are they doing on programs like New Plugin Updates Available?
<resource link>```
Thereâs a simple api for it
Or you can use a lib that makes it even more simple
:p
is a the stat Avg tick dispalyed in the gui with a value of 0.000ms good?
Hmm, easy to understand. Thank you for sharing
Coll did you get anywhere with the ItemFrameMeta ?
Yes and no
I have it basically working but it requires the virtual entity PR to be merged first
Which will probably be a little while
Ooh ok, I'll keep an eye out
I've a sword that can summon a lightning strike on a target entity upon hitting. That part is working. However, the lightning damages both the target entity as well as the wielder. How do I make the wielder immune to the lightning zap?
Hi the spigot non api 1.20.2 with mojang mappings isn't released yet correct?
It is
shh
Yes it is released
In fact it releases with spigot, it doesn't require any extra work
I previously had 1.19.4 version and just changed it to 1.20.2 but am now geting could not find artifact is it not in the spigotmc-repo anymore?
^ run buildtools with --remapped
Hm I did execute the buildtools but forgot the remapped thx đ
And one more question: Is there any good plugin like md5 special source for gradle? And how would I load the build tools stuff into my local gradle repo? Manually?
I only recomend to use Maven as its what spigot supports.
Ok thx guys
Hello how can I just remove this line objective.getScore("§700:30:00").setScore(6); from the scoreboard without removing the others ?
If I'm using a paper server do I also have to use paper in my NMS Plugin? In the past it has worked with my plugin using spigot but after remapping and using the remapped-obf jar in my plugins folder I get errors were classes are not found (ap class)
I went from 1.19.4 to 1.20.2
Ah ok so the remapped-obj is with mojang mappings? I have 4 jars: One normal, one with -remapped, one with -remapped-obf and one with original- (From shadow plugin I guess)
So the one without anything is the one to use?
yes
Ok thx
Would still highly recommend using papers internals if you are running paper
while paper maintains API compatibility with spigot, it certainly does not maintain that compatibility in its internals
Does anyone know if the Singleton pattern is needed in single-threaded environments?
i mean i can just load intsance in load class for exemple
but sonar list dont think so
Needed? No
then what problem does it solve?
The only place where this is useful, as for me, is where the developer constantly forgets to register instance
but this registration is needed 1 time
well, and probably in a multi-threaded environment
Singletons just enforce that there's only ever one instance of an object. In some situations that's just useful
but not in plguin minecraft â
The individual JavaPlugin instances themselves are classpath enforced singletons as well
i.e. you can't do new MyPlugin()
For JavaPlugin instances? You'll get an exception because the classloader prevents you from even doing it
In my case in VeinMiner, no, you can create new instances of it. It just makes no sense to do so
Well, that means there is no point in protection
It depends on what all happens in the constructor of some object. Maybe there are side effects of doing it. Maybe there aren't. Though so long as you're designing your code's access modifiers correctly then you shouldn't be concerned
Yes, somebody can reflectively create new instances of it but at that point that's a them problem
They're doing something stupid so let 'em shoot themselves in the foot lol
yeaa
?tryandsee
such things are probably needed for insurance in some bank program
?paste
Does anybody know why the counter doesnt increase after a kill?
https://paste.md-5.net/qeyayujiyu.cs
getItemMeta returns a copy
you need to set it back
also
?conventions
?
getKiller will always be a player
?
when setting attack speed, what is slow and what would be fast? I thought it was in secondeds so like a 11.3 attack speed would take 11.3 seconds but that don't seem to be the case, everything is just fast.
is it possible to make an armor stand text only visible to a certain player
Hey are the Anti-Cheat guys from yesterday here ?, Just Updated my Thread: https://www.spigotmc.org/threads/how-to-develop-an-minecraft-anti-cheat.621673/#post-4649692, want ask for Feedback
is there a way to download a world zip and then spin it up on a new temporary world (can get deleted after usage)?
i know how to download one, do you just do the basic file operations to use it?
e.g.
- download
- make new world dir
- copy to world dir
- use
- remove world dir when unloaded
Create a world and save it?
https://youtu.be/mqoe_9u7qjc?si=UsRbFAzcd-GsqweJ I think this had something about copying worlds.
do i need to add a # in chatcolor.of
is there a point to this? public static final Logger LOGGER = Bukkit.getLogger(); for use in another classes or i can use just bukkit.getLogger
Yes, but you need to use packets for that.
When an entity is spawned, every player receives a spawn and a metadata packet for the spawned entity.
If you now construct those packets and only send it to a single player, then only his client will know of this entity.
This is often referred to as a "fake" entity because not even the server is aware of it, meaning it wont get ticked,
doesnt draw any resources but is also not functional at all.
You should use the logger assigned to your plugin and not the bukkit logger.
Your JavaPlugin instance has access to your logger
oh alright
JavaPlugin#getLogger
im trying to make ai npc's and need some time before the http request is done and i want to have like a loading screen above the npc's head
This is about as advanced as you can get with plugins and will be very difficult to get right.
You need to properly chain async and sync tasks to not butcher your servers performance with this.
should be close to the thing im making, because it is a minigame
but cloning a world from http, saving it and using it, then deleting
hmm lol i think ill just stick w everyone being able to see the loading screen
Oh no, im seeing cringe
Didn't see that đŚ
If you know how to download, the rest might be easy.
Bukkit.loadWorld() might help?
But the general approach is ok. The main problem is that spigots world management system sucks
and does IO on the main thread, causing unpreventable lag when loading worlds
The system sucks, especially pre 1.17-1.18.
I don't know why my plugin can only make worlds only from onEnable.
you can make worlds from everywhere but if you make them in onEnable the server won't freeze noticeably seeing as you're not on the server to notice the server freezing
What Thread does Bukkit.createWorld need to be run in?
main thread
Not in 1.16.5
Or not for me.
if you want to make worlds asynchronously you'd need to make your own world generator
I don't care about the freeze.
I did.
@Override
public ChunkGenerator.ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
ChunkData chunkData = createChunkData(world);
world.setBiome(16 * chunkX,64,16 * chunkZ, Biome.BIRCH_FOREST);
world.setSpawnLocation(new Location(world,32,64,32));
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
chunkData.setBlock(x+chunkX*16,0,z+chunkZ*16,Material.BEDROCK);
for (int y = 0; y <= 64; y++) {
if (y > 0 && y < 7){
chunkData.setBlock(x,y,z,Material.LAVA);
}
if (y > 3 && y < 35) {
if (random.nextDouble() < 0.2) {
int i = random.nextInt(10);
if (i == 0){
chunkData.setBlock(x, y, z, Material.DIAMOND_ORE);
} else if (i < 6) {
chunkData.setBlock(x, y, z, Material.IRON_ORE);
} else if (i > 6 && i < 9) {
chunkData.setBlock(x, y, z, Material.GOLD_ORE);
}else {
chunkData.setBlock(x, y, z, Material.LAPIS_ORE);
}
}
}
if(y > 35 && y < 60){
chunkData.setRegion(0, y,0,15, y, 15, Material.STONE);
} else {
chunkData.setRegion(0, y, 0, 15, y, 15, Material.DIRT);
}
}
}
}
Bukkit.getLogger().info("Generation complete");
return chunkData;
}
@Override
public boolean isParallelCapable() {
return true;
}```
afaik you still can make worlds sync anywhere you want. it being in onEnable shouldn't change anything
you'd need to provide error
I forgot how to run stuff on the main thread.
bruh
I remember my server just timing out and never responding.
BukkitScheduler#runTask
you are probably downloading the world sync
This is how I used to make it: Bukkit.getScheduler().runTask(this, () -> Bukkit.createWorld(new WorldCreator("arena-" + worldCount).generator(new CustomChunkGenerator())).getWorldBorder().setSize(1000));
Would I be able to create a world from a command listener with this generator?
Or in a virtual thread?
how do i make comments in config
Maybe use #. I'm not sure.
It's YAML syntax, so yes, # for comments
like this? config.addDefault("# Do not touch if you don't understand this", "");
This seems to freeze my server.```java
public static synchronized void createArenaWorld(){
Bukkit.getScheduler().runTask(Main.instance, () -> Bukkit.createWorld(new WorldCreator("arena-" + worldCount).generator(new CustomChunkGenerator())).getWorldBorder().setSize(1000));
updateCounter();
Bukkit.getLogger().info("Start of generation");
try {
Bukkit.createWorld(new WorldCreator("arena-" + worldCount).generator(new CustomChunkGenerator()));
}catch (Exception e){
Bukkit.getLogger().severe(e.getMessage());
}
Bukkit.getLogger().info("Generating world");
}```
your CustomChunkGenerator is probably calling itself
Or is trying to access chunks outside the worldgen region
Not related to the issue but I thought naming the main class Main was against conventions
The only situation where you should name your class Main is if it has the main method
And also not related to the issue but I also thought we use the JavaPlugin logger and not the Bukkit logger
Correct
FileUtil#delete doesn't exist, so can I just use the commonio way?
import org.apache.commons.io.FileUtils;
FileUtils.deleteDirectory(new File("foo"));
wait that package doesnt exist anymore
i got it
why not just File#delete ?
oh lol
I think Files also has a method for it if you have a Path object
Only works with files and empty directories. Non-empty directories need to be recursively deleted.
yeah its a recursive dir
Then File#delete() should be fine then lol
Ugh. Stupid Files making you do more work
doesn't this do the job?
void delete(File file) {
if(file.isDirectory()) {
File[] files = file.listFiles();
if(files == null) return;
for(File child : files) {
delete(child)
}
}
file.delete();
}```
sure
all fun and games until file is another dir
that is why you recusevly call delete again
đ
I'm not that great of a plugin dev
Which part of this is calling itself? I think that might be the issue.
@Override
public ChunkGenerator.ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
ChunkData chunkData = createChunkData(world);
world.setBiome(16 * chunkX,64,16 * chunkZ, Biome.BIRCH_FOREST);
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
chunkData.setBlock(x+chunkX*16,0,z+chunkZ*16,Material.BEDROCK);
for (int y = 0; y <= 64; y++) {
if (y > 0 && y < 7){
chunkData.setBlock(x,y,z,Material.LAVA);
}
if (y > 3 && y < 35) {
if (random.nextDouble() < 0.2) {
int i = random.nextInt(10);
if (i == 0){
chunkData.setBlock(x, y, z, Material.DIAMOND_ORE);
} else if (i < 6) {
chunkData.setBlock(x, y, z, Material.IRON_ORE);
} else if (i > 6 && i < 9) {
chunkData.setBlock(x, y, z, Material.GOLD_ORE);
}else {
chunkData.setBlock(x, y, z, Material.LAPIS_ORE);
}
}
}
if(y > 35 && y < 60){
chunkData.setRegion(0, y,0,15, y, 15, Material.STONE);
} else {
chunkData.setRegion(0, y, 0, 15, y, 15, Material.DIRT);
}
}
}
}
Bukkit.getLogger().info("Generation complete");
return chunkData;
}```
What version is this
actially
Does chunkData not have a setBiome in that version
It works.
It does not.
interesting
I don't think the API changed until 1.17
World#setBiome() is wrong afaik
You should be using BiomeGrid#setBiome()
how can I detect when a display entity is clicked? For my use-case I thought about using an invisible ravager or slime (somthing with a bigger hitbox), but if there's a better way I'd like to use that
hi guys i played in mcci
and i wonder this
my hud like this in lobby
but my health and hunger bar are visible in the game
This makes use of action bars, custom textures, and negative font widths
they do this using shaders, but how exactly?
actually i know this but
i wonder they hide vanilla healthbar and food bar
but in game they not
They don't need it in the lobby. They probably have different resource packs for each game mode, the ones in the modes that require health bars not removing them
They don't they probably just retexture it
i downloaded they texturepack with jdgui
and check icons.png
they didnt removed healthbar and foodbar
and i search something
they doing this with shaders
Maybe they hide it with shaders
yes
but how shaders have this settings ?
Hiding them isn't hard
and can i do this in 1.16.5 ?
Toggling could be done with checking the particle layer for a certain color and toggling it based on that.
Shaders can do pretty much anything. They let you shift around vertices with a vertex shader so they can just shift the bars to the left or right, well off the player's screen
yes
Depends on whether or not you want to write a vertex or a fragment shader đ
I didn't know servers could use shaders
but to activate (i mean health bars) this in the game, do i need to renew the resource pack every time I log in to the game?
It's a resource pack feature
Really i always thought it was a completely separate thing only supported by mods
Well core shaders aren't quite the same as those shaders
I don't think you'll get any SEUS ray tracing with core shaders
But you can do some cool stuff
btw i think this
can i do custom health and food bar with actionbar feature ?
i will make health anims and more đ
and i will remove healthbar from icons.png
"Shader" is kind of a shitty term for OpenGL's shader pipeline ngl
Yeah you could do a health bar on the action bar
They're more accurately called "shader programs". They don't necessarily have to add things like shade to a tree
would this be healthy?
if someone installs another source pack etc.
maybe a bit off topic, but have any of you ever tried integrating some GPU computing code with Java. So something like Cuda for Nividia?
There is probably a library that wraps CUDA bindings directly
Maybe, gotta check before I try something... questionable ÂŻ_(ă)_/ÂŻ
Or if you are fine with OpenCL then you can use what minecraft uses, lwjgl
I just want too compute something using a graphics card, preferably not needing to create like 2 images too transfer data, instead using the PCIE IO port directly.
This can be achieved with some simple cuda bindings. You could also write a CUDA program and compile it using the nvcc, then call the binaries via JNI
That's what I originally planned; But then I'd need to make sure that I only run the binary once and then just keep feeding it data instead of booting up new binaries every time I want to calculate something
jni is slow. You should not use if you want max performance.
so... I made a lot of commits and then I realized that I forgot to change the git data before running BuildTools
how can I fix it and use my name?
chat ur git settings
I also want to preserve the commit dates
how to I fetch them?
their in .gitconfig in ur userhome
after I realized everything was in the name of BuildTools I ran the git config to update my name and email
I already updated it
I believe it was using the ones from BuildTools before
yeah if it isnt set it swaps to buildtools
it should work if you change the config, you will need to commit new stuff for it to change
but how I update the name and email of old commits?
idk if you can or how, @worldly ingot might
I don't think you can, at least not as far as my git knowledge is aware
Hi, I want to create a virtual book that can be edited from the config and when it exceeds the number of characters it moves to other pages, how can I do it, I tried it myself but it didn't work
you ammend with the --author flag
if you intend to pr changes with it at some point, it doesn't really matter on this
Hello can anybody help with the Buildtools?
Everytime if i try to get the git of 1.10.2 this error upcoming
fatal: 'C:/Users/nikie/downloads/Bukkit' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
HEAD is now at c5bf6bc6 SPIGOT-249: Set skull owner by UUID
Resetting Spigot-API to Bukkit...
HEAD is now at c5bf6bc6 SPIGOT-249: Set skull owner by UUID
Applying patches to Spigot-API...
Applying: POM Changes
Using index info to reconstruct a base tree...
M pom.xml
Falling back to patching base and 3-way merge...
Auto-merging pom.xml
CONFLICT (content): Merge conflict in pom.xml
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patchPatch failed at 0001 POM Changes
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Something did not apply cleanly to Spigot-API.
Please review above details and finish the apply then
save the changes with rebuildPatches.sh
Error compiling Spigot. Please check the wiki for FAQs.
If this does not resolve your issue then please pastebin the entire BuildTools.log.txt file when seeking support.
java.lang.RuntimeException: Error running command, return status !=0: [C:\Program Files\Git\usr\bin\bash.exe, applyPatches.sh]
at org.spigotmc.builder.Builder.runProcess0(Builder.java:1062)
at org.spigotmc.builder.Builder.runProcess(Builder.java:993)
at org.spigotmc.builder.Builder.main(Builder.java:738)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)```
Is this your first time running BuildTools? If not, remove all of the directories it created and run it again.
Or, copy the jar file and run it in another directory.
no i have all versions compiled but only 1.10.2 will not work. I will try in another directory
It compiled just fine for me. :p
how u open like this?xD i use gitbash xD
I can't help it. lol
#1117702470139904020 Work in progress tool if you want to try it out.
Although I'll say it time and time again, regular old BuildTools should be run in a new directory every time. Yes it means more downloading, but it will remove 90% of issues.
Yeah but I donât have all day smh
Okay i try đ Buildtools is downloading the git.
Most likely by reapplying all commits as email patches
wow worked thank u
im trying to get this title using event.getInventory().getType().getDefaultTitle() but that is "Chest" so how do i get normal name
InventoryView#getTitle()
Uuid in a title seems⌠questionable
i cant seem to find how to get the InventoryView class from the event
What event
InventoryClickEvent
Event#getView
Question: Using the setPersistent to an Entity makes in unspawneable even after reload or chunk unloading?
By default all entities are persistent. An entity will also not get persisted, if it is riding an entity that is not persistent.
The persistent flag on players controls whether or not to save their playerdata file when they quit. If a player is directly or indirectly riding a non-persistent entity, the vehicle at the root and all its passengers won't get persisted.```
This is the Javadocs info. But it isnt too specific
It stops them from being saved to the server files
But not from despawning on reload or chunk unload, right?
This suits better what im trying to archive?
void setRemoveWhenFarAway(boolean remove)
Sets whether or not the living entity despawns when away from players or not.
Bukkit.createInventory what is the owner what does it do?
Off bukkit question: Does it really matters the complexity shown by CodeMetrics?
public void CreateStats(){
if(this.Holder instanceof ZooFeeAnimalMilkable && this.Holder.Sex.equals(ZooSex.Female)){
ZooFeeAnimalMilkable animal = (ZooFeeAnimalMilkable) this.Holder;
ItemStack MilkQuality = ItemManager.BuildItem("&r&f&lMilk Quality: &r&6&l" + animal.MilkQuality.label,
Material.MILK_BUCKET,
1,
new ArrayList<>(
Arrays.asList(
ChatUtils.setColorName("&r"),
ChatUtils.setColorName("&r&f&lNext Quality: &r&6&lVery good"))
),
true);
this.Menu.setItem(13, MilkQuality);
}
// Age
ItemStack Age = ItemManager.BuildItem("&r&f&lAge: &r&6&l" + this.Holder.Age.label,
Material.CLOCK,
1,
new ArrayList<>(
Arrays.asList(
ChatUtils.setColorName("&r"),
ChatUtils.setColorName("&r&f&lTime left: &r&l" + "45~ days"))
),
true);
// Sex
Material Sex = this.Holder.Sex.equals(ZooSex.Male) ? Material.STICK : Material.DRIED_KELP;
String SexString = this.Holder.Sex.equals(ZooSex.Male) ? "&9&lMale â" : "&d&lFemale â";
ItemStack SexItem = ItemManager.BuildItem("&r&f&lSex: " + SexString, Sex, 1, null, null);
// Ride Animal
ItemStack Ride = ItemManager.BuildItem("&r&6&lRide",
Material.SADDLE,
1,
new ArrayList<>(
Arrays.asList(
ChatUtils.setColorName("&r"),
ChatUtils.setColorName("&r&f&l&oWujuuuuuuuuuuu!"))
), true);
this.Menu.setItem(19, Age);
this.Menu.setItem(22, Ride);
this.Menu.setItem(25, SexItem);
}
It says this code has a complexity of 10, but, is it that complex?
java.lang.RuntimeException: Error running command, return status !=0: [C:\WINDOWS\system32\cmd.exe, /D, /C, C:\Users\Loudbook\Downloads\BuildTools\apache-maven-3.6.0/bin/mvn.cmd, -Dbt.name=3871, javadoc:jar]
"C:\Program Files\Eclipse Adoptium\jdk-20.0.2.9-hotspot\bin\java.exe" -jar BuildTools.jar --rev latest --generate-docs
Getting this error when running build tools. Any ideas?
Running on windows. FAQ mentions Linux.
javadoc.io is still down? lol
Are you running BuildTools in an existing directory?
As mentioned before, BuildTools should always be ran in a new directory. It just solves so many problems.
Also, #1117702470139904020 helps solve some issues by requiring certain java versions to be installed in order to compile specific versions.
Ran in a new directory :)
the problem is that javadoc.io is down and the javadoc goal fails because of it as it can't link them
Ended up downloading Javadocs of the maven repo online
Javadoc generation needs to make web requests?
to link, yes
you can pass offline links to the tool but i don't remember how you do that
Sounds like something that should be PR'd to BuildTools.
Maybe you shouldn't store the messages in arrays. I think the code would be much readable, if you would create variables for them. Write the names of the variables with lowercase, but I don't really have any problems with it. It's pretty straightforward.
Or maybe a soft fail if it can't do the web request and inform the user once finished.
--generate-docs go brrrr
Thanks, ill do that.
But anyways i have to make strings and then add them to a list, thats more boilerplate code there
Are there any good packet apis that I can just shade in my plugin so the user doesnt need a plugin on the server?
Only one I know of is PacketEvents
can someone help me with one line on my elevators skript?
please dont shade nms into your plugin
anyone know how to register a command using extends Command?
oh okay
commandmap
example?
you get command map
with reflection
then add it in
commandmap is on javadocs so read those for that
well i wasnt expecting to make a whole cmd api
i just wanted to make it so there is no core: infront of it
eh
thats what i was trying to do
i didnt want the commented out parts
A bit
could be better made
Im not the best at Java, but, can you give me some direction to make that code better
Ambiguous plugin name, what could genrate this thing? ,searched in Google and nothing helped
Not asking for code tho
show error message
Hmm in the context of GUIs it's weird
It's not super easy to do this without like a proper gui framework
I'm not a fan of the idea of seeing this hardcoded
thats not a gui manager thats a big library containing a whole array of utilities
Ambiguous Plugin Name 'EcoEnchants' for files 'plugins\EcoEnchants' and 'plugins\EnchantSupport' in 'plugins'
check plugin.yml for both plugins i think you have the same name set
"As a GUI Manager", not saying its just that
But, looking at it, it looks pretty good. Paginate, Menus, Different kind of menus
i mean its preference. ive used it for a while i personally dont like how they handle menus
the one that's caused me the least trouble is def TriumphGUI
But they all have their own little quirks
i'd always recommend making your own tbh. that way you can make it just the way you like.
I just have my own
this is a very good starting point if this is something you wanna do https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
Oh, thank very much
Ill do my own
I have a question regarding textures: Is it "hard" to make textures and items looking like MCCI textures?
if you do some research. not really
can yall help me with one line on my skript its an error.
you just gotta read up on how the resourcepacks & model data work
it's mostly just having the art style rather than complex
I have changed my plugin name many times
And the same message appears and the plugin isn't enabled
i need to know what do i replace the 'on jumping' method to in my skript it wont work for 1.20.1
I see, thanks man
there is a server that generates those based on ai
i believe
i mean this error appears when you have 2 of the same plugins so
đ
ehh
tbh I just do this
are you using a library plugin and shading the entire plugin or something? could also cause this
do you guys do skripts here?
no
i do dm me
Yes I'm using ecoenchants as a library
As there is a function that I want to use
bros prob not using any
No , jars

hmm using intellij build artifacts for compiling i guess?
can you show your plugin.yml ?
is it possible to give Commands a return message if I return onCommand?
like, return "Yo the entered name is invalid" instead of just returning false
no
and deep down minecraft uses brigadier which just has a lambda that returns an int
You probably want to return true if you are sending your own message
Arrays.asList(
new AlertCommand()
).forEach(command -> getCommand(command.toString()).setExecutor(command));```anyone know why this wont work?
I mean I wanna not run the command if some conditions are met
and I wanna let the user know what they did wrong
what does command.toString return?
idk
the boolean you return just controls if spigot will show the usage message from the plugin.yml
ahhh ok, and true does not I guess
correct
alright thanks
me neither dw
version: '${project.version}'
main: net.hyperiongames.betacore.BetaCore
commands:
alert:
aliases:
- bc
- broadcast
did you override the toString
what do i put
Otherwise it ain't gonna return alert
how am i gonna return it
That sounds amazing. Is there any AI that i can use to do this?
override toString if you want to do it that way
look up minevision
like any ai service they have a subscription
but u get some free creds
what do i put in that spot for the alert cmd
main: me.oPinqz.EnchantsSupport.EnchantsSupoort
author: oPinqzz
api-version: 1.20
version: 1.0.0
description: EnchantsSupport.```
yeah dude
you need to override toString
if u gonna use it
like that
class NoobCommand implements BlahInterface {
@Override public String toString() {
return "alert";
}
}```
what else can i do
instead of that for it
How is it possible to do this backgroundcolor in the chat and how can i do this bossbar on the top?
https://i.badlion.net/i2xfzFJWPF3Cv3s74TbNX3.png
idk
maybe just do it normally
getCommand("alias").setExecutor(new AlertCommand());
ugh
why dude
I mean sure
it can be nice to create a shorter function for PluginManager::registerEvents
but like
thats goofy
Hey I get com.comphenix.protocol.reflect.FieldAccessException: Field index 0 is out of bounds for length 0 on the #setType line of this code
WrapperPlayServerSpawnEntity packet = new WrapperPlayServerSpawnEntity(minecraftAI.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY));
packet.setEntityID(EntityUtil.getNextEntityID(world));
packet.setType(EntityType.PLAYER);
packet.setX(loc.getX());
packet.setY(loc.getY());
packet.setZ(loc.getZ());
packet.broadcastPacket();
Whatever wrapper API you're using doesn't support the version your server is running
How is it possible to do this backgroundcolor in the chat and how can i do this bossbar on the top? version 1.20.1 and put the icon in the tablist
https://i.badlion.net/i2xfzFJWPF3Cv3s74TbNX3.png
I asked this before but didnt get a repsonse can anyone here help me with MySQL?
I am able to conect to my local host database but once i try to use one that is hosted online i get this error ```Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.```
i dont know if this is only the case with this specific database cause i dont really have a spare database that i can try it out with
Both of those things are just done with custom fonts. They're essentially changing the textures of font glyphs like "a" to show that texture instead
and how can i do this?
https://www.youtube.com/watch?v=-9bjbL1dYAE is a good resource for you
Since Minecraft 1.13 we have access to custom fonts. Since I have not seen much about it here a little video about it.
I want to show you everything you need to know and provide some ideas how you can use fonts creatively.
Resourcepack: https://dmanager.stevertus.com/pack/stevertus:custom-font
Reddit article: https://www.reddit.com/r/Minecraft...
Even when I manually write it I still get the error on entity type
PacketContainer container = minecraftAI.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
container.getBytes().write(0, (byte) 34);
container.getIntegers().write(1, loc.getBlockX());
container.getIntegers().write(2, loc.getBlockY());
container.getIntegers().write(3, loc.getBlockZ());
I don't know what version your server is running but that doesn't look like nearly enough data. In the latest version, this is what all is required
private final int id;
private final UUID uuid;
private final EntityTypes<?> type;
private final double x;
private final double y;
private final double z;
private final int xa;
private final int ya;
private final int za;
private final byte xRot;
private final byte yRot;
private final byte yHeadRot;
private final int data;```
The wiki isn't relevant here
Yeah its not, but it still shouldnt throw Field index 0 is out of bounds for length 0
ProtocolLib uses reflection to set fields, not the raw data sent over the network
It might
since the packet doesnt even get sent
If they use an old version
It's not relevant at all. I'm telling you, it's not relevant
i do and im looking at the older version
checking it out can be easy enough to figure out the fields
The data documented on the wiki is not the same as the data required by PL
Do not use wiki.vg for reference here. I'm telling you
Whatever version you're running you'll want to take a look at the PacketPlayOutSpawnEntity class. Those are the field types you need to set
In the latest version, it's the fields I sent above
đ¤Śââď¸
Shouldnt it not throw Field index 0 is out of bounds for length 0 even if I dont have all the fields set? Cause its getting thrown when I try to set it
Because you're spawning and creating a new entity. It's so the client knows what UUID to use
we don't use it anywhere else but whatever
The client needs it for consistency
Would be really awkward if any of the NBT holding UUIDs pointed to some entity that existed on the server but not on the client
Not even debug
Just synchronization
You're better off setting all fields anyways. I don't know why you wouldn't want to set data that's expected in a packet?
Even if you're not expressly using it, set it to some default value like 0 (for integers)
If you're getting that exception you mentioned it's probably because you're setting the wrong types
Or you're running the wrong version of ProtocolLib or there's a bug, but the latter seems unlikely
Hi, I've created a class that extends BlockPlaceEvent and am calling this.setCancelled(true) but the block is still placed and the event doesn't seem to get cancelled? Any idea why?
public class ClaimBlockPlaceEvent extends BlockPlaceEvent {
public ClaimBlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst,
ItemStack itemInHand, Player thePlayer, boolean canBuild, EquipmentSlot hand, boolean isCompanyClaim) {
super(placedBlock, replacedBlockState, placedAgainst, itemInHand, thePlayer, canBuild, hand);
Claim currentClaim = ChunkUtils.getClaim(block.getChunk());
if (currentClaim.isLandClaimed()) {
thePlayer.sendMessage("This chunk is already claimed by " + currentClaim.getLandOwner());
this.setCancelled(true);
return;
}
Claim newClaim = new Claim(
thePlayer,
isCompanyClaim,
true
);
ChunkUtils.setClaim(block.getChunk(), newClaim);
thePlayer.sendMessage("Chunk claim successful");
}
}
I definitely fall into the currentClaim.isLandClaimed() path as I get the message issued in chat
Yeah but
Bukkit doesn't listen to itself
Like that's not how you make event listeners
I still get Field index 0 is out of bounds for length 0 for setting the UUID
PacketContainer container = minecraftAI.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
container.getIntegers().write(0, EntityUtil.getNextEntityID(world));
container.getUUIDs().write(0, UUID.randomUUID());
container.getEntityTypeModifier().write(0, EntityType.PLAYER);
container.getDoubles().write(0, loc.getX());
container.getDoubles().write(1,loc.getY());
container.getDoubles().write(2, loc.getZ());
container.getIntegers().write(1, 0); //XA
container.getIntegers().write(2, 0); //YA
container.getIntegers().write(3, 0); //ZA
container.getBytes().write(0, (byte)0); //xRot
container.getBytes().write(1, (byte)0); //yRot
container.getBytes().write(2, (byte)0); //yHeadRot
container.getIntegers().write(4, 0); //data (idk what to set)
What version you using?
1.8.9 unfortunately
ow
Probably slightly different data back then
Like I said, refer to PacketPlayOutSpawnEntity
Gotcha - yep didn't think of that cheers
I bet you it's not even an EntityType field
Yeah that's what I thought lol
Yeah I looked it up but I can only find obfuscated version
Usually the serialization at least gives you hints as to what it is, and that you can cross reference against wiki.vg
(the correct version of wiki.vg, that is)
a - entityid
b - x (int variant, multiply by 32 and floor)
c - y (int variant)
d - z (int variant)
e - xVel (short variant, multiply by 8000)
f - yVel (short variant)
g - zVel (short variant)
h - pitch (byte variation, multiply by 256 divide by 360)
i - yaw (byte variation)
j - entity type
k - metadata
there you go
alright thx
unrelated question why does the X value need to be processed like that cant it just be sent normally?
Also what data type is entityId? int?
What are you trying to do by the way?
Because it looks like you were trying to spawn a player, which actually uses a different packet in 1.8
are u serious
Spawn named entity
At least if I'm remembering correctly. This is 8 year old information I'm trying to remember
PacketPlayOutSpawnNamedEntity
IK its been there since 1.8 so that's all you really need to know
if you're dipping below 1.8 you have mental issues so no help for you there
Was it really there in 1.8?
Yes I believe so
Damn I thought it was closer to 1.12
Guess I can just check the old docs
Doh they donât have a search bar
Did it have a different repo back then?
Ok so now I dont get any errors but I also dont see any entity and when I print all the player entities it doesnt print one with the right entity id
Location loc = new Location(world, 0, 61, 0);
PacketContainer container = minecraftAI.getProtocolManager().createPacket(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
container.getIntegers().write(0, 535456);
container.getUUIDs().write(0, UUID.randomUUID());
container.getIntegers().write(1, (int)Math.floor(loc.getX()*32));
container.getIntegers().write(2, (int)Math.floor(loc.getY()*32));
container.getIntegers().write(3, (int)Math.floor(loc.getZ()*32));
container.getBytes().write(0, (byte)0);
container.getBytes().write(1, (byte)0);
container.getIntegers().write(4, 0);
container.getDataWatcherModifier().write(0, new WrappedDataWatcher());
minecraftAI.getProtocolManager().broadcastServerPacket(container);
for(Entity entity1 : world.getEntities()) {
if(entity1.getType() == EntityType.PLAYER) {
Bukkit.getLogger().info("Found a player with ID: " + entity1.getEntityId());
}
}
Looking at this https://github.com/Attano/Spigot-1.8/blob/master/net/minecraft/server/v1_8_R3/PacketPlayOutNamedEntitySpawn.java I dont think I missed a value
it still doesnt spawn at the coordinates though
Any errors on the client or server
On client there is
Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at g.a(SourceFile:45)
at ave.av(SourceFile:881)
at ave.a(SourceFile:325)
at net.minecraft.client.main.Main.main(SourceFile:124)
Caused by: java.lang.NullPointerException
at bcy.a(SourceFile:301)
at fp.a(SourceFile:75)
at fp.a(SourceFile:16)
at fh$1.run(SourceFile:13)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at g.a(SourceFile:44)
... 3 more
dont know how to read obfuscated client classes tho
i have a bunch of classes with info like name, age, nation that extend an abstract class. i want to spawn a npc with it but idk how to get the info from that class into the npc? like /npcb <npc name> would spawn it with itâs information does anyone know how id do this đ
You are sending the client an empty datawatcher, i think thats the case
take a look at NMS entity's constructor to see how it creates the datawatcher
try creating an hashmap of <String, YourNPCClass>, in which key is the npc name
by YourNPCClass do you mean the abstract class i extend
yes, but if fields are a series of constant things, then I suggest to use enums instead, which instantiates easier and just better
Did it exactly how they did it and still get that
Mine:
WrappedDataWatcher dataWatcher = new WrappedDataWatcher();
dataWatcher.setObject(0, (byte) 0);
dataWatcher.setObject(1, (short)300);
dataWatcher.setObject(3, (byte) 0);
dataWatcher.setObject(2, "");
dataWatcher.setObject(4, (byte) 0);
Theirs:
this.datawatcher = new DataWatcher(this);
this.datawatcher.a(0, Byte.valueOf((byte) 0));
this.datawatcher.a(1, Short.valueOf((short) 300));
this.datawatcher.a(3, Byte.valueOf((byte) 0));
this.datawatcher.a(2, "");
this.datawatcher.a(4, Byte.valueOf((byte) 0));
I think something is up to Math.floor, try with the mojang's floor (not sure):
public static int floor(double var0) {
int var2 = (int)var0;
return var0 < (double)var2 ? var2 - 1 : var2;
}
any clue why line 227 isn't actually setting the display name? all the other stuff such as setting banner patterns here works properly
your just setting the meta of a copy of the items meta you have to set the item meta of the item with the modified displayname
?paste
everytime you call getItemMeta() it gives you the cloned version of itemmeta, so if you apply any changes to it, then you should call setItemMeta() followed by that changed meta
right okay
still get it https://paste.md-5.net/ohamemaseq.cs
this makes no sense
You get this error on client just when the entity gets spawned?
Can you try it with forge?
why
because I think it might has different obsucated names that we can map and see whats wrong (forge is based off MCP)
oh alr one sec
some are like func_0223..
Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at net.minecraft.util.Util.func_181617_a(SourceFile:45)
at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1014)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:349)
at net.minecraft.client.main.Main.main(SourceFile:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.NullPointerException
at net.minecraft.client.network.NetHandlerPlayClient.func_147237_a(NetHandlerPlayClient.java:484)
at net.minecraft.network.play.server.S0CPacketSpawnPlayer.func_148833_a(SourceFile:75)
at net.minecraft.network.play.server.S0CPacketSpawnPlayer.func_148833_a(SourceFile:16)
at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at net.minecraft.util.Util.func_181617_a(SourceFile:44)
... 9 more
what minecraft version?
1.8.9
ok, give me a second
how else would ya do it :P
So, i think the gameprofile which client is trying to get is null
Are you sure you are sending the player info packet just before the named entity spawn?
Uh no I wasnt aware I had to the code I sent here was all the code
Canât just make it and then do nothing :p
bet
But i still think that all the schedulers are looped every tick
I would just use NMS straight-forward (On ancient versions like 1.8), it just hurts to use plib, even hypixel, idk:
GameProfile playerProfile = ((CraftPlayer) player).getProfile();
EntityPlayer shopNPC = (EntityPlayer) shopEntity;
EntityUtils.setPlayerProfile(shopNPC, playerProfile.getId(), playerProfile.getName());
EntityUtils.setPlayerTextures(shopNPC, playerProfile);
connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, shopNPC));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(shopNPC));
plib is good, but for when you need version support & trying to avoid creating modules
Something to ask, if you use components on spigot? You have to use the ChatColor from bungeecord or the spigot one i jsut got confused
The bungee one
right, so i just code this for nothing? Hahaha
Trying to fix shity issues with color codes
Which have been there since 1.8x and never been fixed
Have you seen before the issue with coor codes and components?
Well what happen is the next, when you use colro codes in components the color code is applied to the first lines and the others lines the color is not applied
You arenât meant to use them directly in components
Use fromLegacyText or a component builder with the .color methods
No. You need to either weakref the player or store the UUID and check with that
the player will go stale otherwise
and idk if the isOnline check will work
It will
that sucks lmao, what if you wanna make component fully configurable? đ
Use a library like minedown
yeah but just for colors? đ¤
Doesnt make sense i mean its weird
how do you call the thing in between the square brackets?
/somecommand minecraft:acacia_stairs[facing=east,waterlogged=true]
block data? block info? whatever, is there something in the api to parse a string like that and set those properties into a Block object? without having to manually use setFacing, setWaterlogged and all that?
they can just simply fix the issue using the ChatColor regex pattern, getting the text part and applying the color to that part by doing ChatColor#getByChar(), then you are done
đ
If you go by vanilla's standards, block states
but Bukkit calls it BlockData
You can create one with that string using Bukkit#createBlockData(String)
cool, thanks
I sometimes asked myself too much why using third parties is so complicated. I mean they do really too much weirdone things
Thatâs what fromLegacyText is for
no, because thats what it broke it
?
is it more efficient to calculate a hash multiple times for subsets of data or once over the entire set. not really sure the O(n) of a hash

I'm not sure I understand
If you can calculate a hash once then why would you not do that?
Okay so say I had a massive database with N records that i want to synchronize with a remote db. Is it better to hash the ENTIRE db and match it once or hash each record and match each one
I guess it really depends on sample size could be a converging thing
Oh, I see
Unsure the best approach for that tbh, but hashing the whole database just sounds like a long nightmare lol
more theoretical then anything, guess i have to do some deep dives into hashing algos lol
I have a question regarding nms (1.20.2), In 1.19.4 this worked but now it doesnt and it finds no advancement at all:
I sent a ClientboundUpdateAdvancementPacker with my root Advancement as an AdvancementHolder which seems to be new and it worked before. I just want it to show an empty page and then send more packets later on.
This is the creation of the root advancement and conversion to advancementholder:
Advancement rootAdv = new Advancement(Optional.of(new ResourceLocation(namespace, "root")), Optional.of(new DisplayInfo(air, Component.nullToEmpty(""), Component.nullToEmpty(""), new ResourceLocation("minecraft", "..."), FrameType.TASK, false, false, true)), AdvancementRewards.EMPTY, new HashMap<>(),AdvancementRequirements.EMPTY, false);
rootAdvHolder = new AdvancementHolder(new ResourceLocation(namespace, "root"), rootAdv);
Thx in advance I already tried a bit
Are you doing like actual advancements with packets? The API should cover those.
No I dont want actual advancements just for each player to view them (its for a bingo) and I need custom positions which is why the api isn't sufficient
Could not resolve dependencies for project sh.miles.suketto:bukkit-core:jar:2023.10.5: The following artifacts could not be resolved: sh.miles.suketto:core:jar:2023.10.5 (absent): why would I be getting this error when compiling. I'm genuinely confused.
I shouldn't need to shade here I'm pretty sure
https://paste.md-5.net/vadocukevi.xml Everything is shaded in my dist module
I need an efficient way to get all the blocks which a player can see currently within a range. Is there a good way to do this without nesting for loops?
To me that looks like maven
it is :P
Gradle and proper versioning will fix this. Source? Trust me
Probably not. You might be able to use Chunk and ChunkSnapshots to get information, but it would still require some loops.
I feel like that would be very intensive since I want to run it once per second
ChunkSnapshots would be ideal if you plan to run this asynchronously
can i access snapshots async?
yeah but you have to make them synchronously
wait so cna I or can I not access chunk snapshots async?
ChunkSnapshots are a thread-safe read-only task.
cool
You should be fine to do it async.
epic
you can't make ChunkSnapshots asynchronously though
ye
