#help-development

1 messages · Page 1679 of 1

torn oyster
#

how would i do it w/ regex

#

im not very experienced with it

eternal night
torn oyster
#

does replaceall include caps

#

like "BANANA".replace("Banana", "");

eternal night
#

it does not

quaint mantle
#

what are the arguments for PathfinderGoalFollowEnity?

#

in NMS

proud basin
#

bump

sullen dome
#

Math 🤮

proud basin
#

mcp 🤮

sullen dome
#

old-ass version 🤮

proud basin
#

🤮

sullen dome
#

why using such an old version lol

lavish hemlock
#

It's weird how people still ask "why use an old version?" when there's a fuck ton of reasons why you may want to do so.

#

Experimentation/curiosity, compatibility with other old mods that don't have ports, you just like that version, etc.

worldly ingot
#

That excuse was fine 5 years ago

#

1.8 is now 6 years old. Let it die

lavish hemlock
#

I'm currently working on a project that uses 1.7.10 :p and that version is 7 years old.
Why? Well, for one, I enjoy 1.7.10 and I think it fits the spirit of the modpack this project is for (it's meant to be nostalgic since it's basically a remake of a modpack I made years ago when 1.7.10 was still alive), and two, there's some mods that don't exist in newer versions, or at least don't have the same level of quality in newer versions (e.g. Extra Utilities removing Division Sigils in newer versions).

#

So, no. Let people use whatever version they want. Stop policing the version someone uses or else you look like one of those Forge assholes.

split bane
#

Hey anyone who can help is anyone familiar with MACOS and MySQL

floral kindle
#

Does anyone know how to disable collision using scoreboard packages?

lavish hemlock
# worldly ingot That excuse was fine 5 years ago

At that point, wasn't the latest version 1.9 or 1.10? If 1.8 is 6 years old, then 5 years ago can't even be considered as an "excuse," it's just smart to support an older version since it was still commonly played 5 years ago.

#

Hell, some people still play 1.7.10 nowadays because it and 1.12.2 are the best versions for mods.

quaint mantle
#

what are the arguments for PathfinderGoalFollowEnity?

lavish hemlock
#

Other people still play 1.8 because it makes/made PVP less jank on some servers.

proud basin
lavish hemlock
#

e.g. p_549065_yourmom instead of somethingSensible

proud basin
#

huh

#

I never posted anything with that

lavish hemlock
#

well idk what then

floral kindle
#

Do you have any examples?

sullen dome
proud basin
#

sr stands for SaturatedRescale

#

I believe it was ScaledRes until 1.12

echo basalt
#

For some reason Block#getDrops doesn't work properly on BlockBreakEvent

#

Is there a way to go around that issue?

proud basin
#

hola Real

sullen dome
#

hola

#

so... did invalidatign work?

proud basin
#

waiting

proud basin
#

still indexing

#

@sullen dome Didn't work

#

I just did something else and it worked

#

this.drawString(this.fontRendererObj, s1, this.width - this.fontRendererObj.getStringWidth(s1) - 2, this.height - 10, -1);

sullen dome
#

i believe there's even drawCenteredString, if you need that

proud basin
#

I'm not drawing text though

median anvil
#

how do you create an empty Collection<ItemStack> variable?

waxen plinth
#

You can't create a generic Collection

#

You need one of its implementations

#

It varies based on your use case

proud basin
waxen plinth
#

But ArrayList is the most common

median anvil
#

kk

waxen plinth
#

So, Collection<ItemStack> items = new ArrayList<>();

median anvil
#

ty

timber saffron
#

What happened to my getCommand thingy

quaint mantle
#

?

#

why is all of your code missing an indent

timber saffron
#

This guy has the same code but no indent errors

stone sinew
timber saffron
#

ok

timber saffron
quaint mantle
#

select all of it and press tab

timber saffron
#

k

#

nothing

stone sinew
timber saffron
#

nothing happening just text moving

#

the error shows this

#

The method getCommand(String) is undefined for the type Main

stone sinew
#

Works for me

timber saffron
#

oh ok fixed it

#

I didn't save the main file after editing it

quaint mantle
#

i dont think the nodes are merging correctly

#

nvm redempt i wasnt setting the tail's next node

waxen plinth
#

@quaint mantle You got it working?

quaint mantle
#

Mhm

#

and i think i know how to do imports

waxen plinth
#

Nice

steep spruce
#

Hey, it's not directly related to spigot but especially with the compilation of a java / kotlin project with gradle,

I could see with some research that when creating an android application it was possible via "buildType" to insert variables in the code when compiling, but despite my research I did not find any alternative to this outside of android development, does anyone have an alternative solution to have a similar result?

prime reef
#

okay i'm at a loss

#

produces this

#

please ignore the clipped off end of the string at the front

#

the important part is that it's tacking on white numbers

#

it's clearly based on their position in the configured scoreboard

#

but here's the thing - this code worked fine before 1.17, and now it's adding those white numbers

exotic obsidian
#

hello

#

guys who have a good way to create particles

opal juniper
#

with the api

drowsy helm
#

anyone attempted replicating wynncrafts ghost system

#

looks fun

opal juniper
#

SpawnParticle

exotic obsidian
#

nice

#

can u give me the link

opal juniper
#

?jd

exotic obsidian
#

ok ty

shadow night
#

i made a smol PlayerLoginEvent but it doesn't work

drowsy helm
#

show code

shadow night
#
@EventHandler
    public void onLogin(PlayerLoginEvent event) {
        try {
            TimeUnit.SECONDS.sleep(5);
            getServer().broadcastMessage("Кто-то зашел, это что, "+ event.getPlayer().getDisplayName() + "?");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
drowsy helm
#

dont use a sleep function

#

theres bukkit schedulers

shadow night
#

whats that

drowsy helm
#
BukkitWiki

This tutorial will guide you in using the scheduler provided by bukkit. It will allow you to defer the execution of code to a later time. This is not the same as registering a Listener, a block of code which is executed in response to an event in the game. Blocks of code may also be scheduled to be executed repeatedly at a fixed interval, with o...

#

making the thread sleep will pause the entire server for 5 seconds

shadow night
#

also, without sleep it doesn't works too

drowsy helm
#

is it registered

shadow night
#

idk ¯_(ツ)_/¯

drowsy helm
#

show your main calss

#

class

shadow night
#

i just noticed something

#

i did getServer().broadcrastMessage()

#

i think there should be something before getServer()

drowsy helm
#

nope

#

90% chance its just not registered

#

show all your code

shadow night
#
package ...;

import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.concurrent.TimeUnit;

public class testPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        getLogger().info("Loading test plugin!");
    }
    @Override
    public void onDisable() {
        getLogger().info("Unloading test plugin!");
    }
}

river matrix
#

So I am having a few issues with logging online players to a text file with my plugin

public class eventPlayerCount implements Listener {

    public static int playerCount = 0;

    @EventHandler
    public void addPlayerCount(PlayerJoinEvent event)
    {
        playerCount += 1;
        discordPlayerCount.getPlayers();
    }

    @EventHandler
    public void subPlayerCount(PlayerQuitEvent event)
    {
        playerCount -= 1;
        discordPlayerCount.getPlayers();
    }

    public static int returnPlayerCount()
    {
        return playerCount;
    }

}

it does technically work but the thing it produces is a box with a question mark around it, if needed I will share my file writing class

timber saffron
#

me.sab.exlpode.Main

paper server is giving and error that says

#

cannot find main

#

class

#

but I think what I have written in my plugin.yml is correct

quaint mantle
#

Your class is called main, not Main

quiet ice
#

Paper will complain if you call your main class like that

shadow night
#

how to register events?

timber saffron
#

What does this mean

chrome beacon
#

It means the version on the disk is not the same as the one Eclipse has loaded

#

I think...

quiet ice
#

You need to refresh you project with the F5 key

shadow night
#

