#help-development

1 messages · Page 1701 of 1

sullen marlin
#

Which Guava has builtin

quaint mantle
#

I figured it out lol thanks

#

Omg its boss man

opal juniper
#

damm that’s a shame

#

i really wanted some money

#

i don’t really see the issue with it if they consented to it

#

but eh nvm

quaint mantle
#

I highly doubt anyone would actually enable a cryptominer

young knoll
#

What about a plugin that just makes every block pink concrete

unkempt peak
#

Wow hi md5

#

That's the first time I've seen you in the help channel

#

Lol ig he's just never on when I am

gaunt saffron
#

what's the easiest way:
i would like to check if no-one joined the server is last hour (like the server is empty for 1h)

unkempt peak
#

just store the time of the last leave/join and then every 10 minutes or whatever check if that time is over an hour

#

actually you can just store it if that leave drops the player count to 0

#

so if the last player leaves store the time they left

ivory sleet
#

It probably needs to be mapped anyways

#

Maybe a Cache<Integer,E> where Integer serves as the index?

#

if you use caffeine it’s possible to add a remove listener

eternal night
#

or just reuse this as a set and use the lists hashcode as the key

#

then you have your "collection"

ivory sleet
gaunt saffron
unkempt peak
#

Ok if you need more help dm me

ivory sleet
#

The list implementation could be a LinkedList as I assume you might want add to be O(1)

young knoll
#

I'm surprised I've never come into this before, but can you force a block update?

quaint mantle
#

BlockState#update()*

#

and uh

#

im kind of noob, im not sure what im doing

#

if you cant tell, im trying to make a minutely rewards system...

#

im definitely not doing it right

young knoll
paper geyser
#

so

#

and 300 seconds in 5 minutes

#

why not just make a runnable that runs every 5 minutes

quaint mantle
#

because thats not gonna work?

#

if someoen joins halfway through 5 minutes that runnable is gonna give them shards next time it runs

#

not next 5 minutes

paper geyser
#

your system is doing the same thing tho isn't it?

#

oh wait

quaint mantle
#

not at all???

paper geyser
#

ncm

#

I've misread your code

quaint mantle
#

gg

#

ya

vivid lion
#

why not do it for 5 mins loop and when a player joins in they get assigned a separate non-repeating task before being put it into the 5 min loop

paper geyser
#

ooh

#

yeah that

vivid lion
#

so save the 5 minute loop into an object and the list of players attached to it

paper geyser
#

when they join create a runnable and when they leave stop it

#

save their time too

#

obviously

paper geyser
#

btw hitbuns love your pfp

vivid lion
#

aye danks

#

i see you like hololive

#

then

paper geyser
#

did you make it yourself? or is it from a clip

#

ahhh nope just thought it looked cool

vivid lion
#

oh its from a gif i found

paper geyser
#

oh thats cool

opal sluice
#

Hi, I would need some help, in fact, I made a custom event, and for some reason it doesn't seem that it cancel it when I do e.setCancelled(true) (the event implements cancellable of course)

#

here is the custom event

vivid lion
#

how did you link it back to the section you used the event

#

did you remember to also call the event

#

register listeners

opal sluice
#

yup

#

the event works

vivid lion
#

so everything works now right

opal sluice
#
public class VehicleInputListener implements Listener
{
    public VehicleInputListener() {}
    
    @EventHandler
    public void onVehicleInput(VehicleInputEvent e)
    {
        e.setCancelled(true);
        System.out.println("HI ! " + e.getInput().name() + " " + e.isCancelled());
        System.out.println("Nice ! " + e.getPlayer().getName() + "\n" + e.getVehicle().toString());
    
        e.dismount();
    }
}
vivid lion
#

what about the part where you called it

opal sluice
#

the e.isCancelled() inside the sysout does return true

#

but

#
                    if(move != null)
                    {
                        final VehicleInputEvent vie = new VehicleInputEvent(event.getPlayer(), move);
                        Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(vie));
                        System.out.println(vie.isCancelled());
                        event.setCancelled(vie.isCancelled());
                    }
#

it returns false

#

I don't get why

quaint mantle
#

why are you running a task

#

Bukkit.getPluginManager().callEvent(vie)

opal sluice
#

To make it sync

quaint mantle
#

k

opal sluice
#

cause events needs to be called sync

quaint mantle
#

my guess is that you're calling it async then sysout before its called

vivid lion
#

i assume this is a bukkit event

#

you called this from

opal sluice
#

Oooh, yeah, it's an async event it's called from

#

that's maybe bc of that

vivid lion
#

what event is it

#

asyncplayerchatevent?

quaint mantle
#

its his own

opal sluice
#

PacketEvent

vivid lion
#

i see

opal sluice
#

PacketEvent is async I guess

opal sluice
quaint mantle
#

its simple

opal sluice
#

yup done

#

testing it out

quaint mantle
#

K

opal sluice
#

Nice it works :x

#

Thanks 😄

quaint mantle
#

👍🏿

#

so i got ntohing but bad ideas for a response to this, im not sure how i can make this work - any ideas that dont involve making runnables whenever someone joins?

quaint mantle
quaint mantle
vivid lion
#

ye as i was saying you can put them on a separate non repeating task

#

when they first join

opal sluice
#

make a list of player with the actual play time, at the 5 min mark give them

#

you can do it with an unique scheduler

quaint mantle
#

im really not sure

opal sluice
#

nope

quaint mantle
#

shardsloop is just HashMap<Player, Long>

opal sluice
#

You're making a scheduler per player aren't you ?

quaint mantle
#

NEVER

#

nononono

opal sluice
#

Oh lmao

quaint mantle
#

its what im trying to not do

quaint mantle
#

i'll use UUID, thats not too big of a big problem

#

#English

#

i just read somewhere to not use Bukkit API in tasktimers somewhere lmao

opal sluice
#

that's not a problem

quaint mantle
#

okay

#

as for the time check.. is that mostly right?

#

alright

opal sluice
#

100L is

quaint mantle
#

what why

opal sluice
#

cause it works on ticks

quaint mantle
#

okay

#

oh eah that makes sense

#

i saw "Long" and thought.. TIMESTAMP

opal sluice
#

Would be too precise for the actual server to run

quaint mantle
#

yeah, makes sense

#

so 100L is 5 seconds?

opal sluice
#

yup as 20 is 1

quaint mantle
#

meaning 6000L should be 5 minutes?

opal sluice
#

yes

quaint mantle
#

okay coollllll

vivid lion
#

a 5 minute loop would suffice as long as you have a player join separate non repeating task at the start which then puts them back on the 5 minute loop

opal sluice
quaint mantle
#

i dont understand

opal sluice
#

I mean, when I do cancel the event, it seem that it already happened async and so it doesn't seem to be cancelled when cancelled by the sync task

