#help-development

1 messages ยท Page 2226 of 1

tender shard
#

also you should look into encapsulation instead of making all your fields public

#

Hub.getInstance().getPrefix()

#

the only reason when it's okay to use a public field imho is when it's a constant

#

like Collections.EMPTY_LIST

echo basalt
#

Delet this

kind hatch
#

I think my brain isn't working right now.
I have this item I'm trying to make translatable, so I made this section in the config. I'm trying to update the lore in a loop, but I am ending up with duplicate lines. This is the section of code I'm working with right now. https://paste.md-5.net/esosimilib.js

I'm trying to use the values in that one list to update strings while working with another list that isn't the same size.

lethal roost
#

ok uh
basically what i'm trying to do is i'm trying to take a value from a config option in my config file and use that in my handler
except that my code in the beginning looks a bit different than the tutorials i find online, so how would i go ahead to do this?

#

i know why i'm getting the error, it's just that idk how to fix it and run it

tender shard
#

what exactly is the problem? BTW I think it's not very clean to register the listener in the listener's constructor. the listener shouldn't be reponsible for registering itself

#

oh you mean that you cannot access "plugin"? That's because you never declared any field called plugin

#
public class MyListener {
  private final MyPlugin plugin;
  
  public MyListener(MyPlugin plugin) {
    this.plugin = plugin;
  }
  
  ...
}
#

alternatively, just set "config" to "plugin.getConfig()" in the constructor

#
public class PlayerHeldItemHandler {

  private final FileConfiguration config;

  public PlayerHeldItemHandler(HeavyWeapons plugin) {
    this.config = plugin.getConfig();
  }
#

caching the config object though is not a good idea if you want to have a reload command

lethal roost
#

i'm just trying this out one step at a time, i just want to be able to change the material that the code is gonna work around
so would it look something like this?

tender shard
#

yes, that should work fine

lethal roost
#

alright, tysm!

tender shard
#

but dont forget to now register the listener in your onEnable ๐Ÿ™‚

lethal roost
#

yup!

ocean lion
#
public class commandConfigreload implements CommandExecutor {
    public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
            Player player = (Player)sender;
            if (player.hasPermission(Hub.instance.getConfig().getString("configreload.permission"))) {
                Colorize.sendMessage(player,  "&7You are reloading the Hub Config");
                Hub.instance.reloadConfig();
                return true;
            } else {
                Colorize.sendMessage(player, Hub.instance.NO_PERMISSION);
            }
        return true;
    }
}
#

any idea why this isnt reloading the config?

#

Gives no errors and message works fine

tender shard
#

it does reload the config

#

but you cached the config values and never updated your cached stuff

#

if you do stuff like this:

#
String asd = getConfig().getString("asd");
#

and you then reload the config, the "asd" variable deosn't care about that, of course

#

you'd have to do asd = getConfig(...) again

#

(caching config stuff is mostly useless anyway - you can just directly get it from the config everytime)

ocean lion
#

but I dont want to reload the whole server to change some letters in the config n0?

humble tulip
#

u dont have to

#

just update the variables that store config data

tender shard
humble tulip
#

create a class of config paths

#

with public static final strings

#

and use that to get stuff every time

tender shard
#

I usually don't even bother about that

humble tulip
#

i make typos ๐Ÿ˜ฆ

tender shard
#

that's why I just do this

humble tulip
tender shard
#

