#help-development

1 messages · Page 2028 of 1

pliant oyster
#

When I do ChatColor.BOLD + ChatColor.ANYCOLOR, it gives me an error saying that + cant be applied to chatcolor

tall dragon
#

you will have to translate the string using ChatColor.translateAlternativeColorCodes()

#

iirc

tardy delta
eternal night
#

or just .toString() one

tardy delta
#

also possible

pliant oyster
glossy venture
#

can the console output rgb?

tardy delta
#

ye or to string

pliant oyster
#

oh ok

glossy venture
#

this should fade from aqua to green but idk if im doing something wrong

#

or that the console just doesnt support rgb

#

but im pretty sure it does because i tested it

#

once

rapid vigil
#

Hey, I have a question real quick, what is the difference between:

        new BukkitRunnable() {
            @Override
            public void run() {
                //Code here
            }
        }.runTaskTimer(this, 0L, 20L);```
and:
```java
        Bukkit.getScheduler().runTaskTimer(this, () -> {
            //Code here
        }, 0L, 20L);```
glossy venture
rapid vigil
glossy venture
#

i dont think so

#

correct me if im wrong

rapid vigil
#

Oh ok thanks for your answer

tardy delta
#

you can do BukkitRunnable r = new BukkitRunnable() { bla bla}

#

if you need it somewhere or smth

#

but the non deprecated scheduler method return a bukkittask too iirc

rapid vigil
#

You mean if I need to access it to cancel it or something somewhere else?

tardy delta
#

ye

rapid vigil
#

Ah thanks

tall dragon
eternal needle
tardy delta
#

ChatColor.translateAlternateColors translates string like "&cNO" to a red colored string "NO"

glossy venture
#

ok rgb does work

#

brown is there no way guys

tardy delta
#

fancy

glossy venture
#

i just need to fix my gradient function

tall dragon
tall dragon
glossy venture
#

does this look good or trippy

#

the C should get a gradient

#

but im tired so ill fix that tomorrow

ivory sleet
undone axleBOT
grim ice
#

i need lib ideas

ivory sleet
#

Make a pub sub lib

grim ice
#

what

ivory sleet
#

With implementations like redis, rabbitmq, mysql or just server sockets

#

Or even plugin message channels

ivory sleet
#

There is tho

grim ice
#

its a functional interface that has only one abstract method

#

so u can use a lambda instead

#

wait whatg

kindred valley
#

How can I assign a variable that I have given an object as a parameter as scanner.next in the scanner?

ivory sleet
#

Isn’t String x = scanner.next()

#

Altho you need to check for Scanner::hasNext

kindred valley
ivory sleet
#

Mind sharing the code?

kindred valley
#
public void Racing(Car car1, Car car2) {
        System.out.print("First Car: ");
        !!!! //car1 = scanner.nextLine();
        System.out.println("Second Car: ");
        !!!! //car2 = scanner.nextLine();
    }```
ivory sleet
#

String car1 = scanner.nextLine();

kindred valley
ivory sleet
#

Remove that

native nexus
#

In other words you can’t cast a car to a string. Your IDE should pick that up and tell you, then you can read the advice.

ivory sleet
#

The parameters don’t do anything do they?

#

And yeah maybe show your class Car also

undone axleBOT
vivid cave
#

how to make an event listener without using any annotations (@EventHandler) or any kind

#

I need to do that because my interactive debugger doesn't support annotations

vivid cave
#

but

#

listener argument

#

must be an EventListener class

#

which, I assume, will only listen to annotated events no?

grim ice
#

dunno

ivory sleet
#

just use new Listener() {}

glossy venture
#

what are the formulas for a linear gradient from the top left to the bottom right?

#

the x and y are floats from 0 to 1, start to end respectively

lethal iron
#

How to make a mob move to a location in 1.17.1 using NMS

kindred valley
ivory sleet
#

your formal function arguments

#

in that very function you gave us, you dont use those

#

so they can be removed in principle

kindred valley
kindred valley
#

im not using types on that function but i will use it in main method.

#

Ah i did

#

just made String types and equal it to Car type by valueOf

ivory sleet
#

I still dont get your issue here,

Scanner::nextLine returns a String, and since you seem to unable to drop the formal function arguments, you'd either have to use different names for the variables, or mutate the formal function argument and assign them to new Car instances, or just get rid of the formal function arguments.

glossy venture
#

how would i interpolate like this

#

i already have an interpolation function to get the color inbetween two others based on a given point (float)

ivory sleet
#

could look at sth like minimessage

glossy venture
#

but i need to figure out the points in each cell

glossy venture
#

link?

ivory sleet
#

In adventure GitHub repo iirc

glossy venture
#

i dont see anything related to this

#

do they have methods for it?

pliant oyster
#

What is the event when you right click on an item?

ivory sleet
#

@glossy venture

ivory sleet
lethal iron
pliant oyster
#

Oh thanks

glossy venture
#

i already did that

#

im trying to do it on a grid

ivory sleet
#

Oh

glossy venture
#

lets goo i got it

#

that has taken me over 2 hours

lavish hemlock
#

daaamn that's pretty

glossy venture
ivory sleet
#

Yeah that looks scrumptious

smoky adder
#

event.getDrops().removeIf(items -> items.containsEnchantment(Enchantment.DAMAGE_ALL)); I wrote this code that makes sure that all objects that have sharpness are not dropped, how can I make all objects with sharpness 4 not be dropped?

opal sluice
smoky adder
#

How can I do? I don't know how to do much

tall dragon
#

returns 0 if enchantment not found

smoky adder
tall dragon
#

i just told you what to use?

opal sluice
#

We're not going to spoonfeed something that simple ^^'

smoky adder
#

Yes, but I don't know how to use it, have recently been using java 😦 ahahah

tall dragon
#

well, almost exactly the same as what you have rn

#

except you need to use the method i send

lime jolt
#

anyone know how to enable and disable a specific players ability to PVP

chrome beacon
#

Save player UUID to a Set and then when someone gets hit check if the player is in the set and cancel if so

