#help-development

1 messages · Page 1879 of 1

dusk flicker
#

Souts are the only true debugger

lost matrix
#

Sure. Go ahead and try to explain to him how to setup debugging for spigot.

dense heath
#

He's making a plugin, right? lmao

tropic stream
#
        getConfig().options().copyDefaults();
        saveDefaultConfig();
analog prairie
#

How can I get online player list?

tropic stream
#

Should that generate a config file as long as i have stuff in the config

tropic stream
#

it doesnt but i want it too

dense heath
lost matrix
dense heath
lost matrix
dense heath
#

Sure, you could do it with a stream, but it is nicer with an array

lost matrix
# dense heath Random select an element
    Collection<? extends Player> playerCollection = Bukkit.getOnlinePlayers();
    Optional<? extends Player> randomPlayer = playerCollection.stream()
        .skip(ThreadLocalRandom.current().nextInt(playerCollection.size()))
        .findFirst();
lost matrix
#

Doesnt matter

#

Just an example that you can in fact do it 😄

wintry mural
#

Has anyone encountered an error loading values from bukkit enums, 'Cannot be resolved or is not a field", This code was working but suddenly stopped, seems to only be newish blocks, lectern doesnt work either. Any help appreciated

Pom:

    <repository>
        <id>spigot-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>
    <dependency>
           <groupId>org.spigotmc</groupId>
           <artifactId>spigot-api</artifactId>
           <version>1.18-R0.1-SNAPSHOT</version>
           <scope>provided</scope>
    </dependency>
dense heath
eternal night
#

Sounds like a dependency is pulling in outdated spigot API

#

Micro optimization is pretty irrelevant. Using a plain array instead of an array list wrapper is also pretty irrelevant

dense heath
#

Surely you didn't just say micro optimization

wintry mural
#

ahh yep, looks like it weird

eternal night
#

Overall most certainly lol

dense heath
eternal night
#

Unless that code is hot as fuck it doesn't matter

lost matrix
#

copying a collection to an array is an O(n) operation + it uses extra memory.
Skipping n elements in a Stream is really not a big deal.
I would argue that the difference is negligible in this case

wintry mural
#

yeah im not sure what the deal is, the spigot api (1.18) is there, but there is also Bukkit 1.13.1

eternal night
#

You'll have to figure out what dependency pulls that in

#

And manually exclude it

#

Use Mavens dependency tree

lost matrix
eternal night
#

mvn dependency:tree presumably

wintry mural
#

nah, vault is pulling it in

dense heath
lost matrix
dense heath
tender shard
lost matrix
#

You dont. If they have the chunk then they can see the block.

wintry mural
#

Fixed it, thanks guys

tender shard
#

raytracing

#

or easier, if a block is surrounded from all sides with solid blocks, noone can see it anyway

lost matrix
#

Oh you mean direct vision.
Ray tracing. But thats really expensive.
What anti xray engines normally do is check all 6 directions around a block and make it visible if one side is not obstructed (air)

cold field
#

Hi guys quick question. I need to retrieve the total slots of a server (linked through bungee) when there is no one online (Start-up process). Does anyone know how to do this using CustomPluginMessages?

tender shard
dense heath
lost matrix
tender shard
#

I'd use redis too

lost matrix
#

Topics 😄

cold field
#

😦

#

I will go checkout what's redis

tender shard
#

it a key/value db

#

it's like cheap mysql lol

dense heath
dense heath
lost matrix
ivory sleet
#

Yeah redis is damn powerful

tender shard
dense heath
ivory sleet
#

Well then you didn’t need redis in the first place

cold field
#

So I would need to create a bungee plugin that put the total slot of a server inside a redis db and then from my plugin retrieve that value?

ivory sleet
#

Hopefully you got sth like postgre in that case

dense heath
cold field
#

mh, ty

lost matrix
#
# Run complete. Total time: 00:08:02
Benchmark                                (elements)  Mode  Cnt  Score    Error  Units
RandomElementBenchmark.randomFromArray           10  avgt    5  0,029 ±  0,001  us/op
RandomElementBenchmark.randomFromArray          100  avgt    5  0,095 ±  0,001  us/op
RandomElementBenchmark.randomFromArray         1000  avgt    5  0,858 ±  0,056  us/op
RandomElementBenchmark.randomFromStream          10  avgt    5  0,047 ±  0,001  us/op
RandomElementBenchmark.randomFromStream         100  avgt    5  0,139 ±  0,001  us/op
RandomElementBenchmark.randomFromStream        1000  avgt    5  1,418 ±  0,033  us/op

If it would be x10 (1000%) slower then i would consider it an optimization.
Its not even 50%

#

I mean the BlockFaces

dense heath
lost matrix
#

up, down, west etc

lost matrix
dense heath
#

I'll take the dub on "still faster" though :,)

lost matrix
#

Sure... i wouldnt use a stream like that either

dense heath
#

Let's see that benchmark code, though

lost matrix
#

?paste

undone axleBOT
ivory sleet
lost matrix
dense heath
ivory sleet
#

Oh okay

#

Guess I’m in then

dense heath
#

Let's also ditch the rng

lost matrix
dense heath
dense heath
lost matrix
#

Making a field just for a tiny bit of performance improvement smells like micro optimization

dense heath
lost matrix
#

convenience > performance

dense heath
lost matrix
lost matrix
#

Dont use raytracing. You will tank every servers performance into oblivion.

dense heath
tender shard
dense heath
#

Let's get rid of jump instructions as a whole, while we're at it

lost matrix
#

Anti x-ray usually is done like this:

  1. Monitor outgoing chunk packets
  2. Parse them and replace every invisible block with stone.
  3. Invisibility is determined like this: If the block has any relative block (regarding the 6 faces) of type air it is visible.
  4. If a player comes near an obstructed block or a player frees an obstructed block you send a block update packet with the real data
    @quaint mantle
tacit drift
dense heath
#

You cannot detect if the player is in F5. At this point, you're looking for a mod.

#

Since the application you want to use it for is anti-xray, you'd be better going off with 7's recommendation instead of trying to do the math here

#

A cube has six sides. Blocks are cubes, so blocks have six sides. A player would not be able to see a block if all six sides of the block are obscured by another block

#

It would be best to cache the block visibility status somewhere and then only update adjacent blocks on block updates

#

That will grant you the best performance at the sacrifice of some memory

#

Is there practical application for this xray plugin or are you making it for learning purposes?

