#help-development

1 messages · Page 2190 of 1

limber owl
#

Wouldnt that be too small?

terse raven
#

wdym

brave sparrow
#

What do you mean it’s name has version in it

#

That’s the maven config not the plugin config

waxen plinth
#

They're talking about the build artifact

limber owl
#

Lets take 16 teams of 1 player, then you have 16 chunks, and one chunk is 16 block wide, so they would be dropping too close, won't they?

brave sparrow
#

That’s configurable separately, you don’t need to make version null lol

terse raven
brave sparrow
harsh totem
limber owl
#

So double or triple that

terse raven
#

yea

#

just divide your play area by the number of teams

limber owl
#

Okay, thanks

brave sparrow
silent timber
#

What is the new PacketPlayOutMapChunk in 1.18[.2]?

paper crater
#

Anyone know how i can change the specific item back to durability 0 when putting it in a chest/dispenser like the OnWeaponDrop in screen

chrome beacon
#

Use the InventoryClick and InventoryDrag event

brave sparrow
#

Using the appropriate inventory events

waxen plinth
#

Can I make some suggestions

paper crater
#

It's for 1.7.10 and modded server so yh lots of stuff not possible

silent timber
#

whoever just replied to me and deleted it, client bound

paper crater
#

and needs to work with modded items hands the reason why IDs is used

terse raven
viscid fractal
#

Hi quick question, what spigot version do I use to make a 1.8.9 plugin? I assume 1.8.8?

waxen plinth
#

1.18.2

terse raven
#

^

waxen plinth
#

Use latest :)

viscid fractal
#

Oh I can just use latest. Sweet! Thanks

terse raven
#

nonono

#

but why would you want to use 1.8?

waxen plinth
#

Viaversion for backwards compatibility if you really need people to be able to join from 1.8

paper crater
waxen plinth
viscid fractal
#

Now confused....

brave sparrow
#

If you don’t want to help the kid just say that guys

waxen plinth
#

Don't copypaste code, extract it into a method

brave sparrow
#

Don’t lie to him

waxen plinth
#

Use latest

terse raven
viscid fractal
#

But it works for a 1.8.9 server?

brave sparrow
#

For a 1.8.9 server, latest will not work, you want spigot 1.8.8

viscid fractal
#

Okay, thank you very much!

brave sparrow
paper crater
jagged quail
#

i bet i dont even need the else if in this: ```java
Player player = (Player) commandSender;
if (flyingPlayers.contains(player.getUniqueId())){
flyingPlayers.remove(player.getUniqueId());
player.setAllowFlight(false);
Msg.send(player, "&cFlight has been disabled.");
} else if (!flyingPlayers.contains(player.getUniqueId())) {
flyingPlayers.add(player.getUniqueId());
player.setAllowFlight(true);
Msg.send(player, "&aFlight has been enabled.");
}

waxen plinth
paper crater
waxen plinth
#

Matter of fact this code can be dramatically simplified

crisp steeple
#

bro what the actual hell

#

a print statement is determining whether or not my code works

#

??

brave sparrow
#

If flyingPlayers is a set

#

You can replace that contains and remove with just remove

waxen plinth
#

Yep

brave sparrow
#

In a set remove returns true if the element was in the set, false otherwise

waxen plinth
#

It could look like this

crisp steeple
#

anyone have a clue how this is happening

jagged quail
waxen plinth
#
player.setAllowFlight(flyingPlayers.add(player.getUniqueId()));
player.sendMessage(player.getAllowFlight() ? "You can now fly!" : "You can no longer fly!");
if (!player.getAllowFlight()) {
    flyingPlayers.remove(player.getUniqueId());
}```
crisp steeple
waxen plinth
#

Not sure why you even need to have a Set to keep track of a property that's already stored on the player though

jagged quail
waxen plinth
#

Yes

#

Just edit the strings

fair sable
jagged quail
#

intellij asked if i wanted it to be and if else

brave sparrow
jagged quail
#

ok i now have this @waxen plinth

brave sparrow
waxen plinth
#

Prefer ternaries over inline if-else

tender shard
waxen plinth
#

Ehhh

#

It's in the official Google style guide

tender shard
#

I mean I also do love the ? operator

waxen plinth
#

Inline if statements are considered an antipattern

tender shard
#

but there's also nothing wrong in using if else

waxen plinth
#

Use braces

#

Omitting braces is the antipattern

tender shard
#

