#help-development

1 messages · Page 1386 of 1

crude charm
#

?paste

queen dragonBOT
crude charm
#

dont bully for 1.7

#

its not me

deft sedge
#

ok, ill note all of these. Not to be rude or anything I appreciate that ur trying to help me be better, but can u get to the fixing shift click part. It's kinda late and sleep is sadly a thing that is needed 😄

crude charm
#

im just compiling

lost matrix
#

Ok so your jvm targets are set properly... hm

crude charm
#

im using java 11

lost matrix
crude charm
#

compiling

#
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.3.11:compile (compile) on project potpvp-nd: Compilation failure
[ERROR] Unknown JVM target version: 11
[ERROR] Supported versions: 1.6, 1.8
[ERROR]
[ERROR] -> [Help 1]

lost matrix
crude charm
#

how

#

tf

#

do

#

I install java 8

#

I cant find it

#

how do u install jdks

#

from inside intelliJ

lost matrix
#

File > Project Structure >

crude charm
#

ik that

#

but like where do I choose

#

its asking me to select

#

can I just download it

#

from intelliJ

lost matrix
#

If you click on the plus sign you can select "download jdk"

crude charm
lost matrix
crude charm
#

what intelliJ ver?

lost matrix
#

latest.

crude charm
#

um

#

well

#

im on 2019

#

how do I update

#

without breaking stuff

lost matrix
crude charm
#

I dont have that

#

downloaded it

lost matrix
#

then double shift and search for "update"

#

in ij

deft sedge
#

ok, ill note all of these. Not to be rude or anything I appreciate that ur trying to help me be better, but can u get to the fixing shift click part. It's kinda late and sleep is sadly a thing that is needed 😄

crude charm
#

like shift shift

twin cape
#

It doesn't seem to be working

crude charm
lost matrix
deft sedge
#

k

lost matrix
# crude charm

I guess then you just need to download the newest intellij version and update your old one with that launcher

deft sedge
crude charm
twin cape
#

Should I paste my code here or through a site like PasteBin?

lost matrix
lost matrix
twin cape
#
    @EventHandler
    public void onInteract(PlayerInteractEvent e) {
        try {
            Player player = e.getPlayer();
            if (e.getClickedBlock().getType() == Material.DISPENSER && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                this.getLogger().info("Checking if it is a booth...");
                Dispenser dispenser = (Dispenser) e.getClickedBlock().getState();
                NamespacedKey key = new NamespacedKey(this, "isVotingBooth");
                if (Objects.equals(dispenser.getPersistentDataContainer().get(key, PersistentDataType.STRING), "true")) {
                    this.getLogger().info("Booth detected!");
                    if (player.hasPermission("voting.vote")) {
                        String running = (String) this.getConfig().get("data.running");
                        if (running.equals("true")) {
                            e.setCancelled(true);
                            showVotingGUI(player);
                        }
                    } else {
                        player.sendMessage(ChatColor.RED + "Access denied.");
                    }
                }
            }
        } catch (Exception exception) {

        }
    }
#

making a realistic voting plugin

#

I put the "checking if it's a booth" thing to see if it came to that line, and it did. but the if statement doesn't seem to work

lost matrix
#
        } catch (Exception exception) {

        }

So you catch all exceptions and then just hide them so you wont have any idea of why your plugin doesnt work.
Are you a masochist?

#

Never ever catch an exception unless java absolutely forces you to. Exceptions should be avoided at all costs.

#

There are a few small exception to this rule. But generally avoid them

twin cape
#

so print the exception or remove the catch altogether?

lost matrix
#

Remove it

#

If your code throws an exception then you need to fix it

twin cape
#

but then Intellij gives me an error

#

and says I need to add the catch

#

oh, never mind

lost matrix
#

one moment pls

lost matrix
# twin cape but then Intellij gives me an error

Ok this is your code. Just null safe and cleaner.

  @EventHandler
  public void onInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Block clickedBlock = event.getClickedBlock();

    if (clickedBlock == null) {
      return;
    }

    Material clickedType = clickedBlock.getType();
    if (clickedType != Material.DISPENSER) {
      return;
    }

    Action action = event.getAction();
    if (action != Action.RIGHT_CLICK_BLOCK) {
      return;
    }

    this.getLogger().info("Checking if it is a booth...");
    BlockState state = clickedBlock.getState();
    Dispenser dispenser = (Dispenser) state;
    NamespacedKey key = new NamespacedKey(this, "is_voting_booth");
    if (!dispenser.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
      return;
    }

    event.setCancelled(true);
    
    this.getLogger().info("Booth detected!");
    if (player.hasPermission("voting.vote")) {
      boolean running = this.getConfig().getBoolean("data.running");
      if (running) {
        showVotingGUI(player);
      }
    } else {
      player.sendMessage(ChatColor.RED + "Access denied.");
    }
  }
twin cape
#

wow, thanks!

south onyx
#

how to move a player by a certain amount of blocks in a certain direction(north, south, etc)

crude charm
#

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (java-compile) on project potpvp-nd: Fatal error compiling: java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTags -> [Help 1]

#

switched to mac

#

so im on java 8

#

@lost matrix

quaint mantle
south onyx
#

Yes

#

But I don’t want to teleport

#

I want them to move smoothly

frigid anchor
#

you can set there movement velocity?

#

I dont believe you can force them to walk in a certain direction

#

you can with entities

quaint mantle
frigid anchor
#

development on mac is fcking amazing

crude charm
#

Like 15 messages

#

A day

quaint mantle
#

I’m in so many service teams

crude charm
#

Took a 2 year break tho 13 hours a day of coding for 2 years ain’t good for u lmfao

quaint mantle
#

And I do like 1 comiszion / month

crude charm
#

Mcmarket, spigot, mctrades building a name, wom

#

Being known is a big thing

#

U get a lot of random messages

frigid anchor
#

i stopped doing commissions a while back and just got a normal software dev job

#

no more scammers and health insurance

crude charm
#

Yeah I might have to do that

frigid anchor
#

a lot less demanding, only code like 4 hours a day

quaint mantle
#

well im still 15 so its not an option for me

#

:/

crude charm
#

Yeah defo

U make full time of part time sallee you for that time

#

Autocorrect

frigid anchor
#

start early tho, the skills i got from spigot programming was like super helpful

crude charm
#

Yeah

frigid anchor
#

i breezed through university compared to some of the code we do here

crude charm
#

Can’t start at like 20

#

Just won’t learn in time

#

For a long carrier I mean

frigid anchor
#

university programming a joke, a semester to learn about booleans and strings

crude charm
#

Yeah lmfao

near crypt
#

Does anyone know how to send a play or all players a big title on the screen on 1.16.5?

frigid anchor
#

isnt it part of the player api?

quaint mantle
chrome beacon
#

But that's not over complicated ;/

frigid anchor
#

yeah i didnt think so either

#

like 2 lines of code

quaint mantle
#

pre-1.16

young knoll
#

The title API has existed for a while

exotic plaza
#

i want to get a variable by for loop

