#help-development

1 messages ¡ Page 1399 of 1

paper viper
#

That's the only thing I have

#

for playing audio

#

i can send a video

#

so you can understand whats going on

#

if you want

#

i feel like it may have something to do perhaps with the sound needing to be stopped

#

before being replayed

topaz belfry
#

Do anyone know after the installation of dreans always flying plugin in spigot what should we do

sharp bough
#

how can i use config.addDefault to add lists? like this
lore:
- 'testlore3'
- 'testlore4'

lost matrix
topaz belfry
#

Ok sir

lost matrix
sharp bough
#

yea i already figured it out

#

thanks

#

i foudn this online

#

String[] defaultLore = {"first Default Lore", "second Default Lore"};

#

config.addDefault("tiers.2.items.1.lore", Arrays.asList(defaultLore));

lost matrix
#

Looks alright 👍

young knoll
#

Could probably skip the array, but that’ll work

lost matrix
young knoll
#

Fair

red bolt
#

md5 if you're reading, feel free to @ me about my PR (the one about dimension advancements)

#

I'm getting tired of talking on stash lol

unkempt ore
#

The docs say that "<command>" in plugin.yml is a macro for the command's name, right?

#

It's not doing it, I'm not sure if I'm doing it wrong

#

Or am I just being dumb and they're just saying "when we say <command>, we just mean the command name"

lost matrix
#

<command> is just the label iirc

unkempt ore
#

In the docs, in the description for "usage" in plugin.yml, it says "<command> is a macro that is replaced with the command issued wherever it occurs."

#

Perhaps I'm not understanding, but doesn't that mean that for a command "foo", "usage: /<command>" will be replaced with "usage: /foo"?

lost matrix
#

Yes so the label of the command.

commands:
  foo: <- This
   description: Foo command
#

Should be

unkempt ore
#

Right, but it doesn't seem to be working

#

"<command>" remains

#

I'm getting the usage via getUsage() by the way, not by returning false

#

That may be changing things

lost matrix
#

I think getUsage() just returns the raw String gotten from the yml section

unkempt ore
#

Damn it

young knoll
#

I didn’t even know that was a thing

unkempt ore
#

It is

#

But probably only by returning false

#

Could just do the replacement myself

digital plinth
#

when i right click a block

#

the pos1empty boolean don't seem to be updated

solemn shoal
#

is there a compatibility layer for the bungee api?

#

so i can use ChatColor#of(String) on older versions (say, 1.12.2)

#

yes i know old version not supported

young knoll
#

Don’t see why you would want to

#

That’s for RGB

solemn shoal
#

yeah im using rgb, thats why

young knoll
#

Rgb isn’t in 1.12

solemn shoal
#

yes i know

lost matrix
# digital plinth

I see a lot if NPE possibilities in this code. And yout IDE does so too.

solemn shoal
#

i'd like to be able to fall back to supported colors on <1.16

young knoll
#

Probably need something custom

solemn shoal
#

i see

lost matrix
digital plinth
solemn shoal
#

how do you mean "write against an interface"?

digital plinth
#

wut?

lost matrix
digital plinth
#

its an example for what?

#

it would cause an npe?

lost matrix
digital plinth
#

why?

young knoll
#

Has no lore

#

Also air has no meta

#

Ah wait you filter to only stone axes

#

Still a normal stone axe has no lore

lost matrix
# digital plinth

Btw if you set the boolean to false in one line then it will stay that way in the 4 lines afterwards. So setting it to false and then checking if its false is kind of useless.

lost matrix
digital plinth
#

umm

#

an NPE won't cause the log to disappear for what ik

#

hmm lets see what ahppens if i use a normal stpone axe

solemn shoal
#

how can i get the minecraft version as not string?