then I just do ```java
entity.setName(main.getConfig().getString(Config.ENTITY_NAME));

tender shard
#

yeah

quaint mantle
#

in java is a method the same thing as a function?

humble tulip
#

yes

quaint mantle
#

ohh ok ty

#

oh

#

what

tender shard
#

a Function is a functional interface

#

well

humble tulip
#

well a method is a function in the programming sense

tender shard
#

yeah

humble tulip
#

not a java Function

tender shard
#

TL;DR: what other languages call "function" is called "method" in java

quaint mantle
#

in python a function allows you to run code from inside the function

#

is that the same thing

humble tulip
#

yes

quaint mantle
#

ok ty

#

so theres no such thing as a function in java then

tender shard
#

there's also a functional interface called "Function" in java so yo uishould just call that thing you're talking about a method

humble tulip
#

there is the Function interface

tender shard
#
public void doSomething() {
  // do something
}

that is a method

quaint mantle
#

i see

#

ty

lethal roost
#

k pulled another dumb and internet didn't work again
so i have material: "WOODEN_AXE" in the config.yml
how do i have the code use that value in the line of code in the first picture?

humble tulip
#

you mean how do you get the WOODEN_AXE string?

lethal roost
#

pretty much yeah

#

the Material.WOODEN_AXE is an enum, right?

humble tulip
#

getConfig.getString("material")

#

thats to get WOODEN_AXE as a string

tender shard
humble tulip
#

u can then use Material.valueOf to get a material from string as alex said

lethal roost
#

ah ok, ty guys

quaint mantle
#

another thing

#

when u say this for example x.toUpperCase(). what is the word for the stuff that comes after the .

tender shard
#

method

humble tulip
#

. the method?

quaint mantle
#

but a method is what u told me

tender shard
#

and this is how to invoke a method

humble tulip
#

^

quaint mantle
#

oh

#

im confused

tender shard
#
public String toUppercase() {
  return /* something */;
}

^ this is a method declaration

myString.toUppercase();

and this is an invocation of that method

#

?learnjava

undone axleBOT
quaint mantle
#

is calling for a method and invoking a method the same thing?

humble tulip
#

yes

kind hatch
#

call, invoke, execute. They all mean the same thing.

quaint mantle
#

so in python its like this

def func1():
  print("Hi")

func1()

Is the func1() invoking the function?

tender shard
#

yes

humble tulip
#

yes

quaint mantle
#

oh ok

tender shard
#

but you cannot compare python to java at all

quaint mantle
#

ik but its easier for me to learn

#

for now

tender shard
#

you should not try to learn java by comparing it to python

tender shard
quaint mantle
#

alr

#

ty

tender shard
#

java is strictly typed and heavily object orientated

#

that's quite different from python

#

for example, you cannot just define a method somewhere. a method ALWAYS belongs to either a class, or an instance of a class

humble tulip
#

from inside a class, you dont need to invoke the method on anything since it invokes it on itself or "this" by default

#

however, from outside the class, you invoke the method on an object

#

hence why you do someObject.someMethod()

tender shard
#
public void removeFromStat(MyClass this, Stat stat, double amount) {
  this.addToStat(this, stat, -amount);
}

to make the confusion complete: this is the same thing lol

quaint mantle
#

python

#

@classmethod

humble tulip
#

but why is it a thing?

#

isnt this always accesible anyway?

quaint mantle
#

thats not valid java

#

it was an example

humble tulip
quaint mantle
#

you cant name a variable this ๐Ÿ’€

tender shard
#

JLS 8..4.1 receiver parameter

humble tulip
#

intellij isnt mad

quaint mantle
#

no fucking way

humble tulip
#

its dumb right

hasty prawn
#

but why

tender shard
humble tulip
#

BUT WHY

quaint mantle
#

WHY

tender shard
#
class Test {
    Test(/* ?? ?? */) {}
      // No receiver parameter is permitted in the constructor of
      // a top level class, as there is no conceivable type or name.

    void m(Test this) {}
      // OK: receiver parameter in an instance method

    static void n(Test this) {}
      // Illegal: receiver parameter in a static method                         

    class A {
        A(Test Test.this) {}
          // OK: the receiver parameter represents the instance
          // of Test which immediately encloses the instance
          // of A being constructed.

        void m(A this) {}
          // OK: the receiver parameter represents the instance 
          // of A for which A.m() is invoked.

        class B {
            B(Test.A A.this) {}
              // OK: the receiver parameter represents the instance 
              // of A which immediately encloses the instance of B 
              // being constructed.

            void m(Test.A.B this) {}
              // OK: the receiver parameter represents the instance 
              // of B for which B.m() is invoked.
        }
    }
}
humble tulip
#

uhm wtf is that

quaint mantle
tender shard
desert loom
#

good thing that it's implicit

humble tulip
#

@smoky tinsel

#

oh shit thats a person

tender shard
#

their own fault if they name themselves like this lol

humble tulip
quaint mantle
#

receiver but no transmitter arguments pensive_cry

humble tulip
#

if an inner class is not static, does that mean a class instance is created for each instance of the outer class?

tender shard
hasty prawn
#

can someone kill me

humble tulip
#

nice

#

is that jitpack?

hasty prawn
#

It's fuckin Dynmap

quaint mantle
#

30 minute build ๐Ÿ’€

#

you better be using more than one thread to build all of that

#

otherwise you're the fool

humble tulip
#

that looks absolutely stupid

quaint mantle
#

it is

kind hatch
quaint mantle
#

i didnt think you could either

humble tulip
#

if the inner is not static

#

it looks liek a method with a space

tender shard
humble tulip
#

ok fine it exists but usecase?

tender shard
#

you need an instance of Inner

humble tulip
#

i feel like that could be fixed with a public static inner class and a getter method

kind hatch
tender shard
humble tulip
#

like an inner builder class kinda ig

tender shard
humble tulip
#

nah fuck that

#

it looks weird

kind hatch
undone axleBOT
humble tulip
#

did u use ternary operator?

kind hatch
tender shard
#

I got more stuff you won't like @humble tulip @quaint mantle

quaint mantle
#

Ok but thats useful tho

humble tulip
#

wait

quaint mantle
#

wait

humble tulip
#

uhm

quaint mantle
#

the two type parameters are of the same name?

tender shard
#

๐Ÿ˜„

humble tulip
#

why is there a .before <>

quaint mantle
#

which is handy

tender shard
quaint mantle
#

for when working with arrays and whatnot

humble tulip
#

OHH

tender shard
#

the <T> at the class is unneeded in this example

#

could also be like this

humble tulip
#

goddamnit

#

i wanna see an entire program/plugin written with wack code

humble tulip
tender shard
#
    static Wrapper<ImmutableMap<String, ?>> newWrapper(@NotNull ConfigurationSerializable obj) {
        return new Wrapper<ImmutableMap<String, ?>>(ImmutableMap.<String, Object>builder().put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(obj.getClass())).putAll(obj.serialize()).build());
    }
kind hatch
tender shard
#

that's org.bukkit.util.io.Wrapper

humble tulip
#

the 2 pastes do the same thing?

kind hatch
#

Original problem here. #help-development message
Right now, I fixed the duplicate lore lines I was getting.
I'm currently trying to figure out why the replaced values aren't correct.

humble tulip
#

cuz if the any indicator is enabled you put a checkmark

#

u need to do if indicator.isEnabled, s.replace(indicator.getPlaceHolder, "checkamrk");

#

ur not checking if the placeholder ur replacing is for the indicator that is enabled basically

kind hatch
# humble tulip u need to do if indicator.isEnabled, s.replace(indicator.getPlaceHolder, "checka...

Well I don't have a getPlaceHolder method in my Indicator class.
Originally I was just adding the lore to a list and I could just do this.

for (Indicator indicator : indicatorList) {
  if (indicator.isEnabled()) {
  indicatorLore.add(" &a&l" + PluginConstants.CHECKMARK + " &a" + TextUtils.capitalizeFirstLetter(indicator.getType().getValue()));
  } else {
    indicatorLore.add(" &c&l" + PluginConstants.X + " &c" + TextUtils.capitalizeFirstLetter(indicator.getType().getValue()));
  }
}

Now I need to take a variable from an existing list and replace it with whether or not it's enabled.

humble tulip
#

do indicators have a name?

kind hatch
#

They have a type tied to them, but I just tried that and it only worked for the first indicator in the list.

humble tulip
#

LOL

#

one sec

#

updateLore.add(s.replace("%" + indicator.getType().toString().toLowerCase() + "_indicator%", indicator.isEnabled() ? " &a&l" + PluginConstants.CHECKMARK + " &a" : " &c&l" + PluginConstants.X + " &c");

#

comment the entire inside of the indicators loop and put that one line

kind hatch
#

This is what I get when I use that.

humble tulip
#

oops

#

ah that makes sense

#

ok one sec

#

s=s.replace("%" + indicator.getType().toString().toLowerCase() + "_indicator%", indicator.isEnabled() ? " &a&l" + PluginConstants.CHECKMARK + " &a" : " &c&l" + PluginConstants.X + " &c");

kind hatch
#

Yea, just changed it to that and it works.

humble tulip
#

and add to the lore outside the loop

kind hatch
#

I'm a little confused though. Why is it that it wouldn't work with what I had before?

humble tulip
kind hatch
humble tulip
#

cuz ur checking if the indicator is enabled

#

lets say the list of inidcators is [CHAT,TITLES,BOSSBAR]

#

CHAT alone is enabled

#

now let's iterate

#

oh and the lore goes like
BossBar
Chat
Titles

#

so we iterate the lore and were currently in the for loop with BossBar as our lore string,
we noew iterate the Indicators first of which is Chat

#

chat is enabled

#

so ur code will set BossBar to true

#

or enabled

kind hatch
#

Oh wait. I think I see now.
If any one of them was enabled, I was replacing every single placeholder instead of just the one.

humble tulip
#

since u dont check that what ur replacing is of the current indicator

#

yes

kind hatch
#

Man, tonight is not the night. I've been monotonously updating my code to use values from a config and when I got to this, my brain just died.

lunar shuttle
#

I know about Block#breakNaturally(), but is it possible to 'force' the player to break a block so that their tool is damaged as well?

#

With unbreaking and whatnot

humble tulip
#

player.breakBlock

humble tulip
distant wave
#

Is there any function to get type of material? Like if material is iron axe it would return axe

waxen plinth
#

Can always do type.toString().endsWith("_AXE")

distant wave
#

Oh nice

lunar shuttle
formal bear
#

ik i changed that just to test

distant wave
waxen plinth
#

Not sure what you mean

formal bear
#

if you use _axe there will be only axes

distant wave
#

Yy

#

But i want to make it for all other items

waxen plinth
#

That's still really vague

formal bear
#

Create List of Materials then .contains

waxen plinth
#

If you're gonna be using contains, use a Set and not a List

formal bear
humble tulip
strong parcel
humble tulip
humble tulip
formal bear
#

Amounts in int, chance in double

      chance: 0.2
      min-amount: 1
      max-amount: 3
strong parcel
humble tulip
tardy delta
#

Use the scheduler lol

humble tulip
tardy delta
#

๐Ÿค”

sharp flare
#

How does one trigger an advancement at top right with custom message, etc

formal bear
humble tulip
#

huh?

formal bear
#

it displays item from random index, but shouldDrop returns true always

#

something is wrong with shouldDrop function or idk

#
//this part works
        DropItems randomItem = dropListItems.get(randomList);

        if (!event.getBlock().getType().equals(Material.STONE)) return;

then it get stuck in this if
        if (randomItem.shouldDrop(random)) {

            player.sendMessage("item" + random);
            block.breakNaturally();

        }
humble tulip
#

random.nextDouble < chance should not always return true unless chance is either very close to 1 or greater

formal bear
#

i understand ;/ but it look at the return

humble tulip
#

cuz when it doesnt drop it doesnt print?

#

wait where are u printing?

#

in or out the if?

formal bear
#

i can do both sec

humble tulip
#

dont do both

#

just outside the if

formal bear
#

so shouldDrop(random) returns always true ;/

#

why

#

ThreadLocalRandom random = ThreadLocalRandom.current();

humble tulip
#

one sec

#

doenst always give true

formal bear
#
    public boolean shouldDrop(Random random) {

        return random.nextDouble() < chance;

    }

I'm passing the random from StoneBreak method

#

So why does it not give the same result? There's typo somewhere?

humble tulip
#

did u extend random and make it always return 0 or something?

#

cuz that's stupid no one would do that

formal bear
#
    @EventHandler
    public void onStoneBreak(BlockBreakEvent event) {

        Player player = event.getPlayer();
        Block block = event.getBlock();
        ThreadLocalRandom random = ThreadLocalRandom.current();
        int randomList = random.nextInt(dropListItems.size());

        DropItems randomItem = dropListItems.get(randomList);

        if (!event.getBlock().getType().equals(Material.STONE)) return;

       if (randomItem.shouldDrop(random)) {

        ItemStack item = randomItem.makeItem(random);

        player.sendMessage("Should drop: " + randomItem.shouldDrop(random) + ", Item: " + item.getItemMeta().getDisplayName());
}
#

randomList works so random.nextInt gets one item from range Ayo, Essa, Bruh

humble tulip
#
  @EventHandler
    public void onStoneBreak(BlockBreakEvent event) {

        Player player = event.getPlayer();
        Block block = event.getBlock();
        ThreadLocalRandom random = ThreadLocalRandom.current();
        int randomList = random.nextInt(dropListItems.size());

        DropItems randomItem = dropListItems.get(randomList);

        if (!event.getBlock().getType().equals(Material.STONE)) return;

       boolean drop = randomItem.shouldDrop(random);
       player.sendMessage("Should drop: " + drop );
       if (drop) {

        ItemStack item = randomItem.makeItem(random);
    }
}
formal bear
#

now its always false ๐Ÿ™ƒ

humble tulip
#

let me see shouldDrop again?

formal bear
#
    public boolean shouldDrop(Random random) {

        return random.nextDouble() < chance;

    }
humble tulip
#

print chance

#

and random.nextDouble

#
public boolean shouldDrop(Random random) {
        double num = random.nextDouble();
        sout(num + " , " + chance);
        return  num < chance;

    }
#

something like that

formal bear
#

Got it thanks

#

It works now

#

๐Ÿ˜‹

humble tulip
#

what was it the chance?

quaint mantle
#
// called asynchronously
@Override
public boolean canInteractWith(@NotNull Player ownedPlayer, @NotNull Player player) {
    ChatRange range = this.config.getLocalRange();
    
    synchronized(this) {
        return player.getNearbyEntities(range.getX(), range.getY(), range.getZ())
                     .stream()
                     .anyMatch(e -> e == ownedPlayer);
    }
}

is synchronization bad in this instance

#

i dont want to cause a deadlock or race condition on the entity "map" or whatever the fuck handles it

humble tulip
#

are u doing it async?

quaint mantle
#

so yeah

humble tulip
#

ohhh

formal bear
quaint mantle
#

i would ping 7smile7 but hes offline

humble tulip
#

didnt know it was in that event

#

just saw the //called async

humble tulip
#

i heard it's hard to do that

quaint mantle
#

not impossible tho

humble tulip
#

i thought i understood what caused it

#

then was told that i didnt

quaint mantle
#

when a CPU attempts to do two operations at once

#

it can spur out something completely unwanted

#

or freeze

#

(deadlock)

humble tulip
#

btw why dont u use Bukkit.getOnlinePlayers

quaint mantle
#

because they are both waiting for eachother

humble tulip
#

since that returns a copy

#

should be thread safe then

quaint mantle
#

what if there are 15,000 players online?

humble tulip
#

uhhhh

#

if there are

#

there'es probably more entities

quaint mantle
#

in that specific area?

humble tulip
#

one sec

quaint mantle
#

also

#

im not checking .equals

#

it is a memory location check

#

very speedy, no need to worry about the speed of comparison

humble tulip
distant wave
#

Any way to check when player held item changes? Should i use scheduletr or is there any event

quaint mantle
humble tulip
quaint mantle
#

thats why its in the synchronized block

#

i havent tested it yet

humble tulip
#

ok i may be asking a dumb question here

#

but doesnt synchronised mean 2 threads cant execute it at once

#

it doesnt mean that it's magically on the main thread?

quaint mantle
#

true

#

it waits

#

thats why

quaint mantle
#

im unsure

#

if i synchronize it, idk if asynccatcher will recognize it

#

im testing it rn

quaint mantle
#

probably

humble tulip
#

nah i dont think thread jumping is that easy

humble tulip
quaint mantle
#

does it

#

look

humble tulip
#

i dont see how else getNearbyEntities could get the nearby entities

quaint mantle
#

true

#

probably by chunks

humble tulip
quaint mantle
#

fair enough

humble tulip
#

it seems as if it does iterate all tho

quaint mantle
#

thats slow

#

im sure it stores chunks

#

why not do it that way?

humble tulip
#

wait no i think it does use chunks

quaint mantle
#

i was about to say

#

wait

#

what am i doing

#

just get the distance from the players

#

my code was this before because i didnt haved the ownedPlayer parameter

#

forgot to update the code lol

wet breach
#

getnearbyentities uses chunks

#

it doesn't get all the entities in the world

quaint mantle
#

hello frostalf

wet breach
#

so, when you use getnearbyentities it will get the entities in the chunk in the location you have

humble tulip
#

but that cant be called async

wet breach
quaint mantle
#

i fixed it

#

it doesnt matter

humble tulip
#

ohh

#

wait

#

LOL

#

yeah u can just compare the distances

quaint mantle
#

@wet breach ive already asked you this before

#

but are you a fan of tool

wet breach
#

tool?

#

as in the band?

quaint mantle
#

yeah

wet breach
#

they are alright

#

I don't have a particular favorite band

quaint mantle
#

who do you listen to normally

#

im becoming a rock man

distant wave
#

Like this?

quaint mantle
#

yeah

distant wave
#

Kk

desert tinsel
#

what I need to put here if I have an uuid as string

quaint mantle
#

UUID.fromString(str)

#

probably

desert tinsel
#

Thanks

crude cobalt
#

How to give a strength effect to a player (Strength effect is not in PotionEffect)?

crimson terrace
#

do you want to give a potioneffect?

crude cobalt
crimson terrace
crude cobalt
formal bear
#

Is there a way to force enchantment on itemstack?

#

or set glint

summer scroll
formal bear
#

which enchantment can be applied to every item? for example paper

summer scroll
formal bear
#
Caused by: java.lang.IllegalArgumentException: Specified enchantment cannot be applied to this itemstack
        at org.bukkit.inventory.ItemStack.addEnchantment(ItemStack.java:394) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at pl.botprzemek.methods.DropItems.makeItem(DropItems.java:98) ~[?:?]
        at pl.botprzemek.handlers.StoneDrop.onStoneBreak(StoneDrop.java:65) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        ... 23 more
summer scroll
#

Are you using ItemStack#addEnchant?

formal bear
#

ah

#

UnsafeEnchantment

summer scroll
#

yeah that part

#

need to use ItemMeta instead

formal bear
#

nah just change item.addUnsafeEnchantment instaed of addEnchantment

summer scroll
#

i guess you could do that too

strong parcel
#

I am trying to code a plugin that creates a 10 second window whenever someone joins the server where players can say "wb" and trigger an effect. I figured out how to make the 10 second window, but if a second player joins inside of that window, their welcome time gets cut short.

#

To solve this problem, I decided to create a counter that will detect when a player has joined inside of the window, triggering an if statement that cancels the task that would close the welcoming window.

#

However, I am having trouble with how to restart the task. Right now, players would be able to say "wb" and trigger the effect forever.

#

Or did I fix the problem?

#

My brain at 2:30 in the morning, LOL

tall dragon
#

so all you want is for players to have a 10 second window to say welcome back?

#

i woulnt do this with a single Runnable for each join tbh

#

i would have a Map<UUID,Long> storing the player mapped to the time they joined.

earnest forum
#

i would store a central runnable and when a new player joins reset that runnable to a new one

tall dragon
tall dragon
earnest forum
tall dragon
earnest forum
#

yea

tall dragon
#

he doesnt want that tho i think

earnest forum
#

oh wait

#

thats a bug not feature

#

my b

hybrid spoke
#

that whatever array you are trying to read the length from is null

eternal oxide
#

why do you not want to use an embeded resource?

#

I suggest you re-think your design then. Requiring hundreds of yaml files is probably not the best path to take

#

why not use the db for 100%?

#

what are you calling a config? Config is generally one file to configure the plugin.

#

If you are talking about player data, then thats db stuff

#

what is this "hundreds of files" then?

hybrid spoke
eternal oxide
#

all data should be in the db, all config stuff should be in the plugins config.yml

#

I see nothing there which is deserving of its own config

hybrid spoke
#

this could be all merged

#

and divided into different sections

strong parcel
#

Does anybody know why the if statement would return false the second time a player joins?

#

Sorry, I had some extra stuff in there so I could diagnose what the problem was

hybrid spoke
#

means the list doesnt contains that exact object

earnest forum
#

underscores in fields ๐Ÿ˜ญ

#

no its getUniqueId

strong parcel
#

Thanks, I will give that a shot

hybrid spoke
#

YES!

#

doesnt have to be

#

nope

#

constants would be uppercase

#

underscores are totally fine in any variable name

#

there is no convention which says otherwise

earnest forum
#

it just looks so much better with camel case

hybrid spoke
#

depends

earnest forum
#

personally

hybrid spoke
#

in this case those are config values

#

so i "underscored" them

strong parcel
#

It worked ๐Ÿ˜„

hybrid spoke
#

or work for 3 years on the same project and always only add features instead of refactoring

strong parcel
#

I will keep that in mind. Thanks!

hybrid spoke
#

and now its too big to refactor it

#

so you have to recode it or continue what you did the past 3 years

harsh totem
#

is there an event for enchanting?
ik there is PrepareItemEnchantEvent but I want to listen to when the player presses the enchant button and not when the player is preparing the enchantment

#

ok thx

smoky oak
#

how do events work in nms?

eternal oxide
#

Events are API not nms

smoky oak
#

can you even react to what the api calls events in nms then?

eternal oxide
#

those are packets not events

#

If you are looking to use NMS, have a VERY valid reason. Something you can't do with the API

smoky oak
#

I'm aware of that, I'm just a bit curious atm

eternal oxide
#

NMS really is something you should steer clear of unless there is no alternative.

#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

wet breach
#

you should probably do the opposite especially if what you are doing is very minimal. Makes no sense to depend on a large lib for something small

#

makes sense

#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

vocal cloud
#

I love it when people attempt to use NMS but don't understand how to add it

eternal oxide
#

those are NMS classes. you should use Mojang Mappings to use them

#

actually, those classes you should not use at all

#

they are relocatet 3rd party libraries

wet breach
#

they should just be depending on Gson directly

#

from Guava

eternal oxide
#

yep

hybrid spoke
hybrid spoke
#

who is blunt

vocal cloud
#

Tbh I don't even have a joke for that

hybrid spoke
#

instructions unclear, hit a random woman on the street

harsh totem
#

Why is the loot always empty?

    public void loot(LootGenerateEvent event){
        ArrayList<ItemStack> collection = new ArrayList<ItemStack>();
        Random random = new Random();
        for (int i = 0; i < random.nextInt(); i++){
            collection.add(getRandomItem());
        }
        event.setLoot(collection);
    }```
