#help-development

1 messages · Page 1728 of 1

quaint mantle
#

No one will gonna answer me 😫

silk tusk
#

PersistentDataContainer on entities is stored even past restarts, correct?

silk tusk
#

Also sets the default config data to a config.yml that was stored inside the jar

tender shard
silk tusk
#

Also is there any way to set the lifetime of a vex? I'm trying to replace the vexes summoned by a specific evoker, but they end up not automatically dying and don't follow what the evoker attacks.

#

A good method for finding the vexes that were summoned would work too, but I haven't been able to find that either

azure nova
#

i am quite new, so i wanted to ask a quick question, i am using player heads in my gui of my plugin and i want to use "skinrestorer plugin" to set player skins and use its code a bit to use player head of those skins in my code....
So i wanted to ask was, how can i link that plugin code with mine? and how do i use it...like yea

quaint mantle
#

try searching for its api

azure nova
#

ohhh wait i will try

chrome beacon
azure nova
#

ok so

#

can i use skinrestorer plugin as a api? i am making a plugin and i want to use this plugin to get custom heads, for example, i set my skin, and i use a command from my plugin, which opens a "gui" having my player head of the skin that i set...

acoustic widget
#

🇬 radle vs 🇲 aven ?

azure nova
#

what?

chrome beacon
#

I usually use maven so that's what I will put in your poll

ivory sleet
#

Gradle is more configurable and faster once cached

#

Arguably as simple as maven also

quasi shoal
#

i dont mind which one i use, but im more familiar with maven so thats what im voting for

tender shard
#

I don't like gradle, their servers are so slow... it takes a like a minute to download a 100mb wrapper

quaint mantle
#

i vote for those 2

#

i wonder if i can stream some mc monke version pvp here

#

oh wrong channel

#

sorry

tender shard
#

maybe their peering to germany is just shit, no idea

ivory sleet
#

Takes like 2 seconds for me

tender shard
#

yeah no idea why

#

it should also only take a second for me normally ¯_(ツ)_/¯

quasi flint
#

Can someone tell me why this method cant read these strings and add them to my set of materials?

#

public void loadNPCStartup() {
FileConfiguration file = gameManager.getGame().getConfig();
file.getConfigurationSection("world.breakAbleBlocks").getKeys(false).forEach(material -> {
allowBreak.add(Material.getMaterial(material));
});
}

#

world:
breakAbleBlocks:
1: dirt_block
2: grass_block

chrome beacon
mystic sky
#

^yeah what's the debug

quasi flint
#

its just plain empty

chrome beacon
#

Check for typos

quasi flint
#

well i checked, no typos should be there

chrome beacon
#

Does it read from the right config

quasi flint
#

yea theres only 1

austere cove
#

you're calling #getMaterial("1")

#

not #getMaterial("dirt_block")

#

so ye it returns null

quasi flint
#

but it should get me the things behind the 1:

austere cove
#

no it shouldnt

chrome beacon
#

How did I miss that :c

quasi flint
#

:8

austere cove
#

that's not what u did in ur code

quasi flint
#

well and how would one fix this problem?

chrome beacon
#

Get the value with the key

quasi flint
#

okay ;7

austere cove
#
ConfigurationSection section = ...;
for (String key : section.getKeys(false)) {
    String value = section.getString(key);
    // Optional null handling
    /* Code */
}
#

alternatively, you just use a list

#

cos you're not using the keys anyways

#
my-section:
  - diamond
  - emerald
worldly ingot
#

I was just going to ask that as well... is there any reason you're not using a YAML list?

sinful matrix
#

Hey Guys
I would like to create a quest plugin where admins can spawn a "Quest Villager". When a player right clicks on it, I want a custom inventory to open. This all works but now comes the problem. With the function on right click event I check if the villager has the custom name "test", if this is the case the inventory should be opened. But now it is so that the players can create nametags and assign them to other villagers. But i only want to get into this menu if the villager is created by a developer. Is there any solution for this?

quaint mantle
#

for 1.14+ i think

golden turret
#

hello

#

im editing an item with packets

#

but when i open an inventory using openInventory the inventory is updated

#

and the item back to the original item

#

1.17

amber vale
tender shard
ancient plank
#

love pdc <3

quasi flint
#

how can i check against what block a specific block is placed?

crimson terrace
#

getBlockFace() I think

#

or getRelative

quasi flint
#

ok thanks

lavish hemlock
#

it's one of the main problems I have with Wrapper tbh

ivory sleet
#

That’s weird

#

Never experienced such problems

final fog
#

Does anyone know how I can remove 1 of a specific item from a player's inventory?

crimson terrace
#

yes

final fog
#

Ok

#

how

#

smfh

crimson terrace
#

well you didnt ask how before this message

final fog
#

I assume the average human being can figure that out for themselves

#

My bad

crimson terrace
#

I was gonna help

final fog
#

I dont want your help

crimson terrace
#

ok

final fog
#

someone else please

#

fuck sake

#

I tried item.setAmount(item.getAmount() - 1); but there's a problem with that

echo basalt
#

if item is null, you have a problem yeah

#

If that item is a clone, you might have to set it on the inventory

#

Generally give code, what you tried, what works, what doesn't

#

So people have context

tender shard
#

just did it the exact same way 5 minutes agao^^

    public static boolean checkForAndRemoveOneItem(String itemId, PlayerInventory inventory) {
        for(int i = 0; i < inventory.getSize(); i++) {
            ItemStack item = inventory.getItem(i);
            if(item == null || item.getType() == Material.AIR || item.getAmount() == 0) continue;
            if(PDCUtils.has(item,"token", PersistentDataType.STRING)) {
                if(PDCUtils.get(item, "token", PersistentDataType.STRING).equals(itemId)) {
                    item.setAmount(item.getAmount() - 1);
                    inventory.setItem(i, item);
                    return true;
                }
            }
        }
        return false;
    }
final fog
final fog
echo basalt
#

You're probably calling remove(item)

tender shard
final fog
#

no i'm doing it the way you guys are doing

final fog
echo basalt
#

Yeah but you're looping through the inventory

#

consider breaking out of the loop if you're doing so

final fog
#

Oh ic ic

#

tysm

tender shard
echo basalt
#

He wants to remove 1 trident from 1 slot

#

for example

tender shard
#

yes

echo basalt
#

He's looping through all slots and checking if it's a trident

#

but after removing he keeps going

tender shard
#

aaah I thought you were talking about the code I sent

echo basalt
#

Instead of calling break; or return;

lean gull
#

hey everyone! how's your day going?
i am in need of help with nbt. i'm trying to make a placeable building item with spigot api, but i do not know how.
if someone could help that would be really nice. thank you!

final fog
#

Yeah all I had to do was just put a break; and check if the item is not null

#

tysm for the help

muted sand
#

How do I play a sound to a player?
Cannot resolve symbol 'ANVIL_LAND'

player.playSound(player.getLocation(), Sound.ANVIL_LAND, 500.0f, 1.0f);
#

nvm, now it fixed itself when i tabbed org.bukkit.Sound

formal dome
#

