#help-development

1 messages Β· Page 925 of 1

young knoll
#

Okay but like

umbral ridge
#

I personally prefer the latest

young knoll
#

GENERIC_ATTACK_SPEED

slender elbow
#

iTs nOT tHe sAmE

young knoll
#

I knew that was coming

slender elbow
#

bet

young knoll
#

1.20.5 PvP with 64 entity reach

chrome beacon
#

with 10 step height

young knoll
#

and 0.1 scale

quaint mantle
#
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

minor junco
#

render should not invoke multiple runnables?

minor junco
tender shard
#

because only players can trigger maprenders, so why not pass them? how else would you be able to know which player caused it?

pseudo elm
#

do i have to create a new class for every command?

rough ibex
#

It would be a good idea, yes.

heavy void
#

Whats the best way to make multi-version plugin?

shadow night
#

By writing version independant code

cursive loom
#

Hello how I can get only the double in to a string ?

chrome beacon
#

Is there a format of the string

cursive loom
#

no I don't want pu double in a string, i want get the double inside the string

chrome beacon
#

Does it follow a pattern?

distant wave
#

hey guys, whats ur opinion on developing a plugin together with spring api?

cursive loom
#

I don't want .replace("deed", "").replace("fdnenfdj", "")

chrome beacon
distant wave
#

i dont want ot use plain SQL tho

#

so JPA would help me alot

chrome beacon
#

If you're just writing a rest api then you can use something like Javalin

cursive loom
#

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

chrome beacon
#

You can do the same for a double

#

just allow . and ,

cursive loom
#

How i allow the "." ?

chrome beacon
#

\.

cursive loom
#

after the D ?

#

@chrome beacon ?

#

??

glad prawn
#

12.47

cursive loom
#

Exemple my string is "hudzedgvegdv 32.65 euygdfgevfdgev" I want to remove all the chars and keep the 32.65

#

not possible

chrome beacon
cursive loom
#

kiss on you πŸ˜—

chrome beacon
#

Might or might not work

#

give it a try πŸ˜…

cursive loom
#

Ah not working xD

chrome beacon
#

Try [^\d\.\,]

cursive loom
#

not too

remote swallow
#

regexer says that would work

cursive loom
#

show me

chrome beacon
#

Just tested on regexr

remote swallow
#

so does regex101

cursive loom
#

hum hum and in human language ?

remote swallow
#

what

#

there websites that test regex

#

that regex should work

cursive loom
#

I just want keep the numbers

timid hedge
#

So what do you want me to do with the code? how can i make it pretty ☺️

cursive loom
#

with the point

remote swallow
echo basalt
#

read the pinned good habits message

cursive loom
echo basalt
#

& Follow naming standards

remote swallow
#

sure

#

thats most likely intellij escaping stuff so it works properly

chrome beacon
#

^^

umbral ridge
#

also cache the pattern

#

ai generated

cursive loom
remote swallow
#

thank olivo not me

chrome beacon
#

so it works when ebic sends it :kekw:

remote swallow
#

its the pink probably

chrome beacon
#

no longer pink

remote swallow
brazen badge
#

best advanced spigot coding tutorial?

chrome beacon
#

define advanced spigot coding tutorial

brazen badge
#

like nms

#

or reflection

#

plugin compatible with multple software

#

ecc..

icy beacon
#
  • 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
chrome beacon
#

So most of that is just having a good understanding of Java

icy beacon
#

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
chrome beacon
#

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

icy beacon
#

And as a rule of thumb use remapped NMS

#

?mappings

undone axleBOT
icy beacon
#

?nms

timid hedge
#

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)

acoustic pendant
#

To make all events accessible from config, do i need to register all the configs?

chrome beacon
#

?

rough ibex
#

Events from config?

acoustic pendant
chrome beacon
#

so you mean something like:

InventoryClickEvent
  action: <stuff>
#

If so then no

hazy parrot
#

i can't think of any scenario that you would need that

acoustic pendant
hazy parrot
#

besides making some script language

chrome beacon
#

You can use reflection to get the event class

#

and then register a listener for it

acoustic pendant
#

Uh, don't Know reflection

rough ibex
#

Forget data driven, mans making a data speeding

acoustic pendant
rough ibex
#

?di

undone axleBOT
rough ibex
#

to your event and that can get config

#

and do stuff

#

Or, load config and decide what events to register

upper hazel
#

who knows how to fix a bug with crafting when crafting does not work on an item that is not fully durable

terse ore
#