getRandomItem() returns random item
#

when i open chests they're empty

lost matrix
harsh totem
#

why

golden turret
#

bruh

#

for with Random.nextInt

lost matrix
golden turret
#

you must be very lucky for it pick a small number

lost matrix
#

This means it could be 2 billion at some point

eternal oxide
#

You could end up with 2 billion bits of loot ๐Ÿ™‚

#

actually no

#

you will only ever have 1

lost matrix
#

hm?

eternal oxide
#

until it locks

#

when nextInt returns zero

lost matrix
#

Because it returns a random between -2.1b and +2.1b every time the loop made one cycle.
So statistically it will be far less.

harsh totem
#

ok so now I have this but the items in a chest are similar

#
    public void loot(LootGenerateEvent event){
        ArrayList<ItemStack> collection = new ArrayList<ItemStack>();
        Random random = new Random();
        for (int i = 0; i < random.nextInt(1, 4); i++){
            collection.add(main.getRandomItem());
            random = new Random();
        }
        event.setLoot(collection);
    }```
#

example:

lost matrix
lost matrix
lost matrix
barren bear
#

how i overwrite item property like Mixin in fabric
Im just new to spigot

lost matrix
harsh totem
#

example:

lost matrix
harsh totem
barren bear
harsh totem
#

i don't want it to be

lost matrix
lost matrix
sullen canyon
#

is that possible to create potion with unusual duration? For example regen potion for 8 seconds

sullen canyon
#

Thank you, can i also give to player 3 stacked potions?

odd lodge
#

does anybody know why my plugin doesnt work

smoky oak
#

?ask

undone axleBOT
#

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

smoky oak
#

youre missing a bit of context

eternal oxide
#

server not turned on?

lost matrix
eternal oxide
#

Sun Spots! we are all doomed

lost matrix
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

quaint mantle
#

near-valueless electrons, no?

odd lodge
quaint mantle
#

falsely set off dark matter detectors

odd lodge
#

it basically just tells us this guys coordinates if hes online

quaint mantle
#

thats amazing

odd lodge
#

but if i do /whereisbrandon in chat

#

it doesnt work

lost matrix
odd lodge
lost matrix
#

The class that extends JavaPlugin

#

I refuse to call it "main" class

odd lodge
quaint mantle
#

LOL

lost matrix
# odd lodge

Looks

good to me. Is it enabled when you start the server?
Check by typing in

/pl

quaint mantle
#

Wtf

#

was that intentional

lost matrix
#

If he makes me read code like that then he can read answers like that

quaint mantle
#

๐Ÿ’€

quaint mantle
#

i wanna pin that so badly

odd lodge
#

wait

quaint mantle
#

into the command box

lost matrix
#

Thats a command which lists your plugins. Execute it as a player or in console

quaint mantle
#

in your bottom left

odd lodge
quaint mantle
#

try /plugins

odd lodge
lost matrix
odd lodge
#

i think

quaint mantle
hybrid spoke
#

no perms

quaint mantle
#

are you even on spigot

odd lodge
wispy bridge
#

๐Ÿ’€

odd lodge
#

im so stupid

#

oh my go

#

d

quaint mantle
#

LMAO

odd lodge
#

we dont talk about this

lost matrix
#

wait

wispy bridge
#

Where were you even putting your plugin jar

odd lodge
#

in the plugins thing on the server

hybrid spoke
#

what plugins thing if you started a vanilla server

wispy bridge
#

Arenโ€™t you on a vanilla server though?

hybrid spoke
#

what drugs did you take

wispy bridge
#

Or did you manually make a folder called plugins

quaint mantle
#

he probably created a plugins folder

#

yeah lol

lost matrix
#

"my pLugIn isNt loAdinG on muy vaNilLa seVer. HEHLP. Why iSnt thIs wรถrKing"

eternal oxide
#

Thats my laugh for the day. You have to stop now. I'm a married man and only allowed one.

odd lodge
#

no

#

i did not make a folder called plugins

tardy delta
#

Lmao

lost matrix
odd lodge
#

there was already a folder called plugins

wispy bridge
odd lodge
#

on the server provider

quaint mantle
odd lodge
hybrid spoke
#

alzheimer

wispy bridge
#

Uhhhhhh

#

Then I guess your server provider is using a vanilla server jarโ€ฆ?

tardy delta
#

Putting the server in the root folder smh

wispy bridge
#

Does /version exist on your server?

hybrid spoke
#

but why would they bait him with a fake plugins folder

quaint mantle
#

evil

odd lodge
wispy bridge
wispy bridge
#

Did you install Spigot on your provider then switch it back to Vanilla

lost matrix
#

They probably use the same docker hierarchy and just swap out the jar for all the forks.

wispy bridge
#

Ah, I guess theyโ€™re lazy

lost matrix
odd lodge
#

thats why i got confused because i forgot i went back to vanilla

#

wdym commands

#

what commands

#

when i was doing /plugins i did it in chat

lost matrix
#

yeah just switch to spigot then

odd lodge
#

yeah

#

ok ty

hybrid spoke
#

s

lost matrix
wispy monolith
#

oh man, it's been a long time.
How should i send a message to the console saying that the plugin has started?

#

I even forgot how to do this

odd lodge
hybrid spoke
#

you should not, spigot does that for you

odd lodge
#

how do i make it so it doesnt auto fill

#

with an extra whereisbrandon

quaint mantle
#

Dont

#

deal with it

wispy monolith
lost matrix
# wispy monolith oh man, it's been a long time. How should i send a message to the console saying...

You dont. Spigot already does that. But if you want to send a message anyways you should
use the logger for that. Something like

getLogger().info("--------------------------------------------------------------------------")
getLogger().info("
โ•”โ•โ•โ•โ•—โ•”โ•โ•โ•โ•—โ•”โ•โ•โ•โ•—โ•”โ•—       โ•”โ•โ•โ•โ•—โ•”โ•—   โ•”โ•— โ•”โ•—โ•”โ•โ•โ•โ•—โ•”โ•โ•โ•—โ•”โ•โ•— โ•”โ•—    โ•”โ•โ•โ•โ•—โ•”โ•โ•— โ•”โ•—โ•”โ•โ•โ•โ•—โ•”โ•โ•โ•— โ•”โ•—   โ•”โ•โ•โ•โ•—โ•”โ•โ•โ•โ•—
โ•‘โ•”โ•โ•—โ•‘โ•‘โ•”โ•โ•—โ•‘โ•‘โ•”โ•โ•—โ•‘โ•‘โ•‘       โ•‘โ•”โ•โ•—โ•‘โ•‘โ•‘   โ•‘โ•‘ โ•‘โ•‘โ•‘โ•”โ•โ•—โ•‘โ•šโ•ฃโ• โ•โ•‘โ•‘โ•šโ•—โ•‘โ•‘    โ•‘โ•”โ•โ•โ•โ•‘โ•‘โ•šโ•—โ•‘โ•‘โ•‘โ•”โ•โ•—โ•‘โ•‘โ•”โ•—โ•‘ โ•‘โ•‘   โ•‘โ•”โ•โ•โ•โ•šโ•—โ•”โ•—โ•‘
โ•‘โ•‘ โ•šโ•โ•‘โ•‘ โ•‘โ•‘โ•‘โ•‘ โ•‘โ•‘โ•‘โ•‘       โ•‘โ•šโ•โ•โ•‘โ•‘โ•‘   โ•‘โ•‘ โ•‘โ•‘โ•‘โ•‘ โ•šโ• โ•‘โ•‘ โ•‘โ•”โ•—โ•šโ•โ•‘    โ•‘โ•šโ•โ•โ•—โ•‘โ•”โ•—โ•šโ•โ•‘โ•‘โ•‘ โ•‘โ•‘โ•‘โ•šโ•โ•šโ•—โ•‘โ•‘   โ•‘โ•šโ•โ•โ•— โ•‘โ•‘โ•‘โ•‘
โ•‘โ•‘ โ•”โ•—โ•‘โ•‘ โ•‘โ•‘โ•‘โ•‘ โ•‘โ•‘โ•‘โ•‘ โ•”โ•—    โ•‘โ•”โ•โ•โ•โ•‘โ•‘ โ•”โ•—โ•‘โ•‘ โ•‘โ•‘โ•‘โ•‘โ•”โ•โ•— โ•‘โ•‘ โ•‘โ•‘โ•šโ•—โ•‘โ•‘    โ•‘โ•”โ•โ•โ•โ•‘โ•‘โ•šโ•—โ•‘โ•‘โ•‘โ•šโ•โ•โ•‘โ•‘โ•”โ•โ•—โ•‘โ•‘โ•‘ โ•”โ•—โ•‘โ•”โ•โ•โ• โ•‘โ•‘โ•‘โ•‘
โ•‘โ•šโ•โ•โ•‘โ•‘โ•šโ•โ•โ•‘โ•‘โ•šโ•โ•โ•‘โ•‘โ•šโ•โ•โ•‘    โ•‘โ•‘   โ•‘โ•šโ•โ•โ•‘โ•‘โ•šโ•โ•โ•‘โ•‘โ•šโ•ฉโ•โ•‘โ•”โ•ฃโ• โ•—โ•‘โ•‘ โ•‘โ•‘โ•‘    โ•‘โ•šโ•โ•โ•—โ•‘โ•‘ โ•‘โ•‘โ•‘โ•‘โ•”โ•โ•—โ•‘โ•‘โ•šโ•โ•โ•‘โ•‘โ•šโ•โ•โ•‘โ•‘โ•šโ•โ•โ•—โ•”โ•โ•šโ•โ•‘
โ•šโ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•šโ•โ•โ•โ•    โ•šโ•   โ•šโ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•šโ•โ•โ•โ•šโ• โ•šโ•โ•    โ•šโ•โ•โ•โ•โ•šโ• โ•šโ•โ•โ•šโ• โ•šโ•โ•šโ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•šโ•โ•โ•โ•
");
getLogger().info("----------------------------------------------------------------------------")

Admins love those

last sleet
#

haha this is so true

tender shard
#

yes, I'm always disappointed when a plugin does NOT spam the console with this

#

how am I supposed to know that cool plugin was enabled if it doesn't create a 2mb log file with a huge ascii banner

wispy monolith
#

i would have forgot i had this plugin

smoky oak
tender shard
#

imho plugins should call cowsay | lolcat for these sweet banners using a ProcessBuilder and fail to enable if that's not installed

lost matrix
#

XDD

lost matrix
#

You can even do that in 1.7.10

smoky oak
#

k

lost matrix
hybrid spoke
smoky oak
#

I'm an annoyance not a nuisance

rare flicker
#

what's the new correct way of checking for an item's durability?

#

(since ItemStack#getDurability() is deprecated)

tender shard
#

get the itemmeta, cast it to damageable

#

then do getDamage

lost matrix
#

^

tender shard
#

and import the CORRECT DAMAGEABLE

lost matrix
tender shard
#

there are two

#

yeah that one. do NOT use the entity one

vocal pine
#

the world will end

tender shard
#

i think we still have a few billion years

#

but the earth is having a midlife crisis right now

vocal pine
#

that should be reassuring since it's already this old

tender shard
#

chasing waterfalls and stuff

smoky oak
#

aaand now theres two of them

tender shard
#

two of what

smoky oak
#

you

odd lodge
#

is it possible to make someone jump

#

with a plugin

#

?

smoky oak
#

set their upwards velocity to .37 iirc

odd lodge
#

so i could make it so i could do

#

/jump steve

#

and they would jump

#

?

smoky oak
#

yea

odd lodge
#

that is epic

#

ok

distant wave
#

can i use streams in 1.18.2 plugins

#

i mean java streams

hybrid spoke
#

yes

#

even in 1.8 plugins

distant wave
#

cool

hybrid spoke
#

as long as your java version is >=8

distant wave
#

you mean jdk

eternal oxide
#

both

wispy monolith
#

What is the event used for Chat message sent or smt

tender shard
wispy monolith
#

like if someone sent a message in chat

odd lodge
wispy monolith
odd lodge
#

why is it gray

tender shard
tender shard
lost matrix
tender shard
#

pls don't whut

eternal oxide
# odd lodge

Its complaining about no try/catch. Hover over to see the warning

rare flicker
golden turret
lost matrix
#

I constantly have to explain that async doesnt mean multithreaded. Dont lead him there.

golden turret
#

i log nothing

lost matrix
#

You can do stuff async on the main thread

odd lodge
tender shard
odd lodge
#

is the 'brandon' supposed to be gray

lost matrix
#

It may run on a different thread. But thats also not always the case.
I just wanted to clarify that async != different thread

tender shard
#

oh yeah I didn't want to say that

hybrid spoke
#

async means there is no thread

tender shard
#

async means "ultra fast"

#

lol

hybrid spoke
#

async = performance

tender shard
#

always use plugins with async in their name

#

they are always very guud

eternal oxide
lost matrix
tender shard
#

yep! Also consider upgrading to 1.8 for that sweet delicious extra performance

#

some people will claim 1.8 is outdated but they just don't know better

#

i'm running a 1.8 server on windows xp with 11 billion players on 2mb of ram. async, of course

pearl glade
tender shard
lost matrix
eternal oxide
#

Sometimes

hybrid spoke
pearl glade
tender shard
#

yes

lost matrix
tender shard
#

for larger numbers it's even faster

eternal oxide
#

Lol, has this channel turned into the bullshit channel today? ๐Ÿ˜„

rare flicker
#

i have no idea if they're meming or not anymore im just confused

eternal oxide
#

I really hope theres no one here listening

hybrid spoke
lost matrix
#

I bet you even get a discount on async

tender shard
#

lufthansa is now doing their flights async too. berlin <> new york for example is 2 hours faster when the pilot goes async

eternal oxide
#

Someone is going to come back in 6 months and say "But 7smile7 said it was faster!".

rare flicker
#

jokes aside though, isnt there a mod that exists that makes worldgen run on a different thread or smth?

hybrid spoke
lost matrix
pearl glade
rare flicker
lost matrix
rare flicker
#

my bad for my english. let me try and reformulate

tender shard
rare flicker
#

1.17 runs fine on my server
but 1.18 and 1.19 are getting around 19TPS with everyone offline, no plugins and there isnt any crazy redstone machine hidden somewhere, its just a building world
the server has 4 cores and currently 1.19 makes it use one of them to 100% almost constantly, so i've been searching for a way to even out some load to the other cores

hybrid spoke
rare flicker
#

ye it does

lost matrix
rare flicker
#

nope

#

Amd FX idkthemodelanymore

#

so yeah its old

#

ddr3 even

#

i just cant bring myself to trash it

lost matrix
#

ddr3 isnt old. I had an i7 4770 on my root server and it was totally fine with 50 concurrent users on 1.16

rare flicker
#

yeah but did it have 7G of mismatched ram with all different frequencies?

quaint mantle
#

1.16 was built different ig

#

๐Ÿ˜‚

rare flicker
hybrid spoke
#

1.16 is shit

tender shard
#

1.16 was nice when it came out

rare flicker
#

it runs on my crappy server though

smoky oak
#

was the seaweed fixed already then

tender shard
#

it was shit since 1.17 came out

quaint mantle
#

i do like to stay at 1.16 though, if anybody ask me to

tender shard
#

how can you live without goat horns?

smoky oak
#

note blocks

rare flicker
rare flicker
hybrid spoke
#

thats my new plugin idea

quaint mantle
#

there are villager's horns anyways

smoky oak
#

oh true

hybrid spoke
#

since i play sea of thieves

#

i need instruments

smoky oak
#

oh right does anyone know if they mucked up note blocks ?

odd lodge
#

how do i add a potion effect to someone

smoky oak
#

theyre enums

rare flicker
#

new potionEffect(potionEffectType.glowing, 100)

lost matrix
# odd lodge

PotionEffect needs to be instantiated.

new PotionEffect(...)
rare flicker
#

yeah

lost matrix
# odd lodge
  public void slowHisAssDown(Player player) {
    int durationSeconds = 20000;
    int potionLevel = 1;
    player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, durationSeconds * 20, potionLevel));
  }
rare flicker
#

now add it

odd lodge
#

?

hybrid spoke
#

?learnjava

undone axleBOT
lost matrix
halcyon mica
#

How can I get the burn time of a certain fuel item?

odd lodge
#

so its this wrong

lost matrix
eternal oxide
#

Hover over the red warning and see what it says. You are going to jump through a few stages before you figure it out

halcyon mica
#

Because the furnace only provides the current burn time

halcyon mica
#

Cook time is the progress of the "recipe"

lost matrix
#

Yeah i see

#

nms -> AbstractFurnaceBlockEntity.class

#

It also has some properties

odd lodge
#

does anybody here wanna help in dms for rly specific questions

smoky oak
#

just ?ask

halcyon mica
#

I really have to use NMS just to get how long something burns?

hybrid spoke
#

?ask is the real one

undone axleBOT
#

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

odd lodge
smoky oak
odd lodge
smoky oak
#

CamelCase

#

PotionEffectType

tender shard
undone axleBOT
hybrid spoke
#

GLOWING

lost matrix
tender shard
#
bukkit.getplayer(args[])

why no workz

rare flicker
#

nothing about material burn time

tender shard
#

i'd just include the burn times in a resource file and read that

rare flicker
#

looks like the "best" option

#

if you want one that will work past version update and that you really shouldn't do but that still doesnt use nms

  • place a furnace in the world
  • put in the item you want to burn and get the game time
  • repeat every time you need it
quaint mantle
#

e

rare flicker
#

||Disclaimer : don't actually do this it's just bad||

rare flicker
smoky oak
#

iirc wiki has burn time in seconds

halcyon mica
#

Well, how do I get the minecraft type from a item stack

halcyon mica
smoky oak
#

stack.getItem().getType or smth

halcyon mica
#

Not bukkit type

tender shard
#

CraftMagicValues iirc

#

CraftMagicNumbers#getItem(Material)

lost matrix
# halcyon mica Minecraft type

This is what i reverse engineered just now.

  public Item fromMaterial(Material material) {
    String mcKey = material.getKey().getKey();
    Registry<Item> itemRegistry = Registry.ITEM;
    return itemRegistry.get(new ResourceLocation(mcKey));
  }
halcyon mica
lost matrix
#

Alright

halcyon mica
#

I'll probably PR a getTotalBurn time to furnaces

#

To be in line with cook time

tender shard
#

wait

#

getTotalBurn time to furnaces?

lost matrix
halcyon mica
#

Luckily I already have stash access from fixing the worldgen random issue

tender shard
#

I think Material should have a method getFurnaceBurnTime() that returns 0 or -1 for non burnable things

tender shard
#

yeah with "should have" I mean someone should add it ๐Ÿ˜„

halcyon mica
lost matrix
#

It would be quite easy to implement because the burn times are already exposed

halcyon mica
#

Though while it has a getBurnTime#short, it lacks a getTotalBurnTime

#

Might as well add both then

harsh totem
#

idk why the chest is always empty. the variable item is fine after i checked but the resulted loot in the chest is nothing. any ideas?

#
    public void loot(LootGenerateEvent event){
        List<ItemStack> collection = event.getLoot();
        for (int i = 0; i < collection.size(); i++){
            ItemStack item = getRandomItem();
            collection.set(i, item);
        }
        event.setLoot(collection);
    }```