+1 for using {

#

yeah

waxen plinth
#

Not if-else itself

#

Though to be honest I avoid if-else too

brave sparrow
#

Not using braces is how you get security flaws

waxen plinth
#

Having more than a few in one function is a sign of bad code

tender shard
#

but anyway, if/else is nothing that one should avoid imho

brave sparrow
waxen plinth
#

No, either way

mortal hare
#

Man i have this architectural problem

#

I have a feature, function which I would like to implement

waxen plinth
#

Nested or not, if you have more than a few in one function something is probably wrong

#

There are a few exceptions

mortal hare
#

but if i Implement it, there's an impact of performance

waxen plinth
#

It's a rule of thumb

#

Not a universal truth

mortal hare
#

due to how that feature would remove bunch of optimisations

#

which I implemented

fair sable
brave sparrow
#

Well the spigot method is likely performing more than one operation

jagged quail
#

should i move my main class from Mecha.class to Main.class?

brave sparrow
#

You’re probably going to need a few different packets

brave sparrow
#

It should be YourPluginNameHere.class or something to that effect

jagged quail
#

hm ok

fair sable
#

how can I learn what spigot method does? someone said on the code side of things its the ClientboundMoveEntityPacket$Rot but it doesnt mean anything to me as idk much about packets

waxen plinth
#

Maybe make a thread

brave sparrow
# fair sable how can I learn what spigot method does? someone said `on the code side of thing...
GitHub

Provides read and write access to the Minecraft protocol with Bukkit. - ProtocolLib/PacketType.java at 240920d642be3ff5d84f45586e01ddb2444cf1c2 · dmulloy2/ProtocolLib

fair sable
#

thx going to try now

mortal hare
# waxen plinth Explain it

I have an experimental UI framework which allows you to simulate clientside inventory actions, the thing is I could reuse some of the handling code from the action handling system I'm currently using, but they're optimised in way, that some actions are remain to be calculated by the client, by that I'm saving bunch of iterations which server doesn't really need to do. On the other side, these optimisations break my feature of clientside interaction simulation which seems like a cool idea, and I can't think of how to implement this gracefully without any performance drops.

waxen plinth
#

Have an interface that represents all the needed behavior

#

For simulating inventory actions, you have an implementation of it that does all the calculations

#

For non simulated ones it can basically just be a dummy that does nothing

jagged quail
#

makes more sense to put command usage like that?

mortal hare
#

its not monolithic

waxen plinth
#

Adding another polymorphic component seems like the solution

waxen plinth
brave sparrow
#

You’ll probably want to look at the decompiled spigot source for that method and see what it’s doing differently from you then

#

Or look at it on stash

fair sable
#

how can I do that?

mortal hare
# jagged quail makes more sense to put command usage like that?

I would say yes, that way your plugin could properly respond to the changes in the plugin.yml file, if server owner wishes to change the permission nodes or to localize the description of the command (although its not recommended to do it that way, some plugins crash due to this)

#

although command frameworks are more fancy and flexible to work with

#

bukkit api should add static tab completion maps to the plugin.yml

#

that way plugin developers wouldnt need to rely on tab completion events every time, thus save some performance (although not much)

#

dynamic tab completion are not that common for simple commands

#

basic dynamic tab completion is already implemented (player names, worlds, etc.)

silent timber
chrome beacon
#

So why are you trying to send a chunk packet

silent timber
#

Trying to send chunks from a certain area of the world to the player at a different location

chrome beacon
#

Oh well guess you're going to have to dig around a bit

quaint mantle
#

Hey guys! Need some help.
Does any of you know if there's any way I can set an ItemStack display name in multiple languages? So it's translated client-side?

ivory sleet
#

yeah

quaint mantle
#

Just as any other regular Minecraft item

vale cradle
#

Translatable key in the Resource pack

#

Or modify the packet before it's sent to the player replacing a specific placeholder with the text in question

quaint mantle
#

Alright, so I must either use a resource pack or deal with packets?

#

Thank you folks

vale cradle
#

o/

ivory sleet
#

anyway theJsUsed I believe ItemMeta setLocalizedName/getLocalizedName might be for you

#

or if you use paper then those w/o the get/set prefixes

spare marsh
#

for some reason my plugin runs the onDisable method whenever I do /stop but if I do /restart it doesn't. Anybody know how this is possible>

quaint mantle
#

shouldn't I be able to set a localized name for English, Spanish, Protuguese and any number of different languages?

ivory sleet
#

ye its the key

#

yep

#

but the some.name.key gets translated client sidedly

quaint mantle
#

Okay, I'm not getting it. Sorry if i'm just being dump:
Let's say I got an Itemstack with a glowStone material. I want it to be called "magic dust", but I want English clients to see "magic dust" and Spanish clients to see "polvo mágico". How would I achieve that using the ItemStack's localized name?

ivory sleet
#

Oh custom localized names can only be supported using a resource pack as tommy said, or if you translate it server sidedly

#

but that presupposed you also are aware of the language of said usr

quaint mantle
#

I guess I'll just translated I server-side. Player#getLocale should be enough to get the Player's language

ivory sleet
#

indeed

jagged quail
#

hey guys

#

i wanted to make it show the plugin version here

quaint mantle
#

The drawback it that if an English located player crafts my custom item, drops it and then a Spanish located player picks it up, they'll see an English display name and lore.

jagged quail
#

not the server version

#

does anyone know how to do that?

#
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        Msg.send(commandSender, "&7------------= &aMecha &7=------------");
        Msg.send(commandSender, "&aVersion: " + Bukkit.getVersion() + " &ais installed.");
        Msg.send(commandSender, "&4PRE-RELEASE!!! THIS VERSION IS NOT STABLE");
        return true;
    }```
humble tulip
silent timber
#

Do you know what nmsChunk.i.getChunkProvider().getLightEngine() has changed to in 1.18?

jagged quail
echo basalt
#

probably something diferent

quaint mantle
#

user your plugins main instance

humble tulip
#

You need to pass your plugin to your command class

#

?di

undone axleBOT
humble tulip
#

Use dependency injection

quaint mantle
#

Set a static member of type JavaPlugin in your Plugins main class, define it in onEnable(), then access it from your command class

jagged quail
#

okay

limber owl
#

hey, am I dumb because it's too late and I'm overworked or why can't I add player to this Set

private final Set<Player> players = new HashSet<>();
#
    public void addPlayer(Player player) {
        if(players.size() >= size) return;

        players.add(player);
        Logger.info(getPlayers()); //TODO: remove
    }
#

in this function

#

I see it doesn't work

#

it prints out empty set

#

that logger is custom class, just shorter bukkit.getLogger()...

#
    public Set<Player> getPlayers() {
        return players;
    }
#

getPlayers() function

jagged quail
#

if i can find it

lethal python
#

i've got a PlayerInteractEvent and i'm trying to make it so when a player right clicks a container with a certain item, the container won't open. i've already made a list of every block which does something when you right click it. I'm trying to do .setCancelled(true) on the PlayerInteractEvent but it doesn't stop the inventory from appearing?

quaint mantle
#

The Static member approach is just a simple an easy solution. There're definitely more elegant patterns to have the job done, like using dependency injection.

humble tulip
#

what's the value of size?

limber owl
#

I'm going to sleep, you found the problem that I've been working on for 1 and half a hour in minutes, it's 2am and Im tired, sorry

lethal python
#

ok so i will use this code instead, i want to cancel the inventory appearing if the player is sneaking

if (player.isSneaking()) event.setCancelled(true);
#

surely that would work

#

that's what i have

humble tulip
#

Is it an inventory open event?

#

Close the inventory

#

Don't cancel

lethal python
#

make an int called count = 0 and a string called last = null, iterate thru the stringlist and check if the current string = last, if it does increment count by 1, if it doesn't equal it then set count to 0, return current string if count reaches 5

lethal python
lethal python
#

why

humble tulip
#

U gave him an algorithm

#

Just retun no need to cancel

lethal python
#

i got a B in algorithmics

humble tulip
#

Niice

lethal python
#

my problem still : (

humble tulip
#

Just don't open it for them?

#

And return

lethal python
#

nono

#

i have this item which i have detected if they're holding

humble tulip
#

Yes

lethal python
#

i need to check if they are crouching

#

if they are, and they're right clicking a block which is in my list of forbidden blocks, then i need the inventory to not open

#

i mean i cancel the event at the end anyway idk why im actually checking again

#

i always cancel the event

#

but the inventory always opens

humble tulip
#

when u want to exit the method use return;

#

So do ur checks to not open the inv and return

lethal python
#

that won't cancel the inventory opening

humble tulip
#

I dont understand why it won't

lethal python
#

returning from an event handler won't cancel the event

humble tulip
#

U don't have to cancel it

#

Just don't open the inv

lethal python
#

but i'm not opening the inventory

#

if the player right clicks a barrel

humble tulip
#

So why does the inv open?

lethal python
#

i don't want the barrel to open

humble tulip
#

Well cancel tje event first

lethal python
#

i did that

#

it isn't stopping the barrel from opening

humble tulip
#

Can i see ur listener?

lethal python
#

the final line there is supposed to make it so if you right click while crouched, the barrel won't open

#

but the rest of the event listener will play out

humble tulip
#

Yep

#

Set the listener priority to monitor to test if something is uncancelling the event

lethal python
#

how do that :v

humble tulip
#

Next to @EventHandler

#

(priority = EventPriority.MONITOR

#

also print somethingafter u check that the data is correct

lethal python
#

so would adding that have fixed it

humble tulip
#

I'm not sure we're testing to see what the problem id

#

Is

lethal python
#

so what should the monitor have done

#

the thing i added to check if i was crouching says i am

humble tulip
#

Where did you print the crouch check message tho?

lethal python
#

immediately after the last line in that screenshot

humble tulip
#

MONitor makes your listener code run after all other listeners so u have the final say

lethal python
#

oh well

#

the barrel still opened

humble tulip
#

Are u sneaking when u right click the barrel?

lethal python
#

yes

humble tulip
#

Use & & instead of & btw

#

Idk why ur code is bugged

lethal python
#

nop

fervent gate
#

Quick question, for a server that will have a lot of features. What would be the best solution, 1 big plugin or a lot of small ones?

lethal python
#

not using && on purpose

humble tulip
#

You wanna evaluate both?

#

Why

lethal python
#

i don't want to quit the rest of the event listener if the player is only standing up

#

they need to be standing up and clicking a forbidden block

humble tulip
lethal python
#

my brain isn't very good today so that might be wrong but it's working

#

i know && skips evaluating the 2nd one if the first one fails

lethal python
#

anyway the event still isn't getting cancelled

humble tulip
dusk flicker
#

ex 1 core plugin, that handles the stuff that would be used on the full network etc; specific plugins for each gamemode, etc

jagged quail
#

im so bad at this

lethal python
#

i saw someone on a forum post say that they cancelled the event when they clicked a dispenser and it worked for them

humble tulip
lethal python
humble tulip
#

Try other blocms other than barrel

#

And make sure you're crouching

jagged quail
#

idk how to use dependency injection

lethal python
humble tulip
#

And they still open?

lethal python
#

yes

humble tulip
#

Something is wrong

#

Print event.isCancelled

dusk flicker
undone axleBOT
sterile token
#

Is possible to create Mongo POJO's ? so then i dont need to set each class object data into a bson document for them saving, reading, etc

lethal python
humble tulip
#

Doesn't matter

#

Just print it

humble tulip
#

They show u how to do it in that link

#

Just take some time andnread

sterile token
# jagged quail

If you are not in the main class, you cannot call getPlugin()

jagged quail
#

rip

sterile token
#

What are you doing?

dusk flicker
#

you need an instance of your main class

jagged quail
#

trying to grab the version from plugin.yml

dusk flicker
#

from either DI or a singleton, read the guide

lethal python
#

@humble tulip it says iscancelled is true

sterile token
#

You have to pass an instance of the main class using DI or Singleton

#

Rack, do you have experience with mongo?

dusk flicker
#

eh a bit

sterile token
#

Oh ok

humble tulip
dusk flicker
#

What's the issue VERANO?

sterile token
#

I dont think you would know, but mye. I want to know if possible to define model with mongo db

#

Like you do on NodeJS for example

dusk flicker
#

Ive never messed with anything like node, so I cant help you with that

sterile token
#

But not node

#

Im on java

dusk flicker
#

I mean I dont have any reference on what a model would be

sterile token
#

I wondering if possible to use a custom class which define properties so them i can saving/deleting and updating it

dusk flicker
#

I somewhat do that

sterile token
#

Arent called MongoDB Pojo's?

dusk flicker
#

I have objects created that will be used for the DB, but methods in that class I have basic save/update/delete methods; its hardcoded -> All it basically is, is converting it to a bson Document

sterile token
#

Yeah

#

I do that

#

But i seen that some people dont use bson Document

#

They directly save/update/delete/etc a class object with properties already defined

little panther
#

Hey, im not really able to figure out what is the problem with my plugin. Is someone able to help me (this is the console when i enable it: https://pastebin.com/SLhtQRKQ)

humble tulip
#

Command is not defined in plugin.yml

dusk flicker
humble tulip
#

Make sure you put it there

little panther
#

oh, yea. I switch two letters. I am far too tired for this. Thanks 😄

fervent gate
#

I was making pets and did the exact thing here.

echo basalt
#

I'd honestly just do a weird map supplier type thing

#
Map<String, Supplier<SpawnPet>> petSupplier = ...;

petSupplier.put("common_cow", () -> new SpawnCommonCow(this.plugin));
etc


String value = container.get(type, PersistentDataType.STRING);
SpawnPet whatever = petSupplier.get(value).get();

whatever.spawnPet(player, 3);
#

getKeys(true) returns all paths

#

or recursion

#

wait so what's your objective?

#

make a tree view or something?

#

what if you do getKeys(true) and substring(lastIndexOf(".") + 1)

#

it's just simpler

compact haven
#

^ it probably does recursion under the hood lol

normal spire
#

Hello! Is it real to set ItemStack lore with md_5's TranslatableComponent?
I couldn't find the feature I need in the Spigot API

echo basalt
#

?tas

undone axleBOT
normal spire
# echo basalt ?tas

This is inappropriate. I don't ask if I can do it. I ask how exactly can I do what I need

#

I couldn't find the feature I need in the Spigot API

echo basalt
#

"Is it real" doesn't say much but ok

#

Look into kyori

#

Paper includes it by default

normal spire
river oracle
#

Paper loves their components

knotty gale
#

ok so I am trying to use essentialsx, but non opped players cannot use any commands from essentialsx
any fixes?

warm mica
# knotty gale ok so I am trying to use essentialsx, but non opped players cannot use any comma...
BukkitWiki

This tutorial will guide you through how to create your own permissions plugin that sets permissions using the new Bukkit permissions API. This tutorial assumes you have a good understanding of the Java language, and general plugin development. This tutorial will only cover the specifics of the Bukkit permissions API. Everything that can have pe...

knotty gale
#

well using luckperms doesn't work, so why should making another plugin for the same purpose work?

#

(ik u did not know that part)

warm mica
knotty gale
#

that is very true

#

ok ty

minor otter
#

is it possible whatsoever to make every block in a players render distance update? like how reloading/relogging does it?

golden turret
#

is there a way to get a Plugin from bungeecord like bukkit JavaPlugin.getPlugin(Class)?

subtle folio
#

Is there a event for when a entity moves and not just a player?

ivory sleet
#

sadly nope

subtle folio
#

oh heck, is there a way I can check if a mob moves outside of a certain radius or nah?

golden turret
#

but nms have a move method

golden turret
#

inside the Entity class

subtle folio
#

What is the event called?

golden turret
#

i mean

ivory sleet
#

yes but EntityMoveEvent doesnt exist because it had too much overhead

golden turret
#

the Entity class from nms have a method called move

ivory sleet
#

since it would record a timing when the event fired, and the system uses reflection

golden turret
#

but that will only work for custom entities

subtle folio
#

so I cant check if a regular zombie moves somewhere?

minor otter
#

is there a client side block physics event?

golden turret
subtle folio
#

id rather not but alright

golden turret
#

and create a new event bus just to not use the bukkit's one

#

because it uses reflection

flat olive
#

does anybody know how to setup protocollib

#

everytime I build my project it builds as a file

#

folder*

#

im trying to build it as a jar

#

for the entire plugin

drowsy helm
#

wdym?

#

are you trying to shade it

spiral hinge
#

Hey I am looking at the SpigotMC wiki on how to connect to a MySQL database and it provides this snippet of code to test connect

private void testDataSource(DataSource dataSource) throws SQLException {
    try (Connection conn = dataSource.getConnection()) {
        if (!conn.isValid(1)) {
            throw new SQLException("Could not establish database connection.");
        }
    }
}

I do not believe most of this code is valid but I don't exactly know how to fix it so I was wondering if someone could give me a corrected version of it?

subtle folio
#

How do I unobfuscate NMS methods?

ivory sleet
#

you can use a remapper at compile time

#

which also reobfs during compile time so that your plugin can run on servers

subtle folio
#

uhhuh

flat olive
#

how do I build a project with nms

#

I have multiple versions

#

idk how to set it up to read that

ivory sleet
#

first and foremost you pretty much need to use maven/gradle

flat olive
#

I have that and I have no idea how to configure my project

ivory sleet
#

oh you need to create a module per version

flat olive
#

I do?

ivory sleet
#

exampe ^

flat olive
#

oh kkill myself

vital moon
#

I've been trying to do public class main extends JavaPlugin but it doesn't find it for some reason

flat olive
#

thats a lot

ivory sleet
#

yeah alternatively reflection

flat olive
#

Okay I did it

#

but I have a question

#

how do I build this as a jar

#

not a folder

ivory sleet
#

you use the maven tasks

#

through your terminal prob

#

or the ui window

flat olive
#

Yeah I see that

winter nova
#

Anyone know some good plugins for trading items with chest that is crossplay compatible like 1 item for another no money system

flat olive
#

do I use maven compile

#

command

#

nvm found it

#

its install

#

WOAH

river oracle
vital moon
#

it did not create a plugin.yml

river oracle
#

you have to create the plugin.yml

winter nova
#

Anyone know some good plugins for trading items with chest that is crossplay compatible like 1 item for another no money system???

river oracle
#

be patient

#

jesus christ your annoying

winter nova
#

Who

vital moon
river oracle
winter nova
river oracle
#
 The plugin.yml is a file made to contain information about your plugin. Without this file, your plugin will NOT work. It consists of a set of attributes, each defined on a new line with no indentation.
All attributes are case sensitive. Attributes in bold are required. Attributes in italics are not.```
vital moon
#