can you change the skin of a player?

#

im reading some posts on the forum and im getting confused

chrome beacon
#

you can

#

which part are you getting confused about

#

and what version are you on

terse ore
#

im on 1.20.1

terse ore
#

and now idk how to

next iron
#

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);

chrome beacon
#

?conventions

chrome beacon
#

Also use variables

cold kiln
#

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?

timid hedge
chrome beacon
#

Also it's probably not named EntityWolf anymore

cold kiln
#

and how to have ... nms it's a lib ?

chrome beacon
#

nms stands for net minecraft server

#

and refers to Mojangs code

cold kiln
#

ok so in my project libs I replace the spigot lib by the buildTools

quaint mantle
#

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?

acoustic pendant
rough ibex
#

You pass the config to the listener

chrome beacon
#

That doesn't really help them

#

assuming what I said is actually what they want to do

acoustic pendant
chrome beacon
#

you'll have to look in to how reflection works

acoustic pendant
#

hmm, i'll check

tawdry echo
#

Someone have plugin where use ormlite with foreign and i will can look how code look?

cold kiln
shadow night
#

why

chrome beacon
chrome beacon
cold kiln
#

i don't know it's juste a question to be sure

chrome beacon
#

somethings yes others no

cold kiln
#

i want to create a simple naturally spawn mob

chrome beacon
#

Should be fine

cold kiln
#

okok

bleak eagle
#

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)

cold kiln
quaint mantle
#

like i compiled the jar yes but what do i do with it

cold kiln
#

i've take the version and the importation works... for now haha

#

the .jar in version folder

kind hatch
#

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>
chrome beacon
#

Don't forget remapping part

#

?nms

chrome beacon
#

^^

cold kiln
#

yen i've done that and the version folder and the libraries folder was create..

chrome beacon
#

?

cold kiln
#

i'll send a picture it's good?

lost matrix
#

?img

undone axleBOT
#

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

lost matrix
#

But preferably:

#

?paste

undone axleBOT
tawdry echo
cold kiln
#

i can't send picture of my folder here ?

chrome beacon
#

?img

undone axleBOT
#

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

cold kiln
chrome beacon
#

You need to run BuildTools

#

Not Spigot

tender shard
#

^

chrome beacon
#

also the way you got that Spigot jar is most likely unofficial

cold kiln
#

yeah i double click on the bukkit and a menu appear and i press compile

chrome beacon
#

BuildTools is the only official way to get your Spigot jar

cold kiln
#

when i open BuildTools

kind hatch
#

Go to the options tab and select Generate Remapped Jars

#

Then compile.

undone yarrow
tender shard
#

there is no particle called BARRIER in 1.20.4

#

it's called BLOCK_MARKER and expects a data of type BlockData

undone yarrow
#

So, should I just upgrade the pom.xml to the right version?

#

Been a while since I worked on plugins

tender shard
#

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());
undone yarrow
#

Oh material

#

uhmm

#

alr

#

Let me try

cold kiln
kind hatch
#

After compilation finishes, you add that section to the pom and you have access to NMS.

tender shard
undone yarrow
tender shard
undone yarrow
#

Could not find artifact org.spigotmc:spigot-api:jar:1.20.4-R0.1-SNAPSHOT

tender shard
#

?paste your pom

undone axleBOT
undone yarrow
tender shard
#

you didnt add the spigot repo

#
<repositories>
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
</repositories>
undone yarrow
#

I've never had that in there lol

#

and it has always worked

tender shard
#

it worked before because the version you were using before was already cached in your local maven repo

remote swallow
#

probably because you had ran buildtools

cold kiln
#

we have to create a pom.xml like a plugin.yml ?

tender shard
#

pom.xml is the "project file" for maven

undone yarrow
#

No more errors right now, thanks!

tender shard
#

np

undone yarrow
tender shard
#

TL;DR most particles do not require any data, but a few do

undone yarrow
#

Because otherwise I'd have to check for each particle that requires it

tender shard
#

that won't work, getDataType() will return a Class (e.g. Class<Void> or Class<BlockData>)

tender shard
undone yarrow
#

The command allows players to specify the particle

cold kiln
#

ok i've create the pom.xml and adding the informations. which .jar i import in my Java Build Path ?

#

for the nms

tender shard
#

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);
undone yarrow
#

hmm I see

#

Ill give it a try

cold kiln
#

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

tender shard
undone yarrow
tender shard
cold kiln
#

i can use Eclipse to follow the tutorial ?

