#help-development

1 messages Β· Page 1719 of 1

eternal oxide
#

Enums and utility classes are another use

fading lake
#

here-and-there usage of static is usually fine, its just when EVERYTHING is static, that's when there's problems

mortal hare
#

i'd just use the getter honestly

#

for your first case

fading lake
#

what is the point in dependency injection frameworks?

#

all you're doing is passing an instance into a constructor or method..?

mortal hare
#

it gets repetitive overtime

#

just like setting getters and setters

#

it just saves time, that's it

fading lake
#

wait lombok is a dependency injection framework?

#

im just talking in general

mortal hare
#

wait nvm

#

that's a different topic

#

idk if that would work since /scoreboard is probs minecraft brigadier command, but maybe

#Server.dispatchCommand(#CommandSender, "scoreboard players reset @a Rcd");
would work?

outer steeple
#

ok im going to try it

mortal hare
#

idk if that parses the bukkit command map or the both brigadier vanilla command dispatcher and bukkit brigadier command dispatcher

outer steeple
#

it doesnt work

mortal hare
#

does it error out?

#

there's another way by using NMS

#

tbh i'd rather reset the scoreboard via scoreboard api

outer steeple
#

how can i do that with scoreboard api?

mortal hare
outer steeple
#

btw my problem is that i cant detect that a player has the score

#

if i do the command:

#

/execute if score <player name> Rcd = 1

mortal hare
#

well just get all the online players

#

and reset the score

#

that's what literally @a does internally

outer steeple
#

when i do it nothing happens

#

the command fails

mortal hare
#

is it player scoreboard entry

outer steeple
#

this is what happens when i enter the command

idle trellis
#

Wouldn’t you compare the scores with β€˜matches’?

outer steeple
#

its the same thing

#

@mortal hare are u there?

mortal hare
#

maybe its the uuid

#

not the name stored in the entry

outer steeple
#

oh wait

#

1sec

#

even when i use UUID it doesnt work

#

the test still fails

#

@mortal hare

maiden briar
#

https://wiki.vg/Protocol#Teams
Friendly Flags Byte Bit mask. 0x01: Allow friendly fire, 0x02: can see invisible players on same team., how to implement this?

#

@outer steeple use double ==

outer steeple
#

ok

#

wait how? @maiden briar

maiden briar
#

Yes I already got that, but how can I put them in

#

Because the value is an int

mortal hare
#

use XOR

eternal oxide
#

it can;t be an int, it has to be a Byte

mortal hare
#

to flip the 0x1th byte

eternal oxide
#

protocol says its a byte

maiden briar
mortal hare
#

this.j ^= 0x01;

#

try this

maiden briar
#

Ok, and what if I want to use both options?

mortal hare
#

flip another one

#

this.j ^= 0x02

#

0x00 XOR 0x01 === 0x01

#

0x01 XOR 0x10 (0x10 is equal to 2 in binary) == 0x11

maiden briar
#

If I use no option, 0x00, if I choose the first one 0x01 and if I choose the last one 0x02, but what if I want both?

#

Then I need 0x11?

eternal oxide
#

no

#

thats bits you are using hex

#

0x01 & 0x02

maiden briar
#
public int packOptionData() {
        int var0 = 0;
        if (this.allowFriendlyFire()) {
            var0 |= 1;
        }

        if (this.canSeeFriendlyInvisibles()) {
            var0 |= 2;
        }

        return var0;
    }

ScoreboardTeam does this

mortal hare
#

you can do that too

#

thats OR operation

eternal oxide
#

yes

maiden briar
#

How does that work?

#

I am so bad with bytes / ints

mortal hare
#

but the OR operation doesnt allow you to reset the byte back

eternal oxide
#

it performs an OR operation on the value

#

var1 OR 1

maiden briar
#

Can you write an method for me explaining what I have to choose?

eternal oxide
#

Not sure what you are trying to achieve. these are simple operations

mortal hare
#

0b11 should work just fine

#

for both terms

maiden briar
#

There are four options, I want to know what I have to put in if I want to choose them

mortal hare
#

0b01 would select the first one

#

0b10 would select the second one

maiden briar
#

Or none, first one, second one, or both

eternal oxide
#

option first = 1, option second = 2, option both = 3

maiden briar
#

Yes and none = 0?

eternal oxide
#

yes

maiden briar
#

Ok thank you, that is what I wanted to know

mortal hare
#

it uses these weird bitmasks due to save bandwidth

#

since these values can only be true or false

#

why send them as a separate booleans for each when you can store 8 states in one byte

maiden briar
#

What do they mean with Collision Rule?

mortal hare
#

you can disable player collisions for people in the same team

#

this technique is used to disable player collisions like in 1.8

#

a.k.a you couldnt push players

#

honestly it was a feature in since 1.0, i don't know why it was removed and readded in 1.9

maiden briar
#

So that means, they can fight their own team members or now?

mortal hare
#

Collision rule means that they can push other players

#

by movement

#

it doesnt involve with hitboxes at all

maiden briar
#

So they can walk through them?

mortal hare
#

yes

maiden briar
#

Ah ok

mortal hare
#

that's how oldcombatmechanics plugin do it inside

maiden briar
#

Cool

tepid thicket
#
root:
  obj: !!java.util.UUID '2273d49b-91f4-4e93-bfb6-d9a2dde0e4cd'
} catch (InvalidConfigurationException ex) {
    Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
}
#

When I load this YamlConfiguration, it runs this line. (YamlConfiguration.java:188)

#

Are UUIDs not supported? Where can I find the supported types?

maiden briar
#

Save it as string with UUID.toString and load it with UUID.fromString

tepid thicket
#

So no direct support for UUIDs then. Okay, thx. πŸ™‚

#

Just wondered why it let's save that YamlConfiguration without error.

#

Seems a bit error prone.

mortal hare
#

true its weird that uuids can be deserialized but not serialized

tepid thicket
#

Yeah. (though you probably mean serialized)

eternal oxide
#

SnakeYaml will attempt to serialize anything thats passed to it

tepid thicket
#

Isn't it, that it can in most cases? So I hoped the deserialization would work too. πŸ˜›

quaint mantle
tidal hollow
#

I have a question, does anyone know how I can register my event with a constructor in the Main?

rotund lantern
#
    public void onMobSpawn(EntitySpawnEvent e) {
        List<EntityType> types = Arrays.asList(EntityType.ZOMBIE, EntityType.SKELETON, EntityType.VILLAGER);
        if (!types.contains(e.getEntityType())) {
            return;
        }
        LivingEntity entity = (LivingEntity)e.getEntity();
        entity.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));

    }

}```
#

help?

high talon
#

how can i restore the item?

hasty prawn
hasty prawn
hasty prawn
rotund lantern
hasty prawn
rotund lantern
#

maybe .sethelmet is not the right thing to do?

hasty prawn
#

Is the event being called? Add a print statement.

rotund lantern
#

Plugin Ketchop_Tutorial v0.8 has failed to register events for class me.ketchop.pog.main.Events.MobHeads because org/bukkit/event/entity/EntitySpawnEvent does not exist.

#

ok cool

hasty prawn
#

What version are you using

rotund lantern
#

1.8

hasty prawn
#

Thonk well it looks like it exists

rotund lantern
#

im getting scammed

hasty prawn
#

Guess the server just doesn't know about it for some reason

tardy delta
#

Using viaversion or that shit?

acoustic pendant
#

Hello, i need some help

#

this code:

#
            p.sendMessage("Created armor stand");
            p.closeInventory();
            if(plugin.armorstands.containsKey(p)){
                ArmorStand stand = plugin.armorstands.get(p);
                stand.setVisible(true);
                plugin.armorstands.remove(p);
            }```
