#help-development

1 messages · Page 2148 of 1

radiant cedar
#

Not from inside the jar

#

Yes so thats what I was asking initially

#

How can I do it so when I do “install” on maven build

#

It also saves the ymls

#

There

lost matrix
#

Dont cast it to an ArrayList. You dont know the actual List implementation

golden kelp
#

Then?

earnest forum
#

Just list

#

and its getKeys

#

not values

golden kelp
#

Ookay

#

why?

#

oh

#

nvm i m dumb af

#

i thought #getValues returns all the objects

radiant cedar
earnest forum
#

so you want to save the ymls to your plugin data folder?

#

you wanna do that using code inside your plugin not maven

radiant cedar
#

Ye

golden kelp
#

oh btw, the thing doesnt return a list but an set

earnest forum
#

still loopable

lost matrix
earnest forum
#

heres a decent tutorial on that @radiant cedar

earnest forum
#

its using intellij

#

do you use eclipse?

golden kelp
#
Set<String> portals = vClasses.getConfig()
    .getConfigurationSection("portals")
    .getKeys(false);

🤔

radiant cedar
#

Intellij

#

Nah i figured it out

earnest forum
#

ConfigurationSection

#

not string

#

nvm

#

ur right

#

it returns the name of the config section

radiant cedar
#

So normally I opened from my files and saved there

Now that I changed them to do it in the server plugins folder I forgot it will just save there

#

Lol

lost matrix
golden kelp
#

Thanks yous

earnest forum
#

its a set of string

#

not config section

#

you get the section from the string as its the name of the section

golden kelp
#

yea but ill modify da code accordingly

earnest forum
#

yea

lost matrix
#

Btw if you have data driven configs like that then you should most definitely create a class that implements
ConfigurationSerializable and generate the config/load your data this way.
Then all you need to do is:

List<VinPortal> portals = (List<VinPortal>) config.getList("portals");

And you dont need to worry about all that yml nonsense.
@golden kelp

golden kelp
#

O ty

#

I am doing that

#
package io.github.vinesh27.vclasses;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.potion.PotionEffect;

public record Portal (
    Location startBlock,
    Location endBlock,
    boolean replace,
    Material block,
    String[] commands,
    Material[] items,
    PotionEffect[] effects
) {}
#

Btw, does #getKeys() return the whole path OR just the key name

radiant cedar
#

can I access this from

#

here somehow

#

cus I change some values manually for now

lost matrix
golden kelp
#

by deep path you mean the children of it?

#

or just its path

lost matrix
#

Example:

  parent:
    c1:
      x: 1
      y: 1
      z: 1
    c2:
      x: 1
      y: 1
      z: 1

On the parent section: When calling getKeys(false) you get ["c1", "c2"]
On the parent section: When calling getKeys(true) you get ["c1.x","c1.y","c1.z", "c2.x","c2.y","c2.z"]

lost matrix
golden kelp
#

Yea i will replace that, i realized that later, after i was doing that yaml input

#
List<VPortal> portals = (List<VPortal>) config.getList("portals");

So I made a class

public class VPortal extends ConfigurationSerializable { 

}
#

and a constructor

lost matrix
#

One moment im writing an example.

golden kelp
#

ty

lost matrix
#
public record Portal(
        Location startBlock,
        Location endBlock,
        boolean replace,
        Material block,
        List<String> commands,
        List<Material> items,
        List<PotionEffect> effects
) implements ConfigurationSerializable {

  @Override
  public Map<String, Object> serialize() {
    Map<String, Object> map = new HashMap<>();
    map.put("startBlock", startBlock);
    map.put("endBlock", endBlock);
    map.put("replace", replace);
    map.put("block", block.toString());
    map.put("commands", commands);
    map.put("items", items.stream().map(Enum::toString).toList());
    map.put("effects", effects);
    return map;
  }

  public static Portal deserialize(Map<String, Object> map) {
    Location startBlock = (Location) map.get("startBlock");
    Location endBlock = (Location) map.get("endBlock");
    boolean replace = (boolean) map.get("replace");
    Material block = Material.matchMaterial((String) map.get("block"));
    List<String> commands = (List<String>) map.get("commands");
    List<Material> items = ((List<String>) map.get("items")).stream().map(Material::matchMaterial).toList();
    List<PotionEffect> effects = (List<PotionEffect>) map.get("effects");
    return new Portal(startBlock, endBlock, replace, block, commands, items, effects);
  }

}

Now you can save portals in configs.

#
    Portal portal = ...;
    FileConfiguration configuration = ...;
    configuration.set("somePortal", portal);

Or

    List<Portal> portalList = ...;
    FileConfiguration configuration = ...;
    configuration.set("portals", portalList);
    
    // Later
    List<Portal> gainedList = (List<Portal>) configuration.get("portals");
golden kelp
#

I dont really want to write the config

#

just reading

#

and ty

lost matrix
#

Ok but you should generate the default config by writing one or two portals.
If you are data driven then you wont create a yml file in your jar.
All you do is create a new YamlConfiguration and save two portals in there when the server starts.
Just so you see how it looks like,.

golden kelp
#

Ok but you should generate the default config by writing one or two portals.

lost matrix
#

Instead of writing one by hand

golden kelp
#

I think if I put a config.yml in ./resources and write stuff in it, when the plugin is ran, the server makes the exact config in the plugins folder?

lost matrix
#

Sure. But the config wont look like you think it will look like

golden kelp
#

then?

#
    List<Portal> portals = (List<Portal>) vClasses.getConfig().getList("portals");
    ```
portals isnt a list, rather a section containing keys
radiant cedar
#

how can I get a players uuid by their name even when offline

chrome beacon
#

Bukkit#getOfflinePlayer(name)

#

Keep in mind this might have to get the player from Mojangs servers. This means it can block the thread while doing this lookup

radiant cedar
chrome beacon
#

Yes

golden kelp
#

hey guys so I got an array of portals and they have a start location and an end location. I want to check if the player is in that area, how should I approach this

chrome beacon
#

You can use the bounding box api

#

or just calculate if the players coordinate is within the bounds

golden kelp
#

how xd

civic dagger
#

does bedwars plugins send players to another world or another bungee server? i need to send players on a different map but idk what to do

chrome beacon
golden kelp
#

2nd

golden kelp
golden kelp
#
List<ItemStack> items,

I cant figure out how to serialize ItemStack from this config section

items:
          itemOne:
            id: ITEM_ID
            amount: 1
#

discord as always, messing with the indents

lost matrix
#

Dont write a config by hand. Generate one by creating a random Portal.

golden kelp
#

yea, but still, how would you get the object from the config

earnest forum
#

u can create a custom serializer

#

depends on how deep u want to serialize the itemstack info

golden kelp
#

thats the part i lose braincells at

earnest forum
#

just the name, type and amount? or lore, enchantments

#

it serializes and deserializes itemstacks into base64

#

its for inventories but u can modify it

golden kelp
#

ty

lost matrix
earnest forum
#

yes but it doesnt serialize meta

lost matrix
lost matrix
golden kelp
earnest forum
#

does it?

lost matrix
# golden kelp ty

This should be split into different classes. But its the basic setup of how to generate a config when you are data driven:

  @Override
  public void onEnable() {
    File portalsFile = new File(getDataFolder(), "portals.yml");
    YamlConfiguration config;
    if (!portalsFile.exists()) {
      config = new YamlConfiguration();
      List<Portal> portalList = List.of(createDefaultPortal());
      config.set("portals", portalList);
      try {
        config.save(portalsFile);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    } else {
      config = YamlConfiguration.loadConfiguration(portalsFile);
    }
    // Do stuff with config
  }

  private Portal createDefaultPortal() {
    Location start = Bukkit.getWorlds().get(0).getSpawnLocation();
    Location end = Bukkit.getWorlds().get(0).getSpawnLocation();
    boolean replace = false;
    Material block = Material.AMETHYST_BLOCK;
    List<String> commands = List.of("/spawn", "/help");
    List<Material> items = List.of(Material.STONE, Material.COBBLESTONE);
    List<PotionEffect> effects = List.of(new PotionEffect(PotionEffectType.ABSORPTION, 500, 1));
    return new Portal(start, end, replace, block, commands, items, effects);
  }
golden kelp
#

I am just using config.yml i dont need a seperate file

lost matrix
golden kelp
#

No but I mean do I really need a different file

lost matrix
#

You can name it whatever

golden kelp
#

If I name it config.yml, will it cause issues?

lost matrix
#

This is how the generated file looks like:

portals:
- ==: com.gestankbratwurst.spigotsandbox.Portal
  effects:
  - ==: PotionEffect
    effect: 22
    duration: 500
    amplifier: 1
    ambient: true
    has-particles: true
    has-icon: true
  startBlock:
    ==: org.bukkit.Location
    world: world
    x: 128.0
    y: 63.0
    z: 32.0
    pitch: 0.0
    yaw: 0.0
  replace: false
  block: AMETHYST_BLOCK
  items:
  - STONE
  - COBBLESTONE
  commands:
  - /spawn
  - /help
  endBlock:
    ==: org.bukkit.Location
    world: world
    x: 128.0
    y: 63.0
    z: 32.0
    pitch: 0.0
    yaw: 0.0
golden kelp
#

ohhh

#

you are so smort

#

what does the ==: literal do

lost matrix
#

It tells the deserializer that the following section is a class that can be deserialized.

golden kelp
#

is it a YAML thing or just for spigot/bukkit

lost matrix
#

This specifically is part of spigots configuration api

#

The whole point is that you dont want to know your config structure.
All you do is write a class and the save/load that class.

golden kelp
#

o

#

and how does one add comments?

#

for the user to edit & understand

earnest forum
#

if u want to make it easy to read for like a public plugin

#

u can make ur own serializer

golden kelp
#
private Portal createDefaultPortal() {
        Location start = Bukkit.getWorlds().get(0).getSpawnLocation();
        Location end = Bukkit.getWorlds().get(0).getSpawnLocation();
        List<String> commands = List.of("/spawn %p%", "/help");
        List<ItemStack> items = List.of(new ItemStack(Material.STONE, 32), new ItemStack(Material.COBBLESTONE, 32));
        List<PotionEffect> effects = List.of(new PotionEffect(PotionEffectType.ABSORPTION, 500, 1));
        return new Portal(start, end, commands, items, effects);
    }
``` Looks good?
unique spoke
#