org.bukkit.plugin.InvalidPluginException: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register ..testPlugin.testListener@72617e4b while not enabled
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:157) ~[patched_1.17.1.jar:git-Paper-243]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[patched_1.17.1.jar:git-Paper-243]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[patched_1.17.1.jar:git-Paper-243]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:410) ~[patched_1.17.1.jar:git-Paper-243]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:276) ~[patched_1.17.1.jar:git-Paper-243]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1212) ~[patched_1.17.1.jar:git-Paper-243]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-243]
at java.lang.Thread.run(Thread.java:831) [?:?]

#

?

quiet ice
#

how'd you do that?

shadow night
#

what that

#

?

quiet ice
#

I guess you did Bukkit.getPluginManager().registerEvents(listeners, new MyPluginMain());

shadow night
#

PluginManager pm = getServer().getPluginManager();
pm.registerEvents(this.testListener, this);

lavish hemlock
#

it's not the getServer() btw, pretty sure Bukkit just delegates to server calls so it doesn't matter

shadow night
#

but still doesn't works

shadow night
quiet ice
#

that should work? Could you show the actual stacktrace?

#

The stacktrace you gave is obviously cut in half

shadow night
#

[10:57:17 ERROR]: [[STDERR] ] org.bukkit.craftbukkit.v1_17_R1.legacy.CraftLegacy Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
[10:57:27 WARN]: Legacy plugin test_plugin v1.17.1-1.0 does not specify an api-version.
[10:57:27 ERROR]: Could not load 'plugins/testPlugin-1.0-SNAPSHOT.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register com.andreasmelone.testPlugin.testListener@72617e4b while not enabled
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:157) ~[patched_1.17.1.jar:git-Paper-243]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[patched_1.17.1.jar:git-Paper-243]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[patched_1.17.1.jar:git-Paper-243]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:410) ~[patched_1.17.1.jar:git-Paper-243]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:276) ~[patched_1.17.1.jar:git-Paper-243]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1212) ~[patched_1.17.1.jar:git-Paper-243]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-243]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register com.andreasmelone.testPlugin.testListener@72617e4b while not enabled
at org.bukkit.plugin.SimplePluginManager.registerEvents(SimplePluginManager.java:653) ~[patched_1.17.1.jar:git-Paper-243]
at com.andreasmelone.testPlugin.testListener.<init>(testListener.java:14) ~[testPlugin-1.0-SNAPSHOT.jar:?]
at com.andreasmelone.testPlugin.testPlugin.<init>(testPlugin.java:7) ~[testPlugin-1.0-SNAPSHOT.jar:?]
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78) ~[?:?]
at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) ~[?:?]
at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:350) ~[?:?]
at java.lang.Class.newInstance(Class.java:642) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:83) ~[patched_1.17.1.jar:git-Paper-243]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[patched_1.17.1.jar:git-Paper-243]
... 7 more

#

thats all i have

quiet ice
#

remove the registerEvents call in your testListener constructor

#

(never register events in a constructor, ever)

shadow night
#

that this.plugin.getServer().getPluginManager().registerEvents(this, plugin);?

quiet ice
#

yes

lavish hemlock
#

fyi, this is just naming convention, but your classes should be in PascalCase instead of camelCase
aka you should make testPlugin into TestPlugin because that's the more common way to capitalize in Java

quiet ice
#

and apparently PacalCase == camelCase

#

yes, confusing, I know, but apparently that is the case

lavish hemlock
#

PascalCase is just a commonly accepted name for a variation of camelCase, so I mean, you're not wrong

chrome beacon
#

UpperCamelCase and lowerCamelCase

lavish hemlock
#

yeah

#

I prefer PascalCase bc it's shorter but those are the more specific names

#

at least, according to Wikipedia, since people haven't decided on a fixed definition for most variations of programming cases

amber vale
#

Ok i'm working on my plugin which saves persistentdata onto hoppers, but can someone explain why does this code if (container.has(new NamespacedKey(BitMiners.getPlugin(), "miner"), PersistentDataType.BYTE)) {
result in false even though ingame checking the data it is indeed there:

lavish hemlock
#

:miner

amber vale
#

Misspelled

lavish hemlock
#

should be miner-

#

oh

amber vale
#

It

#

I was trying one thing but thats how it used to be

lavish hemlock
#

well, is it actually saved as a BYTE?

amber vale
#

oh

#

im just dumb

#

o,o

lavish hemlock
#

lmao

#

the next suggestion was gonna be "does your getPlugin return null"

amber vale
#

lol

#

im not that dumb

quaint mantle
#

where to check spigot 1.8 -> 1.9 changes and code difference?

lavish hemlock
#

"are you fucking instrumenting the class to change the method body of 'has'" /j

amber vale
#

Someone explain why it's printing the different miners value?
(yes, my math is very bad)

            hashrateList.add(i);
        }
        
        for (int i = hashrateList.size(); i > 0; i--) {
            switch(i - 1) {
                case 0:
                    lore.add(Utils.color("&9" + hashrateList.get(i - 1) + "H/s"));
                case 1:
                    lore.add(Utils.color("&9" + hashrateList.get(i - 1) + "KH/s"));
                case 2:
                    lore.add(Utils.color("&9" + hashrateList.get(i - 1) + "MH/s"));
                case 3:
                    lore.add(Utils.color("&9" + hashrateList.get(i - 1) + "GH/s"));
                case 4:
                    lore.add(Utils.color("&9" + hashrateList.get(i - 1) + "TH/s"));
                case 5:
                    lore.add(Utils.color("&9" + hashrateList.get(i - 1) + "PH/s"));
                case 6:
                    lore.add(Utils.color("&9" + hashrateList.get(i - 1) + "EH/s"));
            }
        }```
#

It has the value 10000

#

And that's what is ment to be displayed, but where tf is it pulling 9 from

#
            case 1:
                lore.add(Utils.color("&8&lCommon"));
            case 2:
                lore.add(Utils.color("&2&lUncommon"));
            case 3:
                lore.add(Utils.color("&1&lRare"));
            case 4:
                lore.add(Utils.color("&5&lSuper rare"));
            case 5:
                lore.add(Utils.color("&d&lEpic"));
            case 6:
                lore.add(Utils.color("&6&lLegendary"));
            case 7:
                lore.add(Utils.color("&d&k&llll&4&lM&c&lY&6&lT&e&lH&2&lI&a&lC&b&lA&3&lL&d&k&llll"));
        }
        ```
#

Same thing here

#

@lavish hemlock youre smart

#

explain

lavish hemlock
#

switch fallthrough

#

there's no break after your lore.add

amber vale
#

?

#

oh

#

im dumb

#

o.o

lavish hemlock
#

meaning case 1 goes directly into case 2

#

and then it goes into the next case

#

and then into the next case

#

and eventually you're traversed the entire switch

amber vale
#

yes

#

im dumb

lavish hemlock
#

See, in a good language, switch fallthrough is explicit.

Java is not a good language.

lost matrix
#

There are quite a bit of alternatives. Most of the require NMS and/or packets.

lavish hemlock
quiet ice
amber vale
#

Java is my sussy baka

lavish hemlock
#

it's my Java too fucker

#

I'll talk shit about it all I want.

amber vale
#

no

#

i become very angry

#

mpo

#

no one insults my sussy baka

quiet ice
#

If you dont want fallthrough you shouldn't be using standard switch statements anyways

lavish hemlock
quiet ice
#

Well, if you are not using latest java you shouldn't be complaining about the language lacking certain features

#

It's like complaining that your computer is slow when it was made in 2005

lavish hemlock
lost matrix
#

Who uses switch statements in 2021 anyways?

amber vale
quiet ice
#

-> > :

amber vale
#

no im not smart

lost matrix
amber vale
#

i make minecraft plugins that dont even work half the time

#

so

lost matrix
#

Or rarely

amber vale
#

screw ->

lavish hemlock
lost matrix
bright jolt
#