lime jolt
#

or nvm I think I get what u saying

spring minnow
#

java.lang.NullPointerException: Cannot invoke "net.minecraft.nbt.NBTBase.a()" because "var1" is null

#

any solution?

#

:>

spring minnow
spring minnow
lime jolt
#

aright

tall dragon
spring minnow
#

in that, check if listener.getDamager().getUUID() is contained in your Set

lime jolt
#

yeyeye

#

I am not using UUID though (I am using an arraylist to store all players)

spring minnow
lime jolt
#

really?

#

wia

#

wait

#

what is a UUID

spring minnow
#

kinda

lime jolt
#

then

spring minnow
#

like i mean

#

a unique code

lime jolt
#

oh I see, I see

spring minnow
#

that every entity has

lime jolt
#

i get it

#

thx though

spring minnow
#

no prob

lime jolt
#

Join.players is the arraylist

spring minnow
#

wdym

lime jolt
#

like players is the array list

spring minnow
#

Join.players is the arraylist of what players?

#

players that must attack?

lime jolt
#

and it is found in class Join

lime jolt
spring minnow
#

ok

#

makes sense

#

but is bad coded

lime jolt
#

cool, thanks

#

oh

spring minnow
#

can be enchanced

lime jolt
#

how, should I change it

spring minnow
#

first, use for(Player player : Join.players)

#

and ofc use player instead of Join.players.get(i) then

lime jolt
#

why for each loop instead

spring minnow
#

because you can use less code

#

its all about making code easier to understand and make it less big possible

lime jolt
#

i see

spring minnow
#

your code works, but can also work with less lines

#

after doing that

lime jolt
#

i seee

#

i seeee

#

thx

spring minnow
#

there is also another thing

lime jolt
#

?

spring minnow
#

actually

lime jolt
#

:0

spring minnow
#

you could totally erase the for

#

using .contains

lime jolt
#

i see

spring minnow
#

and you could also remove the boolean

lime jolt
#

I thought .cotains only worked for arrays not ArrayLists

#

but ok, I try

opal sluice
#

just do event.setCancelled(!Join.players.contains(e.getDamager()))

spring minnow
#

its the opposite

spring minnow
#

i wanted to explain him step by step xDD

#

that's why i just didn't give him the code

#

btw

lime jolt
#

your code

#

you mean our code

spring minnow
#

ZeTioZ

opal sluice
#

I mean, sure, but here there is a lack of java knowledge ^^'

lime jolt
#

dang u cant posts gifs

spring minnow
#

btw, petarpotato i see you're still learning, keep going

lime jolt
#

🙂

opal sluice
spring minnow
#

ye

#

just a second

opal sluice
#

And, you should use mojang mapping instead of original one

#

way easier when dealing with nms

spring minnow
#

its actually just a ItemStack.serialize of an already created itemstack

#

not much to copy xD

opal sluice
#

Oh

spring minnow
#

this.helmet.get().serialize()

#

xD

#

helmet.get() returns an Itemstack

opal sluice
#

I would look at the get() that could be null here

spring minnow
#

it is not

opal sluice
#

or maybe the ItemStack serialization got broky

spring minnow
#

actually, the error goes further

#

so its not

spring minnow
#

i though that too, cuz the error comes directly from nbt called from bukkit serialization

#

what can i do?

opal sluice
#

what you can do is actually saving the object

#

encoded in b64

spring minnow
#

would help?

opal sluice
#

so you keep all the properties of the items

#

since you just encode raw bytes

spring minnow
#

i'll try

opal sluice
#

and then you decode when needed

spring minnow
#

Thanks!

opal sluice
#

yw

spring minnow
#

what does that mean? XD i'm italian

opal sluice
#

your welcome ^^

spring minnow
#

Oh

#

Thanks ^^

opal sluice
#

ofc, you need to encode it by bytes, so don't just encode the object itself

spring minnow
#

yeah, but the only issue now would be, converting savings now... xD

#

since now all the save files of my users are saved with itemstack.serialize and decoded with itemStack.deserialize, will be difficult

#

to convert everything

#

that's why i hoped there was an easier way

opal sluice
#

you can chug the serialized data

#

and convert to b64

#

it will give you the same result

spring minnow
#

chug?

#

wdym

opal sluice
#

like get them all from the file

spring minnow
#

ok i see where you want to go

opal sluice
#

since the serialization is what you convert anyway in b64

spring minnow
#

that's surely helps, thanks again

opal sluice
#

no problems ^^

spring minnow
#

will require a bit of work but, i'll do it

#

i hope

opal sluice
#

well, it's better to save encoded items in database, takes less space and it's consistent ^^

spring minnow
#

wdym with database?

#

btw is this what you meant:

#

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream bukkitObjectOutputStream = new BukkitObjectOutputStream(byteArrayOutputStream);
bukkitObjectOutputStream.writeObject(paramItemStack);
bukkitObjectOutputStream.close();

#

something like that

#

and then convert to b64 these bytes?

opal sluice
#

yeah

simple anvil
#
if (!(sender instanceof Player)){
            sender.sendMessage("Only players can run this command");
        }else if (!(sender.isOp())){
             sender.sendMessage("You don't have the permissions to run this command");
        }else{
            sender.sendMessage("you are a player and you are op");
            
        }

this looks messy is there a way to make this look better?

opal sluice
#

looks like something like that

spring minnow
#

ok, thanks again for the help

opal sluice
simple anvil
#

how

#

its a command

opal sluice
#

(and ofc you add returns to avoid going off the branchs)

lime jolt
#

does anyone know if there is a way to select a large area and make it air

lime jolt
#

yes

#

or do i have to do it block per block

#

with like a loop or something

opal sluice
#

Take two points, loop through the x and y change the blocks through your loops

spring minnow
#

no wait wrong message xDDD

lime jolt
opal sluice
lime jolt
#

like can I just get all blocks inbetween two coords to become air

spring minnow
#