yes but I can't even code it thats what my issue is

river oracle
#

the wiki goes over all the fields you need in it

#

make a file called plugin.yml in your resources folder

vital moon
river oracle
#

oh you don't have the spigot-api added

#

do you know much java?

vital moon
#

nah, but know a bit of other languages

#

added both of those

#

into it

river oracle
#

I'd spend a couple days aquainting yourself with the syntax then that should be really all you need if you have plenty of programming experience already. I also recocmend using a package manager like Maven or Gradle for java projects

vital moon
#

it's also under the "Referenced Libraries"

#

Im using eclipse with a Maven project already

#

I learn syntax by coding something

#

so thats what im doing

river oracle
#

your class naming conventions are slightly off I'd just check out java naming conventions

vital moon
#

I will name them how I like to name them

river oracle
river oracle
uneven fiber
river oracle
#

I'm putting numbers in my class names now for because I want to

ivory sleet
vital moon
#

well it's more of the stuff I code its mostly only for me so Im gonna name them how I like to

uneven fiber
#

so called free thinkers when naming conventions and camel case is brought up

ivory sleet
vital moon
#

yeah rn its just been trying to get the api to actually function but it isn't rn and can't figure out why

river oracle
#

^ wiki tells you how to

vital moon
river oracle
#

are you importing it