I am trying to make a plugin that, when a player joins, it says their server name (I am using BungeeCord). However, whenever I use player.getServer() it returns null, and when I use player.getServer().getInfo().getName() it doesn't print anything.

lavish hemlock
#

you'd <3 a cleaner system more, trust me

lost matrix
amber vale
#

bro

#

i get cyber bullied about my inefficient coding 😢

#

not everyone can be perfect

lost matrix
#

Its not bullying. Just a suggestion. If you like your switch case then keep it.

quiet ice
#

Map<Integer, Object> always scream Object[]

lavish hemlock
#

instantiating an array takes up less memory than instantiating an object most of the time, and you can set the default values of the array easier

#

(plus arrays are fixed size)

#

so if you want extensibility, Map, if you don't need it, array

lost matrix
# quaint mantle ?

Those versions are both really old and unsupported. If you want to find any information you will have to look
into old forum posts or find them out yourself by first loading 1.8 and then 1.9 to see if you have to update any
of your code.

quaint mantle
#

yes but i want to find commits or specific changes in the code

lost matrix
#

?stash

undone axleBOT
lost matrix
#

You can look here ^

manic furnace
#

I coded a plugin that that writes every 10 seconds the position of a player to a file. But after a little bit of time there are not only a move.txt, there are other files like move.txt.save or move.txt.save.1. How can i stop linux to make this files ?

lost matrix
manic furnace
#

Sry i am not at home.

#

I tested it with 10 players a week long and there were no lags.

quaint mantle
#

its not efficient to do it in main thread, you lose smoothness etc

summer scroll
#

I don't think writing something to a file every 10 seconds is a good thing.

#

You can do it simply with HashMap and save/load the location on plugin disable and enables.

manic furnace
#

But how can i stop linux make tihs saves?

chrome beacon
#

Show code

manic furnace
#

How i sayed, I am not at home. But what can be the cause that linux makes that?

summer scroll
chrome beacon
#

Yeah pretty sure it's not Linux creating those files

manic furnace
#

Oh ok

gleaming grove
#

Hey is there some fast way to sort array of objects by one of its property?

manic furnace
#

I can say that i every 10 seconds with a sheduler write the positions to a file

lost matrix
gleaming grove
lost matrix
#

You can either let them implement Comparable<SELF> or provide an external Comparator<YourClass>

gleaming grove
#

My idea is to sort keys by color. First should be all black then all white. Whats wrong with this implementation?

#

Objects are not sorted

ivory sleet
#

You need to consider the comparison cases when it’s a
black against black
white against white
black against white or white against black

gleaming grove
#

is there some more clear way? For example black keys will return 0, Whilte 1, and then i use sth like SQL GROUPBY ?

quaint mantle
#

could just return Boolean.compare(o1.isBlack(), o2.isBlack()); ?

quiet ice
#

that is one way to do it

grand perch
#
Error occurred while enabling Lifesteal v1.0-SNAPSHOT (Is it up to date?)

java.lang.IllegalArgumentException: Invalid key. Must be [a-z0-9/._-]: Heart
#

what happened there ?

sullen dome
#

What is Heart

grand perch
#

its a item

ivory sleet
#

Heart is capitalized

grand perch
#

i belive

ivory sleet
#

it has to be heart

grand perch
#

oh ok so it cant be capitalized ?

ivory sleet
#

Probably because it’s suppose to be a name spaced key

sullen dome
#

key's must be lowercase

grand perch
#

Rip gimme a few days to fix it

sullen dome
#

why tho? just change one char from upper to lowercase

ivory sleet
#

It’s like a 2 seconds fix

grand perch
sullen dome
#

tf

grand perch
#

but turns out i didnt use the var hearts that much so it turns out to be a few minutes

sullen dome
#

go into the class, ctrl+r
enter old
enter new

hit enter

grand perch
#

oh ok

ivory sleet
#

Comprehensive guide right there 😆

sullen dome
#

if i get it right at least

#

sodium is kind of crazy when it comes to fps lol

#

oops wrong channel lol

unreal quartz
#

we do a little gaming

sullen dome
#

currently re-creating a few structures

reef wind
sullen dome
#

i think it is at 28 renderdistance tho

tribal holly
#

someone know how to set a skull skin with a link ?

reef wind
sullen dome
#

rx580

sullen dome
#

with optifine, i'd probably be at about... idk

#

lemme test it lol

reef wind
#

optifine is worse

sullen dome
#

yea

reef wind
#

I use sodium over optifine everyday a week

sullen dome
#

only thing why i still sometimes use optifine is shader-options

reef wind
#

yeah, optifine has some more options, I never use them tho.

sullen dome
#

some more?

reef wind
#

fog and stuff

sullen dome
#

sodium (iris tbc) has no options at all when it comes to shaders

#

you can use some shaders... thats it

reef wind
#

yes ik

#

I put it in a bad way

grand perch
sullen dome
#

eclipse?

grand perch
#

no

reef wind
#

optifine has some options like disabling fog and whatever and other shit*

grand perch
#

intellij

sullen dome
#

well

#

intellij uses ctrl+r for replace in current file

#

yea, like i thought

reef wind
#

cringe

sullen dome
#

but tbh

reef wind
#

optifine smh

sullen dome
#

a lot of that causes come from the 1.17 rendering changes, and of still not really beeing 100% optimized to it

#

at 16 distance

#

that's hillariously bad lmao

rigid hazel
#
double playerMana = AureliumAPI.getMana(player);
double playerMaxMana = AureliumAPI.getMaxMana(player);
double lines = 10;
```How can I do lines (\||\||\||\||\||), they corresponding to playerMaxMana and the lines, that are filled by playerMana should be blueß
#

How can I calculate this?

reef wind
#

@sullen dome we should prob move to #general

sullen dome
#

yea, my bad

exotic obsidian
#

hello guys

#

who's have a good way to create particle effects

vague oracle
vale ember
#

hey everyone, i have a maybe weird question but i want to ask it here cuz its related to spigot
i am thinking at creating some sort of library that will make creating simple commands easier like this (ik that code need to be published to external website but i think it is small enough to publish directly here)
and i am thinking is this useful or just unnecessary overengineiring

public class CommonCommands implements CommandListener {
    @Command(name = "cc", syntax = "addkey {crateID: String} {playerName: String} {keyCount: int}")
    public void onCommandCC(DCommand command) {
        String crateID = command.getString("crateID");
        String playerName = command.getString("playerName");
        int count = command.getInt("count");
        
        // Do some stuff here
    }
}
ivory sleet
#

any framework or lib is useful in a sense probably

#

and that doesnt look particularly over engineered

#

speaking of over engineered, then check out something like cloud

lost matrix
# rigid hazel ```java double playerMana = AureliumAPI.getMana(player); double playerMaxMana = ...

Example for HP and Mana.

  private static final String HP_LOW_PRE = "§c";
  private static final String HP_HIG_PRE = "§a";
  private static final String MANA_LOW_PRE = "§7";
  private static final String MANA_HIG_PRE = "§9";

  public static String createBar(
      final double max,
      final double current,
      final int length,
      final String elem,
      final String lowPre,
      final String higPre
  ) {
    final double percent = 1.0 / max * current;
    final int highCount = (int) Math.ceil(percent * length);
    final int lowCount = length - highCount;
    return higPre + elem.repeat(highCount) + lowPre + elem.repeat(lowCount);
  }

  public static String createHealth(final double max, final double current, final int length, final String elem) {
    return createBar(max, current, length, elem, HP_LOW_PRE, HP_HIG_PRE);
  }

  public static String createMana(final double max, final double current, final int length, final String elem) {
    return createBar(max, current, length, elem, MANA_LOW_PRE, MANA_HIG_PRE);
  }
rigid hazel
ivory sleet
#

the finals boy

lost matrix
#

9469_Pepe_CowboyShoot final9469_Pepe_CowboyShoot

