#help-development

1 messages · Page 1966 of 1

ivory sleet
#

Idk

tardy delta
#

Imagine having to learn js

quaint mantle
#

can they move

sacred mountain
#

react to this if you are extremely homosexual (

sacred mountain
blazing scarab
#

Annotations are uglier

sacred mountain
#

i havent coded it yet

quaint mantle
tardy delta
blazing scarab
#

Tho @Delegate annotation is hot

ivory sleet
#

I mean

#

Lombok is still pretty meaningless imho

sacred mountain
tardy delta
#

😱

ivory sleet
#

Any modern ide allows you to refactor out a delegate

sacred mountain
#

i might give them zombie ai

blazing scarab
#

Oh fr

ivory sleet
#

(Presupposing that’s what @Delegate does)

#

Ye

blazing scarab
#

I wish delegation would be a jvm feature

ivory sleet
#

True

#

Would be very nice

lost matrix
#

But can it do this?

ivory sleet
#

I mean

#

Just normal twr?

tardy delta
#

Damn

#

@Language is hot

quaint mantle
tardy delta
#

Or @UnmodifiableView

blazing scarab
#

Any jetbrains annotation

quaint mantle
#

i create custom inventory class and
its working in newer version but its not work on 1.12.2 bukkit
idk why.. its same code..

Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory cannot be cast to class com.darksoldier1404.dppc.api.inventory.DInventory (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory is in unnamed module of loader 'app'; com.darksoldier1404.dppc.api.inventory.DInventory is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @621d9443)```
https://github.com/darksoldier1404/DPP-Core/blob/master/V1_12_2/src/main/java/com/darksoldier1404/dppc/api/inventory/DInventory.java
tardy delta
#

Still dunno what the difference with Unmodifiable is tho

blazing scarab
#

Contract, Range, Pattern..

tardy delta
#

The bible

ivory sleet
#

Thing is, whatever Lombok can do, is also possible to do with the normal java language features or ide features so that’s why I classify Lombok as useless but that’s just me

lost matrix
#

Or this class. Would be 400 lines delomboked instead of 80. I would have to scroll half my life to add a method.

tardy delta
#

Why not just making a programming language that's based on annotations then

ivory sleet
#

I mean if you detest verbosity as said there are alternatives you could stick with instead

blazing scarab
ivory sleet
#

I believe verbosity is good, at least from what I have experienced so far

blazing scarab
#

annotations are procedural

tardy delta
blazing scarab
#

ok irs nor

ivory sleet
#

Java is to some extent procedural

blazing scarab
#

partially

#

As said before, it can be Object Oriented if you want 😄

ivory sleet
opal juniper
#

I used to hate lombok, now i dont hate it as much

#

though i dislike @Nonnull and how everything else is assumed to be null if not annotated

#

@Nullable & @NotNull are better imo

#

the jetbrains ones that is

lost matrix
#

Anyways. Gotta show something off bc i sat all day on this implementation and visualisation
of an async flood filling algorithm with 3 iterations [scan, safety, action]

ivory sleet
#

I mean javas way of intersecting null with other types is, well… interesting

lost matrix
ivory sleet
#

Holy

#

Yeah deserves a medal

lime bane
#

xD

opal juniper
#

the highlights are very cool

#

he does it with slimes that are glowing lol

lime bane
#

Are those blocks of armor stands with glowing effects?

lost matrix
#

*With slime packets

opal juniper
#

ye

lost matrix
#

200 lines of pure protocollib horror and magic numbers left and right...

opal juniper
#

we love to see it

lime bane
#

Didn't someone else show this earlier today?

opal juniper
#

no

#

that was him

lime bane
#

Oh lol

#

Just making sure xD

Good job man 🍻

sterile token
#

Wait Lombook refactor bytecode right if not i dont find how its work

#

or it has its own "interpreter"

lost matrix
sterile token
#

Ah allrgiht

#

Its like a plugin-dependency

#

Its a dependency that inside contains a plugin

#

Now i understand why it wasnt working btw

opal juniper
#

lol, was looking thru your messages to try and find it, and found the same class as an example from a minute ago, but with remarkably less code in it kek

#

someone was busy today xD

sterile token
#

?

lost matrix
#

Yep...

unique eagle
#

Hello ! is here for bungeecord developpement ? 🙂

opal juniper
#

yep

unique eagle
#

i have a problem, i use ping method on proxy connect, and if the targeted server is offline, the player will send on a another server

sterile token
unique eagle
sterile token
#

Send code please

manic delta
#

guys does anyone know about using authme api?

sterile token
unique eagle
# sterile token Send code please

            String finalPlanet = planet;
            Main.getInstance().getProxy().getServers().get(planet).ping((result, error) -> {

                if (error != null) {
                    event.setTarget(ProxyServer.getInstance().getServerInfo("Limbo"));
                } else {
                    event.setTarget(ProxyServer.getInstance().getServerInfo(finalPlanet));
                }

            });
        }```
manic delta
#

i made a discord bot (jda) and i need it

sterile token
quaint mantle
manic delta
manic delta
sterile token
#

it will give use examples

manic delta
#

tysm

sterile token
#

About using the api

sterile token
manic delta
#

have a good day

sterile token
#

You too

undone axleBOT
sterile token
#

Full event of having inssue please

#

Any issue having?

unique eagle
sterile token
#

if yes, creata paste with the issue

naive bolt
#

what do I do when I submit my premium resource and it requires an authentication key to work.

sterile token
#

java can be decompiled and simply removed the key verification

naive bolt
#

no

lapis widget
#

Licensing systems aren't even allowed in the first place

sterile token
#

And if you obfuscate it, most times can be re-engeniering

granite heart
#

err, i'm in trouble with set data watcher object in 1.16, can s.o help

naive bolt
#

fine i wont have an auth key

sterile token
naive bolt
#

its for an external api i host

sterile token
#

Take in care, that any resource on spigot cannot depend on internet connection for working (Its supid btw, but its a rule)

naive bolt
#

wth

#

fr?

#

oml so this plugin i have spent weeks making can't even be used on spigot

sterile token
#

Ask to @ivory sleet he is staff and can tell you

#

When i read that rule, i was like are you shocking me? how plugins cannot depend on internet connection? If the spigot iselft depend from internet connection. BTW

#

@naive bolt , so your plugin interect with a backend via Rest API i suppouse

vague swallow
unique eagle
#

hello, i have a problem, i use ping method in a ServerConnectEvent and if the targeted server is offline, the player will send on a another server
https://paste.md-5.net/osunejukuj.cs

sterile token
#

Events can have throws keyword?

#

Is it new

sterile token
unique eagle
#

sorry x)