#

Why not?

#

Hypixel is not 100% custom

#

Block visibility status is just if the player can see it or not

#

They use WorldEdit

#

Block updates is just talking about breaks, places, stuff like that

lost matrix
#

Then be prepared for years of development. And at your stage you can add another year for learning stuff and then scrapping your whole code
a year later because you then cringe at your old code. Been there.

quaint mantle
#

Just hide your plugins from public lol

dense heath
#

Real chads make all their plugins custom, like this guy ^^^^ (toto)

#

Good luck.

tacit drift
#

it's cringe to make a server that uses ONLY plugins made by you if you want to make something complex

dense heath
#

The more time that passes, the worse it will get lol

quaint mantle
#

Real chads do not spend time for nothing and reinventing the where, but actually doing unique stuff

tacit drift
#

for example, would you want to pretty much remake worldedit?

dense heath
tacit drift
#

or make your own placeholderapi?

dense heath
ivory sleet
#

Depending on what features the task can be colossal

dense heath
distant granite
#

🍔

tacit drift
#

burghir

dense heath
#

Nothing is hard, you just have to be willing to spend time on it

ivory sleet
#

Yeah, and the bigger the project potentially becomes, the more design problems you’ll have to face and address, which can be hard

dense heath
ivory sleet
#

That very much depends on what features you add as said before

#

We also need to concretize the definition of simple

dense heath
#

Sounds about right. Good luck

dense heath
ivory sleet
#

That’s besides the point, what I mean is how do you define simple as a measurement, since you did use the adjective.

dense heath
#

The features of WorldEdit are simple. You have two points and you manipulate the space between them.

ivory sleet
#

Yes in abstract terms

#

If everything you mean by worldedit is simply that, without any concerns of anything else, then creating your worldedit might be a simple task in terms of both difficulty and time.

dense heath
#

More of a discussion

ivory sleet
#

Tho when I refer to worldedit I don’t mean just two points, I mean the entire project.

dense heath
ivory sleet
#

You disregarded a lot of other things as well, but sure

dense heath
ivory sleet
#