but i don't know how to specify the code lol

hasty prawn
#

You can't really, the best you can do is add #wikiContent at the end of the URL and it'll scroll to that

#

But it seems like all the titles are within that, so you can't scroll to them

formal dome
#

You config will contain something like this:

Code (YAML):// <<<< which yml file is this?

database:
  host: localhost # host of your database
  port: 3306 # default port for MariaDB and MySQL
  database: db # name of your database. A database server can contain multiple databases
  user: username
  password: passy
 
Now we need to configure our DataSource. Both DataSources provide the same methods:

Code (Java):

Database database = config.getDatabase();//<<<HERE
// we set out credentials
dataSource.setServerName(database.getHost());
dataSource.setPortNumber(database.getPort());
dataSource.setDatabaseName(database.getDatabase());
dataSource.setUser(database.getUser());
dataSource.setPassword(database.getPassword());```
#

where is this Database class from?

#

is this config.yml file the auto generated one you create when you use config.addDefault(path: , value: )

tender shard
#

How can I get the NamespacedKey of a recipe?

#

Bukkit.recipeIterator returns an Iterator<Recipe> but in order to unregister that recipe I need the recipe's NamespacedKey

young knoll
#

You need to check and cast to keyed

tender shard
#

Thanks @young knoll !

#

I'm stupid lol

formal dome
#

once i figure it out im' adding it to the wiki :p

#

just sayin

real spear
#

why doesn't this work:

    @EventHandler
    public void playerChat(AsyncPlayerChatEvent e) {
        String rawMsg = e.getMessage();

        for (String i : bannedWords) {
            rawMsg = rawMsg.replaceAll("(?i)" + i, "");
        }

        if (e.getPlayer().hasPermission("donator.minecraft")) {
            rawMsg = rawMsg.replaceAll("(?i):shrug:", "¯\\\\_(ツ)_/¯");
        }

        String msg = e.getPlayer().getDisplayName() + ChatColor.WHITE + ": " + rawMsg;
        e.setFormat(msg);
        dBot.playerMessageSent(e.getMessage(), e.getPlayer().getDisplayName());
    }
#

the banned words part that is

valid solstice
#

anybody know why if i execute a command, instead of executing it, it sends a message in chat of what command i executed?

valid solstice
#

can i send pics here?

#

i dont think i have picture perms

quaint mantle
arctic moth
#

is there an event for whenever someone uses glowstone or their hand on a respawn anchor?

valid solstice
quaint mantle
#

you're returning false

#

send your code

valid solstice
#

I’m returning true

#

I don’t have a return false statement in my code

#

1 sec I’ll Send

#
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if(!(sender instanceof Player)){ return true; }
        Player player = (Player) sender;

        if(command.getName().equalsIgnoreCase("etp")) {
            
            Player target = Bukkit.getServer().getPlayer(args[0]);
            if(target!=null){
                Location targetLoc = target.getLocation();
                player.teleport(targetLoc);
                player.sendMessage("[ExpressTP] You have been teleported to " + target.getDisplayName());
            } else if (target == null) {
                player.sendMessage("[ExpressTP] This player is offline!" + ChatColor.RED);
            }
           
        }
        return true;
    }
quaint mantle
#

did you update your jar?

valid solstice
#

yes

visual tide
#

check what block was clicked & what the item used to click was for respawn anchor & glowstone

golden turret
#

hello

visual tide
golden turret
#

im using protrocollib to intercept some packets

#

specifaclly

#

the setslot, entitymetadata and entityequipament

arctic moth
#

?paste

undone axleBOT
golden turret
#

in 1.16, when a player joins, the server sends a setslot packet

#

to every single item in his inventory

#

but in 1.17 the packet is not sent

arctic moth
#

trying to make a black hole thing

golden turret
#

i want to know how could i intercept the inventory packet sent when a player jpoins

arctic moth
#

lol i just thought of something

#

what if u cancel the join event

arctic moth
#

error?

mortal hare
#

guys

arctic moth
#

how do you check if a material is a block

#

lol

arctic moth
#

thx

mortal hare
#

when editing the bukkit helpmap is more pain than adding the command manually

#

helpmap api should change, maybe sometime i'll do pr for it

#

basically you cannot add helptopics to indexhelptopic

#

only set new collection

#

which sucks

#

why would i create a new object

#

for no reason

#

and guess what sucks more

#

you cannot get the indexhelptopic collection

#

good luck appending new information to indexhelptopic

#

you can use reflections

#

sure

#

but its a fucking bukkit api

#

not OBC

#

or NMS

#

you can use initializeCommands()

#

but it adds overhead

#

it basically refreshes all the topics of the helpmap

charred wind
#

SELECT *, CAST(JSON_EXTRACT(stats, '$.points') AS UNSIGNED INTEGER) AS points, RANK() OVER(ORDER BY points DESC) AS ranking FROM Cookies_LT someone knows, why there's an error at "ranking"? phpmyadmin says, the field points doesn't exist.

#

But if I execute the query, only with the JSON_EXTRACT, everything's working.

#

with another database server, there aren't any problems...

minor garnet
#
[17:43:59] [Thread-6/WARN]:     at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
[17:43:59] [Thread-6/WARN]:     at java.util.ArrayList$Itr.next(Unknown Source)
[17:43:59] [Thread-6/WARN]:     at vinnydgf.grenade.Grenade.stepSimulation(Grenade.java:236)
[17:43:59] [Thread-6/WARN]:     at vinnydgf.grenade.bukkit.scheduler.TPS_60.update(TPS_60.java:37)
[17:43:59] [Thread-6/WARN]:     at vinnydgf.grenade.bukkit.scheduler.TPS_60.run(TPS_60.java:23)```

https://paste.md-5.net/egikahubex.cs where is the problem and how i can fix it
arctic moth
#

is there a way to make it so falling blocks always snap to a block where they can go so that the block is always placed

eternal oxide
#

I'm going to guess it.kill() also removes it from your collection

arctic moth
#

lol i have no idea why i just made a thred i thought id just give it a try

#

so whatever anyone got an idea how to do it

dry forum
#

how can i paste a schematic using fastasync worldedit api? i cant find anything on it, only worldedit, and the worldedit stuff doesnt work just gives me errors

alpine urchin
#

worldedit api works fine for me

dry forum
#

alot of the stuff is showing up as red like Cannot resolve symbol 'MCEditSchematicFormat'

#

^ and Cannot resolve constructor 'EditSession(com.sk89q.worldedit.bukkit.BukkitWorld, int)' Cannot resolve symbol 'CuboidClipboard' Cannot resolve method 'paste(com.sk89q.worldedit.EditSession, org.bukkit.util.Vector, boolean)'

modest garnet
#

?

acoustic pendant
#

How can i set actionbar position and duration without an API ?

fierce jolt
#

You cannot change the position either.

acoustic pendant
fierce jolt
#

As in?

#

The actionbar is fixed at a certain point in the UI

acoustic pendant
#

for example, one in the right of the action bar and the other in the left

acoustic pendant
#

but changing the position of different texts inside the action bar

fierce jolt
#

