#help-development

1 messages · Page 1742 of 1

warped sage
#

just use #getUniqueId()

#

then shove it into the hashmap

ancient plank
#

I'm gonna distastefully drop the command in a moment

shadow tide
#

if I know what ur talking about, I hate it aswell

warped sage
#

what?

glossy venture
#

getUniqueId

#

should exist

shadow tide
#

what Spigot API version are you using

iron palm
glossy venture
#

otherwise cast it to Player as its a player anyways, like this

((Player)damager).getUniqueId();

// or (i recommend this if ur going to use it later)
Player damagerPlayer = (Player) damager;
damagerPlayer.getUniqueId();
glossy venture
#

you need to cast it

#

for the compiler to know

iron palm
warped sage
#

You can

glossy venture
#

you are literally checking if the entity is a player

warped sage
#

you just did an instanceof check

quaint mantle
#

hey if I want to log a command and it's arguments (most specifically /msg and it's content) would I use PlayerCommandPreprocessEvent?

quaint mantle
#

great thanks :D

glossy venture
#

@iron palm you should be able to get the UUID for any entity

#

just use damager.getUniqueId()

quaint mantle
# young knoll yes

i saw it mentioned that it should be avoided as much as possible, is there any examples of best practice while using it?

shadow tide
#

can someone please help with my question here ^

quaint mantle
#

how is vault API outdated

glossy venture
#

or are you using an old version

#

or something

#

idk

young knoll
#
 Many plugins will have no use for this event, and you should attempt to avoid using it if it is not necessary.

Some examples of valid uses for this event are:

    Logging executed commands to a separate file
    Variable substitution. For example, replacing ${nearbyPlayer} with the name of the nearest other player, or simulating the @a and @p decorators used by Command Blocks in plugins that do not handle it.
    Conditionally blocking commands belonging to other plugins. For example, blocking the use of the /home command in a combat arena.
    Per-sender command aliases. For example, after a player runs the command /calias cr gamemode creative, the next time they run /cr, it gets replaced into /gamemode creative. (Global command aliases should be done by registering the alias.) 

Examples of incorrect uses are:

    Using this event to run command logic 
iron palm
shadow tide
glossy venture
#

then damager.getUniqueId() should work

shadow tide
#

I don't want to use the vault API anyways

quaint mantle
#

and why don't you want to use it?

#

it'll make your life 100x easier

iron palm
glossy venture
#

restore?

shadow tide
#

ok, then give me the dependency and repository

quaint mantle
#

1 sec

iron palm
#

I mean getting it in Player death event again

quaint mantle
#

lemme open my project

glossy venture
#

we need to create threads rq

shadow tide
#

I'm doing 1.17.1

quaint mantle
#

alright perfect

#

VM is loading give me a second

glossy venture
#

Gameisntover help

quaint mantle
#

wait wrong thing

#

LMAO

shadow tide
#

thats, the, uhh, spigot API

quaint mantle
#
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>```
shadow tide
#

k

quaint mantle
#
        <dependency>
            <groupId>com.github.MilkBowl</groupId>
            <artifactId>VaultAPI</artifactId>
            <version>1.7</version>
            <scope>provided</scope>
        </dependency>```
shadow tide
#

thanks

#

didn't seem to bug out this time

glossy venture
#

?paste

undone axleBOT
quaint mantle
#

no worries :D

#

have fun

quaint mantle
shadow tide
#

?

#

wdym

#

how do I use the Vault API anyways

quaint mantle
#

put this in your plugins folder

#

for info on how to use the API

shadow tide
#

thanks 4 everything

clear blade
#

hey so, i see there are various logging levels that you can choose to log to (info, fine, etc), so if I wanted to access fine+ levels, how would i do that?

young knoll
#

What do you mean access

next stratus
young knoll
#

Did you shade bstats

#

And relocate it properly

next stratus
#

I did not, I added a metrics class in directly.

young knoll
#

Well it seems it cannot be found at runtime

#

Check the exported jar to ensure it's there

next stratus
#

the class is in there

#

I added the class file directly from the example code

young knoll
#

me/untouchedodin0/privatemines/util/Metrics$CustomChart

#

You have the custom chart class too?

#

As a nested class

next stratus
#

I don't know, I'll check

#

i do

#

I think I've fixed it by using the metrics class directly and not shading it in

clear blade
clear blade
#

ah. thank you o7

lilac valve
#

does anyone know how to get the namespacedkey for existing structures with the new api? I'm trying to use it to create a bastion in the overworld but am a bit confused on its functionality

I had tried using StructureType.getName() but that seems to return null when using loadstructure

pulsar kestrel
#

What would the best way be to make an entity "stick" to a player so that they have the same position at all times? I tried using a scheduler for this and while it did make the entity follow the player, it only updated the position every second or so which looks really ugly

lost matrix
pulsar kestrel
young knoll
#

Packets could work if you want to go that route

pulsar kestrel
karmic bear
#

anyone here has used redis in their cache layer?

drowsy helm
#

yep

karmic bear
# drowsy helm yep

Can you please help me, I am trying to figure out how to go about it
So I am working with mariadb and redis, and from what I can tell
redis is where I should be making my read/writes/sets/gets but at what rate should I apply those changes to mariadb?

#

or like, the frequency at which i apply those changes in mariadb

#

since they are so often

drowsy helm
#

So the way i usually go about doing it is read/writing directly to mongo and then saving that data in 5-10min intervals (depending on how important the data is) to the actual db

#

and in those intervals i usually push all data to db, flush all data from redis, and then pull data when needed again

#

just ensures you don't have too much useless data floating around in redis

warped sage
#

how performant is the BukkitScheduler#runTaskTimer/BukkitScheduler#scheduleSyncRepeatingTask? I need to do something for every player every 5 minutes basically, is it better to create 1 repeating task every minute and check all players, or is it performant enough that I can create a separate interval per player?

drowsy helm
#

i would go the first route, better using 1 repeating task than potentially 100

worldly ingot
#

lol, fun story. Former developer on our server decided it was a good idea to spawn 200+ tasks just to summon particles. An async task for every single particle spawn

#

This is invoked every time the particle goes off by the way, which is on a custom enchantment

paper geode
#

i see no issue

#

its async so its good, right?

#

kek

worldly ingot
#

5Head yep

paper geode
#

i love how every p2w ultra-smart gigahacker kid complains about multithreading

#

boo-hoo my anarchy server with atleast 600 active lag machines isnt working well

worldly ingot
#

Also, yes, it's in JavaScript. Trust me, I hate it too

paper geode
#

i LOVE it

#

if only it was written with python

#

would be even better

worldly ingot
quaint mantle
#
def display_arrow_trail(loc: Location) -> None:
    for i in range(100):
        play_effect(calc_random_offest_3d(loc, 0.15), Particle.CRIT_MAGIC, 0, 1)

# etc...

class Timer(BukkitRunnable):
    def __init__(self, event: ProjectileLaunchEvent) -> None:
        self.event = event


    def timer(self) -> None:
        if self.event.is_cancelled or self.event.entity.is_on_ground():
            self.cancel()
            return

        # etc...

        display_arrow_trail(trail_location)

        self.ticks_ran += 1

        if self.ticks_ran > 10 * 20:
            self.cancel()

timer = Timer(event)
trail_task = bukkit.runSyncTimer(timer, 0, 1)
paper geode
#