Sure go on (:

dense heath
#

Mirroring the entire project, WorldEdit is extremely easy in terms of difficultly, but very time consuming. It would be a lot of easy work, essentially

#

I would love for you to name a feature of WorldEdit that I'm forgetting that is ridiculously difficult to implement ;)

#

bUt WhAT aBoUT ThE PaTtErNs, bK?!//?!1

#

😂

ivory sleet
#

Yes I remember that command you did lol

dense heath
ivory sleet
#

Actually depends on requirements a bit, but let’s say we have the non functional requirement of speed and performance in terms of space. That can be an easy task if we make it a functional requirement but if not, it can be a bit difficult arguably.

dense heath
#

10 minutes of setup for ~10 seconds of code writing

ivory sleet
#

🌞

analog prairie
#

my event doesn't fire

#

Does anyone know what's wrong?

hybrid spoke
#

javas naming convention is a thing

#

but anyways, did you register your listener?

analog prairie
#

In main class

#

getServer().getPluginManager().registerEvents(this, this);

hybrid spoke
#

this, this

#

you just registered your main class

#

you need to register an instance of your listener class

#

getServer().getPluginManager().registerEvents(new eventlistener(), this);

dense heath
tender shard
#

and your methods too

#

you literally use ClassNames for methodNames and methodNames for ClassNames

dense heath
tender shard
#

I know but it's just confusing

dense heath
#

Nah, it isn't that bad

#

I doubt they'll even want to share their code for a while

tender shard
#

it's very bad because it makes them not understand the difference between classes and methods etc

tender shard
#

ThisIsAClass.andThisIsItsField

dense heath
#

Sure, it is convention, but if he wants to define his own local convention as having things named in lower camel case for classes and upper camel case for methods than that's his business

#

It is along the same line as operator overloading in C++

tender shard
#

of course but obviously he has no idea what he's doing so better to stick to the "rules" and learn it the proper way from the beginning

dense heath
tender shard
#

I didnt critize, I just said "please give your classes proper names"

quaint mantle
#

Why not help him along while he's figuring things out.

spiral light
#

isnt it helping if someone will never make an mistake with classnames/methodnames because he fears mfnalex ?

ivory sleet
spiral light
ivory sleet
#

I didn’t say bad

#

I said not perfect

#

What do you mean by flawlessly also?

analog prairie
#

Can I trun Bukkit.getOnlinePlayers() to Array<String> list?

spiral light
#

limit the time per tick where it places stuff for example ^^

tender shard
#

can I get the NMS Item from a Bukkit Material?

ivory sleet
#

Yeah

tender shard
#

if so, how? 😄

ivory sleet
#

Believe there’s a craft class

quaint mantle
#

CraftMagicValues

#

I think

ivory sleet
#

^

#

Yeah probably that

tender shard
#

wtf is that lol

#

CraftMagicValues? 😄

spiral light
#

its magic

lost matrix
#

CraftItemStack.toNMS(org.bukkit.ItemStack) i believe

tender shard
#

Thanks ill check it out lol

quaint mantle
tender shard
#

hm so it requires me to create an itemstack

quaint mantle
#

Ah wait

spiral light
#

CraftMagicNumbers

analog prairie
#

Can I trun Bukkit.getOnlinePlayers() to Array<String> list?😣

lost matrix
#

Why do you want to do that?

young knoll
#

What is an Array<String> list

ivory sleet
#

Kotlin

#

(:

analog prairie
ivory sleet
#

Too bad

spiral light
quaint mantle
#

ugh

spiral light
#

ah nvmd ^^

lost matrix
ivory sleet
#

The players that are online have no notion of order, especially by index

lost matrix
#

If you want to refer to a player, do it by their UUID

analog prairie
lost matrix
#

And why do you need an indexOf method for that?

spiral light
#

you shouldnt need an index of a player then

analog prairie
ivory sleet
#

Thonk

lost matrix
#

Im confused...

analog prairie
#

So is there any way to get players as list?

quaint mantle
spiral light
lost matrix
# analog prairie So is there any way to get players as list?

Just

  public List<String> getOnlinePlayerNames() {
    List<String> names = new ArrayList<>();
    for (Player player : Bukkit.getOnlinePlayers()) {
      names.add(player.getName());
    }
    return names;
  }

or simply

  public List<String> getOnlinePlayerNames() {
    return Bukkit.getOnlinePlayers().stream().map(Player::getName).toList();
  }
quaint mantle
maiden briar
#

@ivory sleet How to make a non-moving visual effect? Because if I do this world.playEffect(point, effect, data); the particles are moving up

ivory sleet
#

I believe that’s out of control?

young knoll
#

Set the speed to 0

ivory sleet
#

Unsure tho

spiral light
maiden briar
#

Where to set the speed?

young knoll
#

There’s an overloaded method with a speed parameter

spiral light
#

check the other methods with more arguments

maiden briar
#

Ok thanks

young knoll
#

Actually it may be called int extra, idk

maiden briar
#

Nope still moving

#

spawnParticle has the same problem

worldly ingot
#

playEffect() is client-driven, you have no control over how that looks. spawnParticle() may or may not respect the extra/speed data

#

Again, client-driven

#

If it doesn't respect speed, you can't make it sit still

upper niche
#

if you want to control movement for spawnParticle you want to set the amount to 0

maiden briar
#

How did Hypixel do that then?

worldly ingot
#

What particle is it?

maiden briar
#

For example, DRAGON_BREATH

ivory sleet
#

Yeah the client could just decide to make the particles on your screen go nuts

worldly ingot
#

Some particles don't even support speed 0, so you may have to set it to speed 0.0001

maiden briar
#

Good idea

worldly ingot
#

The particle arguments are so dependent on the particle it's insane

worldly ingot
#

Then the RGB is the offset params

lean bone
#

Hey there. I'm trying to get BuildTools to build me a JAR that contains the CraftBukkit stuff and the NMS stuff, but I can't get it to work. I've had successful builds using the following commands: java -jar BuildTools.jar --rev 1.18.1 and java -jar BuildTools.jar --rev 1.18.1 --compile craftbukkit. I added both to my Gradle build file, but haven't had any success on either. The normal bukkit things work, but I don't have any of the CraftBukkit stuff (CraftArmorStand for example) and NMS classes for things like packets I also cannot find. Can anyone help me?

worldly ingot
#

It doesn't use DustOptions like redstone does

tender shard
maiden briar
#

Ok will set count to 0

ivory sleet
dense heath
#

A simple task, if you asked me personally

tender shard
#

Another question: in Remapped 1.18, the maxStackSize of an NMS Material ("Item") is Item.maxStackSize. It's private though so I need Reflection. However, special sauce plugin doesn't translate it so I still have to find out the obfuscated name "c" in this case. Is there ANY WAY I can set the private field WITHOUT reflection, or make the special sauce plugin translate it for me anyway?

(Because right now I will have to update my setMaxStackSize method for every new NMS version)

maiden briar
#

Still moving

worldly ingot
#

heh, special sauce

ivory sleet
tender shard
worldly ingot
#

Special source

#

but I like sauce better

ivory sleet
#

The requirement as said is non functional so you won’t be able to match your implementation against anything bk

quaint mantle
tender shard
#

so my question in short: can remapped work with reflection or do I ALWAYS have to use obfuscated mappings for reflection?

tender shard
quaint mantle
#

A library by jpenilla; allows you to work with reflection on mappings

tender shard
quaint mantle
tender shard
quaint mantle
#

Thats a reflection-remapper actually

tender shard
quaint mantle
#

It also has very cool reflection proxies

tender shard
#

oh well that doesn't look too easy

maiden briar
#

I found out that some particle types are indeed not supported

ivory sleet
#

Ye

subtle folio
#

is there any other way of generating blocks in a 10 by 10 besides looping through the x and looping through each z?

spiral light
subtle folio
spiral light
#

the api dont provides something like that.
Where is the problem with looping ?

subtle folio
#

its a little annoying

#

and hard for my head to wrap around

dense heath
spiral light
# subtle folio its a little annoying

you only need to do it once... as a little help you can create a BoundinxBox to get the lowest Position and highest Position... but thats something you can calculate faster too

dense heath
#

xd

spiral light
#

then just calculate minX, maxX and minZ and maxZ ... 4 lines for all^^

subtle folio
#

ok ok

ivory sleet
wooden fable
#
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.724 s
[INFO] Finished at: 2022-01-11T16:58:06+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project LostKingdomDSRV: Could not resolve dependencies for project me.Branchyz:LostKingdomDSRV:jar:1.0: The following artifacts could not be resolved: net.kyori:adventure-platform-api:jar:4.0.0-SNAPSHOT, net.kyori:adventure-text-serializer-bungeecord:jar:4.0.0-SNAPSHOT, net.kyori:adventure-platform-facet:jar:4.0.0-SNAPSHOT, net.kyori:adventure-platform-viaversion:jar:4.0.0-SNAPSHOT: net.kyori:adventure-platform-api:jar:4.0.0-20210914.041527-74 was not found in https://hub.spigotmc.org/nexus/content/groups/public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigotmc-repo has elapsed or updates are forced -> [Help 1]
        <!-- Spigot -->
        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
        </repository>

        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.12.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>

I'm getting a error when i'm trying to build, does any1 know what the problem is?

hardy swan
#

Give a better read to the description

peak needle
#

Metadata

undone axleBOT
wooden fable
hardy swan
wooden fable
#

Thx, that worked!

dense heath
ivory sleet
#

and nil

dense heath
#

Whatever you may call it, I've been memeing the whole time

ivory sleet
#

Yeah I have been serious, as just trolling around doesn’t help anyone here really

quaint mantle
#

Since .getDurability is now depricated, what am I supposed to use to fix my items?

hardy swan
#

Is there a plugin for developers to more easily test their plugins? Things like commands to listen to events and loggin em, changing player's uuid to test shop plugins etc.

hardy swan
#

If you can somehow simulate an entire server sure

rich creek
#

Hi

hardy swan
#

Hi

rich creek
#

Somebody can help me?
I don't know what is the problem with my plugin:c

hardy swan
#

Do state the problem

candid galleon
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

quaint mantle
rich creek
#

This event is not working

@EventHandler
   public void JugadorEntraACama(PlayerBedEnterEvent e) {
      Location playerbed = e.getPlayer().getBedSpawnLocation();
      Boolean weather = this.OverWorld.hasStorm();
      Long time = this.OverWorld.getTime();
      if (weather || this.Dias >= 20L || time < 13000L) {
         e.getPlayer().setStatistic(Statistic.TIME_SINCE_REST, 0);
         e.getPlayer().sendMessage(Main.PluginName + " Se ha reseteado tu sueño");
         e.getPlayer().getWorld().createExplosion(playerbed, 0.0F);
         e.setCancelled(true);
      }

   }```
rich creek
#

Noup

#

Just don't work

hardy swan
ivory sleet
candid galleon
#

check if the if statement is true

ivory sleet
#

MockBukkit would allow you to essentially to do unit tests with mocks

hardy swan
#

Noice, thanks

crude estuary
gritty urchin
#

in your main class?

rich creek
#

Yes

#

Uhm

gritty urchin
#

Can you send us your main class?

rich creek
#

Oka

#

It's large

gritty urchin
#

?paste

undone axleBOT
rich creek
# tranquil adder show "Dias" field
                if(this.getConfig().getString("Fecha").isEmpty()) {
                    int Dia;
                    int Mes;
                    int Año;
                        Dia = this.Actual.getDayOfMonth();
                        Mes = this.Actual.getMonthValue();
                        Año = this.Actual.getYear();
                        String fecha = "";
                
                        if (Mes > 10) {
                            fecha= Año + "-" + Mes; 
                        }else{
                            fecha= Año + "-0" + Mes;
                        };
                        if (Dia > 10) {
                            fecha= fecha + "-" + Dia;
                }else {
                    fecha = fecha + "-0" + Dia;
                };
                 this.getConfig().set("Fecha",fecha);
                 this.saveConfig();
                 this.reloadConfig();
                      
                      System.out.println(ChatColor.translateAlternateColorCodes('&', PluginName+" &fSe ha cambiado la fecha de inicio a &c" +fecha));
                    }else{
                    System.out.println(ChatColor.translateAlternateColorCodes('&', PluginName+" &fFecha de inicio: &c" +fecha));
                        };

                          this.Inicio = LocalDate.parse(this.getConfig().getString("Fecha"));
                          this.getDays = this.Inicio.until(this.Actual, ChronoUnit.DAYS);
                          if(this.getDays == 0) {
                              this.getDays = 1;
                              System.out.println(ChatColor.translateAlternateColorCodes('&', PluginName+ " &fDía de inicio detectado"));
                              }`;```
crude estuary
#

with the Paste System

rich creek
#

This?

#

U can see?

subtle folio
#

register events?

rich creek
crude estuary
#

Ok

rich creek
# subtle folio register events?
        instance = this;
        pm.registerEvents(new JugadorEventos(instance), instance);
        pm.registerEvents(new Cambios(instance),instance);
        registrarComandos();```
subtle folio
#

ok maybe im blind then

rich creek
#

I have seen example codes.
And some have an "final" before the "PlayerBedEnterEvent"
What's that?

spiral light
#

the value can not be changed anymore

crude estuary
#

Because it's... yes

rich creek
#

Uh?

tranquil adder
#

hey @rich creek

#

what do you want to do?

#

your code is very confuse

crude estuary
#

not Modifiable

young knoll
#

Putting final before the event ensures it can’t be reassigned

spiral light
# rich creek Uh?

if you have:
final Player player = ....

you cant modify the player-variable later

crude estuary
#

Just to make sure that it doesn't get Touched by some other Thing

hasty prawn
young knoll
#

Pretty much

rich creek
# tranquil adder what do you want to do?

Ok.
My server is a HardCore Server .
When someone dies, hours of rain are set relative to the number of days that have passed.
But, when some player sleep, the rain goes away.

#

Likes ElRichMc Permadeath Proyect.

crude estuary
#

But you don't have to Cancel the Event

#

Just change it

rich creek
#

So?

crude estuary
#

so, you don't want People to Remove the Rain by Sleeping?

rich creek
#

Yes

crude estuary
#

Disable the Beds when it Starts Raining

#

so it does not have to be Cancelling the Event Every time

young knoll
#

Or you can restore the rain after they sleep

crude estuary
#

Exactly

rich creek
rich creek
crude estuary
#

there's an Event like PlayerExitBedEvent?

#

i don't Remember

tranquil adder
crude estuary
#

Ok

rich creek
#

Yes

tranquil adder
hasty prawn
#

You'd want to cancel PlayerBedEnterEvent to disable beds

#

If you cancel PlayerBedLeaveEvent they'll just be stuck in the bed KEKW

rich creek
young knoll
crude estuary
#

it was to Remove the Rain

hasty prawn
#

Either way Pbt, Coll's idea is better.

tranquil adder
# rich creek Yeah
    @EventHandler
    private void onPlayerBedEnter(PlayerBedEnterEvent event) {
        event.setCancelled(event.getPlayer().getWorld().hasStorm());
    }
analog prairie
#
[00:39:09] [Timer-15/WARN]: Exception in thread "Timer-15" java.lang.IllegalStateException: Asynchronous player kick!
[00:39:09] [Timer-15/WARN]:     at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14)
[00:39:09] [Timer-15/WARN]:     at org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer.kickPlayer(CraftPlayer.java:346)
[00:39:09] [Timer-15/WARN]:     at handler.player.kickplayer(player.java:52)
[00:39:09] [Timer-15/WARN]:     at handler.player.check(player.java:42)
[00:39:09] [Timer-15/WARN]:     at handler.timer.run(timer.java:9)
[00:39:09] [Timer-15/WARN]:     at java.base/java.util.TimerThread.mainLoop(Timer.java:566)
[00:39:09] [Timer-15/WARN]:     at java.base/java.util.TimerThread.run(Timer.java:516)
tranquil adder
analog prairie
#

What's wrong?

crude estuary
rich creek
tranquil adder
analog prairie
#
public static Runnable kickplayer(String player,String msg) {
        Objects.requireNonNull(Bukkit.getPlayer(player)).kickPlayer(msg);
        return null;
    }

This is async?

hasty prawn
#

If you're calling it async it will be

rich creek
#

Thanks for the help duke

spiral light
#

method with just 2 lines and it will always return null but you want an Runnable ???

young knoll
#

Just don’t call it with an invalid name :p

#

The return type is a bit... weird

naive jolt
#

@tranquil adder still not working

#

I hate spigot now xD

tranquil adder
#

you changed the plugin.yml?

#

lul

naive jolt
#

yeah

#

so the folders are

#

com.forbiddenbox.me.swsutils
>Commands (folder)
NPC
SwSUtils (Main)

tranquil adder
#

this is package name

#

look example

#
name: Test
version: 1.0.0
main: com.viiictorxd.test.TestPlugin
#
package com.viiictorxd.test;

import org.bukkit.plugin.java.JavaPlugin;

public class TestPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        System.out.println("Plugin successfully enabled");
    }
}
#

