#help-development

1 messages · Page 2259 of 1

gritty urchin
#
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
            <version>3.0.6</version>
            <scope>compile</scope>
        </dependency>```
hardy crystal
#

and how can i do a verison control for my plugin (inform op player to update the plugin)?

lost matrix
#

Go ingame and click your mouse button really fast and then brag about your cps. Usually helps.

gritty urchin
#

maybe you'll be good at 1.8 pvp?

eternal oxide
lost matrix
quaint mantle
#

It still doesn't work.

lost matrix
daring lark
#

how to change player name above head?

tardy delta
#

teams or packets

hardy crystal
#

thanks

daring lark
#

ok so how could i do this with teams

#

i know that i can change name like global in a team

quaint mantle
#

Hello, I want to loop a .yml file. But:
List<ItemStack> bestellingenList = (List<ItemStack>) main.getSpelerbestelling().getList("Bestelling");
if(bestellingenList == null) bestellingenList = new ArrayList<>();

            for (ItemStack bestelling : bestellingenList) {
                bestellingen.addItem(bestelling);
            }

doesn't seem to work.
Anybody know why?

undone axleBOT
#

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

daring lark
quaint mantle
#

I am adding a head to a .yml file what works but if I try to add it in a inventory it doesn't work.

undone axleBOT
quaint mantle
#

There is no error btw.

tardy delta
#

is 'you unvanished' english lol

lost matrix
quaint mantle
#

Alr

crimson terrace
#

and everyone would understand it so its a word now, your fault.

lost matrix
#

You mean if you try unsoft enough

tardy delta
#

bruh

crimson terrace
#

if you try desofted enough, yeah

quaint mantle
#

Oh f its away

#

gone(

lost matrix
quaint mantle
#

?paste

crimson terrace
undone axleBOT
quaint mantle
#

Here is the code

lost matrix
quaint mantle
#

It isn't even getting executed

#

bruh

#

Thx

dawn plover
#

if this is my .yml how would i do .getKeys() inside myMap
so i would get a list<string> with [number1,number2,number3]

lost matrix
lost matrix
quaint mantle
#

Oh yeah I see it

#

Oh nvm I still don't get it

#

uuh

#

lemme see

#

?paste

undone axleBOT
quaint mantle
lost matrix
eternal needle
#

this do so i make that when some one is in the invisible_list then thay can't pick up things?

@EventHandler
private void Pickup(PlayerPickupItemEvent e){
    Player player = e.getPlayer();
    for (int i = 0; i < plugin.invisible_list.size(); i++){
        e.setCancelled(true);
    }
}
tardy delta
#

wut

#

use a Set<UUID> instead

#

and use ::contains

eternal needle
#

me?

tardy delta
#

yes

eternal needle
#

forget it i did fix it

minor garnet
#

Can anyone explain to me how projectile damage works? in the case of a bow if a player is wearing armor, the damage will be, or if the armor is enchanted

quartz basalt
#

sorry to bother you but did you find anything?

lost matrix
lost matrix
quartz basalt
#

ah alright

minor garnet
tardy delta
#

duplicated code smh

#

anyways is Collection#toArray(Type[]::new) gonna infer the size for the array?

eternal night
#

yes

#

or well

#

might

#

iirc the default Collection#toArray thing just creates it with size 0 ?

#

but JIT already fixes that anyway

tardy delta
#

oh well it uses an infunction, i thought the signature was T[] toArray(Supplier<T[]>)

#

so it infers the size via that i guess

#

smh cat go off my keyboard

#

nb;

#

stupid cat

eternal night
#

iirc, toArray(new int[0]) is/was faster than toArray(new int[size]) anyway

tardy delta
#

hmm

quartz basalt
#

i have
fb.setVelocity(targetLocation.getLocation().toVector().subtract(baseLocation.getLocation().toVector()).normalize());
targetlocation is the location the blocks should be going to and baselocation is the location the blocks spawn at, both the locations are taken from the position of these armorstands in this picture
https://imgur.com/a/462PQjL
the bottom one is the base top is target, the green arrow is what the falling blocks are doing and the red arrow is where they should be going, x and z works fine but the y axis doesnt go any higher then in the pic

dense crow
#

okay i need help, im trying to save mulitple locations in a file for 1 person, how can i do that?

mystic vale
tardy delta
#

or a key value thing

dense crow
#

yeah, but how should i put them in a list, never worked that much with lists bc strings are easier to handle

tardy delta
#

there is a FileConfiguration#getList

lost matrix
mystic vale
lost matrix
tardy delta
#

not even via a getter

river oracle
#

Please learn syntax at the absolute least

mystic vale
#

I'm learning java, I'm not an expert

river oracle
#

Me either but syntax is basic level

sudden violet
#

So i'

#

oops

daring lark
#
        Entity died = e.getEntity();
        Player player = e.getEntity().getKiller();
        String playerId = player.getUniqueId().toString();
        if(!(died instanceof Monster)) {
            player.sendMessage("Dada");
        }
    }```
#

error:

java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.getUniqueId()" because "player" is null
        at me.placek.levelrpg.listeners.EntityDeathListener.combatHandler(EntityDeathListener.java:29) ~[levelRPG.jar:?]        at me.placek.levelrpg.listeners.EntityDeathListener.onEntityDie(EntityDeathListener.java:22) ~[levelRPG.jar:?]```
#

so how could i get killer of entity?

lost matrix
mystic vale
lost matrix
#

Yes. Because the line above will throw a Nullpointer if the entity was not killed by a player.

lost matrix
mystic vale
#

ok

sudden violet
#

I'm working on this core library, and need a way to grab an instance of the core plugin. The ol' core = (AxiusCore) getServer().getPluginManager().getPlugin("AxiusCore");

Up until recently that was working fine, but then it began crashing with an NPE.
I tried switching over to the service manager;

from AxiusCore.java
getServer().getServicesManager().register(AxiusCore.class, instance, this.getJavaPlugin(), ServicePriority.High);

from AxiusPlugin.java

List<RegisteredServiceProvider<?>> providers = getServer().getServicesManager().getRegistrations(Bukkit.getPluginManager().getPlugin("AxiusCore"));
        core = (AxiusCore) providers.get(0).getProvider();

So far, so good. the plugin utilising the core finds what im looking for, but i keep getting an error saying i cant cast AxiusCore to AxiusCore;

 Error occurred while enabling GUIHomes v1.2.1 (Is it up to date?)
java.lang.ClassCastException: class uk.co.benkeoghcgd.api.AxiusCore.AxiusCore cannot be cast to class uk.co.benkeoghcgd.api.AxiusCore.AxiusCore (uk.co.benkeoghcgd.api.AxiusCore.AxiusCore is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @760ac762; uk.co.benkeoghcgd.api.AxiusCore.AxiusCore is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @32e8e121)
        at uk.co.benkeoghcgd.api.AxiusCore.API.AxiusPlugin.onEnable(AxiusPlugin.java:234) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:518) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3486-Spigot-b6d12d1-f3c7a6a]
        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:432) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3486-Spigot-b6d12d1-f3c7a6a]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3486-Spigot-b6d12d1-f3c7a6a]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3486-Spigot-b6d12d1-f3c7a6a]
        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:263) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3486-Spigot-b6d12d1-f3c7a6a]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1007) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3486-Spigot-b6d12d1-f3c7a6a]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3486-Spigot-b6d12d1-f3c7a6a]
        at java.lang.Thread.run(Thread.java:833) [?:?]

Any ideas?

river oracle
#

You can't cast an object to a class directly iirc

wind tulip
#

does BossBar#addPlayer display it at the top or bottom of the screen (when you have multiple bossbars active already)

lost matrix
lost matrix
wind tulip
#

so towards the bottom

#

alright

sudden violet
river oracle
#

That would be it's not loading before you get it

sudden violet
#

the RSP registry runs from the constructor too, and that returns an object

river oracle
#

So your trying to retrieve the instance before its initialized

radiant umbra
#

And how do I do that?

sudden violet
lost matrix
lost matrix
radiant umbra
#

alr, ty

small current
#

there is a repo like this
how can i update the 25 commits on a localy clowned repo of the fork ?

tardy delta
#

?plugin.yml

worldly ingot
#

Heh. Clowned

river oracle
worldly ingot
#

You'll have to rebase your commits onto the base branch

#

Though this is generally why it's advised to make commits to a new branch when forking an active repository

small current
#

but its old

#

kinda

radiant umbra
small current
#

how can i update the 26 commit to it

lost matrix
quartz basalt
#

if an entity has a passenger can you not modify the rotation of the passenger?

#

also will the passengers rotation change with the parent entity?

sudden violet
#

Still nothing.
And to answer questions; Yes, i have the plugin depended. I also get the same casting error when i use the regular core = (AxiusCore) getServer().getPluginManager().getPlugin("AxiusCore");

radiant umbra
fleet comet
#

Hey! I'm making an addon system for my plugin
I came up with some steps for the addon system

  1. The base plugin will be loaded and checks for JARs inside its addon folder
  2. The base plugin loads all JARs inside the addon folder (Java deserialization / Java class loader / Java stuff somehow...)
  3. The base plugin executes a main method of the addon, so the addon can handle its stuff (all addons must provide a main method, so the base plugin could invoke it by reflection)
  4. The addon registers its events
  5. Communication between both plugins given by direct references (maybe the base plugin passes its instance to the addon constructor)
    Disadvantage: The addon needs to hook deeply to register it's own commands, since the addon itself is not a plugin and has no plugin.yml and gets not loaded by Spigot

I've coded most of the stuff, I just can't figure out to complete steps 4 and 5, I think I should pass a instance of the base plugin to the addon, but I'm not sure how.
Help would be greatly appreciated

eternal oxide
#

as you never numbered anythign we don't know what steps 4 and 5 are

fleet comet
#

Sorry, i've changed it

eternal oxide
#

teh addon has access to Bukkit via the main plugin so it can register it's own Listeners

dense crow
drifting halo
#

the way i handle addons is by having it implement a specific interface and adding it to the main plugins classloader and then once thats done you can just do your logic like you normally would

sudden violet
# fleet comet Hey! I'm making an addon system for my plugin I came up with some steps for the ...

https://github.com/BenKeoghCGD/AxiusCore/blob/PRODUCTION/uk/co/benkeoghcgd/api/AxiusCore/AxiusCore.java

Take a look at how i register other plugins within my own plugin. The way i register commands can be easily manipulated to register just about anything from the main script

GitHub

A super light-weight plugin development API, used to ease the hastle of some common development hurdles. - AxiusCore/AxiusCore.java at PRODUCTION · BenKeoghCGD/AxiusCore

drifting halo
#

are those addons full plugins?

fleet comet
sudden violet
#

huge facepalm ik

#

works tho

#

I have a commit to make for code cleanup tbf

lost matrix
drifting halo
#

oh yeah it needs some more fine tuning

#

but since i'm the only one bothering making them

#

¯_(ツ)_/¯

lost matrix
#

If you have RandomAddon on your classpath then you can as well make it compile time safe with RandomAddon.class.get...()

drifting halo
#

hmm right, i'll take a look at that

#

the whole plugin could use some love tbh

lost matrix
# sudden violet works tho

It works until someone else tries to use this.
What happens if someone just does this:

AxiusCore.registeredPlugins.add(new TestPlugin());

Is the plugin then enabled?
Or if they are funny they can just do this:

AxiusCore.registeredPlugins.clear();

Not encapsulating is just purposefully sabotaging your codes robustness.

drifting halo
daring lark
#
        this.exp += exp;
        Player player = Bukkit.getPlayer(UUID.fromString(playerId));
        player.sendMessage(LevelRPG.getPrefix() + ChatColor.GREEN + "Zdobyłeś " + ChatColor.YELLOW + exp + ChatColor.GREEN + " punktów doświadczenia w walce.");
        if(exp >= expNeeded) {
            levelUp();
        }

    }```
drifting halo
#

currently i just say fuk it and stated that new versions dont work before that commit, but i'd like at least some backward compat

daring lark
#

error:

        at java.util.UUID.fromString(UUID.java:237) ~[?:?]
        at me.placek.levelrpg.skills.skillManager.SkillManager.addExp(SkillManager.java:56) ~[levelRPG.jar:?]
        at me.placek.levelrpg.listeners.EntityDeathListener.combatHandler(EntityDeathListener.java:42) ~[levelRPG.jar:?]
        at me.placek.levelrpg.listeners.EntityDeathListener.onEntityDie(EntityDeathListener.java:25) ~[levelRPG.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor591.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]```
fleet comet
# drifting halo then an addon can look something like this: <https://github.com/DarkEyeDragon/Ra...

regarding that, im doing it differently i think

try {

     URLClassLoader loader = new URLClassLoader(new URL[] { myJar.toURI().toURL() },
             CustomClass.class.getClass().getClassLoader());

     Class classToLoad = Class.forName("org.plugin.addons.addon", true, loader);
     System.out.println(classToLoad);
     Method method = classToLoad.getDeclaredMethod("helloWorld");
     Object instance = classToLoad.newInstance();
     Object result = method.invoke(instance);

 } catch (MalformedURLException | ClassNotFoundException | NoSuchMethodException | SecurityException
         | InstantiationException | IllegalAccessException | IllegalArgumentException
         | InvocationTargetException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
 }
``` I'm using this code to invoke a method on an external jar file. That was a previous step. How could i give an instance of my plugin when accessing that method?
sudden violet
lost matrix
daring lark
fleet comet
lost matrix
drifting halo
quaint mantle
#

So in my plugin I load a players data when they join and I save it when they leave through MongoDB, but with this if the server crashes it rolls everybody back because it can’t save them. Is there a way to make it so I can detect if the server thread has crashed and if it has save the player.

daring lark
drifting halo
#

oh nvm thats minecraft version 🤦‍♂️

drifting halo
lost matrix
small current
#

guys when a block gets broken or changed to air, if a pressure plate is on it it will drop
how can i cancel the drop in 1.8.8 ?

#

there is no BlockDropItemEvent

fleet comet
small current
#

if someone says update

lost matrix
small current
#

i will block them

drifting halo
quaint mantle
quaint mantle
quaint mantle
drifting halo
#

