#help-development

1 messages · Page 2189 of 1

iron glade
#

Don't start static abuse

#

This is literally all you have to paste in your listeners class

carmine valley
#

ooooooohhh I though you meant Private Plugin MCBrawl. it's actually Private MCBrawl plugin

#

that's why

#

I solved the plugin error, but I still have the runTask error

iron glade
#

why would you do this

carmine valley
#

oops sry, meant private

humble tulip
#

Tbh it doesn't matter although if you're not experienced, you'll abuse this making your code cluttered. You may end up having schedulers in data classes and whatnot

#

Dependency injection is better because it makes you think about where you're passing your plugin instance

carmine valley
#

I would like to specify the ticks, how can I solve that runTask error?

tardy delta
#

if you want to use a real singleton, use JavaPlugin#getPlugin, dont use instance unless there is no better way

humble tulip
#

runTaskLater

limber owl
iron glade
#

Dependency Injection > that

ivory sleet
tardy delta
#

and it looks ugly af

#

👉👈

iron glade
humble tulip
carmine valley
#

works great, really appreciate the help everyone, I will test it and see what happens

tardy delta
#

thats what she-

limber owl
humble tulip
#

There's only supposed to be one instance

#

Yeah i agree but if you have access to your plugin eberywhere, it can lead to messier code

#

You'll have to know when not to use it

limber owl
#

@iron glade you understand that you can only have one JavaPlugin class, so it can be static, right?

ivory sleet
#

well ideally you should rarely have to pass your plugin instance in a spigot plugin minion, unless the api demands you to, but even then its better to create middle level facade classes and pass instances of those

iron glade
limber owl
ornate roost
#