ivory sleet
#

😏

lost matrix
minor garnet
lost matrix
#

Example: Linux server without GPU

minor garnet
#

i'm managing this library through maven

#

oh

#

i think not

maiden briar
maiden briar
#

Ok

#
public void validate(YamlConfigFile yamlFile)
    {
        Map<String, Object> validatedObjects = new HashMap<>();
        List<String> wrongObjects = new ArrayList<>();
        boolean missing = false;

        yamlFile.saveDefaultConfig();
        Configuration config = yamlFile.getConfig();

        for(Map.Entry<String, ConfigClass> path : paths.entrySet())
        {
            String key = path.getKey();
            ConfigClass configClass = path.getValue();

            if(!config.contains(key))
            {
                System.out.println("Config does not contain " + key);
                missing = true;
                continue;
            }

            if(configClass.parse(config, key))
                validatedObjects.put(key, config.get(key));
            else
                wrongObjects.add(key);
        }

        System.out.println("Wrong " + wrongObjects);
        System.out.println("Missing " + missing);

        if(missing || !wrongObjects.isEmpty())
        {
            yamlFile.saveDefaultConfig(yamlFile.getName().replaceAll("\\.yml", "") + ".invalidconfig.yml");
            yamlFile.delete();
            yamlFile.saveDefaultConfig();

            config = yamlFile.getConfig();

            for(Map.Entry<String, Object> validatedObject : validatedObjects.entrySet())
                config.set(validatedObject.getKey(), validatedObject.getValue());
        }
    }

missing is always true because it can't find it

quaint mantle
maiden briar
#

Some classes are custom

lost matrix
maiden briar
#

So team.setScore(1); for example

quaint mantle
#

yeah i set it to sidebar

#

and to 10

maiden briar
#

Did you send it to the player?

#

player.setScoreboard

quaint mantle
#

yup

lost matrix
maiden briar
#

I found that out, but I have no clue how to fix that, because I want to make it universal for every configuration

lost matrix
maiden briar
#

Yes, to check if where for example a boolean is a boolean in the config from the server files

#

And that an integer not a boolean is

outer crane
#

What do brackets around a minecraft item's display name mean? Custom Texture Data?

lost matrix
outer crane
#

im on the latest build and yeah im using adventure with a load of other libs

maiden briar
#

@lost matrix do you have any clue to fix it?

quaint mantle
lost matrix
lost matrix
maiden briar
lost matrix
maiden briar
#

Ok just with MemorySection#getKeys(true)

#

I save the original config for another name and get the keys there, and remove the file

lost matrix
#

Then the paths have to match.

maiden briar
#

Yes, but I get everything incomplete without plugin.

lost matrix
#

Show me how you build the paths structure.

maiden briar
#

The full class

#

Configuration is an interface, which will work for bungee and bukkit and it has all methods like Bukkit's yaml

lost matrix
maiden briar
#
[05:55:58 INFO]: Found key plugin
[05:55:58 INFO]: Found key plugin.world
[05:55:58 INFO]: Found key plugin.world.name
[05:55:58 INFO]: Found key plugin.world.autoreset
[05:55:58 INFO]: Found key plugin.game
[05:55:58 INFO]: Found key plugin.game.start
[05:55:58 INFO]: Found key plugin.game.start.countdown
[05:55:58 INFO]: Found key plugin.game.playing
[05:55:58 INFO]: Found key plugin.game.playing.gametime
[05:55:58 INFO]: Found key plugin.game.playing.playable
[05:55:58 INFO]: Found key plugin.game.playing.rejoin
[05:55:58 INFO]: Found key plugin.game.playing.hearts
[05:55:58 INFO]: Found key plugin.game.playing.chatformat
[05:55:58 INFO]: Found key plugin.game.dogs
[05:55:58 INFO]: Found key plugin.game.dogs.base
[05:55:58 INFO]: Found key plugin.game.dogs.base.speed
[05:55:58 INFO]: Found key plugin.game.dogs.base.health
[05:55:58 INFO]: Found key plugin.game.dogs.base.damage
[05:55:58 INFO]: Found key plugin.game.dogs.base.range
[05:55:58 INFO]: Found key plugin.game.dogs.upgrade
[05:55:58 INFO]: Found key plugin.game.dogs.upgrade.speed
[05:55:58 INFO]: Found key plugin.game.dogs.upgrade.health
[05:55:58 INFO]: Found key plugin.game.dogs.upgrade.damage
[05:55:58 INFO]: Found key plugin.game.dogs.upgrade.range
[05:55:58 INFO]: Found key plugin.game.dogs.max-target-distance
[05:55:58 INFO]: Found key plugin.game.end
[05:55:58 INFO]: Found key plugin.game.end.restart
[05:55:58 INFO]: Found key plugin.game.end.teleport
maiden briar
#

IMPORTANT: If you want to show the scoreboard you have to call update, this will update it for all players

#

This is the problem: I still get MemorySection:

[06:01:29 INFO]: Found key plugin.world
[06:01:29 INFO]: Key is universal: class org.bukkit.configuration.MemorySection
lost matrix
#

Oh so you need to properly handle the sub sections.

maiden briar
#

Yes, but how can I remove them? Just checking for with get?

lost matrix
#

There is honestly still so much happening in the background that i have no idea what you are doing.

maiden briar
#

Ok I will just try it

#
@Override
    public Collection<String> getKeys()
    {
        Collection<String> keys = bukkitConfiguration.getKeys(true);
        keys.removeIf(key -> get(key) instanceof MemorySection);
        return keys;
    }
#

Yes that works, now let's test overall

maiden briar
#

Why does MemorySection#get(path) return false if the value in the config is true?????

maiden briar
#

Yes

#

I have debugged it

eternal oxide
#

it can;t return false if the value is actually set true, unless you set the default true and not the actual value

stone sinew
#

try getBoolean?

maiden briar
#

No because I am making it universal for all objects so I don't acutaly know if it's a boolean

maiden briar
#

I even did reloadConfig

maiden briar
stone sinew
maiden briar
#

Ok

#

System.out.println("Config: " + key + " " + config.get(key));
[06:28:06 INFO]: Config: plugin.world.autoreset true

#

Now I will try it with instanceof for you

outer crane
#
{
   "italic":false,
   "extra":[
      {
         "color":"white",
         "hoverEvent":{
            "action":"show_item",
            "contents":{
               "id":"minecraft:paper",
               "tag":"{CustomModelData:1,PublicBukkitValues:{\"sealeaf:key\":\"sealeaf:prop_money\"},display:{Name:\u0027{\"italic\":false,\"extra\":[{\"color\":\"#80ed99\",\"translate\":\"sealeaf.item.money.name\"}],\"text\":\"\"}\u0027}}"
            }
         },
         "translate":"chat.square_brackets",
         "with":[
            {
               "italic":true,
               "extra":[
                  {
                     "italic":false,
                     "extra":[
                        {
                           "color":"#80ed99",
                           "text":"Money"
                        }
                     ],
                     "text":""
                  }
               ],
               "text":""
            }
         ]
      }
   ],
   "text":""
}
#

still no idea where its coming from :p

maiden briar
maiden briar
eternal oxide
#

then the returned value can't be false.

maiden briar
#

And still System.out sais it is false

#
yamlFile.saveDefaultConfig();
        yamlFile.reloadConfig();
        Configuration config = yamlFile.getConfig();

        for(Map.Entry<String, ConfigClass> path : paths.entrySet())
        {
            String key = path.getKey();
            ConfigClass configClass = path.getValue();

            if(!config.contains(key))
            {
                missing = true;
                continue;
            }

            if(configClass.parse(config, key))
            {
                validatedObjects.put(key, config.get(key));
                System.out.println("Config: " + key + " " + config.get(key));
            }
            else
                wrongObjects.add(key);
        }
maiden briar
#

And integer, string, etc

eternal oxide
#

