#help-development

1 messages · Page 1905 of 1

boreal sparrow
#

except no becuase the variable is already defines in scope

vernal pier
#

send your code

#

do you know how to iterate?

chrome beacon
boreal sparrow
#

List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
Player hunter = players.remove(new Random().nextInt(players.size()));
hunter.teleport(new Location(Bukkit.getWorld("Game2"), -9.5, 75, -4.5));
for(List<Player>; help me here what do i do here pls) {
player.teleport(new Location(Bukkit.getWorld("Game2"), 0, 65, 0));
}
(sad code noises)

young knoll
#

You continue if the player is not the hunter

boreal sparrow
#

yea forgot to remove

young knoll
#

So you only teleport the hunter in your loop

vernal pier
#

just loop through the players and teleport each one

#

no need for the check since the hunter is not in the new list

boreal sparrow
#

yes

#

but every time

#

i get Variable already defined in scope when i just try to use it in my for loop

vernal pier
#
        Player hunter = players.remove(new Random().nextInt(players.size()));
        for (Player player : players)
            player.teleport();```
boreal sparrow
#

hmm thnx ill try that

#

VARIABLE ALREADY DEFINED IN SCOPE

#

i have decided

#

that i want to die

vernal pier
boreal sparrow
#

ok sure

#

parameter is never used

vernal pier
#

can you screenshot the error

boreal sparrow
#

cant send screens

#

in this server

#

who decided this

young knoll
#

Verify

boreal sparrow
#

big brain time

#

i have this:
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
Player hunter = players.remove(new Random().nextInt(players.size()));

i can tp the hunter
how do i tp the players that are in the list

#

if i do this:

for (Player player : players){
player.teleport(new Location(Bukkit.getWorld("Game2"), 0, 65, 0))
}

the word "player" in the for loop gets an error variable already defines in scope

young knoll
#

So give it a different name

boreal sparrow
#

no way

#

i swear

#

ok now it says var never used is that ok

young knoll
#

Did you rename the other usages of it?

boreal sparrow
#

wdym

young knoll
#

You use player twice in the snippet of code you sent

#

And you only renamed one

boreal sparrow
#

yea

#

if i rename those then i get var already defined in scope

#

so im kinda stuck now

snow crow
#

hello coll

#

back again

#

with

#

A Lang error i cant fix ;-;

boreal sparrow
#

List<Player> lala = new ArrayList<>(Bukkit.getOnlinePlayers());
Player hunter = lala.remove(new Random().nextInt(lala.size()));
Random rand = new Random();

for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {

hunter.teleport(new Location(Bukkit.getWorld("Game2"), -9.5, 75, -4.5));

for (Player chingchang : lala){
     player.teleport(new Location(Bukkit.getWorld("Game2"), 0, 65, 0));
 }

gonna try this

snow crow
#

can someone help me with my plugin dm

manic furnace
#

How can i make a API for my Plugin so that other plugins can communucate with my Plugin?

quaint mantle
#

Create a separate module and write interfaces to interact with your plugin

#

in plugin module, implement those interfaces

manic furnace
#

Is there a Tutorial how to so that?

lost matrix
ivory sleet
#

^ you want your api to be simple above all the complex details your plugin operates on

boreal sparrow
#

does this select a random player out of online?
List<Player> lala = new ArrayList<>(Bukkit.getOnlinePlayers());
Player hunter = lala.remove(new Random().nextInt(lala.size()));

icy beacon
#

why do you remove?

boreal sparrow
#

hmm it doesnt look like its working

#

always selects the same guy
or its just super lucky

icy beacon
#

do you have more than 1 player online

boreal sparrow
#

yeaa

#

but

#

wait

#

my friend is pulling this stunt where he is running 2 instances of mc at the same time, and hes in hypixel in the other instance

#

yea and i cant tp him

#

propobly that lmao

lost matrix
boreal sparrow
#

but i cant execute anything on him

lost matrix
#

On your server?

lost matrix
boreal sparrow
#

yea cant tp him (his character just doesnt appear) but i can kick/ban him etc. hes just not rendered (becuase his in another server and mine at the same time)

lost matrix
#

Oh i see. He uses the same account for both servers.

young knoll
#

That’s not how that works

lost matrix
#

How is he even able to join then?

young knoll
#

You can join as many servers as you want at once

lost matrix
#

til

young knoll
#

Just can’t join the same server twice

snow crow
lost matrix
snow crow
#

17:28:02] [Server thread/ERROR]: Error occurred while enabling EnderRider v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "String.replace(java.lang.CharSequence, java.lang.CharSequence)" because the return value of "org.bukkit.configuration.file.FileConfiguration.getString(String)" is null
at enderrider.enderrider.utils.Lang.loadLang(Lang.java:23) ~[?:?]
at enderrider.enderrider.Main.onEnable(Main.java:56) ~[?:?]

lost matrix
#

Main.class line 56
Send that pls

snow crow
#

sec

young knoll
#

Blah now I’m second guessing turning all my data instinct strings for storage

lost matrix
# snow crow sec

And pls make sure this time (and this is important)
that the version you are shwoing matches the version installed on the server. 1:1
No fiddling with your code while you track down an error!

snow crow
lost matrix
# snow crow

Pls compile this exact code and run it again. Then show the stack trace.

#

And the full stack trace this time pls.

snow crow
#

ok

#

so i have run this in the mc server again.

#

ok

#

?paste

undone axleBOT
lost matrix
#

Ok then show the loadLang() method pls

snow crow
#

ok

boreal sparrow
#

if i do this hunter.getInventory().addItem(Material.BOW);
then i get cannot resolve method

young knoll
#

Because there is no method to add a material to an inventory

lost matrix
#

tbf the stack trace is really conclusive.
return value of "org.bukkit.configuration.file.FileConfiguration.getString(String)" is null
Just means you call getString(String) somewhere and it returns null.

snow crow
boreal sparrow
#

oh do i add it with: public enum Material implements org.bukkit.Keyed

#

its what error tells me to do

lost matrix
lost matrix
snow crow
boreal sparrow
#

hmm how do i implement or use the additem get inventory thing

lost matrix
# snow crow

Your keys are as follows:
"Lang "
"EnderPeralName "
"CoolDownTime "
Notice the space character at the end of each line + the spelling error in Pearl

lost matrix
boreal sparrow
#

ok

#

any way to enchant the item?

young shell
#

Is there a way to get the NMS Dependency into a private Maven Repository?

lost matrix
young shell
young shell
lost matrix
lost matrix
young shell
#

Since it's snapshots uploading won't work. I need to run it through mvn deploy, but I don't know which module and so on I need to use

snow crow
#

smile the same error again

lost matrix
lost matrix
#

Show me the plugin.yml in your plugins folder

snow crow
gritty urchin
#

hey

#

How can I add a new String

#

to a config file

lost matrix
#

sry

gritty urchin
#

lets say I have a config

lost matrix
exotic obsidian
#

hello

gritty urchin
#

claims:

#

how do I add a new child String

#

to it

exotic obsidian
#

how i can create top 5?

gritty urchin
#

Like this

lost matrix
gritty urchin
#

claims
"claim-1"

lost matrix
gritty urchin
#

to a String value

lost matrix
#
config.setString("claims.claim-1", "Something");
gritty urchin
#

yeah but "claim-1"

#

doesnt exist yet

#

I want to create it

#

in the config

lost matrix
#

Write it in the FileConfiguration then save it to a File.

gritty urchin
young knoll
#

Iirc setString doesn’t exist

gritty urchin
#

to an existing FileConfiguration

young knoll
#

It’s just set

snow crow
gritty urchin
lost matrix
young knoll
#

Setting a key that doesn’t exist will create it

gritty urchin
#

Ah great

lost matrix
# snow crow

Nope. In your plugins folder on the file system. Not the one inside your jar. You need to remove the old one.

young knoll
snow crow
lost matrix
quaint mantle
#

Its a choice between efficiency and simplicity

lost matrix
#

And modularity. Because using json Strings also enables you to simply store the data in Flatfiles or a DocumentDB like Mongo

quaint mantle
young knoll
#

Does that matter much

quaint mantle
#

with proper design you can take an advantage of relational dbs even with flat-file and mongo. On last 2 variants, it is not ging to be that efficient though

quaint mantle
young knoll
#

Yeah I don’t really need any complex queries

lost matrix
#

For me it never mattered

young knoll
#

It just feels wrong

#

Even if it saves me writing a whole bunch of classes to handle properly transforming data into tables

quaint mantle
lost matrix
#

Just dont bother using relational DBs then 🤷

quaint mantle
#

There's no way back

#

now i think that mongo is inefficient

lost matrix
quaint mantle
#

non-relational

snow crow
#

smile

young knoll
#

I mean the data isn’t really relational

#

But SQLite is convenient, and most shared hosts offer MySQL

spiral light
#

just create your own database :p

lost matrix
# snow crow smile

Your config.getString returns null. Make sure the keys match 100%. Thats all you need to do.

lost matrix
young knoll
#

Would it be a blob or a text column

quaint mantle
#

JSON data type

spiral light
#

json is nice to read but not efficient ^^

young knoll
#

Does that provide any advantage over just text

snow crow
spiral light
#

easy to read with api stuff ... just text is a bit different

lost matrix
young knoll
#

Neat

#

I did plan to simplify the storage of some stuff to non-json strings, but this may make me re-consider

dusk vigil
#

hello set block wheat ?

spiral light
dusk vigil
#

what is do ?

spiral light
#

yes

dusk vigil
#

how to

#

?

#

example code ?

spiral light
#

block.setType(Material.CROPS)

dusk vigil
#

pls

spiral light
#

or SEED

#

or WHEAT

dusk vigil
#

Not working

spiral light
#

what exactly is not working ?

snow crow
#

hmmmmm

spiral light
#

doesnt make rly sense ^^

snow crow
#

did removed them

#

now

#

and again the replace is saying to add a notnull parameter

#

ahhh getstring is nullable

mint quiver
#

hi,
i tried creating a ftp client connection in plugin but im getting an error

#
[19:24:40 WARN]: Unexpected exception while parsing console command "startup-b"                                         org.bukkit.command.CommandException: Unhandled exception executing command 'startup-b' in plugin icecube v1.0.1                 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]              at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]          
#

it was big but these are first few lines of error

snow crow
#

?paste

undone axleBOT
spiral light
#

send full eror via paste ^^

mint quiver
#

ok

snow crow
mint quiver
#

i have also added the lib jar in project structure artifacts

#

still not working

snow crow
trim creek
#

How can I check if an argument (a player) is set?

mint quiver
drowsy helm
#

check if its null

young knoll
#

What argument are we talking about

#

Command?

trim creek
#

Yes.

#

I want to check if the args[1] is set, but I cannot find any method.

young knoll
#

args.length >= 2

trim creek
#

Or if I can find any, then the whole command without any arguemtns are dead

snow crow
#

xyz.squeek.icecubesmp.plugin_cmds.backup_cmd.onCommand(backup_cmd.java:28)

trim creek
# young knoll args.length >= 2
Caused by: java.lang.ClassCastException: class com.destroystokyo.paper.console.TerminalConsoleCommandSender cannot be ca
st to class org.bukkit.entity.Player (com.destroystokyo.paper.console.TerminalConsoleCommandSender and org.bukkit.entity
.Player are in unnamed module of loader java.net.URLClassLoader @484b61fc)
young knoll
#

So you want to check if the command sender is a player

#

Nothing to do with arguments

trim creek
#

It is not checked, but I will also do it.

#

The thing that is checked at this time is the permission

trim creek
#

(aka the console will also be able to run the command)

mint quiver
#

i cannot see any error in ide

young knoll
#

Then don’t cast sender to player

#

Console is not a player

snow crow
trim creek
#

Umm

#

Then probably there is the error:

        Player a = (Player) sender;
        Player v = Bukkit.getPlayer(args[1]);
mint quiver
snow crow
#

the stack trace shows line 28

trim creek
#

AdminCommand.onCommand(AdminCommand.java:15) - little console log :3

#

I cannot cast a as the admin. 😆

mint quiver
#

yes but i didnt understood , its just FTPClient ftpClient = new FTPClient(); i am unable to find anything

young knoll
#

You can’t cast sender to player if sender isn’t a player

trim creek
#

I know. The console has shown that I currently cannot use the line Player a = (Player) sender;, because it is unused.

#

I just removed this line (which was the 15th line), and now it works.

#

Thank you for your help! 😄

snow crow
#

also

#

FTPClient ftp = new FTPClient();

#

@mint quiver

#

try this hmm

mint quiver
#

ok

gritty urchin
#

doesnt seem to work

young knoll
#

Did you save the config after

#

Or whatever yml file it was

gritty urchin
#

yeah

#

it does set it

#

but it just sets the value

#

doesn't create a new child String

#

e.g.

#

claims: "claim-1"

#

and not

#

claims: "claim-1"

#

like I want

analog prairie
#

The player has 3 groups of the same and the same number of items, when I use player.getInventory().remove, all three groups will disappear

young knoll
analog prairie
#

How do I refer to remove a group

young knoll
#

You need to pass a List<String> to .set

gritty urchin
#

yeah but I don't want to create a list

#

I just want a child key

analog prairie
#

?jd

young knoll
#

You can’t have an empty child key

#

It’s needs a value of some sort

gritty urchin
#

yeah

#

it does

#

but I want to create an initial child key

#
  "claim-1":
    type: 1
    location: world,x,y,z```