hey guys
i have a question, how to add gravity to EntityPlayer? (npc) with nms
can anyone help ?

eternal oxide
#

To have gravity the NPC has to have AI

elfin atlas
#

Does someone know why this gives me a normal Alex head and not a player head?
Version: 1.18.1

ItemStack item = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3);
                        SkullMeta skull = (SkullMeta) item.getItemMeta();
                        skull.setOwningPlayer(Bukkit.getOfflinePlayer(p.getUniqueId()));
                        skull.setDisplayName(p.getName());
                        item.setItemMeta(skull);
                        p.getInventory().setHelmet(item);
golden kelp
#

So I got two ends of a Nether Portal. and I have an array of those ends
How do I check if a player went in one of them and get which end was it

eternal oxide
golden kelp
#

Yes I know

#

but how do I know if that portal is in my portals array

eternal oxide
#

it tells you the portal block they are touching

golden kelp
#

Yes, i got that as well

eternal oxide
#

Then I have no idea what you are asking

golden kelp
#

Now how do I find out if that portal block is between specific startLocation and endLocation

eternal oxide
#

Math

golden kelp
#

yea thats what i cant figure out rn

eternal oxide
#

Easiest way is to create a BoundingBox from your start and end Locations. You can then use BoundingBox#contains to check the portal block

golden kelp
#

Ohh

#

ty

civic dagger
eternal oxide
#

BoundingBox.of(start, end).contains...

#

if you are using the Player BoundingBox you shoudl use BoundingBox.overlaps rather than contains

kindred valley
#

Any good docs u know about java gui

quaint mantle
#

Why do I keep haviung this problem in any sql code that I try when i try to insert the plyaer's uuid

#
\/
PreparedStatement statement = connection.prepareStatement("INSERT INTO player_data (uuid, money, chips, team) VALUES (" + p.getUniqueId().toString() + ", 500, 0, None);");```
#

Unknown column '86f4a314' in 'field list'

ivory flume
#

is there any way to stop slot transfer?

eternal oxide
#

Because you are still not using PreparedStatements

quaint mantle
#

It is a prepared statement tho ?

eternal oxide
#

no

#

you are just throwing a concatenated string into a PreparedStatement

ivory flume
#

how do I stop the transferring of items in an inventory

quaint mantle
#

like a "small" explanation

#

if u could please

eternal oxide
#

it should be VALUES (?, ?, ?, ?);

ivory flume
#

its just a way to insert stuff into a database

quaint mantle
#

Isn't it what i'm doing ?

ivory flume
#

a better way to describe it is just straight up SQL calls

#

its SQL language

eternal oxide
#

then statement.setString(1, p.getUniqueId().toString());

quaint mantle
#

OOOOOOOOO

#

kinda forgot about htat lol

#

omg thx

eternal oxide
#

do that for each value

quaint mantle
#
Connection connection = DataBase.getConnection();
        PreparedStatement statement = connection.prepareStatement("SELECT * FROM player_data;");

        statement.setString(1, p.getUniqueId().toString());
        statement.setFloat(2, 500);
        statement.setFloat(3, 0);
        statement.setString(4, "None");```
#

This is the correct code, right ?

eternal oxide
#

are those really floats?

#

not integers?

quaint mantle
#

Nope.

#

They arent.

eternal oxide
#

The columns in teh schema are floats?

quaint mantle
#

But I want to have more than 1bil in my number

quaint mantle
eternal oxide
#

if they are integer numbers you should really use bigInt then

ivory flume
#

long would suffice

eternal oxide
#

yep

quaint mantle
#

Ohh okay.

#

Parameter index out of range (1 > number of parameters, which is 0).

#

Do I first have to store them in result set ?

eternal oxide
#

no

#

a result set is what you get after the queiry

#

show your statement

quaint mantle
#
@EventHandler
    void setPlayerFirstData(PlayerJoinEvent e) throws SQLException {
        Player p = e.getPlayer();

        Connection connection = DataBase.getConnection();
        PreparedStatement statement = connection.prepareStatement("SELECT * FROM player_data WHERE uuid=12;");

        statement.setString(1, p.getUniqueId().toString());
        statement.setFloat(2, 500);
        statement.setFloat(3, 0);
        statement.setString(4, "None");

    }```
#

This is the whole snippet.

eternal oxide
#

you missed off thr VALUES

eternal oxide
quaint mantle
#

ohhh

#

so it'll auto replace the ?

#

Yep

eternal oxide
#

yeah, wrong query

#

thats a SELECT query. Your original was an INSERT

quaint mantle
#

Whats the correct way

eternal oxide
#

INSERT is for adding data to yoru table

quaint mantle
#

Yes.

#

And select is for getting data.

#

Then setString() etc...

#

right ?

earnest forum
#

google java sql basics

eternal oxide
#
connection.prepareStatement("SELECT * FROM player_data WHERE uuid=?;");
statement.setString(1, p.getUniqueId().toString());```
golden kelp
#
java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.ConfigurationSection.getKeys(boolean)" because the return value of "org.bukkit.configuration.file.YamlConfiguration.getConfigurationSection(String)" is null
        at io.github.vinesh27.vclasses.VClasses.loadPortals(VClasses.java:56) ~[?:?]
        at io.github.vinesh27.vclasses.VClasses.onEnable(VClasses.java:39) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:518) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3483-Spigot-42b6152-9cc7d76]
        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:432) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3483-Spigot-42b6152-9cc7d76]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3483-Spigot-42b6152-9cc7d76]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3483-Spigot-42b6152-9cc7d76]
        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:263) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3483-Spigot-42b6152-9cc7d76]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1007) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3483-Spigot-42b6152-9cc7d76]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3483-Spigot-42b6152-9cc7d76]
        at java.lang.Thread.run(Thread.java:833) [?:?]