best thing to do is periodically save

small current
#

ok so ahh
anyone helping ?

fleet comet
#

i-

lost matrix
#

Its not an opinion. Using ancient software is an unintelligent choice. Thats factual.
And i find it extraordinarily rude that you suggest suicide as a result of stating this fact.

small current
#

ok

#

and

quaint mantle
small current
chrome beacon
#

You can disable the new pvp

drifting halo
small current
fleet comet
lost matrix
small current
#

i once done this disable new pvp thing

lost matrix
#

You wont even notice it

small current
#

and ate all my ram because new software fancy
new software more usage

river oracle
#

Make it efficient then

small current
#

i guess if you know, you can help me im being asked to code the plugin in 1.8.8

drifting halo
# fleet comet I didn't see that, could you explain it?
@Override
public boolean isValid(RandomLocation randomLocation) {
    //TODO this is a dirty hack since the addon manager is only set after instantiating the addon so it cannot be done in the constructor.
    if (plugin == null) {
        plugin = ((RandomTeleport) getAddonManager().getInstance()).getPlugin();
        landsIntegration = new LandsIntegration(plugin);
    }
    return !landsIntegration.isClaimed(WorldUtil.toLocation(randomLocation));
}

basically set the instance of your plugin when you construct the addon, then have a method to retrieve it

tardy delta
small current
#

if you are gonna pay me the amount im getting paied

#

then ok i will use 1.17

#

for a pvp minigame plugin

#

now if you know help, how can i cancel the thing

lost matrix
#

You can run a server with 1.17 and softlock it so only 1.8 clients can connect

quaint mantle
#

quick question: is it possible to use reflection to copy an Event bukkit class while also preserving its values ?

lost wolf
#

How can you change the behaviour of a particle?

ivory sleet
#

Cuz reflection is mainly invocation, and class scanning

small current
#

that is just one of 5 lobbies

drifting halo
#

@fleet comet

/**
 * @param clazz the {@link Class} to instantiate. Must extend {@link RandomAddon}
 * @return the {@link } {@link RandomAddon} instance.
 */
protected final RandomAddon createAddonInstance(Class<? extends RandomAddon> clazz) throws ReflectiveOperationException {
    RandomAddon randomAddon = clazz.getConstructor().newInstance();
    randomAddon.setAddonManager(this);
    return randomAddon;
}

i do it like this, but i'm sure theres better ways

small current
#

i don't have time for this 1.8 argue

#

when a block gets broken or changed to air, if a pressure plate is on it it will drop
how can i cancel the drop in 1.8.8 ?

lost matrix
river oracle
#

Check the block above if pressure plate set air

pine lake
#

Hello, I'm new at development of plugins. How can I get the world from the Server class?

small current
drifting halo
#

i just dont mention i work with ancient versions and hope it still applies

small current
#

if you continue

#

i will kindly block you

fleet comet
drifting halo
#

yeah

dense crow
drifting halo
quaint mantle
# ivory sleet Uh elaborate

like given an event (ex: InventoryClickEvent, Event extended classes, PlayerJoinEvent), is it possible to use reflection to duplicate this class during @EventHandle section? and be able to refer to it in future in time even after that event has been fired/cancelled since it might be async/sync?

pine lake
fleet comet
lost matrix
river oracle
river oracle
#

For world name

ivory sleet
#

I’m very baffled

dense crow
#
public static boolean setLocation(String frak, Location loc) {
        cfg.set(frak + ".world", loc.getWorld().getName());
        cfg.set(frak + ".x", loc.getX());
        cfg.set(frak + ".y", loc.getY());
        cfg.set(frak + ".z", loc.getZ());
        try {
            cfg.save(f);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return true;
    }

thats it, the only one i got working bc the list ones require that im using arraylist on the location itself too

small current
dense crow
#

dont harass me

river oracle
#

I know how yo duplicate a class

.clone or new

#

Boom

lost matrix
ivory sleet
#

That duplicates/instantiates an instance but that might just be what they mean

small current
tardy delta
drifting halo
small current
#

the whole block

#

?

lost matrix
quaint mantle
pine lake
small current
lost matrix
drifting halo
fleet comet
#

yeah

lost matrix
drifting halo
fleet comet
drifting halo
#

accidentally removed it

#

a better scenario would be where you just pass the AddonManager or plugin instance in your case in the constructor of the addon, but i dont think an interface can enforce that

lost matrix
tardy delta
#

he was trying to set a list of locations or smth

drifting halo
#

hope that helps, i'll be afk for a bit but feel free to ping me if you have other questions

lost matrix
tardy delta
#

ye i know

#

tell that to him

#

:)

quartz basalt
#
                        p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 100000, 1));
                        p.sendMessage(ChatLib.t("&7[&a+&7] Night vision enabled"));

                    }
                    else {
                        p.removePotionEffect(PotionEffectType.NIGHT_VISION);
                        p.sendMessage(ChatLib.t("&7[&a+&7] Night vision disabled"));
                    }``` why doesnt this work? it gives me night vision fine but when i run the command when i have night vision it still tries to give me night vision
lost matrix
hardy crystal
#
[17:24:03 WARN]: [Roleplay Utilities] Could not submit bStats metrics data
java.io.IOException: Server returned HTTP response code: 429 for URL: https://bStats.org/api/v2/data/bukkit
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1997) ~[?:?]
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589) ~[?:?]
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224) ~[?:?]
    at org.manfry.roleplayutilities.MetricsBase.sendData(MetricsBase.java:196) ~[?:?]
    at org.manfry.roleplayutilities.MetricsBase.lambda$submitData$4(MetricsBase.java:161) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
    at java.lang.Thread.run(Thread.java:833) [?:?]```
#

anyone can help me whit bstats?

lost matrix
ivory sleet
#

lol

eternal oxide
#

you should send ONE at startup

hardy crystal
#

?paste

undone axleBOT
lost matrix
#

You might be sharing an IP Address with a lot of other people. Do you use a VPN?

eternal oxide
#

did you put your own plugin ID in your startup and not use teh default?

lost matrix
# hardy crystal no

Well then either wait for some time or use one. This code doesnt look like it should be rate limited.

left swift
#

How can I inject my own arguments into the minecraft command like /summon?

dense crow
lost matrix
chrome beacon
lost matrix
left swift
#

I mean I register my custom entity type, and It works with /summon good, but I want to add it to the arguments list

lost matrix
river oracle
#

I found a writable registry in nms idk what it's for though

dense crow
left swift
chrome beacon
river oracle
#

Maybe try looking at the WritableRegistry 🤷‍♂️

lost matrix
chrome beacon
#

All of them iirc

left swift
#

yes

lost matrix
#

hmm interesting

left swift
#

Yea, but with plugin you can unfreeze it

dense crow
lost matrix
dense crow
#

its from a Event with event.getClickedBlock.getLocation

lost matrix
lost matrix
raw sky
#

what kind of features would be useful in a lib?

ivory sleet
#

I mean mostly framework classes that aim to abstract repetitive patterns you want to avoid writing every time

lost matrix
# raw sky what kind of features would be useful in a lib?

