#help-development

1 messages · Page 1650 of 1

fluid cypress
#

and then do some stuff with the mca files

young knoll
#

world has a method to get the folder

ivory sleet
#

Dependency injection good tho

tall dragon
#

you can use your plugins data folder to get its parent(s)

somber hull
#

@tawdry cedar

ivory sleet
#

Why hyperlink

tawdry cedar
#

Yeah you just need to set up the instance in the Main class though

somber hull
#

oh

tawdry cedar
#

Add this:

private static Main instance;

public Main() {
    instance = this;
}

public static Main getInstance() {
    return instance;
}
#

Change Main to your main class name

#

I’m on mobile so it’s harder or I would of done it

ivory sleet
#

Go with dependency injection tho

tawdry cedar
fluid cypress
hybrid spoke
#

singleton is so oldschool and wrong

#

and bukkit already provides this

#

no need to reinvent the wheel

ivory sleet
#

let alone the example above there isn't even a singleton

lavish hemlock
#

that
I don't think that code would really work unless you construct the class

#

which goes against one of the points of a singleton

ivory sleet
#

?

lavish hemlock
#

instance isn't set until new Main()

hybrid spoke
#

it is a singleton

lavish hemlock
#

but new Main() is public, meaning you can override instance multiple times

ivory sleet
#

its not set until onEnable is invoked

hybrid spoke
ivory sleet
#

oh right

hybrid spoke
#

means as soon as bukkit builds the plugin it gets instantiated

ivory sleet
fluid cypress
#

how can i know if a world is overworld, nether or end type?

ivory sleet
#

getEnvironment iirc

hybrid spoke
fluid cypress
#

what is a custom environment type?

opal juniper
#

for plugins essentially

ivory sleet
#

basically what the name says

hybrid spoke
#

Represents a custom dimension

fluid cypress
#

in overworld maps the region files are inside world_name/region/, for nether they are inside world_name/DIM-1/region/, and for end world_name/DIM1/region, so what about that custom type?

hybrid spoke
#

Represents a custom dimension

reef wind
#

would it be smarter to have a key lets say "Economy" and then a hash map with all players and their balance or have it under the players other data? (in a database)

ivory sleet
#

wait wym now

reef wind
#

uhh

hybrid spoke
#

if you dont just want to have it local you would have to use a database-alike

#

to cache it a hashmap seems fine

#

but i would go with OOP

reef wind
#

I have a database, should I store all players balance under 1 key or under the players basic data. I ahve no idea how to explain this

#

wait

unreal quartz
#

what type of database first

hybrid spoke
#

now you are confusing me

ivory sleet
#

like a total server balance amount desk?

somber hull
#

ok, i have never worked with enums before

unreal quartz
#

time to get learning then!

somber hull
#

Arent they just like 1 2 3 but with names instead of numbers?

hybrid spoke
#
key:
  player1: 1
  player2: 2
# or
player1:
  amount: 1
player2:
  amount: 2
#

?

reef wind
#

example:

Economy

someuuid : 522
someuuid : 3533
someuuid : 3263

or

playeruuid

balance: 235
other data..

playeruuid

balance: 633
other data..
hybrid spoke
#

that depends on how much data you have to save

unreal quartz
#

the latter makes the most sense for an object oriented language

reef wind
#

barely any

hybrid spoke
#

the second way is the one i would recommend

ivory sleet
#

the latter is extendable

karmic grove
#

whats this error mean bro

reef wind
#

but are both good ways too go? or is the first one just dumb?

reef wind
#

..

karmic grove
#

thats only error tho

hybrid spoke
#

if your purpose is to just store the balance the first way would be fine aswell

reef wind
#

look more

#

it says why

hybrid spoke
#

but i would always go the second one

#

since you can extend it

ivory sleet
#

I mean there's no real benefits choosing the former over the latter apart from less verbosity

karmic grove
reef wind
#

alright thanks

young knoll
#

1.16

reef wind
young knoll
#

Not 1.16.5

karmic grove
#

so no .5

hybrid spoke
karmic grove
#

oh

#

sheesh

reef wind
#

why can't ppl read stack trace

karmic grove
#

cuz i has the stupid

hybrid spoke
#

you has the stupid

karmic grove
#

yes

reef wind
#

your pfp

somber hull
#

Can someone explain why this would be useful, i know nothing of enums..

karmic grove
#

pinaaple

reef wind
#

oh

hybrid spoke
#

ew

#

go away

karmic grove
#

it gud tho

reef wind
hybrid spoke
#

yes

reef wind
#

cap

ivory sleet
hybrid spoke
#

just like mushrooms or tuna

#

just ew

reef wind
#

def would not pick over salami/kebab but it's not "ew".

somber hull
#

He suggested i use an enum

opal juniper
#

pineapple on pizza is great

somber hull
#

and idk what he meant

hybrid spoke
ivory sleet
#

hmm yeah well using an enum or not is probably an insignificant choice

reef wind
#

I am proud of sweden and kebab pizza

ivory sleet
#

in this case

somber hull
#

Well i was asking if i should just have a method to return the item for every item i create, all in the same class/file

#

Or if i should have every item be created in a method inside its own file/class

minor wedge
#

how can I place blocks without any server lag?

ivory sleet
#

I think one class is fine

somber hull
#

Bet

ivory sleet
#

but it depends on the design here

somber hull
somber hull
reef wind
minor wedge
#

without lag

hybrid spoke
somber hull
#

or setType

somber hull
#

or whatever it is

minor wedge
reef wind
#

bru

somber hull
hybrid spoke
#

how they do it

minor wedge
#

ok

ivory sleet
#

someone link 7smile7s post thx

minor wedge
#

not sure where to look lmao

somber hull
hybrid spoke
#

FAWE

reef wind
undone axleBOT
minor wedge
tawdry cedar
minor wedge
#

i mean in FAWE source

hybrid spoke
reef wind
minor wedge
#

i know how to internet sometimes

somber hull
minor wedge
#

ty

ivory sleet
#

You'd have to spend an hour at least if you want to read through fawes abstractions and what not

somber hull
#

or did you mean to make it a constructor

proud basin
#

he mean’t it in onEnable

somber hull
#

thanks

ivory sleet
#

he meant dependency injection 😄