#

oof

earnest forum
#

make sure what ur getting actually exists

#

wanna send the code

eternal oxide
#

?paste

undone axleBOT
golden kelp
#

lemme check if it made the file firs

#

Okay it seems the file was created

quaint mantle
golden kelp
#
portals:
- ==: io.github.vinesh27.vclasses.entities.Portal
  effects:
  - ==: PotionEffect
    effect: 22
    duration: 500
    amplifier: 1
    ambient: true
    has-particles: true
    has-icon: true
  startBlock:
    ==: org.bukkit.Location
    world: world
    x: 0.0
    y: -60.0
    z: 0.0
    pitch: 0.0
    yaw: 0.0
  items:
  - ==: org.bukkit.inventory.ItemStack
    v: 2975
    type: STONE
    amount: 32
  - ==: org.bukkit.inventory.ItemStack
    v: 2975
    type: COBBLESTONE
    amount: 32
  commands:
  - /spawn %p%
  - /help
  endBlock:
    ==: org.bukkit.Location
    world: world
    x: 0.0
    y: -60.0
    z: 0.0
    pitch: 0.0
    yaw: 0.0

#

the yaml

#

it generated

river oracle
#

== key?

#

Ohhh

#

Never done that before so I wasn't sure

#

Yea same here

river oracle
golden kelp
#

Its not the string I think

#

its the loadPortals method

#

after the config is made

river oracle
#

The path your inputting is null

earnest forum
#

show the code

golden kelp
#

    private void loadPortals() {
        Set<String> portalNames = config.getConfigurationSection("portals").getKeys(false);
        for (String portalName : portalNames)
            portals.add(
                Portal.deserialize(
                    (Map<String, Object>)
                    config.getConfigurationSection("portals." + portalName)
                )
            );
    }
#

yep its wrong

quaint mantle
#

@safe notch
is there something like mysql INSERT INTO table_name IF NOT EXISTS (column_1, column_2) VALUES (value1, value2);

river oracle
golden kelp
#

tamilpp, are u tamil xD

quaint mantle
#

Soooo, is there a way to check if uuid of that already exists ?

eternal oxide
#

You do the not exists if you expand your statement

golden kelp
#

tamilpp & TheBigDongggggg are chatting rn

#
portals:
- ==: io.github.vinesh27.vclasses.entities.Portal
  effects:
  - ==: PotionEffect
    effect: 22
    duration: 500
    amplifier: 1
    ambient: true
    has-particles: true
    has-icon: true
  startBlock:
    ==: org.bukkit.Location
    world: world
    x: 0.0
    y: -60.0
    z: 0.0
    pitch: 0.0
    yaw: 0.0
  items:
  - ==: org.bukkit.inventory.ItemStack
    v: 2975
    type: STONE
    amount: 32
  - ==: org.bukkit.inventory.ItemStack
    v: 2975
    type: COBBLESTONE
    amount: 32
  commands:
  - /spawn %p%
  - /help
  endBlock:
    ==: org.bukkit.Location
    world: world
    x: 0.0
    y: -60.0
    z: 0.0
    pitch: 0.0
    yaw: 0.0

How do I loop through all the objects under portals

#

I dont know how to get that portals list

quaint mantle
#

Would you mind writing a small snippet ?

golden kelp
#

Oh

#

bru

golden kelp
eternal oxide
#

if you only want one entry per player you set the UUID column as primary unique

