#help-development

1 messages · Page 1777 of 1

jade grove
#

like give you the answers to code the plugin

round finch
#

your should work too

#

then it just need the world

#

i havn't try it myself

quaint mantle
worldly steppe
#

Hello

jade grove
#

just make a field in the config file for the overworld name and grab it from there using the Bukkit#getServer()#getWorld(plugin#getConfig#getString("world.name"))

worldly steppe
#

How can i do that on the plugin saber factions in one world you can't claim land but in other yes?

round finch
#

Checked--> org.bukkit.Location.Location(@Nullable World world, double x, double y, double z)

jade grove
#

how

#

lol

#

it just requires the user to change a string from a yaml file

young knoll
#

I think you can technically use a hacky method to get the main world

round finch
#

Interesting

hoary pawn
#

How can i use a string to create a item stack with a material named in the string?

tardy delta
#

You need to listen for the BlockBreakEvent

#

Check the getDrops()

#

In your case probably replace them

round finch
#

lol i will remember this! :)))

hybrid spoke
quaint mantle
hoary pawn
round finch
#

i havn't memorized the whole spigot api yet hahah🤣 fingerguns

hybrid spoke
#

just like everyone said

tardy delta
#

It might be worth looking up how to listen for events

young knoll
#

Don't use the middle one ideally

#

Otherwise you have to deal with the exception

hoary pawn
#

lol

round finch
#

1?

pine island
#