tender shard
#

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

manic canopy
#

Commands:
- '%Player% group add captain' ( i need to write the luckyperms add rank command if someone know it i don't know, ty ! )

tender shard
#

not a development question

quaint mantle
#

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...

tender shard
#

which errors?

quaint mantle
#

Try to run Maven import with -U flag (force update snapshots)
tender shard
#

mojang maps are only available for 1.17 and newer

#

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...

tawdry echo
#

Someone have plugin where use ormlite with foreign and i will can look how code look?

quaint mantle
#

so the only difference is i have to build it my self?

tender shard
#

no, you always have to build spigot yourself

#

the difference is that you cannot use mojang mappings in 1.16.5

#

that means

  1. run buildtools without --remapped flag
  2. use just "spigot" as dependency, without the <classifier>remapped-mojang
quaint mantle
#

oh alright

#

thanks <3

tender shard
#

np

undone yarrow
# tender shard the config value of "particle-blockdata"

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

quaint mantle
#

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

spice furnace
tender shard
# undone yarrow Sorry but I still don't get it. The .getMaterial tries to get the material from ...

no, you don't "get the material from the blockdata". you simply create two variables:

  1. The actual Particle (e.g. Particle.BLOCK_MARKER)
  2. 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

lost matrix
quaint mantle
quaint mantle
#

breh then packets preety useless for what i wanted to do

lost matrix
#

You could still do it, but you would need to intercept some packets as well.
Why not just store his inv temporarly

quaint mantle
#

yea i am just gonna do that

tender shard
# tender shard no, you don't "get the material from the blockdata". you simply create two varia...

@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

undone yarrow
#

Whats up with the whole getConfig part. That's what I don't understand. Why is particle suddenly = whatever you typed at the top?

tender shard
#

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

undone yarrow
#

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

tender shard
#

you also need to get the material somehow

undone yarrow
#

I didn't need to do that in 1.17 though

#

did that change?

tender shard
#

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

undone yarrow
#

Why did they change it to be more complicated πŸ˜‘

tender shard
#

because this allows you to use any block instead of just barriers

undone yarrow
#

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

tender shard
#

then you can keep your old code but remember that you can't use BARRIER anymore then

undone yarrow
#

Alright

#

that's fine

#

good to know

#

I'll see if it still works

heavy void
#

If i use Spigot 1.20 API + Java 8 + XSeries and dont use any NMS, my plugin can run in 1.8?

remote swallow
#

no

#

you would need to use 1.8 api

heavy void
#

You need to make a checker

eternal oxide
#

You just need to load your internal config as a default, then add your saved one. Then save, if different

lost matrix
#
  • 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
eternal oxide
#

you can look at the Spigot/Bukkit source to see how they do it for the Spigot.yml.

bleak eagle
eternal oxide
#

no

remote swallow
#

only if its empty

quaint mantle
#

can u set inventory slot regardless if player is offline or online?

eternal oxide
#

copyDefaults only moves defaults (if you added any) to live values

cold kiln
#

Am i obligated to use Maven to use nms ?

#

ok thanks

rough ibex
#

You aren't required, no

#

but it makes it a lot easier

tender shard
#

maven vs no maven is like dishwasher vs washing dishes by hand

cold kiln
#

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 ?

chrome beacon
#

That won't work

kind hatch
#

?bootstrap

undone axleBOT
#

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

kind hatch
#

It would only work on 1.17 and below.

#

Otherwise, read above.

#

OR

#

Just use a dependency management tool.

#

Like maven or gradle.

remote swallow
#

how is it mojank obsfucation

cold kiln
#

ok if i create a maven project the "lib" or i don't know how it's called the spigot.. will automactly added ?

eternal oxide
#

API, yes

#

you add it in your pom.xml

cold kiln
#

and after i can create my plugin without importint anything ?

eternal oxide
#

Generally yes, but it depends

#

which is your prefered IDE?

cold kiln
#

ok i'll try, thanks

#

Eclipse

eternal oxide
#

NICE

cold kiln
#

it's good ?

#

or i should use Intellij ?

eternal oxide
#

Eclipse is my prefered IDE

#

Thats a full tutorial for Eclipse using Maven

cold kiln
#

ok thanks

eternal oxide
#

ignore teh video, and read

cold kiln
#

good i'll do that thanks

tender shard
#

why not just use getKeys() and iterate them

#

i doubt that "." is a valid path

remote swallow
#

to get all values just call getValues

tender shard
tender shard
remote swallow
#

cmerco when he ran buildtools and didnt copy the javadoc jar

eternal oxide
#

all API has javadocs

#

Implementation doesn;t

remote swallow
#

lmfao i didnt even realise

tender shard
#

new nickname

remote swallow
#

oh alex while ur here is the nonce on prem resources different on every download or is it same per version per user

tender shard
#

different on each download

undone yarrow
undone yarrow
chrome beacon
#

Instead of 1.20.4

undone yarrow
#

ah

#

Ill give that a try

kind hatch
#

api-version is intended for major versions, not minor ones.

undone yarrow
#

πŸ‘ good to know

kind hatch
#

Make sure you also put 1.20 in quotes.

undone yarrow
#

why

kind hatch
#

Yaml will view it as 1.2 if it's not stringified properly

undone yarrow
#

...

#

so, '1.20'

kind hatch
#

Ye

remote swallow
#

that was fixed iirc

eternal oxide
#

it was

undone yarrow
#

So no quotes?

eternal oxide
#

but it's still good practice

kind hatch
eternal oxide
#

1.20.2 I think

#

so safest to use quotes if you are supporting 1.20

tender shard
#

so that your plugin doesnt fail at runtime if some method doesnt exist etc

grim hound
#

yoo

#

does anyone know any libs for Searge?

#

like the packet library

eternal oxide
#

Without it it assums you are legacy and you don;t get access to new blocks

#

Material

grim hound
terse ore
#

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);
cold kiln
#