So you are saying its not find any values?

maiden briar
#

Yes

#

(After editing)

eternal oxide
#

then you are either deleting them or you are using the wrong path

maiden briar
#

I am deleting the file if there are objects wrong

#

But not that early

eternal oxide
#

are you pulling MemorySections and parsing them individually?

maiden briar
#

This is the full class

#

Look in validate

eternal oxide
#

Why are you making this so complex?

maiden briar
#

It is not complex if using the full framework

#

This is just a snippet

eternal oxide
#

all you are doing is reading from a config

maiden briar
#

Yes, and checking if the value is actually a boolean if it is also a boolean in the /resources folder

solemn gulch
#

is it better to do this
Bukkit.getLogger().info("Hi");
over
System.out.println("Hi");

eternal oxide
#

90% of this code is not needed

maiden briar
#

If not, I will replace the config with the default values and set the validated values

maiden briar
stone sinew
eternal oxide
#

Well ConfigurationSerializable already handles all primitives and registered classes

maiden briar
#

Yes, but I am making it universal with every config

#

I am not going to do this with 1 config

eternal oxide
#

It look slike you are just over complicating it all

maiden briar
#

It is not

#

But how to fix that I can't read the newest values?

eternal oxide
#

one sec let me have a play

maiden briar
#

Ok

true perch
#

How can I make an armor stand helmet's pose North, South, West, and East?
The top armor stand isn't an exact 90 degree angle:
https://imgur.com/a/gpzaxKx

maiden briar
#

.setDirection is that a method in Entity? Or just set the yaw and pitch

#

Vectors are also an option

quaint mantle
#

i just saw you responded me tvhee thx a lot

maiden briar
quaint mantle
#

i'm trying it rn

true perch
#

No need to change the head pose if I can just rotate the entire stand I suppose 😂 thanks

maiden briar
#

Ok because I just made it 1 month ago

true perch
# maiden briar 😄

Seems it's not doing anything when I change from setHeadPose to setRotation 🤔

#

armorStand.setRotation(270,0) is doing nothing

maiden briar
#

Hm that is weird

#

Try teleport

true perch
#

👍

formal dome
#

@chrome beacon Cannot invoke "java.sql.Connection.createStatement()" because the return value of "com.craftinc747.discord.logReader.access$000(com.craftinc747.discord.logReader)" is null

#

or anyone... why does this return null... please ping me if you respond. i need to be notified

true perch
# maiden briar Try teleport

armorStand.teleport(new Location(teleport.getWorld(),teleport.getX(),teleport.getY(),teleport.getZ(),270,0)); also not working 🤔

maiden briar
#

You have to set the YAW

true perch
#

yeah sorry I did haha

#

edited ^ didn't work

maiden briar
#

Ah ok I see

#

This is kinda weird

#

It should work

#

270 is north, west, east or south?

true perch
#

Not sure, I'd assume yaw has 360 degrees total right?

maiden briar
#

Yes

#

It is one circle

true perch
#

0 degrees works perfectly for the very first armor stand placed, but I'm trying to place 4 armor stands in each direction

#

1 in each direction* 4 total

maiden briar
#

Ok I understand

#

People say that .setDirection should work

#

On the forums

true perch
#

Oh cool! yeah I've been looking into EurAngle stuff for a bit. Don't understand it, and the forums didn't really help answer what I need so I thought I'd try here

#

I'll try setDirection

sacred ice
#

move into quaternions

true perch
#

for some reason there's no setDirection method for the object 🤔

maiden briar
#

Yep I see that

#

entity.getLocation().setYaw(yaw);?

true perch
#

Sounds promising

#

didn't work! Damn.

eternal night
#

you will need to teleport the entity afterwards

true perch
#

They're all spawning as if they're 0 yaw

true perch
eternal night
#

the location returned by getLocation() is not linked to the entity location

#

more like a copy of the location at the time of the method call

maiden briar
#

Then use .add and .setLocation

worldly ingot
sacred ice
#

you will lose colors

#

in console

worldly ingot
#

System.out.println() provides no source from where the log message came, Bukkit.getLogger() has it come from the server itself which is also untraceable

#

Use your plugin's logger

#

JavaPlugin#getLogger()

severe oracle
#

how do i add a map that has something drawn on it intro costum GUI ?

stone sinew
worldly ingot
#

Nah

#

Nothing more annoying than a server owner seeing "Hello!" from some unknown source

stone sinew
#

nah

worldly ingot
#

If you're going to educate people on what to use, at least educate them on the correct way

true perch
#

Thanks for the help

stone sinew
worldly ingot
eternal night
#

I too like my server spitting out random log messages

stone sinew
#

I prefer

[Time] Message
[Time] Message
Rather then
[Time] [Plugin] Message

eternal night
#

especially if the plugins I use are not mine but third party and I have no clue what those messages are

#

sure that layout is "ok" for you if you run your own server with just your plugins

#

you probably know all the messages that pop up

wild reef
#

Hey short question. I want to change / check some things when TNT is exploding. For Example the explosion radius should be reduced at some points and I am looking an event where I can check for the blocks which are going to be destroyed

eternal night
wild reef
#

Oh thank you, was searching for a get... that's why I didn't found the blocklist 😅

dense remnant
eternal night
#

if you don't use a command framework, add all the names of the currently online players to the tab completion ?

wild reef
wild reef
summer scroll
#

You can use return null; instead, it will show a list of online players name.

dense remnant
#

Thanks

eternal oxide
#

@maiden briar When you replace a value are you replacing just the value at that path, or do you replace the map?

maiden briar
#

I only replace the value

eternal oxide
#

then I see no reason for yoru issue

#

nothign obvious anyway

maiden briar
#

Yes I am also not

#

I just put config.get

#

I will look onto this tomorrow

eternal oxide
#

You do know you can just use teh class of the object, no need to define your own?

#

config.get(path).getClass()

#
[15:27:24] [Server thread/INFO]: autoreset:class java.lang.Boolean```
winged anvil
#

my current plugins are like 44,000 KB I assume its due to the API jar being around 44,000. how do i reduce the size

quaint mantle
#

dont shade it

winged anvil
#

what is shading

quiet ice
#

maven or gradle?

winged anvil
#

what i use?

#

neither

#

should i use one

quiet ice
#

Then you are on your own

eternal oxide
#

what IDE?

winged anvil
#

intellij

eternal oxide
#

No idea if thats available without maven as I don;t use InteliJ

winged anvil
#

well i can use Maven if its useful

#

i just didnt before cause i didnt know what it was

carmine ice
#

does anyone know if there's a way to listen to block break events from spawning iron golems

near night
#

what number should be here its not right

rigid hazel
#
                    for(Guild guild : plugin.getGuilds())
                    {
                        for(GuildChunk chunk: guild.getOwnedChunks())
                        {
                            if (chunk.getChunk().getX() == player.getLocation().getChunk().getX() && chunk.getChunk().getZ() == player.getLocation().getChunk().getZ())
                            {

                            }
                        }
                    }
```How can I do that easilier? With stream perhaps?
eternal night
#

sure, tho keep in mind using streams in often called code might not be the most speedy idea

eternal oxide
#

if (chunk.getChunk().equals(player.getLocation().getChunk()))

eternal night
#

also, is the getChunk call going to load the chunk ??

#

if so, please don't

formal dome
eternal night
#

?paste

undone axleBOT
formal dome
#

thx

#

i also get a sql error: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

eternal night
#

are you executing SQL connections on every single log message 👀

formal dome
eternal night
#

well, your connection instance is null.

#

the reason the null message looks so weird is because you are using an inner class that captures outer class state (as in your connection field)

#

maybe you should look into using an SQL connection pool like HikariCP

formal dome
#

as opposed to jbdc?

eternal night
#

The connection pool still uses it under the hood

#

but it manages creating connections for you

severe oracle
#

is it possible to detect X, Y cordinates of a click on the item frame ?