#

like this

#

How would I do that?

#

@young knoll

brittle cipher
#

I have my own server in aternos with spigot/paperbucket but whenever I add my username in ops list and when I join the server but I didn't get op perms what should I do now?

visual tide
#

not use aternos

#

for a start

lyric oar
#

Hello, how can i get blocks that are next to a block please ?

#

next to the 6 faces

analog prairie
#

The player has 3 groups of the same and the same number of items, when I use player.getInventory().remove, all three groups will disappear
How do I refer to remove a group?

brittle cipher
young knoll
snow crow
#

this.getCommand("getpearl").setExecutor(new givePearl());

#

setexecutor leads to a NPE

opal juniper
opal juniper
snow crow
young knoll
#

If a command isn’t in your plugin.yml getCommand will return null

opal juniper
#

what coll said

young knoll
#

Plugin

thorny python
#

how can I get the current server name (bungee) in spigot plugin event

pastel mauve
#

hey, i have a problem with connecting 2 plugins with eachother :/ I only know how to set a variable of another plugin but not how to call a method:

Plugin 1 accessing Plugin 2:

Plugin plugin = Bukkit.getPluginManager().getPlugin("SahneBuildings");
try {
    Field field = plugin.getClass().getField("a");
    field.setAccessible(true);
    field.set(plugin.getClass(), 1);
} catch (NoSuchFieldException | IllegalAccessException e) {
    e.printStackTrace();
}```

Plugin 2:
```Java
public static int a = 0;