main class package name (com.viiictorxd.test) + main class name (TestPlugin)

#

result: com.viiictorxd.test.TestPlugin (main class)

naive jolt
#

Ah let me just double check

#

I think I found the problem maybeeee

tranquil adder
#

🥳

naive jolt
#

Im comparing

#

it to my other plugin

tranquil adder
#

if you can't solve the problem, mark me

#

i still will try help you

#

😂

naive jolt
#

Appreciate that

#

and yeah its not working

tranquil adder
#

let's try again kkkk

#

now it's will work

#

send me last recent error, plugin.yml and main class

naive jolt
tranquil adder
#

hey...

#

are you using eclipse or intellij?

naive jolt
#

InteliJ

tender shard
#

Ctrl+Alt+M in Intellij isnt working for me 😦

#

does it work for you people?

tranquil adder
naive jolt
naive jolt
tranquil adder
naive jolt
#

yeah let me go to imgur

naive jolt
tender shard
#

did you have sth selected that could be refactored into a method?

tranquil adder
tender shard
#

it should do this: (1 sec)

tender shard
#

weird

tranquil adder
tender shard
#

yeah it works for me only by using the menu

#

but not using the hotkey

tranquil adder
#

i have used hotkey

tender shard
#

try the hotkey

daring lark
#

@EventHandler
public void EntitySpawnEvent(org.bukkit.event.entity.EntitySpawnEvent e)
{
Entity mob = e.getEntity();
if(mob instanceof Zombie)
{
ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemMeta meta = chestplate.getItemMeta();
meta.addEnchant(Enchantment.DURABILITY , 5 , true);
meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL , 5 , true);
meta.setDisplayName(ChatColor.AQUA + "Zombified chestplate");
chestplate.setItemMeta(meta);
((Zombie) mob).getEquipment().setChestplate(chestplate);
((Zombie) mob).setHealth(10000);
mob.setCustomName("Zombie Minibos");
mob.setCustomNameVisible(true);
}
}