#

Like, if the PacketEvent would be cancelled, the player wouldn't be able to jump for example

quaint mantle
#

are you sure it would be 6000 @opal sluice

opal sluice
#

if I cancel it directly inside the async task, it does cancel it properly

quaint mantle
#

oh yeah nvm

opal sluice
#

20*300 = 6000

opal sluice
proud basin
#

ok im able to do some testing now my power is back

proud basin
#

and nothing is null there

torn oyster
#

hey guys

#

how would i make a custom world generator that only has river, plains and forest biomes

#

or well

#

only set biomes

unkempt peak
#

GeneratorSettings?

young knoll
#

Can’t select specific biomes with those anymore

#

Only a single biome

unkempt peak
#

Oh

#

Can't you make custom worlds with a datapack now?

#

Maybe you could do it that way

young knoll
#

You can, yes

quaint mantle
#

how can i uh.. fix this

#

im following a tutorial for the most part, at least now i know my events /run/

#

just not sure how to fix that

#

i can send the entire error if needed but it happens with every event right now

#

first go search what that is

#

zip file closed?

#

btw ankle

#

yeah... nothings corrupt, nor bad in the JAR file

#

give us the events that it is happens right now

#

GuildMessageReceivedEvent

#

well it did something actually?

#

nvm

#

wait dont you have to .queue() it

#

or something

#

.await() i fforgor

#

hold on

#

do u mind to give the code?

#

tbh no LMAO

#

let me try this .queue magic real qucik

#

make sure im not going crazy

#

yeah im juist an idiot, i just had to .queue(), thanks

#

lmaooo

lavish hemlock
#

Oh yo, you found the problem? @proud basin What was wrong?

torn oyster
#

how do i sort a hashmap by its value

young knoll
#

You can’t sort a hashmap

torn oyster
young knoll
#

Yeah you can get the values into a collection and sort that

proud basin
quaint mantle
torn oyster
#

a bit late

#

haha

quaint mantle
lost matrix
torn oyster
#

btw i copied code

#

lmao

#

but here

#

lemme get it

#
Stream<Map.Entry<UUID, Double>> stream = money.entrySet().stream()
                    .sorted((k1, k2) -> -k1.getValue().compareTo(k2.getValue()));```
#

uh its sorta like that

#

i was sorting player balances btw

#

making /baltop

#

prob not most efficient

lost matrix
#

Ah ok you just sorted the entry set.

torn oyster
#

but hey

torn oyster
#

also is there a better way to do this

#
            final int[] i = {page};
            stream.forEachOrdered(e -> {
                if (i[0] > page * 10) {
                    return;
                }
                p.sendMessage(i[0] + ". " + g.getNameByUUID(e.getKey()) + " - $" + new DecimalFormat("###,##0.0#").format(e.getValue()));
                
                i[0]++;
            });```
#

i dont like using final arrays lol

#

it feels a bit hacky but i wouldn't know

lost matrix
#

AtomicInteger from java or MutableInt from apache.

#

As you dont need multithreading you should go with MutableInt

#
      MutableInt pageMutable = new MutableInt(page);

      ... {
        int pageVal = pageMutable.intValue();
        ...
        pageMutable.increment();
      }
torn oyster
#

ah

#

alright

#
            MutableInt pageMutable = new MutableInt(page);
            stream.forEachOrdered(e -> {
                if (pageMutable.intValue() > page * 10) {
                    return;
                }
                p.sendMessage(pageMutable.intValue() + ". " + g.getNameByUUID(e.getKey()) + " - $" + new DecimalFormat("###,##0.0#").format(e.getValue()));
                
                pageMutable.increment();
            });```
#

that?

#

oop

lost matrix
#

Yeah

torn oyster
#

alright

#

i'll take note of that

#

thanks

torn oyster
# lost matrix Yeah

is there a way to get the spigot.yml (or bukkit.yml i forgot) no-permission message?

quaint mantle
torn oyster
#

im not bothered to look into that lol

#

it works fine

lost matrix
torn oyster
#

ty

#

if i change that in spigot.yml, will it use that

lost matrix
#

It uses whatever was in the config when the server started.

torn oyster
#

Condition 'Bukkit.getOfflinePlayer(args[0]) != null' is always 'true'

#

im just gonna ask questions lol

#

im bored

lost matrix
torn oyster
#

im trying to go full custom 👀

#

we'll see how it goes

#

well apart from worldedit, worldguard and lp

lost matrix
# torn oyster `Condition 'Bukkit.getOfflinePlayer(args[0]) != null' is always 'true' `

getOfflinePlayer will always return an OfflinePlayer.
It will first check for an online player
then check in the offline player cache
then check all profiles on the disk
if there is no data available it will query the mojang API and create a new profile.

So it will return an OfflinePlayer no matter what.
This method can be quite expensive if the player is not online and not in the player cache (about the last 10.000 players which connected)

torn oyster
#

would hasPlayedBefore() work?

lost matrix
torn oyster
#

and check my yaml file

lost matrix
#

You should be fine for the most part.

tacit drift
#

Hello, I get an error on a plugin using it with a modified spigot, and I know that all other plugins that use packets work but this one doesn't and the error comes from here

#
    @SneakyThrows
    public static WrappedClass getNMSClass(String name) {
        Pattern toTest = Pattern.compile("\\." + name.replace("$", ".") + "$");
        for (String className : classNames) {
            if(!className.startsWith("net.minecraft")) continue;

            if(toTest.matcher(className).find()) {
                return getClass(className);
            }
        }
        throw new ClassNotFoundException(name); // line 71
    }
``` (the error is from line 71)
#

what are other ways of getting a NMSClass

#

an example for "name" is "Packet"

lost matrix
#

Check timestamps on access or with an executor service.

lavish folio
#

sorry why this line still threw java.lang.NullPointerException (line: 2) in the code:
1 | team = scoreborad.getTeam (TeamHelper.getColorFromEnum (color) + arenaName);
2| team.setColor (ChatColor.RED);

quasi flint
#

check if team == null and then print team

#

if its null. and see whats wrong

lavish folio
#

Cannot be null.
because this calls an error that already exists: team = scoreborad.registerNewTeam (TeamHelper.getColorFromEnum (color) + arenaName);

quasi flint
#

the error says it

#

sure the variables are always the same??

lavish folio
lavish folio
quasi flint
#

hmmmmm

lavish folio
#

otherwise the plugin would write that they are different and copy them

lavish folio
quasi flint
#

just so i know

#

why is it null?

lavish folio
dense remnant
#

Hey I am currently trying to change the knockback of a mob attack.

I am able to import the Attribute Enum but not use its values...

quasi flint
#

non static values go brrrrrrr