somber hull
#

hold up

#

nvm im using static methods

#

i cant do this can i?

ivory sleet
#

then ur main plugin class violates the single responsibility principle if every other class of yours has to depend on your main plugin class

hybrid spoke
#

mhhhhhhhhhhhhhhh

somber hull
hybrid spoke
#

bukkit actually already griefs the SRP by itself

ivory sleet
#

anyways hyper, its not anything near enterprise of what you're doing so that getInstance() will do fine

somber hull
ivory sleet
#

😐

hybrid spoke
#

static constructor

#

or what exactly do you mean

somber hull
#

public static ItemStack getWateringCan(FarmingOverhaul plugin) {

hybrid spoke
ivory sleet
#

HyperLink I guess you could do that

somber hull
#

is that not something i should do?

ivory sleet
#

well

somber hull
#

Cause why create an instance of the class every time?

ivory sleet
#

Idk I cant see the entire method

hybrid spoke
#

thats a bad practice

somber hull
#

Im just creating a item..

#
        ItemStack wateringCan = new ItemStack(Material.CLOCK);
        ItemMeta canMeta = wateringCan.getItemMeta();
        PersistentDataContainer canData = canMeta.getPersistentDataContainer();
        List<String> lore = getCanLore(10);
        
        canData.set(new NamespacedKey(plugin, "isWateringCan"), PersistentDataType.BYTE, (byte) 1);
        canData.set(new NamespacedKey(plugin, "waterLeft"), PersistentDataType.INTEGER, 10);
        
        canMeta.setDisplayName(ChatColor.DARK_BLUE + "Watering Can");
        
        canMeta.setLore(lore);
        wateringCan.setItemMeta(canMeta);
        
        return wateringCan;
hybrid spoke
#

instead you could create it one time and store it as a class variable

ivory sleet
#

if you have like a set of items then you should probably have a registry

hybrid spoke
#

or use an enum

eternal night
#

👀 enums in 2021

hybrid spoke
#

enums are lit

ivory sleet
#

just stick with godciphers solution, not working with independent deployment or smtng anyways

#

just dont use it as a dependency magnet

somber hull
#

I already asked

hybrid spoke
#

?learnjava

undone axleBOT
somber hull
#

Cause enums are just like a list of numbers with names right

#

like

#

if you were to do a switch statement

eternal night
#

tbh enums that create items are pretty trash ngl

hybrid spoke
somber hull
#

for 1 2 and 3

#

Enums are the same thing but with names no?

ivory sleet
eternal night
#

back in the days

#

but spigot makes this shit even worse

ivory sleet
#

myes

eternal night
#

if your enum creates item stacks on init you can't even touch that class in unit tests

ivory sleet
#

the enum that used to crash ides

eternal night
#

or you explode

ivory sleet
#

lmao

#

So will paper do anything about these enums or just let them be there?

eternal night
#

the spigot enums?

#

mojang hasn't been on enums for a while now

ivory sleet
#

yeah, the spigot enums

eternal night
#

¯_(ツ)_/¯

#

who knows till the hardfork

ivory sleet
#

ah yes

eternal night
#

only way you could remotely do stuff like this pre hardfork would be a fat fat bytecode rewrite of half the plugins xD

#

kind of defeats the speed aspect of the fork

ivory sleet
#

good point

young knoll
#

The material Enum likes to crash my IDE

somber hull
#

Wait, i could create my own object that has the item information getters. Then just make an item creater and use the object and its values to create an item that way no?

ivory sleet
#

I was considering jumping over to sponge until they started keyfying everything

young knoll
#

Fabric

eternal night
#

meh sponge is pretty overkill in their API design tbh

ivory sleet
#

kashike does pretty overkilling stuff

somber hull
eternal night
#

yea

ivory sleet
#

suppose its better than some underengineered design

eternal night
#

has the advantage of being pretty future proof

ivory sleet
#

yeah indeed

eternal night
#

but like, if only docs would follow

#

lol

ivory sleet
#

🥲

#

when did ya join triage btw

eternal night
#

a few weeks ago 🙂

#

don't know why they wanted me tbh

ivory sleet
#

ah then I am up to date at least

eternal night
#

not like I am that useful

#

nor do I really know anyone besides commenting on github PRs xD

ivory sleet
#

lol well someone has to do that fingerguns

young knoll
#

I still think fabric is a good way forward for servers

eternal night
#

idk I just gotta get in touch with the people 🙂

proud basin
#

I will inject you conclure

ivory sleet
#

What framework are you using?

ivory sleet
#

but they're bumping yarn frequently with pretty unjustified refactors apart from "I love these refactors"

#

As you can probably tell its a disaster when using libs during dev tests

eternal night
#

I think spigot api is gonna be the best baseline ¯_(ツ)_/¯

#

tho tbh, major breaking changes need to happen

ivory sleet
ivory sleet
eternal night
#

🙏 Yea hopefully. It is already at the point where either your plugin will update to the newest version pretty fast or it is just not maintained anyway

#

see the 1.17 NMS changes

#

a LOT of plugins had their issues, but all of the maintained ones updated already

ivory sleet
#

oo yeah

young knoll
#

Remap reflection wen

eternal night
#

why even use reflection tho xD

#

not really any reason for that anymore

young knoll
#

Some things are private

eternal night
#

True I guess

#

propose API to fix that :>

young knoll
#

And we don't have access transformers

ivory sleet
#

mixins wen 😛

young knoll
#

That too

#

Then we can have parity with the mod loaders :p

ivory sleet
#

aye

young knoll
#

And then I can make my pistons push everything plugin

reef wind
#

what in the hell is "CAVE_AIR" and "VOID_AIR", is void just like damaging air?

young knoll
#

No blocks exist in the void

hexed hatch
#

Speaking of pushing blocks, is it possible to make blocks get pushed (without a piston) with a plugin?

young knoll
#

I honestly don’t know how void air works

reef wind
#

what about cave_air

young knoll
#

Caves

hexed hatch
#

That’s how the game detects when you’re in a cave

#

To play cave sounds and shit

reef wind
#

ohh

#

alright, thanks.

young knoll
#

I think light level is also used for that

#

No idea, it used to be anyway

#

Cave air is useful for terrain generators

#

And if you fill it with water you can go for a nice swim

ivory sleet
#
class ItemRegistry {
  IdentityHashMap<Class<? extends Item>,Item> map = new IdentityHashMap<>();
  
  <S extends Item> void register(S item) {
    map.put(item.getClass(),item);
  }

  <S extends Item> S get(Class<S> type) {
    return type.cast(map.get(type));
  }
}
@FunctionalInterface interface Item {
  ItemStack supply();
} 
class HeroSwordItem implements Item {
  Plugin plugin;

  HeroSwordItem(Plugin plugin) {
    this.plugin = plugin;
  }

  @Override public ItemStack supply() {
    //do whatever u want here

  }
}

class MainPluginClass extends JavaPlugin {
  @Overrie public void onEnable() {
    ItemRegistry registry = new ItemRegistry();

   //register items
    registry.register(new HeroSwordItem(this));

    //then to access HeroSwordItem
    ItemStack stack = registry.get(HeroSwordItem.class).supply();
  }
}```
@somber hull You could have something like this
#

and sorry for the spoon

rotund pond
#

Hello everyone !

I'm trying to setup a custom config and I'm trying things with spigot config file...

I'd like to change a value in the config file then save it, but It doesn't save idk why ... 😦

        mainConfig.set("test.enabled", true);

        try {
            mainConfig.save(new File(this.pluginTest.getDataFolder(), "test.yml"));
        } catch (IOException e) {
            e.printStackTrace();
        }

Please ♥ 😦

ivory sleet
#

send more code

#

that looks fine

rotund pond
#

What do you need ? x_x'

ivory sleet
#

the entire class is always a good start

rotund pond
#

I won't, it's not for me so I can't give codes like that 🤷‍♂️

And these 2 lines are the only one I use with config

ivory sleet
#

well nothing is wrong from the snippet you sent me

rotund pond
#

Ah 🤔
Thank you :/

ivory sleet
#

that said it is guaranteed a bug outside that code

#

or for that part just something you missed

rotund pond
#

Yeah maybe, I'm just gonna sleep, let's see tomorrow

#

Thank you ^^

ivory sleet
#

cheers

hardy pivot
#

Hi

#

Anyone knows why i my ide dont detects the api where im using?

#

this show me when i try to build

#

i added the .jar to the libraries

eternal night
#

you are using maven to build and manage your project

#

adding things to your libraries manually isn't going to work out too well

hardy pivot
#

how i can add the api correctly?

eternal night
#

by adding it to the pom.xml like any other library

#

concerning this is your own api, you will have to install it into your local maven repo

#

run mvn install in the project root of the API you are trying to use

hardy pivot
#

ok...

eternal night
#

Yea it is sadly a bit more complicated to work between multiple projects than the minecraft development plugin just nicely setting things up for you 😭

hardy pivot
#

i get this

eternal night
#

that seems to still be in progress

#

give it some time

#

if it fails, maven usually is quite good at spitting you a stacktrace

waxen plinth
ivory sleet
#

Welcome to my code style

waxen plinth
#

I bet you do

@CommandHook("thing") public void thing(CommandSender sender) {

}```
#
@Override
public String toString() {
//
}```
#

Yeah that's the only acceptable inline annotation

#

I never use those though lol

ivory sleet
#

@Override @Nullable @ImmutableView @Contract public ...

#

(:

dusk flicker
#

NO CONCLURE

#

NO

waxen plinth
#

Bad

#

Oh hey rack quick question

#

Were you one of the people who objected to a plugin dependency command framework

dusk flicker
#

uhh

#

not sure

#

Don't recall it

waxen plinth
#

Understandable

dusk flicker
#

uh oh

#

admittedly this is the first time ive really spent time here in a few days

fluid cypress
#

whats the api equivalent for the /save-all command?

#

if no chunk has been modified, will it write to or read from disk anyway? i mean, it will be slow or not if there is no chunks modified?

waxen plinth
#

Bukkit.getWorlds().forEach(World::save);

#

Probably this

#

Not 100% sure though

#

Of course, you could always just Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "minecraft:save-all");

loud rune
#

beep

hardy pivot
#

what this icon mean?

#

i have added an .jar to the libraries but i get this icon

#

the other api's have the first one

karmic grove
#

so to create a second command do i have to create a whole 2nc @overide or do i just start at the if statement below that

forest edge
#

I don't really have time to test it out, but does anyone know if Bukkit's ServiceManager can be used in the onLoad method? Trying to register manager classes without worrying about load order

ivory sleet
#

Hmm try and see actually.

#

If it’s your api, just have one context interface and the a concrete implementation to it

forest edge
#

Well, I imagine Bukkit is loaded before plugins so I don't see why it wouldn't be. I'll just see if it does when I actually deploy everything for testing 🙂

ivory sleet
#

Idr but it might be the case that onLoad is invoked before Bukkit::setServer is called

#

Personally haven’t needed to try it out so would appreciate if you could let me know about your findings

fluid cypress
#

World#save() is sync, right?

ivory sleet
#

Probably depends on where you would calll it

waxen plinth
#

But doing commands that way is very ugly

waxen plinth
karmic grove
waxen plinth
#

No I mean that's basically the way you have to do it unless you use a command framework

#

I have a good one you can use if you want

ivory sleet
#

😌

waxen plinth
#

And it's SHADED now

fluid cypress
# ivory sleet Probably depends on where you would calll it

even if it is, i dont think thats the problem, im trying to delete mca region files, but for some reason, File#isFile() returns false, and therefore, i cant delete the file, even tho it actually exists, im seeing it, even before calling the method that tries to delete it. is there any way to make theFile#delete method show me the reason why it cant delete a file? instead of just returning false

waxen plinth
#

So you won't need a plugin dependency

karmic grove
fluid cypress
#

the ide says something about java.nio.file.Files, but i cant use that bc its private, or something like that

ivory sleet
#

I don’t know frankly, I stopped using File long time ago

#

Files is just a helper class for Path

fluid cypress
#

what do you use then

waxen plinth
fluid cypress
#

what should i use

ivory sleet
#

Path (:

fluid cypress
#

mmm

waxen plinth
#

Yeah nio is 👌

#

Very streamy, I love it

ivory sleet
#

Wait are you trying to delete a file or just save?

fluid cypress
#

now im trying to delete

waxen plinth
#

Delete a world?

fluid cypress
#

no, just some specific region files

karmic grove
ivory sleet
#

That’s probably disastrous in a sense to achieve

waxen plinth
#

But I'm telling you, there is only pain down that road

#

At least use CommandExecutors

ivory sleet
#

Cause you’d need to save the world, unload those chunks corresponding to the region files and then pray it to make those chunks actually unload.

fluid cypress
#

im already doing that

waxen plinth
#

Why are you trying to delete region files

karmic grove
ivory sleet
#

^ also a good question

waxen plinth
fluid cypress
#

bc im generating chunks, and only 1 will be used at the end

waxen plinth
#

Okay

#

You can disable chunk saving

fluid cypress
#

can i discard the changes somehow?

waxen plinth
#

Yes

fluid cypress
#

or do i have to restart the sv

waxen plinth
#

Disable auto save for the chunks

fluid cypress
#

ok, sounds good, how can i do that

waxen plinth
#

And set them to not save in ChunkUnloadEvent

#

If you really really need the world to not save changes then you can also unload the world without saving on shutdown

fluid cypress
#

i can set autosaving independently on each chunk?

waxen plinth
#

You can choose per event

#

So you can listen for ChunkUnloadEvents and tell them to not save if you don't want them to

#

ChunkUnloadEvent#setSaveChunk(boolean)

fluid cypress
#

do i need to set autosave false to the world if im stopping it from saving in that event?

#

or its bc it can save the chunk even if its still loaded

waxen plinth
#

I'm not sure about autosave but if you don't want the world saving I would set it to false

#

Not fully sure but I think autosave saves loaded chunks periodically whereas they otherwise only save when they're unloaded

fluid cypress
#

it depends on time or on ticks?

#

bc im doing it before the first tick

waxen plinth
#

Dunno

fluid cypress
#

when a chunk is unloaded, it will always be saved, right?

#

wouldnt make sense otherwise, i think

#

unless the chunk didnt change, that would be nice, but i dont think thats how it works

waxen plinth
#

Unless you set it to not save, I believe so, yes

fluid cypress
#

ok, ill try that

#

thanks

quaint mantle
#

Can someone help me please

#

I got this error:

#

Im trying to connect to a server on my bungee cord world and its not working

#

Just to say all of my other bungeecord servers are working correctly

#

do the touch handlers not work anymore in holographic displays api?

summer bridge
#

Hey i am using multiverse core and I want to use /summon from the console. Is there a way to specify the world? Or, since it is a vanilla command is that not an option?

quaint mantle
#

how to sort players in tab

#

dont

#

have

#

all

#

day

torn oyster
#
kits:
  no:
    items:
      AIR:
        slot: 0
    armor:
      AIR:
        slot: 0```
why when i try to do this:
```java
        ConfigurationSection kit = kits.getConfigurationSection("kits." + name);
        ConfigurationSection items = kit.getConfigurationSection("items");```
does it say "kit" is null
name = "no"
quaint mantle
#

?

quaint mantle
quaint mantle
#

ik

#

im doign rn

quaint mantle
#

gyys

#

i made a method to convert name to uuid

#

for making a team

#

but longer then 16

#

niow i wanna die

#

bcuz took em ages

#

Caused by: java.lang.IllegalArgumentException: Team name '4124ca7131b046dcb2e55eea68e47a94' is longer than the limit of 16 characters

median anvil
#

getting a problem where i have an multiple if statements and in these statements i have event.setCancelled(true); and the first 1 works, but if the second case happens, the event does not get canceled, but everything else in the if statement works (does happen)

quaint mantle
#

k

median anvil
#

if (statement) { event.setCancelled(true); do some other stuff... } else if (statement) { event.setCancelled(true); do some other stuff... }

#

the both if statements work fine, but only cancels the event on the first one

#

everything else about them work fine

#

only cancels if the first one is true, if the second one is true, it wont cancel but will do everything else.

tacit drift
quaint mantle
#

is there a

#

way

#

to

#

loop through all teams

#

and

#

then

#

unregister

#

Hey there,
what's the name of the packet for changing sign data(sign lines)?

slim bough
#

where can I find placeholder API action bar plugin

quaint mantle
#

huh

slim bough
#

yes

quaint mantle
#

tf is that supposed to mena

slim bough
#

what

quaint mantle
#

tf is a placeholder api action bar plugin

slim bough
#

really big

quaint mantle
#

assuming u mean a plugin to change action bar that supports papi?

slim bough
#

yes sorry english

quaint mantle
#

k

slim bough
#

i have image for example

quaint mantle
#

title manager

#

use

slim bough
quaint mantle
slim bough
#

thanks so much

quaint mantle
#

k

quaint mantle
#

thanks anyways I found it myself

median anvil
#

nvm i solved my problem aswell

#

who knew programming was legit just problem solving. 😅

grim ice
#

how to rename a configuration section without deleting its child sections?

eternal oxide
#

You can't

#

well you can move

#

get the Section then re-add it under a new Path

plain scroll
#

why aint the spigot web API updating?

chrome beacon
#

Which of them are you using?

solid cargo
#

why??
I currently use
if(target == null); sender.sendMessage("This player isn't online or doesn't exist!");

#

I have also used if(!target.isOnline blah blah blah)

chrome beacon
#

On if

solid cargo
#

ok

#

still does it

chrome beacon
#

And return or prevent the other code from running

solid cargo
#

ok

#

it still does it :(

#

should i switch it to

#

uh

solid cargo
#

!target?

somber hull
solid cargo
#

(!target.isOnline)?

#

maybe this?

grim ice
#

jk i knew that

#

for (String string : config.getConfigurationSection("warps." + warp).getKeys(false)) {
config.set("warps." + message + "."+string, config.get("warps." + warp +string));
}

#

ez

solid cargo
#

what if i do both 🤔

#

okay that doesnt work

chrome beacon
#

Send your entire code

solid cargo
#

entire class?

chrome beacon
#

Method or class

grim ice
#

does config.set create a new section if one does not already exist

#

like

#

config.set("lol.lol" , "e");

#

what if lol.lol didnt exist

#

only lol did

chrome beacon
grim ice
#

will it make a new one and set it to "e"

solid cargo
#

still

grim ice
#

pls someone say yes or no

solid cargo
#

i put it in the else thingy

chrome beacon
#

Send code with null check

solid cargo
#

hm ok

#

but

solid cargo
eternal oxide
chrome beacon
solid cargo
#

ah

chrome beacon
#

You need to stop the other code from running too

eternal oxide
#

Then delete the old warps section

solid cargo
#

by return false?

grim ice
chrome beacon
grim ice
#

yours will set the parent directory @eternal oxide

#

wait

eternal oxide
#

yes, you wanted to rename a config section

grim ice
#

yes but not "warps"

#

the one under "warps"

eternal oxide
#

thats what you showed

grim ice
#

w ha t

#

config.set("warps." + message + "."+string, config.get("warps." + warp +string));

#

i showed that

solid cargo
grim ice
#

yeah but the configuration section in my case is a child section

#

that also has child sections

covert valve
#

does player persistent meta transfer over a bungee network?

#

if not i have to learn mysql

eternal oxide
#

no

grim ice
#

btw elgar

#

is my thing right

#

or

chrome beacon
#

You might have missed a .

grim ice
#

o

#

yeah i thnk i did

solid cargo
#

anyways

#

wait i will ask for help in 5 mins

#

if i need any

#

is there an opposite of null?

#

okay i have tried all possible combinations i know, and still it gives me null

opal juniper
#

show ur code

#

@solid cargo

solid cargo
#

ok

#

porque?

opal juniper
#

probably don’t use exact

#

use getPlayer()

solid cargo
opal juniper
#

yes

solid cargo
#

It already was in code tho

vague oracle
#

Where is your null check?

solid cargo
#

hm

#

stoopid question but

#

where to put it
cause i put it in the uh

#

the offline message place

#

and deleted it soon after

vague oracle
#

You put your null check straight after you get the target variable

#

Player target = Bukkit.getPlayer(args[0]);
if(target == null) return;

solid cargo
#

ahh

#

ok

#

sorry for asking for the plane to go into the mouth

#

(aka spoonfeeding)

#

yeah but return what

#

false?

opal juniper
#

meh probs not

#

return true and send the command sender a message

#

to say it failed

solid cargo
#

hm

#

now the command doesnt execute at all

#

nothing in console

#

ffs

#

as you can see- nothing

chrome beacon
#

You probably returned before sending a message

solid cargo
#

oh yeah

grim ice
#

help

#

im stuck

#

pluginManager.registerEvents(new ChatEvent(new ClickEvent()));

#

ClickEvent

#

wants ChatEvent as a param

#

and click event needs chat event as a param

eternal night
#

circular dependencies 🥳

#

basically solved by extracting the logic/data needed into a third type

#

that is then passed to both listeners

grim ice
#

uhu

#

how

solid cargo
#

so i decided to make another command

#

and this one still has the problem

grim ice
#

@eternal night u there'

chrome beacon
grim ice
#

uhh

#

help

solid cargo
eternal night
#

Well what do your two classes need each other for

grim ice
#

uh

#

so i can fix it

#

but i have my arraylist

#

in a class

#

i want it in my chatevent class

#

if there were pdcs in 1.8.8 i wouldnt need to do this :/

eternal night
#

👀

grim ice
#

do i just move the arraylist to an other place

#

or what

eternal night
#

but if you only need the array list from the click event in the chat event, how are you failing

grim ice
#

because im a failure

eternal night
#

:bruh:

#

what is it you are trying to setup anyway

grim ice
#

WAIT

#

i just fixed it

#

IM SO DUMB

eternal night
#

5head

grim ice
#

i couldve just moved the array list

#

to the other class

#

bruh

solid cargo
#

yo how can i replace a specific phase with another phase

#

in intelij

opal juniper
#

wdym

#

you can refactor

solid cargo
#

yeah, change these with another thing

opal juniper
#

i have no clue what i am looking at

solid cargo
#

wait nvm

#

found a work around

grim ice
#

how to check how many times has the code ran in a enhanced for loop

quiet ice
#

extract a counter variable that is ticked on every run

grim ice
#

yes i did try that but um

#

i did

quiet ice
#

so somethin like

int i = 0;
for (foo bar : bars) {
    i++;
}
grim ice
#

int i = 0;
i++
if(i =5){
DoSmth();
}

#

it says

#

i == 5 is always false

quiet ice
#

yes, because you always redefine i

grim ice
#

nvm its cuz i is inside the for

quiet ice
#

i needs to be defined outside the loop in order to work as intended

grim ice
#

ok tyyy

quiet ice
#

Also, you should increment i at the END of the loop

#

Otherwise you could get some strange behaviour if you are not carefull enough

main dew
#

How disable physics sand, gravel etc?

main dew
#

But how player place block

grim ice
#

this is in a foor loop: if(i < 54) {
i++;
gui.addItem(item);
}

quiet ice
#

you cant permamently turn gravity off

grim ice
#

will the i++ still work

quiet ice
#

yes, as long as i is under 54

grim ice
#

no

#

i++ is outside of the if

#

my bad

#

if(i < 54) { gui.addItem(item); } i++;

#

like dis

quiet ice
#

why not use a traditional loop at this point?

grim ice
#

ehh

#

im getting each key

quiet ice
#

it would even get rid of the .iterator() overhead

grim ice
#

of a collection

quiet ice
#

ah, using the collection interface

#

well, then

grim ice
#

just tell me

#

will it work

#

lol

stone sinew
quiet ice
#

he's doing a foreach loop

#

so you cant do that

#

and yes, it would work

main dew
quiet ice
#

well, it wont be a one-liner then

stone sinew
#

Turn gravity off on what?

quiet ice
#

sand

main dew
#

Gravel sand etc

stone sinew
#

Oh it was you that asked xD

stone sinew
# main dew Gravel sand etc
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent e) {
    if(e.getSourceBlock().getType() == Material.SAND)
        e.setCancelled(true);
} // This event isn't needed
    
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
    if(e.getEntityType() == EntityType.FALLING_BLOCK) {
        if(e.getTo() == Material.AIR && e.getBlock().getType() == Material.SAND) {
            e.setCancelled(true);
            e.getBlock().getState().update(false, false);
        }
    }
}
```https://www.spigotmc.org/threads/prevent-sand-from-falling-upon-placing-sand.133386/
main dew
main dew
#

This is work in 99% but

stone sinew
quiet ice
#

sand & co aren't tile entities and as such vanilla wont store any data on them for this particular usecase. You will have to use inefficent event listeners

stone sinew
#

Or do what I said when you asked in the past and send packs to the player then just set the block

main dew
#

EntityChangeBlockEvent when you place block server set air in this place and latter set your block again and create falling block after remove

main dew
#

BlockPhysicsEvent blocked update block around

#

Don't work on block which you place

#

I am writing code that can disable physics but it has 200 lines and is terrible

eternal oxide
#

Is there an event when TNT actually primes and becomes an entity? I expected BlockRedstoneEvent to fire before it happens, but nope. Neither does ExplosionPrimeEvent.

quiet ice
#

I once wrote 2k lines just to rotate the colours of materials and it works fine (as long as mojang doesnt add more colours). Not everything should be measured by the line count

visual tide
#

is there a way to store some data on a player without persistentDataContainer

eternal oxide
#

Persistantly?

#

Meta, but it does not persist

quiet ice
#

that wont persist either

visual tide
quiet ice
#

well then, Meta or Maps

visual tide
#

oke ty!

quiet ice
#

maps are more common in such usecases, just dont forget to remove the key (the player) on logout to avoid really small memory leaks if you got the Map<Player, Value> route

tidal skiff
#

how do i remove all snowballs in onEnable?

stone sinew
tidal skiff
#

just delete them

#

i mean

#

with remove();

stone sinew
visual tide
tidal skiff
#

how though

stone sinew
quiet ice
#

map.put()?

tidal skiff
#

how do i kill all snowballs on onEnable

#

is a better way to put it

quiet ice
#

you first need to have worlds loaded, onEnable does not gurantee that

visual tide
grim ice
#

whats an inventory max slots

tidal skiff
quiet ice
#

you have to use : and not = in foreach loops

stone sinew
tidal skiff
#

from the world

visual tide
tidal skiff
#

thx

grim ice
#

whats an inventory max slots

quiet ice
#

the size of the inventory?

grim ice
#

yes

#

like

quiet ice
#

Usually a multiple of 9

grim ice
#

Inventory gui = Bukkit.createInventory(player, HOW MUCH???);

#

wdym multiple of 9 dude

quiet ice
#

are you for real

grim ice
#

bro

#

it has a max

quiet ice
#

54

grim ice
#

ok

#

ty

quiet ice
#

That is if I understood your question right

grim ice
#

you did

#

I already had 54 but i wasnt sure

#

if it was actually the max

late stone
#

how can i make passive mobs attack players?

quiet ice
quiet ice
tidal skiff
#

how do you get the current world with Bukkit.getWorld()?

grim ice
#

not lots of code

#

?paste

undone axleBOT
grim ice
#

why is this sending me an internal error thing

quiet ice
grim ice
#

i use this method in a command class

#

but the command class is empty it only has GuiMenu.openMenu(player);

#

some one who doesnt mind pls help kthx

quiet ice
#

stacktrace or bust

grim ice
#

wdym

#

oh right

#

lemme check the console

#

bruh

#

i got npe'd

#

for (String childSection : section.getKeys(false)) {
thats the line

stone sinew
grim ice
#

omg right i forgot to add it onenable

#

wait nvm

#

if (warps.getConfig().getConfigurationSection("warps") != null) {

#

is ok?

stone sinew
grim ice
#

what

stone sinew
#

if (warps.getConfig().isSet("warps")) {

grim ice
#

but

#

ok 1s

#

my config looks like this

#

warps:
something:
e:
e:

#

is ur solution fine with that

stone sinew
#

isSet() just checks if the path you input "is set"

grim ice
#

k

#

i added like 3 more null checks just incase lmao

slim kernel
#

So I need to save Locations. I did it in an ArrayList. But can I somehow save Locations that are relative to the player? Example: the Location I want to save is 2 Blocks above the Player and should be still 2 Blocks above the player if the player moved. Can someone help me with that pls?

rigid hazel
rigid hazel
#
Location centerLocation = new Location(this.chunk.getWorld(), this.chunk.getX() << 4, 64, this.chunk.getZ() << 4).add(8, 0, 8).clone().subtract(0, 1, 0);

                centerLocation.getBlock().setType(Material.GOLD_BLOCK);

                // Sets the blocks manually, because I'm bad in math
                centerLocation.add(1, 0, 0).getBlock().setType(Material.GOLD_BLOCK);
                centerLocation.add(0, 0, 1).getBlock().setType(Material.GOLD_BLOCK);

                centerLocation.subtract(1, 0, 0).getBlock().setType(Material.GOLD_BLOCK);
                centerLocation.subtract(0, 0, 1).getBlock().setType(Material.GOLD_BLOCK);

                centerLocation.add(1, 0, 1).getBlock().setType(Material.GOLD_BLOCK);
                centerLocation.subtract(1, 0, 1).getBlock().setType(Material.GOLD_BLOCK);

                centerLocation.subtract(1, 0, 0).add(0, 0, 1).getBlock().setType(Material.GOLD_BLOCK);
                centerLocation.subtract(0, 0, 1).add(1, 0, 0).getBlock().setType(Material.GOLD_BLOCK);

                centerLocation.add(0, 1, 0).getBlock().setType(Material.BEACON);
#

Why does it look like this? It should be this:

candid galleon
#

Location is mutable

#

do centerLocation.clone().add(___

rigid hazel
stone sinew
slim kernel
rigid hazel
candid galleon
#

updated code?

rigid hazel
#

I updated @candid galleon

candid galleon
#

I don't see clone

stone sinew
candid galleon
#

oh

#

you have to do it on every line

#

centerLocation.clone().add(1, 0, 1).getBlock().setType(Material.GOLD_BLOCK);

rigid hazel
#

Ah. Thanks

candid galleon
#

maybe compress it into a for loop

rigid hazel
#

I will try,

rigid hazel
candid galleon
#

👍 hf changing 9 lines of code for 1 bug

slim kernel
candid galleon
#

yes

stone sinew
slim kernel
stone sinew
rigid hazel
#
[12:49:30] [Server thread/ERROR]: [org.bukkit.craftbukkit.v1_17_R1.CraftServer] de/cimeyclust/utils/mysql/MySQLConnector initializing CimeyRolePlay v1.0.0 (Is it up to date?)
java.lang.NoClassDefFoundError: de/cimeyclust/utils/mysql/MySQLConnector
        at de.cimeyclust.Plugin.onLoad(Plugin.java:44) ~[CimeyRolePlay-1.0.jar:?]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:410) ~[patched_1.17.1.jar:git-Paper-157]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:276) ~[patched_1.17.1.jar:git-Paper-157]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1126) ~[patched_1.17.1.jar:git-Paper-157]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[patched_1.17.1.jar:git-Paper-157]
        at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.ClassNotFoundException: de.cimeyclust.utils.mysql.MySQLConnector
        at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:146) ~[patched_1.17.1.jar:git-Paper-157]
        at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) ~[patched_1.17.1.jar:git-Paper-157]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
        ... 6 more
#
this.connector = new MySQLConnector(this); // Line 44
#

I just moved MySQLConnector.java from package utils to utils.mysql

#

Why I get this error now?

slim kernel
tall dragon
#

@rigid hazel rebuild it along with any dependencies you are using and that should fix it

rigid hazel
#

I cklied the reload icon in the left corner and packaged

tall dragon
upper osprey
#

How to set custommodeldata to slot chestplate

rigid hazel
tall dragon
#

👍

tacit drift
#

can i create a book (not physical) from vanilla json?

#

it's quite a large book and I don't want to risk anything as it's easily obtainable :))

upper osprey
tacit drift
plain scroll
#

What are some things I should add to my plug-in?

slim kernel
#

Can I subtract 1 number of the other a better way than checking before if one of the numbers is negative every time?

upper osprey
tacit drift
#

ip?

lost matrix
lost matrix
upper osprey
tacit drift
#

maybe they make "fake" armor

lost matrix
lost matrix
tacit drift
#

you can make an item

#

to be like an armor

#

like have "armor points"

#

idk how it's callled exactly

lost matrix
lost matrix
tacit drift
#

yeah

tacit drift
#

didn't know that

#

but wouldn't putting it in a armor slot just show the in-hand model?

vivid hill
#

hello i need some help so i want to add time to my scoreboard could someone help me there?

slim kernel
# lost matrix Example pls. This makes no sense to me.

I want to store a Location relative to the player. So I store the x, y and z difference between the 2 Locations. But if I would do:

x = location.getBlockX() - player.getLocation().getBlockX();

Then if both would be negative I wouldn't get the difference only if both would be positive. And I think there is a better solution than checking every coordinate if its negative or positive before thats what I want to know.

lost matrix
vivid hill
#

like how can i code this with java?

slim kernel
vivid hill
#

that it shows the esact time of a country at the sscoreboard

lost matrix
# slim kernel oh thank you
  public Vector getRelativeLocation(final Player player, final Location absoluteLocation) {
    return absoluteLocation.toVector().subtract(player.getLocation().toVector());
  }

  public Location getAbsoluteLocation(final Player player, final Vector relativeVector) {
    return player.getLocation().add(relativeVector);
  }
lost matrix
surreal brook
#

Hello, i have a question about adding team to player. Do i need to do it by HashMaps ?

vivid hill
#

thx how do i add this to the scoreboard?

lost matrix
supple elk
#

Does anyone know why this code seems to cause an infinite loop?

#

essentially all it does is if a player tries to close a certain inventory it will try to reopen that inventory for the player

eternal night
#

delay it by a tick

lost matrix
eternal night
#

modifying the inventory open during the close event kindly destroys the internal tracking

supple elk
#

I see

lost matrix
supple elk
surreal brook
eternal oxide
#

Player#teleport

lost matrix
surreal brook
thick tundra
#

Hey, Is it possible to check if player is left or right of a location? and if so how?

lost matrix
#

Either hard code it or use a Map<UUID, Location>
If its just a duel then i would hard code it.

Player player = Bukkit.getPlayer(firstID);
if(player == null) {
  // player is offline...
  return;
}
player.teleport(firstLocation);

Same with secondID and secondLocation.

fervent gate
#

What is wrong with this statement?

supple elk
#

when you create a duel pass in the UUID of both players and store them, as well as your spawning locations. When you want to teleport the players to the spawning locations, so for example at the start, use player#teleport(location)

eternal night
#

"left" and "right" are not really useful without the axis you consider the basis

lost matrix
supple elk
#

you can get a player from a UUID by using Bukkit.getPlayer()

lost matrix
thick tundra
fervent gate
#

I thought that was for strings

lost matrix
lost matrix
thick tundra
#

okay thanks i will look into it 😄

lost matrix
surreal brook
#

@lost matrix Ehm... Okay and so if i have more players than 2 and i want let them to select what team they want for example like in some minigames like bedwars ... Can i do it with HashMap ? If yes can you tell me how?

lost matrix
surreal brook
#

Okay thank you.

fervent gate
#

Is there a way to set the damage for the next hit? So what I am trying to do is make a sword that on right click, deals double damage for the next 2 hits

lost matrix
fervent gate
#

What is pdc?

grim ice
#

?pdc

thick tundra
#

you think this is good?

lost matrix
# fervent gate What is pdc?

Here is an example:

  private static final NamespacedKey DAMAGE_KEY = NamespacedKey.minecraft("extra-damage-amount");
  private static final NamespacedKey COUNT_KEY = NamespacedKey.minecraft("extra-damage-count");

  public void grantExtraDamage(final ItemStack itemStack, final double damage, final int amount) {
    final ItemMeta meta = itemStack.getItemMeta();
    final PersistentDataContainer container = meta.getPersistentDataContainer();
    container.set(DAMAGE_KEY, PersistentDataType.DOUBLE, damage);
    container.set(COUNT_KEY, PersistentDataType.INTEGER, amount);
    itemStack.setItemMeta(meta);
  }

  private double getExtraDamageAndDecrement(final ItemStack itemStack) {
    if (itemStack == null || itemStack.getType() == Material.AIR) {
      return 0;
    }
    final ItemMeta meta = itemStack.getItemMeta();
    final PersistentDataContainer container = meta.getPersistentDataContainer();
    final Integer count = container.get(COUNT_KEY, PersistentDataType.INTEGER);
    final Double damage = container.get(DAMAGE_KEY, PersistentDataType.DOUBLE);
    if (count == null || damage == null || count < 1) {
      return 0;
    }
    container.set(COUNT_KEY, PersistentDataType.INTEGER, count - 1);
    itemStack.setItemMeta(meta);
    return damage;
  }

  @EventHandler
  public void onDamage(final EntityDamageByEntityEvent event) {
    final Entity attacker = event.getDamager();
    if (attacker instanceof LivingEntity livingAttacker) {
      final EntityEquipment equipment = livingAttacker.getEquipment();
      if (equipment == null) {
        return;
      }
      final double extraDamage = this.getExtraDamageAndDecrement(equipment.getItemInMainHand());
      event.setDamage(event.getDamage() + extraDamage);
    }
  }

spoonfeed

eternal night
#

if someone uses the minecraft namespace for pdc the spigot contributors shall smite them

#

ngl

lost matrix
#

Nowadays you can just use two Strings for that.

eternal night
#

yea there are a lot of neat ways to distribute your namespaced keys around

quaint mantle
#

do the touch handlers not work anymore in holographic displays api?

whole pasture
#

Is there a way to add grouped recipes similar to how items like logs are handled? I'm planning on adding a recipe that lets players craft an item between it's 16 states, but I don't want 16 or more spaces in the book.

quaint hedge
#

Hi guys i need help. I want to create a permission plugin for bungeecord but i need to find a way to get the permissions of the other bungee plugins but i don't find a solution. Someone can help me with that?

quaint mantle
ivory sleet
quaint hedge
#

Conclure can you help me please?

whole pasture
#

Hmm, got it :/ any idea what the ShapelessRecipe.setGroup() method is then?

Set the group of this recipe. Recipes with the same group may be grouped together when displayed in the client.
I'm assuming that's it, I was still digging around after sending my message.

ivory sleet
#

I am not experienced with bungeecord permissions but maybe checkout how something like LuckPerms do it? @quaint hedge

#

oh mov51 yeah that might be it

quaint hedge
#

i tried to search how Luckperms do that but there is no answer in google or spigot

chrome beacon
#

LuckPerms is open source

ivory sleet
#

However when I created recipes last time (in fabric) you could define a group of materials and then use that group as an ingredient

Afaict not possible with spigot

chrome beacon
#

Look at it

ivory sleet
#

then go in the bungeecord module

quaint hedge
#

i saw their open source but he is very complicated to understand

whole pasture
#

Awesome, lol. I'll give it a shot then. Sorry for asking prematurely.

ivory sleet
#

The code is well over engineered for being a plugin maybe but it’s great since it protects itself from code symptoms

whole pasture
quaint hedge
#

do you know someone from this server that understand in bungeecord?

ivory sleet
#

By the looks of it. Bungeecord has little to no permission api

#

Basically a PermissionCheckEvent, then CommandSender with the addGroup, removeGroup, hasPermission, setPermission and so on

#

Very minimal

#

Unlike spigot every plugin does not define permissions and their default level etc

quaint hedge
#

Maybe with PermissionCheckEvent i can get all the permissions?

ivory sleet
#

I believe at least

#

Yeah that’s true

quaint hedge
#

Ok i will try to get the permissions with PermissionCheckEvent

#

thank you

#

And one last question. If i will need more help with this topic can i mention you?

ivory sleet
#

Sure

#

Might not be available but if I am then I’ll get back

quaint hedge
#

Ok thank you!

rare crater
#

Hey everyone, i'd like to know how to get the tagCompoung of an ItemStack

#

and how to set it , thx in advance

dense goblet
#

@rare crater I don't think you can mess with nbt tags directly like in forge

#

Generally you'd use the pdc

young knoll
#

You can

#

But you should avoid it

rare crater
#

in fact i'd like to store a data (where T<PotionEffect>) inside an intemStack

#

u know what i mean ?

young knoll
#

Use pdc

#

?pdc

quaint hedge
#

@ivory sleet Well after a few minutes i saw that there is no way to get all Permissions through PermissionCheckEvent. i think Luckperms know how to analyze the main class of every plugin and get the lines of register commands and with that they go to commands class and their they taking the permissions. But this is very complicated to make something like that. What do you think?

rare crater
#

btw im on a Spigot fork > Paper

young knoll
chrome beacon
rare crater
#

for fun i think

quaint hedge
#

cause i want to develop it for my server

#

and also for fun 🙂

rare crater
#

what's the alternative to internalin Java ?

quaint hedge
#

and to learn of course

quaint hedge
#

Ok

dense goblet
#

@rare crater for more complex types I prefer to serialise to bytes and store as a bytearray in the pdc

quaint hedge
#

I really appreciate your help and that of the rest of the company here

eternal night
dense goblet
#

If you want more efficient storage you can write your own data type

rare crater
#

UwU

eternal night
#

yes

rare crater
#

C# = Java > Ctrl + C V

eternal night
#

yea c# just kind of copy pasted xD

#

tho they have way nicer generics

rare crater
#

lol

eternal night
#

¯_(ツ)_/¯

#

every language for their specific usecase

rare crater
#

imagine sorting java array without Linq

rare crater
eternal night
#

I mean, java has streams

#

¯_(ツ)_/¯

pearl wolf
#

what event should i use to disable flowers from dropping if they not in Grass Block ?

rare crater
#

3 B devices kappa

solid cargo
#

yo guys, having some problems

#

the command aint executing, aint anything

#

also doesnt disable fall damage where i tell it to

ivory sleet
#

@quaint hedge actually looks like it’s just using PermissionCheckEvent

tidal skiff
#

do Player variables delete when the player in question leaves?

quaint hedge
#

But how?

chrome beacon
vivid hill
#
        timezone.addEntry(ChatColor.GRAY+ "" );
        timezone.setPrefix(ChatColor.GRAY+ TimeZone.getTimeZone("GMT+05:30"));
 ``` so i am trying to put time on a scoreboard
eternal night
#

no, the gc will not just clear a variable of yours

vivid hill
#

but iuts an error

solid cargo