#help-development
1 messages Β· Page 925 of 1
I personally prefer the latest
GENERIC_ATTACK_SPEED
iTs nOT tHe sAmE
bet
1.20.5 PvP with 64 entity reach
with 10 step height
and 0.1 scale
public class MapRender extends MapRenderer {
private BufferedImage image = null;
@Override
public void render(MapView mapView, MapCanvas mapCanvas, Player player) {
if (image != null) {
new BukkitRunnable() {
@Override
public void run() {
mapCanvas.drawImage(0,0,image);
}
}.runTaskLater(WhosThatPokemon.plugin, 1);
}
}
}``` does this look correct?
wait no
render should not invoke multiple runnables?
And if I was to create a runnable, I'd do it like this:
Bukkit.getScheduler().runTaskLater(plugin, () -> /* Lambda body */, 1);
because only players can trigger maprenders, so why not pass them? how else would you be able to know which player caused it?
do i have to create a new class for every command?
It would be a good idea, yes.
Whats the best way to make multi-version plugin?
By writing version independant code
Hello how I can get only the double in to a string ?
Is there a format of the string
no I don't want pu double in a string, i want get the double inside the string
Does it follow a pattern?
hey guys, whats ur opinion on developing a plugin together with spring api?
I don't want .replace("deed", "").replace("fdnenfdj", "")
Depends on what you're making but it could be overkill
i want to have a plugin with database and public api anyone could access
i dont want ot use plain SQL tho
so JPA would help me alot
If you're just writing a rest api then you can use something like Javalin
I just want to remove all the chars, for a int I use this .replaceAll("[\\D]", "")) but I don't know whats the method for a double
How i allow the "." ?
\.
12.47
Exemple my string is "hudzedgvegdv 32.65 euygdfgevfdgev" I want to remove all the chars and keep the 32.65
not possible
[\D][^\.\,]
kiss on you π
Ah not working xD
Try [^\d\.\,]
not too
regexer says that would work
show me
so does regex101
hum hum and in human language ?
finally keep chars or number?
I just want keep the numbers
So what do you want me to do with the code? how can i make it pretty βΊοΈ
with the point
use this regex[^\d\.\,]
read the pinned good habits message
??
& Follow naming standards
^^
thx
thank olivo not me
so it works when ebic sends it :kekw:
its the pink probably

best advanced spigot coding tutorial?
define advanced spigot coding tutorial
- For NMS you could take a look at Kody Simpson and CodedRed but obviously nobody covers the entirety of NMS
- Reflection is not limited to spigot
- I have no idea what you mean by that last part
So most of that is just having a good understanding of Java
If you mean "supporting multiple versions of Minecraft", you could follow some principles
- Code against the lowest version you want to support (e.g. for a 1.13-1.20 plugin code against 1.13)
- If you use version-dependent code like NMS, you can use abstraction and reflection to have a central interface with multiple implementations (or modules, but I don't know much about them)
- For stuff like Material or PotionEffectType, you can use XSeries which helps to support multiple versions at once
NMS: Have good enough understanding to read Mojang code and then reuse it
Reflection: Not part of Spigot, just a Java thing
plugin compatible: Not sure what exactly you mean here but a good understanding of Java will help you write multiversion plugins by knowing how to only load things that are supported on the current server version
Compare different mappings with this website: https://mappings.cephx.dev
?nms
Can someone please help me with why when the sword-type in the config is set to example "abc" and the sharpness in the config is set to 0 it skips the sword and gives the next item (exactly as it should) but if the sword-type is set to "abc" and the sharpness is set to ex. 1 it cancelles the sword and everything else. I need help to fix so that it skips the sword if the sword-type dosent exist
Code: https://pastebin.com/2bK8S3ra
(Its for 1.8.9)
To make all events accessible from config, do i need to register all the configs?
?
Events from config?
Like, to be able to configure from config what happens in some event
i can't think of any scenario that you would need that
What do you mean?
besides making some script language
Uh, don't Know reflection
Forget data driven, mans making a data speeding
A missions plugin
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
to your event and that can get config
and do stuff
Or, load config and decide what events to register
who knows how to fix a bug with crafting when crafting does not work on an item that is not fully durable
can you change the skin of a player?
im reading some posts on the forum and im getting confused
im on 1.20.1
some people were arguing that is some other that it isnt, some other say that its only possible by using the spawn player packet
and now idk how to
i was having issues understanding why this is always true:
if (!levelmanager.claimedlevelrewards.get(e.getWhoClicked().getUniqueId().toString()).contains(Integer.getInteger(level)))
when i print the claimed levels (int list) it i get [list including level] :::: level
e.getWhoClicked().sendMessage("" + levelmanager.claimedlevelrewards.get(e.getWhoClicked().getUniqueId().toString()) + "::::" + level);
?conventions
Also use variables
Hi I have a question to create a custom mobs
I was following a tutorial
and in the tuto it shows extends EntityWolf but I can't import that..
someone knows?
Can someone help me with this?
?nms
Also it's probably not named EntityWolf anymore
and how to have ... nms it's a lib ?
.
nms stands for net minecraft server
and refers to Mojangs code
?switchmappings
ok so in my project libs I replace the spigot lib by the buildTools
hey if i wanted to set inventory of player to a map for like 1min. is it okay to packet set all their slots and just update their inventory when done?
I don't understand how can you do that with dependency injection
You pass the config to the listener
That doesn't really help them
assuming what I said is actually what they want to do
Yea lol
you'll have to look in to how reflection works
hmm, i'll check
Someone have plugin where use ormlite with foreign and i will can look how code look?
if i use nms i couldn't use geyserMC for java and bedrock ?
why
ORMLite should have good documentation on how it works
depends on what you do with nms
i don't know it's juste a question to be sure
somethings yes others no
i want to create a simple naturally spawn mob
Should be fine
okok
need some help with changing one's skin while in-game:
PlayerAPITextures playerAPITextures;
try {
playerAPITextures = new PlayerAPITextures(strings[0]);
} catch (InvalidPlayerException e) {
commandSender.sendMessage(ChatColor.RED + "A valid premium username is required to run this command");
return true;
} catch (Exception e) {
commandSender.sendMessage(ChatColor.RED + "An internal server error has occurred: " + e);
return true;
}
PlayerProfile playerProfile = ((Player) commandSender).getPlayerProfile();
PlayerTextures playerTextures = playerProfile.getTextures();
playerTextures.setSkin(playerAPITextures.getSkinURL(), playerAPITextures.isSlim() ? PlayerTextures.SkinModel.SLIM : PlayerTextures.SkinModel.CLASSIC);
playerTextures.setCape(playerAPITextures.getCapeURL());
playerProfile.setTextures(playerTextures);
strings[0] is a string containing the username of a player from whom to fetch the skin to set from
PlayerAPITextures is my class but it should be irrelevant because it works fine. it's used to retrieve skin and cape urls from assets.minecraft.net by a username (as a string passed to its constructor)
InvalidPlayerException can be thrown by PlayerAPITextures's constructor as well and that one's self explanatory
(issue's that the skin doesn't change of course)
after conpiling the build-tools, I use the .jar in the version folder ?
lmao i got same question
like i compiled the jar yes but what do i do with it
i've take the version and the importation works... for now haha
the .jar in version folder
no
If you use maven, just add this to your pom.
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<classifier>remapped-mojang</classifier>
</dependency>
^^
yen i've done that and the version folder and the libraries folder was create..
?
i'll send a picture it's good?
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
Yes, but I would rather see how someone uses it even in the simplest way
i can't send picture of my folder here ?
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
That's not what it tells you to do
You need to run BuildTools
Not Spigot
^
also the way you got that Spigot jar is most likely unofficial
yeah i double click on the bukkit and a menu appear and i press compile
BuildTools is the only official way to get your Spigot jar
Screenshot of this?
Does anyone know what is up with this error? I upgraded to 1.20.4 and am met with this error.
https://paste.ofcode.org/39dwwbY5GFtVF5uk8mUfAwt
there is no particle called BARRIER in 1.20.4
it's called BLOCK_MARKER and expects a data of type BlockData
So, should I just upgrade the pom.xml to the right version?
Been a while since I worked on plugins
yes, and then you replace Particle.BARRIER with Particle.BLOCK_MARKER + a blockdata
something.spawnParticle(..., Particle.BLOCK_MARKER, Material.BARRIER.createBlockData());
sth like this
world.spawnParticle(Particle.BLOCK_MARKER, someLocation, amount, Material.BARRIER.createBlockData());
I don't get the second part. Atm I have this
Oh material
uhmm
alr
Let me try
after compiling ?
After compilation finishes, you add that section to the pom and you have access to NMS.
.
you need to use one of those spawnParticle methods that has a "data" parameter - "particle" is Particle.BLOCK_MARKER and the "data" is a BlockData for the material you wanna show, so in your case Material.BARRIER.createBlockData()
IntelliJ stiill comes up with Particle.Barrier instead of .Block_marker
maven? click the maven reload button
Could not find artifact org.spigotmc:spigot-api:jar:1.20.4-R0.1-SNAPSHOT
?paste your pom
you didnt add the spigot repo
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
it worked before because the version you were using before was already cached in your local maven repo
probably because you had ran buildtools
we have to create a pom.xml like a plugin.yml ?
pom.xml is the "project file" for maven
Aha
No more errors right now, thanks!
np
bump
Do all particles require this, or just the barrier?
check the javadocs, I once PRed the required datatype into the descriptions
TL;DR most particles do not require any data, but a few do
But if I add the particle.getDataType() when using particles that dont require it, will that matter?
Because otherwise I'd have to check for each particle that requires it
that won't work, getDataType() will return a Class (e.g. Class<Void> or Class<BlockData>)
yep that's correct - I assume you want to make the particle configurable?
Yes
The command allows players to specify the particle
ok i've create the pom.xml and adding the informations. which .jar i import in my Java Build Path ?
for the nms
In that case I'd do it like this:
particle: BLOCK_MARKER
particle-blockdata: BARRIER
Particle particle = ...; // get particle type somehow
Object particleData = null;
if(particle.getDataType() == BlockData.class) {
particleData = Material.getMaterial(...).createBlockData();
}
// ...
...spawnParticle(particle, ..., particleData);
are you even using maven?
idk, i juste open eclipse and create new java project and import the JavaPlugin of spigot and start to do plugin
maven.. idk really what is it
yeah you're not using maven - I suggest you create a new project from scratch, using maven - this guide is for IntelliJ but it should work like 99% the same using eclipse: https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/
What should be in the 3 dots in the getMaterial? You can't get a particles material.
the config value of "particle-blockdata"
i can use Eclipse to follow the tutorial ?
more or less, I guess. It shouldn't be too different in eclipse
probably instead of "new java project" you can just choose "new maven project" or sth in eclipse
I'd suggest using intelliJ, imho it's much easier to use with maven though
Commands:
- '%Player% group add captain' ( i need to write the luckyperms add rank command if someone know it i don't know, ty ! )
not a development question
i followed https://blog.jeff-media.com/nms-use-mojang-mappings-for-your-spigot-plugins/ but its giving me error in pom
If you need to access NMS classes from inside your Spigot plugin, it is a very good idea to use the so called Mojang mappings. Disclaimer: This post is written for 1.20.4. If you use another version, you of course have to replace every occurance of β1.20.4β with the version you actually use. What are...
which errors?
Try to run Maven import with -U flag (force update snapshots)
mojang maps are only available for 1.17 and newer
1.16.5 and older: https://blog.jeff-media.com/using-nms-classes-with-maven/
Many people are confused on how to use NMS classes when theyβre new to writing Bukkit/Spigot plugins because their IDE doesnβt find those classes. Donβt worry. What is NMS? NMS refers to net.minecraft.server. This package contains all the classes that Mojang wrote for the vanilla Minecraft Server. You can use them to change the serverβs...
Someone have plugin where use ormlite with foreign and i will can look how code look?
so the only difference is i have to build it my self?
no, you always have to build spigot yourself
the difference is that you cannot use mojang mappings in 1.16.5
that means
- run buildtools without --remapped flag
- use just "spigot" as dependency, without the <classifier>remapped-mojang
np
Sorry but I still don't get it. The .getMaterial tries to get the material from the blockdata. So inside the brackets should be the particles blockdata. Does that mean I should just do particle.getdatatype.tostring? or .gettypename?
or smth else
Hey btw lets say i wanted to set all slots of player to air and 1 slot to a minecraftmap for like 30 seconds, can i just PacketSet all slots and update inventory when 30 seconds ends
they have an example in their docs, i can send it to you, if you haven't already looked at it
no, you don't "get the material from the blockdata". you simply create two variables:
- The actual Particle (e.g. Particle.BLOCK_MARKER)
- an optional (might be null) object that holds the required data for that particle. It's either null or an instance of BlockData
If myParticle.getDataType() == BlockData.class, then you get the value of "particle-blockdata" from the config and turn it into a Material, using Material.getMaterial, and then use that to create a blockdata
It will be a pain because the server will correct the client if he clicks on an empty slo
so the slot will update if player try to mess with it?
breh then packets preety useless for what i wanted to do
You could still do it, but you would need to intercept some packets as well.
Why not just store his inv temporarly
yea i am just gonna do that
@undone yarrow Example:
particle-type: BLOCK_MARKER
particle-data: BARRIER
public void spawnParticle(Location location) {
Particle particle = Particle.valueOf(getConfig().getString("particle-type"));
Object particleData = null;
if(particle.getDataType() == BlockData.class) {
particleData = Bukkit.createBlockData(Material.valueOf(getConfig().getString("particle-data")));
}
location.getWorld().spawnParticle(particle, location, 1, particleData);
}
might also use getMaterial instead of valueOf for Material, but whatever
Whats up with the whole getConfig part. That's what I don't understand. Why is particle suddenly = whatever you typed at the top?
you wanted to make the particle configurable - where else would you get the particle type from, if not from the config? o0
the top part is supposed to be in your config.yml
The particle is given when the player runs the command. I get the particle in a different method/script. Let's pretend I already have the particle at hand, stored in Particle particle
e.g. /runMyCommand BLOCK_MARKER
you also need to get the material somehow
yes, BLOCK_MARKER can be any block
it can be BARRIER or GRASS_BLOCK, etc
that's why you have to also pass in a blockdata object
Why did they change it to be more complicated π
because this allows you to use any block instead of just barriers
Oh wait but these are just block_markers
ohh
Alright, well let's say I dont want to use block markers at all
So, players can only use the traditional particles
and not block markers
then you can keep your old code but remember that you can't use BARRIER anymore then
If i use Spigot 1.20 API + Java 8 + XSeries and dont use any NMS, my plugin can run in 1.8?
You need to make a checker
You just need to load your internal config as a default, then add your saved one. Then save, if different
- Create an object,
- add default values in your constructor
- load the yml file
- replace all values from the yml to your object
- save the entire object back to file
you can look at the Spigot/Bukkit source to see how they do it for the Spigot.yml.
bump
no
only if its empty
can u set inventory slot regardless if player is offline or online?
copyDefaults only moves defaults (if you added any) to live values
maven vs no maven is like dishwasher vs washing dishes by hand
after compiling my BuildTools.jar i have this folder
what i do next to implement in my plugin in eclipse ?
i don't know but i could try if it's better
else i just take the spigot 1.20.4.jar and put it like as external jars ?
That won't work
?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
It would only work on 1.17 and below.
Otherwise, read above.
OR
Just use a dependency management tool.
Like maven or gradle.
how is it mojank obsfucation
ok if i create a maven project the "lib" or i don't know how it's called the spigot.. will automactly added ?
and after i can create my plugin without importint anything ?
NICE
ok thanks
ignore teh video, and read
good i'll do that thanks
to get all values just call getValues
oh yeah I always forget that exists
?
cmerco when he ran buildtools and didnt copy the javadoc jar
cmerco lol
lmfao i didnt even realise
new nickname
oh alex while ur here is the nonce on prem resources different on every download or is it same per version per user
different on each download
I now seem to be getting these errors. The plugin doesn't work at all atm.
https://paste.md-5.net/iwetetenuq.sql
Idk which API is unsupported
Use 1.20 in your plugin.yml
Instead of 1.20.4
api-version is intended for major versions, not minor ones.
π good to know
Make sure you also put 1.20 in quotes.
why
Yaml will view it as 1.2 if it's not stringified properly
Ye
that was fixed iirc
it was
So no quotes?
but it's still good practice
When did it get fixed?
so that your plugin doesnt fail at runtime if some method doesnt exist etc
Without it it assums you are legacy and you don;t get access to new blocks
Material
where do I download this stuff?
Hey guys, this isn't working, when executed the skin kind of blinks like if it were to change but it doesnt
Player player = (Player) sender;
PlayerProfile profile = player.getPlayerProfile();
PlayerTextures textures = profile.getTextures();
try {
textures.setSkin(new URL("https://textures.minecraft.net/texture/7376a5cbb20ccee1d4ea7f02eb444050b744b897cd11a46b2e54905cd756e464"));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
profile.setTextures(textures);
player.setPlayerProfile(profile);
?nms
what is the pom.xml for the nms
in this link it show thing for bungee...
ok but i try to import net.minecraft....EntityWolf but the net.minecraft doen't exist.. i don't know if it's normal
did you purge caches and restart IJ already?
yeah i close and reopen Eclipse
did you run buildtools, as the post told you to?
and WHY are you diving into NMS when you are only just starting with plugins/java?
yeah i follow the tutorial, the plugin works on server.
i aleardy done plugin just never with maven
don;t touch nms unless it's a last resourt
hmm ok
Nms is for power users
Guys, whats the easiest way to multi-version support?
with nms?
Seems like a you issue
Does anyone know the placeholder name or how to show online vip players on a scoreboard?
That's a question for #help-server
ah crap, thanks!
is there a way to spawn a zombie in a place where it should normally spawn?
im trying to spawn a lot of zombies at the same time
but want them to look naturally spawned
I just want it for a moment in particular
Pretty sure they spawn basically anywhere that's dark
But short of copying the algorithm, don't think so
You can try checking nms and see if there's something you can use
I should learn how nms works
So i can avoid this using XSeries?
I mean, for Material
I have a RLiveObject containing a HashMap.
Thread 1 retrieves a value from the HashMap.
Thread 2 also retrieves the same value.
Thread 1 modifies values in the retrieved object.
Thread 2 reads the values: <- Does Thread 2 have the current values or does Thread 2 have the values from the point at which it retrieved the object?
depends on what type of map you have
and the object behind the hashmap too
its a hashmap, tho i dont think a concurrenthashmap would help regarding the fact that those are multiple servers
hashmap is not thread safe
what do multiple servers have to do with anything?
separate servers run on separate VMs, they can't see or interact with each other
idk is it thread safe when i use a concurrenthashmap
no
Well CMH won't randomly make your algo thread-safe if it wasn't beforehand
ConcurrentSkipListMap is thread safe
I mean CHM is thread safe in that operations are atomic and other threads will see them
but it all depends on how you use it
it also does not make your data structures that you are storing in it thread safe
Reading concurrently from a normal HashMap is not a problem. The question was aimed at two threads retrieving the object.
And the answer to that: They will both have a reference to an object, its the same memory address for both.
How can I include reflections in my compiled plugin?
its 2 different servers so not the same memory adress
You dont need to include them. Just write them like every other code.
Then they also dont have access to the same HashMap
its an Rliveobject so they kinda do
unless they mean org.reflections
but I use the reflections API tho
org.reflections:reflections:0.10.2
normal threading invariants do not apply between separate JVMs
In that case you need to shade
How?
they do not see each other and they'd be communicating via networking or similar, which is wildly different and depends on how the library you are using works
They still have completely different objects.
RLiveObjects simply synchronize the fields between all other objects with the same ID.
It works by publishing changes to other applications, which listen to those publications to change the current state of their objects.
maven or gradle
Gradle groovy
shadow plugin
run the shadowJar task
yes thats true, do you know how i can fix my issue other than computeifpresent?
Hey! Good evening i've a problem deleting entities that are in unloaded chunks. i have this code but it's isn't working :/ if anyone have a idea ? π
public void delete() {
Bukkit.broadcastMessage("Β§4Deletion");
if (this.armorStands == null) return;
AtomicInteger i = new AtomicInteger();
this.armorStands.forEach(entity -> {
Bukkit.broadcastMessage("Removing");
if (entity == null) {
Bukkit.broadcastMessage("null " + i);
return;
}
Chunk chunk = entity.getLocation().getChunk();
if (!chunk.isLoaded()) {
Bukkit.broadcastMessage("Loading " + i);
chunk.load();
}
entity.remove();
i.getAndIncrement();
});
}
(none of the entities are considered in unloaded chunk but they are and they don't disapear :/)
Whats the issue?
the entity reference is wrong
its links to a no longer existing entity
Also ?xy
that too yea
Can you not just set persistent (false)
this here, i could fix it by having methods to modify the provided values in the map, but i would rather like to just use the setters that are alr in the object contained in the map
thank you
iv'e tried to store my entities in a list of UUIDs and get them with Bukkit.getEntity but it's not working too :/
Explain what you are trying to do
you'd still have to load the chunk first. Really not fun to do that
if u remember my playerservice, im trying to redesign it, the map contains proxyplayers which contain the server their on which needs to be changed
Then just get the RLiveObject and call getServer() on it. The others will be notified of this change
if i leave the chunck the entitie will diseaper or it's just on server stop? (i got it lmao)
but the proxyplayer is in the map if i get it, modify and write back to the map, other servers might have an outdated version cached when they have the object in use
Is it a normal HashMap?
Both
yes but a concurrent one wouldnt change it either as those are multiple servers and not threads
If its a normal HashMap then you never "read" or "write" those objects.
Its simply in the map all the time. Even if you call get() on it.
So just get the Object and call setServer() on it. Then all other RLiveObjects get this change.
i'm trying to do a Elytra race with rings, to handle the playerRingEnter i'm using armor stands and i detect collision. But my maps are too big to be loaded in once so everytime the server stop it delete all the armor stand and when it start it recreate all of them. (I also need to delete them when i delete a map)
yes but if 2 servers have an instance at the same time of a player, and one changes it and writes back, the other server will have an outdated version, because the player isnt a rliveobject and just something in a map, or do i understand something wrong?
Simply: Set the persistence to false. Have a map from a chunk coord to your Rings and simply listen to
the ChunkLoadEvent. If a chunk loads and contains rings in it, spawn them. No need to clean them up because they are not persisted when the chunk unloads.
Yep so just setPersistent (false) and add armour stands when chunk loads
Whimmy wham wham wozzle

Okay i will try that thx!
Come in verified
Hi, I created a 1.20.4 server with buildtools, created a maven project in Intellij, added this dependency in pom.xml: xml <dependencies> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.20.4-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.20.4-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies> however when I want to view source code of some spigot or nms class, IntelliJ is decompiling class files, I want to see spigot mappings (or mojang mappins, any are fine), I can click on 'choose sources' but I'm unsure what to pick
?nms
it's for mojang, thanks, how would i go about spigot mappings? (asking just in case)
the decompiled code is spigot mappings
lol
i was wondering if it's still possible to get docs like this somehow
Is there a way I can figure out what's missing in this packet to cause this error? [17:50:28] [Render thread/WARN]: Client disconnected with reason: Internal Exception: io.netty.handler.codec.DecoderException: java.io.IOException: Packet play/90 (class_2748) was larger than I expected, found 41 bytes extra whilst reading packet 90
No I'm using https://github.com/CatCoderr/ProtocolSidebar to send sidebars to players
I'm not actually sending any packets, it's just a wrapper for bukkit scoreboards that supports adventure components
Everything is at the packet level, so it works with other plugins using scoreboard and/or teams
Itβs hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
what
ban speedrun ig
if i put something in resources foldor of my pluginn will it compile with it?
It should be included with. But it really depends on your compilation method and what you want to put inside
its like 1000 images
The best way to check is to compile and open your jar with a zip software lmao
lmao
private File dir = new File("resources\\assets\\whosthatpixelmon\\sprites"); a bit of java question but this is correct way to get that foldor right?
oh shoot
if i only use the foldor name not actual file name , will it give me a array list of all files inside it?
As you used here, File object is used to get a folder
yes
So you can just apply the method to a folder
okay!
URL resource = getClass().getClassLoader().getResource("your_folder");
if (resource == null) {
throw new IllegalArgumentException("folder not found!");
} else {
File folder = new File(resource.toURI());
}
so yea its the same method they are using
private File getFileFromResource(String fileName) throws URISyntaxException {
ClassLoader classLoader = getClass().getClassLoader();
URL resource = classLoader.getResource(fileName);
if (resource == null) {
throw new IllegalArgumentException("file not found! " + fileName);
} else {
// failed if files have whitespaces or special characters
//return new File(resource.getFile());
return new File(resource.toURI());
}
}```
(I copy pasted ahah)
wdym?
So like the foldor i want has this path "resources\\assets\\whosthatpixelmon\\sprites" what do i use as a file name now? still this or just sprites
Oh just before answering your question we both read too quickly ahah
"Not working in JAR file."
You have to use InputStream and not File because we can't get an URI from the resources
oh;c
Just without "resources"
// The class loader that loaded the class
ClassLoader classLoader = getClass().getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream(fileName);
// the stream holding the file content
if (inputStream == null) {
throw new IllegalArgumentException("file not found! " + fileName);
} else {
return inputStream;
}
}``` so this one
yep
hey but how do i use that InputStream (sorry never really used these)
So InputStream is a stream of a file (not folders)
If you use images for instance, you can use a BufferedImage object
yes exactly i need BufferedImage
BufferedImage image = ImageIO.read(inputStream);
Let me explain more
sprites foldor has 800+ .pngs
i need randomly 1 as a BufferedImage
But since there is no method to list files from resources to my knowledge, you have to:
- know the file names
- use an easy format like 1.png 2.png ...
can it just randomly get 1 from those 800 ?
- Name your files 1.png .... 800.png and just get the Random#nextInt(bounds).png
- Or: fetch all files and select one randomely https://stackoverflow.com/questions/3923129/get-a-list-of-resources-from-classpath-directory
I'll rather go for the first one
gotta go for 2nd one since some files are named slightly different
good luck with that ^^
thanks i guess?
the stackoverflow post has a method given i will j try to implement that
There are multiple methods in the first solutions
First one doesn't require a lib
The other ones need one
hmm what if i just make a way that it copies the entire resource foldor to plugins foldor?
wait i know 1 last way ;O
i can just copy all file names and just make a method that gives me 1 random name xD
Yeah but the question is how do you get all file names ahahaha
i type it manually?
Why don't you just rename your files 1.png - 800.png ?
Do you need to keep their name ?
And is it a problem to rename them all ?
unfortunately yes
Ah ok ok
So then you have two options:
- Implement a method (that might require a lib) from the stackoverflow post
- Gather the name of all filesand save it in your plugin
you know i got a idea rn
And btw is it a plugin for your own or something you're making available to download ?
own plugin
Because if it's for you, it's way better to put the images in the plugins folder
Then you can list files
Yes i am gonna zip the pngs and unzip in plugin foldor
then just use the normal java thing
that I initially tried
It's so much better ahahah
yea
How can I get the name of a world?
Like I ONLY want it to be
Overworld, Nether, End, other misc worlds
There is no direct way of doing that.
You have to check the World.Environment of the World by using World#getEnvironment
As you can see there are 4 possibilities:
NORMAL, # The overworld
NETHER,
THE_END,
CUSTOM; # misc
File file = new File("sprites.zip");
if (!file.exists()) {
InputStream stream = this.getClassLoader().getResourceAsStream("sprites.zip");
try {
Files.copy(stream, file.getAbsoluteFile().toPath());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}``` does this make sense?
on startup its going to copy the file
because its 800 images
Why don't you just put all the files in the plugins folder ?
It seems good to me
What ?
yea i was making this for 1.16.5
So why would you need older java version ?
you cant run a 1.16.5 server on jdk 16 above
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.3.0:resources (default-resources) on project WhosThatPixelmon: filtering E:\WhosThatPixelmon\src\main\resources\sprites.zip to E:\WhosThatPixelmon\target\classes\sprites.zip failed with MalformedInputException: Input length = 1 -> [Help 1]
Let me see your pomxml
This is not the default one since there is the shading plugin but still I can't see where the error can come from
Nope that is auto generated one
ok yea built
used this lemme see if it compiled properly
smile
Just out of no where, what's the size of your zip file ?
Mmmh, try to still execute it
okay
Reading a jar file with winrar isn't meant to clearly work
lemme add plugins to server
it will be fun if it ran without errors
did nothing lmao
no errors nothing
LMAO nvm it pasted it in main server foldor
but yea the zip looks corrupted
Is it in your IDE ?
what is in my IDE?
the zip file. Is it corrupted ?
I think its just they 0'd out the crc hash's
which makes archivers think that the contents are broken
I dont remember how, but there exists some way to either skip crc validation or recalculate it
ok
hmm can i just ask 1 last question
are u able to copy entire foldor from resources ? and paste it
Same problem: you need the file names
what if i have name of foldor with everything in it
theres like 5 different copy methods which one should i use?
well 3 i lied
It seems that you have to use copyResourcesRecursively
But you have to provide a correct originURL with should open a connection to a JarURLConnection
Perfect, finally ahahah
yea about time lmao xd
now i can finally do what i wanted to do =D
only took a little over an hour
Ahahah and now you'll hate Java resources
xd but atleast i learned them
sorta
wait theres 1 small issue
File destination = new File(this.getDataFolder().getAbsolutePath());
FileUtils.copyResourcesRecursively(this.getClassLoader().getResource("sprites"), destination);
}```
why tf is it putting the zip file now
thats weird it shouldnt be putting the old zip file here
Wdym?
you remember the old zip file i tried to paste
yea its pasting that too for some reason
Ahahahaha
That's the problem of copy pasting some premade code
I think the problem should be with the URL
i will just add a file deleter
Because right now in your resources it's like:
|
| sprites.zip
| sprites
| 0.png
| 1.png
| ...
right?
Did you clean your jar?
you need to add in there to skip files that are zips
otherwise this code is going to copy everything in that directory and below
how do u clean it
it only has 1 foldor
the directory has no zips
zip file is created before the recursion
congrats!
;P i should really learn these file stuff
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (!(event.getInventory().getHolder() instanceof DonateMenu) && !(event.getInventory().getHolder() instanceof MinigameMenu)) {
return;
}
if (event.getInventory().getHolder() instanceof MinigameMenu && event.getClickedInventory().getHolder() instanceof MinigameMenu) {
if (event.getCursor() != null && event.getCursor().getItemMeta().getDisplayName().equals("Arcade")) {
Bukkit.dispatchCommand(event.getWhoClicked(), "partyjoin");
} else if (event.getCursor() != null && event.getCursor().getItemMeta().getDisplayName().equals("Oitc")) {
Bukkit.dispatchCommand(event.getWhoClicked(), "oitcjoin");
}
}
event.setCancelled(true);
}``` suppose I have such a code, everything works except that it throws out the NPE at the moment of taking the item at line ```java
if (event.getCursor() != null && event.getCursor().getItemMeta().getDisplayName().equals("Arcade")) {``` my inventory```java
inventory = SumeruGUI.main.getServer().createInventory(this, 9, "Minigames:");
final ItemStack arcade = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);;
SkullMeta sm = (SkullMeta) arcade.getItemMeta();
sm.setOwner("mario");
sm.setDisplayName("Arcade");
arcade.setItemMeta(sm);
inventory.setItem(0, arcade);
final ItemStack oitc = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);;
SkullMeta sm2 = (SkullMeta) oitc.getItemMeta();
sm2.setOwner("camber");
sm2.setDisplayName("Oitc");
oitc.setItemMeta(sm2);
inventory.setItem(1, oitc);```
PlayerChangedWorldEvent why does this event only have getFrom() and not getTo()
or it is already executed after the player has changed the world and i can just use player.getWorld()
can you cancel it?
if not, it is probably called after
true statement
and you can't cancel it
is it possible to remove the black pixels in the armorstand name(holograms) or is it impossible to change it?
is there any event listening to work with a whetstone?
Do you need to work with armorstands or do you only need the text? If you use armorstands to create holograms use TextDisplay instead
you can set the background of textdisplay to transparent
it supports 1.12.2?
no
So there's no way?
no
Do you mean click or actions of the grindstone?
I think the always workaround to cancel that is to cancel the click event on the result
Or maybe when clicking on a grindstone you open a fake grindstone
Or clearly disabling grindstone
there is a separate event for the anvil so why not for the whetstone lol
Hey Rolyn i had 1 more question
ahaha go ahead
Ivysaur("002","Ivysaur"),
Venusaur("003","Venusaur"),
Charmander("004","Charmander"),
Charmeleon("005","Charmeleon"),``` lets say i have a enum like this
I got the dexNumber = 001 how do i obtain string "Bulbasaur"
You could have a static method in your enum that loops over all the enum and check the first parameter equality. If it is String equals then you return this enum (or directly the second value of this enum)
would for loop be slow? it has like 800 items
I can actually show you
give me a sec to get a link
Ty
For BungeeCord, is there a way to get what server the player joined, but only during the first join?
I'm using ServerConnectedEvent, but this fires upon a server switch as well.
PostLoginEvent works, but doesn't provide which server they player joined
This is the easiest but forstalf will guide you through the best way
The very thing you are wanting is what I use for my permissions
here you go
also shows you how to use dynamic stuff too
MongoDB: Caching?
might have to alter this to your needs, but I use this for dynamic permissions where I don't know the permission ahead of time
You can use ServerConnectedEvent and add a flag to the player once he connected. Then if the flag is marked don't check this event anymore (for the given player)

Is there a built-in way to add a flag like how the "vanish" flag is added to players on Spigot? Or do I need to make this myself?
I'm assuming getGroups()?
I'm not an expert with Bungee. I'd use a list for that. Or if you have other player data to manage could be beneficial to have your gameplayer object
I see, I'll test out Player#addGroups and Player#GetGroups if not ill just make a custom object for it
anybody got a simple guide on how can i register my own placeholder.
i basically want to tell some other plugin a certain number, i think i need to register this number to placeholder api and that plugin can check for it?
well then i can just make a HashMap then
smart, I checked the docs and this should work
Worked! Thank you for your help. Can't believe I didn't think of this
You actually did most of the work. Just needed a little outside note ahah
private final String dexnumber;
private final String pokemonName;
private HashMap<String, String> hashMap = new HashMap<>();
PokemonEnum(String dexnumber, String pokemonName){
this.dexnumber = dexnumber;
this.pokemonName = pokemonName;
this.hashMap.put(dexnumber, pokemonName);
}```
i can just make a hashmap and get value of key then?
you don't need one, a loop is fine. Even if there is 800 enums, the loop only works on the stuff inside of the enum you are looking at
i mean HashMap just looked easy
it is, but then it means you also don't really need enums
well yea true
enums don't go away, they always stay in memory, so its pointless to have a hashmap of the enum as a key value pair
002-Ivysaur
003-Venusaur
004-Charmander
005-Charmeleon
006-Charizard
007-Squirtle
008-Wartortle``` the file looks like this
should i just try to map it in a hashmap?
so if you want to go the hashmap way, I recommed removing the enums then
either way is completely fine
just don't want to do redundant things is all π
can u store a .txt file in a plugin?
sneaky, do you speficially want the pokemon or is that just an example?
certainly
How can I fix a bug when crafting an item does not work when its ingredient does not have constant strength?
just add it to your resources directory in your project and it should automatically be put in the root of the jar
just like plugin.yml is
however unlike accessing the config or plugin yml files, you will need to fetch the resource differently
fortunately spigot has an api for that π
uh thats the file containing all names
i just wanna be able to give the code a three digit number and get the pokemon name
ah
threedigitnumber-pokemonname
i will just try splittng each line of file then mapping it to a hashmap
split by line breaks, then split by "-" and boom
guys its a little irrelevant but wanna know how i made that textfile into java code?
if you wanted to make every pokemon from scratch, I would've suggested using pokeapi so you didn't have to type in everything manually, but it seems like you don't need it
as an svg?
whats a svg
well if I was doing this, I would probably implement memory mapping and expiring cache. Load up a hundred or so or if you already know what is most likely to be common, load those up in a hashmap. Load more as needed, the expiring cache would cause it to shrink if some of the things are not being used. Reason for the memory mapping is this places the file into memory and with 800 items you are looking at maybe like 1mb or less of memory needed and it speeds up reading on the file without taking up I/O on the disk
like in the image but each column is seperated by a ; and each row is seperated by a new line
wait no
im convusing
yes
Csv
Hmmm i got a idea
SVG is the image format
i dont really need all the names at once
also the advantage of memory mapping is if the server crashes the OS will auto save the file in memory for you just takes some time π
i can just try to find which line has that dexnumber and split to get the name
but that is my two cents worth on how I would set this up
That's a tradeoff as explained by frostalf
For common access pokemon it will be slower
But I'm not sure at this scale we really care
stuff is very confusing now
yeah at this scale it wouldn't be noticed unless you were heavily profiling this
you would need a few million entries before noticing anything
i think for experimentation purposes i will make a java project to test
launching minecraft server every compile is pain
you gotta remember i dont know some things
if you do it right and keep the data binary with a simple way to separate the data. You can load 10 million or so blocks of data in 6 seconds and save in 3
now mind you I helped conduct this test about almost a decade ago
so with modern hardware and improvements with java, the speed is most likely faster now
its fine the server has 32 gb ram
ram isn't the issue
the 10million blocks I think only took up an extra 1-2gb of ram
10million blocks != 10 million lines just fyi. This test was conducted by someone that made a custom plugin for tracking who set a creative block so that if someone who didn't have creative couldn't obtain the block
I helped guide them through the whole memory mapping and keeping everything binary because one of the things with memory mapping is that anything in memory has to be binary so the OS has to do a conversion on anything that isn't already binary to binary to put it in memory
It seems like you're playing with c pointers
so keeping it binary just speeds up the memory mapping process
not really a necessity but it can be if you have a significant amount of data
also another neat feature of memory mapping is that you actually don't need to load the entire file
you can load up only partial and you can define how large your buffer is to shift data out and shift data in as you read through
handy if you want to keep memory management under control and not like try to load a 10gb file when you might not have the resources for it XD
otherwise you will get some OOME's
Aka Streaming
Or
Spanned files i forgot the formal name
Its spanned in zip
You can have 4 pebibyte file thats actually just 10 bytes
o.O
Bulbasaur``` i am pro coder
Sicc
yes you are!
good luck
i will surely comeback for map renderers
:)
i really need to clean the code
i got like 20 classes , i just kept making new one when i realised the code in that class wont work
no one's code is clean their first iteration
yeah, we all have our methods for making stuff, but no one has clean code
I myself use the method of getting things working first, then I refine the code later
others like to try different routes, but at the end of the day you end up with hacky methods whether you like it or not
I remembered my code was so bad I had to use reflection to call fields in a class because i was too stubborn to use a map
lmao
yea imma just quickly clean up and write boat of load code to test at once
wow really reduced 20 classes to 3 classes
Sounds fine to me
public class Renderer extends MapRenderer{
private final Player player;
private final BufferedImage image;
private boolean done;
public Renderer(Player player, BufferedImage image) {
super();
this.player = player;
this.image = image;
}
@Override
public void render(@NotNull MapView mapView, @NotNull MapCanvas mapCanvas,@NotNull Player player) {
if (done)return;
mapCanvas.drawImage(0, 0, image);
mapView.setTrackingPosition(false);
this.done = true;
}
}``` does this seem like a okay renderer
?paste
Hello, i wasn't getting this error before, now i get it for some reason... https://paste.md-5.net/cesicewesi.cs
has people found a way to check for specific entities in an area more efficient than iterating over all world entities yet?
no
sysout pluginCommands.getHandler().name() before you try to use it.
ok
the only class in commands package is TestCommand with command name "heal"
and it souted heal
is heal in your plugin.yml?
getCommand reads teh entry from plugin.yml
If it's not there it returns null.
wait 1 sec
OH lol
mb
it was spelt wrong
but
i thought it enables registered commands, and if its not registered it skips it
are the components in 1.20.5 on items gonna change how pdc work?
could you use this?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/world/EntitiesLoadEvent.html#getEntities()
declaration: package: org.bukkit.event.world, class: EntitiesLoadEvent
sadly not, i need to check a specific area for an item without it being dropped
how to set a texture for an item, without custom model data, since it is not available in 1.12.2?
You can use damage values on items to change the texture/model
I mean, hopefully not?
that is half the point of creating an API
you mean durability? ItemStack customItem = new ItemStack(Material.WOOD_HOE, 1, (short)1);
yo what
yeah
okay
the command code btw
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (command.getName().equals("test")){
File dir = new File(WhosThatPixelmon.getInstance().getDataFolder().getAbsolutePath());
File[] files = dir.listFiles();
Random random = new Random();
assert files != null;
File file = files[random.nextInt(files.length)];
ItemStack map = new ItemStack(Material.FILLED_MAP);
MapMeta meta = (MapMeta) map.getItemMeta();
for (MapRenderer r : meta.getMapView().getRenderers()){
meta.getMapView().removeRenderer(r);
}
map.setItemMeta(meta);
try {
BufferedImage image = ImageIO.read(file);
meta.getMapView().addRenderer(new Renderer(image));
map.setItemMeta(meta);
} catch (IOException e) {
throw new RuntimeException(e);
}
Player p = (Player) commandSender;
p.getInventory().addItem(map);
}
return true;
}```
Caused by: java.lang.IllegalStateException: Item does not have map associated - check hasMapView() first!
it was a filled map tho
Make and set your own map view
It doesn't have one if you make it like that
oh so theres no need to remove renderers?
lemme try removing renderer code
Caused by: java.lang.IllegalStateException: Item does not have map associated - check hasMapView() first! this has to be trollin
ah i need to make new MapView and set it ig
this is the "damaged" parameter in the resource pack?
for example java ItemStack customItem = new ItemStack(Material.WOOD_HOE, 1, (short)1); json "overrides": [ {"predicate": {"damaged": 1, "damage": 0}, "model": "item/wooden_hoe"} ]
I don't remember the exact name of the predicate
Haven't worked with that in years
using a bigger image, or is the image alr big?
scale it up
image is 32x32
heh how?
like does bukkit have a thing for it or i need to use java
uH
whats the size of minecraft map?
128x128
https://stackoverflow.com/questions/4216123/how-to-scale-a-bufferedimage Second answer is simplest.
no ik how to do it using java but like i dont know how big is map
is it like 100x100?
128*128 I think
[22:56:39] [Server thread/INFO]: sdxq issued server command: /kit create test
[22:56:39] [Server thread/INFO]: ItemStack{STONE_SWORD x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, enchants={DAMAGE_ALL=1}}}```
so I created this command which just do this:
```java
List<ItemStack> items = new ArrayList<>();
for (int i = 0; i < inventory.getSize(); i++) {
ItemStack item = inventory.getItem(i);
if (item != null) {
items.add(item);
System.out.println(item);
}
}
String name = ChatColor.stripColor(kitName.toLowerCase());
kitManager.addKit(new KitData(items, name, new ItemStack(Material.STONE)));```
[22:56:41] [Server thread/INFO]: sdxq issued server command: /kit test
[22:56:41] [Server thread/INFO]: test [ItemStack{STONE_SW
ORD x 1}, ItemStack{BIRCH_STAIRS x 8}] ItemStack{STONE x 1}```
private void claimKit(String kitName, Player player) {
KitData kit = kitManager.getKitByName(kitName);
for (ItemStack item : kit.items()) {
player.getInventory().addItem(item);
}
}```
Server: 1.20.4, Java: 17, Client: 1.20.4
whats the question
Why the enchants doesn't get added to the item?
why when I serialize and Item the enchant doesn't get applied?
can you send where you serialize the item
they should, where is your serialization code
it's doesnt
I just serialize the item save it
then load back the file and deserialize it
and the enchant doens't get addded
share the code
In 1.20.1 the /kit <name> give the item enchanted
Sure 1sec
BufferedImage simage = image.getScaledInstance(128,128, Image.SCALE_DEFAULT);```
its a bufferedimage
there you go
that's definitely not enough code to properly implement json serialisation
hm
why not just use inbuilt yaml?
md_5 do u know?
because I'm dumb, and didn't know this feature, how so?
The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...
getConfig().set / getConfig().getItemStack
YamlConfiguration if you want a custom file
private FileConfiguration kits;
I'm using this
yep
how to set the item stack?
so just use kits.set and kits.getItemStack
List<String> itemsList = new ArrayList<>(); for (ItemStack item : kit.items()) { itemsList.add(item.toString()); }
correct?
no, List<ItemStack>
yes sorry
draw simage back onto a bufferedimage e.g.
Image resultingImage = originalImage.getScaledInstance(targetWidth, targetHeight, Image.SCALE_DEFAULT);
BufferedImage outputImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB);
outputImage.getGraphics().drawImage(resultingImage, 0, 0, null);
should do it.
pretty sure u get better quality when you just draw the original to a new buffered image with different dimensions tho.
oh okay
to load it back, because the .items it's a list?
? both ways List<ItemStack>
List<ItemStack> itemsList = BoxPvP.getInstance().getKits().getItemStack(key + ".items");
but getItemStack it's Object
not a list
- ==: org.bukkit.inventory.ItemStack
v: 3465
type: STONE_SWORD
meta:
==: ItemMeta
meta-type: UNSPECIFIC
enchants:
DAMAGE_ALL: 1```
does this look right?, I mean for modifications
looks correct
alr
thanks, now it's working love ya
how to determine that the inventoryclickevent event is executed when player taking an item and not for example the place the item?
which InventoryAction is responsible for taking
multiple
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryAction.html & they are all documented
What?
Well did you figure it out to make it atomically safe for read-modify-writes yet?
With RLocks they are inefficient tho, did you find something better?
Okay, what is it?