opal juniper
#

is it so that only your plugins can access an api

sterile token
lime bane
#

Omg this is so helpful

naive bolt
#

it just is a param in the api request.

#

i don't really need it but it was like a attempt to stop piracy

sterile token
unique eagle
# sterile token What was the error having

like this
[10:51:14] [Netty Worker IO Thread #0/WARN]: Plugin listener be.shark_zekrom.listener.OnJoin took 188ms to process event ServerConnectEvent(player=DeathStarBricks, target=BungeeServerInfo(name=Station, socketAddress=/92.222.199.97:25567, restricted=false), reason=JOIN_PROXY, request=net.md_5.bungee.api.ServerConnectRequest@16bceced, cancelled=false)!

opal juniper
sterile token
opal juniper
#

yeah but you can just decompile the plugin lol

#

we werent talking about man in the middle attacks

naive bolt
#

the backend api checks for the auth key

#

and denys the request if not present

opal juniper
#

sure - thats fine

#

but uh- whats the api for exactly

naive bolt
sterile token
#

Oh so take a look at: "Microsoft key-value"

#

Prob it can help

naive bolt
visual tide
naive bolt
#

i could use JDA but prefer not

visual tide
#

or 403 i dont remember

crimson terrace
#

401

deft forum
#

anyone know how to check if a player opens an anvil and what items did he put in?
and set what will come out

crimson terrace
#

401 is unauthorized

deft forum
#

!jd

sacred mountain
#

can i create 2 commandexecutors with the same name?

i want to create /vlu reload in one class
and /vlu give in another

#

is that possible

naive bolt
#

the code doesnt do anything anyway

sterile token
sacred mountain
#

or do they have to be in the same class

opal juniper
sterile token
naive bolt
#

which i can set to 0

sacred mountain
#

that isnt my proble tho

opal juniper
#

Cool that should be fine then

sterile token
naive bolt
sacred mountain
#

im just asking if i can create a different argument in a seperate class file

sterile token
sacred mountain
#

to make things cleaner

#

since i cant keep scrolling through a really long class

sacred mountain
ivory sleet
naive bolt
ivory sleet
#

mostly to avoid stupid plugins to depend om some sort of cloud service

sacred mountain
#

i really do need a lib for better command args

ivory sleet
#

just so when the cloud service goes down the plugin doesnt become utterly useless

sterile token
#

He has a cloud i think

sacred mountain
#

verano what lib btw

vague swallow
#

Hi, umm

private static ForcePowersManager force;

public static ForcePowersManager getForce() {
    return force;
}

How can I let this only return force if force != null? (ForcePowersManager is a seperate class)

I tried:

public static ForcePowersManager getForce() {
    if(force != null) {
        return force;    
    }
}

But it said that there is a missing return statement

(Sorry I am new in developement)

naive bolt
#

does bstats error when no internet

#

if discord decides to reload when im typing again imma shred my cpu

lime bane
#

Is this any good?

naive bolt
lime bane
#

Seems oudated

opal juniper
naive bolt
#

its so you get this

tardy delta
#

Or throw exception if it should t be null

tardy delta
vague swallow
tardy delta
#

Well then make it's initialized

vague swallow
#

how can I do that?

lime bane
tardy delta
#

= new ForceThing()

naive bolt
tardy delta
#

Don't know what you're trying

#

Looks weird

naive bolt
#

half of the plugins are dead because i started them but couldnt be bothered to finish them

tardy delta
#

Lol antijoinmessage i can Imagine that s only five lines of code

naive bolt
#

i start out with a simple name

#

and develop of it

lime bane
#

Maven vs Gradle?

naive bolt
#

the plugin does more actually

tardy delta
#

I was Willing to create a npc plugin

naive bolt
#

still not much but it isnt just block

tardy delta
#

BlockNoises creepy

naive bolt
#

yea i wanted to make a plugin so when you break a block its a random noise

#

but gave up

tardy delta
#

Imagine your chest making noise and Running away

#

Bye mate

#

🥶

naive bolt
#

i got this far before i gave up

tardy delta
#

Lol

#

Nice plugin

#

Never gonna give you up

naive bolt
#

ty its $15.99

lime bane
#

xD

tardy delta
#

Never gonna...

#

Nvm

vocal cloud
#

Well thankfully the delete key is free

lime bane
vocal cloud
#

Press it a few

tardy delta
#

The stupid song is in my head now

naive bolt
lost matrix
#

This sounds like it can be done in 10 lines with ProtocolLib

tardy delta
#

Protocollib 🥶

lime bane
tardy delta
#

Omg noo

#

😂

naive bolt
#

😢

lime bane
naive bolt
#

it reloaded again

#

shredding my cpu as we speak

lime bane
#

Maybe if you make optimize plugin that replaces every int with a string saying the actual number, it'd optimize pc

naive bolt
#

smart

lime bane
#

||I'm so dead 🤣||

naive bolt
#

done

lime bane
#

LOL xD

tardy delta
#

🥲

lime bane
#

Now, turn that into a framework, called ||The numbers that never existed|| TNTNE

#

100m downloads

#

🥲

tranquil viper
#
blockMeta.getPersistentDataContainer().set(new NamespacedKey(plugin, "convert-spawner"), PersistentDataType.STRING, cBlock.getSpawnedType().toString());
blockMeta.getBlockState().update();
System.out.println(blockMeta.getPersistentDataContainer().get(new NamespacedKey(plugin, "convert-spawner"), PersistentDataType.STRING));
#

prints out "PIG", or "COW", etc.

#

Whenever I try to access the pdc I can't, as it says it's not there

tardy delta
#

Imagine having a cow and it prints frog

#

Oopsie

tranquil viper
#
String spawnerType = cBlock.getPersistentDataContainer().get(new NamespacedKey(plugin, "convert-spawner"), PersistentDataType.STRING);
            System.out.println(cBlock.getPersistentDataContainer().has(new NamespacedKey(plugin, "convert-spawner"), PersistentDataType.STRING));
            System.out.println(spawnerType);
            if(cBlock.getPersistentDataContainer().has(new NamespacedKey(plugin, "convert-spawner"), PersistentDataType.STRING)) {
                cBlock.setSpawnedType(EntityType.valueOf(spawnerType.toUpperCase()));
            }```
prints out false and null
lime bane
#

Are you running Minecraft 1.19.2?

grim ice
#

if i do smth like

        for(ItemStack stack : p.getInventory().getArmorContents()){
            double newDamage = ((damage / 100) * (100 - Durable.getInstance().getDamageRate(DamageRate.valueOf(
                    stack.getType().name().split("_")[0]))));```
            **stack.setDurability((short) (stack.getDurability() - newDamage));**
        ```java
}```
rough drift
grim ice
#

the thing in bold

rough drift
#

its fully up to date

grim ice
#

will it update the itemstack

vague swallow
grim ice
#

or do i have to set the armor slot

eternal oxide
grim ice
#

to the itemstack

tardy delta
vague swallow
#

okay

tardy delta
#

For your force thing

#

Idk what you're doing

lost matrix
#
  private static final Set<Sound> BLOCK_SOUNDS = Arrays.stream(Sound.values())
          .filter(sound -> sound.getKey().getKey().toLowerCase(Locale.ROOT).contains("block"))
          .collect(Collectors.toSet());

  @Override
  public void onEnable() {
    ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, PacketType.Play.Server.NAMED_SOUND_EFFECT) {
      @Override
      public void onPacketReceiving(PacketEvent event) {
        PacketContainer container = event.getPacket();
        StructureModifier<Sound> soundStructureModifier = container.getSoundEffects();
        Sound original = soundStructureModifier.read(0);
        if (SmileCore.BLOCK_SOUNDS.contains(original)) {
          Sound[] allSounds = Sound.values();
          Sound randomSound = allSounds[ThreadLocalRandom.current().nextInt(allSounds.length)];
          soundStructureModifier.write(0, randomSound);
        }
      }
    });
  }