public static void testMethod() {
  Bukkit.broadcastMessage("yooo");
}```

I just want to call "testMethod()" 🙂 I appreciate your help 😄
snow crow
boreal sparrow
#

what is the hungerdepletion event?

spiral light
#

PlayerFoodLevelChangeEvent

#

gets called for adding or losing food ^^

boreal sparrow
#

Ty ^^

snow crow
#

something like that?

young knoll
#

no

#

Look at the wiki page for plugin.yml format

mint quiver
quaint mantle
snow crow
#

whts the new error?

mint quiver
#

same as before

#

;-;

snow crow
#

hmm

#

friend me

mint quiver
#

:D. done

boreal sparrow
#

any way to keep player sprint forever (they dont run out of hunger) but dont regen health

loud grove
#

Hello, on 1.8 move an armorstand spawned with packets with setVelocity does not work
how can I move an armorstand from a point A to B smooth
tx 🙂

thorny python
#

teleport

quaint mantle
#

Wht packets

loud grove
thorny python
#

you can do it with packet

#

EntityTeleportPacket iirc

#

or something similar

quaint mantle
#

Why do you use packets

loud grove
#

yes i found it

quaint mantle
#

There's a packet for velocity as well

thorny python
#

probably because want to avoid server side entity

loud grove
restive tangle
#
        when(item){
            ItemManager.unranked -> {
                val inventory = UnrankedInventory()
                player.openInventory(inventory.inventory)
            }

            ItemManager.ranked -> {
                val inventory = RankedInventory()
                player.openInventory(inventory.inventory)
            }
        }

This is a snippet from my PlayerInteractEvent and it works fine (Kotlin), The only problem is it would start getting bloated once I keep adding item events, Is there a better way to do this which won't bloat the class?

loud grove
#

but it does not work :/

thorny python
#

I think velocity may not work for dummy entity

#

because position calculation is serverside

#

wdym keep adding item events

loud grove
#

@thorny python according to wiki.vg, the teleport packet is only for moving entity more than 8 blocks..

restive tangle
#

When they right click, The items do things

thorny python
loud grove
#

let's try 🙂

thorny python
quaint mantle
#

Entity Move packet?

restive tangle
#

No, I just want to make it more dynamic so the class won't get too bloated if I add many items that I want to trigger certain events with

thorny python
#

hm

#

sound like you may use factory?

restive tangle
#

What?

thorny python
#

factory pattern, or command pattern (I feel they are similar sometimes)

loud grove
# thorny python then you may check what packet will be used within 8 blocks...but I think it wil...

it's not working. I must say too that it's in a task

public void run() {
  firstVector = armorStand.getLocation().toVector();
   destination = armorStand.getLocation().add(0, 3, 0).toVector();
   move = destination.subtract(firstVector);
   PacketPlayOutEntityTeleport teleport = new PacketPlayOutEntityTeleport(armorStand.getEntity().getId(),
                    move.getBlockX(), move.getBlockY(), move.getBlockZ(), (byte)0, (byte)0, false);
            ((CraftPlayer)player).getHandle().playerConnection.sendPacket(teleport);
}
restive tangle
#

I don't know what you mean by that

thorny python
#

so you keep a map which map a ItemStack to a 'Handler' object

quaint mantle
#

ItemStack maps are not going to work well

#

Use PDC instead

thorny python
#

I just give an example

#

xd

#

ya but you need a workaround

restive tangle
#

Hm

thorny python
#

so you try to get handler object from a ItemStack

#

if the map give you nothing, you dont do anything; if you get a handler object, handler will run the code it should run correspond to that ItemStack

restive tangle
#

Hm, So like a consumer?

thorny python
#

ya that's it

#

I was doing something similar before

#

about map an ItemStack to certain object (e.g. String or Consumer)

#

so I keep a Map<Material, List<Tuple<ItemStack,TargetType>>>

#

for any given ItemStack, it get List<Tuple<ItemStack,TargetType>> according to item Material

#

then iterate over the bucket to attempt find the right Tuple<ItemStack,TargetType> via isSimilar() in ItemStack

boreal sparrow
#

a

thorny python
#

if one tuple return true in isSimilar(), you can use the second value in the tuple (TargetType)

quaint mantle
#

Lol just use pdc

#

Much cleaner and faster

restive tangle
#

Can't I just have a Map which stores the ItemStack and a Consumer that takes a player?

thorny python
#

uh what's that

quaint mantle
#

Persistent Data Container

thorny python
#

oh

eternal oxide
#

?pdc

thorny python
#

sometime that's an option

restive tangle
#

Are you telling me store the PDC in the map instead?

thorny python
#

but I need to map an arbitrary minecraft ItemStack to other object

quaint mantle
#

No. Give a consumer some key, and store the key in pdx

#

The get the key from pdc, and retrieve the consumer from map

thorny python
#

such as minecraft:potato

rich inlet
#

How do I increment a value in a config by 1, because:
config.set("path.to.something", config.getInt("path.to.something") + 1);
doesn't work, it always says the value of "path.to.something" is 0, and increases then to 1. but the next time I run this, it is 0 again

#

(I save the config afterwards)

boreal sparrow
#

hey guys i get 2 of each item, with no enchants, any ideas?

hunter.teleport(new Location(Bukkit.getWorld("world"), -9.5, 75, -4.5));
ItemStack bow = new ItemStack(Material.BOW, 1);
ItemStack arrow = new ItemStack(Material.ARROW, 1);
ItemMeta bowmeta = bow.getItemMeta();
bowmeta.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
bowmeta.addEnchant(Enchantment.ARROW_KNOCKBACK, 1, true);
bowmeta.addEnchant(Enchantment.DURABILITY, 3, true);

hunter.getInventory().addItem(bow);
hunter.getInventory().addItem(arrow);

spiral light
#

you dont set the itemmeta to the itemstack again

boreal sparrow
#

oo

spiral light
boreal sparrow
#

how do i do that lmao

spiral light
#

?paste

undone axleBOT
spiral light
spiral light
#

there you can see what the ItemMeta is and that you need setItemMeta after changing stuff

boreal sparrow
#

hm ok ty

#

what do you mean how lmao lemme check docs

#

how do i set itemeta bacc to itemstack

thorny python
boreal sparrow
#

oh

#

how

thorny python
#

uh

loud haven
#

Bro

thorny python
#

bow.setItemMeta(bowmeta);

boreal sparrow
#

ty ^^

thorny python
#

._.

boreal sparrow
#

._.

snow crow
#

@spiral light @lost matrix @young knoll Srry For Ping But The Plugin Finally works without errors tysm for your help guys

spiral light
#

i dont know what i did O.o

spiral light
boreal sparrow
#

how clear inventory

thorny python
#

player.getInventory().clear() maybe

boreal sparrow
#

ty

rich inlet
restive tangle
#

Get their inventory and then use the clear method

thorny python
#

btw any good approach to get current spigot server (bungee) name in spigot plugin?

snow crow
#

hell no i got exicted earlier ;-;

#

now it stopped working ahhhh

spiral light
spiral light
rich inlet
spiral light
#

the problem is getFile and saveCustom ...

gritty urchin
#

Hey

#

how do I get the next key

#

for a yml file

rich inlet
thorny python
#

you cannot get next key

gritty urchin
#

because atm

thorny python
#

well

gritty urchin
#

there is a method

thorny python
#

do getKeys(false)

rich inlet
gritty urchin
#

but that does not get

thorny python
#

match the first one equals your current key then take next

gritty urchin
#

the next key

#

it returns the key itself

#

for instance

#

claims: claim1: claim2: claim3:

#

I want to get all of the child keys

#

but it just returns "claims"

spiral light
thorny python
#

uh

rich inlet
spiral light
#

did you test it ?

thorny python
gritty urchin
#

yeah but I just want to get the first

#

children keys

#

there are multiple keys for those children keys

thorny python
#

._.

spiral light
#

@rich inlet i rly dont think its the config file you want.

thorny python
#

so can you give a better example?

gritty urchin
thorny python
#

what's your input and what's your expected output

#

yes

rich inlet
spiral light
#

did you use git add correctly ?

gritty urchin
spiral light
gritty urchin
#

child keys specifically

#

for just one key

#

claims: claim1: claim2: claim3:

#

so like this

spiral light
#

well to upload to github (by using commands) you need to add files ^^

rich inlet
gritty urchin
#

thanks for the help

thorny python
#

ok

spiral light
loud haven
#

@gritty urchin just use getKeys(true), iterate through them and check if the key contains the string "claim". If not, skip the key. Then when it finds one, do some more stuff to get the number from the key.

gritty urchin
#

thanks tho

vast shale
#

Has anyone had any luck with creating a custom snowball model to make it look like the player is throwing something like a cupcake model assigned to the snowball?

real merlin
#

Questions about protocollib?

quaint mantle
#

?

vast shale
#

Could I use that to accomplish this?

lyric oar
#

hey

quaint mantle
lyric oar
#

how can i break a big amount of blocks? Sometimes i have like 600 blocks to break and when i iterate over my arraylist of blocks and then break naturally them the server directly crash

thorny python
#

um I dont think 600 blocks is large enough to crash the server

spiral light
#

?paste

undone axleBOT
vast shale
quaint mantle
#

Yes

thorny python
#

vanilla /fill can do 4k blocks iirc

quaint mantle
#

32k blocks actually

lyric oar
thorny python
#

oh probably im outdated

quaint mantle
#

are you doing it async

lyric oar
#

i don't think

thorny python
#

ConcurrentModificationException sound like you trying to remove something on list while iterate it?

lyric oar
#

but i don't know how to break blocks asynchronously

lyric oar
thorny python
#

may you show your code? sound like a fixable problem

hybrid spoke
#

you are trying to remove a block which is used on the main thread at the same time

#

á ConcurrentModificationException

lyric oar
#
for(Block b : blocks) {
                b.breakNaturally();
            }
#

that's my code

thorny python
#

where is blocks come from

lyric oar
#
private ArrayList<Block> blocks = new ArrayList<>();
#

from this

spiral light
#

ok ... i dont understand what your doing xD

normally you can just use:
git status
git add *
git commit -m "random"
git push

thorny python
#

un looks good; does the exception been thrown from b.breakNaturally()?

spiral light
#

i cant help you with what your doing

lyric oar
#

the error is:

java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1445)
    at java.util.HashMap$KeyIterator.next(HashMap.java:1469)
    at net.minecraft.entity.EntityTracker.func_72788_a(EntityTracker.java:293)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:910)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:461)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:778)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:624)
    at java.lang.Thread.run(Thread.java:748)
quaint mantle
lyric oar
#

To break trees. I made some code that search all woods and leaves blocks that are next to them and then stores the block in the arraylist

thorny python
#

where are you run this code?

lyric oar
#

wdym?

thorny python
#

so is this code been triggered by some event?

lyric oar
#

yes, BlockBreakEvent

#

and to try to remove the crash i even tried to run it in a new thread

thorny python
#

I dont think run in a new thread fix it

lyric oar
#

you're right

#

it doesn't fix

tardy delta
#

Removing stuff while looping over a collection?

thorny python
#

you may print something to console while running your code

lyric oar
#

wait a min

#

yea maybe it's because the blocks are stored in the arraylist while it is break?

thorny python
#

it may potentially because when you do breakNaturally() it fire another new BlockBreakEvent again

lyric oar
#

ah

#

hm

thorny python
#

idk

lyric oar
#

well, no

#

because i check if the player have an axe

thorny python
#

uh

#

I am probably going to quickly look into nms xd

vast shale
# quaint mantle Yes

Custom model on the snowball doesn't seem to work. Just getting the missing block texture on it

lyric oar
#

looks like the problem wasn't what i think

thorny python
#

what's your spigot version?

lyric oar
#

1.12.2 and i just found the problem

#

the problem was the new thread

thorny python
#

._. I feel like someone already asked you if you are doing it in async

lyric oar
#

before the bug i wasn't

#

so i was a bit confused

#

because if i break a little amount of block asynchronously everything is fine so i though it wasn't the problem 🤷

#

thanks for helping

#

i have just a last question, will breaking a big amount of block without async freeze my server?

thorny python
#

concurrent exception come in chance; the longer time it take to process the higher chance it will happen

#

WE have async version to edit world iirc

eternal oxide
thorny python
#

not sure how the magic happen anyway

lyric oar
#

mh okay

eternal oxide
#

WE jumps back sync to perform all changes.

thorny python
#

hm

gritty urchin
#

hey

#

how do I delete a key?

#

and all of its child keys

eternal oxide
#

set the section to null

thorny python
#

it is complicate in some sense anyway

waxen plinth
lyric oar
#

that's a good idea

gritty urchin
waxen plinth
#

Just call set(path, null)

#

That will delete it, and if it's a section, it will delete the whole section

tender shard
#
    private void removeOldRecipes() {
        //System.out.println("Removing Recipes...");
        Iterator<Recipe> it = Bukkit.recipeIterator();
        NamespacedKey dummy = new NamespacedKey(this,"dummy");
        it.forEachRemaining(next -> { // <---------- THIS
            if(!(next instanceof Keyed)) return;
            Keyed keyed = (Keyed) next;
            if(!keyed.getKey().getNamespace().equals(dummy.getNamespace())) return;
            Bukkit.removeRecipe(keyed.getKey());
        });
    }

How the fuck can this line throw an error?!

spiral light
#

it can ^^

tender shard
#

yes but how? why?

thorny python
#

concurrent modication error lol

tender shard
#

no?

#

how would that throw a concurrent modification exception

spiral light
#

since the Bukkit.recipeIterator() contains a obj with all recipes which gets modified by removeRecipe your iterator has less recipes then it thinks it has

tender shard
#

but that's what the iterator is supposed to be for

spiral light
#

i know its rly stuppid

tender shard
#

when using Iterator.remove, it does NOT remove the recipe

thorny python
#

iterator no allow you to remove item during iterate iirc

spiral light
#

someone mentioned it a while ago and had the same error

tender shard
#

which I used before, but Bukkit seems to not actually return an iterator over the actual collection but just a copy or sth >.<

thorny python
#

um

spiral light
#

its probably just a unwanted bug ...

thorny python
#

make a copy by yourself to see if it fix

tender shard
#

yeah no idea

#

I'll just loop over my list of saved recipes to remove them instead

spiral light
#

you can cast the Iterator<Recipe> to RecipeIterator ^^

tender shard
#

but it's weird

tender shard
#

RecipeIterator?

spiral light
#

thats what CraftServer gives you ^^

tender shard
#

lol well I won't use NMS for such a simple thing though 😄

#

I just loop over my already existing HashSet<Recipe> to remove my own ones

thorny python
#

it no yet go down to nms anyway

spiral light
#

just make a extra list where you add those you want to delete

tender shard
#

anyway it's weird though 😄

thorny python
#

ya make a copy of recipe by yourself should fix the issue

gritty urchin
eternal oxide
#

save config after

gritty urchin
#

oh shit

tender shard
#

I just do this now

gritty urchin
#

thanks

tender shard
#
    private void removeOldRecipes() {
        NamespacedKey dummy = new NamespacedKey(this,"dummy");
        recipes.stream()
                .filter(recipe -> recipe.getNamespace().equals(dummy.getNamespace()))
                .forEach(Bukkit::removeRecipe);
    }
snow crow
#

this.getCommand("getpearl").setExecutor(new givePearl());
this returns to a NPE

#

error

tender shard
#

register your command in plugin.yml

thorny python
#

lol

#

quick respond

snow crow
#

howwww

tender shard
snow crow
#

the wiki is confusing

spiral light
#

i dont know.. maybe just read how the plugin.yml works ? XD

void wraith
#

Hi! How I use the PlayerCommandSend event? How to delete commands here?

thorny python
#

cancel event

tender shard
#

remove the command from get getCommands() collection

#

it isn't even cancellable

thorny python
#

oh I was thought it is the event which fired when player send command xd

#

you can just remove String in getCommands()

#

according to docs

snow crow
snow crow
tender shard
void wraith
tender shard
snow crow
tender shard
#

because you spelled it differently

tender shard
void wraith
#

Oh thy

thorny python
#

so any good way to get current spigot server name? ._.

snow crow
thorny python
#

I ask three times already xd

tender shard
tender shard
snow crow
#

ok thx ill try again

void wraith
#

Thy it's works.

tender shard
#

Bukkit.getServer().getMotd()

thorny python
#

I mean the name used in bungee server

tender shard
#

oh

#

using plugin messaging

digital rain
#

  String str;
  int number;

  public Object(String str, int number) {
    this.str = str;
    this.number = number;
    whateverList.add(this);
  }
}```
Can anyone tell me how to do this properly, im stupid ik :(, it says unsupported operation exception
tender shard
tender shard
#

er

#

I always forget the command

thorny python
#

ya that's almost work, but I need the name right in the event handling so cannot wait the callback

tender shard
thorny python
#

hm

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

thorny python
#

ya that's would probably works

#

but what if the server reload xd

tender shard
thorny python
#

hm ok

#

thanks

digital rain
#

its a basic error, because of my limited knowledge, just tell me how would you add the object to a list upon its initialization

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

tender shard
#

I don't ask for the exact error for fun

spiral light
tender shard
#

you probably have an immutable list but since you just say it's a "basic error", noone can really know

digital rain
spiral light
tender shard
#

don't worry, they don't even show the error message, no need to try and guess without the error message

digital rain
#

java.lang.UnsupportedOperationException at java.util.AbstractList.add(AbstractList.java:153) ~[?:?]
at java.util.AbstractList.add(AbstractList.java:111) ~[?:?]

tender shard
#

ABSTRACT List

#

where did you even get this list from

boreal sparrow
#

i have a list of players, how do i disable pvp in that list?

tender shard
boreal sparrow
#

ty

tender shard
#

then cancel that event is both attacker and victim are players

#

and if the victim or attacker is in your list

boreal sparrow
#

um

#

ok ty

tender shard
digital rain
#

so changing List to ArrayList is the solution?

#

bruh

tender shard
#

no

tender shard
snow crow
#

im back again]