eternal night
#

so you can create the pool once (in your onEnable) and then just pass the pool around to allow other instances to use SQL connections

eternal night
#

isn't it just a raytrace

#

seems pretty straight forward

severe oracle
#

can raytrace detect sub pixel ?

eternal night
#

actually the PlayerInteractAtEntityEvent already provides you a vector through getClickedPosition

#

see if that is accurate enough for you

severe oracle
#

ok

#

will try

opal juniper
#

EntityDeathEvent#getDrops - can i change the set of itemstacks?

eternal night
#

mutating the list will mutate the drops if that is what you are asking

opal juniper
#

yep forgot the word - thanks

formal dome
#

i thought this line returned a connection instance connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/logReader?autoReconnect=true&useSSL=false");

eternal night
#

I mean, it is possible if the DriverManager.getConnection call errored

#

while you print the stack trace, it will continue your code after that

formal dome
#

it did

eternal night
#

Yea then the connection will simply not be set because the connection = ... call failed

#

and hence is null

formal dome
#

Could not create connection to database server. Attempted reconnect 3 times. Giving up.

#

ah

#

lol

#

gotta solve that first... i think the problem is with my sql url

tacit drift
opal juniper
#

nope

ivory sleet
#

might b in a distance fork of spigot

#

but not in spigot to my knowledge sadly

opal juniper
#

most likely a paper thing

tacit drift
#

Nah i was using spigot when I was experimenting with mob drops probably remembered wrong

opal juniper
#

as lynx said it is just a mutable list

eternal night
#

not like there would be much need for such a method if the list itself is just used

opal juniper
#

quick

.clear
.addAll

does the same ig

ivory sleet
#

ye I mean probably better to have the field to the list final rather than mutating the list field since someone could drop in a list that breaks lsp

opal juniper
#

If i have 4 Locations which are corners to a square - is the only real way to work out if a location falls inside the "region" is to essentially check all x/z coords? or is there a handy dandy way i can use

ivory sleet
#

well why 4 locs

#

u theoretically only need 2 locs right

opal juniper
#

🤔 yes you right

ivory sleet
#

also 2 locs would be enough to check if something is contained between the 2 locs

opal juniper
#

if target.x > loc1.x && target.x > loc.z && target.x < loc2.x && target.z < loc2.z

#

something like that ig

#

to work out if it is outside

ivory sleet
#

yeah

#

I usually have 2 methods when I create a region representing class like that

vast sapphire
#
//set
    @EventHandler(priority = EventPriority.MONITOR)
    public void Place(BlockPlaceEvent event) {
        PlayerPlaced.add(event.getBlockPlaced().getLocation());
        this.getConfig().set("blocks." + event.getBlock().getType(), PlayerPlaced);
        this.saveConfig();

    }
//get
        if (check) {
            if (e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)) {
                    if (e.getBlock().getType().equals(Material.GRASS) || e.getBlock().getType().equals(Material.TALL_GRASS)) {
                        e.getBlock().breakNaturally();
                    } else {
                        e.setCancelled(true);
                        Material item = e.getBlock().getType();
                        e.getPlayer().getInventory().addItem(new ItemStack(item, 2));
                        e.getBlock().setType(Material.AIR);
                    }
                }
            if (getConfig().getLocation("blocks").equals(e.getBlock().getType())) {
                e.setCancelled(true);
                Material item = e.getBlock().getType();
                e.getPlayer().getInventory().addItem(new ItemStack(item, 1));
                e.getBlock().setType(Material.AIR);
            }
        }
        else {
            e.setCancelled(false);
        }
``` The blocks aren't changing when I try and get them from the config, when a player places a block, it saves the location of the block to a config and if that block is equal to that area of the config then it only drops 1, everything else will drop 2 of the broken block
ivory sleet
#

one that checks if its inside

#

and one that checks it its inside or at the borders

opal juniper
#

oh lol i thought you were gonna say "one that checks if it is outside"

undone axleBOT
ivory sleet
#

lmao

ivory sleet
opal juniper
#

yep

#

reminds me of myself not that long ago

vast sapphire
#

https://paste.md-5.net/qazozefiji.cs
The blocks aren't changing when I try and get them from the config, when a player places a block, it saves the location of the block to a config and if that block is equal to that area of the config then it only drops 1, everything else will drop 2 of the broken block

opal juniper
#

mfw

if booleanVariable == True:
ivory sleet
#

python ew

opal juniper
#

conclure

#

i think you have to remember

#

that the reason that i did shit like this

#

is cause it was the only lang i knew

ivory sleet
#

oh fair

opal juniper
#

and had terrible teaching

ivory sleet
#

I have to learn python rn lol

opal juniper
#

its quite a nice lang tbh

#

not performant

#

but still

quaint mantle
#

it should only be used for web dev

opal juniper
#

meh

#

its quite good for ai cause of all the libs there are for it

ivory sleet
#

ye

#

I hate its type hint system

opal juniper
#

i forget the name

opal juniper
#

dont get me started on the lambdas smh

hushed spindle
#

having an issue with InventoryDragEvent where e.setCursor() does not actually change the cursor
tried the same with e.getWhoClicked().setItemOnCursor() and no difference
anyone else had experience with a similar issue?

opal juniper
#

isnt it deprecated for basically this reason

#

cause it dont really work

hushed spindle
#

that would be InventoryClickEvent

opal juniper
#

ah my bad

hushed spindle
#

but with inventorydragevent its not deprecated

opal juniper
#

lemme have a look

hushed spindle
#

works perfectly fine for click event but for drag it just doesnt

opal juniper
#

i have never really used this event

hushed spindle
#

im trying to do things with custom brewing recipes which works mostly fine but its not working consistently because GUIs are so sensitive to making an inventory click event an inventory drag event if you just move your mouse a little bit, and its making my brewing go inconsistent and buggy

#

so sometimes you have to use both

ivory sleet
#

then we got stuff like
def do(x: Union[type(lambda: None), str])

#

or smtng

opal juniper
#

lol

humble heath
#

hey can anyone help plx

opal juniper
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!

hushed spindle
#

actually i didnt word my issue properly, sorry about that. cursor setting works (kind of) but with this code it only works when you attempt to insert an item into a brewing stand that isn't supposed to go there. with items that do work for it the cursor is not changed. i cancelled the event just to make sure the custom insertion system is used, and doing so apparently set the event result to DENY. which then apparently makes it so cursors are not changed as a result of the event

humble heath
hushed spindle
#

e.setResult(Event.Result.ALLOW) after cancelling the event fixed the issue

humble heath
#

any idea

hushed spindle
#

wdym like are you confused about the red part

humble heath
#

yea

hushed spindle
#

you're using a method that doesn't exist

humble heath
#

how can i get the target server to display

eternal night
#

concerning that this isn't cancelable,the player might already have the updated server

hushed spindle
#

well it doesnt look like a serverswitchevent knows about the target server

hushed spindle
#

what about a ServerConnectEvent

#

i think you're just using the wrong type of event

#

because ServerConnectEvent DOES have getTarget()

#

i guess that makes sense because switching to a new server does not necessarily imply the person connecting makes it to that server

humble heath
#

i know but i dont want the message to run when the player joins the hub server on login is there a way to check that they are coming from another server and not loging in

eternal night
#

please try if the proxied player's getServer returns the new one 😦

humble heath
#

no red

#

that worked thank you

severe oracle
#

how do i add an element to List ?

eternal night
#
myList.add(myElement);
severe oracle
#

List looks like this:```java
public class button {
public String name;
public int id;
public int x;
public int y;
public int x1;
public int y1;
}

