#help-development

1 messages · Page 1780 of 1

plucky fog
#

its there

#

oh wait

#

ive had an idea

#

nope didnt work

#

its in the JAR's root

#

oh

#

i made a typo xD

tardy delta
#

does string.replace("a", "b") does anything?

#

instead of str = str.replace()

plucky fog
#

string.replace(... where string is your string object

tardy delta
#

that doesnt modify string right?

plucky fog
#

try it and see

tardy delta
#

i tried

quaint mantle
tardy delta
#

uhu

quaint mantle
#

so any modifcation methods returns a New string

marble granite
#

Is there a way to store an item and its NBT data in a flat file? without NMS

tardy delta
#

ah i understand

quaint mantle
marble granite
#

But that doesnt save NBT does it?

quaint mantle
#

it does?

marble granite
#

oh ok

tardy delta
#

also does .replace() keeps colorcodes?

marble granite
#

i was just wondering

plucky fog
tardy delta
#

thanks

quaint mantle
quaint mantle
marble granite
#

i mean, i can work around that

plucky fog
#

so how would i access my file from my plugins Data dir?

marble granite
#

thanks for the info 👍

quaint mantle
plucky fog
#

thx

quaint mantle
#

how would i detect when a player makes a grass path?

tardy delta
#

there's probably an event for that

brave goblet
#
 gui.setItem(0, glassEmpty);
        gui.setItem(1, glassEmpty);
        gui.setItem(2, glassEmpty);
        gui.setItem(3, glassEmpty);
        gui.setItem(4, glassEmpty);
        gui.setItem(5, glassEmpty);
        gui.setItem(6, glassEmpty);
        gui.setItem(6, glassEmpty);
        gui.setItem(7, glassEmpty);
        gui.setItem(8, glassEmpty);
        gui.setItem(9, glassEmpty);```
is there an easier way of doing this? for all slots that dont have a value eg
``` gui.setItem(10, skull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjIwNjU3ZTI0YjU2ZTFiMmY4ZmMyMTlkYTFkZTc4OGMwYzI0ZjM2Mzg4YjFhNDA5ZDBjZDJkOGRiYTQ0YWEzYiJ9fX0=","Blaze"));```
so i don't have so many lines
quaint mantle
brave goblet
tardy delta
#

its the PlayerInteractEvent

#

check if the player's holding a hoe

#

and if he rightclicked on grass block

sleek pond
#

anyone know why this is happening?

sleek pond
#

basically the first println is the same as the seconds varuiable

#

and this is what i get

brave goblet
#

u mean shovel...

#

but ye basically that

wide creek
#

I want to check if a player is in a determinate zone. So, i created two vectors (idk if I have to use Vector or Location) and now I don't know if there's a method for check if the player is between the vectors.

brave goblet
#

and check if the block clicked on is grass

misty current
#

when i use spigot().respawn() on a player in a PlayerDeathEvent, the dead player picks up the items they dropped before getting teleported

#

basically makes the server keep inventory

tardy delta
quaint mantle
misty current
#

nah i wish

#

anyways i solved by clearing the drops and respawning them on the ground a tick later

#

is there a better solution tho?

quaint mantle
misty current
#

then it would show the death screen for a split second

quaint mantle
#

Thats the point. When Death event is fired, player is actually not dead. So, by respawning them you cancel his Death -> no loot

foggy estuary
#
             if (cmd.getName().equalsIgnoreCase("start")) {    
                 Entity Scrooge = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"), 0 , 33 ,-181 ),EntityType.VINDICATOR);
                 Entity Pet = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"), 0 , 33 ,-181 ),EntityType.PHANTOM);
                 Entity Lightning2 = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"),-5, 67 ,-153 ),EntityType.LIGHTNING);    
                 Entity Lightning3 = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"),4, 67, -153 ),EntityType.LIGHTNING);
                 
                 Scrooge.setGlowing(true);
                 Scrooge.setCustomName(ChatColor.RED + "Scrooge");
                 Scrooge.setCustomNameVisible(true);
                 Scrooge.addScoreboardTag(label);
                 Pet.setCustomName(ChatColor.GOLD + "Scrooges Pet");
                 Pet.addPassenger(Scrooge);
                 Pet.setCustomNameVisible(true);    

                if (Scrooge.isDead()) {
                Bukkit.broadcastMessage("test");
                }```  here
mystic sky
#

Well, they need to put start.

foggy estuary
#

if anyone else can figure out why the msg wont broadcast it would be greatly appreciated

foggy estuary
mystic sky
slim kernel
#

Can I somehow check If a Player is directly infront of another player?

foggy estuary
worldly ingot
#

Location and if you want to verify whether or not they're looking at them, dot product between product vector and their direction

#

targetLocation.toVector().subtract(playerLocation.toVector()).dot(player.getDirection()) should give you a value between 1 and -1, where 1 is looking directly at them

mystic sky
foggy estuary
#

i added a body so it willdo it once scrooge isdead

#

it doesnt execute it once i do command. I've tried it

slim kernel
plucky fog
#

how can i get the players who have OP perms?

worldly ingot
#

You'll want to give some lenience there obviously because the likelihood of someone looking directly at another player is slim to none lol

#

Can do like <= 0.8 or something

#

Bukkit#getOperators(), Millzy

slim kernel
worldly ingot
#

Right, >=, my bad

slim kernel
worldly ingot
#

I mean at least that means you understand it aPES_Laugh

worldly ingot
#

location.toVector()

#

Forgot to include that

west oxide
#

hey

#

noob question

slim kernel
west oxide
#

is this a reason why some ppl chose eclipse?

#

like the layout

#

or am i just stupid

worldly ingot
#

Not sure I understand the question

#

I've been using Eclipse for almost 7 years

west oxide
#

why eclipse over intelliij idea ?

#

intellij helps alot while coding

#

idk if eclipse does

worldly ingot
#

It does. It's an IDE as well. It's a matter of preference.

crimson terrace
#

Hey, I am using LuckPerms and adding a permission from my own plugin to myself doesnt give me the ability to execute the command I set the permission to.

echo basalt
#

Show code

crimson terrace
#

?paste

undone axleBOT
west oxide
#

and am just curious

#

lol

worldly ingot
#

Mostly bullshit tbh. You can use either, you'll output the same code

#

I feel far less efficient writing in IJ

crimson terrace
echo basalt
west oxide
#

F

#

seems like its just preference then

#

i'll just keep using intellij cuz its cleaner looking imo xD

echo basalt
#

Ij has github copilot, not sure about eclipse

worldly ingot
#

Yeah, it's entirely preference. I get ridiculed for my use of Eclipse pretty regularly but so long as I'm writing code the way I feel most comfortable, don't really care

visual tide
#

i'd be full on intellij user if jetbrains didnt constantly push kotlin in my face

echo basalt
#

Wdym I don't get pushed kotlin

west oxide
#

you mean the thing that helps you code ?

echo basalt
visual tide
#

the "ai" that's supposed to turn human instructions into code

west oxide
west oxide
#

its very nice

#

i like it

worldly ingot
#

Haven't looked because Copilot hasn't interested me at all

foggy estuary
#
                 Entity Pet = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"), 0 , 33 ,-181 ),EntityType.PHANTOM);
                 Entity Lightning2 = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"),-5, 67 ,-153 ),EntityType.LIGHTNING);    
                 Entity Lightning3 = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"),4, 67, -153 ),EntityType.LIGHTNING);
                 
                 Scrooge.setGlowing(true);
                 Scrooge.setCustomName(ChatColor.RED + "Scrooge");
                 Scrooge.setCustomNameVisible(true);
                 Pet.setCustomName(ChatColor.GOLD + "Scrooges Pet");
                 Pet.addPassenger(Scrooge);
                 Pet.setCustomNameVisible(true);    

                 
                if (Scrooge.isDead()) {
                    Bukkit.broadcastMessage("test");
                }
                
                ```
#

i dont want to be repetitive but i
just want to know why this code isnt working, the isdead statement

#

and why wheni killhim it doesnt broadcast themsg

brave goblet
#
Inventory gui = Bukkit.createInventory(null, 36,ChatColor.RED + "Test GUI" );
player.openInventory(gui);

How can I make it so people can't take or place items in that specific GUI

lavish hemlock
slim kernel
#

Does anyone know a good tutorial for how to force resourcepacks on players?

brave goblet
#

because it's a menu GUI

#

with items

lavish hemlock
#

then you can check the X and Y for your "buttons"

misty current
#

how can I spawn a lightning bolt with packets? current code:

        int x = loc.getBlockX();
        int y = loc.getBlockY();
        int z = loc.getBlockZ();

        ProtocolManager pm = ProtocolLibrary.getProtocolManager();
        PacketContainer packet = pm.createPacket(PacketType.Play.Server.SPAWN_ENTITY_WEATHER);
        packet.getIntegers().write(0, Utils.randInt(1000000000, Integer.MAX_VALUE));
        //packet.getBytes().write(0, (byte) 1);
        packet.getIntegers()
                .write(1, x)
                .write(2, y)
                .write(3, z);
        try {
            for (Player player : Bukkit.getOnlinePlayers()) {
                if (player.getLocation().distance(victim.getLocation()) < 100.0f) {
                    pm.sendServerPacket(player, packet);
                }
            }
        } catch (InvocationTargetException e){
            e.printStackTrace();
        }
brave goblet
tardy delta
#

can you iterate on an empty hashmap?

west oxide
#

hi, why does this show me an error ?

#

i followed the turorial as they did

lavish hemlock
#

=, not ==

west oxide
#

i think its because am using java17 ?

#

oh yeah

#

nvm

#

sorry

#

it didnt fix

worldly ingot
lavish hemlock
# brave goblet wym? X and Y "buttons"

you know what I mean.
you have a GUI, it has "buttons" (which are actually just itemstacks) that performs actions on click, you check the X and Y in that gui for the specific items you need actions to occur on clicking, and you cancel the event so that it doesn't pick up the item (but the code before the cancel still executes if it matches your X/Y checks)

tardy delta
#

channels is an initialized list

tardy delta
#

it's coming from that line

lavish hemlock
#

mainChannel is probably null or smthn

paper viper
west oxide
#


import org.apache.groovy.groovysh.Main;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;

public class DataManager {
    private Main plugin;
    private FileConfiguration dataConfig = null;
    private File configFile = null;

    public DataManager(Main plugin){
        this.plugin = plugin;
    }

    public void reloadConfig(){
        if (this.configFile==null){
            
            this.dataConfig = YamlConfiguration.loadConfiguration(this.configFile);
        }
    }
}


am getting error here

this.configFile = new File(this.plugin.getDataFolder(),"data.yml");

#

idk why

paper viper
#

or you can use the new packet which has a boolean i think that allows you to force resourcepacks if you are on the new version

slim kernel
crimson terrace
#

to reiterate my problem from earlier, I have made a command from my plugin need a permission to function, set it to default: op and if I add the permission to a group in LuckPerms and add myself to that group I am not able to execute that command. here are the permissions and the code which prevents unauthorized use. https://paste.md-5.net/kinacuvuxa.cs
I can use the command when I am op, but not when I am deopped, so it works that far at least.

brave goblet
lavish hemlock
paper viper
#

wdym

#

Yeah

#

if you do that method sure

#

keep a set or something of people who sent the resourcepack to and check in the status event if the uuid is inside the set

paper viper
#

and remove it after

lavish hemlock
#

there's a small problem

#

you can see everyone who has access to that inventory

#

but not a specific player

lavish hemlock
#

best idea? store a Map<UUID, Inventory> or smthn to hook the player's UUID to the target inventory

brave goblet
#

but ill try that

worldly ingot
#

Would opt to store the InventoryView instead, but yeah

#

Map is the way to go

tardy delta
lavish hemlock
#

I've seen that before

#

what is it for?

worldly ingot
#

It's basically the top and bottom inventories combined

#

Inventory is just one of the two inventories

brave goblet
#

well @lavish hemlock the only reason I need a player is because when i create the gui I do public Inventory GUI(Player player){ return gui; }

worldly ingot
#

Player#openInventory() will return the InventoryView and the InventoryView is fetchable in an InventoryClickEvent

#

They're == comparable as well last I recall

lavish hemlock
#

why would it create multiple instances? lol

brave goblet
#

are there any other ways i could do that though?

lavish hemlock
#

so what is your GUI (should be gui btw) method for?

brave goblet
#

lemme send paste bin of my code

lavish hemlock
#

wow a sane developer xd

brave goblet
#

nah

#

i am useless

#

tbh

#

when u see the pastebin u gonna cringe

lavish hemlock
#

you should see the people who were in here last night

#

multiple people posted errors without the first line

#

AKA the most important part of the error that tells you the actual type and message of the error

brave goblet
#

:/

#

here u go

tardy delta
#

hehe i like bukkit has its own Consumer<T>

worldly ingot
#

Pre-Java 8

lavish hemlock
#

well that and the fact that it's necessary for cancellation

#

unless, well

#

you wanted to make cancel a default method

#

otherwise it violates SAM requirements

tardy delta
#

what's SAM? 🥺

lavish hemlock
#

single abstract method

tardy delta
#

i already know SRP but yeah

lavish hemlock
#

the requirements for an interface to be able to be used as a lambda

tardy delta
#

aha

lavish hemlock
#

AKA a functional interface

tardy delta
#

never understood the FunctionalInterface annotation

lavish hemlock
#

an interface, if declared with @FunctionalInterface, must only have 1 abstract method

#

meaning one without a body, of course

#

that's cuz that method is used to call the lambda belonging to the interface

tardy delta
#

but if you just make an interface with one abstract method it also works

lavish hemlock
#

and it wouldn't make sense to have more than one abstract method, as there's no syntactical representation for it

tardy delta
#

hmm

lavish hemlock
#

without the annotation, compilers won't error if you violate the SAM contract

#

Java's got a lot of "warn/error if I have this and I do something bad" annotations

#

e.g. @Override, @SafeVarargs, @FunctionalInterface

brave goblet
#

wait

#

@lavish hemlock

#

could i check if ``` public void InventoryClick(InventoryClickEvent event){

}```
#

is an instance of GUI?

tardy delta
#

cant you use an interface with 2 abstract methods as lambda?

lavish hemlock
#

nah

lavish hemlock
#

you'd have to do new MyInterface {}

#

I think that's the syntax at least

tardy delta
#

oki thanks 💗

paper viper
lavish hemlock
paper viper
#

but you cant have 2 abstract methods

quaint mantle
lavish hemlock
#

ye Pulse is right

brave goblet
lavish hemlock
#

Bukkit's scheduler tasks require anonymous class usage tho

quaint mantle
brave goblet
paper viper
#

i find it so stupid that when i import the consumer for some of the bukkit methods i have to use the god damn bukkit one

#

in most cases i can just use the method reference

#

but still stupid

shadow night
#

how do I create recipes?

quaint mantle
# brave goblet did u get error message or what?

This is my code

   public void HarvestCheck(PlayerInteractEvent e) {
       double rng = (int) (Math.random() * 10);
       Block b = e.getClickedBlock();
       Player p = e.getPlayer();
       Material[] materials = {Material.DIAMOND_SHOVEL,Material.WOODEN_SHOVEL,Material.GOLDEN_SHOVEL,Material.IRON_SHOVEL,Material.NETHERITE_SHOVEL,Material.STONE_SHOVEL};

       if (b.getType().equals(Material.GRASS_BLOCK)) {
           p.sendMessage("blok");
           if (materials.toString().contains(e.getItem().getType().toString())) {
               p.sendMessage("itm");
               if (rng < 5) {
                   p.sendMessage("yes");
                   b.getWorld().dropItemNaturally(b.getLocation(), rock);
               }
           }
       }
   }
tardy delta
#

which i dont need

paper viper
#

No, please

#

stop

#

dont use that over the java one

lavish hemlock
#

lmao

paper viper
#

people are gonna flame you

tardy delta
#

ah bruh i switched to it over 10 minutes ago

lavish hemlock
#

but functional composition is great :(

shadow night
#

how do I create recipes?

paper viper
#

ShapedRecipe or ShapelessRecipe

lavish hemlock
#

regardless of the Java interface having additional methods, said methods are default and mainly just utils

quaint mantle
lavish hemlock
#

methods are part of the classes they're declared in and not the instances, so it makes no real difference in performance

#

and it's less clean to use Bukkit interfaces over Java interfaces

shadow night
paper viper
#

You have to use exact choice iirc

lavish hemlock
#

you might need to use a different constructor then :p

brave goblet
#

why u testing for all shovels?

misty current
#

i'm tryna use this code to show the health of a player below its name but it doesn't do anything

    private void createHealthBar(){
        Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
        Objective objective = scoreboard.registerNewObjective("health", Criterias.HEALTH);
        objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
        objective.setDisplayName(ChatColor.RED + "❤" + ChatColor.GRAY);
    }
brave goblet
#

lemme send something useful

#
e.getPlayer().getInventory().getItemInMainHand().getType().toString().toLowerCase().contains("pick")```
shadow night
lavish hemlock
#

namespace + resource key

#

namespace being something like minecraft or your plugin ID

#

resource key being, well, the key of the resource (like dirt)

misty current
#

never used spigot scoreboards, i've followed a guide online

#

what do you mean with theres no health in it

brave goblet
#

@quaint mantle

#
    @EventHandler
    public void HarvestCheck(PlayerInteractEvent e) {
        double rng = (int) (Math.random() * 10);
        Block b = e.getClickedBlock();
        Player p = e.getPlayer();
   if(e.getPlayer().getInventory().getItemInMainHand().getType().toString().toLowerCase().contains("shovel")){
       if (b.getType().equals(Material.GRASS_BLOCK)&&e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
           p.sendMessage("blok");
               if (rng < 5) {
                   p.sendMessage("yes");

               }
           }
       }
   }```
#

works

mighty pier
#

how do i check which slot was clicked in an InventoryClickEvent?

lavish hemlock
#

I believe there's an index

#

like uhhh

#

there's probably a getSlotId

#

but you'd have to do some math to extract the X and Y from that, if you wish

mighty pier
#

getRawSlot?

lavish hemlock
#

ah, getSlot would work I think

sterile token
#

Why when i start a thread from a spigot plugin the server doesnt finish the start process?

#

It get locked

shadow night
#

I did what the tutorial said. what

lavish hemlock
lavish hemlock
#

If you don't know what a deadlock is, don't use concurrency.

brave goblet
quaint mantle
#

uh ill see

quaint mantle
sterile token
#

Can be that the problem?

lavish hemlock
#

Honestly I have no idea without seeing your code :p

sterile token
#

Allright

#

Let me send it

lavish hemlock
#

But the likelihood is you're doing some kind of check that requires mutable state across threads, which is a big no-no.

quaint mantle
#

wtf

#

just created a gradle module

#

now i cant create a java file

#

kotlin only

lavish hemlock
#

stonks 👌

quaint mantle
#

is this an adverstiment

sterile token
shadow night
lavish hemlock
#

you are now officially a Kotlin dev @quaint mantle

lavish hemlock
sterile token
#

The thing that u put before the code

#

´´´java

#

Which is?

ivory sleet
#

`

sterile token
#

Thanks

lavish hemlock
#

it's called a backtick

tardy delta
#

js 🥺

lavish hemlock
#

a comma is a ,

sterile token
#

I didnt know the name thats why btw

lavish hemlock
#

what you were thinking of, which is similar to a backtick, is an apostrophe '

sterile token
#

Server class (Called by the plugin)

public class Server {

    protected ServerSocket server;
    protected Connection connection;

    public void connect(Integer port) throws IOException {
        this.server = new ServerSocket(port);
        System.out.println("[Server] Connection has been opened on port " + port);
        while (true) {
            new Thread(this.connection = new Connection(this.server.accept())).start();
        }
    }

    public void disconnect() throws IOException {
        this.connection.close();
        this.server.close();
        System.out.println("[Server] Connection has been closed");
    }

    public Handler subscribe() throws IOException, ClassNotFoundException {
        return (Handler) this.connection.getInput().readObject();
    }

    public void publish (Handler handler) throws IOException {
        this.connection.getOutput().writeObject(handler);
        this.connection.getOutput().flush();
    }
}

Connection class

public class Connection extends Run {

    protected final Socket socket;
    protected ObjectInputStream input;
    protected ObjectOutputStream output;

    public Connection(Socket socket) { this.socket = socket; }

    @Override
    public void execute() throws IOException {
        System.out.println("Client " + this.socket.getPort() + " has connected");
        this.input = new ObjectInputStream(this.socket.getInputStream());
        this.output = new ObjectOutputStream(this.socket.getOutputStream());
    }

    public void close() throws IOException {
        this.input.close();
        this.output.close();
        this.socket.close();
    }

    public ObjectInputStream getInput() { return input; }
    public ObjectOutputStream getOutput() { return output; }
}
lavish hemlock
#

holy shi-

#

actually decently clean I'm a bit impressed but let's see

#

btw if you declare close, I recommend implementing Closeable

#

allows you to try-with-resources an instance of said closeable class

sterile token
#

I think the server get locked when calling the new Thread() from Server.class

#

What do you think?

shadow night
#

whats wrong here?

ivory sleet
#

lol that while loop looks kinda uh yeah

lavish hemlock
#

yeah I was thinking about that too

#

instantiating a thread is an expensive operation, and might cause the server to slow down exponentially

sterile token
#

I put it because i need a thread per socket

lavish hemlock
#

so creating a thread basically every tick is...

sterile token
#

How i can do it? because every new socket its a new thread

lavish hemlock
#

hm well I understand the pattern

#

you should probably use an ExecutorService (Executors) btw

#

structured concurrency ftw

sterile token
#

ftw?

lavish hemlock
#

for the win

sterile token
#

ah ok

#

Executor executor = Executors.newFixedThreadPool(2);
executor.execute(connection);

right?

ivory sleet
#

Verano idk if you are aware but there is something called AsynchronousSocketChannel

ivory sleet
#

Yeah lol

lavish hemlock
#

Anyway basically while (true) on the main thread will hang the server permanently.

ivory sleet
#

At least in newer versions hahayes

sterile token
lavish hemlock
#

incoming Java 8 hate

ivory sleet
#

I think it’s a thing in java 8 also

lavish hemlock
#

incoming Maow defending Java 8

ivory sleet
#

Lol

lavish hemlock
#

listen Java 9 made it hard to do Java metaprogramming so I hate it >:(

ivory sleet
#

Also got its server variant AsynchronousServerSocketChannel

sterile token
#

I cant use another java, because the server fuck that its compiled with a recent version that the spigot doesnt support

#

🤔

#

In conclusion the while (true) its locking the server?

lavish hemlock
#

Oh yeah, BuildTools versions require you to have specific versions, is that what you're talking 'bout?

shadow night
ivory sleet
#

From javadoc 8

sterile token
#

I think spigot only support java 1.8

lavish hemlock
sterile token
#

What does the AsyncSocketChannel class?

#

Im not using io selector

lavish hemlock
#

It works on MC 1.16+ so it has to run on newer versions.

sterile token
brave goblet
#

can some one help me test if an inventory opened is a inventory that was created?

lavish hemlock
sterile token
sterile token
#

Let me send my main pl class

lavish hemlock
#

Well Minecraft's server is running on the same thread as your Server, so when you run while (true) on that thread, it pauses the thread to perform actions indefinitely.

sterile token
#

So i need to remoeve the while true

#

How i will wait for the socket connection if i remove the while?

lavish hemlock
#

No, you just need to launch your Server on a separate thread.

sterile token
#

Plugin class

public class Main extends Plugin {

    private static Main instance;
    private Server server;

    @Override
    public void onEnable() {
        instance = this;
        this.server = new Server();
        try {
            this.server.connect(3021);
        } catch (IOException ex) {
            System.out.println("[Server] Has thrown an exception while opening the connection");
            System.out.println("[Server] Exception: " + ex);
        }
        getProxy().getPluginManager().registerCommand(this, new Test());
        System.out.println("[Server] Has been enabled");
    }

    @Override
    public void onDisable() {
        try {
            this.server.disconnect();
        } catch (IOException ex) {
            System.out.println("[Server] Has thrown an exception while closing the connection");
            System.out.println("[Server] Exception: " + ex);
        }
        System.out.println("[Server] Has been disabled");
    }

    public static Main getInstance() { return instance; }

    public Server getServer() { return server; }
}
lavish hemlock
#

btw what are you using this for?

#

just out of curiosity

sterile token
#

I will use this library for a network

#

That hate using data brokers

#

😂

#

But if it works i will publish it free on my gth

lavish hemlock
#

I think you can do

new Thread(() -> {
    this.server.connect(3021);
}).start();
sterile token
#

I have already do that on my server class?

#

I have to do it again?

lavish hemlock
#

You do it for your socket connections, but not your server.

sterile token
#

Ahhhhh

lavish hemlock
#

So, you probably need to do it for your server.

sterile token
#

Im an idiot

ivory sleet
#

sure it is

sterile token
#

So the while should be on the server class

lavish hemlock
ivory sleet
#

but a socket is usually for single threaded stuff

sterile token
#

Im just starting on java. I have 15 years

lavish hemlock
#

I've used a socket with multithreading in the past :p

brave goblet
#
 public void InventoryClick(InventoryClickEvent event){
 Player player = (Player) event.getWhoClicked();
        if(event.getInventory()==GUI()){
            player.sendMessage("hello");
        }


    }
 public Inventory GUI(){
       Inventory gui = Bukkit.createInventory(null, 36,ChatColor.RED + "Test Screen" );
         ItemStack glassEmpty = new ItemStack (Material.PURPLE_STAINED_GLASS_PANE);
        ItemMeta glassEmptyMeta = glassEmpty.getItemMeta();
        glassEmpty.setItemMeta(glassEmptyMeta);
        gui.setItem(0, glassEmpty);
        return gui;

@lavish hemlock I changed the code abit to what I think might work but this doesn't? could u maybe explain why.

lavish hemlock
#

Bragging ^

sterile token
#

Maow for just being new on Java do you think that i have good coding? Like code cleaning, etc

lavish hemlock
#

Ye

ivory sleet
#

yeah well usually a SocketChannel will do better

sterile token
lavish hemlock
#

I thought a SocketChannel was for communicating on a socket?

ivory sleet
#

CompletableFuture might actually create a new thread

#

Socket is sort of an io device

#

socket channel is the non blocking variant

lavish hemlock
#

It's part of the NIO Channel API so, I assumed it was a replacement for using a OutputStream/InputStream on a Socket.

sterile token
#

I havent explain but the Run class i have created using a java trick. Because with normal Runnable you cant thrown exceptions

#

Maow, in theory my plugin class should create a new thread for the server starting. And the while true should be there or should be taken out?

lavish hemlock
lavish hemlock
#

Well the while (true) needs to be there otherwise you can't have more than one connection.

paper viper
lavish hemlock
#

Well

#

When you've done

#

A try/catch around your method that declares a lambda

#

And then you have to put another try/catch in your lambda

#

And, if you have nested lambdas, even more try/catches

#

You kinda give up on living.

ivory sleet
#

lol

lavish hemlock
#

I wish Java's lambdas took their parent scope's exception tables :p

sterile token
#

Maow its should be:

new Thread(() -> {
this.server = new Server();
this.server.connect(3021);
}).start();

Right?

lavish hemlock
#

I could probably create a compiler that does that tbf but I'm lazy.

lavish hemlock
#

I mean, for the new

#

For the connect, yes.

sterile token
#

Ah ok

#

So let me change it and tried again

#

Then i will try implementing a event-listener system like bungeecord one. For when the connection its opened, closed, receiving

#

But i couldn´t find anything on google. It shown other things

lavish hemlock
#

Eh, observers aren't complicated.

#

I'll send you a design pattern guide.

sterile token
#

Really thanks!!!

lavish hemlock
sterile token
#

You and Conclure help me a lot

lavish hemlock
#

This is an event listener ^

sterile token
#

Really good people here

#

Maow for the Server class connection closing i should stop the thread?

lavish hemlock
#

Not sure, I don't know if the GC does that automatically. Probably, though.

lavish hemlock
brave goblet
#

one final question I see lots of people use Inventory.getName
but this doesn't work anymore

#

how could I possible work around this?

eternal night
#

You can still grab the title of an inventory during interaction using the inventory view

tardy delta
#

any way to remove this message?

brave goblet
#

um

#

well

#

lemme check

#

but i don't think it is possible

#

@eternal night ur a life saver

tardy delta
#

does anyone knows what the &6 color is in ChatColor?

#

which ChatColor.

#

ah wait found it in the class

brave goblet
#
            event.setCancelled(true);
                if(item.getItemMeta().getDisplayName().contains("§6")){

                 do stuff

                }

        }```
This works but if the player shift clicks it works some times and lets them take the item
#

how can i fix this

#

and by sometimes i mean 1% of the time

#

but still a bug that needs to be fixed

eternal oxide
#

also monitor the drag event

tacit drift
stone sinew
#

Also check the actions and update the players inventory.

left swift
#

How can I remove / change entity recoil after hitting it, but to get damaged? I need to cancel the event and add my own velocity and damage is there any other option?

crimson terrace
quaint mantle
sterile token
#

A new question how does closeable works with socket?

#

Because when i use closeable when data goes out/in an exception is thrown

quaint mantle
#

any plugin for prefixes for bungeecord?

#

I have luckperms but EssentialsChat doesn't support it because it is on the bungeecord

sterile token
#

Wait wait

#

Explain again, you should put luckperms on Bungeecord and on the servers. Then use LPC (LuckPerms Chat) on every server

#

Yes you can

#

I think you should the event InventoryClickEvent
Then check if the slot equals to 9
And then block it

quaint mantle
sterile token
#

You should do it via Item name and if it have lore, via item name and item lore

digital rain
#

guys how do you test plugins

sterile token
digital rain
#

i meant like trying to avoid bugs, and that stuff

sterile token
#

Try this:

  1. Check the item slot he clicked
  2. Then obtain the item stack of what he clicked
  3. Compare the item stack with your item stack
sterile token
digital rain
#

like what circumstances do you check when doing doing stuff since i always miss like a small detail when trying implement a function (for example, it doesnt work with multiple players, or it doesnt work in the nether etc..)

sterile token
#

Definitly i dont understand what you make reference

digital rain
#

like bug testing

sterile token
#

I put the plugin on the server i test it manually if I see a bug i tried to understand why happen and then how i can fix it

#

Sometimes when i dont find any bug i send the plugin to friends so they have another opinion about the plugin

digital rain
#

oh you have friends :)

sterile token
lavish hemlock
#

congrats 👏

sterile token
#

Now null pointer

#

I have that idk why

#

I have been looking for a while but i cannot find what happen

mighty pier
#

how can i make custom chat messages?

sterile token
#

Chat format?

mighty pier
#

yea

sterile token
#

Use the PlayerChatEvent

mighty pier
#

why is it crossed out?

sterile token
#

Its called AsyncPlayerChatEvent i think

#

Let me check

mighty pier
#

ok

#

it is

sterile token
#

I think the name i said its for bungeecord

mighty pier
#

ok

sterile token
#

Yeah its called AsyncPlayerChatEvent on Spigot

mighty pier
#

what do i do then?

sterile token
#

I recommend you reading the javadocs of the event

mighty pier
#

ok

sterile token
#

Or you can look for code snippet on spigot

tardy delta
#

use the async one

sterile token
mighty pier
#

ty

sterile token
#

Amazing seriable its not working on Java IO 1.8. I get the object from input/output null

echo basalt
#

Probably isn't, but just to make sure, your object shouldn't be transient

tardy delta
#

yes it works to save inventory to base64

digital rain
eternal oxide
#

==

#

to compare numbers, what the heck are you doing there?

#

getting an ItemStack and trying to compare it to 8?

young knoll
#

You do know you can just use e.getCurrentItem

digital rain
#

first id check whether the item has meta and has lore or youll get returned null

#

unless you know for sure that the slot has lore

#

yeah check for that as well

tardy delta
#

is it possible to get a list of registred command by your plugin or do you need to save them yourself?

digital rain
#

if (item != null && item.hasItemMeta && item.getItemMeta.hasLore)

paper viper
young knoll
#

item.hasItemMeta != null

tardy delta
#

oki

young knoll
#

item.hasItemMeta is a boolean

digital rain
#

e.getcursoritem

#

or wait no

#

yes cursoritem

#

do that instead

#

currentitem is during shiftclick

#

its e.getCursor()

sterile token
# lavish hemlock congrats 👏

Not working btw. Only the connection get stablish. But sending an receiving not working. Here is the error.

  Unexpected exception while parsing console command "test out client-1 Hola"
  Caused by: java.lang.NullPointerException at dev.alex.net.api.Client.publish(Client.java:29)

Im sending an serializable object with 2 parameters (sender, message)

left swift
#

how can I set the velocity for entity so that it moves in the direction the player hit?

eternal oxide
#

get vector from player to entity and set entitys velocity to that

sterile token
#

Does anyone know why you get a NullPointerException with sockets?

#

Im seding a serializable object

eternal oxide
#

something in line 29 is null

sterile token
#

this

#

public void publish (Handler handler) throws IOException { <- That its line 29
this.connection.getOutput().writeObject(handler);
this.connection.getOutput().flush();
}

#

The method its not null

#

Literally its saying that a method its null btw

eternal oxide
#

which line is 29?

sterile token
eternal oxide
#

a method definition can not be throwing an NPE. thats not line 29

#

?paste your full stack trace

undone axleBOT
sterile token
#

ok

#

omg google doesnt open

quaint mantle
#

hello how can i change a potion's duration in PotionItemMeta (1.12.2)
i can extend it but how to decrease

quaint mantle
#

how do I setup a MySql database in localhost ?

eternal oxide
gaunt hatch
#

Do chunks not unload in 1.17.1?

quaint mantle
#

they do

gaunt hatch
#

hmmm

eternal oxide
#

check connection is not null

#

add a sysout

sterile token
#

wait i will send full client class and connection

eternal oxide
#

just check connection

gaunt hatch
#

I have my view distance set to 4 and it has 908 chunks loaded and when I walk out in the world it gets bigger, but never goes down.

Walked forward a big and now its at 921 and does not go down.

#

hmm 1012 and still not going down, very werid.

eternal oxide
#

I said to "check" the connection

sterile token
#

How check the connection?

eternal oxide
#

sysout this.connection == null

sterile token
#

Its connected because when i close my lobby console on the proxy appears a socket exception saying connection reset

eternal oxide
#

um, what the heck is this? new Thread(this.connection = new Connection(socket)).start();

sterile token
#

Per socket you need a new thread

eternal oxide
#

this is not how threads work

sterile token
#

Uhm

#

What i can do?

#

Maow nice to see you

lavish hemlock
sterile token
#

Now i dont know what the fuck but the connection its no getting stablish btw

lavish hemlock
sterile token
#

maow do you want all the source code?

lavish hemlock
#

I'm sorry I'm a bit busy atm.

sterile token
#

Ahh ok

#

No problem

#

I will tried on my own

#

I really get angry because the connection its not getting opened and there is no exception thrown

#

Its amazing programming

livid tundra
#

how do I check if it is nighttime

zealous osprey
#

Is there a way to recreate the deletion of the players chat like with F3+D, without just spamming the player with new empty lines ?

young knoll
#

No

zealous osprey
#

Since it's client side and not server side I presume ?

opaque grove
#

Does anyone knows a good article or documentation about the PerlinNoiseGenerator. I understand the basics, like generating a 2D heightmap, but i dont know how octave, freucenc and amplitude change the result

manic furnace
#

Hey guys! I want to delete a file but its in use. What can i do?

manic furnace
#

How can i do that?

hybrid spoke
mortal hare
#

cursed

manic furnace
#

When i try this i become an error, that the class can't be found.

grave kite
#
try {
    CraftTravelAgent = Class.forName("org.bukkit.craftbukkit"+Utils.getVesion()+"CraftTravelAgent");
} catch (ClassNotFoundException e) {
    e.printStackTrace();
}
if (CraftTravelAgent == null)
    return false;

TravelAgent travelAgent = null;
try {
    travelAgent = (TravelAgent)CraftTravelAgent.getField("DEFAULT");
} catch (NoSuchFieldException e) {
    e.printStackTrace();
}

how can I cast Field to a TravelAgent? Those reflections are too complicated 😅

tardy delta
#

whats the point of making a field private if you can access it using reflections

grave kite
young knoll
#

Proper encapsulation is good

#

And reflections aren’t exactly a supported API

grave kite
#

I don't need it in newer versions, but in 1.12.2 there is no other way

mortal hare
#

That's why I prefer PacketDataSerializers for Packets, they allow me to work without reflection overhead

young knoll
#

Honestly they aren’t that slow those days

#

Especially if you cache the fields and methods

mortal hare
#

yea but still, if there's a way to not use them, exploit that way

#

unless its heavier to compute ofc

#

also by not using reflections you avoid all utility class mess with try catch blocks

grave kite
#

there is probably one more way, but I don't want to make changes in spigot.jar

#

the problem is, I don't know how to cast that Field thing

#

TravelAgent is an interface

stiff cedar
#

Can someone help me? I'd opened a Cross server for my friends and me and I installed a skills mod, but whenever they try to buy a skill point with xp they can't (in bedrock mobile). How can I solve this?

points-purchase:
  material: 'BOOK'
  name: '&2Skill Points: &e%points%'
  slot: 4
  lore:
  - '&eRight Click &7- Buy 1 for &e%pointsprice% &7level(s).'
  - ''
  - '&7These are your skill points.'
  - '&7You can use these skill points'
  - '&7to spend them on individual skills.'
  - '&7You can spend your experience levels'
  - '&7for skill points.'
  right-click: true
prime harness
#

can you help me

mortal hare
#

you can try to run through online yaml parser

#

to see if there's an syntax error inside yaml file

quaint mantle
#

smae with fields

left swift
#

how can i set any enchant to for exaple block item or other type?

young knoll
#

I mean it’s certainly slower that regular method calls

grave kite
young knoll
#

But it’s been optimized a lot in modern java

fading pulsar
#

How to let the player execute the command as the OP?

quaint mantle
grave kite
prime harness
#

guys i have some servers, from hub to another mode it's fine but from the other modes you can't go back, what can i do?

quaint mantle
#

aha

mortal hare
#

i did the impossible 😄

quaint mantle
grave kite
quaint mantle
#

Ah

#

You Just resonded to the message related to the reflection speed 🤷‍♀️

prime harness
#

please help me

grave kite
late sonnet
mortal hare
#

its packet level magic

quaint mantle
mortal hare
#

i basically wrote synced server just for this

late sonnet
left swift
#

Why the player cannot get the result item from the anvil (PrepareAnvilEvent)

event.setResult(result);```
young knoll
#

Is the level cost 0

left swift
# young knoll Is the level cost 0

I did not set any costs, I think it will be the reason, but I would like the cost to be natural, i.e. the higher the number of enchants

#

but how can i make it?

visual tide
#

is there any lib that can convert stuff like 1m and 1,000,000 to 1000000?

ivory sleet
#

Maybe some utility lib

#

I wouldn’t be surprised if for instance apache utils had one

grave kite
#

is it safe to do travelAgent.findOrCreate in async/separate thread? It does seem to lag the server for a few seconds

waxen plinth
#

Let me give it a shot on my phone

wind dune
#

How can I fix this erro with reflection:

java.lang.IllegalAccessException: class de.neo.jagil.cmd.GuiExportCmd cannot access a member of class org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMetaSkull with modifiers "private"

--illegal-access=permit is already set.

My Code:

((SkullMeta)is.getItemMeta()).getClass().getField("profile").setAccessible(true);
((GameProfile)((SkullMeta)is.getItemMeta()).getClass().getField("profile").get(is.getItemMeta())).getProperties().get("texture").iterator().next().getValue(); // this line causes the exception.
ivory sleet
#

You should cache the field object

wind dune
#

Simple as that?

waxen plinth
#
private static String suffixes = "kmbt";
public static long parseFormattedNumber(String str) {
  int pow = suffixes.indexOf(str.charAt(str.length() - 1));
  long multiplier = (long) Math.pow(1000, pow + 1);
  if (pow != -1) {
    str = str.substring(0, str.length() - 1);
  }
  return Long.parseLong(str.replace(",", "")) * multiplier;
}```
@visual tide
young knoll
#

Hmm, clever

blazing scarab
#

Oh wait

waxen plinth
#

Looks overkill

#

The method I posted above should work

blazing scarab
#

That was for Durations

young knoll
#

I wouldn’t have thought of that, I would have used a switch

waxen plinth
waxen plinth
#

Didn't want to type any more than I had to on mobile

#

If you wanted it to be clean and fast you could use a map or array

#

But I feel like this isn't especially performance critical anyways

#

Not that indexOf on a 4 character string is really that slow, lol

visual tide
#

yeah it's for a withdraw command, which hopefully doesnt have to be spammed

waxen plinth
#

Oh yeah commands aren't performance critical

#

Unless you're running hundreds of them per second in which case I have some questions for you

visual tide
stone sinew
#

@ivory sleet 🤦
I can just do

if(!file.exists()) {
    file.getParentFile().mkdirs();
    file.createNewFile();
}
waxen plinth
#

💀

visual tide
#

can you even use plugin commands in those

waxen plinth
#

Yes

#

Do you use a command framework?

visual tide
#

nah

waxen plinth
#

Another 💀 for you

visual tide
#

wait wouldnt be a problem anyways since the block's not a player

ivory sleet
visual tide
waxen plinth
#

Asks for a library to do basic parsing, doesn't use a library to handle commands

waxen plinth
#

The safety and simplicity really helps

#

And there are some that are very easy to use

#

cough

visual tide
#

yeah but if you put basically your whole plugin.yml in a method call it's not more readable or simple than before

stone sinew
visual tide
#

is it?

waxen plinth
#

Here can I dm you

visual tide
#

yeye

ivory sleet
#

yapperyapps for reference here

stone sinew
digital rain
#

can someone tell me why dont these two uuids equal

young knoll
#

You are using ==

#

Use .equals

digital rain
#

when should i be using what

young knoll
#

== compares memory references

#

You use it for primitives and enums for example

digital rain
#

oh ok

left swift
#

how can i get the texture form player head? (itemstack)

west oxide
#

hi everyone

#

i have been trying to add a custom config file to cache player data before saving it to mysql database

#

but

#

it wouldnt work

#

i even followed a few tutorials

#

and it just gave errors everywhere

#

can someone help me out

tardy delta
#

why caching in a file?

#

yml is cached into a map

#

so no reason to do so

young knoll
#

Yeah cache it in memory

#

And then go straight into SQL

tardy delta
#

^^

echo basalt
#

For some reason I can't get chunks to properly load when unloading/reloading the world very fast

west oxide
echo basalt
#

Has anyone had this issue before and knows how to fix it?

west oxide
#

i still wanna learn how to use custom .yml file lol

#

and i dont know how to cache into memory ;-;

cedar dawn
#

file is a File object

west oxide
#

wait

#

its that simple ?

cedar dawn
#

yeah

#

dont forget to config.save(file)

west oxide
#

ok so i tried learning about classes and stuff ,
i'll have to do something like this ?

    FileConfiguration config = YamlConfiguration.loadConfguration(file);
}```
#

and then i'll be able to use it on other classes ?

west oxide
cedar dawn
#

you need to actually make the file

#

this 1 line wont work by itself

mortal hare
#

are scoreboard teams for living entities only

#

?

cedar dawn
#

what are you trying to achieve @mortal hare ?

quaint mantle
#

what

west oxide
#

also

#

i get this error

#

every time

mortal hare
#

im just asking if non living entity for example arrow can be part of the scoreboard team

cedar dawn
mortal hare
west oxide
quaint mantle
#

No, you are using loadCo nfg uration

#

Yiu need loadCon nfi guration

mortal hare
#

either 1.8.8 doesnt suite static method for this

quaint mantle
#

loadConfiguraion

#

Copy it

quaint mantle
cedar dawn
#

youre missing an i lol

west oxide
#

oh yeah

#

i missed the i

young knoll
#

But yes I believe you can add any entity

cedar dawn
#

@west oxide something like this will probably work

public final class Main extends JavaPlugin {

    public static FileConfiguration data;

    @Override
    public void onEnable() {
        // Plugin startup logic
        File folder = getDataFolder();
        if(!folder.exists())
            folder.mkdir();
        File file = new File(getDataFolder() + "/data.yml");
        if(!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        data = YamlConfiguration.loadConfiguration(file);
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
        File file = new File(getDataFolder() + "/data.yml");
        try {
            data.save(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
zealous osprey
#
subComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.YELLOW + "[Teleport]")));

For the life of me I cant figure out why this is throughing an error, but only due to the "ChatColor.YELLOW + "[Teleport]"" part, the rest is fine.

cedar dawn
#

Try this

#
subComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.YELLOW + "[Teleport]").create()));
young knoll
#

You can’t use ChatColor in components

#

Unless you use TextComponent.fromLegacyText

zealous osprey
cedar dawn
#

np

zealous osprey
#

yup, colors work fine

livid tundra
#

how do I check if it's nighttime

cedar dawn
#

Get the World object first, and use the method getTime()

Bukkit.getWorld(WORLDNAME).getTime();

From there you can check if the time is day or night

west oxide
#

i'll read it and try to recreate

#

ur approach is very different from every tutorial i have seen lol

left swift
#

why if I have event.getInventory().setMaxStackSize(1); I can give more with shift anyway?

waxen plinth
#

I have never used that method

#

You might have to do it manually 🌚

native bloom
#

It's possible to get a player's right and left click block actions.
Is it possible to get their pick (middle click) block actions?

quaint mantle
native bloom
#

Is the output of that not limited to the action enum?

waxen plinth
#

It is handled clientside

native bloom
#

rip

waxen plinth
#

When in creative mode the server basically just lets you do whatever with your inventory

#

You can still kind of detect it though

#

I have done it before

#

Let me dig up the code

#

?paste

undone axleBOT
waxen plinth
#

@native bloom This is how I did it

native bloom
#

😮

waxen plinth
#

Basically, just check for when InventoryCreativeEvent is fired

#

Check if it's a hotbar slot and their cursor is empty

#

Then check if the block they selected is the same as the one they are looking at

native bloom
#

Probably a dumb question, but does inventorycreativeevent fire in gms?

waxen plinth
#

It's not perfect or foolproof but it should work

native bloom
#

rip... the primary intended use case for my attempt to detect it is survival

#

Basically trying to find a way a player can interact with a block without right clicking it or left clicking it (both of which are already used for something else)

waxen plinth
#

Hmm

#

I don't think that fires any event

#

Well, it would actually

#

The event for changing their hotbar slot

#

I guess the best you could do is see if they change their selected hotbar slot to be holding the same block as what they are looking at

#

That would be even less reliable than the creative mode one though

native bloom
#

hmm

#

Are these three also client side?

waxen plinth
#

I'd imagine so

#

at me.wally.guilds.GUIHandler.Lore.getLore(Lore.java:35) ~[Guilds-1.0-SNAPSHOT.jar:?]

#

This is the line you need to be looking at

#

Lore.java, line 35

patent horizon
#

ah i just found it

waxen plinth
#

Trying to cast string to int

patent horizon
#

nah it was a logic error

mortal hare
quaint mantle
hybrid spoke
mortal hare
hybrid spoke
#

what about PlayerInteractEvent ClickType?

mortal hare
#

wait nvm

hybrid spoke
#

or InventoryCreativeEvent

mortal hare
#

he was asking for middle click outside inventory

quaint mantle
mortal hare
#

like pick the block

#

well he can detect that by checking if the block is changed in his main hand

quaint mantle
#

creative and inventories

mortal hare
#

but it could be tricky

hybrid spoke
noble lantern
#

By any chance would anyone know why this would be happening? It happens after I moved my packages around and all of the sudden now when I want to import anything from this package it just absolutely refuses? It just tells me that the import doesn't exists, however when I type the package import in manually it shows up and I can tab complete it, ill show in next screenshot

sullen marlin
#

recompile?

hybrid spoke
#

otherwise invalidate caches

sterile token
hybrid spoke
#

?ask

undone axleBOT
#

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

mortal hare
#

is there any data structure in java or bukkit utils that could represent 3 floats in it (for storage of rotation)

noble lantern
worldly ingot
#

A Bukkit Vector, dovidas

mortal hare
#

that stores doubles

noble lantern
worldly ingot
#

(not java.util.Vector, that's a Collection)

#

Oh, if you specifically want floats, then no.

mortal hare
#

Vector stores doubles not floats, i don't want to cast it

sterile token
# sullen marlin recompile?

Would be useful to implement some easy way to communicate on bungee-spigot/spigot-bungee networks? Something more sofisticated over than plugin message channel?

mortal hare
#

im currently using vectors

worldly ingot
#

Vector species API is still in incubation so there's nothing native

#

J18 will have one

mortal hare
#

eh fine

#

i'll make it myself

sullen marlin
#

you're gonna make a class with 3 primitive fields yourself!?!?!

#

wild

mortal hare
#

yeaa

#

i was just lazy

#

i wanted something sleek like vector

quaint mantle
#

Thats good was grammar

mortal hare
#

but without any block stuff

hybrid spoke
quaint mantle
hybrid spoke
#

you are not

#

you are a bully

#

not sorry

hybrid spoke
sterile token
#

Does anyone have problems with intellij ? like you change a method name you are calling from other class and until you close the class and re open the error go out

sterile token
#

Conclure

ivory sleet
#

Every backend server is essentially a server socket

#

that goes with bungeecord too

#

So you can’t establish another one

#

As the port is already reserved

worldly ingot
#

People just setup Redis pub/sub lol

ivory sleet
#

Yeah could use redis pub sub, Kafka or rabbitmq

sterile token
#

I think it should be possible to hack the spigot and proxy netty to inject a new channel for sending/receiving data between proxy-server and server-proxy

#

But i cant find where the spigot has a getter for the Netty class

ivory sleet
#

If it was that easy

#

Just injecting something into netty and make it all work

sullen marlin
#

it would have the same limits as a plugin channel lol

#

if you want a message queue use a message queue

#

right tool for the job and all

sterile token
#

Why netty should be same as plugin channel?

#

You can use it with/without players

#

Btw

#

Plugin message channel its to work with the client

ivory sleet
#

No that’s not how netty works

sterile token
#

netty are sockets connected btw

#

🤔

sullen marlin
#

ok but then youre just making a netty server

#

no 'hacking' at all

sullen marlin
sterile token
#

Why you should need a netty server??

#

The bungeecord itselft its a netty server

sullen marlin
#

well how else are you going to use it without players

sterile token
#

if sockets work without players netty that its based on sockets should work

ivory sleet
#

Sure it would be possible for bungeecord to be a server socket whilst backend servers setup up their own sockets and connect to bungeecord

#

But then again, there are way better alternatives

sterile token
sullen marlin
#

why

sterile token
#

But idk why im getting NPE when the connection its open

sullen marlin
#

there are better tools for the job and they already exist

#

use them

hybrid spoke
sterile token
sullen marlin
#

why would we use your duct-taped socket library when there are tools used by billion dollar companies that work totally reliably

sterile token
#

I will put sout on every method to see what the fuck its happening

ivory sleet
#

Or send the code here and we could see what’s the trouble

sterile token
#

Allright i will post all the library on md5 paste

#

?paste

undone axleBOT
sterile token
#

So you dont tried to help me on the air

ivory sleet
#

?

sterile token
#

Library:

https://paste.md-5.net/onusuqoqeq.java - Server (From my library)
https://paste.md-5.net/ibucofalup.java - Client (From my library)
https://paste.md-5.net/tiherugika.java - Connection (From my library)
https://paste.md-5.net/ohowowayit.java - Handler (From my library)

Plugins

https://paste.md-5.net/mimisinaso.java - Bungee plugin (Represent the server)
https://paste.md-5.net/ahojanefep.java - Spigot plugin (Represent the client)
https://paste.md-5.net/qanixiduta.java - Spigot command (Where the error occurs)

Error

https://paste.md-5.net/xiheruvuqa.java - Spigot command error

#

There you have all conclure for help

#

The erorr happen on line 30 on my Client library but line 30 its the method declaration

#

So im weird right now

hybrid spoke
#

a method declaration can't be null

#

are the version in your IDE and the one you tested the same?

sterile token
#

Im not testing in the ide

#

Im testing the server plugin on a bungee and the spigot plugin on a spigot server

hybrid spoke
#

read again what i wrote

sterile token
#

Yes

#

I programme in java 1.8 and i have running the servers on java 1.8

hybrid spoke
#

maybe i was unclear

sterile token
#

Yeah

#

Im spanish speaker that why

hybrid spoke
#

is the version of your plugin equal to the version of the plugin you have on your server?

sterile token
#

Yes

hybrid spoke
#

so if you would compile it would be the same jar as on your server?

sterile token
#

Yes

#

I have looked again the error its on line 30 on method publish, that line is: this.connection.getOutput().writeObject()

#

So probably the stream are not getting open

hybrid spoke
#

so check if either the connection or the output is null

sterile token
#

I have made a command for checking that

#

GodCipher an error its thrown

#
>test info
[19:53:02 INFO]: Client info
[19:53:02 INFO]:
[19:53:02 INFO]: Connection: null
[19:53:02 WARN]: Unexpected exception while parsing console command "test info"
org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin Client v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [Spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [Spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [Spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [Spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [Spigot.jar:git-Spigot-db6de12-18fbb24]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_301]
Caused by: java.lang.NullPointerException
        at dev.alex.net.spigot.commands.Test.onCommand(Test.java:20) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
        ... 8 more
#

Hum now that i see connection its null, so the streams are null

#

Now i will have to discover why connection its null

sterile token
#

Hum i cant understand why its null

eternal oxide
#

in Server

sterile token
#

Why?? if i take out the server will accept only 1 connection

eternal oxide
#

Your server is going to fall on its ass as its spawnign new Threads constantly

ivory sleet
#

No not really

#

But yeah it’s not a good design

eternal oxide
#

a while true loop around a new Thread? Once thats called its death

ivory sleet
#

ServerSocket::accept or whatever it’s called is awaiting a socket to connect to the server socket

eternal oxide
#

ah

sterile token
#

So what i can do? I have been checking all the client and the connection i cant find the reason why its null

eternal oxide
#

make a little more sense

sterile token
#

the loop wait for connections and when a new its received it create a thread for that connection

ivory sleet
#

Verano what about publishing it all on GitHub or smtng

sterile token
#

For you to see it?

ivory sleet
#

Would be very easy to follow everything you did then.

#

Yeah

eternal oxide
#

snippets are so hard to read when its this complex

sterile token
#

Ok

#

I will publish it on my gth

eternal oxide
#

for example, if no socket is accepted in that Thread, no connection is made and connection remains null forever

#

move your System.out.println("[Server] Connection has been opened on port " + port); message inside the While, after the new Thread

#

then you will see that no connection is ever made

sterile token
#

There you have

ivory sleet
#

Yuh, its probably smart to have something like

AtomicBoolean shutdownSignal = new AtomicBoolean();
CountDownLatch latch = new CountDownLatch(1);

Thread socketFactory = new Thread(() -> {
while (!shutdownSignal.get()) {
Socket socket = serverSocket.accept();
//TODO
}
this.latch.countDown();
}
socketFactory.start();

#

And then if you want to await destruction

#

latch.await();

eternal oxide
#

then you will see if a connection is ever made

sterile token
#

ok