lost matrix
lost matrix
# harsh totem yes

Any exceptions being thrown? Because i can imagine that event.getLoot() returns an immutable list.

hybrid spoke
#

Get a mutable list of all loot to be generated.

#

what does getRandomItem do

harsh totem
harsh totem
hybrid spoke
#

yeah, code?

harsh totem
#

here is an example of debugging. the first in each box is the vanila loot and the second is getRandomItem()

lost matrix
harsh totem
#

i made sure

hybrid spoke
#

build to project once with the hammer

#

so that really everything is up to date

harsh totem
#

what?

hybrid spoke
#

not sure when you are using eclipse

#

but if you are using intellij press the hammer

harsh totem
#

i just checked and the collection.set does set the item in the slot to the random item

harsh totem
lost matrix
harsh totem
#

it does actually set it

#

but the chests are empty

golden turret
#

then event.getLoot returns the actual list of loot and not a copy, like some events do

lost matrix
harsh totem
#

ok but how did this fix it? i wanna know

#

and thx

lost matrix
#

So for you it is:

  @EventHandler
  public void loot(LootGenerateEvent event){
    List<ItemStack> collection = new ArrayList<>(event.getLoot());
    collection.replaceAll(current -> main.getRandomItem());
    event.setLoot(collection);
  }
#