package com.cyan.elytrarace;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class Main extends JavaPlugin {

@EventHandler
public void onPlayerUse(PlayerInteractEvent event){
    Player p = event.getPlayer();
    if(p.getItemInHand().getType() == Material.PHANTOM_MEMBRANE); {
        p.teleport(p.getLocation().add(0,200,0));
limber owl
#

?paste

undone axleBOT
ornate roost
#

can someone help me i just cant figure out why it wont teleport me

humble tulip
#

Your class doesn't implement listener

#

And u need to register your listener in onEnable

limber owl
#

?

dreamy arrow
#

installing it on virtualbox ubuntu

#

installing smoothly without problem

humble tulip
#

Doing Plugin.getInstance it very long though

#

Esp if you have a long plugin name

#

Very wordy to have in ur code

#

So u may want to store a plugin instance in the class

#

And you're back to storing the instance

humble tulip
#

By that logic all manager classes should be static

compact haven
#

unnecessary memory

#

you're literally storing a reference which is 8 bytes in the JVM

humble tulip
#

His logic

#

Cuz you'll only have one

ivory sleet
#

oh yeah

ornate roost
ivory sleet
#

myeah the entire one instance <=> singleton argument doesnt work anymore since its been proven to degrade code architecture

humble tulip
#

Sorry I'm not sitting at your keyboard

iron glade
humble tulip
limber owl
compact haven
#

1000 classes kekw

vivid cave
#

I have question, would you guys think it'd be possible to make unicorn? (lets say riding a horse flying in the air, when u try to make it jump it goes higher, to make it go down u click in the direction of the horse)

ivory sleet
#

static approach is better when you just need it once in one class
still no

iron glade
#

people be rewriting whole minecraft? xd

ivory sleet
#

static should be used for global, stateless and arguably pure stuff

compact haven
#

^ this

#

also when you use static, it's not like you aren't using memory

#

you still need to store, in the constant pool, the field reference

#

which requires the signature as a utf8 string

#

or the method reference for the static getter, same situation

tardy delta
#

🤓

quiet ice
compact haven
#

No it's not

compact haven
#

a reference is 8 bytes

tender shard
#

it's 4 bytes on 32 bit and 8 bytes on 64 bit

#

IIRC

compact haven
#

when you store an object in a variable, you aren't storing the object itself

#

you're storing a reference to that object

carmine valley
#

hey guys, this time for some reason the player is being knocked to a wrong direction after the heatValue exceeds 8, even though I'm LITERALLY using the same math, any ideas why? cpp @EventHandler public void onPlayerHitPlayer(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) { heatValue++; LivingEntity damaged = (LivingEntity) event.getEntity(); LivingEntity damager = (LivingEntity) event.getDamager(); Vector damagedV = damaged.getLocation().toVector(); Vector damagerV = damager.getLocation().toVector(); damaged.setVelocity(damagedV.subtract(damagerV).normalize().multiply(heatValue)); if(heatValue >= 8){ Bukkit.getScheduler().runTaskLater(plugin, () -> {}, 20); damaged.setVelocity(damagedV.subtract(damagerV).normalize().multiply(heatValue)); }

quiet ice
#

Yeah, I think I confused those two

compact haven
#

that's why you can pass an object through a method and manipulate the object from the method

tardy delta
tender shard
compact haven
#

quite a lot larger would be >8 bytes, the only other case is 4 bytes on a 32-bit machine, which is less?

dreamy arrow
#

but i have a question. will there be any problem if i just transferred build tools from my virtualbox ubuntu into my main windows@tender shard

quiet ice
#

Or better said treated them the same

dreamy arrow
#

alright 👍

tender shard
#

:3

humble tulip
quiet ice
#

Which means that I treated an reference to be 50 - 120 (not sure what the exact size was but eh) bytes in size

humble tulip
#

You're reusing the vectors which had math done on tjem already

carmine valley
#

oooh

compact haven
#

:? definitely not but all right then

humble tulip
#

Or save the calculated vector to a Vector variable and just set that as the velocity

ornate roost
limber owl
#

copy the link up the top after you paste it

carmine valley
ornate roost
#

so now the event is red why?

humble tulip
eternal night
#

a learn java moment

#

you cannot declare a method inside a method

humble tulip
#

LOL

#

Class is still not a listener

eternal night
#

nor are you registering it

humble tulip
#

?wiki

undone axleBOT
carmine valley
# humble tulip You're not saving the calculated vector

so like that? ```cpp
@EventHandler
public void onPlayerHitPlayer(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
heatValue++;
LivingEntity damaged = (LivingEntity) event.getEntity();
LivingEntity damager = (LivingEntity) event.getDamager();
Vector damagedV = damaged.getLocation().toVector();
Vector damagerV = damager.getLocation().toVector();
Vector velocity = damagedV.subtract(damagerV).normalize().multiply(heatValue);
damaged.setVelocity(velocity);
if(heatValue >= 8){
Bukkit.getScheduler().runTaskLater(plugin, () -> {damaged.setVelocity(damagedV.subtract(damagerV).normalize().multiply(heatValue));}, 20);

                }
            }
        }
ornate roost
#

Can you please just tell me how instead of posting links to some websites

iron glade
humble tulip
acoustic pendant
#

could someone tell me why is this null?

iron glade
humble tulip
tardy delta
undone axleBOT
acoustic pendant
tender shard
humble tulip
#

Well look at your getCustomFile method then

ornate roost
# humble tulip ?wiki

its just a guide on how to set everything up i dont need that i just need help with my program

tardy delta
#

still..

#

i was people calling their fields like a method

acoustic pendant
tardy delta
#

saw

iron glade
dusk flicker
#

?learnjava

undone axleBOT
tender shard
humble tulip
acoustic pendant
#

I mean, getCustomFile works in other things

dusk flicker
#

alex its obvious

#

look at the code

#

lol

humble tulip
#

That's your error, figure out why it's null

tender shard
#

like wtf is that supposed to mean

dusk flicker
#

just intellij formatting

#

probably underlined red as it isnt right

humble tulip
#

better than not working

#

At least we know it's not working and red

upper vale
#

he is metaphorically describing the state of his event

ornate roost
#

im already learning java, its just that im not so far but my dad wished for his birthday that im coding something for him im sorry

humble tulip
#

He wants a mc plugin?

ornate roost
#

no he wanted that i code a minigame for him he can play

carmine valley
#

Any idea why the runnable code sends the player so damn high up in the opposite direction?

    @EventHandler
    public void onPlayerHitPlayer(EntityDamageByEntityEvent event) {
        if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
            heatValue++;
            LivingEntity damaged = (LivingEntity) event.getEntity();
            LivingEntity damager = (LivingEntity) event.getDamager();
            Vector damagedV = damaged.getLocation().toVector();
            Vector damagerV = damager.getLocation().toVector();
            Vector velocity = damagedV.subtract(damagerV).normalize().multiply(heatValue);
            damaged.setVelocity(velocity);
            if(heatValue >= 8){
                Vector velocity2 = damagedV.subtract(damagerV).normalize().multiply(heatValue);
                Bukkit.getScheduler().runTaskLater(plugin, () -> {damaged.setVelocity(velocity2);}, 20);

                    }
                }
            }```
ornate roost
eternal night
#

I mean, don't know what your heatvalue is

#

but it is incremented by 1

#

velocity is pretty sensitive

carmine valley
tardy delta
#

the world is heating up 🥺

eternal night
#

a vector of like length 3 is already a lot of velocity when applied to a player

ornate roost
eternal night
#

if e.g. the damager and target are 3 blocks apart

#

if you multply that by like 3

#

things will get insane

carmine valley
#

I've tried stupid amounts, it always only knocks the player back 18 blocks and not any further

upper vale
#

gonna keep it real with you a minigame is NOT how you begin coding

tardy delta
#

minigame with basic java knowledge lets gooo

#

guess the number kekw

tender shard
ornate roost
#

its just that it teleports the player up

tender shard
#

why are you doing math on it again? makes no sense to me

carmine valley
tender shard
#

no

carmine valley
#

or isn't velocity2 a clone of velocity1?

tender shard
#

velocity2 is damagedV.subtract(damagerV).normalize().multiply(heatValue);

#

it has nothing to do with velocity(1)

carmine valley
#

wouldn't that be the same as Vector velocity2 = velocity1

eternal night
#

no

#

you are just assigning a variable

#

no cloning is involved

carmine valley
#

what's cloning then?

sterile token
#

what the diff btween locatin and vector?

eternal night
#

final Vector cloned = vector.clone()

#

location may have a world

#

vector does not

sterile token
#

Oh ok

eternal night
#

and then obviously methods are different

tender shard
#

try sth like this

    @EventHandler
    public void onPlayerHitPlayer(EntityDamageByEntityEvent event) {
        if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
            heatValue++;
            LivingEntity damaged = (LivingEntity) event.getEntity();
            LivingEntity damager = (LivingEntity) event.getDamager();
            Vector damagedV = damaged.getLocation().toVector();
            Vector damagerV = damager.getLocation().toVector();
            Vector velocity = damagedV.subtract(damagerV).normalize().multiply(heatValue);
            damaged.setVelocity(velocity.clone());
            if(heatValue >= 8){
                Bukkit.getScheduler().runTaskLater(plugin, () -> {damaged.setVelocity(velocity.clone());}, 20);
            }
        }
    }
carmine valley
eternal night
#

no

tender shard
#

btw I fucking hate spoons

sterile token
tender shard
#

some people even eat pasta with spoons

#

like wtf

#

why don't they use a fork

eternal night
#

wat

#

I just write the final modifier

carmine valley
eternal night
#

because I don't like mutable stuff

ivory sleet
#

void

tender shard
sterile token
#

conclure

carmine valley
#

I eat smaller pastas with a spoon

#

way easier

tender shard
#

weird

#

I hate spoons

#

spoons are for soup and nothing else

sterile token
#

till not understand why the socket input send a number 3 to console

#

Is an id or what?

ivory sleet
#

might be

eternal night
#

wat

#

what socket input

#

oh were you writing your "fake client"

#

or was that someone else

ivory sleet
#

its him

sterile token
carmine valley
clever musk
#

can PersistentDataContainer store data across restarts? I'm using it to store player configs.

sterile token
#

Im connecting a fake client to server, doing handshake and login packet. After that i read socket input

sterile token
#

And display a number 3 to console. So i dont knon what means that number 3

compact haven
#

it indeed does store across restarts

ivory sleet
#

thats the point of that thing hence the prefix Persistent

tender shard
clever musk
#

Oh

#

I wasn't using setPersistent(true)

tender shard
#

and not Volatile

sturdy reef
#

how can i do something every 1 second white an integer is not 10

compact haven
undone axleBOT
clever musk
#

I don't think I'm using persistent data container correctly

sturdy reef
#

but how can i do it somehow like this

tender shard
sturdy reef
sturdy reef
tender shard
#

oh my bad

#

I read it incorrectly

#

wait wtf is your code doing? you are creating like 36 runnables

sterile token
#

How do iread that

#

Im already reading input stream, but debugging to console it send a mumber "3"

sturdy reef
#

so you can give me the real code

tender shard
#

yeah but what are you trying to do after all?

sterile token
tender shard
#

you have the "run()" method. just put inside the code you want to run every second

tender shard
sterile token
#

Oh sorry mfnalex, i get confused

sterile token
carmine valley
#

IT FINALLY WORKS LIKE I WANT IT TO LESSGOOOOO

tender shard
carmine valley
#

wouldn't just reusing the velocity work?

#

why clone

tender shard
#

no, the volocity changes all the time

#

and the vector too, it's mutable

carmine valley
#

I see

tender shard
#

so you want to create your vector once and then use a clone every time to reset the velocity

carmine valley
#

welp now, how do I make the heat value different for each player and not static for the whole server like it is right now

#

I certainly can't add a variable to the player class

#

do I make a child class of player, add the heatValue and use that?

#

or is there an easier way?

eternal oxide
#

just a Map<UUID, int>

carmine valley
#

what's that if you don't mind me asking

#

I know what's a uuid and the int here is my heatValue

#

but what's Map

#

oh wait I took that in java 3

#

that's a generic?

#

lemme google and see :P

quaint mantle
#

😏

sturdy reef
#

@tender shard

clever musk
#
@EventHandler
public void e(PlayerQuitEvent e) {
    Bukkit.getConsoleSender().sendMessage("logout " + e.getPlayer().getPersistentDataContainer().getKeys().size()+"");
}
@EventHandler
public void e(PlayerLoginEvent e) {
    e.getPlayer().setPersistent(true);
    Bukkit.getConsoleSender().sendMessage("login 1 " + e.getPlayer().getPersistentDataContainer().getKeys().size());
    e.getPlayer().getPersistentDataContainer().set(ACTIVE_PROFILE, PersistentDataType.STRING, "test");
    Bukkit.getConsoleSender().sendMessage("login 2 " + e.getPlayer().getPersistentDataContainer().getKeys().size());
}

On the first login, I'm setting persistent data, and when I logout, the persistent data is not being saved, so when I login again, the data isn't there. Am I missing something?

tender shard
#

why ping

sturdy reef
tender shard
#

lol

#

yes, it's this weird plugin that allows people to write shitty plugins without java

clever musk
#

Sounds like Denizen

sturdy reef
#

but do you remember the line that can hold the event or the command for a couple of seconds

#

like

#

wait 3 seconds

tender shard
#

I never used skript

#

I don't know anything about it

sturdy reef
#

okay do you know how to do this

#

like wait 1 second then continue the code

tender shard
#

?scheduling

undone axleBOT
sturdy reef
#

how to do it in java

ivory sleet
# humble tulip Because access is too easy right?

oh didnt see you asked, but basically

  • what if the singleton class requires dependencies on creation
  • classes that depend on that singleton class are gonna tightly depend on a single unit, this is known as tight coupling and makes it a hell to organize and test
  • using singletons insinuates your code with hidden dependencies, which makes the code hard to test (unit test particularly)
  • how do you manage creation, usage and deconstruction of the singleton in a multi threaded environment
  • how do you manage to change behavior without modifying it? (open closed principle)
  • you lose dependency inversion and inversion of control to most extent with singletons

(of course there are some advantages)

  • globally accessible, sometimes advantageous, like when you want to provide an api
  • sometimes a good and defensive pattern to manage expensive objects
tender shard
# sturdy reef how to do it in java
        System.out.println("This runs now");

        Bukkit.getScheduler().runTaskLater(this, () -> {
            System.out.println("This runs one second later");
        },1*20L);
#

1*20 = one second because minecraft has 20 ticks per second

ancient plank
#

sleep(900000)

tender shard
jagged quail
#
package me.oliver193.mecha.Commands;

import me.oliver193.mecha.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class Heal implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if(!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cThis command can only be used by players.")
            return true;
        }
        Player player = (Player) commandSender;
        player.setHealth(20);
        Msg.send(commandSender, "&aYour health is now full.");
        return true;
    }
}
``` so this?
ancient plank
#

"why is my server crashing???": sleep(900000)

compact haven
#

yes!

#

well one small thing

#

change your package Commands to be lowercase

tardy delta
#

someone doing while loop in event

tender shard
#

oh yeah

compact haven
#

seems your convention on everything else is good though

tender shard
#

package names should be lower case although ti actually doesnt matter

tender shard
sharp kayak
#

how do i convert unix time to yyyy-mm-dd HH:mm?

compact haven
#

SimpleDateFormatter

sharp kayak
#

can u provide an example pls?

humble tulip
#

google

#

Also u pretty much have it done since you already know your format

brittle lily
#

Hey Guys I want to add Every Player Except 1 Player to an Array List How can I exclude that 1 player

humble tulip
#

Create a new arraylist with all onlije players

#

And remove that pkayer

brittle lily
#

wow

humble tulip
#

Or add all but that player

brittle lily
#

wow

#

thankss

tender shard
jagged quail
#
package me.oliver193.mecha.commands;

import me.oliver193.mecha.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class Heal implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if(!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cThis command can only be used by players.");
            return true;
        }
        Player player = (Player) commandSender;
        player.setHealth(20);
        Msg.send(commandSender, "&aYour health is now full.");
        return true;
    }
}
``` thats perfect?
compact haven
#
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date fromUnix = new Date(unixTimestamp);
System.out.println(formatter.format(fromUnix));
#