digital plinth
#
                return;
            }```
young knoll
#

What do you want it as other than string

digital plinth
digital plinth
#

what why does java work that way

solemn shoal
digital plinth
#

so i just need to put a few lines between the setting and checking

young knoll
#

What do you mean why does it work that way

digital plinth
#

hmm very reasonable

young knoll
#

If you set something to false

#

It’s not going to magically change to true

lost matrix
digital plinth
#

what?

#

ofc its not

young knoll
#

You set the Boolean to true, and then check if it’s false a few lines later

#

It will never be false at that point

digital plinth
#

ohhh shoot

lost matrix
#

You set it to false. So it will always be false in the both conditions after that

digital plinth
#

i set the wrong variable

solemn shoal
#

wait..

young knoll
#

Yeah false, that’s what I meant

solemn shoal
#

Arrays.stream(ChatColor.class.getDeclaredMethods()).anyMatch(x->x.getName().equals("of"))

#

lol

young knoll
#

True and truen’t

lost matrix
digital plinth
#

oh formatting

#

okay sire

lost matrix
digital plinth
#

checking if the two pos is in the same world

young knoll
#

I mean relying on exceptions should be avoided

digital plinth
#

so the loc variable should have a world

lost matrix
digital plinth
digital plinth
#

but im setting variables here

#

cmd is an instance of the Commands class

#

when i did cmd.pos2 = e.getClickedBlock().getLocation();

#

it should give the pos2 variable the location value of the block

#

and that includes the world that the block is in

solemn shoal
#

how to convert 24bit color to 16 colors

lost matrix
solemn shoal
#

how?

young knoll
#

I don’t think they mean 16 bit color

solemn shoal
#

im trying to convert RGB colors to ChatColor lol

young knoll
#

I think they mean 16 colours

solemn shoal
lost matrix
#

I think ChatColor has a method to get the color from awt Color? Maybe?

solemn shoal
#

thats fine for 1.16

#

trying to backwards support lol

lost matrix
#

So ChatColor.of(awt.Color) then create a new awt.Color instance with your 24bits

solemn shoal
#

yeah thats fine for 1.16

lost matrix
#

I think this existed for a while

solemn shoal
#

im trying to return legacy colors for <1.16 servers

#

RGB chat colors have existed since 1.16 lol

#

wait hold on...

lost matrix
summer scroll
eternal night
#

I guess outOfStock might be null xD

summer scroll
#

but I gave a default value to the stockPlaceholder tho.

eternal night
#

Yeah but you are setting it after that anyway

#

Doesn't matter if you have the "Placeholder Error!"

#

you'd usually apply the default after all possible "non default" values

#

so like a last if(stockPlaceholder == null) stockPlaceholder = "Placeholder Error!";

summer scroll
#

ah, gotcha.

#

thanks

eternal night
#

👍

solemn shoal
#

mmm

#

one working color

#

consume all the cpu, yes

#

tfw my code is so slow it actually crashes the server

young knoll
#

What on earth are you doing to convert colours

#

5th dimensional geometry?

worn tundra
#

ai

solemn shoal
#

nah

#

bitshifting

#

somehow this is like, super slow

#

no shit its slow

#

the for loop isnt for looping

#

oh fuck, right, bytes are signed

young knoll
#

Wouldn’t that overflow anyway

#

Since 256 > 255

stone sinew
young knoll
#

0 - 64 - 128 - 192 - 256 (overflow)

stone sinew
#

Yeap soz didn't see that

lost matrix
# solemn shoal

You should probably use a NavigableMap<Integer, ChatColor> for that

#

Where the key is the rgb representation of the color

#

So you can just use a binary search to obtain the closest ChatColor from any given rgb int

solemn shoal
#

so i'd have to generate a map of all the colors

lost matrix
#

Yes. You can do that once using 1.16 and then just hard coding the values

solemn shoal
#

??

#

minecraft's data dumps have that data?

#

if i get it working i might make it available as a library

lost matrix
#

Thanks bungee...

#

null for non-rgb colors

#

Then getting the Keys for the NavigableMap might be a bit more tricky

drowsy helm
#

okay i officially like IJ now

#

highlights regex 😮

lost matrix
# solemn shoal if i get it working i might make it available as a library
  private static final NavigableMap<Integer, ChatColor> COLOR_MAP = new TreeMap<>() {{
    this.put(11141120, ChatColor.DARK_RED);
    this.put(16733525, ChatColor.RED);
    this.put(16755200, ChatColor.GOLD);
    this.put(16777045, ChatColor.YELLOW);
    this.put(43520, ChatColor.DARK_GREEN);
    this.put(5635925, ChatColor.GREEN);
    this.put(5636095, ChatColor.AQUA);
    this.put(43690, ChatColor.DARK_AQUA);
    this.put(170, ChatColor.DARK_BLUE);
    this.put(5592575, ChatColor.BLUE);
    this.put(16733695, ChatColor.LIGHT_PURPLE);
    this.put(11141290, ChatColor.DARK_PURPLE);
    this.put(16777215, ChatColor.WHITE);
    this.put(11184810, ChatColor.GRAY);
    this.put(5592405, ChatColor.DARK_GRAY);
    this.put(0, ChatColor.BLACK);
  }};

  public static ChatColor chatColorFromRgb(final int rgb) {
    final int lower = SpigotCore.COLOR_MAP.floorKey(rgb);
    final int higher = SpigotCore.COLOR_MAP.ceilingKey(rgb);
    final int result = (rgb - lower) <= (higher - rgb) ? lower : higher;
    return COLOR_MAP.get(result);
  }

  public static ChatColor chatColorFromAwtColor(final Color color) {
    return chatColorFromRgb(color.getRGB());
  }

This is what i came up with. Works.

#

This should honestly be a feature in the api...

solemn shoal
#

Bold, underline etc

lost matrix
solemn shoal
#

So it returns null if you pass it ChatColor.RED?

lost matrix
#

Wait... now it doesnt.

solemn shoal
#

We could make it a library, for the people who want it

#

Coz i doubt md5 would accept it as a feature request

lost matrix
#

Oh i see my mistake. I iterated over all ChatColor constants and it threw a NPE when it hit formatting ones

#

Whatever. I have my map now anyways

solemn shoal
#

So far ive bothered writing a console compat function. For rgb colors

#

(replaces all color codes with ansi sequences)

drowsy helm
#

ou thats sick

#

what would annotation for that be

solemn shoal
#

How do you mean?

drowsy helm
#

are you replacing the regular & colour notation?

#

or just on the code side

solemn shoal
#

I have a function rhat takes in a mc formatted string and returns an ansi formatted one

#

So my rgb test works in console

drowsy helm
#

ah right

sullen marlin
#

@lost matrix that code is very meh

#

You want closest distance in the 3d projection

#

Square and sum the components

lost matrix
#

Eh. Right. Didnt think about that

sullen marlin
#

So easy fix actually

lost matrix
solemn shoal
#

@lost matrix time to test

#

hm, no ooutput?

lost matrix
digital plinth
#

is it humble servers

solemn shoal
#

its pterodactyl

lost matrix
#

Im currently thinking about a performant way for the comparator implementation

solemn shoal
#

it failed on 0,0,0

digital plinth
solemn shoal
#

@lost matrix your code failed at final int lower = COLOR_MAP.floorKey(rgb);

lost matrix
#

?paste

queen dragonBOT
lost matrix
#

Wait i can also just pollute the chat with this one

  private static final int[] ZERO_COLOR = new int[]{0, 0, 0};

  private static final Comparator<Integer> RGB_ANGLE_COMPARATOR = (colorA, colorB) -> {
    int[] vecA = SpigotCore.splitToRgbVector(colorA);
    int[] vecB = SpigotCore.splitToRgbVector(colorB);
    return (int) (SpigotCore.angle(vecA, SpigotCore.ZERO_COLOR) - SpigotCore.angle(vecB, SpigotCore.ZERO_COLOR));
  };

  private static final NavigableMap<Integer, ChatColor> COLOR_MAP = new TreeMap<>(SpigotCore.RGB_ANGLE_COMPARATOR) {{
    this.put(11141120, ChatColor.DARK_RED);
    this.put(16733525, ChatColor.RED);
    this.put(16755200, ChatColor.GOLD);
    this.put(16777045, ChatColor.YELLOW);
    this.put(43520, ChatColor.DARK_GREEN);
    this.put(5635925, ChatColor.GREEN);
    this.put(5636095, ChatColor.AQUA);
    this.put(43690, ChatColor.DARK_AQUA);
    this.put(170, ChatColor.DARK_BLUE);
    this.put(5592575, ChatColor.BLUE);
    this.put(16733695, ChatColor.LIGHT_PURPLE);
    this.put(11141290, ChatColor.DARK_PURPLE);
    this.put(16777215, ChatColor.WHITE);
    this.put(11184810, ChatColor.GRAY);
    this.put(5592405, ChatColor.DARK_GRAY);
    this.put(0, ChatColor.BLACK);
  }};

  private static int[] splitToRgbVector(final int color) {
    return new int[]{(color >> 16) & 0xff, (color >> 8) & 0xff, (color) & 0xff};
  }

  private static double angle(final int[] vecA, final int[] vecB) {
    final int xa = vecA[0];
    final int ya = vecA[1];
    final int za = vecA[2];

    final int xb = vecB[0];
    final int yb = vecB[1];
    final int zb = vecB[2];

    final double med = xa * xb + ya * yb + za * zb;
    final double lenA = Math.sqrt(xa * xa + ya * ya + za * za);
    final double lenB = Math.sqrt(xb * xb + yb * yb + zb * zb);
    return Math.acos(med / (lenA * lenB));
  }
#

Ah... this still doesnt quite hit the mark actually...

#

Because multiple colors can have the same angle to zero

solemn shoal
#

Easiest way to test would be to print a bunch of letters in a 3 layer for loop

lost matrix
#

Ill do that

solemn shoal
#

Id recommend making a for loop for each channel

#

0-255 or whatever max is in java

#

Anyways, intervals

#

Lemme grab my pc

lost matrix
#

I just use this

    for (int r = 0; r <= 250; r += 50) {
      for (int g = 0; g <= 250; g += 50) {
        for (int b = 0; b <= 250; b += 50) {
          final Color color = new Color(r, g, b);
          final ChatColor trueColor = ChatColor.of(color);
          final ChatColor fetchedColor = SpigotCore.chatColorFromAwtColor(color);
          System.out.println(trueColor + "XXX §r>> " + fetchedColor.toString() + "XXX");
        }
      }
    }

But it pretty much always resolves black

solemn shoal
#

Fun, my pc bluescreened

lost matrix
sullen marlin
#

Just look at the map code in spigot

#

It does exactly this for map colours

solemn shoal
#

My audio drivers bluescreened my pc whilst resuming from sleep

#

Now windows updates

lost matrix
solemn shoal
#

Ah fuck bluescreened again

lost matrix
#
    private static double getDistance(@NotNull Color c1, @NotNull Color c2) {
        double rmean = (c1.getRed() + c2.getRed()) / 2.0;
        double r = c1.getRed() - c2.getRed();
        double g = c1.getGreen() - c2.getGreen();
        int b = c1.getBlue() - c2.getBlue();
        double weightR = 2 + rmean / 256.0;
        double weightG = 4.0;
        double weightB = 2 + (255 - rmean) / 256.0;
        return weightR * r * r + weightG * g * g + weightB * b * b;
    }

Thats what we need

solemn shoal
#

Cool

#

My laptop is dead

lost matrix
solemn shoal
#

Tried ro do a hard shutdown during boot tp get to safemode and now it doesnt power on anymore

solemn shoal
#

It litterally doesnt power on anymore

#

And i cant reseat battery coz its non removable

lost matrix
solemn shoal
#

MSI

lost matrix
#

Anyways im not quite sure how to implement that in O(log n) complexity. Its only working with iterating over all keys so far...

#

Oh i see. Spigot also does it in O(n)

solemn shoal
#

Time to download intellij on my phone

ivory sleet
#

Wait

#

Wat

solemn shoal
#

Hm?

ivory sleet
#

Does that even exist

solemn shoal
#

Yes

lost matrix
#

I think im close

solemn shoal
#

If you thonk hard enough

lost matrix
#

Some are more accurate, others not so much

quaint mantle
#

what's the difference between PacketPlayOutParticles and loc.getWorld().spawnParticle()

stone sinew
quaint mantle
#

ah okay

lost matrix
solemn shoal
#

Intellij time

lost matrix
#

Oh god...

lost matrix
#

Basically

sullen marlin
#

If you're using packets to spawn particles your an idiot

#

The API has literally always been a near direct mapping to the packets

#

There is literally no excuse for using packets

quaint mantle
#

i mean, i just wanna show the particles to the player im sending the packets to

sullen marlin
#

There's particle methods in Player

quaint mantle
#

lemme check that out

#

oh p.spawnParticle();

#

huh thats neet

solemn shoal
#

Progress\™️

opal juniper
#

Why tho

#

I mean I get it laptop ded

solemn shoal
#

My laptop is dead

opal juniper
#

😣

solemn shoal
#

So phone it is

#

I wont have a pc for a week if it doesnt power on with adapter

opal juniper
#

Rip

solemn shoal
#

And i need a pc for school

opal juniper
#

When’s school, today?

solemn shoal
#

Today till friday

opal juniper
#

Oh yikera

#

Better fix that

solemn shoal
#

Im still in middle school so yeah

#

Mmm ubuntu install slow

#

Shoulda picked arch

solemn shoal
#

ok my laptop works again

#

and so does ubuntu on my phone lol

visual tide
#

am i being really dumb or why does this not work

`@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

    if(command.equals("check")) {

        Player player = (Player) sender;

        PlayerInventory playerinv = player.getInventory();

        if (playerinv.contains(Material.BARRIER)) {
            playerinv.remove(Material.BARRIER);
            player.sendMessage(ChatColor.RED + "Illegal items were removed from your inventory!");

        }
    }