There is no real limit. But here are some suggestions:

  • GUIs
  • Holograms
  • IO support
  • Serialization
  • Language support
  • Persistent Block data storage
  • Task and scheduling utility
  • ItemBuilder is a big one
  • Getting player input through signs, chat, anvils etc
  • Custom head api
  • Generally a bunch of util classes

Basically everything you would copy/paste into every new plugin.

raw sky
#

oh boy thats a lot

#

ok yea I can work on that, ty both! Dont know if I should make my own api or fork a api like Red Lib

marble copper
#

How do I make it so staff can't see ip from console?

lost matrix
#
  • Custom recipe api
  • Clickable message bridge api
  • enchantment api
  • Custom item usils
  • Region api
  • multiblock structures
  • nms helpers
dense crow
#

okay now it throws out just nothing, in intellij or in console nothing, and nothing in file

raw sky
#

ooh even more ok

dense crow
#

is there something wrong in this? ```java
public static boolean setLocation( Location loc, String frak) {
List<Location> locations = new ArrayList<>();
locations.add(loc);
FileConfiguration config = YamlConfiguration.loadConfiguration(f);
config.set(frak, locations);
locations.remove(loc);
try {
cfg.save(f);
} catch (IOException e) {
e.printStackTrace();
}
return true;
}

ivory sleet
#

Looks expensive (2 io calls)

lost matrix
eternal oxide
#

you read from config but save cfg

dense crow
#

so read from cfg and save with cfg would fix that?

#

OHHH

#

im a idiot

ornate patio
#

I've tried this already, the chunk stays loaded but it is not ticking (my horse does not pathfind)

dense crow
#

argh no

lost matrix
dense crow
lost matrix
dense crow
#

yep, but my dumb brain wont tell me what i have to put behind the = at the list<location> locations

#

actually im pretty lost with that as my heads smoking since 4 hours bc of that lol

lost matrix
#

Yes that one.
So all he has to do is override the inactiveTick() with his usual tick method.

eternal oxide
#

So all neighboring chunks have to be loaded for a chunk to tick

ornate patio
#

hm?

ornate patio
eternal oxide
#

try it and see

ornate patio
#

do I put this in my custom horse entity?

#
@Override
public void inactiveTick() {
    super.inactiveTick();
    super.tick();
}
lost matrix
#
@Override
public void inactiveTick() {
    this.tick();
}
ornate patio
#

isn't there extra stuff that is run in super.inactiveTick() though

#

and also I haven't really overriden the tick method, I've just added many pathfinder goals. you think the pathfinding will still work fine?

crude loom
#

How do I put spaces in a config?

golden turret
#

how can i check if an item can fit in an inventory?

ornate patio
eternal oxide
#

Not easily. The lazy way, copy the inventory, add the items and check the return map to see if its empty.

lost matrix
golden turret
#

but i cant add the item

#

i just need to check

lost matrix
#

Cant you just drop the overflown items to the players feet?

golden turret
#

no

#

i can just check

tardy delta
#

smth like inv.addItems(item).values().isEmpty()?

golden turret
#

my goal is only to check

golden turret
#

i dont want that

tardy delta
#

oh checking

golden turret
#

i would like something simple like inventory.canFit(item)

lost matrix
#

Is it ok for it to be very expensive?

golden turret
#

i will consider

#

but sent it anyways

ornate patio
#

what would be an efficient way to add plugin chunk tickets to chunks around a horse as it moves around, while also remove plugin chunk tickets when it moves away from added ones

quaint mantle
#

]: Error occurred while enabling DeepSmpPlugin v1.0-SNAPSHOT (Is it up to date?)
java.lang.IllegalArgumentException: Crafting recipes must be rectangular
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-31.0.1-jre.jar:?]
at org.bukkit.inventory.ShapedRecipe.shape(ShapedRecipe.java:72) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at deepsmpplugin.deepsmpplugin.Main.onEnable(Main.java:39) ~[DeepSmpPlugin-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:536) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:561) ~[paper-1.19.jar:git-Paper-41]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:475) ~[paper-1.19.jar:git-Paper-41]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:633) ~[paper-1.19.jar:git-Paper-41]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:419) ~[paper-1.19.jar:git-Paper-41]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[paper-1.19.jar:git-Paper-41]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1121) ~[paper-1.19.jar:git-Paper-41]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:302) ~[paper-1.19.jar:git-Paper-41]

#

there's something wrong

lost matrix
lost matrix
ornate patio
#

hmm that'll involve math

#

alright

quaint mantle
ancient plank
#

use pastes or codeblocks (```) for large stack traces

undone axleBOT
ornate patio
#

how do I check if it moves over a border? Should I just keep track of the last position the horse was in and see if a chunk border is in between the last position and the current position?

grim ice
#

https://paste.md-5.net/idesisuvus.xml
help im getting
Cannot resolve commons-lang:commons-lang:2.6

Cannot resolve me.tigerhix.lib:scoreboard:1.0.1-SNAPSHOT

Cannot resolve org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT

Cannot resolve com.google.guava:guava:21.0

Cannot resolve org.yaml:snakeyaml:1.27

Cannot resolve com.google.code.gson:gson:2.8.0

Cannot resolve net.md-5:bungeecord-chat:1.16-R0.4

tardy delta
#

mvn reload?

golden turret
#

i guess i will just copy the logic from addItem but instead of setting items in the inventory, i will set them in a map

lost matrix
grim ice
#

same thing @tardy delta

#

help holy shit this is annoying

grim ice
#

i even cleared cache and restarted

tardy delta
#

does it show errors in your pom?

grim ice
#

yes

ornate patio
#

why does that work i mean

lost matrix
grim ice
#

bro it doesnt even let me import

#

forget building

weak wasp
#

I dislike these remote build systems for this very reason

lost matrix
quaint mantle
#

]: Error occurred while enabling DeepSmpPlugin v1.0-SNAPSHOT (Is it up to date?)
java.lang.IllegalArgumentException: Crafting recipes must be rectangular
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-31.0.1-jre.jar:?]
at org.bukkit.inventory.ShapedRecipe.shape(ShapedRecipe.java:72) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at deepsmpplugin.deepsmpplugin.Main.onEnable(Main.java:39) ~[DeepSmpPlugin-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:536) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:561) ~[paper-1.19.jar:git-Paper-41]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:475) ~[paper-1.19.jar:git-Paper-41]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:633) ~[paper-1.19.jar:git-Paper-41]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:419) ~[paper-1.19.jar:git-Paper-41]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[paper-1.19.jar:git-Paper-41]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1121) ~[paper-1.19.jar:git-Paper-41]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:302) ~[paper-1.19.jar:git-Paper-41]

#

SHIT WRONG ONE

tardy delta
#

delete it then if its wrong

#

?paste is a thing too

undone axleBOT
grim ice
#

Failure to transfer me.tigerhix.lib:scoreboard:1.0.1-SNAPSHOT/maven-metadata.xml from http://repo.tigerhix.me/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of tiger-repo has elapsed or updates are forced. Original error: Could not transfer metadata me.tigerhix.lib:scoreboard:1.0.1-SNAPSHOT/maven-metadata.xml from/to tiger-repo (http://repo.tigerhix.me/content/repositories/snapshots/): Transfer failed for http://repo.tigerhix.me/content/repositories/snapshots/me/tigerhix/lib/scoreboard/1.0.1-SNAPSHOT/maven-metadata.xml