quaint mantle
#
such as this \/
CREATE TABLE player_data(

    uuid VARCHAR(64) PRIMARY KEY UNIQUE,
    money BIGINT,
    chip BIGINT,
    team VARCHAR(16)

);```
#

is it important to close it ?

golden kelp
#
portals:
- ==: io.github.vinesh27.vclasses.entities.Portal
  effects:
  - ==: PotionEffect
    effect: 22
    duration: 500
    amplifier: 1
    ambient: true
    has-particles: true
    has-icon: true
  startBlock:
    ==: org.bukkit.Location
    world: world
    x: 0.0
    y: -60.0
    z: 0.0
    pitch: 0.0
    yaw: 0.0
  items:
  - ==: org.bukkit.inventory.ItemStack
    v: 2975
    type: STONE
    amount: 32
  - ==: org.bukkit.inventory.ItemStack
    v: 2975
    type: COBBLESTONE
    amount: 32
  commands:
  - /spawn %p%
  - /help
  endBlock:
    ==: org.bukkit.Location
    world: world
    x: 0.0
    y: -60.0
    z: 0.0
    pitch: 0.0
    yaw: 0.0
- ==: io.github.vinesh27.vclasses.entities.Portal
  effects:
  - ==: PotionEffect
    effect: 22
    duration: 500
    amplifier: 1
    ambient: true
    has-particles: true
    has-icon: true
  startBlock:
    ==: org.bukkit.Location
    world: world
    x: 0.0
    y: -60.0
    z: 0.0
    pitch: 0.0
    yaw: 0.0
  items:
  - ==: org.bukkit.inventory.ItemStack
    v: 2975
    type: STONE
    amount: 32
  - ==: org.bukkit.inventory.ItemStack
    v: 2975
    type: COBBLESTONE
    amount: 32
  commands:
  - /spawn %p%
  - /help
  endBlock:
    ==: org.bukkit.Location
    world: world
    x: 0.0
    y: -60.0
    z: 0.0
    pitch: 0.0
    yaw: 0.0

How do I get the elements in the portals list

quaint mantle
#

and to close it you do connection.close();?

humble tulip
#

@quaint mantle don't close your connection

#

You're using sqlite

quaint mantle
#

i'm using mysql

humble tulip
#

Now u are?

#

Do u use hikaricp?

quaint mantle
#

Yep.

#

I snatched some of your code and tweaked it a bit.

humble tulip
#

Well look at my mysqldatamanager class

#

You see how i have try (Connection connection = database.getConnection)

#

Anything in the () is automatically closed

#

@quaint mantle u can use replace into

#

If the uuid exists it replaces the other columns

#

If it doesn't it inserts it

#

Replace into works the same way as insert

golden kelp
humble tulip
#

Alternatively you can use update table set column=value where uuid=whatever

humble tulip
#

Or do you use it to store your data

golden kelp
#

Yes they do edit it

#

I make a simple structure for them

#

they edit it according to their needs

humble tulip
#

Do you make changes to the config while your plugin is enabled?

golden kelp
#

No

#

only the player does

#

I figured out how to do it

humble tulip
#

Ok great well then

#

Lol

golden kelp
#

now i got a different error

humble tulip
#

Ok

humble tulip
golden kelp
#

when I serialize the file

        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3483-Spigot-42b6152-9cc7d76]
        at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.IllegalArgumentException: Specified class does not exist ('io.github.vinesh27.vclasses.entities.Portal')
        at org.bukkit.configuration.serialization.ConfigurationSerialization.deserializeObject(ConfigurationSerialization.java:197) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.construct(YamlConstructor.java:48) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]

it seems it cant find the class

#

even though it is there

eternal oxide
#

did you register the class?

humble tulip
#

^^

golden kelp
#

Portal?

humble tulip
#

Yes

golden kelp
#

No

#

How to register it?

humble tulip
#

You need to do so in onenable

eternal oxide
#

if it implements ConfigurationSerializable it has to be registered for deserialization

golden kelp
#

Oh

#

How to register?

eternal oxide
#

read teh javadoc on ConfigurationSerializable

golden kelp
#

why does my IDE say its not a method

#

It is static

#

oh nvm i m so dumb

#

nvm i wasnt dat dumb

golden kelp
#

Ohh, its an interfface i just forgot

humble tulip
#

The class names are so confusing for serialization

golden kelp
#

Yess

quaint mantle
#

@humble tulip what i did is open then close the connection on every event

#

and close the statements as well

golden kelp
#
portals:
- ==: io.github.vinesh27.vclasses.entities.Portal
  effects:
  - ==: PotionEffect
    effect: 22
    duration: 500
    amplifier: 1
    ambient: true
    has-particles: true
    has-icon: true
  startBlock:
    ==: org.bukkit.Location
    world: world
    x: 60
    y: 60.0
    z: 60
    pitch: 0.0
    yaw: 0.0
  items:
  - ==: org.bukkit.inventory.ItemStack
    v: 2975
    type: STONE
    amount: 32
  - ==: org.bukkit.inventory.ItemStack
    v: 2975
    type: COBBLESTONE
    amount: 32
  commands:
  - /spawn %p%
  - /help
  endBlock:
    ==: org.bukkit.Location
    world: world
    x: 60
    y: 50
    z: 50
    pitch: 0.0
    yaw: 0.0

#

the file

#

I am serializing

eternal oxide
#

did you implement everything it says to implement in the javadoc?

golden kelp
#

Ohh

#

public record Portal(
    Location startBlock,
    Location endBlock,
    List<String> commands,
    List<ItemStack> items,
    List<PotionEffect> effects
) implements ConfigurationSerializable {
    
    @Override
    public Map<String, Object> serialize() {
        Map<String, Object> map = new HashMap<>();
        map.put("startBlock", startBlock);
        map.put("endBlock", endBlock);
        map.put("commands", commands);
        map.put("items", items);
        map.put("effects", effects);
        return map;
    }
    
    public static Portal deserialize(Map<String, Object> map) {
        Location startBlock = (Location) map.get("startBlock");
        Location endBlock = (Location) map.get("endBlock");
        List<String> commands = (List<String>) map.get("commands");
        List<ItemStack> items = (List<ItemStack>) map.get("items");
        List<PotionEffect> effects = (List<PotionEffect>) map.get("effects");
        return new Portal(startBlock, endBlock, commands, items, effects);
    }
    
    public static Portal valueOf(Map<String, Object> map) {
        return deserialize(map);
    }
}
#

I dont really know how to change the constructor as that will cause issues with other methods?

#

Or should I convert it to a class and have multiple constructors?

humble tulip
#

If so, you're doing it properly

golden kelp
#
public final class Portal implements ConfigurationSerializable {
    private final Location startBlock;
    private final Location endBlock;
    private final List<String> commands;
    private final List<ItemStack> items;
    private final List<PotionEffect> effects;
    
    public Portal(
        Location startBlock,
        Location endBlock,
        List<String> commands,
        List<ItemStack> items,
        List<PotionEffect> effects
    ) {
        this.startBlock = startBlock;
        this.endBlock = endBlock;
        this.commands = commands;
        this.items = items;
        this.effects = effects;
    }
    
    public Portal(Map<String, Object> map) {
        this(
            (Location) map.get("startBlock"),
            (Location) map.get("endBlock"),
            (List<String>) map.get("commands"),
            (List<ItemStack>) map.get("items"),
            (List<PotionEffect>) map.get("effects")
        );
    }
    
    @Override
    public Map<String, Object> serialize() {
        Map<String, Object> map = new HashMap<>();
        map.put("startBlock", startBlock);
        map.put("endBlock", endBlock);
        map.put("commands", commands);
        map.put("items", items);
        map.put("effects", effects);
        return map;
    }
    
    public static Portal deserialize(Map<String, Object> map) {
        Location startBlock = (Location) map.get("startBlock");
        Location endBlock = (Location) map.get("endBlock");
        List<String> commands = (List<String>) map.get("commands");
        List<ItemStack> items = (List<ItemStack>) map.get("items");
        List<PotionEffect> effects = (List<PotionEffect>) map.get("effects");
        return new Portal(startBlock, endBlock, commands, items, effects);
    }
    
    public static Portal valueOf(Map<String, Object> map) {
        return deserialize(map);
    }
}

I think I have everything now

#

It was just to avoid boilerplate

#
        ConfigurationSerialization.registerClass(Portal.class, "Portal");

Registering it in the onEnable method as well

static hollow
midnight shore
#

why do i get a fucking wall of error all with the same sentence?

waxen plinth
#

Stack overflow

midnight shore
#

wdym?

waxen plinth
#

The method is calling itself forever

#

It causes a stack overflow

midnight shore
#

and how could i fix it?

waxen plinth
#

Seems like the condition to break out is never met

#

Not sure why this is recursive anyways

#

This could easily just be a while loop

midnight shore
#

i thought this was the way to go (?)

waxen plinth
#

It's a way to go

#

Doing it iteratively is more performant

#

Usually

#

Anyways

midnight shore
#

anyways could you help me with the while loop?

waxen plinth
#

Print out the material

#

Add some debug output, whatever you need

#

Because it's never selecting a location it considers valid

#

So it keeps going on forever

#

Honestly you also shouldn't be using a list

#

You don't need a loop either

#

You can just do contains

#

That aside

midnight shore
waxen plinth
#
public static Location getRandomFishSpawnLocation(Location center, float radius, Set<Material> acceptableMaterials) {
  while (true) {
    Location loc = Util.getRandomLocationInRadius(center, radius);
    if (acceptableMaterials.contains(loc.getBlock().getType())) {
      return loc;
    }
  }
}```
midnight shore
#

whoah

#

is this ok?

blazing rune
#

Uhh how do you save doubles or ints to a config.yml?

waxen plinth
#

With ConfigurationSection#set

#

Same as any other value

#

Let's see the getRandomLocationInRadius thing too

#

It should look something like this

glass mauve
#

how can I get the url for Minecraft steve skin? I try to get the users skin with player.getPlayerProfile().getTextures().getSkin(); and I want to set the url to steve skins url if getSkin() returns null

twilit roost
#

Heyyy,
im trying to save all Treasures(Block Locations) into config.
Here's my code :

    public static void addTreasure(Chest chest){
        if(!treasures.contains(chest))
            treasures.add(chest);
        TreasureConfigManager.getDataConfig().set("treasures.players",chest.getLocation().serialize());
}

but when I run it and place some Treasures so it Saves into file it does this:
https://ctrlv.cz/e3y6

midnight shore
#

because of the Random method getting the location is always getting a relatively different location

waxen plinth
#

No

twilit roost
#

imma try to add Save at the end of it

waxen plinth
#

Just set the location itself

#

Then you can use ConfigurationSection#getLocation when you need to deserialize it

twilit roost
#

oooooh

#

okk

waxen plinth
#

Yeah I also asked to see this and haven't seen any code

midnight shore
waxen plinth
#

Damn

twilit roost
#

well it still saves the same thing

waxen plinth
#

That's not a good way of doing that

twilit roost
waxen plinth
#
public static Location getRandomLocationInRadius(Location loc, double radius) {
  double dist = Math.sqrt(Math.random()) * radius;
  loc = loc.clone();
  loc.setPitch((float) (Math.random() * 360));
  loc.setYaw((float) (Math.random() * 360));
  loc.add(loc.getDirection().multiply(dist));
  return loc;
}```
twilit roost
twilit roost
# twilit roost

that saveTreasures() doesn't do anything except printing msg

waxen plinth
#

bruh

#

why do you call load before you call save

#

that overwrites any changes with whatever is saved in the file

#

don't call load when you actually want to save

twilit roost
#

ooh that's why it wouldn't save

#

i though that you need to load the file before saving it

waxen plinth
#

no

#

loading gets the values from the file and loads them into memory

#

so calling load immediately followed by save will do literally nothing

twilit roost
#

riight
thx

#

when I have the basic structure in config:

treasures:
  players:

it delete's it and the config is blank afterwards

#

without structure it also stays blank

waxen plinth
#

.-.

#

In saveData

#

Why do you create a new YamlConfiguration

#

Of course it's deleting everything, you're creating a blank config and then saving it

#

Literally the only thing you need to do in order to save the data

#

Call save(file) on the YamlConfiguration you have been writing to

twilit roost
#

even after that its big nono

its back to ```yaml
treasures: {}