uh oh that dint work:

 @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event)
    {

        String PlayerName = event.getPlayer().getName();

        Bukkit.broadcastMessage(ChatColor.RED + "for debugging ONLY ");

        Location location = new Location(Bukkit.getWorlds().get(0), -206, 71.500, 47, -90, 0);

        event.getPlayer().teleport(location);









    }```
hoary pawn
#

just the one i picked

pine island
#

as in?

young knoll
#

Delay the teleport 1 tick

hoary pawn
#

like this ```java
itemstacks.put(filename, new ItemStack(Material#getMaterial(JsonValues.getValueMaterial();)));

hybrid spoke
#

and remove the semicolon

hoary pawn
#

i was confused about that lol

pine island
#

how do i delay a tick i never di it ;-;

young knoll
#

?scheduling

undone axleBOT
hybrid spoke
#

?scheduler

#

oh

#

scheduling

hasty prawn
hybrid spoke
#

my ban went too long

#

i forgot the commands

young knoll
#

Don’t get banned then 5head

hoary pawn
#

how can i make it deal with nulls

undone axleBOT
hoary pawn
#

if the material is null how can i make it print a error to console

young knoll
#

Save the result to a variable

#

And check variable == null

hoary pawn
#

ahh fuck that thats gonna be a problem later

round finch
#

if Item == null?

pine island
#

Omg i cant understand scheduling

#

its weird

ivory sleet
#

Maybe a little yeah

pine island
#

well can someoen tell me how to delay a tick?

#

a few

ivory sleet
#

Bukkit.getScheduler().runTaskLater(plugin,()->{},1L);

#

Where the lambda would be your "command"

pine island
#

in the curly braces right?

#

ok yeah i was correct

round finch
#

isn't there more simplified version i remember maybe?

young knoll
#

That is the simplified version

pine island
#

pplugin is red

young knoll
#

An instance of your main plugin class

pine island
#

oh...

young knoll
#

Actually I guess I should say the instance

pine island
#

yeah

#

it tells me to make my instance a object tho?

#

braces are better for bigger code

young knoll
#

You don’t need to use runTaskLater

#

Just runTask is fine

pine island
#

i need delay for the delay in tp

#

or it wont work

young knoll
#

runTask already has a delay

round finch
#

i'm curious i can't remember exactly how do you save Tasks to list?

young knoll
#

The method returns a BukkitRunnable

#

Or an int for some of the older methods

paper viper
#

do not

#

EVER

#

recommend that

#

lmfao

#

You are lucky I caught you

pine island
#

i wont be doing it anyways

paper viper
#

you are in for a treat

pine island
#

im already in my main class

hasty prawn
#

Oh thank God youre talking about Main and not Singleton vs DI

paper viper
#

Also, using static here is not needed and dependency injection is the preferred method

paper viper
#

lol

hasty prawn
#

oh now you're lame blushimcSad

#

Singleton is fine for the Main class instance

#

Since you only make one anyways

paper viper
#

It's fine, but it really isnt

#

lmfao

round finch
pine island
#

anyways what do do now?

paper viper
#

id give a rant to say like a bunch of stuff but conclure can do that for me

#

xD

hasty prawn
#

DI IMO with the main instance is just such a mess

paper viper
#

if you think its a mess, then use guice or smthing

pine island
hasty prawn
#

I've had this conversation with Conclure about this and never got any definitive answer for why one is better than the other

#

I agree DI is better for basically all class implementations, but when it comes down to the plugin instance it doesn't really matter

round finch
tardy delta
#

put this

#

if you're in your main class

young knoll
#

Well no, it doesn’t matter

pine island
young knoll
#

But teaching people to use static for one thing means they will use it for others

round finch
#

this works

pine island
#

works

hasty prawn
ivory sleet
#

I mean technically you never need static

#

It’s just that it happens to be handy sometimes

young knoll
#

Make a plugin with all static

tardy delta
#

store all your instances in an interface :pepe:

paper viper
#

lol

#

theres a dude who stored his plugin instance inside an enum

#

Like what the fuck

#

lmfao

hasty prawn
round finch
#

UH!??

tardy delta
#

smh

young knoll
#

Everyone knows you gotta use a record

tardy delta
paper viper
#

theres a tutorial with that??

tardy delta
#

idk

#

imagine

hasty prawn
#

Hopefully not

round finch
#

Stores Plugin in Plugin there stored in Plugin...
LMAO

paper viper
#

tbh, plugin instance inside an enum is not really much different between just making it static

#

sooooooo

tardy delta
#

mwoa

round finch
tardy delta
#

my teacher said rawr to me this morning :/

#

like

#

NO DONT RAWRR

young knoll
#

Serialize the plugin instances to bytes and store it in a database

round finch
#

wut is Serialize?

#

exactly

young knoll
tardy delta
#

omg cutie

#

🥵

round finch
tardy delta
#

eh here we go again

round finch
#

i'm not furry

#

🤣

tardy delta
#

indeed not funny

round finch
tardy delta
#

when is discord going to add pat emojis

round finch
young knoll
#

Pap pap

tardy delta
#

uhh goodnight

#

😇 uwu

steep bay
#

Hey, I am trying to get a maplist with materials and amounts from a config file.
Other things in the config file work.
I've tried to sysout-print the size of config.getMapList("test.items") but it is 0 and the MapList is empty. Is there sth wrong with my yaml syntax?

The Maplist in the config: https://www.toptal.com/developers/hastebin/hizozirize.yaml

worldly steppe
#

How can i do that on the plugin saber factions in one world you can't claim land but in other yes?

young knoll
#

Ask the plugin dev

undone axleBOT
round finch
#

i had to ask is it possible to put nothing as displayname on a item

#

like "";

#

i mean like complete Nothing

#

fx "";

#

closed off no space

young knoll
#

No

round finch
#

Ok

young knoll
#

An empty string will be ignored

round finch
#

then i gotta change it to space

ivory sleet
#

have you tried through properties.maven.compiler ?

round finch
#

Thanks guys l_chickheart

ivory sleet
#
<properties>
  <maven.compiler.source>16</maven.compiler.source>
  <maven.compiler.target>16</maven.compiler.target>
</properties>``` as opposed to configuring the maven compiler plugin
#

should be said, I don't use maven so Idk if that'd fix it

#

I presume you've tried invalidate caches and restart

#

do you have jdk 16 installed btw?

steep bay
ivory sleet
#

ah yeah

mortal hare
#

whoever added this into java:

if (entity instanceof Player player) { 
  player.sendMessage("auto casting!");
}

is a god for me

young knoll
#

Yes very nice

ivory sleet
#

pattern matching yuh

#

could very much be the issue 😅

jade grove
#

when setting an item to the player it returns this NPE:

Caused by: java.lang.NullPointerException
        at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:68) ~[server.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:46) ~[server.jar:git-Spigot-db6de12-18fbb24]
        at io.github.hexab.hub.items.impl.EnderButtItem.getItem(EnderButtItem.java:57) ~[?:?]
        at io.github.hexab.hub.listeners.PlayerListener.lambda$onPlayerJoin$1(PlayerListener.java:41) ~[?:?]
        at java.util.Arrays$ArrayList.forEach(Arrays.java:3880) ~[?:1.8.0_282]
        at io.github.hexab.hub.listeners.PlayerListener.onPlayerJoin(PlayerListener.java:40) ~[?:?]```
#

any solutions?

mortal hare
#

as far i can see

#

your EnderButtItem.getItem() returns null

#

specifically line 57

ivory sleet
#

did nothing lol but pog it was fixed

jade grove
# mortal hare specifically line 57
        Material material = Material.getMaterial(plugin.getConfig().getString("items.Enderbutt.item"));
        ItemStack item = new ItemStack(material);```
#

this is line 56 and 57

mortal hare
#

try adding debug message

#

for material variable

#

and see if it outputs as null or not

#

maybe your configuration classes are not set up properly

jade grove
#

nevermind

#

im stupid

#

i found the cause

mortal hare
#

it happens

jade grove
#

yeah LOL

#

the e and in enderbutt is capitalised for the path

#

whilst the config was undercase

mortal hare
#

i've wasted 8 hours thinking why my plugin wasnt working, to only find out that the the cause for it was that I uploaded the patched version to the world folder

mortal hare
#

too bad the player location objects are not thread safe

#

they kinda are

ivory sleet
#

extend and make it thread safe?

mortal hare
#

nah, that's not what i was thinking

#

i meant player location

ivory sleet
#

oh

#

yeah

lavish hemlock
#

you can make anything thread-safe :)

mortal hare
#

.getLocation() returns new location object everytime, but the pulled values to create that object are not from volatile or atomic fields

#

thus the info in the location objects could be stale

#
    public Location getLocation() {
        return new Location(this.getWorld(), this.entity.locX(), this.entity.locY(), this.entity.locZ(), this.entity.getBukkitYaw(), this.entity.getXRot());
    }
young knoll
#

Why is one getBukkitYaw

#

And the other getXRot

mortal hare
#

idk

#

its probably because minecraft uses

#

cursed trigonometry

#

for pitch and yaw

#

wiki.vg states that it doesnt follow classical trigonometry rules

young knoll
#

I see

mortal hare
#

i would love too see if paper could implement async player move event

#

but it would require lots of work probs

ivory sleet
#

holy yeah

quaint mantle
#

whats the point

young knoll
#

Async AsyncChatEvent

ancient plank
#

Everything async

quaint mantle
#

movement is not async, and a lots of thing relies on movement aswell

young knoll
#

Async entity AI when

ivory sleet
#

lol

quaint mantle
#

All attempts of async entities or worlds always led to world corruptions so

young knoll
#

Yeah it’s a shame

mortal hare
#

well, to make things like this it would require to rewrite the server software from scratch.

young knoll
#

AI is the heaviest thing atm

mortal hare
#

AI is not parallel?

quaint mantle
#

The problem that is rewriting from scratch is even harder

mortal hare
#

yes

young knoll
#

Mojang could achieve so much if they remade the game

quaint mantle
young knoll
#

But that wouldn’t be profitable

quaint mantle
#

On c++!

young knoll
#

That is still from like

#

2012

mortal hare
quaint mantle
#

However noone likes bedrock or any other attempt of full minecraft recode

mortal hare
#

Bedrock is fine, but its feeling

#

is just off

ivory sleet
mortal hare
#

Playing Bedrock after playing Java edition feels like playing GTA Definitive editions after playing OG versions lol

quaint mantle
#

Everything goes ok except client reimplementation

young knoll
#

Mojang should hire me

#

I recode entire game in 1 fortnight

#

Money back guarantee

ivory sleet
#

I'd actually give a shot in a multithreaded server implementation in C# or Java if it wasn't for the case that multithreading is incredibly excruciating to test

young knoll
#

C# would be nice

ivory sleet
#

yeah

quaint mantle
#

rust

ivory sleet
#

Does rust have multithread capabilities?

young knoll
#

I miss all the little things from C# that java doesn’t have

ivory sleet
#

yuh

quaint mantle
young knoll
ivory sleet
#

ah okay cool, I mean certain languages are to most extent meant to be single threaded although with functionality of running stuff async like js and dart ig

mortal hare
#

jesus fucking christ

#

64x64px images are being converted to hd images without blurry artifacts

young knoll
#

Yep

quaint mantle
#

Oh

young knoll
#

And it has funny side effects like ThisPersonDoesNotExist

quaint mantle
#

i used ESRGAN in 2019

mortal hare
#

imagine this technology for game texture streaming

limber mica
#

How can I detect if a player is speeding (using cheats)

young knoll
#

Not easily

limber mica
#

im using packets

mortal hare
limber mica
#

would I check though if their speed is faster than like 0.2?

round finch
young knoll
#

You gotta account for legit ways of going fast

mortal hare
#

it could prevent simple cheats

#

but its useless for more advanced ones

#

what you could check instead

#

is to have VL system

#

by checking the time travelled between two locations

limber mica
#

I do have a vl system

#

velocity?

round finch
#

it is pretty much just variables and checks

young knoll
#

Gotta get spigot to implement that PlayerCheatEvent

mortal hare
#

do a PR

limber mica
#

so would their first location be where ever they start then second is where the end?

round finch
mortal hare
#

yes

#

get rough time

#

how fast you can travel

round finch
#

that just a joke

#

terrible idear

mortal hare
#

but you need to make implementations for every type of movement speeds

round finch
#

Speed = Distance / time

Distance = point 1 - point 2

limber mica
#

then I'm already getting their two locations

#

Also im using these, Location locationLook = new Location(world, xLook, yLook, zLook, yawLook, pitchLook); Location lastLocationLook = getLocation() != null ? getLocation() : locationLook;

mortal hare
#

I suggest you not to develop anticheats by yourself

#

just get one from the web

limber mica
#

but i have a method that checks for the location

mortal hare
#

its a cat and a mouse game

#

you wouldnt have time to develop your own anticheat

limber mica
#

I'm doing this for experience

round finch
#

i mean you can if you got experience

mortal hare
#

he clearly doesn't

young knoll
#

All anti cheats must combine into one

alpine urchin
round finch
#

XD

alpine urchin
#

where did jonhan go

#

he just kinda dissapeared for a bit

#

atleast on discord

young knoll
#

Is he someone that actually knew how to make tutorials

round finch
young knoll
#

I tried to detect fly with player.isFlying when I was a noob

ivory sleet
#

lol

young knoll
#

It didn’t work 😢

round finch
#

yes check if player is flying hacking lmao

#

player.isFlyingHacking();

young knoll
#

PR plz

round finch
#

it would be great additional API plugin

young knoll
#

I’ve never actually used an anti cheat, I just randomly check on players

#

The hackers are usually painfully obvious on a PvE server

round finch
#

if player is sus send to jail

young knoll
#

Jails are great

#

More servers gotta use em

round finch
#

most server think it is a waste

alpine urchin
#

just check if player.isFlying()

#

ez

#

dont fly

#

flying is cheating

#

/j

round finch
#

well if they arent having fly mode then they clearly hacking or floating

young knoll
#

My brain says a fly check would be easy

#

But I’m not even close to a anti cheat person, so probably not

round finch
#

i admit i bypass an anticheat by using float hacks

#

back then i were young

#

they only check if the player went up

#

so i slided forward to islands in air with float

#

people have evolve like anticheat so that won't work anymore

young knoll
#

Constant game of cat and mouse

#

No idea who is winning

mortal hare
#

fly check is not easy due to latency and spoofing of onground packet field

young knoll
#

Can’t you just like

#

Check if they are in the air and at a relatively constant y level

mortal hare
#

what if player timeout

#

in a middle of air

young knoll
#

Ban them anyway

round finch
#

check for lag

young knoll
#

Or take into account ping and lack of movement

round finch
#

it possible to win ageinst hacks

mortal hare
#

its not

young knoll
#

Maybe I’ll try to make an anti cheat one day... probably not though

mortal hare
#

its cat and mouse game

round finch
#

no

mortal hare
#

just like Antiviruses can't beat all of the viruses

round finch
#

it limted

young knoll
#

I much prefer gameplay plugins anyway

round finch
#

Check for packet

#

it is not like virus

#

they're not limted

mortal hare
#

if clientside kernel level anticheats couldnt beat hard cheaters, what would make serverside anticheat so special

young knoll
#

Ban everyone

#

100% effective

round finch
#

you make a server side anticheat

mortal hare
#

serverside anticheats couldnt work with 100% accuracy and efficiency at the same time

#

since movement is all clientside

#

movement could be interpolated into separate packets

#

and voila

round finch
#

clearly you're far off

mortal hare
#

if movement is not clientside, why latency doesnt effect the gameplay

#

server receives those position packets

#

and then checks them

#

but what if packets are manipulated in that way

#

server couldnt be sure

#

if he's cheating

round finch
#

you check if the packet legit to server

mortal hare
#

or its the other problems

#

like latency

#

or packet dropping

round finch
#

packet drop will just be ping drop

mortal hare
#

packet drop is not just a latency thing.

#

packets couldnt arrive at the server, due to connectivity issues

#

in order that server protocol expects to

round finch
#

no packet no change?

mortal hare
#

what if the client deliberately sends those packets out of order

#

how would you prevent that

#

the only way is to play guessing game of VL's

round finch
#

still Check if it is legit

young knoll
#

The best anti cheat would probably be:

  • Only auto ban in extreme cases
  • Stick to kick and log most of the time
  • accounts for ping
  • configurable
  • maybe some level of machine learning
mortal hare
#

for example client send onGround boolean with positional packets to the server

#

but most of the hacked clients deliberately inject their own code to prevent that

round finch
#

You Check if Packet is legit to the server stuff

mortal hare
#

that still wouldnt be as accurate as client information

#

as i said due to connectivity

#

it's a cat and mouse game, sure you can patch hacked client

round finch
#

and measure the legitimacy

#

Dont trust the Client jeez

mortal hare
#

VLs are not the solution to cheating. VL are probability calculator how suspicious the player is

round finch
#

how hard it is for you to figure it out

mortal hare
#

I do understand your concept

#

what i wanted to say that's is impossible to detect cheats with 100% accuracy unless hacked client made a mistake in their own code

west oxide
#

HELP

round finch
#

the only problem could be if the server itself lag
but i guess you can check the TPS

ivory sleet
#

?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. Create a thread in case the help channel you are using is already in use!

west oxide
#

idk why my plugin stopped working

#

all i did is add a new command

#

and it started showing this error on start and plugin doesnt work ```[00:50:50 INFO]: [BwCore] Enabling BwCore v1.0.0
[00:50:50 ERROR]: Error occurred while enabling BwCore v1.0.0 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "online.shakiz.BwCore.BwCore.getCommand(String)" is null
at online.shakiz.BwCore.BwCore.onEnable(BwCore.java:13) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:407) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:359) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:318) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:408) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:372) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:327) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:267) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:563) [patched.jar:git-PaperSpigot-"4c7641d"]
at java.base/java.lang.Thread.run(Thread.java:833) [?:?]
[00:50:50 INFO]: [BwCore] Disabling BwCore v1.0.0
[00:50:50 INFO]: Stopped BwCore...

