#help-development

1 messages ยท Page 2049 of 1

sterile token
#

Because i wont have 2 coners

#

I will have 1 block in middle of a radio of x (any amount of blocks) blocks

#

And i need to use do it with cuboid

#

I have been trying this since 1pm of my city, and its 7 pm

glossy venture
#
Vector bp = ...; /* block position */
int     r = ...; /* radius */

Cuboid cuboid = new Cuboid(
  new Vector(bp.x - r, bp.y - r, bp.z - r),
  new Vector(bp.x + r, bp.y + r, bp.z + r)
);
``` like this?
#

this will make a cuboid of radius r around block bp

#

like

sterile token
#

Oh rlly thanks :D im happy i would prob end up with this

glossy venture
#
-----                  -----
-----                  -###-
--#-- with radius 1 -> -###-
-----                  -###-
-----                  -----
#

advanced diagram

sterile token
#

orby

glossy venture
#

but then in 3d

#

yes?

sterile token
#

Orby so the code will works in every "dimension"? Bottom, top, right and left?

glossy venture
#

yes

sterile token
#

Allright

glossy venture
#

but in 3d

sterile token
#

And would it lag?

glossy venture
#

no it calculates 2 points

sterile token
#

Because i ill use it on PlayerMoveEvent too

glossy venture
#

nah shouldnt lag

sterile token
#

And idk how many claims would exists

#

Allright

quaint mantle
#

How can I insert objects into the gui using length, height?

sterile token
#

Really thanks

glossy venture
#

np

sterile token
glossy venture
glossy venture
#

you need to convert it do an index into the list

sterile token
#

Orby do u have any problems if dm you

glossy venture
#

nah

sterile token
#

Allright really thanks :D
Nice to meet you

glossy venture
#

you too

glossy venture
#
public final int width = ...;

public int getIndex(int x, int y) {
  return width * y + x;
}
#

use that

quaint mantle
#

Thanks

glossy venture
#

and then do inventory.setItem(getIndex(x, y), item)

quaint mantle
#

What is width?

#

inventory.size()?

glossy venture
#

nah like for chests its 9, for hoppers its 5, for droppers its 3

quaint mantle
#

Okay, thanks

sterile token
#

I rember one way i was so idiot that i didnt rember that slot counts from 0

glossy venture
#

advanced diagram vol. 2

sterile token
#

orby, so final code is:

public class Cuboid {
  
  private final Vector cornerA;
  private final Vector cornerB;
  private final Integer radious;

  public Cuboid(Vector cornerA, Vector cornerB, Integer radious) {
    this.cornerA = cornerA;
    this.cornerB = cornerB;
    this.radious = radious;
  }
      
}
#

And then im stuck

#

Forget what i said

eternal night
#

Why does a cuboid have a radius ๐Ÿ˜…

hybrid spoke
#

^

sterile token
#

That why using radious

eternal night
#

But there is no radius that properly describes a cuboid

hybrid spoke
#

cuboid = circle

eternal night
#

Youd just create a sphere at the centre of a cuboid

eternal night
wide coyote
#

doesnt spigot has already a object for that

eternal night
#

It does

#

BoundingBox

#

It's called

wide coyote
#

yeah

frozen thorn
#

Hello, I saved my default config.yml in UTF-8, but when I save the default config, the "รฉ" is converted into "\xc3\xa9"
https://prnt.sc/YoKKsliP1vk0

sterile token
#

My problem is that it will be multi platform starting from 1.8x and lastest

#

So under 1.13 you dont have that class

wide coyote
#

i see

wide coyote
frozen thorn
#

ty fixed

#

using "-Dfile.encoding=UTF-8" in startup parameters

wide coyote
#

yeah

west oxide
#

will this still work fine ?

chrome beacon
#

Yes, but I do recommend using non-deprecated methods

west oxide
#

Runnable doesnt allow me to

wide coyote
#

runTaskTimer(plugin, (task)->{
task.cancel()
});

west oxide
#

what

wide coyote
#

you may not need the () idk
wrote it from my mobile device

#

ups forgot the delay and period

chrome beacon
undone axleBOT
wide coyote
west oxide
#

ohhh it worked

sterile token
# chrome beacon Yes, but I do recommend using non-deprecated methods

I finally end up with this class. What do you think?

public class Cuboid {

    private final Vector a;
    private final Vector b;

    public Cuboid(Location location, Integer radiuos) {
        this.a = new Vector(location.getX() - radiuos, location.getY() - radiuos, location.getZ() - radiuos);
        this.b = new Vector(location.getX() + radiuos, location.getY() + radiuos, location.getZ() + radiuos);
    }

    public boolean contains(Location location) { return location.toVector().equals(a) && location.toVector().equals(b); }

    public Vector getVectorA() { return this.a; }

    public Vector getVectorB() { return this.b; }
}```
viral crag
#

thinks the spelling is radians

#

Or radius

sterile token
#

Oh ok

#

But its good the class?

vocal cloud
#

Personally using an x y z | x y z is easier to do contains checks.

vocal cloud
#

Within the class. Rather than using vectors

young knoll
#

That's just a BoundingBox

sterile token
sterile token
vocal cloud
#

Yeah but less isn't necessarily better

rancid snow
#

do anvils have a pdc?

viral crag
#

Vector math is more efficient java 16+ if you use the native math, below probably not so much

sterile token
#

In conclusion my class isnt wrong?

viral crag
#

Seems alright for just storing a cube, and its movable

sterile token
#

My idea is to use it to save many regions

vocal cloud
#

?paste

undone axleBOT
vocal cloud
#

Super serializable. Minimal data to store

dawn hazel
#

alright so i have this code right here. not to special right? except when someone does close the gui it outputs a giant stacktrace thats so long its longer than my consoles scroll limit

    @EventHandler
    public void inventoryCloseEvent(org.bukkit.event.inventory.InventoryCloseEvent e) {
        if (plugin.isFrozen.contains(e.getPlayer().getUniqueId())) {
            //normal gui stuff here except its part of a semi private library 
        }
    }```
vocal cloud
#

Well good thing the log file exists

#

read it

dawn hazel
#

me when the log file doesnt show up anywhere

vocal cloud
#

The logs folder

dawn hazel
#

i know

#

its not there

vocal cloud
#

your logs folder is empty

dawn hazel
#

no

#

it has logs in it

#

and logs from today

#

but not the logs from the time the error happened

vocal cloud
#

Then you've got a bigger issue on your hands shrug1 and without the code we can't exactly help

dawn hazel
#
    @EventHandler
    public void inventoryCloseEvent(org.bukkit.event.inventory.InventoryCloseEvent e) {
        if (plugin.isFrozen.contains(e.getPlayer().getUniqueId())) {
            Gui gui = new Gui("Frozen", 3, plugin);

            //creating item and item meta
            ItemStack barrier = new ItemStack(Material.BARRIER);
            ItemMeta barrierMeta = barrier.getItemMeta();
            barrierMeta.setDisplayName(ChatColor.RED + "ยงlYOU HAVE BEEN FROZEN!");
            ArrayList<String> barrierLore = new ArrayList<>();
            barrierLore.add(ChatColor.RED + "DO NOT LEAVE UNTIL YOU ARE UNFROZEN!");
            barrierLore.add(ChatColor.RED + "LEAVING NOW WILL RESULT IS PUNISHMENT!");
            barrierMeta.setLore(barrierLore);
            barrierMeta.addEnchant(Enchantment.RIPTIDE, 1, false);
            barrierMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
            barrier.setItemMeta(barrierMeta);

            gui.setItem(barrier, 12);
            gui.setItem(barrier, 13);
            gui.setItem(barrier, 14);
            gui.setNoPermError("");
            gui.setSoundOnNoPerm(false);

            gui.openGui((Player) e.getPlayer());
        }
    }
}```
#