Probably needs some fine tuning. But thats the general idea.

tranquil viper
eternal oxide
#

you put the meta back

naive bolt
#

can premium plugins have free dependency's

lost matrix
lime bane
naive bolt
#

k good

lost matrix
#

Just not paid ones

rough drift
lime bane
#

Can free plugins have paid dependencies is the real question lmao

lost matrix
undone axleBOT
naive bolt
#

i was just checking as the rules are strict and confusing

lime bane
#

Paid dependencies is a joke lmfao

naive bolt
#

a prem plugin with a prem dependency plugin with a prem dependency

rough drift
#
if(version >= 1.16) System.out.println(Material.BLACKSTONE);
else System.out.println(Material.COBBLESTONE);
```Can you do something like that?
rough drift
#

i suppose nms?

lost matrix
rough drift
#

ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

i see

#

they just have materials and legacy ones

#

and i suppose if you do like

#

get(int data, String legacyName) you get the correct one?

#

yeah

sterile token
#

This should create instance if it doesnt right?

rough drift
#

you can do

#

return this.mongo == null ? this.mongo = new Mongo(credentials) : this.mongo;

sterile token
#

Im confused if first go the true result, or first the false

rough drift
#

then false

lost matrix
rough drift
#

its

if(condition) thing else statement

naive bolt
#

if you don't like my error messages imma have to ask you to leave

sterile token
blazing scarab
#

Singletones are kinda cringe

sterile token
rough drift
#

Singletons*

#

also no

sterile token
#

It other way around

rough drift
#

System.out.println(true ? "true" : "false")

sterile token
#

cuz intellij say it will be null allways the var if ichange to what you said

rough drift
#

show me the error

sterile token
#

And the error said that "the var will be always null"

rough drift
sterile token
#

That you explain in your code

rough drift
#

i just said remove ()

sterile token
#

I follow your example

rough drift
#

you don't need those

wooden fable
#

How would i approach to create a bigger leaf decay distance?

rough drift
#

oh shit

#

i typed it wrong

sterile token
#

Oh

#

That why

rough drift
#

wait no

#

i typed it right

sterile token
#

It really confused

sterile token
#

My brains exploded

sterile token
lost matrix
rough drift
#

it is

#

copy it

naive bolt
rough drift
#

and paste it

#

then tell me

sterile token
naive bolt
rough drift
#

imma show you my config

lost matrix
sterile token
# naive bolt really?

For documenting, the method should contain:

Small description of what does
arguments it need and small description
if throw exceptions or not

rough drift
#

that's mine

#

ignore first char i was testing smt

naive bolt
#

i was gonna say

rough drift
rough drift
sterile token
# rough drift it is

System.out.println(true ? "true" : "false") -> this its not always

return this.mongo == null ? this.mongo = new Mongo(credentials) : this.mongo; -> this return always null

rough drift
#

how'd you manage that

#

its a shorter if statement

#

so you messed something up

sterile token
wooden fable
sterile token
drifting sonnet
#

@lost matrix I think hes asking how he'd make a limit to define how close you need to be for leafs to decay

sterile token
rough drift
#

no, i am still confused as how you managed to make true ? "true" : "false" always false, its the equivalent of if (true) { return "true"; } else { return "false"; }

sterile token
ancient jackal
#

I tried to use saveResource() but the file I'm trying to save "isn't found in the plugin jar"

#

I put it in resources next to config.yml

rough drift
#

is it in your resources folder?

ancient jackal
#

yes

rough drift
#

is the name correct? ("/resourcename")

ancient jackal
#

"src/main/resources/words.txt"

rough drift
#

you need to type it as "/words.txt" iirc

ancient jackal
#

saveResource("src/main/resources/words.txt", false);

rough drift
#

no

rough drift
sterile token
#

What you said

System.out.println(true ? "true" : "false"); // Its not always applicable

This is wrong

public Mysql mysql(Credentials credentials) {
  return this.mysql == null ? this.mysql : this.mysql = new Mysql(credentials); // It always return null  
}

Correct way

  public Mysql mysql(Credentials credentials) {
    return this.mysql == null ? this.mysql = new Mysql(credentials) : this.mysql; 
  }

ancient jackal
#

just "/words.txt"

sterile token
#

Do you understand now?

sterile token
rough drift
#

it will always output true

sterile token
rough drift
#

eh

naive bolt
rough drift
#

add the # right before the line

midnight shore
rough drift
#

adding spaces between the lines

naive bolt
rough drift
#

like

enabled: true # Enable/Disable command should become

# Is the command be enabled?
# Default: true
enabled: true

nextThing
#

imo that is much more helpful

#

because it replies to the question

#

so like

#

Is the command enabled? true

rough drift
#

add a Default section

naive bolt
#

yea

rough drift
#

so people know how to reset

#

and add spaces between options

#

so after the option and before the next comment, add a space

sacred mountain
#

e

rough drift
#

almost perfect

#

add a space between join message and the comment

#

for every category

naive bolt
#

must be perfect now

rough drift
#

yep

naive bolt
rough drift
#

np

#

i have seen a great reduction of people asking me basic questions after i did this

#

so it should be good xD

#

@naive bolt you missed

naive bolt
#

i dont think its neccecary

#

its so simple

rough drift
#

good point

ebon stratus
#

Hi, i want to make a plugin that records the player movement and rotation and then play it, like a replay mod, but its not very smooth cuz minecraft its running on 20 ticks so like 20 fps for the video i think.. any idea?

ancient jackal
rough drift
#

you can do so by either using protocollib or nms

rough drift
ebon stratus
naive bolt
#

i have lots of private void setupSQL() { sorta things in my main.java should i split them into other files

rough drift
tranquil viper
#
//block break event

ItemStack spawnerToDrop = new ItemStack(Material.SPAWNER);
BlockStateMeta blockMeta = (BlockStateMeta) spawnerToDrop.getItemMeta();

blockMeta.getBlockState().setBlockData(block.getBlockData());
blockMeta.setDisplayName("§d" + StringUtils.capitalize((cBlock.getSpawnedType().toString().toLowerCase()) + " Spawner"));

blockMeta.getPersistentDataContainer().set(key, PersistentDataType.STRING, cBlock.getSpawnedType().toString());

spawnerToDrop.setItemMeta(blockMeta);

This works properly and prints that it exists and with the proper value, although when I try and access this later on:

//block place event

if(cBlock.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
    String spawnerType = cBlock.getPersistentDataContainer().get(key, PersistentDataType.STRING);
    cBlock.setSpawnedType(EntityType.valueOf(spawnerType.toUpperCase()));
    cBlock.update();
}

If I were the print the values it prints that the pdc doesn't contain the key. Any thoughts on why this might be so?

naive bolt
rough drift
ancient jackal
rough drift
ancient jackal
#

oh, that's a thing too?? time to replace some things...

rough drift
#

yeah

ebon stratus
rough drift
#

you can get a resource from the .jar to load and use without extracting

mortal hare
#

do you guys shutdown thread pools?

coarse crow
#
world.playEffect(location, Effect.FIREWORK_SHOOT);
Plays an effect to all players within a given radius around a location.
Params:
location – the Location around which players must be to hear the effect
effect – the Effect
data – a data bit needed for some effects
radius – the radius around the location```