[00:50:50 INFO]: Server permissions file permissions.yml is empty, ignoring it```

ivory sleet
#

1.8 😮

west oxide
#

yes

#

cuz pvp

round finch
#

@mortal hare if the server crashs and ban all there should be a reserve method for that time

west oxide
#

yes

#

should i send the command's code ?

eternal oxide
#

command is not in your plugin.yml (the one thats in the jar)

young knoll
#

You almost certainly did not add it to the plugin.yml

winged ocean
#

still learning java in general, but making plugins as well, new to this so if i ask something dumb, plz just point it out
im just wondering how i can use fee to deduct player hp, and also check that their hp isnt too low to die in the process

west oxide
#

fly:
description: Toggles fly mode.
usage: /fly username

#

this is what i added to the plugins?yml file

mortal hare
winged ocean
#

well fee works fori tems

#

idk

ivory sleet
#

what is fee lol

winged ocean
#

just variable

west oxide
#

getCommand("fly").setExecutor(new Fly());

round finch
#

@mortal hare i mean if someone manage to crash your whole server RIP F

eternal oxide
undone axleBOT
west oxide
#
  heal:
    description: Heals player to max health
    usage : /heal username
  feed:
    description: Heals player to max health
    usage: /feed username
  gmc:
    description: Sets player's gamemode to creative
    usage: /gmc username
    aliases: c
  gms:
    description: Sets player's gamemode to creative
    usage: /gms username
    aliases: s
  gmsp:
    description: Sets player's gamemode to creative
    usage: /gmsp username
    aliases: sp
  bangui:
    description: bans players with a gui
    usage: /bangui
  online:
    description: shows online players
    usage: /online
  enchant:
    description: enchant's players' hand item
    usage: /enchant enchantment level username
    aliases: et
    fly:
      description: Toggles fly mode.
      usage: /fly username
west oxide
eternal oxide
#

see the error?

round finch
#

but it simple logical steps Sir

west oxide
west oxide
eternal oxide
#

look at yoru list of commands. you can see the error

west oxide
#

what

round finch
#

but not Anymous
just a Minecraft player

eternal oxide
#

just look at it in teh paste

winged ocean
#

conclure do u mind if i msg u instead

mortal hare
west oxide
#

ohhhhhh

#

i get it now

#

ok thank you very much

#

am stupid

round finch
west oxide
#

yeah

winged ocean
#
        if (label.equalsIgnoreCase("tribute")) {
            if (!(sender instanceof Player)) {
                sender.sendMessage("Console can't use tribute.");
                return true;
            }
            Player player = (Player) sender;
            notsurehowtodeducthp```