there isnt much you can tell from this code

#

the gui stuff is from a library that isnt widely known

vocal cloud
#

is that causing the issue?

dawn hazel
#

i cant tell

vocal cloud
#

IE when a frozen player closes their inventory the error shows up?

dawn hazel
#

the error happens once when the player tries to close their menu

#

but it doesnt happen again cause my panel says its throttled the amount of data outputted

vocal cloud
#

You're not running it locally?

dawn hazel
#

no

#

its on a host

vocal cloud
#

Try clearing the logs folder running it again. Once the error occurs do /stop and then check for the log

dawn hazel
#

!paste

vocal cloud
#

?paste

undone axleBOT
kind hatch
#

?paste

undone axleBOT
dawn hazel
#

thanks

viral crag
#

found mike a log file

vocal cloud
dawn hazel
#

the stack trace doesnt show up in the log file

#

odd

viral crag
#

Does your gui library have it's own logger?

dawn hazel
#

not to my knowledge

#

wait

#

i got a shorter stacktrace

sterile token
#

Its possible to set a value to block so them i can identfy from the blocks ?

dawn hazel
#

stackoverflow error

vocal cloud
#

yup

dawn hazel
#

my guess is somethings overloaded

#

but what could be causing it

sterile token
vocal cloud
#

no

sterile token
#

Oh lol

vocal cloud
#

mmmm paper

dawn hazel
#

to my knowledge it shouldnt be overloading from just calling the inventory close event

#

line 48 seems to be mentioned

#

gui.openGui((Player) e.getPlayer());

#

hmm

vocal cloud
#

Does gui.OpenGUI happen to close any currently open GUI's?

dawn hazel
#

im unsure

#

i could put a scheduler in there and see if that fixes it

#

wait

opal sluice
vocal cloud
dawn hazel
#

if i put a closeinventory method before calling the inventory opening

#

maybe that would help

vocal cloud
#

Stackoverflow errors are often caused by recursive functions.

#

you're in the inventoryclose event

dawn hazel
#

it shouldnt be calling it multiple times

vocal cloud
#

so if you open an inventory but that closes the inventory to open the new one

dawn hazel
#

hmm

vocal cloud
#

You're looking at a stackoverflow error

opal sluice
dawn hazel
#

heres the src

#

gui part is in objects

pliant oyster
#

?jd-s

undone axleBOT
pliant oyster
#

for me btw

opal sluice
#

com.woolmc.hyperfreeze.Events.InventoryCloseEvent.inventoryCloseEvent(InventoryCloseEvent.java:48)

#

is the issue

dawn hazel
#

thats gui.openGui((Player) e.getPlayer());

viral crag
#

Those are some interesting commit comments

sterile token
#

How can i check in BlockPlaceEvent if there is a block which contains a custom displayname and lore??

vocal cloud
#

count probably

sacred mountain
#

when someone tells you they can help code, but they really mean they can configure other plugins

#

pain

vocal cloud
#

rekt

sacred mountain
#

"i have experience in configuring and consoles"

#

???

unkempt peak
viral crag
opal sluice
dawn hazel
vocal cloud
#

I bet you that the issue is that it's calling the close event over and over again

dawn hazel
#

its my other devs

opal sluice
#

The problem is, that the lib open a new inventory

#

so it close the inventory actually here

#

before the game closed it

#

and so it goes on over and over

vocal cloud
#

what

viral crag
dawn hazel
#

i put a delay in

sterile token
dawn hazel
#

lets see if that fixes anything

unkempt peak
dawn hazel
#

and success

#

no more error

opal sluice
#

since it's "InventoryCloseEvent" the event isn't completed yet

sterile token
unkempt peak
opal sluice
#

So, the lib open a new inventory, but, there is already a gui, so the game close it, and throw an other close event, but, lib open a new one, so close, and so on

#

infinite loop delaying the opening, will just make the close event perform and then the opening from the lib will just open and not close

sterile token
unkempt peak
#

The even is called before its placed

#

Event*

unkempt peak
#

Get the Player and compare the item meta of their hand

dawn hazel
#

the issue is fixed now by just adding a slight delay

#

thanks

sterile token
#

I need to check when player break blocks if near a block with custom displayname and lore, and then do stuff

#

That why

unkempt peak
#

Oh my bad I thought you said on place

sterile token
#

Oh that why

unkempt peak
#

You need to store the blocks location somewhere

sterile token
opal sluice
# dawn hazel i see

tbh, if you open the same inventory, just cancel the close event, it will be better

dawn hazel
unkempt peak
#

Just check if the block that is broken is the one stored

#

So on place store position and either put it in a list if it has the correct meta or store the meta and compare it that way

dawn hazel
#

plus thats the first thing i tried doing when i made the inventorycloseevent

opal sluice
#

Oh, yeah, it doesn't implements cancellable ๐Ÿ˜ฎ

#

well, my explanation doesn't holds then

dawn hazel
#

yeah

opal sluice
#

or that's it, but without the cancellable assumption x)

vocal cloud
#

I mean you can always check the name of the inventory being closed and check if it's not the same as the one currently being opened

opal sluice
#

At least you can give it a shot, not sure that it will not give you a NPE here

tender shard
#

No NPE will ever happen in this case

opal sluice
viral crag
#

Interesting, doesnt really seem like closing is implemented yet for that library beyond a sound

opal sluice
viral crag
#

I guess, ... seems to open on access - I am bad with gui libraries anyway

glossy scroll
#

@viral crag i found the problem with my code btw

#

its a mc bug that i've now submitted a spigot PR for

golden turret
#

needing help with this?

viral crag
muted sand
#

how do I send how "broken" a block is to a client?
how would I go about modifying the hardness of a block (ie stone mines faster with my hand opposed to an actual pick)?

#

afaik i can send packets to simulate how "broken" a block is, but yea!

worldly ingot
#

Player#sendBlockDamage()

#

Though changing a block's hardness isn't possible afaik

muted sand
muted sand
#

would it be possible with nms?

worldly ingot
#