but thx for that saving thing, didn't realize that one
waxen plinth
#

There's probably some mistake in the other code

twilit roost
waxen plinth
#

My god

#

dfojghbnosjdfgbgjhsfdbjdgfbjdgohfbodghjdghbjsdghj

#

Why are you constantly creating new config objects

#

Stop

#

Of course nothing is getting written because every time you get the config it's just loading it from disk

#

Keep ONE YamlConfiguration instance, call load ONCE when you create it, and call save whenever you need to save it

#

Stop making new instances and stop loading unnecessarily

timid quail
#

i am making a clicker server where i store the money in the persistantdatastorage of the player, how can i make a leaderboard from all player's stats (including offline player)?

#

so how can i get the persistantdatastorage of an offline player?

waxen plinth
#

You can't

twilit roost
waxen plinth
#

Why would looping through online players help

#

Database is definitely better for that

timid quail
#

is firebase good? (have some experience with it)

waxen plinth
#

That's a remote database

twilit roost
#

MySQL prob better

waxen plinth
#

That would be extremely overkill

#

MySQL or SQLite

quaint mantle
#

can someone help me update plugins?

#

old abandoned plugin without a way to contact owner

waxen plinth
#

Is it open source

quaint mantle
#

I think some are

#

not all

dark harness
#

How can i place a Lit Candle?

uncut nebula
grim ice
#

i need ideas to code

uncut nebula
naive bolt
#

whats this mean

torn shuttle
#

javascript is so flexible it should be illegal

torn shuttle
# naive bolt whats this mean

I think that means the jar is corrupted or something like that's it's been a minute since I've seen that specific error

waxen plinth
maiden thicket
#

its not terrible

#

js, sure, ts? nah

tranquil viper
#

How can I include a .jar file in compilation when compiling with maven in intellij? Trying to use DeluxeCombat API and there’s no maven repo

maiden thicket
tranquil viper
#

What do I put for the dependency?

#

It’s a .jar file

sterile token
#

And then use maven-shade-plugin

tardy delta
#

system scope goes brr i heard

sterile token
#

I dont kno i have used many times and work good

#

Another option is to install the jar to your local repo

keen star
#

hi

waxen plinth
#

hi

#

how is your day

keen star
#

is there have any way to PlayerInteractEvent have hit damage? i want to make player use right click to get damage nearby entity

waxen plinth
#

Entity#getNearbyEntities

keen star
#

but entity sethealth not make entity have knockback just take a damage

keen star
waxen plinth
#

LivingEntity#damage

keen star
#

ok thank

steel swan
#

is there a way to show the players in tab only if they are in the same world?

ivory flume
#

do you mean nether/ow

steel swan
#

i mean different worlds

#

yeah can be nether/ow but also like world1/world2

tranquil viper
sterile token
#

So maybe, you can try installing the api to your lo cal maven repo

#

mvn install

uncut nebula
compact cape
#

Stupid question, But is there any way to make the plugin handle all error it cause by itself?

river oracle
#

Yea

#

I suggest

#

?learnjava

undone axleBOT
compact cape
#

I know try and catch 😮‍💨

river oracle
#

Error handling Is basic concept you need to check out

river oracle
compact cape
#

I just don't want to add try and catch everywhere...

river oracle
#

He's probably talking nulls integer formation etc

#

Use it strategically

ivory sleet
#

myes, wrapping everything in a try catch Throwable usually isnt very smart if thats what you're currently doing

compact cape
#

I know Spigot has a error handler for the plugin... I'm looking to find a way and override it for my plugin

ivory sleet
#

ugh what and why

compact cape
river oracle
#

There is a good chance your overusing try catch wrap more strategically

ivory sleet
#

it catches exceptions that yield from onEnable, onLoad, onDisable and Listeners and the command api to avoid arbitrary code termination

river oracle
#

Also you can easily throw your custom errors

uncut nebula
compact cape
ivory sleet
#

then try catch

#

but like usually its very trivial to point out the sources of which conceivable errors will yield

compact cape
#

For every command and listener?

ivory sleet
#

like from input parsing

river oracle
#

If you use try catch strategically you'll be fine and jt won't be messy

ivory sleet
#

or lets say IO

compact cape
river oracle
#

Bruh

ivory sleet
#

no1 cares about how good looking your code is

river oracle
#

Lmfao

ivory sleet
#

if its clean then its good enough

river oracle
#

Good chance what your trying to achieve can be easily done with 1 try catch too

compact cape
#

I have a messenger API which can handle all the exceptions (instead of traceback in the console it will save it in a file and return the file name in console) and using a try catch I can easily handle them, But having try catches is annoying and I'm looking for a way to make my plugin handle any exception it gets with this method (As messenger also have a metrics that upload all the errors to my discord server for better support)

river oracle
#

Try catch

compact cape
river oracle
#

Sounds like a good option if you are smart yoh will only need a few at most otherwise its your fault

tardy delta
#

why not just logging them to console and then the traceback will be in the console log lol

river oracle
#

I just log ASakashrug

compact cape
ivory sleet
#
try{
  //TODO code that yields any instance of Exception
}catch(Exception e){
  //handle any instance of Exception
}
#

basically

tardy delta
#

ah in discord lol

crisp steeple
quaint mantle
#

ALTER TABLE contacts
MODIFY balance INTEGER 1000;

#

This'll change the column's value, right ?

compact cape
waxen plinth
#

That's trying to alter the table itself

#

The column doesn't have a value

#

Each row has a value for that column

#

You want update

#

UPDATE contacts SET balance=100 WHERE name="John" or something

quaint mantle
#

oooooh okay

#

so that'd work, right ?

waxen plinth
#

Assuming you have a string column called name

quaint mantle
#

well yeah.

#

name = name of the column

amber palm
#

hey guys, i need help, i'm searching for plugin which can limit the number of shulkers in inventory

lethal python
#

can spigot render text to the spot where held item text usually goes

#

below the actionbar

#

like that

chrome beacon
#

You can rename the item a player is holding

lethal python
#

:( is that the only way

crisp steeple
#

well yeah, since that text rendering is client side

#

could do it with packets if you don’t want to change the name of the actual item

visual tide
#

would still run into the issue that the player will have to be holding your packet item at all times

#

or if youre just renaming with packets then it wont work with air

crisp steeple
#

well you could make a fake item and then set it in their hand with packets

visual tide
#

true

#

but that might a lil intrusive

#

for the player

#

i mean you could cover it up with a texture pack

halcyon mica
#

Question, what are possible reasons as to why the PlayerInteractEvent fires twice?

visual tide
#

the player has 2 hands

#

it fires once for each hand

halcyon mica
#

Can I restrict it to the main hand only?

visual tide
#

if you only want it for one you can check and ignore if its offhand

ancient plank
#

I have 4 hands

tardy delta
#

i have 8

river oracle
#

I have 16

visual tide
#

that is great

golden kelp
#

I have 0 :)

trail oriole
#
@EventHandler
    public void onEnchantClick(PlayerInteractEvent event) {
        
        if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) return;
        if (event.getClickedBlock().equals(Material.ENCHANTMENT_TABLE)) {
            Player player = event.getPlayer();
            event.setCancelled(true);
            Inventory inv = Bukkit.createInventory(null, 45, "§5Enchanting Table " + player.getName());
            player.openInventory(inv);
        }
    }``` this doesn't work, it still opens the enchant table inventory
snow compass
trail oriole
#

wut

#

oh

#

wow

#

i'm so dumb

tardy delta
#

no need to use equals to compare enum constants, use != instead

snow compass
#

no worry's 🙂

trail oriole
#

how does it work

#

i'm so confused

halcyon mica
#

Have there been any changes to glowing btw?

#

Setting setGlowing doesn't seem to work anymore

trail oriole
#

addGlowing

#

oh

#

how do i do

halcyon mica
trail oriole
#

i know

#

using for the inventory comparator

halcyon mica
#

I am trying to spawn a persistent falling block entity that glows, but while the entity spawns, it does not glow

#
        FallingBlock e = block.getWorld().spawnFallingBlock(tg.clone(), block.getBlockData());
        e.setGravity(false);
        e.setInvulnerable(true);
        e.setGlowing(true);
        e.teleport(tg.clone());
        e.setDropItem(false);
        e.setHurtEntities(false);
        e.setSilent(true);
        e.setTicksLived(1);
        e.setVelocity(new Vector(0, 0, 0));```