you can use Msg.send(player, "..."); btw

#

without a cast

sharp kayak
#

ty

compact haven
#

it doesn't matter whichever you use, but you don't need to cast player in Msg.send() because the method accepts a CommandSender

tender shard
#

yeah @jagged quail EVERYTHING that is a player is also a CommandSender because Player extends CommandSender

tender shard
jagged quail
#

time to fix this ```java
package me.oliver193.mecha.commands;

import me.oliver193.mecha.CommandBase;
import me.oliver193.mecha.Msg;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class Feed {
public Feed() {
(new CommandBase("feed", true) {
public boolean onCommand(CommandSender sender, String[] arguments) {
Player player = (Player)sender;
player.setFoodLevel(20);
Msg.send((CommandSender)player, "&aYour hunger is now full!");
return true;
}

        public String getUsage() {
            return "/feed";
        }
    }).enableDelay(2);
}

}

tender shard
#

yeah get rid of that ASAP lol

compact haven
#

compared to that, it's perfect lol

tardy delta
#

not even a functionalinterface

jagged quail
#

will just change some stuff from heal and it'll work

#

for feed

tender shard
#

those "essentials-like" plugins are actually the best to learn spigot api imho

tardy delta
#

wait wha Msg.send((CommandSender)player

jagged quail
#

yeah

tender shard
jagged quail
#
package me.oliver193.mecha;

import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

public class Msg {
    public static void send(CommandSender sender, String message) {
        send(sender, message, "&a");
    }

    public static void send(CommandSender sender, String message, String prefix) {
        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + message));
    }
}
#

its ok now?

tender shard
#

@jagged quail imagine you have the following class structure:

LivingThing -> Human -> German

so every German is also a Human and every Human is also a LivingThing. If you now have a method that requires a Human you can of course also always pass a German, since every Germa nis a Human. But you cannot pass a LivingThing because not every LivingThing is a Human (animals, mushrooms, plants, ...)

#

that's why casting Player to CommandSender is useless

jagged quail
#

heal is green but feed is blue

tender shard
#

that's git

ancient plank
#

vcs

subtle folio
#

git moment

tender shard
#

because you changed something in the one file

crisp steeple
tender shard
#

just ignore it

crisp steeple
#

if perfect is defined by shortest amount of lines

subtle folio
#

commands are color coded to what they do

tender shard
crisp steeple
#

true

tender shard
#

I'm so helpful

crisp steeple
#

or just remove all the newlines and have a one line file

tender shard
#

yeah I once coded AngelChest in 5 lines

#

the rule was "no more than 3 semicolons per line"

jagged quail
#

time to fix this ```java
package me.oliver193.mecha;

import me.oliver193.mecha.commands.Feed;
import me.oliver193.mecha.commands.Heal;
import org.bukkit.plugin.java.JavaPlugin;

public class Mecha extends JavaPlugin {
private static Mecha instance;

public void onEnable() {
    instance = this;
    getLogger().info("Mecha version " + getDescription().getVersion() + " is loading");
    new Heal();
    new Feed();
}

public void onDisable() {
    getLogger().info("Mecha version " + getDescription().getVersion() + " is disabling.");
}

public static Mecha getInstance() {
    return instance;
}

}

crisp steeple
#

make Msg.send always throw an exception to avoid returning true 😎

crisp steeple
#

exceptionsort on top

upbeat sky
#

Hey guys, I'm trying to stop villagers from discounting (when getting converted.) How would I go about changing this?

jagged quail
#

@tender shard how would i make it load the commands now sorry

tender shard
jagged quail
#

yeah

tardy delta
#

class Mfnalex extends german

jagged quail
#

my brain isnt braining

tender shard
#

in your onEnable()

#

also you have to add the "heal" command to your plugin.yml

#

in plugin.yml:

commands:
  heal:
    description: "Heals the player"
jagged quail
#

also cleared it up by removing version ```java
public void onEnable() {
instance = this;
getLogger().info("Mecha is loading");
new Heal();
new Feed();
}

public void onDisable() {
    getLogger().info("Mecha is disabling.");
}```
tender shard
jagged quail
#

oh yea

tardy delta
#

why setting a system property?

jagged quail
#

should rename the command java file to HealCommand from Heal

tardy delta
#

yes

tender shard
#

?learnjava

undone axleBOT
tender shard
#

😛

jagged quail
#

okay this is the plugin.yml