Or

  @EventHandler
  public void loot(LootGenerateEvent event){
    event.setLoot(event.getLoot().stream().map(i -> main.getRandomItem()).toList());
  }

Because less lines = faster code kappa

hybrid spoke
twilit roost
#

https://youtu.be/lvuUquvkZFA

I need new code for getting new location when moving x blocks forward
Works fine when its straight, but when its rotated somehow, it doesn't work anymore

    public static Location getMoveToLocation(Ship ship){
        Location current = ship.getCurrentLocation();
        Location newLoc = new Location(current.getWorld(),current.getX(),current.getY(),current.getZ());
        Vector dir = new Vector(ship.getCurrentLocation().getDirection().getX(), 0, ship.getCurrentLocation().getDirection().getZ());
        int speed = (int) (ship.getSails().getOpenStatus().getValue()/10*ship.getCurrentSpeed()*ship.getSails().getStrength());
        int bpt = (int) 0.1; //Blocks Per Tick
        int blocksMoved = speed;
        if(dir==null){
            return null;
        }
        newLoc.add(dir.multiply(-1*blocksMoved));
        return newLoc;
    }
lost matrix
twilit roost
#

ye but how do I get direction from one location?

lost matrix
#

What do you mean? You already get the direction from one location.

ship.getCurrentLocation().getDirection()
eternal oxide
#