There is only one actionbar. You can send a message that is like: LEFT STAT HERE RIGHT STAT and that would cound as left and right of it

acoustic pendant
#

ok, ty!

winged ridge
#

Hey, so basically I made a shop were there are multiple items but I can only buy one of each, what would be the best way to put a number of item selector, so the player can buy multiple items at a time? I already tried making another Inventory and calling it every time a player click on an item in shop, but it's too much of a pain, and I wanted to know if there was easier way of doing it.

white thicket
#

Hey, so I have coded a bot which sends discord message to minecraft which is perfectly fine just that it is sending it 3 times even if someone types a message once
Code

    @Override
    public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
        super.onGuildMessageReceived(event);
        if (botEnabled) {
            if (event.getChannel().getId().equals(plugin.getConfig().getString("chatIntegrationChannelID"))) {
                if (!Objects.requireNonNull(event.getMember()).getUser().isBot()) {
                    String format = plugin.getConfig().getString("DiscordToMinecraftFormat");
                    assert format != null;
                    format = format.replace("{user}", Objects.requireNonNull(event.getMember()).getUser().getName());
                    format = format.replace("{message}", event.getMessage().getContentRaw());
                    Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', format));
                }
            }
        }
    }
minor garnet
#
    @Override
    public void run() {
        running = true;
        long startTime, elapsed, wait;
        while (running) {
            startTime = System.currentTimeMillis();
            update(); // line 23
            
            elapsed = System.nanoTime() - startTime;
            wait = targetTime - elapsed / 1000;
            if (wait < 0) wait = 5;
            try {
                Thread.sleep(wait);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    
    private void update() {
        plugin.stepSimulation(); // line 37
        Grenade.blocks.removeIf(block -> block.body.isDisposed());
    }

}```
white thicket
#

Eg, 1 Stack, 2 Stack, 3 Stack, etc...

white thicket
#

Yeah I just got that lol

winged ridge
white thicket
#

And no I don't think it is

#

I mean the bot is run on other codes too does that count?

#

oh but it was not happening before?

#

it recently started to give this issue

#

Also the code is not in Java, it is in JavaScript, like the same bot is doing other things too

white thicket
winged ridge
#

no

white thicket
#

Ok so they have this really cool feature

#

Where you can select how much stack of an item you want to buy

#

Something like this

#

You could implement this into your shop system

lyric grove
#

How would I fix this? Im having trouble setting the block face to up

quaint mantle
#

do not use materialdata

#

it has been deprecated since legacy

lyric grove
#

What else should i use?

winged ridge
lyric grove
#

thanks

quaint mantle
#

wait

#

thats deprecated too

#

wtf

#

((Directional) block).setFacing(BlockFace.UP);

white thicket
#

Or you could do that in chat too

real spear
#

why doesn't this work:

    @EventHandler
    public void playerChat(AsyncPlayerChatEvent e) {
        String rawMsg = e.getMessage();

        for (String i : bannedWords) {
            rawMsg = rawMsg.replaceAll("(?i)" + i, "");
        }

        if (e.getPlayer().hasPermission("donator.minecraft")) {
            rawMsg = rawMsg.replaceAll("(?i):shrug:", "¯\\\\_(ツ)_/¯");
        }

        String msg = e.getPlayer().getDisplayName() + ChatColor.WHITE + ": " + rawMsg;
        e.setFormat(msg);
        dBot.playerMessageSent(e.getMessage(), e.getPlayer().getDisplayName());
    }
white thicket
#

yes

winged ridge
real spear
lyric grove
quaint mantle
#

👍🏿

white thicket
#

The only issue with the chat thing is that this might not work for people who are muted

winged ridge
#

hm

white thicket
#

Sorry to tag you but does it matter if the bot is being ran by some other code in other language? It might be running in JS by my co-dev for some other stuff

#

But then why isn't it sending minecraft messages to discord 3 times? 🤔

#

What?

formal dome
#

actually, so the config.yml is generated in a directory in the plugins directory named after your plugin

#

so that's where i would place a manually created one

#

so everythings cool... other than the fact that i need to put my database password in that config file

#

i would think its typical to try to keep that secret when someone downloads your plugin? how do you do that?

#

i need to store my own database not an external one

#

wait let me do something then

young knoll
#

?

blissful folio
#

how to listen to packets using Spigot & ProtocolLib 1.17?

#

Every single example code I've seen fails

regal moat
#

How can I get all of the blocks in a chunk?

chrome beacon
#

What are you planning to do?

stone sinew
fierce jolt
#
                "custom_model_data": 1
            },``` Is it possible to change custom_model_data to something like MyCustomData?
#

(resource packs)

ivory sleet
#

afaik no

young knoll
#

Hover over it

fierce jolt
#

fml

#

seems so logical, since you can attach custom data

ivory sleet
acoustic pendant
#

Does anyone know why this send an error to the console?


    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {
        Player player = e.getPlayer();
        ActionBarAPI.sendActionBar(player, "action bar message.");

    }
}
#

it's well imported

ivory sleet
#

Maybe send the error

acoustic pendant
#

sure

#
[23:09:01] [Server thread/WARN]: java.lang.NoSuchMethodException: net.minecraft.server.v1_16_R3.PacketPlayOutChat.<init>(net.minecraft.server.v1_16_R3.IChatBaseComponent,net.minecraft.server.v1_16_R3.ChatMessageType)
[23:09:01] [Server thread/WARN]:        at java.base/java.lang.Class.getConstructor0(Class.java:3517)
[23:09:01] [Server thread/WARN]:        at java.base/java.lang.Class.getConstructor(Class.java:2238)
[23:09:01] [Server thread/WARN]:        at com.connorlinfoot.actionbarapi.ActionBarAPI.sendActionBar(ActionBarAPI.java:79)
[23:09:01] [Server thread/WARN]:        at com.connorlinfoot.actionbarapi.ActionBarAPI$1.run(ActionBarAPI.java:104)
[23:09:01] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:81)
[23:09:01] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:400)
[23:09:01] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1179)
[23:09:01] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:394)
[23:09:01] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1127)
[23:09:01] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:966)
[23:09:01] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273)
[23:09:01] [Server thread/WARN]:        at java.base/java.lang.Thread.run(Thread.java:831)```
fierce jolt
ivory sleet
#

Well

acoustic pendant
#

without the API

#

i can send the message

#

and doesn't send any error

ivory sleet
#

The process goes like this:
The server creates an item stack,
The server sets the custom model data tag on that stack to for instance 1,
The server sends a packet to the client about the item stack,
The client receives it
The client decodes the item stack so that it can know how to render the item stack,
The client looks if the custom model data tag is set to a value, if so then it gets the corresponding texture and renders it,

thing is the custom model data tag must be hard coded such that both the client and server knows what tag to use as communication

acoustic pendant
#

so, the problem is from the API?

ivory sleet
#

Yes

acoustic pendant
#

hmm

#

uh

#

do you know any great thread about actionbars?
I haven't find anything about it

ivory sleet
#

If you use 1.16

#

Just use the api method

acoustic pendant
#

but is sending an error

vague oracle
#

What’s the error

ivory sleet
#

I didn’t mean ActionBarAPI

#

That shit is old and obsolete

acoustic pendant
#

it was a newer

ivory sleet
#

use the api method spigot has

acoustic pendant
#

player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Hello!")); this?

ivory sleet
#

Precisely

hasty prawn
#

Would anyone happen to know how to get Gson to store a single backslash as a property, instead of escaping it? Trying to store \uE000 as a String and it keeps making it \\uE000

acoustic pendant
#

i haven't find any thread about it

#

so i don't know how to align or send the action bar much times so it doesn't dissapear

ivory sleet
#

Use a scheduled task to send it repeatedly

acoustic pendant
#

ok, that's the next episode i was about to see in the guide xD

fierce jolt
#

oops

acoustic pendant
#

and the align? days ago i did something (don't know what) and it appeard a method called align but don't know how i did it :/

ivory sleet
#

It gets automatically aligned tho?

#

Like centered

acoustic pendant
#

i mean

ivory sleet
#

Believe Apache has a StringUtil class which might just fit your needs

acoustic pendant
#

don't want to get it centered

#

i want to align it to the left or right

hasty prawn
ivory sleet
#

You could use String::format

hasty prawn
#

It's valid JSON though so it has to be possible somehow

ivory sleet
#

Not through gson

#

Gson is dead anyways but ye

hasty prawn
#

Yeah I was just trying to use whatever came with Spigot

#

Okay thanks Conclure NODDERS

acoustic pendant
#

damn

ivory sleet
#

Yeah Idk maybe check out jackson or moshi dessie

hasty prawn
#

I wonder if org.json will do it

ivory sleet
#

Adri possibly a stack overflow post with a google might assist you here

acoustic pendant
#

hmm

#

ig, ty as well

marsh burrow
#

Any hardcore programmers can help a homie out. I have this thing were I have an enum that stores sub-commands, but one of the sub commands I can use it in multiple places, but it needs another enum input. When I check up on the value inputted, it returns null, anyone know what might be happening?

ivory sleet
#

So you mean the pointing value of CommandType.AMETHYST is null?

#

Or what is the issue?

marsh burrow
#

Yeah, CommandType.AMETHYST is null when I grab it

ivory sleet
#

Could be possible but that screenshot there is too little to tell anything

#

Most likely you’re Enum cycling

stone sinew
#

You're returning CommandType are you sure CMD_Help isn't null?

marsh burrow
#

Heres the Cmd_Help

#

and the console output

#

console should be saying false

acoustic pendant
#

i can't literaly find anything about actionbar in spigot lol

ivory sleet
#

If you load Enum constant a which requires Enum constant b that requires Enum constant a then it won’t work

#

As said you’ll get yourself an Enum cycling dependency flow

marsh burrow
#

oof, I think you are right

#

didnt realize I load this enum off the other enum

ivory sleet
#

However the entire idea of using enums for this is a bad practice somewhat

#

Just create a Map or smtng which acts like a repository / registry for your commands and can do lookups

marsh burrow
ivory sleet
#

Much more object oriented and will help you with your code infrastructure

marsh burrow
#

yeah, calls it self....

#

i technically could just do two help commands

#

just that this help command can show help for both commands

ivory sleet
#

And with objects you can to a certain extent have two objects simultaneously interdependent

marsh burrow
#

true, I can just extend this special help command

#

tried doing it the cheaty way

ivory sleet
#

No I mean
class A {
B b;
A() {
b = new B(this);
}
}
class B{
A a;
B(A a){
this.a = a;
}
}

#

Here they’re interdependent

#

And what makes it possible is that you can control when they’re instantiated

fierce jolt
#

Is there something with overrides only working to a certain depth?

marsh burrow
ivory sleet
#

Gl (:

ivory sleet
#

PlayerItemConsumeEvent or smtng

#

Listen to that

#

The other stuff is trivial

#

Check if the item stack is your item

#

Then apply the effect

young knoll
#

AddPotionEffect

#

?jd

worldly ingot
#

Potions is NMS. You've no reason to be using that

#

It's not even compatible with that method signature

vague oracle
#

Quite simple should learn Java first, using the correct parameter types and understand deprecation is so simple

dry forum
silk tusk
# chrome beacon What are you trying to do?

My plugin lets you tame random mobs, and I want a tame evoker to summon tame vexes. I ended up making it so that on evoker cast I save the evokers status, and then when vexes spawn I apply the status based on the last evoker spell. It might not be perfect, but it seems to be working.

crude charm
dry forum
#

i dont use gradle or maven

crude charm
#

...

dry forum
#

and yes i added it as a library and dependency

crude charm
#

obv not

dry forum
#

obv i did

crude charm
#

ok well you can figure it out yourself if you're going to give me an attitude

dry forum
#

how am i giving u attitude

shadow tide
#

?paste

undone axleBOT
ivory sleet
#

It’s almost a pre requisite for managing dependencies

paper viper
#

Yeah

#

if you aren't using Maven or Gradle, you are missing out on so much oppurtunity

#

also its easier cause you can just add one line to add a dependency

#

rather than all this ui stuff

dry forum
#

idk i just find it extra work thats rly un-neccesary since i dont really make plugins with dependencies and why make life harder when you can already do it jsut by adding a library :p

paper viper
#

Spigot api is a dependency...

#

I have no idea what you are talking about

dry forum
#

ik

ivory sleet
#

It’s not unnecessary work

dry forum
#

i mean adding a plugin dependency

paper viper
#

In fact, you can add a library with one simple line

#

Yep

#

one line

ivory sleet
#

It’s to protect your future self from a catastrophe

paper viper
#

Realize that the advice we give to you is so you can succeed in the future 🙂

real spear
#

why doesn't the chat blocker part of this work:

    @EventHandler
    public void playerChat(AsyncPlayerChatEvent e) {
        String rawMsg = e.getMessage();

        for (String i : bannedWords) {
            rawMsg = rawMsg.replaceAll("(?i)" + i, "");
        }

        if (e.getPlayer().hasPermission("donator.minecraft")) {
            rawMsg = rawMsg.replaceAll("(?i):person_shrugging:", "¯\\\\_(ツ)_/¯");
        }

        String msg = e.getPlayer().getDisplayName() + ChatColor.WHITE + ": " + rawMsg;
        e.setFormat(msg);
        dBot.playerMessageSent(e.getMessage(), e.getPlayer().getDisplayName());
    }
paper viper
#

Just try it

dry forum
#

idk i guess i can look at it butttt i still added it as a library and my code doesnt work

#

some world edit stuff does work and lets me import it and all that but what i sent it isnt recognizing

ivory sleet
#

The only reason not to use a built automation tool would be if it’s a test project of some sort where JDK solely is needed

#

Anyways there isn’t much assistance many of us can give here unless you’re willing to use a build automation tool

dry forum
#

so no one would know why my code isnt working?

ivory sleet
#

I don’t know what does it say?

dry forum
ivory sleet
#

Can you screenshot?

dry forum
#

it saying it doesnt recognize the stuff?

ivory sleet
#

But most likely the dependencies aren’t added to your compile time classpath

#

Which might be due to incorrect project setup

#

Needless to say gradle or maven would help significantly in this case

dry forum
#

well its added as a library

ivory sleet
#

I meant the whole screen facepalm

ivory sleet
#

Looks like it should be added

#

But ant is ass

#

(IntelliJs default build automation tool)

#

Which is the one you’re using

#

So can’t help you any further unless you decide to make a big commitment and try maven or gradle out

dry forum
#

rip ok ty anyway ig

paper viper
#

ant is like old grandpa

ivory sleet
dry forum
#

the thing under the file setting?

ivory sleet
#

Indeed

dry forum
#

i just tried it, nothing changed

ivory sleet
#

Hmm alright then Idk sorry

shadow tide
ivory sleet
#

It’s good except the abysmal comments

shadow tide
#

yeah

#

lol

ivory sleet
#

Thing is, I’m gonna give you a pro tip

shadow tide
#

if it is sc.nextInt I know

ivory sleet
#

You can extract a method called for instance multiplying and then do multiplying the operation in that function and just call that function

shadow tide
#

I just don't know the error for it not being an int

ivory sleet
#

Then the code will explain itself

#

Thus no need for that comment

shadow tide
#

yeah

#

It works, the problem is that its cluttered. That would fix that clutter

ivory sleet
#

I’m planning to write an object oriented guide, Object Orientation in Spigot Practice

shadow tide
#

nice

ivory sleet
#

Yeah cjendantix

#

Longer functions are rude and impolite to the reader

#

Because you need to read the entire function in order to understand what it does

shadow tide
#

Its the main class, so its technically not a function

ivory sleet
#

If we extract functions we will get this semantic layers of function calls so we can then exit early if we want

#

It’s in a function

#

main(args)

shadow tide
#

not really

#

its a class

ivory sleet
#

Yes

#

But the code is declared within a function

shadow tide
#

yes I know public static void main(String[] args)

ivory sleet
#

So it’s in a function

shadow tide
ivory sleet
#

I don’t know about that one 🥴

shadow tide
#

if its the only function in the main class

#

of course

ivory sleet
#

Idk I mean it’s important to differentiate between classes and functions

#

But as long as you understand it is in a function then it’s fine Ig

shadow tide
#

ok then its just main

ivory sleet
#

Yeah guess that’d be more accurate (;

paper viper
#

your main function is still a function

#

lmao?

shadow tide
#

bruh

#

reread the entire chat

paper viper
#

Yes i did

#

but you just called it "main"

#

lmao

shadow tide
#

I just don't want to call it a function unless necessary, its called preference

paper viper
#

These are functions and are defined as such

shadow tide
#

mutes the server

paper viper
subtle kite
#

LeArN jAvA ,

ancient plank
#

kek

valid solstice
#

im not returning false

unkempt peak
#

? What are you trying to do?
Aslo can you show the code

valid solstice
#
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if(!(sender instanceof Player)){ return true; }
        Player player = (Player) sender;

        if(command.getName().equalsIgnoreCase("etp")) {
            
            Player target = Bukkit.getServer().getPlayer(args[0]);
            if(target!=null){
                Location targetLoc = target.getLocation();
                player.teleport(targetLoc);
                player.sendMessage("You have been teleported to " + target.getDisplayName());
            } else if (target == null) {
                player.sendMessage("This player is offline!" + ChatColor.RED);
            }
           
        }
        return true;
    }```