trail oriole
#

use potion effects

halcyon mica
#

Not worth it

#

They don't exist for a long time, creating and applying effects is a waste of cycles

#

The glowing property should set a glow, just pivoting to a different approach is not solving the problem

#

It's not a player

#

It's a falling block

#

Yes

#

The player is not part of any team

#

And is not going to be

#

Glow is literally a boolean entity property

#

Entirely unrelated to scoreboards and teams

#

When was this behaviour changed?

#

Because it used to simply work

#

Then why could I simply set setGlowing to make a entity glow before 1.18

quaint mantle
#

I'm also having this issue

halcyon mica
#

Yeah bs on the scoreboard only stuff

#

Setting the nbttglowing tag manually works just fine

#

Setting the glowing tag of the handler entity doesn't work either

sterile token
#

Any here knows if there is a way on bungee and spigot to inject into netty a custom channel handler?

halcyon mica
#

So it looks like mojang borked this one, since spigot just redirects to that

worldly owl
#

Hey, fixing up some really old code (1.8) i know i probably wont get support but i just need to know 1 question? How comes this: ((CraftPlayer) player).getHandle().spectating = false; doesnt work, and how would i get this to work exactly? (e.g. is there another way of finding this out?)

sterile token
#

By default they are obfuscated

worldly owl
#

Ah

#

Wait so is that what the remapped is in my build folder?

sterile token
#

no no i explained

#

Spigot lastests version has a remap option, that already come with some deobfuscated methods for working

#

But olders spigot doesnt have that

worldly owl
#

yeah but the remap thing sounds like a file i have in my spigot build folder, spigot-1.8.8-R0.1-SNAPSHOT-remapped.jar

halcyon mica
#

Manually sending the metadata update packet doesn't seem to work either

sterile token
#

Do this

worldly owl
#

so right now im using eclipse

sterile token
#

on "getHandle()", press ctrl + click and it will decompile the class. So check if the class contains that method

#

Oh ok

worldly owl
#

wait no

#

are you sure there is no remap?

radiant cedar
#

how can I delete all items dropped by a player

#

not when each is dropped tho

worldly owl
#

i replaced it with the remapped file in the folder and its now not trying to stab me

lost matrix
halcyon mica
#

The entity has the glowing flag set, meaning it should be synced with the client

#

So why does modifying the data via command work, but setting the flag in code doesn't

worldly owl
lost matrix
halcyon mica
#

No, I am spamming proper, synced falling block entities

#

My goal is to create a "ripple" effect through a structure

#

By hiding a block, spawning a stationary falling block which glows in its place and replace it with the actual block once more

#

And just have that repeat through the structure

lost matrix
#

Yeah makes sense. How do you hide the block? By using a block update packet?

halcyon mica
#

Block update

#

But that is not the issue right now in general

#

The issue is that the falling block entity simply will not glow

lost matrix
#

Just wanted to see the full picture.
Would you mind showing your code that spawns the falling block currently?

halcyon mica
#

It's definetly not a restriction on falling block entities in particular

#
        Location tg = block.getLocation().clone().add(0.5, 0, 0.5).clone();
        FallingBlock e = block.getWorld().spawnFallingBlock(tg.clone(), block.getBlockData());
        e.setGravity(false);
        e.setInvulnerable(true);
        ((CraftFallingBlock)e).getHandle().setGlowingTag(true);
        e.teleport(tg.clone());
        e.setDropItem(false);
        e.setHurtEntities(false);
        e.setSilent(true);
        e.setTicksLived(1);
        e.setVelocity(new Vector(0, 0, 0));```
#

Ignore that I am doing the handle directly, I was testing

#

mhm

lost matrix
halcyon mica
#

But the spigot abstraction behaves the same

lost matrix
#

Not sure what the problem here is. Let me do some testing.

#

Those are my yields:

  @Override
  public void onEnable() {
    Bukkit.getPluginManager().registerEvents(this, this);
  }

  @EventHandler
  public void onInteract(PlayerInteractEvent event) {
    Block block = event.getClickedBlock();
    if (block == null || event.getHand() != EquipmentSlot.HAND) {
      return;
    }
    BlockData data = block.getBlockData();
    block.setType(Material.AIR);
    FallingBlock falling = block.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 0.01, 0.5), data);
    falling.setGlowing(true);
    falling.setVelocity(new Vector(0, 0.33, 0));
  }

@halcyon mica

halcyon mica
#

I don't get it

#

What am I doing wrong then

lost matrix
#

I have no idea. Try isolating the problem by removing other properties first.

tardy delta
#

ayy that looks cool

lost matrix
#

Hm what was this algorithm to draw discrete circles again...

waxen plinth
#

I would just use breadth-first

lost matrix
#

I mean that would would result in a rombo, wouldnt it?

ancient plank
#

gonna end up being one of those satisfying wave machine things people make with redstone and sand

lost matrix
ancient plank
#

sometimes when I'm tired I just go watch mumbo jumbo wave machine videos

tardy delta
#

mumbo jumbo kek

halcyon mica
#

I think I have found the issue

midnight shore
#

How can I change the color of the glowing overlay of an entity?

lost matrix
halcyon mica
#

It's the way how I create the falling entity

#

Using the material and data method works just fine

lost matrix
#

Easy way to remove grass lul

halcyon mica
#

But creating the entity using blockdata does not

ancient plank
halcyon mica
#

Which is a problem

#

And honestly I don't know why

tardy delta
#

aaaa

lost matrix
tardy delta
#

tsunami be like

#

imagine seeing that thing passing

halcyon mica
#
        FallingBlock e = block.getWorld().spawnFallingBlock(tg, block.getType().createBlockData());```
#

now it only works on leafs

#

But not on logs

lost matrix
halcyon mica
#

I am at a loss

#

What the fuck

radiant cedar
#

Caused by: java.lang.IllegalArgumentException: Cannot open an inventory of type CRAFTING

halcyon mica
#

I genuinely don't understand

shut field
#

what does this mean?

#

it is relating to this line:

#

humans has type org.Bukkit.Entity

echo basalt
#

Read the exception

#

it means that it's trying to modify a final value

tardy delta
#

refelction stuff

#

aaa type aids

echo basalt
#

you could just get the handle, get the intlist via reflections and modify it

#

instead of setting a new value

trail oriole
#

How do I check if a damage hits succesfully ?
I have a EntityDamageByEntityEvent, checking a player hitting another, but it also triggers in wg region where pvp is disabled. Any ideas ?

supple elk
#

What's the best way to create a formatted message to send to a player?

shut field
halcyon mica
#

@lost matrix This has to have something to do with block data

#

When just getting the material of the block data, it skips over acacia logs

#

But it's fine pasting acacia logs normally

tardy delta
halcyon mica
#

When giving it block data in general, it just straight up does nothing

tardy delta
#

you might want to change the priority too if it doesnt work

twilit roost
#

Hey,
currenly when I reload/shutdown/restart my server , my config get's wiped out
Imma try to attach some code that might come in handy

if you need more code , ask for it 🙂

#

he was helping with saving to the file

now it doesn't stay after shutdown

#

lmao
onEnable is way too long for Discord

#

give me a minute

tardy delta
#

i see static abuse