vital moon
#

it doesn't regconize it

uneven fiber
# vital moon it doesn't regconize it

Ever wanted to know how to make Minecraft plugins for Java edition? In this new series we'll be starting with the basics and eventually diving into the advanced details of plugin development.

I've been developing plugins and running my own servers since 2013, so expect to see step-by-step tutorials with plain English explanations.

🎓 Take my FR...

▶ Play video
#

Could be useful

#

he walks through the process, may have something

vital moon
#

im already watching one but I'll give that one a look rq

uneven fiber
#

👍

vital moon
#

yeah so a few issues, he's using linux I believe, im on a windows machine and I already tried that software and it didn't work for jack shit so I removed it and am using eclipse

uneven fiber
#

oh your not using intelliJ/jetbeans?

vital moon
#

nah was having issues with it so using eclipses

uneven fiber
#

oh, yeah then I'm not much help

#

why doesn't it work on your computer?

#

cause i also have windows

vital moon
#

pretty sure it was something with the java file I had downloaded it using intelij and kept saying it was corrupted and wouldn't continue

uneven fiber
#

rip

vital moon
#

yeah but eclipse works without issue so just went with that

uneven fiber
#

yeah i heard that you can use eclipse, but i never have so im not sure what the issue may be

flat olive
#

how do I make holograms, I want to make a plugin to do /npc hologram <line> <message>

shut field
#

how can I send a string between a Waterfall plugin and my server plugin?

quaint mantle
#

Im making a care package plugin and im just trying to figure out how i can make the care package spawn ON surface, im randomizing the x,y,z but i want the package to be on surface and if its meant to spawn in a ocean/over water, itll restart the randomization

summer scroll
flat olive
#

how do I access the second argument the user sends

#

for a command

#

args[0]?

#

nvm I figured it out

shut field
#

second is args[1]

#

third is args[2]

minor otter
#

Is there a packet associated with tripwire client predictions