I don't know why when i'm spawning zombie he doesn't have custom name and he has basic hp?

spiral light
#

how do you spawn it ?

daring lark
#

it's all in SpawnEvent

tranquil adder
#

if (mob.getType() == EntityType.ZOMBIE) { }

tender shard
tranquil adder
daring lark
#

so it's not this

tranquil adder
tranquil adder
naive jolt
#

internet sucks rn wth

naive jolt
#

finally

tranquil adder
daring lark
naive jolt
#

uploaded

tranquil adder
daring lark
#

my game is glitched

tranquil adder
tranquil adder
#

what's wrong with your code 😂

naive jolt
#

bruh xD

#

there are no errors anywhere too

#

what about pom.xml

tender shard
daring lark
tranquil adder
daring lark
#

lol it's now working

#

i'm on 1.18

sacred osprey
#

I own a premium plugin, but decided to make it free from now on. How would I do that? Website wont allow me to set price to 0 😄

tranquil adder
daring lark
tranquil adder
#

kkkkkkkkkkkkkkkkkkkkk

daring lark
#

it's happening when i'm adding line which is setinghealth

tranquil adder
#

i think you can't change the life to 10000

#

i THINK the max is 2024

daring lark
#

i know what is wrong

daring lark
sacred osprey
daring lark
#

i'm setting it to 1000

tranquil adder
tranquil adder
maiden briar
tranquil adder
sacred osprey
#

Well I added the github link today, but being paid and open source is not mutually exclusive.

ancient plank
#

many premium resources do that ^

#

most people take it like, you're paying for support etc

sacred osprey
#

Yea anybody could build the plugin themselves, but by buying it you support the development and support etc.

ancient plank
#

plus, 9/10 times the people who self-compile probably wouldn't actually buy the plugin anyways kek

daring lark
# tranquil adder ok, try and say me if it's works

i can't set hp of zombie by calling function

void processZombie (Zombie zombie) {
ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemMeta meta = chestplate.getItemMeta();
meta.addEnchant(Enchantment.DURABILITY , 5 , true);
meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL , 5 , true);
meta.setDisplayName(ChatColor.AQUA + "Zombified chestplate");
chestplate.setItemMeta(meta);
zombie.getEquipment().setChestplate(chestplate);
zombie.setCustomName("Zombie Minibos");
zombie.setCustomNameVisible(true);
zombie.setHealth(1000);
}

coarse shadow
#

i dont get any error in console but i can still spawn with egg

vocal cloud
#

check what e.getEntity().getWorld() returns

coarse shadow
#

it returns world aight but how do i get a world from config then

tranquil adder
vocal cloud
coarse shadow
#

lol

tranquil adder
coarse shadow
#

getWorld.getName?

vocal cloud
#

try it

exotic obsidian
#

hello guys

chrome beacon
#

What's the problem

exotic obsidian
#

I have a problem with selling I can't sell

chrome beacon
#

You don't have any steak to sell

hardy swan
#

close inventory one tick later

exotic obsidian
#

i know

#

but i have

hardy swan
#

item wont be air

exotic obsidian
#

but it's 32

#

if i want to sell one i can't

vocal cloud
#

What does "I can't" mean please be descriptive?

exotic obsidian
#

I mean, if I have 32 pieces and I want to sell one piece, I can't even though I have 32 pieces!?

hardy swan
#

try my suggestion

#

also

#

Inventory#contains(ItemStack) tests the exact stack

spiral light
#

isnt it possible to set a block to chest
and set something in the pdc of it in the same tick ?

spiral light
#

because i cant even with a delay:
it is never set with this code

tulip owl
#

Are there any good API's for custom config? I want to be able to get all yml files in a folder with it, a bit like how DeluxeMenus gets their config.

jagged bobcat
#

Make one

hardy swan
waxen plinth
#

I have a config library

spiral light
hardy swan
#

yea that, did you forget that

spiral light
#

i dont use blockdata to get pdc ?... its directly in state

#

oh

#

state ... update() ... -.-

glossy venture
#
public class ExamplePluginClass extends JavaPlugin {
    final ConfigurationWrapper myCustomConfig = new ConfigurationWrapper(this, new File("myCustomConfig.yml"));
    @Override
    public void onEnable() {
        // load config
        myCustomConfig.trySaveDefault(/* overwrite */ false);
        myCustomConfig.reload();
    }
}
tulip owl
#