?nms

cold kiln
#

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

quiet ice
#

did you purge caches and restart IJ already?

cold kiln
#

yeah i close and reopen Eclipse

eternal oxide
#

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?

cold kiln
#

yeah i follow the tutorial, the plugin works on server.

#

i aleardy done plugin just never with maven

eternal oxide
#

don;t touch nms unless it's a last resourt

cold kiln
#

hmm ok

rough ibex
#

Nms is for power users

heavy void
#

Guys, whats the easiest way to multi-version support?

remote swallow
#

with nms?

slender elbow
#

I mean

#

"it depends"?

rotund ravine
#

Seems like a you issue

dire blaze
#

Does anyone know the placeholder name or how to show online vip players on a scoreboard?

dire blaze
terse ore
#

is there a way to spawn a zombie in a place where it should normally spawn?

chrome beacon
#

hm? what exactly is the goal here

#

Are you trying to increase the mob count

terse ore
#

im trying to spawn a lot of zombies at the same time

#

but want them to look naturally spawned

terse ore
sullen marlin
#

Pretty sure they spawn basically anywhere that's dark

#

But short of copying the algorithm, don't think so

terse ore
#

f then

#

ill just generate random coords and spawn them on a random altitude

chrome beacon
#

You can try checking nms and see if there's something you can use

terse ore
#

I should learn how nms works

heavy void
#

So i can avoid this using XSeries?

heavy void
inner mulch
#

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?

eternal oxide
#

depends on what type of map you have

slender elbow
#

and the object behind the hashmap too

inner mulch
#

its a hashmap, tho i dont think a concurrenthashmap would help regarding the fact that those are multiple servers

eternal oxide
#

hashmap is not thread safe

slender elbow
#

what do multiple servers have to do with anything?

#

separate servers run on separate VMs, they can't see or interact with each other

inner mulch
#

idk is it thread safe when i use a concurrenthashmap

eternal oxide
#

no

quiet ice
#

Well CMH won't randomly make your algo thread-safe if it wasn't beforehand

eternal oxide
#

ConcurrentSkipListMap is thread safe

slender elbow
#

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

lost matrix
#

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.

analog mantle
#

How can I include reflections in my compiled plugin?

inner mulch
lost matrix
lost matrix
inner mulch
#

its an Rliveobject so they kinda do

remote swallow
analog mantle
slender elbow
#

normal threading invariants do not apply between separate JVMs

lost matrix
analog mantle
#

How?

slender elbow
#

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

lost matrix
# inner mulch its an Rliveobject so they kinda do

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.

remote swallow
analog mantle
#

Gradle groovy

remote swallow
#

shadow plugin

analog mantle
#

got it installed already

#

what do i need to do

remote swallow
#

run the shadowJar task

inner mulch
raw epoch
#

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 :/)

eternal night
#

its links to a no longer existing entity

sullen marlin
#

Also ?xy

eternal night
#

that too yea

sullen marlin
#

Can you not just set persistent (false)