no

#

i'd say no

young knoll
#

Repeating task? Never heard of it

pulsar kestrel
worldly ingot
#

I despise the fact that Python forces you to write in self into your method arguments

#

Do like any sane languages does and imply that stitchFrustrated

quaint mantle
#

a bad attempt at backwards compatibility

#

python 2.7 extending object

#

it should just be a keyword

worldly ingot
#

iirc,

public void myMethod(TypeOfThis this, String hello) {
    
}```
is valid Java
#

but we just imply that this argument because again, most languages are sane pepecringe

ancient plank
worldly ingot
#

Author of that code coincidentally sells a server fork targeting performance improvements btw

ancient plank
#

he came to me like "why isn't this working", the whole system was jank, and I spent like an hour fixing it up ThumbsUpSmile

formal dome
#

so relatively general question here. but my plugin, once connected to a minecraft instance, also needs to connect to a non-minecraft server i'm hosting in a shell on my own computer. what libs or functions would connect?

#

sockets? would i have to implement spring within my plugin?

fading lake
worldly ingot
#

5Head honestly hoping I figured that out without pasting it into my editor

#

Good puzzle though. I like that class

#

IDE confirms that I'm correct as well. PES_Hypers

sullen marlin
#

sorry what

formal dome
sullen marlin
#

This This(This this) {

#

how is that valid?

#

aren't keywords keywords no matter the scope

worldly ingot
#

It's a method with no access modifier called This that returns This, with the implicit type this

#

It's equivalent to public This This()

#

this is a keyword, This is not 🙂

sullen marlin
#

there's a lowercase this there

worldly ingot
#

That's the implicit parameter. Every method has that implicitly

sullen marlin
#

pls cite jls

worldly ingot
#

I believe it's officially named "the receiver parameter"?

#

Ye

sullen marlin
#

yeah

#

that's stupid

worldly ingot
#

It's akin to Python's self

sullen marlin
#

netbeans doesnt even autoformat it correctly

worldly ingot
#

My IDE gets a little confused about object highlighting when it's around as well lol

worldly ingot
#

Probably for annotation stuffs

sullen marlin
#

yeah not in 7

worldly ingot
#

Ah that's precisely why they did it. Annotations. Not sure why you'd ever want to annotate the implicit parameter but you can!

sullen marlin
#

there's probably 3 people in the world that use type annotations

quaint mantle
#

annotations = reflection daddies

young knoll
#

I've recently used annotations to automatically register stuff

#

Much nicer than having to remember to do it for each new class I make

formal dome
#

Spring uses too many annotations.

young knoll
#

Is it more than heretere

wild marten
stone sinew
wild marten
#

yea ik that, i usually just change my artifact build path but I am shading so I cant do that

#

is there a way around the blocker?

rancid pine
#

how can i make a sky world with only air

quaint mantle
young knoll
#

Or copy the output jar with maven/gradle

verbal nebula
#

Hi, I am trying to make a command but it just keeps on giving me this error:

worldly ingot
#

GUI.CommandGames isn't a valid name for a class

verbal nebula
#

oh

worldly ingot
#

Just CommandGames would suffice

verbal nebula
worldly ingot
#

You've probably changed the name in your .java file but not of the .java file itself

#

Or you're going some really... strange... access?

verbal nebula
#

No

quaint mantle
#

Showing code is helpful too

#

People usually debug issues with errors and code

verbal nebula
#
    public class CommandGames implements CommandExecutor {
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (sender instanceof Player) {
                Player player = (Player) sender;
                openNewGui(player.getPlayer());
            }

            return true;
        }
    }
worldly ingot
#

Also, hi Borlea, I feel like long time no see your name around

verbal nebula
#

This is the code that is the executing the command

    public class CommandGames implements CommandExecutor {
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (sender instanceof Player) {
                Player player = (Player) sender;
                openNewGui(player.getPlayer());
            }

            return true;
        }
    }

This is the code that is trying to access it

package me.Elyas207;

import org.bukkit.command.CommandExecutor;
import org.bukkit.plugin.java.JavaPlugin;
public final class GUIMaker extends JavaPlugin{
    public void onEnable() {
        getServer().getPluginManager().registerEvents(new GUI(), this);
        this.getCommand("Games").setExecutor(new CommandGames());

    }
worldly ingot
#

Asking because of the indentation. Is your code structured like this in a single file?

public final class GUIMaker extends JavaPlugin {

    public void onEnable() {
        getServer().getPluginManager().registerEvents(new GUI(), this);
        this.getCommand("Games").setExecutor(new CommandGames());
    }

    // etc.

    public class CommandGames implements CommandExecutor {
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (sender instanceof Player) {
                Player player = (Player) sender;
                openNewGui(player.getPlayer());
            }

            return true;
        }
    }
}```
verbal nebula
#

no

#

two different files

worldly ingot
#

Or are they in separate files/packages? If they're in separate packages, there's no import

#

If in the same package, disregard

verbal nebula
#

They are in the same package

worldly ingot
#

Well those two files look fine. Though your most recent error indicated that there was something wrong in the GUI class

#

?paste it if it's too long:

undone axleBOT
verbal nebula
worldly ingot
#

Ah

#

Two options:

  1. Move your CommandGames class into its own file outside of GUI (preferred)
  2. Make CommandGames a static class, though that may come with other implications
#

At the moment however you have no way of creating more than one instance of your gui so if more than one person wants to open the GUI at once you're going to have some issues

verbal nebula
#

oh ok

primal wave
quaint mantle
last ledge
#
            if(args.length < 3 || args.length > 5){
                sender.sendMessage(ChatColor.GOLD + "/spawnboss [worldname] [Location]");
            }
            Bukkit.getServer().getWorld(args[0]);```
#

lmao will this work?

sullen marlin
#

well you probably want a return after the sendMessage

#

and you probably want to do something with the result of getWorld

last ledge
#

ye

#

will this work?

acoustic widget
#

Hello on gradle I run my server using a task (after plugin compilation) with

    mainClass = "org.bukkit.craftbukkit.Main"
    workingDir = "server/"
    standardInput = System.in
}```

But i have to add in dependencies
> compileOnly 'org.bukkit:craftbukkit:1.17-R0.1-SNAPSHOT'

Can I use spigot-api main class instead ?
sullen marlin
#

org.spigotmc:spigot is probably what you want?

#

and idk enough gradle to tell you if its possible to put a dependency only for an exec task

acoustic widget
#

||oh it's the real md5 😮 ||
Thanks I'll try, I'm new at java development

last ledge
#

i just want when player type the command /spawnboss [worldname] [location]. I can get the worldname/cords and use it

sullen marlin
#

well your code does that

#

see my comments above

pine island
#

is there a listener built in Essentials that checks if the /eco command was successful?
need that for a plugin that trades lives & depends on Essx's Eco

pastel stag
#

do plugins get bumped when updates are pushed or anything like that on spigot resources?

pine island
last ledge
#

EconomyResponse response = economy.depositPlayer(player, 5000000);

#

this is a example

#

this video has all those explained:

pine island
#

ok ty! i was looking for a documentation for Essx!

last ledge
#

ah someone help me dude

#

i am trying to get world name from players entered command

#

like /spawnboss [worldname] [location]

#

this will work?

pine island
#

getMessage?

last ledge
#

String world = args[0];