public static List<button> buttons = null;```
eternal night
#

why is your list null tho ?

severe oracle
#

initializes it ?

eternal night
#

no lol

opal juniper
#

LOL

severe oracle
#

???

#

sorry i never used lists before

#

as they are not in C

opal juniper
#

= new ArrayList<>(); iirc

#

if you wanted an arraylist

quaint mantle
#

help with removing nearby armor stands

#
        if (args[0].equals("remove")) {
                          for(Player all : Bukkit.getServer().getOnlinePlayers()){
                                Entity e = (Entity) all.getNearbyEntities(10, 10, 10);
                             if (e.getType() == EntityType.ARMOR_STAND) {
                  
                                 e.remove();
                                 p.sendMessage(ChatAPI.color("&b&l(!) &fnearby leaderboards has been deleted."));
                                 p.sendMessage(ChatAPI.color(e.getCustomName() + " removed."));
                                 return true;
                             }
                            }
                    }```
#

code not works

eternal night
#

getNearbyEntities does not return an entity

#

your IDE should already be screaming at you

#

it returns a List<Entity>

quaint mantle
#

okay thx

severe oracle
#

but i dont wand an array list i basicly need a StructureList

#

if it exists

opal juniper
#

what is the point of a StructureList

severe oracle
#

public class button {
public String name;
public int id;
public int x;
public int y;
public int x1;
public int y1;
}

opal juniper
#

what / how does it store

severe oracle
#

this is called structure isnt it ?

opal juniper
#

Object

#

A list can store any type of object

#

and use UpperCamelCase for class names

#

So
List<Button> buttons = new ArrayList<>();
is a list of Button Objects

lusty cipher
#

the empty <> is just a Java feature that takes the generics from the type specified List<Button>

#

so new ArrayList<>() would just be new ArrayList<Button>(), essentially

ivory sleet
#

type inference 😄

opal juniper
#

My mother always taught me to not Assume angryeyes

#

what if the List doesn't want its type guessed

ivory sleet
#

could always go with
List<E> list = new MomsExplicitList<E>();

severe oracle
#

ok so how do i add an element to that array ?

ivory sleet
#

u cant add an element to an array

#

only insert

severe oracle
#

it is a list

#

not an array

ivory sleet
#

oh ok

#

say that then 😄

#

but well

#

list.add(element)

severe oracle
#

what should element be for ```public class button {
public String name;
public int id;
public int x;
public int y;
public int x1;
public int y1;
}

public static List<button> buttons = new ArrayList<>();``` ?
ivory sleet
#

idk

#

depends on what buttons u want to add ofc

severe oracle
#

i dont know how to add an object with all of those parameters

#

name, id, x, y...

ivory sleet
#

well first of all you need to create an object of the class button

severe oracle
#

public class button {
public String name;
public int id;
public int x;
public int y;
public int x1;
public int y1;
}

ivory sleet
#

I'd suggest creating a constructor

severe oracle
#

this should be that obj

ivory sleet
#

thats not an object

#

thats a class

#

that being said classes can create objects

#

I'd strongly suggest learning the difference between the notion of a class and the notion of an object/instance

severe oracle
#

so that class isn't like struct in C ?

ivory sleet
#

forget C

#

c isnt even object oriented

severe oracle
#

but it has strcuture vars

#

and i want to use something like that in java

ivory sleet
#

yes but its far from object oriented

#

obj-c is object oriented sure

brittle loom
#

Hello, I'm having trouble finding a way to remove all swords in an inventory until there's only one left, could you help me?```

for (final ItemStack item : inventory.getContents()) {

            if (item != null && item.getType().name().contains("SWORD")) {
                inventory.remove(item);

                System.out.println(item.getType().name());
            }
        } ```
ivory sleet
#

anyways stargate, seeing u as coming from C I'd still recommend to read on a little about how java works

#

?learnjava might get you started with that

undone axleBOT
brittle loom
#

Well right now the code is removing all swords

ivory sleet
#

I'd do this

#
boolean hasSword = false; 
for (int i = 0; i < inventory.getSize(); i++) {
  ItemStack item = inventory.getItem(i);
  boolean isNotNull = item != null;
  boolean isSword = item.getType().name().contains("SWORD");
  
  if (isNotNull && isSword) {
      if(!hasSword) {
        hasSword = true;
        continue;
      }
      inventory.setItem(i,null);
  }
} 

maybe?

brittle loom
#

I'll try it out, thanks a lot for the help.

ivory sleet
#

👍

humble heath
#

The issue im getting now it is telling me the server the player leaves not the one they are joining

severe oracle
#

can you please check if this code is right ? ```java
public class buttons {
public static int id = 0;
public static int x = 0;
public static int y = 0;
public static int x1 = 0;
public static int y1 = 0;

private static List<buttons> buttonsList = new ArrayList<>();

//constructor
private buttons(int id, int x, int y, int x1, int y1) {
    this.id = id;
    this.x = x;
    this.y = y;
    this.x1 = x1;
    this.y1 = y1;
}

public static void addButton(int id, int x, int y, int x1, int y1) {
    buttonsList.add(new buttons(1, 0, 0, 2, 3));
}

}```

ivory sleet
#

looks alright I guess

severe oracle
#

thanks

eternal night
#

conclure be lying

chrome beacon
#

PascalCase the class name

ivory sleet
#

oh I missed the static

eternal night
#

the fact that the "class fields" are static shall be ignored

ivory sleet
#

wth

eternal night
#

lol

humble heath
#

any idea on how to disable the conected to hub message when joining the server

crimson terrace
#

replace it with an empty message?

humble heath
#

@EventHandler
public void severconect(ServerConnectEvent event) {
ProxiedPlayer player = event.getPlayer();
ProxyServer.getInstance().broadcast(ChatColor.LIGHT_PURPLE + player.getDisplayName() + " has joined " + ChatColor.GREEN + event.getTarget().getName());
}

#

i want it to broadcast when someone joins the hub from another server

crimson terrace
#

can we talk about "severconect"?

humble heath
#

but not when they join the server

crimson terrace
#

then you might not wanna use the ServerConnectEvent since that gets called when someone joins the server

humble heath
#

well what event do i need cus when i use serverSwichEvent it broadcastes the server they where on and not the server they are going to

crimson terrace
#

cant even find serverSwitchEvent

#

oh youre using bungee arent you

humble heath
#

yes

echo basalt
#

uH

#

You're broadcasting to all servers in the proxy

crimson terrace
#

never used Bungee

humble heath
#

yes

#

any idea

severe oracle
#

this might be a stupid question but what does static mean in java ?

crimson terrace
#

accessible from anywhere

severe oracle
#

thanks

humble heath
#

is there a way in server conectevent to check if theye are moveing servers

unkempt peak
#

Don't use it

crimson terrace
unkempt peak
crimson terrace
#

so how would one get a Method from a class to work in another class

unkempt peak
#

Objects.

crimson terrace
#

fair

unkempt peak
#

Java is an object oriented language

crimson terrace
#

but I am not

unkempt peak
#

Well then you shouldn't be using java

humble heath
#

i feel that wall is geting further than i am

quaint mantle
#

its not used in the correct places sometimes

crimson terrace
#

you can tell me bad practice as much as you want Ill still use it since its convenient

unkempt peak
quaint mantle
#

yes

quaint mantle
lavish hemlock
#

"The concept of global variables being bad is Java propaganda." -A wise man.

lavish hemlock
#

BAD

unkempt peak
#

I generally just avoid it whenever possible

lavish hemlock
#

HERE IS EXACTLY WHY YOU DO NOT USE ASSERT:

#

assert only works if a flag is set when running the program.

#

It's only intended for testing.

quaint mantle
#

they are testing

#

and to get your ide to shut the fuck up

unkempt peak
#

Lol

crimson terrace
quaint mantle
#

true

#

assert vs /ConstantConditions/

lavish hemlock
#

ok well if you're only testing then

#

assert is fine

crimson terrace
#

tbh if my IDE asked me for my credit card number I would give it just to get it to remove the warning

quaint mantle
#

"Pay to get rid of nullable warnings"

severe oracle
#

can i debug the pluigin while it is running (get varaiabble values) ?