#

any ideas, im clueless how to do remove hp

round finch
winged ocean
#

and also check for the fact they have sufficient amounts

young knoll
#

player.setHealth and getHealth

#

Use the javadocs

#

?jd

winged ocean
#

oh ty

west oxide
#

command worked :D

#

first command with no tutorials whilst making

round finch
#

Check for offline player is online?

west oxide
#

just used the api

round finch
#

good job

west oxide
west oxide
#

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class Fly implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (args.length == 0) {
            Player p = (Player) sender;
            if (p.getAllowFlight() == false) {
                p.setAllowFlight(true);
                p.sendMessage("§dYou have enabled flight.");
            } else if (p.getAllowFlight() == true) {
                p.setAllowFlight(false);
                p.sendMessage("§dYou have disabled flight.");
            }
        }
        else {
            Player target = Bukkit.getPlayerExact(args[0]);
            if (target != null){


                if (target.getAllowFlight() == false) {
                target.setAllowFlight(true);
                sender.sendMessage("§denabled flight for "+ target.getDisplayName()+".");
                }
                else if (target.getAllowFlight() == true) {
                target.setAllowFlight(false);
                sender.sendMessage("§ddisabled flight for "+ target.getDisplayName()+".");
                }
            }
            else    if(target == null) {
                sender.sendMessage("§cPlayer not found or offline.");
            }
        return true;
        }
        return true;
    }
}
round finch
west oxide
#