Thanks, i'll give them a look

glossy venture
#

lmfao

modern vigil
#

What's the event for a grass block changing to dirt when a block is above it? I've asked before but all those events didn't do the trick for me

glossy venture
#

maybe BlockFormEvent

#

nevermind

main matrix
#

Any way to check when a method was implemented?

glossy venture
#

using reflection?

#

like are you overriding or are you just declaring

manic furnace
#

I only have to worry about the libraries that are actually in my jar, not all that i have downloaded, right?

main matrix
#

Using abstraction, want to know when the Player#sendTitle method was implemented

glossy venture
#

because if its abstract or in an interface then it has to be

#

so theres no point in checking because you cant instantiate an abstract class or interface

main matrix
glossy venture
modern vigil
#

imma try that again

glossy venture
#

or maybe blockformevent

#

because its forming a dirt block

#

i guess

main matrix
glossy venture
#

ohh

#

i guess you could use

try {
  player.sendTitle(...);
} catch (UnsupportedOperationException e) { }
#

and wrap that in a method

#

i dont think theres a way to only check it

#

except through bytecode analysis

#

@main matrix

eternal oxide
#
        try {
Player.class.getMethod("sendTitle");
        } catch (Exception ex) {
            // Server too old to support command.
        }```
glossy venture
#

wait does he mean like it throwing an UnsupportedOperationException

#

or it actually not existing

tardy delta
#

it wont throw that

glossy venture
#

oh

tardy delta
#

a noclassdeffound or something

glossy venture
#

yeah i know

#

but some spigot methods threw that right

#

because they werent implemented yet

tardy delta
#

yeah the Player#spigot ones

glossy venture
#

yeah so i thought maybe it does it there too

quaint mantle
glossy venture
#

why would it be

#

you would need more api-implementation complexity

#

we would get like CraftSpigot or something

tardy delta
main matrix
#

Found another way by just changing the version in the docs link and using ctrl f to find the method.
Seems like sendTitle(title, subtitle, fade, stay, fade) was implemented in 1.11 :)

quaint mantle
quaint mantle
glossy venture
#

yes but we would need either a seperate CraftSpigot from CraftBukkit or a fork of CraftBukkit

glossy venture
quaint mantle
#

Why so

tardy delta
glossy venture
#

and CommandSender.Spigot

#

but yes

glossy venture
#

and you would have to put that somewhere

tardy delta
#

its like only send messages

glossy venture
#

yeah

#

ive never understood Collection, Set and List and what they promise

#

actually only what they promise

#

i know that List promises some degree of ordering or something

#

but thats it

quaint mantle
#

Ikr

#

But why cant you just put the implementation in craftbukkit?

glossy venture
#

yeah that would be possible

quaint mantle
#

Like, to make Spigot work you eill have to extend it as well

glossy venture
#

but whatever i just see no point in the extra effort

tardy delta
#

you also have Iteratable but that makes sense

glossy venture
#

yeah

quaint mantle
#

LoL you only get extra effort by throwing excwptions in every unimplemeneted method

glossy venture
#

what

quaint mantle
#

I dont see any reason of why Player.Spigot cant be just an interface

glossy venture
#

ok

quaint mantle
glossy venture
#

._.

quaint mantle
glossy venture
#

yeah i know

#

ah yes BeanContextServicesSupport is my favorite collection

#

oh ok so a Set promises no duplicates

#

a collection is ambigous and doesnt promise shit

#

only that it exists and has stuff

hardy swan
#

and promises that its implementing classes support basic operations like adding and removing elements from the collection

glossy venture
#

oh it has add

#

but that still falls under the catagory "i have stuff which may or may not be mutable"

modern vigil
#

this does smth

#

but it logs

hardy swan
modern vigil
#

CraftBlock{pos=BlockPosition{x=127, y=62, z=108},type=GRASS_BLOCK,data=Block{minecraft:grass_block}[snowy=false],fluid=net.minecraft.server.v1_16_R3.FluidTypeEmpty@48284d0e}

glossy venture
#

where did you get it from

quaint mantle
modern vigil
#

BlockFadeEvent.getNewState().getBlock()

quaint mantle
#

But okay lets forget this fucking design nightmare

glossy venture
#

in the current state

#

just log getNewState

modern vigil
#

why does it say getNewState

glossy venture
#

because the state is just a collection of data

#

its not something in a world

#

and it links back to the block

#

so just log getNewState

mellow edge
#

is sign a block or an entity?

hardy swan
#

the state is Dirt's default Block State, if you don't cancel the event that state will be updated

hardy swan
mellow edge
#

ty

quaint mantle
#

Tile entity to be exact

quaint bough
#

which events do you need to cancel in order to prevent movement of an certain item? There is so many different events with moving items (hotkey swap, clicking and dropping item or swapping an item, throwing the item out etc). Is there any examples of people doing this?

glossy venture
hardy swan
quaint bough
mellow edge
#

also is anyone here using intellij minecraft plugin to make plugins?

glossy venture
#

and InventoryClickEvent

#

i could find those

#

may be more

mellow edge
#

because I want to know how I can set the output directory in maven

quaint bough
#

InventoryMoveItemEvent is for hoppers

glossy venture
#

oh shit

#

InventoryDragEvent maybe but i dont know if this accounts for hotkeys

#

or shift click

quaint bough
#

yea that is what i mean so many different ways and if you cancel the wrong event you might cancel two times and it will clip in the inv

hardy swan
modern vigil
#

just

glossy venture
#

that is the block

#

getNewState().getBlock() is this block

#

the block is just a position

#

it will be changed after the event

modern vigil
#

so check the block at the location for a dirt block?

glossy venture
#

no because the event happens before it is applied

hardy swan
#

what are you trying to achieve lol @modern vigil

glossy venture
#

if you want to set what it changes to, i think you can modify getNewState() directly

modern vigil
#

check if the grass block changed to dirt

#

that's it

hardy swan
#

don't have to check, if it isn't cancelled, it will change

glossy venture
#

getNewState().getType() == Material.DIRT

modern vigil
#

tried that

glossy venture
#

and it was false

modern vigil
#

yes

glossy venture
#

i dont think it changes every time

#

does the block turn to dirt?

modern vigil
#

yes

#

but the block's type doesnt

glossy venture
#

then it might be the wrong event

hardy swan
glossy venture
#

this is really weird

#

it said that will be, suggesting that its the current state

modern vigil
#

it says getNewState()

#

but returns the old block?

glossy venture
modern vigil
#

seems weird to me

glossy venture
#

yeah

hardy swan
#

it isn't weird

#

you didn't understand what orby said

glossy venture
#

wait

glossy venture
modern vigil
#

just getBlock().getType()

glossy venture
#

you mean getNewState().getType()

#

i assume

hardy swan
#

don't do that

#

they both do the same thing

#

lmao

glossy venture
#

no because getBlock returns the block right

#

in the world

hardy swan
#

or equivalent

glossy venture
#

which has the current state

#

because the event is called before

#

or not?

modern vigil
#

so if I understand it right, I have to check the block after the event triggers?

glossy venture
#

no check the new state

hardy swan
#

yes but if you look into the method BlockState#getType(), it gets the block first before getting its material too

glossy venture
#

bruh

#

in CraftBlockState?

hardy swan
#

yes

#

anyways

modern vigil
#

lemme try getting the block in the world

hardy swan
#

trust the event with this, it will update unless the event is cancelled

modern vigil
#

so is there a way to get the block that the block faded into?

hardy swan
#

use the correct terms

#

block, yes

modern vigil
#

and the type?

glossy venture
#

but yeah as solar said just trust it it doesnt matter

#

if you still want the new material for some reason just use event.getNewState().getBlockData().getMaterial()

#

i checked the craftbukkit source

hardy swan
#

wait lmao i just checked how the event is fired

#

it seems like you won't be able to tell from the new state

glossy venture
#

no fucking way

#

bruh why

#

its the new state

glossy venture
hardy swan
#

wait nvm you can

glossy venture
#

ohk

hardy swan
#

BlockData yes

#

getBlockData

glossy venture
#

ok

#

where is it fired

#

is in in an nms patch

hardy swan
#

you can take a look at BlockDirtSnowSpreadable

#

randomTick method

modern vigil
#

that seems to have worked

glossy venture
#

wait is that nms class

hardy swan
#

yep

glossy venture
modern vigil
#

yes

glossy venture
#

oh nice

#

the fact that it references the block in the state is so stupid

hardy swan
#

BlockState stores the location

glossy venture
#

oh

#

and then it uses that to get the block to get the type?

hardy swan
#

yea...

glossy venture
#

w h a t

hardy swan
#

oh wells

#
@Override
public Material getType() {
    return CraftMagicNumbers.getMaterial(data.getBlock());
}
glossy venture
#

bruhhh

glossy venture
#

what package

hardy swan
#

net.minecraft.world.level.block

glossy venture
#

ah thx

#

ah shit i dont have mojang mappings

#
CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.j.getBlockData()
#

is that what fires it

hardy swan
#

yes

#

where j is DIRT

glossy venture
#

oh lmfao

#

obfuscating block names

#
public static final Block a;
``` my favorite block
hardy swan
#