#

?learnjava

undone axleBOT
sour fog
#

I have an idea for a plugin, but I think I will need to learn about custom world generation.
The idea:
The plugin generates a world where dirt and diamonds are switched. How would I do this? Thanks in advance.

lost matrix
#

ItemMergeEvent

lost matrix
slim kernel
#

.poll() means you get the first thing in the deque and it get removed right?

slim kernel
#

okay thank you

quaint mantle
#

the addItem method in inventory doesnt require any check to see if the inventory is full ?

proud basin
quaint mantle
#

how to change the durability when the setDurability method is depreciated

exotic obsidian
#

hello

stone sinew
exotic obsidian
#

anyone know how i can protect my database from sql injection?

young knoll
stone sinew
toxic mesa
#

Would it be possible to calculate how a player's y level would change with a certain y velocity?

lost matrix
toxic mesa
#

So let's say the y level is 0.0 and the velocity 0.2 the next tick the y level would be 0.2?

lost matrix
#

Yes

toxic mesa
#

Alright ty

slim kernel
#

I thought about it a lot now. Dont I need to calculate every path possible to be able to tell which one is the shortest?

tacit drift
#

you could use baritone's path finding "way"

eternal oxide
#

No point in appealing unless you have fixed the issue

strange patrol
#

I did fix the issue for which it was deleted

slim kernel
tacit drift
#

👍

#

see how they do it

#

probably the best way

#

and translate that into the spigot api

slim kernel
#

okay I will try that

lost matrix
#

Pretty sure actually

#

Or a surface linked Theta*

slim kernel
lost matrix
#

Dont copy that. Its not abstracted enough so you wont be able to just translate it to spigot.

#

Hm. Maybe it is.

slim kernel
#

I am kind of overstrained

lost matrix
quaint mantle
#

guys

#

I have PlayerInteractEvent called 2 times. how can I fix this?

#
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e) {
        Player p = e.getPlayer();
        Action a = e.getAction();
        EquipmentSlot h = e.getHand();
        if (a != Action.RIGHT_CLICK_BLOCK)
            return;

        if (h == EquipmentSlot.HAND) {
            p.sendMessage("HAND");
            e.setCancelled(true);

        }

        else if (h == EquipmentSlot.OFF_HAND) {
            p.sendMessage("OFF_HAND");
            e.setCancelled(true);

        } else {
            return;
        }
    }
slim kernel
quaint mantle
#

yes

#

2 hand

#

how can I fix this?

slim kernel
# quaint mantle .

I did it like this:

if (event.getHand() != EquipmentSlot.HAND) {
            return;
        }
quaint mantle
#

no

trail flume
#

Any idea what java.lang.NullPointerException: Cannot invoke "org.bukkit.Material.getId()" because "type" is null means?

eternal night
#

your "type" variable is null ?

trail flume
#

It's not though

quaint mantle
#

show the code and the line its shooting the error on

eternal night
#

it should be enough

trail flume
#

Oh sorry, wasn't setting the variable in the constructor. Sorry for wasting your time.

eternal night
#

you have a variable that is null xD

trail flume
#

yeah

quaint mantle
#

;/

#

ah

trail flume
#

I was doing material = material; instead of this.material = material; lol

#

Ok well now ItemStack.setData(new MaterialData(byte)) isn't working

timber imp
#

there is a a symbol on near npc anmes how to fix it ??

#

this symbol

exotic obsidian
#

anyone know how i can protect my database from sql injection?

eternal oxide
#

use prepared statements

#

validate any text imput

hasty prawn
#

Is that what PreparedStatements are for?

#

I never really understood their specific use-case

eternal oxide
#

yes, it sanitises any values it inserts

hasty prawn
#

Oh, awesome. Learn something new pretty much everytime I click this server

stone sinew
#

So I'm serializing an item to a json string but when I try to parse it back into a json object it errors...

Map<String, Object> serializedItem = i.serialize();
String serializedString = JSONObject.toJSONString(serializedItem);
p.sendMessage(serializedString);

JSONObject objectMap;
try {
    objectMap = (JSONObject) new JSONParser().parse(serializedString);
    ItemStack desearlize = ItemStack.deserialize(objectMap);
    p.getInventory().addItem(desearlize);
} catch (ParseException e) {
    e.printStackTrace();
}

Parsed string:
{"v":2730,"type":"DIAMOND_PICKAXE","meta":UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name=[{"text":"Testing","italic":false,"color":"gold","bold":true}], lore=[[{"text":"","italic":false}], [{"text":"Testing","italic":false,"color":"gray"}]], enchants={DIG_SPEED=5, LOOT_BONUS_BLOCKS=3, DURABILITY=3}, ItemFlags=[HIDE_ENCHANTS, HIDE_UNBREAKABLE], Unbreakable=true, Damage=1560}}

Error:
Unexpected character (U) at position 42.

eternal oxide
lusty cipher
#

For BukkitScheduler#runTaskTimer:
Delay should usually be 0, or what?
Period is in ticks I assume?

#

why would it crash it?

stone sinew
lusty cipher
#

I thought that was the delay for the time after it starts for the first time

#

or similar

#

If my period is 0 that would certainly crash it, no?

eternal oxide
#

you could try that, its just expecting a value or an object

lusty cipher
#

ah, thought so

#

well good

stone sinew
eternal night
#

It's a static method

#

(on the item stack)

slim kernel
stone sinew
eternal oxide
#

Why are you not simply serializing the ItemStack?

stone sinew
eternal oxide
#
ItemStack itemStack = new ItemStack(Material.STONE);
Gson gson = new Gson();
String message = gson.toJson(itemStack);```
lusty cipher
#

when opening up an inventory, can I somehow tell the client not to show the players own inventory?

eternal oxide
#

Not tested but try ```java
Gson gson = new Gson();

//Serialize
String message = gson.toJson(item);

// Deserialize
Map<String, Object> map = gson.fromJson(message, new TypeToken<Map<String, Object>>(){}.getType());
ItemStack is = ItemStack.deserialize(map);```

proud basin
#

for something to be actually drawn on screen the class has to extend GuiScreen correct?

zealous osprey
#

For persistant storing of simple data, is scoreboard or persistentdataholder better ?

stone sinew
eternal oxide
#

sec and I'll test

stone sinew
#

Yeah testing with item.serialize() instead of just item

ivory sleet
#

Why not just use a type token of ItemStack and pass that as the serializer/deserializer

eternal oxide
#

yep

ivory sleet
#

Also use a GsonBuilder where you can pass complex object serializers like a type adapter of ItemMeta

stone sinew
#

So... Map<String, Object> map = gson.fromJson(message, new TypeToken<ItemStack>(){}.getType());?

eternal oxide
#
Gson gson = new Gson();

//Serialize
String message = gson.toJson(drop.serialize());
            
// Deserialize
ItemStack is = gson.fromJson(message, new TypeToken<ItemStack>(){}.getType());```Seems to work
#