pine island
fading lake
#

Should work theoretically

last ledge
#

just realised something is wrong in my code

#

now i stored world name as String world = args[0];
now i want to spawn one mob in that world how do i use that world name?

fading lake
#

World world = Bukkit.getWorld(name);

#

then like normal

last ledge
#

World world = Bukkit.getWorld(world);

#

this should work?

fading lake
#

yes

last ledge
#
            World world = Bukkit.getWorld(world);```
error: Variable 'world' is already defined in the scope
error: Variable 'world' might not have been initialized
fading lake
#

you need to change one of the variable names

last ledge
#

k then

#
            World world = Bukkit.getWorld(worldname);```
#

now how do i get location from commmand like x, y, z postion

quaint mantle
#

you are trying to set spawn or something like that right?

last ledge
#

no i want so spawn a mob

#

first i am getting world name

#

then the x, y , z location

#

to spawn the mob

quaint mantle
#

i have an example code for u and it is way easier for set spawn
but you can just modify the code a little bit for it to work

#

as what u want

last ledge
#

ok send me

quaint mantle
last ledge
#

bruh

quaint mantle
#
    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
        if (sender instanceof Player p) {
            if (p.hasPermission("risingcore.spawnsystem")) {
                if (args.length == 1) {
                    String locationName = args[0];
                    if (!locations.getConfig().contains("Locations-Data." + locationName)) {
                        locations.getConfig().set("Locations-Data." + locationName, p.getLocation());
                        locations.save();
                        language.setSpawn(p);
                        return true;
                    }
                    language.alrName(p);
                    return true;
                }
                language.noArgs(p);
                return true;
            }
            language.noPerm(p);
            return true;
        }
        language.playerOnly(sender);
        return true;
    }```
#

wait

#

wait

#

maybe it is kinda uhhh

#

bruh

last ledge
#

bruh

quaint mantle
#

bruh...

#

oh ok...

#

it should be like this if u want to spawn a mob in p location

#

wait a bit

last ledge
#

k

quaint mantle
#

spawn different mobs right?

#

or only 1 mob

last ledge
#

i have custom made mob

#

i will spawn that

#

i will be using its metadata to spawn

#

so its easy

quaint mantle
#

so

#

u already have a mob.

last ledge
#

ye

quaint mantle
#

do u needs any args for the plugin or only the cmd and it will spawn it anyway?

pine island
#

gave it the repo & still getting th error

last ledge
#

ye /spawnmob [worldname] [location]

#

2 args

quaint mantle
last ledge
#

x, y, z

#

position

quaint mantle
#

only 1 args is needed lol

#

and spawn on specific location not player standing location?

last ledge
#

noo like i said /spawnmob worldname 567, 10, 789

#

like this

quaint mantle
#

hmmm

last ledge
#

whatever the user inputs in args[2] will be x location

#

args[3] y location

#

args[4] z location

#

ig

quaint mantle
#

ok

fading lake
#

also what repo are you using

quaint mantle
#

uhhh @last ledge i will only check if the lengths of the args is 4 (4 args), if u want more specific check for the lengths the feel free

hollow dew
#

Hey, I have a question related to writing code that is supported through multiple Java Versions.

Basically, I used Java 8 for compiling all versions prior to 1.17, at that point they switched over to Java 16. I already have my maven project setup to support all versions using different modules for each version, however I am running into one problem. Essentially, I made an Abstract Class that every single version class extends, at that point I have one singular class that will detect the version your server is running on and makes sure to select the correct version.

Example:

    private AbstractNBTItem abstractNBTItem;

    public NBTItem(ItemStack itemStack) {
        super(null, null);
        String version = Version.getVersion();
        switch (version) {
            case "v1_7_R4":
                abstractNBTItem = new AbstractNBTItem_1_7_R4(itemStack);
                break;
            case "1_8_R3":
                abstractNBTItem = new AbstractNBTItem_1_8_R3(itemStack);
                break;
            case "v1_9_R2":
                abstractNBTItem = new AbstractNBTItem_1_9_R2(itemStack);
                break;
            case "v1_10_R1":
                abstractNBTItem = new AbstractNBTItem_1_10_R1(itemStack);
                break;
            case "v1_17_R1":
                abstractNBTItem = new AbstractNBTItem_1_17_R1(itemStack);
                break;
            default:
                throw new UnsupportedOperationException("This version is not supported");

The issue comes in with the AbstractNBTItem_1_17_R1.class being compiled in Java 16, with the other classes being compiled in Java 8. This leads to the entire class being compiled in Java 16 and therefor unusable in a Java 8 environment. For a temporary fix I went ahead and used reflection for 1.17, I was just wondering if anyone knew a better way.

pine island
pine island
#

even tho the repo is added still the dependency shows red underline

#

anyhelp?

karmic mural
#

hover over it, what does it say

pine island
#

w8

karmic mural
#

Did you restart IntelliJ

pine island
#

i did that rn

#

its loading

#

bad pc you know

karmic mural
#

No worries

pine island
#

it is.......Gone why does it do that?

#

so weird

karmic mural
#

Well, things are weird

quaint mantle
karmic mural
#

Basically, restarting intellij will fix your mistakes for you... but not really but also kinda

karmic mural
#

Works for me, even if it doesn't do anything it gives me a few seconds to stop being smooth-brain

quaint mantle
#

You can just reload the pom.xml file manually. When editing the pom.xml it would show an icon

#

reload pom.xml

#

so it can take changes and download every vault file needed

iron palm
#

Hi im using intelij for developing plugins
my plugin version is for 1.17
but i also wanna compile it for 1.16.5
how can i do that?
(i have java 16 and 1.8 both)

pine island
#

use Java 16 all versions > 1.17 use java things should remain same for the most part!

#

@iron palm

iron palm
pine island
#

yes hopefully

iron palm
#

sounds good thanks

pine island
#

np!

iron palm
# pine island np!

so i gone to afk then i reloaded the server but
server wasnt detecting my plugin still...

fading lake
#

like plugin.yml load failure

iron palm
#

oh well

fading lake
#

It'll be towards the top

iron palm
#

i think i know why it wasnt detecting

#

my api version was still 1.17

fading lake
#

that could be why

iron palm
#

yee

#

cant i make it multiversion support?

fading lake
#

You could, idk how though

last ledge
native bolt
#
version: 1.3
main: de.sabbelsocke.projekt1.main.Main

commands:
   heal:
      description: Dieser Command heilt dich.
   dead:
      description: Probiers mal aus.
   kit:
      description: Kit Inventar.
   setspawn:
      description: Setze den Spawnpunkt.
   spawn:
      description: TP dich zum Spawn.
   partystart:
      description: Starte eine Party auf der Bühne.```
Hi can someone say me whats wrong with this plugin.yml?
restive tangle
#

you need an api-version

native bolt
#

1.16.5

fading lake
#

then @restive tangle is correct

last ledge
outer crane
#

Am I doing this correctly? I'm giving a player a glowing effect for one second, but it doesn't show up on the player.

                ((Player) entity).addPotionEffect(
                        new PotionEffect(PotionEffectType.GLOWING, 1, 1, false, true, true)
                );