spiral light
#

?ask

undone axleBOT
#

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

digital rain
#

its defined as "public static List<Object> whateverList = Arrays.asList();"

snow crow
#

with the same error 😢

digital rain
#

or idk what youre asking

snow crow
#

this.getCommand("getpearl").setExecutor(new givePearl());

tender shard
#

Arrays.asList is an immutable list, as I already said

#

so

#

you have to create a new list

#

for example

snow crow
#

idk but your fast

tender shard
#

List<Object> whateverList = new ArrayList<Object>(Arrays.asList(...));

boreal sparrow
#

how do i check for player in a list i have

quaint mantle
#

it is nof. Immutable but

#

Lists.newArrayList

digital rain
#

oh ok im grateful for your response

tender shard
boreal sparrow
#

ty

tender shard
sage patio
#

How I can detect how much arguments player enter in a command ?
For example I enter /test a b c d e f and my plugin returns 6

quaint mantle
#

gwt tge length of args array?

snow crow
#

Thread

boreal sparrow
#

hmm checking if attacker and victim are in the same list is hard lmao

eternal oxide
#

Not hard, its only a list

boreal sparrow
#

true but still is

eternal oxide
#

if (list.contains(attacker) || list.contains(victim))

boreal sparrow
#

oh

trim creek
#