quaint mantle
#
world.getBlockAt(gen_x, 100, gen_z).setType(Material.CHEST);

So how can I put some contents into this chest?

flat olive
#

whenever I type in /hologram t

#

its saying what I used for if the length of args is above 2

#

length of args array

#

it makes no sense

#

why is it sending when the arg is 1

quaint mantle
#

can you send an ss of what it sends in game?

flat olive
#

its exactly what my message is

#

Please use /hologram <message>

#

/hologram t

quaint mantle
#

ah, okay i got it

flat olive
#

oh

#

my

#

GOD

#

I meant to use a greater than sign

#

but I used less than

#

nvm im dumb

quaint mantle
earnest forum
#

and then cast it to a Chest

#

then from that you can do Chest#getBlockInventory()

quaint mantle
earnest forum
#

on the block sorry

#
Block block = world.getBlockAt(x,y,z);

if (block.getState() instanceof Chest){
  Chest chest = (Chest) block.getState();
  Inventory inv = chest.getBlockInventory();

}
#

@quaint mantle

flat olive
#

does anybody know how to make new lines for hologram custom names

earnest forum
#

you can't

#

just have to make a new armour stand

flat olive
#

bro what

#

I mean new lines as in

#

lines that go over again

earnest forum
#

the plugin holograms?

flat olive
#

no

#

I mean like when you enter text in

#

one line

#

two lines

#

this is the first line
this is the second line below it

#

\n

earnest forum
#

yes

#

you make a new armour stand for each line

#

armour stand 1 name = line 1
armour stand 2 name = line 2

#

offset them on the y coordinate a little bit

#

are you programming a plugin or using someone else's

flat olive
#

so if user args[0] == line number for whatever user sends the command make a new armorstand and offset its value in the same location the previous hologram was but make its y coordinates minus a few values?

#

Making my own plugin

earnest forum
#

yep

flat olive
#

okay

#

sounds hard as shit

#

🤣

earnest forum
#

oh wait

#

so when the text gets too long you want it to automatically go to the next line?

minor otter
#

Is there a way to get client block update packets?

flat olive
#

no I just want other to be able to do /hologram 1 test 2 another

#

and in coding logic

#

print("test"\n"another")

earnest forum
#

looking at how other plugins do it

#

you create a hologram which is stored somewhere with a name

#

and then you set each line of it with a separate command

#

/createhologram "test"

#

/changehologramline "test" 1 "this is line 1"

#

/changehologramline "test" 2 "this is line 2"

flat olive
#

wait

#

instead ill do /hologram a b c

so arg 1 which is a will be line 1
b is 2
c is 3

#

ill automatically make whatevers next on the next line

#

that way its not so complicated

earnest forum
#

but then you can't have sentences

flat olive
#

oh

earnest forum
#

because a space in the command

flat olive
#

oh my god

earnest forum
#

makes it a different argument

quaint mantle
#
            int min_xpos = -3000;
            int max_xpos = 3000;
            int gen_x = (int)Math.floor(Math.random()*(max_xpos-min_xpos+1)+min_xpos);

            int min_zpos = -3000;
            int max_zpos = 3000;
            int gen_z = (int)Math.floor(Math.random()*(max_zpos-min_zpos+1)+min_zpos);
            Block block = world.getBlockAt(gen_x, 100, gen_z).setType(Material.CHEST);```
"Incompatible types. Found 'void', required org.bukkit.block.Block"

*pain*
earnest forum
#

setType doesnt return anything

#
 Block block = world.getBlockAt(gen_x, 100, gen_z);
block.setType(Material.CHEST);
#

@quaint mantle

quaint mantle
#

oh

#

great

#

yeah that makes sense

flat olive
#

how do I get whatever is in the first argument and whatever ends off the last bit of the argument

#

args[0:-1]?

#

or is it args[-1:0]

ivory sleet
#

no java doesnt have that

flat olive
#

wtf?

#

js

#

and python do

ivory sleet
#

yes

flat olive
#

bro WHAT

earnest forum
#

java isnt js and python

flat olive
#

how can I do that thne

earnest forum
#

if you want to get the last argument you get the length of the args array and then subtract it by 1

river oracle
#

for loops!

#

or just basic math

earnest forum
ivory sleet
ivory sleet
#

I mean they only add features if proper motivation is given else than arbitrary usefulness

flat olive
#

how would I setcustom name to all the args they provide instead of just one

earnest forum
#

for loop

flat olive
#

I cant use for loops ?

quaint mantle
#

Im making a care package plugin and im just trying to figure out how i can make the care package spawn ON surface, im randomizing the x,y,z but i want the package to be on surface and if its meant to spawn in a ocean/over water, itll restart the randomization

i am an extreme beginner so if you guys do know, please dumb it down a lil lol

flat olive
#

hologram.setCustomName(ChatColor.RED + args[0]);
I cant use a variable and keep adding onto it and setting it

somber hull
#

Lemme find it

#

Your trying to find the highest solid block right

quaint mantle
#

more or less yeah

quaint mantle
#

i want it to spawn on any available block but not inside of one

earnest forum
#

world#gethighestblock(x,z) I think

somber hull
#

That one

#

Yea

#

It’s

tranquil viper
#

Is Bukkit.getServer().broadcast() supposed to be deprecated?

somber hull
sour brook
somber hull
quaint mantle
#

im gonna try it out

tranquil viper
ivory sleet
#

if its paper

#

since they favor adventure

tranquil viper
#

Oh I forgot I'm using paper for this project, nevermind

#

Whilst you're here though, what should I put for the permission if I want it to be null?

ivory sleet
#

uh

#

broadcast is permission based

tranquil viper
#

Within paper using a string yes

quaint mantle
#

it worked! tyvm

somber hull
tranquil viper
#

Whatever I'll just go learn how to do it the way they want me to

#

Even though I'll probably never use paper again

ivory sleet
#

use Bukkit.getServer().sendMessage() if you wanna do it without permission

#

(paper only)

quaint mantle
#

so my next and hopefully last question for a while is, how can I make an armorstand and make it spawn at an exact location? this goes hand in hand with the care package

tranquil viper
ivory sleet
#

Component.text("blah")

tranquil viper
#

I've used them briefly in the past but I lowkey forgot

tranquil viper
#

lmfao

#

thank you very much

ivory sleet
#

with styling it gets a bit more intricate

#

but ye

sour brook
quaint mantle
earnest forum
#

spawn entity has location argument

quaint mantle
#

ah yep im dumb

gleaming olive
#

wdym subtract health ? I dont want double damage, i just want double attack speed..

earnest forum
#

might be some way to do it with nms

gleaming olive
#

aw

#

nms o:

#

ok il'l try that

sour brook
earnest forum
#

Add a " " after

flat olive
#

I am

#

trying rn

#

to do that

sour brook
quaint mantle
#
Location location = new Location(gen_x, 100, gen_z);```
im misunderstanding something here :thonk:
sour brook
#

