#development

1 messages · Page 122 of 1

shell moon
#

What have you tried

#

Can you show

dark garnet
#

sry sry lmao i got distracted

dark garnet
# shell moon What have you tried

when the number key check is outside of if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null) it works

#
if (event.getClick() == ClickType.NUMBER_KEY) {
    event.setCancelled(true);
}
if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null) {
    ItemStack item = event.getCurrentItem();
    if ((item.isSimilar(Morph.skeletonBow()) && slot == 0) || (item.isSimilar(Morph.skeletonArrow()) && slot == 27)) {
        event.setCancelled(true);
    }
}```
#

but then it applies to every slot

dark garnet
#

if i remove the slot == X then it works (except it affects the item no matter slot its in)

broken elbow
#

Should I be going for something like this or should I just make an action system instead?

#

I feel like an action system would be better in the long run but maybe a bit harder to understand?

junior shard
#

code: https://pastebin.com/8STk4WWR

I am having trouble figuring this out-

essentially what my intentions are is to get the command to send what the player put for the arguments of the command as a chat visible to all players

#

However, it is showing up like this;

broken elbow
#

Use string#join

night ice
#

I don’t think u can pass array like that

broken elbow
#

yeah.

#

array to string in java will return that

night ice
#

Args is an array Either use what Blitz said or Arrays#toString or use String Joiner

junior shard
#

String msg = Arrays.toString(args); ?

night ice
#

Actually i am a bit doubtful abt tht

junior shard
#

It at least shows the message, but default includes "[]" and commas between the args

night ice
#

Use string#Builder and append each element

night ice
junior shard
#

How do I use string#Builder?

broken elbow
#

yeah. string join will also include that

#

I believe he meant to say StringBuilder

night ice
broken elbow
#

actually. string#join shouldn't add the commas and []

#

you should be able to specify a separator

#

what am I talking about

night ice
#

There are multiple String Classes…i am actually confused what all does what 😂

wintry grove
#

how do you put an itemstack into an armorstand slot? I cant find any method that does so kekwhyper

broken elbow
wintry grove
#

like a skull into a armorstand's head

night ice
wintry grove
#

deprecated

pulsar ferry
#

d;spigot EntityEquipment#setHelmet

uneven lanternBOT
#
void setHelmet(@Nullable ItemStack helmet, boolean silent)```
Description:

Sets the helmet worn by the entity

Parameters:

helmet - The helmet to put on the entity
silent - whether or not the equip sound should be silenced

junior shard
#

String msg = String.join("", args); such as this?

wintry grove
night ice
junior shard
wintry grove
night ice
#

There are 2 methods…1 is deprecated 1 with the boolean isn’t

#

Check java docs

pulsar ferry
#

d;spigot LivingEntity#getEquipment

uneven lanternBOT
#
@Nullable
EntityEquipment getEquipment()```
Description:

Gets the inventory with the equipment worn by the living entity.

Returns:

the living entity's inventory

pulsar ferry
wintry grove
#

I'm just doing this, I dont understand

pulsar ferry
#

You don't need the second setHelmet, you're already setting

wintry grove
#

oh

#

didnt think about that

dark garnet
#

same with this question

#

ping me if u reply to either

winter nimbus
#

Is it possible to create a world that's say 1000x1000 and the rest would be void outside that?

shell moon
# dark garnet when the number key check is outside of `if (event.getCurrentItem() != null && e...

You should share full code or at least full click event in a bin to be able to reply. As i said, number key is also cancelled when click event is cancelled, thats of course when checks are made correctly (i have no idea if thats your case).
If its a GUI for a plugin, then you should cancel at the beginning when the inventory is recognized and use slots instead of checking items, idek what you are trying to do tbh

shell moon
winter nimbus
#

I was thinking maybe create a world generator that uses the default world generation unless getting x amount of chunks away from the spawn. However can't seem to figure how to get the default world generation

sleek wedge
#

how i can define a player in other methods?

lyric gyro
sleek wedge
#

for papi config

#

i dont know what im doing

#

but its not work

#

i want to put papi in config but i dont know how i can do

#

ok now its work

#

but still dont know how to get player

#

im using this

static CommandSender sender;
public static Player p = (Player) sender;
#

for get player because i dont really know what i can do

sleek wedge
#

its no work anymore bruh

limpid trail
#

is anyone able to help me with lp api

sleek wedge
#

papi dont work

#

lol

#

i dont know whats wrong but papi make my %something% invisible

#

if someone know how fix this bug please ping me.

warm steppe
#

it works

sleek wedge
#

why papi dont replace thing??

broken elbow
#

do you have the expansions installed?

sleek wedge
#

so whats wrong??

dusky harness
#

Is it possible to change a player's glow color without changing their username color too?

sleek wedge
#

so?

#

any good dev (with papi experiences) know how to fix it>

pulsar ferry
#

Oh dear, that's a lot of static

sleek wedge
#

yea yea

dusky harness
#

isn't this a config issue or something?

#

where do u use papi

sleek wedge
#

i need to remove much of statics

sleek wedge
dusky harness
sleek wedge
#

yup

dusky harness
#

🤔

sleek wedge
#

there i can get the player

dusky harness
#

well

#

if you remove PAPI from this

#

what does it show

sleek wedge
#

if i remove it works

dusky harness
#

wait you don't even use the papi variables

#

in the command class

sinful portal
#

where do you use papi

#

cause i can't find it

sleek wedge
#

i dont know how tf i need to use PAPI

#

lol

dusky harness
sleek wedge
#

just using random tut from internet

sinful portal
#

it's in the wiki of papi

#

how to use it and things like that

sleek wedge
#

its just found only hooking

dusky harness
#

where do you use playerNameMessagePAPI

sinful portal
#

PlaceholderAPI.setPlaceholders(PLAYER, TEXT); <- this is a String object
PLAYER - player to parse placeholders for
TEXT - text to parse placeholders from

#

that's all you need to do

sleek wedge
#

and for config?

sinful portal
#

wdym

sleek wedge
#

the %something% should be use on config

sinful portal
#

so you have playerNameMessage: "Player: %player_name%" in config

#

right?

sleek wedge
#

yes

sinful portal
#

you would preferably have a shorter method to parse the placeholders in and return a string

sleek wedge
#

hm

sinful portal
#
    public static String color(Player player,String text){
        return ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.setPlaceholders(player,text));
    }
#

that's what I usually have

sleek wedge
#

this is for color hehe

sinful portal
#

yeah I also translate color codes in the same method

#

cause i would do that anyway

sleek wedge
#

so what's i need to do?

sinful portal
#

I think it's pretty self explanatory

sleek wedge
#

😭 i dont understand

#

whats i need to put in return

#

only that i dont understand

sinful portal
#

you need to return the string with the placeholders parsed/set

#

PlaceholderAPI#setPlaceholders does that

sleek wedge
#

and how its work this method>

#

?

#

like

#