lost matrix
grim ice
#

and many similar errors

tardy delta
#

tf have you been doing lol

grim ice
#

ffs

quaint mantle
#

ItemStack CustomItem1 = new ItemStack(Material.NETHERITE_AXE);
ItemMeta meta = CustomItem1.getItemMeta();
meta.setDisplayName(ChatColor.GRAY + "Random!");
meta.addEnchant(Enchantment.DIG_SPEED, 6, true);
meta.addEnchant(Enchantment.DURABILITY, 5, true);
meta.addAttributeModifier(Attribute.GENERIC_LUCK, modifer);

    ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, "Random"), CustomItem1);
    recipe.shape(" NN"," SN"," S");
    recipe.setIngredient('N', Material.NETHERITE_INGOT);
    recipe.setIngredient('S', Material.STICK);

    Bukkit.addRecipe(recipe);
#

should work ?

tardy delta
#

use code blocks please```java
stuff

lost matrix
tardy delta
#

bruh

grim ice
#

i wanna use scoreboardlib tho

lost matrix
grim ice
#

the fuck do i do

#

and i even tried with jitpack

quaint mantle
#

where ?

tardy delta
#

" SN"

#

ig

quaint mantle
#

no

lost matrix
fleet comet
#

@drifting halo hey so heres my code for the addon

package org.cloud.addon;

import org.eternitystudios.plugins.cloud.Cloud;

public class Addon {

    Cloud instance;

    public Addon(Cloud instance) {
        this.instance = instance;
    }

    public void addonMain() {
        instance.server
    }
}
fleet comet
#

And heres the addonmanager class ```java
package org.eternitystudios.plugins.cloud.utils;

public class AddonManager {

Cloud instance;

public AddonManager(Cloud instance) {
    this.instance = instance;
}

public void registerAddons() {
    File [] files = instance.af.listFiles();
    for (File file : files) {
        if (file.isFile()) { // this line weeds out other directories/folders
            if (file.getName().endsWith(".jar")) {
                registerJAR(file);
            }
        }
    }
}

public void registerJAR(File jar) {
    try {

        URLClassLoader loader = new URLClassLoader(new URL[] { jar.toURI().toURL() },
                Cloud.class.getClassLoader());

        Class classToLoad = Class.forName("org.cloud.addon.Addon", true, loader);

        System.out.println(classToLoad);
        Class<?>[] type = {Cloud.class};
        Object instance = classToLoad.newInstance();
        Constructor<?> cons = classToLoad.getConstructor(type);
        Object newInstanceObj = cons.newInstance(instance);
        Method method = classToLoad.getDeclaredMethod("addonMain");
        Object result = method.invoke(instance);

    } catch (MalformedURLException | ClassNotFoundException | NoSuchMethodException | SecurityException
             | InstantiationException | IllegalAccessException | IllegalArgumentException
             | InvocationTargetException e) {
        // TODO Auto-generated catch block
        if (instance.getConfig().getBoolean("debugMode")) e.printStackTrace();
        Bukkit.getLogger().warning("Could not load addon " + jar.getName());
    }
}

}

lost matrix
fleet comet
#
package org.eternitystudios.plugins.cloud;

import org.bukkit.Server;
import org.bukkit.plugin.java.JavaPlugin;
import org.eternitystudios.plugins.cloud.utils.AddonManager;

import java.io.File;

public final class Cloud extends JavaPlugin {

    public File af;
    public AddonManager addonManager;
    public Server server;

    public Cloud() {
    }