iirc it's hard-coded into the block settings so probably not without recompiling the server, no

golden turret
#

asm?

lavish hemlock
#

You could only use bytecode modification with an instrumentation agent, JVMTI agent, or custom classloader.

#

Problem is that the first requires an extra launch argument, the second is a JDK exclusive feature, and the last requires your code to load before the ones you're modifying.

wary harness
#

is it possible to get instance of OfflineProxiedPlayer

#

I need to check there ip I got there uuid

#

but I get null point if I try to get ProxiedPlayer

#

and I am hooking to litebans to check if they are banned and LiteBans need there ip

tranquil viper
#

๐Ÿ‘‹ Trying to optimize https://github.com/Crazy-Crew/Crazy-Crates. I noticed that the main issue was from the stripColor() method when checking if the inventory is a crate inventory or not. What would be the best way to go about erasing the stripColor() method entirely?

#

using 4.35% of the overall cpu which is causing some problems.

ivory sleet
#

Could use InventoryView to identify said inventories

vale cradle
waxen plinth
#

@

golden turret
#

if you are using the remapped version

#

it is the 6th

#

and you need to listen the PlayerInteractEvent

#

as there the player start to pull the bow

glossy venture
#

how can i hook into the minecraft command system?
i made my own command engine which takes an input string and;

- executes the command
- creates suggestions for the command
- sets error messages (like the ones in brigadier above the chatbox)
#

i just want to get everything past the /

#

as a string

#

and then have the above stated outputs be sent to the sender

#

console or player

#

also for feature 3, this is what i mean:

#

the thing above

#

i guess 5 am isnt the time for development help

hardy swan
#

Sleep is for the weak

#

Jk, sleep for a better working brain

glossy venture
#

its weekend so yeah

#

staying up till 5:30 am or so

#

but i still need help

#

on my problem

summer scroll
#

Can I play music only to specific player?

hybrid spoke
kind hatch
thin venture
#

How would I make a cmd like this /pg on
this is the code i already have

package com.quartz.pearlGame.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import net.md_5.bungee.api.ChatColor;