color(player, getConfig().getString("path");

#

i dont understand how that should be used.

noble cedar
#

Hi, my server is on 1.17 and I use ViaVersion so players can join using 1.18 and I just realised that player heads does not show up in menus when im on 1.18...
Please help :/

robust flower
sleek wedge
#

so?

dark garnet
# shell moon You should share full code or at least full click event in a bin to be able to r...

here is my entire onInventoryClick:

@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    int slot = event.getSlot();

    if (TeamManager.isUndead(player)) {

        // If in menu, don't let them manipulate inventory
        if (!MorphManager.isMorphedPersistent(player)) {
            event.setCancelled(true);
            JoinMenu.select(player, event.getSlot());
        }

        // If morphed and skeleton, don't let them move bow/arrow
        if (MorphManager.isMorphedPlayer(player)) {
            for (String key : Main.morphs.getKeys(false)) {
                String value = Main.morphs.getString(key);
                assert value != null;
                UUID uuid = UUID.fromString(value);
                Entity entity = Bukkit.getEntity(uuid);
                if (entity instanceof Skeleton) {
                    if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null) {
                        boolean skeletonBow = event.getCurrentItem().isSimilar(MorphManager.skeletonBow()) && slot == 0;
                        boolean skeletonArrow = event.getCurrentItem().isSimilar(MorphManager.skeletonArrow()) && slot == 27;
                        if (skeletonBow || skeletonArrow) {
                            event.setCancelled(true);
                        }
                        if ((skeletonBow || skeletonArrow) && event.getClick() == ClickType.NUMBER_KEY) {
                            event.setCancelled(true);
                        }
                    }
                    player.sendMessage(slot + " " + event.getCurrentItem().getType());
                }
            }
        }
    }
}```here's video with debug msgs: https://media.srnyx.xyz/java_9zzwig9z50.mp4
sleek wedge
#

whats wronmg?

dark garnet
sleek wedge
#

oh

idle crown
#

is there a packet for when a player hits another entity?

past ibex
#

fuck off bot

#

interact_entity

icy shadow
#

Does anyone know if you're supposed to wrap the DAO classes with jetbrains exposed, or interact with them directly?

#

i'm doing the latter rn but it's kinda laggy

pulsar ferry
#

You can interact with them directly, you might need a data class as a wrapper depending on what you do but a lot of the times that's fine
Though i am not entire sure I mostly use DSL instead

icy shadow
#

hmm

#

when interacting with them directly it seems to be doing more queries than it probably should though

#

but Idk if that's the caching not working, or intented behaviour

#

i guess i'll wrap them

terse belfry
#
19.02 12:49:32 [Server] INFO org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
19.02 12:49:32 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:154) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
19.02 12:49:32 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
19.02 12:49:32 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
19.02 12:49:32 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
19.02 12:49:32 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
19.02 12:49:32 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_292]
19.02 12:49:32 [Server] INFO Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
19.02 12:49:32 [Server] INFO ... 6 more```
#

but i dont see any problem with my plugins.yml

#
name: Discord
version: 1.0
author: Convace

commands:
  discord:
    description: d
    usage: /discord
    permission: discord.use```
broken elbow
#

the problem is that it doesn't exist

dark garnet
terse belfry
#

it's in the packet

broken elbow
#

oh right. what srnyx said

#

you might've added an extra s

#

there

terse belfry
#

oh lmao

leaden sinew
#
    @Nullable
    public <T extends BaseUser> T toUser(
            final Class<T> clazz,
            final CosmeticManager cosmeticManager,
            final int entityId,
            final List<ArmorItemDAO> armorItems,
            final Wardrobe wardrobe,
            final int armorStandId
    ) {
// ...

        if (clazz.equals(User.class)) return new User(this.uuid, entityId, playerArmor, wardrobe, armorStandId);
        if (clazz.equals(NPCUser.class)) return new NPCUser(this.uuid, entityId, playerArmor, armorStandId);
        return null;
    }

Do I really have to cast here?

sterile hinge
#

yes, because equals is a method that is called at runtime, not something that can be proven at compile time

leaden sinew
sterile hinge
#

that's the method that decides what type to return

leaden sinew
#

that doesn't affect it, even without the equals check it still does not work

#

You're probably right about the runtime part though

sterile hinge
#

what "does not work"?

leaden sinew
sterile hinge
#

yeah, what does not work about that? Compilation Error?

leaden sinew
#

Yeah

#

Required type 'T' provided 'User'

pulsar ferry
#

Well yeah, you need to cast it

leaden sinew
#

Do I then also need to cast when I use the return type?

#

Oh wait I'm dumb

leaden sinew
dense horizon
#

k I was just wondering if anyone is intrested and if so where would I post that

#

in this discord server

#

cuz yk it has devs

#

in dev general ig

dark garnet
# dark garnet here is my entire `onInventoryClick`: ```java @EventHandler public void onInvent...

i was able to fix this by doing:

if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null) {
    boolean skeletonBow = event.getCurrentItem().isSimilar(MorphManager.skeletonBow());
    boolean skeletonArrow = event.getCurrentItem().isSimilar(MorphManager.skeletonArrow());
    if ((skeletonBow && slot == 0) || (skeletonArrow && (slot == 27 || event.getClick() == ClickType.NUMBER_KEY))) {
        event.setCancelled(true);
    }
}
if (event.getHotbarButton() == 0) {
    event.setCancelled(true);
}```focusing on this part:
```java
if (event.getHotbarButton() == 0) {
    event.setCancelled(true);
}```
shell moon
#

Good to hear you fixed it!

#

I personally use inventory holder to check if its my plugin inventory

#

And the first thing i do is cancel it

#

After that i check clicked slot and do stuff

sleek wedge
#

Nice!!!

dense drift
#
Traceback (most recent call last):
  File "C:\Users\dumit\test\traduceri.py", line 27, in <module>
    main()
  File "C:\Users\dumit\test\traduceri.py", line 18, in main
    with open(file_path, 'wt', encoding='utf8') as file:
PermissionError: [Errno 13] Permission denied: 'C:/Users/dumit/test/Constantine.S01E01.1080p.BluRay.x264-YELLOWBiRD.srt'```
Any idea how to fix this? 😒
this is the code <https://gist.github.com/iGabyTM/a6f30123f125c35f7133d2121032a6bb>
worn jasper
#

hi. so. trying to use adventure and relocating it but the question is... MiniMessages are in adventure api 4.10.0-SNAPSHOT, are they also in the bukkit platform version of adventure?

dusky harness
worn jasper
dusky harness
#

try excluding the adventure dependency from minimessage

neon wren
worn jasper
#

I only need these right?

lyric gyro
#

You also need to relocate tho

worn jasper
#

both?

lyric gyro
#

Relocate all of net.kyori tbh lol

worn jasper
#

lol

#

had this

river solstice
#

is there a trick to not define API version in plugin.yml?

lyric gyro
#

set it to 1.13 and call it a day

river solstice
#

well my plugin works on 1.8 and on 1.17

lyric gyro
#

Ok

river solstice
#

but if I define higher

#

it shouts at me that it's not supported

lyric gyro
#

That field was introduced in 1.13 so anything lower doesn't even know it exists

river solstice
#

aight

#

wasn't aware of that

#

thanks

lyric gyro
#

np

worn jasper
#