name: Mecha
version: '${project.version}'
main: me.oliver193.mecha.Mecha
api-version: 1.18
authors: [ oliver193 ]
description: Mecha Plugin
website: https://github.com/oliver193/Mecha-Plugin
commands:
  heal:
    permission: mecha.heal
    description: Heal yourself.
    usage: /heal
  feed:
    permission: mecha.feed
    description: Feed yourself.
    usage: /feed```
#

so that should work hopefully

tender shard
#

looks good

jagged quail
#

should get rid of this

#
package me.oliver193.mecha;

import me.oliver193.mecha.commands.FeedCommand;
import me.oliver193.mecha.commands.HealCommand;
import org.bukkit.plugin.java.JavaPlugin;

public class Mecha extends JavaPlugin {

    public void onEnable() {
        getLogger().info("Mecha is loading.");

        // Load commands
        getCommand("heal").setExecutor(new HealCommand());
        getCommand("feed").setExecutor(new FeedCommand());

    }

    public void onDisable() {
        getLogger().info("Mecha is disabling.");
    }
}
``` main file looking good
tender shard
jagged quail
#

yeah i dont

#

since i removed the commandbase 🤢

tender shard
#

but I'd keep it because some time you WILL need it

#

there are probably some people here who want to talk you into DI instead but

#