if (!(sender instanceof Player)) {
sender.sendMessage("Only players can run this command");
return;
}
if (!(sender.isOp())){
sender.sendMessage("You don't have the permissions to run this command");
}else{
sender.sendMessage("you are a player and you are op");
}

opal sluice
#

That's exactly what I said

spring minnow
#

only thing i see can be done

lime jolt
spring minnow
simple anvil
#
if (!(sender instanceof Player)){
            sender.sendMessage("Only players can run this command");
            return true;
        }else if (!(sender.isOp())){
             sender.sendMessage("You don't have the permissions to run this command");
            return true;
        }else{
            sender.sendMessage("you are a player and you are op");

        }
#

this is what i have dis good?

spring minnow
#

you coudl remove the else now

#

since there are returns

#

if (!(sender instanceof Player)){
sender.sendMessage("Only players can run this command");
return true;
}
if (!(sender.isOp())){
sender.sendMessage("You don't have the permissions to run this command");
}else{
sender.sendMessage("you are a player and you are op");
}

simple anvil
spring minnow
#

that's pretty much all you can do

#

there is no need, return does that

simple anvil
#

ohh ok

spring minnow
#

return stops the function

simple anvil
#

what the dif between your code and mine?

opal sluice
spring minnow
#

pretty much no difference

simple anvil
#

ok

spring minnow
#

it works both, just different ways

#

as ZeTioZ said, you can't do much

simple anvil
#

also
```java

code here

```

#

ok

spring minnow
#

thanks

#

i don't use discord much

simple anvil
#

do i need return or return true whats the diff

spring minnow
#

depends

lime jolt
#

anyone know how to make a specific block turn into air

ivory sleet
#

It compiles down to a raw nested if else

spring minnow
#

if you have a void there is return, if you have boolean there is return false and true

ivory sleet
#

So pretty much no difference apart from readability

simple anvil
#

ok

spring minnow
simple anvil
#

danke

lime jolt
spring minnow
#

wdym?

simple anvil
#

does anyone know what i cant generate a getter and setter method? im using intelliJ and i used to be able tot do it

spring minnow
#

i'm italian so i don't understand much

lime jolt
spring minnow
spring minnow
#

then Location loc = new Location(world, x, y, z)

#

loc.getBlock().setType(Material.AIR)

pliant oyster
#

How can I check if a player right clicked on a certain item using PlayerInteractEvent?

spring minnow
#

how

simple anvil
#

its not there

#

its gone

spring minnow
#

do you have actually variables in it?

#

xD

#

cuz i have getters

simple anvil
#

have a nice day bye

pliant oyster
spring minnow
#

you mean With a certain item or on a certain block?

pliant oyster
#

I have created the itemstack already

#

I mean if they right clicked a certain item

#

basically interacted with the item

spring minnow
#

so like if they click on a diamond block

pliant oyster
#

not the block

#

the item

spring minnow
#

oh interacted with the item like they use flint and steel

pliant oyster
#

no lol

spring minnow
#

then what

#

like they use a flint and steel, that is an interaction

#

with the item

opal sluice
pliant oyster
#

I need to check if they right clicked the item

spring minnow
#

yeah

#

then

#

you can

opal sluice
#

Player#getInventory()$getItemInMainHand()

spring minnow
#

check interactEvent.getAction() == Action.RIGHT_CLICK_AIR

spring minnow
opal sluice
#

When the action is right click air or right click block

pliant oyster
#

it can be either

#

can I make it either?

opal sluice
#

Yeah, that's what the "or" do

pliant oyster
#

alr

pliant oyster
opal sluice
#

interactEvent.getAction() == Action.RIGHT_CLICK_AIR || interactEvent.getAction() == Action.RIGHT_CLICK_BLOCK

pliant oyster
#

oh wait

#

if(e.getAction() == Action.RIGHT_CLICK_AIR) or (e.getAction() == Action.RIGHT_CLICK_BLOCK)

opal sluice
#

xD

pliant oyster
#

like this?

#

I see

#

I never used or statement lol

opal sluice
#

or = || in java

pliant oyster
#

I see

#

or will make more sense to me so i'll just use that

opal sluice
#

Well you can't x)

pliant oyster
#

oh

#

im stupid

#

yeah

opal sluice
#

you need to use ||

pliant oyster
#

theres an error

#

alr

#

tysm

simple anvil
#
Inventory tpGUI = Bukkit.createInventory(, 9, "Teleport GUI");
#

what do i set the holder as?

drowsy helm
#

can be null, can be the player

#

pretty negligible in most cirumstances

simple anvil
#

i was trying to make a teloport gui, if i set it to null would i stilll be able to do a click event?>

drowsy helm
#

yeah you would

simple anvil
#

ok

#

danke

lime jolt
#

anyone know whats wrong with this code