humble heath
#

can any one help me plx

severe oracle
#

how ?

humble heath
#

plz

unkempt peak
#

Sysout

#

@severe oracle

unkempt peak
severe oracle
#

where will sysout put the values ?

unkempt peak
#

Oh

unkempt peak
severe oracle
#

server console ?

unkempt peak
#

Yes

humble heath
#

@hasty prawnwhat you mean they did

hasty prawn
#

@humble heath It depends on what you're doing, and if you're using BungeeCord or Spigot.

#

So, whats your goal

humble heath
#

bungee

#

and i have it announce when a player joins a server but i dont want it to announce saying they have joined the hub when they join the server

hasty prawn
#

Then just don't broadcast when they join the Hub

humble heath
#

but i want it to if they go to the hub say from towny

hasty prawn
#

If you join Towny right now does it say "ArcaneLegend has joined Towny"

humble heath
#

yes

hasty prawn
#

Yeah, so if the server is the Hub server, don't broadcast, otherwise, broadcast.

humble heath
#

i dont get how to check if they are joining the server or moveing from another server

lost matrix
lavish hemlock
#

I just suppress warnings

quiet ice
#

the issue with supressing warnings is that it would often supress the warnings in a far to large scope

lavish hemlock
#

you can do statement-level suppression in IDEs :p

severe oracle
#

how can i get my plugin to draw stuff on an empty map ?

lost matrix
severe oracle
#
  • that map is in an item frame
restive tangle
#

how would i communicate from discord to minecraft and vise versa, more specifically if i type a command in minecraft how would i make it so my bot sends a message to a channel containing information about the message

worldly ingot
#

Assertions are super useful as means to ensure that code is working the way it should be working. For instance,

ItemStack item = new ItemStack(Material.STONE);
ItemMeta meta = item.getItemMeta();
assert meta != null;

meta.setDisplayName("Hello");
item.setItemMeta(meta);```
#

Perfectly valid and appropriate use of assert because that should never return null for anything that isn't air

#

If it does, it's the fault of the implementation. Which is what assert is for. It's to denote developer fault

lost matrix
#

Also known as "fail fast principle"

worldly ingot
#

Generally speaking you should be using assert on conditions that you know for certain should be true. If it's false, you know that either you or the implementation you're using fucked up

short shale
#

can someone help me to create a delay?

#
    \\ delay
}```
lost matrix
# short shale ```while() { \\ delay }```

Delays in spigot should be done with the scheduler.
If you block with a while loop your server just crashes because your code is ran consecutively on
the main thread.

ivory sleet
lost matrix
#

?scheduling

undone axleBOT
worldly ingot
#

I hate the use of requireNonNull for a few reason. (1) If you're in Bukkit context, you have Preconditions which are objectively better and more flexible. (2) It throws an NPE anyways instead of an IllegalArgumentException

severe oracle
lost matrix
worldly ingot
#

Validate

#

Though I think Preconditions > Validate in most cases tbh

lost matrix
#

^

ivory sleet
#

I just do it on instinct when I see nullable problems or smtng

worldly ingot
#

Well that's mostly where I use assert for getItemMeta() calls. It's included in null access

#

If you assert it's not null, your IDE won't kill you for trying to use it lol

ivory sleet
#

yeah I do it for getAttribute(GENERIC_MAX_HEALTH) when called on a player also

#

yup lol

worldly ingot
#

Another great place to use it, yeah

marble copper
#

please can someone tell me the placeholder api got a players name?

severe oracle
#

how can i draw on a map that is in an item frame ?

hasty prawn
#

Would anyone happen to know why if I call LivingEntity#damage(), in EntityDamageEvent the event.getDamage() is significantly lower?
I assumed maybe damage() was pre-calculating armor/resistances, but it doesn't seem to be doing that either.

marble copper
#

plae holder for a players name?

lost matrix
marble copper
lost matrix
marble copper
#

thnx

lost matrix
hasty prawn
#

Maybe, lemme see if I can find it.

restive tangle
severe oracle
#

how do i stop players from rotating things in item frames ?

lost matrix
severe oracle
#

i did

#

and setcanceled

#

and it didnt do it

opal juniper
#

Entities i am spawning in are being despawned when the player moves too far from them. I have tried the .setPersistent and also adding chunk loading tickets before i spawn them and then removing after i spawn them but it doesn't work - the zombies always despawn. Any ideas ?

lost matrix
hasty prawn
#

Doesn't actually seem to matter what that entity is either, the reduced is the same no matter what. Thonk

hasty prawn
#

1.17.1

lost matrix
#

Let me check that...

opal juniper
lost matrix
#

Did you check for potion effects or attribute mods?

hasty prawn
#

Really? Lemme update spigot and see if that does anything.

#

Wouldn't those apply to the regular damage too though?

lost matrix
#

I mean for the attacking entity.

hasty prawn
#

Oh, right now I'm just grabbing a random entity from the world.

#

I got a Bee, a Creeper and an Enderman KEKW

#

They all did the same damage

lost matrix
#

...

opal juniper
#

lol

hasty prawn
#

what LULW

#

I was too lazy to spawn in an entity to test with

opal juniper
#

...

is grabbing an entity not more lines thonk

hasty prawn
#

They're both technically 1 line I guess

#

Still angy

#

Yeah same thing even after updating to latest

hasty prawn
#

@lost matrix Found it, it's because the DamageSource is set to EntityDamageSource (as opposed to Generic), which scales with Difficulty. It was on Easy so it was reduced because of that. NOOO

manic bison
#

hey, i'm making a kill system (top kills) using a database. A table named kills contains player username and their kills. Is there a way to sort kills (integers) from highest to lowest and get the player name with it ?

#

i tried searching on the internet how to sort by ASC or DESC, but did not find how to bind a table value to highest

#

i hope its understandable

winged anvil
#

so ive created the worlds, an overworld dimensionm, a nether dimension, and end dimension using WorldCreator. How would I go about making sure when a player enters a portal in the new overworld world ive created, that it links and takes them to the new nether world/end world ive created

manic bison
#

so if a players enters a portal in a certain world, it teleports him to another world

#

use PlayerPortalEvent

winged anvil
#

yeah thats what i was thinking as well

waxen plinth
winged anvil
#

was juts wondering if there was an easier way

manic bison
#

and get the actual world name, and if one player enters a portal, and world name is X, teleport the plyer to world Y

waxen plinth
#

Create an index on the table in the kills column

#

And then you can just do SELECT name, kills FROM users ORDER BY kills DESC LIMIT 10 or something

manic bison
#

i'll try it. thanks a lot for helping

opal juniper
#

Why is Config#getFloat() not at thing?

hushed spindle
#

i guess because double and float are similar enough its not considered necessary?

opal juniper
#

but getFloatList is a thing

#

seems weird

hushed spindle
#

tf lol

#

yeah it is

opal juniper
#

There is probably a very good reason

#

hang on

opal juniper
#

sorry for ping

#

thought you would kno

#

and you were active a sec ago

hushed spindle
#

you're not entitled to answers

#

people ask questions and when people feel like it they answer

opal juniper
#

put a sysout immediately so that you know if it gets called

waxen plinth
#

I'm not 100% sure

#

But I know that I almost always use doubles over floats

opal juniper
#

yeah but what i want to know is why getFloatList is a thing

waxen plinth
#

And I know that's very common

#

Oh 🤔

#

I dunno that's really weird lol

opal juniper
#

lol

#

oh well

#

thanks

waxen plinth
#

Maybe use my config manager

#

I actually ran into a similar issue recently

#

Someone got an error because they were storing a float in config and it was always loaded as a double

#

The fix was pretty simple but it's an interesting issue

#

I wonder how it makes the distinction between an int and a long, it's a similar ordeal

patent horizon
#

is there a way i can check if a list contains a value that isn't case sensitive? or is .contains() already not case sensitive?