relocated it all like you said

dusky harness
#

unless you want to do Material compatibility yourself

#

(since spigot already handles it for you)

lyric gyro
queen niche
#

Is there any support for bungeecord/waterfall?

lyric gyro
#

for..?

queen niche
#
  format = PlaceholderAPI.setPlaceholders(player, format);

player is a proxies player

lyric gyro
#

PAPI is for bukkit only

queen niche
#

Thats what I was asking thankyou

lyric gyro
#

np

queen niche
#

What would be the easiest way to get formatted messages on bungee via papi?

worn jasper
lyric gyro
#

from mm

worn jasper
lyric gyro
#

the joys of working with snapshot artifacts

#

yeah don't exclude anything from mm

lyric gyro
#

I mean the EASIEST way would be to just reinvent the wheel tbh

worn jasper
#

my plugin just got over 1mb size pain

lyric gyro
pulsar ferry
#

Oh no, a whole megabyte

worn jasper
broken elbow
#

why is it pain tho?

#

why do you really care?

#

1mb is like literally nothing

dusky harness
#

btw

#

is slimjar back up

worn jasper
#

is it normal that MiniMessage makes everything italic by default?

dusty frost
#

MiniMessage doesn't heads do

pulsar ferry
#

It's not about mini message, that's default in minecraft

dusty frost
#

It just doesn't override the default formatting

worn jasper
#

uh so... I need to add the reset tag

#

before?

sand ermine
#

Yes that should fix @worn jasper

pulsar ferry
#

Add decoration(TextDecoration.ITALIC, false) to the parent component

worn jasper
#

the what and what

trail burrow
#

best version of HikariCP to use?

steady ingot
#

No need to dunk on Jitpack rn. I don't control the project

night ice
trail burrow
#

was running 5.0.0 when I tested and no issues I updated to 5.0.1 and I had a user having issues

shell moon
pulsar ferry
#

4.0.3

wintry grove
#

how would you setup a github action for checking if the plugin's code is good? been checking on it but I'm blind I think

dark garnet
#

am i doing something wrong? Bukkit.setSpawnRadius(Main.config.getInt("settings.spawn-protection"));
players can still break blocks and stuff

pulsar ferry
dark garnet
#

also, how can i detect offhand swaps (by using keybind [default f])?

past ibex
#

PlayerSwapHandItemsEvent

random mesa
#

So I am currently making a withdraw plugin. I am extremely new to plugin making which is why i'm starting off simple.
Also, there are like no tutorials for this which is why I'm asking here. Anyone know how to do this (i'm not asking for code i'm just asking how to get started)

past ibex
lyric gyro
#

the good old bukkit wiki is actually fairly decent for beginners

tacit belfry
#

How would I do hotswapping for a minecraft server?

#

?hotswap

neat pierBOT
tacit belfry
#

I guess a better way to phrase it is: Can I do hotswapping for java 17-18?

random mesa
past ibex
#

it's terrible code to convert diamonds -> vault -> diamonds

#

but the code is well tested at least.

#

so I really don't want to change it

wintry grove
#

how does hypixel's minions have small heads? while using player heads its just more big

brittle thunder
#

d;spigot ArmorStand#setSmall

uneven lanternBOT
#
void setSmall(boolean small)```
Description:

Sets whether this armor stand is scaled down.

Parameters:

small - whether this is scaled down

dusky harness
#

you can use that, just remove lines 26 - 27

#

unless you mean like codacy

#

u can also add a new gradle command like ./gradlew clean test

#

(idk if the clean is necessary, but why not 🤷)

wheat carbon
#

jetbrains runtime includes dcevm

#

you can use that with hotswapagent

dark garnet
#

and i have another question
what exactly does .append(stuff) do?

#

cause in a part of my plugin it replaces each letter of a swear word with *, but it just does result.append("*")
StringBuilder result = new StringBuilder();

dense drift
#

If result is a StringBuilder it just adds the star at the end

#

d;jdk stringbuilder#append

uneven lanternBOT
#
public StringBuilder append(long lng)```
Description:

Appends the string representation of the long argument to this sequence.

The overall effect is exactly as if the argument were converted to a string by the method String.valueOf(long), and the characters of that string were then appended to this character sequence.

Parameters:

lng - a long.

Returns:

a reference to this object.

