#help-development

1 messages · Page 1691 of 1

fallow hearth
#

just increment the ID bei 10_000 or something and check if it spawns

#

And check if there is a player-entry in the tab-list for that player

tepid cargo
#

Spigot breaks a vanilla mechanic where explosions push invulnerable mobs. Any idea how to fix?

proud basin
#

How could I make this lighter than what it's already ababab hex color

stiff ember
#

How light?

proud basin
#

like a decent amount

#

I want to still be able to see the white but like not too much

stiff ember
#

Did you try a color picker?

quaint mantle
#

what

echo basalt
#

What is the error?

#

are you saving it as a .bat file?

#

yeah

#

save it as a .bat file

#

Save as

#

All files

#

start.bat

#

ug

#

save

#

and run the file

#

all files

#

same thing

paper viper
#

is it private or something?

#

oh

#

you need to verify

echo basalt
#

you didn't use the all types option

#

yea

#

uh

#

rename your spigot.jar to just spigot

#

as you have it as spigot.jar.jar atm

#

means you got no ram

quaint mantle
#

how much ram do you have installed?

gaunt hatch
#

What was world.setGameRuleValue replaced with?

quaint mantle
#

on your system

worldly ingot
#

Just setGameRule(), Doc

vague oracle
#

world.setGameRule(GameRule.DO_PATROL_SPAWNING, false);

worldly ingot
#

as is noted in the deprecation notice ;p

vague oracle
#

try 4

#

also aren't you meant to have a min value or is that not required?

gaunt hatch
#

Would be cool if when they are deprecated they tell you why and what to use. I guess I am asking for to much.

eternal oxide
#

They do, you just can't read

worldly ingot
#

It does

#

Literally right there lol

quaint mantle
gaunt hatch
#

i mean in code not on the online javadocs

worldly ingot
#

Download the docs

#

Spigot's done their part, do yours lol

unreal quartz
#

ye u lazy

eternal oxide
#

I can assume you are using Eclipse if you don;t see teh javadocs in your IDE

gaunt hatch
#

Can you import them?

worldly ingot
#

Eclipse shows docs just fine Elgar KEKW

unreal quartz
#

click button

eternal oxide
paper viper
#

if you use intellij you get nice formatting

unreal quartz
gaunt hatch
#

This is what i see

#

I dont use maven

#

Need to how i can do this i did not know i could import them

unreal quartz
#

it is automatic for gradle

gaunt hatch
#

well i guess not cause what i posted it what i see for that method

unreal quartz
#

google is your friend

gaunt hatch
#

Yup doing that now

unreal quartz
gaunt hatch
#

What should i use the spigotapi?

unreal quartz
#

this is from spigot-api (see bottom line)

gaunt hatch
#

yea that looks way better

#

nope still the same

#

implementation "org.spigotmc:spigot-api:$MINECRAFT_VERSION-$SPIGOT_API_VERSION-SNAPSHOT"

unreal quartz
#

is there a sources jar in ur dependencies

gaunt hatch
#

yes

unreal quartz
#

just add the documentation manually

gaunt hatch
#

how? is the question

unreal quartz
gaunt hatch
#

That i found, but the issue is that file path i have nothing in.

vague oracle
#

you change 6 to 4 and save the file

young knoll
#

Do you have 64bit java

#

Mhm

paper viper
#

yes

young knoll
#

You can’t see your file extensions

#

So it’s technically named start.bat.txt

#

Iirc it’s an option in the view tab

#

Google can probably help

quaint mantle
#

why you askin me

#

you're in notepad

#

its just text

#

if you open a .java file its just text

#

code is just txt until its turned into machine code

quaint mantle
#

how do i modify the text of an existing hologram

paper viper
#

like entity uuid?

quaint mantle
#

i think i could edit it inside the if statement but i want hologram3 to be public to all if statements

young knoll
#

Do you have any control over the namespace when you register a command with brigadier, or will it always be minecraft:command

paper viper
#

or like define the variable at least

#

if that makes sense

quaint mantle
paper viper
#

then do it

#

lol

quaint mantle
#

how do i replace p.getLocation with player cords

paper viper
#

asign p.getLocation to a variable and reasign it?

prime reef
#

wait...can you have custom sounds without replacing any?

#

I've been under the impression that you can't

young knoll
#

You can

quaint mantle
quaint mantle
#

so i guess im confused

#

how exactly do i use AttributeModifier to increase health

#

i know the URLs, i know the GENERIC_MAX_HEALTH

#

im just wondering like... how?

quaint mantle
#

ykw nvm

summer scroll
#

I'm trying to create a multi-module project with Maven, can someone guide me with it? Right now I have a project but I want to implement a feature with NMS.

ivory sleet
#

I could if it was gradle

summer scroll
#

Ah, is it complicated to switch from Maven to Gradle?

ivory sleet
#

I wouldn’t say

#

But some assert it is

#

It’s like 1 command in the cmd line

summer scroll
#

I can try maybe

#

Let me open up a thread real quick

#

Converting Maven project to Gradle in IntelliJ

ivory sleet
#

Alright download https://gradle.org/releases

Then put it into the directory
C:\Gradle

Then add an environment variable under Path called, C:\Gradle\gradle-7.2\bin

#

Assuming u use Windows

#

Or doc

#

Once you’ve done that, you can basically open up the IntelliJ terminal and run gradle init

summer scroll
ivory sleet
#

I mean there aren’t really anything else going on rn

summer scroll
#

For the multi module too

ivory sleet
#

But sure Ig

quaint mantle
#

how to make a livingentity not drop items

#

cancel the drops in ondeath ? (if it is possible)

quasi flint
#

or just clear em

#

but yeah that will work

quaint mantle
#

ok thanks

#

and anyway to spawn a livingentity naturaly ?

#

like how zombies spawn

#

give the entity spawn chance

quaint mantle
#

that could not help cause im not using nms for the mob

quasi flint
#

?

quaint mantle
#

and the thread did not explained

quasi flint
#

packets?

quaint mantle
#

bukkit

#

livingentity

quasi flint
#

oh so no custom entity

#

i see where this is going

quaint mantle
#

it kinda is

quasi flint
#

no clue then

#

sorry :c

open prairie
#

Cant teleport a player on first join

gray zodiac
#

Anyone knows how to repeat a message every minute?

eternal oxide
#

?scheduling

undone axleBOT
gray zodiac
#

worked ty

#

took me 3 hours to create a simple plugin bruh

crude charm
#

?learnjava

undone axleBOT
burnt current
#

Hey! short question:
I try to connect my Spigot plugin with a MySQL Database. For this purpose I have created the following class:
https://hastebin.com/qinejabexa.java
My config for this looks like this:
https://hastebin.com/juxirokuni.yaml
This is what my Main Class looks like:
https://hastebin.com/nulupijaha.java

Then when i start the plugin i get the following error:
https://hastebin.com/zowajuwipu.sql

where the most important places would be the following:

at de.straussfalke.straussfalkeserverplugin.MySQL.DataSourceProvider.testDataSource(DataSourceProvider.java:32) ~[?:?]
        at de.straussfalke.straussfalkeserverplugin.MySQL.DataSourceProvider.initMySQLDataSource(DataSourceProvider.java:27) ~[?:?]
        at de.straussfalke.straussfalkeserverplugin.Main.onEnable(Main.java:41) ~[?:?]```

These all lead to the line `try (Connection conn = dataSource.getConnection()) {`
Which can be found in the first link / class I sent in the `testDataSource` method.

Unfortunately, I don't know what I could have done wrong and therefore wanted to ask for help here.
eternal oxide
#

English

burnt current
#

oh sorry 😅

#

so i should make my Methods in my MySQL Class unstatic?

eternal oxide
#

yes, call them via your dataSource instance not static

burnt current
#

so wait...
I just need to make this unstatic?:

public static DataSource initMySQLDataSource() throws SQLException {
        MysqlDataSource dataSource = new MysqlConnectionPoolDataSource();

                dataSource.setServerName(Main.instance.getConfig().getString("host"));
                dataSource.setPortNumber(Main.instance.getConfig().getInt("port"));
                dataSource.setDatabaseName(Main.instance.getConfig().getString("database"));
                dataSource.setUser(Main.instance.getConfig().getString("user"));
                dataSource.setPassword(Main.instance.getConfig().getString("password"));

                testDataSource(dataSource);
                return dataSource;
    }

    private static void testDataSource(DataSource dataSource) throws SQLException {
        try (Connection conn = dataSource.getConnection()) {
            if(!conn.isValid(1000)) {
                throw new SQLException("Database not connected");
            }
        }
    }```
eternal oxide
#

and fix your main

#

dataSource = new DataSource(this)

burnt current
#

so I should remove private DataSource dataSource;.
and replace dataSource = DataSourceProvider.initMySQLDataSource(); from my try cathc block in the main method with your example?

eternal oxide
#

no

#

teh Field is fine

#

but you are never instancing your DataSource

burnt current
#

I do that in my try catch block in my on enable method.

#
try{
            dataSource = DataSourceProvider.initMySQLDataSource();
            if(dataSource.getConnection() != null)
                Bukkit.getLogger().info("MySQL Database connected!");
            else {
                getLogger().log(Level.SEVERE, "MySQL database connection is null");
                return;
            }

        } catch(SQLException e) {
            getLogger().log(Level.SEVERE, "Could not establish MySQL Database Connection ", e );
            return;
        }```
eternal oxide
#

No you don't you never pass an instance of main to the constructor. You static access

burnt current
#

Sorry, I don't quite understand what you mean.

eternal oxide
#

You only ever access your DataSource via static methods. The class requires a reference to Main, which you never pass it as you never instance call the class.

#

You never call its constructor

burnt current
#

ok and where and how can i do this right?

eternal oxide
#

I told you. Remove all your static methods and instance your class in your main with dataSource = new DataSource(this);

burnt current
#

ok so i made public static DataSource initMySQLDataSource() to public DataSource initMySQLDataSource()
and private static void testDataSource(DataSource dataSource) to private void testDataSource(DataSource dataSource)
and i edited my onEnable method so it looks like this:

@Override
    public void onEnable() {
        String s;
        instance = this;
        this.saveDefaultConfig();
        dataSource = new DataSource(this);
        try{
            dataSource = DataSourceProvider.initMySQLDataSource();
            if(dataSource.getConnection() != null)
                Bukkit.getLogger().info("MySQL Database connected!");
            else {
                getLogger().log(Level.SEVERE, "MySQL database connection is null");
                return;
            }

        } catch(SQLException e) {
            getLogger().log(Level.SEVERE, "Could not establish MySQL Database Connection ", e );
            return;
        }
    }```
eternal oxide
#

DataSourceProvider?

#

if thats teh name you need to instance that. dataSource = new DataSourceProvider(this);

#

your init method doesn;t need to return anything

#
dataSource = new DataSourceProvider(this);
try {
   dataSource.initMySQLDataSource();```
burnt current
#

ok i have done that. but new DataSourceProvider(this) gives me an error in my IDE: expexted 0 arguments but found 1. then when I remove this it tells me that it needs a DataSource type and I have provided it with a DataSoruceProvider. I guess because I created the variable before with private DataSource dataSource;.

#

so should I then also change private DataSource dataSource; to private DataSourceProvider dataSource;?

eternal oxide
#

in your main yes

burnt current
#

okay

#

now the line if(dataSource.getConnection() != null) gives an error: cannot resolve 'getConnection' in 'DataSourceProvider'

eternal oxide
#

Your DataSourceProvider is a wrapper, so you need to expose methods in that to access your database

#

you should not expose the database connection directly

#

also MysqlDataSource dataSource needs to be a field in the class as you are accessing it from other methods.

calm whale
#

hey guys does anyone know what is this error ? Invalid entity rotation: NaN, discarding

opal juniper
#

it just means you cannot pass a NaN to the method

eternal oxide
#

NaN = Not a Number

opal juniper
#

idk where you are getting it tho

calm whale
#

I'm not sure but I think I get it when I disconnect my account during this code which is executed in a repeating task

#
for(Player p : WORLD.getPlayers()){

  if(!lasers.containsKey(p.getUniqueId()) /*&& p.getGameMode() == GameMode.SURVIVAL*/){
    createBeam(p, WORLD, lasers);
  }

  try {
    if(p.isOnline())
      lasers.get(p.getUniqueId()).moveEnd(p.getLocation());
    else
      lasers.get(p.getUniqueId()).stop();
  } catch (ReflectiveOperationException e) {
    e.printStackTrace();
  }

}```
opal juniper
#

what is the whole error- is there a stack trace?

calm whale
#

well I get nothing else that a huge spam of Invalid entity rotation: NaN, discarding even when I have no more laser beam

#

I thought it was because I was disconnected so I added the isOnline check

opal juniper
#

hmm doubt

calm whale
#

but it didn't fix it

eternal oxide
#

That online check is pointless

calm whale
#

the world.getPlayers already does it

eternal oxide
#

you also know that when no one is online the for loop will never enter so you can;t stop any lasers

calm whale
#

ok I'm gonna edit this to loop through the hashmap keys

opal juniper
#

i imagine the error is coming from the method

#

*class

eternal oxide
#

You'd probably be better looping your lasers rather than players

burnt current
eternal oxide
#

Not in main, in your DataSourceProvider

burnt current
#

there i already have this Variable

eternal oxide
#

You need it as a Field not a variable

burnt current
#

how should that looks like?

eternal oxide
#

a variable is inside a method. A Field is a class level variable.

#

you have it as a variable in a method at the moment. It needs to be a Field

burnt current
#

does i understand that right that i just should put the Variable outside of the Method?

calm whale
#

ok

#

so

#

it works

#

but

#

the the problem was not what I expected

#

the error occurs when I have a laser beam running and I call this code

#
Random r = new Random();
        int max = r.nextInt(10 - 5) + 5;
        count = 0;

        fireballTask = new BukkitRunnable(){

            @Override
            public void run(){

                if(count >= max)
                    cancel();

                for(int i = 0; i < GameSettings.FIREBALLS_COUNT; i++){

                    int x = r.nextInt(50 + 50) + -50;
                    int z = r.nextInt(50 + 50) + -50;

                    Location loc = new Location(WORLD, x, 90, z);
                    Fireball ball = loc.getWorld().spawn(loc, Fireball.class);
                    ball.setIsIncendiary(false);
                    ball.setDirection(WORLD.getHighestBlockAt(x, z).getLocation().toVector().subtract(loc.toVector()).normalize().multiply(2f));

                }

                ++count;

            }
        }.runTaskTimer(RushToTheBeacon.getInstance(), 0, 15);```
burnt current
# eternal oxide yes

ok and then i have created a getConnection method which looks like this:

 public DataSource getConnection() {
        try {
            dataSource.getConnection();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        
    }```
so there is missing a return statement and im not sure what i should return there
quaint mantle
#

Hello , does i can check if "beacon" word is exist in config file?

#

i have tried to use getStringList().contains

#

but not works for me

#

example

eternal oxide
#

you return dataSource.getConnection(); or null

quaint mantle
#
Location:
 spawn: x, y, z
 pvp: x,y,z```
#

so i want to check if pvp is exist

#

okay @eternal oxide

eternal oxide
tardy delta
#

file.getString("Location.pvp") != null?

quaint mantle
#

@tardy delta not works

#

bcz

#

Location.pvp is not exist

#

i just want to check

#

if it's exist or not

quasi flint
#

well that deos excstcky that

#

excactly

tardy delta
#

doesnt it return null when not exist?

quasi flint
#

when its null it just stops

#

if it ecusts it continues

#

exists

tardy delta
#

oh :/

quasi flint
#

u can prob add a !

fading pulsar
#

Hi I want write a double xp plugin
But my plugin doesn't trigger PlayerExpChangeEvent(Console don't have "test: (Amout)" Who can teach or help me answer the question

@EventHandler
    public void expchange(PlayerExpChangeEvent event) {
        Player player = event.getPlayer();
        int getexp = event.getAmount();
        int int_val = Integer.parseInt(getConfig().getString("default.expdouble"));
        int TotalAmout = (getexp * int_val);
        player.setExp(TotalAmout);
        Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GRAY + "test: " + int_val);
    }
quasi flint
#

if u want to do smth when its null

#

registered it in the main?

fading pulsar
quasi flint
#

yes

fading pulsar
#

public class Main extends JavaPlugin implements Listener {

quasi flint
#

no in ur onEnable

quaint mantle
#
try {
        if (LocationManager.Config.getString("Spawns.pvp") != null) {
            // code
        } 
} catch (NullPointerException nullPointerException) {
    nullPointerException.printStackTrace();
}```
like this ? @quasi flint @tardy delta
tardy delta
#

FileConfiguration#contains(String)?

fading pulsar
#
public void onEnable() {
        Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GRAY + "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
        Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "DoubleExpPlugin" + ChatColor.BLUE + "Enabled");
        Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Author: Dainner#2085" + ChatColor.WHITE + " | "
                + ChatColor.RED + "Version." + getDescription().getVersion());
        Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GRAY + "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
        this.saveDefaultConfig();
        this.getServer().getPluginManager().registerEvents(this, this);
    }