#

        boolean playerCanPlaceBlock = false;

        for(int i = 0; i < Join.players.size(); i++){

            if(Join.players.get(i) == event.getPlayer()){

                playerCanPlaceBlock = true;

            }

        }

        if(playerCanPlaceBlock == false || Join.isGameRunning == false){
            event.setCancelled(true);
        }


    }```
#

trying to dissable a players ability to place a block

drowsy helm
#

use UUIDs instead of referencing the player

#

you can also just use .contains

#

and idk the context but this is probs static abuse

lime jolt
#

static abuse?

#

what dat

drowsy helm
#

is there any reason for Join.players to be static

lime jolt
#

yes

#

players is a static arraylist of Player in Join class

drowsy helm
#

ok if it works for you ig

#

but dont use Player use UUID

lime jolt
#

idk how

drowsy helm
#

ArrayList<UUID>

lime jolt
#

but am I using the right event, or at least cancling the right one

#

BlockPlaceEvent

drowsy helm
#

yeah should be

lime jolt
#

dang

drowsy helm
#

is it registered

#

and have you verified that its being called at all

lime jolt
#

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

drowsy helm
#

is that listener in the main class?

lime jolt
#

yes

drowsy helm
#

should be fine then

#

is it executing at all when you place a block?

lime jolt
#

very strange

lime jolt
#

I will try

drowsy helm
#

yeah quickly print something out

#

dont forget @EventHandler aswell

lime jolt
lime jolt
simple anvil
#

how can i see what then name of a opened inventory is with InventoryOpenEvent?

drowsy helm
simple anvil
#

class?

drowsy helm
#

are you checking name to handling clicking?

#

if so theres way better ways of doing that

simple anvil
#

i want to get the name of a chest and if the chest name is give then i want it to fill up with netherite

opal sluice
#

Player#getInventoryView()$getTitle()

lime jolt
#

it no work

drowsy helm
#

can you show your entire class

opal sluice
lime jolt
#

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

#

?

lime jolt
opal sluice
#

yes

#

but that's "registerEvents(new YourListener(), this)"

drowsy helm
#

the listener is in his main class

#

hes done it correctly

lime jolt
#

where can I paste code

drowsy helm
#

?paste

undone axleBOT
lime jolt
#

to long here

opal sluice
lime jolt
drowsy helm
#

paste it, press save then send the link

lime jolt
drowsy helm
#

theres no @EventHandler

#

you need it on every event function

lime jolt
#

26

#

EVEry?

drowsy helm
#

yeah all of them

#

not just 1

lime jolt
#

._.

#

this is new information

#

I will try that

drowsy helm
#

lol

#

yeah the annotation targets a single function

opal sluice
#

actually, what's "Join"

#

since there is nothing imported with that class name?

drowsy helm
#

probably in the same package

lime jolt
#

its a diffrent class

drowsy helm
#

doesnt need to be imported

lime jolt
#

and I am just using it to acess the arraylist found in the class

opal sluice
#

Oh, weird structure x)

lime jolt
#

(I just learning)

#

playing around with things

drowsy helm
#

they're new let him be

lime jolt
#

🙂

lime jolt
#

I never knew it actually did anything to code

#

I thought it was like a comment

#

but

drowsy helm
#

nah it can actually have functionality

lime jolt
#

dang

#

aright

drowsy helm
#

its more so for when the event manager scrapes through your code it sees "oh this function handles events, im gonna register it"

lime jolt
#

aright, cool

drowsy helm
#

But yeah i'd really recommend looking into changing the players arraylist to a uuid arraylist

#

having a collection of players can cause mem leaks

lime jolt
#

but what is UUID

#

how would I getPlayer for example with UUID

drowsy helm
#

uuid is just their unique identifier

simple anvil
#

how do i get a list of all online players and there names?

drowsy helm
#

getPlayer().getUniqueId()

drowsy helm
#

then iterate through that and get their name

lime jolt
#

like if we had ArrayList<UUID> something = new ArrayList<UUID>(); would I do something.get(0).getPlayer(); if there was a player in the 0 index

drowsy helm
#

oh you want to get a palyer from uuid?

lime jolt
#

ye

#

or is UUID something else

drowsy helm
#

Bukkit.getPlayer(UUID)

lime jolt
#

can u show me an example of using UUID

#

I think i am confusing myself

drowsy helm
#

sure

#

give me a sec

lime jolt
#

ok

drowsy helm
#
List<UUID> playerUUIDs = new ArrayList<>();
//Adding a player to the list
playerUUIDs.add(player.getUniqueID());

//getting a player from the list
Player myPlayer = Bukkit.getPlayer(playerUUIDs.get(0));

//Check if a player is in the list
boolean isInList = playerUUIDs.contains(player.getUniqueID());
#

you're basically doing the same thing as you were before but using the UUID instead of the player object itself

lime jolt
#

oh i see,

#

thanks for the clarification

drowsy helm
#

all good

#

i know its more complicated but it will save you headaches in the longterm

frosty flame
#

Because of the cross-region Minecraft server, I want to cluster Minecraft server through bungee core, but it seems that bungee core is not based on redirection but proxy, I am not sure about this problem, with doubts, I read bungee core once Part of the code seems to be based on the fact that the proxy is so, all the traffic from the client needs to go through the bungee core to reach the server, just like the relationship between the reverse proxy on nginx and 301 / 302 / 303 redirection, like this The process will cause significant delays. Is there a way to make bungee core redirect the client directly to the server without going through bungee core? Or am I overlooking something...
My English is not very good, please forgive me if there are any grammar mistakes.

warm trout
#

Is there any way to convert a bukkit entity back into a custom entity? I know I can use getHandle(), but I can't convert it back into a custom entity with casting it

drowsy helm
#

bungee is purely a proxy i dont think theres any way to actually bypass that. the delay is negligible though and iirc you can have multiple proxies, so just have region based proxies

#

additionally having a proxy means you don't have to expose the port which makes life much easier

frosty flame
drowsy helm
#

as for minecraft solutions i havent heard of any but i would recommend looking into BGP (Border gateway protocol) i've heard that can help. If you have the development team for it you could also try and fork bungee and see what options you have but again multiple proxies is probably your easiest option

#

then you could set up a load balancer which sends them to the appropriate proxy based off of latency or something

#

but this is pretty hard to achieve

frosty flame
#

In fact, if the bungee core host suffers a network attack, all sub-server players will be offline. I imagine a redirection portal that accepts the client and forwards it to the verification server for verification and shares the verification result with other servers and then redirects to the game server. , is a redirect instead of a proxy. This makes it possible to deploy multiple servers across regions.

drowsy helm
#

When i used to own a multi server network i just used kubernetes to instance the servers, afaik ping wasn't really a big issue but then again we really only had players from the us, australia and parts of europe and asia

frosty flame
drowsy helm
#

no worries, its quite a complex topic but there are a few solutions

pliant oyster
#

I'm trying to call public void openCratesMenuGui(Player player, InventoryClickEvent e) in a different class but when I do Class openCratesMenuGui = new Class().openCratesMenuGui(player, ); I don't know what to put in the 2nd parameter

drowsy helm
#

what class is openCratesMenuGui in?

#

and why does it need an inventory click event

pliant oyster
#

I called the class CratesSystem

drowsy helm
#

is CratesSystem already instantiated?

pliant oyster
#

because it's an event

pliant oyster
drowsy helm
#

I think you're confusing yourself a bit

pliant oyster
#

I am

drowsy helm
#
CratesSystem cratesSystem = new CratesSystem();
cratesSystem.openCratesMenuGui(player);
#

you shouldn't need to take the event in

#

you're not doing and event handling

#

just remove that parameter all together

pliant oyster
#

openCratesMenuGui is event handling

drowsy helm
#

how so

#

the name doesn't indicate that it does

pliant oyster
#
    public void openCratesMenuGui(Player player, InventoryClickEvent e)```