#

should close the menu but it doesn't

#

and it sends the message

rotund lantern
hasty prawn
#

πŸ€·β€β™‚οΈ the only thing I can think of is that it doesn't exist in the server JAR.

#

No idea how that would happen though

#

Unless you're using some fork that renamed it for some reason

rotund lantern
#

idek what a fork is tbh

hasty prawn
#

PaperSpigot, for example, is a fork

acoustic pendant
#

dessie, could you help me? πŸ˜„

chrome beacon
#

Always delay close with one tick

#

Same goes for open etc

hasty prawn
#

^ That's the only thing I could think to do

acoustic pendant
#

how?

chrome beacon
#

?scheduling

undone axleBOT
acoustic pendant
#

but in the video i saw he didn't need to do delay

#

but he does the 1.12.2 inventories code maybe is for that

ivory sleet
#

1.12.2 😬

solid cargo
#

did i mess up curly braces?

eternal oxide
#

they are all if statements, no else

#

so if its less than 0.0001 it will pass every test

undone aspen
#

how to i fill a inventory with the items from a custom loot table that is added with a data pack?

quaint mantle
#

Wait but do java really depending that much on the order of them?

#

Blame me for not reading java tutorial by oracle

solid cargo
#

how is a growing wheat called?

quaint mantle
quaint mantle
solid cargo
quaint mantle
#

I used world painter to make map so i only know that

hasty jackal
# quaint mantle Wait but do java really *depending* that much on the order of them?

with what you were doing it, it very much did depend on the order.

String a = null;
this.component = new Component(a);
a = "Me";

What do you think the string that is now saved in Component would contain now? What if you put the a = "Me" before?
You're essentially passing the values that are contained in the variables. if you re-assign the variables, it only affects those variables, not the ones you passed previously. Especially since you were passing uninitialized stuff around.

undone aspen
#

I have a data pack on my server that contains a bunch of custom loot tables for our loot system, how can i fill an inventory with the loot? I see for vanilla loot tables you can use the LootTables enum and the
fillInventory method. But how can i do with with a custom loot table. No there is no physical chest to run a command on it needs to be added to an Inventory object within code. It it helps the loot table can be given to a player like this

/loot give @s loot lms:chests/common_loot

But i need to add it to a Spigot Inventory.

ornate heart
#

How would i detect which hand a player has attacked with?

vast shale
#

My method of getting an object returns succesfully, but won't work correctly...

    public BattleData getBattleData(Location l) {
        for (int i = 0; i < allBattles.size(); i++) {
            Location tempL = allBattles.get(i).getKey();
            double rangeX = l.getX();
            double rangeY = l.getY();
            double tempX = tempL.getX();
            double tempY = tempL.getY();
            
            if (rangeX < 0) {
                tempX *= -1;
                rangeX *= -1;
            }
            if (rangeY < 0) {
                tempY *= -1;
                rangeY *= -1;
            }
            
            if ((tempX < (rangeX + 10) && (tempX > (rangeX - 10))) && (tempY < (rangeY + 10) && (tempY > (rangeY - 10)))) {
                return allBattles.get(i);
            }
        }
        return null;
    }
#
BattleData battleData = main.battle.getBattleData(p.getLocation());
        npcs = battleData.getBattleNPCList();
#

The NPCs line fails because "battleData" is null

solid cargo
#

how can i check if a pumpkin/melon has been grown naturally

eternal oxide
#

show us the actual stack trace

vast shale
#
Caused by: java.lang.NullPointerException: Cannot invoke "me.WesBag.TTCore.Files.BattleData.getBattleNPCList()" because "battleData" is null
        at me.WesBag.TTCore.BattleMenu.Gags.Throw.Throw.onUse(Throw.java:26) ~[?:?]
        at me.WesBag.TTCore.BattleMenu.BattleMenu.onInventoryClick(BattleMenu.java:577) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7]
        ... 18 more
eternal oxide
#

um, your rangeX isn;t actually a range, its the X cord of the Location

vast shale
#

But I use it to just add or subtract 10 to get the range

eternal oxide
#

thats not a range

minor garnet
#

how i could use the build tools ? i already run build tools

eternal oxide
#

you are making any negative x,y into a positive while ignoring z

chrome beacon
#

Did you build 1.12.2

vast shale
#

Yeah I'm just checking if the player's location is nearby the object's key location

#

Y doesn't matter to me

eternal oxide
#

x and z are teh axis. y is height

vast shale
#

Yes

eternal oxide
#

why not just use teh Location.Distance method?

vast shale
#

Mmm thats a good idea

eternal oxide
#

you never use Z

vast shale
#

Oh damn

#

Im losing it lmao

minor garnet
vast shale
#

I'm still facing the problem of the method returning correctly but battleData being null though...

eternal oxide
#

its falling though and returning null

#

because your math is all wrong

#
for (BattleData data: allBattles) {
  if (data.getKey().distance(l) < 10)
    return data;
}```
vast shale
minor garnet
eternal oxide
#

your math is all wrong. you are not using Z and you are not even calculating a distance between x and y

minor garnet
#
      <repository>
        <id>spigotmc-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>

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

west lance
#

Any idea why my plugin still contains mojang mappings after remapping with specialsource?

#
    register<Exec>("obfuscate") {
       workingDir = project.buildDir
       commandLine(
           "java",
           "-jar",
           project.rootDir.resolve("specialsource").resolve("SpecialSource.jar").absolutePath,
           "--live",
           "-i", project.rootDir.resolve("out").resolve("build.jar").absolutePath,
           "-o", project.rootDir.absolutePath + "/out/build-remapped.jar",
           "-m", project.rootDir.resolve("specialsource").resolve("maps-spigot.csrg").absolutePath
       )
    }```
eternal oxide
#

because you should not be using speciaSource

eternal oxide
minor garnet
#

wait

minor garnet
#

look again

eternal oxide
#

you are using maven? @west lance

west lance
#

No

eternal oxide
#

ok, then perhaps you should be using special source

#

Maven does it all for you

west lance
#

I did everything as said in the "manual" guide