StringBuilder builder = new StringBuilder();
for(int i = 1; i < args.length; i++) {
builder.addend(args[i] + " ");
}

flat olive
#

Nice that works

#

now I need to figure out the super hard part

#

different lines

#

I think I want to make a specific system for this

#

after the hologram armor stand is made give them a random generated ID

#

they can take that id and add a line to the hologram, what it does is make a new hologram with whatever text in the same location as the hologram given (the id given) just subtract y value some

sour brook
quaint mantle
#
Location location = new Location(player.getWorld(), gen_x, world.getHighestBlockYAt(gen_x, gen_z), gen_z);
            world.spawnEntity(location, EntityType.ARMOR_STAND);```
This code spawns it perfectly, now how can i make my armorstand invisible and give it a name? im not sure how to access the armorstand itself
earnest forum
#

store the entity when you spawn it

#

Entity e = world.spawn....

#

you can then cast it to ArmorStand which has cool stuff

quaint mantle
#

i saw a ArmorStand class too, would that work too?

#

oh

earnest forum
#

yea

flat olive
#
ArmorStand hologram = (ArmorStand) player.getWorld().spawnEntity(player.getLocation(), EntityType.ARMOR_STAND);
                hologram.setGravity(false);
                hologram.setVisible(false);
                hologram.setCustomNameVisible(true);
#

thats for you

#

anyways

sour brook
#

armorStand.setVisible(false);

flat olive
#

how can I make this an NPC

#

instead of armor stand

earnest forum
#

nms

flat olive
#

what is nms

sour brook
earnest forum
#

basically mojang's code

#

spigot is an API which builds on mojang's code and makes it easier

sour brook
earnest forum
#

it's basically packets

flat olive
#

so... can I just make an npc in the same location the armor stand gets created at?

earnest forum
#

you can Google player npc tutorials on YouTube

#

you basically have to make a fake player

flat olive
#

right

sour brook
#

Ye

earnest forum
#

I'm on phone and I think teixayo is too so it's probably best to look up a tutorial

ivory sleet
#

Use citizens

#

It handles everything you don’t want to lay a finger on

flat olive
#

this is nms?

sour brook
#

Yep

flat olive
#

alr

quaint mantle
#
ArmorStand entity = (ArmorStand) world.spawnEntity(location, EntityType.ARMOR_STAND);
            entity.setCustomName(ChatColor.translateAlternateColorCodes('&', "&l&cCARE PACKAGE!!!"));

it spawns but it doesnt have the custom name..

compact haven
#

entity.setCustomNameVisible(true)

quaint mantle
#

oh my bad didnt see it

tranquil viper
#
    public void particilizeAirdrop(Location airdropLoc) {

        Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {

            int i = 10;

            @Override
            public void run() {
                if (i <= 0) {
                    Bukkit.getScheduler().cancelTask(how to get the task id);
                }

                airdropLoc.add(0, i, 0).getWorld().spawnParticle(Particle.FIREWORKS_SPARK, airdropLoc.add(0, i, 0), 8, 0.2F, 0F, 0.2F);
                i--;
            }
        }, 0, 10);
    }

I have this method that particilizes an airdrop, but I'm not sure how to cancel it after it runs 10 times. I don't want to create a variable outside the loop because then it would be replaced if someone places a different airdrop and the task would never be cancelled. Any ideas?

quaint mantle
#

so ive got a chest, how can i add an item with something like efficiency 6 or protection5 to the chest?

tranquil viper
#

Make an ItemStack[], add the item you want to the array, then set the contents to the array

#

Or just make an ItemStack and add it to the chests inventory

#

Either way works

quaint mantle
#

main issue im facing is getting the item enchanted

#

how can i make it an enchanted item

chrome beacon
#

Or addUnsafeEnchantment if you want to enchant highee levels

quaint mantle
#

oh thank god you told me about unsafe

#

and does anyone have a little guide on how to make custom enchants?

earnest forum
#

it's really bad

quaint mantle
#

yeah me neither, i decided against it

earnest forum
#

I recommend making your own enchantment system

quaint mantle
#

and is there a like PlayerAttack event? for when a player hits an entity

earnest forum
#

EntityDamageByEntityEvent

#

check if the Damager is a player

tranquil viper
chrome beacon
#

It's still really messy to deal with

#

Highly recommend using an already existing plugins api

tranquil viper
#

It's a fun project and you learn a lot from it

chrome beacon
#

It's fun until you realize how creative mode works

woeful moon
#

How can you get a player's IP (such as 12.34.56.78)? I've tried Player#getAddress, but it returns null.

tranquil viper
#

the lore is for show

dreamy arrow
#

hello

#

people

tranquil viper
#

hi BikGamer!

dreamy arrow
#

i need help my buildtools arent installing

#
Exception in thread "main" java.lang.RuntimeException: Error running command, return status !=0: [C:\Windows\system32\cmd.exe, /D, /C, I:\Developement\BuildTools\apache-maven-3.6.0/bin/mvn.cmd, -Dbt.name=582a, clean, install]
        at org.spigotmc.builder.Builder.runProcess0(Builder.java:973)
        at org.spigotmc.builder.Builder.runProcess(Builder.java:904)
        at org.spigotmc.builder.Builder.runMaven(Builder.java:873)
        at org.spigotmc.builder.Builder.main(Builder.java:698)
        at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)
#

this is wat error i get

tranquil viper
woeful moon
#

It's a little more complicated than that, I need to get it outside of any event

#

where I only have the Player object

chrome beacon
undone axleBOT
tranquil viper
#

Ok so here: Store it in a database or something when a player logs in, then you can just access the database to get the ip

tranquil viper
woeful moon
#

Thanks for the tip

chrome beacon
#

There can be multiple players with the same name

#

It will break stuff

tranquil viper
#

That's why I just said to use uuids :p

chrome beacon
#

Yeah just explaining why

tranquil viper
#

Ah, also all the methods using BukkitRunnable are deprecated?

chrome beacon
#

No

#

You should just use the BukkitRunnable directly

tranquil viper
#

ohhh

#

I see now

#

That's what I get for coding at 12am lmao

#

thank you

chrome beacon
#

Sleep is important

tranquil viper
#

Indeed

#

I'm in one of those periods of time where I just can't stop coding

#

Then I'll get burned out in a few months ago

#

It's a whole cycle at this point

brittle lily
#

Hey Guys I'm making Warp Plugin and I wanna make warp list command How can I get Warps name from config?

tranquil viper
#

string lists

#

configuration sections

#

few different ways to do it tbh

heady pumice
#

Im a bit confused about how to properly depend on another one of my plugins.
I thought i always need to get the plugin instance by doing PluginManager.getPlugin etc etc or whatever.
Braindead i wrote it like PluginMainClass.getWhatever and it works fine, is that intended or did i just not get far enough to encounter issues?

little panther
#

Hey, im kinda new to coding and trying to learn hashmaps for a plugin. Is there a way to sort information after value to make a leaderboard?

quiet ice
#

Now that is a complicated problem

heady pumice
quiet ice
#

Generally you wouldn't want to use HashMap but rather LinkedHashMap for displaying the sorted key-value pairs

#

And then sort the linked hashmap through clearing the whole map and inserting the elements in their sorted order

little panther
#

do you have some sort of example, sorry if thats too annoying to get 😄

quiet ice
#

In one of my plugins I instead use TreeSet using a custom immutable datatype that stores player UUID and player score - however it's #equals and #hashcode operations are rigged to only compare UUID where as the compareTo compares only the score. You'd need to delete and reinsert the datatype to update the score however and I am not overly sure if that really works since I have only used that approach in plugins I use for my own server which is pretty much empty

#

(Don't comment on the rest of the code - I know that it is absolutely trash)

little panther
#

but yea, i think i get what you have done

iron glade
#

Any idea why this keeps teleporting me into the ground like this?

Location newLoc = p.getLocation().clone().add(xDistance, 0, zDistance);
p.teleport(newLoc.getWorld().getHighestBlockAt(newLoc).getLocation());```
quiet ice
#