public class PearlCMDS implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        
        if(sender instanceof Player) { 
            Player player = (Player) sender;
            String symbol = ChatColor.DARK_AQUA + "[" + ChatColor.AQUA + "!" + ChatColor.DARK_AQUA + "] ";
        
            // /pg on
            
            if(args.length > 0) {
                
                
                
            } else {
                player.sendMessage(symbol + ChatColor.GOLD + "/pg on" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Turn game on");
                player.sendMessage(symbol + ChatColor.GOLD + "/pg off" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Turn game off");
                player.sendMessage(symbol + ChatColor.GOLD + "/pg add <player>" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Add player to game");
                player.sendMessage(symbol + ChatColor.GOLD + "/pg remove <player>" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Remove player from game");
                player.sendMessage(symbol + ChatColor.GOLD + "/pg list" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Get list of players currently playing");
            }
            
            
            return true; 
        } else {
            System.out.println("Only players can use that command!");
        }
            
        return true;
    }
}
#

basically im not entirely sure how to do it using the args, I am relatively new to plugin making

#

I've googled a bit but havent found anything that helps me

earnest forum
#

then whatever ur code is

earnest forum
#

args[1] would be the second part

#

etc.

#

example: /testcommand arg0 arg1 arg2

kind hatch
thin venture
summer scroll
rare pike
#

Does anyone know anticheat plugin for spigot?

tranquil viper
summer scroll
kind hatch
tranquil viper
#

Anyone have any code snippets on how to use InventoryView?

earnest forum
#

it has a top and bottom inventory

#

like when you open a chest

#

the bottom inventory is the player's

#

and the top is the chest

tranquil viper
#

So I declare it using what though, a regular inventory?

earnest forum
#

player object should have a method to get

#

it

#

give me a second

#

im not actually sure how to get the object

tranquil viper
#

Yea that's why I was confused lol

earnest forum
#

ive never used it

tranquil viper
#

I'm looking for an alternative for stripColor()

#

As it seems to be effecting performance pretty harshly

kind hatch
#

String#replace() ๐Ÿ˜›

tranquil viper
#

wym, I need to strip the color of the inventory

#

I can't do that with replace

earnest forum
#

Player#getOpenInventory() returns an inventory view

kind hatch
tranquil viper
#

I was recommended to use InventoryView to check if it's the right inventory type

#

Not sure if that's my best option

kind hatch
#

Well, I'm pretty sure that stripColor actually does call replace(), which was part of the joke I was trying to make. String comparisons are expensive calls. You should ideally compare the inventory instances as it would be far more efficient. You can also use the InventoryViews to do the comparison.

tranquil viper
kind hatch
tranquil viper
#

A ton I guess, I don't have direct access to the server but I was given this in the spark report

#

Actually uses 9%

kind hatch
#

Yea. String comparisons should really be your last resort option. There are some cases where string comparisons can be really fast, but they are few and far between. However, any other type of comparison should be significantly faster.

tranquil viper
lethal coral
#

Am I allowed to ask questions about protocollib here?

earnest forum
#

yea

lethal coral
#
    private void sendDestroyPacket(){
        PacketContainer container = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
        container.getModifier().writeSafely(0, 1);
        container.getModifier().writeSafely(1, new int[]{this.disguiseEntity.getEntityId()});
        try{
            Games.getInstance().getProtocolManager().sendServerPacket(this.player, container);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }


    }
errant narwhal
#

hi

#

can soneone help please

#

List<Location> list = ( plugin.getConfig().getlocationlist("loc"));``` i want to get locationlist in config file but it don't have any code about `getlocationlist ` how to get someone help pls
earnest forum
#

you cant get a Location from config

#

you store 3 numbers

#

x,y,z

#

and then convert it into a location

errant narwhal
#

how to do that

radiant cipher
#

yo, does anyone know how/where to get the java.utils package to import? I'm trying to get a random number rolled and internet isnt giving me any options to download that i can find

earnest forum
#

its in java

radiant cipher
#

using intellij

earnest forum
#

builtin

radiant cipher
#

how to import it?

lethal coral
radiant cipher
#

im noob to java no idea what that means

earnest forum
#

not u

lethal coral
#

comes out as this (something of the sort)

radiant cipher
#

o my b

earnest forum
#

are u using an ide

radiant cipher
#

yeah

#

intellij

earnest forum
#

hover over it

#

and press import

#

hover over the error

#

intellij has a thing to import anything ur using

#

when ur typing it in

#

if u select it in the autocomplete

#

it will import it automaticaly

radiant cipher
#

yeah it doesn't show still

lethal coral
#

I must not understand something here

radiant cipher
#

i hover mouse over and says

errant narwhal
radiant cipher
#

"no documentation found"

earnest forum
#

random isnt a thing

#

Random

lethal coral
#

why are you manually importing

radiant cipher
#

oh it's capitalized

#

-_-

lethal coral
#

๐Ÿ˜

errant narwhal
# earnest forum x,y,z

alse do you have anymetmod to when place block have ItemMeta like name "cow" then when break it still drop ItemHaveMeta name "cow"?

earnest forum
#

i dont understand that

errant narwhal
earnest forum
#

thats complicated

#

i dont have time to explain it rn

#

ask somebody else

errant narwhal
#

ok

radiant cipher
#

is there a way to wait for ticks to pass in spigot?

earnest forum
#

yeah

earnest forum
#

with runTaskLater

#

it'll run code after a certain amount of ticks is passed

radiant cipher
#

what's the import for it

lethal coral
earnest forum
#

intellij will automatically import bro

lethal coral
#

intellij has an auto import feature

earnest forum
#

u dont need to manually import

radiant cipher
#

how

#

lmao

earnest forum
#

hover over it

#

and press import

radiant cipher
#

over what

earnest forum
#

the class

radiant cipher
#

what class

earnest forum
#

if you are typing new BukkitRunnable

#

hover over bukkit runnable

#

and click import

#

you should learn the basics of an ide]

#

before coding

radiant cipher
#

Thank you

thin venture
#

Using the args of /pg, I would want it to have multiple options/args like /pg on or /pg off how would i do this?

earnest forum
#

check if args[0] equals on

#

if not

#

use an else if

#

for equals off

thin venture
#

thanks

thin venture
earnest forum
#

send the code

thin venture
#
if (cmd.getName().equalsIgnoreCase("pg")) {
                
                if (args[0] == "on") {
                    player.sendMessage("You joined the game");
                } else if (args[0] == "off") {
                    player.sendMessage("You left the game");
                } else if (args[0] == "help") {
                    player.sendMessage(symbol + ChatColor.GOLD + "/pg on" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Turn game on");
                    player.sendMessage(symbol + ChatColor.GOLD + "/pg off" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Turn game off");
                    player.sendMessage(symbol + ChatColor.GOLD + "/pg list" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Get list of players currently playing");
                }
            }

was just about to do that

earnest forum
#

dont use ==

thin venture
#

ok

earnest forum
#

String#equals(string)

#

so

#

args[0].equals("on")

thin venture
#

ohhhh

earnest forum
#

use == for enums n stuff

thin venture
#

ok thanks

earnest forum
#

you should realistically use .equalsIgnoreCase

#

because if they do /pg ON it wont run

thin venture
#

I just did /pg help and it sends the msg twice

earnest forum
#

send the full code

#

whole method

radiant cipher
#

how to edit this to get delay?

#

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

public class command4 implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
    {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            Plugin plugin;
            Bukkit.getScheduler().runTaskLater(plugin, () -> {
                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say ran a delayed command");
            }, 40L);

        }

        return true;
    }
}```
#

Like obvious it's Plugin plugin but im just not sure what to put there

#

im trying to get this to send a server message after 40 ticks

earnest forum
vale cradle
# golden turret

Ya, the thing is that I didn't want to use NMS at all, anyways I have tools that end up being more handy than that :p

#

ty Anyways tho <3

radiant cipher
#

would I use that?

earnest forum
#

the type of the plugin variable is the class that extends JavaPlugin

#

whenever you require an instance of the plugin you have to get the singleton instance of that class

#

there cannot be more than 1 of that class

#

you can do this with dependency injection

#

?di

undone axleBOT
radiant cipher
earnest forum
#

Test plugin

#

assuming that the name of your class that extends javaplugin is Test

#

then to get the instance

earnest forum
#

or you can make a static method inside of the Test class

#

i personally prefer the static method

#

create a private static Test plugin; in Test

#

and then in the onEnable set plugin to this

#

then make a public static Test getInstance() method that just returns plugin

radiant cipher
#

doing that just piles up errors for me, without an example it's no good

earnest forum
#

ill give u some snippets from my plugin

#

created a static instance

#

in the onEnable i set that instance to this

radiant cipher
#

mk

earnest forum
radiant cipher
#

i did test.instance

earnest forum
#

and what happened?

radiant cipher
#

no errors

earnest forum
#

ok

#

good

#

now

#

whenever you need an instance of the plugin

#

test.getInstance()

radiant cipher
earnest forum
#

thats to get the instance

#

Mining is the name of my class

radiant cipher
#

yeah I see, where would I write it though

#

in the main class or in other classes>

earnest forum
#
Bukkit.getScheduler().runTaskLater(test.getInstance(), () -> {
                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say ran a delayed command");
            }, 40L);
#

other classes

#

thats the whole point of this

#

so you can get the instance of your plugin in other classes

#

lots of things require an instance of the plugin

#

BukkitRunnables, NamespacedKeys

radiant cipher
#

you lost me xD

earnest forum
#

ok

#

so

#

ill give u another example from my plugin

radiant cipher
#

nono it's the way it's being explained

#

I literally just need 1 entire example shown

#

and then i got it

#

not snippets

earnest forum
#

public class Main extends JavaPlugin {
  private static Main plugin;

  public void onEnable(){
    Main.plugin = this;
  }

  public static Main getInstance() { return Main.plugin }

}

Main.java ^^

public class OtherClass{

  public OtherClass { // constructor
      Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> {

      }, 40L);
  }

}
#

point of the static method

#

is so when you require that plugin object

#

you can just call Main.getInstance()

#

or in your case

#

test.getInstance()

radiant cipher
#

ok will try it

earnest forum
#

which line is the error on

#

im not reading all of that

hardy swan
#

what's the difference between ItemMeta#setLocalizedName(String) and ItemMeta#setDisplayName(String)

earnest forum
hardy swan
#

how does it even allow setting of localized names

radiant cipher
#

still having problems

#

going to undo it

#

maybe if i sent my main and the command for it

earnest forum
#

send the code that's related

#

to enchanting

#

is 49 the slot where you put the item to enchant?

radiant cipher
#

import org.bukkit.plugin.java.JavaPlugin;

public class test extends JavaPlugin {
    @Override
    public void onEnable() {
        getLogger().info("onEnable is called!");
        this.getCommand("kit").setExecutor(new command1());
        this.getCommand("test").setExecutor(new command2());
        this.getCommand("complex").setExecutor(new command3());
        this.getCommand("wait").setExecutor(new command4());
    }
    @Override
    public void onDisable() {
        getLogger().info("onDisable is called!");
    }
}```
main ^

package com.lerfing;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class command4 implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (sender instanceof Player) {
Player player = (Player) sender;
test plugin;
Bukkit.getScheduler().runTaskLater(plugin, () -> {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say ran a delayed command");
}, 40L);

    }

    return true;
}

}```
^ command4

#

What do I change in main and command4 to get it to work

earnest forum
#
public class test extends JavaPlugin {
    private static test plugin;

    @Override
    public void onEnable() {
        test.plugin = this;
        getLogger().info("onEnable is called!");
        this.getCommand("kit").setExecutor(new command1());
        this.getCommand("test").setExecutor(new command2());
        this.getCommand("complex").setExecutor(new command3());
        this.getCommand("wait").setExecutor(new command4());
    }

    @Override
    public void onDisable() {
        getLogger().info("onDisable is called!");
    }

    public static test getInstance(){
      return test.plugin;
    }
}
#

for your main class

#

and then in command4

#

set plugin to test.getInstance()

short raptor
#

How can check the player's cause of death from PlayerDeathEvent?

#

All I need to know is if they were killed by another player or not

#

Including kill cred like "burned while trying to escape x"

earnest forum
#

use EntityDamageByEntityEvent

#

check if the damager and victim are both players

#

there ya go

earnest forum
short raptor
#

Ok

#

And then I just do the entity.is dead or something

radiant cipher
#

ok done, says in main cannot resolve symbol plugin, and in command4 it says cannot resolve method getInstance

earnest forum
#

yeah

short raptor
#

To see if they died

#

What about when they died to something like fall damage @earnest forum? because fall damage is not an entity

earnest forum
short raptor
#

Do I need to use another event for that

earnest forum
#

ive done this before

short raptor
#

@tropic idol PLEASE use pastebin because this spam of chat is horrible

earnest forum
#

fr

short raptor
radiant cipher
# earnest forum are you sure u added my changes

import org.bukkit.plugin.java.JavaPlugin;

public class test extends JavaPlugin {
    @Override
    public void onEnable() {
        test.plugin = this;
        getLogger().info("onEnable is called!");
        this.getCommand("kit").setExecutor(new command1());
        this.getCommand("test").setExecutor(new command2());
        this.getCommand("complex").setExecutor(new command3());
        this.getCommand("wait").setExecutor(new command4());
    }
    @Override
    public void onDisable() {
        getLogger().info("onDisable is called!");
    }
}```

```package com.lerfing;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class command4 implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
    {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            Bukkit.getScheduler().runTaskLater(test.getInstance(), () -> {
                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say ran a delayed command");
            }, 40L);

        }

        return true;
    }
}```
earnest forum
#

read carefully

#

Ah

#

@short raptor

#

in PlayerDeathEvent

#

you can call

#
EntityDamageEvent c = e.getEntity().getLastDamageCause();
#

EntityDamageEvent allows you to check the damage cause

short raptor
#

Ohh okay cool

earnest forum
#
if (c.getCause() == DamageCause.ENTITY_ATTACK)
#

you can also do

radiant cipher
#

ok, no errors

#

trying now

earnest forum
#
if (e.getEntity().getKiller() instanceof Player)
#

keep in mind this one is using the PlayerDeathEvent object^

short raptor
#

Yeah ok that's a lot better for me

#

Thank u

earnest forum
#

np

radiant cipher
#

ok really weird thing

#

when I run the plugin with stuff you sent it gives error in console including java issue

#

or something

earnest forum
#

send the error

radiant cipher
#

but when I undo everything it goes back to being fine

earnest forum
#

just because theres an error doesnt mean you have to get rid of everything

radiant cipher
#
27.03 08:09:01 [Server] INFO java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.lerfing.test.getCommand(String)" is null
27.03 08:09:01 [Server] INFO at com.lerfing.test.onEnable(test.java:13) ~[?:?]
27.03 08:09:01 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:520) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:434) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:619) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:266) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1010) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at java.lang.Thread.run(Thread.java:831) [?:?]```
#