#

and I use inventoryclickevent inside the openCratesMenuGui

drowsy helm
#

you should have 1 function for openCratesMenuGui and another function for cratesMenuClickEvent

#

logically speaking how you are doing it won't work

#

and cant work actually

pliant oyster
#

oh

drowsy helm
#

Can i see what you are doing in openCratesMenuGui

pliant oyster
#

so I have to make some variables global then I think

drowsy helm
#

show the whole function

pliant oyster
#

it's a huge one lmao

#

I think I know which ones to make global

drowsy helm
#

?paste

undone axleBOT
drowsy helm
#

i can read it lol

#

show your code, theres different ways of doing it depending on how you're executing it

#

this.cancel() should work

#

let me read up one min

#

oh try using BukkitRunnable

pliant oyster
#

@drowsy helm nvm I'ma need help

drowsy helm
#

okay so first off I'd start by splitting that into 5 different functions

#

for each inventory

pliant oyster
#

so like

#

each gui has it's own function?

drowsy helm
#

yeah split it up makes life much easier

#

and doesn't make your function so big

pliant oyster
#

should I make the inventory variables global?

frosty flame
drowsy helm
#

maybe they've started working on it again idk

drowsy helm
#

you could make them global but its not really good practice

nimble torrent
drowsy helm
#

yeah just use global variables then lol

pliant oyster
#

alr lol

drowsy helm
#

and pls dont use 1 letter variables

nimble torrent
nimble torrent
pliant oyster
drowsy helm
#

addUnsafeEnchantment is already part of ItemSTack

#

you dont have to cast it

pliant oyster
#

bcuz the variables are outside of the void

drowsy helm
#

no, if its declared outside of a variable you can access it in side the function

pliant oyster
#

oh

nimble torrent
#

just

#

the reason

#

cuz it was working before

#

i just added more recipes

drowsy helm
#

idk i dont work with EnchantmentStorageMeta, but you don't need to do it in the first place anyway

nimble torrent
#

i tried with doing addenchantment and it said that it was in between 1 and 4

#

i got an error

drowsy helm
#

wdym

#

on itemStack

#

This method is unsafe and will ignore level restrictions or item type. Use at your own discretion.

#

did you do addEnchantment or addUnsafeEnchantment?

nimble torrent
#

at fuirst i did addEnchantment

#

but

#

i got error

#

so i did unsafe enchantemtn

drowsy helm
#

and that still didnt work?

nimble torrent
#

it worked but i just added more enchantments

#

and now it doesnt

drowsy helm
#

huh

#

that shouldnt be the case

nimble torrent
#

ok so i just had 1 recipe

nimble torrent
drowsy helm
#

what is something?

nimble torrent
#

even tjough i changed the variables

drowsy helm
nimble torrent
drowsy helm
nimble torrent
#

no

#

nop

#

so

#

i have

#

i had

#

addenchantments

#

and it didnt work

#

then i used

#

unsafeenchantments

#

it worked

#

and

#

i copied the recipe

#

changed it a little

#

and pasted it

#

and changed the variables

#

wait im stupid i forgot to change something

frosty flame
#

It seems that this will not be the final solution, because the traffic will still go through the entry bungeecord. From what I understand, when the bungee cord changes the subserver, the client's response is to change a dimension (world), so the bungee cord and the client The established connection is unbreakable, once cut means leaving the game... And my idea is to send a login packet to the client through bungee cord, so that the client mistakenly thinks that it is entering the server and according to the bungee cord data packet After entering the designated new server, the subsequent data will only be processed on the new server without going through the bungee cord. Is it possible to achieve such a requirement without the help of forge/fabric?

#

The context is the problem: if the implementation of bungee cord is similar to 301 / 302 jump in nginx, avoid the network delay caused by the physical distance between bungee cord and the actual game server, the reason for using bungee cord is because there are many ingress connections to implement game server

#

My English is not very good, I try to make the questions as clear as possible, which makes them seem a bit long...and excuse me.

#

😋

iron tundra
#