dark garnet
#
public static String censor(String message) {
    String[] words = message.split(" ");
    StringBuilder result = new StringBuilder();
    for (String word : words) {
        if (Main.lists.getStringList("banned-words").contains(word.toLowerCase())) {
            for (char ignored : word.toCharArray()) {
                result.append("*");
            }
            result.append(" ");
        } else {
            result.append(word).append(" ");
        }
    }
    return result.toString().trim();
}```
#

i wanna make it instead append &k to the swear word (and then &r at the end)

dense drift
#

append(ChatColor.OBFUSCATED).append(word).append(ChatColor.RESET).append(' ')

dark garnet
#

oh so it matters where the append is?

dense drift
#

Yes

dark garnet
#

ohhh

kind granite
#

append is string concatenation but better

dense drift
#

^

pulsar ferry
#

Iirc string concatenation in java 11+ is faster than string builder
Ofc string builder is still more useful in cases like this

kind granite
#

it compiles to stringbuilder anyway

pulsar ferry
#

Not in newer versions

kind granite
#

oh?

dark garnet
#

it worked, ty!

pulsar ferry
# kind granite oh?

I think it was changed either 11 or 15, but it uses a new concatenation system that is faster than string builder, can't find the place i saw it so i could be wrong

icy shadow
#

i think it was 11

#

it uses some magic

#

oh no it was 9

#

i think it generates the implementation dynamically or something

sterile hinge
pulsar ferry
#

Yeah i think so

rugged sierra
#

ᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠ

#

ᅠᅠᅠᅠᅠᅠ

#

ᅠᅠᅠᅠᅠᅠᅠᅠ

#

ᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠ

#

lol how u like it?

#

i be hackin

lyric gyro
dark garnet
broken elbow
#

debug the format before setting it at line 46

dark garnet
#

debug?

broken elbow
#

print it to console

dark garnet
shell moon
#

you can't use %

#

use {prefix} or something like that

#

instead

dark garnet
#

omg

broken elbow
#

he is replacing them before setting them as the format

dark garnet
#

format = format.replace("%player", "%s");

broken elbow
#

well most of them

dark garnet
broken elbow
#

at least

#

nice xD

dark garnet
#

i forgot to add another % after player

floral beacon
#

how can i invoke invoke Block#breakNaturally() using copied item from hand

#

i've managed to copy item from hand (+ remove enchantments as that is what i need)
but i don't know how to invoke Block#breakNaturally() like it's broken with that copied item from hand

wintry grove
proud pebble
#

the paramater can be any itemstack.

#

mainhand is just an example

floral beacon
#

thank you, i learned something new today

#

:DD

proud pebble
dark garnet
proud pebble
#

breakNaturally just has 2 methods.

#

for the future, if you dont know if something elses then look at the spigot api docs

#

cause thats what i did

#

and it tells you when you search breaknaturally that theres a method without a parameter and one with itemstack as a parameter

#

invoking works like what exactly?

dark garnet
dark garnet
trail burrow
#

Best place to upload plugin code so it can be used in maven

kind granite
#

maven central

#

or jitpack failing that

leaden sinew
#

Maven central is such a pain though

dusky harness
leaden sinew
dusky harness
#

uh

#

gimme a bit

lyric gyro
#

if you're having a bad day it can take like.. 30 minutes tops? 10~15 minutes if not

lyric gyro
#

All you need is:

  • Set up a sonatype account
  • Open an issue and claim the group ID
  • Get gpg up and running
dusky harness
trail burrow
#

trying to install maven central and it is a pain, still not working

warm steppe
#

no its not

trail burrow
#

will it run on JAV16?

dusky harness
#

yes

#

well you don't install maven central

trail burrow
#

not sure what I'm doing wrong then

#

Maven calls it install

dusty frost
#

🥴

trail burrow
#

I unzipped file and then added Environment Variables

dusky harness
#

u sure ur not hosting a maven repo

dusty frost
#

HUH

#

bro you just add a single repository

#

in your pom.xml

lyric gyro
#

wat

trail burrow
#

don't I need the Apache Maven to upload it

lyric gyro
#

No

trail burrow
#

guess i found the wrong how toos to get this done

#

I want my plugin to available for others to use in their plugins if they choose

lyric gyro
dusky harness
#

or if you want i can paste in my DkimTutorial™️

#

😉

#

¯_(ツ)_/¯

#

or theres some stuff on google

#

if u dont have any experience with publishing or signing etc then imo the official guide isn't enough

lyric gyro
#

I didn't have any experience with either tho but idk, to each their own ig

solid forgeBOT
#

only admins can set the DJ role of the server!

dusky harness
#

oops

trail burrow
#

for my latest two plugins to have no errors on a clean build I need to have them on maven, using ajar in library throw's tons of errors

lyric gyro
#

such as..?

#

I can't help with what I can't see

dusky harness
#

🙈

trail burrow
#

ok, guess I should of not been lazy and not re-opened my cmd prompt

trail burrow
#

now for fixing the 5 plugins that don't have working maven dependency

junior shard
#

Does anyone know why " &cIncorrect Usage! &7Use &b/appoint help &7to see correct command usage." is not sending when a player does "/appoint"

#

It's giving an error:

broken elbow
leaden sinew
#

Line 7

#

You are accessing an index when there are no args

broken elbow
#

args is empty when someone does /appoint

junior shard
#

Oh, so I should just move that into one of the if statements then?

broken elbow
#

well this should be your first check java if (args.length < 1) { player.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + " &cIncorrect Usage! &7Use &b/appoint help &7to see correct command usage.")); }

#

and you should be returning there

dark garnet
#

if (!(TeamManager.isStaff(player) || player.isOp()) && !(player.isSneaking() || BypassManager.check(player)))
this will check if player is staff or op and if they r either sneaking or bypassing
only one from both have to be true (or in this case false, since they r inverted) in order to continue, right?

leaden sinew
#

If either are false in either condition, then they will become true

dark garnet
#

o sry i forgot to say its an if statement

leaden sinew
#

I assumed it was

dark garnet
#

ok so if either r false it will continue right?

leaden sinew
#

So you are checking (!(condition || otherCondition) && !(condition || otherCondition))
So for the first (), if either is true, then the whole () becomes false

#

Same with other set

#

So both need to be false to continue

#

At least I am pretty sure

#

It seems like a weird way to write the statement

dark garnet
#

what would be a better way?

#

to only require either one to result in false

leaden sinew
#

So you want it to be true if either condition is true right?

#

In both parenthesis

dark garnet
#

staff: false
op: true

sneak: false
bypass: true

#

example ^

leaden sinew
#

Ok

#

So if ((isStaff || isOp) && (isSneaking || isBypassing))

dark garnet
#

thats what i have rn except with exclamation marks cause it cancels the event if it succeeds

leaden sinew
#

Could you show your full code?

dark garnet
#
        // Check Locked Block
        player.sendMessage("(staff: " + TeamManager.isStaff(player) + " || op: " + player.isOp() + ") && (sneak: " + player.isSneaking() + " || bypass: " + BypassManager.check(player) + ")");
        if (!(TeamManager.isStaff(player) || player.isOp()) && !(player.isSneaking() || BypassManager.check(player))) {
            player.sendMessage("check 1");
            if (LockManager.isLocked(event.getBlock())) {
                player.sendMessage("check 2");
                if (LockManager.isLockedForPlayer(event.getBlock(), player)) {
                    player.sendMessage("check 3");
                    event.setCancelled(true);
                    new MessageManager("block-locked")
                            .replace("%block%", LockManager.getName(event.getBlock()))
                            .replace("%player%", Bukkit.getOfflinePlayer(UUID.fromString(Objects.requireNonNull(LockManager.getLocker(event.getBlock())))).getName())
                            .send(player);
                    player.playSound(player.getLocation(), Sound.BLOCK_CHEST_LOCKED, 1, 1);
                    return;
                }
            }
        }```
leaden sinew
#

And that doesn't work right?

dark garnet
#

nope, requires them all to be false (based from the first player.sendMessage thing which doesnt have exclamation marks)

leaden sinew
#

So then does it work without !?

dark garnet
leaden sinew
#

Can you send the output?

dark garnet
#

staff: false
op: true

sneak: false
bypass: false

#

doesnt cancel event

leaden sinew
#

Well both sneak and bypass are false

dark garnet
#

ye it dont make sense

leaden sinew
#

Wait do you want the if statement to continue if either is false?

#

I thought you wanted either to be true

#

if ((!isStaff || !isOp) && (!isSneaking || !isBypassing))

dark garnet
#

without !:
set 1:
staff: true
op: false
set 2:
sneak: true
bypass: false

#

gonna label them so its easier

leaden sinew
#

Try the new one I sent you

dark garnet
#

now it requires all of them to be false

leaden sinew
#

Only one from both sets should need to be false

dark garnet
#

if (!((TeamManager.isStaff(player) || player.isOp()) && (player.isSneaking() || BypassManager.check(player))))

leaden sinew
#

That's not what I sent

dark garnet
#

ik but i think thats working

leaden sinew
#

So what's the issue?

dark garnet
#

well ig nothing anymore lmao

#

ty

leaden sinew
#

Oh lol

#

Glad you figured it out

dark garnet
#

how do i get the entity right clicked in PlayerInteractEntityEvent?

dusty frost
#

event#getRightClicked()

dark garnet
#

very strange

#

usually its like event.getEntity(), weird

pulsar ferry
#

It depends on the event tbh, bukkit has like 0 consistency

dusky harness
#

well the event has two entities

#

¯_(ツ)_/¯

pulsar ferry
#

Well but one is player

trail burrow
#

I have a integer returning 9.0 and I only want it to return 9

dusky harness
#

integers do not have decimals

trail burrow
#

thats what I thought, I think I figure it out

#

I copied some javascript code into my plugin and missed the Math.floor

dark garnet
#

anyone know why this isnt working?