yeah I can redo it

earnest forum
#

send the class

radiant cipher
#

which one

earnest forum
#

test

radiant cipher
#

k

#

import org.bukkit.plugin.java.JavaPlugin;

public class test extends JavaPlugin {
    private static test plugin;

    @Override
    public void onEnable() {
        test.plugin = this;
        getLogger().info("onEnable is called!");
        this.getCommand("kit").setExecutor(new command1());
        this.getCommand("test").setExecutor(new command2());
        this.getCommand("complex").setExecutor(new command3());
        this.getCommand("wait").setExecutor(new command4());
    }

    @Override
    public void onDisable() {
        getLogger().info("onDisable is called!");
    }

    public static test getInstance(){
        return test.plugin;
    }
}
earnest forum
#

did you not do that?

radiant cipher
#

i did

#
    description: wait command
    usage: /wait
    permission: lerfing.wait```
earnest forum
#

did you put commands: before it

radiant cipher
#
version: '1'
main: 'com.lerfing.test'
api-version: 1.17
commands:
  kit:
    description: kit command
    usage: /kit
    permission: lerfing.kit
  shit:
    description: shit command
    usage: /shit
    permission: lerfing.shit
  complex:
    description: complex command
    usage: /complex
    permission: lerfing.complex
  wait:
    description: wait command
    usage: /wait
    permission: lerfing.wait```
#

ignore shit lol

earnest forum
#

you havent put "test" as a command

#

it doesnt exist

#

this.getCommand("test").setExecutor(new command2()); this line is the error

radiant cipher
#

test it the main class name

#

wait is the command

earnest forum
#

yes

radiant cipher
#

I didn't need to do that with every other command

earnest forum
#

you are registering a non-existant command

#

this.getCommand("test").setExecutor(new command2()); get rid of this

radiant cipher
#

what if I change the yml

#

kinda want to keep it

earnest forum
#

go ahead

#

you can have the same command name as your main class btw]

radiant cipher
#

it worked

#

wooo

earnest forum
#

and you should really get into the practice of naming your classes correctly

#

never start a class with a lowercase

radiant cipher
#

understood

earnest forum
#

its not like

radiant cipher
#

ok question

earnest forum
#

gonna give u an error

#

its just like common practice

radiant cipher
#

yea

#

so this part