    @Override
    public void onEnable() {
        // Set server
        server = getServer();

        // Save config
        saveDefaultConfig();

        // Instantiate addonManager
        addonManager = new AddonManager(this);

        // Save addons folder if It's not there.
        String configPath = getDataFolder().getAbsolutePath();
        File addonFolder = new File(configPath);
        af = addonFolder;
        if (!addonFolder.exists()) addonFolder.mkdir();

        // Start searching for addons
        addonManager.registerAddons();
    }





    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }
}
``` this is the main plugin
quaint mantle
#

lol

fleet comet
#

on the addon, i cant access any of the server functions, how can i fix this?

grim ice
#

i hate maven

dim palm
#

the best way to do a damage is *, + or /?

lost matrix
dim palm
#

i don't know

#

i think multiply will instantkill the player

#

or no?

fleet comet
#

depends??

ivory sleet
#

Depends on the operands

lost matrix
ivory sleet
#

I mean if you send in a value that is smaller than 1 the damage would effectively decrease

fleet comet
ivory sleet
#

:>

ancient plank
#

use pastes angystomp

tardy delta
#

people wont listen

#

🥺

fleet comet
lost matrix
#

multiply by 1/(2* sin(x))
Sometimes you do 50% damage and sometimes you do 1000000% damage

crude loom
#

Any idea as to why does my config get extra spaces automatically?

vast musk
#

is there anything like the new /place feature command in spigot?

grim ice
#

BRO WHAT THE FUCK

#

IM USING A COMPLETELY DIFFERENT LIB

#

AND THIS ERROR

#

IS STILL FOLLOWING ME

quaint mantle
#

So you're the problem

ivory sleet
#

IntelliJ trolling you then probably lol

hoary knoll
#

will a chunk automatically unload when a plugin chunk ticket is removed?

#

as in unload as normal

quaint mantle
#

Probably 5 minutes to despawn

lost matrix
weak wasp
#

link an offline lib

hoary knoll
#

ok thanks

bold bough
#

Hello, hi to create config file to my plugin?

quaint mantle
#

?configs

undone axleBOT
lost matrix
bold bough
ivory sleet
#

(:

quaint mantle
#

Whos ready to fall some guys??!

chrome beacon
quaint mantle
grim ice
#

imma restart intellij one more time

quaint mantle
#

?workdistro

tardy delta
#

stumble guys 🥺

grim ice
#

if it doesnt work

weak wasp
grim ice
#

im going to

#

fucking

#

kill whoever made iintellij

quaint mantle
weak wasp
#

download is done once

#

you build

lost matrix
weak wasp
#

offline is just a work around it doesn't actually fix the current build setup

ivory sleet
#

IntelliJ yields some pretty interesting (to the fucking extreme extent irrelevant as well) issues when you have slight mistakes in your setup occasionally

golden turret
fleet comet
#

Need help with reflection and spigot and addons

ivory sleet
golden turret
#

not exactly

ivory sleet
#

Then wym by improve?

#

Performance wise?

golden turret
#

i would like to know if it is possible to avoid the array creation, for example

ivory sleet
#

Exactly where? Or everywhere?

golden turret
ivory sleet
#

Okay so not the var arg

#

Since that also does array stuff under the hood

golden turret
#

let it there

ivory sleet
#

Aight

#

But well, if you have to use Inventory::getContents, then you can’t avoid that array

golden turret
#

i actually need it

#

because the method uses ItemStack#setAmount

#

and i would like to not edit the items in the inventory

ivory sleet
#

Don’t think getContents return the actual view tho

#

So you don’t need to clone, or maybe Im mixing things up now

golden turret
#

let me see

ivory sleet
#

Yeah check the impl (:

golden turret
#

yea

#

it seems not to be the acutal items

ivory sleet
#

Thats good

golden turret
#

actually

#

it is

ivory sleet
#

Oh that’s less ideal

golden turret
#

and it set everything to 1

ivory sleet
#

Ah

#

What a shame

tardy delta
#

people dont know that you can iterate over the inv 😳

golden turret
#

i do

tardy delta
#

im now implementing Iterable on all my repo stuff kekw

#

no longer exposing collections

ivory sleet
#

That’s solid design

golden turret
#

collections

tardy delta
#

are

#

lmao founds bugs in my old code

#

makes sense i havent tested it

dense shoal
#

I have an EventHandler looking at BlockBreakEvent in which I want to check if any of the drops of a block broken are an ore (ie gold ore or diamond ore or iron deepslate ore). I was looking for some kind of interface that was implemented somewhere so I could check instanceof ore or something, but it looks like that isn't an option for my use case.

Right now, I just have a big case statement for all the ores, but as Mojang updates, I'm going to inevitably need to update said case statement.

That lead me to the Tag class (https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Tag.html) where I think I might be finding a solution to this by checking if the drop has a tag of STONE_ORE_REPLACEABLES or DEEPSLATE_ORE_REPLACEABLES. However, I saw this note which is giving me some pause:

" * Represents a tag that may be defined by the server or a resource pack to

  • group like things together."

Does anyone have a more clever way to check if a material or item stack is an ore like gold ore, coal ore, nether quartz ore, etc?

#

I might be completely in the wrong direction because this seems to be doing something with resource packs.

tardy delta
dense shoal
#

That's so cursed lol

lost matrix
lost matrix
# dense shoal That's so cursed lol
  private static final Set<Material> ORES = Arrays
          .stream(Material.values())
          .filter(mat -> mat.toString().contains("_ORE"))
          .collect(Collectors.toSet());

stream, filter, reduce

ornate patio
#

that _ is important

waxen plinth
#

The pattern never dies

lost matrix
quaint mantle
#

Surprised there isnt a Tag.ORE

bold bough
#

Can anyone help me set up the config in my plugin?

dense shoal
quaint mantle
#

the method above

lost matrix
#

?configs

undone axleBOT
quaint mantle
#

😐

ornate patio
#

or actually idk how this would work if there are multiple horses next to each other

drifting halo
fleet comet
drifting halo
#

👍

fleet comet
paper viper
#

Send it here 🙂

quaint mantle
#

It would be nice if you linked one in your profile

tardy delta
#

450 lines for vanish command now aaaa

paper viper
#

I’m on vacation in the middle of the desert oh a phone but I’ll still look

grim ice
#

how to shade a dependency

drifting halo
fleet comet
tardy delta
#

oeh can i have dessert too?

#

smh he edited it

fleet comet
paper viper
#

3G 3 bars data lmao

quaint mantle
#
import java.lang.*;

class ${
java.lang.Void To_String($ this,
Character... Characters )
{
        for (Integer CurrentIndex = new Integer(0);
CurrentIndex < Characters.length;
CurrentIndex += new Integer(1)
)
{

                java.lang.System
                    .out
                    .println(Arrays
.asList(Characters).
get(CurrentIndex))
;}
grim ice
#

how to shade a maven dependency

tardy delta
#

$ this?

grim ice
#

what

ivory sleet
#

Receiver parameter

grim ice
#

im using this

#

and its telling me to shade it

tardy delta
#

Cannot resolve symbol '$' :(

dense shoal
#

Any result from an ore?

tardy delta
#

oh god

fleet comet
grim ice
#

the zero >:(

tardy delta
#

i need internal methods aaa

quaint mantle
#

𝘚 = 𝓀ᵦ ln Ω

verbal dagger
#

i have a simple problem with coding my plugin. so i want to make it so when i leave a server i get deop automatically. I already coded the onLeave listner just need the deop string

tardy delta
#

🤔 = 1

grim ice
#

event.getPlayer().setOp(false);

verbal dagger
#

yeah thx

grim ice
#

also this isnt a string

#

a string is covered between quotes

#

so you should ask "how do i deop a person"

tardy delta
fleet comet
#

google it (:
or just ask here

verbal dagger
fleet comet
#

honestly google is mean

grim ice
#

its fine :D

fleet comet
#

just ask here

tardy delta
#

imajin is mean too 😠

grim ice
#

everyone is mean

#

depends on how you interprete it

#

since

#

investing is basically taking advantage of other people

paper viper
#

Programming community is going to be toxic. I’ve always had toxic people in the beginning when they give me tips. So honestly deal with it and just grow up or smthing

fleet comet
#

google is mean, it cuts out its server just for me

ivory sleet
#

Choose not to be offended usually works

grim ice
ivory sleet
#

Unless you get flamed in which you might wanna contact mods of said community

grim ice
#

still, u being somehow offensive helped me

paper viper
#

Because you don’t focus on the yelling part

#

You focus on what they are telling you

grim ice
#

yeeah

#

its been a whole year anyways

#

lol

ivory sleet
#

Yeah you’re a chad programmer now

tardy delta
#

people who teach stuff the hard way usually help the most

#

like that dude which got banned year ago

ivory sleet
#

Nnyak?

grim ice
fleet comet
ivory sleet
#

He’s still around here I’d presuppose just laying very low

tardy delta
#

idk someone with random uppercase chars in his name

paper viper
#

Well you didn’t focus on what I told you…

tardy delta
#

elgarl know who im talking bout

paper viper
#

It’s not like I wanted to change stuff either when I was a beginner

fleet comet
fleet comet
#

i wanted addons that werent plugins lol

paper viper
#

If you want to learn fast, you have to be open minded

ivory sleet
#

Not being sarcastic

#

:3

grim ice
#

who? @tardy delta

fleet comet
paper viper
#

Your repository clearly shows it lol

tardy delta
paper viper
#

Anyways

fleet comet
tardy delta
#

NNY... was his name

grim ice
#

i mean using github is something u do daily if u code often

tardy delta
#

man with the skeleton head with christmas hat in his pfp
ill remember him

paper viper
fleet comet
#

thats how i learn fast

tardy delta
#

well anyways goodnight

ivory sleet
#

Sleep tight

tardy delta
#

you too

grim ice
#

good night

#

its 20:21 for me lol

ivory sleet
#

If you truly wanna practice reflection then create something like a dependency injection library

paper viper
#

I’m not sure if an addon system is really useful for learning reflection…

paper viper
#

Even something like using NMS would be better

tardy delta
#

tomorrow morning my profile will be like: playing ij for 16 hours ¯_(ツ)_/¯

ivory sleet
#

Sounds exciting

fleet comet
ivory sleet
#

Pulse remember block us… I mean we kinda learned some stuff from that piece of garb

paper viper
#

Ya obviously

ivory sleet
#

🥲

paper viper
#

But at least we listened to what people said lol

ivory sleet
#

True

paper viper
#

Even tho it was a fuckmess

fleet comet
#

d o g

#

dog.class

#

public abstract class dog() {}

paper viper
#

Remove the System.out lines and replace them with actual logging stuff

fleet comet
#

divide your code into more methods, thats the only thing i understand

paper viper
#

In your main class, I’d encourage you to not do ‘public static JavaPlugin’

#

Also, use Java NIO instead of Java IO

#

I’m on phone give me some time

ivory sleet
#

I fucking roflmao everytime I go back to check that junk loll

paper viper
#

LOL

fleet comet
paper viper
#

DI

ivory sleet
#

?di

undone axleBOT
paper viper
#

Also im in the middle of the fucking desert lmao

ivory sleet
#

Oo nice

#

Veri epic

grim ice
#

holy shit i finally can read manga peacefully

#

i finished 2 projects today

paper viper
# fleet comet whats encapsulation?

Encapsulation is when you make your class variables private so they cannot be accessed outside the class directly. Getter/setter methods are used in conjunctive with encapsulation to retrieve/set the variable with the actual method, rather than directly

ivory sleet
#

What a graceful reward hex

#

What type of mangas do you read

fleet comet
#

what classes should i use that in?

grim ice
#

i find them more realistic

paper viper
ivory sleet
#

Hmm, alright I see I see

paper viper
fleet comet
# paper viper DI

also isnt that more complicated? other devs are going to making addons so it should be farely simple

ivory sleet
#

What is complicated is static

#

It looks fairly straightforward

paper viper
#

Conclure can give better explanation

fleet comet
#

@ivory sleetgimme

ivory sleet
#

Uh what should I explain?

fleet comet
#

di

ivory sleet
#

DI vs mono state?

fleet comet
#

DI

#

im so confused

grim ice
#

similar to indentation styles

quaint mantle
ivory sleet
#

Okay so I assume you’ve done something like
(Aka Monostate)

static Plugin heeheeeheehawPlugin;
#

@fleet comet

quaint mantle
#

heeheeheehaw

paper viper
grim ice
#

hehehehaw, bitch ive beat the odds

grim ice
#

isnt there a song like that

ivory sleet
#

Yes but whatever, the point is the static

#

You basically have a butch of static variables that are re-assignable, which means the value of them can be changed throughout the runtime of the server

#

This is bad, veri bad

ivory sleet
#

(I’m exaggerating a bit now since in some select few scenarios it might be fine) but let’s keep to the rules

eternal night
#

psssht, conclure we might be getting the first valhalla previews in java 20

ivory sleet
#

Wait

#

Fr?

eternal night
#

ye

ivory sleet
#

Woooohooo

ivory sleet
#

Sry Jade 1 sec I need to see this

eternal night
#

(also thanks mini for showing me that site, never knew it existed)

hybrid spoke
#

you didnt knew about openjdk?

ivory sleet
#

Oh woaw

#

This is awesome lynx

eternal night
#

not about the dashboard for JEPs xD

paper viper
#

Light weight JSON API

eternal night
#

Yea hype af

paper viper
#

Lol

young shell
#

Is there a reason why PermissionAttachments are not exposed in the API?

grim ice
ivory sleet
#

Good bye fast util 👀

grim ice
#

value classes

eternal night
#

PermissionAttachment is a part of the API 🤔

young shell
#

So any Attachments added by Permissible#addAttachment(Plugin plugin) are excluded from that

#

and the ones added with Permissible#addAttachment(Plugin plugin, int ticks) too

fleet comet
#

@ivory sleetb u m p

ivory sleet
#

Anyway continuing,

Static variables / mono state causes:

  • Tight coupling
    • Classes suddenly depend on a specific instance/variable, this becomes hard to manage and degrades flexibility
  • General unmaintainability, for instance it becomes harder to test different layers of your application and refactoring details in different modules
  • Extreme pain when dealing with multi threading

To sum it up, you become immobile, fragile, rigid and prone to viscosity

This is why programmers avoid certain patterns and try to write code defensively

#

This is for instance why we like encapsulation

fleet comet
#
  • Extreme pain when dealing with multi threading
    that is the most accurate thing ive ever heard
ivory sleet
#

It makes our code more robust and flexible

#

Yeah

#

Especially since Java doesn’t have anything to just magically fix concurrency update problems, dead locks and all that crappy stuff

ivory sleet
#

(It does have a memory model and some classes)

#

But I mean it’s till up to you to incorporate those tools effectively

fleet comet
#

okay continue

gritty urchin
#

How to convert a String to a InetSocketAddress?

young shell
#

InetAddress.getByName(String host)

fleet comet
#

@ivory sleet

grim ice
#

yeah that too prob

gritty urchin
young shell
#

Oh true fair enough

gritty urchin
young shell
#

Use this Constructor

gritty urchin
#

I don't have a port

#

its just a IPv4 string

young shell
waxen plinth
# young shell

That's probably not a good thing to suggest without more context about the use case

young shell
#

I mean do you really need a InetSocketAdress or is a InetAdress enough

lost wolf
#

How can I make a mob shake similarly to how a Zombie Villager shakes while being cured?

ivory sleet
fleet comet
#

thanks

ivory sleet
#

Idk if there’s much to add

#

I mean I could be here all day rambling about best practices

#

But that wouldn’t get you anywhere

fleet comet
#

yeah and i dont know how to add

ivory sleet
#

How to add what? Owo

fleet comet
#

DIs

flint coyote
#

?di

undone axleBOT
lost wolf
#

How can I make a mob shake similarly to how a Zombie Villager shakes while being cured?

ornate patio
#

I'm trying to completely overwrite a method from NMS

echo basalt
ornate patio
#

wait lmao

#

so my custom entity is called SuperiorHorseEntity

#

which extends Horse

#

which extends AbstractHorse

#

which extends Animal

#

what I'm trying to do is directly call Animal#aiStep() directly from SuperiorHorseEntity, completely skipping AbstradctHorse#aiStep()

echo basalt
#

uhhh

#

given it's overriden you might have to remake that method honestly

ornate patio
#

because AbstradctHorse#aiStep() has some private method calls that I can't exactly do with normal overriding

ornate patio
sterile token
#

How do i save a mongo pojo class?

#

I cannot giure how to save it

echo basalt
#

serialize it to a byte[] and save it directly

ornate patio
#

I've tried doing

animalAiStepMethod = Animal.class.getDeclaredMethod("w_");
...
animalAiStepMethod.invoke(this);
sterile token
#

Mongo have codec for that

echo basalt
#

actually nah

ornate patio
echo basalt
sterile token
#

Looks harcoded that thing for aving

sterile token
ornate patio
#

if I want to remake the entire method I'm gonna have to use reflection to access every private field and method that the super classes use 😐

echo basalt
#

yessir

ornate patio
#

is this really my fate

echo basalt
#

I wasted like an hour remaking pathfinders so that zombies can't walk through client-sided blocks

#

only had to remake 2 classes

#

this is very helpful except you're asking for code help and not presenting any code

ornate patio
#

i'm just trying to stop horses from doing the eating grass animation damnit

echo basalt
#

lmfao you can probably avoid that with pathfinders or some shit

ornate patio
#

nah

#

the code for eating grass is completely seperate from pathfinders

echo basalt
#

lol ok thanks bukkit

ornate patio
#

its in its own method, with a random chance of it happening every tick

#

which is a god damn pain

echo basalt
#

I mean

ornate patio
echo basalt
#

if you want to go that custom just fork spigot and remove it

ornate patio
#

but it want to delete that one part

echo basalt
#

oh god

paper viper
#

Oh god

ornate patio
#

bro

paper viper
#

Lol

ornate patio
#

?paste

undone axleBOT
sterile token
#

?paste

undone axleBOT
paper viper
#

I’m on phone

#

It’s so much worse

sterile token
#

Oh ok

bold bough
#

sry

ornate patio
#

i'm trying to make it work on any spigot server

echo basalt
#

then like

sterile token
echo basalt
#

remake the entire horse logic

ornate patio
#

welp this is gonna take a long time

sterile token
#

Pulse i couldnt fix my issue with mongo :/

echo basalt
#

or just call the private methods via reflection

sterile token
#

Heheh

#

Im still reading about fixing it

echo basalt
#

what's the part of append("id", POJO); that you don't understand

#

as long as it's annotated with @Serializable you're good

sterile token
#

Ilusion ait i ill send code

bold bough
#

**Hello i have problem with config creationg. **
**If i creating config (?configs) **

1) config.yml dont install on server
2) Events (playerOnJoin) dont work

https://paste.md-5.net/oxobegaded.java

sterile token
#

?doesntwork

#
public class ClaimManager {

    private final Set<Claim> claims = new HashSet<>();
    private final StorageManager sotrage;

    public ClaimManager(Main plugin) { this.storage = plugin.getStorage(); }

    public void load() {
        for (Claim claim : this.storage.getClaims().find()) this.claims.add(claim);
    }

    public void save() {
        for (Claim claim : this.claims) this.storage.getClaims().updateOne(Filters.eq("uuid", claim.getUuid()), (Bson) claim, new UpdateOptions().upsert(true));
    }
]```
echo basalt
#