for (Main.i = 10; Main.i < 1; Main.i--) {
            if (p.hasPermission("damage.get." + Main.i)) {
                Double d = (Main.(("level") + Main.i + ("_getdamage")));
                Double d2 = (Main.("level" + Main.i + "_damage"));
                getdamage.put(p.getName(), d);
                damage.put(p.getName(), d2);

but it doesn't work
actually i am getting the permission of damage.get.(10 to 1)
How to do so?

bright jasper
#
        getServer().getMessenger().registerIncomingPluginChannel(this, Channels.BROADCAST, new BroadcastListener(this));

        TeleportListener teleportListener = new TeleportListener();
        getServer().getMessenger().registerIncomingPluginChannel(this, Channels.TELEPORT, teleportListener);
        getServer().getMessenger().registerIncomingPluginChannel(this, Channels.BROADCAST, teleportListener);

this will process BROADCAST on two listeners right?

flint elk
#

How can i make a Tablist like this?

ivory sleet
#

pretty sure the API can accomplish that BitLukas

quaint mantle
#

SO does spigot treat commands ran by a command block as a player or console?
Furthermore, can you get the position of the command block responsible for running the command?

#

hi

quaint mantle
#

ty

ivory sleet
#

registerCommand("astreansbuildsystem", new AstreansBuildSystem(), new AstreansBuildSystem(), false);

#

its like you're creating two more units of ur plugin

#

replace new AstreansBuildSystem() with this and you should be good to go

#

this refers to the unit itself, not a new one

quaint mantle
#

omg

#

there was my main class not command class

ivory sleet
#

lol ye I'm afraid so

quaint mantle
#

i dont get it i just woke up to many imports missing and then this error

ivory sleet
#

lol

#

never call new ClassThatExtendsJavaPlugin()

#

bukkit does that for you

#

or spigot*

quaint mantle
#

yeah yeah ik

ivory sleet
#

pog

quaint mantle
#

i know that i putted command class yesterday

ivory sleet
#

ye

hollow sand
#

Hello,I wanted to ask. If anyone has exepreinced this. I opened a project thru github with intellij and when i tried to put some code in. No code examples, nor errors were shown. Is there a way to fix this?

ivory sleet
#

whats the issue if I may ask?

hollow sand
#

When i try to code, I dont get any examples

#

let me show a gfew ss'

#

few*

wispy monolith
ivory sleet
#

like suggestions when putting a dot etc?

hollow sand
ivory sleet
#

oh

#

thats because you cannot annotate there

rugged topaz
#

is it possible to teleport a player to another world without the use of a 3rd party plugin such as multiverse to load the world?

#

is it possible for me to load the world?

hollow sand
ivory sleet
#

Invalidate and restart caches

wispy monolith
hollow sand
ivory sleet
#

File -> Invalidate Caches/Restart IDE

hollow sand
rugged topaz
#

with my own singular plugin, i wanna p.teleport(Bukkit.getWorld("customworld), 0, 0, 0); @wispy monolith

wispy monolith
#

try updating IDE

rugged topaz
#

so that a ya?

wispy monolith
#

p.teleport(CustomWorld, 0, 0, 0);

rugged topaz
#

customworld is a what?

#

a World?

wispy monolith
hollow sand
ivory sleet
#

update IDE also like hesham said

hollow sand
ivory sleet
#

so you're on latest with other words?

hollow sand
#

should i try to reinstall it?

hollow sand
ivory sleet
#

uh yeah that might the last resot

wispy monolith
hollow sand
wispy monolith
# rugged topaz a `World`?

if this didn't work try:

Location ExampleLoc = new Location(CustomWorld, <X cords>, <Y cords>, <Z cords>);
p.teleport(ExampleLoc);
rugged topaz
#

that won't change anything (: i can instantiate the location without initializing it

#

i've just had trouble with teleporting players to a world in the past

#

bcuz i'm pretty sure you do have to load it, but i'll try in a sec

main dew
#
public static void setBlockInNativeChunkSection ( World world, int x, int y, int z, int blockId, byte data ) {
    net. minecraft . serwer . v1_14_R1 . World nmsWorld = ( ( CraftWorld ) świat ) . getHandle ( ) ;
    netto. minecraft . serwer . v1_14_R1 . KawałeknmsChunk = nmsWorld. getChunkAt ( x >> 4 , z >> 4 ) ;
    IBlockData ibd = net. minecraft . serwer . v1_14_R1 . Zablokuj . getByCombinedId ( blockId + ( dane << 12 ) ) ;

    ChunkSection cs = nmsChunk. getSections ( ) [ y >> 4 ] ;
    jeśli ( cs== nmsChunk. a ( ) ) {
        cs = new ChunkSection ( y >> 4 << 4 ) ;
        nmsChunk. getSections ( ) [ y >> 4 ] = cs ;
    }
    cs. setType ( x i 15 , y i 15 , z i 15 , ibd ) ;
}```
I find this metod to fast place block but how I can translate this to 1.12.2?
wispy monolith
summer scroll
#

By teleporting player, the chunk will automatically loaded, at least that's what md_5 said.

wispy monolith
wispy monolith
#

without translate

#

bcz spigot api doesn't change alot

eternal oxide
wispy monolith
#

and change the api version in plugin.yml

main dew
#
if (cs == nmsChunk.a()) {
        cs = new ChunkSection(y >> 4 << 4);
        nmsChunk.getSections()[y >> 4] = cs;
    }```
This fragment don't work
#

from what I understand, it forces the section to be loaded

wispy monolith
wispy monolith
main dew
#

is an excerpt in case the section fails to load

wispy monolith
main dew
#

yea this fragment I understand

wispy monolith
#

but the if statement have nmsChunk.a

#

which will always make it false I think

near crypt
#

how can i send a code and say that it is in java?

#

in dc?

main dew
near crypt
#

java if()

#

hmm

#

oh i think ik know

main dew
near crypt
#
if()```
#

okay thx

main dew
near crypt
#

can anyone send me a if statement which asks if a player have a elytra equipped?

#

i struggle hard with this

#

haha

eternal oxide
#

We already did that yesterday

near crypt
#

no i dindnt work idk why...

eternal oxide
#

I gave you the full code, it works

near crypt
#

hmm the thing is i want to ask if a player has a elytra equipped if not he can execute the command

summer scroll
#

Would getChestplate works?

#

player.getInventory().getChestplate()

eternal oxide
#

Yep, teh code I gave you yesterday check if they had an elytra equipped

near crypt
summer scroll
#

No, you need to get the type.

near crypt
#

oh yes true and then ==

summer scroll
wide galleon
#

How can I display the players hearts on tab?

wispy monolith
wide galleon
#

but i want to do it with my plugin

wispy monolith
wide galleon
#

player.getHealth()?

wispy monolith
wide galleon
#

alr

wispy monolith
wide galleon
#

okay

wispy monolith
#

And then

player.setPlayerListName(<player.getName variable> + " " + <player.getHealth variable> + "HP")
wide galleon
#

would that update?

#

like when the player looses health

near crypt
#

@summer scroll now it says an error message if the player has no elytra and if he has an elytra it does the else as i want it but i dont want the error

wispy monolith
near crypt
#
if(!(p.getInventory().getChestplate().getType() != null || p.getInventory().getChestplate().getType() == Material.ELYTRA))```
#

this is my code

wide galleon
near crypt
#

my if statement

summer scroll
#
if(p.getInventory().getChestplate() != null && p.getInventory().getChestplate.getType() == Material.ELYTRA)
near crypt
#

ah okay thx

wide galleon
#

so this is my Class:

@EventHandler
    public void Health(EntityDamageEvent event){
        Player player = (Player) event.getEntity();
        for (Player all : Bukkit.getOnlinePlayers()){
            all.setPlayerListName(all.getName() + " " + all.getHealth() + "HP");
        }
    }```


and this is the error message that is constantly repeating: https://ghostbin.com/paste/38LX6
summer scroll
wispy monolith
summer scroll
#

You have unchecked cast.

wide galleon
#

ohh okay ty

summer scroll
#

yo, why static

wispy monolith
summer scroll
#

yes, but it's unnecessary.

wispy monolith
summer scroll
#
@EventHandler
public void onDamage(final EntityDamageEvent event){
  final Entity entity = event.getEntity();
  if(entity instanceof Player){
    Player player = (Player) entity;
    player.setPlayerListName(player.getName() + " " + player.getHealth() + "HP");
  }
}
```better.
wispy monolith
#

@wide galleon
and make a PlayerJoinEvent and add the code to it

#
@EventHandler
    public static void onPlayerDamage(PlayerJoinEvent event) {
       Player player = event.getPlayer();
       player.setPlayerListName(player.getName() + " " + player.getHealth() + "HP");
    }

like that

wide galleon
wispy monolith
wide galleon
#

also, is there a way to display the "HP" as just hearts?

wispy monolith
wide galleon
#

like the hearts next to the player name

wispy monolith
#

like a heart icon?

summer scroll
wide galleon
wispy monolith
#

This is how to display it like that

#

I don't think that there is a way to display it like that using plugin

wispy monolith
rigid hazel
#

Hello.

wispy monolith
rigid hazel
#

How do this stuff, when someone is clicking text, that I can execute code

wispy monolith
#

there is way to make it using minecraft vanilla command

#

and u can use plugin

rigid hazel
#

For example:

#

Hello Verox [cancel]

#

By clicking [cancel]: execute this.plugin.cancel()

sullen marlin
#

You have to map it to a command

#

Or out it on a sign

ivory sleet
#

@eternal oxide How do you deal with loading and data syncing in groupmanager and what type of cache design are you using? I'm just curious ignore if you're busy I can check the code else wise.

rigid hazel
wispy monolith
rigid hazel
#

By myself

sullen marlin
#

ClickEvent

#

Lots of people contribute

rigid hazel
#

Thanks

eternal oxide
#

If I remember correctly

ivory sleet
#

hmm okay and when do you save data precisely? I mean I guess you would do it from time to time but also post player quit or no?

eternal oxide
#

by a config setting, default 10 minutes

#

It checks the timestamp on the file to see if its been altered since the last save

ivory sleet
#

ah nice okay thanks for answering 🙏

eternal oxide
#

If any data (cached) is changed between saves its is flagged as changed, so when the next save cycle happens we only need to check the changed flag.

ivory sleet
#

clever, I was also looking in to LuckPerms the other day but it seemed like they never saved the data so wanted to get another aspect of how the handling of data is done btw

eternal oxide
#

I've not looked at LP much, other than their loading

rigid hazel
#

How I can send a message with a normal String + a TextComponent

ivory sleet
#

From what I understand they load data on join, then they have a housekeeper which is responsible for the unloading (unloads non online users) and is running like once every 30 seconds or something. And when it loads the data of a user it creates a new user object and then later mutate the user based of their storage implementation I think.

ivory sleet
rigid hazel
#

Because I dont want that you can clik the whole text to execute a ClickEvent

ivory sleet
#

use a component builder

rigid hazel
#

Okay

twilit cliff
#

Does the EntityPotionEffectEvent only exists in newer versions?

#

And if so, how else can I make something happen when a player gets/loses a potion effect?

#

In 1.8.8

hollow sand
supple marsh
#

Hello, so I have this really weird problem that I need help with so if someone can help, please do.
Here is what's happening:
I am making this tutorial plugin for someone, and I am now setting it up in their server, and for some reason, the player gets removed (Entity#remove) and I try to teleport them but because they are removed it makes a lot of errors and doesn't teleport, but I don't know why it's removing the player, in my code there isn't a single time that I remove a player (I remove another entity but I check that's it's not a player before I remove), if anyone can help, please do @supple marsh

quaint mantle
eternal oxide
eternal oxide
#

player.setVelocity(new Vector(1,0,0).multiply(player.getVelocity().length()))

#

That will set the players current velocity in a single axis. If the player is not moving there is no velocity

quaint mantle
eternal oxide
#

then you just setVelocity with a new Vector

quaint mantle
#

player.setvelocity(new Vector(1, 0,0).length()) you mean like that?

eternal oxide
#

no length

#

setVelocity takes a Vector

quaint mantle
#

if i do that then if the player moved against a different axis it sets any others to 0 which feels weird

eternal oxide
#

Thats precicely what you asked for. Explain exactly what you are trying to achieve

quaint mantle
#

A wind like adding velocity, i tried taking their current velocity and adding to it by 0.02 on x axis but it interferes with their sprinting etc even if their going in the direction the velocity is pushing them. And setting a new velocity as 0.02, 0, 0 pushes them yes but if they then jump becuase its every 2 ticks it stops them mid air. pushes them, stops, pushes etc.

eternal oxide
#

If teh player takes any action it will cancel your velocity

#

unless you apply it in a 1 tick timer

quaint mantle
#

i set it to 1 tick but now it doesn't move the player when their not moving or affect them in anyway just slows them down in a way

eternal oxide
#

show what you are doing

quaint mantle
#

code or in game

eternal oxide
#

code

#

?paste

queen dragonBOT
quaint mantle
#

mind i i dm it u

eternal oxide
#

you have nothing in your code everyone here has not seen 100 times

quaint mantle
#

let me just take out a few lines quick

eternal oxide
#

You are trying to move ALL entities in the world?

quaint mantle
#

yes

#

including the player

#

but affecting the player has to be smooth or it interferes with gameplay, im looking for a way to push the player a tiny bit without affecting their inputs by glitches etc

eternal oxide
#

your current code is going to slowly increase the velocity if nothign counters it

quaint mantle
#

realisticWeather.wind speed is every tick

#

its a int of 1 just in another class

eternal oxide
#

yep, but you are adding that value every tick to the entities current velocity

quaint mantle
#

your saying realisticWeather.windPushPower the value is too small

#

its 0-0.02 so yes very small

eternal oxide
#

no, I'm saying if an entity doesn't do anything to cancel that push its going to move faster and faster

#

you need to cap you addition so it won;t exceed a set speed

quaint mantle
#

the code your seeing there does this in game

eternal oxide
#

You are also scheduling a repeatign task inside a repeating task. None of those tasks ever end

#

you are going to run out of memory as your server slows to a crawl with all teh tasks you are adding

quaint mantle
eternal oxide
#

yes, every 3 minutes you start a new repeating task. However the old task is still running. Its never cancelled

quaint mantle
#

right i see

#

ive been doing this for hours ill be back in abit

eternal oxide
#

use a BukkitRunnable so you get a cancellable task object back

quaint mantle
eternal oxide
#

the runnable where you set the velocity needs to be cancelable

quaint mantle
#

I dont understand why

eternal oxide
#

make it a field inside your 3 minute runnable

#

then if its not null you cancel it when yoru 3 minute runnable starts

quaint mantle
#

It is possible to get player's inventory on death?

eternal oxide
# quaint mantle I dont understand why

If its not cancellable you are starting a NEW runnable every time your 3 minute repeats. So now you have 2 running. Next time you have 3 running and so on.

ivory sleet
#

pogh

eternal oxide
gritty mist
#

hi what is the enum value for sharpness in Enchantment Enum

young knoll
#

DAMAGE_ALL iirc

gritty mist
#

thx

gritty mist
#

oh thank you enchantments names are a bit confusing in spigot ^^

lusty cipher
#

How can I read and parse a YAML file and also do all yml files except plugin.yml get put into plugins/PluginName/?

lusty cipher
#

ah nice

#

now how would I read and parse a yml file that I have saved?

lusty cipher
#

thanks for teh link

gritty mist
#

when i start my local server i have this error in console "Unsupported Java detected (60.0). Only up to Java 15 is supported."

#

how can I fix it

winged spindle
gritty mist
#

how can I fix it

#

its the JDK or java on my computer ?

winged spindle
gritty mist
#

ok thank you

sand hinge
#

Hello

lusty cipher
#

Is there an alternative to JavaPlugin#getResource that just returns a File?

#

Ah getTextResource​ returns Reader which I can use, nvm

cold field
#

What is the maximum distance at which a player can see another player?

#

Is it managed from the view-distance property?

winged spindle
#

ur render distance

chrome beacon
#

It can be shorter than that

#

It depends

cold field
#

does the server send any packet that tell the client how much far a player should be rendered?

chrome beacon
#

Don't think so. I just think it tells the client to unload the player and no more data is sent

cold field
#

Does the server decide that a player shouldn't load another player thanks to the view-distance property?

eternal oxide
cold field
#

I'm making a NPC plugin and I don't want send the packet to spawn the player to all the clients.

chrome beacon
#

There's a setting called
entity-tracking-range-players

#

It controls how far you see players

eternal oxide
#

If you are creating NPC's then you have to control who you send their data to

cold field
eternal oxide
#

If you are creating NPC's that you only want specific players to see you have to manage what packets are sent.

cold field
#

Ahh, yeah

quaint mantle
#

how to make an event in command run with 5 sec delay?

eternal oxide
#

bukkit scheduler

gritty mist
#
        if (sender instanceof Player) {
            Player player = (Player) sender;
            if (args[1].equalsIgnoreCase("sharp10")){
                ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
                ItemMeta swordItemMeta = sword.getItemMeta();
                swordItemMeta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);
                sword.setItemMeta(swordItemMeta);
                player.getInventory().addItem(sword);

            }else{
                player.sendMessage(ChatColor.RED + "Invalid command usage !");
                return false;
            }
        }else{
            return false;
        }
        return true;
    }```
#

is there too much return ?

earnest junco
#

Not really, but you can make it look nicer by inverting the statement and not having indentation hell.

if (!(sender instanceof Player))
    return false;

if (args.length != 1) {
    sender.sendMessage("....");
    return true;
}

// etc.
gritty mist
#

ima try this

bright jasper
#

That thing with the screen I showcased yesterday btw has a partially functional dev server at etm.dev

#

Called EscapeFromMars

#

Very cool image generated screen map thingy

gritty mist
#
        if (!(sender instanceof Player)) {
            return false;
        }
        if (args.length == 1) {
            sender.sendMessage(ChatColor.RED + "Invalid usage ! : /kit <kitname>");
            return true;
        }
        if (args.length == 2){
            switch (args[1]){
                case "sharp10":
                    Player player = (Player) sender;
                    ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
                    ItemMeta swordItemMeta = sword.getItemMeta();
                    swordItemMeta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);
                    sword.setItemMeta(swordItemMeta);
                    player.getInventory().addItem(sword);
                    break;
                default :
                    sender.sendMessage("Invalid usage ! : /kit <kitname>");
                    break;
            }
        }
        return true;
    }```
#

i went for that but when I type /kit sharp10 is sends me invalid usage ! : /kit <kitname>

eternal oxide
#

/kit sharp10 is args.length() == 1

gritty mist
#

hmm

#

ok so args[] doenst include the command name

#

which is kit

eternal oxide
#

no

gritty mist
#

okay ill fix it

ebon shoal
supple marsh
#

?paste

queen dragonBOT
eternal oxide
supple marsh
#

Player gets removed for no reason, any help?

ebon shoal
eternal oxide
#

You are also not setting the players inventory onJoin

ebon shoal
#

is this a good fix?

#

plugin.vaultInventory.setItem(i, items.get(i));

eternal oxide
#

ok theres a few issues with yoru code.

#

First you don;t need to check if sections exist and create them.

ebon shoal
#

oh, i did that because it returned an error when i tried to add items to them even when i did this.saveDefaultConfig(); in the onEnable()

gritty mist
#

ok guys thx for the one that helped me

eternal oxide
#

if you want to store the players inventory java plugin.getConfig().set("Vaults." + uuid, player.getInventory().getContents());

ebon shoal
#

oh, i didnt know it was that simple lol

#

and getting the players inventory?

gritty mist
#
        if (!(sender instanceof Player)) {
            return false;
        }
        if (args.length == 1) {
            switch (args[0]) {
                case "sharp10":
                    Player player = (Player) sender;
                    ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
                    ItemMeta swordItemMeta = sword.getItemMeta();
                    swordItemMeta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);
                    sword.setItemMeta(swordItemMeta);
                    player.getInventory().addItem(sword);
                    break;
                default:
                    sender.sendMessage("Invalid usage ! : /kit <kitname>");
                    break;
            }
        }else{
            sender.sendMessage(ChatColor.RED + "Invalid usage ! : /kit <kitname>");
        }
        return true;
    }```
eternal oxide
#

You may have to parse teh contents into an array is all

gritty mist
#

I ended up with this

ebon shoal
#

ok, ill try that

gritty mist
ebon shoal
#

@eternal oxide this returns an error
ItemStack[] items = (ItemStack[]) plugin.getConfig().getConfigurationSection("Vaults").get(player.getUniqueId().toString()); and i have to do inventory.setContents(ItemStack[]) what should i do

ebon shoal
#

oh

#

what should i do

cinder thistle
eternal oxide
#

yes

cinder thistle
#

fuck automod

#

sorry guys for the ping

quaint mantle
#

is there an event when a user receives a chat event?

cinder thistle
#

AsyncPlayerChatEvent

#

there might be a newer one but idk it

quaint mantle
#

hi! it is possible to get a list of items on player on the moment of his death ?

quaint mantle
cinder thistle
#

you can just cancel the message and send it to who you want if that's not what you're doing

quaint mantle
#

no I need the event to not be cancelled

#

as plugins like discordsrv use it to then display the messages

hybrid spoke
earnest junco
nova hare
#

hey Can some one help me with building? On my server

nova hare
#

thank you

willow fossil
#

How can i do something when i click on an item in my inventory?

dense kestrel
#

that is called by*

quaint mantle
dense kestrel
#

Player#getExpToLevel

#

that?

#

or Player#getExp

hushed crescent
#

How can I make it where when someone plants a tree it adds one point to a leaderboard

dense kestrel
#

then either a placeholder or just make your own leaderboard

hushed crescent
#

Yeah I want to make a leaderboard

dense kestrel
#

You need to get the slots items are placed in and compare it to the slots for your custom recipe

#

if its correct

#

then you can set the result to be the custom item

dense kestrel
#

Check the items in each slot?

#

one sec, let me check

wide galleon
#

could someone tell me whats wrong with this code? java @EventHandler public void onInvClick(InventoryClickEvent event){ Player p = (Player) event.getWhoClicked(); if(event.getView().getTitle().equals("§6Settings §8• §bConditions")){ event.setCancelled(true); if(event.getCurrentItem().getType().equals(Material.SLIME_BALL)){ if(event.isLeftClick()){ if(Main.getInstance().getConfig().getBoolean("isChunk", true)){ p.sendMessage(Main.getErrorPrefix() + "§bChunk Effects §care already enabled§8!"); } else if(Main.getInstance().getConfig().getBoolean("isChunk", false)){ p.closeInventory(); Main.getInstance().getConfig().set("isChunk", true); Main.getInstance().saveConfig(); p.sendMessage(Main.getPrefix("Chunk Effects") + "§bChunk Effects §aactivated§8!"); Bukkit.reload(); } } else if(event.isRightClick()){ if(Main.getInstance().getConfig().getBoolean("isChunk", false)){ p.sendMessage(Main.getErrorPrefix() + "§bChunk Effects §care already deactivated§8!"); } else if(Main.getInstance().getConfig().getBoolean("isChunk", true)){ p.closeInventory(); Main.getInstance().getConfig().set("isChunk", false); Main.getInstance().saveConfig(); p.sendMessage(Main.getPrefix("Chunk Effects") + "§bChunk Effects §adeactivated§8!"); Bukkit.reload(); } } } } }

quaint mantle
#

everything

wide galleon
#

huh

quaint mantle
#

your code is super messy

wide galleon
#

oh

#

and how could i fix that?

quaint mantle
#

use variables

#

Main.getInstance should be dependency injection if inside of a listener class

#

and dependency injection for most other things

dense kestrel
ivory sleet
#

Yeah use dependency injection although I guess you could still use static singleton

dense kestrel
#

yea you can, just make the custom itemstack :/

#

you could use event.getInventory().getItem()

#

and check each item in the table then

#

np

ivory sleet
#

amitco

ivory sleet
#

r u trying to make a recipe with itemstack ingredients rather than material based

#

?

wide galleon
ivory sleet
#

also yes you can @SuppressWarnings("deprecation")

#

yeah

#

cuz its a draft

#

Idk I think it still works to a certain extent

#

might be worth trying needless to say

dense kestrel
wide galleon
#

wdym with comments?

dense kestrel
#
ConfigValue1: "hjeiu9ijosej3ij90 r20 9" #This is a random string
ConfigValue2: 82 #This is a random int
ConfigValue3: false #Random bool

would become

ConfigValue1: "hjeiu9ijosej3ij90 r20 9"
ConfigValue2: 82
ConfigValue3: false

using .saveConfig(); i belive

wide galleon
#

i dont have any comments

dense kestrel
#

ahh

#

so whats going wrong with it though?

wide galleon
#

when the config is set to true, and i click the item, nothing happens

dense kestrel
#

ok

#

let me look

quaint mantle
#

So, anyone got the saucy for converting a player object to a username string?

wide galleon
dense kestrel
#

Ok, let me try something

quaint mantle
#

found it

dense kestrel
# wide galleon when the config is set to true, and i click the item, nothing happens
    @EventHandler (ignoreCancelled = true)
    public void onPlace(InventoryClickEvent event) {
        Player player = (Player) event.getWhoClicked();
        
        if (!event.getView().getTitle().equals("§6Settings §8• §bConditions")) {
            return;
        }
        event.setCancelled(true);

        ItemStack item = event.getCurrentItem();
        
        if (item == null || item.getType() == null || item.getType().equals(Material.AIR)) {
            return;
        }
        
        if (!item.getType().equals(Material.SLIME_BALL)) {
            return;
        }
        
        if (event.isLeftClick()) {
            if (plugin.getConfig().getBoolean("isChunk")) {
                //Send your message
            } else {
                player.closeInventory();
                plugin.getConfig().set("isChunk", true);
                plugin.saveConfig();
                //send your message
            }
        } else if (event.isRightClick()) {
            if (!plugin.getConfig().getBoolean("isChunk")) {
                //Send your message
            } else {
                player.closeInventory();
                plugin.getConfig().set("isChunk", false);
                plugin.saveConfig();
                //send your message
            }
        }
    }

Use this and see if it works

hushed crescent
#

Is there a way I can make this work?

dense kestrel
#

no

hushed crescent
#

Wow no images

dense kestrel
#

lmao

hushed crescent
#
package com.synth.tns;

import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;

public class PlantSapling implements Listener {

    String[] saplings = {Material.OAK_SAPLING, Material.SPRUCE_SAPLING}

    @EventHandler
    public void onPlayerPlantSapling(BlockPlaceEvent event) {
        Block saplingPlaced = event.getBlockPlaced();

        if (saplingPlaced.getType() ==  saplings)
    }

}```
dense kestrel
#

you cant compare an material to a string array...

hushed crescent
#

Well, my bad. I barely know java and I am trying to make something in 2 days

dense kestrel
#

one sec

hushed crescent
#

How can I compare saplingPlaced to all of the sapling types?

rugged topaz
#

how do u check if player only has their inventory open?

dense kestrel
#

one sec, let me grab ya something

ivory sleet
#
Set<Material> materials = ImmutableSet.of(Material.DIAMOND, Material.DIRT);

//then

if (materials.contains(block.getType())) {

}```
dense kestrel
#

damn it, ya beat me to it XD

hushed crescent
#

Is that for me?

ivory sleet
#

ye

ivory sleet
hushed crescent
#

Oh, thank you!

#

Do I need to import import com.google.common.collect.ImmutableSet;

ivory sleet
#

yup

dense kestrel
ivory sleet
#

I think you could do smtng like getOpenInventory()

rugged topaz
#

getOpenInventory().getBottomInventory() == p.getInventory()

#

or no

dense kestrel
#

umm, that should work

#

just test it

rugged topaz
#

depends if it's nullable

#

sec

ivory sleet
#

probably shouldn't compare inventory api objects

rugged topaz
#

y

ivory sleet
#

they're just delegates to nms inventories essentially

#

when you compare with == you actually compare objects memory addresses

rugged topaz
#

heard about that

#

so what's the solution

dense kestrel
#

.equals

eternal night
#
if(Tag.SAPLINGS.isTagged(block.getType()) {
}
#

btw is probably the better solution for @hushed crescent

ivory sleet
#

Idk but from what I know bukkit api recreates new inventory api instances for events etc yanlol

quaint mantle
#

I get that when starting my server and plugin, can someone help me?

[15:09:25] [Server thread/INFO]: [PleromaMC] Enabling PleromaMC v0.3.2
[15:09:25] [Server thread/ERROR]: Error occurred while enabling PleromaMC v0.3.2 (Is it up to date?)
java.lang.NullPointerException: null
dense kestrel
#

umm

hushed crescent
#
public class PlantSapling implements Listener {

    Set<Material> materials = ImmutableSet.of(Material.OAK_SAPLING, Material.ACACIA_SAPLING, Material.JUNGLE_SAPLING, Material.DARK_OAK_SAPLING, Material.BIRCH_SAPLING, Material.BAMBOO_SAPLING);

    @EventHandler
    public void onPlayerPlantSapling(BlockPlaceEvent event) {
        Block saplingPlaced = event.getBlockPlaced();

        if (saplingPlaced.getType() ==  materials)
    }

}```
#

This did not work

ivory sleet
#

no

#

you use materials.contains(saplingPlaced.getType())

quaint mantle
# dense kestrel is there more

Yes:

[15:09:25] [Server thread/INFO]: [PleromaMC] Enabling PleromaMC v0.3.2
[15:09:25] [Server thread/ERROR]: Error occurred while enabling PleromaMC v0.3.2 (Is it up to date?)
java.lang.NullPointerException: null
    at com.kaonashi696.pleromamc.listeners.PlayerDeathListener.<init>(PlayerDeathListener.java:24) ~[?:?]
    at com.kaonashi696.pleromamc.PleromaMC.onEnable(PleromaMC.java:23) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:493) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:407) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
    at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:435) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
    at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:218) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
    at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:809) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
    at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