this?

tardy delta
#

dont catch npr

quaint mantle
tardy delta
#

heh

quasi flint
#

do smth when it hullpoints

quasi flint
#

u @override the method

#

remove this.

#

only getServer.blablabla

fading pulsar
#

remove what

#

getPluginManager()?

tardy delta
#

work with \n

quasi flint
#

change this.getServer to getServer.getPluginManager etc

#

just remove the this.

fading pulsar
#

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

tardy delta
#

doesnt really matter

#

yea

quasi flint
#

yea

#

wont change a thing

#

its just lookin better

fading pulsar
#

no it just look error

quasi flint
#

that shouldnt happen

#

whats the error?

fading pulsar
#

getServer cannot be resolved

quasi flint
#

send ur whole class

#

?paste

quaint mantle
undone axleBOT
fading pulsar
quasi flint
#

oh i did not notice that

quaint mantle
#

why this method is deprecated
why things like potioneffettype or entitytype getbyname method is not

quasi flint
#

whats jt saying?

fading pulsar
#

But same no't trigger

quaint mantle
quasi flint
#

@quaint mantle Its an old method

quaint mantle
#

is there any other way for it ?

quasi flint
#

new one is getByKey

quaint mantle
#

and how to get it with a namespacedkey ?

quasi flint
#

Enchantment.getByKey(NamespacedKey key);

fading pulsar
#

1.    public void expchange(PlayerExpChangeEvent event) {
2.      Player player = event.getPlayer();
3.      int getexp = event.getAmount();
4.      int int_val = Integer.parseInt(getConfig().getString("default.expdouble"));
5.      int TotalAmout = (getexp * int_val);
6.      player.setExp(TotalAmout);
7.      Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GRAY + "test: " + int_val);
8.    }

line 7 edit to line 2
line 2 edit to line 7
Console have send( "test: " + int_val) But now no't send ("test: " + int_val)

mossy laurel
#

Is there a way to load dependency in-runtime with 'libraries' section, while dependency isn't in maven central? Specifing repository or something.

quasi flint
#

Enchantment.getByKey(NamespacedKey.minecraft(name));
}

quaint mantle
#

like this ?

#

oh

#

wait

fading pulsar
#

Emm...

quasi flint
#

gold cool send ur whole class

#

?paste

undone axleBOT
quasi flint
#

multi taskin as hell rn

fading pulsar
#

all code?

quasi flint
#

the whole class

#

?paste

undone axleBOT
fading pulsar
#

Emm i paste all code

quasi flint
#

command not registered

#

and maybe first register everything

#

then send messages

#

i dont see nothing erong

fading pulsar
#
name: DoubleExpPlugin
main: co2.rto.DoubleExpPlugin.Main
version: 1.0
author: COVID19
commands: 
  dexp:
    usage: /dexp [reload]
tardy delta
#

COVID19

#

smh

fading pulsar
#

i have register command

quasi flint
quasi flint
fading pulsar
quasi flint
#

look at my link

quaint mantle
#

what could be null here should i ignore it ?

quasi flint
#

there it explains now

#

his hand could be null

#

prob ignore it

#

or maybe try catch

#

i dunno

quaint mantle
#

ok thx

quasi flint
#

i would ignore it

fading pulsar
quaint mantle
fading pulsar
#

this project is All code in one file

quaint mantle
#

You still need to register the command

fading pulsar
#

Error。

quaint mantle
#

iirc you have to to use this

paper viper
#

just saying, you should really at least learn basics like importing

paper viper
#

this is already referring to the plugin

#

you cant set the command executor to the same plugin

#

you have to define a new instance of the command executing class

#

he just isnt importing it

#

or the class name is wrong

quaint mantle
#

Mhh idk, i never put all code in one file. :^)

fading pulsar
#

I never put the code in more than two files :^)
because my plugin all just have reload command
no't other command

quasi flint
#

which is a bad waynof doing java shit

#

of

fading pulsar
#

w

#

i test the event

tardy delta
tardy delta
#

german

#

i thought i saw dutch

fading pulsar
#
@EventHandler
    public void expchange(PlayerExpChangeEvent event) {
        Player player = event.getPlayer();
        int getexp = event.getAmount();
        int int_val = Integer.parseInt(getConfig().getString("default.expdouble"));
        int TotalAmout = (getexp * int_val);
        player.setExp(TotalAmout);
    }

this ( player.setExp(TotalAmout); ) no't trigger but... why?

quasi flint
tardy delta
#

learning german verbs rn 😢

quasi flint
#

because the event is not executed

#

in dont know what u made wrong

quasi flint
tardy delta
#

Guten Tag

#

maybe one word smh

quasi flint
#

well morning is the first step

#

but german is hard af

#

how long u learned it for now?

tardy delta
#

uhh 2 years in school

quasi flint
#

i see

fading pulsar
tardy delta
#

still dont get the A2 on my level test 😳

quasi flint
quasi flint
fading pulsar
#

just no't trigger "f" ( no trigger player.setExp )

tardy delta
#

or maybe just

quasi flint
#

setExp uses doubles

#

if i recall coreectly

fading pulsar
#

Oh!

#

let me edit and try

quasi flint
#

but i dont know for certain

tardy delta
#

doesnt matter calling an int where it expects a double

quasi flint
#

rounding be gone tho

fading pulsar
quasi flint
#

then di what u have to do

fading pulsar
#