the pitch and yaw gives the direction ^

twilit roost
#

ye but I need to calculate the direction so I can set it to the location when rotating

agile anvil
#

Hello guys,
I just watched the new 1.19 version, and I can't find the "setCustomName" method on EntityLiving. I know that last time it was a(IchatBaseComponent ..).

#

Anyone knows new name of the method pls ?

twilit roost
eternal oxide
#

IchatBaseComponent are you talking about NMS?

agile anvil
#

Yep

agile anvil
lost matrix
# agile anvil Yep

EntityLiving is not an actual class (if you use the mojang mappings (which you should))

agile anvil
#

Yep I know, it extends Entity

#

Looks like it's now the b method

eternal oxide
#

isn;t it setCustomName Component.fromText(...) or something?

lost matrix
#

In nms entity there is this method

twilit roost
#

Is there a way to convert a float into a Vector?

hybrid spoke
#

context

eternal oxide
agile anvil
lost matrix
twilit roost
#

I have yRotation ( float )
And I need to calculate based of that Vector of whole 'Ship'

lost matrix
#

With yRotation you mean yaw i suppose? Or a rotation around the y axis

agile anvil
#

How do you represent your ship ?

twilit roost
#

like this

lost matrix
#

Pretty sure you mean the yaw...

twilit roost
#