@EventHandler
public void onPlayerEntityInteract(PlayerInteractEntityEvent event) {
    if (event.getPlayer().getInventory().getItemInMainHand().getType() == Material.NAME_TAG) {
        if (Main.morphs.contains(event.getRightClicked().getUniqueId().toString())) {
            event.setCancelled(true);
        }
    }
}```
`Main.morphs` file looks like this:
```yml
e907083e-5db6-41fc-9e32-5c4d99a08712: b43731f4-1277-40f9-b6e5-dd233291954e```player uuid ^                                                                          morph entity uuid ^
past ibex
#

What is the contents of morphs?

dark garnet
past ibex
#

is this a hashmap? What is it?

dark garnet
past ibex
#

I'm just suspicious of the .contains call

dark garnet
#

yeah i thought that would be the problem

#

how would i detect if the entity's uuid exists anywhere in the file?

burnt turret
#
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class EventListeners extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        System.out.println("Plugin has been enabled");
        getServer().getPluginManager().registerEvents(listener: this, plugin: this);
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        System.out.println("A player has joined the server.");
    }

}```
#

getServer().getPluginManager().registerEvents(listener: this, plugin: this);

#

not working

#

why> :>

proud pebble
#

also if your using floor or ceil or whatever cast your inputs as double.

#

otherwise you might end up with inaccurate results

burnt turret
#

hey @proud pebble sorry to ping

#

but could you look at what I sent above

trail burrow
#

yes I fixed that, once I noticed I missed removing Math.floor

burnt turret
#

not sure why line 13 is not working:'

solar kraken
#

getServer().getPluginManager().registerEvents(this, this);

dark garnet
# dark garnet anyone know why this isnt working? ```java @EventHandler public void onPlayerEnt...

fixed this by doing:java @EventHandler public void onPlayerEntityInteract(PlayerInteractEntityEvent event) { String old = event.getRightClicked().getCustomName(); event.getPlayer().sendMessage(Main.morphs.getKeys(false).toString()); if (event.getPlayer().getInventory().getItemInMainHand().getType() == Material.NAME_TAG) { event.getPlayer().sendMessage("NAME TAG"); for (String key : Main.morphs.getKeys(false)) { String value = Main.morphs.getString(key); assert value != null; if (value.contains(event.getRightClicked().getUniqueId().toString())) { event.getPlayer().sendMessage("SUCCESS"); event.setCancelled(true); } } } }

solar kraken
dark garnet
#

i have another issue:java @EventHandler public void onAttack(EntityDamageByEntityEvent event) { Entity damager = event.getDamager(); Entity victim = event.getEntity(); if (damager instanceof Player || damager instanceof Arrow || damager instanceof Trident || damager instanceof IronGolem) { Player entity = MorphManager.getPlayer(victim); // AFK invulnerability if (Main.config.getBoolean("settings.afk-invulnerable") && damager instanceof Player && entity != null && AfkManager.afk.contains(entity)) { event.setCancelled(true); } } }this doesnt work. it only works when both players are alive (no morphs)
ping if reply

unborn fulcrum
#

How can I get the actual damage an item will inflict on a player (listening to EntityDamageByEntityEvent)?

junior shard
#

So if I want to create a part of my config that has the ability for unlimited strings under a section how would I do that? For instance I want to allow the server admin to make as many things as they want in the configuration, and under each section they create they can add as many strings as they'd like

#

something like ```yaml
Group1:
- "number1"
- "number2"
- "number3"
Group2:
- "number1"
- "number2"
- "number3"

and so on
unborn fulcrum
#

How can I extend an event so I can replace it inside an event handler and it will still be called? I want to extend EntityDamageByEntityEvent and create a second implementation of getFinalDamage(), which uses other fields in the class. I want my custom event to be called under the same conditions as EntityDamageByEntityEvent.

fiery pollen
junior shard
fiery pollen
#

For each loop

junior shard
#
Groups:
  'Group1':
    permission: '' # Permission node required for a user to appoint / fire the listed groups below.
    groupNames: # LuckPerms group names this permission class should be allowed to appoint/fire.
      - ''
      - ''
#

this would be the config so I would do ConfigurationSection#getStringList(Groups.?.groupNames)

fiery pollen
#

Your configurationSection would be group1

#

And you get the list named groupNames

junior shard
#

so just .getConfigurationSection("Groups.group1").getStringList("groupNames");? Sorry I am a bit new to making fully configurable plugins.

#

I want people to be able to create multiple groups and include multiple group names which when they run a command, the list of groupNames for the group they have permission for would send in their chat

#

Im pretty sure that would only work for if group1 is actually named group1

low pivot
#

Try group 2

junior shard
#

what

low pivot
#

Group2 for group1

junior shard
#

Im just trying to make it so the server admin can make as many groups as they want and add as many groupNames as they want without having to make it static and repeating it with Group1, Group2, Group3.... up to Group50

sudden sand
#

then you can use this

#

:

#

make a loop of all the keys in the 'Groups' Config Section

#

you can found some code for it on internet @junior shard it's easy

icy shadow
#

Anyone know a way of getting icons (pngs or whatever) for a given Material?

#

guessing it's client side but worth a try

dense drift
#

https://minerender.org/ maybe this helps? idk

dusky harness
#

and find the block/item

#

but i dont think theres anything that links to Material

icy shadow
#

yeah i guess thats probably the easiest way

dusky harness
#

¯_(ツ)_/¯

icy shadow
#

not sure I need anything that fancy, just a material icon to render onto dynmap

dusky harness
#

oh

dense drift
#

well

icy shadow
#

if that had a rest api it would be great

dense drift
#

if you don't need them in-game, there's probably plenty of ways to do it

icy shadow
dense drift
#

or download the texturepack

limpid trail
#

has coding changed for to set a player glowing because my code don't work anymorejava case 2: { if (!player.isGlowing()) { player.setGlowing(true); e.setCancelled(true); e.getWhoClicked().sendMessage(Utilities.color(plugin.getConfig().getString("Prefix")) + player.getName() + " " + Utilities.color(plugin.getConfig().getString("glow-on"))); } else { player.setGlowing(false); e.getWhoClicked().sendMessage(Utilities.color(plugin.getConfig().getString("Prefix")) + player.getName() + " " + Utilities.color(plugin.getConfig().getString("glow-off"))); e.setCancelled(true); } e.setCancelled(true); } e.setCancelled(true);

icy shadow
proud pebble
#

also dont use sysout

#

use Bukkit.getLogger().info("your message here") or your plugins logger

burnt turret
#

what's the difference in efficiency?

#

thank you btw

#

I'm new

proud pebble
#

which would be EventListeners.getLogger().info("other messages or smth")

proud pebble
#

if your talking about the listener: and plugin: they are prompts generated by the ide thats visual only. you dont type them out or anything.

#

i think they are generated if a method has javadoc params set.

#

with /**

hoary scarab
#

Is there a way to set multiple output directories in pom.xml? Tired of commenting 1 or the other when ever I want it outputted to a specific location.

lyric gyro
#

hi guys im having issues enabling mysql support to my spigot plugin, im running maven
this is my console error, trying to connect to the database :
java.sql.SQLException: No suitable driver found for jbdc:mysql://xxxxxxxxxx:3306/xxxxxxxxuseSSL=false

sudden sand
#

Can you send the class where you are making the sql connection ?

#

@lyric gyro

lyric gyro
#

the issue was a typo, i wrote jbdc instead of jdbc

#

lol

neat pierBOT
#
📋 Your paste: Relism
https://paste.helpch.at/evenexunon

A member of staff has requested I move your message to a paste,
Most likely because it contains a config/error/code snippet.

sudden sand
#

yes 1 min

lyric gyro
sudden sand
sudden sand
sudden sand
sudden sand
#

[19:17:12 WARN]: at RCore-1.0.jar//relismdev.cf.rcore.MySQL.connect(MySQL.java:27)
[19:17:12 WARN]: at RCore-1.0.jar//relismdev.cf.rcore.RCore.onEnable(RCore.java:30),

#

what are those lines ?

#

@lyric gyro

lyric gyro
#

need the class of the connection??

sudden sand
#

yes I need to check

lyric gyro
sudden sand
#
synchronized (this) {
                Class.forName("com.mysql.jdbc.Driver");
                connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true&useUnicode=yes", username, password);
            }```
#

this is some of my code

dark garnet
sudden sand
#

Add the Class.forName("com.mysql.jdbc.Driver");

#

@lyric gyro

shell moon
#

the new driver package is different, isnt it?

sudden sand
#

that's old code

#

I use hikari now

shell moon
#

do you support 1.8 and java8?

sudden sand
#

?

shell moon
#

(in your plugins)

lyric gyro
sudden sand
#

no

sudden sand
shell moon
#

so you dont support java8 or spigot1.8.8

#

i was about to ask which hikaricp you shade

sudden sand
#

It's not a matter of supporting or not

#

5.0.1

shell moon
#

and if you shade mysql-connector or not

sudden sand
#

on plugins no because spigot got the mysql connector package if I'm not wrong

shell moon
#

yeah, issue is that 1.8.8 doesnt work well with mysql 8.x

sudden sand
#

1.8.8 is old

#

I prefere coding with 1.17 and java 16

shell moon
#

we all do

#

but supporting old version helps people

lyric gyro
shell moon
#

hiring a dev just to "remake" a plugin costs

#

so i support 1.8.8 and java8 yet

sudden sand
lyric gyro
#

Failed to login : invalid session

sudden sand
#

it's because of the error

#

yep it's an credientals error

#

it can't find the host

#

maybe an error on port or ip

#

or maybe your database isn't public if done on a vps

#

and you are testing on your own pc

lyric gyro
#

i can dm you my credentials, i dont mind it

sudden sand
#

I can check test a connection

#

dm the creds

kind granite
shell moon
#

nice point of view, another reason is that i rather 1.8 pvp mechanics over 1.9+

kind granite
#

why

#

1.8 pvp is literally just spamclick

dusky harness
#

yes, it gives an advantage
but thats why pvp servers kick/ban ppl who double click :))