at least on a simple object like sand

stone sinew
#

Didn't work for me.
Item testing:
minecraft:give @p diamond_pickaxe{Damage:1560,Unbreakable:1,display:{Name:'[{"text":"Testing","italic":false,"color":"gold","bold":true}]',Lore:['[{"text":"","italic":false}]','[{"text":"Testing","italic":false,"color":"gray"}]']},Enchantments:[{id:efficiency,lvl:5},{id:fortune,lvl:3},{id:unbreaking,lvl:3}],HideFlags:5} 1

eternal oxide
#
[15:51:00] [Server thread/INFO]: ItemStack{SAND x 2}```
stone sinew
#

Oh my bad you're doing ItemStack instead of map. let me try that

torpid vault
#

hi

#

i finish my first plugin

#

in intilej

#

how i can export it

#

to my server files

eternal night
#

are you using maven or gradle ?

torpid vault
#

maven

eternal night
#

open your "maven" tab on the right side of your screen usually

#

find the goal "package"

#

and just double click that

#

intellij should then run the required maven command to package your plugin into a jar

stone sinew
# eternal oxide ```java Gson gson = new Gson(); //Serialize String message = gson.toJson(drop.s...
ItemStack is = gson.fromJson(message, new TypeToken<ItemStack>(){}.getType());```
`Caused by: java.lang.RuntimeException: Unable to invoke no-args constructor for interface org.bukkit.inventory.meta.ItemMeta. Register an InstanceCreator with Gson for this type may fix this problem.`
`Caused by: java.lang.UnsupportedOperationException: Interface can't be instantiated! Interface name: org.bukkit.inventory.meta.ItemMeta`
eternal oxide
#

yep I just tested on a more complex item

stone sinew
#

Yeah so my next test was to just serialize and desearilize the ItemMeta instead of the whole item. But there is no ItemMeta creation method off a string or map. (Deserializer)

#

At this point it looks like I might just have to make my own.

quaint mantle
#

what does the luck enchantment does ?

sour fog
#

Can someone please send an in depth tutorial on how to manipulate and create custom world generation?

timber imp
quaint mantle
#

how the inventory gettype method can produce nullpointerexception ?

stone sinew
quaint mantle
stone sinew
quaint mantle
#

then you didnt clicked on the inventory

stone sinew
quaint mantle
#

bruh

stone sinew
#

Hence... its null

quaint mantle
#

and what is the inventorytype for disenchanter

stone sinew
#

IDK you're gonna have to search for that lol

stone sinew
quaint mantle
#

i have question

#

what pathfinder goal should i set

#

so an entity attacks any player

#

other than you

ivory sleet
#

You probably have to implement a custom one

#

But use the same logic as the normal attack one and target goal, just change it a little bit

#