oh yeah
im not comfortable with yaw/pitch namings

lost matrix
#

Ok so you want yaw -> projected vector

twilit roost
#

yep

agile anvil
twilit roost
#

I have current rotation in which the ship is steering aka yaw

agile anvil
#

If you want to rotate some vectors, you should multiply your vectors with the rotation Matrix

glossy venture
eternal oxide
#

He's in Spigot so I'm not sure what he's trying to do. Vector has all the math you need

glossy venture
#

i think

#

but thats how you do it right

lost matrix
#
  public Vector fromRot(float yaw) {
    return new Vector(Math.sin(yaw), 0, Math.cos(yaw));
  }

damn i got sniped

eternal oxide
#

if you want to adjust a heading and get a vector just Location.setYaw(float) then getDirection()

agile anvil
#

@twilit roost We need to know what you have in input and what you're looking for in output

#

For those wondering, yep the setCustomName nms method is now b(IChatBaseComponent)

eternal oxide
#

Most here who use nms use MojangMappings, so still use setCustomName

agile anvil
#

Okay

glossy venture
hushed spindle
#

I think I may have found a spigot bug, could anyone confirm?
When you attempt to damage a mob outside of attack range, specifically if there is a block behind that mob, no interact events of any type are fired.
So in the range far enough to not attack an entity but close enough to be able to to target a block, no interactevents trigger. Does anyone know of a workaround or know of any events that do trigger in this case?