return true;

}`
quiet ice
#

```java
your code here
```

visual tide
#
@Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        if(command.equals("check")) {

            Player player = (Player) sender;

            PlayerInventory playerinv = player.getInventory();

            if (playerinv.contains(Material.BARRIER)) {
                playerinv.remove(Material.BARRIER);
                player.sendMessage(ChatColor.RED + "Illegal items were removed from your inventory!");

            }
        }

    return true;

    }

quiet ice
#

It's worth it for the better formatting

#

That should work, perhaps there are no Barriers in the inventory?

mystic cliff
#
PlayerFishEvent.State.REEL_IN```
It says the event "REEL_IN" doesn't exist, im using spigot 1.12.2, does anyone know a fix?
narrow berry
#

does bungeecord allow for global banning at once on e.g. 8 servers?

#

do i need to install a plugin in bungeecord. to ban on all servers at once?

quiet ice
#

perhaps

quaint mantle
#

Hello, Anyone has Protocollib dependency and repository?

sage swift
sage swift
#

is there an event for when a player begins to draw their bow back?

#

kind of like BlockDamageEvent

quaint mantle
sage swift
#

actually i guess PlayerInteractEvent could work

sage swift
#

what does it show under PlayerFishEvent.State

mystic cliff
#

@sage swift

left swift
#

How can I make slime that I can click through, can't beat, etc. I've tried slime.setInvulnerable(true); but it doesn't work

mystic cliff
#

this is in 1.13.2 so i think REEL_IN wasnt added in 1.12.2 yet :/

brittle nova
#

how do I cancel a runnable?

stone sinew
#

Bukkit.cancelTask(id) but depending how you create/start the task there are other ways.

brittle nova
stone sinew
brittle nova
#

correct?

brittle nova
#

cancel() doesn't work. It's red underlined

solemn shoal
#

maybe i should add a reset lol

stone sinew
#