``` if i type ```bash
/effect give <player> minecraft:glowing 1 1 true
``` it works just fine
javadocs regarding this: https://papermc.io/javadocs/paper/1.17/org/bukkit/potion/PotionEffect.html
outer crane
last ledge
#

it was working all fine

#

until someone changed something, which i dont know

outer crane
#

roteSpMeta.displayName(Component.text(ChatColor.translateAlternateColorCodes('&', "&cRotes &7Splitter"))); wtf did you do here

eternal night
#

something not good

outer crane
#

just use the proper formatting for components

last ledge
outer crane
#

read some docs on components before using them

#

anyway

#

are you using intellij?

last ledge
#

yes

outer crane
#

set a breakpoint on the events that you think arent being triggered and run the server in debug mode

iron palm
#

hey there im getting a few errors for this code:

           Killstreak.get(damager.getName())  ,Killstreak.put(damager.getName() + 1);

'put(java.lang.String, java.lang.Integer)' in 'java.util.Map' cannot be applied to '(java.lang.String)'
damaer is my entity and Killstreak is the hashmap
Map<String,Integer> Killstreak = new HashMap<>();

outer crane
#

read some javadocs

#

actually, just learn java first

misty current
#

You don't even use conventions

#

Learn java

outer crane
ivory sleet
#

LegacyComponentSerializer.legacySection().serialize(str) should work assuming you don’t want to use the verbose appending of components

misty current
#

Actually thats not even the worst part

outer crane
ivory sleet
#

Idk I don’t use paper

misty current
#

Im pretty sure the numbers are in ticks for spigot/paper

#

Put a 20

outer crane
#

oh

#

alright

#

got too used to velocity api lol

#

thanks

misty current
#

Since i dont think 1 tick of glowing even renders

#

Np

last ledge
outer crane
#

wym

#

was that the issue?

last ledge
#

yes

#

i fixed that

#

and everything started working back as normal

outer crane
#

alright

quaint mantle
#

do not trust me then

latent dove
#

ducks

quaint mantle
#

🦆

last ledge
#
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
        if (sender instanceof Player p) {
            if (p.hasPermission("Ur perm here!1!!!!1!!1!!1!!!!")) {
                if (args.length == 4) {
                    Bukkit.getWorld(args[0]).spawnEntity(new Location(Bukkit.getWorld(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])),  EntityType.SKELETON));
                }
                language.noArgs(p);
                return true;
            }
            language.noPerm(p);
            return true;
        }
        language.playerOnly(sender);
        return true;
    }```
#

@quaint mantle error in language

#

cannot resolve symbol

eternal night
#

ur entity 👀