undone axleBOT
quaint mantle
#
int getPlayerMoney(
            Player p,
            ResultSet result
    ) throws SQLException {
        int money = 0;
        while(result.next()){
            p.sendMessage(result.getString(1));
            if(result.getString(1).equalsIgnoreCase(p.getUniqueId().toString())){
                p.sendMessage(result.getString(1));
                money = result.getInt("money");
            }
        }
        return money;
    }```
restive mango
#

@ancient plank looks neat

quaint mantle
#

Why isn't it returning the value that it's supposed to ?

twilit roost
quaint mantle
#

???

tardy delta
#

you dont see to close resultsets

quaint mantle
#

no i close it later

restive mango
#

@ancient plank I think he’s just making falling blocks out of all the grass blocks and launching them upward

twilit roost
tardy delta
#

i wont speak about the connection i guess

twilit roost
quaint mantle
#

sorry?

ancient plank
restive mango
#

Oh yeah it’s cool though

ancient plank
#

because you like falling blocks

tardy delta
#

public class OnDiable AAAAAAAAAAAA

twilit roost
quaint mantle
#

@small bay how would you do it ?

tardy delta
#

PLEASEEEE

restive mango
#

@ancient plank ask him to move the blocks around en masse in space and check if they become disjointed

#

I hate it

#

That on lotc

tardy delta
#

my second last brain cell just fking died

restive mango
#

I don’t think we send packets

#

Frequently enough

#

So the blocks become all fucky

#

It’s probably a server speed saving precaution

quaint mantle
#

I'm new to using databases -_-

restive mango
#

From bukkit or spigot or something

quaint mantle
#

oh soz

restive mango
#

I can’t do it on a basic server because my stuff is all designed for tythan @ancient plank

ancient plank
#

I can get tythan working on my dev server @restive mango

restive mango
#

No it’s not that

#

It’s that something inherent to lotc reduces how frequently a falling block sends packets to players @ancient plank

#

So it’s doing it like every fifth tick

twilit roost
#

since my Main class is over 150lines
I wanned to make it more organised
and i didn't have better names then OnBoot and OnDisable

restive mango
#

Instead of every tick

#

Something like that

#

I don’t know exactly how it works

#

But there is something that makes our falling block entities more jittery

#

@ancient plank use /aeso telerip 6 on a chunk of terrain and wave it around, look at how the blocks break up and it takes a few moments before you see them correctly

tardy delta
#

might come in handy

restive mango
#

It’s something with lotc that does that

#

Idk what

tardy delta
#

you might get the connection in another way

#

why not just CompletableFuture#supplyAsync? @quaint mantle

halcyon mica
#

The entities are actually being spawned

tardy delta
#

and not using the bukkit scheduler

halcyon mica
#

But they just don't have any properties applied

tardy delta
#

looks a bit cleaner in my opinion x)

#

nah its returning a CompletabFuture<Void>

tardy delta
twilit roost
#

its checking if Config files are existing, registering listeners

tardy delta
#

i mean that code has to be called somewhere

twilit roost
#

I write to that file only when someone places a block with specific Material

I then add it to the Config
and save it

restive mango
#

@lost matrix hey

#

Just to let you know ahead of time

#

If you ever want to generate falling blocks at the location of a block without destroying that block

ivory flume
#

why use mysql or mongodb, which one?

restive mango
#

You’ll need to send an update to all the players who can see it that the block is not in fact destroyed

tardy delta
#

im not sure about your createDataConfig method

restive mango
#

Or it’ll be an invisible hidden block

twilit roost
#

I just removed one unneccesarry saveData() and it saved correctly even over reload?

ivory flume
#

i already have mysql but idk if i should switch to mongo

restive mango
#

@ancient plank do you remember if falling fire blocks continued their animations while falling

#

Or falling magma blocks

twilit roost
#

so maybe i was saving null values when I didn't have to

#

mb

halcyon mica
#

Non-living entities cannot actually be set to be invisible, can they?

ivory flume
#

armor stands can be set invisable

#

so mot just living entities

halcyon mica
#

Armorstands are living entities

supple elk
#

How can I get any colour from an RGB value?

quaint mantle
#

INSERT IGNORE INTO player_data VALUES(?,?,?,?);

I use this to stopre player data, and for some reason it's duplicating, if someone is able to, can you please help me ?

worldly ingot
supple elk
#

what do I need to specify?

worldly ingot
#

If you want an org.bukkit.Color, there's a static fromRGB() method where you can just pass the int. But if you want the individual r, g, and b components you'll have to do some bitshifting

halcyon mica
#

I don't understand, the entity exists, has all the properties, everything

worldly ingot
#

because your question was "how do I get colour from a colour"

halcyon mica
#

It just doesn't render

#

why

supple elk
#

I want a ChatColour to change the colour of a chat message to any colour, rather than a value from the existing enum

worldly ingot
#

That's more specific. You want the bungee ChatColor instead

supple elk
#

ok thx

worldly ingot
#

(and you can just do new Color(rgb))

ivory flume
#

when i use that it says deprecated

halcyon mica
#

What is so special about this entity that makes the game not render it?

supple elk
#

I'd looked stuff up and seen the .of() method but couldn't see it on docs for ChatColour

worldly ingot
#

Yeah it's the bungee ChatColor, not Bukkit's

supple elk
#

mhm

ivory flume
#

yes same jet

halcyon mica
#

It looks like minecraft just fails to render falling blocks with certain blockstates

#

idk

quaint mantle
#

How do I make sure that my database is always up to date ?

#

coz sometimes, it doesn't update itself

dusk flicker
#

what db?

quaint mantle
#

mysql

dusk flicker
#

mysql should update upon data entered/edited

#

If it isn't its probably on your end somehow

quaint mantle
#

for some reason, it doesn't get the information uuid and doesnt compare it

#

it worked once with this code

#

now it doesn't

#

here's the "getPlayerMoney"

tardy delta
#

have you followed the tuturoial i sent you?

#

some spigot forum link

quaint mantle
#

Oh I haven't seen it, sorry.

dusk flicker
#

so, I run Mongo so if someone else has more experience with SQL feel free to jump in, but from what I see at the moment, it seems that you are running a wide scope check pulling playerdata every time but you could edit the statement and just get the data for the specific player, rather than everyone

quaint mantle
#

so use WHERE ?

dusk flicker
#

I also don't know if it is necessary to connect to the db and get the connection every time, especially with how you it seems using static variables to do so, could easily be an issue there id bet

#

ye

tardy delta
#

i'm glad i learnt some basic SQL at school

quaint mantle
dusk flicker
#

also I dont know why you are statement.executeUpdate(); after that scoreboard

quaint mantle
#

i removed it

#

i accedentaly added it

tardy delta
dusk flicker
#

Take a look at the forum post, as that can help you a lot, BY met is its something to do with

        DataBase.establishConnection();
        Connection connection = DataBase.getConnection();

Getting the connection like that, as it could be out of date or something else weird being that its a status way of getting it and not unique to this one instance

#

might not want to leak your db connection info here

quaint mantle
#

yeah

#

too late

#

xD

#

i'll change it

#

rn

dusk flicker
#

yeah good idea

quaint mantle
#

then statement.setString(1, p.getuuid().tostring) right?

tardy delta
#

ye

quaint mantle
#

oh okay

dusk flicker
#

Now my own question time, I'm looking for a system to distribute jars across a server, ex upload new jar to a specific place and then run a command or something and it will automatically copy it to all the servers upload directory.
I'm not sure if something like this exists but any info would be appreciated

tardy delta
#

lmao i read SELECT MONKE

quaint mantle
#

then statement.getInt(2);?

tardy delta
#

it wants the name of the placeholder

quaint mantle
#

okay okaay

#

thanks alot!

tardy delta
#

so if you make a table (name VARCHAR(20)) you would have to do getString("name")

#

iirc

#

long time since i used databases

#

making a good table design is also important but thats the advanced stuff we learnt at school lol

dusk flicker
#

Assuming you mean like dedicated server, yes

lost matrix
dusk flicker
#

Alright thanks (Same machine so not bad at the moment)

lost matrix
#

If you want to distribute files over multiple machines then i would suggest using S3 from aws

kindred valley
#

?paste

undone axleBOT
shut field
#

i'm confused- what am I supposed to depend on? The spigot regular jar doesn't contain any of it, and the shaded jar md_5 sent out in their post doesn't contain CraftBukkit

tardy delta
#

use maven

#

and buildtools iirc?

tardy delta
#

does buildtools works for 1.18 too?

sterile token
sterile token
tardy delta
#

that will return false, false, false, false,... smh

#

😂

sterile token
#

That will broke the database

waxen plinth
#

No that's invalid syntax

sterile token
#

really?

#

I dont remembe ri dont use it since a year

waxen plinth
#

Pretty sure you can't use dashes in column names

tardy delta
#

ah ye in that way its invalid

#

lets try

sterile token
#

yeah but my intention wa to joke

#

Not to do a working statement

tardy delta
#

yep '-' doesnt work

sterile token
#

ResultSet == MongoCollection right?

#

Know that i dont use anymore mysql i cannot remember tho

river oracle
#

MongoDB is goated

waxen plinth
#

Why does it feel like mongo is just the database for people who don't like sql

#

lol

#

Redis has its own thing going on but mongo just seems like that

#

It feels a bit like the python of databases if that makes sense

sterile token
#

sql i like but its really engorrous the reason that you cannot save objects

#

I really hate that

waxen plinth
#

engorrous?

tardy delta
#

save them as binary kekw

lost matrix
#

Yeah lets all screw document and relational databases.
How about we use OrientDB from now on. Or Neptune*

sterile token
tardy delta
#

lol

crisp steeple
#

object output stream

lost matrix
sterile token
#

Lol mysql orms eists

#

I thought it have been discontinued because its so old

#

😂

lost matrix
#

MySQLs latest version is only like a month old.
Same goes for MySQL in good (Postgres). All latest technology.

sterile token
#

What postgres?

#

Its like mysql?

lost matrix
#

MySQL in good

sterile token
#

Hmn dont still undmerstand but okay

lost matrix
#

In the enterprise world, Postgres is the golden standard

tardy delta
#

mysql without the security issues iirc?

#

or no it was another issue

lost matrix
#

Im saving this so i can send it after every other code we have to go through.
https://www.youtube.com/watch?v=ZzwWWut_ibU

This is the guard clauses technique to make your if else statements easier to understand and read. If else conditions is one of the most used thing in coding, but using if statement and nesting them like this is the worst thing ever. You should never nest if statement because it is hard to read and edit. Instead you should always use guard claus...

▶ Play video
tardy delta
#

good plan

worldly ingot
sterile token
#

What a mad thing to see nesting inside nesting of nesting if-else

tardy delta
#

bruh cloud broken when i need a document

sterile token
#

Are you using a potato as cloud?

#

😂

tardy delta
#

finally lol

#

printing at 11:20 pm when parents sleep mhm

sterile token
#

Lol

#

Why that time lmao

#

Dont you do hmws during the day?

knotty gale
#

I have a couple projects and I want to put them all in one plugin. Anyway I can do that?

compact haven
#

cloud is meant to not go down :(

#

that’s the whole purpose of the cloud

lost matrix
compact haven
#

only ur internet goes down, don’t blame the cloud or the cloud will come beat you

tardy delta
#

tips to not awake your parents when printing: put a pillow on top of the printer

compact haven
lost matrix
#

WD40

nova prism
#

Facts

tardy delta
#

step 1 to bring an usb stick to school: remove the iso files and format it

#

smh what have i been doing

knotty gale
#

also, how do I make a command that toggles a variable for 1 player, which is the player that toggled the command?

humble tulip
#

Add them to a set

#

If toggle set will contaim them

#

If not it wont

#

Put the set in some manager class and have a toggle method that accepts player

#

Remove player on leave

lost matrix
knotty gale
#

ok

humble tulip
#

If you need multple varable use a map as @lost matrix said

#

If it's just true or false u can use a set

lost matrix
#

Another approach: Use the PDC of the player. This way the values will be persistent.

sterile token
opal juniper
#

Map<Player, X> trolled

lost matrix
sterile token
opal juniper
#

stored on the world data

lost matrix
#

by saving it

opal juniper
#

with the entities

sterile token
#

If persitent it should be saved somewhere

lost matrix
opal juniper
#

it’s stored in the proprietary mojang format

lost matrix
#

its saved in the nbt format

knotty gale
lost matrix
#

Player#getUniquiId or something

opal juniper
#

entity#getUuid()

#

yeah

knotty gale
#

k

opal juniper
#

what he said

sterile token
#

Actually you have the ?jds

opal juniper
#

lol

sterile token
#

?jd

opal juniper
#

it has to be at the start

sterile token
#

Javadocs are really useful for using the spigot api

#

When you dont know a method you can read them to find it

knotty gale
#

?listener

#

whats the thing for registering the listeners that arent the main class?

opal juniper
#

?event-api

undone axleBOT
knotty gale
#

ty

opal juniper
knotty gale
#

oh ok

sterile token
#

Sorry if i sound rude, but have you watch a full tutorial

#

That atleast talk about the basics

tardy delta
#

most tutorials are bad lol

sterile token
#

I think if someone start doing decent tutorial can be really known

#

Because lot of people would watch the tutos

compact haven
#

it's difficult to teach things in a tutorial

sterile token
#

For me its pretty easy

compact haven
#

yes and then only you understand it lol

#

People jump right into spigot dev. without understanding basic fundamentals of OOP or Java

crisp steeple
#

first spigot tutorial i watched made listeners separate classes

sterile token
#

No i mean in really talkfull and explain things good

crisp steeple
#

idk why so many people just make main a listener

compact haven
#

so when you tell them you need a Listener they're like "huh what's implements"

compact haven
sterile token
#

If i have to explain something i take my time to explain it

compact haven
#

later

sterile token
#

Every tutos are on 1.8

#

Most of them atleast

compact haven
#

nah there's a few on 1.12.2 and some newer versions

crisp steeple
#

same without a lot of people use command event and getName instead of using commmandexecutor

knotty gale
#

so if i am correct. to register listeners that are in the same class as the line where you are registering, you do java this, this
?

opal juniper
#

yeah

knotty gale
#

ok ty

opal juniper
#

well, that is implying that “this” is both the main class and “this” implements listener

undone axleBOT
grim ice
#

how to make ai

compact haven
#

AIFactory.makeAI()

grim ice
#

no

#

AI.construct() {
return new ComplexArtificialIntelligence();
}

compact haven
#

you've just violated sin #3

#

you've attempted Kotlin syntax

#

but failed at it

grim ice
compact haven
#

you used curly braces at the end of a method call

#

which results in a Lambda as the last parameter in Kotlin

#

and then you've added the new keyword before the class ComplexArtificialIntelligence

#

in Kotlin, you don't use the new keyword, you just call the constructor as if it was a method

humble tulip
#

I've tried learning kotlin like 3 times then get frustrated when i have to keep googling syntax

crisp steeple
#

it gets easier over time

#

only thing i still don’t really get is why you have to put object : before instantiating a local interface or abstract class

knotty gale
#

if you have over 1 command, how would you list that in the plugin.yml

brave trellis
#

using dispatchCommand and an armor stand as the "sender" should work, but its not exactly executing which it should, which is weird considering I have another class which uses the exact same method and executes just fine with the armor stand as the sender

#

Do I just send the snippet of code here? Its not very large anyways

crisp steeple
#

yeah, sort of confused on why you would want an armor stand to execute a command though

brave trellis
#

because I need a command to execute in certain worlds

#

and getConsoleSender only works in one world

crisp steeple
#

i mean theres usually ways to do things without involving making console send commands

tardy delta
#

check if the player is in the desired world?

crisp steeple
#

depends on what you're trying to do

brave trellis
crisp steeple
#

well idk what the result is that you're trying to achieve