Plugin's probably not even loading

paper viper
#

Bruh you are still casting to Bson

#

Why

sterile token
#

I dont know how to update it

#

that why

echo basalt
#

Create a new document and append it

sterile token
#

Why document

#

Im using POJO

echo basalt
#

Just see my datasync code smh

#

Document is a fancy bson wrapper

sterile token
#

POJO != Document

#

POJO is like a model

echo basalt
#

You can append pojos to a document

#

And get em back

sterile token
#

but i dont want to use document

#

I just ant to use POJO

echo basalt
#

Then I don't want to help you

sterile token
#

Okay...

#

Oh lmao i dont know why is do diff to understand

sterile token
#

Becaue it not a document

#

The info i read explain that when you are using POJO's classes you dont need document thing

paper viper
#

What is your goal

echo basalt
#

¯_(ツ)_/¯

sterile token
#

MongoCollection#updateOne()

paper falcon
#

do you guys know any up-to-date guides about custom enchants?

sterile token
river oracle
sterile token
#

Also im reading official mongo docs

#

So i dont kno why it doesnt work

#

Hahaha

echo basalt
#

you miss out the 3 tons of annotations and codecs underlying

sterile token
#

He?

#
public class StorageManager {

    private final Main plugin;
    private MongoClient client;
    @Getter private MongoCollection<Claim> claims;