#

since theres more to it

#

¯_(ツ)_/¯

dark garnet
#

im making a cooldown thing, but for some reason it isnt working:

private final Map<Entity, Duration> cooldownTimes = new HashMap<>();
public boolean onCooldown(Entity entity, Duration duration) {
    boolean cooldown = cooldownTimes.containsKey(entity) && cooldownTimes.get(entity).toMillis() > System.currentTimeMillis();
    cooldownTimes.put(entity, Duration.ofMillis(duration.toMillis()).plusMillis(System.currentTimeMillis()));
    return cooldown;
}```here's the `if` statement im using: `if (!onCooldown(player, Duration.ofMillis(5000)))`

and when using `Bukkit.broadcastMessage(String.valueOf(!onCooldown(player, Duration.ofMillis(5000))));` (to debug), it tells me every 5 seconds (5000 milliseconds) that its `true`, which means it should be working
spiral prairie
shell moon
shell moon
lyric gyro
#

what does "[Server] INFO org.bukkit.event.EventException: null" mean?

shell moon
#

probably something is null

#

maybe more share the full stacktrace

#

or that's everything?

dusky harness
#

we'll need the entire stacktrace

lyric gyro
dusky harness
lyric gyro
dusky harness
#
21.02 21:39:50 [Server] INFO Caused by: java.lang.NullPointerException
21.02 21:39:50 [Server] INFO at me.mason.rankupgui.events.ClickEvent.clickEvent(ClickEvent.java:29) ~[?:?]
#

what's on line 29

#

of ClickEvent

lyric gyro
shell moon
#

both are together?

lyric gyro
shell moon
#

he asked TUXicalo

#

but you replied, i was asking if both of your

dusky harness
#

lol

shell moon
#

worked together

lyric gyro
#

yes

shell moon
shell moon
# lyric gyro yes

well most likely

  1. plugin is null
  2. getVaultAPI() returns null
  3. getEconomy() returns null
dusky harness
#

one of them is prob null

shell moon
#

he probably has
private Main plugin;
and hasn't assigned it

dark garnet
# spiral prairie Well, would you like to tell us what isnt working?

second one:

player.playSound(player.getLocation(), Sound.BLOCK_CHEST_LOCKED, 1, 1);
new MessageManager("block-locked")
        .replace("%block%", LockManager.getName(event.getClickedBlock()))
        .replace("%player%", Bukkit.getOfflinePlayer(UUID.fromString(Objects.requireNonNull(LockManager.getLocker(event.getClickedBlock())))).getName())
        .send(player);```
lyric gyro
shell moon
#

first, share full code in a bin

#

so we can know if thats the case

neat pierBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
HelpChat Paste - How To Use

shell moon
#

otherwise is the rest, getVaultAPI returns null

#

or getEconomy returns null

#

why the ping xD

dusky harness
#

we need ClickEvent

shell moon
#

i was asking TUXicalo xd

spiral prairie
shell moon
#

in your case, it's weird how you do the things there

#

instead of using isOnCooldown thing

#

i rather making it to check if is on cooldown

#

and then (inside the code add the cooldown)

#

not doing it in one method

dark garnet
shell moon
#

as it might leads to issues when you first start coding plugins

lyric gyro
shell moon
lyric gyro
shell moon
spiral prairie
shell moon
#

yeah

lyric gyro
#

guys i need help with my config file, it only copies the first line into the plugin folder

shell moon
#

well, we need more info than that

#

you probably made it wrong

#

saveDefaultConfig() usually works

#

(ofc ignores comments when modified using saveConfig())

lyric gyro
deep mulch
#

Ah okay

sinful shard
dark garnet
shell moon
#

tbh, your code is a mess

#

hence why is "hard" to read

sinful shard
#

me?

shell moon
sinful shard
#

oh ok

dusky harness
#

since UUID doesn't implement ConfigurationSerializable

sinful shard
#

oh ok ty

dusky harness
sinful shard
#

ok

#

it worked!

dark garnet
sinful shard
#

now guys if i want to find the world name in there would i use getString

shell moon
#

otherwise finding the issue might be hard

#

(tbh i have no idea what your action do)