Oh cause its not in a runnable.
Dojava int i = 0; i = Bukkit.getScheduler().runTaskTimer(plugin, () -> { Then instead of cancel do Bukkit.cancelTask(i); I think that should world

stone sinew
#

@brittle nova did that work?

brittle nova
brittle nova
patent cargo
#

Im trying to make a dupe plugin that requires a client or a mod

stone sinew
patent cargo
#

But i dont know how

solemn shoal
#

mm

patent cargo
#

Like the book dupe

solemn shoal
#

java streams yes

brittle nova
#

What should I do?

brittle nova
stone sinew
#

Its the same thing but alittle cleaner

solemn shoal
#

ah yes black

visual tide
#

oh i forgot the getName

#

thx

solemn shoal
#

dope

mossy loom
#

Hi!
I have a small question. What do I need to remember to write efficient plugins? I'm new to it and unfortunately I make some mistakes with it...

eternal oxide
#

Tidy code

stone sinew
visual tide
#

kinda looks like a carrot tbh

solemn shoal
#

@lost matrix any luck? lol

mystic cliff
#
PlayerFishEvent.State.REEL_IN``` Does not exist within spigot 1.12.2, does anyone know how i can still check for this event to happen?
sage swift
#

probably check for failed attempt/caught fish/other possibilities

mystic cliff
#

Those dont act the same as reel in :/

sage swift
#

out of date = bad

mystic cliff
#

:<

mystic cliff
sage swift
#

Player#setCooldown(Material.BOW) works... almost. every once in a while the player charges the bow despite the cooldown bar appearing. is there a better way to handle stopping the use and in this case charging of an item than the cooldown?

solemn shoal
#

Continueing the heresy

daring sierra
#

alright 👀

solemn shoal
#

Lol

#

@daring sierra

summer scroll
#

oh hell no

solemn shoal
#

Running natively on my phone

proper notch
#

Bruh

#

Just run IDEA Projector versions on a pc then access it via a browser

mystic cliff
#

(event.getState().equals(PlayerFishEvent.State.IN_GROUND) || event.getState().equals(PlayerFishEvent.State.FAILED_ATTEMPT))

daring sierra
left swift
#

How can I make slime that I can click through, can't beat, etc. I've tried slime.setInvulnerable(true); but it doesn't work

left swift
#

doesn't work

quaint mantle
#

I need to add MultiverseInventories

#

Plss help

eternal oxide
eternal oxide
quiet ice
#

not entirely sure that even is possible without not sending the slime to the client

eternal oxide
#

Depends what he's trying to do. Raytracing is always an option

quiet ice
#

Yeah

solemn shoal
#

and raytrace

#

and fire the proper events lol

left swift
#

I want to make slime, which's hitbox is on my head and i can't beat etc.

eternal oxide
#

You are trying to set a slime to look like your head but you are finding when you left or right click you are hitting the slime?

left swift
#

yeah

eternal oxide
#

and setCollidable didn;t work

solemn shoal
#

afaik setCollidable only changes its collision?

eternal oxide
#

Yep, I was hoping it would prevent interactions too

#

A shame Teams can't accept LivingEntities

fresh dragon
main dew
#

How clone Packet?

solemn shoal
#

SpigotAV

solemn shoal
fresh dragon
#

thanks

cinder thistle
#

@vagrant stratus it'd be real ironic if the malware finder had malware in a compiled version /hj

vagrant stratus
#

only scans one thing, which my Anti-Malware already deals with 😛

cinder thistle
#

lmao

vagrant stratus
#

Ye

main dew
#

How I can clone Packet?

cinder thistle
#

bruh they do be promoting yatopia

vagrant stratus
cinder thistle
#

ooof

vagrant stratus
#

Yea, also... for funisies.. gimme a sec

cinder thistle
#

time's up

vagrant stratus
#

assuming there's a compiled jar...

#

i really don't wanna compile it just to prove a point..

solemn shoal
#

@vagrant stratus check releases lol

vagrant stratus
#

oh shit there is owo

#

now we'll get to see why i don't do it this way ☺️

solemn shoal
#

warned for tagging lots of people

#

anyways yes creeper, yatopia epic

cinder thistle
#

who pinged

solemn shoal
#

and they sparked the idea to begin with

#

me

#

but bot deleted lol

cinder thistle
#

why

#

i hat you

#

bloxed

solemn shoal
#

ok

vagrant stratus
#

IDE froze (╯°□°)╯︵ ┻━┻

solemn shoal
#

lmao fun

cinder thistle
#

rip

#

intellij crashed earlier

vagrant stratus
#

oh it's fixed uwu

solemn shoal
#

meanwhile intellij on phone

cinder thistle
#

it's scary until you rmr saving files isn't a thing

#

what

solemn shoal
vagrant stratus
#

oh this is always fun 🤣

solemn shoal
#

what is?

vagrant stratus
#

You'll see

solemn shoal
#

oh no

main dew
#

How I can clone Packet?
packet.clone don't work

vagrant stratus
#

There's one very important reason why anti-malware plugins will NOT work

cinder thistle
#

sechz?

solemn shoal
#

i never claimed to prevent it

vagrant stratus
#

pretty much, and you using S gives basically the entire alphabet to mess with your shit

solemn shoal
#

?

wraith rapids
#

anti malware plugins are dumb

vagrant stratus
#

^

wraith rapids
#

only way to be sure is to decompile or look at source

solemn shoal
#

i mean, at least itll run on hosts

wraith rapids
#

and if it's obfuscated, just not use it

cinder thistle
#

EWG be like

solemn shoal
#

if its obfuscated

wraith rapids
#

yeah well fuck ewg

solemn shoal
#

oh so, 99% of paid plugins?

wraith rapids
#

yes

vagrant stratus
wraith rapids
#

99% of paid plugins are trash anyway

cinder thistle
#

if your code is shitty enough to want to hide then i don't wanna be running it

solemn shoal
#

you got code to enable the plugin on disable?

wraith rapids
#

because they are obfuscated and closed source so they don't get the benefit of open source contributors

solemn shoal
#

well yeah

#

also the how so was meant for optic

vagrant stratus
#

you'll see

wraith rapids
#

strangely enough songoda's premium plugins are open source

#

doesn't make them any less shit though

vagrant stratus
solemn shoal
#

ok but nothing malicious right? @vagrant stratus

#

just asking before i execute it lol

main dew
#

How I can clone Packet?
packet.clone don't work

vagrant stratus
#

Nope, it's a plugin though. Wold have to have your av in the plugins folder too :p

solemn shoal
#

well yeah its a plugin

cinder thistle
#

ploogan

solemn shoal
#

mmm

#

gg

vagrant stratus
#

again, best case scenario :p

solemn shoal
#

true

wraith rapids
#

what am i looking at

solemn shoal
#

i could make my plugin rename itself

vagrant stratus
#

doesn't matter as long as something loads before it

wraith rapids
#

like what is it trying to do

vagrant stratus
#

all my plugin did is load before theirs, and then delete the jar :p

wraith rapids
#

but like

#

does that help

vagrant stratus
#

shows how vulnerable plugin based AV's are

#

and why i went with the approach i did :p

wraith rapids
#

yeah i have no idea what you're talking about

vagrant stratus
#

AV in this case is Anti-Virus.
My Anti-Malware is a third party program, which means it's not loaded as a plugin

#

SpaceDash's however is, so to deal with it all a malicious plugin needs to do is load before theirs

#

and then delete their file

#

quite literally rendering the plugin useless

wraith rapids
#

so which ones are being run in the screenshot

vagrant stratus
#

Mine

main dew
#

How I can clone Packet?
packet.clone don't work

wraith rapids
#

use google

#

like good god you have been asking that every 15 minutes for hours

vagrant stratus
#

ProtocolLib probably has a way

main dew
#

without protocolib (I must edit spigot)

wraith rapids
#

just instantiate a new packet with the required parameters i suppose

minor garnet
#

is it possible to get what's in a player's chat text field?

wraith rapids
#

yes

#

listen to tab complete event or whatever it was called

cold tusk
#

Hello, how to make a easy Scoreboard?

wraith rapids
#

every time the player writes a new character in the text box, they send a tab complete request to the server

#

by keeping track of these requests you can monitor what players write in real time

#

although i think that's only limited for commands actually

#

so yeah you're kind of fucked unless it's a command

vagrant stratus
main dew
wraith rapids
#

why

solemn shoal
#

@vagrant stratus hm?

main dew
#

spigot don't like edit packet with chunk

#

and I must change this

wraith rapids
#

what

vagrant stratus
# solemn shoal <@!172395749814960134> hm?

If you know how to check code, you'll know :p
If you don't, then learn because you'll need that knowledge if you'll take the project seriously....learn about deobfuscation too

wraith rapids
#

hmm

#

how long have you been working on this anti malware thing

#

because I vaguely remember running into some guy on some libtard discord who was working on something very similar

#

and I think that might have been you

vagrant stratus
wraith rapids
#

I remember getting banned because I said I would not purchase a product from a chinese person if they didn't know english

#

which was apparently racist and ableist

#

2019 huh

#

i'm not sure then

#

might pull some logs later and check

vagrant stratus
wraith rapids
#

have I seen you on this guild before

vagrant stratus
#

this one specifically?
Maybe

wraith rapids
#

because your name is familiar and if it isn't from here it's probably from that libtard guild

#

it's a strange premonition and it's disconcerting

#

but whatever i guess

vagrant stratus
#

what's the name of it?

wraith rapids
#

i have no clue

#

it was like some minecraft server or plugin community or something I think

vagrant stratus
#

ah, paper's discord maybe?
I've been on there once or twice

wraith rapids
#

nah

#

but i might remember you from there then

#

got banned from there too because apparently supporting 1.8 builds is a crime

lost matrix
wraith rapids
#

geneva convention more like geneva suggestion

lost matrix
#

yeah

#

still

#

1.8 bad hurr durr

silver shuttle
#
            ItemStack[] contents = sellitem_seller.getInventory().getContents();
            int counter = 0;
            for (int i = contents.length; --i > -1;) {
                if (contents[i] != null && contents[i].isSimilar(sellitem_sell_item)) {
                    counter += contents[i].getAmount();
                }
            }            ItemStack[] contents = sellitem_seller.getInventory().getContents();
            int counter = 0;
            for (int i = contents.length; --i > -1;) {
                if (contents[i] != null && contents[i].isSimilar(sellitem_sell_item)) {
                    counter += contents[i].getAmount();
                }
            }

How can I modify this to give me the amount of items matching a specific ItemStack, WITHOUT the ItemName?

#

Because DisplayName of sellitem_sell_item is null

wraith rapids
#

wut

silver shuttle
#

so at the moment that there gives me the amount of items matching an ItemStack

vagrant stratus
# solemn shoal 3 days lol

You've got a lot of work to do, have fun trying to deal with the one major thing that render your project useless too :p

wraith rapids
#

do you want the isSimilar to ignore the display name?

silver shuttle
# wraith rapids wut

But I want it to give me the amount of items matching the ItemStack but with any DisplayName

wraith rapids
#

yeah uh you might have to reimplement isSimilar

silver shuttle
#

so DisplayName can be anything, idc what

stone sinew
wraith rapids
#

yes, see, that strips out everything

#

not just the display name

vagrant stratus
# solemn shoal thanks

welcome 🤣
But seriously though, that really should be your main concern as an AV dev

wraith rapids
#

but also all item meta

silver shuttle
wraith rapids
#

you might as well compare just materials by that point

solemn shoal
#

fair enough

silver shuttle
#

cant

#

Because then I would loose support for custom items

#

Which I definitely need as its a shop plugin

solemn shoal
#

time to make my plugin move itself on disable @wraith rapids

wraith rapids
#

yeah you'll have to reimplement a version of issimilar that ignores display name

stone sinew
silver shuttle
wraith rapids
#

my anti malware related suggestion would be to give up

silver shuttle
#

what why

stone sinew
silver shuttle
#

can I not somehow for each contents in there set the DisplayName to null?

wraith rapids
#

all anti malware does is give people a inflated sense of security and makes them do dumb shit that gets their system infected down the road

stone sinew
silver shuttle
#

well if the displayname of contents and the one of sellitem_sell_item is null itll work

vagrant stratus
#

Found malicious plugins that were uploaded in 2016

stone sinew
#

lol

vagrant stratus
#

that would work too

main dew
#

How I can clone PacketPlayOutMapChunk

wraith rapids
#

new PacketPlayOutMapChunk

main dew
#

but clone

wraith rapids
#

then set the data, reflectively if necessary

#

do you even know what clone does

solemn shoal
main dew
#

+- and I want deep clone xD

vagrant stratus
solemn shoal
#

lol ok

stone sinew
solemn shoal
#

?

silver shuttle
stone sinew
wraith rapids
#

then deep clone the data

eternal oxide
#

they are loaded in whatever order teh platform responds to listfiles

wraith rapids
#

and iirc the plugin description file is loaded way before any plugin code is even executed

#

so you might have a difficult time changing it at runtime

#

i remember someone trying to set their api-version based on the server version and running into that issue

solemn shoal
#

lol

wraith rapids
#

api version is fucking dumb

#

if I set it to a too low of a value, I get stupid material issues like crossbows showing up as air

#

if I set it to too high of a value, the plugin doesn't load on older versions

vagrant stratus
#

Keeping backwards compatibility is great, isn't it

wraith rapids
#

what happened to me, the developer, being able to write version compatibility?

stone sinew
wraith rapids
#

i am perfectly capable of writing a plugin that is backwards and forwards compatible

#

api-version just makes it so much more annoying

vagrant stratus
wraith rapids
#

it tries to do it for you, and it fucking sucks at it

solemn shoal
#

ah?

vagrant stratus
#

Ye

wraith rapids
#

some of the more notable issues are ItemStacks in inventories appearing as air, because their material exceeds your api-version

#

same happens for blocks

main dew
# wraith rapids then deep clone the data
    public static void setField(final Object packet, final String field, final Object value) throws NoSuchFieldException, IllegalAccessException {
        final Field f = packet.getClass().getDeclaredField(field);
        f.setAccessible(true);
        f.set(packet, value);
    }```
Use this?
wraith rapids
#

plenty of rtp plugins without an api-version specified have the issue of teleporting people inside physical blocks, because they see those blocks as air

silver shuttle
#

Can I have some help with reimplementing the isSimilar without DisplayName checks?

wraith rapids
#

well, it still happens

#

try it; call Block::getType() on a nether gold ore or whatever they're called

#

with api-version unset

#

it's gonna be air

#

ItemStack::getType() on a crossbow or a trident will also return air

#

so fuck you if you're trying to find empty slots in a player's inventory or something

eternal oxide
silver shuttle
main dew
#

@wraith rapids to deep clone use setField?

silver shuttle
#

I just dont know how reimplementations work

wraith rapids
#

well, the simplest reimplementation is

#
  1. copy the code
  2. modify the code
  3. call your modified code instead of the original
silver shuttle
#

yeah I tried that

wraith rapids
#

however that said, the itemstack isSimilar impl is pretty absurd

#

it redirects all over the place

silver shuttle
#

but I dont know how to properly get the copied stuff working

silver shuttle
wraith rapids
#

and is implemented in bits and pieces across a million itemmeta classes

ivory sleet
#

Isn’t it basically same as equals just ignoring amount

wraith rapids
#

myeah

#

which has to call itemmeta::equals

#

which is oof

main dew
#

or maybe better implements cloneable? to PacketPlayOutMap? @wraith rapids what you think

ivory sleet
#

Yeah big oof time

wraith rapids
#

set api version to none

silver shuttle
#

okay then maybe another way

wraith rapids
#

set api version to none

silver shuttle
#

Can I for every item in counter set its displayname to null?

            ItemStack[] contents = sellitem_seller.getInventory().getContents();
            int counter = 0;
            for (int i = contents.length; --i > -1;) {
                if (contents[i] != null && contents[i].isSimilar(sellitem_sell_item)) {
                    counter += contents[i].getAmount();
                }
            }
wraith rapids
#

i suppose yes

#

though that is extra meta cloning

#

and can be expensive

silver shuttle
#

its not called a lot

wraith rapids
#

i don't think you really have an alternative though

silver shuttle
#

only when people sell items

solemn shoal
#

?jd

wraith rapids
#

yeah just wait until people try to sell an inventory full of shulker boxes lol

silver shuttle
silver shuttle
wraith rapids
#

set sellitem's display name to null

#

and then set the display name of every item in contents to null

stone sinew
wraith rapids
#

i super vaguely remember having issues even with it set to 1.13

#

but i could be wrong i suppose

#

like, having api version set to 1.13 and having some but not all materials showing up as air

solemn shoal
#

imma go afk for a bit

#

@vagrant stratus dont worry

#

itll be great

vagrant stratus
#

mhm

wraith rapids
#

what happens if I just spawn a thread in my ctor and preload all of my classes to memory so you deleting the jar doesn't really affect anything

stone sinew
wraith rapids
#

or does your av thing kick in before the plugin ctor is called

#

yeah i don't know i could have been drunk then

silver shuttle
#
            ItemStack[] contents = sellitem_seller.getInventory().getContents();
            int counter = 0;
            for (int i = contents.length; --i > -1;) {
                ItemMeta invmeta[i] = contents[i].getItemMeta();
                contents[i].setItemMeta(invmeta[i]);
                if (contents[i] != null && contents[i].isSimilar(sellitem_sell_item)) {
                    counter += contents[i].getAmount();
                }
            }

How do I get this working

wraith rapids
#

i guess things aren't ass horribly bad as I thought

#

that's good

#

well, uh

#

why is invmeta an array

#

or rather

#

why are you declaring a single ItemMeta variable

#

and then accessing it as if it were an array

silver shuttle
#

because I am trying to get each items itemMeta

wraith rapids
#

myes, but you see

#

you are getting each item's meta, one at a time

#

you are processing a basket full of apples

#

but you are only doing stuff with one apple at a time

silver shuttle
#

thats why I have [i] I thought

wraith rapids
#

you only need one apple sized hole to put the apple you're processing in

#

change ItemMeta invmeta[i] = contents[i].getItemMeta();
to
ItemMeta invMeta = contents[i].getItemMeta();

silver shuttle
#

and then?

wraith rapids
#

and here we do a little trick

#

for the sake of optimization

silver shuttle
#

nono wait it doesnt work yet

#

oh nvm

wraith rapids
#

invMeta is not an array

#

don't [ ] it

#

only arrays have []

silver shuttle
#

ok

#

wow I just got warned for spam

wraith rapids
#

if it were an array, you'd do ItemMeta[] invMeta = new ItemMeta[10]

#

which would create an ItemMeta array of size 10, and put it in a variable called invMeta

silver shuttle
#

okay

wraith rapids
#

you'd then call invMeta[n] to get the n'th element of the array

#

but none of that is necessary here, as you only need to hold onto one item meta at a time

#

because we're only processing one item stack at a time

silver shuttle
#

yeah true

wraith rapids
#

anyway, isSimilar does basically 2 things

#

first, it compares the Material of the item

#

second, it checks if the getItemMeta of the items are equal

silver shuttle
#

yeah I looked at it in its own implementation

wraith rapids
#

equals would in addition to this check if the getAmount's are equal

#

now, getting an itemstack's itemmeta is expensive

#

because bukkit is trash

#

setting an itemstack's itemmeta is also expensive

#

so, let's just not do that

silver shuttle
#

it also doesnt work

wraith rapids
#

instead of setting the itemmeta of the inventory item, just test the two separately

silver shuttle
#

because if a slot is empty it gives an error

wraith rapids
#

null check

silver shuttle
#

yes

#

^^ you can hook into CoreProtect

wraith rapids
#

if (Objects.equals(a.getType(), b.getType()) && Objects.equals(a.getItemMeta(), b.getItemMeta()))

silver shuttle
#

yes

wraith rapids
#

a block logging plugin

silver shuttle
#

a plugin that logs every interaction

#

to items and blocks

wraith rapids
#

the above snippet is what isSimilar does, in essence

silver shuttle
#

yea

wraith rapids
#

it has some tweaks and shit but they're mostly redundant

#

now, we already have the item meta of item B

#

because we had to modify that item meta

#

to set the display name

silver shuttle
#

implement the methods of CoreProtect yourself

#

and log every single block interaction

wraith rapids
#

so, instead of putting that modified itemmeta back into the stack and then comparing the stack, we want to compare the meta

silver shuttle
#

yes

#

prefferably without the DisplayName

wraith rapids
#

if (Objects.equals(a.getType(), b.getType()) && Objects.equals(metaA, metaB))

#

metaB is the ItemMeta you get from the stack in the inventory

#

before calling this, you would set the display name to null

#

and before the entire loop, you get the comparison item's ItemMeta

#

and also set its display name to null

silver shuttle
#

yeah already got that one

#

ok lemme try this

wraith rapids
#

and you get something like this

#
            ItemStack[] contents = sellItemSeller.getInventory().getContents();
            int counter = 0;
            ItemMeta metaA = itemA.getItemMeta();
            metaA.setDisplayName(null);
            for (int i = contents.length; --i > -1;) {
                ItemStack itemB = contents[i];
                
                if (itemB == null || itemB.getType() == Material.AIR) continue;

                ItemMeta metaB = metaB.getItemMeta();
                metaB.setDisplayName(null);

                if (Objects.equals(itemA.getType(), itemB.getType()) && Objects.equals(metaA, metaB)) {
                    counter += contents[i].getAmount();
                }
            }
silver shuttle
#
            for (int i = contents.length; --i > -1;) {
                if(contents[i].getItemMeta() != null) {
                    ItemMeta invMeta = contents[i].getItemMeta();
                    invMeta.setDisplayName(null);
                }
                if (contents[i] != null && Objects.equals(contents[i].getType(), sellitem_material) && Objects.equals(itemmeta, invMeta)) {
                    counter += contents[i].getAmount();
                }
            }

I'd have done it like this

wraith rapids
#

that will blow up if any of the itemstacks in contents[] is null

#

and also you are declaring invMeta in the scope of the first if block

#

the second if block won't remember it

eternal oxide
# silver shuttle ```java for (int i = contents.length; --i > -1;) { i...

Modified isSimilar to compare stacks ignoring amount and custom name ```java
public boolean isSimilar(ItemStack source, ItemStack compare) {

    if (source == null || compare == null) {
        return false;
    }
    if (compare == source) {
        return true;
    }
    ItemStack sourceStack = source.clone();
    ItemStack compareStack = compare.clone();

    if (sourceStack.hasItemMeta() && sourceStack.getItemMeta().hasDisplayName()) {
        ItemMeta meta = sourceStack.getItemMeta();
        meta.setDisplayName(null);
        sourceStack.setItemMeta(meta);
    }
    if (compareStack.hasItemMeta() && compareStack.getItemMeta().hasDisplayName()) {
        ItemMeta meta = compareStack.getItemMeta();
        meta.setDisplayName(null);
        compareStack.setItemMeta(meta);
    }
    Material comparisonType = (sourceStack.getType().isLegacy()) ? Bukkit.getUnsafe().fromLegacy(sourceStack.getData(), true) : sourceStack.getType(); // This may be called from legacy item stacks, try to get the right material
    return comparisonType == compareStack.getType() && sourceStack.getDurability() == compareStack.getDurability() && sourceStack.hasItemMeta() == compareStack.hasItemMeta() && (sourceStack.hasItemMeta() ? Bukkit.getItemFactory().equals(sourceStack.getItemMeta(), compareStack.getItemMeta()) : true);
}```
#

probably. Not tested

silver shuttle
#

instead of metaB you mean itemB right?

wraith rapids
#

cloning itemstacks 👀

#

yeah

#

no code highlighting in discord

silver shuttle
#

ok lemme test it

wraith rapids
#

next thing you should look into is probably something called 'scope'

silver shuttle
#

ayy it works

#

thanks a lot

wraith rapids
#

basically, if something is declared inside a pair of { }

#

it will be forgotten when the } is reached

silver shuttle
#

needs to be declared before

#

but can be modified anywhere

wraith rapids
#

in this for example

#
            for (int i = contents.length; --i > -1;) {
                if(contents[i].getItemMeta() != null) {
                    ItemMeta invMeta = contents[i].getItemMeta();
                    invMeta.setDisplayName(null);
                }
                if (contents[i] != null && Objects.equals(contents[i].getType(), sellitem_material) && Objects.equals(itemmeta, invMeta)) {
                    counter += contents[i].getAmount();
                }
            }
#

you declare invMeta inside a { }

silver shuttle
#

yea

wraith rapids
#

but the { } ends before you reference it again

#

so it explodes

silver shuttle
#

ah ok

wraith rapids
#
            for (int i = contents.length; --i > -1;) {

                ItemMeta invMeta;

                if(contents[i].getItemMeta() != null) {
                    invMeta = contents[i].getItemMeta();
                    invMeta.setDisplayName(null);
                }
                if (contents[i] != null && Objects.equals(contents[i].getType(), sellitem_material) && Objects.equals(itemmeta, invMeta)) {
                    counter += contents[i].getAmount();
                }
            }
#

it would have to be like this

#

also what on earth are you trying to do vinny

silver shuttle
#

vinny?

wraith rapids
#

vinny7

#

posted some weird ass code snippet and asked a question that they now deleted

silver shuttle
#

oh lol

minor garnet
#
        String[] sword = { "SWORD", "PICKAXE", "AXE", "SHOVEL", "HOE", "BOW", "ROD", "STICK", "BONE"};
        if (materialName.contains(sword.toString())) {
            Bukkit.broadcastMessage("funfou");

        }``` this
eternal oxide
#

Thats not going to work

#

sysout sword.toString() and you''ll see why

minor garnet
#

null ?

eternal oxide
#

you have to loop your array and check each

minor garnet
#

i found it

    public static boolean contains(String input, String[] items) {
        return (Arrays.asList(items).contains(input));
    }```
eternal oxide
#

That will fail if its a GOLDEN_SWORD

minor garnet
# wraith rapids yes

I would need this actually for a command's arguments, where I can check three numeric arguments to be able to show the player

minor garnet
#

when a player executes the / loot command create string will call a method that will appear an armor stand below it where you performed it, like this:

#

in this case, i would do more for future projects the possibility of the player being able to rotate the head of the armor stand with the item to make the item be on the wall, anyway

#

so every time the player changes the argument in the chat as / loot rotate x y z, the x, y, z would be numbers and would show the player what the position would look like without the player executing the command to see understand?

#

i hope the translator doesn't get in the way

wraith rapids
#

use a precomputed Set

#

array/list contains is slower

#

and set represents what you want to do more accurately

#

and don't create a new array/set/whatever every time, precompute it

minor garnet
#

precomputed Set ?

wraith rapids
#

yes

minor garnet
#

what is this

wraith rapids
#

create a set once at startup, put the Strings in it

#

and then use that same set every time

#

what you are doing now is creating a new array every time

quaint mantle
#

What's the best way to save statistics etc when dealing with bungee servers

minor garnet
#

then you mean like a camp ?

wraith rapids
#

wut

minor garnet
#

give me an example

wraith rapids
#

private static final Set<String> myStrings = new HashSet<>();

#

static {
myStrings.add("peepeepoopoo");
}

#

does not need to be static nor final, the point is that you don't create a new set or list or array every single time

#

you reuse data which has already been created

#

so you don't need to compute it every time

#

it's a pre-computed resource

minor garnet
#

but the question of whether this item is in that hash?

wraith rapids
#

wut

#

myStrings.contains("peepeepoopoo")

minor garnet
#

so in order to initialize the plugin would i add these strings?

wraith rapids
#

yes

minor garnet
#

oh, i never got to use that, but thanks

wraith rapids
#

in my case, I filled the Set in a static {} block, which is executed when the class is initialized

#

that is, once and exactly once, and before any of the code in the class is run

cinder thistle
#

I always think of your username as NNN instead of NNY

#

and I always read it as no nut november

ivory sleet
#

lmao

wraith rapids
#

mmm

cinder thistle
#

eternal and never-ending NNN

ivory sleet
#

@cinder thistle I copied ur status

#

:]