Like what it may target (:

hasty prawn
#

NearestAttackableTargetGoal takes a Predicate, you should be able to use that to filter out any players you don't want it to attack

quaint mantle
#

i dont know how

cobalt lagoon
#

Is there a specific reason spigot chose not to implement Cancellable for EntityDeathEvent?

ivory sleet
#

A predicate is a function which takes an argument in this case an entity and returns a boolean, basically a function that acts like a filter

quaint mantle
#

what is that in 1.17.1

hasty prawn
#

Well, look at how Mojang does it. That's just how it is with NMS.

They're creating a Goal for this (which in this case is a Zombie), telling it to Attack turtles (Turtle.class), at a random interval of 10, it must see the Turtle but doesn't have to "reach" it (true, false), and the Turtle must be on land. (Turtle.BABY_ON_LAND_SELECTOR is the predicate for "this turtle must be a baby AND on land for the zombie to attack it.) You'd use the Predicate part to filter the player.

ivory sleet
#

You can use the damage event if you wanna cancel a death

cobalt lagoon
#

Ah, so papermc made it pre death?

ivory sleet
#

Presumably

cobalt lagoon
#

thx

hasty prawn
ivory sleet
#

👍

prisma needle
#

Hey guys! How can I check if a chest is part of a double chest, and then get the location of both sides of it? I have already tried casting to a DoubleChest and then using .getLeftSide().getInventory().getLocation() and .getRightSide().getInventory().getLocation() but those always output the same location. Any ideas?

ivory sleet
#

Well Geek the chest has one inventory

prisma needle
#

That is what I figured, but then what is the point in the rightSide and leftSide :P

proud basin
#

clicking types?

ivory sleet
#

Hmm believe the holders still are for the different locations

#

Actually it might be a bug

prisma needle
#

unfortunately, doubleChest.getRightSide().getLocation() doesn't exist...

ivory sleet
#

Yeah

#

And what does DoubleChest#getLocation give you?

prisma needle
#

it gives me the location directly in between both sides

ivory sleet
#

Oh ok

prisma needle
#

so idk mby there is a more manual way of just checking if it's connected to a chest, then checking for direction, and then getting the block shifted by 1

proud basin
#

would you count a DoubleChest as a BlockState?

ivory sleet
prisma needle
#

Ok now the question is, how do I check which direction half a double chest is facing :P

proud basin
#

nvm

prisma needle
#

yeah I have, which is why I figured the rightSide and leftSide should give different locations... but alas

proud basin
#

can you show me how your casting DoubleChest?

prisma needle
#

?paste

undone axleBOT
prisma needle
proud basin
#

instead of if (chest.getInventory().getHolder() instanceof DoubleChest doubleChest) try something like this if (chest.getInventory() instanceof DoubleChestInventory){}

prisma needle
#

:O

#

it worked

#

tysm

proud basin
#

awesome!

prisma needle
#

Another question:

On some occasions I cancel a block break event. However when breaking a double chest half of it looks detached from the other side after the event is canceled until I interact with it again. Is there some solution to this?

hasty prawn
#

How are you breaking it

timber imp
#

how should i fix this?? (there are two symbols that mustn't be here :|

ivory sleet
#

fix your encoding

timber imp
#

how ?

#

i have -Dfile.encoding=UTF-8 it in the start.bat

#

:|

ivory sleet
#

one way is to use ChatColor.COLOR instead of §COLOR

#

in case u use that

timber imp
#

ammm i havent code any plugin for that

#

i happent today

#

it was fixed before

#

:|

ivory sleet
timber imp
#

ok

#

but i have asked it before and no one awnsered :|

#

then ok

sharp kelp
#

OOO command geek

#

real one??

#

the yt

sharp kelp
#

u actual command geek?

#

Anyone who can spoon feed me?

#

I need help in this intializing I dont get it

#

In making a custom items and then afterwards Initializing them

#

can someone help me with it?

ivory sleet
#

be patient, one message suffices

sharp kelp
#

Okay sorry

#

I have to sleep unfortunately but may check any replies

sharp kelp
# ivory sleet be patient, one message suffices

I will just ask and sorry for ping but is asking for spoon feeding allowed here? I got taunted in another plugin development help discord in which because I am not a pro and not even at a level of noob so I didn't got what they meant and when I asked can you edit the code and give me which will help me understand what you meant then they said we wont spoonfeed
So I will ask first

ivory sleet
#

it is allowed but a naive way to solve your problem

sharp kelp
#

Yes It annoys the helpers a little

#

I actually want to learn java only for bukkit api

ivory sleet
#

it will just solve your issue superficially which is the long term problem (spoonfeeding)

sharp kelp
#

so I am starting java along with bukkit api and I came acrosss some other professional devs which did same

ivory sleet
#

yeah

sharp kelp
#

so If I directly ask for code

#

Is it rude and spoon feed?

ivory sleet
#

its not rude but spoonfeed, people will less likely help you

sharp kelp
#

because I thought it makes it easier for both

#

soo okay

#

in another server I asked for help but the person was just saying Initialize Initialize and i didnt get it

ivory sleet
#

it doesnt

sharp kelp
#

Okay thankz

slim kernel
#

I think theres a big difference between spoon feed where you want to get the exact code you need and asking for an example because you can understand the code easier then

sharp kelp
#

I read all basics of java and tried to learn some as well but I did not come across Initialize

sharp kelp
proud basin
#

What don't you understand about initializing

ivory sleet
#

Because if u spoonfeed youll learn scarcely anything, and then you'll come back the next day asking for more, its a continues evil circle

trail flume
#

Hiya. When looping through player.getInventory().getContents() ItemStack is null, do you know why?

sharp kelp
#

While Non spoon feed would be they teach us how to fill up a spoon and put it in our mouths oursellves

sharp kelp
#

can you take a look at my code however and explain what I should do?

#

and what Is initialize

proud basin
#

what code?

sharp kelp
#

Making custom items

proud basin
#

?paste

undone axleBOT
sharp kelp
#

I need to register the recipes

#

Yes kay please wait

trail flume
#

Hiya. When looping through player.getInventory().getContents() ItemStack is null, do you know why?

#

oops

#

didnt mean to send again lol

proud basin
#

How are you using ItemStack?

trail flume
#
public static int getHowMuchPlayerHasOfItem(@NotNull Player p, @NotNull Material material) {
        int count = 0;
        System.out.println(p.getInventory().getContents());
        for (ItemStack itemStack : p.getInventory().getContents()) {
            if (itemStack.getType() == material) {
                count += itemStack.getAmount();
            }
        }

        return count;
    }
sharp kelp
#

I think item stack was for one specific type of item?

#

I am probably wrong nvm...

trail flume
proud basin
#

this? for (ItemStack itemStack : p.getInventory().getContents()) {

sharp kelp
#

as I guessit will be less annoying

trail flume
proud basin
#

I was talking to CCCFan Yassev

#

what is line 5?

trail flume
#
if (itemStack.getType() == material) {
#

This error:

#

java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "itemStack" is null

proud basin
#

well

sharp kelp
#

you need to add a else statement

trail flume
#

no

proud basin
#

you need to put their contents in a itemstack list

trail flume
#

if statements do not require else statements

proud basin
#

oh actually

trail flume
#

I'm looping through the contents

#

It's an ItemStack[]

proud basin
#

let me try something

trail flume
#

kk

ivory sleet
sharp kelp
proud basin
#

yeah I'd put the ItemStacks in a list

trail flume
#

but then it wouldn't even loop

sharp kelp
#

so if we add a else statement saying if its null and then run its specific action wont that work?

trail flume
#

there would be nothing to loop

#

and my inv isnt empty

sharp kelp
#

Oh Hmm I guess I will leave it to pros

proud basin
#

so ItemStack[] inventoryItems = p.getInventory().getContents()

sharp kelp
trail flume
proud basin
#

then you can do for (ItemStack itemStack : inventoryItems) {

sharp kelp
#

Oh I guess you are making this in a util form

trail flume
#

yes

trail flume
sharp kelp
#

Nvm I still dont get it properly I will first learn.

proud basin
#

does the player have a single item?

trail flume
#

yes....

proud basin
#

well

#

try having 2 things of the same thing

trail flume
#

still doesnt work

proud basin
#

ok let me open up my ide

trail flume
#

ok

balmy coyote
#

Hi, any ideas what can be used in order to remove Elytra from End Item Frames?
Like they never generate EVER.

trail flume
#

Turns out I do have to null check ._.
Sometimes I hate the Bukkit API

sharp kelp
#

I also needed that once but dropped the idea to first try basics

sharp kelp
#

I wanted to make a custom item and auto generate it as loot in end and nether forestress

balmy coyote
#

I'm disabling all Vanilla items from Ingame

#

And Elytra it's the last one to go

pliant flame
#

Can spigot detect if you hit middle click if you’re not in creative

onyx shale
sharp kelp
balmy coyote
#

So upon generation obtain all entities in that chunk if instanceof ItemFrame and contains Elytra remove?

sharp kelp
#

Hmm

onyx shale
#

yep

sharp kelp
#

Maybe a event to check any items frames with that item

onyx shale
#

considering the chunk itself has a getEntities inside it

sharp kelp
#

And then get the location of it and break it then use kill item to kill the item in a radius of 2 or 1

balmy coyote
#

I'll try that out just now and see if it gives any results

onyx shale
#

best bet for the generation one

#

if you listen to all item frames you risk deleting ones placed by the player

balmy coyote
#

Yeah i know

sharp kelp
#

Yea but dont you wanna disable the item itself?

balmy coyote
#

No

sharp kelp
#

Oh then I guess my idea is wrong in that case 🙂

balmy coyote
#

It is just removed from it's Vanilla form

#

But exists in Custom form

sharp kelp
#

anyway gn

#

@proud basin I finnally fixed itttt

proud basin
#

fixed what?

sharp kelp
#

Literally going to bathroom refreshes your mind like pressing a refreshing button on a hanged site

#

The error in custom item

#

It was not being registered in recipes

proud basin
#

oh cool

sharp kelp
#

now i can finnaly continueeee

eternal oxide
#

?stash

undone axleBOT
sharp kelp
#

also jtx care to help me tmr with a thirst plugin ?

#

I need some help on variables if you know

proud basin
#

uh

balmy coyote
#

Did they removed the checks if the World == END world? Or i'm just being unable to find it?

sharp kelp
#

i couldnt find any tutorials and any help info

proud basin
#

idk

#

I didn't even help you today

sharp kelp
#

do you know about finallized or yml saved data files?

#

well yea I used 5 - 7 tutorials and stacked em together to fix it

#

tmr I may need help

#

I will need help on making a file like a config file to save player thirst data with uuid

proud basin
#

ok

sharp kelp
#

I will use both uuid as first priority and username as second priority so that it may work on cracked if needed to

#

Gunna be real hard 😦

#

gn...

#

and wrong channel

proud basin
#

use InventoryClickEvent

sharp kelp
#

I think he meant middle clicking a player or block

pliant flame
#

Ye

#

Like not in inventory

#

And which channel should I ask then

proud basin
#

then use PlayerInteractEntityEvent

pliant flame
#

Mk

#

Uh that detects if the player pressed middle click?

proud basin
#

no

#

your gonna have to check for that

tardy delta
#

uwu cuties

golden turret
#

if i get the getClass of an object

#

and the class of a class

#

and use them as key for a map

#

will they be the same?

tardy delta
#

the class of the class wait my brain goes brr

#

you mean obj.getClass() and this.getClass() inside a class?

#

the classes will be the same if obj instanceof getClass()

golden turret
tardy delta
#

its the same

golden turret
#

:D

ivory sleet
#

yes

#

every class has a Class<ClassName> instance which can be used as an identity holder

#

However invoking this.getClass() might at runtime return the Class<? extends ClassName> instance of a subclass

#

hence the extends

naive jolt
#

how do I stop a player from dropping items onDeath

sleek pond
#

Listen to the PlayerDeathEvent and clear the drops

quaint mantle
#

i realy want to know what does this do in worldguard source code so i can change it to a runnable

tardy delta
#

that doesnt makes sense

naive jolt
tardy delta
#

if there is an else sure

naive jolt
#

player.dropItem(false);

#

?

quaint mantle
sleek pond
#

yes

naive jolt
#

oh thanks

quaint mantle
#

you can clear it

#

change it or whatever

#

i used this to edit drops for my plugin

quaint mantle
shadow night
quaint mantle
sleek pond
#

but nothing happens after

#

probably something was there but then it got removed

quaint mantle
#

so

#

its this the code

#

that ruined the server's performance

#

with just 2 regions ?

sleek pond
#

doubt it

unique meteor
#

no

tardy delta
#

why do you even use it?

quaint mantle
#

its in worldguard source code

tardy delta
#

well ok

#

how many Gb do you have allocated on your server?

eternal oxide
#

it should be in every plugin that monitors the move event

quaint mantle
#

it doesnt fully ruin it

#

but when we use spark profiler

quaint mantle
#

the playermoveevent is annoying

tardy delta
#

cant you just check if event.from() != event.to()

sleek pond
#

i think that's a bigger check

eternal oxide
#

much heavier, and no, as that would not early exit

#

it would allow for minor movement including head movements

quaint mantle
#

bruh wait

#

wait

#

it was not only that

#

it had more than it below it

#

eyesight power 100

eternal oxide
#

That code is to optimize the move event and prevent it running when it doesn't need to. That code is perfect.

quaint mantle
#

i know

#

i just

#

didnt see the code below it

#

bruh

lavish hemlock
#

unless block positions are cached, I don't think != would work.

eternal oxide
#

from and to are not block positions, they are Locations, so bad to use them to test, which is why it uses getBlockX etc

tardy delta
worldly ingot
#

Yeah. getFrom() and getTo() are Location instances which aren't rounded. The slightest movement would allow the condition to pass

tardy delta
#

true

worldly ingot
#

Though that method above only cares to call once a whole block position was changed

#

Could call getFrom().getBlock().equals(getTo().getBlock()) but that's then creating an unnecessary CraftBlock middle-man instance just to perform the same comparison

#

So yeah, compare getBlockXYZ()

quaint mantle
#

i have a question about PlayerChangedWorldEvent

#

what is the getFrom method

spice hornet
#

Can someone tell me why this Gradle build file does not work:

...

repositories {
    maven {
        url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'

        content {
            includeGroup 'org.bukkit'
            includeGroup 'org.spigotmc'
        }
    }

    maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
    maven { url = 'https://oss.sonatype.org/content/repositories/central' }
    mavenLocal()
}

dependencies {
    compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT' // The Spigot API with no shadowing. Requires the OSS repo.

    /*
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.0'
     */
}
...
eternal oxide
quaint mantle
eternal oxide
#

Its not cancellable so the action has already taken place.

quaint mantle
#

i want to check the new world

#

that the player just teleported to

#

should i check the player's world ?

eternal oxide
#

the players location is IN the new world

quaint mantle
#

Ok thanks

modest garnet
#

anyone know a plugin which will let me have multiple economys

e.g. Tokens, gems, money

/tokenbal
/gembal
/bal

tardy delta
#

MultiCurrency

#

Let's you create multiple currecies

modest garnet
tardy delta
#

hmm

shadow tide
#

with the PlayerDeathEvent event, is it possible to also get the thing that killed the player, I've looked at the docs and there are no methods to do so.

acoustic widget
#

Hello where can i find a tutorial for create my first plugin based on maven ? Thanks for help

shadow tide
#

everybody say "Bruh" in 3

#

2..

#

1..

#

BRUUUUUH

wintry pumice
#

im playing around with protocol lib, is there a recommended way to debug packets that crash my client when the server sends bad packets

shadow tide
#

looks like there are more helpees than helpers

tardy delta
#

is there an event.getDeathSource()?

shadow tide
#

I've looked at the docs and there are no methods to do so

tardy delta
#

too lazy to open my ide

shadow night
#

bruh, its opening very fast, why not do it

tardy delta
#

intellij

#

no

#

it will load all my files and eat my cpu

shadow night
#

intellij is opening for me like 3 seconds

tardy delta
#

uhh ryzen 5 4000

#

mwoa

#

with some shitty programs opened

shadow night
#

I have intel core i5 8th gen

tardy delta
#

😳

shadow night
#

With minecraft, discord and firefox ran

spice hornet
#

IntelliJ is absolutelty fine in terms of memory consumption

shadow night
tardy delta
#

indexing...

shadow tide
tardy delta
#

analyzing...

shadow night
#

I can write code while indexing 😂

spice hornet
#

That happens once on launch, then you are fine

spice hornet
#

Not even syntax highlight if I'm not wrong

tardy delta
shadow night
#

Yep

#

But you can code, its the main use of an ide

shadow tide
#

bruh

shadow night
#

Put the api key into the config, there no one sees it

tardy delta
#

whats an api key 🤔

eternal oxide
#

there is no safe way to include an API key

shadow night
#

Why would someone see you api key?

#

No one can access the configuration file

young knoll
#

Yes they can?

eternal oxide
#

what? everyone can see a config file

young knoll
#

That is the point of a config

shadow tide
#

exactly

shadow night
#

I don't understand what the holy fuck is going on here

shadow tide
#

bruh

hasty prawn
#

The best way to do it probably would be for the user to get their own API key and give that to your plugin to use.

shadow tide
#

config.yml is accessed by everyone.

hasty prawn
#

They need to pay for it then ¯_(ツ)_/¯

shadow night
#

¯\_(ツ)_/¯

#

Or, you could use something like a password hash for the api key

#

So no one could access it

eternal oxide
#

Can't be done

#

If the key is in your jar it can be read

shadow night
#

Hmm

#

Then don't put it in the jar

eternal oxide
#

It would probably be better to not comment 🙂

tardy delta
#

comment :/

shadow night
#

you could create a own api to access the api key on a secured way idfk

tardy delta
#

encrypt it 🧠

eternal oxide
shadow tide
shadow night
#

I just though, who the fuck would decompile a plugin to get access to an api key

#

No, just don't tell them about the key

#

No one would do it then

eternal oxide
#

Someone will find it. every plugin gets decompiled

shadow tide
shadow night
#

then obfuscate the plugin, add a lot of artifacts. Add fake api keys. Etc.

eternal oxide
#

Safer, but still not safe. at some point the key gets used. It can be read from memory

shadow tide
#

someone will find it then everyone will

shadow night
#

Then just create your own api instead of using the one with the api key

shadow tide
#

THE POINT OF AN API IS SO YOU DON'T HAVE TO DO SOME OF THE WORK DUDE

#

this guy bro

#

just leave the chat

young knoll
#

You can do what Mojang did in 20w14infinite :p

eternal oxide
#

We could probably advise better if we knew what API it is

young knoll
#

They had a string encrypted in the jar

shadow night
#

A api is a programming interface

young knoll
#

A lot of people worked to try and crack it :p

shadow skiff
#

This is supposed to Teleport a player to spawn when they join, anyone have any idea where I have gone wrong?```java
package me.Teric7.PlayerJoinTP;

import java.util.logging.Logger;

import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;

public class PlayerJoinTP extends JavaPlugin implements Listener {
public static PlayerJoinTP plugin;
public final Logger logger = Logger.getLogger("Minecraft");

@Override
public void onDisable() {
    PluginDescriptionFile pdfFile = this.getDescription();
    this.logger.info(pdfFile.getName() + "§cHas Been Disabled");
}

@Override
public void onEnable() {
    PluginDescriptionFile pdfFile = this.getDescription();
    this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion()
            + " §aHas Been Enabled");
}

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
this.getServer().getPluginManager().registerEvents(this, this);
Player player = event.getPlayer();

    double x = 0.50; //This is the spawn coordinates
    double y = 65; //This is the spawn coordinates
    double z = 0.50; //This is the spawn coordinates

    Location spawn = new Location(event.getPlayer().getWorld(), x, y, z); //Spawn location

    player.teleport(spawn); //This should have teleported the player to spawn
    System.out.println("§6§lThis Player Got Teleported To Spawn");
    }
}
undone axleBOT
shadow night
#

It was a float :drunkcat:

shadow skiff
#

alr

shadow tide
shadow skiff
#

not asking for that

#

just asking what's wrong

shadow tide
#

I got told that 1,000,000 times or more

young knoll
#

You can use the damage event

shadow tide
#

yes, but I only want to get it when the player is killed

worldly ingot
#

getKiller() is just the Player that killed them, not any cause

young knoll
#

That is only if a plyer kills them tho

#

ye

shadow tide
#

thanks

eternal oxide
#

choco beat me to it

shadow skiff
#

Ok so this is what I got. From what I can tell it's not actually checking the PlayerJoinEvent or it would've sent a message in console

Code:

 @EventHandler //joinevent
    public void onPlayerJoin(PlayerJoinEvent event) {
     System.out.println("§aJoin Event works?");
         this.getServer().getPluginManager().registerEvents(this, this);
         //scheduler
         getServer().getScheduler().runTaskLater(this, new Runnable() {
             public void run() {
                 Player player = event.getPlayer();
                 
                 
                 double x = 0.50;
                 double y = 65;
                 double z = 0.50;
          
                 Location spawn = new Location(event.getPlayer().getWorld(), x, y, z);
          
                 player.teleport(spawn);
                 System.out.println("§6§lThis Player Got Teleported To Spawn");
             }
         }, 20L);

Console:

[21:35:01 INFO]: Teric7 joined the game
[21:35:01 INFO]: Teric7[/80.233.57.76:10863] logged in with entity id 2164 at ([world]7.143007547713338, 65.0, 10.132142567622157)
shadow tide
#

I don't need the cause so getKiller() is fine

worldly ingot
#

So it's not registered then

eternal oxide
shadow skiff
#

ah xD

worldly ingot
#

lol didn't even notice that

young knoll
#

UUID

shadow tide
#

I need to add an attribute to a player without them holding an item or anything like that, I am pretty certain this is possible because you can do it ingame with commands

worldly ingot
#

equals(). Unless you know the difference between == and equals() (which I highly advise reading about, great information on when and when not to use it), you should be using equals() because it at least defaults to ==

spice hornet
#

Can someone tell me how the Event API works under the hood? How is it possible for the event managing class to call MyListener.onPlayerDeath(PlayerDeathEvent) without having that method signature declared anywhere? It is not declared in the Listener interface nor anywhere else where I can see.

spice hornet
#

Is this some reflection action or how does it work?

worldly ingot
#

Yes, reflection

#

When registered it filters through methods in the class, checks if it's annotated and gets the first argument in the method. Registers it to the appropriate HandlerList and calls them reflectively

young knoll
#

Spigot gets all the methods annotated with @EventHandler and reflectively invokes them

spice hornet
#

Ah yes, so basically checking using reflection what the signature is and what arguments it takes and based on that call the method? Why go with that complicated route?

#

Or is there some benefit from that that I don't see?

solar sable
#

i have an error in my plugin testing but do i send it here?

shadow tide
worldly ingot
#

There's no other good route tbh

young knoll
#

Consumers

worldly ingot
#

I just linked it to you ;p

shadow tide
#

where

young knoll
#

I use something like that for my event manager

worldly ingot
#

The link in my message to which you replied

#

That is the attribute API

shadow tide
#

ik

worldly ingot
#

entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).addModifier(AttributeModifier)

#

Or setBaseValue(), but you're best to add a modifier

young knoll
#
    public void register(Plugin plugin, EventPriority priority) {
        Bukkit.getPluginManager().registerEvent(this.eventClass, this, priority, this, plugin);
    }
shadow tide
#

yeah, I tried that before I asked the question. getAttribute() isn't a method for my entity.

worldly ingot
#

In what version?

#

Those attribute APIs were added in like 1.10 or something

hasty prawn
#

Are Attributes persistent ?

worldly ingot
#

Yes

shadow tide
#

1.17.1 lol

#

idk

hasty prawn
worldly ingot
#

Well if you have just an Entity, you're not going to have them. Entity itself doesn't implement Attributable

quaint mantle
#

How to make .db file in plugin folder

worldly ingot
#

You'll have to instanceof and cast accordingly

young knoll
#

I don't think entity has it

#

Only living

spice hornet
shadow tide
#

lol

young knoll
worldly ingot
#

because then it would break between versions if we ever needed to add new events (which we do all the time)

#

You have to implement all methods in an interface

spice hornet
#

Ah yes that makes a lot of sense

#

Wait yes true

#

An abstract class would do then, no?

winter sand
#

I'm trying to send an offline player (I mean in another server connected in the same bungeecord) to a Bungeecord server in a Spigot plugin. I found that I can do it with online players with player.sendPluginMessage, but how do i do with an offline one?

quaint mantle
young knoll
#

Yes

worldly ingot
#

There's also the hassle of having to determine how events are listened. How does it ignore cancelled events? How does it set its listening priority?

quaint mantle
#

I need a way to make local db

young knoll
#

SQLite

quaint mantle
#

I tried mysql but didnt work

young knoll
#

MySQL isn't local

quaint mantle
#

So SQLite?

spice hornet
#

Try SQLite

quaint mantle
#

Okay thanks

spice hornet
#

Yeah, it's fine imo.

spice hornet
#

I have not worked with reflection yet so it's like a black magic box for me and hard to comprehend

worldly ingot
# winter sand is there a way to do it?

You have a couple options. Handle this with a BungeeCord plugin so you can communicate with it, or use something like Redis pub/sub (imo the better option)

young knoll
#

Something about every problem being a nail when all you have is a hammer

winter sand
worldly ingot
#

Redis can save your ass a lot in the future. It's a nice way to mimic packets

shadow tide
#

In an attribute modifier their are 3 operations, ADD_NUMBER, ADD_SCALAR, and MULTIPLY_SCALAR. is there a way to subtract a number? I need to lower the player's max health by 1

worldly ingot
#

ADD_SCALAR with a negative amount ;p

shadow tide
#

k

worldly ingot
#

Actually it might be ADD_NUMBER. I don't remember. One of them adds 1 I think by default

shadow tide
#

U usually use ADD_NUMBER, idk what ADD_SCALAR does

winter sand
worldly ingot
#

Yeah, it's NUMBER

shadow tide
#

what does ADD_SCALAR do?

worldly ingot
#

Plugin channels work fine and are a viable options. Though it may suffer the same issues because plugin channels are player <--> server communciation

#

You still need a player

#

Honestly, don't know the different CJ

shadow tide
#

lol

winter sand
shadow tide
#

also, thanks for calling me CJ, thats my nickname IRL lol

worldly ingot
winter sand
slim kernel
shadow tide
#

What do you put in the addModifier method?

shadow tide
#

and, yes I looked at the docs

eternal oxide
#

an AttributeModifier.Operation

#
.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier("extra_damage", 10, AttributeModifier.Operation.ADD_NUMBER));```
#

an example

winged ridge
echo basalt
#

call file.getParentFile().mkdirs();

#

To create the folder

winged ridge
#

works but now no data is being written to the file

#
FileConfiguration userconfig = YamlConfiguration.loadConfiguration(userfile);
                        userconfig.set("path.to.key", false);

                        try {
                            userconfig.save(userfile);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }``` 
code to write to file
echo basalt
#

You gotta write the content

winged ridge
torn oyster
#

how do i check what the current weather is

#

like if it is storming

#

raining

#

or clear

proud basin
#

Bukkit.getWorlds().get(0).hasStorm();

waxen plinth
#

You're probably trying to remove while iterating

#

Can you show the full code

#

You can use removeIf

#

Otherwise you could construct a second list of items to remove and then use removeAll

#

Removing from within an enhanced for loop also will not work

golden turret
#

or you can remove while using iterator

plain scroll
#

how can i stop all them numbers from appring? [ Ping me ]

limber jackal
#

@plain scroll round it when you are converting from float/double to string

plain scroll
#

im adding it like this

#

nvm

#

i think i did it

#

anyone know why this wont lock the item in place? It works for all my other items in the gui

#

^^ fixed

young knoll
#

So is there a good way to force a block update? setType doesn't update the block itself, only the blocks around it. Block.getState.update doesn't appear to work either

ivory sleet
#

Isn’t there like a tick function?

young knoll
#

Not sure?

#

Don't see anything on the javadocs

#

I'm surprised setBlockData doesn't cause an update

golden turret
young knoll
#

String.format is probably the easiest

worldly ingot
#

Or if you want to be really fancy, just cast it to an int lol

#

The truncation of that value is not at all significant

young knoll
#

But what if I want some decimals

quaint mantle
#

cast to float

worldly ingot
#

In effect it's a whole number. 20 half hearts

#

Anything in between that should be considered insignificant for front-facing strings

#

Minecraft renders by truncating that value anyways

quaint mantle
#

why does java return .000000000000000001 sometimes

young knoll
#

Floating point precision errors

worldly ingot
#

Pretty interesting topic tbh

#

Best example I can give. What's 1/3 + 1/3 + 1/3. It's 3/3, right? But how do you represent an infinitely repeating number using bits? You can't represent 0.33333333 forever, it has to stop somewhere. So if you add 0.33333333 + 0.33333333 + 0.33333333, you get 0.99999999

#

Boom, floating point precision

#

I think standard precision is 23 decimal places, though I could be off by like 1 or 2

young knoll
#

And this is why you should always round your numbers if you are showing them to the user

quaint mantle
#

intellij, fix

worldly ingot
#

I've noticed Eclipse doing that recently too. Usually just an F5 fixes it

quaint mantle
#

thanks

worldly ingot
#

haha I dunno why it's doing that. Only started a few months ago

young knoll
#

Yeah mine does it randomly too

torn oyster
#

compactedWheatRecipe.addIngredient(new ItemStack(Material.WHEAT, 64));

#

why is that throwing error

#

java.lang.IllegalArgumentException: Shapeless recipes cannot have more than 9 ingredients

quaint mantle
#

tells you

torn oyster
#

i want u to have to use 64 wheat to make it

quaint mantle
#

use the recipe event

torn oyster
#

i want this to make it

quaint mantle
#

use the recipe event

torn oyster
#

but i am 99% sure there is a way to do it with recipes

#

nvm did it