inner mulch
analog mantle
raw epoch
eternal night
#

See md's comment, you probably have a better solution here

#

and well

lost matrix
#

Explain what you are trying to do

eternal night
#

you'd still have to load the chunk first. Really not fun to do that

inner mulch
lost matrix
#

Then just get the RLiveObject and call getServer() on it. The others will be notified of this change

raw epoch
inner mulch
inner mulch
lost matrix
raw epoch
# lost matrix Explain what you are trying to do

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)

inner mulch
lost matrix
sullen marlin
#

Yep so just setPersistent (false) and add armour stands when chunk loads

#

Whimmy wham wham wozzle

raw epoch
#

Okay i will try that thx!

silver robin
#

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

slender elbow
#

?nms

silver robin
#

it's for mojang, thanks, how would i go about spigot mappings? (asking just in case)

sullen marlin
#

the decompiled code is spigot mappings

fallen lily
#

lol

silver robin
#

i was wondering if it's still possible to get docs like this somehow

young knoll
#

Sure

#

It should be the same as it was before if you are using the maven repo

zealous scroll
#

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

drowsy helm
#

nothings missing

#

it has too much

#

are you sending your own packet?

zealous scroll
drowsy helm
#

contact the dev of that

#

why do you need packets for a sidebar?

zealous scroll
#

I'm not actually sending any packets, it's just a wrapper for bukkit scoreboards that supports adventure components

young knoll
#

It’s not

#

It’s packet based

#

Also it doesn’t support 1.20.3/4

drowsy helm
lilac palm
#

?hello

#

?nocode

undone axleBOT
#

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.

lilac palm
#

?ello

#

?hi

rough ibex
#

what

glad prawn
#

ban speedrun ig

quaint mantle
#

if i put something in resources foldor of my pluginn will it compile with it?

agile anvil
#

It should be included with. But it really depends on your compilation method and what you want to put inside

quaint mantle
#

its like 1000 images

agile anvil
#

The best way to check is to compile and open your jar with a zip software lmao

quaint mantle
#

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?

agile anvil
#

Mmh no. You have to use the Resource's getters from the classloader

quaint mantle
#

oh shoot

quaint mantle
agile anvil
#

?

#

Folder and Files are managed quite similarly

agile anvil
quaint mantle
#

yes

agile anvil
#

So you can just apply the method to a folder

quaint mantle
#

okay!