wintry grove
#

is there like a way to do event managers or command managers, that read the command files using reflection to add them to the, well command list and stuff

sinful shard
wintry grove
#

I currently use reflections for it but I want to know if there is another way that doesnt make me use a big lib lmao

void orchid
pearl topaz
#

how do you store a type in a variable? e.g.
myVariable.type = String or myVariable.type = boolean

pure crater
#

what

#

you can't store types

#

you mean generics?

#

that's much different tho

pearl topaz
#

no, i want a variable to store the type that an object is using for something external

pure crater
#

or do you mean like Class<T>

#

or something

#

i mean i guess you could use Class<T>

#

like String.class, Boolean.class, (wrappers for primitives) and use that to store stuff, but it's a bit unclear on what you are trying to accomplish

hoary scarab
#

Or just use Object

pure crater
#

you are going to do a bunch of instanceof checks?

pearl topaz
#

well i've got a bunch of monitor classes that monitor data of certain types, and i'm trying to extract json values to make a map of these like:

"monitors": {
        "monitor1": {
            "datatype": "int",
            "a": 1
            "b": 2,
        }
}

and then monitors.get("monitor1").dataType should return Integer

#

or something like that

pure crater
#

Object won't work here

hoary scarab
pure crater
#

Well, i'd prefer Class in this case

hoary scarab
#

👍 was just giving the option based on his variable message.

pearl topaz
#

if you have an interface Monitor, and classes like IntMonitor, StringMonitor that implement that interface, can you make a map like HashMap<String, Monitor> and then store IntMonitor etc as values?

#

it's not possible to use generics here via an abstract class, as IntMonitor etc individually extend from MutableInt etc

pearl topaz
#

thanks

dark garnet
#

how can i get the type of boat destroyed in VehicleDestroyEvent?

dusty frost
#

VehicleDestroyEvent#getVehicle#getType

dark garnet
dusty frost
#

yeah, would that not be what you're after?

dark garnet
#

but i think that just returns boat, minecart, etc...

dusty frost
#

I mean yeah, the EntityType enum doesn't go into more depth

dark garnet
#

so how could i get the material type of it?

dusty frost
#

that is the material type

#

the EntityType enum

#

is the entity equivalent of the Material enum

#

oh oh

#

okay so if you get the type and see if it's a boat

#

then I think you can cast it to a Boat type and that has getWoodType

#

and that returns a TreeSpecies lmao

dark garnet
dusty frost
#

uh no

#

because it won't be an instanceof Boat

#

it'll be an instance of Vehicle

#

you'd want event.getVehicle().getType() == EntityType.BOAT or similar

#

then you can cast it to a Boat

dark garnet
dusty frost
#

yeah don't cast the getType

#

cast event.getVehicle()

dark garnet
#

love when oak boat species is called GENERIC unlike every other one

#

oh and cant forget about spruce being called REDWOOD

#

literally why bruh

pure crater
#

I'm about to flip right now lol

#

I run gcc and it works fine in a normal command prompt tab

#

then i go into goland and use the terminal there

#

and it says it can't recognize gcc

#

even tho the path variable is set

leaden sinew
dusty frost
dusty frost
leaden sinew
pure crater
#

It's odd cause when i do echo %PATH%

#

it shows up

#

lol

#

whatever, I just didnt use the terminal provided and used command prompt to do it

#

cause im lazy

dusty frost
dark garnet
dusty frost
#

convert what

dark garnet
#

GENERIC treespecies

dusty frost
#

like, in what context?

dark garnet
#
Boat boat = (Boat) vehicle;
Material material = Material.valueOf(boat.getWoodType() + "_BOAT");
attacker.getWorld().dropItemNaturally(vehicle.getLocation(), new ItemStack(material));```
leaden sinew
#

You could do boat.getWoodType().replace("GENERIC", "OAK")

dark garnet
#

doesnt let me use .replace

#

o wait i gotta make it string first

leaden sinew
#

Yeah

dark garnet
#

weird how something like this didnt work:

if (boat.getWoodType() == TreeSpecies.GENERIC) {
    material = Material.OAK_BOAT;
}
if (boat.getWoodType() == TreeSpecies.REDWOOD) {
    material = Material.SPRUCE_BOAT;
}```
leaden sinew
#

That should work

#

What about it doesn't work?

dark garnet
#

i get the same error in console as if it wasnt there

#

and i tried adding debug msgs but they wouldnt work

leaden sinew
#

What error?

dark garnet
#

java.lang.IllegalArgumentException: No enum constant org.bukkit.Material.GENERIC_BOAT

leaden sinew
#

That was in console or compile error?

dark garnet
leaden sinew
#

Oh, that was when you were using .valueOf

leaden sinew
#

You get the error because you have Material material = Material.valueOf(boat.getWoodType() + "_BOAT"); at the top

dark garnet
#

thats for all the other boats

#

but shouldnt it redefine by the material = in the if statements?

leaden sinew
#

No, because the error is thrown first

#

An error is thrown if the enum is invalid

dark garnet
#

ahh i get now

#

this works:

Boat boat = (Boat) vehicle;
Material material = null;
if (boat.getWoodType() == TreeSpecies.GENERIC || boat.getWoodType() == TreeSpecies.REDWOOD) {
    if (boat.getWoodType() == TreeSpecies.GENERIC) {
        material = Material.OAK_BOAT;
    }
    if (boat.getWoodType() == TreeSpecies.REDWOOD) {
        material = Material.SPRUCE_BOAT;
    }
} else {
    material = Material.valueOf(boat.getWoodType() + "_BOAT");
}
assert material != null;
attacker.getWorld().dropItemNaturally(vehicle.getLocation(), new ItemStack(material));```
#

but imma do the replace thing cause its a lot simpler and what i was originally gonna do

leaden sinew
#

That way is faster ^

#

If you care about that

dusty frost
#

yeah Strings are slow

dark garnet
#

o the if statement way?

dusty frost
#

also the assertion is cute

#

sadly this is Java where assertions are only checked at compile time when you're running a Test framework

leaden sinew
#

Oh yeah forgot to say to remove that

#

lol

dark garnet
#

remove what?

leaden sinew
#

assert materia != null

dusty frost
#

the assertion

#

it does nothing in real code

dark garnet
#

intellij screams at me if i remove it FLOOSH

leaden sinew
#

assert throws an error, you shouldn't use it unless you are testing

#

Use if (null) return

dark garnet
#

ok

leaden sinew
#

or put the code inside if (not null) {}

dusty frost
dusty frost
dusty frost
leaden sinew
#

It depends if they have code afterwards

dusty frost
#

early exiting is always where it's at

leaden sinew
dark garnet
leaden sinew
#

No, you have to check if material is null

dusty frost
#

Java's assertions are shit

#

you have to be running a test framework for assertions to do anything

dark garnet
#

ive been using assertions a bit (there were like 5 in my plugin) and nothing broke cause of them

dark garnet
dusty frost
#

yeah they do literally nothing in normal usage

leaden sinew
#

I'm going to add a bunch of assertions everywhere now just to confuse people

dark garnet
#

lol

dusty frost
#

lmao

#

see in most languages, assertions do work in real programs, because why not?

#

Rust's assert! macro works everywhere

#

and it's a good way to assert something is true

leaden sinew
#

What about Skript?

dusty frost
#

Skript isn't really a language lmao

#

I doubt it has assertions

leaden sinew
#

Its the best programming language

grim oasis
#

What's the best way I can go about registering a command for my papi expansion?

#

Was looking at the jsexpansion and ended up with something like this but not sure if I need to do anything else as nothing happens when it executes (doesn't say unknown command though)

    Field field;
    try {
      field = Bukkit.getServer().getClass().getDeclaredField("commandMap");
      field.setAccessible(true);
      CommandMap commandMap = (CommandMap) field.get(Bukkit.getServer());
      commandMap.register("papichess", new ChessCommand("chess"));
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }```
dusty frost
#