cinder thistle
#

?

#

||I understand||

vast quest
#

can I not uncancel a BedEnter event
that is cancelled cuz of the reason NOT SAFE
I got the detection but event.setCancelled(false); doesnt seem to work

glass sparrow
vast quest
#

uh how will I do that in an event tho

wraith rapids
#

@EventHandler(priority = EventPriority.MONITOR)

#

or something

glass sparrow
#

yea

ivory sleet
#

rip @brave glen for all the pings he gets

glass sparrow
#

ikr

wraith rapids
#

@brave glen

vast quest
#

like this
@brave glenHandler(priority = EventPriority.MONITOR)

#

oh LOL

glass sparrow
#

yea

vast quest
#

rip @brave glen

wraith rapids
#

only superior clients like ripcord are immune

round finch
#

glad no one is named @EventHandler

#

wtf!

wraith rapids
#

@EventHandler

#

git gud

vast quest
#

still doesnt owrk :P

unkempt ore
#

Is there an event for an inventory changing (add/remove an item)?

wraith rapids
#

there's the inventory click event

#

and drag event

unkempt ore
#

Could that do?

wraith rapids
#

more or less

vast quest
#

this is what I have got idk what I did wrong ```
@EventHandler(priority = EventPriority.MONITOR)
public void sleep(PlayerBedEnterEvent event) {
if(event.isCancelled()) {
if(event.getBedEnterResult().equals(PlayerBedEnterEvent.BedEnterResult.NOT_SAFE)) {
event.setCancelled(false);
event.getPlayer().sendMessage("Yes");

        }
    }
}```
#