i used this to check

#

yeah

#

:D

round finch
west oxide
#

gtg sleep gn everyone and thanks :D

round finch
#

yeah if player is null then they're not online

#

then it will return null if player is not on server

west oxide
#

yeah

round finch
#

gl

#

🙂

#

Someone quick tell which Event is for Checking Item Move?

#

is it InventoryMoveItemEvent?

limber mica
round finch
#

i will try quick

sullen marlin
#

what is item move

young knoll
#

Gonna need to be more specific

round finch
#

i wanna check if item is gonna be moved by player in inventory

young knoll
#

InventoryClickEvent

sullen marlin
#

InventoryClickEvent mostly

round finch
#

then Cancel

#

hmm

#

ok

mortal hare
limber mica
#

like the comment section?

mortal hare
#

yes

round finch
#

is it wrong to use static for hashmaps?

#

or what is the proper way to do it?

ivory sleet
#

Not wrong

#

But it makes your code architecture very complex unnecessarily

round finch
#

just wanna know more

ivory sleet
#

Usually the usage of a map indicates some sort of registry/manager/cache/repository class

#

So encapsulate the map and create a class with the functionality you desire

limber mica
ivory sleet
#

Then just pass the instance of that class (:

limber mica
#

its weird how if I sprint and jump holding it down it only counts once

#

for it to go off it has to be jump and sprint etc..

#

I have to spam it

stone sinew
#

Whats the best way to get folders in order from the source folder to a file?
I was gonna do a recursion method but feel like there is something better.

Ex; source-folder/folder-1/folder-2/file.file
I want to get a list in order so I can check if the folder exists.

or if anyone has a better idea then going through all folders checking if they exist then using mk.dir(); createNewFile()

ivory sleet
#

Maybe Files class got some method for that

#

like Files::walk if im not wrong

#

altho that one might actually do it the other way

eternal oxide
#

just call mkdirs(), it will create teh tree

round finch
#

File f = new File(Path);

YamlConfiguration Config = new YamConfiguration.load(file)

stone sinew
ivory sleet
#

File::getParentFile

#

then use mkdirs() on the parent file instance

round finch
#

yes Parent is Folder

stone sinew
#

lets say the file is in folder-6 it wouldn't get all the folders before it.

ivory sleet
#

given
source-folder/folder-1/folder-2/file.file

ivory sleet
#

new File("source-folder/folder-1/folder-2/file.file").getParentFile().mkdirs() would create the necessary directories which in this case would be source-folder if not exists, folder-1 if not exists or folder-2 if not exists

stone sinew
#

Ill try it. I also found some method in Files that I am gonna try.

ivory sleet
#

yeah

#

if you can

#

use Files and Path over File

#

as File is obsolete and has some problems

#

Files::createDirectories might be your friend

#

and Files::exists as well as Files::isDirectory

#

also you can get a path instance by File::toPath Paths::get or Path::of iirc

stone sinew
#

Yeah checking out Files.list(path)

ivory sleet
#

pog

young knoll
#

JarFile 😓

round finch
#

here is my terriable attemp

``
public static void CreateFolders(File File_Input) {
if (!File_Input.getParentFile().exists() && File_Input != null) {
File_Input.getParentFile().mkdirs();
try {
File_Input.getParentFile().createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}

``

ivory sleet
#

C# coder?

round finch
#

me?

ivory sleet
#

yeah

young knoll
#

Checking null after calling getParentFile

#

🤔

round finch
#

i got no knowledge of any C,s

ivory sleet
#

ah okay

opal juniper
#

cake?

round finch
#

but nice try Sherlock

young knoll
#

Then why no follow java conventions

round finch
#

:))

opal juniper
#

i like cake

young knoll
#

:(

ivory sleet
#

cuz C# function name convention is like GetMyCakeNow(true)

opal juniper
#

which type of cake

young knoll
#

UpperCamelCase < lowerCamelCase

round finch
#

i were Following a Tutorial on clean code

ivory sleet
#

flying cake is pretty tasty

ivory sleet
young knoll
#

Hope it wasn’t a java tutorial

round finch
#

i hate inconsistency

ivory sleet
#

same lol

round finch
#

having motheds start with lowercase

#

and then have some with Uppercase

young knoll
#

Then don’t

round finch
young knoll
#

They should all be lowerCamelCase in java

#

Same with variables

round finch
#

i chose to keep it UpperCase

#

mostly for readability

opal juniper
#

unpopular opinion: idc if they are not the language specific conventions as long as they are consistent across an api

young knoll
#

Yeah that’s fair

#

OTG uses C# style {}

#

Although if you are working anywhere in business you probably want to follow language conventions

round finch
#

If(Something)

if(Something2)

no baskets 😂

ivory sleet
# round finch i chose to keep it UpperCase

itsvollx I wholeheartedly respect UpperCase when it comes to class names, but you should follow java naming conventions to the letter as it makes it easier for other java devs to read your code etc

#

well yaa

#

I mean you do you but yeah 😄

round finch
#

Thanks

#

i will consider it

ivory sleet
#

👍

young knoll
#

Alright new language: no upper case ever

round finch
#

i'm trying to learn clean coding

young knoll
#

Not even in strings

ivory sleet
#

No1 will kill you if you refuse to follow it so no worries in case you disregard

#

yeah clean code is hard because it has a very big sense of being a subjective topic

#

though in object oriented programming we do have some soft things you might want to consider

round finch
#

best way i saw was keep it simple and readable

young knoll
#

That’s why I make my code take daily showers

ivory sleet
#

yeah

sleek pond
#

any way to stop an item from dying in the void?

ivory sleet
#

simplicity is good I agree

sleek pond
#

EntityDamageEvent doesn't work with void damage for some reason

ivory sleet
young knoll
#

It should

sleek pond
#

works with cactus/lava/fire and everything else

lavish hemlock
young knoll
#

But does it fire for Items?

sleek pond
#

yes

#

it does

young knoll
#

Weird

round finch
#

please run a check?

#

i wanna know

sleek pond
#

me?

round finch
#

yeah

#

i'm lazy

sleek pond
#

how would one do that

young knoll
#

Sysout the damage cause

round finch
#

if Entity is Item

cancel

sleek pond
#

also this is my code rn

#
@EventHandler
    public void onEntityDamageEvent(EntityDamageEvent e){
        if(!plugin.getCrownManager().isRunning()) return;

        if(e.getEntity().getType() != EntityType.DROPPED_ITEM) return;
        ItemStack itemStack = ((Item)e.getEntity()).getItemStack();
        if(!plugin.getCrownManager().isCrown(itemStack)) return;
        plugin.getCrownManager().setCrownState(CrownState.DAMAGE, null, ((Item)e.getEntity()), false); //Re-teleport
        e.setCancelled(true);
    }
#

it works with everything but void

lavish hemlock
#

actually quite clean, nice

paper viper
#

the only thing i can say is make a variable for the cast

young knoll
#

Nitpick time

paper viper
#

but its good in general

young knoll
#

Pretty sure you can just do event.getEntityType

round finch
ivory sleet
#

Maybe wanna use more explanatory variables and make the entire function on the same abstraction level if we’re being pedantic

paper viper
#

And also use some final

#

and also consider storing stuff as vars yeah

sleek pond
#

I came here for help with the event not my code quality

paper viper
#

cause item is like any entity

young knoll
#

I mean

paper viper
#

and when entities fall in the void

#

they take damage

young knoll
#

This is Mojang

paper viper
#

but idk

round finch
#

not if it does Item Remove

paper viper
#

ik, but its still an entity

#

but idk

sleek pond
#

i can try depugging out the damage

round finch
#

No Damage if it doesn't exist

sleek pond
#

heh?

round finch
#

Check if there any damage

#

if not...

#

then it is deleting item

#

output Entity Item Damage

#

i just wanna be 100% sure

sleek pond
#

ye ye i'm doing that rn

round finch
#

try with lava too XD

sleek pond
#

cd ../..

#

oops

#

that's not console

round finch
#

did you try with Bukkit.broadcastMessage();

sleek pond
#

huh?

#

i'm logging it right now, my server just takes ages to start up

round finch
#

use broadcastmessage

sleek pond
#

why?

round finch
#

it won't take ages

#

and you can see it ingame

sleek pond
#

no

young knoll
#

It doesn’t take any less time than sysout

sleek pond
#

yea

sleek pond
round finch
sleek pond
#

but im a chad, so I use sysout

#

also spigot doesn't flame me

round finch
#

But Console ... System.out.print

ivory sleet
#

sysout yeah same tbf

#

cant be helped I still use sysout lol

stone sinew
#

@ivory sleet

public List<File> getFoldersFromSource(File f) {
    List<File> folders = new ArrayList<>();
    try {
        List<Path> paths = Files.list(Paths.get(f.getPath())).filter(path -> new File(path.toString()).isDirectory()).collect(Collectors.toList());
        paths.forEach(p -> folders.add(new File(p.toString())));
    } catch (IOException e) {
        e.printStackTrace();
    }
    return folders;
}

Files.list(path)
Only works if the file is already generated 😦

paper viper
#

why are you using both Path and File

#

use one

round finch
#

my server told to use to Logger instead of System out put

young knoll
#

Yeah paper liked to yell at me while debugging

ivory sleet
#

yapperyaps, what are you trying to do now again?

young knoll
#

Fricken nerd

paper viper
#

lol

ivory sleet
#

yeah logger is better

#

or well even better, mock bukkit lol

round finch
young knoll
#

I mean I could always attach a debugger

stone sinew
young knoll
#

But meh

paper viper
#

you know

ivory sleet
#

yeah it could better in some angles

paper viper
round finch
#

it actually doesn't output with System out on my pc on spigot

stone sinew
paper viper
#

just use Path only

#

or File only

ivory sleet
#

but it does work just fine for automating tests

round finch
#

until i click on console

paper viper
#

but the first one is better

paper viper
#

im thinking of setting up automated testing

#

lol

young knoll
#

I pop the disk tray as a debug output

ivory sleet
#

yeah its so helpful

limber mica
#

What's the difference between Accel and Delta?

ivory sleet
#

delta like the difference between two values?

round finch
#

@sleek pond any updates?

limber mica
#

yea

round finch
#

i got Creative way Store Items into List Before it falls into the void

young knoll
#

I mean if damage doesn’t work then you gotta use a runnable

paper viper
#

path -> new File(path.toString()).isDirectory())

#

you can just do path -> Files.isDirectory(path)

sleek pond
#

Don't pay attention to TELEPORT PODIUM and DAMAGE

stone sinew
#

👍 doesn't fix that Files.list() requires and already created folder/file

sleek pond
#

those after it said teleport i dropped the crown into the void

round finch
#

where should i look?

sleek pond
#

and FIRE_TICK is me setting it on fire

torn lintel
#

No I'm not.

sleek pond
paper viper
sleek pond
paper viper
#

im just saying that you should try to use one or the other cause converting back and forth will make ur code messy

round finch
#

did it output?

sleek pond
#

there isn't a sysout

#

look at the more detailed screenshots

round finch
#

ok then not

ivory sleet
#
public static List<Path> getUncreatedDirectoriesFromFile(Path path) {
  if (Files.exists(path)) {
    return Collections.emptyList();
  }
  List<Path> uncreatedPaths = new LinkedList<>();
  parent = path.getParent();
  while (!Files.exists(parent)) {
    uncreatedPaths.add(parent);
    parent = parent.getParent();
  }
  return uncreatedPaths;
}```
 @stone sinew
#

Idk, is this what you're looking for?

sleek pond
stone sinew
#

But yes kinda

sleek pond
young knoll
#

Use a runnable and check if the item is below y 0

ivory sleet
#

there's nothing wrong with a while loop

torn lintel
paper viper
#

Whats wrong with while lol

young knoll
#

Yes because checking a single thing is gonna nuke the sever

ivory sleet
#

Files::list does some iteration also

sleek pond
#

you never know how many crowns I have

torn lintel
#

Maybe anyone can craft one?
Idk

young knoll
#

Alright then, cover the void in lava

torn lintel
limber mica
ivory sleet
#

well

#

delta is the difference

#

as simple as that

#

the value is usually obtained through |a-b|

#

@limber mica

#

anyways wym by accel?

stone sinew
#

Merging the code so no one gets confused.

public List<Path> getFoldersFromSource(File f) {
    try {
        return Files.list(Paths.get(f.getPath())).filter(path -> new File(path.toString()).isDirectory()).collect(Collectors.toList());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
``` ```java
System.out.println("Testing file system...");
String path = ConfigManager.get().getSourceFolder().getPath();
for(int i = 0; i <= 6; i++)
    path = path+File.separator+"Folder-"+i;
ConfigManager.get().getFoldersFromSource(new File(path)).forEach(p -> System.out.println(p.toString()));

java.nio.file.NoSuchFileException: .\Folder-0\Folder-1\Folder-2\Folder-3\Folder-4\Folder-5\Folder-6

ivory sleet
#

still dont know what you're trying to achieve here

round finch
stone sinew
paper viper
#

Why??

sleek pond
paper viper
#

Why do you want to make your life harder??

ivory sleet
#

you're so confusing some times yapperyaps

round finch
sleek pond
#

u guys are spigot

ivory sleet
#

because it would lag the shit out of spigot

#

considering how often it might be called

stone sinew
torn lintel
#

They did tho, it has one.
Yapper you good?

ivory sleet
#

I guess paper got it way more performant due to asm generated event executors

round finch
#

spot on

old cloud
#

Using a BlockingDeque - is this queue.offerFirst(queue.take()); equivalent to "take without remove"?

ivory sleet
#

what implementation?

young knoll
#

There won’t be any incoming packets

#

But there will be outgoing ones

old cloud
round finch
#

ops wrong person

ivory sleet
#

lol nw

round finch
ivory sleet
#

getFirst is the simple peek at the top without removal

lavish hemlock
#

then the fuck is offer

round finch
#

wait it possible to Override the Void Deleting item?

ivory sleet
#

or well head rather than top but yeah

torn lintel
round finch
#

i wonder

old cloud
round finch
torn lintel
ivory sleet
#

wait if the queue is empty?

old cloud
#

I want "take" but without removal so basically while(queue.isEmpty());

round finch
torn lintel
#

atless

old cloud
# ivory sleet wait if the queue is empty?

take(): Retrieves and removes the head of the queue represented by this deque(in other words, the first element of this deque), waiting ifnecessary until an element becomes available

ivory sleet
paper viper
#

peek?

#

it gets the value

#

but doesnt remove it

old cloud
#

...

ivory sleet
#

Oh yeah SpinAndDrain

#

take might await an element

paper viper
#

im confused by what you're asking sorry

ivory sleet
#

Deque#getFirst would just throw you an exception if the instance is empty

old cloud
#

Yes thats exactly what I want, I just want to wait if the queue is empty until an element is there

ivory sleet
#

ah I see

paper viper
#

Yeah take blocks

old cloud
#

Shouldn't this queue.offerFirst(queue.take()); exactly do that? I mean its kinda dumb but idk any other way without a while loop

ivory sleet
#

yeah now when I understand what you mean

#

probably

hybrid spoke
#

but why do you want to offer the queue the first as the first

round finch
#

check index of one?

torn lintel
sleek pond
#

I think I'll do that you know

torn lintel
#

Thanks I knew it would work!

sleek pond
#

better than what some of this lot has suggested

round finch
#

if player gets hit steal item

#

on low heath

#

or dying

sleek pond
#

SpinAndDrain is typing...

old cloud
round finch
#

here some ideas

young knoll
#

How will that help if the void still doesn’t trigger the damage event

old cloud
#

And there is no takeButDontRemove

hybrid spoke
#

but.. why are you doing it this way?

#

just use a while or wait on the object

round finch
#

why not remove?

old cloud
round finch
#

then save?

hybrid spoke
#

its not

old cloud
#

ok, then I'll just use a while loop

round finch
#

i would get the index of the Player who left, and..
move all Players one down after that number?

#

if you wanna sort them ofcouse

old cloud
round finch
#

ok

#

ignore the other comment then

hollow hill
#

does anyone know how I would be able to give a world data?

Basically I mean like to generate a new world that's a map.

Like an arena or something.

round finch
#

wut world data?

#

you can getWorld?

hollow hill
#

basically I want to generate a world that's a copy of a world or something

young knoll
#

Just copy the folder and then createWorld to load it

round finch
#

OH

#

getWorld copy it

#

load it

hollow hill
#

createworld*

young knoll
#

By name

#

World name should match folder name

hollow hill
#

oooooh

#

so I getWorld then createWorld?

young knoll
#

Don’t need to getWorld

round finch
#

nah use createworld to load

hollow hill
#

how do I pass in the data then?

round finch
#

copy the Files

young knoll
#

What data

#

You can copy a world folder using regular java file apis

hollow hill
#

but how do I let the line know to use the file?

young knoll
#

You give it the name

hollow hill
#

the same name as the file?

hollow hill
#

like ./worlds/arena1?

young knoll
#

Should just be arena1

#

Iirc all world folders go in the root folder

round finch
#

FileUtils.copyDirectory(old Path, new Path)

hollow hill
worldly ingot
hollow hill
#

could I see like a small example or something?

worldly ingot
#

Where worlds are stored is actually configurable, so while by default it's in the root of the server, they may be placed elsewhere

near kite
#

Choco is typing..

round finch
#

you use Java Api to copy and paste files and directory

young knoll
#

Ah, well there you go you can use that

#

Never knew you could change that

#

For a server to be connected to bungee, does bungee cord have to be true in spigot.yml?

hollow hill
#

so I should do something like:


World duelsNewWorld = server.createWorld(new WorldCreator(fileName));

??

young knoll
#

Pretty much

hollow hill
#

so one last time because I'm really slow how do I let world creator access the file?

young knoll
#

With the name of the folder

hollow hill
#

or where should I put the file?

hollow bluff
#

You just type the file name basically

young knoll
#

You should put the file where all your other world folders are

round finch
#

it is case Sensitive

#

remember to put Exact name in

hollow hill
#

but I mean like say I use a host, where should I put the file then?

hollow bluff
#

Same place you would if you hosted it yourself

round finch
#

you mean copy world files to?

hollow hill
#

essentially

#

oh

#

I mean I want to send the world files to shockbyte, do you know where in shockbyte I should put them? like under what folder?

young knoll
#

The root folder is the default

round finch
#

Copy world Files to Path
if Files exist Then Not

this is auto copy and paste 👆

then load world

young knoll
#

Look for the folder with your other worlds in it

#

Put it there

hollow hill
#

I only have a world folder

#

world / world_the_nether / world_the_end

hollow bluff
#

same place those are located, all the other world folders should go

hollow hill
#

On shockwave it litterally just says put it in the spigot folder nothing else

#

shockbyte*

#

I'll try that really quick

round finch
#

yeah
YourServerFolder / YourWorldName

hollow bluff
#

All world folders should go in the default directory (same place you fine world, world_nether) and then you just type the folder name for the WorldCreator thing. That’s all you basically need to do

hollow hill
#

oh ok

#

sorry I took so long to understand lmao

round finch
#

it gotta be along with the other world map directory

#

beside it

hollow hill
#

alright

#

thank you 😁

round finch
#

sorry for any confusion 🙂

#

you welcome

hollow hill
#

no it's fine

round finch
#

i would glad help with what i can👍

hollow hill
#

also would I use "s or no "s

round finch
#

it gotta be Exact name to load

#

like your folder name

hollow hill
#

like "arena1" or arena1 ?

round finch
#

If Folder is arena1 then it must be arena1

hollow hill
#

alright

round finch
#

exactly has written

hollow hill
#

I just tested with the regular world file and it's giving an error

young knoll
#

You can’t load the default world

#

It’s already loaded

hollow hill
#

oh makes sense

round finch
#

yeah exactly has he said

#

then you would load the same world twice

round finch
young knoll
#

No

round finch
#

Oh big Sadge sadge

hollow hill
#

I have a question, if multiple people are using the same arena would it unload the world?

#

like if there was multiple arena1's

young knoll
#

You can’t have folders with the same name

round finch
hollow hill
#

so would I just have to have a lot of world folders?

round finch
#

the Files is the Data

hollow hill
#

or could I make and delete new ones based off of the orginal folder>

young knoll
#

You can do that, yes

round finch
#

yes

hollow hill
#

oh cool, would that make a new file as well?

#

or just a new world?

young knoll
#

What

hollow hill
#

I mean folder

round finch
#

copy world and paste world somewhere

young knoll
#

A world contains many files, what file are you referring to

hollow hill
#

I meant the folder

young knoll
#

Yes each world is a different folder

hollow hill
#

ok

#

so, how would I go about making a new world based off of the original?

young knoll
#

Copy it

round finch
#

Java API

hollow hill
#

could I make a new folder with the same data everytime someone runs the command?

young knoll
#

Sure

#

If you wanted to

hollow hill
round finch
#

Copy world and paste world with new name

young knoll
#

Yes, you can unload and the delete it

hollow hill
#

oh ok

round finch
#

i'm curious is it possible to load the world somewhere from like Worlds/word2?

#

i haven't checked

young knoll
#

No idea

#

Maybe if you pass worlds/world2 as the name

hollow hill
#

also is it possible to load a world with a name like:

test #4

?

#

cause it doesn't use " 's right?

young knoll
#

Should work

round finch
#

Folder name: test #4
World duelsNewWorld = server.createWorld(new WorldCreator("test #4"));

hollow hill
round finch
#

" " is string

#

you need it

#

the 2 " " is to contain the text in String

#

if you don't know this i recommend java tutorials

hollow hill
#

I do but I asked you if I should use it and you said no lol

hollow hill
hollow hill
ivory sleet
#

Be patient

hollow bluff
#

He meant that the world folder name gotta be the same inside the string

round finch
#

it takes a String mean you need "The Name here"

hollow hill
#

I know

#

Thank you lol

round finch
#

yeah no need to be salty
this isn't a salt factory pepeLaugh
true

#

i just not the best wording things

limber mica
round finch
#

😃

sullen marlin
#

'
New
How can i get the BlockFace, if i have only the block. My method before this is in 1.17 with

#

<block>.getBlockData().getAsString().split("facing=")[1].split(",")[0].toUpperCase();

#

'

#

goodness

#

now that is some cursed code

limber mica
#

google

unreal quartz
#

their code is simply too advanced for us

ancient plank
#

getConfig().getLocation("location").getBlock().getBlockData().getAsString().split("facing=")[1].split(",")[0].toUpperCase();

round finch
#

Oh no cursed code

young knoll
#

Sometimes I think my code is bad

#

Sometimes it’s nice to be reassured there is worse

round finch
#

Can it get Even worse?

#

Challenge

young knoll
#

If you ever want to feel good about your coding

#

Decompile random plugins on the latest release page

hollow hill
round finch
#

i believe you can do it!
and learn 100% with time

round finch
#

possible the worst thing ever

#

then worse
quantum pc states

tranquil viper
#

plugin.getServer().broadcastMessage(format("&6ROULETTE &8» &f" + player.getDisplayName() + " &7has just won &adouble &7their money in the &6Roulette Game &7(/roulette)")); anyone know why this gives me the message: