#help-development

1 messages · Page 1396 of 1

sharp bough
#

why doesnt this create a custom config file on enable?

        this.saveDefaultConfig();
        FileConfiguration config = this.getConfig();
        config.addDefault("enabled", true);

        boolean enabled = CheckIfEnabled();

        if(enabled){
            Bukkit.getLogger().info("test");
        }
mortal hare
#

ok

#

whoever done this

#

i hate you

#
    public static boolean equals(ItemStack itemstack, ItemStack itemstack1) {
        return itemstack.isEmpty() && itemstack1.isEmpty() ? true : (!itemstack.isEmpty() && !itemstack1.isEmpty() ? (itemstack.tag == null && itemstack1.tag != null ? false : itemstack.tag == null || itemstack.tag.equals(itemstack1.tag)) : false);
    }

    public static boolean matches(ItemStack itemstack, ItemStack itemstack1) {
        return itemstack.isEmpty() && itemstack1.isEmpty() ? true : (!itemstack.isEmpty() && !itemstack1.isEmpty() ? itemstack.c(itemstack1) : false);
    }

    private boolean c(ItemStack itemstack) {
        return this.count != itemstack.count ? false : (this.getItem() != itemstack.getItem() ? false : (this.tag == null && itemstack.tag != null ? false : this.tag == null || this.tag.equals(itemstack.tag)));
    }
#

this is nms code of itemstack compare

#

for some reason equals and matches are reversed

silver shuttle
#

how do I easily get the total amount of items matching a Material in the inventory of player?

mortal hare
#

.equals() == #ItemStack.isSimiliar() and .matches() = #ItemStack.equals()

#

wtf

sharp bough
mortal hare
#

yea

#

but it was mapped

#

by bukkit team

#

and for some reason equals and matches are reversed

#

this is NMS

mortal hare
chrome beacon
mortal hare
#

or iterate it yourself

#

and check if type is the same

quaint mantle
#

what should i do with .runTaskLater?

wide current
#
Bukkit.getScheduler().runTaskLater(this,
  () -> { p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getInt("knockback-of-players");
}, <delayInTicks>);
mortal hare
#

.runTaskLater(#PluginInstance, #Runnable(), #delayInTicks);

silver shuttle
mortal hare
#

BukkitScheduler is deprecated in some flavours of spigot. Prefer using

new BukkitRunnable() {
  @Override
  public void run() {

  }
}.runTaskLater(#PluginInstance, #DelayInTicks);
quaint mantle
#

ok ty

gaunt sluice
#

Hello
I have a problem, when I try add %mcrealistic_thirst% to the plugin simplescore it show me this

cunning cloak
#

I'm wondering making someone verify to receive their license key on discord to receive it after they have purchased it from spigot is breaking the premium guidelines?

mortal hare
#

The placeholder value is probably not inside the plugin itself but inside some kind of plugin or hook (for example PlaceholderAPI)

#

see plugin's documentation to hook your plugin with another plugin's placeholders

#

or if plugins placeholders are placeholderAPI implementation type seek for its documentation for getting placeholder values.

mortal hare
#

spigot only allows low type of obfuscation on the market

paper viper
#

and also

#

why

#

why go this far

chrome beacon
#

Yo Pulse :)

paper viper
#

seems oddly stupid

#

hi

silver shuttle
chrome beacon
#

Anyway your plugin is going to get leaked regardless of what you do

dusty herald
#

new ItemStack(Material)

silver shuttle
#

And I need it to be exact, if I just put in the Material it displays the amount of full stacks

cunning cloak
silver shuttle
#
            Material sellitem_material = sellitem_seller.getInventory().getItemInMainHand().getType();
            ItemStack sellitem_itemstack = new ItemStack(sellitem_material);
            int amount = sellitem_seller.getInventory().all(sellitem_itemstack).size();
            sender.sendMessage(String.valueOf(amount));
dusty herald
kind coral
#

one question, how could i hide the plugin doing commands from the console
for example lets assume i use the method that makes the plugin do a command in the console, how could i make it hidden?

dusty herald
mortal hare
#
ItemStack[] contents = #Inventory.getStorageContents();
int counter; 

for (int i = content.length; --i > -1;) {
  if (contents[i].getType() == Material.#SomeSort) {
    counter += contents[i].getAmount();
  }
}
#

@silver shuttle

dusty herald
#

Inventory.getStorageContents()*

silver shuttle
#

mhm

silver shuttle
dusty herald
#

getContents returns Armor slots and offhand

#

do the code that Dovidas just edited

cunning cloak
wraith rapids
#

you don't

wide current
#

Is it possible to update inventory each tick without runnables ?

dusty herald
#

the plugin needs to run without restriction or internet connection

mortal hare
#

forgive me for the weird for loop. I like optimising it since it seems bytecode is more efficient

wraith rapids
#

basically you aren't able to do anything anti-piracy related while complying with spigget's guidelines

#

which is fine

#

anti piracy is cancer

dusty herald
#

I wish premium plugins were open sourced and forced to follow the same license as Bukkit

#

🤷‍♂️

cunning cloak
mortal hare
#

I've saw some plugins go up for prices like 200$

dusty herald
wraith rapids
#

you can do that

#

but it will still be cancer

silver shuttle
#
            Material sellitem_material = sellitem_seller.getInventory().getItemInMainHand().getType();
            ItemStack[] contents = sellitem_seller.getInventory().getContents();
            int counter = 0;

            for (int i = contents.length; --i > -1;) {
                if (contents[i].getType() == sellitem_material) {
                    counter += contents[i].getAmount();
                }
            }
            sender.sendMessage(String.valueOf(counter));

Whats wrong with this now?

wraith rapids
#

and you will be cancer for perpetuating it

gaunt sluice
mortal hare
dusty herald
#

I'm all for premium plugins but I prefer when they're open source pepe_sob

wraith rapids
#

chances are that your code probably isn't realistically valuable enough to fuss over it being stolen

wraith rapids
#

you should put your effort towards making it better, rather than playing cat and mouse with the piracy people

dusty herald
#

and anti piracy can easily be thwarted

chrome beacon
mortal hare
#

wtf

#

i found a bug

wraith rapids
#

yeah, it's a game where everybody loses

mortal hare
#

inside the bot

dusty herald
#

easily, especially when you develop in Java

silver shuttle
mortal hare
#

name of plugin would result you in getting a warning for tagging lots of people 😄

#

wtf

mortal hare
#

reverse name of plugin and remove of

wraith rapids
#

plugin name?

dusty herald
#

name plugin

#

what

mortal hare
#

without question mark

wraith rapids
#

plugin name

dusty herald
mortal hare
#

ok wtf

#

why do i get warned for that

wraith rapids
#

i saw your message getting deleted a few times

mortal hare
dusty herald
#

@queen dragon is shit that's why

wraith rapids
#

dunno what that's about

mortal hare
#

:DDDDDD

#

wtf

wraith rapids
#

oh

#

it's because you repeated the same message

#

iirc

dusty herald
#

yeah

mortal hare
#

it was my first message

wraith rapids
#

well

mortal hare
#

then i tried it again

wraith rapids
#

the bot disagrees

mortal hare
#

how strange

dusty herald
#

do you have any plugins NNYa

wraith rapids
#

only one public one

dusty herald
#

can I see

wraith rapids
#

look up villager lobotomizatornator

echo mountain
#

can anyone help me with a Bukkit maven issue?

mortal hare
silver shuttle
mortal hare
#

Command's code

#

48 line

#

@silver shuttle

#

value is null

chrome beacon
#

You should look in to how you read stacktraces

silver shuttle
silver shuttle
#

if (contents[i].getType() == sellitem_material) {
thats 48th line

wraith rapids
#

contents[i] is probably null

chrome beacon
#

^^

mortal hare
#
            Material sellitem_material = sellitem_seller.getInventory().getItemInMainHand().getType();
            ItemStack[] contents = sellitem_seller.getInventory().getContents();
            int counter = 0;

            for (int i = contents.length; --i > -1;) {
                if (contents[i] != null && contents[i].getType() == sellitem_material) {
                    counter += contents[i].getAmount();
                }
            }
            sender.sendMessage(String.valueOf(counter));
#

try this

#

maybe items are not air itemstack but null

wraith rapids
#

never know with bukkit

#

best practice to always check both cases

silver shuttle
mortal hare
#

well in NMS its NonNullList so there's no nulls, in bukkit its different

echo mountain
wraith rapids
#

can you link the image itself

#

rather than the page the image is on

deep wave
#

bukkit repo died literally years ago

wraith rapids
#

oh hey cat, you're here

mortal hare
deep wave
#

for some reason I lurked across

dusty herald
#

hello stranger

wraith rapids
#

don't worry, i'll be on the paper discord in a bit once all of my alts are done brewing

#

then I can pester you with yellow images again

silver shuttle
mortal hare
#

ItemStack[64] + ItemStack[4] = Total items 68
and not
ItemStack[64] + ItemStack[4] = Total items 2

deep wave
#

and the batting crews will be awaiting

mortal hare
#

@silver shuttle

wide current
#

Is it possible to do sth like this in java ?

final Wheel wheel1 = car1.wheel, wheel2 = car2.wheel;
wheel1 == wheel2 //true
wheel1 == wheel2  //false because they have not the same instance
wraith rapids
#

it took your mods like a month to notice me last time

wraith rapids
#

and i wasn't even hiding

silver shuttle
#

i just testes it it works great

dusty herald
#

are you banned in paper or something lmao

wraith rapids
#

several times over

dusty herald
#

what did you do

wraith rapids
#

provided help for 1.8 people

dusty herald
#

oh no

mortal hare
#

so comparing it wheel == wheel2 will return false

#

because they're different objects

dusty herald
#

how could you

wraith rapids
#

i know right

sharp bough
#

how can i add a comment to a config file?

mortal hare
#

and have different hashcodes

sharp bough
#

config.addDefault("#", "this is a doc"); ?

deep wave
#

== compares identity

wraith rapids
#

hashcode isn't relevant

deep wave
#

.equals allows you to implement whatever equality checks you want

chrome beacon
dusty herald
mortal hare
#

.equals() provided by class implementation of equality
== means if both object hashcodes match (same instance)

deep wave
#

if you have to ask questions like that, you should probably go read up on OOP a bit..

wide current
#
new ItemStack(Material.AIR) == new ItemStack(Material.AIR)

I would like this is false bc not the same instance

wraith rapids
#

that is an implementation note

sharp bough
#

thanks

deep wave
#

and that will be false

wraith rapids
#

and not relevant to what == or equals does

deep wave
#

hashcode has nothing to do with ==

#

I mean, if == is the case the hashcode will be the same unless you done fucked up

#

but, hashcodes equaling does not imply ==

wraith rapids
#

would be kinda weird if == was true but the hashcodes were different

wide current
#

Would like to test instance of subobjects of object inside Set<>

wraith rapids
#

if that's what you really want, create an identity hash set and call contains on it

final fog
#

Is there a way where I can make it so I can set player#hasPlayedBefore() to false?

wraith rapids
#

not via api, I don't think

chrome beacon
naive haven
#

noob here. i'm watching a tutorial where he put "Player player = (Player) sender; " and "Player" highlights pink, "player" highlights yello and "sendder" highlights blue. but for me in eclipse it doesnt highlight at all- what do i do to get it to highlight?

final fog
#

I reset my servers worlds

#

does that count?

wraith rapids
#

nnnnot necessarily

final fog
#

or do I have to delete that file exactly

#

thats why it didnt work ig

#

ty all

wraith rapids
#

playerdata is in the primary world directory under the playerdata directory

#

either delete the entire directory or just the file of the player you want to erase

final fog
#

I mean, that folder is empty

gaunt sluice
wraith rapids
#

then it might be pulling from the usercache or something

final fog
#

Should I still delete it?

wraith rapids
#

well

#

delete the whole serbur I suppose

#

not like there's much left after deleting the world and all player data anyway

chrome beacon
gaunt sluice
mortal hare
# gaunt sluice Iam maybe just stupid, I know how to do it, but I cant find right ecloud

Everyone is learning, no worries. Download PlaceholderAPI and put it as a dependency inside your project
when you do in order to get the placeholder value specify the string to the placeholder api instance:

String text = "Player's thirst: %mcrealistic_thirst%";
String thirst = PlaceholderAPI.setPlaceholders(#player, text);

#Player.sendMessage(thirst);
wraith rapids
#

what happens if you're super thirsty

wraith rapids
#

do you die

mortal hare
#

oh

gaunt sluice
mortal hare
#

19 emerald block = 1 stone

#

nice

dusty herald
#

lmak

#

that's great

mortal hare
#

hmm

#

bukkit's .isSimiliar() works just fine

#

but NMS one seems to be funky

#

but i need as raw method as possible

dusty herald
#

equals has like no documentation

mortal hare
#

since im dealing with nms

#

ofc it wouldnt

dusty herald
wraith rapids
#

itemstack's issimilar usually redirects to nms equals though

mortal hare
#

so wtf

wraith rapids
#

since craftstacks are just wrappers over nms data

#

and most itemstacks are craftstacks

mortal hare
#

not an bukkit one

wraith rapids
#

yeah, i'm talking about you saying bukkit's issimilar working fine

dusty herald
#

my bad

mortal hare
#

its not

#

redirecting to nms .equals()

wraith rapids
#

see craftitemstack

dusty herald
#

I usually just look at the spigot api, I don't do much nms Sadge

wraith rapids
#

most itemstacks are actually craftitemstacks aka craftstacks

#

it doesn't directly redirect to nms stack's equals, no, but the impl is almost the same

regal dew
#

NMS has a static .equals() method afaik

wraith rapids
#

that is, it compares the nbt tag compound

mortal hare
#

once again

#

its not redirecting

#

that's a craftitemstack

wraith rapids
#

literally read what i just said

mortal hare
#

oh

mortal hare
#

but it returns that stone is equal to emerald_block lol

wraith rapids
#

that's haram

#

yeah i don't know how that'd happen

#

i mean, the impl of it is this

    public static boolean equals(ItemStack itemstack, ItemStack itemstack1) {
        return itemstack.isEmpty() && itemstack1.isEmpty() ? true : (!itemstack.isEmpty() && !itemstack1.isEmpty() ? (itemstack.tag == null && itemstack1.tag != null ? false : itemstack.tag == null || itemstack.tag.equals(itemstack1.tag)) : false);
    }
#

i might be blind, but I'm not seeing a material comparisn there

#

only the tag which holds the meta

#

or, well, nms doesn't use materials, but you know what i mean

mortal hare
#

yea

wraith rapids
#

Item comparison

mortal hare
#

but why this does exist then

wraith rapids
#

hell if i know

regal dew
#

could be just one of spigots amazing mapping names

mortal hare
#

yea

wraith rapids
#

probably

regal dew
#

🤷‍♂️

wraith rapids
#

use ItemStack.matches instead

#

it looks to be doing the comparison properly

mortal hare
#

the thing is

#

matches is bukkit's equals()

#

its strict on item amount

#

as you can see

wraith rapids
#

literally copy the impl but drop the amount check i guess 👀

mortal hare
#

but that's really bizarre

#

it looks like if mapping just fucked up

wraith rapids
#

yeah well

#

maybe we just can't comprehend md69's infinite wisdom

#

as with things like VillagePlace and entityJoinedWorld

mortal hare
#

yea

#

copying it and dropping the amount check worked perfectly

wraith rapids
#

peak software development moment

wraith rapids
#

reminds me of when I had to cobble together a reflective hack to stop slimefun from killing my server with its shit tier ticker task implementation

#

writing an entire class with nothing but reflection was great

cinder thistle
#

anyone got experience with intellij plugins? keep getting this:
Caused by: java.lang.ClassNotFoundException: com.github.jwpjrdev.betterimportplugin.actions.ImportAction PluginClassLoader[PluginDescriptor(name=better-import-plugin, id=com.github.jwpjrdev.betterimportplugin, path=/Users/joshua/Desktop/better-import-plugin/build/idea-sandbox/plugins/better-import-plugin, version=0.0.1)] com.intellij.ide.plugins.cl.PluginClassLoader@4fd64a7c

#

the action is registered in plugin.xml and all that

#
    <actions>
        <action id="com.github.jwpjrdev.betterimportplugin.actions.ImportAction"
                class="com.github.jwpjrdev.betterimportplugin.actions.ImportAction" text="ImportAction"
                description="Triggered when the import hotkey is ran">
            <keyboard-shortcut keymap="$default" first-keystroke="shift meta O"/>
        </action>
    </actions>
#

the only thing I can think of is that by default it was a kotlin project

#

and this file is Java

#

because I cba to deal with kotlin code

tranquil viper
#

how does one remove attributes from

wraith rapids
#

kotlin 👀

#

get the, uh, attribute modifiers from the item meta

#

and then remove them somehow

#

i don't quite remember how, but i do remember that attributes and modifiers are cancer to work with

cinder thistle
#

indeed

wraith rapids
#

also that looks like a line of lore rather than an actual attribute

tranquil viper
#

true

main dew
cinder thistle
#

what are we looking at

main dew
#

What I do bad?

cinder thistle
#

at ray.Utils.setBlockFast(Utils.java:108)

#

also note the ArrayIndexOutOfBoundsException

main dew
#

yea but I try invoke private metod with Class NMS Chunk

#

a maybe moment xD

cinder thistle
#

what does that method even do

main dew
#

I try update light with ChunkSection

cinder thistle
#

ah

gaunt eagle
#

Should I care about that?

wraith rapids
#

maybe

grim umbra
#

Hey. I am having a problem if anyone can help me. I run a bungeecord server and I have been having this problem where after someone teleports, they become invisible to other players and their body gets left back at their pre teleport spot, but it doesnt move and it cant be moved. Killing that player does seem to fix the issue, but that isnt an option for me since most of the time players teleport to go into a minigame or something. I have read that this is a problem with vanilla minecraft, but I have not found any solutions for it.
Any help would be appreciated.

wraith rapids
#

it could be null

#

and if it's null, that method will throw an exception

gaunt eagle
#

Why was it just this when others wouldn't be the problem xd?

wraith rapids
#

getString is annotated as @Nullable

#

getWorld's parameter is annotated as @NotNull

#

getDouble returns a double, which is a primitive and cannot be null

wraith rapids
#

that is why only the String one is raising the warning

tranquil viper
#

oh i figured it out

gaunt eagle
#

understood, I guess it won't be a problem. Thanks ^^

wraith rapids
#

if you want to be robust, grab the string into an intermediate variable and null check

tranquil viper
#

ItemFlag.HIDE_POTION_EFFECTS exists

wraith rapids
#

and give the end user an informative error message

#

if the end user configures a null value for that key, this will explode with an exception

#

but that's 'fine'

#

as you probably shouldn't configure a null value for that key

gaunt eagle
#

@wraith rapids IDE saved the warning by editing it in this way. Does it create a problem?

#

Objects.requireNonNull

quaint mantle
#

is it possible to get a new line in a yml file? plugin.yml to be precise i have a no permission message and I want to get a new line:
permission-message: §4(!) §aThis plugin was made by §cBo0ked61! §b(Version §d1.4§b) §4(!)

wraith rapids
#

that will still explode with an exception, yes

#

it just indicates your intent that you want it to be not null more clearly

cinder thistle
#

just have a null check

#

although I wouldn't consider that a big issue

cinder thistle
#

considering that the only way afaik that it could be null is if it's missing from the config period

wraith rapids
#

the difference between now and then is that now you are willingly taking something that might be null and blowing up if it is, and then you weren't; you might not have realized that it was nullable, which would have been a programming mistake

#

which is why it was giving a warning then and not now; now your blowing up is intentional

#

that said yeah it isn't an issue and just wrapping it with that is fine

#

but if you want to be robust you could nullcheck it and print a message

#

you probably would also want to nullcheck the return value of Bukkit.getWorld, so the end user can see if they misconfigured their world

#

Locations with a null world tend to explode arbitrarily when passed around, which can be difficult to track down

dusty frost
#

Join event```java
package me.alpha.alpha.events;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.Bukkit;

public class Join extends JavaPlugin implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
System.out.println("Player Joined");
}
}```

Main class

@Override
    public void onEnable() {
        System.out.println("Ready!");
        getCommand("kick").setExecutor(new Kick());
        getCommand("ban").setExecutor(new Ban());

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

        final FileConfiguration config = this.getConfig();
        config.options().copyDefaults();
        saveDefaultConfig();

    }```
#

basically, when I join, it doesn't log to the console. Why

cinder thistle
#

is your plugin enabled

dusty frost
#

yes

tribal sparrow
#

Are kick and ban in your plugin.yml? If not it would throw an npe and not register your events as it’s after that part of the code

dusty frost
#

yes kick and ban are in plugin.yml, those commands work fine

tribal sparrow
#

Is join your main class?

dusty frost
#

No, like I said, join is the event, my main class is, as you can see in the package of the Join event class, 'Alpha'

tribal sparrow
#

Can you send the entire main class

dusty frost
#

alright

#
package me.alpha.alpha;

import me.alpha.alpha.commands.Ban;
import me.alpha.alpha.commands.Kick;
import me.alpha.alpha.events.Join;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class Alpha extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        System.out.println("Alpha is ready!");
        getCommand("kick").setExecutor(new Kick());
        getCommand("ban").setExecutor(new Ban());

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

        final FileConfiguration config = this.getConfig();
        config.options().copyDefaults();
        saveDefaultConfig();

    }

    @Override
    public void onDisable() {
        System.out.println("Alpha has been unloaded");
    }
}
tribal sparrow
#

Ok for the join class remove extends Java plugin,
And in your on enable change it ...registerEvents(this, this); to registerEvents(this, Join());

dusty frost
#

aight

autumn ingot
#

can you take the functionality of a plugin (listeners, commands, etc.) and put it in the server jar itself

tribal sparrow
#

Only your main class needs to extend JavaPlugin

dusty frost
#

wait, you're sure it's this, Join(), instead of Join(), this? since the first argument is listener

tribal sparrow
#

Yeah do the second one

#

I’m on my phone and also forgot the order it was

dusty frost
#

Alright, thanks so much, it was the first one btw, but it's working now

tribal sparrow
#

That’s alright, glad it’s working now

vital ridge
#

Hey

#

I have a full list of cords in a yml file, but they are as a string

#

I need to loop through them and use them

#

but i cant use them

#

as location

#

Anyone has any idea how to make string a location?

#
CordinatesYML.getCordsFile().getList("Cords")
#

printing out this

#

will give me sht tons of cords in the console

tribal sparrow
#

Save x y z yaw pitch and world name to config, eg location.name.world and location.name.x etc... when loading location get all variables from config and create a location object Location loc = new Location(world, x, y, z);

wraith rapids
#

Location is ConfigurationSerializable

#

no need to jump through hoops saving the dimensions and world separately

#

just config.set(path, location)
and config.getSerializable(path, Location.class)

sinful python
#

I have this code:

            Inventory clickedInventory = inventoryClickEvent.getClickedInventory();
            clickedInventory.setItem(3, heldItem);
       }

Only problem is that instead of actually putting it in the inventory, it just doubles the cursor item (?)

#

I'm assuming that it's just that as soon as the code puts it in that slot, it gets picked up as you click the slot

#

Would adding some kind of delay help with that?

woven flume
#

package me.royalben10.keysFromMcmmoFishing;

import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin{

}

#

Opens the new class wizard to create the type.

Package: org.bukkit.plugin.java
public class JavaPlugin {
}

#

JavaPlugin cannot be resolved to a type

#

Someone asked me to post this as text

near kayak
woven flume
#

Worked

#

Can you explain why that is?

near kayak
#

Well I can't explain that easily since I main python so yea here is the wiki

woven flume
#

Could you be a bit more specific. That page does not mention anything related to module-info.

near kayak
#

hmm

woven flume
#

For example, how did you know do to that?

#

module info was created by default.

near kayak
#

also

woven flume
#

I also don't see how it would interfere with the class' ability to locate the relevant file

worldly ingot
#

Bukkit isn't modular

#

We compile against 8, not 9

woven flume
#

Then why did this tutorial tell me to create a module lmao

near kayak
#

having module-info.java file is in the default package doesn't require requires <module>; statement that is why jpms is usefull

worldly ingot
#

what tutorial are you using that told you to create a module info?

woven flume
#

Rhetorical question

worldly ingot
#

or are you confusing it with a Maven module?

near kayak
woven flume
#

"How to make a Minecraft Plugin | Working in 2021"

#

Have it pulled up on my Ipad but ill see if I can find the link

near kayak
woven flume
#

lol yeah

worldly ingot
#

I hate when content creators do that

near kayak
woven flume
#

Yeah I saw something in the comments about that but I figured they had checked the video to make sure it still worked

worldly ingot
#

I see no reference to a module-info though

near kayak
worldly ingot
#

unless he mentioned it verbally for some reason, there was nowhere in the video where he created one

near kayak
#

well anyway I am just glad it worked

worldly ingot
#

yepyep

#

Avoid modular programming for plugins for the time being

woven flume
#

I didn't create it either

worldly ingot
#

oh your project probably auto created it if you're using Java 9+

woven flume
#

It was created by defualt, prob because of my jdk version

worldly ingot
#

Yep

woven flume
#

Well I already created this package. Do I have to start over?

worldly ingot
#

Eclipse has a checkbox when creating a project to create a module-info.java. You can uncheck that

#

Nope, you're fine

#

It's just the module-info.java that denotes it as modular

woven flume
#

Kk

#

Appreciate the support @worldly ingot. Sorry if I was curt @near kayak

near kayak
# woven flume Kk

nothing check this guy I love his codes https://www.youtube.com/c/TheSourceCodeTutorials/videos

woven flume
#

For what it's worth I know Java, i just haven't developed a plugin before. I am trying to write a hopefully simple plugin to replace an item with another when it is picked up by a player entity. Does the source code channel have a good video on creating your first plugin?

near kayak
# woven flume For what it's worth I know Java, i just haven't developed a plugin before. I am ...

I don't really use java as I mentioned before since I only want python for blender there are many ways to learn there are even tutorials on the spigot page however a video is by far the easiest way to learn and just a quick reminder to check the dates on a video anyway here is a good one I found https://www.youtube.com/watch?v=GK4aQzxQSoQ

Intellij (Make sure you download the community edition!)
https://www.jetbrains.com/idea/

Java 8 JDK (You have to make a free Oracle account to download the JDK)
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

Feel free to ask in the comments or drop a message in my discord server and I will be glad to help!

Please L...

▶ Play video
woven flume
#

Thanks again 🙂

sinful python
#

I didn't watch the whole series though, trying to learn on my own

tulip lodge
#

how to a coding Collision with glass?

young knoll
#

What?

daring sierra
#

im quoting that

tulip lodge
#

Colision with block message

young knoll
#

Eh

#

You want to send a message when the player collides with a block?

tulip lodge
#

yes

#

you can help me?

young knoll
#

You can check surrounding blocks with a move event I suppose

#

Or use the players velocity to check for blocks in a path

tulip lodge
#

PlayerMoveEvent

#

?

young knoll
#

Mhm

tulip lodge
young knoll
#

Yes that forum has some suggestions as well

quaint mantle
#

hi im trying to use the or || operator but it says it can't be applied to two strings likt this
e.getMessage().equalsIgnoreCase("shop" || "store")

young knoll
#

Yeah you can’t do that

#

You need to call equalsIgnoreCase twice

quaint mantle
#

on two separate lines?

young knoll
#

You can connect them with || on the same line

#

You just need to call the method fully each time

#

Because || works on booleans, not strings

#

You could also uses arrays.asList(your, options, here).contains(string)

#

Probably a bit slower though

quaint mantle
#

ah

#

thx

junior breach
#

This is probably very niche, but SlimeWorldManager's discord is extremely inactive. Can someone please help me find the source of this stack trace? [02:57:46 INFO]: Levah issued server command: /swm create Test file [02:57:46 INFO]: [SWM] Creating empty world Test. [02:57:46 WARN]: [SlimeWorldManager] Plugin SlimeWorldManager v2.5.3-SNAPSHOT generated an exception while executing task 23 java.lang.UnsatisfiedLinkError: 'long com.github.luben.zstd.Zstd.compressBound(long)' at com.github.luben.zstd.Zstd.compressBound(Native Method) ~[?:?] at com.github.luben.zstd.Zstd.compress(Zstd.java:612) ~[?:?] at com.github.luben.zstd.Zstd.compress(Zstd.java:601) ~[?:?] at com.grinderwolf.swm.nms.CraftSlimeWorld.serialize(CraftSlimeWorld.java:171) ~[?:?] at com.grinderwolf.swm.plugin.SWMPlugin.createEmptyWorld(SWMPlugin.java:291) ~[?:?] at com.grinderwolf.swm.plugin.commands.sub.CreateWorldCmd.lambda$onCommand$1(CreateWorldCmd.java:84) ~[?:?] at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:100) ~[patched_1.16.5.jar:git-Purpur-1015] at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:58) ~[patched_1.16.5.jar:git-Purpur-1015] at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.16.5.jar:git-Purpur-1015] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?] at java.lang.Thread.run(Thread.java:834) [?:?]

sullen marlin
#

Not running spigot

junior breach
young knoll
#

I feel md has some kind of bat signal for that

#

Or he just happens to look at his discord a lot, imagine that

cinder thistle
#

xD

olive lance
#

how does mineplex, cubecraft etc get on featured servers for bedorck

cinder thistle
#

"paper" "purpur" "tuinity" "non-spigot" "airplane"

#

just gets notifications for that shit

young knoll
#

They have bedrock servers

olive lance
#

and why can't console players enter any IP address

cinder thistle
olive lance
#

on console youre locked to only featured servers or realms

young knoll
#

And were part of some kind of initial launch with partnered servers

#

Yes

olive lance
#

cant put an ip

young knoll
#

Bedrock bad

olive lance
#

yes

cinder thistle
#

bedrock is trash

olive lance
#

plain ridiculous i thought it was gonna be lit. cross platform servers

#

nope

#

cross platform mineplex woohoo

young knoll
#

You know, I commend bedrock for bringing so many people together

#

And it has some decent tools with behaviour packs

#

But still, Java > Bedrock

tulip lodge
#

What suggestions do you have?

young knoll
#

For what

young knoll
#

Use one of the ones from the thread

#

Or do some vector stuff using player.getLocation.getDirection

tulip lodge
#

ok

quaint mantle
#

yo

#

I have this question

#

error*

#

lemme get my code

sleek dragon
#

in a tellraw command I could use {"translate":"space.80"} to place whatever is linked to that in my resourcepack in chat or my actionbar. how do I do this via spigot? I already have player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(mana_bar)); but im wondering how I also send a translate json component with the text

#

so next to my TextComponent.fromLegacyText(mana_bar) i also want to send a translate component

#

cant seem to find it in the spigot docs

young knoll
#

TranslatableCompnent I imagine

sleek dragon
#

ah

sour phoenix
sleek dragon
#

in actionbar

#

before the mana_bar string

sour phoenix
#

with this you can append a component to another

#

like this

player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new ComponentBuilder(translatable_component).append(TextComponent.fromLegacyText(mana_bar)).create());
sleek dragon
#

thanks! helped a lot.

sour phoenix
#

glad i could help 🙂

sleek dragon
#

something weird i just ran into

#

this is how the icons look in my actionbar using my plugin

#

this is how it looks in my datapack

#

same resourcepack so they have the same ascent and height values

#

in my datapack I use unicode for both the icons and negative space which closes the gaps between the icons

#

doesnt seem to want to work in my plugin tho

#
        TranslatableComponent space = new TranslatableComponent("space.100");
        String negative_space = "\uF802";

        String empty_mana = "\uE003";
        String half_full_mana = "\uE002";
        String full_mana = "\uE001";

        String mana_bar = "";

        int i;
        for (i=1 ; i<=10; i++)
            mana_bar += full_mana;
            mana_bar += negative_space;

        player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new ComponentBuilder(space).append(TextComponent.fromLegacyText(mana_bar)).create());

        return true;
#

this is my code

#

should work as far as I know

fervent chasm
#

Hey, how can I add lwjgl64 to java.library.path

cinder thistle
#

use camelCase for variable names

#

not lower_snake_case

sleek dragon
#

my bad so used to it lol

young knoll
#

What languages use that

#

I feel like I know it

quaint mantle
novel hornet
#

what's the event for summing primed tnt

lost matrix
final fog
#

I do camel case when naming my variables, I'm just wondering why it matters.

cinder thistle
#

because it's what everybody else does

#

it's the standard

#

if everyone's code is how they want it to be rather than the standard there is no standard

#

and readability plummets ⤵️

final fog
#

ah, I see.

errant drift
cinder thistle
#

fuck u too

young knoll
#

Too be fair some java conventions are less followed than others

#

Line width is one

cinder thistle
#

I try to follow it

#

But I don’t newline willy nilly for that stuff

#

I prefer to just not write code that looks bad if it has a new line or not

#

Functional programming is an exception

tame wolf
#

whats the best way to make a request system from a player to player

#

so like someone does a command

#

that has some player in its args

#

and then that player has to do a command

#

to accept or deny the request

cinder thistle
#

Piece by piece

#

You just have a map of requests and when a player runs the accept/deny command it checks if that request is in the map

#

And you can use json hover n click if you’re fancy

tame wolf
#

ok

#

i dont understand

cinder thistle
#

The request create command adds a request to a map

#

The accept/deny command checks the map and does whatever you want after accepting or denying

#

And if it IS in the map it gets removed

tame wolf
#

[22:19:29 ERROR]: Could not load 'plugins\BedMe-1.0-SNAPSHOT.jar' in folder 'plugins': uses the space-character (0x20) in its name

#

i got this error

#

why

#

nvm

cold vector
#

created a function to create a compass that points to a player
the name doesn't change to "Tracking: Player", it stays as compass, any reason why?

    public void giveTrackedCompass(Player compassReceiverPlayer, Player trackedPlayer)
    {
        ItemStack compass = new ItemStack(Material.COMPASS);
        compass.setAmount(1);
        compass.getItemMeta().setDisplayName("Tracking: " + trackedPlayer.getDisplayName());
        compassReceiverPlayer.getInventory().addItem(compass);
        compassReceiverPlayer.setCompassTarget(
                new Location(compassReceiverPlayer.getWorld(),
                trackedPlayer.getLocation().getX(),
                trackedPlayer.getLocation().getY(),
                trackedPlayer.getLocation().getZ()
                ));
    }
lost matrix
cold vector
#

oh okay ill do that, thank you

lost matrix
cold vector
#

yeah i was going to add a right click event to update the position of it

cold vector
summer scroll
#

How can I make entity look at specific player?

lost matrix
summer scroll
#

Continuosly, well I already have a runnable to teleport. I just need the method.

#

or the location ig.

lost matrix
#

teleporting in a runnable... hm.
But ok. So you want to calculate a vector that points from the head of the mob to the head of the player
and set this vector as direction of your teleport location.

A vector from vecotr A to vector B is calculated using
vector dir = B.subtract(A)

summer scroll
#

Alright, I'll try it, thanks.

drowsy helm
#

anyone know of any good tablist libraries that let me maniulate and add fake players to tab

cold field
#

How Do I get rid of a nullpointerException with @SupressWarning(..)?

eternal oxide
#

you don;t

#

you find where the npe is and fix it

dusky sierra
#

I need to do something async, then run another task synchronously. I've noticed that in the JavaDoc it says Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks. Is creating a new task thread safe?

                Bukkit.getScheduler().runTaskAsynchronously(Builder.getPlugin(Builder.class), new Runnable() {
                    @Override
                    public void run() {
                        Optional<SlimeWorld> worldOptional = WorldLoader.loadWorld(world); // This is recommended async
                        
                        worldOptional.ifPresent(slimeWorld -> Bukkit.getScheduler().runTask(Builder.getPlugin(Builder.class), new Runnable() {
                            @Override
                            public void run() {
                                slimePlugin.generateWorld(slimeWorld); // Has to be sync
                            }
                        }));
                    }
                });
cold field
dusky sierra
#

thanks

eternal oxide
cold field
#

But it can't be

#

wait

eternal oxide
#

you can always test

#

An npe happens when you get teh return of some method and try to use it without testing if its null

cold field
#

I know that but wait I 'll show you me code

#

I'm registering the command right above

#

with reflection

stone sinew
cold field
#

...

stone sinew
cold field
#

nvm, I see that I'm not explained myself good enough

drowsy helm
eternal oxide
cold field
#

CraftServer use that map

eternal oxide
#

plugin command constructor?

cold field
#

The register method require a obj of that class

eternal oxide
#

This is how you dynamically register commands ```java
List<Command> commands = new ArrayList<>(4);
commands.add(new AcceptCommand());
commands.add(new DenyCommand());
commands.add(new ConfirmCommand());
commands.add(new CancelCommand());
try {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");

        bukkitCommandMap.setAccessible(true);
        CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());

        commandMap.registerAll("commands", commands);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }```
cold field
#

this is the method that is called from Server.getCommand("mycommand")

#

JavaPlugin class

eternal oxide
#

That above code is how to dynamically register commands. It works and is currently used in Towny

cold field
#

This is the same code of mine

#

lol

eternal oxide
#

No, all you are showing is getting commands

#

Your registering is broken because you are doing it wrong

#

Which is why you are throwing npe

cold field
#

Mh, it works

#

...

#

We are telling the same thing

eternal oxide
#

it works, except for you coming asking how to silence an npe with suppress warnings

cold field
#

The npe is thrown every time even if you register the command in the plugin.yml

eternal oxide
#

You should not have ANY npe. You are doing it wrong

cold field
#

Maybe you are right

eternal oxide
#

As I said, your registering reflection code is wrong. The above code I just posted is correct

cold field
#

But I dont know where I'm doing it wrong

#

Can you tell me?

eternal oxide
#

I just told you. Use the code or don't. I'm not bothered

cold field
#

But why it works if I'm doing it wrong...

#

I checked the source code and I'm editing the same command map that your code is using

eternal oxide
#

You are throwing an NPE, its NOT working!

#

show your full npe error

cold field
#

It's a warning into the IDE

minor vapor
#

Is there a stacktrace being thrown, yes or no?

cold field
#

no

#

If i do the command it works

minor vapor
#

Alright, then the IDE is telling you something CAN be null and you need to check for it, simple

#

just add a null check, that's all that it's asking for

cold field
#

what I was asking is how can it be null if I'm adding the command inside the commandMap that getCommand use

#

to retreive the command

minor vapor
#

because you're using reflection and the field and such can be null

dusty herald
#

getCommand is always nullable

#

that's why I always only execute code if it isn't null DogKek

#

not checking for nullables is silly

#

it's annotated Nullable for a reason

cold vector
#

Trying to detect a right click on a compass, then update the target, it's not detecting the right click.
Anyone know why?

    @EventHandler
    public void updateTrackedCompass(PlayerInteractEvent e) {

        Action action = e.getAction();
        Player player = e.getPlayer();
        if ((action == Action.PHYSICAL) || (e.getItem() == null) || (e.getItem().getType() != Material.COMPASS)) { return; }

        String trackedPlayerName = playerTrackingDict.get(e.getPlayer().getDisplayName());
        Player trackedPlayer = Bukkit.getPlayer(trackedPlayerName);
        if (trackedPlayer != null)
        {
            player.setCompassTarget(
                    new Location(player.getWorld(),
                            trackedPlayer.getLocation().getX(),
                            trackedPlayer.getLocation().getY(),
                            trackedPlayer.getLocation().getZ()
                    ));
        }
    }
eternal oxide
#

This event will fire as cancelled if the vanilla behavior is to do nothing (e.g interacting with air). For the purpose of avoiding doubt, this means that the event will only be in the cancelled state if it is fired as a result of some prediction made by the server where no subsequent code will run, rather than when the subsequent interaction activity (e.g. placing a block in an illegal position (BlockCanBuildEvent) will fail.

stone sinew
cold vector
#

Oh, I forgot I was supposed to register it.

dusty herald
#

happens to the best of us

cold vector
#

Lol late night coding in a nutshell

opaque grove
#

How do i create an click event for inet.kyori.adventure.text.Component

eternal oxide
#

ask paper

#

or use Spigot components

tribal holly
#

Hey... i have a completely random problem out of no where... this morning i start intellij and open my project and then it don't found some of my import in the same package. I prefer to say that last day everything works well and i still can compil the project and it work... can't understand what's going on

#

the import are here but never used

tribal holly
#

okay it work thx

solemn shoal
#

is there a way to get server uptime?

#

?jd

quiet ice
#

You can start a timer in your onEnable

solemn shoal
#

no i mean like

#

i want to use it in my onEnable

#

to detect if my plugin is being reloaded

eternal oxide
#

why do you need to detect a reload?

quiet ice
#

If you just wish to detect reloads you could check if there are online players, it is usually a dead giveaway of a reload

solemn shoal
#

not in the case of small servers

solemn shoal
#

(intentionally)

eternal oxide
#

um, why?

solemn shoal
#

its an antivirus

wide dune
#

Does anyone know why File.delete() won't work?

solemn shoal
#

it warns server owners on startup

wide dune
#

[06:33:38] [Server thread/INFO]: Attempting to delete mlg_1v1_1 (/home/container/./mlg_1v1_1) [06:33:38] [Server thread/INFO]: Attempting to delete mlg_1v1_2 (/home/container/./mlg_1v1_2) [06:33:38] [Server thread/INFO]: Attempting to delete mlg_1v1_3 (/home/container/./mlg_1v1_3) [06:33:38] [Server thread/INFO]: Attempting to delete mlg_1v1_4 (/home/container/./mlg_1v1_4) [06:33:38] [Server thread/INFO]: Attempting to delete mlg_1v1_5 (/home/container/./mlg_1v1_5)

File worldDir = new File(Bukkit.getServer().getWorldContainer().getAbsolutePath() + File.separator + s);

            //If not found
            if (worldDir.exists()) {
                System.out.println("Attempting to delete " + worldDir.getName() + " (" + worldDir.getAbsolutePath() + ")");
                worldDir.deleteOnExit();
            }```

the worlds dont get deleted though?
eternal oxide
quiet ice
#

they could be locked

#

I don't think NMS stores an uptime though

#

There are plenty of ways to detect an reload though

solemn shoal
#

its so you'd feel a noticeable slowdown in your startup

#

no point in doing it on reload tho

eternal oxide
#

Sorry you are not makign much sense. A delay/slowdown in startup seems pointless

quiet ice
#

Listening for Commands for example are an easy way (you'd need to store it in a persistent file to remind your future self)

#

You might also look if worlds are loaded

lost matrix
#
  @Override
  public void onEnable() {
    getLogger().info("Loading plugin...");
    getLogger().info("Doing some complex computations...");
    Bukkit.getPluginManager().registerEvents(this, this);
    Bukkit.getScheduler().runTaskTimer(this, this, 1, 1);
    try {
      Thread.sleep(5000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    getLogger().info("Done loading");
  }
dusty herald
eternal oxide
#

Place a chunk ticket on the Overworld spawn at teh end of your startup.

#

check for said ticket at teh start of yoru onload

#

it shoudl still be there if its a reload

solemn shoal
#

how can i do that?

eternal oxide
#

although, thats just a guess

quiet ice
#

Isn't that a paper-specific thing?

eternal oxide
#

no

solemn shoal
#

no its there

quiet ice
#

ah ok

eternal oxide
#

You'll have to test its not cleared on a reload, but I'd guess its not

solemn shoal
#

ill see in a hot sec

dusty herald
#

I wish there was a method to check if a reload was issued other than overriding the command or checking if anyone is online

lost matrix
solemn shoal
#

yeah seems it gets cleared

lost matrix
#

A simple boolean should suffice.

solemn shoal
#

onload:

#
Scan(!getServer().getWorlds().get(0).removePluginChunkTicket(0,0,this));```
#

onEnable: getServer().getWorlds().get(0).addPluginChunkTicket(0,0,this);

eternal oxide
#

why are you removing?

solemn shoal
#

it returns a boolean

#

im assuming the boolean tells wether it was successfully removed or not

eternal oxide
#

your plugin instance will be different so you shoudl just check the presence of any ticket

solemn shoal
#

oh

#

doesnt work either @eternal oxide

#

Scan(!(getServer().getWorlds().get(0).getPluginChunkTickets(0,0).size() > 0));

eternal oxide
#

Shame. It was just a guess

#

I just tried with meta on the world but that wipes too

solemn shoal
#

oh

#

the JVM reports uptime

#

ManagementFactory.getRuntimeMXBean().getUptime()

eternal oxide
#

oh, one sec, meta is not wiped on a reload

solemn shoal
#

Scan(ManagementFactory.getRuntimeMXBean().getUptime() < 120_000);

#

this should work

#

yep as far as i can tell

#

yep it works

quiet ice
#

I recall worlds not being loaded if you are initialising early enough, perhaps you can exploit this?

eternal oxide
#

even easier... if (Bukkit.getWorlds().isEmpty()) //this is a fresh start

solemn shoal
#

the uptime thing works fine

quiet ice
#

not always

solemn shoal
#

how so?

quiet ice
#

If the JVM for some reason is reused or shared

solemn shoal
#

doubt it

eternal oxide
#

the world test will always work

#

if there are worlds its a reload. if empty its a fresh start

quiet ice
#

I mean, someone will try to host multiple servers within a single JVM

eternal oxide
#
        if (Bukkit.getWorlds().isEmpty()) {
            System.out.println("Fresh Start");
        } else
            System.out.println("Reload");```
solemn shoal
#

let me test that

#

inb4 a plugin loads their world in the onload

#

oh yeah, that works

eternal oxide
#

I can update a few of my plugins to use that too

#

um, it just didn;t work for me

#

oh wrong method😛

solemn shoal
#

wait i wonder

#

what happens if you try printing a ChatColor to console?

drowsy helm
#

Anyone know how to list the players how I want? I'm adding them from 0-80 but obviously doesn't list by order of input

solemn shoal
#

its alphabetical @drowsy helm

#

not sure you can order them

#

but probably

drowsy helm
#

well all my names are the same

#

surely it would've listed my index aswell if it was alphabetical

maiden briar
#

I want to override the nms ServerPing.Serializer, and return super.serializer(customServerPing, type, jsonSerializationContext) with reflection

#

Just invoking the method won't work, because I don't have a Type or JsonSerializationContext

#

I am trying to set the Gson in the PacketStatusOutServerInfo to my own Gson

hot panther
#

Does anyone know how I can program a Daily Reward system?

quiet ice
solemn shoal
#

id just store time in a config

#

and check if its been 1 day since

ivory sleet
solemn shoal
#

its perfect

maiden briar
#

So I am changing the Gson at ServerPing.class, I want there my own serializer

#

But I can't invoke the serialize method because I don't have a Type of JsonSerializationContext

#

I created my own class 'ServerPing' which is just a NMS ServerPing, but it will set the fields with reflection

quiet ice
#

ChatColor in console is usually a gamble

solemn shoal
#

ah

#

it seems to work

minor garnet
#

what is this

ivory sleet
#

tvhee well I guess reflection is fine ?

eternal oxide
ivory sleet
#

It says malware found several times

minor garnet
#

''malware found!!!!'''

eternal oxide
#

is that your plugin?

minor garnet
#

no

eternal oxide
#

Then not sure why you are asing in a dev channel

minor garnet
#

i didn't really ask you that

#

i wanted to know what this did @solemn shoal

#

worm.backdoor.Rafael100 ???

solemn shoal
#

yes

#

antivirus for minecraft

#

people been complaining in yatopia discord about javassist errors

#

turns out its caused by backdoored plugins

#

that spread themselves to other plugins

ivory sleet
#

Isn’t like plugman also injecting javassist at runtime in plugins

solemn shoal
#

no?

ivory sleet
#

Uh weird then

solemn shoal
#

plugman doesnt even use javassist

#

javassist is a java library to do java bytecode manipulation lol

#

like, modify jars

#

like, all of the infected plugins still have their meta-inf intact

ivory sleet
#

Yes I’m aware of that however I did encounter a plugin which injected javassist into other plugins so I was unsure whether it was plugman or not

solemn shoal
#

ah yeah no

#

might have been this malware

ivory sleet
#

Yeah would be more plausible

solemn shoal
#

here's a more invasive sample of the same malware

summer scroll
#

is that a new thing? the virus.

#

on minecraft

solemn shoal
#

no idea

#

i have no reason to believe it hasnt existed for 3 years

#

the ones i have dont actually overwrite the main class, but rather append to it's onenable etc

#

that paste is the most invasive ive seen, just overwriting the entire class

#

you cant even tell its there because the plugins still work normally

dusty karma
#

Im getting this error when trying to load a kit: https://pastebin.com/T1V9bvTv I used this Thread to do it: https://www.spigotmc.org/threads/help-with-saving-load-inventory.246693/

solemn shoal
#

notice how theyre working fine?

#

(tablist and scoreboard)

#

those are infected plugins lol

ivory sleet
#

This is kinda scary lol

solemn shoal
#

it was uncovered by yatopia

#

yknow, that one server software everyone hates

ivory sleet
#

I mean it’s the superior server software 😛

solemn shoal
#

regardless

#

theres a reason for the name

#

worm.backdoor.Rafael10

maiden briar
ivory sleet
#

Hmm damn

solemn shoal
#

i mean

#

it makes sense right?

#

hes obviously using SOME exploit to run code on the server end to op himself

maiden briar
#

And another possibility is listening for packets of send a modified packet

summer scroll
#

really scary lmao

ivory sleet
#

Yeah tvhee you could do that tho also

solemn shoal
#

thats why im writing an antivirus for spigot n forks

ivory sleet
#

Oo nice

solemn shoal
#

thats why youre seeing that console output on my server

#

investigation around these malware plugins, and possibly finding others, goes on in the yatopia discord lol

#

but my dms are always open

ivory sleet
#

Yeah, but how dare you going to detect? By packages or will you run some sort of check after every plugin load so that you can see if every plugin did something suspicious.

solemn shoal
#

so far its just by checking jar contents

ivory sleet
#

Ah

solemn shoal
#

javassist has its own detection rule (PUL.javassist), but if .l1 and .l_ignore files are found aswell, itll mark it as worm.backdoor.Rafael10

summer scroll
#

Rafael10 got 100+ videos about griefing server xd

solemn shoal
#

since .l1 and .l_ignore are marker files used by that strain of malware to mark files as already infected

summer scroll
#

i wonder how the server owners feels.

ivory sleet
#

He’s a notorious guy

#

Sort of

solemn shoal
#

yeah

maiden briar
solemn shoal
#

im accepting PR's btw, if you can add more malware to the detection list

ivory sleet
#

Yeah I might write a plugin load checker if someone isn’t writing that already

solemn shoal
#

for my thing?

ivory sleet
#

Yeah

solemn shoal
#

well

#

we had a report of someone getting a RAT on their server...

ivory sleet
#

Oof

lost matrix
solemn shoal
#

yes

solemn shoal
#

find the suspicious port

ivory sleet
#

Uh idk one of the unknowns ?

lost matrix
#

12345...

lost matrix
# solemn shoal

Do you just detect based on a database of already known applications or are you also adding dynamic scans?

solemn shoal
#

im writing my own detection rules

eternal oxide
#

Just by name or heuristics?

solemn shoal
#

by name for now

#

because idk how to do heuristics 😅

solemn shoal
#

surely thats not supposed to be on a minecraft server right?

lost matrix
#

I would install it... as root

solemn shoal
#

theres people who run their server as root

lost matrix
#

I do that too (if my server is inside a docker)

solemn shoal
#

in the case of docker, thats fine

#

its disposable

#

but still

#

running stuff as root is a security flaw in itself

#

i once recovered a production system using nothing but docker @lost matrix

#

got screwed over in the middle of a dist upgrade, but we had rancher running on it, so i was able to make a docker container and escalate to the host

lost matrix
#

Is that only possible with mounted volumes? I couldnt think of a way to get from a docker to the host

solemn shoal
#

ssh got disconnected in the middle of the upgrade, so we had to escalate to the host through docker just to get a screen session with the installer

solemn shoal
#

if you mount some folder in your container to / on your host

#

and give the container the right permissions

#

you can chroot into your host

lost matrix
#

Thats what i suspected

solemn shoal
#

anyways im gonna make my AV scan recursively from .

maiden briar
#

new NamespacedKey(plugin, "minecraft");

topaz belfry
#

Guys do anyone know how to get dreams always flying pkugin

maiden briar
#

Yes create a plugin which adds recipes

topaz belfry
#

Pls

sleek dragon
#

anyone here use spigradle? how could I set it up so when I build with gradle it automatically spits it into my test server's plugin folder? (locally on my machine) using the gradle prepareSpigotPlugins command i believe.

topaz belfry
#

If you know tell ne

maiden briar
#

Which error?

#

Show

#

Then I don't know

#

But why do you want to add with minecraft:item ? You can also do new NamespacedKey(plugin, name), then the item will be pluginname:item

lusty cipher
#

How can I save all resource files? (I don't want to just create a List of all resources or hardcode this)

wraith rapids
#

it probably doesn't want you to use minecraft: keys in that

#

using them is generally ill advised to begin with

#

no reason for you not to use your plugin's namespace anyway

maiden briar
wraith rapids
#

i don't recall there being a built in method for that

topaz belfry
#

I am tellinghow do i get drean always flying plugin for minecrfat java do anyone know

maiden briar
#

Yes then do new NamespacedKey(plugin, name) as namespace

wraith rapids
#

inb4 what is plugin

maiden briar
#

Yes

lusty cipher
#
Caused by: java.lang.NullPointerException
        at me.generallyblinky.bettercraft.bettercraftitem.BreakManager.onBlockBreak(BreakManager.java:29) ~[?:?]

this should be enough to answer your issue

topaz belfry
#

Guys do i need forge to run dreams always flying mod

maiden briar
#

For mods you need forge or others mod clients

lusty cipher
#

NullPointerException so either loc or whatever the other function returns is null

lost matrix
#

Main.mainInstance could be null
Main.mainInstance.blockManager.blockMap could be null
Main.mainInstance.blockManager.blockMap.get(blockId) could return null
Main.mainInstance.blockManager.blockMap.get(blockId).drop could be null

wraith rapids
#

imagine if there was something like helpful or more detailed npe messages

#

they should add that in some future java version

maiden briar
#

Try printing everything:

System.out.println(Main.mainInstance.bloackManager);
System.out.println(Main.mainInstance.bloackManager.blockMap);
System.out.println(blockId);
System.out.println(Main.mainInstance.bloackManager.blockMap.get(blockId));
System.out.println(Main.mainInstance.bloackManager.blockMap.get(blockId).drop);
System.out.println(Main.mainInstance.bloackManager.blockMap.get(blockId.create()));
wraith rapids
#

oh wait

topaz belfry
#

Guys it is telling i need forge 1.12 or forge 1.13 but 1.13 doesn, t bow exist in minecraft

lost matrix
wraith rapids
#

real men split every deference on a new line

maiden briar
wraith rapids
#

so the line number is all you need

topaz belfry
#

I mean forge 1.13 now doesn, t exsist

lost matrix
young knoll
#

It does

silver shuttle
#

How do I spawn x amount of Items matching a given ItemStack at a location?

topaz belfry
#

What

wraith rapids
#

clone the itemstack

#

set amount to x

#

call World::dropItemNaturally

topaz belfry
#

What weond discird

#

I mean what wrong discord

young knoll
#

This is spigot, not forge

maiden briar
#

Are u coding a plugin then?

#

For Spigot

silver shuttle
wraith rapids
#

then use a while loop

#

and drop them one stack at a time

silver shuttle
#

hmmm

maiden briar
#

Or for and count

silver shuttle
#

and how would I check how much space a player has as inventory for a given item? Because different stack sizes

maiden briar
#

Also a possibility

lusty cipher
#

Yo does anyone here know how I can quickly save all resources instead of hardcoding all of them?

// in plugin
this.saveAllResources();

instead of

this.saveResource("config1.yml", false);
this.saveResource("config2.yml", false);
....
wraith rapids
#

while (todrop > 0) world.dropItemNaturally(location, itemToDrop.asQty(Math.min(todrop, itemToDrop.getMaxStackSize())))

#

not sure if the self-returning method to set a stack's amount is there on spigot though

#

might be paper only

lost matrix
#
  public void dropItem(final Location location, final ItemStack item, final int exactAmount) {
    final int maxStackSize = item.getMaxStackSize();
    int stacks = exactAmount / maxStackSize;
    int left = exactAmount % maxStackSize;
    World world = location.getWorld();
    for (int i = 0; i < stacks; i++) {
      ItemStack drop = item.clone();
      drop.setAmount(maxStackSize);
      world.dropItemNaturally(location, drop);
    }
    if (left != 0) {
      ItemStack drop = item.clone();
      drop.setAmount(left);
      world.dropItemNaturally(location, drop);
    }
  }
topaz belfry
#

I told that when i go to dreams always flying mod it is telling i need 1.12 or 1.13 versions

wraith rapids
#

don't clone the item every time doofus

silver shuttle
#

why not

wraith rapids
#

because cloning can be potentially expensive

#

and is redundant

silver shuttle
#

ok then how do I check for the exact amount of a specific item a player has space for in his inventory?

lost matrix
wide current
#

I can't understand why it doesn't work :/

final UUID sId = UUID.fromString(topInventory.getItem(22).getItemMeta().getAttributeModifiers().get(new NamespacedKey(Logger.getInstance(), "UUID"), PersistentDataType.STRING));
topaz belfry
#

I need forge to run it but 1.13 doesn, t exsist and 1.12 when i downloaded it after that when i try to open it it diesn, t come like we need to install it first that doesn, t coms

lost matrix
young knoll
silver shuttle
maiden briar
#
Gson serverPingSerializer = new GsonBuilder().registerTypeAdapter(serverPingServerDataClass, serverPingServerDataSerializerClass.newInstance())
.registerTypeAdapter(serverPingPlayerSampleClass, serverPingPlayerSampleSerializerClass.newInstance())
.registerTypeAdapter(serverPingClass,
//Start
new net.minecraft.server.v1_16_R3.ServerPing.Serializer()
{
   @Override
   public JsonElement serialize(net.minecraft.server.v1_16_R3.ServerPing var0, Type 
   var1, JsonSerializationContext var2)
   {
      return super.serialize((net.minecraft.server.v1_16_R3.ServerPing) 
      serverPing.getNMS(), var1, var2);
   }
})
//End
.registerTypeHierarchyAdapter(iChatBaseComponentClass, iChatBaseComponentChatSerializerClass.newInstance())
.registerTypeHierarchyAdapter(chatModifierClass, chatModifierChatModifierSerializerClass.newInstance())
.registerTypeAdapterFactory((TypeAdapterFactory) chatTypeAdapterFactoryClass.newInstance()).create();

How to do this with reflection?

lost matrix
wraith rapids
#

they usually either drop the leftover items at your feet, or just don't charge you for items that don't fit in your inventory

silver shuttle
#

^^ essentials has a config option to warn or to drop

#

essentials kits have a config option to say abort if no space or drop if no space

lost matrix
#
  public void addOrDrop(final Player player, final ItemStack item) {
    final World world = player.getWorld();
    final Location playerLoc = player.getLocation();
    player.getInventory().addItem(item).values().forEach(overhead -> world.dropItemNaturally(playerLoc, overhead));
  }

Something like this

young knoll
#

addItem returns a map of items that don’t fit, so it’s pretty easy to drop the rest

silver shuttle
#

wait it returns the amount of items that didnt fit in the inventory?

wraith rapids
#

myeah

silver shuttle
#

bruuuuhhhhh

#

that solves it

wraith rapids
#

maybe like

silver shuttle
#

thanks lmao

wraith rapids
#

read the javadocs or something

silver shuttle
#

How can I add things like Material to autocomplete in a command?

#

So you do /xdelete (shows list of Material)

wraith rapids
#

iirc there are several ways

#

the easiest of which is to implement tab executor

#

or was that what that was called

#

i literally can't remember

young knoll
#

Yeah and make use of material.values and StringUtil.copyPartialMatches

lost matrix
#

just implement tab executor and let it return a pre-calculated list of materials

silver shuttle
#

ok ty

wide current
wraith rapids
#

spigot doesn't let you do tab completions asynchronously still I don't think

#

but that won't be an issue with a simple material list

silver shuttle
#

okay

lost matrix
young knoll
#

Don’t use that

lost matrix
#

ChatColor.translateAlternateColorCodes

wide current
silver shuttle
#
int amount = Integer.getInteger(args[1]);