#help-development

1 messages ยท Page 1955 of 1

vale ember
#

plz send code

humble heath
#

System.out.println

#

private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
System.out.println();
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
System.out.println();
return false;
}
econ = rsp.getProvider();
return econ != null;
}

spiral light
#

?paste would be better

undone axleBOT
vale ember
humble heath
#

like

vale ember
#

like System.out.println("First if statment pased")

#

example

humble heath
#

ok

tender shard
#

what the fuck

#

Files.copy was added in java 7?!

#

why have I been messing around with bufferedwriters and inputstreams all the time

quaint mantle
#

How do I change project folder in intellij

humble heath
tender shard
humble heath
vale ember
tender shard
undone axleBOT
tender shard
#

oh nvm

quaint mantle
tender shard
#

do you actually have any economy plugin

humble heath
chrome beacon
#

?paste Please use this

undone axleBOT
humble heath
#

im dumb

#

did not have an economy plugin

tender shard
#

this is why printing useful errors is helpful ๐Ÿ˜„

#

I'd do something like

#
public enum EconomyResult {
  SUCCESS, NO_VAULT, NO_ECONOMY_PLUGIN;
}
#

and return that instead of a boolean

spiral light
#

reading the pluginyml and catch the command na mes

naive bolt
#

but i want the server operator to add other commands to config

tender shard
#

you can for each getDescription().getCommands()

spiral light
tender shard
#

oh in config.yml

#

they are talking about config, not plugin.yml

spiral light
#

oh i see xD

tender shard
#

getConfig().getConfigurationSection("commands").getKeys(false)

#

that will not work

#

getCommand returns null if it's not defined in plugin.yml

young knoll
#

^ youโ€™d need to reflect the command map

vale ember
#

is System.out.println the only way to print message in console without "[16:38:08] [Server thread/INFO]: "?

tender shard
tender shard
#

why would you ever want to do that?

vale ember
#

i don't want that shit over it

tender shard
#

no admin wants "fancy text"

#

they will refer to it as "annoying text"

tender shard
vale ember
young knoll
#

A certain fork will also yell at you if you use sysout

tender shard
#

it would break all log parsers

tender shard
tender shard
#

the log format exists for a reason. e.g. if you open the file with a log parser, you can tell it to "only show errors" and ignore infos, etc

sour socket
#

Hello lads

sour socket
#

So

#

I have come

#

To discuss

tender shard
#

you didn't define your command in plugin.yml

sour socket
#

The CraftItemEvent

tender shard
#

you forgot @ EventHandler

sour socket
#

Nope lol

tender shard
#

lol jk

sour socket
#

loll

#

Tryna phsyc

#

lmao

#

anyway

#

Help me out

#

I need help figuring out how to check if a player Crafted a workbench

tender shard
#

you can get the recipe from CraftItemEvent

#

from the recipe, you can get the result

#

and check if it's Material.CRAFTING_TABLE

sour socket
#

Oh mk

tender shard
#

but, and that's important

sour socket
#

How can I check the player who crafted it

tender shard
#

CraftItemEvent is called when the item is taken out

sour socket
#

cus e.getplayer don't work ;-;

tender shard
#

NOT when the crafting recipe was finished, if you know what I mean

sour socket
#

Yeah ofc

tender shard
#

you need the player?

sour socket
sour socket
tender shard
#

you can get the INventoryView from the event

#

and then do getPlayer()

#

however it returns a HumanEntity, not a player

#

so you have to check if it's a player, then cast it

sour socket
#

Ohh

#