#

this issue was found while testing an attack range custom attribute

hushed spindle
#

1.19

#

the weird thing is that absolutely no interact events trigger, despite me definitely left clicking with an item in my hand

#

if i go outside this range interact events start triggering again, if i get too close i just attack the entity

lost matrix
lost matrix
# hushed spindle 1.19

But if you leftclick with an item in hand then the interact event will be fired regardless of any blocks or entities in your way.

hushed spindle
#

it doesnt here

#

i might be able to make a video on it later

odd lodge
#

would this work

lost matrix
odd lodge
#

if the coordinates are like

#

44.834093840398

#

it would just do

#

45

hushed spindle
#

yeah, it would round it to the closest whole coordinate

odd lodge
#

so what i put

#

would work

lost matrix
hushed spindle
#

that would result 45, 44.4999999 would output 44

#

casting to int i believe would round it to the first number down right? so 44.9 would become 44 i thought

#

havent played around with it a lot tho

#

because any decimal places are just chucked out

lost matrix
hushed spindle
#

Yup that works

eternal oxide
#

or (int) Math.floor(double)

lost matrix
eternal oxide
#

its all one line so it must be faster than your 3 line method ๐Ÿ™‚

lost matrix
#

true

eternal oxide
#

actually, yours should add 0.4 not 0.5

#

as a value of 2.5 should round down

lost matrix
#

Im posting this just in case you realise and delete it later ๐Ÿ˜„

eternal oxide
#

or 0.499