I am trying to figure out why when I use a sword with an enchant on it I get a null error even though it should just pass on through. If you can explain to me what I am missing I would appreciate it ```java
public void EntityDamage(EntityDamageByEntityEvent event) {
if (!(Objects.requireNonNull(((Player) event.getDamager()).getPlayer()).getInventory().getItemInMainHand().hasItemMeta())) return;
//rest of my code
}

iron tundra
#

I found the issue that I was checking with the wrong stuff

#

Thanks for trying to help though

worldly ingot
#

I'd say it's probably just to encourage you to use Bungee's scheduler instead

#

Yeah that's what I mean. Not meant for use outside of internal calls but it's a way to associate tasks with a plugin

#

So make use of Bungee's scheduler. Consider that deprecated method as internal

quaint mantle
#

how in all is godly do i make ui like this

worldly ingot
#

Realistically, it should be marked as @ApiStatus.Internal from Jetbrains' annotations

quaint mantle
#

i cant find ANYTHING online

#

on how to create stuff like that

hexed hatch
#

3D models as items placed inside interfaces

#

many of them use a special font to create the background, and the dynamic parts are done with the custom models

quaint mantle
#

also weird question: can i compile a server resouce pack

#

AKA decrypt it

hexed hatch
#

What

#

Yeah

drowsy helm
drowsy helm
#

havent updated the code but exactly the same concept

hexed hatch
#

I’m genuinely surprised this was a trade secret, I had been doing this before it even went mainstream at all. None of my projects went anywhere but the ground though lol

quaint mantle
hexed hatch
#

What file format is it again

drowsy helm
#

are you asking if you can download a server's resource pack?

quaint mantle
hexed hatch
#

If I remember correctly 7zip can extract those files

drowsy helm
#

idk but if you want Origin Realms' you can download it anywhere

#

there isa folder in your %appdata%

hexed hatch
#

It’s in .minecraft in the serverresourcepacks folder

drowsy helm
#

well that screenshot is from OR so i was assuming thats what you wanted

hasty prawn
#

It's just a zip file

#

Just add .zip at the end and open it normally lol

wet breach
#

resource packs are not designed to be hidden o.O

soft karma
#

Hello! Please tell me how to put a mob on the player's head using protocolLib.

quaint mantle
#

Can someone tell me what's wrong because whenever I load the server it console it says it enables my plugin(one is plugins.yml and the other is the main class)

quaint mantle
#

the server doesn't recognize what the commands are when I do them

quaint mantle
#

notice how the first command is indented but the others arent

#

the first command doesn't work either

#

ok well fix the issue i just pointed out

quaint mantle
#

theres this plugin i relally want,its meant for 1.13 when Im on 1.18 it loads into /plugins, but it doesnt work and console goes crazy when health updates (low health screen plugin) is there a way to make it work?

modest shard
#

anyone know how to change the experience gained from killing a mob

vocal cloud
quaint mantle
#

do you know other health plugins that mess with the player screen when getting hurt / or low? 1.18

vocal cloud
#

This isn't exactly the place to ask. This is for development help not a plugin search service

soft karma
#

Tell me the packet that allows the mob to land on the player (ProtocolLib)

maiden thicket
#

what

#

land on the player

#

????

visual tide
wooden fable
#

Will FileConfiguration#getStringList work for an array?

aliases: ["dc"]
coarse shadow
#

how can i prevent chest loots to generate tools with enchantments?

#

i checked loottables on doc but i couldnt find how to remove an item from it

visual tide
#

btw u dont need the quotes

wooden fable
#

I didn't know it worked with an array too, I always used it just for this:

output:
    - "&6Our &6&lDiscord&r&6 Server:"
    - "&6https://discord.gg/spigotmc"
#

Thank you!

visual tide
#

that

#

is an array

#

its the same thing just different ways of writing it

wooden fable
#

Ohhh

glossy venture
#

can i run code at normal onEnable time (post-world) from a plugin with

load: STARTUP
#

something like

// called on startup due to flag in plugin.yml
public void onEnable() { 
  // run code that is supposed to run here
  // ...

  // run code at normal onEnable time
  Bukkit.runPostWorld(() -> {
    // ...
  });
}
#

i know that Bukkkit.runPostWorld being a thing is very unrealistic

quaint mantle
#

try waiting a tick

glossy venture
#

that runs it when the server is done right

#

using the scheduler

quaint mantle
#

maaaaaybe 🧐

#

@glossy venture

glossy venture
#

ay thanks

#

illlook into it

#

i found this

#

i might be able to use that to run the code

#

just when a plugin has been enabled, i run it right after

quaint mantle
#

thats not reliable

glossy venture
#
    @EventHandler
    public void tryFullInit(PluginEnableEvent event) {
        if (event.getPlugin().getDescription().getLoad() == PluginLoadOrder.STARTUP) return;
        initialize();
    }
glossy venture
#

oh yeah

quaint mantle
glossy venture
#

if there are no other plugins

#

yeah

#

you know what ill just use the scheduler to make it run later

#

ez

mellow edge
#

is spigot the same as paper plugin?

#

for paper servers I always created spigot plugins, but what if I use paper instead, is code the same?

ancient jackal
#

Code isn’t the same, paper is a fork of spigot

#

It will mostly be the same except for the things paper changes

#

You can use a spigot plugin with paper but if you use paper to make a plugin only paper servers can use it

mellow edge
#

oh then batter then I just continue making spigot plugins

#

thanks 🙂

ancient jackal
#

Unless you use something from paper which is why I said it will mostly be the same

#

But not exactly the same

lilac dagger
#

how would you name something that splits an array of elements into pages of elements?

ancient jackal
#

Correct or not, you probably shouldn’t be using a fork of spigot to be making spigot plugins

hybrid spoke
#

paginate

#

PaginatedCollection

ancient jackal
#

Why else would you use paper instead of spigot?

lilac dagger
#

I was having Paginator

last tulip
#
    public void tpjoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        Location loc = new Location(Bukkit.getWorld("lobby"), 1, 64, 0, 0, 0);
        player.teleport(loc);
    }```
what's wrong with this?
hybrid spoke
hybrid spoke
last tulip
#

the event doesn't work

hybrid spoke
#

probably the teleport. do it on the next tick

vestal barn
lilac dagger
#

no one shall have more than pageSize elements >:) @hybrid spoke

last tulip
last tulip
hybrid spoke
#

yes

last tulip
#

aight lemme test

hybrid spoke
lilac dagger
#

the code?

hybrid spoke
#

a wrapper? a method sublisting?

#

?paste

undone axleBOT
hybrid spoke
#

^

lilac dagger
#

it's pretty clean i'd say

hybrid spoke
lilac dagger
#

the name seems pretty descriptive

hybrid spoke
#

oh and a int getPageOfElement(T element) would be cool

lilac dagger
#

it compiles the array into pages

hybrid spoke
#

and/or hasElement

lilac dagger
#

getPageSizeOfElement?

#

ohhh

hybrid spoke
#

and/or hasPageElement(int, T)

lilac dagger
#

nvm, i understand

#

i'll keep it simple for now

hybrid spoke
hybrid spoke
lilac dagger
#

it's internal most of it

#

the only thing left is from get page but it's annotated with nullable

hybrid spoke
#

even if its internal i would avoid null

lilac dagger
#

it's very difficult then to update the pagination with new elements