make a wild guess

glossy venture
#

air

#
a = a((String)"air"
#

lmfao

hardy swan
#

oh lol

glossy venture
#

kinda cool to see the internals of the server

#

when looking at for example the block dispenser you can see the code behind something youve seen in action and taken for granted thousands of times

chrome beacon
#

Mojmapped makes things much better

glossy venture
#

yeah

#

im going to try to install it

#

or enable it

#

or whatever

#

using gradle

hardy swan
#

buildtools

chrome beacon
#

Ah use the userdev from Paper

#

Or use Maven

glossy venture
#

already intimidated by the lack of information i can find

#

what is loom

chrome beacon
#

Loom is for Fabric

#

And their mappings

hardy swan
#

banners maker

glossy venture
glossy venture
hardy swan
#

time to switch to fabric modding

#

heading to curseforge discord

glossy venture
#

lmao

spiral light
#

how would you use mojang mappings for different versions in maven ?

hardy swan
#

nvm you can't

#

unless you set up a multi-module project

glossy venture
#

do you think i can use loom for paper

hardy swan
#

where each separate module imports a certain version of the artifact

glossy venture
#

or actually spigot

spiral light
#

hmmm i think i will stick to the newest version only xD

hardy swan
#

yes force users to update

chrome beacon
glossy venture
#

ty

lyric oar
#

Hello, does someone have a working code to check if a player is in a specific area please? It's been few days i'm looking for something like this, and i coded a thing that worked a bit but i think my code isn't good

spiral light
#

?paste your code

undone axleBOT
lyric oar
#

okay

buoyant viper
lyric oar
ivory sleet
#

Store the location in a variable

#

But that looks not bad

lyric oar
hardy swan
#

isn't there a region class

#

or sorts

lyric oar
#

it works for tiny areas but it doesn't with very big area so i thought my code is wrong 🤷

ivory sleet
#

Yes

#

There’s

#

But it’s mutable iirc

spiral light
#

are you calculating what getX1 is ?
probably X1 and X2 are not min and max and cause some errors when not min/max declared

lyric oar
#

i can give you the whole class

spiral light
#

you can also create a boundinx box with 2 locations and check if the player boundinxbox hits this

lyric oar
#

it's just a class that save the coordinates of the area

lyric oar
hardy swan
#

ah yes boundingbox

#

that's what i meant

spiral light
#

its like the class you just created ... but with more functionality xD

#

and safer code then yours is since it calculates min/max from your input

lyric oar
#

Okay thanks

quaint bough
#

e.getCursor is the most useless thing ever

wide coyote
#

ok dont use it then

manic furnace
lyric oar
#

so the only solution i have is coding something myself to know if the player is in the area

spiral light
#

or just copy BoundingBox class ^^

lyric oar
#

good idea

#

but where can i find it?

spiral light
#

probably online

lyric oar
#

and even after copying it i wouldn't know how to use it for what i want

spiral light
#

if you want to code it yourself you should think about how to get the min Location and max Location and check if the player is between them

lyric oar
#

it should be ok if i copy it 🤷

vocal cloud
#

Copyright 2016 inventivetalent. All rights reserved.

lyric oar
#

ah

#

i should search for the official class but i can't find it

vocal cloud
manic furnace
vocal cloud
#

What license are you using?

manic furnace
#

Gplv3

vocal cloud
# manic furnace Gplv3

If you're creating an open-source Gplv3 plugin why would you need this? You only need to do this if their license requires it

manic furnace
#

Because spigot is under gplv3, and gplv3 says that i have to use the Same license

manic furnace
spiral light
lyric oar
#

okay, thanks

#

i'll try this

vocal cloud
manic furnace
vocal cloud
undone axleBOT
manic furnace
#

OK thanks

#

What mean Attribution notice?

vocal cloud
#

It's basically if the library or whatever has an attribution notice you must copy that over

If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
manic furnace
vocal cloud
lyric oar
# spiral light the only thing you should rly need is this part and a check whether the playerLo...

It works now, thank you very much!
I added this to my class and execute setMinMax method when a coordinate is added:

public boolean isPlayerInRegion(Player p) {
    Location pLoc = p.getLocation();
    double x = pLoc.getX();
    double y = pLoc.getY();
    double z = pLoc.getZ();
    return x >= this.minX && x < this.maxX
            && y >= this.minY && y < this.maxY
            && z >= this.minZ && z < this.maxZ;
}

public void setMinMax() {
    this.minX = Math.min(this.x1, this.x2);
    this.minY = Math.min(this.y1, this.y2);
    this.minZ = Math.min(this.z1, this.z2);
    this.maxX = Math.max(this.x1, this.x2);
    this.maxY = Math.max(this.y1, this.y2);
    this.maxZ = Math.max(this.z1, this.z2);
}
quaint bough
#

When I am calling my custom BagInventoryClickEvent whenever I pass through all variables and the events get called the e.getWhoClicked().getHolder() chances

main dew
#

hi do you know open source project use ASM?

quaint bough
#

?

main dew
#

ASM

main dew
quaint bough
#

no

main dew
#

oh but this was realy good

#

but I have problem with use this ;/

lavish hemlock
#

A few of my projects use it

#

What are you trying to use ASM for?

tender shard
#

what do you prefer?

ChatColor.RED + "" + ChatColor.BOLD
// or
ChatColor.RED.toString() + ChatColor.BOLD
lavish hemlock
#

The above performs an unnecessary stack push and method call

#

I'd probably create a function like format

#

which would be format(ChatColor..., String)

#

oh wait varargs are at the end

#

uhh

#

format(String, ChatColor...)

dry forum
#

if i have a java 16, 1.17 server, would a plugin made with java 17, 1.17 spigot api work on the java 16 spigot 1.17 server?

main dew
#

you can give me example? to apply change to exists class?

lavish hemlock
#

Is the class loaded?

#

If you can't answer that question, you shouldn't be doing ASM.

main dew
lavish hemlock
#

Then you can't apply changes to it.

#

JVM implementations typically disallow the modification of an already loaded class.

#

You have to apply transformations before the class is loaded, e.g. within a custom ClassLoader implementation or via instrumentation (java.lang.instrument)

main dew
#

I would like to override the already existing spigot classes

lavish hemlock
#

You require instrumentation then (as you can't change how Spigot loads via a Spigot plugin)

#

But there's a problem with that:

#

It's harder to set up for the end-user, AKA server owners, as it requires adding an additional startup flag.

main dew
lavish hemlock
#

Well, you can't.

main dew
#

;/

lavish hemlock
#

If you're going in through a Spigot plugin, Bukkit/Spigot is already loaded and even then you can't change the classloader they use.

#

Instrumentation is run before every class is loaded, no matter how it's loaded, and is therefore the only option.

#

Your other option would be modifying Bukkit itself via a fork, but obviously that's not viable.

lavish hemlock
#

When you have access to the bytecode of a class (represented as a byte[], like in ClassFileTransformer), you can pass it to an ASM ClassReader.

#

With the ClassReader, you can work with the class via ASM using a ClassVisitor (which you will implement yourself)

lavish hemlock
#

I'll give some code give me a second.

faint sage
#

you could attach a dynamic agent at runtime and retransform loaded classes, few limitations but they aren't too bad

lavish hemlock
#
var cr = new ClassReader(bytes);
var cv = new MyClassVisitor(Opcodes.ASM9); // Create MyClassVisitor yourself.
cr.accept(cv, /* flags here */);

I believe that should be correct ^

lavish hemlock
#

They're also incredibly hacky.

tender shard
#

if you compile it for java 17, it won't

#

you can set the desired target version e.g. in your pom.xml

#

I always use java 17 to compile (so I can also access 1.18 NMS) but set my target to java 8 so it also works in 1.16 on java 8

lavish hemlock
#

@main dew You need a basic understanding of JVM bytecode if you want to work with ASM, at least for method instructions.

lavish hemlock
#

Oh right sorry I also forgot to mention ClassWriter

main dew
dry forum
#

so i have a light which is on top of a mountain (part of a plugin im making) and it spins slowly but i want to make an invisble light source wherever it is facing so when the light spins the light source moves with it making it look like there is a beam of light coming from it, is there an api to help with this or an easy way to do this?

proven river
#

If I wanted to display currency on screen from a hotbar message how could I reposition it on the screen for example in the top right or is it not possible?
If not then is there another way?

lavish hemlock
#

ClassWriter is used for saving an ASM class to bytes.

#

Not just for writing to a file.

#

It is essential for classfile transformation.

main dew
lavish hemlock
#

Notice the toByteArray()

#

That returns a byte[], and is not exclusive to file IO.

#

I believe ClassFileTransformer requires you to return a byte[] on transform?

#

Yes

#

The return value is the transformed bytecode while classfileBuffer is the original class.

main dew
#

but how can i use it later?

lavish hemlock
#

One second.

lavish hemlock
#

Just wanted to add clarification.

main dew
#

but you tell this is imposible 😅

#

sorry for my English

lavish hemlock
#
var cw = new ClassWriter(/* flags */);
cv.accept(cw);
byte[] bytes = cw.toByteArray();
#

Note: You have to utilize the return value of the visitor's methods to actually transform things.

#

ASM also uses nested visitors, so you have a MethodVisitor created by your ClassVisitor.

main dew
#

yea I have byte code with edits what next?

lavish hemlock
#

Well

#

You find some way to pass that byte array to transform the class ig

#

You have 2 possible options:

main dew
#

what's an ig?

lavish hemlock
#

it stands for "I guess"

#
  • Static instrumentation (jvmagent)
  • Dynamic instrumentation (Attach API)

So either way, there's going to be some pain for server owners.

main dew
#

what does it do?

lavish hemlock
#

What does what do

main dew
#

this is the first time I hear these terms

lavish hemlock
#

But

#

What are you referring to

main dew
#

what am I doing these things and why are they problematic?