    public StorageManager(Main plugin) {
        this.plugin = plugin;
    }

    public void open() {
        Logger.getLogger("org.mongodb.driver").setLevel(Level.OFF);
        this.client = new com.mongodb.MongoClient(new MongoClientURI(""));
        CodecProvider provider = PojoCodecProvider.builder().automatic(true).register(Cuboid.class).build();
        CodecRegistry codec = CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry(), CodecRegistries.fromProviders(provider));
        this.claims = this.client.getDatabase("test").withCodecRegistry(codec).getCollection("claims", Claim.class);
        this.plugin.getLogger().info("Connected to database");
    }

    public void close() {
        this.client.close();
        this.plugin.getLogger().info("Disconnected from database");
    }
}```
#

Look its working

quiet ice
#

Just don't use DBs people

sterile token
#

Everything works except MongoCollection#updateOne()

#

oh lmao

#

I would ill have to wait smile

#

Also ImIlussion and Pulse thanks for trying to help i just will be pacient and wait for Smile to get online

#

Have a nice day

bold bough
sterile token
quiet ice
#

Smile Probably will only Go on tomorrow for the record (or He has a messed Up sleep cycle)

sterile token
#

geol

#

i didnt udnerstand

#

Sorry

bold bough
quiet ice
#

Smile lives in Central Europe and it's 11pm there - chances are He is asleep

sterile token
sterile token
#

Yeah you are totally right

#

Geol dont you know about mongo?

quiet ice
#

Never used DBs in my life

sterile token
#

Oh allright really thanks dont worry

#

oh lmao i have discovered a nice trouble about doing DI into an Enum

pliant oyster
#

For some reason, player.getVelocity() is showing 0 for both X and Z even when I'm moving around, it only changes when I'm jump running, how do I get the actual velocity for X and Z?

ivory sleet
#

🤔

sterile token
#

I have jut realized about that

#

How the heck i would get my config instance

eternal night
#

DI into an enum

#

What

#

You don't

#

Enums are pure constants

paper viper
#

Lol

eternal night
#

or should be

paper viper
#

Lombok

sterile token
paper viper
#

Also an interface is better for constants if you don’t want the stupid type

sterile token
#

pulse

#

Did i told u that i still cannot fi the shit

#

:sad:

eternal night
#

What do you mean "for getting config value"

paper viper
#

Well nobody knows rlly how to do it lol

eternal night
#

Then your enum holds the yaml paths

sterile token
#

yes

eternal night
#

And you pass the config to the method

sterile token
#

Im trying to do that

eternal night
#

But like, this fails so early

sterile token
#

Im ondering to do:

Messages.Invalid_Sender

eternal night
#

What if your value is an int

#

Or a list of strings

sterile token
#

Oh enums only strings right

#

Yeah good point

eternal night
#

Well not but they aren't generic

sterile token
#

You are totally right

eternal night
#

I usually just write an interface for language

sterile token
#

Oh ok

#

And how you pas the file intance

#

😂

paper viper
#

? English

sterile token
#

Because interface neither abs class can be initialized

eternal night
#

Component levelUpMessage(int level);

#

For example

#

Rip the closing bracket

#

Well

#

You implement that

paper viper
#

Lol I do something similar but much cursed for messages

sterile token
sterile token
paper viper
#

XD

sterile token
#

We are hopefully to have you

#

Oh shit its not helper its a booster

#

Im dumb

subtle folio
#

lmfao

eternal night
#

Yes pulse that is cursed

sterile token
#

I dont kno how i can confuse colors

eternal night
#

Lmfao

paper viper
#

LuckPerms used that for a while

#

Lol

subtle folio
#

why would anyone even begin to want to moderate this discord 💀 hello conclure

paper viper
#

I need to store them in a file

#

XD

sterile token
ivory sleet
#

When u don’t have generic var args 😦

sterile token
ivory sleet
#

Sql bro?

sterile token
#

Oh