Trying to use playEffect but when I do Effect.FIREWORK_SHOOT in particular it plays the bow shoot sound instead
mortal hare
#

lets say i dont need to shutdown my tasks gracefully

mortal hare
#

do you use viaversion/protocolsupport

coarse crow
#

1.15, yes

mortal hare
#

it could be that viaversion converts sound packets badly

#

try removing it

#

and see if that's an issue

coarse crow
#

OK

lime bane
coarse crow
mortal hare
#

🤔

#

what version is your server on

coarse crow
#

1.17.1

mortal hare
#

to the server's version

#

but i doubt that'll change anything

lime bane
sacred mountain
#

more features!!!!

lime bane
#

Lol xD

sacred mountain
#

anyone know a good command api (like subcommands, commands, etc)

#

im trying to clean up some of my code with nice libs

mortal hare
#

aikar's commands

worn tundra
sacred mountain
#

which should i use

#

lamp or acf

mortal hare
#

Lamp

sacred mountain
#

acf seems a lot more in-depth

#

mk

mortal hare
#

Lamp is inspired by ACF

next stratus
coarse crow
#

@mortal hareyeah that did nothing unfortunately

lime bane
sacred mountain
#

Compiling 69 source files

#

nice

lime bane
#

0-0

rough drift
quaint mantle
#

the 2018 memes marathon

quaint mantle
naive bolt
#

why do i get
java.lang.ClassCastException: class xyz.arr4nn.DiscordMembers.functions.AutoAnnouncer cannot be cast to class org.bukkit.plugin.Plugin (xyz.arr4nn.DiscordMembers.functions.AutoAnnouncer is in unnamed module of loader 'DiscordMembers-1.0.jar' @7835e032; org.bukkit.plugin.Plugin is in unnamed module of loader java.net.URLClassLoader @5c29bfd)
in
https://paste.gg/p/anonymous/c8c5644d0d914759b97e638516cd518d

ebon stratus
# rough drift nice