yeah ig I can remove the isCancelled check

glass sparrow
#

you might have to do some funky packet sending instead of uncancelling it

wraith rapids
#

can you set the result?

#

or is that read only

#

bukkit and beds are kind of fucked

vast quest
#

uh setUseBed?

#

maybe

ivory sleet
#

I dont think bukkit reads event mutations after HIGHEST

#

unsure but yeah the name monitor is somewhat self explanatory

wraith rapids
#

i don't remember such a distinction being made in most events

#

it's more just best practice and "don't do that"

eternal oxide
#

You should NEVER attempt to modify an event in MONITOR

vast quest
#

ight according to intelij this will work

#

event.setUseBed(Event.Result.ALLOW);

ivory sleet
#

ah well that might be the case then NNY

wraith rapids
#

because MONITOR is for monitoring

#

the point to monitor's existence is that you can see what happened to the data

vast quest
#

HIGHEST?

wraith rapids
#

what plugins did to it

eternal oxide
#

All plugins expect MONITOR to be the final result of the event. no changes at that point

wraith rapids
#

if someone changes the data during monitor, there is no guarantee that any listener on MONITOR sees the right data

#

because someone might modify it later

#

that's why monitor is sacred and should be read-only

vast quest
#

ok so uh

#

HIGHEST?