#
        return test.plugin;``` at the end of the code, what does that do
earnest forum
#

wdym?

radiant cipher
#

for every other command I made

#

I didn't have to do private static anything

#

so why this one?

earnest forum
#

yes because

#

BukkitRunnable

#

requires an instance of the plugin class

#

to run

radiant cipher
#

yeah but why return

#

on it

#

i still dont get why this works

earnest forum
#

you need to do that because theres only 1 instance of the main class

short raptor
#

What's wrong with this line? I don't understand why it "cannot be applied to" registerEvents

earnest forum
#

so just this

mortal cedar
#

Is it possible to let a player execute a command and ignore if they have the permissions for that command?
Giving op before and removing it afterwards isn't an option since most permission plugins override the op feature completely

radiant cipher
#

ok rather

#

getInstance(){

}

short raptor
radiant cipher
#

where and how and why use it

#

is that like

#

built into java

earnest forum
#

no

#

its a spigot thing

#

u can change themethod name to anything

radiant cipher
#

huh

earnest forum
#

you can make it

radiant cipher
#

wait so getInstance could be named anything?

proper notch
earnest forum
#

ues

#

you can make it ILoveFortniteMethodAndMiencraftAndEmoting

#

literally whatever u want

mortal cedar
#

too bad

earnest forum
#

as its required sometimes in other classes

radiant cipher
#

ok 1 more question

earnest forum
#

go ahead

radiant cipher
#

when you write test.plugin = this;

earnest forum
#

yea

radiant cipher
#

what is this actually representing

proper notch
#

Ideally you wouldn't be statically instancing your plugin's main class and instead you'd use proper dependency injection

proper notch
#

No it's good practice.

earnest forum
#

you have to create new object of everything

proper notch
#

No... you have one instance you properly pass through dependency injection.

earnest forum
#

i prefer using a static method though

proper notch
#

I don't throw static getters everywhere in my projects for all its core components and I don't have hundreds of instances of them.

earnest forum
#

more convenient

radiant cipher
#

hmm

#

ok

proper notch
radiant cipher
#

ok so this actually means test

earnest forum
#

what we're trying to get is the Plugin class because you need that for a bukkit runnable

#

so you set that static variable to the Plugin class

#

and then create a method to get that

proper notch
#

So say you had a method public String getSomething() { return "something"; }, from within that class' method you can do this.getSomething()

radiant cipher
#

so if i were to replace this; with test;

#

it would do the same thing right?

earnest forum
#

yea

radiant cipher
#

since the class is named test

earnest forum
#

no

proper notch
#

That wouldn't work as test would have to be a variable that is of your class.

radiant cipher
#

woot

proper notch
#

So for instance if you did;

private Test test = this;

you could then use test

earnest forum
#

this is used for instance context

radiant cipher
#

ok but then that means

earnest forum
#

test is used for static context (unless you have a variable named test)

radiant cipher
#

test = this;

#

and this = ?????

earnest forum
#

you should really change the class to Test

proper notch
#

this is the instance of the class you're currently in, in that case, that instance of Test

radiant cipher
#

ok so the test object

proper notch
#

So if you did private Test test = this, you're assigning the variable test to the instance of that class you're currently in. test would therefore function the same as this within that class.

radiant cipher
#

correct?

proper notch
#

Yes

radiant cipher
#

mk

earnest forum
radiant cipher
#

i dont wanna hold shift while pressing t

proper notch
#

yh, never name your classes with lowercase. Always follow proper naming conventions.

earnest forum
#

otherwise your coding experience gonna be a hell of a lot more confusing

#

u realistically start variables with lowercase, so when you type in class names you might confuse them for variables

radiant cipher
#

facts

#

im lazy tho

earnest forum
#

programming includes lots of typing

#

should probably get used to it\

sacred mountain
#

mine is just

#

<letter>TAB<letter>TABTABTABTAB

earnest forum
#

fr

#

occasional hold shift for enums

sacred mountain
halcyon mica
#

So I am currently trying to spawn a armor stand manually using packets, but this causes the receiving player to immediatly be kicked after adding the equipment metadata packet to it

#

What am I missing here?

#
    private static void sendSpawnPackets(Player p, ArmorStand stand) {
        PacketUtils.send(p, stand.getAddEntityPacket());
        PacketUtils.send(p, new ClientboundSetEntityDataPacket(stand.getId(), stand.getEntityData(), true));
        List<Pair<EquipmentSlot, ItemStack>> items = Lists.newArrayList();
        for(EquipmentSlot s : EquipmentSlot.values())
            if(stand.hasItemInSlot(s))
                items.add(new Pair<>(s, stand.getItemBySlot(s)));
        PacketUtils.send(p, new ClientboundSetEquipmentPacket(stand.getId(), items));
    }```
mortal cedar
#

For vanilla commands at least but thats exactly what I wanted

frigid rock
#

Hey, how can you put "new" worlds in a different folder?

sick ermine
#

how can i solve?

delicate lynx
#

update java

tardy flame
young nest
#

Hey guys, I'm having a hard time understanding what's wrong.. I am trying to read my querries externaly but it throws an error..
The error:

11:48:23 [SEVERE]     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
11:48:23 [SEVERE]     at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
11:48:23 [SEVERE]     at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
11:48:23 [SEVERE]     at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:371)
11:48:23 [SEVERE]     at me.caujasutom.tcore.TCoreBungeeCord.initDb(TCoreBungeeCord.java:124)
11:48:23 [SEVERE]     at me.caujasutom.tcore.TCoreBungeeCord.onEnable(TCoreBungeeCord.java:40)
11:48:23 [SEVERE]     at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:265)
11:48:23 [SEVERE]     at net.md_5.bungee.BungeeCord.start(BungeeCord.java:285)
11:48:23 [SEVERE]     at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67)
11:48:23 [SEVERE]     at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)```
The SQL code:
```CREATE TABLE IF NOT EXISTS `TCore.Player_data` (
    `UUID` VARCHAR(36),
    `USERNAME` VARCHAR(16),
    `IP` VARCHAR(35),
    PRIMARY KEY (`UUID`)
);```
sick ermine
glossy venture
tardy flame
young nest
# young nest Hey guys, I'm having a hard time understanding what's wrong.. I am trying to rea...

The querry code:

        String setup;
        try (InputStream in = getClass().getClassLoader().getResourceAsStream("SQL/Create.sql")) {
            setup = in.readAllBytes().toString();
        } catch (IOException e) {
            getLogger().log(Level.SEVERE, "Could not read db setup file.", e);
            throw e;
        }
        String[] queries = setup.split(";");
        for (String query : queries) {
            try (Connection conn = ds.getConnection();
                 PreparedStatement stmt = conn.prepareStatement(query)) {
            stmt.execute();
            }
        }
        getLogger().info("ยง2Database setup complete.");
    }```
spiral light
#

did you try to debug what "setup" prints out ?

#

because in.readAllbytes().toString() is mostly an array which then .toString() will not make bytes to string but obj to string

#

thats why you get "[B@5488b5c5" which is the product of an array.toString()

#

@young nest your probably looking for new String(byte[]);

short raptor
#

When a ground item is destroyed (e.g. cactus, lava, explosion, void, NOT despawn), it causes an EntityDeathEvent right?

spiral light
#

?tryandsee

undone axleBOT
spiral light
#

or

#

?jd

spiral light
#

EntityDeathEvent

short raptor
short raptor
#

ยฏ_(ใƒ„)_/ยฏ

spiral light
#

i am sure that an item is not alive O.o

chrome beacon
#

An item isn't a living entity. It does not have hp

short raptor
#

so then it wouldn't cause EntityDeathEvent

#

But what event would it be? I looked through the events list on docs but there wasn't any event

chrome beacon
#

You could try the entity damage event

short raptor
#

Yeah I'll try that

midnight shore
#

Hi, how can i make an item able to break a block in adventure mode?

regal dagger
#