my plugin records every position loc paket, makes a file with a bunch of locations and then when i play them i teleport the players to those locations, any other idea on how should i do this? i mean the packet idea worked, i have a lot more locations in the file now but when i try to play it, it is still kinda lagging

ebon stratus
#

?

rough drift
#

basically create more copies of positions between 2 packets

#

like

grim ice
#

Any good guides for reflection

#

ones that can get me to a master level I guess? I'm gonna grind it out

rough drift
#

from (1, 0, 0) to (2, 0, 0) you can get 10x more movements by doing

(1.1, 0, 0)
(1.2, 0, 0)
(1.3, 0, 0)
...
(2, 0, 0)

#

that would work ig

#

lemme get you a guide @ebon stratus

quaint mantle
storm crescent
#

How would I make a fake login process without having the player leave and rejoin?

rough drift
grim ice
ebon stratus
grim ice
#

Well I didn't say I will use it, I will learn it though

#

I'm planning on getting into nms

#

later on after mastering reflection

quaint mantle
#

ehhhh

grim ice
#

Not doing any nms until I get an intermediate knowledge of reflection and some other advanced topics

#

which is probably a wise choice, isnt it

merry kindle
#

How does spigot handle plugin loading for the @Override onEnable(){} and other events cause im kinda wanting to do something like that and was wondering if anyone could provide me with some insight on how it works.

quaint mantle
#

But please, do not do relfeciton based code on nms and use modules instead

sacred mountain
#

am i stupid or something

#

why dont these imports work

ebon stratus
quaint mantle
grim ice
grim ice
grim ice
#

fine im gonna learn modules after reflection

quaint mantle
#

That's classical inheritance

grim ice
eternal oxide
grim ice
#

onEnable and onLoad etc arent like that though

#

they're probably called when server loads up

#

as they are not events, I assume

coarse crow
#

@mortal hare do you think that maybe I need to be providing some different kind of data along with Event.FIREWORK_SHOOT?

eternal oxide
#

a field you are trying to access via reflection does not exist

midnight shore
#

Modifiers is the name of the field I’m trying to access?

eternal oxide
#

at me.will0mane.epl.nametagchanger.NameTagChanger.enable(NameTagChanger.java:363)

midnight shore
#

That doesn’t access any reflection field tho

eternal oxide
#

thats where the error is thrown

midnight shore
#

That line is a not null check

eternal oxide
#

its getting null because the field doesn;t exis

midnight shore
#

It doesn’t even mention reflection

midnight shore
eternal oxide
#

You can see your stack trace. you are calling your ReflectUtils class looking for a modifiers field

midnight shore
#

So there is a compiler error

grim ice
#
       Process process = Runtime.getRuntime().exec("jshell");
        process.getOutputStream().write("System.out.println(\"Hello World!\");".getBytes(StandardCharsets.UTF_8));
        process.getOutputStream().write('\n');```
midnight shore
#

I’m not calling that

grim ice
#

just doesnt work

#

how would I achieve this goal

rough drift
# ebon stratus im waiting :)
public Vector lerp(Vector pos, Vector otherPos, double speed, double errorMargin) {
    if(pos == null) throw new IllegalArgumentException("pos can't be null!");
    if(otherPos == null) throw new IllegalArgumentException("otherPos can't be null!");

    if(pos.equals(otherPos) || pos.distanceSquared(otherPos) <= errorMargin * errorMargin) return otherPos;

    Vector delta = otherPos.subtract(pos).normalize();

    return new Vector(pos.getX() + (speed * delta.getX()), pos.getY() + (speed * delta.getY()), pos.getZ() + (speed * delta.getZ()));
}
```Should be it (To increase the position, run lerp on the already lerped vector)
grim ice
#

of executing code from a string

rough drift
#

wait

#

forgot to use speed

#

hold yp

#

up

ebon stratus
#

ok

rough drift
#

done

quaint mantle
ebon stratus
rough drift
grim ice
#

uh ok

rough drift
#

JShell shell = new JShell()

#

its built-in to java

grim ice
#

alr

#

Cannot resolve symbol 'JShell'

#

or maybe ot

#

not

rough drift
#

you need java 9+

#

so iirc nothing below 1.17/1.16

grim ice
#

ok

#

thats pain but alr

grim ice
#

what

#

eval?

ebon stratus
rough drift
grim ice
#

its JShell.create() btw

rough drift
#

you lerp

quaint mantle
rough drift
#

between old position that you know of the player

#

and the new one

#