(I wouldn't listen to them)

#

lol

jagged quail
#

oh i'll add it back

tender shard
#

I always do it like this

public class CBDTest extends JavaPlugin implements Listener {
    
    private static CBDTest instance;

    {
        instance = this;
    }
    
    public static CBDTest getInstance() {
        return instance;
    }
}
twilit pulsar
#

RWAR

#

i mean

tender shard
#

wrong

#

you never set the instance

jagged quail
#

oof

tender shard
#

add this

{
    instance = this;
}
jagged quail
#
package me.oliver193.mecha;

import me.oliver193.mecha.commands.FeedCommand;
import me.oliver193.mecha.commands.HealCommand;
import org.bukkit.plugin.java.JavaPlugin;

public class Mecha extends JavaPlugin {
    
    private static Mecha instance;
    
    public void onEnable() {
        getLogger().info("Mecha is loading.");

        // Load commands
        getCommand("heal").setExecutor(new HealCommand());
        getCommand("feed").setExecutor(new FeedCommand());

    }

    public void onDisable() {
        getLogger().info("Mecha is disabling.");
    }

    public static Mecha getInstance() {
        return instance;
    }

}
jagged quail
tender shard
jagged quail
#

oh needs to be in onEnable

tender shard
#

no

#

onEnable is way too late to set your instance

#

you want to set it as soon as it's created (in the constructor)

jagged quail
#
package me.oliver193.mecha;

import me.oliver193.mecha.commands.FeedCommand;
import me.oliver193.mecha.commands.HealCommand;
import org.bukkit.plugin.java.JavaPlugin;

public class Mecha extends JavaPlugin {

    private static Mecha instance;

    public void onEnable() {
        instance = this;
        getLogger().info("Mecha is loading.");

        // Load commands
        getCommand("heal").setExecutor(new HealCommand());
        getCommand("feed").setExecutor(new FeedCommand());

    }

    public void onDisable() {
        getLogger().info("Mecha is disabling.");
    }
    public static Mecha getInstance() {
        return instance;
    }

}
tender shard
#
package me.oliver193.mecha;

import me.oliver193.mecha.commands.FeedCommand;
import me.oliver193.mecha.commands.HealCommand;
import org.bukkit.plugin.java.JavaPlugin;

public class Mecha extends JavaPlugin {

    private static Mecha instance;

    {
        instance = this;
    }

    public void onEnable() {
        getLogger().info("Mecha is loading.");

        // Load commands
        getCommand("heal").setExecutor(new HealCommand());
        getCommand("feed").setExecutor(new FeedCommand());

    }

    public void onDisable() {
        getLogger().info("Mecha is disabling.");
    }
    public static Mecha getInstance() {
        return instance;
    }

}
#

like this

jagged quail
#

ah

#
package me.oliver193.mecha;

import me.oliver193.mecha.commands.FeedCommand;
import me.oliver193.mecha.commands.HealCommand;
import org.bukkit.plugin.java.JavaPlugin;

public class Mecha extends JavaPlugin {

    private static Mecha instance;
    
    {
        instance = this;
    }

    public void onEnable() {
        getLogger().info("Mecha is loading.");

        // Load commands
        getCommand("heal").setExecutor(new HealCommand());
        getCommand("feed").setExecutor(new FeedCommand());

    }

    public void onDisable() {
        getLogger().info("Mecha is disabling.");
    }
    
    public static Mecha getInstance() {
        return instance;
    }

}
``` done
quaint mantle
#
{

}```is the same as a no argument constructor
humble tulip
#

@tender shard as long as you set the instance before anything gets it, it's all good

#

The top of onEnable or even onLoad is fine

jagged quail
#

like this?

humble tulip
#

Yep

jagged quail
#

let me build and test it

tender shard
#

that's wrong

#

{ } gets added to EVERY constructor

quaint mantle
#

what

tender shard
#

t always gets called no matter what constructor you use

#

for real

acoustic pendant
#

Hello! I'm trying to solve a problem but I haven't figured out how...

Basically I'm getting this as null: java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.file.FileConfiguration.contains(String)" because the return value of "me.fragment.skyblockplugin.files.IslandManagerFile.getCustomFile()" is null

and this shouldn't be null as i'm doing this:

(main class)

public IslandManagerFile islandFile;

(on enable method)

this.islandFile = new IslandManagerFile(instance);

quaint mantle
#

somebody told me otherwise

tender shard
#

it's used to share code between all constructors

quaint mantle
#

but nice

tender shard
#

I have tested this

carmine valley
#

hey guys, how do I set a non-static int to all players? if you've been following with my Knockback plugin, then I want to make the heatValue for each player and not global like it is right now

jagged quail
#

ok thats good

tender shard
# quaint mantle somebody told me otherwise
public class Test {

    {
        System.out.println("Test");
    }
    
    public Test() {
        
    }
    
    public Test(String asd) {
        
    }

    public static void main(String[] args) {
        new Test();
        new Test("asd");
    }


}

this prints "Test" twice

tender shard
quaint mantle
tardy delta
#

then set it in onLoad

tender shard
#

maybe other plugins need your instance before your onLoad ran 😛

quaint mantle
#

well

tardy delta
#

then fuck those

compact haven
#

^^^^ it's called using depends in plugin.yml

tender shard
#

anyway can't hurt to set it as soon as possible

acoustic pendant
quaint mantle
hasty prawn
acoustic pendant
tender shard
#

there is no reason to delay setting the instance to "this". One should do it as soon as possible, no matter when you need it.

jagged quail
#

im guessing that the build time varies on how much load the system has

tender shard
#

it makes no sense to wait until onLoad to set the instance

acoustic pendant
#

ehm

quaint mantle
acoustic pendant
#

shouldn't be

tender shard
acoustic pendant
humble tulip
#

It doesn't matter whether u thinknit should or shouldn't

tender shard
#

also I like the { } syntax because it confuses total bneginners lol

#

static { } is also awesome

hasty prawn
quaint mantle
#

anyway

jagged quail
#

gonna upload the updated version to github

acoustic pendant
quaint mantle
#

using ConfigurationSection#get(String) on this```yaml
object:

  • a: 1
    b: 2
  • c: 1
    d: 2
(or is it because it needs a parent?)
acoustic pendant
#

and then in OnEnable method

tender shard
#

static { is so awesome, for example for stuff like this

public class AdvancementInfo {

    private static final Class<?> CLASS_CRAFTADVANCEMENT;
    private static final int MC_VERSION;


    static {
        Class<?> tmp = null;
        try {
            tmp = getNMSClass("org.bukkit.craftbukkit", "advancement.CraftAdvancement", true);
        } catch (Exception ignored) { }
        if(tmp == null) throw new NMSNotSupportedException();
        CLASS_CRAFTADVANCEMENT = tmp;

        MC_VERSION = McVersion.getMinor();
    }
quaint mantle
jagged quail
carmine valley
tender shard
carmine valley
#

loop what?

jagged quail
#

oh shit i left the old heal in the plugin

tender shard
carmine valley
#

well yes but how do I set them the int?

tender shard
#

what int? do you have a hashmap or sth, or what?

carmine valley
#

I don't

#

what's that

tender shard
#

so what "int" are you talking about

carmine valley
#

I want each player to have a unique one

quaint mantle
tender shard
#
private final Map<UUID,Integer> heatMap = new HashMap<>();
jagged quail
#

what should i call the Gamemode java file

tender shard
jagged quail
#

because GamemodeCommand.java seems like a long name

tender shard
jagged quail
#

ok

tender shard
#

I'd call it
com.jeff_media.pluginname.commands.GamemodeCommand

tender shard
quaint mantle
#

yeah but how

#

;-;

tender shard
#

I'll show you in a minute

quaint mantle
#

I can't find the deserialization methods bukkit uses

tender shard
# quaint mantle yeah but how
    public static ConfigurationSection fromMap(Map<String,Object> map) {
        ConfigurationSection section = new MemoryConfiguration();
        for(Map.Entry<String,Object> entry : map.entrySet()) {
            section.set(entry.getKey(), entry.getValue());
        }
        return section;
    }```
#

like this

quaint mantle
#

wait

#

oh you don't need deep copy im dumb

#

ty

carmine valley
tender shard
#

yes but you shouldn't

#

because when a player rejoins, the Player object is invalid

#

you should really use UUIDs

jagged quail
#

okay so i need to figure out to tell what a string is saying

quaint mantle
tender shard
jagged quail
#

so they do /gamemode creative for example

#

or /gamemode c

tender shard
#

okay so

#

your onCommand methods has a String[] args

#

args[0] will be "c" if they enter "/gamemode c"

#

example:
/somecommand my name is jeff
then
args[0] = "my"
args[1] = "name"
etc

jagged quail
#

have this so far:

package me.oliver193.mecha.commands;

import me.oliver193.mecha.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class GamemodeCommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String [] strings) {
        if(!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cThis command can only be used by players.");
            return true;
        }
        Player player = (Player) commandSender;
    }
}
#

need to remove the space in between String []

tender shard
# jagged quail have this so far: ```java package me.oliver193.mecha.commands; import me.oliver...
        @Override
        public boolean onCommand(CommandSender commandSender, Command command, String s, String [] strings) {
            if(!(commandSender instanceof Player)) {
                Msg.send(commandSender, "&cThis command can only be used by players.");
                return true;
            }
            Player player = (Player) commandSender;
            String targetedGamemode = args[0].toLowerCase();
            switch(targetedGamemode) {
                case "c":
                case "creative":
                    // set to creative mode
                    break;
                case "s":
                case "survival":
                    // set to survival mode
                    break;
                    // etc...
            }
        }
carmine valley
tender shard
carmine valley
lost matrix
undone axleBOT
lost matrix
#

"strings"

jagged quail
#

ah

tardy delta
jagged quail
tardy delta
#

ye but if the used did /gamemode it will throw an ArrayOutOfBoundsError

jagged quail
#

maybe i wont make a gamemode command then

#

but i can make a /fly command easily

tender shard
jagged quail
#

lol my server has the first version aka the worst

#
         if (commandSender.hasPermission("mecha.heal")) {
            player.setHealth(20);
        } else {
            Msg.send(commandSender, "&4You do not have permission to run this command.");
        }``` this should work
#

fingers crossed

#

gonna test

sacred mountain
#

it should work

#

depending on what Msg.send() is

jagged quail
#

Msg.send is my class to translate colour code

#
package me.oliver193.mecha;

import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

public class Msg {
    public static void send(CommandSender sender, String message) {
        send(sender, message, "&a");
    }

    public static void send(CommandSender sender, String message, String prefix) {
        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + message));
    }
}
sacred mountain
#

and it accepts a commandSender

#

alr

#

should work as long as your commands are setup right

jagged quail
#
name: Mecha
version: '${project.version}'
main: me.oliver193.mecha.Mecha
api-version: 1.18
authors: [ oliver193 ]
description: Mecha Plugin
website: https://github.com/oliver193/Mecha-Plugin
commands:
  heal:
    permission: mecha.heal
    description: Heal yourself.
    usage: /heal
  feed:
    permission: mecha.feed
    description: Feed yourself.
    usage: /feed```
#

plugin.yml

sacred mountain
#

main class?

#

did you set the commandexecutor

jagged quail
#
package me.oliver193.mecha;

import me.oliver193.mecha.commands.FeedCommand;
import me.oliver193.mecha.commands.HealCommand;
import org.bukkit.plugin.java.JavaPlugin;

public class Mecha extends JavaPlugin {

    private static Mecha instance;

    public void onLoad() {
        instance = this;
    }

    public void onEnable() {
        getLogger().info("Mecha is loading.");

        // Load commands
        getCommand("heal").setExecutor(new HealCommand());
        getCommand("feed").setExecutor(new FeedCommand());

    }

    public void onDisable() {
        getLogger().info("Mecha is disabling.");
    }

    public static Mecha getInstance() {
        return instance;
    }

}
sacred mountain
#

yeah that looks fine

jagged quail
#

gross first edition

#

using hacky methods

sand vector
#

how do you check to see if a item has a PDC?

lost matrix
#

?ask

undone axleBOT
#

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

#

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

sand vector
jagged quail
#

when executed by console

#

so that block works

undone axleBOT
#

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

river oracle
#

xD

#

man you illiterate as fuck

#

just ask the question and someone will help you

#

are you a troll this has to be a troll

#

I give up

tender shard
#

stop spamming

river oracle
#

its definitly a troll

#

or a 10 year old

undone axleBOT
#

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

river oracle
#

👀

compact haven
#

listen man

#

the command ?ask is there for us to tell you "ASK THE QUESTION"

ivory sleet
#

?ban @quaint mantle trolling

river oracle
#

Can you read yet?

undone axleBOT
#

Done. That felt good.

tender shard
carmine valley
#

I made a hashmap to track player's heat value, how can I retrieve the int using the UUID ?? cpp @EventHandler public void onJoin(PlayerJoinEvent event2) { heatMap.put(event2.getPlayer().getUniqueId(), 0); } }

tender shard
#

or wait for conclure to ban them

#

oh it already happned

#

lol

lost matrix
river oracle
tender shard
jagged quail
tender shard
jagged quail
#

dont even need to add the extra stuff it does it for me already ;p

tender shard
#

yes, that's what plugin.yml is for

jagged quail
#

ok i'll go remove that extra shit i added

#

which isnt needed

#

alex do you want the very first build i made of it

#

to see how bad it is

lavish folio
#

this is equation from explosion

carmine valley
quiet ice
#

+ 1

#

Though I'd use .getOrDefault

#

Not get

tender shard
quiet ice
#

Valhalla when

carmine valley
tender shard
quiet ice
#

no, set with put

carmine valley
#

aight

tender shard
tender shard
#

if someone wants to be spoonfed, they get it

#

it's their own fault that they won't understand anything then

lost matrix
#
  public static <T> void increment(Map<T,Integer> map, T object) {
    map.compute(object, (key, value) -> value == null ? 1 : value + 1);
  }
quiet ice
#

Or:

map.merge(key, 1, (old, ignore) -> ++old);
tender shard
tender shard
#

but wait

#

if value is null it should be 0 not 1

quiet ice
#

Nah, use Map#merge, no Map#compute

carmine valley
#

why not this int heatValue = heatMap.get(event.getEntity().getUniqueId()); heatValue++; heatMap.put(event.getEntity().getUniqueId(), heatValue);

lost matrix
quiet ice
#

Project Valhalla is not a thing yet

#

Unless you come from the future

#

In that case I am relieved that it is a thing

tender shard
#

wtf is this valhalla thing you keep mentioning all the time

quiet ice
#

Universal generics

lost matrix
#

I also really like using MutableInt for this

  public static <T> void increment(Map<T, MutableInt> map, T object) {
    map.getOrDefault(object, new MutableInt(0)).increment();
  }
quiet ice
#

And LWorld

tender shard
#

I really have no idea what you're talking about lol

quiet ice
#

Then you don't care about performance all that much heh

tender shard
#

I actually don't

lost matrix
tender shard
#

I only care about performacne when it's worth it

lost matrix
#

I mean if you have very hot code then you can use FastUtils

quiet ice
#

Well avoiding boxing will have a massive performance impact

tender shard
#

avoiding chunk loading will have a massive performance impact

#

avoiding unboxing has a totally neglegible performance impact

unkempt peak
quiet ice
#

It tends to be worse than one thinks

lost matrix
quiet ice
#

But really Valhalla also ships nice QoL changes such as Records

#

Ah, that was Amber

#

They do have primitive classes as JEP 401/402, which has more or less the same spirit

spare marsh
#

for some reason my plugin runs the onDisable method whenever I do /stop but if I do /restart it doesn't. Anybody know how this is possible>

jagged quail
#

i did a fly command ;D

#
package me.oliver193.mecha.commands;

import me.oliver193.mecha.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.ArrayList;

public class FlyCommand implements CommandExecutor {

    private ArrayList<Player> list_of_flying_players = new ArrayList<>();
    @Override

    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if(!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cThis command can only be used by players.");
            return true;
        }

        Player player = (Player) commandSender;
        // Enable/disable fly mode
        if (list_of_flying_players.contains(player)){
            list_of_flying_players.remove(player);
            player.setAllowFlight(false);
            Msg.send(player, "&cFlight has been disabled.");
        }else if(!list_of_flying_players.contains(player)) {
            list_of_flying_players.add(player);
            player.setAllowFlight(true);
            Msg.send(player, "&aFlight has been enabled.");
        }
        return true;
    }
}
spare marsh
jagged quail
#

gonna test it

quiet ice
jagged quail
#

💀

#

im not very good at java

tardy delta
spare marsh
#

There is easier/better ways to do it but I think that works for someone who doesn't know much java

quiet ice
#
  1. Using ArrayList instead of List (You declare using the interface most of the time)
  2. list_of_flying_players being in snakeCase
  3. Using ArrayList instead of HashSet (Set is better at #contains)
  4. The alias parameter is mislabled
  5. The args parameter is mislabled
  6. Having a class called Msg (Class names should be descriptive)
  7. .contains and .remove can be in one call
  8. No need to call .contains twice - if X does not contain Y, we know that X does not contain Y and do not need to test that again
  9. Not checking whether another plugin has disabled flight in the meantime
  10. Using <Player> instead of <UUID> (Avoid memory leaks)
  11. @Override is blatantly misplaced
  12. No space between ) and {, while sometimes it exist (Keep code consistent)
  13. Relatively useless comments (Code should be self-documenting)
  14. list_of_flying_players should be final
  15. list_of_flying_players too descriptive. The fact that it is a list is already shown through the datatype
#

So yeah, there is a bit too much wrong there

harsh totem
#

If I use Raid.getLocation() do I get the center of the village?

#

or a different location in the village

jagged quail
#

would this be better in this case @quiet ice

#

when i put UUID it comes up with java.util

quiet ice
#

Yeah, that is the right one

quiet ice
#

though really you'd have private final Set<UUID> flyingPlayers = new HashSet<>();

jagged quail
#

it imported that

quiet ice
#

that is the correct import

compact haven
#

a UUID isn’t a Minecraft thing lol

#

It’s a global standard for unique id’s of any resource

jagged quail
#

so i need to get the uuid somehow

#

from the player

#

unless my shit code is wrong

quiet ice
#

?jd-s

undone axleBOT
dusk flicker
#

get it from the player object?

tardy delta
dusk flicker
#

have you gotten that far into spigot without knowing how to get a unique id? Not trying to be rude or anything just honestly wondering

tardy delta
#

HashSet#remove will return true if it was actually able to remove the element
also HashSet#add will return the same, but for adding

vale ember
#

how can i get item's attack speed and damage from it attribute modifiers?

jagged quail
#

ok all the errors are gone now just these which i can ignore i guess

quiet ice
#

Well at least your IDE is set to be pedantric

vocal cloud
#

I mean you can just implement the fixes to them and have no warnings lol

jagged quail
#

my 4gb ram begging for mercy

tardy delta
#

show what's exactly in that spot

compact haven
#

no

tardy delta
#

is it just a list like

list:
  - "player blalblala
```"
brittle lily
#

what does "instance" do?

compact haven
#

A list #contains must have an element in the list match exactly

#

yes

tardy delta
#

then you have to specify the entire string

#

i guess you want to use a map

jagged quail
#

okay, gonna test this now

#
package me.oliver193.mecha.commands;

import me.oliver193.mecha.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public class FlyCommand implements CommandExecutor {

    private final Set<UUID> flyingPlayers = new HashSet<>();
    @Override

    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if(!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cThis command can only be used by players.");
            return true;
        }

        Player player = (Player) commandSender;
        // Enable/disable fly mode
        if (flyingPlayers.contains(player.getUniqueId())){
            flyingPlayers.remove(player.getUniqueId());
            player.setAllowFlight(false);
            Msg.send(player, "&cFlight has been disabled.");
        }else if(!flyingPlayers.contains(player.getUniqueId())) {
            flyingPlayers.add(player.getUniqueId());
            player.setAllowFlight(true);
            Msg.send(player, "&aFlight has been enabled.");
        }
        return true;
    }
}
#

need the spacing

#

shoot

acoustic pendant
#

How can i make this to be created when the server starts? I have tried save resource but i don't know how to use it.

jagged quail
#

@quiet ice @tardy delta your method worked

tardy delta
ruby fjord
#

Guys I need to store Data from MySQL to an HashMap.

Basically on the database I have UUID and Playernames related to UUIDs

I am selecting the Columns from the table

"SELECT UUID,NICKNAMES FROM databasename ";

So now I have UUID and Nicknames in the ResultSet.

How can I iterate through it to put in the HashMap<UUID,String> the values?

humble tulip
#

while (resultSet.next)

#

resultset.getString(Uuid)

#

And resultSet.getString(nickname)

#

And put it in the map

humble tulip
#

Maven filtering corrupts schematics

acoustic pendant
#

uhm

ruby fjord
#

I am new about mysql, I just know the basic, but with this function I will load correctly all the UUID and Playernames related in the HashMap?

acoustic pendant
#

sure wait a sec

ruby fjord
#

I mean, UUIDs corresponding to pplayernames correctly

humble tulip
#

resultSet.next tells u if there are more rows in the resultset and moves to the next one if there is

#

So everytine you get data from a resultset, it corresponds to a row so yes

tardy delta
# jagged quail

a thing might be to check if the player is not in creative before disabling its flight, cuz it overrides it

acoustic pendant
#

nvm, now works

humble tulip
#

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>schem</nonFilteredFileExtension>
<nonFilteredFileExtension>tar.gz</nonFilteredFileExtension>
<nonFilteredFileExtension>tgz</nonFilteredFileExtension>
<nonFilteredFileExtension>gzip</nonFilteredFileExtension>
<nonFilteredFileExtension>schematic</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>

#

Make sure you have the schematic extension as non filtered

quiet ice
#

Or just filter whatever is required

#

whitelists > blacklists, change my mind

dusk flicker
#

ye

humble tulip
#

well ur gonna have yml and schematic

#

So it doesn't matter

#

Cuz it's just 1

unkempt peak
humble tulip
#

It's a paper fork which is a spigot fork

#

So it probably works

cursive sand
#

what is this teleport api i keep hearing about?

humble tulip
#

Complete compatibility with any plugin compatible with Paper

tardy delta
#

papers async teleport

humble tulip
#

Is tp that expensive?

#

That it needs to be async

tardy delta
#

just a completablefuture afaik

#

have never used it but i took a look at the src

daring lark
#
        return inventory.getItem(inventory.first(type));
    }``` what is wrong with this code?
ruby fjord
#

Hey Minion, Because I store UUID using UUID Binary16, how can I get them in the resultset?
I have binned to them so SELECT BIN_TO_UUID(UUID) etc, but How can I get them?

daring lark
#
        at java.util.Arrays$ArrayList.get(Arrays.java:4165) ~[?:?]
        at net.minecraft.core.NonNullList.get(NonNullList.java:47) ~[paper-1.18.1.jar:git-Paper-186]
        at net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity.getItem(RandomizableContainerBlockEntity.java:111) ~[?:?]
        at org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventory.getItem(CraftInventory.java:49) ~[paper-1.18.1.jar:git-Paper-186]
        at me.placek.blockeconomy.tools.InventoryManager.getItem(InventoryManager.java:32) ~[BlockEconomy.jar:?]
        at me.placek.blockeconomy.tools.InventoryManager.removeItems(InventoryManager.java:21) ~[BlockEconomy.jar:?]
        at me.placek.blockeconomy.commands.test.onCommand(test.java:18) ~[BlockEconomy.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        ... 21 more```
tardy delta
#

inventory.first returning -1

daring lark
tardy delta
#

i thought the method was called inv.firstEmpty

#

there is no slot

#

simple

daring lark
#

but there is

#
        for(ItemStack item : inventory.getContents()) {
            if(item != null) {
                if(item.getType().equals(type))
                    return item;
            }
        }
        return null;
    }``` it's better for me
humble tulip
#

U could just use uuid as a string

#

And do UUID.fromString()

#

To get back your uuid

ruby fjord
#

No problem because I am using Binary 16 UUID? and calling it using a String method?

humble tulip
#

Idk what binary16 uuid is sry

#

SELECT BIN_TO_UUID(uuid, true) AS uuid, nickname FROM foo;

ruby fjord
#

Yes that's what I am doing, thanks minion

harsh totem
#

In command executor what is the parameter label for?

#

like if I use /idk label would be "idk"?

#

ok thx

sand vector
#

I have this piece of code which creates an explosion. Is there a way to increase the power of the explosion so it could destroy anything?(max obsidian)

humble tulip
#

I dont think any explosion can break obsidial

#

U can break it yourself though

sand vector
#

yeah my bad forgot about that 🤦‍♂️ . Can you change the power of tnt though?

harsh totem
#

If I have "RED" in a string how do I use it like ChatColor.RED?

opal juniper
#

ChatColor.valueOf(String)

harsh totem
#

ok

calm karma
#

hey there, I have a question which I am a bit dumbfounded about. I have never had problems with Spigot Events and maybe it is completely obvious, but I am registering a listener class, and in the class i have two eventhandlers. The blockbreakevent handler works and gets called, the blockplaceevent however does not. Does anyone know why?

opal juniper
#

Send the code

#

?paste it

undone axleBOT
calm karma
brittle lily
opal juniper
calm karma
#

that's what i am thinking too haha

humble tulip
#

If you return false, bukkit sends the usage to the player

iron glade
#

how is this thing with the item meta done?

#

that it changes color all the time

brittle lily
humble tulip
#

What do u see in ur chat

brittle lily
#

just /setwarp

iron glade
#
public CommandSetWarp(WarpMain plugin){
    this.plugin = plugin;
    plugin.getCommand("setwarp").setExecutor(this);
}```
Is this a thing?
#

First time seeing someone register the command directly in the same class

humble tulip
#

U can do that

brittle lily
#

yep

humble tulip
brittle lily
#

yeah I tried but same

humble tulip
#

Paste ur main pls

iron glade
#

whats ur plugin.yml looking like?

iron glade
brittle lily
#

?paste

undone axleBOT
humble tulip
#

nah

brittle lily
humble tulip
#

Just get the inv and update thenitemstack

#

Maybe every 2 ticks

iron glade
#

hmm

#

hmm

brittle lily
humble tulip
#

U can abstract it away tbh if you wirte a good menu library

#

Arda u sure u do new CommandSetWarp in ur main

iron glade
#

^

brittle lily
acoustic pendant
#

Caused by: java.lang.NullPointerException: Cannot invoke "com.sk89q.worldedit.schematic.SchematicFormat.load(java.io.File)" because the return value of "com.sk89q.worldedit.schematic.MCEditSchematicFormat.getFormat(java.io.File)" is null

Why is this null?


        WorldEditPlugin worldEditPlugin = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
        File schematic = new File(SkyblockPlugin.getInstance().getDataFolder() + "schematics/island.schematic");
        EditSession session = worldEditPlugin.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(SkyblockPlugin.getInstance().getSkyblockWorld()),
                10000);

        try {
            CuboidClipboard clipboard = MCEditSchematicFormat.getFormat(schematic).load(schematic);
            clipboard.paste(session, new Vector(loc.getX(), loc.getY(), loc.getZ()), false);
        } catch (MaxChangedBlocksException | DataException | IOException e) {
            e.printStackTrace();
        }```
humble tulip
#

Paste your main before u test

iron glade
#

does it end with .schem or .schematic?

acoustic pendant
#

schematic

iron glade
#

what version are you using ur plugin on?

acoustic pendant
#

1.8

iron glade
#

okay should work then

#

check the path

humble tulip
#

Don't use +

#

Replace the plus in file

#

With a,

acoustic pendant
#

i'll try

iron glade
#

shouldn't change anything

#

I use + too and it works

acoustic pendant
#

same error

humble tulip
#

Check if schematic.exists()

#

And print schematic.toString

harsh totem
#

I'm getting java.lang.IllegalArgumentException: The embedded resource 'config.yml' cannot be found in plugins/main-1.0.jar and idk why.
I have this in my main file ``` this.saveDefaultConfig();
config.addDefault("playerMutedColor", "RED");
config.addDefault("playerMutedText", "The chat is currently muted!");

    config.addDefault("chatMutedColor", "RED");
    config.addDefault("chatMutedText", "The chat has been muted!");

    config.addDefault("chatUnmutedColor", "GREEN");
    config.addDefault("chatUnmutedText", "The chat has been unmuted!");```
limber owl
#

event for when player crafts item in crafting table?

harsh totem
harsh totem
acoustic pendant
limber owl
acoustic pendant
#

but still the same error

iron glade
harsh totem
harsh totem
limber owl
humble tulip
#

Ah ok so it exists

acoustic pendant
#

yes

humble tulip
#

Did u do what intold u with the resource filtering?

acoustic pendant
#

File schematic = new File(SkyblockPlugin.getInstance().getDataFolder(), "schematics/island.schematic");

#

this?

#

oh

#

that thing

#

but the schematic does exists

#

it doesn't get filtered right?

iron glade
#

@humble tulip same thing that caused me trouble you mean?

harsh totem
#

@iron glade thank you! it works

iron glade
limber owl
#

how do I get player from CraftItemEvent and how do I change it's result

humble tulip
acoustic pendant
humble tulip
#

Make sure schematic files are ignored

acoustic pendant
#

hmm

acoustic pendant
#

how was that?

#

i'm looking pom.xml and don't find it

harsh totem
#

@limber owl it's getWhoClicked()

iron glade
#
                        <nonFilteredFileExtension>schem</nonFilteredFileExtension>
                        <nonFilteredFileExtension>tar.gz</nonFilteredFileExtension>
                        <nonFilteredFileExtension>tgz</nonFilteredFileExtension>
                        <nonFilteredFileExtension>gzip</nonFilteredFileExtension>
                        <nonFilteredFileExtension>schematic</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>```
limber owl
iron glade
#

I think the schem and schematic one is enough but as it started to work for me I didn't want to touch it anymore

#

@acoustic pendant

acoustic pendant
#

paste it right?

iron glade
#
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <nonFilteredFileExtensions>
                        <nonFilteredFileExtension>schem</nonFilteredFileExtension>
                        <nonFilteredFileExtension>tar.gz</nonFilteredFileExtension>
                        <nonFilteredFileExtension>tgz</nonFilteredFileExtension>
                        <nonFilteredFileExtension>gzip</nonFilteredFileExtension>
                        <nonFilteredFileExtension>schematic</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>
                </configuration>
            </plugin>```
#

that's where I have it

#

and it stopped all my trouble with schematics getting corrupted

cedar hull
#

Hello there dear friends, does any spigot plugin works like vault on 1.18.2 version?

iron glade
#

vault is still working for me

cedar hull
#

can u send me

iron glade
#

it's the official one from the site

cedar hull
#

1.18.2 vault

acoustic pendant
iron glade
#

?paste show me your pom

undone axleBOT
acoustic pendant
iron glade
#

did you reload maven?

#

in the top right

harsh totem
humble tulip
#

Maven resources plugin

harsh totem
#

did you use it?

humble tulip
#

U put it in thencompiler. Plugin

#

The compiler plugin*

iron glade
#

ah yes indeed

acoustic pendant
#

yea

brittle lily
iron glade
#

has to be in the resources one

#

sometimes it shows red but there are no problems, did you reload maven?

acoustic pendant
#

yes

harsh totem
#

Is there a way to make auto completions in a config.yml?

humble tulip
humble tulip
#

Paste

limber owl
#

thx

acoustic pendant
#

?paste

undone axleBOT
acoustic pendant
humble tulip
#

Wrong plugin as we told u

#

It's the maven resources plugin

#

Delete all thebred stuff

iron glade
#

still in the compiler plugin

humble tulip
#

U can remove all the useless extensions

harsh totem
#

how do I make notes in a config.yml file?

humble tulip
harsh totem
#

k

acoustic pendant
#

well, the schematic "created" but i have other error xD i'll try to figure it out thanks

tardy delta
#

those are called comments

limber owl
#
if(type == Material.WOOD_AXE || type == Material.STONE_AXE || type == Material.IRON_AXE || type == Material.GOLD_AXE || type == Material.DIAMOND_AXE)
``` any way to improve this if statement?
acoustic pendant
#

yea, it's related with the paste#

humble tulip
#

Can we see

acoustic pendant
#

well, if you want

iron glade
acoustic pendant
humble tulip
#

Are you using fawe?

acoustic pendant
#

fawe?

humble tulip
#

So no

#

Fast async worldedit

iron glade
acoustic pendant
#

don't think so

humble tulip
#

Regular worldedit sucks

#

Use fawe

iron glade
#

did you paste more than 10000 blocks?

acoustic pendant
#

uhm

#

I downloaded this schematic, i don't really know what is it

tardy delta
chrome beacon
tardy delta
#

or check if the name ends with AXE yes

#

didnt really take a look at the materials

limber owl
chrome beacon
#

API may change. It might not be an Enum in the future

tardy delta
#

smh when it changes edit it

brave sparrow
#

In which case you just change it to a HashSet

humble tulip
#

That'll break so many stuff

chrome beacon
#

This is noted in the 1.18 release post

humble tulip
#

It won't matter

iron glade
#

guys handsdown which api are you using atm?

crude cobalt
#

Please tell me how to do something similar. Maybe someone has a guide or know?

quiet ice
#

API as in what?

iron glade
#

bukkit / spigot / paper

brave sparrow
#

As long as the variable type is just Set<Material> like it’s supposed to be and is just initialized with an EnumSet, you can easily swap that out when you need to update

#

Custom spigot

#

Lol

tardy delta
#

if youre checking Enum#name and it isnt an enum anymore if will break too

tardy delta
#

and i guess when material changes to a class, there are still a kind of constants?

quiet ice
crude cobalt
crude cobalt
humble tulip
#

Not item

crude cobalt
humble tulip
#

You have textures for the inventory

crude cobalt
humble tulip
#

That's a player head

crude cobalt
terse raven
#

as you dont want to overwrite the inventory

humble tulip
terse raven
# crude cobalt No, i want, that this texture have only one inventory

Today I'll show you how to add new GUIs (graphical user interface) to Minecraft! You don't have to replace any pre-existing GUI textures and you can make anything you like, new containers, new storage blocks, new crafting station, whatever you want!

►Subscribe - http://bit.ly/Subscribe_Sarc
►Follow Me On Twitter - http://bit.ly/SarcTweet

─────...

▶ Play video
terse raven
brave sparrow
#

Oh we found the same video

#

Lol

terse raven
#

youtube is recommending me alot of simply sarc recently

#

i dont know why

crude cobalt
#

You are the best

calm karma
# humble tulip Test this

I tested it and I realise this is a bit offtopic, but I was running it on a mohist server and there it is not working. On vanilla spigot everything works great.
On the offchance that anyone here knows of any possible reasons, I would appreciate any help :)

terse raven
brave sparrow
#

There’s also this one @crude cobalt https://youtu.be/SbdLNsWn7aI

Today I'll show you a brand new, custom Mana Bar in Minecraft! This trick allows you to display pretty much anything you like on the screen as a custom HUD!

►Subscribe - http://bit.ly/Subscribe_Sarc
►Follow Me On Twitter - http://bit.ly/SarcTweet

───────
Other info:
───────

Music: http://incompetech.com
Sound Effects: http://www.freesfx.co.uk...

▶ Play video
limber owl
#

Probably dumb question but any idea how to determine spawn placements for uhcrun?

terse raven
#

whats uhcrun

calm karma
humble tulip
#

Wat is mohist

terse raven
calm karma
#

yes its a forge plugin hybrid server

limber owl
#

Uhc? You never heard of it?

terse raven
#

yea but what is uhc run

limber owl
#

Faster version

#

Like enchants for shovel, axe, pickaxe, and it autosmelts your resources when you mine them

terse raven
#

so you want spawn placements for player, items or what

harsh totem
#

When I make a plugin it's name has the version in it's end and I don't want it. I tried to remove it but id makes an error.
Is there a way to make the version null or something like that?

limber owl
#

Players

#

Normal uhc spawning, how to determine where to spawn the platform and players on it

terse raven
#

divide your play area into the same amount of chunks that you have players

#

and then tp the players into the center of those chunks