#

should I use that instead?

ivory sleet
#

Yeah

#

Or just HIGH Ig

vast quest
#

yep

#
    @EventHandler(priority = EventPriority.HIGHEST)
    public void sleep(PlayerBedEnterEvent event) {
        if(event.getBedEnterResult().equals(PlayerBedEnterEvent.BedEnterResult.NOT_SAFE)) {
            event.setUseBed(Event.Result.ALLOW);
            event.getPlayer().sendMessage("Yes");

        }
    }``` works
#

it was setUseBed ig

ivory sleet
#

I would argue for that you should use == for enum constant comparison

#

Not because equals doesn’t work

#

But it will be negligibly faster

wraith rapids
#

no point in not doing it

vast quest
#

Idk im just not used to ==

#

it just feels wrong

wraith rapids
#

you probably want to get used to it

ivory sleet
#

Uh well it’s sort of it a reference equality, as NNY said earlier if the unit a == b if and only if that’s the case then a is b but then we can infer if a is b then a == b.

vast quest
#

yeah I guess im just not used to the double =

wraith rapids
#

== should be used for identity elements and primitives

#

it implies intent and understanding that this is indeed an identity element or a primitive

ivory sleet
#

That’s totally fine, then you have something new to learn 2day (:

vast quest
#

yep

wraith rapids
#

you know what grinds my gears

ivory sleet
#

tell me

lost matrix
#

a bunch of sand

wraith rapids
#

that none of the navigable collections and maps are actually navigable

ivory sleet
#

are they?

lost matrix
wraith rapids
#

they're sorta navigable but it's shit

vagrant stratus
#

I wonder what SpaceDash has planned 🤔

ivory sleet
#

yeah I guess they aren't "unnavigable" to say at least

wraith rapids
#

i mean, the only way to get a next or a previous element is by going through the entire collection all over again

sharp bough
#

i was just doing a code and i found out that int cant be null but Integer can

wraith rapids
#

you can't store a pointer inside the map and then navigate from there to the surrounding elements

#

you can just ram your massive bony fucking head into the map over and over again

sharp bough
#

thats so weird lol

wraith rapids
#

that's because int is a primitive and Integer is an object

ivory sleet
wraith rapids
#

when you have a Integer myInteger = new Integer(10), you are creating an Object of type Integer, storing a primitive value of 10 in it, and then storing a reference to that object in a variable named myInteger

#

that reference may point to nothing; such a reference would be a null pointer, or null

#

however, when you do int myInt = 10

#

you are directly allocating 32 bits worth of space on the stack

#

and storing the raw number 10 in those 32 bits

ivory sleet
#

Integer is literally smtng like

class Integer {
  int i;
}

like any other class I guess

wraith rapids
#

that variable will always have a value; even if it's 0, which for a reference would be null, it's still a value

#

0 is 0

young knoll
#

None of the primitives can be null, but the wrapper types can

sharp bough
#
if(enchantName != null){
                        Integer enchantLevel = getEnchantLevel(currentTier,items);
                        if(enchantLevel == null){
                            enchantLevel = 1;
                        }
                        finalItemMeta.addEnchant(Enchantment.getByName(enchantName), enchantLevel, true);
                    }```