agile anvil
#
URL resource = getClass().getClassLoader().getResource("your_folder");
if (resource == null) {
    throw new IllegalArgumentException("folder not found!");
} else {

File folder = new File(resource.toURI());
}
quaint mantle
#

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());
        }

    }```
agile anvil
quaint mantle
#

xD

#

wait small question

#

is my file name still the path or just the foldor name

agile anvil
#

wdym?

quaint mantle
#

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

agile anvil
#

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

quaint mantle
#

oh;c

quaint mantle
#

        // 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
agile anvil
#

yep

quaint mantle
#

hey but how do i use that InputStream (sorry never really used these)

agile anvil
#

So InputStream is a stream of a file (not folders)

quaint mantle
#

nvm

#

yea

agile anvil
#

If you use images for instance, you can use a BufferedImage object

quaint mantle
#

yes exactly i need BufferedImage

agile anvil
#
BufferedImage image = ImageIO.read(inputStream);
quaint mantle
#

Let me explain more
sprites foldor has 800+ .pngs
i need randomly 1 as a BufferedImage

agile anvil
#

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 ...
quaint mantle
#

can it just randomly get 1 from those 800 ?

agile anvil
#

I'll rather go for the first one

quaint mantle
#

gotta go for 2nd one since some files are named slightly different

agile anvil
#

good luck with that ^^

quaint mantle
#

thanks i guess?

#

the stackoverflow post has a method given i will j try to implement that

agile anvil
#

There are multiple methods in the first solutions

#

First one doesn't require a lib

#

The other ones need one

quaint mantle
#

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

agile anvil
#

Yeah but the question is how do you get all file names ahahaha

quaint mantle
#

i type it manually?

agile anvil
#

Why don't you just rename your files 1.png - 800.png ?

#

Do you need to keep their name ?

quaint mantle
#

yes there are named that way but few are named differently

agile anvil
#

And is it a problem to rename them all ?

quaint mantle
#

unfortunately yes

agile anvil
#

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
quaint mantle
#

you know i got a idea rn

agile anvil
#

And btw is it a plugin for your own or something you're making available to download ?

quaint mantle
#

own plugin

agile anvil
#

Because if it's for you, it's way better to put the images in the plugins folder

#

Then you can list files

quaint mantle
#

Yes i am gonna zip the pngs and unzip in plugin foldor

#

then just use the normal java thing

#

that I initially tried

agile anvil
#

It's so much better ahahah

quaint mantle
#

yea

analog mantle
#

How can I get the name of a world?
Like I ONLY want it to be
Overworld, Nether, End, other misc worlds

agile anvil
#

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
quaint mantle
# agile anvil It's so much better ahahah
        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

agile anvil
#

Wait wait wait

#

Why are you using zip file now?

quaint mantle
#

because its 800 images

agile anvil
#

Why don't you just put all the files in the plugins folder ?

quaint mantle
#

eh i wanna try it this way

#

atleast i get to learn a bit about inputstreams

agile anvil
#

It seems good to me

quaint mantle
#

i will j try it

#

bruh i need to download older version of java

agile anvil
#

What ?

quaint mantle
#

yea i was making this for 1.16.5

agile anvil
#

So why would you need older java version ?

quaint mantle
#

you cant run a 1.16.5 server on jdk 16 above

agile anvil
#

Wait, Java should be backward compatible

#

let me check

quaint mantle
# agile anvil let me check

[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]

agile anvil
#

Let me see your pomxml

quaint mantle
#

the default one

agile anvil
#

This is not the default one since there is the shading plugin but still I can't see where the error can come from

quaint mantle
#

Nope that is auto generated one

#

ok yea built

#

used this lemme see if it compiled properly

agile anvil
#

Just out of no where, what's the size of your zip file ?

quaint mantle
#

the sprites zip is corrupted looks like

agile anvil
quaint mantle
#

okay

agile anvil
#

Reading a jar file with winrar isn't meant to clearly work

quaint mantle
#

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

agile anvil
#

Is it in your IDE ?

quaint mantle
#

what is in my IDE?

agile anvil
#

the zip file. Is it corrupted ?

quaint mantle
#

yes

#

i tried opening using winrar

agile anvil
#

Ah

#

Nvm it's the opposite

quaint mantle
#

that has litteraly no answers

#

okay lemme try another way

white root
#

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

quaint mantle
#

ok

quaint mantle
#

are u able to copy entire foldor from resources ? and paste it

agile anvil
#

Same problem: you need the file names

quaint mantle
quaint mantle
#

well 3 i lied

agile anvil
#

It seems that you have to use copyResourcesRecursively

#

But you have to provide a correct originURL with should open a connection to a JarURLConnection

quaint mantle
#

yea did it

#

thanks πŸ‘

agile anvil
#

Perfect, finally ahahah

quaint mantle
#

yea about time lmao xd

#

now i can finally do what i wanted to do =D

#

only took a little over an hour

agile anvil
#

Ahahah and now you'll hate Java resources

quaint mantle
#

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

agile anvil
#

Wdym?

quaint mantle
#

you remember the old zip file i tried to paste

#

yea its pasting that too for some reason

agile anvil
#

Ah

#

Just remove it and pretend it never happened

quaint mantle
#

nah thats goofy

#

that is scaring me

agile anvil
#

Ahahahaha

#

That's the problem of copy pasting some premade code

#

I think the problem should be with the URL

quaint mantle
#

i will just add a file deleter

agile anvil
#

Because right now in your resources it's like:
|
| sprites.zip
| sprites
| 0.png
| 1.png
| ...

#

right?

#

Did you clean your jar?

wet breach
#

otherwise this code is going to copy everything in that directory and below

quaint mantle
#

it only has 1 foldor

#

the directory has no zips

wet breach
#

zip file is created before the recursion

quaint mantle
#

o

#

i edited the code and i know its gonna end miserably

#

oh wow i actually did it

agile anvil
#

congrats!

quaint mantle
#

;P i should really learn these file stuff

sterile flicker
#
@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);```
agile anvil
#

getItemMeta() can be null

#

(especially if the item you click is AIR)

sterile flicker
#

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()

spice furnace
#

if not, it is probably called after

agile anvil
#

and you can't cancel it

sterile flicker
#

is it possible to remove the black pixels in the armorstand name(holograms) or is it impossible to change it?

upper hazel
#

is there any event listening to work with a whetstone?

agile anvil
#

you can set the background of textdisplay to transparent

agile anvil
sterile flicker
#

So there's no way?

agile anvil
#

no

agile anvil
upper hazel
#