dense kestrel
#

PlayerDeathListener.java:24

#

send that

quaint mantle
#

What do you mean? @dense kestrel

dense kestrel
#

send that line

#

well

#

just send those lines from that class

#

the whole area around line 24

quaint mantle
#

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

dense kestrel
#

put a comment for the line that is 24

#

thats in the "PlayerDeathListener" class?

quaint mantle
#
package com.kaonashi696.pleromamc.listeners;

import java.io.IOException;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;

import com.kaonashi696.pleromamc.HTTPSPostRequest;
import com.kaonashi696.pleromamc.PleromaMC;

public class PlayerDeathListener implements Listener{
    
    PleromaMC core;

    public PlayerDeathListener(PleromaMC core) {
      this.core = core;
    }
    
    FileConfiguration config = core.getConfig();
    String post_url = config.getString("post_url") + "api/v1/statuses";

    @EventHandler
    public void onPlayerDeath(PlayerDeathEvent event) throws IOException {
        String deathMessage = event.getDeathMessage();
        List<ItemStack> drops = event.getDrops();
        String dropsMessage = StringUtils.join(drops, ", ");
        if (StringUtils.isBlank(deathMessage)) return;
        
        HTTPSPostRequest.sendPOST(core, post_url, "status=" + deathMessage + " and dropped " + dropsMessage);
    }
    

}
ivory sleet
#