#

if i pre instance the pages

hybrid spoke
#

you don't do anything else than wrapping Arrays.copyOf(objects, objects.length, sample) in an optional

#

hm.. which would need a little rework since you cant just pass in an array

lilac dagger
#

i don't like that much that class

hybrid spoke
lilac dagger
#

i like the annotations more

#

they serve pretty much the same purpose afterall

hybrid spoke
#

except that it's a bad design. else you could also return a static empty array everytime

lilac dagger
#

but i don't like initializing objects for no good reason

hybrid spoke
#

thats a pretty good reason

lilac dagger
#

other than to be safe

hybrid spoke
#

and it won't do anything

#

you won't even notice it

lilac dagger
#

or rather to prevent others from doing mistakes

hybrid spoke
#

except if you get it returned

#

okay, well. lets see the scenarios


public void doSomeStuffWithMyPage(Pagination<Object> pagionation) {
  
  Object[] myPage = pagination.getPage(2);
  // is it there? is it not? we have to check! otherwise possible circumstances
  if(myPage == null) return; // can't do further actions here anymore
  
  for(....) {...}
}

// but with returning a once initialized static array (**global context**) you won't have thoes problems

public void doSomeStuffWithMyPage(Pagination<Object> pagionation) {
  
  Object[] myPage = pagination.getPage(2);
  
  for(....) {...} // it could be empty but who cares
}
lilac dagger
hybrid spoke
#

hence i said static array. a class variable

lilac dagger
#

it's a generic oriented class

#

i can't use static and know the class type

hybrid spoke
#

so get a static Object array?

lilac dagger
#

i can at worst have one at the constructor

#

a static object array will fail casting if that is what you mean

hybrid spoke
#

for what casting?

lilac dagger
#

if i need a T[] array

#

casting Object[] to T[] will fail casting

#

they are not of the same type

hybrid spoke
#

yes and that should work. but still dont know what the purpose of sample is

lilac dagger
#

is to know at runtime what type of array i need

#

you know java has type erasure

#

there's no other way to work with arrays and generic

#

all of this has to be blamed on backwards compatibility and the bad decision of making arrays covariants

tender shard
#

who ghost pinged >.<

tender shard
#

one second, I'll send my code to create generic arrays

lilac dagger
#

i've actually looked and i haven't found anything good

tender shard
#
package de.jeff_media.jefflib;

import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Array manipulation related methods
 */
@UtilityClass
public class ArrayUtils {

    /**
     * Returns a new array of the given class type with length 0
     * @param componentType Class of the array's component type
     * @param <T> Array's component type
     * @return Array of the given class type with length 0
     */
    public static <T> T[] createArray(@NotNull final Class<T> componentType) {
        return createArray(componentType, 0);
    }