#
java -cp $HOME/.m2/repository/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar:$HOME/.m2/repository/org/spigotmc/spigot/1.17-R0.1-SNAPSHOT/spigot-1.17-R0.1-SNAPSHOT-remapped-obf.jar net.md_5.specialsource.SpecialSource --live -i $PLUGIN-obf.jar -o $PLUGIN.jar -m $HOME/.m2/repository/org/spigotmc/minecraft-server/1.17-R0.1-SNAPSHOT/minecraft-server-1.17-R0.1-SNAPSHOT-maps-spigot.csrg```
eternal oxide
#

can;t help there, I've not done it manually

vast shale
#

@eternal oxide I've tried your function and even added a message when it returns correctly. It does return correctly but the null error persists. Am I adding it to the list of BattleData incorrectly?

BattleData battleData = new BattleData(players, npcs, battleKey);
        allBattles.add(battleData);
#

Because the method is working correctly, just the object it returns is not correct

eternal oxide
#

it can;t be null if it returned a BattleData

vast shale
#

I get the returned correctly message when run though...

    public BattleData getBattleData(Location l, Player p) {
        for (BattleData data: allBattles) {
            if (data.getKey().distance(l) < 10) {
                p.sendMessage("Returned correctly!");
                return data;
            }
        }
}
#
Caused by: java.lang.NullPointerException: Cannot invoke "me.WesBag.TTCore.Files.BattleData.getBattleNPCList()" because "battleData" is null
        at me.WesBag.TTCore.BattleMenu.Gags.Throw.Throw.onUse(Throw.java:26) ~[?:?]
        at me.WesBag.TTCore.BattleMenu.BattleMenu.onInventoryClick(BattleMenu.java:595) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7]
        ... 18 more
eternal oxide
#

Throw.java:26

vast shale
#
        BattleData battleData = main.battle.getBattleData(p.getLocation());
        npcs = battleData.getBattleNPCList();
eternal oxide
#

which line is 26?

#

the npcs>?

vast shale
#

The 2nd one

#

yes the npcs

eternal oxide
#

add another debug for if it doesn't find a battle

vast shale
#

Like doesn't return in getBattleData

eternal oxide
#

yes, when it falls through to your return null

#

I'm going to guess you are removing teh battleData from your list/set when they click?

vast shale
#

No, I leave it there. Will that cause update issues?

#

I get the returned successfully message with no message about null...

eternal oxide
#

No I was just guessing as the inventory click event can fire twice

#

nm, I'm thinking of the interact event

vast shale
#

Just realized the getBattleData method isn't running in the Throw.java class

#

I get the message "done getting the first db" and thats the last thing i get before console throws the errors..

eternal oxide
#

The code you are showing now and the code you showed originally does not match the error you have been showing

quaint mantle
eternal oxide
#

the getBattleData method in this Listener is a two arg method.

waxen barn
#

hi there, can I set item meta even for air?

eternal oxide
#

no

#

AIR has no meta

waxen barn
#

and is there some other way how to mark inventory

#

other than name

mortal hare
#

inventory slots

#

inventory object

#

player metadata

#

data structures that store data whenever you do something

eternal oxide
#

object instance

mortal hare
#

every Inventory has its own Inventory object

#

if the compared instances don't match, they're different

#

no matter if they're identical in item stacks, names, lores, inventory view name

waxen barn
mortal hare
#

you want metadata for inventories?

waxen barn
#

so I can just check some boolean and get if it is protected, .....

waxen barn
mortal hare
#

well just wrap Inventory object into custom class

#

which holds booleans, etc

#

WrappedInventory.isProtected()

waxen barn
#

hmmm, that sounds as an solution

mortal hare
#

i bet you're doing a library for guis, right :D?

waxen barn
#

and the inventory from the event will be still this class, right?

mortal hare
#

no it wont

#

but you can check if that particular inventory is custom one

#

by storing it inside hashmap

#

or other data structure

waxen barn
mortal hare
#

inside some kind of InventoryManager

#

if InventoryManager doesnt have Bukkit provided Inventory inside its own data structure

#

ignore it

waxen barn
#

but from what you are saying, it gets reconstructed somewhere, so I can't just use == to check if they are still the same?

mortal hare
#

besides that return CustomInventory

#

if you dont want custom data

#

just use ==

#

to compare if inventories are the same

#

if you do

#

you need some kind of registry to hold your wrapped inventories somewhere

waxen barn
vast shale
mortal hare
#

lemme give you quick example

vast shale
#

The code itself is the same in terms of usability

waxen barn
# mortal hare just use ``==``

wait what, this isn't possible (or it is, but it isn't something, that will happen in this case) to have the same pointer, but different class?

waxen barn
mortal hare
#
public class InventoryMeta {
  private final Inventory inventory;
  private boolean protect;

  public InventoryMeta(Inventory inventory) {
    Objects.requireNonNull(inventory, "Failed to construct custom inventory! Bukkit Inventory object cannot be null!");
    this.inventory = inventory;
    this.protect = protect;
  }
  
  @Nullable
  public Inventory getInventory() {
    return this.inventory;
  }

  public boolean isProtected() {
    return this.protect;
  }  
}
#

then

waxen barn
#

but why can't i just extend the class then

#

because it isn't final

mortal hare
#

you can

#

the thing is Inventory is an Interface

#

and implementation is CraftInventory

waxen barn
#

ik

mortal hare
#

this makes you use OBC

#

internal bukkit implementations

#

which would require reflections to support every version

waxen barn
#

np, because it can be version dependent

mortal hare
#

even still i think you couldnt extend it

#

because you wouldnt be allowed to create extended inventory

#

via bukkit methods

#

Bukkit.createInventory would create #CraftInventory

#

not your extended class

waxen barn
mortal hare
#

what you would need to do is to register your own custom class inventory to some sorts of bukkit registry

#

that way Bukkit Event API would return you an inventory that you extended

#

new CraftInventoryCustom(owner, size); is a constructor for custom notchian type chest inventory

#

like 9x1, 9x2, 9x3, 9x4,9x6.. etc chest inventories

#

its not worth it

#

tbh

#

unless you write a gui lib

#

even that i would probably try to write packet level guis

#

which are more safe from dupes

#

since the items don't exist on the server and they're on the receiver's client only

#

idk how inventories are stored in bukkit

#

so cant say anything besides that

abstract summit
#

I am currently having a few issues with my servers. I uploaded a plugin which does a lot of thing async and therefor always calls Bukkit.getScheduler().runTaskAsync(() -> { [...] })
However since I uploaded that I am experiencing Server crashes. Normally I would just blame it on the plugin but I took a look at the heap dump:
After the Server crashed I had nearly 1 Million org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncDebugger instances.
After I then restarted I just had 150 instances.

So I suspect this is could be related. Is there any know Issues about that? Or is it something the plugin made wrong when calling runTaskAsync?
Btw the code which runs async publishes a message though jedis, so its most likely not stuck in the Async Task.

Disclaimer I know 1.8 is outdated af. I am not asking for a fix (I dont even know if its spigot related). I just want to know if there is a known bug / issue.

mortal hare
#

what do you run in async task

quaint mantle
#

How to make a player spin in random directions very fast?

mortal hare
#

change their pitch and yaw

opal juniper
#

?paste the code you are using

undone axleBOT
abstract summit
# mortal hare what do you run in async task
                Bukkit.getScheduler().runTaskAsynchronously(Core.getInstance(), () -> {
                    String json = gson.toJson(notifyData);
                    try (Jedis jedis = Core.getInstance().getJedisPool().getResource()) {
                        jedis.publish("server:v1:notify", json);
                    }
                }```
mortal hare
#

i don't use jedis (redis), but here's what I found: Jedis is all synchronous with the exception of pipelines. Pipelines allow asynchronous usage of Redis but, unfortunately, cannot be used alongside clustering. However, pipelines are easy enough to use:

ivory sleet
opal juniper
#

you could always just have a new thread that you dedicate to publishing

ivory sleet
#

You might unintentionally grow the cached thread pool craft scheduler is using for async tasks which is unnecessary.

abstract summit
quaint mantle
#

is there any way to completely remove the display of a player's name (above their head)

opal juniper
#

i think you do it with teams

worldly ingot
#

You can add them to a scoreboard team and set the display nametags option to false

#

Yep

quaint mantle
#

Ok thx

#

If i want to constantly check in an event if a player is contained in a set, should I use PlayerJoinEvent?

opal juniper
#

Well - It only gets triggered when a player joins - what do you mean by "constantly"

quaint mantle
#

If i do a specific command the player gets added to a set, now to detect whether the player is in the set or not... im not sure what event to use since playerjoinevent only triggers when the player has joined

eternal oxide
#

don;t track players, track their UniqueId

opal juniper
#

You can use a runnable to loop every x ticks

eternal oxide
#

the Player object can go stale, their UUID will not

opal juniper
#

But idk what you are trying to do

#

and yes

#

what ElgarL said

misty current
#

hi, small question about MongoDB designing, i have multiple documents that hold different coordinates and an owner. Should i have different documents for each location or have a single document with a single owner and all the locations? what is more efficient/cleaner to access/write to?

idle trellis
#

does anyone know the damagecause of /kill?

golden turret
#

suicide and depression πŸ’€

misty current
#

SUICIDE - Damage caused by committing suicide using the command "/kill"

solid cargo
#

Yo how can i include the api in the plugin

#

So i dont have to add 3836117 apis to a server

#

And just put all in one plugin

onyx shale
#

Compile it all together

#

The jar will get bigger tho

waxen barn
solid cargo
#

Yeah ik

#

But like

#

Where do i put it

#

/how do i compile it to include the api

misty current
#

some plugins can't be shaded into your jar

#

such as protocollib

solid cargo
#

Yeah ik

#

But like netherboard api?

misty current
#

you can use maven's scope for that

misty current
#

test i guess

solid cargo
#

But shaded includes the apis?

misty current
#

try to add it as a dep and see if it works even without the plugin in your folder

#

well if you add it as a depend with maven/gradle ofc you have the api access

solid cargo
#

i tried removing the api from the thing

#

and the main plugin just dies

#

like doesnt even show on /pl

misty current
#

send the error

solid cargo
#

ugh, i just booted up my pc

#

ok i wil

#

UnknownDependencyException

#

quite usual

#

means that the api is missing

misty current
#

remove the plugin from depend or soft depend

solid cargo
#

aights

#

hm now the plugin doesnt die

#

lets see if it works

#

nope now the plugin is colored red

#

wait nvm

#

the joinevent doesnt work

#

everything else does

#

joinevent contains the netherboard api thing

misty current
#

then i guess netherboard needs to be included as a pl

#

lemme check their git hold o

#

yeah pretty sure you need to

solid cargo
misty current
#

ah mb it says either

#

are you using maven or gradle?

solid cargo
formal dome
#
  public class BroadcastReader extends JavaPlugin implements Listener {

    public JDA jda;
    public String guildId;
    public String channelId;
    public String botId;

    @Override
    public void onEnable() {

        guildId = "758813062848708670";
        channelId = "758813063448363011";
        botId = "nonyas";


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

        try {
            jda = JDABuilder.createDefault(botId).build();
        } catch (LoginException e) {
            e.printStackTrace();
        }
    }

    @EventHandler
    public void onMessageBroadcast (BroadcastMessageEvent event) {

        jda.getGuildById(guildId).getTextChannelById(channelId).sendMessage(event.getMessage());

    }```

my plugin is intended to trigger on a broadcast message and then send the message to my discord channel. however it is not working as intended
#

or at least, i'm not sure hwo to debug it

quaint mantle
#

uhhm

formal dome
#

a few questions:

  1. what is considered a broadcast message?
  2. is my event handler set up correctly to trigger on broadcast messages?
  3. i have 3 warnings:
    a. Method invocation 'getTextChannelById' may produce 'NullPointerException'
    b. Method invocation 'sendMessage' may produce 'NullPointerException'
    c. Result of 'MessageChannel.sendMessage()' is ignored
worldly ingot
#
  1. Calls to Server#broadcast(). Maybe not quite what you want. You'd be more interested in AsyncPlayerChatEvent most likely
  2. Yes
  3. a. getGuildById() will return null if a guild with the id doesn't exist. You should check for this.
    b. getTextChannelById() will return null if a channel with the id doesn't exist. ""
    c. You can ignore this. Your IDE is being extremely over-sensitive. Unless of course you want to send some output based on the result of that sendMessage() call
#

Actually, JDA doesn't want you to ignore the return value. It seems to be annotated with @CheckReturnValue. Docs say you should follow calls to sendMessage() with a call to queue() (presumably so that you don't overload the Discord API)

upper vale
#

The message will never be sent if you don’t queue, complete, or submit it

worldly ingot
#

Ye

misty current
worldly ingot
#

So everything seems fine only you'll want to change your listener to look a bit more like this:

    @EventHandler
    public void onMessageBroadcast (BroadcastMessageEvent event) {
        Guild guild = jda.getGuildById(guildId); // Though you should only get this once and then cache it, probably
        if (guild == null) {
            return;
        }

        TextChannel channel = guild.getTextChannelById(channelId); // This too you should probably get once and cache
        if (channel == null) {
            return;
        }

        channel.sendMessage(event.getMessage()).queue();
    }```
(and use AsyncPlayerChatEvent if preferred - I don't know if you're actually listening to server broadcasts on purpose)
misty current
#

so I have a method that makes a request to mongo and returns the value and i was wondering if there was a way to execute it async as it probably would slow down the main thread

#

of if i should not be worried about it

worldly ingot
#

CompletableFuture is your best friend

trail oriole
#

hello

#
05.10 21:07:35 [Server] Server thread/ERROR Could not load 'plugins/BingoBook.jar' in folder 'plugins'
05.10 21:07:35 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: fr/frenchkiwi/bingobook/Main has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0```
can someone explain what this means rq ?
misty current
worldly ingot
trail oriole
#

i can't load my plugin

misty current
#

would it give issues with spigot or nah

trail oriole
#

which is sad

worldly ingot
#

Your server is running on Java 8, your plugin is compiled against Java 16, frenchkiwi

trail oriole
#

how do i fix this ?

worldly ingot
#

So either downgrade the version against which you're compiling your plugin, or run your server using 16

trail oriole
#

how do i downgrade the compiling version ?

worldly ingot
#

Going to assume you're not running MC 1.17+ because it requires Java 16 heh

#

Depends on your IDE

trail oriole
#

eclipse

worldly ingot
#

1 sec

trail oriole
#

and no, mc 1.16.5

worldly ingot
#
  1. Click your project and press Alt + Enter
  2. Press "Java Build Path"
  3. Select "Libraries" in the top tab bar
  4. Click on "JRE System Library [JavaSE-16]" (or something similarly named to that), then press "Edit" on the right
  5. Select the Java 8 build environment
trail oriole
#

found it

worldly ingot
#

If you don't see "jdk-8.0.275.1" (or something similar to that), you may not have Java 8 installed properly. Though I think Eclipse has it installed by default

trail oriole
#

thanks imma try rq

quaint mantle
worldly ingot
#

Also, are the docs fucked up for anybody else? πŸ˜… Everything is bold in that doc

opal juniper
#

yep - all bold

quaint mantle
#

yea

worldly ingot
#

Pretty much anywhere you want. Presumably on startup if you're performing the same task such that your plugin is enabled

#

Can just schedule a timer to run every tick or every second in your onEnable()

quaint mantle
#

are methods in methods even possible?

worldly ingot
#

No, but it's not a method. It's a Runnable

opal juniper
#

you can provide a lambda

worldly ingot
#
@Override
public void onEnable() {
    Bukkit.getScheduler().runTaskTimer(this, () -> {
        // Code written in here is run every tick
    }, 0L, 1L);
}```
mortal hare
worldly ingot
#

Or you can have a class implement Runnable as well and create a new instance of it

#

If you require some instance fields and constructors, etc.

quaint mantle
#

oh ok

trail oriole
#
getCommand("bc").setExecutor(new CommandTest());``` this is so basic and yet not working what is wrong with me
opal juniper
#

what is not working

#

what is CommandTest

trail oriole
#

error says this line isn't

#

it's a java class

opal juniper
#

i figured

misty current
#

so i've looked into completable future but would I be able to cancel an event async with it? I'm tryna check on block break if my db contains the coords of those blocks and if they are there cancel

trail oriole
#
05.10 21:13:48 [Server] INFO at fr.frenchkiwi.bingobook.Main.onEnable(Main.java:12) ~[?:?]```
misty current
#

you need to register your commands in the plugin.yml

trail oriole
#

am i that dumb ?

#

like fr ?

misty current
#

maybe

trail oriole
#

okay well thanks

misty current
#

happens often

#

np

trail oriole
#

sorry to ask dulb questions

misty current
#

dw

visual tide
trail oriole
#

nah i had forgot

#

sorry

quaint mantle
opal juniper
#

What do you need to do if the player is in the set>

formal dome
quaint mantle
opal juniper
#

So just make a runnable that runs every say 20 ticks and give them 2 secs of those effects to allow for tps drops

quaint mantle
#

But i dont know how to reference the player in the main class

opal juniper
#

Where is the set, why dont you have it as a field in the main and then just add adder / remover methods

formal dome
#

even doing messages to and from the server would be dope

young knoll
#

Not many plugins use broadcastMessage

formal dome
#

i can concern myself with the actual content of the message after

quaint mantle
#

there is no setMarker method in 1.8.8 for entityarmorstand
what to do

worldly ingot
#

Β―_(ツ)_/Β―

#

We're 6 years ahead of you here

quaint mantle
#

no one delays hit

#

and uses shitty plugins like ocm

#

any idea what to do ?

opal juniper
#

was that even a thing in 1.8

#

but i mean

#

implement it yourself??

#

just add it to craftbukkit and bukkit and then compile

quaint mantle
#

you mean i should edit the whole 1.8 for a plugin ?

young knoll
#

Or you can use NMS

quaint mantle
#

im using nms

opal juniper
#

that^

quaint mantle
#

what is entityarmorstand then

#

craftarmorstand has setMarker

#

but not entityarmorstand

#

anyway to edit its nbt

#

without NBTAPI

young knoll
#

entityarmorstand probably has the methof name obfuscated

quaint mantle
#

oh cool

#

great

#

and no one knows shit

young knoll
#

The craftarmorstand version should work

quaint mantle
#

there was nothing on bukkit, spigot and..

quaint mantle
#

i want the nms armorstand

formal dome
#

@worldly ingot messages aren't sending... i want to assume that using /broadcast message here

#

would work

quaint mantle
#

What does nms stand for

#

net.minecraft.server

formal dome
#

oh wait a second

worldly ingot
#

Assuming you mean Essentials' /broadcast command, it depends entirely on how Essentials implements it

#

They might just loop all players and use Player#sendMessage() manually instead of Server#broadcast()

formal dome
#

my guild is returning null

worldly ingot
#

Well, that would help too πŸ˜…

formal dome
#

why

quaint mantle
#

how to edit nbt of entityarmorstand

#

and set the marker to true

#

marker:1 aaaaa

worldly ingot
#

If you're using the NMS stand, the method is probably obfuscated by that point because API hadn't been added until later

#

Take a browse through nms.EntityArmorStand and see where the field determining its marker status is being set

quaint mantle
#

the code ?

worldly ingot
#

Could be .h() or something ;p

#

Yes

#

Reading the entity's NBT save/load methods makes determining which field is marker much easier (because strings aren't obfuscated, for obvious reasons), then find the method that sets that field to whatever value

quaint mantle
#

i guess n

formal dome
#

idk what changed but the guild isn't returning null anymore

#

hang on

meager flare
#

Is anybody using jitpack as maven repo for java 16 project?

#

I just cant make it work

quaint mantle
#

i found a thread yesterday explaining how to make floating items with packets
but i cannot find it now. can anyone give a thread explaining how to do it

subtle kite
#

ctrl + H

quaint mantle
#

and it is dead

trail oriole
#

what is a LEGACY_SKULL_ITEM, i'm just trynna get the skull

#

like legacy

young knoll
#

What

trail oriole
#
ItemStack skull = new ItemStack(Material.LEGACY_SKULL_ITEM, 1, (byte) 3);```
#

this

#

i tried SKULL_ITEM

#

but the only way is the LEGACY_SKULL_ITEM

#

What's the difference

young knoll
#

That is a pre 1.13 name

#

Heads were split up post 1.13

worldly ingot
#

PLAYER_HEAD is what you want

#

No byte data

#

new ItemStack(Material.PLAYER_HEAD)

trail oriole
#

ouh

#

ok

worldly ingot
#

Anything LEGACY_ you should avoid and never directly reference

trail oriole
#

ok thanks

#

wait so is my entire code old with pre 1.13 stuff ?

worldly ingot
#

If you're using LEGACY_ constants, yes. You want to use the ones without that prefix

#

You'll want to set api-version: 1.13 (or higher) if you're using the new constants

alpine urchin
#

what does latest spigot do if api version is older than the spigot version

#

i always assumed it would just deactivate the plugin

#

or say your spigot is too new or something

minor garnet
alpine urchin
minor garnet
#

yes and yes

alpine urchin
#

ok

#

cool..

alpine urchin
#

ok

opal juniper
#

as long as you specify it

#

if not you are in backwards compat hell

alpine urchin
#

i heard on 1.16+ it downloads dependencies in plugin yml

#

automatically

opal juniper
#

yep

#

from maven central

alpine urchin
#

from spigotmc?

#

oh

#

i heard you guys do maven abusing

opal juniper
#

😈

alpine urchin
#

forge once did this and got a letter from maven

opal juniper
#

yeah but it does get cached

#

*Saved

opal juniper
#

so its no different to just an ide loading really

#
  • as in downloading it
#

if not in m2

alpine urchin
#

Ok

opal juniper
# alpine urchin Ok

It seemed like it was "you cant have access to the class loader but we will give you this instead"

subtle kite
#
@EventHandler
        public void entityDamagedByEntity(EntityDamageByEntityEvent e){
            if (e.getDamager() instanceof Player) {
                Player damager = (Player) e.getDamager();

                Entity entity = e.getEntity();

will 'Entity entity = e.getEntity();'
use a player as a entity

subtle kite
#

I think I just need to target blazes only

worldly ingot
#

Yeah, that will call for any entity, including players

subtle kite
#

thought so

worldly ingot
#

You can compare e.getEntityType() if you'd like

#

Or instanceof if you want some more convenient casting

#
if (e.getEntity() instanceof Blaze blaze) {
    // etc.
}```
subtle kite
#

e.getEntityType() should just do the job

worldly ingot
#

Depends on what you want, yeah

subtle kite
#

just when a players hit them , they don't take kb

civic apex
#

is there any event fired just after inventoryclickevent? to get the resulting inventory after the server processes inventoryclickevent

worldly ingot
#

Suppose GSON is treating them as actual objects

stone sinew
#

Yeah I see the = lol

worldly ingot
#

That being said, for what reason are you serializing/deserializing?

stone sinew
#

Chest items need to be saved.

civic apex
#

or do I have to use schedulers in some way

stone sinew
#

Anyway to fix the gson using = instead of :?

stone sinew
formal dome
#

MY PLUGIN WORKS LETS GOOOO

ivory sleet
#

Nice

civic apex
#

nice

stone sinew
#

Wow... exactly 2k chars and it won't let me post it.

civic apex
#

yup

#

i had issues with that as well

#

discords client would let me send it

stone sinew
#
Gson gson = new Gson();
Map<String, Object> serializedItem = i.serialize();
String serializedString = gson.toJson(serializedItem);
Bukkit.broadcastMessage("GSON >> "+serializedString);
        
ItemStack is = null;
Map<String, Object> deserializedItem = gson.fromJson(serializedString, new TypeToken<Map<String, Object>>(){}.getType());
Bukkit.broadcastMessage("deserializedItem >> "+gson.toJson(deserializedItem));
is = ItemStack.deserialize(deserializedItem);

GSON >> {"v":2730,"type":"DIAMOND_PICKAXE","meta":{"displayName":"[{"text":"Testing","italic":false,"color":"gold","bold":true}]","lore":["[{"text":"","italic":false}]","[{"text":"Testing","italic":false,"color":"gray"}]"],"enchantments":{"Enchantment[minecraft:efficiency, DIG_SPEED]":5,"Enchantment[minecraft:fortune, LOOT_BONUS_BLOCKS]":3,"Enchantment[minecraft:unbreaking, DURABILITY]":3},"attributeModifiers":{},"repairCost":0,"hideFlag":5,"unbreakable":true,"damage":1560,"unhandledTags":{},"persistentDataContainer":{"customDataTags":{},"registry":{"CREATE_ADAPTER":{},"adapters":{}},"adapterContext":{"registry":{"CREATE_ADAPTER":{},"adapters":{}}}},"version":2730}}

deserializedItem >> {"v":2730.0,"type":"DIAMOND_PICKAXE","meta":{"displayName":"[{"text":"Testing","italic":false,"color":"gold","bold":true}]","lore":["[{"text":"","italic":false}]","[{"text":"Testing","italic":false,"color":"gray"}]"],"enchantments":{"Enchantment[minecraft:efficiency, DIG_SPEED]":5.0,"Enchantment[minecraft:fortune, LOOT_BONUS_BLOCKS]":3.0,"Enchantment[minecraft:unbreaking, DURABILITY]":3.0},"attributeModifiers":{},"repairCost":0.0,"hideFlag":5.0,"unbreakable":true,"damage":1560.0,"unhandledTags":{},"persistentDataContainer":{"customDataTags":{},"registry":{"CREATE_ADAPTER":{},"adapters":{}},"adapterContext":{"registry":{"CREATE_ADAPTER":{},"adapters":{}}}},"version":2730.0}}```
Besides integers being doubles they're the same now. But item still isn't the same.

civic apex
#

but it would show as red and clyde said it was unable to be sent

stone sinew
#

I repasted the message and it said -6 chars even though originally it said 0

civic apex
#

importe?

#

imports

#

?

vague oracle
#

It will tell you if you hover over

civic apex
#

what

#

cant find what

#

if you are using eclipse

#

ig you can try ctrl a ctrl x ctrl v

#

sometimes magically fixes problems for me

#

cause eclipse manages to find problems that dont even exist

#

btw how can i get the inventory after InventoryClickEvent? (Im talking about the β€˜event.getInventory()’ one not the β€˜event.getWhoClicked().getInventory()’)

ashen flicker
#

What?

#

What are you trying to do

civic apex
#

get the inventory AFTER server processes inventoryclickevent

stone sinew
young knoll
#

You will need to use a runnable I imagine

civic apex
ashen flicker
#

My first question is. Why is that necessary?

#

However if it was, you’d have to store it somewhere and use it from that

civic apex
stone sinew
ashen flicker
#

What are you trying to do, like what problem are you solving that makes you think you need to do that

civic apex
young knoll
#

1 tick is all you need

ashen flicker
#

You don’t need to do that for a GUI

stone sinew
civic apex
civic apex
#

im pretty sure HIGH can still cancel events

young knoll
#

Correct

#

Monitor can, but it shouldn't

ashen flicker
#

make a GUI handler class, and make guis from that. I extend my GUI class and make guis from that. All the listeners are handled through my api. If you do it manually every time, you’re just dealing with too much duplicate code

stone sinew
civic apex
civic apex
#

that goes after all events

#

even the HIGHEST ones

#

iirc

ashen flicker
#

I don’t think I understand your objective

stone sinew
ivory sleet
#

All priorities can cancel events

ashen flicker
#

And I don’t think you understand what I’m saying

civic apex
opal juniper
arctic moth
#

anyone know how to get where the current world border is

arctic moth
#

i googled but all i got was shit about how to use /worldborder

civic apex
#

how would i know the inventory state if an event can run later (HIGHEST), and cancel the click

ivory sleet
#

If it implements Cancellable then it should

ivory sleet
#

Sadly there isn’t really any post events for certain actions

#

You’d just have to rely on that no one is manipulating at monitor priority

#

And if someone actually does that then it’s out of your control

civic apex
#

if i have a HIGH priority event i cannot determine the post state since a HIGHEST event could easily cancel it

ivory sleet
#

What state?

#

The event state

#

?

young knoll
#

Monitor can be used

civic apex
ivory sleet
#

But yeah highest is invoked after high

young knoll
#

Plugins shouldn't be cancelling in monitor

ivory sleet
#

Why not just set yours to highest?

plain scroll
#

ive been trying to fix that whole in a gui when you have an item thats null it giving that error to the console, I cant find anything that works anyone got any ideas?

civic apex
ivory sleet
#

Plugins shouldn’t generally be doing anything considered as a mutation in monitor

quaint mantle
#

if another plugin is cancelling the event it should be cancelled

young knoll
#

^

ivory sleet
quaint mantle
#

or use monitor

plain scroll
quaint mantle
#

the type cant be null

civic apex
#

but how do i schedule? because e.getinv is always the same

plain scroll
#

OH

young knoll
#

Type can never be null anyway

plain scroll
#

THAT MAKES SENSE

young knoll
#

afaik

vagrant stratus
#

ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
What's this for 1.13+

civic apex
#

no matter when its run

civic apex
#

, 1

quaint mantle
#

magic values πŸ™‚

vagrant stratus
young knoll
#

the 1 isn't needed

#

1 is the default stack size

ivory sleet
#

@civic apex it isn’t

civic apex
ivory sleet
#

Either it’s the actual instance or a delegate

#

So any actions made on that instance would have to be reflected onto the actual inventory

civic apex
ivory sleet
#

Even if scheduled

vagrant stratus
formal dome
#

can i have two plugins in one jar?

young knoll
#

They generally match the in game name

ivory sleet
#

But if it’s having 2 jars in one jar

#

Yeah in principle

#

Like nested jars

civic apex
#

btw random question how should i handle compilling after a project gets big

formal dome
#

i just need to have two extenstions on one class

#

is that possible

civic apex
#

many classes

formal dome
#

i was considering doing another class that extends another javaplugin

civic apex
#

compile time high

ivory sleet
#

Uh code architecture or just compiling time?

mortal hare
#

split it into many artifacts

#

and use it as depedencies

mortal hare
#

i guess

formal dome
#

well the issue comes down to the fact that i cant extend two classes in one

young knoll
#

Correct

ivory sleet
# civic apex time

Well you can isolate your io devices from your business rules and put them behind boundaries, each io device handler would then have its own jar such that you can independently deploy

young knoll
#

You can implement several interfaces though

ivory sleet
#

In that case not everything would have to recompile everytime

young knoll
#

Also you can only have one class extending JavaPlugin

formal dome
#

public class BroadcastReader extends JavaPlugin implements Listener extends ListenerAdapater

mortal hare
formal dome
#

ohhh

ivory sleet
#

Multiple class inheritance is not possible

#

Due to the Diamond problem for instance

plain scroll
#

java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because the return value of "org.bukkit.event.inventory.InventoryClickEvent.getCurrentItem()" is null

#

this error is so annoying

#
}else if (e.getCurrentItem() == null) {
                    return;
                }```
#

this should work right?

young knoll
#

Yes but why is it in an elseif

#

It should be one of the first checks

plain scroll
#

kk

#

ty

arctic moth
#

is it possible to get a world from a location

ivory sleet
#

Yes

#

Location::getWorld

arctic moth
#

thx

quaint mantle
ivory sleet
#

Just method reference noping2

arctic moth
#

also is there a way to disable spawn protection

#

so it doesnt get in the way

#

lol

young knoll
#

Yes

#

server.properties, set it to 0

arctic moth
#

i meant with spigot

young knoll
#

I mean, you can probably modify that file with spigot

arctic moth
#

ok

young knoll
#

But you probably shouldn't

arctic moth
#

lol someone made a library

#

thx google

#

outdated reeeeeeeeeeeeeeeeeeee

#

what is DedicatedServer in the new api

formal dome
#

ah so commands don't count as playermessageevents

young knoll
#

Correct

#

PlayerCommandPreprocessEvent iirc

formal dome
#

what kind of events are those?

#

ohhh

#

thanks

arctic moth
#

would something like this work?

try {
            List<String> lines = Files.readAllLines(path);
            for(String line : lines) {
                if(line.startsWith("spawn-protection")) {
                    lines.remove(line);
                    break;
                }
            }
            lines.add("spawn-protection=0");
            Files.write(path, lines, StandardOpenOption.TRUNCATE_EXISTING);
        } catch (IOException e) {
            e.printStackTrace();
        }
formal dome
#

is there a generic event that handles all console messages?

#

i may not want it just because i want control over which events and messages are sent to discord

arctic moth
#
Path path = Paths.get(getDataFolder().getParentFile().getAbsolutePath()).getParent().resolve("server.properties");
        try {
            List<String> lines = Files.readAllLines(path);
            for(String line : lines) {
                if(line.startsWith("spawn-protection")) {
                    if(line != "spawn-protection=0") {
                        lines.remove(line);
                        lines.add("spawn-protection=0");
                        reloader.runTaskLater(this, 30L * 10L);
                    }
                    break;
                }
            }
            Files.write(path, lines, StandardOpenOption.TRUNCATE_EXISTING);
        } catch (IOException e) {
            e.printStackTrace();
        }
#

now would it work lol

#

(reloader is just a bukkitrunnable with Bukkit.reload)

#

it returns a ClassNotFoundException

#

nvm

#

i screwed up plugin.yml lol

torn shuttle
#

ok so this is an issue that has been haunting me for a little while and I want to get it fixed at this point

                            for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(10, 10, 10)) {
                                entity.setVelocity(entity.getLocation().clone().subtract(eliteEntity.getLivingEntity().getLocation()).toVector().normalize().multiply(2).setY(1.5));
                                if (entity instanceof LivingEntity)
                                    ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 3, 2));
                            }

is sometimes - not always - printing java.lang.IllegalArgumentException: x not finite for set velocity

#

am I somehow rounding this in a dumb way because I can't really picture how x isn't finite here

#

I just can't picture how x isn't finite

#

the only way I can twist this into something I can understand is if somehow on the same tick the entity died but also still somehow got picked up in the nearby entity scan and also somehow the location of the entity is now nonsensical

formal dome
#

how do i reference my current instance of spigot in a class outside of my javaplugin class

torn shuttle
#

of spigot or of your plugin

formal dome
#

the server

#

i want to send a message

#

like a broadcast

torn shuttle
#

Bukkit.getServer() gets your server

formal dome
#

okay

#

is there a server class

#

that i can set that equal to as a variable

#

yes there is

torn shuttle
#

... that's what that method returns

crisp arch
#

TabCompleter vs TabExecutor?

worldly ingot
#

TabExecutor is just a TabCompleter and a CommandExecutor

#

instead of implementing both, you can just implement TabExecutor. Is just a convenience interface

quaint mantle
#

really? i always implemented both

vagrant stratus
#

So, here's a good question.
There's a utility class that creates a bunch of items with customizable lore/display names.
What's the best way of handling that as a whole?

Make the messages config public static or what?

torn shuttle
#

some people go extra hard to make sure they're used in a specific way

vagrant stratus
echo basalt
#

with automatic colors and whatever

torn shuttle
#

making the class constructor private is so extra I have a hard time bringing myself to do it

echo basalt
#

Then my messages.yml file looks like

messages:
  prefix: "&5&lSome&d&lPlugin &8Β»&f"
  
  some-message: "%prefix% &aHello!"

and I just call

messagesFile.sendMessage(commandSender, "some-message");

vagrant stratus
echo basalt
#

In that case

torn shuttle
#

this is for storing config fields?

echo basalt
#

A constants class with a public static void load(FileConfiguration config) method

torn shuttle
#

or rather to store stuff you get from config is how I should phrase it

echo basalt
#

And whatever methods you need

vagrant stratus
echo basalt
#

Are you using those items in enums or something?

vagrant stratus
echo basalt
#

only case I'd have to make a Constants class is if I am using enums with custom values

torn shuttle
#

personally I have a setup that initializes public static non-final fields for whatever it is I need from config and they're stored in the class that does the config initialization, makes it super convenient to me

echo basalt
#

I can't really share much code but my idea is just

#

with some getters

#

and that's the only project I ever had to use such code because it's like 90% enums

vagrant stratus
echo basalt
#

But if I need items from config

torn shuttle
#

static isn't bad code

echo basalt
#

yeah

vagrant stratus
#

It depends

echo basalt
#

static is good when applied correctly

#

People just abuse it often

vagrant stratus
#

trying to not abuse it, hence the question πŸ˜‚

echo basalt
#

for convenience

torn shuttle
#

static abuse is bad, but static exists for a valid reason and it would be bad code not to use it in those instances

#

this sounds like one such instance

echo basalt
#

It's not abuse as you're using it for constants that are used throughout the plugin's lifespan and serve no other purpose

#

just make sure to call clone() otherwise you can have weird issues (when manipulating the constant objects)

vagrant stratus
#

Yea, no real clean way to do it non-statically in this case.
Unless i wanna pass a class around just for items that are constants 🀣

echo basalt
#

I usually always pass my main

#

and just have like 200 references to it

torn shuttle
#

sure there are clean ways to do it non-static

#

they're just way worse than using static

echo basalt
#

my main always acts as a sort of proxy to all getters I'll ever need

#

No matter the project size, all classes that need to interact with each other have access to my main

#

via dependency injection

vagrant stratus
echo basalt
#

just pass your main and have an ItemManager class

#

and a getter to it

torn shuttle
#

I don't see what the problem with them being configurable is

#

I've got literally thousands of those and it's not a big deal

#

actually I have tens of thousands but w/eve

#

r

vagrant stratus
#

It's done in a Util class which means I can't pass a class to it. Wasn't 100% sure on the best way of handling that hence asking

echo basalt
#

just make a public static void load(...)

vagrant stratus
#

Yea, most likely gonna do that.
Don't like it, but anything else is just dumb

echo basalt
#

Β―_(ツ)_/Β―

echo basalt
#

I've seen people use constructors for it

#

which is just even worse

vagrant stratus
#

Yea, this class can't be extended, implemented, or initialized πŸ˜‚

torn shuttle
#

don't get stuck picking the wallpaper

echo basalt
#

yeah just do it and move on

#

I'm looking at some massive projects of mine and I'm just like

vagrant stratus
#

Yea i know, I figured it was best to ask here first to see if there was some better way πŸ˜‚

echo basalt
#

"how tf did I make a whole skyblock core with multi-proxy support and custom packet system in 5k lines"

torn shuttle
#

3 months from now you'll look back and find a better way

vagrant stratus
#

maybe lol

torn shuttle
#