well

dense kestrel
#

which is 24

ivory sleet
#

thats obvious npe

cinder thistle
#

you realise that later java versions have cool http apis right?

quaint mantle
ivory sleet
#

fields are initialized before constructors run

dense kestrel
#

oh

hollow sand
#

does anyone know where i can find out about scheduled tasks?

dense kestrel
#

XD

hollow sand
#

like a source

hollow sand
#

yep, i tried looking there. Its out dated

hollow sand
#

unless i can try again

#

thx for the help Conclure

quaint mantle
ivory sleet
#
// SOLUTION
MemorySection config;

public PlayerDeathListener(Core core) {
  config = core.getConfig();
}```

```java
Core core;
MemorySection config = core.getConfig(); 

public PlayerDeathListener(Core core) { //contructor
  this.core = core;
}```
Look at the latter. Both the variable core and config is initialized before the constructor runs. So it's effectively equivalent to:
```java
Core core;
MemorySection config = null.getConfig(); 

public PlayerDeathListener(Core core) { //contructor
  this.core = core;
}```
hushed crescent
dense kestrel
ivory sleet
#

^

dense kestrel
#

Random question, I wanna learn to use JSON configs anyone have anything good for it by any chance?

cinder thistle
#

GSON

#

Jackson

dense kestrel
#

ok, GSON XD

ivory sleet
#

Well I would recommend using configurate if you just wanna use JSON formatted configs. But yeah GSON is the way to go when working with JSON in Java.

dense kestrel
#

Yea, I mainly just want it for auto-updating configs

cinder thistle
#

a reminder that json was designed to store data in a compact manner

#

not to be readable

rugged topaz
ivory sleet
#

and btw all json is valid yaml

#

almost all

cinder thistle
#

what?!

#

that's crazy

ivory sleet
#

yeah

#

{
  "pog": 10,
  "notPog": "hi", #WITH COMMENTS
  "lol": [
    1,
    3
  ]
}```
hushed crescent
#