quaint mantle
last ledge
# quaint mantle remove one `)` after the skeleton entity type
    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
        if (sender instanceof Player p) {
            if (p.hasPermission("Ur perm here!1!!!!1!!1!!1!!!!")) {
                if (args.length == 4) {
                    Bukkit.getWorld(args[0]).spawnEntity(new Location(Bukkit.getWorld(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), EntityType.SKELETON).Metadata("SkeletonKing");
                }
                language.noArgs(p);
                return true;
            }
            language.noPerm(p);
            return true;
        }
        language.playerOnly(sender);
        return true;
    }
}```
quaint mantle
#

wait

#

did you change the language LOL?

#

the language is my class

#

so just replace it with ur message

fading lake
iron palm
#

thats maybe because why i cant understand hashmaps

fading lake
#

you're currently doing this: Killstreak.put(String) when it wants Killstreak.put(String, Integer)

#

you're adding 1 to a string here Killstreak.put(damager.getName() + 1)

fading lake
#

you need

Killstreak.put(damager.getName(), Killstreak.getOrDefault(damager.getName(), 0) + 1);
#

getOrDefault just sets the returned value to 0 if its null

barren nacelle
#

?paste

undone axleBOT
karmic mural
#

I must be mentally challenged... java.lang.IllegalArgumentException: The embedded resource 'config.yml' cannot be found in plugins\pluginname.jar

#

I figured it out

#

I am mentally challenged indeed. Thank you 🙃

fading lake
#

someone break something so I can help

#

im like really bored

#

either this or go to a maths study session for stuff I already know cause I got nothing to do

last ledge
#

i want to spawn Skeleton with meta data "SkeletonKing"
This is my current code, but doesnt spawn skeleton with the meta data, how do i do it
Bukkit.getWorld(args[0]).spawnEntity(new Location(Bukkit.getWorld(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), EntityType.SKELETON).getMetadata("SkeletonKing");

vague oracle
#

Ok there is a lot wrong with that

#

many opportunities for NPE

#

and NumberFormatExeptions

#

then you are also getting the metadata and not setting it

fierce jolt
#

Okay I need some help wrapping my head around this

fading lake
#

is AsyncPlayerChatEvent deprecated in newer versions?

fierce jolt
#

Everyone understands try {} catch{}. But was does finally exactly do? It's mentioned that it always executes. But isn't this true for code AFTER a try catch too?

vague oracle
#

just a suggestion though

iron palm
fierce jolt
lavish hemlock
#

since when has Map::merge existed??

acoustic widget
#

How do you test your plugin in development ? Do you have something mechanical for test faster your plugin ?

ivory sleet
#

MockBukkit

vague oracle
lavish hemlock
#

well what's it do?

ivory sleet
#

Yeah that higher order function has been there for quite a while

#

It takes the second param and and the already existing value, applying it with the binary operator to yield a new value which gets stored into the map

#

iirc

last ledge
acoustic widget
young knoll
#

Show the full error

vague oracle
#

It tells you the errors

young knoll
#

Caused by: java.lang.IllegalArgumentException: No enum constant org.bukkit.Sound.ANVIL_LAND

vague oracle
#

can't have health above 300

young knoll
#

Can’t have health above maxHealth, specifically

#

What

vital void
#

Anyone need help in here?

last ledge
#

I have a mob Skeleton with meta data "Skeleton King", and made a command to spawn it but its not working
Bukkit.getWorld(args[0]).spawnEntity(new Location(Bukkit.getWorld(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), EntityType.SKELETON).getMetadata("SkeletonKing");
The skeleton spawns but
but the normal one
i want to spawn the skeleton with its metadata

young knoll
#

You are using getMetadata

#

Not setMetadata

vital void
#

^

last ledge
#

error: 'setMetadata(java.lang.@org.jetbrains.annotations.NotNull String, org.bukkit.metadata.@org.jetbrains.annotations.NotNull MetadataValue)' in 'org.bukkit.metadata.Metadatable' cannot be applied to '(java.lang.String)'

code: Bukkit.getWorld(args[0]).spawnEntity(new Location(Bukkit.getWorld(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), EntityType.SKELETON).setMetadata("SkeletonKing");

young knoll
#

It does tell you, you have the parameters wrong

#

It takes a string and a metadata instance

native bolt
#

hi how can i check the permission of a player? with if(player.hasPermission("Projekt1.Kit")) { and he has the permissions it doesnt work

fading lake
#

If its not working they don't have the permission

hollow spindle
#

Is it possible to resolve an Entity type to a Player type?

eternal oxide
#

use lowercase in permissions. Some plugins will ignore case

native bolt
#

ohh okay

#

i have to edit it in the plugin and the perms or only in the perms

young knoll
iron palm
tender shard
#

what do you mean "integer in hashmap isnt working??"

iron palm
tender shard
#

because you always set it to "+1"

#

you have to set it to do this:

#

Killstreak.put(damagername,Killstreak.get(damagername)+1)

#

also pls stick to proper variable names. Killstreak should be lowerCamelCase

#

e.g. killStreak

tender shard
#

yeah using "Killstreak" suggests that it's a class, but of course it should work anyway^^

worldly ingot
#

The no profile picture is tripping me up

tender shard
#

me too lol

worldly ingot
#

but he's right. Adhering to naming standards makes code readability far better

#

According to your bio you write in C#! You should know about naming standards being important! :((

tender shard
#

I lost my first unity game 😦 it was on a backup that I cannot find anymore

#

but it's no loss, it was shit anyway

vague oracle
#

what isnt working

iron palm
#

Caused by: java.lang.NullPointerException
at PlayervoidDeath(deathlistener.java:52) ~[?:?]

iron palm
vague oracle
#

whats damagername?

vague oracle
#

you have sent us something different

#

to what you code is

#

killStreak.put(damagername,killStreak.get(damagername) + 1);

#

we have literally told you this 10 times

#

or use the merge thing I sent you killStreak.merge(damagername, 1, Interger::sum);

tender shard
#

you have to check whether the map contains that key already

#

e.g.

#
killStreak.put(damagername, killStreak.contains(damagername) ? killStreak.get(damagername) + 1 : 1)
vague oracle
#

thats the whole point of using merfe

#

merge

#

you don't need to check

tender shard
#

I haven't read the prior conversation

vague oracle
#

ah ok

iron palm
vague oracle
#

?learnjava

undone axleBOT
iron palm
tender shard
#

btw what's your code supposed to do anyway?

#

you are creating a new hashmap in every event so it will always be empty

iron palm
tender shard
#

okay but

#

then you must only use ONE hashmap and not create a new one every time

#

the hashmap should not be a local variable but instead a field of your listener class

#

you do know what a field is, right?

iron palm
tender shard
#

okay, so make the hashmap a field and it should work

iron palm
tender shard
#

did you get it working?

wide creek
#

im using a EventHanlder on PlayerAdvancementDoneEvent but it runs even when you unlock a recipe

#

how can I fix it?

tender shard
# iron palm ok i'll try thanks

I'd probably just do it like this, I think it's cleaner to use own methods for adding kills:

public class Test extends JavaPlugin implements Listener , CommandExecutor {

    private final HashMap<UUID, Integer> killStreaks = new HashMap<>();

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onPlayerDeath(PlayerDeathEvent event) {
        Player player = event.getEntity();
        Player killer = player.getKiller();
        if(killer == null) return; // No PvP death
        addKill(killer);
        if(getKills(killer) == 5) {
            killer.sendMessage("Yo yo yo bro you did the kill thing 5 times dude");
        }
    }

    private int getKills(Player killer) {
        return killStreaks.getOrDefault(killer.getUniqueId(), 0);
    }

    private void addKill(Player killer) {
        killStreaks.put(killer.getUniqueId(), getKills(killer) + 1);
    }
}
tender shard
young knoll
#

Yeah recipes use advancements

#

You can probably check if the key contains recipe or something

tender shard
#

hm then I'd simply check if Bukkit.recipeIterator contains the key and if yes, it's a recipe

young knoll
#

Different key

young knoll
#

Wonder what discordsrv does

wide creek
#

org.bukkit.craftbukkit.v1_17_R1.advancement.CraftAdvancement@3763200b

#

with System.out.println(event.getAdvancement());

young knoll
#

That’s not the key

wide creek
#

i was answering to mfnalex

#

wdym with key?

young knoll
#

Namespaced key

tender shard
#

cast the advancement to Keyed

#

then use getKey

#
Keyed keyed = (Keyed) event.getAdvancement();
System.out.println(keyed.getKey());
wide creek
#

minecraft:recipes/tools/fishing_rod

#

all the recipes are minecraft:recipes/..

frosty tinsel
wide creek
#

if (keyed.getKey().toString().contains("minecraft:recipes/")) {return;}

something like this can work?

royal hawk
#

Hello i need help. I try add to pom.xml:

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

 <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.12.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>17.0.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>17.0.0</version>
            <scope>compile</scope>
        </dependency>

this is not work

tender shard
frosty tinsel
tender shard
#

but as already mentioned, the cast is unnecessary

frosty tinsel
#

You can do just event.getAdvancement().getKey()

tender shard
#

I rememebered the cast is necessary because it indeed is when using Recipes

#

somehow recipes have to be cast to Keyed before you can access getKey

#

no idea why though

worldly ingot
#

Because Recipe doesn't extend Keyed, but ShapedRecipe and ShapelessRecipe do

#

There are some Recipe implementations which aren't keyed

#

For instance, MerchantRecipe

#

Advancements however are already direct children of Keyed

tender shard
#

yeah I just checked

#

all Recipes implement Keyed except the MerchantRecipe

#

makes sense now

#

actually I should have known that because I just recently added a recipe parsing class to my lib lol

hollow spindle
quaint mantle
#

Any idea why the check for the advancements before the player join?

#

Like a player can get the advancement before they join if the server don’t save player advancement and players already did it

tender shard
#

why would a server not store the advancements?

little trail
quaint mantle
#

I dont see anything wrong

little trail
#

do what now

tender shard
tender shard
little trail
#

ohhh ty

quiet ice
#

And set the scope to compile (even if it is the default)

radiant plaza
#

any way to get the last entity to exit a boat

quaint mantle
quiet ice
#

And remember to set spigot's scope to provided

little trail
tender shard
little trail
#

spigot is on provided yes

quiet ice
#

otherwise you'd get a 50 Mb jar

tender shard
#
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <configuration>
                    <relocations>
                    </relocations>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
#

basically just add this inside <build><plugins>

little trail
#

tysm

tender shard
#

np, did you get it to work?

#

but remember to add <scope>provided</scope> to ALL dependencies you do NOT want to shade

#

e.g. vault, worldedit, worldguard, etc bla bla

little trail
#

yeah i only have this and spigot rn

#

its compiling now

#

wait now ive got a -shaded one do i use that

tender shard
#

use the one with the bigger file size

little trail
tender shard
#

how exactly the file is called depends on your other pom config stuff

little trail
#

theyre the same

tender shard
#

I'd use the third one

#

but they basically all should be the same lol (except the 4kb one of course)

little trail
#

it works nice

#

ty

tender shard
#

nice

#

buut

#

you might also think about relocating that class

#

otherwise you might get problems when two plugins want to access the same library you are using

#

in the <relocations> section, add this:

                        <relocation>
                            <pattern>de.jeff_media.jefflib</pattern>
                            <shadedPattern>de.jeff_media.testlibs.de.jeff_media.jefflib</shadedPattern>
                        </relocation>

replace the pattern with the package name of the lib and shaded pattern with something containg YOUR plugins package

#

it's not really necessary but you should do it anyway to avoid future trouble

#

e.g. <pattern>com.mitch528.sockets</pattern>

#

and <shadedPattern>Your.Package.Name.libs.sockets</shadedPattern>

#

it basically just moves the dependency to your package so your plugin will not try to access the original class that was maybe shaded into other plugins that didnt relocate it either

#

I hope I explained it in an understandable way lol

tender shard
#

yeah someone explained the reason for it already

frosty tinsel
#

Yea I get it now

next stratus
visual tide
#

how does spigot decide which command should execute if several plugins have the same command registered?

hasty fog
#

Is it possible to have a webhook from your plugin page to a discord channel? Same idea as github webhook, but for spigot. I would like to automatically post my resource updates in a discord channel.

split lake
#

I have this piece of code that spawns a block in certain conditions but its taking ALOT of ram, and by this dropping the fps by a whole lot. Any ideas how to make this less laggy?


    @EventHandler
    public void onGenerate(ChunkPopulateEvent e) {

        Double allowPatch = 0 + (Math.random() * (15-0));
        int aP = (int) Math.round(allowPatch);
        if (allowPatch == 5) {

            final World world = e.getWorld();
            final Chunk chunk = e.getChunk();

            final Block block = chunk.getBlock(8, 0, 8);
            block.getBiome();

            if (block.getBiome() == (Biome.SWAMP)) {

                Double randomLocationDoubleX = 0 + (Math.random() * (15 - 0));
                int rLoc = (int) Math.round(randomLocationDoubleX);
                Double randomLocationDoubleZ = 0 + (Math.random() * (15 - 0));
                int rLoc2 = (int) Math.round(randomLocationDoubleZ);

                Integer y = world.getHighestBlockYAt(rLoc, rLoc2);
                Block check = world.getHighestBlockAt(rLoc, rLoc2);

                Block structureLocation = chunk.getBlock(rLoc, y, rLoc2);
                structureLocation.setType(Material.DIAMOND_BLOCK);
                Bukkit.broadcastMessage(String.valueOf(structureLocation));
            }
        }
    }
}
paper viper
#

Double allowPatch = 0 + (Math.random() * (15-0));

quaint mantle
#

professional code, u won't understand :kekw:

paper viper
#

thats not the cause of memory issue

#

but still lmao

split lake
#

ik its bad code but im trying some things

eternal oxide
#

your random generation at the start is pointless. You round it . Just random an int

paper viper
#

lol

quaint mantle
#

y not use random class?

split lake
#

ik its bad what i already said but i just wanna know why it lags so much

eternal oxide
#

Lastly your lag is probably caused by your Broadcast

split lake
#

bruh

#

i added the broadcast after it crashed my test server and broadcast doesnt do that much lag

eternal oxide
#

Its teh pixies then

split lake
#

why hate, cant you just help?

quaint mantle
#

what do u mean by pixies?

split lake
#

its him making a joke

quaint mantle
#

oh

eternal oxide
#

ok your issue is you are using world.getHighestBlock and Y using world coords of 0-15, those are not chunk relative

#

also stop using Double and then rounding. Its pointless and adds overhead you don't need

#

Your whole code is placing structures in chunk 0,0 not in the populated chunk

#

well its actually checking chunk 0,0 then placing at those coords in yoru populated chunk

split lake
#

aah i see it now, ty, one last question tho when i use this code (a little things changed with the if statements) it did spawn dia blocks in chunks that loaded, how come that worked

#

nvm lmao

#

ty

eternal oxide
#

yoru checks are on 0,0, then you spawn it in your populated chunk at the coords from 0,0

#

random.nextInt(15) I believe

split lake
#

ill try

pulsar kestrel
#

Has anyone got protocollib to work with Paper? Trying to load the ProtocolManager class gives me this error:

java.lang.NoClassDefFoundError: com/comphenix/protocol/ProtocolLibrary
eternal oxide
#

protocol lib is not on your server

paper viper
#

instead of just Random

pulsar kestrel
tardy delta
#

should i make instances of my configs, now i have a static method which loads all my files and getters to get thm

#

I got this now and i'm worried how to change it

eternal oxide
#

if that were mine, I'd not hard code the names and everything in the loading code

#

I'd probably create an enum of teh configs

muted sand
#

how do i disable vanilla commands / functions?
i.e, /w, /me, the stats menu

tardy delta
#

why not just override them?

#

or if you really want to disable them yesh

muted sand
#

or override, that could work

#

but how-?

#

oh wait its in the spigot config lmfao

#

now how do i replicate time played :thonk:

last ledge
#

p.getLocation().getWorld().spawnEntity(EntityType.CREEPER).setMetadata("BossCreeper", new FixedMetadataValue(plugin, "BossCreeper"));

Error: Cannot resolve method 'spawnEntity(org.bukkit.entity.EntityType)'

visual tide
#

how does spigot decide which command should execute if several plugins have the same command registered?

last ledge
#

p.getlocation()

#

is there already

hasty prawn
hasty prawn
visual tide
visual tide
quaint mantle
#

These is no way as it is depends on plugin name, and i think 2 plugin can’t start if they have the same name

#

The namespace key i mean

hasty prawn
#

Not sure, you might just have to play around with things and see if the order they're registered matters.

quaint mantle
#

They depends on the pl name

hasty prawn
#

If you just type /tp

quaint mantle
#

Priorities. Maybe

young knoll
#

I believe it’s whatever loads last

hasty prawn
#

It's probably the order in which their registered? I'd assume the last one register is the one Spigot defaults to, but you'd have to check that.

visual tide
hasty prawn
#

Well they override because vanilla is loaded first

tardy delta
#

this better?

paper viper
#

no

#

because its unnecessary static

#

ideally, you should have a Configuration class, and make all your configurations extend that specific class and override methods if necessary for serialization/deserialization

tardy delta
#

all methods of that class are static

paper viper
#

You shouldn't have made them static the first place 🙂

tardy delta
#

kinda true

#

how can i give it a value?

hasty prawn
#

...?

tardy delta
#

i know i should do configfile = ... but i want it in one method

hasty prawn
#

So put it in one method

tardy delta
#

i do file = new File() but that is for the parameter

#

and i want to do it for all the files so i cant choose one

hasty prawn
#

I do not understand

tardy delta
#

it isnt modifying the field

hasty prawn
#

Is the method supposed to define the File?

tardy delta
#

create the file and load it into the fileconfiguration

hasty prawn
#

Do it in a constructor if the user is required to pass the File in, and just have an argument for each one that's required.

tardy delta
#

bleh that class was supposed to be used static

tardy delta
#

so i should have multiple config instances in my main file?

hasty prawn
#

Hm? No

tardy delta
#

ah i understand

#

so something related to plugin.getConfigManager().getLang().set

pine island
#

I am using economy .getBalance() to get balance of a player but i want to subtract but the problem is i have to use economy.format(economy.getBalance); but this can only be in a string any good way to fix?

tardy delta
#

does Integer.parseInt() works on an untrimmed string?

onyx shale
#

dont think it does

#

as empty space is not exactly considered a number

ivory sleet
#

fourteen why not just try and see?

iron palm
tardy delta
ivory sleet
#

google it then

#

also the test wouldn't take longer than 30 seconds to do

tardy delta
#

ah online compiler yes

ivory sleet
#

ye

little trail
#

java.net.ConnectException: Network is unreachable um

#

is this a generic bukkit thing or just per hosting that you cant use http

tardy delta
#

does anyone knows if CodePen supports Java?

#

prob not

#

not going to authorize github for nothing 💀

#

bae it doesn't

wary harness
#

any one can help with this problem
with gradle
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.lang.Package[] java.lang.ClassLoader.getPackages() accessible: module java.base does not "opens java.lang" to unnamed module @77cd7a0
is it wrong java
version or something

tardy delta
#

using reflection?

regal moat
#

how can i get the slime other slimes splitted from in creaturespawnevent

young knoll
#

Although that event only has the slime they split from and the number it will split in to

regal moat
#

yeah

#

alright

pastel mauve
#

Is it possible to program a tablist which is not affected when the scoreboard is updating?

ivory sleet
#

Cant really do much axe

proud basin
#

anyone know the regex to get anything before the character |

young knoll
#

You could just use String.subString(0,String.indexOf("|"))

#

Well you probably want to check that indexOf doesn't return -1, but yeah

proud basin
#

I find regex more efficient

mild forum
young knoll
#

Yeah you can’t do that

#

You would have to use a custom font to mess with the display

mild forum
#

deam that pain

wide creek
#

ez question: how can I call Main besides this way?

private Main main;
    public SetSizeCommand(Main main) {
        this.main = main;
    }
#

(yes I know I should not call my Main Class "Main")

young knoll
#

That’s generally the preferred way

wide creek
#

atm for call Main class im using this:
Main.jar

public final class Main extends JavaPlugin {

    private static Logger log = Logger.getLogger("Minecraft");
    public static Main plugin;
    private static WorldBorderApi worldBorderApi = null;


    @Override
    public void onEnable() {
        // Plugin startup logic
        plugin = this;
young knoll
#

You could also create a static getter in your main class

#

But dependency injection is preferred

proud basin
#

Why does message.split("\\|")[0] remove all of the string?

#

shouldn't this remove everything after |

golden turret
#

hello

#

i would like to allow hoppers to transfer items to blocks

barren nacelle
#

Anyone know how to make something happen randomly?

golden turret
#

how could i do this?

lost matrix
barren nacelle
#

For ex pick a item out of every item in the game?

barren nacelle
proud basin
#

You could use Random

barren nacelle
#

You can use that for players?

lost matrix
# barren nacelle Huh

Do you want something to be executed at a random point in time or do you want to select a random element from a Collection of elements?

barren nacelle
lost matrix
lost matrix
proud basin
#

yea except it's just removing all the characters from the string

lost matrix
proud basin
#

Isn't that just what I wrote but longer?

lost matrix
golden turret
#

hm

lost matrix
#

So it has to be a TileState and this state has to implement BlockInventoryHolder.

golden turret
#

can i set a block to BlockInventoryHolder?

worldly ingot
#

Avoids the splitting and is probably faster if all you care about is that first bit

proud basin
#

Yea for me that just deletes everything from the string

golden turret
#

:C

lost matrix
young thicket
#

?note

barren nacelle
proud basin
lost matrix
# golden turret :C

Actually two.
When the Chunk loads, get all TileStates and filter them so you get all the Hoppers in that Chunk.
Then for each hopper:

Either
Get their orientation and manually tick them.
Or
Go into NMS, and overwrite their implementation so they can transfer ItemStacks to your custom Blocks.

worldly ingot
#

Because Java doesn't just "not work" lol

lost matrix
#

Im guessing that its empty to begin with

worldly ingot
#

Also, strings aren't mutable. So if you haven't already, re-assign it if you're trying to use the result

golden turret
#

but i was thinking about set the block to chest

#

and modify it via packets for the player

lost matrix
golden turret
#

interesting

#

where i start?

plucky crow
onyx shale
#

please... separate... arena from a game object...

lost matrix
golden turret
#

ok thanks

lost matrix
proud basin
#

I found out what was happening

onyx shale
#

anyway @plucky crow have a ondeath listener,check if your players list contains it,remove it from the list,set him as spectator?

#

game engine strunk

proud basin
#

so I have java String message = ""; int i = 0; for (String s : args) { if (i >= 0) { if (message != "") message += " "; message += s; } i++; } and I was checking if i was > than 0 and that was removing the first argument

worldly ingot
#

!= "" won't ever return true

#

.isEmpty()

onyx shale
#

oh boy string checking with ==

lost matrix
proud basin
#

yall are wack if you don't use != with string

echo basalt
#

Welcome to Java

onyx shale
#

i feel like a stringbuilder might fit better..

echo basalt
#

You're wack

proud basin
#

no

lost matrix
#

Or with a filter:

  public String toSentence(String[] words) {
    return Arrays.stream(words).filter(String::isEmpty).collect(Collectors.joining(" "));
  }
echo basalt
#

ehh stream

#

Looks nice but I'd rather have that 2 clock cycles of performance yk

onyx shale
#

lol

#

micro managing performance eh?

lost matrix
#

If you use += with Strings then you can throw your saved cycles right out of the window...

onyx shale
#

wut you can use that with strings?

#

the more you know..

lost matrix
#

Better unknow it

onyx shale
#

i doubt il ever use it

#

if i need to parse multiple args i go with stringbuilders

lost matrix
#

Allocating a new String every concat is bad mkay.

onyx shale
#

pain is fun

young knoll
#

So I take it the compiler won’t optimize that

lost matrix
echo basalt
#

String concatenation is something like O(n squared)

#

StringBuilder is O(1)

lost matrix
#

But not if the logic is too convoluted

echo basalt
#

String.format is purely awful so don't use it

young knoll
#

I know it will with standard “” + “” + “”

lost matrix
golden turret
#

sad

#

but thanks

#

but do you remember how you did it?

echo basalt
#

aren't faster furnaces just like

#

setCookTime or something

onyx shale
#

only available in paper in 1.17 afaik

#

it now has a api method to simply do setCookSpeedMultiplier

#

otherwise time tricks..

tight hedge
#

Looking for devs to help with my server (not hiring just idk help)

echo basalt
#

check how paper does it internally

onyx shale
#

stop spamming i doubt any decent dev will spend time without being payed @tight hedge

echo basalt
#

Am a self-proclaimed decent dev, here's what I can tell you:

we ain't slaves

worldly ingot
#

Self-proclaimed, eh?

opal juniper
#

i proclaim that i am shit

echo basalt
#

lmao

opal juniper
echo basalt
#

Just saying "self-proclaimed" so people don't think I'm BSing because they expect to be better than everyone

#

Also comedic effect

young knoll
#

I’m a self proclaimed self

solid cargo
#

yo guys what method should i use to store how much times a player has been punished (preferably store it on the server)

young knoll
#

SQLite, json, yml

#

Plain text file if you want to for some reason

solid cargo
#

aight thanks

worldly ingot
#

Preferably some SQL schema because you would then just store the punishments in SQL and could query from there

plucky crow
onyx shale
#

i already told you

#

or are you expecting the spoon instead?

plucky crow
#

I'll take the spoon

solid cargo
worldly ingot
#

If you load it at runtime, sure

onyx shale
plucky crow
#

I didn't do it, I just added it.

#

I started learning java 4 days ago

echo basalt
#

Don't use YML for data storage

#

You use it for a bit and you suddenly have like 3 minute startup times

#

If you're storing on a file, use either sqlite (.db) or write your own proprietary extension

onyx shale
#

or dont be dumb to load everything at once and load it async on preloginevent..

#

and check there

echo basalt
#

Still good to not use yml unless needed

opal juniper
young knoll
#

Definitely

#

Every tick too

opal juniper
#

oh yeah

#

it might get out of date if not

#

make sure that the data is up to date

onyx shale
#

inb4 he actually does it

solid cargo
#

lmfao i just talked with my dad who is experienced in db's and he said that yml is an actual piece of shit

onyx shale
#

true

golden turret
onyx shale
#

its mostly used for very basic data storage

solid cargo
onyx shale
#

kinda

solid cargo
#

the server just fetches it when a new player is punished

#

and adds +1 to that player's punishment amount

young knoll
#

It’s used for configuration

#

Because it’s easier to work with than json

#

Toml is nicer though

onyx shale
#

as i said you can use.. if you want to make use of the async login

#

however a sql can also be used in that time as well

#

even better as its async

golden turret
#

how could i edit a block when the chunk packet is sent?

#

1.12

young knoll
#

Carefully

#

The block format in the chunk packet is weird

mortal hare
#

Its so cold in my country that my gpu stays ingame at 35 C lol

quasi flint
#

Better formulated: It's so cold in your room

little trail
#

is it at all possible to connect to minehut via http https://cdn.tooty.xyz/wAXL new HTTPServer(this, 6969, handlers); ```java
public class HTTPServer {
private Logger logger;
private HttpServer httpServer;

public HTTPServer(Tooty plugin, int port, Map<String, HttpHandler> mapping) {
    logger = plugin.getServer().getLogger();
    try {
        httpServer = HttpServer.create(new InetSocketAddress(port), 0);
        for (var entry : mapping.entrySet()) {
            httpServer.createContext(entry.getKey(), entry.getValue());
        }
        httpServer.setExecutor(null);
        logger.info(String.format("Server listening on port %s", port));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

public void start() {
    this.httpServer.start();
}

}
java
public class HTTPServer {
private Logger logger;
private HttpServer httpServer;

public HTTPServer(Tooty plugin, int port, Map<String, HttpHandler> mapping) {
    logger = plugin.getServer().getLogger();
    try {
        httpServer = HttpServer.create(new InetSocketAddress(port), 0);
        for (var entry : mapping.entrySet()) {
            httpServer.createContext(entry.getKey(), entry.getValue());
        }
        httpServer.setExecutor(null);
        logger.info(String.format("Server listening on port %s", port));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

public void start() {
    this.httpServer.start();
}

}

#

it went all the way to 24s this time

#

ping on reply

lavish hemlock
#

I don't think I'd recommend com.sun.net.httpserver.HttpServer as it's sort of in-between API and Internals.

#

I believe Apache has their own solution.

#

also:

#

how would you connect to another server via a server? lol

warped sage
#

is there an easy way to parse itemstacks that are formatted like this:

acacia_boat{display:{Name:'[{"text":"My Item","italic":false}]',Lore:['[{"text":"Description","italic":false}]']},Enchantments:[{id:aqua_affinity,lvl:1}]}

?

quaint mantle
#

google gson

#

then just extract the data

warped sage
#

are you sure that the properties match exactly?

quaint mantle
#

?

little trail
#

So I don’t know if it'll work

quaint mantle
#

what is that even trying to do and why is the code posted twice

warped sage
# quaint mantle ?

this is what's used for the /give command, I'd assume that there is an automatic way of doing it

#

I assumed you meant pass it to ItemStack#parse

lavish hemlock
#

essentially, NBT formatted as a JSON-like language

warped sage
#

I see

#

is there an official way of parsing those

#

or will I have to use a json library like imaginedev said

#

because I'm pretty sure it's not valid JSON with some keys not having quotes

quaint mantle
#

right

warped sage
#

it's not an insurmountable problem, I'd just assume the function already exists since this is parsed for the /give command as well

chrome beacon
#

Yeah find the deserializer in NMS

dull sparrow
#

Hiya I've created a custom pathfinder goal for a mob (using NMS) and I've spawned the mob. It's moving all lovely, but when I disconnect and reconnect the pathfinder stops (aka the mob stands still) Why is this? when running /reload it keeps its pathfinder goals

ivory sleet
#

Sounds like a bug

sharp bough
#

wdym it doesnt grow?

opal juniper
#

exactly that

#

it doesn’t grow up

#

how did you break it

#

ok

#

so try using the api

#

and you will have more luck i imagine

true perch
#

What event is fired for the Cartography Table when making a copy of maps?

opal juniper
#

ok well by using nms you are probably forgetting some method call to make it tick again

#

that is because it does all the extra checks to make sure it don’t break anything

#

well don’t look here for support with nms, look at the source code for the setType and see what method calls it does, or do some debugging first to see if it works with Block#setType

neon nymph
#

My Gs, how the heck does regex in java work? More specifically, the one in #String.split()? I've tested the regex in testers online and it seems to work perfectly, but when I copy and paste it inside the split() method, it just doesn't work. Is there some other format for it?

Here's what I tested in the regex testing website:

#

And here's what's in my method:

String sched = "MTWThF";
String[] weekdays = sched.split("/[A-Z]h|[A-Z]/g");
System.out.println(weekdays[0]);

// Output:
// MTWThF

// Expected Output:
// M
ivory sleet
#

What regex tester is that?

neon nymph
ivory sleet
#

The first one isn’t for Java iirc

#

Nor the second one

#

It’s for JavaScript which follows quite a different convention

neon nymph
#

Oh, they're not all the same?

ivory sleet
#

Sadly not

neon nymph
#

Dang. Do you know any websites for java regex?

ivory sleet
#

Try google java regex tester maybe

neon nymph
ivory sleet
#

Oh believe that one works

neon nymph
#

Aight then, I'll learn yet another set of regex formats

#

Thanks a bunch

ivory sleet
#

Yeah nw lol

eternal night
#

regexr allows you to switch to the PCRE regex style

#

there is a cute dropdown in the top right

ivory sleet
#

Ah couldn’t spot it 😆

young knoll
#

Gotta love stuff with a bunch of small differences

#

Like the various SQL options

neon nymph
#

Ohh neat, so java is the PCRE one?

young knoll
#

PCRE is for perl apparently

#

I assume Java’s is based on it and therefor very similar

eternal night
#

it is very close to perl 5 syntax

#

but is missing a few construct

#

should not matter for most usecases tho

elder granite
#

would this be a smart place to ask for help with citizens or no

young knoll
#

They have a discord don’t they

neon nymph
#

Bruh, the one in java still has the same format as what I'm aiming for. But now I realize the mistake

#

I forgot that #String.split() actually splits with the given regex, and not including it in the result

#
String sched = "aMbTcWdTheFf";
String[] weekdays = sched.split("[A-Z]h|[A-Z]");
System.out.println(weekdays[0]);

// Output:
// a
#

Like so

#

So I actually had the correct syntax, just not the correct method I guess?

golden turret
#

hello, im editing blocks with packets

#

basically a simple player.sendBlockChange

#

but when he interacts at the modified block it backs to its original type

#

i would like to prevent this

young knoll
#

Send the packet again using the interact event

golden turret
#

no

#

it will flick

young knoll
#

Might be able to listen for and cancel the outgoing change

#

Assuming there is one

dull sparrow
#

Hi, I'm listening to the PlayerInteractEvent and trying to get Action.RIGHT_CLICK_AIR. I know docs say this: This event will fire as cancelled if the vanilla behavior is to do nothing (e.g interacting with air). so I've tried putting @EventHandler(ignoreCancelled = true) but it is never firing the event, thus I'm never catching theAction.RIGHT_CLICK_AIR, however it's catching Action.LEFT_CLICK_BLOCK etc. How do I listen to a player right clicking the air?

golden turret
#

remove the ignore cancelled

dull sparrow
#

Lol