actions

#

to cancel the result

agile anvil
#

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

upper hazel
#

there is a separate event for the anvil so why not for the whetstone lol

quaint mantle
#

Hey Rolyn i had 1 more question

agile anvil
#

ahaha go ahead

quaint mantle
#
    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"
agile anvil
quaint mantle
#

would for loop be slow? it has like 800 items

wet breach
#

give me a sec to get a link

quaint mantle
#

Ty

small valve
#

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

agile anvil
wet breach
#

here you go

#

also shows you how to use dynamic stuff too

green prism
#

MongoDB: Caching?

wet breach
#

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

agile anvil
wet breach
small valve
#

I'm assuming getGroups()?

agile anvil
#

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

small valve
#

I see, I'll test out Player#addGroups and Player#GetGroups if not ill just make a custom object for it

ashen quest
#

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?

quaint mantle
#

well then i can just make a HashMap then

agile anvil
small valve
agile anvil
quaint mantle
#
    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?

wet breach
quaint mantle
#

i mean HashMap just looked easy

wet breach
#

it is, but then it means you also don't really need enums

quaint mantle
#

well yea true

wet breach
#

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

quaint mantle
#
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?

wet breach
#

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 πŸ˜›

quaint mantle
#

can u store a .txt file in a plugin?

native ruin
wet breach
upper hazel
#

How can I fix a bug when crafting an item does not work when its ingredient does not have constant strength?

wet breach
#

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 πŸ˜„

quaint mantle
#

yea ik how to access file

#

i spent entire morning on it

quaint mantle
#

i just wanna be able to give the code a three digit number and get the pokemon name

native ruin
#

ah

quaint mantle
#

threedigitnumber-pokemonname

#

i will just try splittng each line of file then mapping it to a hashmap

agile anvil
#

split by line breaks, then split by "-" and boom

quaint mantle
#

guys its a little irrelevant but wanna know how i made that textfile into java code?

native ruin
quaint mantle
#

whats a svg

wet breach
#

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

native ruin
#

wait no

#

im convusing

quaint mantle
#

yes

native ruin
#

what was it called again

#

not svg

minor junco
#

Csv

native ruin
#

csv

#

yea

quaint mantle
#

Hmmm i got a idea

minor junco
#

SVG is the image format

quaint mantle
#

i dont really need all the names at once

wet breach
#

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 πŸ™‚

quaint mantle
#

i can just try to find which line has that dexnumber and split to get the name

wet breach
#

but that is my two cents worth on how I would set this up

agile anvil
#

For common access pokemon it will be slower

#

But I'm not sure at this scale we really care

quaint mantle
#

stuff is very confusing now

wet breach
#

you would need a few million entries before noticing anything

quaint mantle
#

i think for experimentation purposes i will make a java project to test

#

launching minecraft server every compile is pain

wet breach
#

well I have already tested memory mapping in the past

#

with block data

quaint mantle
#

you gotta remember i dont know some things

wet breach
#

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

quaint mantle
#

i just need 898

#

xD

wet breach
#

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

quaint mantle
#

its fine the server has 32 gb ram

wet breach
#

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

agile anvil
#

It seems like you're playing with c pointers

wet breach
#

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

fallen lily
#

Or

#

Spanned files i forgot the formal name

#

Its spanned in zip

#

You can have 4 pebibyte file thats actually just 10 bytes

wet breach
#

o.O