    /**
     * Returns a new array of the given class type with the given length
     * @param componentType Class of the array's component type
     * @param <T> Array's component type
     * @param length Array's length
     * @return Array of the given class type with the given length
     */
    public static <T> T[] createArray(@NotNull final Class<T> componentType, final int length) {
        //noinspection unchecked
        return (T[]) Array.newInstance(componentType, length);
    }

@lilac dagger

hybrid spoke
lilac dagger
#

i was actually looking into this

#

but i don't wanna make a util to just skip the inspection warning

mellow edge
#

why can't I make 1.18.2 plugin with intellij's minecraft plguin:

lilac dagger
mellow edge
tender shard
#

or just manually change the value in your pom.xml or build.gradle to 1.18.2

mellow edge
#

I use maven

tender shard
#

then change 1.18.1 to 1.18.2 in your pom.xml

tender shard
ancient jackal
#

I'm so sorry... try reading what I sent after that again

quaint mantle
#

if i change <version> in pom.xml from 1.17.1 to 1.18.1 does it mean plugin will work on 1.18.1?

crimson terrace
#

usually if your plugin works on 1.17.1 it works on 1.18.1

quaint mantle
#

so i just need to change <version>?

mellow edge
quaint mantle
#

ye

crimson terrace
#

you shouldnt even need to change the version

quaint mantle
#

ok

crimson terrace
#

I think if you change the version it wont work on 1.17 anymore

hybrid spoke
#

it will

#

except if he uses 1.18+ stuff

crimson terrace
#

lower version is better imo since the plugin will work on more versions overall

lilac dagger
#

@tender shard this is the best i could think of

mellow edge
#

is that ok in plugin.yml: api-version: 1.18 in 1.18.2 plugin

hybrid spoke
#

but yeah

lilac dagger
tender shard
bitter crystal
tender shard
#

what do you think about my genius exception name?

try {
            final StateFlag allowFlag = new StateFlag("allow-angelchest", true);
            registry.register(allowFlag);
            FLAG_ALLOW_ANGELCHEST = allowFlag;
        } catch (final Exception weDontUseflagConflictExceptionBecauseItThrowsNoClassDefFoundErrorWhenWorldGuardIsNotInstalled) {
            final Flag<?> existing = registry.get("allow-angelchest");
            if (existing instanceof StateFlag) {
                FLAG_ALLOW_ANGELCHEST = (StateFlag) existing;
            } else {
                main.getLogger().warning("Could not register WorldGuard flag \"allow-angelchest\"");
            }
        }
rough drift
#

amazing

#

10/10

tender shard
#

thanks!

vernal pier
#

but stateFlag and all those other worldguard classes will throw before it anyway so

tender shard
#

my whole worldguard code is a bit weird lol

#

it's not an actual WorldGuard StateFlag but my custom one

vernal pier
#

oh

tender shard
#

I wish it would be easier to support WorldGuard without needing to wrap all the code in case worldguard is not installed

#

basically a WorldGuardAPI that does what it tells you to or just silently fails/does nothing when WG is not installed

mellow edge
#

is worldedit open-source, I wanna manually update it to 1.18.2

rough drift
#

why not just

#

use FAWE

mellow edge
#

what is that?

rough drift
#

fast async world edit

#

faster and up to date version of world edit

#

i believe it also has more features

mellow edge
#

I can use it if it's not virus

rough drift
#

its not?

#

its basically what everyone uses

mellow edge
#

thanks 🙂

#

it should work on paper?

rough drift
#

yes i believe

mellow edge
#

wow it actually works

#

FastAsyncWorldEdit officially supports the Spigot and *Paper (recommended)

tender shard
#

it works fine on 1.18.2

tender shard
mellow edge
#

bdw

#

I wanna get unbanned from enginehub discord

#

I was banned because I didn't talk in off-topic

tender shard
#

they ban you for that? lol

quiet ice
#

Doubt that

tender shard
#

I doubt that was the reason

mellow edge
#

I asked intellij vs eclipse

#

and he said so ban then?

tender shard
#

if it was really like that, they're jerks

mellow edge
#

you can actually see that

quiet ice
#

Well, that topic is banned in many discords

mellow edge
#

just search

#

but how can I came back in

quiet ice
#

Plus it is possible that they have a tyrannical mod

#

Spigot is extremely lax in moderation stuff

bitter crystal
quaint mantle
mellow edge
#

can u say if they can ban me they don't even have ban appeals lol

quiet ice
#

Lenient

mellow edge
#

no

quaint mantle
quiet ice
#

Which jar though?

quaint mantle
#

Any

tender shard
#

black magic yo

quiet ice
#

Yeah lol

#

Works 100% of the time

quaint mantle
tender shard
#

are you drunk or sth?

quiet ice
#

Probs

quaint mantle
#

Just do 69zip

#

That works better

tender shard
#

k

quiet ice
#

Or a troll

#

Probably latter

tender shard
#

maybe both

quiet ice
#

Perhaps

quaint mantle
#

Essentials

quiet ice
#

Nuke as in?

#

TNT nuke or Just removing all Blocks in a sphere?

quaint mantle
#

Just do //wand

#

And change the whole house to tnt

#

Or download a Nuke mod

#

Plugin

quiet ice
#

Worldedit probably works, yes

tardy delta
#

summon a few explosions

quaint mantle
#

Or /summon creeper ~ ~ ~ {ExplosionRadius:120}

quiet ice
#

AH

quaint mantle
#

Do it

#

It's a nuke

#

Literally

tardy delta
#

radius 120?

quaint mantle
#

Any higher is nothing

quiet ice
#

It will Not instantly explode though

quaint mantle
#

2.5 secs is fast enough for me

#

Just go onto the house

#

Not in

#

It's that strong

#

Summon a million

quiet ice
#

And an Obsidian House will Withstand this

quaint mantle
#

Use /ban Joe bidens mom

quiet ice
#

But you would need to Prime the Creeper manually

quaint mantle
quiet ice
#

Really?

quaint mantle
#

Just summon the damn creeper

#

And light it

quiet ice
#

Yes, that requires Manual labour

quaint mantle
#

Or have it go near the guy and it will prob die, so summon a million

#

I will prob break all his armor

#

Do /spawnmob tnt_minecart 1000

quiet ice
#

Isn't it summon?

quaint mantle
#

No

#

Essential commands

quiet ice
quiet ice
earnest forum
#

why use the essentials one

quaint mantle
#

Idk

glossy venture
#

does anyone have a more efficient algorithm for this?

quiet ice
#

If that's Code, send it as a Code block

glossy venture
#

ight

#
    static JsonValueSpec<?> getPrimitiveFor(Object o) {
        if (o == null) return JsonValueSpec.NULL_PRIMITIVE;
        if (o instanceof Number) return JsonValueSpec.NUMBER_PRIMITIVE;
        else if (o instanceof Boolean) return JsonValueSpec.BOOLEAN_PRIMITIVE;
        else if (o instanceof String) return JsonValueSpec.STRING_PRIMITIVE;
        else if (o instanceof Character) return JsonValueSpec.CHAR_PRIMITIVE;
        else if (o instanceof JsonArray) return JsonValueSpec.JSON_ARRAY_PRIMITIVE;
        else if (o instanceof JsonObject) return JsonValueSpec.JSON_OBJECT_PRIMITIVE;
        throw new IllegalArgumentException();
    }
#

but it wraps

#

soyeah

#

i thought that looks better

quiet ice
#

Bandwidth is more important

#

Anyways, that is as efficent as it gets without reordering the blocks

kindred valley
#

can we give abstract methods parameter

quiet ice
#

Yes

kindred valley
#

i cant

quiet ice
#

Why that?

kindred valley
# quiet ice Why that?

should i pass the parameter in the abstract class or inside the abstract class method which i redefine in the inheriting class?

quiet ice
#

The Parameter needs to be defined in the head of both Abstract and overriding method

kindred valley
quiet ice
#

What

#
public abstract void Meth(Clazz param);
@Override
public void Meth(Clazz param) {}
#

This is how you define it

quiet ice
#

To invoke it is Like a regular method

quiet ice
kindred valley
#

thanks

quaint mantle
#

hi, I need to do some action lasting 5 seconds, after the expiration, disable the task and remove the object from the list, how can this be implemented

quiet ice
#

?scheduler

#

Smh

tender shard
#

ugh someone got any idea why my HttpUrlConnection changes its URL once I call getResponseCode()? It seems to use rDNS to turn the given IP into a host name or something similar weird

#

?scheduling

undone axleBOT
tender shard
#

@quaint mantle

#

^

quiet ice
#

It could also be redirects

tender shard
#

hm yeah it probably is, it seems to use the wrong Host header

#

although I am explicitly changing it

quiet ice
tender shard
#

yeah it seems like it doesn't apply the custom host header i'm setting

#

because I wanna use the IP to avoid DNS lookups

#

then add the Host: header manually

#

it's working in my CLI project but not in Spigot >.<

#

I AM STO STUPID

#

I am using setRequestProperty instead of addRequestProperty

#

so I am overriding the host field when setting the user agent

prisma needle
#

Something with Unchecked Calls...

tender shard
#

hm weird, addRequestProperty also overwrites existing properties