unkempt peak
#

?paste

undone axleBOT
unkempt peak
#

Can you use that

valid solstice
#

alright

unkempt peak
#

It should be label not command

#

You need to check if label equals etp

eternal oxide
#

no

ancient plank
#

command works fine

unkempt peak
#

Wait really

#

I have never used command

eternal oxide
#

I got that wron for the longest time

ancient plank
#

can't remember what label is for but isn't it like, for the aliases or smth?

valid solstice
eternal oxide
#

yes

unkempt peak
#

What exactly is the issue @valid solstice ?

valid solstice
#

when executing the command, it just sends the command in chat

unkempt peak
# eternal oxide yes

Also are you actually supposed to use command because if so I've been doing it wrong for like a year lol

eternal oxide
#

yep, cmd will give you the actual command thats registered and was used. label gives you whatever was typed (alias) to trigger the command

ancient plank
#

fk

#

ill just do the example I was gonna give

unkempt peak
#

@valid solstice do some sysouts because it is returning true somewhere

valid solstice
#

i dont have a "return false" statement

unkempt peak
#

The last one should be false

ancient plank
#

if you use label, you gotta look for all the aliases

if(label.equalsIgnoreCase("peanut") || label.equalsIgnoreCase("pnt"))

while with cmd you can just do

if(command.getName().equalsIgnoreCase("peanut"); // this will get the command /peanut, even if you use the /pnt alias
unkempt peak
#

Oh ok I always check each alias

#

Thanks I will start doing that

eternal oxide
#

looks to me from that SS you havn't registered the command

unkempt peak
#

Won't it return an error if that's the case?

ancient plank
#

no

valid solstice
unkempt peak
#

No on your onEnable

valid solstice
#

oh

ancient plank
#

if you don't register the command but have it in your plugin.yml it'll "exist" but there's no code for it to execute, so it just returns false by default

unkempt peak
#

ah ok

valid solstice
#

that must be why, thank you

quaint mantle
#

how would i add x points into an int i, and if it pass y then it would reduce the i to equals y other than using a nested loop like this?

    int i = 2;
    if (i < 3) {
    i = i + 3;
    System.out.print(i);
    System.out.println("");
    for (int e = i; e >= 3; e--) {
    System.out.println(e);
    }
    }```
drowsy helm
#
i = (i + x) > y ? y : i;
#

is that what you mean?

quaint mantle
drowsy helm
#

the explanation is a bit hard to follow

quaint mantle
#

let me try

#

i think i know it

#

but i forgot what is the ? is

#

switch?

#

or what?

hasty prawn
#

Ternary

drowsy helm
#

value = boolean ? value1 : value2;

#

basically an if statement

quaint mantle
#

let me learn java basic 😂

drowsy helm
#
i = (i + x) > y ? y : i;

is the same as

if((i+x) > y){
  i = y;
}else{
  i = i
}```
quaint mantle
#

oh that is if else

#

thanks :v

spare marsh
vague oracle
#

If the code runs you have a listener preventing changing of gamemodes

quaint mantle
drowsy helm
#

you can just use Math.max for that

quaint mantle
drowsy helm
#

sorry not max, min

#

Math.min(i, 5);

#

if i is less than 5, it will chose i

quaint mantle
#

look through its code

#

hmm

drowsy helm
#

if i is greater than 5, it will chose 5

drowsy helm
#

whats up with the if(3 < 5)

#

that will always be true

quaint mantle
#
    public void addLives(UUID pUUID, Integer lives) {
        getConfig().set("Players-Data." + pUUID + ".Fantom", Math.min(getFantom(pUUID) + lives, getMaxFantom(pUUID)));
        saveConfig();
    }```
wait then it would only be this 😂
arctic moth
#

Anyone know how to use vector speed

#

I thought it was multiply but doesn't seem to do anything

#

Like multiplied by 10 seems to have no difference from 20

young knoll
#

Minecraft has a limit iirc

arctic moth
#

Ik but the limit is like 500 or smth

#

Cuz I've seen plugins yeet ppl rlly far

#

But with just multiplied by 10 or 20 or smth doesn't seem to make a difference

young knoll
#

They probably do it continually

arctic moth
#

Just yeets a little bit

#

?

young knoll
#

I’ve found 10 is around the limit

arctic moth
#

O

#

But its like barely any yeeting

#

Lol

young knoll
#

If you want to send someone really far you need to keep applying a velocity with a runnable

arctic moth
#

Oh

#

K

young knoll
#

But generally an x y and z of 10 is the max

jaunty merlin
#

does anyone know where knockback would be located in the Spigot-Server folder

#

like I would like to modify knockback

#

but modifying it with a plugin seems a bit scuffed

young knoll
#

You’d need to create a patch over NMS

jaunty merlin
#

yeah i get that, but do you know which file knockback would be located

young knoll
#

No idea

#

EntityPlayer, maybe

#

Or one of the superclasses

jaunty merlin
#

wait also is NMS only for newer versions?

young knoll
#

No

#

NMS just stands for net.minecraft.server

jaunty merlin
#

ye my bad

quaint mantle
#

hmmm can this serialize location hmmm```java

public String locationToBase64(Location pLoc) throws IllegalStateException {
    try {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
        
        dataOutput.writeObject(pLoc);
        dataOutput.close();
        return Base64Coder.encodeLines(outputStream.toByteArray());
    } catch (Exception e) {
        throw new IllegalStateException("Unable to save location.", e);
    }
}```
young knoll
#

Location is already configuration serializable

#

But yes that will probably work for converting it to base64

#

Alternatively you can just write worldname,x,y,z,pitch,yaw

quaint mantle
#

*yea

#

sorry caps

#

but uhh

#

i dont think i need to change anything in the location normal

#

so change it to base64 is maybe less storage

#

:yay:

#

oh no thanks i will not change it to base64 let it be normal maybe better

sullen marlin
#

that is horrible

young knoll
#

MD does not approve

quaint mantle
#

😂

sullen marlin
#

I'm gonna go gouge my eyes out now

young knoll
#

To be fair I don’t know what id do to save a location outside of yaml

young knoll
vestal berry
#

How to make a Bungeecord server

quaint mantle
vestal berry
#

@young knoll then what to do

sleek dragon
#

for some reason when I right click on sand and replace it with a note block it plays the sound but not on grass or dirt

#

does that have something to do with grass/dirt being able to be turned into dirt paths using shovels but theres no interaction with shovels on sand so it still registers the right click on sand?

#

how should I go about getting around this?

young knoll
#

What’s the issue? I’m confused

#

And the file doesn’t embed

valid solstice
#

java.lang.IllegalStateException: PlayerTeleportEvent may only be triggered synchronously. anybody know whats causing this?

young knoll
#

You are teleporting a player async

#

Or manually calling the event async

valid solstice
#

yea i have a async player chat event

#

how do i fix this?

young knoll
#

Use a schedular to call it sync

#

By just wrapping it in a runTask

valid solstice
young knoll
#

runTask iirc

young knoll
valid solstice
#

thanks

sleek dragon
#

i already have it canceling the event prior to even converting the block

young knoll
#

Weird

#

It may be the second event call with the offhand? Not sure

sullen marlin
#

worst code I've seen this week

#

why would you want to do that

quaint mantle
#

😦

sullen marlin
#

I'll answer: terrible

onyx shale
#

I assume so, as well

#

Wouldnt that encoding be a lot slower than serializing the normal way

sullen marlin
#

Double paired with string wrapped in map converted to bytes converted to string

quaint mantle
#

I really need to learn java 😂

#

?learnjava

undone axleBOT
young knoll
#

I’m sure we can add more conversions

last ledge
#

I am making a nick plugin, but i am having a problem, i want to change the player's name in player list too, to his nicked name.

    @EventHandler
    public void PlayerList(PlayerJoinEvent event) {
            event.getPlayer().setPlayerListName(event.getPlayer().getDisplayName());
        }
    }```

this is my code
but it dosent work
give solution
opal juniper
#

is it registered

last ledge
#

yes

opal juniper
#

ok

#

try sysout their display name

#

idk what the difference is

#

it may be working you just don’t realise

sleek dragon
last ledge
#

in chat the nicked name is coming

#

but in player list

#

its not

opal juniper
#

where are you changing the nick

last ledge
#

in another class

opal juniper
#

ah ok

#

ik in the past people have had issues with the player list

#

and changing names and stuff

last ledge
#

just its not showing in player list, though i have modified it to display name

young knoll
last ledge
#

ah someone experienced pls help

tacit drift
#
  1. You can save a location as a string in config
vestal berry
#

How to make Bungeecord server

#

🥺

tacit drift
#
  1. There are n other ways to store a location in a config in a readable way
#

you may use base64 serilization for inventories maybe 👀

quaint mantle
#

But anyways u don’t have it reply to it

#

Or at least don’t ping

tacit drift
quaint mantle
#

i guess it is faster to stick to the normal way after some mins after posting the question 😂

vestal berry
#

Anyone know to make Bungeecord server

#

🥺

quaint mantle
#

and

vestal berry
#

Do you know

quaint mantle
quaint mantle
vestal berry
#

Lol

#

Where

#

Do I post it

quaint mantle
vestal berry
#

Sowwwy

last ledge
#

I am making a nick plugin, but i am having a problem, i want to change the player's name in player list too, to his nicked name.

    @EventHandler
    public void PlayerList(PlayerJoinEvent event) {
            event.getPlayer().setPlayerListName(event.getPlayer().getDisplayName());
        }
    }```


this is my code
but it dosent work
give solution
sleek dragon
#

do i have to use NMS if I want to trigger the clientside animation of a player "using" a shovel

#

like they swing it

thick tundra
#

how would I go about hiding an armorstand with packets and then let it reappear with the same equipment? im using minecraft 1.17.1

sullen marlin
#

no nms

solid cargo
#

so my custom made itemstack is having this issue

#

the checker checks if there is lapis

#

and for the item to work, it should be like this

#

not this

vernal pier
#

contains(Material.

solid cargo
#

just contains?

#

no new ItemStack?

vernal pier
#

yes

solid cargo
#

wait is getItemInUse equal to getItemInHand?

vernal pier
#

use material

#

uh no

#

item in hand is the thing their holding

#

and in use is uh

#

using

solid cargo
#

duh

vernal pier
#

like

#

eating

#

idk

solid cargo
#

ah ok

#

i understand

#

and

#

wait

#

that isnt important

solid cargo
#

why does the console say i tped twice. it also consumes twice

#
 
public static void onClick(PlayerInteractEvent e){
        Player p = e.getPlayer();

        if (!( p.getInventory().contains(Material.LAPIS_LAZULI) ) && p.getInventory().getItemInHand().equals(SMPCoreMightAdded.aspectOfTheEnd)) {
            if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                e.setCancelled(true);
                p.sendMessage(ChatColor.RED + "Not enough materials!");
                p.playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 999f, 0.5f);
            }
        } else if (p.getInventory().contains(Material.LAPIS_LAZULI)) {
            if (e.getAction() == (Action.RIGHT_CLICK_AIR) || e.getAction() == (Action.RIGHT_CLICK_BLOCK)) {
                if (p.getInventory().getItemInHand().equals(SMPCoreMightAdded.aspectOfTheEnd)) {

                    Block b = p.getTargetBlock((Set) null, 8);
                    Location loc = new Location(b.getWorld(), (double) b.getX(), (double) b.getY(), (double) b.getZ(), p.getLocation().getYaw(), p.getLocation().getPitch());
                    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, 3));
                    p.setWalkSpeed(0.2f);
                    p.teleport(loc);
                    Bukkit.getLogger().info("got tped 1x");
                    p.getInventory().removeItem(new ItemStack(Material.LAPIS_LAZULI, 1));

                    p.sendMessage(ChatColor.AQUA + "Teleported!");
                    p.playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 99999f, 1f);
                }
            }
        }
    }
}

here is my code for the event

vague oracle
#

Newer versions fire twice for both hands

#

So check if they are using Main hand

solid cargo
#

so

#

getItemInMainHand ?

vague oracle
#

Nope

#

Check which hand called the event

solid cargo
#

ah ok

vague oracle
#

?jd

muted sand
#

How would I run a command as console, & get the output?

chrome beacon
muted sand
#

that doesn't return the output though
it'll only return an output if there's an error

crimson terrace
#

it does return an output to console tho

muted sand
#

how do i read that output then?

crimson terrace
#

not sure if what youre trying to do is possible unless you scan every message in console for what youre looking for

muted sand
#

rip, alrighty

eternal night
#

you could attempt to implement your own command sender

crimson terrace
#

but I havent played with that yet so i might just be completely off

eternal night
#

that wraps the existing console representation

chrome beacon
#

The real question is why

muted sand
chrome beacon
muted sand
#

I did uh, this

public interface FormattedCommands extends CommandSender{


    default void sendMessage(@NotNull String message) {

    }
    

}

but it's always returning void for some reason

eternal night
#

you have to capture the message

#

e.g. have a List<String> field

#

and append each message passed to sendMessage to that list

muted sand
#

oh

eternal night
#

tho this is obviously an interface

#

you'll need to implement it

muted sand
#

confusing, but i'll attempt something like that

lavish breach
#

If I add 2 different versions of spigot in dependencies, can I use functions from both of them or will there be some conflicts? I'm new to java.

lavish breach
#

Probably wouldn't work because they share some classes?

quaint mantle
lavish breach
#

I will, I'd just like to have some idea of what is and isn't possible, because I have a feeling whatever resource I'm going to read through does not make this obvious.

drowsy helm
#

if you are adding 2 different versions im assuming there is functionality in one version that doesn't exist in the other?

chrome beacon
#

If you want multiple spigot versions you should use Gradle or Maven modules

drowsy helm
#

your runtime environment will only contain one of those dependencies

chrome beacon
#

Assuming you what you want is multiversion support

chrome beacon
#

I'd use a string list and convert that

sour fog
#

what theme is that?

#

Thanks, looks nice

chrome beacon
#

Something like that yeah

last ledge
quasi flint
#

Can someone tell me, why this is throwing me hundreds of errors after backing up the world, unloading the old one onDIsable, deleting it, moving the new one there?

plain helm
solid cargo
# last ledge https://paste.gg/p/anonymous/49b625b18b6f4f38861bc5449f3b3698 hello why is my Ni...

if you are new to programming, i would recommand learning at least the mere basics of java
great tutorials are from Alex Lee (https://www.youtube.com/watch?v=az6SehZyY7U&list=PL59LTecnGM1NRUyune3SxzZlYpZezK-oQ)

Full Java Course: https://course.alexlorenlee.com/courses/learn-java-fast
If you're new to programming, I HIGHLY RECOMMEND solving challenges on Edabit: https://edabit.com/?ref=alexlee
Get my favorite programming audiobook for free! https://audibletrial.com/alexleefree
20% off Brain.fm (productivity hack): https://www.brain.fm/alexlee20
Get Tabn...

▶ Play video
quasi flint
#

?learnjava

undone axleBOT
quasi flint
#

but still it throws error when unloading the world

#

and then moving the new one there

quasi flint
#

ok redid it again

#

i got so far to delete the world folder without errors

#

but when now moving the backup world to the right location it still loads the old one

#

someone got an idea why?

#

this is currently my onDisable method

#

@SneakyThrows
@Override
public void onDisable() {
for(Player p : Bukkit.getOnlinePlayers()) p.kickPlayer("");

    Bukkit.unloadWorld("world", false);

    File mapBackup = new File(this.getDataFolder() + "/maps/world");

    File target = new File("world");

    System.out.println(ChatColor.RED + target.toString());

    FileUtils.deleteDirectory(target);
}
pastel stag
#

do you have to have a plugin disable itself in the main class?

#

or can you somehow have a method in a sub-class that triggers a plugin disable

#

with like getServer().getPluginManager().disablePlugin();

quasi flint
#

No i do Not have smth that disables my Plugin

#

Why should i?

pastel stag
#

oh sorry i wasn't directing that at you i was asking a general question lol

chrome beacon
#

I think you can disable it when you feel like it. No real restriction

quasi flint
#

Yeah, but why would U disable IT 😂

pastel stag
#

lets say plugin detects it has lost connection to a database and the database is critical for its operation

quasi flint
#

I could cry rn. The Plugin deleted the whole world folder and replaces it with a fresh one. But it still loads the old one. Why 😂

pastel stag
#

it sees it cant reconnect so it disables itself

quasi flint
#

Makes sense

quasi flint
#

Makin no sense

fading lake
#

how would I find out whether a server a plugin is on is bungee or spigot at runtime? trying to have 2 different main packages, one for spigot, one for bungee in one jar and select between the 2 given each's needed environment, I'm fine with adding a third manager package/class if needed

#

or would it just be as simple as having both, and then one of them just doesnt run

young knoll
#

Yes

fading lake
#

alright, ill try it, thanks ❤️

quasi flint
#

Just 2 ymls

fading lake
quasi flint
#

Nah

#

Just a plain old spigot.yml

#

Alongside a bungee.yml

fading lake
#

?

quasi flint
fading lake
#

where Bungee and Spigot are extends Plugin and JavaPlugin respectively

young knoll
#

Yes

fading lake
#

thanks both of you ❤️

acoustic pendant
#

?jd-s

undone axleBOT
acoustic pendant
#

Could someone explain me about getHealthScale?

#

For what it is used

quasi flint
#

Could someone here send me an example on how to load an world after deleting the old one?

#

for some reason it still gives me te old map

#

got this for deleting the old map

#

Bukkit.getWorld("world").setAutoSave(false);

    for(Player p : Bukkit.getOnlinePlayers()) p.kickPlayer("");

    Bukkit.unloadWorld(Bukkit.getWorld("world"), false);

    File unloadedWorld = new File("world");

    FileUtils.deleteDirectory(unloadedWorld);
regal moat
#

How can I check if a block is a block entity?

eternal oxide
#

do you mean a TileEntity?

regal moat
#

Ah

#

Yes

eternal oxide
#

instanceof

regal moat
#

So like block.getState() instanceof TileState

eternal night
#

👍

#

tho getState creates a snapshot

#

similar to getItemMeta

#

you will have to store it in a variable before modifying it

quaint mantle
#

i have a question

#

how to disable these warns

#

what warn shod i suppress

#

im sure it will not cause

#

and it does not need any null check

quasi flint
#

you could input a wrong configuration section

#

and that will nullpoint

quaint mantle
quasi flint
#

because u dont supresswarnings

#

u fix them

quaint mantle
#

it is fixed

#

im sure it wont get null

ivory sleet
#

lol

quaint mantle
#

there is 0 chance for it to get null it is impossible

quasi flint
#

better make it -1

quaint mantle
#
for (final String s : data.getConfig().getKeys(false)) {
                    final ConfigurationSection locationSection = data.getConfig().getConfigurationSection(s).....

how could it get null

#

not possible

acoustic pendant
#

Could someone explain me about getHealthScale?
For what it is used?

quaint mantle
eternal oxide
quaint mantle
eternal oxide
#

if a method can return null checking for null is nto useless code

quaint mantle
#

can return null

eternal oxide
#

it may not be a config section under that key. It could be a value

#

which would return null when you call getConfigurationSection

quaint mantle
#

thats a data file

#

so it will get set

#

a user should not edit the data file

#

unless its needed

eternal oxide
#

Stop arguing against correct coding practices. You are trying to convince others that your shortcut is valid.

quaint mantle
#

bro just what should i supress

eternal oxide
#

if ANY method can return null test for it

#

you do NOT supress

quaint mantle
#

i want to suppress
please tell

eternal oxide
#

No

quaint mantle
#

i know how to code

eternal oxide
#

Then code properly

quaint mantle
#

can you please tell so

quasi flint
#

No

eternal oxide
#

test for the null and you'll have no warnings

quaint mantle
#

helpful, thx

#

i will just leave this conversation

quasi flint
quaint mantle
#

i know i can null check

#

but i want to know

ivory sleet
#

Lets chill guys

quaint mantle
#

that what should i suppress

#

cause when i suppress all

#

it will go

quasi flint
#

check if the configurationsection is null

quaint mantle
#

so there must be something that i can suppress

quasi flint
ivory sleet
#

using @SuppressWarnings("") will just tell the ide what it shouldnt inspect

quaint mantle
#

right ?

#

no

quasi flint
#

tf

ivory sleet
#

it does not affect your codes behaviour at all

quaint mantle
#

i know

#

it is wrong

quaint mantle
#

see

#

it is annoying

ivory sleet
#

and you can only pass a string there

quaint mantle
#

i know it is a string

quasi flint
#

just in your loop if(configurationsection == null) return; or smth along these lines

ivory sleet
#

because its an annotable interface

#

so ofc passing a boolean expression wont work

quaint mantle
#

i know

#

i know

eternal oxide
#

We are not going to tell you how to avoid coding correctly. We WILL tell you have to do things properly

quaint mantle
#

i just wrote the code to tell him that i want that
not a null check

quaint mantle
#

i will put a check

#

but just tell me

#

what suppresswarning is it

eternal oxide
#

google then. We will not do this for you

quaint mantle
#

that will prevent that warns

ivory sleet
#

NullableProblems iirc

#

@quaint mantle

quaint mantle
#

lemme see

#

my intellij is not open

quasi flint
quaint mantle
#

...

ivory sleet
#

anyways you can check that yourself

#

alt enter on the inspection and chose suppress

#

in intellij

quaint mantle
#

lemme open

ivory sleet
#

idkhow2 do it in eclipse

eternal oxide
#

its literally in his code add if (locationSection == null) continue;

ivory sleet
#

I think he just wanted to suppress it

eternal oxide
#

yes he does

ivory sleet
#

yeah

eternal oxide
#

Which is why I'll not tell him. Code properly and don't ignore errors

ivory sleet
#

¯_(ツ)_/¯

quasi flint
#

Quick question: For map resetting, can I just delete the world folder in my onDisable and then just copy a new one there?

eternal oxide
#

no

ivory sleet
#

nope

eternal oxide
#

only in onLoad

quasi flint
#

Rly?

eternal oxide
#

If its a fresh start

#

so getWorlds().isEmpty()

quasi flint
#

I mean for minigames

#

Someone build there

#

Server shuts down and map gets reset

ivory sleet
#

thing is first you need to unload the world, then hope and pray to the omniscient god that it will be garbage collected

#

then once gc'd delete the folder

eternal oxide
#

they are still loaded/accessed in onDisable

ivory sleet
#

and then load a new world

#

assuming you wanna replace one

eternal oxide
#

and assuming its not the main world

ivory sleet
#

^

quasi flint
#

Or not?

eternal oxide
ivory sleet
#

use the right arrow key for the first option

#

it will promt some additional options

eternal oxide
#

it has to be fully unloaded with all file locks released

ivory sleet
#

such ass suppress

quaint mantle
#

ah yes

ivory sleet
eternal oxide
#

yep

quasi flint
#

so somehow i have to get the players off the main map and onto the other map that i can reset?

summer scroll
#

Or maybe you can keep tracks of all blocks that are destroyed/placed and you can replace/break the blocks at the end of the game.

hasty prawn
#

Yeah, you can't have any players in a world you're trying to unload

quasi flint
#

just kick everyone

#

thats not the problem

#

or ima just use worldedit

#

will do the trick too

#

thanks tho

acoustic pendant
#

Could someone explain me about getHealthScale?
For what it is used?

misty current
#

how can I shade mongoDB in my plugin using maven?

eternal night
#

the maven-shade-plugin will do

misty current
#

kk

#

i'll try to edit one of the shades i already have

#

hm i cant figure

#

im bad

acoustic pendant
#

How can i do that a plugin works for different versions

maiden briar
#

How can I get all classes that are implementing / extending a class? (Reflection purposes)

eternal night
#

boils down to scanning all classes

#

the super class does not track/know its children (by design anyway). Sealed classes would obviously change that fact but eek

maiden briar
#

Ok, and if I have scanned then just check their superclasses / interfaces?

mellow edge
#

ok so I undrestand, how I can listen to BlockBreak event but I dont know how I can drop random item when it is mined

summer scroll
mellow edge
#

maybe with random but not sure how I can get it to work

#

ok so I have found the solution

spare glen
#

Hey I have small confusing is event handler annotations necessary? (I am a starter)

mellow edge
#

I can iterate though all minecraft items and add them to arraylist and then just pick random one with random!