cast it? (I'm a new dev)

tender shard
#

something like this: (one min)

#
@EventHandler
public void onCraft(CraftItemEvent event) {
  if(event.getRecipe().getResult().getType() != Material.CRAFTING_TABLE) return;
  if(!(event.getView().getPlayer() instanceof Player)) return;
  Player player = (Player) event.getView().getPlayer(); // this is a cast
}
#

although it returns a HumanEntity, you can cast it to Player using (Player)

sour socket
#

Oh yeah mkmk

#

Yep

#

Nicenicenicenicenice

neon nymph
#

Does proxiedPlayer return null if player isn't online or isn't connected?

tender shard
#

should be mentioned in the javadocs

sour socket
tender shard
#

?jd-b

#

?jd-bc

tender shard
sour socket
#

ah

young knoll
#

Thatโ€™s also in the docs

tender shard
#

what method exactly

#

ProxyServer.getPlayer(name) or (uuid) probably returns null if the player is not online

#

but not sure, the docs don't clarify it

#

since bungee doesn't save any playerdata though, I'm pretty sure it'll be null if they are not online

neon nymph
tender shard
#

I highly doubt you'll get a ProxyPlayer when using getPlayer("asdawdasdasdasd");

#

but - just try it and see ๐Ÿ˜›

neon nymph
#

Good point

#

Alright, thanks

tender shard
#

it's 99% the same as in spigot

#

Bukkit.getPlayer("somePlayerWhosNotOnline") returns null

#

but Bukkit.getPlayer("mfnalex") returns an object, and when I leave, you still have the player object around

neon nymph
#

I'll treat it the same as Spigot's Player then

tender shard
#

I got a question about my current design for my discord quizbot.

I currently have this:

1. A GameManager that keeps track of open Games.
2. A Game object for every open game. It holds a List<Question> and a HashMap<DiscordUser,List<Question>>. The List<Question> is a list of all questions that will be asked in this quiz, and the hashmap contains the correctly answered questions per player
3. A Question object, containing a List<String> with the question itself, and a List<String> with the correct answers for this question

Anything that I'm missing? From what I see, that's already everything needed lol

arctic delta
#

NoClassDefFoundError

spare prism
#

Why does the UUID that I have in-game doesn't match the UUID that I get from the Mojang API?

spare prism
tender shard
#

is your server set to online-mode: true ?

spare prism
#

It's like 3 different uuids

spare prism
tender shard
#

that's intended

tender shard
#

you MUST use online-mode to get proper UUIDs

tender shard
# sour socket Wins/Losses

per user? yeah, I'll add that later ๐Ÿ™‚ currently I just need the base game working, then later I'll add a Statistics class

sour socket
#

Essential playerdata etc

spare prism
tender shard
spare prism
#

What I want is to get UUIDs of offline players on Bungee

blazing scarab
spare prism
blazing scarab
#

Well then toy will never have a uuid

#

If you're on offline mode

glossy venture
#

you get the list and use List#contains(...)

#

i recommend using UUIDs

#

as they are name independant

#

otherwise it would break if someone changed their name

naive bolt
#

ik

#

whats clazz

sour socket
#

Hmm

vocal cloud
naive bolt
#

idk im not reading it. YOLO

vocal cloud
#

Hmmm maybe you should

naive bolt
#

No results found on spigot javadocs

naive bolt
#

clazz - the type of the requested object

#

so String ?

#

idk

tender shard
#

why don't you just use getString()? o0

naive bolt
#

because its an object

#

["Name","Name2"]

tender shard
#

that's a string array or string list

naive bolt
#

ok i will try getStringList

sour socket
#

I have an public int function, which returns the player's progress (in a tutorial plugin)

#

And I want to check if a player who crafted an item (in another RecipeCraft class) has already passed through the other steps

#

Here's the function

willow stream
#

cube gravity

sour socket
#
    public int getProgress(OfflinePlayer p, int amount) {
        if (progress.get(p.getUniqueId()) != null) {
            return progress.get(p.getUniqueId());
        } else {
            return 0;
        }
    }```
elfin atlas
#

Question is there a way to update a players location without teleporting him?

sour socket
#

Update?

elfin atlas
#

But without teleporting the player

sour socket
#

So, to move a player

#

To a loc without tp?

#

Where do you want their location to be updated?

elfin atlas
#

Yep because the Player is sitting on a PacketSpawned entity and this is moving

sour socket
#

Ohh

#

So when they hop off, you want them to be where they actually hopped off?

elfin atlas
#

And at a range from 45 Blocks it is despawning and the player still has the same loaction on the server and it moves more then 45 blocks that is my problem

naive bolt
#

can i not cancel join event

#

do i have to kick the player instead

elfin atlas
sour socket
#

Go ahead

#

Ohh

elfin atlas
#

Yep

sour socket
#

Hm

sour socket
elfin atlas
#

A friend told me in older version it was working with nms but in newer version it should be a other way but he don't know

sour socket
#

What version is your library?

elfin atlas
sour socket
#

Damn, I'm afraid I can't help you with that

#

I work with older/legacy versions

elfin atlas
#

Can't update currently because of the annoying lead bug

sour socket
#

1.15

#

Gotcha

elfin atlas
#

This is why I'm sticking on 1.17

glossy venture
#

moving a player is the same as teleporting them

#

or am i understanding it wrong

spare prism
#

is there a way to check if the BungeeCord has online or offline mode?

elfin atlas
late sonnet
#

ahh this lead

elfin atlas
#

Yep

sour socket
#

Lol

elfin atlas
#

And 1.18 has a annoying bug

tender shard
sour socket
elfin atlas
tender shard
#

is there a good tutorial on deserialization yaml files into custom objects using SnakeYaml (NOT Spigot/Bukkit API, but plain snakeyaml)?

#

of course I could just create one fromMap method or sth

#

but maybe there's already some builtin way

glossy venture
#

you could use like reflection

#

im writing a simple impl

tender shard
#

hm what do you people think - is it bad style to set a variable and return it in the same statement?

    public Question getNextQuestion() {
        if(!hasQuestionsLeft()) {
            throw new RuntimeException("No more questions left");
        }
        return currentQuestion = questions.get(currentQuestionNumber++);
    }
hardy swan
deft forum
sleek pond
#

Why do you have a runnable

#

In the block list loop

deft forum
#

cuz i don't want all blocks to appear at the same time

sleek pond
#

I see

#

So it logs everything but doesn't actually do anything?

deft forum
#

yes

sleek pond
#

The reason is because in 2 seconds it's air

#

Just as a test, instead of doing set type(mat)

deft forum
#

yes

sleek pond
#

Set it to like dirt or something

deft forum
#

i figurided uot now

#

but if i set it to Material.GRASS_BLOCK it doesn't do anything still

tender shard
#

from the outside you can only get Question getCurrentQuestion() and int getCurrentQuestionNumber()

deft forum
#

it worked now

#

i fixed it!

sleek pond
#

What's you do

deft forum
#

thanks a lot for the help!

#

i set it to grass_block xd

hardy swan
deft forum
#

i tried that yesterday but it didn't work for some reason xd

tender shard
#

e.g.

new Game();
game.getCurrentQuestion() -> null
game.getNextQuestion() -> returns first question
game.getCurrentQuestino() -> returns first question
game.getNextQuestino() -> returns second question
deft forum
#

actually do you have an idea to make it apper not at the same time cuz the for loop run like infinitly fast
and even if i make a runnable it feels the same like if i didn't make the the runnable it just sets the blocks 2 secs after

#

...

hardy swan
tender shard
tender shard
#

not really needed

#

I'll remove it

hardy swan
#

Because I wont want myself to forget to update that reference

#

Unless the data structure is a tree

tender shard
#

it's this now

#
public Question getNextQuestion() {
        if(!hasQuestionsLeft()) {
            throw new RuntimeException("No more questions left");
        }
        return questions.get(currentQuestionNumber++);
    }
    
    public Question getCurrentQuestion() {
        return questions.get(currentQuestionNumber);
    }
hardy swan
#

Ye

tender shard
#

I think I'll just put the whole thing on github in an hour or two, maybe some other people are willing to contribute. Because I think the current #bot-commands bot sucks so we need our own

hardy swan
#

I was taught to not use wildcards for imports

tender shard
#

i think the default threshold is 3

#

if you use more than 3 imports of a package, it uses the wildcard

hardy swan
#

Personally the first thing that came to my mind for trivia is queue

#

That the asked question can just be discarded

tender shard
#

yeah but I might need to get the previous questions again, e.g. to show a summary at the end of each game or sth

#

I

#

AM

#

SO

#

SMART

blazing scarab
#

Tho you can use some library like Configurate

tender shard
#

I already just wrote my own deserialization stuff

#

it's really not much

#

not worth to change it now

ancient jackal
tender shard
#

yeah not very smart lmao

ancient jackal
#

is it still up? ๐Ÿ˜

tender shard
#

I changed the token 5 seconds later lol

ancient jackal
#

๐Ÿ˜ฉ

#

why is it in light mode?

tender shard
#

I like light mode

wispy bridge
#

Flashbang

tender shard
#

dark mode is so depressing

#

but it's actually amazing

#

the same second in which I accidently commited my bot token

#

I got the discord message

#

I wonder how it works

ancient jackal
#

discord on that grind

tender shard
#

they cant possibly scan all public github commits every second

ancient jackal
#

github can scan every repo in a few seconds when searching though so like, maybe

tender shard
wispy bridge
#

Might only check your account's linked GitHub?

tender shard
#

yeah that sounds more reasonable

worldly ingot
#

Was just about to say, you have GH linked

tender shard
#

thank god I did that

#

lol

ancient jackal
#

your token is still in the config

tender shard
#

I know

#

it will be there forever

#

in the git history

wispy bridge
#

Its a useless token now I assume

tender shard
#

it's now useless, though

#

yes

deft forum
#

anyone have an ide to run a for loop but not at the same time?

wispy bridge
#

You want to run a for loop but not at the same time? I dont understand

deft forum
#

i'll cide

#

code

#

a sec

#

source bin

wispy bridge
#

The IDE isnt gonna change whatever problem you might be facing

tender shard
#

they meant "idea"

#

I guess

wispy bridge
#

Ohhh maybe

deft forum
#

yes?

wispy bridge
#

Use it?

deft forum
#

im using it

tender shard
#

the current code is pretty bad

deft forum
#

i know...

wispy bridge
#

You're using runTaskTimer

tender shard
#

you spawn a new repeating task everytime a creeper explodes

wispy bridge
#

Not runTaskLater

tender shard
#

so @wispy bridge that won't help

#

if 1000 creppers explode, there will be 1000 repeating tasks

deft forum
#

then how could i do it?

tender shard
#

what exactly are you trying to do?

wispy bridge
#

runTaskLater doesnt make a repeating task?

#

Im not sure what you mean

deft forum
#

when a creeper explodes i want to replace the blocks that it exploded but not replace the blocks instantly like 1 block 1 sec

tender shard
#

yeah then

#

runTaskLater

#

as strubbe said

wispy bridge
#

There are 20 ticks per second so multiply that by the index of the block you're looping for the tick offset

tender shard
#

but also

#

your code is still bad because

#

you only set back the material

#

you want instead to set back the blockdata

deft forum
#

what?

tender shard
#

otherwise stuff like signs will have the wrong orientation etc

wispy bridge
#

Well im sure they'll figure stuff out, thats part of the fun

#

LOL

tender shard
#

true

#

๐Ÿ˜„

deft forum
#

yeah

tender shard
#

you can't clear a block's getDrops list

#

it's just a "general" method to get the "usual" drops

#

I think it's even an immutable list

deft forum
#

then how do i delete the drops?

wispy bridge
#

You could just cancel the event couldnt you?

#

Then remove the blocks or set them to air yourself

tender shard
#

setYield to 0

wispy bridge
#

Oh I didnt know that was a thing

tender shard
#

it's in the explodeevent

#

e.g. 1 will make every exploded block drop itself

#

0.5 only 50%

deft forum
#

just please help me to fix my code

#

how do i make blocks appear back in time

wispy bridge
#

This is help, you are currently being helped

tender shard
#

we told you what to do

deft forum
#

i didn't ask for it

tender shard
#

now it's your task to turn our suggestions into code

#

to prevent drops from explosions: setYield to 0 in your event

#

and do NOT use a taskTimer, but runTaskLater

#

because you only want to restore the blocks once

#

not unlimited times

deft forum
#

block.setYield(0) does not exist

#

and i already changed runtasktime to runtasklater

mortal hare
#

does any of you used java.nio classes here before

#

if so, is there any difference besides architecture to use AsynchronousFileChannel and async OutputFileWriter

wispy bridge
#

Its in the explode event

#

Not the block

deft forum
#

and it deletes the dropped items?

wispy bridge
#

Setting the yield to 0 means that no items will drop from the explosion

deft forum
#

ohh

#

thx

tender shard
deft forum
#

YES!

wispy bridge
#

What a flex

tender shard
#

yeah okay so you COULD spawn one runTaskTimer for every block

#

like I did here, like this:

#
    @EventHandler
    public void onExplode(EntityExplodeEvent event) {
        event.setYield(0);
        long delay = 60;
        for(Block block : event.blockList()) {
            BlockData data = block.getBlockData().clone();
            Bukkit.getScheduler().runTaskLater(this, () -> {
                block.setBlockData(data);
            },delay);
            delay+=5;
        }
    }
#

but

#

BUT

#

this is very bad

#

you will end up with a ton of delayed task

#

that's not what you should do

#

you should instead schedule ONE repeating timer

#

you should create a new Map<Block,BlockData>

#

then run your repeating task and always replace one block with its former blockdata at a time

wispy bridge
#

I think the tasks get cancelled by the scheduler if its a run task later, I dont think they hang in the server?

tender shard
#

and once you're done iterating through it, cancel your task

tender shard
#

you will now have 1000 delayed tasks

#

of course, they will all be gone once all blocks were replaced

mortal hare
#

yea one timer is way better

tender shard
#

but you could do the same thing with just one repeating task

mortal hare
#

since task allocation is way more expensive

#

than couple if stements

wispy bridge
#

Yeahhhh thats true but if its just a creeper explosion I think the performance is negligible

mortal hare
#

inside the code

tender shard
#

and they all raid some dungeons or whatever

#

it probably doesn't matter much but since it's also a tiny bit of work, I'd go for one task fro mthe beginning

wispy bridge
#

Thats fair, I just think for a beginner it might be better to think small first, I dont know how much more complicated that might be for them

#

The single repeating task is much better in general yes

deft forum
#

actually why do u use block.getBlockData().clone()
what does clone "do" here? it should do the same if you don't use .clone()

mortal hare
#

JAVA NIO vs JAVA IO

#

Which side do you guys pick

#

File vs Path

wispy bridge
#

Clone returns a new instance which contains all of the information of the first but does not modify the original

mortal hare
#

Nio seems great for me

wispy bridge
#

I dont know if getBlockData() returns a mutable copy

tender shard
#

it's a clone

#

I just wrote a way without one runnable because I was bored

#
    private static class OriginalBlock {
        private Location loc;
        private BlockData data;
        public OriginalBlock(Block block) {
            this.loc = block.getLocation();
            this.data = block.getBlockData();
        }
        public void restore() {
            loc.getBlock().setBlockData(data);
        }
    }

    @EventHandler
    public void onExplode(EntityExplodeEvent event) {
        event.setYield(0);
        List<OriginalBlock> originalBlocks = new ArrayList<>();
        event.blockList().forEach(block -> originalBlocks.add(new OriginalBlock(block)));
        new BukkitRunnable() {
            int current = 0;
            @Override
            public void run() {
                originalBlocks.get(current++).restore();
                if(current >= originalBlocks.size()) cancel();
            }
        }.runTaskTimer(this,40,2);
    }
#

you'll still have a bad time destroying stuff like signs, containers, etc

#

they will be empty

deft forum
#

why i use getBlockData and setBlockData

tender shard
#

use materials instead and see for yourself

#

hint: signs have orientation, chests have orientations, torches have orientations, blocks can be waterlogged or not, candles can have different amounts and can be lit or unlit, etc

#

3 red lit candles and 1 unlit red candle both are Material.RED_CANDLE

#

that's why you should use BlockData instead of material

deft forum
#

so set material first then set blockdata?

#

i use blockdata man

tender shard
#

?

#

blockdata includes the material

deft forum
#

i know and?

tender shard
#

I don't get your question

#

I literally sent you the fully working finished code that preserves everything except for stuff like block inventories

deft forum
#

i use getBlockData and setBlockData it should set the items in a chest etc?

tender shard
#

BlockState != BlockData

deft forum
#

so i should set blockstate too right?

tender shard
#

you can't

#

there is no such thing as setBlockState

deft forum
#

and really there isn't

tender shard
#

you have to manually check if something is getState() instanceof Container, then save the inventory and set it back afterwards

deft forum
#

fhuuu

tender shard
#

you can easily expand my custom class that I provided

deft forum
#

i'll do it!

#

and thanks a **LOT **for the help and the support!

#

bye!

tender shard
#
    private static class OriginalBlock {
        private Location loc;
        private BlockData data;
        private ItemStack[] inventory;
        public OriginalBlock(Block block) {
            this.loc = block.getLocation();
            this.data = block.getBlockData();
            if(block.getState() instanceof Container) {
                this.inventory = ((Container)block.getState()).getInventory().getContents();
            }
        }
        public void restore() {
            loc.getBlock().setBlockData(data);
            if(inventory != null) {
                ((Container)loc.getBlock().getState()).getInventory().setContents(inventory);
            }
        }
    }
#

no idea why I'm spoonfeeding so much today

#

I haven't tested this though

#

it may be possible that you still have to somehow prevent the chest from dropping their contents and/or also create a clone of all the chest contents

#

but you get the idea

manic crater
#
@EventHandler
    public void mysticWellClick(PlayerInteractEvent e) {
        Player p = e.getPlayer();
        
        if (e.getClickedBlock().equals(Material.END_PORTAL_FRAME)) {
            if (e.getAction().equals(ClickType.RIGHT)) { // 176, 263.337
                if (e.getClickedBlock().getLocation().getBlockX() == 188.462) {
                    if (e.getClickedBlock().getLocation().getBlockY() == 176) {
                        if (e.getClickedBlock().getLocation().getBlockZ() == 263.337) {
                            p.sendMessage(ChatColor.RED + "[???] This currently isn't ready at the moment...");
                        }
                    }
                }
            }
        }
    }

Apparently this doesn't work? So i was wondering since this doesn't work how can i get the location of a block?

tender shard
#

getBlockX will enver be equal to a double

#

it returns an int

manic crater
#

hm ok,

manic furnace
#

I delete a file in my plugin, but i get a FileNotFoundFoundException, although it is deleted. I run that task asynchronously.

manic crater
#

So then how can i go about getting the location of the given block?

#

wait nvm i think i got it

tender shard
manic furnace
#

Its there

willow stream
tender shard
manic furnace
#

First it's there. The it is deleted and i suddenly get a FileNotFoundException

tender shard
#

So you delete a file and then you wonder why it's not there anymore?

manic furnace
#

I only delete it one time

tender shard
#

how about posting the error message...

#

?paste it pls

undone axleBOT
manic furnace
tender shard
#

what's FileSystem line 134?

#

you are trying to read a json from the deleted file

manic furnace
#

Its a class i coded

tender shard
#

obviously...

viral delta
#

How Can I chance minecraft:iron_sword to mynamespace:emerald_sword?

tender shard
#

what is "minecraft:iron_sword"?

#

a string?

#

a namespacedkey?

viral delta
#

That what it shows you when you hower over a item

#

@tender shard

hasty prawn
#

I'm fairly certain that cannot be changed

viral delta
hasty prawn
#

Where

mortal hare
#

it could be changed but im not quite sure how but i think, you need to fiddle with NMS ItemRegistry to edit the namespace

#

i've saw this in action before too, but i dont remember where

#

but I don't recommend that

#

I would instead suggest listening to tab complete packet (that would only work for tab completion, but you can always listen for chat related event)

#

and change it through there

hasty prawn
mortal hare
#

i'm talking about serverside command namespaces

#

you cant change namespaces for clients

hasty prawn
#

Yeah that's what he's asking though

mortal hare
#

well you cant then

hasty prawn
#

I see what you're saying too though, adding a custom namespace into the commands. Definitely possible to do that

#

Just can't change what it displays blushi_bonse

tender shard
#

it's hidden by default

#

you only see it because you have advanded tooltips enabled

hasty prawn
#

F3 + H changes whether the client shows it

tender shard
#

and no, you cannot prevent players from enabling those

viral delta
tender shard
#

F3+H

hexed orbit
#

Hello guys, I'm using packets to appear a block in the world, but the block that appears when it breaks does not drop any items and the sound of breaking is stone, but the block is dirt, could anyone help me? I'm using this code:

WrappedBlockData loke = WrappedBlockData.createData(targetBlock.getType());
pacote.getBlockData().write(0, loke);```
tender shard
#

also the API already has a method to send fake blocks, there is no need at all to use weird packets for that

#

player.sendBlockChange

hexed orbit
tender shard
#

block.setType()?

torn shuttle
#

hey anyone here happen to have tried to spawn minecarts on tracks before?

#

do you know if they automatically go on the tracks correctly or does that require some dark magic

tender shard
#

I'm new to java 17 switch statements. is it correct that I don't need break; after the first case?

tardy delta
#

dont you have to work on thr track object then?

maiden thicket
#

no ur using enhanced switches

#

do u dont need breaks

#

iirc

torn shuttle
#

to the next case

hasty prawn
#

You don't need breaks for enhanced

tender shard
tender shard
torn shuttle
#

wait there's enhanced switches now?

#

tf

hasty prawn
#

You can also straight up return the switch statement I think alex

tender shard
torn shuttle
#

what's enhanced about them?

dusk flicker
#

They r nice

tender shard
torn shuttle
#

ah yeah thanks

hasty prawn
#

Say that website's name challenge

tardy delta
#

what happens when you return an enhanced switch and it has no default case and no label matches?

#

returns null?

tender shard
torn shuttle
#

man

tardy delta
#

iight

torn shuttle
#

that's a lot of tech the switches got huh

tardy delta
#

ey what is yield

torn shuttle
#

wonder if intellij will still yell at you for putting several cases on the same line

#

it really hates it when you put several things on the same line

#

that and sonarlint

tardy delta
#

does anyone even uses if (Collection#contains) { Collection#get } instead of ``if (Collection#get != null) { Collection#get
}` ?

hasty prawn
#

yes

ivory sleet
#

Collection::get?

tardy delta
#

well in case of a map, i most of the time store the variable and nullcheck it instead of calculating it twice

#

idk if someone understands me

#

i was thinking if i call get twice or a contains then it basically does extra calculation instead of just storing it and null check it right?

tardy delta
#

if i just do object o = map.get; if (o != null) // bla bla bla then isnt it faster than calling contains?

undone pebble
#

I mean, one call is better than two calls; so yeah

tardy delta
#

i guess

tender shard
#

I wouldn't worry about what's faster

#

unless this is really a bottleneck

#

premature optimization is always a waste of time

robust ginkgo
#

I wonder how people make plugins like Jython

#

Plugins that lets you code in a different language than Java

#

does anyone know how it's done?

tardy delta
#

some other language interpreter?

viral delta
vocal cloud
#

Read the error and it'll tell you

robust ginkgo
tardy delta
#

it doesnt expect a command class instance

vocal cloud
#

Yup and what does that error mean?

tardy delta
#

it says to cast it to what

#

you cant cast it but i tells what you need

viral delta
vocal cloud
#

?learnjava moment

undone axleBOT
tardy delta
#

it tells you to cast your first parameter to a Plugin, because you provided something other than it expected

#

it tells you that it needs a plugin

viral delta
#

ok, thx

warm light
#

how to get the update folder?

#

.getServer().getUpdateFolderFile() not working

tardy delta
#

works with me

robust ginkgo
tardy delta
#

idk

#

its just a guess

warm light
tardy delta
#

?notworking

undone axleBOT
#

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

warm light
#

it should download jar from github to update folder in plugins dir

#

but it download jar file in plugins dir

olive lance
#

Anybody know what triggers intellij to mark my .get as a 'suspicious call'?

torn shuttle
#

or something to that end

olive lance
#

what ive got is a ArrayList<HashSet<Faction,Faction>>.contains(Set.of(faction a, faction b))

#

maybe because i havent written anything to add any sets to the list

warm light
torn shuttle
#

and start again with something that makes more sense

olive lance
#

ik its bad design

#

just trying to do it quick

torn shuttle
#

do it quick, do it twice

tall dragon
#

either do it good or dont

torn shuttle
#

intellij probably detected that your statement will never result in something valid

olive lance
#

I got it

#

Set.of returned a set

#

not hashset

torn shuttle
#

good now delete it all and make a proper class

olive lance
#

i would

torn shuttle
#

you will

olive lance
#

uhh. dentist appointment gtg

torn shuttle
#

hope your dentist isn't in as much of a rush to take care of your teeth as you are to make server software

olive lance
#

shit me too LOL

#

but in reality i was just doing this to test something i was gonna do

#

i will end up making a proper class and such

torn shuttle
#

cue the dentist showing up with a chainsaw and a pair of aligator clips and saying "yeah I know it's not ideal but i'm in a rush, I have to take my car to the garage in a minute"

#

then, at the garage...

olive lance
#

welds wheel to axle cause mechanic was in a rush to get home

torn shuttle
#

don't blame him, he's in a rush to get home because the electrician is coming by in a minute

#

just wait till you see what that dude is in a rush for

olive lance
#

๐Ÿคฃ

warm light
tardy delta
#

does it do anyhting?

ancient jackal
#

Mechanic welds differential because he needed to scoot home in a hurry

torn shuttle
#

you just have the wrong directory

olive lance
#

Add a '/' before the .jar name

#

maybe

#

wait im trippin

warm light
olive lance
#

yeah i was bugging hard

#

idk

torn shuttle
#

electrician superglues the electrical panel on because he's in a rush to go have his house treated by pest control

wild cedar
#

Hey there,
I'm trying to spawn a hologram for a single player using NMS 1.18.1, and the problem starts from DataWatcher section which is required for entity meta data packet.
When it comes to setting 0x20 byte (which makes the entity invisible), it requires a packetdataserializer object. I have no idea where to get that from. I would appreciate any help and please if you don't have enough knowledge about this, do not reply.
https://cdn.discordapp.com/attachments/902581431019135030/943202795127975996/unknown.png

olive lance
#

pest control burns the house down cause they were in a rush to get called to the witness stand in a death penalty trial of an innocent man

torn shuttle
#

the jury becomes an impromptu firing squad without a trial because the judge is in a rush to get home to play Minecraft, he heard @olive lance is about to drop a hot plugin

olive lance
#

yessirski

torn shuttle
#

see what you did

olive lance
#

killed an innocent man

#

and burned a house

torn shuttle
#

good, I hope you learned something

quaint mantle
#

Hi, How are permission files with ranks formed?

tall dragon
quaint mantle
#

Why, it's for a plugin

tall dragon
#

ah well forget i said that.

#

you mean the default permission file from spigot?

quaint mantle
#

xD

tall dragon
#

then we might benefit from some more information

quaint mantle
#

What?

tall dragon
#

you need to give some more information

#

what permission file do you mean

quaint mantle
#

I am creating a rank plugin and I want to assign permissions to each ranks

tall dragon
#

well it sounds like its completely up to you how those are formed no?

quaint mantle
#

The plugin with the ranks?

tall dragon
#

well it depends, do you have a permission plugin?

quaint mantle
#

No

tall dragon
#

do you use the plugin Vault?

quaint mantle
#

It can be useful ?

tall dragon
#

well its an api for permission, economy, chat based to plugins to easily communicate together

#

id advice to use a permission plugin tbh

tardy delta
#

is the onTabComplete method fired in spigot when typing command in console, so can the sender be a CommandSender and not a Player?

tardy delta
#

why does it get fired when it isnt useful?

#

like you cant see any completion options in console

warm light
#

which option will be better for auto update?

  1. Overwrite in plugins folder
  2. download plugin in update folder
tender shard
#

2

#

but

#

you should never auto update plugins

quaint mantle
tender shard
#

admins should always have 100% control over what .jars are running

tender shard
#

also 0.0.0.0

#

makes no sense

#

you must specify a proper IP in your bungee config.yml

#

but

warm light
tender shard
#

overwriting a running .jar is a bad idea

warm light
tender shard
#

overwriting the current .jar also requires the same .jar name

warm light
#

if someone change plugin name, it wouldn't work

wild reef
#

Hey so I am trying to work on a plugin where I have a command to relaod the plugins config.
Basically what I want to achieve:
When a player uses the "reloadConfig" command I want to initialize my PluginConfig object with the new values from the updated file. Right now when I am initializing the object again the written values get removed. How can I avoid that from happening?
That's how I create my Config Object:

public PluginConfig(MyPlugin plugin) {
        this.plugin = plugin;
        this.config = plugin.getConfig();
        initConfig();
    }
...
private void initConfig() {
  this.config.addDefault("fadeTime", 20);
  this.config.addDefault("testValue", false);
  config.options().copyDefaults(true);
  plugin.saveConfig();
}
tender shard
wild reef
#

Does it reload the yaml file when calling plugin.getConfig() again?

tender shard
#

plugin.reloadConfig()

wild reef
#

Okay but does that work with this strcuture?

private FileConfiguration config;
    private final MyPlugin plugin;

    public PluginConfig(MyPlugin plugin) {
        this.plugin = plugin;
        this.config = plugin.getConfig();
        initConfig();
    }
    
    public void reloadConfig() {
        plugin.reloadConfig();
    }

Just asking because reloadConfig is not returning a new FileConfiguration. So do I need to update config in my class manually somehow or does that happen automaticly?

#

Or would I just need to call plugin.getConfig()afterwards again and init my config FileConfiguration with it?

tardy delta
#

?paste

undone axleBOT
tall dragon
tardy delta
#

updated my sdk to java 16

tender shard
#

JavaPlugin#getConfig() returns the already loaded config

#

if you want to reload your config, just use JavaPlugin#reloadConfig()

#

it's a method that already ecists

#

imagine this:

tardy delta
#

could i be shading with the wrong version of the shading plugin?

tender shard
#

getConfig() -> returns your config
now change something in config.yml
getConfig() -> returns old config
reloadConfig() -> config reloaded
getConfig() -> now it returns your new config

tender shard
tardy delta
#

thats everything when trying to build the package

tender shard
#

no no

#

on the left side, click the uppermost thing

#

then you get the full error message

deft forum
#

anyone know what is the problem?

tender shard
wild reef
deft forum
tender shard
undone axleBOT
#

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

tardy delta
deft forum
#

i wanna create an item stack but it says an err and the err is that i gave material type but it needs IMaterial

#

but it doesn' exist..

#

what

#

the is 2 item stacks

#

what

tardy delta
deft forum
#

i've never noticed this

tender shard
tender shard
#

looks you imported the NMS ItemStack

#

instead of the bukkit one

#

also pls don't call your events "e"

tardy delta
#

liek this?

tender shard
#

yes, you'll need the maven snapshot repo too I guess

#

one sec

#

add this to your pom

#
<pluginRepositories>
  <pluginRepository>
    <id>apache.snapshots</id>
    <url>https://repository.apache.org/snapshots/</url>
  </pluginRepository>
</pluginRepositories>
tardy delta
#

oh ye i saw the answer on stackoverflow too :D

#

and the 3.30-SNAPSHOT version?

#

doesnt seem to find it

tender shard
#

3.3.0

#

not 3.30

tardy delta
#

ye that, i typed ir correctly in my pom

tender shard
#

just hit maven -> lifecycle -> package

#

it should then download the correct plugin

tardy delta
#

:o

#

thankjoe ๐Ÿ™‰

tender shard
#

np ๐Ÿ™‚

tardy delta
#

pom shows an error but i can build plugin :C

tender shard
#

it's just intellij being slow

#

file -> invalidate caches -> restart

tardy delta
#

meh

last iris
#

ItemMeta

tender shard
#

does someone know: how can I schedule a delayed task in java (NOT using bukkit API) that I can also cancel at anytime?

#

java.util.Timer() allows me to schedule a task but it returns void so no idea on how I can cancel it before it executes

young knoll
#

Java has runnables

tender shard
tender shard
#

I need something like this:

sacred mountain
#

him nalsfkexc

#

nmfealkx

#

mnafelx

#

mfalenk

tender shard
#
Task myTask = new Task(...);
myTask.runIn20Seconds();
.....
myTask.iChangedMyMindDontRunIt();
sacred mountain
#

bukkit runnable delay?

tender shard
sacred mountain
young knoll
#

Create a class that extends TimerTask

#

Then get an instance of it and execute it with a Timer

sacred mountain
young knoll
#

You can cancel it before it runs via TimerTask#cancel

tender shard
sacred mountain
#

ohhh

#

is it bc discord py gone

tender shard
sacred mountain
#

i seem to remember someone saying they would remove it

#

or somethjing

#

i have no idea about any discord related news

young knoll
#

Here's an example

tender shard
#

thanks

maiden thicket
#

typescript discord bot when

#

๐Ÿ˜”

ivory sleet
#

dont use timertask perhaps

#

ScheduledExecutorService x)

young knoll
#

Listen to him

tender shard
young knoll
#

He probably is less smolbrain than me

#

:p

tender shard
#

I never did any timer / tasks / stuff in plain java

maiden thicket
#

its conclure thats what the advantage is

#

hes smart

sacred mountain
#

i have code comments just to help me

young knoll
#

Caused by: java.lang.NullPointerException
at com.clonkc.vlands.kitpvp.Utils.Rep.rep3(Rep.java:16) ~[?:?]

sacred mountain
#

i know but i dont see why thats a problem

tender shard
#

what's Rep line 16

sacred mountain
#

it literally just replaces placeholders

#

like

#

its a rubbish name

tender shard
#

what's Rep line 16

sacred mountain
#

return ChatColor.translateAlternateColorCodes('&', string.replace(placeholder, replace));

tender shard
#

placeholder is null

young knoll
#

Something there is null

tender shard
#

or replace is null

worldly ingot
#

getFireballTotalDamageMessage() is null ;p

young knoll
#

Or string

tender shard
#

or string is null

sacred mountain
#

hmm ill check that

worldly ingot
#

That being said, the description message would have been far more informative had you been using modern Java and modern game version

#

You're on a 6 year old version

sacred mountain
#

yea ik

young knoll
#

Woo new NPEs

sacred mountain
#

oh it was a typo

#

._.

#

i spelt fireballs as 'firebals'

#

in my config util

ivory sleet
sacred mountain
#

ok so i fixed it, but e.getDamager() sends a message to the fireball and not to the player who lanuched the fireball

#

how do i get that player

#

using entitydamagebyentityevent

young knoll
#

e.getDamager().getShooter

#

Then check and cast

sacred mountain
#

o ok

#

ty

young knoll
#

Actually you probably have to cast e.getDamager too

sacred mountain
#

so like

#

Player shooter = (Player) e.getDamager().getShooter();

mellow edge
#

what would be the eaziest way to store chunks into a file and then eazily load it?

sacred mountain
#

ok so i cant use e.getDamager().getShooter() because the listener is for the explosion not the fireball throw

delicate lynx
#

does anyone know if bungee has some type of "resend commands" function like bukkit does? bukkit has updateCommands() but I don't see anything like that on bungee

deft forum
#

anyone know how to access my main file from other files?

deft forum
#

main files properties and like getConfig() and things like that?

lost matrix
#

?di

undone axleBOT
tardy delta
#

just tested my plugin and all the commands are giving errors ._.

deft forum
#

-.- its bad a deal

hasty prawn
#

What is a bad deal?

tardy delta
#

is 'name' a reserved keyword in mysql or something?

deft forum
#

i think so

#

in bungeecord its yes and no

#

it changes it to true, false

unborn axle
#

Hey everyone, I have a problem with the PermissionEx plugin, can someone help me?

unborn axle
tardy delta
#

so i cant use it in a table ._. lets try

blazing scarab
tardy delta
#

ah right never used it

#

lets see

#

seems to work

tender shard
#

ugh any idea why I can't print umlauts with my plain java app?

#
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
#
    @Override
    public void onMessageReceived(@NotNull MessageReceivedEvent event) {
        System.out.println("รผ");
quiet ice
#

Your terminal does not support umlauts

lost matrix
tender shard
quiet ice
#

As evidently seen in your device name

tender shard
#

it works fine using spigot

tardy delta
#

dont think your terminal cares about your project encoding

#

its being rude

#

slab it

lost matrix
tender shard
#

also the java app itself doesn't recognize umlauts from discord

#

very weird

quiet ice
#

It could be possible that the terminal is using another encoding

mortal hare
#

does anyone used java.nio package before here

tender shard
#

i am pretty sure that my terminal supports umlauts

brave sparrow
#

But it doesnโ€™t

#

Look at your host name on it

#

Itโ€™s messed up

tender shard
#

then why does echo รถรครผรŸ work

quiet ice
#

Probably because it is another encoding

deft forum
#

anyone can help me to access my Main file from outside my main class?
i mean access getConfig() and things like that

quiet ice
#

รถรครผรŸ and co are all non-ascii chars

brave sparrow
quiet ice
#

I. e. what happens if you use the umlaut value according to codepage 437?

tender shard
#

it works fine using utf8 with cat, echo, ...

tardy delta
#

when i have to do chat

#

rip hex colors

quiet ice
#

Yeah, this is interesting

#

I know that windows acts a bit strange, but this is git bash after all so everything could be at fault here

tender shard
#

yeah but as I said - if I get a message from discord that's only "รผ" and I compare it using message.getContentRaw().equals("รผ") it also returns false

#

seems like something's wrong with my .jar

quiet ice
#

Perhaps java uses a seperate encoding?

tender shard
#

I#ve set maven to use utf8 :/

quiet ice
#

What happens if you use JDK 18, it should use UTF-8 by default, but eh

#

Yeah, mysterious

tender shard
#

I only have jdk 17 installed

deft forum
#

it shows nothing when i type jv.

tender shard
#

you're doing this outside a code block

brave sparrow
#

Main m = JavaPlugin.getPlugin(Main.class);

#

@deft forum

blazing scarab
buoyant viper
dusk flicker
#

?main

quiet ice
#

If it were to be encoded in codepage Codepage 437 it would mean that the umlauts are probably in the range of 0xB1 - 0xB3 which would not make much sense if it was utf8 unicode

tardy delta
#

heh nice my database isnt saving users

quiet ice
deft forum
quiet ice
#

Generics

tardy delta
#

dependency injection please

quiet ice
#

Main must extend JavaPlugin though

buoyant viper
#

?di

undone axleBOT
deft forum
#



    m.```
blazing scarab
quiet ice
#

Well, depending on the circumstances, JavaPlugin#getPlugin is the better solution

blazing scarab
#

But seriously, the arguments are nothing

brave sparrow
#

I donโ€™t know why your IDE isnโ€™t showing you the methods you want

#

Does it compile?

quiet ice
#

Are you sure you are importing the right class?

deft forum
#

yes

quiet ice
#

Because with such a name there is an extreme danger that you are importing sun internals

deft forum
#

imports:

package me.andris.warppl.commands;

import me.andris.warppl.Main;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
#

my main is in me.andris.warppl.Main

delicate lynx
#

rename your class so it's not called main please

quiet ice
#

and it extends org/bukkit/plugin/java/JavaPlugin?

#

I mean, as long as a package name is set, it isn't too dangerous

deft forum
#

i goptt

#

i gotta go!

#

bye

quiet ice
#

Sure, it can lead to many issues, but as long as you know what you are doing it won't create too large issues

grim ice
#

I wanna learn cpp

#

but i hate vsc

#

and clion is paid

#

any good option?

delicate lynx
#

notepad

lost matrix
quiet ice
#

Eclipse CDT

grim ice
#

bre

#

i will do eclipse

quiet ice
#

It is remarkably good as long as you are willing to ditch windows

tardy delta
#

you can get Clion for free right?

grim ice
lost matrix
#

Id rather use word 2003

sage dragon
quiet ice
#

I'm talking about eclipse CDT here, it is good way to learn cpp

sage dragon
#

Oh, sorry ๐Ÿ˜…

brave sparrow
quiet ice
#

On windows it also works but it is less plug-and-play as you have to install MinGW and whatnot

brave sparrow
#

Itโ€™s not that big of a hassle

grim ice
#

what do i install

quiet ice
#

(sure, on linux you have to install GCC, but you are likely to have it preinstalled beforehand)

#

MinGW is a must for CPP dev on windows

brave sparrow
grim ice
#

i dont even have gcc i think

quiet ice
#

I think you can compile from CLI via gcc when you have MinGW installed

buoyant viper
grim ice
#

i dont get how vs works

#

its too confusing

buoyant viper
#

u just make a new project pretty sure

grim ice
#

theres no option for that

#

only new folder

#

actually not even new folder, "open folder"

#

and new file

quiet ice
#

You are probably using vs code

tender shard
grim ice
quiet ice
#

Vscode is meant for general use, vs is more c/cpp/c# (I think?) centric

brave sparrow
grim ice
#

idk whats that

#

i installed that C/C++ extension pack tho

brave sparrow
#

Then you should be able to make a new project

#

I suspect youโ€™re getting lost in the IDE because youโ€™re not familiar with it

#

You may want to Google how

grim ice
#

i did

#

their ide looks different than mine

#

not the same options

brave sparrow
#

Keep googling lol

grim ice
#

not a single video has something like mine

#

i even thought i have to update it or smth

quiet ice
#

Are you using visual studio or visual studio code?

brave sparrow
#

Can you send a screenshot of your vs

quiet ice
#

Then you should search for vscode, those are two different IDEs

grim ice
#

virtual studio code is what im using

brave sparrow
#

VS and vs code are two different things yeah

#

Then you need to Google that

grim ice
#

so do i use visual studio code or visual studio

buoyant viper
#

visual studio is that absolute chonker of an IDE from windows

#

like im talkin a fuckin hefty, clunky monolith

#

enough to fill an entire harddrive thicc

quiet ice
#

And it is prone to failure from what I heard

buoyant viper
#

all the time

brave sparrow
#

Visual studio will install most of the c++ tools for you

buoyant viper
#

but i dont know anything better for .NET on winblows

#

and i kinda barely write C or Cpp, when i do i use vsc lol

quiet ice
#

But it is a pretty good one from when I looked at it

buoyant viper
#

true

#

but it does what i need it to (most of the time)

brave sparrow
#

Personally Iโ€™ve never had an issue with visual studio but Iโ€™m on the enterprise license