Probably because it is the highest block but that will still be non-air (you'd need to add 1 to y to get the air block)

iron glade
#

So I'd have to add (0, 1, 0) to land on top of it

#

alright

quiet ice
#

Most likely

iron glade
#

Is there a reason I'm always facing the same direction event though setting the yaw randomly

sacred mountain
#

yaw randomly between what values

iron glade
#

-180 to +180

sacred mountain
iron glade
#

always facing 0 (south)

#
        Random r = new Random();
        float randomYaw = -180 + r.nextFloat() * 360;

        Location newLoc = p.getLocation().clone().add(xDistance, 0, zDistance);
        newLoc.setYaw(randomYaw);```
sacred mountain
#

and yeah getting the highest location will put you in the block

#

so add 1

iron glade
#

works fine now

sacred mountain
#

alr

#

r.nextFloat(min, max)?

#

or is that not a thing

brittle lily
#

How can I string of String Path?I will save a many warps. and I wanna make list of them. How can I get String of their name

sacred mountain
#

im not sure what the -180 * r.nextFloat() stuff is

iron glade
#

it's basically the same formula to set bounds

#

min and max

#

min + r.nextFloat() * (max - min)

iron glade
#

the generated values are fine, but it's not setting them

sharp kayak
#

how do i add skins to player heads in an inventory?

iron glade
jagged quail
#

?wiki

undone axleBOT
iron glade
drowsy helm
#

so whats stopping you from jusit getting the player's uuid and removing it?

#

@jagged quail

jagged quail
#

?paste

undone axleBOT
jagged quail
dreamy arrow
#

@drowsy helm :v can I get some help with buildtools

dreamy arrow
#

Wait let me post the logs

drowsy helm
earnest forum
#

PlayerQuitEvent?

#

or make a method

dreamy arrow
#

there is an error

jagged quail
#

so make this public?

#

and maybe move the @Override up

drowsy helm
#

yeah

#

nah leave the override

earnest forum
#

store an instance of the class too

#

dont wanna make 2 different hashsets

drowsy helm
dreamy arrow
#

java -jar BuildTools.jar --rev 1.8.8

jagged quail
dreamy arrow
#

who r u replying to

jagged quail
# earnest forum store an instance of the class too
package me.oliver193.mecha.commands;

import me.oliver193.mecha.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public class FlyCommand implements CommandExecutor {

    public final Set<UUID> flyingPlayers = new HashSet<>();
    @Override

    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if (!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cThis command can only be used by players.");
            return true;
        }

        Player player = (Player) commandSender;
        // Enable/disable fly mode
        player.setAllowFlight(flyingPlayers.add(player.getUniqueId()));
        if (player.getAllowFlight()) Msg.send(player, "&aYou can now fly!");
        else Msg.send(player, "&cYou can no longer fly!");
        if (!player.getAllowFlight()) {
            flyingPlayers.remove(player.getUniqueId());
        }
        return true;
    }
}
``` how would this make 2 hashsets?
quaint mantle
#

no

#

dont make it public

jagged quail
quaint mantle
#

public variable bad

#

public variable mean can be reassigned

#

dont do that

dreamy arrow
earnest forum
dreamy arrow
#

right in here

jagged quail
#

your basically on your own if you have issues unless people want to help

dreamy arrow
#

but worked on my ubuntu system. buildtools isnt installing on main system

jagged quail
dreamy arrow
#

java 8

jagged quail
#

do you have git installed?

dreamy arrow
#

u mean git bash?

#

ye

jagged quail
#

hm

#

well it should work then

dreamy arrow
#

there is a java runtime rror

jagged quail
#

send the log in

dreamy arrow
#

i even tried installing latest on windows with latest java still doesnt work

jagged quail
#

?paste

undone axleBOT
jagged quail
#
[ERROR] I:\Developement\BuildTools\CraftBukkit\src\main\java\net\minecraft\server\DedicatedServer.java:[1] The type org.apache.logging.log4j.util.Supplier cannot be resolved. It is indirectly referenced from required .class files```
#

try deleting buildtools and download it again

iron glade
# iron glade I start to belive that this is a bug rn, no matter what I try it's not setting y...

Nevermind, got it working now

        Random r = new Random();
        float randomYaw = r.nextFloat(-180, 180);

        Location newLoc = p.getLocation().clone().add(xDistance, 0, zDistance);
        p.teleport(new Location(newLoc.getWorld(), newLoc.getX(), newLoc.getWorld().getHighestBlockYAt(newLoc), newLoc.getZ(), randomYaw, newLoc.getPitch()).add(0, 1, 0));```
.getHighestBlockAt(loc).getLocation() seems to return a locatino with yaw and pitch = 0, that was the reason I think
dreamy arrow
#

yep tried 5 times already

#

even switched to windows power shell

#

same error

jagged quail
#

is the ubuntu system a vps or local system

dreamy arrow
#

then how am i gonna use it. it wouldnt be in my local maven repository

dreamy arrow
#

hmm

#

wot to do :v

jagged quail
# dreamy arrow wot to do :v

put this in your repositories <repository> <id>spigotmc-repo</id> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> </repository>

dreamy arrow
#

oh

#

wait can i even access nms

jagged quail
#

then this in dependencies <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.8.8-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency>

earnest forum
#

change spigot-api to spigot

jagged quail
#

doesn't intellij download it automatically for you?

earnest forum
#

no

#

spigot-api only includes what spigot builds on top of nms

jagged quail
#

i have this

earnest forum
#

you have to install that i think

#

its an intellij plugin

jagged quail
#

yes

earnest forum
#

because i havent got that

jagged quail
#

i did that

dreamy arrow
#
    <repositories>
        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.8.8-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>
jagged quail
dreamy arrow
#

its already like that but i can't access nms

earnest forum
#

change spigot-api to spigot

#

artifactId

opal juniper
#

You need build tools to install the nms to local yes

#

what error are you getting?

dreamy arrow
#

did

sacred mountain
dreamy arrow
opal juniper
#

yes

dreamy arrow
iron glade
dreamy arrow
#

thats the error log

opal juniper
#

hmmm thats weird

dreamy arrow
#

ik

#

oops caps

#

it installed on my ubuntu system perfectly

#

but in win10

jagged quail
#

@dreamy arrow install the plugin

#

on intellij

dreamy arrow
#

I DID

#

:V

#

oops caps

#

breh

jagged quail
#

this one?

dreamy arrow
#

i am going for nms not normal spigot

jagged quail
#

nms?

dreamy arrow
#

when u install buildtools it puts nms on ur local repository

jagged quail
#

ah

dreamy arrow
#

net.minecraft.server

jagged quail
#

oh

#

you are running it in git bash?

dreamy arrow
#

HMM

#

oops caps

#

breh this capos

vale ember
#

how can i get the base value of any Attribute?

sacred mountain
#

the default?

#

theres a thread on that

#

might help you

#

i dont think the spigot api has it

#

but then again its been like 4-5 years

opal juniper
#

why do you keep saying this

thorny dawn
#

can someone help? i am getting kotlin.UninitializedPropertyAccessException: lateinit property plugin has not been initialized in my dependancy injection]