12 months later you'll go back and find an even better way

echo basalt
#

perhaps

#

10 years later he's just gonna do it in assembly

vagrant stratus
#

I have yet to learn assembly, but i want to πŸ˜‚

torn shuttle
#

20 years later and you'll be too drunk from trying to forget all the bad code decisions that took you to that point in life to find better solutions

echo basalt
#

20 years from now he'll make custom hardware that loads it

#

or that

vagrant stratus
#

gonna code a MC server in assembly

#

sell it for $1K

torn shuttle
echo basalt
#

1k is nothing for an mc server

vagrant stratus
echo basalt
#

yeah

#

if it's unique

#

if you're reselling then 500 works

torn shuttle
#

you need to review your definition of what a mc server is and how much money 1k is

echo basalt
#

depends

#

if it's like commissioned then 1k is little

vagrant stratus
#

Tbf, that would probably be the most optimized server jar out there πŸ˜‚

echo basalt
#

specially in assembly

torn shuttle
#

99% of people out there aren't paying $1 even if doing so gave them eternal life

echo basalt
#

but if you're reselling

vagrant stratus
#

Imagine the amount of click-bait i can put 🀣

echo basalt
#

then you can charge less

#

stop it optic

#

you're gonna make it seem like minestom

vagrant stratus
#

"100% MOST OPTIMIZED SERVER JAR ON THE MARKET"

echo basalt
#

"fully async no lag only performance best jar minecraft fortnite tik tok 2019 2022"

#

just toss all the keywords

torn shuttle
#

you guys are going in the wrong direction

echo basalt
#

"gets you laid the moment you run it in kubuntu"

torn shuttle
#

say hello to MineStonk, the first cryptominer mc server

#

play mc and get paid to do it

#

I get 50% of whatever you mine

echo basalt
#

I know a lot of pump and dump that were quicker than that

vagrant stratus
#

I'd probably want to learn C or C++ first though lol

torn shuttle
#

who cares about performance when you're making that stonks money

echo basalt
#

C was fun

vagrant stratus
#

I do have a book on assembly though, same with python and php πŸ‘€

echo basalt
#

"minesupreme we sell your IP address every time you join to some swat team"

#

I dislike python

vagrant stratus
echo basalt
#

it's simple to the point of autocompletes not working

torn shuttle
#

minetrends please fill this form every time you join so we get 50 cents for every 1000 forms filled

echo basalt
#

optic quick question not sure if you know

#

If I send a new metadata packet, with 1 element, do all old values get overwritten to their default state?

vagrant stratus
#

no idea i haven't used packets

#

ask me in 40 years when I'm making my own CPU's

echo basalt
#

am I more advanced than you 😞

vagrant stratus
#

Nah, i just don't main spigot deving lol

torn shuttle
#

I main spigot deving and I don't touch packets

echo basalt
#

rip

torn shuttle
#

that shit is cursed

echo basalt
#

I got bored so I made my own packet system inspired on NMS

torn shuttle
#

if I wanted to do nms I'd go make my own game instead

#

which is what I am doing

echo basalt
#

with like 250 different ways of handling

carmine nacelle
#

What is the lambda way to run a Sync task inside an Async task? I forgot

echo basalt
#

you can config it to use redis, rabbitmq, plugin messaging

#

mysql if I can bother with querying every 5ms

carmine nacelle
#

and im getting Netty Server IO #1 ERROR Recursive call to appender Async

echo basalt
#

show code

carmine nacelle
#

trying to get nearby entities inside a ProtocolLib listener.

echo basalt
#

Ah

#

just use the bukkit scheduler

torn shuttle
#

god that stupid reddit meme about programmer socks is stuck in my mind every time I think about having to buy new socks

echo basalt
#
if(!Bukkit.isPrimaryThread())
  Bukkit.getScheduler().runTask(main, () -> fetch(idk));

fetch(idk);
torn shuttle
#

oh my god even amazon sellers are unironically doing this meme

torn shuttle
#

1000 years from now people will look back at things like programming socks and I am not sure that they will know that it was meant to be a joke

#

because they will be standard

ripe pawn
#

I am having trouble changing the game state change packet, the issue seems to be on the line packet.getIntegers().write(4, 1); but I can't seem to find any example of what I need to do instead of that, what could I use?

echo basalt
#

Not the constructor

#

And also look at how it serializes and what it corresponds to in wiki.vg

ripe pawn
carmine nacelle
#

Is there a way to add "custom" data to a block that can be stored inside it through restarts...?

#

instead of having to store info about it in lore.

echo basalt
#

Then middle click in intellij

#

Example: PacketPlayOutSpawnEntity

#

As for serializing

#

There's usually a method that writes stuff to a PacketSerializer

#

And that stuff corresponds with wiki.vg

#

Helps you figure out what field is what

ripe pawn
echo basalt
#

Don't import spigot-api

#

Run buildtools and import spigot

ripe pawn
#

ok

quaint mantle
#

Can I use offlineplayer to get a player even if he is online?

young knoll
#

If you want to

quaint mantle
#

Have no problems generating a player using offline player?

#

Example:
Offlineplayer player = args[0]
if(player.isonline) {
//code
else {
// code
}

young knoll
#

I mean that isn’t how you get an offline player, but sure

quaint mantle
#

Any dev who want to make a plugin for me? I have Paypal DM please

young knoll
#

Keep in mind getting an offline player by name may involve a blocking web request

#

Bukkit.getOfflinePlayer

quaint mantle
#

OfflinePlayer target = Bukkit.getOfflinePlayer(args[1]);

#

?

young knoll
#

Mhm

quaint mantle
#

How do I get through uuid?

young knoll
#

You need to have a uuid

#

Then call the same method

ripe pawn
quaint mantle
#

that plugin is for intellij

ripe pawn
#

I have done that

carmine nacelle
#

are entity ids/uuids persistent through restart

worldly ingot
#

Entity ids, no. UUID, yes

quasi stratus
#

I'm very new to this, so I am sorry if this is a bit dumb. I'm trying to add Spigot API thru gradle but it seems to be failing whenever I add 1.17 but not on other versions, any ideas as to why?

#
plugins {
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
    maven { url "https://hub.spigotmc.org/nexus/content/repositories/public/" }
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
    implementation 'org.bukkit:bukkit:1.17.1-R0.1-SNAPSHOT'
    implementation 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
}

test {
    useJUnitPlatform()
}```
worldly ingot
#

You don't need the Bukkit API if you're adding the Spigot API

#

Though it LGTM. No reason for that not to work as far as I'm concerned

quasi stratus
#

This may help, but not sure.

worldly ingot
#

Yeah. Remove the Bukkit dependency

#

Spigot comes with Bukkit and the Bukkit API isn't hosted on the Nexus anymore

quasi stratus
#

Ah, that's what it was.

#

Thanks so much! πŸ™‚

worldly ingot
zealous terrace
#

Hey, Im trying to use postgres with spigot but I get a ClassNotFoundException even Though I package it with gradle, here are my build and Postgres class files, Can anyone point out whats wrong to me? Thanks a ton! (I use Intellij IDEA)
Postgres :
https://srcb.in/IbVOKirPcd

Gradle Build:
https://srcb.in/11JAAledIA

quaint mantle
#

hello, how the ItemStack works in NMS ?

zealous terrace
zealous terrace
#

Please help, Error in that Image ^^

quaint mantle
zealous terrace
#
name: Ranks
version: 1.0
author: Rithul Kamesh
main: com.rithulk.ranks.Ranks
description: The Ranks Plugin for Sniping_'s Mc Server
api-version: 1.8.8S