you can't register a command in a standalone papi expansion

grim oasis
#

maybe not register, but at least get the command working

dusty frost
#

bro what the fuck

#

that is so cursed

grim oasis
#

it's a theme

dusty frost
#

just make a standalone plugin???

grim oasis
#

also I take it all back

#

it does work

dusty frost
#

wtf lol

grim oasis
#

prob gotta do something with /papi reload though

grim oasis
#

if it's an "expansion" it makes more sense

#

the whole point was chess in dm

#

:L

dusty frost
#

well yeah that's still super cursed

grim oasis
#

blame whoever did the js expansion

dusty frost
#

you have the Java capabilities, just use a GUI library and do it yourself

#

it'd be 50x more performant

grim oasis
#

nah dm is beautiful

#

again, the point was to make chess in deluxemenus

dusty frost
#

well, you're like 90% of the way to being a standalone plugin lmao

#

the only difference is that PAPI loads you and not Bukkit

#

which is very cursed because I don't think expansions are even supposed to do that

high edge
fading elk
#

i can run deluxemenus with minecraft 1.8
i run my 1.8 with jdk 11 :)
please write in spigot page that plugin supports 1.8

#

🙂 🙃

high edge
#

Leave.

cobalt sun
#

Ah shit here we go again

#

Now I gotta try to choose between mongo and postgres again

warm steppe
#

mongo

fading elk
dusty frost
cobalt sun
#

Not sure

dusty frost
#

what kind of data are you storing?

cobalt sun
#

I wanna make a point of sale system for a quick service restaurant

frosty cobalt
#

Does anyone know how i can make it so if you type a custom command, the code in the repeats until the custom command is typed again? kinda like a toggle system

shell moon
frosty cobalt
shell moon
#

This dont work like that. Hence why we strongly suggest people to learn java (at least basics) before jumping into spigot or bungeecord

shell moon
sudden sand
#

does someone has a good tutorial about multi modular project with gradle on intellij because I'm searching rn and I only found indian dudes with crap mic and windows 7

hoary scarab
shell moon
#

¯_(ツ)_/¯

shell moon
#

java is not spigot

#

java is the language

#

and knowing that, seriously help when jumping into spigot

shell moon
hoary scarab
shell moon
#

a player can mean operator or admin

#

however, as you mention, he probably want to make a particles trail

hoary scarab
#

Either one could be right just giving the options lol

shell moon
#

or something that follows the player

pearl topaz
#

for updateRedis() it says "Private methods in interfaces should have a body". but how can i add the body in the interface when using variables from my classes?

leaden sinew
#

You don’t need public, and interfaces can’t have private methods

#

Wouldn’t make sense

pearl topaz
#

and then it says "Class 'BooleanLogger' must either be declared abstract or implement abstract method 'setValue()' in 'Logger"

leaden sinew
#

That one is pretty self-explanatory, you need to override the method setValue() in BooleanMonitor

pearl topaz
#

"Method does not override method from its superclass"

leaden sinew
#

The interface has no parameter

pearl topaz
#

but all of my classes are using different parameters

#

boolean, boolean[], String etc

leaden sinew
#

You can use generics

pearl topaz
#

how can i use generics that accepts both boolean and boolean[]?

#

is this right?

lyric gyro
#

interface Logger<T> and setValue(T value) but yes

pearl topaz
#

hmm i can't actually do this with the primitive types i need

#

like boolean

#

oh wait

pearl topaz
lyric gyro
#

mhm

#

generics over primitives (implements Logger<boolean>) are not a thing

#

so you need to implements Logger<Boolean> and override both methods from Logger and MutableBoolean

pearl topaz
#

i think it's better to just use an empty interface

#

all i want is to be able to make a map HashMap<String, Logger> that i can store any type of logger in as a value

lyric gyro
#

whatever floats your boat ¯_(ツ)_/¯

leaden sinew
lyric gyro
#

I assume a marker interface? Like Bukkit's Listener kinda deal

leaden sinew
#

I don't think that would work for them

#

@pearl topaz you could use a Map<Class, Logger>

#

Then use loggerMap.get(Boolean.getClass()), etc.

pearl topaz
#

i think it works fine

#

i'm wondering though

#

can you specify a subtype as a generic in Kotlin?

#

but i dont think this is possible in java

leaden sinew
#

Well that won't work because updateRedis() is private in Logger

#

Wait

#

this.redis.set(this.loggerName, this.value.toString()); You change it to a String anyways?

#

What's the point of this?

pearl topaz
#

you can only store strings as redis values

dark garnet
#
if (args.length == 1) {
    if (Bukkit.getServer().getWorlds().toString().contains(args[0])) {
        Bukkit.getServer().getWorld(args[0]).setTime(1000);
        new MessageManager("plugin.time")
                .replace("%time%", "day")
                .replace("%world%", args[0])
                .send(sender);
    } else {
        new MessageManager("errors.invalid-world")
                .replace("%world%", args[0])
                .send(sender);
    }
    return true;
}```https://paste.srnyx.xyz/baqofehivi.properties
night ice
#

Its better to do a null check

dark garnet
night ice
#

Yp

dark garnet
night ice
#

Yeah…it warns you that the world might be null and you should handle it

shell moon
#

getWorlds().toString()

#

really?

night ice
#

Tbh, I don’t understand the second if

night ice
shell moon
#

is clear

#

that he wants to check

#

if world

#

with that name exists

#

but thats not the way

dark garnet
#

^

#

oh

shell moon
#

please, learn some java first

#

you can't simply use toString()

#

for everything to check

#

thats not how things are done

night ice
shell moon
#

yeah you can do that

#

however, not sure if that set the time of the world

#

or it restarts the day count

night ice
night ice
#

yep....i just stored it into a variable...thats the only diff

dark garnet
#

alr, well intellij still gives me the same warning

night ice
#

Its a warning, bcs the method is annotated as @Nullable, its kinda a marker annotation iirc, so just handle the check there and you would be good to go

#

Also don't always dependent on IJ... it sometimes too dumb...

dark garnet
night ice
dark garnet
#

it only gives the error if i only put in part of a world (ex: wor, world_neth, etc...)

dense drift
#

The cause is pretty self explanatory

#

Also, put the world into a variable and then check if is not null

night ice
dense drift
#

Yeah, it is weird