jagged quail
#

ok i need to figure out how to make it remove the player from the hashlist when they leave

quiet ice
#

Listen for the PlayerQuitEvent (or however it is called)

jagged quail
#

in the main class?

brittle lily
#

?paste

undone axleBOT
thorny dawn
#

Bukkit.getScheduler().runTaskLater(Bukkit.getServer().pluginManager.getPlugin("Mobwars")!!, Runnable {}, 20) is this a good way to delay execution?

earnest forum
#

new Runnable

thorny dawn
#

kotlin

earnest forum
#

ah

#

idk

thorny dawn
#

the syntax is correct

#

im asking if the logic is correct

earnest forum
#

should work yeah

#

realistically should be using di for the plugin

thorny dawn
#

at least i haven figured out with my knowledge

earnest forum
#

what does !! do

quiet ice
#

!! or what?

thorny dawn
#

it assures that the plugin is not null

#

"?" means nullable and "!!" means not null

earnest forum
#

ah

quiet ice
#

Basically an Objects.requireNonNull, right?

thorny dawn
#

probably, not familiar of how it would be done in java

quiet ice
#

But yeah, I think this logic is right

thorny dawn
#

hm for some reason its not waiting before executing in my for loop

quiet ice
#

Are you sure that you are using runTaskLater?

thorny dawn
#

yeah

jagged quail
#

ok so i have this so far

quiet ice
#

Yank up the delay I guess, it might be too slow for you to notice the difference

jagged quail
#

i cant import that because it's private

#

should i make it public?

earnest forum
#

u should maybe make it static

#

since you only will have 1 set ever right

jagged quail
#

private final static

earnest forum
#

public

jagged quail
#
    private final static Set<UUID> flyingPlayers = new HashSet<>();

    @Override

    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if (!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cThis command can only be used by players.");
            return true;
        }

        Player player = (Player) commandSender;
        // Enable/disable fly mode
        player.setAllowFlight(flyingPlayers.add(player.getUniqueId()));
        if (player.getAllowFlight()) Msg.send(player, "&aYou can now fly!");
        else Msg.send(player, "&cYou can no longer fly!");
        if (!player.getAllowFlight()) {
            flyingPlayers.remove(player.getUniqueId());
        }
        return true;
    }```
earnest forum
#

you could make it public or make a static method which removes it

#

public static void removePlayer(UUID uuid){
remove from set
}
quiet ice
#

...

earnest forum
#

sorry im rushin

#

and ive never actually used a set idk if you use .remove on it lol

jagged quail
#

dont think that'll work

#

need to change it abit probably

earnest forum
#

oh my god

#

remove from set is not valid code

#

i just put it there as placeholder because i was rushing

iron glade
#

Anyone knows a way to get a random color code? java ChatColor.getByChar(Integer.toHexString(r.nextInt(16))) isn't working anymore for me

earnest forum
#

put that in there

jagged quail
earnest forum
#

whats the error

jagged quail
earnest forum
#

wait

#

can u show the whole code

jagged quail
#
package me.oliver193.mecha.commands;

import me.oliver193.mecha.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerQuitEvent;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;


public class FlyCommand implements CommandExecutor {

    public final static Set<UUID> flyingPlayers = new HashSet<>();


    @Override

    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if (!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cThis command can only be used by players.");
            return true;
        }

        Player player = (Player) commandSender;
        // Enable/disable fly mode
        player.setAllowFlight(flyingPlayers.add(player.getUniqueId()));
        if (player.getAllowFlight()) Msg.send(player, "&aYou can now fly!");
        else Msg.send(player, "&cYou can no longer fly!");
        if (!player.getAllowFlight()) {
            flyingPlayers.remove(player.getUniqueId());
        }
        return true;

        public static void removePlayer(UUID uuid) {
            flyingPlayers.remove(player.getUniqueId());
        }
    }
}
earnest forum
#

dont put the method inside the onCommand

#

do you actually know how to code in java

jagged quail
#

not really .-.

#

i'm just trying for the first time

earnest forum
#

you should probably learn

#

?learnjava

undone axleBOT
earnest forum
#

helps a lot

jagged quail
#

yeah

thorny dawn
#

Bukkit.getScheduler().runTaskLater(Bukkit.getPluginManager().getPlugin("Mobwars")!!, Runnable {}, 20) its still not waiting execution

dreamy arrow
#

:V breh its been 3 days and i still cant fix this problem

sharp flare
#

is looping a map entry set in a block break event a bad idea

quiet ice