How to cancel task after it's been done once?

             new BukkitRunnable() {
            @Override
            public void run() {
                boosting.remove(event.getPlayer());
            }
        }.runTaskTimer(Main.instance, 5, 5);```
chrome beacon
chrome beacon
regal dagger
#
    @EventHandler
    public void Boost(PlayerToggleSneakEvent event) {

        Player p = event.getPlayer();
        if (p.isSneaking()) {
            return;
        }

        p.setVelocity(p.getLocation().getDirection().multiply(35));
        p.playSound(p.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH, 10, 1);
        boosting.put(event.getPlayer(), true);

             new BukkitRunnable() {
            @Override
            public void run() {
                boosting.remove(event.getPlayer());
            }
        }.runTaskTimer(Main.instance, 5, 5);
    }
}```
dire marsh
#

scheduleSyncDelayedTask

chrome beacon
#

^^

#

Or just runTaskLater

regal dagger
#

Didn't know about that, thanks!

fierce glacier
#

hi

#

the getCustomName don't work for why i search to do

#

so, i need to understand how to use the getMetadata() please

#

just " .getMetadata("name"); " ?

chrome beacon
#

You shouldn't have to use Metadata

#

What doesn't work with getCustomName?

fierce glacier
#

i need to get the name of a modded entity of customNPC's mod

chrome beacon
#

Spigot isn't designed to work with mods

fierce glacier
#

I'm sure it's possible ! :c

chrome beacon
#

Well yes, but you might have to use NMS instead of Spigot API

fierce glacier
#

what is that ?

chrome beacon
#

You should be making a Forge or Fabric mod instead

#

Spigot is not made for modded

fierce glacier
#

i'm on 1.7.10 version

#

with cauldron

chrome beacon
#

Even worse

#

We don't support 1.7 nor hybrid forks

#

You're on a dead version. No support will be given

fierce glacier
#

nice =-="

tender shard
fierce glacier
tender shard
#

I don't have any problem with that, it's just funny to see someone using a 9 year old version instead of, well, just not doing that lol

fierce glacier
#

for exemple, paladium is on 1.7.10 version

spiral light
#

i can underdstand using 1.8 but whts the point of 1.7.10

fierce glacier
#

i don't see any problem x)

dire marsh
#

1.7.10 is so different now I doubt anyone knows how to do what you want anymore

fierce glacier
spiral light
#

what O.o

#

i think ppl use 1.8 because they want to stupid pvp mechanic

#

but 1.7.10 is just old and has even less features then 1.8

fierce glacier
#

yeah i know :/

dire marsh
#

what's cauldron again

tender shard
dire marsh
#

forge with spigot plugins?

spiral light
#

i thought he talks about the block O.o

fierce glacier
dire marsh
#

magma is a more up-to-date version

fierce glacier
#

on 1.8 version ?

dire marsh
#

no...

#

1.12 and 1.16

fierce glacier
#

that is the problem

tender shard
#

updating = problem?

fierce glacier
#

i have try to switch to 1.12.2 version

tender shard
#

1.12.2 is so old, why would anyone consider this an "update"? even 1.16 is already outdated lol

dire marsh
#

1.12 is like the 1.8 of 1.9 pvp

fierce glacier
#

and i have found a lot of problem like : need to restart all my work

spiral light
#

i mean... if you update to 1.16.5 ... why not update to 1.18.2 directly ?

dire marsh
#

magma isn't out for 1.18

tardy delta
#

Lmao my discord broken

dire marsh
#

forge with spigot plugins is a pretty bad setup in the first place though

spiral light
#

in the future there will be awesome world api changes (if md_5 will someday implement the Enum-Change)

dire marsh
tender shard
fierce glacier
#

just, what the entity.getHandle() does exactly ?

dire marsh
#

it's clearly better that we support 1.8 developers rather than improving the API

spiral light
#

almost nothing i can think of will break with the enum change

tender shard
spiral light
#

and with the world-api-changes there is nothing to break too (if i cant implement it in the way i can think off)

dire marsh
#

wdym by enum change

tender shard
dire marsh
#

I thought we were planning to get rid of enums

fierce glacier
#

NMS is ?

dire marsh
#

I don't have access to stash

tender shard
spiral light
fierce glacier
#

๐Ÿค”

dire marsh
#

nah

fierce glacier
#

okay thank

dire marsh
#

don't want to sign my life away to md_5

spiral light
dire marsh
#

yeah exactly

#

how is that not gonna break old plugins

#

cause those enums they're referencing won't exist anymore, right?

tender shard
spiral light
#

like mfnalex said... everything should work (maybe EnumSets not)

spiral light
dire marsh
#

hm

spiral light
#

also someday its time to say goodbye to ancient version support ๐Ÿ˜„

spiral light
#

abstract ^^

fierce glacier
#

I have found a solution for my problem ! ๐Ÿ˜„

young nest
spare canyon
#