but same no't trigger xD

ancient plank
#

no't

quasi flint
#

🍞

fading pulsar
#
@EventHandler
    public void ExpChange(PlayerExpChangeEvent event) {
        Player player = event.getPlayer();
        int getexp = event.getAmount();
        int int_val = Integer.parseInt(getConfig().getString("default.expdouble"));
        int TotalAmout = (getexp * int_val);
        float d=(float) TotalAmout;
        player.setExp(d);     <<this no't trigger
    }
tardy delta
#

making three ints and a float inside a method 🤔

quasi flint
#

castjng an int to an float

#

ouch

ancient plank
#

🤔

#

double to int to float

tardy delta
#
@EventHandler
public void onExpChange(PlayerExpChangeEvent event) {
  Player player = event.getPlayer();
  player.setExp(event.getAmount() * Double.parseDouble(getConfig().getString("default.expdouble")))
}

?

fading pulsar
ancient plank
#

doesn't

tardy delta
#

set the amount to a very high and check if it works

fading pulsar
#
default:
  expdouble: "10.0"
#

Emmm my check is

@EventHandler
    public void onExpChange(PlayerExpChangeEvent event) {
      Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GRAY + "a");
      Player player = event.getPlayer();
      Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GRAY + "b");
      player.setExp(event.getAmount() * Integer.parseInt(getConfig().getString("default.expdouble")));
      Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GRAY + "c");
    }

www (Console doesn't send "c")

young knoll
#

There is a getInt for config you know

eternal oxide
#

you can't getInt on a double

echo basalt
#

and I'm pretty sure you're coming into floor(num) issues when casting to int

fading pulsar
#

i very sure is

player.setExp(event.getAmount() * Integer.parseInt(getConfig().getString("default.expdouble")));

dosen't trigger

eternal oxide
#

that line is probably throwing an exception so C never prints

fading pulsar
#

But i don't know what's is the problem

eternal oxide
#

show your config that has the default.expdouble

fading pulsar
#
default:
  expdouble: "10.0"
eternal oxide
#

why are you using a string/double?

paper viper
#

Double.parseDouble

#

that's a decimal btw

#

i dont think the parseInt supports .0

fading pulsar
paper viper
#

then do Float.parseFloat

quasi flint
#

that says what u have to do

paper viper
#

i dont see a point of actually using float

#

maybe you should use double if you wanted to lol

#

for precision

quasi flint
#

?learnjava

undone axleBOT
fading pulsar
#

Emm what is getAmout() 's return? int? double? float?

quasi flint
#

ur ide is jur help

#

your

fading pulsar
#

?_?

ancient plank
#

if u hover over it in your IDE, it will tell u what it returns if you read

#

if you can't read, rip

#

learn to read

stoic ravine
#

Anyone managed to have different textures to same armor in 1.12.2 or lower?

#

I tried durablity but minecraft forces the normal texture when equipping so im really curious if there is a solution for this in version under 1.14

tardy delta
#

weewoo

ancient plank
#

a server I used to dev for made use of NBT tags and optifine, idk any other solution

#

you can set nbt tags with a name, and optifine / mods can read the nbt tags on an item and apply different textures to them

quasi flint
#

it says

#

woops

#

wrong channel

quaint mantle
#

Hello so i'm asking for does i can make a cooldown
but when the server restarts it's saving the cooldown with out reset it

gaunt hatch
#

hmm is it just me or does it seem in 1.17(+) the world chunk(s) don't seem to want to unload at all.

stoic ravine
#

@ancient plank doesnt everyone need to have optifine then?

ancient plank
#

yes.

#

that's why I said its a solution

stoic ravine
#

Yeee thanks, you cant force palyers to auto download optifine like you can force them to download a texture pack if they allow it?

ancient plank
#

na you can't force them

#

its one of those things where you have to coerce them like "If you download optifine with our resource pack you can see these awesome textures"

stoic ravine
#

ye true i guess

robust forge
#

What would be the best way to register multiple listener classes?
Normally I would do:
Bukkit.getPluginManager().registerEvents(new Class_Name(), this);
But is there a better method to do that for bigger core plugins? For example if I have 30 classes that implements listener can I somehow loop trough all of them and register them? The code looks pretty bad with one big chunky method that has 30 rows of the example code.

stoic ravine
#

sad only that there is no real solution. but ye that sounds good cuz ill just have decent textures for those who dont use optifine

tardy delta
#
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new Listener, this);
...
#

or put them into an array and loop over them idk

robust forge
#

Yeah but I dont want to have 30 rows of
pm.registerEvents(new Listener, this);

gaunt hatch
#

you could use reflection

tardy delta
#

^^

robust forge
#

Any example?

gaunt hatch
#

that is some advance stuff man, might want to learn refection before you start playing with it, you can do so bad damage with it

tardy delta
robust forge
#

Thanks

gaunt hatch
#

that works lol

tiny wolf
#

Hey anyone know why when I save my bungee config it completely removes comments and reformats it ?

tardy delta
#

thats just the api

#

you could create a new one but that goes brr

tiny wolf
#

oof really

#

why did they make the spigot one way better lmao

tardy delta
#

🤷

#

its just the same with spigot

tiny wolf
#

with spigot it keeps it the same when you save it

gaunt hatch
#

Anyone know what is up with chunks and not wanting to unload in 1.17(+)

solid cargo
#

any way a custom entity can drop an item while its still alive

burnt current
hasty prawn
solid cargo
hasty prawn
golden turret
#

how could i detect when a method is being called? using reflection

eternal oxide
burnt current
hasty prawn
#

Am I reading that right? Are you trying to connect to the address "connect"...?

burnt current
#

no?

#

at least I don't know anything about it

eternal oxide
#

DataSourceProvider.java:33

#

?paste the DataSourceProvider class

undone axleBOT
burnt current
hasty prawn
#

What's in the config

#

Don't send the password, just the other fields

burnt current
#
MySQL:
  host: localhost
  port: 3306
  database: straussfalkeplugins
  user: Server
  password: <password>```
eternal oxide
#

you are setting all your dataSource values to null

#

getString("host") will return null as its "MySQL.host"

burnt current
#

oh yeah sure. i will fix that

#

okay the error is gone but now comes [StraussfalkeServerPlugin] MySQL database connection is null What was created by the user and should come exactly when the database connection corresponds to zero.

shy wedge
#

Hey, is there something like Location.distance() but it ignores Y coordinate?

ivory sleet
#

Just manipulate y?

burnt current
#
try{
            dataSource.initMySQLDataSource();
            if(dataSource.getConnection() != null)
                Bukkit.getLogger().info("MySQL Database connected!");
            else {
                getLogger().log(Level.SEVERE, "MySQL database connection is null");
                return;
            }

        } catch(SQLException e) {
            getLogger().log(Level.SEVERE, "Could not establish MySQL Database Connection ", e );
            return;
        }

is the corresponding code

ivory sleet
#

You can set one’s y to the other’s y value

chrome beacon
#

You can always calculate the distance yourself or set the location y so they match

#

Why did that take 20 seconds to send

#

Discord u good

shy wedge
#

lol

#

Indeed, very smart thanks

eternal oxide
#

it should be returning a Connection, not a DataSource

burnt current
#

I had now specified null as the return type, since you said earlier that I can return either dataSource.getConnection or null.

#
public DataSource getConnection() {
        try {
            dataSource.getConnection();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }

thats the Method

eternal oxide
#

no you return the result of getConnection, or null

#

return dataSource.getConnection();

burnt current
#

ok

quaint mantle
burnt current
#

now it looks like that:

public DataSource getConnection() throws SQLException {
        try {
            dataSource.getConnection();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return (DataSource) dataSource.getConnection();
    }
}```
eternal oxide
#