When using getNewScoreboard();, why is the server disallowing the visibility of the registered teams (to be clean: the teams are visible over the tab, and the tags are also hidden (because it is set to be that), when using getMainScoreboard();, but when using getNewScoreboard(); nothing will be displayed on the tablist, and the tags are also visible again. Is there a way to fix this? I even made it be in another plugin)

loud haven
# boreal sparrow oh

This is why we've been telling you to learn Java. So many of the things you've asked are basic Java knowledge. Please, just take a bit of time to read a Java beginner tutorial. Maybe do some coding practices too before jumping straight into plugin developing.

#

Otherwise you're gonna have a hard time.

sage patio
#

Get string from 2 more arguments

tender shard
#

that's literally one line of code

sage patio
#

mfnalex can u check my thread again

snow crow
#

?paste

undone axleBOT
red sedge
#

Is there a way to check if the player is still mining

snow crow
snow crow
red sedge
#

yes

#

its wont break your plugin

#

but something is null without you checking it

#

so it can break in the future

spiral light
red sedge
spiral light
#

do you like nms ?

red sedge
#

nah im good

#

maybe I can try packets?

snow crow
#
                        try {
                            synchronized (metrics.optOutLock) {
                                if (metrics.isOptOut() && metrics.task != null) {
                                    metrics.task.cancel();
                                    metrics.task = null;
                                    Iterator var3 = metrics.graphs.iterator();

                                    while (var3.hasNext()) {
                                        enderrider.enderrider.utils.Metrics.Graph graph = (enderrider.enderrider.utils.Metrics.Graph) var3.next();
                                        graph.onOptOut();
                                    }
                                }
                            }
chrome beacon
#

Iirc only main scoreboard is synced to the client

spiral light
trim creek
#

So there is no point of making a scoreboard then? 😄

red sedge
snow crow
red sedge
#

I need to see if the player is still mining

#

^

hardy swan
#

There is not such thing

#

But

#

You can check when player stops/abort mining

red sedge
#

hmm?

hardy swan
#

I think

red sedge
#

I believe so

#

there is a start stop and a abort packet for it

hardy swan
#

Yea thats it

snow crow
red sedge
#

I wonder if it works with mining fatigue

#

imma try it

hardy swan
#

Also i think the action of mining is client side

red sedge
#

yeah I think so

#

it just sends a change event tho

hardy swan
#

Read the error

red sedge
#

I just hope when it switches it sends the abort packet first

snow crow
#

its a warn

#

in line 87

hardy swan
#

It is not just a warning

#

It is an exception

red sedge
snow crow
hardy swan
#

What does the message tell you

#

Cannot read field "optOutLock" because "this.this$0.metrics" is null

snow crow
#
                                    metrics.task.cancel();
                                    metrics.task = null;
                                    Iterator var3 = metrics.graphs.iterator();

                                    while (var3.hasNext()) {
                                        enderrider.enderrider.utils.Metrics.Graph graph = (enderrider.enderrider.utils.Metrics.Graph) var3.next();
                                        graph.onOptOut();
                                    }```
#

this part

#

should i change the null part

hardy swan
#

Im telling you it isn't

snow crow
#

but the stacktrace says line 87

hardy swan
#

Look again

snow crow
#

oops i missed one line

#

synchronized (metrics.optOutLock) {

#

top of before one

tender shard
#

wait wait wait

#

did you manually copy bstats into your plugin?!?!

hardy swan
#

Oh lol

#

You mean should you?

snow crow
#

um

#

lol

hardy swan
#

Shade?

tender shard
#

I'd just let maven shade it, yes

hardy swan
#

Thats it

#

See its github readme

snow crow
hardy swan
#

Ok not readme

snow crow
hardy swan
#

That's all you have to do to add bstats into your plugin

#

Wait what you tryin achieve

spiral light
snow crow
#

trying to make a player ride a enderpearl

chrome beacon
#

So why do you need metrics

hardy swan
#

Metrics for riding pearls??

chrome beacon
#

I have a feeling this is too hard for you

snow crow
snow crow
tender shard
hardy swan
#

This is either mind blowing

snow crow
#

or tottaly dumb

tender shard
#

"My animation is laggy, better add bStats to make it smoooth" lmao

snow crow
#

lmao

tender shard
#

do you have any idea what bstats / metrics does? o0

snow crow
#

a big NO

tender shard
#

this is what bstats does

#

it collects about who uses your plugin, how many, what java version they use, etc

snow crow
#

ik abt that it keeps some record thats all

sage patio
#

I have this code to get a string like wtf is this from /test add wtf is this, I removed add from the string but still print it in the result

tender shard
snow crow
#

ok

hardy swan
#

Or remove the first element from the equation during join

sage patio
sage patio
spiral light
#

no

sage patio
#

I GOT IT

#

sorry

#

im a dumb

spiral light
#

replace "add " not " add "

sage patio
#

yea

snow crow
#

we are all dumb at some point. expect some ppl

hardy swan
sage patio
hardy swan
#

Damn thanks

sage patio
#

😁 np

#

works great now :D

red sedge
spiral light
red sedge
#

pr?

hardy swan
#

There isnt a packet for that

red sedge
#

oj

#

oh

hardy swan
#

Im afraid

red sedge
#

im stupid

hardy swan
red sedge
red sedge
rich inlet
#

Is it possible to use the FileConfiguration#isSet(path) method so it ignores the upper or lower case of the path?

rich inlet
red sedge
hardy swan
#

No, fileconfigurations should be case-sensitive

red sedge
#

I should probably verify eh?

rich inlet
#

e.g. config.contains("path.ExAMpLE") will return the same as config.contains("path.example") ?

red sedge
#

yeah no

#

quick question does verifying make my discord name same as my spigot?

hardy swan
#

No

#

Just blue

rich inlet
red sedge
#

create your own system

#

prob not very efficient but will work system

#

loop through all the values and chekc

hoary tiger
#

What I extend to make a zombie Custom Mob class?

spiral light
rich inlet
#

hmm okay

red sedge
red sedge
#

also @spiral light does verifying make my name same as myspigot one

hoary tiger
spiral light
#

no just blue

spiral light
sage patio
#

Problem with my File Manager class ( custom yml )

quaint mantle
#

so what do i do here for maven

spiral light
#

open git bash

quaint mantle
#

ok

#

what next

spiral light
red sedge
#

should i use protocollib for packet management

quaint mantle
#

but I would perfer plain nms

red sedge
#

you see

#

me no smart enough for nms

spiral light
spiral light
#

then you no packets use

red sedge
#

but me want packets use

#

me need packets use

spiral light
#

ah for the break thing ?

red sedge
#

yessir

#

also how do i send a textcomponent

#

totally unrelated

red sedge
spiral light
#

uhmmm cant be thaaaat complicated to make events for that :/ but i am to lazy for adding this to spigot since i dont know why its not existing already ... its worth you make an feature-request maybe someone will add it

red sedge
#

pretty sure it wont be an event

#

well idk what youre talkin abt but im talking abt smth like if the player is still mining

spiral light
#

just adding event called "BlockBreakStartEvent" and "BlockBreakEndEvent"

red sedge
#

hm

#

i still need to packet tho

red sedge
patent horizon
#

what type would i put in a method to accept an instance of a class as a param

red sedge
#

Object?

patent horizon
#

hm k

spiral light
#

Class clazz ?

patent horizon
spiral light
#

argument Class ?

patent horizon
#

how do i iterate over a hashmap?

quaint mantle
#

entrySet

pine island
#

can someone give me a example of setting players armor im reading the doc and i dont get a thing

#

(i have read docs before but i dont seem to get this one)

patent horizon
patent horizon
#
        for (Map.Entry<String, ConfigManager> set : configManagers.entrySet()) {
            
        }``` i have this, but `set` doesn't seem to be a ConfigManager
pine island
#

isnt like armor 103?

tacit drift
pine island
#

hmm ill find a doc or smth tysm

#

also i dont have 40 im on 1.8

tacit drift
#

Player#getInventory

tacit drift
#

index - slot

pine island
#

alr

#

i found a forum thread on it tho

rich inlet
#

?paste

undone axleBOT
rich inlet
pine island
#

how do i use this?

#

like how will the array work?

golden turret
#

which packet is sent when an entity do something that create particles?

latent zephyr
#

Hi, guys, why doesn't EntityPlayer have getServer(), getServer() and other methods in 1.18.1?

rich inlet
neon minnow
#

Help

red sedge
#

how do I use new HoverEvent?

golden turret
quaint mantle
#

Double Shift + ClientBound Particle

neon minnow
#

Hi guys why cant I use colors in messages? Intellij just says unsolved reference

and the + is red

https://ibb.co/nrGc5k4

red sedge
#

getmemory isnt a string?

neon minnow
golden turret
quaint mantle
#

Then PacketOutPlay

mighty pier
#

how do i get the item a player is holding?

quaint mantle
#

getItemInMainHand

mighty pier
#

ty

#

there is no getiteminmainhand

hasty prawn
#

Get the inventory first

mighty pier
#

k

patent horizon
#
    public void progressBar(Double progress, int bars) {
        int x = (int) Math.floor(progress * bars);
    }``` is this a proper way to do double -> int conversion, or is blind casting bad in this case?
quaint mantle
#

seems fine

manic bison
#

hey does anyone know how to get Material.HEAD ? Player head i dont know but NOT skull ? Api : 1.9

mighty pier
#

int x = (int) 1-5; will this work?

#

is that how i set a random number from 1-5

loud haven
#

No.

ivory sleet
#

ThreadLocalRandom.current().nextInt(5)+1

#

that’d be the quickest way (where nextInt() takes an integer and returns an integer from 0 to the passed integer-1 [hence the +1])

mighty pier
#

ok ty

sly trout
#

I'm trying to serealize an inventory and save it to config

#

and then fetch it and deserealize it

#

how would i do that

ivory sleet
#

Hmm to your comfort ItemStack is already serializable and there’s a good api for that

#

Idk same could be said about inventory

#

But create an object which implements ConfigurationSerializable properly (guides exist on the web)

#

and the just use
set(path, customObject);
getSerializable(path,CustomObject.class);

spiral light
#

btw conclure .... your code from yesterday did not help xD
you can set private final fields to null but not to smth else 😄

sly trout
#

ok but would i make an ArrayList of <Serializable> and then put all the itemstacks in his inv in there and then save it to config

#

and then get the arraylist back and then deserialize them and loop them and add them to his inv

ivory sleet
#

but it must obv be the correct type

onyx fjord
#

h devs

#
const something = () => {
}``` do u call that lambda or im incorrect
#

and yes im aware its js

pine island
#

i have a command its registered in both plugin.yml and my main class still dosnt work just shows cant find command

ivory sleet
#

It is indeed a lambda kacper

restive mango
#

Is there an event called by bukkit if another plugin (like bungeecord) causes a player to swap between servers?

ivory sleet
#

Or well “arrow function”

#

In java a Runnable can be considered equivalent to some extent

restive mango
#

Would it be login? Or the world swap event like when you go through a nether portal?

restive mango
#

Ugh

ivory sleet
#

The backend servers don’t have any inherit knowledge about proxy behavior

ivory sleet
restive mango
#

Actually, what I mean is, I’m not looking to differentiate the two

ivory sleet
#

I suggest you provide us with relevant resources