(if you don't know an old one, skip lerping)

ebon stratus
#

the replay start pos?

rough drift
#

when you get a packet for movement

ebon stratus
#

yeah

rough drift
#

just store it as the old pos, then on any new packet, lerp for X amount of times from the oldPos to the currentPos

grim ice
#

@rough drift I wanna run a few lines of code though

grim ice
#

do I just make a string and keep \ning

#

also that link

#

shows how to do it in console

#

not with code

ebon stratus
rough drift
#

you are using events, that also works

#

ig

ebon stratus
#

packets

sacred mountain
#

why cant i use jetbrains annotations?

#

i cant seem to find out how to use it

#

cant import

eternal oxide
#

using maven?

grim ice
#

Yep my idea worked

#

u can just \n

#

Alright now I gotta make a spigot ide

sacred mountain
eternal oxide
#

I gave you the dependency entry for maven to use org.jetbrains annotations

quiet ice
grim ice
#

Ummm

#

does JShell work for libraries

#

so like

#

if i use jshell to execute

#

for example Bukkit.getPlayer("Notch").sendMessage("ur mom");

#

will that work? or does it only recognize java stuff

quiet ice
#

I know that with beanshell it will work with libraries. But I do not know how jshell works there, but probably too

grim ice
#

what is beanshell

quiet ice
#

Another scripting lang with java syntax

#

Perhaps they are the same thing, idk

ebon stratus
# rough drift yeah

just one more question, should i use scheduler.RunTaskTimer to play the replay?

rough drift
grim ice
#

make an interface, implement it for each version

minor garnet
#
        dif.setY(0);
        armor.teleport(armor.getLocation().clone().setDirection(dif));``` just when i move close that rotate is stranger
ebon stratus
rough drift
#

them*

#

and replay them at once

#

with a while loop or smt

#

iirc there's a lookAt method

ebon stratus
#

I mean i store and play with the move packet

rough drift
#

wdym

#

show me the code you have

#

i am starting to get confused

ebon stratus
#

Ok

#

Ill send you in private

rough drift
#

kk

quaint mantle
midnight shore
#

Hi! how can i make a team with a suffix and add a player to that team so that he will have a suffix saying for example "DUMB"

minor garnet
patent horizon
#

how do i set my character encoding to UTF-8 in gradle?

rough drift
#

well

midnight shore
grim ice
#

or maybe yes

quaint mantle
#

you have no choice

grim ice
#

sigh ok

rough drift
#
Vector dir = playerLoc.subtract(armorLoc).toVector();
dir.setY(0);
dir = dir.normalized();

armor.teleport(armor.getLocation().setDirection(dir));
#

there

grim ice
#

:(

rough drift
remote quiver
#

oh

#

sorry

#

ty

midnight shore
#

what should i do next?

midnight shore
midnight shore
#

also i have a custom chat system

rough drift
#

i swear it did

rough drift
midnight shore
#

but i already have a chat system

#

i need the prefix above the head

#

sorry

#

suffix

rough drift
#

suffix is the same code, just add it after

worldly ingot
#

setDisplayName() really doesn't change much outside of chat plugins and the tab list

midnight shore
#

its not as easy as saying p.setcustomname and you have changed the player name (above the head). you need teams to do that and i'm wondering how to do teams 😐

grim ice
#

teams

#

:o

midnight shore
#

ScoreboardTeams

grim ice
#

exactly

worldly ingot
#

From there, getMainScoreboard(), operate on it

grim ice
#

its so easy tbh

#

some ppl tell u to literally use packets and shit idek why

midnight shore
worldly ingot
#

You can register teams there and manipulate its prefixes/suffixes/colours, add players to it and you're good to go

midnight shore
#

i already did that

#

i don't know how to add players

grim ice
worldly ingot
#

In that snippet there, you have no reason whatsoever to be using server internals

grim ice
#

why is this nms

rough drift
# midnight shore what should i do next?

okay, so

Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
Team team = board.getTeam(player);
if(team == null) tam = board.registerNewTeam(player);
team.setSuffix(prefix);
team.addPlayer(player);
player.setScoreboard(scoreboard);
```iirc its like that
worldly ingot
#

Looks about right

midnight shore
#

🙄 i didn't know i could do that with bukkit api 😐

#

my bad

grim ice
#

wha

worldly ingot
#

Though you'll want to addEntry(), not addPlayer(). The latter is deprecated

#

team.addEntry(player.getName())

rough drift
#

ohk

worldly ingot
#

Also don't have to Player#setScoreboard() if I recall correctly, though it's been a while since I last used the scoreboard API.

grim ice
#

Yes you probably do

rough drift
grim ice
#

that's what I did at least

worldly ingot
#

Worth trying both with and without 🙂

rough drift
#

yeah

worldly ingot
#

If it works without setting, bonus. If not, set it

grim ice
#

what is MethodHandle

rough drift
grim ice
#

Learning

midnight shore
#

whoa my code is so much shorter

rough drift
#

wops

#

fixed it

rough drift
minor garnet
#

my version is 1.12.2

rough drift
#

at the start

rough drift
minor garnet
#

what do you mean with the method lookAt

midnight shore
#

oh ok

rough drift
#

just use the code i sent you, that makes the armor stand look at the position you want iirc

minor garnet
#

is just a method to make a entity look a direction ok

rough drift
#

(it will look at the player)

midnight shore
#

wouldn't this code interfer with other plugins?

minor garnet
minor garnet
rough drift
#

change that*

next stratus
#

is stream normally faster than forEach? It seems to be 4x faster for me

minor garnet
tranquil viper
#

is there a build in method to check what hand broke a block?

worldly ingot
#

Depends on what you're doing. If you're just using a stream to for each, don't 😛

rough drift
worldly ingot
#

Always the main hand, Pray. You can't break blocks with the off hand

rough drift
minor garnet
rough drift
#

hold on

next stratus
#

I mean I did a check and forEach took 12ms on a small build and 6ms using stream

rough drift
worldly ingot
#

Location#toVector()

#

Presumably what you want to do

rough drift
#

done

minor garnet
rough drift
minor garnet
#

i just telling him ur mistakes

#

continue dontr working

#

is not the problem with the vector

rough drift
#

show me the erorr

#

error

minor garnet
#

no errors

#

and some problem that i don't know what it is basically armor stands rotates only when i new abruptly

rough drift
#

wdym

minor garnet
#

From then on it starts to spin, soon I'll make a video that explains it better, this is annoying

woeful crescent
#

how do i check if an item is consumable?

minor garnet
# rough drift wdym

When i spawn the method makeLook os calling but the armor stand dont rotate

woeful crescent
rough drift
#

wait

#

can't find it myself

storm crescent
#

Is there a way to fake a player relog? I want to make the server think that the player has left and rejoined the server.

#

I need to update the player after changing their uuid

naive bolt
#

you don’t change uuid’s

#

they are unique

storm crescent
#

I needed to change uuids to allow players to have different save files

#

essentially creating an entirely new player

tranquil viper
#

persistentDataContainers aren’t affected by permissions, right?

drowsy helm
#

no

#

they just hold information

tranquil viper
#

that’s what I figured 😂

hybrid spoke
#

DataContainer

sterile token
#

Does Java have any class implementation that allow me to do a consumer 2 values and then executing a function (if string, be able to catch that return).

So be able to do:

public void test() {
Consumer<T> consumer = new Consumer(Void);
consumer.accept((value-1, value-2), () -> System.out.println("My String"));
}

ivory sleet
#

Yes

#

Well

#

BiConsumer

worldly ingot
#

A BiFunction? BiConsumer?

#

Yeah, not sure what you're trying to do

sterile token
#

My most importante method should this one

#
public String replace(String text) {
   return consumer.accept((value-1, value-2), () -> text.replace(value-1, value-2)).get();
}```
#

Im trying to recreate exactly

worldly ingot
#

Yeah, not sure what you're trying to do in that first argument, but that looks like a BiFunction to me

#

BiFunction<T, U, String>

#

Whatever T and U are

#

2 inputs, 1 output

sterile token
#

But BiFunction doesn allow you to do get()?

worldly ingot
#

Wrap it in a Supplier then I guess 😛

#

The BiFunction returns the String so the get() is unnecessary

sterile token
#

Ohhh

worldly ingot
#

You can actually even do string::replace and that would be a BiFunction<String, String, String>

#

(or CharSequences, I can't remember)

ivory sleet
#

There’s also BinaryOperator but ye

worldly ingot
#

Depends on your inputs

ivory sleet
#

Indeed

sterile token
#

Oh im the same

#

I will prob endup doing a custom implement of Hasmap with custom forEach

#

😮‍💨

worldly ingot
#

oh, you want to do map.forEach() and yield the result of the string

sterile token
#

Yess

#

That what im trying to do

#

Oh you catch it nicee

worldly ingot
#

Basically a lambda-ified variable replacement

#

Ehm, off the top of my head I can't think of a great way to do that

sterile token
#

Oh :(

#

I was exctied that someone understand

worldly ingot
#

There's probably something like a StringBuilder or StringBuffer you can wrap your string around to manipulate the chars mutably

#

(the former two only accepting indices, not CharSequences)

sterile token
#

So it isnt possible doing a BiFunction with a supplier?

worldly ingot
#

Probably not, no. The immutability of strings makes it pretty difficult to do unless you write some sort of wrapper around a String that would make it "mutable"

sterile token
#

Oh fuckkkk

#

Big problem

#

I just rember that strings are inmutable 😡

worldly ingot
#

Not too hard, I guess.

public class MutableString {

    private String string;

    public MutableString(String string) {
        this.string = string;
    }

    public void replace(CharSequence find, CharSequence replace) {
        this.string = string.replace(find, replace);
    }

    public String get() {
        return string;
    }

}```
sterile token
#

Oh

worldly ingot
#
MutableString mutableString = new MutableString(string);
map.forEach(mutableString::replace);
return mutableString.get();```
#

That's probably a way to do it, though it's not super pretty lol

sterile token
#

Oh GREAT

worldly ingot
#

I don't actually know if that will work. That was just written here

sterile token
#

Yeah

#

No problem its my job test it

worldly ingot
#

lol, looks like that works.

#

That was interesting to write

sterile token
#

OHH

#

THANKS

#

Im wondering doing this since "Enero"

#

I dont remeber how its called in English

worldly ingot
#

January? The month?

sterile token
#

Really thanks

worldly ingot
#

o/ Take that class with a grain of salt. While that might be a clean way to write it there's probably a more efficient way to go about doing that.

tranquil viper
#

What is “String…” in methods? I’ve seen it in the past and was never able to learn about it

wet breach
#

It will probably still be better to use a StringBuilder in there

wet breach
#

String... args String[] args String args[] all mean the same thing

hybrid spoke
#

except you can pass them in a lil different

woeful hollow
woeful hollow
tranquil viper
#

oh cool

#

thanks

woeful hollow
#

But its not commonly used. Its an old java feature.

hybrid spoke
#

well, i use that

woeful hollow
#

I mean, its a user preference more less 😄

wet breach
# hybrid spoke except you can pass them in a lil different

The main difference between String... and String[] is this

//String...

public void myMethod( String... foo ) {
    // do something
    // foo is an array (String[]) internally
    System.out.println( foo[0] );
}

myMethod( "a", "b", "c" );
// OR
myMethod( new String[]{ "a", "b", "c" } );
// OR without passing any args
myMethod();
//String[]
public void myMethod( String[] foo ) {
    // do something
    System.out.println( foo[0] );
}
// compilation error!!!
myMethod( "a", "b", "c" );
// compilation error too!!!
myMethod();
// now, just this works
myMethod( new String[]{ "a", "b", "c" } );
rare pike
#

what version of java is needed to run spigot 1.8.8

wet breach
#

Hope that helps answer your question @tranquil viper

wet breach
rare pike
wet breach
sterile token
wet breach
sterile token
#

Ah allright

#

I ask because i did:

string[] array = {"a", "b"}; and worked

wet breach
#

the first example might work though with super, never tested it

#

not usually something I need super for lol

sterile token
#

I used it as an example

dry pike
#

Anyone know how to lay a player on the ground using protocol lib 1.15.2

waxen plinth
#

Probably have to send a packet to other players that says the player is sleeping in a bed

dry pike
#

Thats a fact

young knoll
#

Huh, I have no idea how to rerun a future task until the result meets a certain condition

waxen plinth
#

Could you elaborate?

young knoll
#

I have this

        int x = random.nextInt(Config.randomTeleportMinRange, Config.randomTeleportMaxRange);
        int z = random.nextInt(Config.randomTeleportMinRange, Config.randomTeleportMaxRange);

        Location location = new Location(player.getWorld(), x, 0, z);
        
        PaperLib.getChunkAtAsync(location, true).thenAccept(chunk -> {
            location.setY(location.getWorld().getHighestBlockYAt(location, HeightMap.MOTION_BLOCKING_NO_LEAVES));
            player.teleport(location.add(0.5, 1, 0.5));
        });
``` But I want to keep retrying if the found location is a liquid
#

Don't look at the paperlib~

sterile token
waxen plinth
#

And what are you trying to do?

young knoll
#

Keep re-running it if the target location is a water block

waxen plinth
#

The x and z don't change, do they?

young knoll
#

Well, I would re-randomize them

waxen plinth
#

Ah

#

Well I think I know the best way to do it then

#

You would do something like

wet breach
waxen plinth
#
public CompletableFuture<Location> thing() {
  Location loc = randomLocation();
  return loc.getWorld().getChunkAtAsync(location, true).thenApply(c -> {
    loc = loc.getWorld().getHighestBlockAt(loc).getLocation();
    if (!loc.getBlock().getType().isSolid()) {
      return loc;
    }
    return null;
  }).thenApply(l -> l == null ? thing() : l);
}```
#

Something like this

#

It's not the prettiest but it should keep going until it finds a spawnable location

young knoll
#

Hmm

thing(player.getWorld(), random).thenAccept(obj -> {
            Location location = (Location) obj;
            player.teleport(location.add(0.5, 1, 0.5));
        });
``` only works when it succeeds the first time
#

Also it makes me return CompletableFuture<Object>

sterile token
#

My happy ending 🙂

waxen plinth
#

Why do you need this

sterile token
#

Because fucked forEach itsa void

#

And i need to return string

waxen plinth
#

What does build do

sterile token
waxen plinth
#

Dear god man

#

That's gonna be bad

sterile token
#

Other solution?

waxen plinth
#

I gave you one the other day and you apparently ignored it

wet breach
#

StringBuilder is probably the answer here

waxen plinth
#

It's part of it

sterile token
#

Or not?

waxen plinth
#

...

#

You know what?

wet breach
#

I did say StringBuilder earlier and it appears Redempt gave you something better 😛

waxen plinth
#

If you really can't fucking handle the code being more than one line

#

Then sure

young knoll
#

lul

waxen plinth
#

Go with your terribly-optimized solution that's going to lag out a server if it has to handle a lot of placeholders

#

Because at least it's one line, right?

sterile token
#

It will not support placeholder from multiple plugins

#

It just for the plugin config

#

🤔

waxen plinth
#

Then why is it even a map

#

And what are you replacing anyways

#

I don't get why you're replacing fixed strings with other fixed strings, how would that even work as placeholders?

#

Are you reconstructing the entire map every time?

#

You're not using it as a map at all, it's just a series of string pairs

#

Maps shine when you need to do lookups but you're only doing iteration

sterile token
#

Oh

#
  MapUtil<String, String> vars = new MapUtil<>();
  vars.put("{name}", "alex");
  vars.put("{age}", "16");
  String text = "{name} is {age}";
  System.out.println(vars.forEach(text));
#

Hmn

waxen plinth
#

...

#

Why

#

Are the placeholder values dynamic?

#

You're building a map every single time?

sterile token
waxen plinth
#

So they're static

sterile token
#

No

#

@Singleton

waxen plinth
#

What

sterile token
#

its class annotated with @Singleton and there its the map

waxen plinth
#

But where do the placeholder values come from

#

Is this just going to always replace {name} with alex no matter the context?

sterile token
#

it was an example

#

You would just add the placeholders you want

waxen plinth
#

So you do rebuild the map every time

sterile token
#

No

#

Its singleton

waxen plinth
#

Well fuck, man, you can't have it both ways

sterile token
#

The map never get recreated

waxen plinth
#

Not what I mean

sterile token
#

Hmn

waxen plinth
#

I mean you have to go back through and change all the placeholder values every single time

#

Really not sure why you would make something like this a singleton to begin with

#

Especially not sure why you would make it parameterized when you're always going to be treating the keys and values as strings

sterile token
#

Hmn

#

I would love to use something like Set<T> but instead being Set<K, V>

#

So i can use the lambda expressions

waxen plinth
#

What

#

What do you mean "so I can use the lambda expressions"

#

What would a Set<K, V> even be

#

A set of pairs of values?

#

Because you can do that, you know

sterile token
#

I need key-pair that allow me looping and returning

waxen plinth
#

But man it is very frustrating trying to help you

sterile token
waxen plinth
#

Because you're focused solely on trying to use lambdas and write short code

#

And it's coming at the cost of performance and sanity

#

And I gave you a clean, performant solution, but you rejected it because it wasn't a one-liner

#

Hate to break it to you but sometimes you will need to write more than one line of code, and sometimes you won't be able to use lambdas

vital yacht
hexed hatch
#

b-but short code = better code

vital yacht
#

Yeah that’s why nms uses only one character variable names

#

No other reason

hexed hatch
#

nms is top-model code

sterile token
#

Oh thanks for yours words redempt

#

I ill try to change

#

I really apreciate your time and sorry i lost your time

waxen plinth
quaint mantle
sterile token
#

Redempt would you recommend me doing forEach or iterator (I have deleted the class) ?

hexed hatch
#

the virgin snake divelopar vs the chad coffee devloper

vague swallow
#

Can someone please tell me why 10*(2^(1)) returns 30?

sterile token
#

Yeah

waxen plinth
#

You want Math.pow

#

2^1 = 3

sterile token
#

But im between iterator or forEach

waxen plinth
#

The simplest way to do it is with regex

hexed hatch
waxen plinth
#

All your placeholders are {somethingHere}, right?

hexed hatch
#

They do basically the same thing

waxen plinth
#

You can have a Map<String, Supplier<String>>

sterile token
#

yeah

waxen plinth
#

Or

#

If it's dependent on the player as the context

sterile token
#

I rember that you sent some weeks before

waxen plinth
#

Map<String, Function<Player, String>>

sterile token
waxen plinth
#

So you could use regex to match the placeholders, then get them by name from the map, then replace the values

vague swallow
waxen plinth
#

This is not the most performant solution you can get

#

You can get much faster

sterile token
#

Function<Player, String> would be to send directly the message?

waxen plinth
#

No

#

It would be to get the replacement for a given placeholder for a given player

sterile token
#

Oh allright

waxen plinth
#

For example, you would map {name} to p -> p.getName()

vague swallow
waxen plinth
#

Or Player::getName

waxen plinth
#

10*Math.pow(2, 1)

hexed hatch
#

equalations has been added to my vocabulary

vague swallow
#

thank you

sterile token
#

My placeholders will be just in messages on mine plugin and only in yaml files

#

Would apply the same right?