remove the cast and make the method return a Connection

quaint mantle
#

why did you cast it

#

what is happening right now

burnt current
#

It was a suggestion from the IDE so I thought it would be useful.

quaint mantle
#

weird

eternal oxide
#

you are returning a Connection not a DataSource

burnt current
#

yes i changed it

eternal oxide
#

your IDE is too dumb to tell whats wrong

burnt current
#

yeah the Database now has connected

old cloud
#

Hello. I want to store an area of blocks so I made a wrapper class to serialize BlockState Objects. The problem is that it obviously doesn't save the content of a chest or of a sign. How can I store those values as well?

burnt current
#

Thank you so much for your help and sorry for the trouble I have caused

old cloud
hasty prawn
#

BlockState I think is what you want.

old cloud
slim kernel
tardy delta
#

?paste

undone axleBOT
tardy delta
old cloud
undone axleBOT
eternal oxide
old cloud
#

Yea, I was hoping I could just save some other values and it would work but thats obv not the case

vernal pier
#

You can save the nbt of the tile data

eternal oxide
#

needs to be dataSource = new DataSourceProvider(this);

old cloud
slim kernel
burnt current
eternal oxide
#

then your DataSourceProvider is wrong. Its constructor shoudl be public DataSourceProvider(JavaPlugin plugin) {

old cloud
#

after .build()

slim kernel
old cloud
burnt current
pastel coyote
#
    public static String f(String s) {
            return ChatColor.translateAlternateColorCodes('&', "{prefix}" + s);
    }

yo fellas so basically i have this util to format my messages but want it to add with prefix, i've tried replacing the prefix using ``plugin.getConfig().toString("Prefix")` but returns null in console afterwards. any suggestions? 🤔

sorry if this seems obvious

solid cargo
#

ayo can someone tell me on how to declare a world. im asking cause im tired asf and not functioning

slim kernel
old cloud
tardy delta
#

why is this redundant? i just check if the player already executed that command and increase the teller if thats true
if (uses.get(uuid) < 2) uses.put(uuid, uses.get(uuid) + 1);

hasty prawn
#

You're not doing anything in it

tardy delta
#

well i check if its smaller than 2 and then teleport them

hasty prawn
#

Oh wait nvm

slim kernel
hasty prawn
#

I read it wrong

tardy delta
#

oh

old cloud
#

or <Player> depending on what you want to store

slim kernel
old cloud
#

np

tardy delta
#

and what does inlining mean?

pastel coyote
hasty prawn
#

You don't need to assign getLocation(p, name) to a variable since you only use it once.

Just put getLocation(p, name) where you use loc.

old cloud
tardy delta
#

but if its null i want to return

pastel coyote
tardy delta
#

?

pastel coyote
#

is there a class you want to return?

tardy delta
#

just return in a void smh

pastel coyote
#

what do need help with? 🤔

toxic mesa
#

I got a packet listener and stuff and got this

            PacketPlayInPosition posPacket = (PacketPlayInPosition) packet;
            Bukkit.broadcastMessage("x: " + posPacket.a);
            Bukkit.broadcastMessage("y: " + posPacket.b);
            Bukkit.broadcastMessage("z: " + posPacket.c);
            Bukkit.broadcastMessage("possible ground boolean: " + posPacket.g);
            Bukkit.broadcastMessage("possible ground boolean2: " + posPacket.h);

x y and z are correct and stuff but there are 2 booleans which are g and h. I was expecting one of them to be the onGround boolean and yet 1 is a constant true and the second is a constant false. Any way I can get the onGround value from the packet?

old cloud
#
(seconds / 60) + ":" + (seconds % 60)
old cloud
#

But I think there is actually a better way, not sure atm

eternal oxide
#

quite possibly

hasty prawn
#

@tardy delta https://paste.md-5.net/nukofufode.cs that's how I would do it. I didn't really check your time messages. I don't really know why you're converting it to days, but I assume you have your reasons? PauseChamp

upper vale
#

Use %02d for the minutes if you want it like 03 instead of 4

#

*3

old cloud
eternal oxide
#

other stuff?

old cloud
#

Like the text of a sign, content of a commandblock or chest, etc...

eternal oxide
proper shore
tardy delta
burnt current
#

@eternal oxide I have another question regarding MySQL. How should I create my methods to insert something into my table?

late dove
#

How to place a player in a worldguard group? I need this for a different number of private players. I'm sorry for the question.

slim kernel
# old cloud np

Just one last question: do I need to register the arrayList somehow?

slim kernel
eternal oxide
burnt current
#

do you have an example?

eternal oxide
#

no

old cloud
#

Because command block for example isnt there

eternal oxide
#

I never tested on a command block

burnt current
eternal oxide
#

mainly because a command block should not be anywhere near TNT

old cloud
#

Yea

eternal oxide
#

I didn;t think about it honestly

old cloud
#

Can't I just get all the NBT data or something and store that?

eternal oxide
#

No clue, I only use the API

burnt current
#

I had already found an example:

public boolean someMethod(Object obj1, Object obj2) {
    try (Connection conn = conn(); PreparedStatement stmt = conn.prepareStatement(
            "INSERT INTO player_coins(uuid, coins) VALUES(?, ?);"
    )) {
        stmt.setSomething(1, obj1);
        stmt.setSomething(2, obj2);
        stmt.execute();
        return true;
    } catch (SQLException e) {
        logSQLError("Something went wrong.", e);
    }
    return false;
}```
but I don't know what the conn() method should look like in that case
eternal oxide
#

thats a connection you get from your provider

burnt current
#

like this?:

public Connection getConnection() {
        try {
            return dataSource.getConnection();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }```
hasty prawn
#

Couldn't you technically use reflection to get all the values and serialize those?

#

Not sure how it would know what to save and what not to save, but it would atleast be able to be generalized over all the special block cases

ivory sleet
#

Ye

#

You could just include a strategy pattern for the exclusion

hasty prawn
#

True. I assume most the stuff you'd want excluded is in the main BlockState class anyways. All the stuff within the subclasses are probably pretty important KEKW

ivory sleet
tardy delta
#

worldguard hates me, i've set some neccesary flags up and when i leave a horse worldguard says that i may not leave because i cant re enter, i overrid that event so you can leave them but now i cant enter horser :/

#

and worlguard thinks i'm still on that horse while i'm not

crimson terrace
#

is there a way to keep a creeper from despawning when it explodes?

ivory sleet
#

I believe not

#

Unless you’d fake the explosion

chrome beacon
#

I'd just spawn an explosion

crimson terrace
#

totally related question: can I spawn an entity into the world which I made before? aka spawn the creeper into the world after it disappears

tardy delta
#

event priority highest is executed the last right?

ivory sleet
#

iirc no

#

Monitor is last

chrome beacon
#

^

hasty prawn
#

It is

tardy delta
#

but monitor cant cancel the event?

ivory sleet
#

It can

#

Just by convention shouldn’t

tardy delta
#

that

chrome beacon
#

Don't cancel in Monitor

ivory sleet
#

Altho plugins like LuckPerms do it

hasty prawn
#

smh

tardy delta
#

i want to decide as last whether or not to cancel the event

#

to override worldguard smh

burnt current
ivory sleet
# hasty prawn smh

Or well, they disallow login at monitor state so idk it’s exactly the same thing but yeah

hasty prawn
#

I'm sure they have somewhat good reasoning behind doing it that way.

ivory sleet
#

Idk

#

Some of the design in luckperms is questionable, not because I write the most godly code myself

hasty prawn
ivory sleet
#

But they pass the plugin instance in so many classes

hasty prawn
#

Ah, instead of doing Singleton?

tardy delta
#

but which priority is executed last now?

ivory sleet
#

No dessie

hasty prawn
crimson terrace
#

if I do this, will the UUID of creeper be the same as the UUID of creeperNew?

ivory sleet
#

Thing is,they should pass their higher level components like their data managers and such instead of passing the plugin instance and then invoking blah.getDataManager()

#

imo

hasty prawn
#

Ahhh okay I'm with you now

old cloud
crimson terrace
#

perfect

old cloud
#

Which is useless

#

because if you change something in "creeperNew" it will also be changed in "creeper" and visa versa because they are the same objects

crimson terrace
#

hm

#

ok got it. complicated fix it is

old cloud
#

Anyone knows how to get and set the NBT (?) data of a block?

tardy delta
#

every time when a command is called, does that makes a new command instance?

old cloud
#

No, it just exectues "onCommand" of the registered "CommandExecutor" instance

tardy delta
#

so no new instance

#

ok

solid cargo
#

why cant i combine Item item = item blah blah blah with Bukkit.getScheduler

stone sinew
solid cargo
#
Bukkit.getScheduler().runTaskLater(SMPCore.getInstance(), () -> Item dropped1 = e.getDamager().getWorld().dropItem(e.getDamager().getLocation(), new ItemStack(Material.BOOK, 1)), 255);
#

oops

quaint mantle
#

```language
code
```

stone sinew
old cloud
solid cargo
#

dont give me the command

#

ik whats wrong

quaint mantle
#

L

old cloud
#

Thats like if you would try to do that:

void hi() {
   Item a = ...;
}

void anotherHi() {
   System.out.println(a); // <- doesnt work because its not visible here
}
solid cargo
#

ahhh

quaint mantle
#

?learnjava

undone axleBOT
solid cargo
#

NOO

#

YOU SENT IT

#

ok tis fine

quaint mantle
#

🤨

solid cargo
quaint mantle
#

Bruh

stone sinew
#
ItemStack item;
Bukkit.getScheduler().runTaskLater(Plugin, () -> {item = <your item>}, 0, 20);
old cloud
#

You need to declare the variable before your Runnable

solid cargo
#

wait

old cloud
#

yea like that, except that you need to set "ItemStack" final

solid cargo
#

i dont have to make it drop?

#

i can just

#

do the drop in the runnable?

old cloud
#

ofc

solid cargo
#

how tho?
item.dropItem(new ItemStack(Material.MATERIAL)) ?

#

and also location and shiz ofc

#

but in general like that right?

old cloud
#

Just like that in your case: e.getDamager().getWorld().dropItem(e.getDamager().getLocation(), new ItemStack(Material.BOOK, 1))

solid cargo
#

yeah but what if i want to set the velocity

old cloud
#

just do

() -> {

}
```and you have infinite lines
solid cargo
#

thats why i need to like

#

ahh

proud basin
#

Why do custom fonts look stupid when your screen is full screened in minecraft

old cloud
# solid cargo ahh

Thats the general usage of a lambda expressions. Its just a short variant of creating a new instance of an interface with 1 method.

interface MyInterface {

    T method(A a, B b, C c, ...);

}

// First (standard) variant:

MyInterface k = new MyInterface() {
    
    @Override
    T method(A a, B b, C c, ...) {
          // do your stuff here
    }

};

// Second (lambda) variant:

MyInterface l = (a, b, c, ...) -> {
      // do your stuff here
};
#

And since Runnable's method "run" doesnt have any arguments, you leave it empty like that () -> {

young knoll
#

It actually does, you just don't use it often

young knoll
# old cloud No?
        Bukkit.getScheduler().runTaskTimerAsynchronously(this, (task) -> {
            task.cancel();
        }, 10, 10);
old cloud
burnt current
#

short question: I have connected my plugin to a MySQL database and have the following class for it: https://paste.md-5.net/novulovevu.java
now I would also like to insert data into my tables and ask how exactly I can do that? (I have already dealt with MySQL - I am only interested in the JDBC part). can anyone help me with this?

young knoll
floral pewter
#

Hey, there seems to be a problem with creating stonecutter GUIs. Adding items to them via spigot seems to have no effect whatsoever. I've found this two-year-old issue on the forums which still seems relevant https://www.spigotmc.org/threads/unable-to-set-itemstack-in-stonecutter-inventory.389400/.

#

The code I'm using:

Inventory inventory = Bukkit.createInventory(player, InventoryType.STONECUTTER);
inventory.setItem(0, new ItemStack(Material.STONE));
player.openInventory(inventory);
#

The result

#

Switching out the inventorytype to chest, shulker et al. works fine, but the stonecutter is problematic

#

Calling Player::updateInventory after a tick or so does not work either

lost matrix
floral pewter
#

Adding the itemstack afterwards gives the same result. Inventory::getContents shows the itemstack regardless if I add it before or after showing it

lost matrix
floral pewter
#

I'll try that

#

setInputItem does not seem to be a method of the StonecutterInventory class. Running ```java
StonecutterInventory inventory = (StonecutterInventory) Bukkit.createInventory(player, InventoryType.STONECUTTER);
inventory.setItem(0, new ItemStack(Material.COAL));

    player.openInventory(inventory);
gives `java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryCustom cannot be cast to class org.bukkit.inventory.StonecutterInventory (org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryCustom and org.bukkit.inventory.StonecutterInventory are in unnamed module of loader 'app')`
lost matrix
#

Thats weird...

floral pewter
#

Very...

#

Perhaps I should try importing version-specific craftbukkit

crimson terrace
#

can I cancel the EntityTargetEvent without it costing too many resources?

floral pewter
#
CraftInventoryStonecutter inventory = (CraftInventoryStonecutter) Bukkit.createInventory(player, InventoryType.STONECUTTER);

inventory.setItem(0, new ItemStack(Material.COAL));
player.openInventory(inventory);

Gives java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryCustom cannot be cast to class org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryStonecutter (org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryCustom and org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryStonecutter are in unnamed module of loader 'app'), which to me is even stranger

lost matrix
#

Try this workaround.

  private final Map<HumanEntity, Consumer<StonecutterInventory>> cutterPrepMap = new HashMap<>();

  public void openStoneCutterFor(final Player player, final Consumer<StonecutterInventory> prepConsumer) {
    final Inventory inventory = Bukkit.createInventory(null, InventoryType.STONECUTTER);
    this.cutterPrepMap.put(player, prepConsumer);
    player.openInventory(inventory);
  }

  @EventHandler
  public void onOpen(final InventoryOpenEvent event) {
    final Consumer<StonecutterInventory> consumer = this.cutterPrepMap.remove(event.getPlayer());
    if (consumer != null) {
      consumer.accept((StonecutterInventory) event.getInventory());
    }
  }

...

  openStoneCutterFor(player, cutterInv -> cutterInv.setInputItem(item));
lost matrix
crimson terrace
#

its not too heavy

#

I guess my question is "How many times does it get called"

lost matrix
#

Ah wait

crimson terrace
#

I want the enderman not to target the mite and the other way around

worldly ingot
#

getTarget().getType() vs getEntityType() ;p

floral pewter
#

Still getting an empty stonecutter

lost matrix
floral pewter
#

I do not

#

But nothing is showing in the stonecutter

lost matrix
crimson terrace
worldly ingot
#

No I know I was clarifying to smile's question there

crimson terrace
#

I specifically want the targetted type tho

lost matrix
crimson terrace
#

oh ok

#

thought you were saying "replace this with that"

#

my bad

lost matrix
# crimson terrace oh ok

You can have a little performance enhancement by returning after the first event.setCancelled()

crimson terrace
#

cats can have a little salami.

#

programmers can have a little performance enhancement

#

😄 good tip. will do

floral pewter
#

Aha! The event handler fires, but the consumer does not

minor garnet
#

who is best to use, reflection or interface ?

ivory sleet
#

For what?

minor garnet
#

for nms classes

ivory sleet
#

I go with both

minor garnet
#

:

ivory sleet
#

I use some sort of abstraction, but if I have no concrete implementation for the interface I fallback to some good old nms

floral pewter
lost matrix
# minor garnet for nms classes

Interfaces perform better.
If you know how to properly cache your reflections then they get also really performant with enough time on the JIT

floral pewter
#

I am worried about not finding the setInputItem method

ivory sleet
#

Yeah well sadly Java 8 doesn’t have all those reflection optimizations I believe newer versions have in case you’re a legacy fan

lost matrix
floral pewter
#

1.17.1

#

Spigot, remapped

lost matrix
floral pewter
#

CraftBukkit?

#

Because that should be bundled through buildtools

hasty prawn
#

Is it setItem(int, ItemStack)?

floral pewter
#

That's what I see

hasty prawn
#

Is that not the same thing as setInputItem

#

Just named differently

floral pewter
#

setInputItem seems stonecutter-specific

#

Which in turn may run some stonecutter-specific update logic

hasty prawn
#

Hm, I don't know why they would've removed that method... I assume setItem(0, ItemStack) would effectively just be the same thing.

floral pewter
#

I would as well. I'm going to try capturing some packets to see if a specific slot is being used

hasty prawn
#

I mean I know Input is 0 and Result is 1 if that's what you're wondering.

floral pewter
#

ah

#

Perhaps an update packet is not sent

hasty prawn
#

There's static variables for them if you prefer to use those instead of 0 and 1

floral pewter
#

ah StonecutterMenu.INPUT_SLOT

hasty prawn
#

Yes

floral pewter
#

I'll use that, a nice alias :)

young knoll
#

So SmithingRecipes doesn't preserve the meta of the output, and if I use PrepareSmithingEvent#setResult I can't take the item out...

floral pewter
#

I solved it using NMS

#
StonecutterMenu stonecutterMenu = new StonecutterMenu(1, ((CraftPlayer) player).getHandle().getInventory());
stonecutterMenu.setTitle(new TextComponent("something"));

stonecutterMenu.setItem(StonecutterMenu.INPUT_SLOT, 0,CraftItemStack.asNMSCopy(new ItemStack(Material.COAL)));
player.openInventory(stonecutterMenu.getBukkitView());
#

For anyone interested

young knoll
#

I don't understand why I can't remove this item

waxen plinth
young knoll
#

Hmm, good idea

#

Nope

quaint mantle
#

i have a question
if i changed integer value every 1 seconds using runnables
that will give low tps and high cpu usage or will it not affect?

opal juniper
#

every one second is not that much

#

it would have a negligible effect on the server

#

And if the task is as easy as you said it is, just simply setting an int var it would be such a fast operation

quaint mantle
#

i wanna try to make cooldown using runnables and config that why i asked

#

so the integer will change for so many players

#

i wan't to make a cooldown using config because if i want to save secondsleft

#

if there another way to save integer value when server restart can someone tell me about it?

young knoll
#

You could attach it to the players pdc I guess

quaint mantle
young knoll
#

?pdc

lost matrix
quaint mantle
young knoll
#

The problem with that is time continues when the server is offline

#

You could save the time left, and then recalculate the timestamp when it starts again

lost matrix
#

😄

young knoll
#

Depends if you want that I guess

quaint mantle
#
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
        Main.getInstance().getConfig().set("Player.time", format.format(date));
        if (date > Main.getInstance().getConfig().get("Player.time")) {
            //code
        }```
it's should be like this?
but how to check if the new date bigger than  old date with 1hours?
#

and i have a error here xD if (date > Main.getInstance().getConfig().get("Player.time")) {

#

@lost matrix if you are not busy, can you help please?

eternal night
#

dates are not compared using the > operator

#

the > is for numeric primitive types

#

e.g. int,double

quaint mantle
#

mm so how to check if new date bigger than old date with 1hour ? @eternal night

eternal night
#

there is Date#before and Date#after

quaint mantle
#

well, how to use it with cooldown?
how i can set the Data before

#

date*

eternal night
#
final Date dateOneHourInTheFuture = new Date(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1));
quaint mantle
#

this will be saved if server has been restarted ? @eternal night

eternal night
#

what ?

#

no

#

pretty much on you how you are saving things

#

this just creates a date object that points to a time on hour in the future from when your code executed that created it

quaint mantle
#

oh

#

well thx dude

rigid wyvern
#

anyone familiar with how entities work on chunk load? I'm trying to prevent the pickup of certain items. when a player logs in, they have items in their inventory from the ground, but the code prevents pickup on items that weren't close enough to get picked up initially.

toxic mesa
#

So i'm used protocollib, I got this up and running and returning the correct value
player.sendMessage(PlaceholderAPI.setPlaceholders(player, "%PvpToggle_status%"));
What do I need to do for other plugins to be able to use this?

rigid wyvern
toxic mesa
#

ty

young knoll
#

Let the game handle it

rigid wyvern
young knoll
#

Delete them on shutdown?

rigid wyvern
#

the issue comes from items being dropped for an effect, and then the server closing before the timer from that effect deletes them

#

wouldn't help with crashes tho no?

young knoll
#

No

#

Add a pdc tag to the item, delete nearby ones when a player logs in

rigid wyvern
#

atm I'm using item lore, which also helps me keep them from stacking with eachother, but it's not loading that before the pickup happens

#

I might do the pickup delay and delete on close. if they aren't deleted on server stop, they'll never be able to get picked up and someone will just need to burn them

young knoll
#

Like I said, pdc

rigid wyvern
#

would that work when the lore doesnt?

#

I figure all the data would get loaded at once

young knoll
#

It can be attached to the entity itself

#

Not the itemstack

rigid wyvern
#

oh hmm, I'll try that out then. thanks! 😄

burnt current
#

Hey Quick question: I would like to be able to insert values into the database via my database connection and have already created the following:

private DataSourceProvider dataSource;


    public Connection conn() {
        dataSource = new DataSourceProvider(Main.getPlugin());
        return dataSource;
    }

    public boolean addPlayer(UUID uuid, String playername, int coins) {
        try (Connection conn = conn(); PreparedStatement stmt = conn.prepareStatement("INSERT INTO playerdata (UUID, playername, coins) VALUES (?,?),")) {
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

However, return dataSource; returns an error because a connection is expected there.
I don't know what I have to change. Can anyone help me to correct this?

young knoll
#

You gotta return dataSource.getConnection

#

Or change the return type

dull sparrow
#

[NMS] How to register a custom entity 1.17.1 ?

burnt current
#

now I have the problem that I cannot call the method where I need it (in which case it is in a different class) even though the method is public

young knoll
#

Do you have an instance of the class

burnt current
#

No

wary harness
#

got qustion is it possible to prevent specific method to run two times

#

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

              try {
                  if (!getMysql().isConnected()) {
                      getMysql().connect();
                  }


                  PreparedStatement statement = getMysql().prepareStatement("SELECT time FROM Vyplata WHERE uuid=?");
                  statement.setString(1, uuid.toString());
                  ResultSet result = getMysql().query(statement);
                  if (!result.next()) {
                      statement = getMysql().prepareStatement("INSERT INTO Vyplata (UUID,time) VALUES(?,?) ON DUPLICATE KEY UPDATE UUID=?");
                      statement.setString(1, uuid.toString());
                      statement.setDouble(2, 0);
                      statement.setString(3, uuid.toString());
                      getMysql().update(statement);
                      setData(uuid,0);
                      statement.close();
                      result.close();
                      return;
                  }

                  setData(uuid,result.getInt("time"));



              } catch (SQLException e) {
                  e.printStackTrace();
              }

          }
      }.runTaskLaterAsynchronously(this,20);


  }```
#

my load data method for player

#

but it could be runned again for example from place holder

#

asking for player data and running method again to load data but there could be one instance already in action

#

could I use here some how sync

#

or maybe I could made hashset like loading list

#

and put player uuid on start

#

in

#

and when finished remove it out

#

or on exception

quaint mantle
#

is there a reason why the PlayerCommandPreprocessEvent aint functioning ? its still doing the normal help

#

also check event sout isnt called

vague oracle
#

First use the plugins logger

#

as system out doens't really work (Idk why I Just know not to use it)

hasty prawn
#

System out works fine?

quaint mantle
#

weird since the sout on join works ( testing if events where working)

hasty prawn
#

Are you sure that your JAR is being updated @quaint mantle? That's really the only reason I can think that wouldn't be called at all.

quaint mantle
#

i manually overwrite it but ill check that one

#

works thanks

dense shoal
#

I have a Set of what are essentially chunks in a square and I want to get them into a WorldEdit region and copied with a ForwardExtentCopy

            ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
                editSession, region, clipboard, region.getMinimumPoint()
            );```
My thought process is to get the corner chunks of the Set. But I need to get the min/max coords of a chunk. Anyone know of a way to do that?
#

Please don't spoonfeed me, but a nudge in the right direction would be appreciated.

regal dew
#

find smallest chunk coordinates & biggest chunk coords

#

since its a square to get the min pos its just smallest chunk XYZ coordX * 16, 0, coordZ * 16

#

and for the max XYZ u do it with the max chunk but add 15 to the X and Z

dense shoal
#

These are my calculations, this isn't completely adding up

regal dew
#

umm why would you think largest needed is (-240,4,255) ?

#

that coordinate lies in chunk -15,15 @dense shoal

dense shoal
#

I forgot how coordinates worked. Lemme work this out and try again.

regal dew
#

I think the X,Z you showed are correct

#

but im not sure why you are adding 1 to the X

#

and subtracting 16 for the X with largest chunk coord

dense shoal
#

OK, so math aside, I'm doing this
16 * CHUNK + 15 for the larger number chunk
16 * CHUNK for the smaller chunk

Where chunk is the chunk coords

regal dew
#

yea

#

thats fine

fallen sparrow
#

I'm creating a custom crafting plugin with a custom inventory, but I need to check when an item is added to the crafting menu. What Inventory event triggers when an item is moved into an inventory, not clicked?

fallen sparrow
#

I already tried that

quaint mantle
#

appearently not correctly

fallen sparrow
#

that calls when the item is clicked not when it is placed

quaint mantle
#

what does that even mean

#

and run whatever check ur looking for

#

and broadcast what event it was

fallen sparrow
#

It calls when you pick the item out of your inventory, but not when you place it in the crafting inventory

quaint mantle
#

its just 4 lines of code

#
@EventHandler
public void inventoryEvent(InventoryEvent e){
    Bukkit.getServer().broadcastMessage(e.getEventName());
}
fallen sparrow
#

im pretty sure i already did that, but ill retry

#

Doesn't work

quaint mantle
#

then the event isnt handled by Spigot

#

because thats literally an InventoryEvent

#

so if it was, it'd had done something

unkempt peak
#

Deos your class implement Listener and is your event registered onEnable

fallen sparrow
#

ya, every thing works, except it doesnt update the recipe output when an item is taken out of the inventory or moved into it

unkempt peak
#

What are you trying to do

fallen sparrow
#

i think i got it.

#

nevermind don't got it

#

I want to run the function checkRecipeCompleted() when an item is moved into the inventory or out

#

Got it, i just had to schdule it a tick later, so i could get where it moved to

quaint mantle
#

explain to me how this is a development issue @sweet cradle

nova grove
#

How can I make a config.yml file for my plugin?

quaint mantle
frosty tinsel
frosty tinsel
stone sinew
quaint mantle
stone sinew
safe flower
#

Does org.bukkit.conversations.Conversation#begin() block until the conversation is over?

quaint mantle
#

as far as i know yeah you can do custom crafting and recipes

#

maybe its worthwhile on crafting events to listen to the itemstacks in the craft inventory

#

im fairly certain thats how it works (if thats what your goal is)

#

better than doing a scheduler imo ^

tribal sparrow
#

is there a way to get players to see skins without an issue on first join?
if you open minecraft, join the server all skins are default steve, but when moving away and back again sending the packets again when in range the skins show. Then if i disconnect again and connect (without closing mc) the skins load to the player perfectly using the same packets? i've tried with a delay on login, i've tried showing and hiding then showing again after 60 ticks nothing seems to work.

solid cargo
#

Hey how can i make the customly dropped item unpickable up

opal juniper
#

cancel the pickup event

solid cargo
#

Doesnt it cancel all books?

opal juniper
#

just check to see if the item is yours

#

using teh pdc or sommin

#

then cancel it

solid cargo
#

Make the item a meta?

opal juniper
#

mmm no i would use the pdc

#

?pdc

solid cargo
#

If item.hasMeta blah blah blah

#

Ah ok

waxen plinth
#

You don't need to cancel pickup events

#

That's a waste of processor time

#

20 times per second per player nearby

#

Just set the pickup delay to int max

solid cargo
#

Its ror a friend showcase anyways

solid cargo
waxen plinth
#

Yeah this is still easier

#

Doesn't involve handling events to do it

solid cargo
#

Ok thanks!

waxen plinth
#

👍

solid cargo
#

And is there a way to make the item not like uh

#

Going in one chonk?

opal juniper
opal juniper
solid cargo
#

You know when you drop multiple of the same items

opal juniper
#

oh

solid cargo
#

It looks like 1 item

opal juniper
#

the stacking?

solid cargo
#

Ye

#

Lesson starting. Will answer in 40 minutes!

opal juniper
#

uh i mean idrk on this one

#

there is probably an event but there may also be another way

waxen plinth
#

It's not super simple to do

waxen plinth
tribal sparrow
# solid cargo Going in one chonk?
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(new Random().nextInt(Integer.MAX_VALUE) + "");
        meta.setLore(Arrays.asList("COIN_ITEM", new Random().nextInt(Integer.MAX_VALUE) + ""));
        item.setItemMeta(meta);
        return item;
    }```
having a different display name or lore for the item will make it not go into one item
waxen plinth
#

To prevent them from merging you give them each a random UUID in their lore or PDC

#

I mean, a random number also works but is more likely to collide

#

You have to do this after the items are dropped

tribal sparrow
#

and on entityitempickup you could see if it has a display name and change it so when it's picked up it doesn't show the random number

waxen plinth
#

Yep, remove it on pickup

tribal sparrow
#

using pdc

waxen plinth
#

And if you want it to not despawn

#

Set age to int min

copper dove
#

My Ghast can't find a path to a target - the yellow underlined part returns null

#

(location 'target' is not null)