quaint mantle
#
Bulbasaur``` i am pro coder
minor junco
#

Sicc

native ruin
#

yes you are!

quaint mantle
#

well big thanks <3

#

now i can finish this plugin maybe today

native ruin
#

good luck

quaint mantle
#

i will surely comeback for map renderers

wet breach
#

good news

#

we know how to do those things too πŸ˜„

quaint mantle
#

:)

#

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

native ruin
#

no one's code is clean their first iteration

wet breach
#

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

native ruin
#

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

wet breach
#

lmao

quaint mantle
#

yea imma just quickly clean up and write boat of load code to test at once

#

wow really reduced 20 classes to 3 classes

native ruin
#

oh dayyum

#

how much repeating code did you have

quaint mantle
#

alot

#

child.delete(); this just sounds wrong

eternal oxide
#

Sounds fine to me

quaint mantle
#
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
eternal oxide
#

restart IDE

#

cleared cache?

worthy star
#

?paste

undone axleBOT
worthy star
hybrid spoke
#

has people found a way to check for specific entities in an area more efficient than iterating over all world entities yet?

hybrid spoke
#

so its up to me

eternal oxide
worthy star
#

ok

worthy star
#

the only class in commands package is TestCommand with command name "heal"

#

and it souted heal

eternal oxide
#

is heal in your plugin.yml?

#

getCommand reads teh entry from plugin.yml

#

If it's not there it returns null.

worthy star
#

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

inner mulch
#

are the components in 1.20.5 on items gonna change how pdc work?

hybrid spoke
wet breach
#

o.O

#

but if its not dropped then it isn't an item yet?

#

well an item entity

sterile flicker
#

how to set a texture for an item, without custom model data, since it is not available in 1.12.2?

chrome beacon
#

You can use damage values on items to change the texture/model

eternal night
#

that is half the point of creating an API

sterile flicker
quaint mantle
inner mulch
quaint mantle
# quaint mantle yo what

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

eternal oxide
chrome beacon
chrome beacon
quaint mantle
#

oh so theres no need to remove renderers?

chrome beacon
#

yeah

#

There's no renderer when a map is made that way

quaint mantle
#

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

sterile flicker
#

for example java ItemStack customItem = new ItemStack(Material.WOOD_HOE, 1, (short)1); json "overrides": [ {"predicate": {"damaged": 1, "damage": 0}, "model": "item/wooden_hoe"} ]

chrome beacon
#

I don't remember the exact name of the predicate

#

Haven't worked with that in years

quaint mantle
#

how can i make this look bigger?

#

its a buffered image

inner mulch
#

using a bigger image, or is the image alr big?

echo basalt
quaint mantle
quaint mantle
#

like does bukkit have a thing for it or i need to use java

echo basalt
#

uH

quaint mantle
#

whats the size of minecraft map?

echo basalt
#

128x128

eternal oxide
sullen marlin
quaint mantle
#

no ik how to do it using java but like i dont know how big is map

#

is it like 100x100?

sullen marlin
#

128*128 I think

trail pilot
#
[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

sullen marlin
#

whats the question

trail pilot
#

Why the enchants doesn't get added to the item?

#

why when I serialize and Item the enchant doesn't get applied?

spice furnace
#

can you send where you serialize the item

sullen marlin
#

they should, where is your serialization code

trail pilot
#

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

sullen marlin
#

share the code

trail pilot
#

In 1.20.1 the /kit <name> give the item enchanted

trail pilot
quaint mantle
#
                BufferedImage simage = image.getScaledInstance(128,128, Image.SCALE_DEFAULT);```
#

its a bufferedimage

trail pilot
#

!paste

#

hm

trail pilot
sullen marlin
#

that's definitely not enough code to properly implement json serialisation

trail pilot
#

hm

sullen marlin
#

why not just use inbuilt yaml?

quaint mantle
trail pilot
sullen marlin
#
BukkitWiki

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

trail pilot
sullen marlin
#

yep

trail pilot
#

how to set the item stack?

sullen marlin
#

so just use kits.set and kits.getItemStack

trail pilot
#

List<String> itemsList = new ArrayList<>(); for (ItemStack item : kit.items()) { itemsList.add(item.toString()); }

correct?

sullen marlin
#

no, List<ItemStack>

trail pilot
#

yes sorry

tall dragon
# quaint mantle md_5 do u know?

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.

quaint mantle
#

oh okay

trail pilot
sullen marlin
#

? both ways List<ItemStack>

trail pilot
#

List<ItemStack> itemsList = BoxPvP.getInstance().getKits().getItemStack(key + ".items");

#

but getItemStack it's Object

#

not a list

sullen marlin
#

sorry yeah didnt realise list

#

use getList

#

will need to cast

trail pilot
# sullen marlin will need to cast
  - ==: 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
sullen marlin
#

looks correct

trail pilot
#

alr

trail pilot
ivory sleet
#

@inner mulch

#

I figured something out you might wanna test btw

sterile flicker
#

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

tall dragon
#

multiple

inner mulch
ivory sleet
# inner mulch What?

Well did you figure it out to make it atomically safe for read-modify-writes yet?

inner mulch
ivory sleet
#

Maybe maybe

#

not sure if it would work but it might be worth testing

inner mulch
#

Okay, what is it?

ivory sleet
#

well four things

#

Have you tried encapsulating a…

  1. RAtomicLong
  2. normal AtomicInteger/Long
  3. one of those RMaps
  4. a normal Map
    … inside ur data object?
#

the maps have an operation called replace(K key, V newVal, V oldVal)