Ok, how do I create a leaderboard? Do I make a new class?

ivory sleet
#

what type of leaderboard

hushed crescent
#

The basic one that is on the right of your screen

#

Not the hologram one

ivory sleet
#

oh a sidebar scoreboard?

hushed crescent
#

Yes

ivory sleet
#

I mean you don't need a new class for it however I would strongly advocate it

hushed crescent
#

I want my plugin to add one point to the person on the leaderboard when they place a sapling, and minus one point when they destroy one

ivory sleet
#

sure

#

you probably want to create a new scoreboard

ivory sleet
rugged topaz
#

well e.getWhoClicked().getOpenInventory().getTopInventory().equals(e.getWhoClicked().getInventory()) is somehow always false (:

ivory sleet
#

yes as I said you cant compare

quaint mantle
rugged topaz
#

uh

rugged topaz
deft sedge
#

ok, i have a problem my code runs everytime aplayer takes something out of a crafting table, I am trying to stop the player from being able to take things out of the crafting table if they don't have a specific item. Here are my attempts to stop it, the event i'm listening to is inventory click event, and it checks if they click on the output slot of a crafting table, the problem is that if you shift click you can steal the item faster then my plugin can stop you. any ideas on how to fix? Here is code: (I know it's not very clean 😜 ) https://paste.md-5.net/vukonopewe.cs

ivory sleet
#

I personally use InventoryHolders but yeah people hate on them although they're perfect for tracking inventories tbf

young knoll
#

Nah, using the views is better

deft sedge
#

?

ivory sleet
young knoll
#

Yes

hushed crescent
#

So I made the scoreboard.

    
public void createBoard(Player player) {
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard board = manager.getNewScoreboard();
        Objective obj = board.registerNewObjective("Saplings", "", "Saplings Placed");
        obj.setDisplaySlot(DisplaySlot.SIDEBAR);
    }```
#

How Can I make it show the each users points

deft sedge
ivory sleet
#

uh no nrn I m checking inventor views

deft sedge
#

ok

#

Is there a simple function for delaying things?

ivory sleet
# young knoll Yes

May I ask how you even compare that? By storing it or am I just stupid now?

deft sedge
#

seems random but i think it could fix my problem

ivory sleet
deft sedge
young knoll
#

You can just store them in a hashset and use .contains

#

But I use a map so I can connect them to my custom inventory instances

eternal oxide
ivory sleet
#

hmm interesting coll

ivory sleet
quaint mantle
#

How can I convert this:

ItemStack{IRON_INGOT x 3}, ItemStack{IRON_SHOVEL x 1}, ItemStack{IRON_AXE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=131}}, ItemStack{IRON_SWORD x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=8}}, ItemStack{DIAMOND_PICKAXE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=164}}, ItemStack{IRON_SHOVEL x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=77}}, ItemStack{HONEYCOMB x 3}, ItemStack{TORCH x 58}, ItemStack{BAKED_POTATO x 40}, ItemStack{SHEARS x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=1}}, ItemStack{ROTTEN_FLESH x 3}, ItemStack{STICK x 6}, ItemStack{WHEAT x 7}, ItemStack{BIRCH_DOOR x 2}, ItemStack{CRAFTING_TABLE x 1}, ItemStack{IRON_BOOTS x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=10}}, ItemStack{IRON_LEGGINGS x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=10}}, ItemStack{IRON_CHESTPLATE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=10}}, ItemStack{IRON_HELMET x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=10}}
#

to something clean

ivory sleet
#

First probably split it

#

then parse every split string I guess

hushed crescent
quaint mantle
#

I would like something like:

3 IRON_INGOT, 1 IRON_SHOVEL, 1 IRON_AXE, etc etc
ivory sleet
#

oh

#

how do you handle meta then?

quaint mantle
#

I don't want meta jajaja

#

I just want a list of dropped items

deft sedge
#

the plugin,()

ivory sleet
#

but if you have a bunch of itemstacks (non tostringed) do smtng like:

List<ItemStack> list;

String items = list.stream()
    .map(it -> String.format("%d %s",it.getAmount(),it.getType()))
    .collect(Collectors.joining(", "));
#

tho it might be slow

quaint mantle
ivory sleet
#

AverageSam you plugin instance, which is your main class I believe you might have smtng like Main.getInstance() or else dependency injection

#

its negligible but String#format, could concat for faster speed and also avoid the stream and just use a raw for loop

quaint mantle
#

oh okay

#

i dont think that's a problem, it just runs when someone dye

ivory sleet
#

sure yeah its nothing remarkable but fyi

ivory sleet
#

yeah sure Main.getPlugin(Main.class)

#

works

deft sedge
#

ok

deft sedge
ivory sleet
#
Bukkit.getScheduler().runTaskLater(Main.getPlugin(Main.class), () -> {
  // delayed code
}, 20L * seconds);
deft sedge
#

OHHH ok

#

thanks

sharp bough
#
    chance: 1
    items:
        diamond_block:
            name:
                - "name of the diamond block"
            lore:
                - "the first lore"
                - "the second loe
                - "the third lore"
            enchantments:
                durability:
                    level:
                        - 10
                        
        emerlad_block:
            name:
                - "name of the emerlad block"
            lore:
                - "the first lore"
                - "the second loe
                - "the third lore"
            enchantments:
                durability:
                    level:
                        - 9
                        
        gold_block:
            name:
                - "name of the gold block"
            lore:
                - "the first lore"
                - "the second loe
                - "the third lore"
            enchantments:
                durability:
                    level:
                        - 15```
is it possible to get those items and their meta, and add it to a chest using inv.addItem
ivory sleet
#

yeah it is

sharp bough
#

how

#

i ahve no idea how to do it

ivory sleet
#

is that config.yml

#

?

sharp bough
#

yea

#

so far i have been using this

        Chest chest = (Chest) b.getState();
        Inventory inv = chest.getInventory();
        ItemStack one = new ItemStack(Material.DIAMOND);
        ItemMeta oneMeta = one.getItemMeta();
        oneMeta.setDisplayName("test diamond");
        oneMeta.addEnchant(Enchantment.DURABILITY, 1,true);
        one.setItemMeta(oneMeta);
        inv.addItem(one);

to add items

#

but idk how to addapt that to take items from the config

ivory sleet
#

I mean you would loop through the config keys so smtng like:

ConfigurationSection section = plugin.getConfig().getConfigurationSection("tier1.items");
for (String key : section.getKeys(false)) {
  Material material = Material.matchMaterial(key);
  String name = section.get(key+".name");
  List<String> lore = section.getStringList(key+".lore");
  //etc
}```
#

gtg

cinder thistle
#

I'd just get @waxen plinth to write me a parser

waxen plinth
#

Huh

#

Oh

cinder thistle
#

a challenge he cannot resist

waxen plinth
#

Looks like you're just printing out the ItemStacks

cinder thistle
#

that's what i thought lol

waxen plinth
#

My library already has methods to convert items to JSON and back

#

👀

eternal oxide
#

Yaml is simpler

#
    @EventHandler
    public void onQuit(PlayerQuitEvent event) {

        Player player = event.getPlayer();
        Map<Integer, ItemStack> inventory = new HashMap<>();

        ItemStack item;
        for (int slot = 0; slot < player.getInventory().getSize(); slot++) {
            item = player.getInventory().getItem(slot);
            if (item != null && item.getType() != Material.AIR)
                inventory.put(slot, item);
        }
        plugin.getConfig().set("vaults." + player.getUniqueId(), inventory);
        plugin.saveConfig();
        plugin.reloadConfig(); // reload so the Map is correctly converted to a MemorySection
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {

        Player player = event.getPlayer();
        String uuid = player.getUniqueId().toString();

        if (plugin.getConfig().isConfigurationSection("vaults." + uuid)) {
            MemorySection section = (MemorySection) plugin.getConfig().get("vaults." + uuid);

            player.getInventory().clear();
            for (String key: section.getKeys(false)) {
                player.getInventory().setItem(Integer.valueOf(key), section.getItemStack(key));
            }
        }
    }```
#

save and load an inventory

compact hedge
#

I have a short for color but I need a DyeColor, how?

compact haven
#

dont

#

use

hybrid spoke
compact haven
#

yaml for data like that

#

sadge

compact hedge
eternal night
#

mate just told you xD

#

DyeColor#getByDyeData(byte)

hybrid spoke
compact hedge
hybrid spoke
#

just wasn't sure about the method^^

compact hedge
#

thanks a lot

eternal night
#

just make sure to feel ashamed for using shorts for colour xD

eternal oxide
compact hedge
compact haven
#

you dont store entire player vaults in a yaml file

#

that looks like its all in one file as well

eternal oxide
#

And why not? make an arguments instead of just saying "don;t do it"

compact haven
#

ok ok lets say you have

#

20 players

#

each with 2 vaults

#

and they put all of their good stuff in there

#

then u load that all into memory

#

and you write the entire file every time it changes

eternal oxide
#

Bad example, the file is written on logout

#

however, still whats your downside you are trying to point out?

compact haven
#

a terrible idea lmao

#

well

#

its a good idea for your system

#

what if the server crashes

#

the items just

#

gone

ivory sleet
eternal oxide
#

If the server crashes there is just as much chance of the player.dat file being corrupted

eternal night
compact hedge
#

it worked to yeah idc

eternal night
#

lul

#

/pray that is isn't dropped in like 1.17

compact hedge
#

I wouldn't mind, it's 1.8.9

eternal night
#

oh

#

yikes

compact hedge
#

lol

hybrid spoke
ivory sleet
#

thought they use per file approach

sharp bough
quaint mantle
waxen plinth
#

You can serialize items to YAML

#

With bukkit config

waxen plinth
#
ItemStack item = new ItemStack(Material.GOLD_INGOT);
config.set("path.to.item", item);
item = config.getItemStack("path.to.item");```
sharp bough
#

yea but the item stack name can change

#

the idea is to be able to edit that config file

#

not set a premade Material.GOLD_INGOT

#

idk how many items there will be, or how many enchants or lore lines

waxen plinth
#

Yeah you can set it in config and it can be named

#

The name of an item can then be modified

sharp bough
#
        Chest chest = (Chest) b.getState();
        Inventory inv = chest.getInventory();
        ItemStack one = new ItemStack(Material.DIAMOND);
        Main.get().getConfig().set("items", one);
        one = Main.get().getConfig().getItemStack("items");
        ItemMeta oneMeta = one.getItemMeta();
        oneMeta.setDisplayName("test diamond");
        oneMeta.addEnchant(Enchantment.DURABILITY, 1,true);
        one.setItemMeta(oneMeta);
        inv.addItem(one);```
so i made this
waxen plinth
#

Why do you modify the item after setting it in config?

sharp bough
#

ah

#

but

#
        Chest chest = (Chest) b.getState();
        Inventory inv = chest.getInventory();
        ItemStack one = new ItemStack(Material.DIAMOND);
        Main.get().getConfig().set("items", one);
        one = Main.get().getConfig().getItemStack("items");
        inv.addItem(one);```
would this take all items and add them? or do i have to loop it?
lunar schooner
#

Hey there, does anyone know how I can easily save an entire folder from within the jar to the disk?

#

(with multiple subfolders)

eternal oxide
#

if you add the item to a list before adding it to the config you can use getList to retrieve them, then .toArray() will return an ItemStack[]

#

You can then add that array to your inventory

novel lodge
#

Does anybody know why this doesn't work? I want it to stop all block placements ```java
public class onblockplaced implements Listener {
@EventHandler
public void onBlockPlaced(BlockPlaceEvent event){

    if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
        event.setCancelled(true);
}

}

#
        getServer().getPluginManager().registerEvents(new onblockplaced(), this);
sharp bough
#

you are missing an { ?

novel lodge
#

no

eternal oxide
#

You didn;t register the listener

lunar schooner
#

Correct he isn't :"D an if (or any statement) which is only 1 statement can be without { }

eternal oxide
#

nope, ignore that

#

If all the code is as you showed there is no reason for it to not work

chrome beacon
#

That should work fine

lunar schooner
sharp bough
#

ah

#

thats interesting

lunar schooner
#

Yup, I tend to avoid it though for consistency

undone pebble
odd gulch
#

Try doing a few printouts and make sure it actually enters where you cancel the event.

undone pebble
#

Didnt see !=, whoops

novel lodge
#

I had it in multiple files for listeners for some reason so I just put them all into the sam efile

#

But now I have the issue of this, this is in the right file but still doesn't work

    @EventHandler
    public void PlayerJoinEvent(Player playerJoined, String joinMessage){
        playerJoined.getPlayer().setHealth(60);
    }```
Is this something to do with the player joining before the entity spawns?
eternal oxide
#

thast not a valid event

novel lodge
#

ok

#

Does PlayerRespawnEvent apply to a player joining?

odd gulch
#

The name of the method is mostly irrelevant. It does not make it a PlayerJoinEvent because you named it that. The parameter would be PlayerJoinEvent

eternal oxide
#

No, you just have teh whole definition wrong

novel lodge
#

Oh yeh I see now

#

👍

eternal oxide
#

myPlayerJoinEventAnyName(PlayerJoinEvent event)

compact haven
#

bukkit looks for methods annotated with EventHandler then uses reflection to determine what events they listen for based on the parameter, that needs to extend Event in one way or another

#

the method name, like elgar said, has nothig to do with it :)

lost depot
#

hi, how do you set the weather to clear? i thought it was world.setClearWeatherDuration(0); but that doesnt seem to work

#

i dont want to specify a forced duration of clear weather, i just want the duration to be natural

#

i do know there is setStorm(false) but does that work for rain as well?

odd gulch
#

Set the clear weather duration. The clear weather ticks determine whether or not the world will be allowed to rain or storm. If clear weather ticks are > 0, the world will not naturally do either until the duration has elapsed. This method is equivalent to calling /weather clear with a set amount of ticks.

#

So you would have to provide the duration of ticks you want the weather to be clear.

#

Otherwise you can set the gamerule on the world such that the weather will always be clear.

lost depot
#

so you're telling me what i want is impossible?

eternal night
#

I think the average duration is 6000 ticks

#

at least that is what the weather command defaults to

lost depot
#

oh rly, hmm

odd gulch
odd gulch
#

Didn't see that. Well then I suppose you could use the default duration as Lynx mentioned.

lost depot
eternal night
#

Eh probably not

lost depot
#

:/

eternal night
#

but I mean the value you set there forces the weather to some degree

#

so realistically you should be fine just setting storm and thunder off

#

and just waiting no ?

#
world.setThundering(false);
world.setStorm(false);
#

javadocs for both say it resets the worlds clear weather ticks

#

so I'd imagine it would just equal a storm ending

mortal hare
#

im impressed how much NMS code have been deobfuscated

lost depot
#

fair enough

chrome beacon
#

Well people have been modding the game for well over 10 years now

mortal hare
#

i've been working with NMS 24/7 for the past 2 weeks, and in some points its as flexible as craft API implementations

lost depot
#

awesome, isnt it?

dry beacon
pulsar schooner
#

Some people just have too much time on their hands

mortal hare
lost depot
#

yeah

#

either player or loc is null

#

what is plugin.player?

mortal hare
#

why wouldn't you pass Player object

#

in to the runnable constructor

#

instead

dry beacon
#

ah, I declared the player in main and didn't give it a value

lost depot
dry beacon
#

I'm a bit blindly following this tutorial, I'm still pretty new to java https://bukkit.fandom.com/wiki/Scheduler_Programming

BukkitWiki

This tutorial will guide you in using the scheduler provided by bukkit. It will allow you to defer the execution of code to a later time. This is not the same as registering a Listener, a block of code which is executed in response to an event in the game. Blocks of code may also be scheduled to be executed repeatedly at a fixed interval, with o...

eternal night
chrome beacon
#

At least we can use them as refrence

prime nimbus
#

Hey, I was wondering if I could make a plugin that resets the end every time a server restarts, I'll run the function every time the plugin starts but what do I put inside the function to reset the end

lost depot
#

🤷‍♂️

lost depot
mortal hare
lost depot
#

i am at least delighted to use them for reference

dry beacon
lost depot
#

^^^

prime nimbus
#

Yeah, but the plugin is loaded after the world files are, so it wouldn't generate a new one

eternal night
#

Yeah just get mojang to release their damned plugin api for java

dry beacon
#

if you rename the file while the server is running it will generate a new one on startup

eternal night
#

and ship some fun paper performance patches

mortal hare
#

i would use cron jobs because i would be too lazy

prime nimbus
#

I didn't know that existed, Tysm

mortal hare
#

but wait

#

there's an even easier solution

lost depot
#

good point, a plugin probably isnt even necessary

mortal hare
#

just use bash script to launch the minecraft server and delete with rm -f command

dry beacon
#

or just make a script ;-;

#

^^^

mortal hare
#

cron jobs are only for scheduled tasks

dry beacon
mortal hare
#

pass it in to the constructor

dry beacon
#
    @Override
    public void run(player) {
        Location loc = new Location(Bukkit.getWorld("world"), 120, 62, 342, 0, 0);
        player.teleport(loc);
        player.sendMessage(ChatColor.RED + "You have been teleported to the afk location.");
    }```
mortal hare
#

dependency injection

#

google it

dry beacon
#

ah

lost depot
#

specifically constructor injection

mortal hare
#

that way you could reuse the runnable

lost depot
#

that is a pretty basic OOP concept though, i recommend you spend some time learning those kind of concepts

dry beacon
#

right, I'm using player from the Main class, it points to null though because I declared player public Player player; my actualy player is in the OnCommand function, how can I reuse the variable then?

prime nimbus
dry beacon
#

my bad, the null might have been in the loc which I did not declare...

mortal hare
smoky finch
#

Is BlockDamageEvent simply for when players are breaking a block (like a spamy event) or something else?

digital plinth
#

so umm

#

can i make the server console type something in chat?

#

dispatchcommand type stuff as a command

#

and i dont ant that

digital plinth
#

is that a new event?

digital plinth
#

mine*

dusky lynx
#

can i make the server console type something in chat?
@digital plinth I think “say” is a default command to send messages to in game chat from the console

dry beacon
digital plinth
#

so what im trying to do is

#

automate world creation by mv

#

mvinv

#

so i do

#

/mvinv group

#

then i need to type "create"

#

as a word and NOT a command

lost matrix
#

Use the mutliverse api

digital plinth
digital plinth
#

oh right

#

console can only perform commands

lost matrix
#

I mean. Yours is just hacky

digital plinth
quaint mantle
#

"Startup script './start.sh' does not exist! Stopping server." - Any help? I have been trying to solve this for 3 days

sleek pond
quaint mantle
#

define the start file in the spigot.yml

smoky finch
#

Is there like some kind of built-in method for detecting if a block/material can be affected by gravity?

sleek pond
sleek pond
quaint mantle
smoky finch
hushed crescent
#

Ok, so my database is a yml file. Is there any way to extract the lines to a minecraft leaderboard?

#

Jesus christ wtf

lost matrix
#

Fk my ears. Can someone pls warn or temp ban this guy?

severe zenith
#

Is it possible to get the Bukkit Player from a ProxiedPlayer (bungeecord)

lost matrix
quaint mantle
#

@worldly ingot

digital plinth
#

how am i supposed to know which im using

#

:<

lost matrix
lost matrix
digital plinth
#

:/

#

so im using the third one

#

manual?

lost matrix
#

Yes

severe zenith
lost matrix
lost matrix
# hushed crescent .

Sure. But a yml file is not a database. You can just read the File using the FileConfiguration api from spigot.

hushed crescent
#

I know it's not a database. Just like json in javascript is not a database

#

I just need an easy way to put players points in

severe zenith
#

thanks

lost matrix
# hushed crescent I just need an easy way to put players points in

In you yml file? Use the FileConfiguration API from spigot. Or use Gson to create json files. If the data has a simple structure like Map<UUID, Integer> then
you can just pass the whole instance to Gson and get it later back when you need to load it again. Ill give you an example.

hushed crescent
#

I am new to java

novel lodge
#

How can I get the list of tags for a player?

hushed crescent
lost matrix
# hushed crescent I am new to java

Then you probably shouldnt be writing spigot plugins. You need to at least understand the basics of Java before jumping into spigot.
There are some concepts in Spigot that will just confuse you for months without you getting anything done if you dont know a bit of Java.
So you should at least learn to the point of where you understand
What a method is
What a constructor is
What an instance is
What the differences between scopes are
What static means and why it should be used sparcely

worldly ingot
#

?kick @lunar wigeon We don't do that here

queen dragonBOT
#

👢 Kicked zitreF#4365

worldly ingot
#

ngl I was expecting a monkey dick or something lol

hushed crescent
#

lmfao

lost matrix
#

XD

lost matrix
novel lodge
#

Yes

lost matrix
#

Player#getScoreboardTags() -> Set<String>

#

Is mutable btw. So can also be used to add/remove tags

worldly ingot
#

It's mutable? o.O

lost matrix
#

The field is not but the set itself

worldly ingot
#

I have a feeling it's not because there's addScoreboardTag() and removeScoreboardTag()

quaint mantle
#

how do i create a startup script I have been having this problem for 3 days

worldly ingot
#

Probably returns a clone

mortal hare
worldly ingot
#

Oh, it is mutable

#

That's strange o.O

hushed crescent
#

How can I get the username of the player who placed an item

lost matrix
#

just returns the ay set...

worldly ingot
#

Yeah but it really should not be mutable given that there's no size check on it

#

addScoreboardTag() does check

lost matrix
#

Never noticed lol

worldly ingot
#

I mean changing it now would probably break a plugin or two so it's not really worth changing tbh. 1024 tags is a hard limit to hit lol

lost matrix
#

But changing it now might break some plugins

worldly ingot
#

ye

#

I would use the add/remove equivalents though if you plan on doing so

#

Unless the docs explicitly state that a collection is mutable, you should assume it's not

lost matrix
#

Or a new Set implementation with internal size checks on add/remove XD

worldly ingot
#

lol right

woeful moon
#

Does anyone know how to send to discord webhooks in your plugin? I couldn't find any guides or tutorials online

worldly ingot
#

It's just a regular ole HashSet tho

#

Discord's API has that documented. It's just a web request with a bot auth token

mortal hare
worldly ingot
lost matrix
#

The field is a Set so returning a wrapper that implements Set for it wont hurt

#

I might add that.

worldly ingot
#

Oh you mean to change its implementation? Meh. It's honestly not worth it

mortal hare
worldly ingot
#

Again, 1024 is a hard limit to hit

#

lol

lost matrix
#

Yeah

woeful moon
quaint mantle
worldly ingot
#

Discord's docs should cover most of what you need