why does this say that enchantName might be null when i already checked if its null or not
lost matrix
wraith rapids
#

and the warning

lost matrix
#

^

sharp bough
#

thats the warning

wraith rapids
#

read

#

it says Enchantment.getByName might be null

sharp bough
wraith rapids
#

not enchantName might be null

sharp bough
#

cide

wraith rapids
#

what if an enchant does not exist by that name?

#

then it will be null

#

even if enchantname is not

lost matrix
#

Thats why you should always go the verbose route if you are still learning. Allocate a new Enchantment variable and check for null on it.

wraith rapids
#

i had to literally write my own implementations of treemaps and shit to make them properly navigable

#

i'm sure I could have found some properly navigable impls somewhere but I didn't have the effort to search

vast quest
#

Can you guys give me some simple things to practise :p

wraith rapids
#

do a backflip

vast quest
#

already did that

wraith rapids
#

write a rtp plugin

#

or write me a crates plugin that isn't trash

young knoll
#

Figure out how spiders work

lost matrix
vast quest
#

thanks

wraith rapids
#

i guess a rtp plugin is more for paper

#

since spigot plebians still don't have async chunks

lost matrix
wraith rapids
#

or do you

#

working with futures is good practice

lost matrix
#

I dont get why that would hinder you from writing a rtp plugin

wraith rapids
#

you can, but it's far more straight forward on spigot

lost matrix
#

Ah i see

wraith rapids
#

since you don't need to deal with futures or threading or concurrency or anything of the like

#

which would have been the main focus of the practice

lost matrix
#

So calling the chunk async and reacting on the future with a tp to learn them

wraith rapids
#

that would be the trivial implementation yeah

vast quest
#

rtp plugin is done /spreadplayers -96.00 110.80 50000 500000 true WhyHax

#

:P

wraith rapids
#

if you want to get fancy, you can do all sorts of interesting stuff

#

that one guy whose name starts with dark has made a pretty robust one