is there a way to make all interactable blocks non-interactable? (like a chest you can't open, door you can't open/close, button you can't press, etc...)
im working in 1.8

#

and yes ik 1.8 is not the best version to work with but im doing it anyways

#

thanc in advanc

chrome beacon
#

Cancel the PlayerInteractEvent

spare canyon
#

oh ok

#

does the PlayerInteractEvent have a special property like if it's a block being interacted with?

spare canyon
#

thx

tardy flame
#

Don't even say that

#

1.16 will be never outdated

#

because I will always remember it

#

๐Ÿ––

frigid rock
#
public class Prison {

    private final TakaoMines plugin = TakaoMines.getInstance();
    private String name;
    private UUID uuid;
    Location prisonLocation;
    int x;
    int y;
    int z;

    public Prison(Player p) {
        this.name = p.getName();
        this.uuid = p.getUniqueId();

        if(!prisons.contains(name)){
            createPrison();
        }

        x = Files.prisons.getInt("Prisons." + name + ".x");
        y = Files.prisons.getInt("Prisons." + name + ".y");
        z = Files.prisons.getInt("Prisons." + name + ".z");


    }
    
    private void createPrison(){
        int x = prisons.size() + 3;
        int z = prisons.size() + 3;
        int y = 100;

        prisonLocation = new Location(Bukkit.getWorld("prisons"), x, y, z);
        Files.prisons.set("Prisons." + name + ".x", x);
        Files.prisons.set("Prisons." + name + ".y", y);
        Files.prisons.set("Prisons." + name + ".z", z);
        try {
            Files.prisons.save(prisonsFile);
        } catch (IOException e) {
            e.printStackTrace();
        }

        Bukkit.getWorld("prisons").getBlockAt(x, y-1, z).setType(Material.BEDROCK);

    }

    public Location getPrisonLocation(){
       return prisonLocation;

    }
}```Does anyone know why getPrisonLocation() returns null?
chrome beacon
#

Do you have a world named prisions

frigid rock
#

yeah

#

the createPrison() method works fine but then when i want to access the location from another class it returns null

chrome beacon
#

Are you sure that's the method returning null and not something else

frigid rock
#

yeah wait

#

uh

#

it was another thing bruh

#

lol thanks

onyx fjord
#

how to check if message is json?

chrome beacon
#

What message

smoky oak
#

doing new EffectDiagrammRunnable(effectRepeats,this).runTaskTimer(echo, effectTickDelay, effectRepeatTime); with values of 1, 0, 1 called on this class

import org.bukkit.scheduler.BukkitRunnable;

public class EffectDiagrammRunnable extends BukkitRunnable {
    int Repeats;
    EffectDiagramm ed;
    public EffectDiagrammRunnable(int Repeats, EffectDiagramm d){
        this.Repeats = Repeats;
        ed = d;
    }
    @Override
    public void run(){
        if(Repeats>0){
            Repeats--;
            ed.activate();}
        else this.cancel();
    }
}

causes me to time out & become unable to join the server. However, calling activate() on the parsed class works just fine and as intended. Does anyone know why? (Logs only say 'Running 5000 ms behind; Moterius timed out)

onyx fjord
chrome beacon
#

Or do you want to check for ChatComponents

smoky oak
#

oops

#

nevermind

#

its an infinite loop creating infinite bukkitRunnables

#

ffs my machine is posessed

#

thats supposed to be 0 1 0 bruh

onyx fjord
#

is there a way to make it a normal json message?

chrome beacon
#

How are you sending it

tardy delta
#

dont you need a textcomponent to send json messages?

chrome beacon
#

Yeah you should use that

tardy delta
#

also where is that message coming from?

sterile token
#

Hi how are you?

tardy delta
#

๐Ÿค”

#

fine

sterile token
#

I have been thinking allright about my claim system

#

And i finally decided to keep a list or set inside my player profile. What do you think?

tardy delta
#

thats what i do

sterile token
#

@sterile token

tardy delta
#

saving everything in the user class

sterile token
#

Yes I do the same

onyx fjord
tardy delta
#

lol tell me

onyx fjord
#

i store all messages except one and resend them

chrome beacon
#

If you want to send json messages use the ChatComponent API

onyx fjord
#

mhm

tardy delta
#

its a TextComponent[].toString()

#

how are you storing them btw

sterile token
#

Fourteej what I can do so?

#

Because im having some troubles

onyx fjord
tardy delta
#

as string format? as textcomponents?

onyx fjord
#

hold on

#

slowly

tardy delta
onyx fjord
#

how to store message from PlayerChatEvent to a chatcomponent

tardy delta
#

there is a #getMessage method which returns a string

#

what are you actually trying?

sterile token
# tardy delta take a drink

Because im keeping a claim object, which contains name, location. And them I thinking and thinking how to get each player claim on MoveEvent

tardy delta
#

wdym gets each player? are you trying to find the claim where the player is in when he starts moving?

warm light
#

will it be any problem if I use 1.18.2 API and add 1.13 in plugin.yml?

sterile token
#

What do you think?

#

@sterile token

#

@sterile token

tardy delta
#

why are you tagging yourself?

sterile token
#

Lol

#

I thoug I Where tagging u

#

Do you know what I ando

tardy delta
#

so a claim has a Collection<Location>?

sterile token
#

Its a Collection<Claim>

#

Where claim contains, owner name, location, radious and flags

tardy delta
#

a claim has a collection<claim>?

sterile token
#

Yeah

tardy delta
#

what

sterile token
#

I didnt understand

#

I just keeping in my user profile a Collectiom<Claim>

#

So first I get player profile based on event and them im looping through Claim colection

tardy delta
#

i would make claims a square form

#

and store a collection of claims in the profile

sterile token
#

I cannot because its based on a center block

#

Wait I will send code and you let me know

#

Because prob im no expรฑainimg

grim ice
#

Anyone has a library idea

#

I'm thinking of making a software like

#

Plugin Finder

#

scans through spigot to find plugins with your keywords and lists them in a order by stars (rating)

sterile token
#

I dont think you would like it

#

Hahaha

grim ice
#

and u can choose how to sort

#

By downlods / by rating / by author fame

sterile token
#

Isnt called spiget?

grim ice
#

cant search keywords for the description

tardy delta
#

verano send code

#

for the claim thing

sterile token
#

Yeah im doing that fourten

#
public class Cuboid {

    private final Location a;
    private final Location b;

    public Cuboid(Location location, Integer radius) {
        this.a = new Location(location.getWorld(), location.getX() - radius, location.getY() - radius, location.getZ() - radius);
        this.b = new Location(location.getWorld(), location.getX() + radius, location.getY() + radius, location.getZ() + radius);
    }
    
    public boolean contains(Location location) {
        
    }

    public Location getLocationA() { return this.a; }

    public Location getLocationB() { return this.b; }
}
#

@tardy delta there you have. And thanks for helping

tardy delta
#

Integer -> int?

sterile token
tardy delta
#

lol i didnt do anything

sterile token
tardy delta
#

why not creating claims based on a chunk?

#

or are the radiuses different every time?

sterile token
#

The radious can change depending of protection type

#

And chunk could be lagging

#

For having lot of protections with x amounts of radius

tardy delta
#

i guess a and b are the corner locations?

sterile token
tardy delta
#

and the location you pass in the constructor is the center

sterile token
#

I have just created this method, what do you think?

public boolean contains(Location location) { return location.toVector().equals(this.a.toVector()) && location.toVector().equals(this.b.toVector()); }```
#

Wait i dont think it will work

tardy delta
#

i've never worked with vectors

#

in what class is that method defined?

sterile token
tardy delta
#

i would check if the x of that location is between the minimum and maximum x

#

same for z

#

i dunno if thats efficient, vectors might be more efficient

#

๐Ÿคท

sterile token
#

Allright i wil continues searching on github

sterile token
tardy delta
#

ah

sterile token
#

And this class is though to be used from 1.8x to lastest spigot

#

That why im not using a public api

tardy delta
#

1.8 brr

sterile token
#

I know

#

I dont use 1.8

#

Fourten could you test it?

#

Im coding to test it in another plugin

tardy delta
#

uhm ye

#

does 1.17.1 work?

sterile token
#

Yeah no matter it should be working on every version

#

The cuboid i have seen it should work on every version

tardy delta
#

my plugin at its best

#

ah shit i need your plugin

#

before i start it

sterile token
#

What?

tardy delta
#

you asked me to test?

sterile token
#

Yeah

#

Im still coding to test it again

tardy delta
#

or do i need to put it in my plugin is that what you said?

sterile token
#

Yeah just put the cuboid class on one of your

#

And if you can check if the cuboid works in that version

tardy delta
#

where is it?

#

ah alr i forgot this server

#

i was testing a cannon here

sterile token
#

Oh nice

tardy delta
#

it shoots vertically ;-;

sterile token
tardy delta
#

yes

#

shoots a few hundred tnt at once

#

if i make it shoots horizontally ,-,

#

DESTRUCTION

sterile token
#

Fourten

#

Let me know when you test the cuboid if it works on that version

#

I will test it on 1.7x and 1.8x

#

And them i will go up