#help-development

1 messages · Page 161 of 1

wary topaz
#

should i replace label with cmd

wet breach
#

label refers to the command alias if it has one, but defaults to the command if no alias is set

wary topaz
#

oh so it does work

#

?

eternal oxide
#

label is actually the command you typed, be it the command or its alias

#

you shoudl use cmd, if you are passing multiple commands through a single executor

wet breach
eternal oxide
#

cmd.getName is the command not the alias

wary topaz
#

alr ty

#

switch (cmd.getName()) {?

eternal oxide
#

there is a seperate entry fore alias

wet breach
eternal oxide
#

yep, we are both correct. label is precisely what you typed

wary topaz
static ingot
#

you have return when args.length == 0 and then check for args.length to be greater than or equal to 1, when it's already guaranteed to be

wary topaz
#

ah I just realized that

wet breach
#

so you know exactly what is or is not being executed

wary topaz
#

it errors before it can print though

wet breach
#

that is fine, you can always have debug messages before and after too

#

this way you always know where in the code blocks the issue is arising. Just makes it easier to see where you need to figure out something is all, doesn't tell you exactly the problem. Some info is better then none at all

static ingot
#

i keep saying it's because right at the beginning of your command, you only return when args.length == 0, and then get args[1] right after

#

lol

wet breach
#

so any time you have returns, you can put a debug message to print to console or broadcast where the code is being executed currently

#

even if that code block generally doesn't do much anyways

wet breach
static ingot
#

That's not my point :v

wet breach
#

I know it isn't but the fact that there is a return is causing it to not go to the next code block

static ingot
#
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (args.length == 0) {
        sender.sendMessage("§4§lUsage: /Gamemode <[Creative, Survival, Adventure, Spectator]> <Player>");
        return true;
    }
    // ...
    Player target = Bukkit.getPlayer(args[1]); // <---
    // ...
}```
just changing the 0 to a 2 would fix it, lol
wary topaz
#

But theres not 2 args

#

theres only 1 because java counts from 0

wet breach
#

0 + 1 = 2

#

0 is a number, and 1 is a number

#

that makes 2 numbers

static ingot
#

length starts from 1. index starts from 0.

wary topaz
#

^

static ingot
# wary topaz ^

that was directed at you. literally just change it to args.length != 2

#

!=

#

sorry

wet breach
#

<[Creative, Survival, Adventure, Spectator]> <Player> you are checking for 2 arguments

wary topaz
#

At what line

static ingot
#

26

wet breach
#

we have the command at the beginning /Gamemode this is the command. Anything after the command is called arguments

wary topaz
#

Yes but what about the /gmc?

wet breach
#

that is a command

wary topaz
#

That only has 1 argument

wet breach
#

then you need to separate your checks

wary topaz
#

So the switch is useless?

wet breach
#

and check if it has 1 argument or 2 arguments. If it only has 1 argument then you need to have its own code block in what to do with that

#

and if it has 2 arguments do something else

wary topaz
#

alr

static ingot
#

Check what label is used and run your command based on that. if it's just gm or gamemode, then do your normal stuff

wet breach
#

you can have multiple onCommand classes that you can divert the command to based on the arguments being used 🙂

wary topaz
#

oo

quaint mantle
#

does anyone know how I can cacnel the shift click?

river oracle
#

for what

#

you cant explicitly prevent the player from pressing the shift key but I guess you could control some logic that is usually used by the shift key

quaint mantle
#
if (e.getClickedInventory().getType().equals(InventoryType.FURNACE)) {
            if (e.getCursor().getType() == Material.IRON_ORE) 
              e.setCancelled(true);
```It won't let a player put that iron ore in a furnace but if they shift click it goes in the furnace so I want to try and cancel that
river oracle
#

I'd just cancel putting iron ore at all into the furnace rather than preventing pickup with the cursor

quaint mantle
river oracle
#

you can also check the click type by using getClickType method i'd assume

#

this looks promissing its an old thread but the logic is explained well

#

InventoryMoveItemEvent

#

now exists

#

while this is talking about chest same logic will apply to furances

quaint mantle
river oracle
#

?google

undone axleBOT
river oracle
static ingot
#

are you trolling

river oracle
#

indexes start at 0

wary topaz
#

?

river oracle
quaint mantle
river oracle
#

its just being uneducated

static ingot
#

Idk how many times i've said he needs to change that to args.length != 2

wary topaz
#

Yeah but that ruins my code

#

It makes it error more

static ingot
#

oh. right. maybe you should make your gmc, gms stuff separate commands

river oracle
#

🤦‍♂️ fix the errors you also need to learn how to read stack traces and bugfix your own code stuff like this should just be a tad of tweaking

#

example switching index numbers

#

than retrying

#

add Sysout to see why something may be wrong

static ingot
#

the command logic is just pretty messy in general. changing the order in which you do certain things would do a lot of good. i.e. handling /gms, /gmc, etc. probably would be one of the first things you wanna do

river oracle
#

sender.sendMessage("§4§lCan't find player by the name of " + args[1]);
You can't get the 2nd argument from args if it doesn't exist simple problem / solution here
at BetterCommands.Commands.Gamemode.onCommand(Gamemode.java:34) ~[BetterCommands.jar:?]
We know its at line 34 in the gamemode class
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
We know there is an out of bounds exception
if (args.length == 1) { we know args length must be one so therefore you can't get the second element

#

indexes start at 0

#

not 1

#

0

#
String[] args = {"arg0", "arg1"}
sysout(args[0])
sysout(args[1])
output:
arg0
arg1
wary topaz
#

^length starts from 1. index starts from 0.

river oracle
#

fix it than recompile and try again

flint pollen
#

yes. because if you have 1 element, then your array is 1 elements long.
and yes, it doesn't contradict the fact that it's, effectively, 0th.

wary topaz
#

Holly crap that just fixed the whole plugin ty @river oracle

static ingot
#

sheesh

#

glad you could figure it out at least

river oracle
#

the commands class is a mess and all but the stack trace gods give us the solution 🙏

static ingot
#

🤨

#

sure

flint pollen
#

hey, just a quick question.
is there any particular reason this function right here won't work? all debug prints get called properly and i get no errors in the console

#

damn

#

why can't i attach a screenshot

river oracle
#

you need to verify with your spigot account

#

?img

undone axleBOT
static ingot
#

I believe you have to verify with your forums account

river oracle
#

though

#

?paste

undone axleBOT
flint pollen
#

what a strange thing to be made mandatory.

wary topaz
#

?commands

river oracle
#

is probably better for all code stuff

flint pollen
#

anyways.

#
public void unspecifiedEvent(PlayerSwapHandItemsEvent event) {
        System.out.println("AAA");
        Player player = event.getPlayer();
        if (event.getOffHandItem().getType() == Material.SHIELD) {
            player.getInventory().setItemInOffHand(new ItemStack(Material.WOODEN_HOE, 1)); // this func won't work
            player.sendMessage("There's a good reason I've forbidden shields in offhand, you know.");
        }
    }
#

does discord md count?

river oracle
#

you can't embed with discord md

#

afaik

flint pollen
#

well, what did i just do, pray tell?

river oracle
#

thats not an image...

flint pollen
#

it doesn't have to be an image to show what's wrong in my case

river oracle
flint pollen
#

does it?

river oracle
#

so both player message and system message print

flint pollen
river oracle
#

🤦‍♂️ yes I read so good

static ingot
#

Are you using @EventHandler?

flint pollen
#

I do.

#

And I have everything imported properly

static ingot
#

and registering the listener?

river oracle
#

sometimes this works lmao

flint pollen
#

yes, I am registering it in main class.

static ingot
#

oki. doesn't hurt to check the basics, lol

flint pollen
river oracle
#

i'll give an example are you familiar with Dependency injection

#

?scheduler

#

fuck

flint pollen
#

Nope.

river oracle
#

uhm do you know how to get variables to other classes without static

flint pollen
#

objectName.variableName?

river oracle
#

oh no

#

?di

undone axleBOT
river oracle
#

like this ^ guide

#

its really good

#

because you'll need a plugin instance for scheduling

#

?scheduling

undone axleBOT
river oracle
#

^ this is the scheduler

#

reading these guides should be enough to get the idea

#

you'd just delay it 1 tick and then place the wooden hoe in their offhand

#

My guess is its possible that PlayerSwapHandItemsEvent is triggered prior to the swap

flint pollen
#

yes, I figured it all out.

#

No offense, but it feels bloated. Like, why do I have to pass my plugin in? And why do I have to manually create and assign these objects?

#

can't it all be done, like, automatically or something? is there something i don't understand about java?

#

perhaps all these years of coding in python for godot engine have corrupted me and reduced my brain capabilities but

#

i fail to grasp why did they overcomplicate everything.

#

anyways, I figured it all out and now it works.

alpine narwhal
#

No one is saying you have to use di for everything. Its just recommended.

wary topaz
flint pollen
alpine narwhal
#

Plus, di isnt even that bad. Yes it can be annoying but its easy

alpine narwhal
#

Yes. but why is that important.

wary topaz
#

It's hard to scroll to the bottom which concerns me

static ingot
#

Though oftentimes you wouldn't often do it for a single method like that :b

#

wait

#

you're talking about the scheduler, i'm talking about DI, my bad, lol

flint pollen
#

anyways

#

all that aside

#

i've got a grasp of how things are doing

#

everything i've learned here just now, including DI, helped me out now

#

and will help me out later

#

thank you all for your help.

fast path
#

Is here anyone good at gradle?

wet breach
#

?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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

fast path
#
An exception has occurred in the compiler (17.0.4.1). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.NullPointerException```
wet breach
#

that doesn't really tell us anything

fast path
#

So I upgrade to java 17.

#

Then this happened.

torn shuttle
#

Brah just use enums

wet breach
dusk scroll
#

bracket moment

torn shuttle
#

You can use my new programming language, I call it enummeroni

wet breach
#

nothing what you have showed above indicates what exactly is wrong only that the compiler encountered an NPE

dusk scroll
torn shuttle
#

There's only one kind of object, enums

fast path
#

?paste

undone axleBOT
fast path
#

Ok that's it

wet breach
#

its quite possible the issue most likely in the libs

#

just because your code is usable with java 17, doesn't necessarily mean the libs are compatible with java 17

fast path
#

What if I use java 18:

dusk scroll
#

enum >>

torn shuttle
# dusk scroll

Don't post that kind of smut here, illusion will probably ask to marry you

dusk scroll
#

The enums are pretty essential though. Since im not releasing the plugin publicly I just decided to do it this way. Kind of like an internal config that's more flexible 😂

torn shuttle
#

I can practically hear illusion being a coomer from here after reading that

dusk scroll
#

no pyramids in sight

#

egypt is far away atm

dusk scroll
#

well what, you think a config file is better?

#

a YML?

#

it would be if i was releasing this publicly 😂

torn shuttle
#

Ever heard of classes?

wet breach
#

so compiling for java 16 is completely fine as java 17 will still be able to run it

dusk scroll
fast path
#

The API requires using Java 17 at development time. Make sure to point your toolchain to Java 17.

torn shuttle
dusk scroll
#

in particular here these are shop items, basically itemstacks with custom properties and some other settings that affect how they are obtained etc

#

I would 100% understand the reasoning for using classes if it was something like a kit

#

that has custom listeners and functions for each one

#

which is actually what I do for kits

wet breach
#

odds are they just compiled using java 17 thus making the project unusable in earlier versions

#

highly doubt they are making use of code that is specific to java 17 though

dusk scroll
#

but this enum is pretty easily understood if you just see what the variables are

#

and know how the game itself functions

torn shuttle
dusk scroll
fast path
dusk scroll
#

It's never been a problem

wet breach
fast path
#

wait a minute

wet breach
#

what I was talking about is cloning the fawe project, and compile the fawe jar separately

dusk scroll
#

There's big games that use huge configurations like this

#

If you've ever played a game made by Supercell on your phone, their configs are literally CSV files. Basically structured like this where a lot of values are null unless otherwise stated

#

Is there a possibility I could make a CSV system too? Maybe. Or a config file? sure. But again im not releasing this to the public, this was the fastest way for me to do it 🤷

wet breach
#

you can make any system you want

#

all csv is just a spreadsheet

dusk scroll
vocal cloud
#

It's just a bunch of comma separated values

dusk scroll
#

i know it's def possible to use a spreadsheet lol

wet breach
#

you don't have to use yml if you don't want to

#

yml works differently though in where null values are generally not acceptable

#

and actually causes the entry to be removed

dusk scroll
#

so this would have to work differently as a yml file

wet breach
#

or use something else other then yml

#

or make a custom yml lib

#

where it does accept null values

grave lagoon
#

just use the square root of the ladderologist bias

dusk scroll
#

apparently triggers that magma guy for some reason.

wet breach
#

don't mind him lol

dusk scroll
#

as long as you don't do cross-reference you are fine

#

doing this system actually taught me about that

#

so pretty cool

#

this was the result

#

recording is lagging for some reason

#

but yeah ENUMS WORK

tender anvil
#

i'm watching the cody simpson nms tutorial and for some reason i can't do some of the things he's doing.

playerConnection.sendPacket(packet)

it says sendPacket doesn't exist for some reason. I did spigot instead of spigot-api in my pom.xml but it doesn't work for some reason.

fast path
#

.a

tender shard
#

on 1.17+ you need to use mojang mappings, or use the obfuscated names like a()

river oracle
tender anvil
#

ah that sucks

#

whatever

river oracle
#

I still have obfuscated ones

#

Maybe need to rerun build tools

dusk scroll
#

((CraftPlayer) player.getPlayer()).getHandle().playerConnection.sendPacket(packet);

#

this works for me on spigot 1.8

#

dont know if it will work at all on new

#

lol

river oracle
#

1.8 💀

#

Its probably changed

dusk scroll
#

packets themselves change all the time

#

but the way you send them should still be similar at least

river oracle
#

Hmm curious about something

dusk scroll
#

obviously playerConnection.sendPacket() is supposed to still be a thing in kody's vid

river oracle
#

?1.8

undone axleBOT
fast path
#

🤔

tender anvil
#

is there a list of what most of the mappings do?

river oracle
#

Wow 1.8 is old as fuck

tender anvil
#

or do you kinda have to ask or figure them out yourself

dusk scroll
#

👍

tender anvil
river oracle
dusk scroll
dusk scroll
#

not every server uses bStats and most servers running 1.8 I would argue actually disable b stats

#

or just don't have it

#

newer version servers are mostly SMPs ran by people who just wanna have a plug-and-play type thing with their friends

#

they don't really bother with the config too much and thus are more likely to have bstats on/installed

hasty prawn
#

Yeah but bStats is probably the best metric there is, unless you can prove that 1.8 is popular via another metric....

river oracle
#

Thats not a metric

dusk scroll
#

Over half of MC accounts have logged into hypixel at some point or another

hasty prawn
#

Okay, you've got one.

hasty prawn
river oracle
#

I'd argue hypixel isn't a good metric if you want to have the best experience you use the core version of the server

dusk scroll
#

people use other versions too

#

however MOSTLY people use 1.8

hasty prawn
#

Even if 1.8 is the most popular on hypixel that doesn't translate at all to all servers.

dusk scroll
#

if we look at data from back in february

river oracle
dusk scroll
#

https://hypixel.net/threads/removing-support-for-more-minecraft-versions-1-11-1-13.4799817/ back when they removed support for 1.11 1.13 they gave us these statistics

quaint mantle
#

Does anyone here know how to check slots for brweing stands?

hasty prawn
#

Thats for Hypixel

#

And Hypixel alone

tender anvil
#

ya

dusk scroll
#

Hypixel has a LOT of players

tender anvil
#

also is using build tools still a good way of getting the latest nms version or no?

hasty prawn
#

Sure but you can't take just a small sample size of exactly one server and apply it to every server in the world.

dusk scroll
hasty prawn
#

bStats has a much larger sample size, thats the thing giggle

#

Thats why it's the most accurate we have

dusk scroll
#

how many servers use bStats? and how many players play on servers with bstats?

hasty prawn
#

157k servers and 100k players on non-peak hours

#

Much larger than Hypixel.

tender anvil
#

are there any good lists on the mojang mapping or should i just try to figure it out myself? (or ask in here :)

hasty prawn
#

That's also for Bukkit/Spigot alone

river oracle
#

Does paper have their own metrics system or sum?

#

I thought they used bStats

dusk scroll
#

maybe even higher, can't recall atm

hasty prawn
#

Ok, so?

river oracle
dusk scroll
#

but interesting nontheless

#

guranteed there's tons of bukkit/spigot servers that do not have bStats that are not included here

#

has bStats been integrated into spigot itself?

#

and if so from what version is it integrated?

hasty prawn
#

You're talking about 179k servers, and only 6% of them are running 1.8.8, and this, of course, is Bukkit/Spigot only.

Hypixel is ONE server.

#

It doesn't matter how many players are on there

dusk scroll
hasty prawn
#

No, it shows what server is the most popular lol

dusk scroll
#

i mean if we include vanilla numbers - ofc the latest is always going to be the highest

#

that's just how it works

hasty prawn
#

Well isn't that what we're talking about? Most popular version?

tender anvil
# river oracle Screamingsandals

i went to their github page and it seems as though there is a gradle plugin there? i use maven but i wouldn't know what to do with it anyway. i'll most likely just as around here

hasty prawn
#

Why would it matter if it's Vanilla or not 😛

tender anvil
#

oh i didn't go there lol

#

ty

quaint mantle
#

is it possible to prevent from like a certain potion being made if a player didnt have x permission ?

dusk scroll
#

well initially i made the argument that 1.8 is still one of the most popular mc versions, which it clearly is

river oracle
#

If you don't know where to even start though your better off commissioning someine

quaint mantle
#

is it that complicated?

river oracle
dusk scroll
#

i never stated that the latest version isn't popular, of course it will always be popular

#

but you can't really say 1.8 isn't popular at all

#

lol

hasty prawn
#

I never said it wasn't popular

tender anvil
hasty prawn
#

Of course it is, it's just not the most popular.

#

Latest version will always be the most popular version.

quaint mantle
# river oracle Not in my opinion

I was thinking of using the inventory event

if (e.getView().getTitle().equalsIgnoreCase("Brewing Stand")) {
        //some code here
                if (!p.hasPermission("medievalmc.physician")) {
#

in the some code here I was thinking of either checking the slots in the brewing stand and if like 2/3 are already there u can't put the 3rd one? BUt I don't know how to check the brewing stand slots if you could help me out with that

dusk scroll
#

BrewingStandFuelEvent or BrewEvent

#

best bet here

quaint mantle
dusk scroll
#

BrewEvent can be cancelled

river oracle
#

No player target necessarily for the specific brewing stand

#

Best to stick to the inventory events

dusk scroll
#

and check and see

#

lol

#

that's probably the cheesiest way to do it

#

but ig it's possible that way

#

inventory events should also work

quaint mantle
#

so i am on the right pathh..?

river oracle
#

If you use the map make sure to use WeakReference

#

Player objects tend to cause some serious memory leakage when stored in maps

dusk scroll
#

but i mean ig at that point just use inventory events

dusk scroll
#

you can check for this instead of the inventory name

hasty prawn
#

ye it is

#

InventoryType.BREWING

#

Use that

quaint mantle
#

What about slots

dusk scroll
#

in the inventory click event you should be able to check the slots clicked

quaint mantle
#

like each slot in the brewing stand

dusk scroll
#

e.getSlot()

#

it's an int so just like a chest gui

#

there's a number for each slot

#

if you really don't know what these are just send a message to yourself with the number and you can see what each slot is but it should be pretty straightforward starting from 0

quaint mantle
#

e.getSlot()

dusk scroll
#

then once you know what each is you can remove it and add your code for it as you need

quaint mantle
#

e.getSlot() check if it contains anything and then check the rest and then if like 2/3 ingredients are there the 3rd one will not be able to go in there that could work right?

dusk scroll
#

well

#

on inventory click event you will be able to know without checking the slot what it is they clicked (just not the slot it's in)

#

you need to make sure this isn't null, however

#

or you will get nullpointerexceptions

quaint mantle
#

hm okay im gonna mess around with it and see where I end up

dusk scroll
#

awesome 😄 good luck

quaint mantle
#

thank you i really appreciate it! (for everyone that helped me)

dusk scroll
#

np

tender anvil
#

anyways, should i use spigot mappings for 1.19 or mojang mappings?

torn oyster
#

how would I check when a player was killed by a non-player?

dusk scroll
dusk scroll
#

but if you are going to distribute your plugin you must distribute it with spigot mappings

torn oyster
tender anvil
tender anvil
dusk scroll
#

because i mean, it's kind of "illegal"

#

mojang doesn't allow it

tender anvil
#

and?

dusk scroll
#

they give the mojang mappings for development only

torn oyster
dusk scroll
#

i didnt know about it

torn oyster
#

yeah

dusk scroll
#

i make plugins for 1.8 so mojang mappings are usless to me anyways

#

since i dont have any

#

😂

wet breach
dusk scroll
#

that's why i said it in quotes

#

either way mojang doesn't intend you to use their mappings for distribution

torn oyster
#

isn't it for copyright or something

dusk scroll
#

yea

torn oyster
#

because piracy

#

and other things

dusk scroll
#

right

#

even though things like lunar client exist

#

lol

wet breach
dusk scroll
#

they allow you to use them for development

wet breach
#

that also doesn't mean you can't have partial mappings in your code either

dusk scroll
#

but when you distribute you should convert back to spigot mappings

#

in fact there's a way to do this automatically

#

with your jar

#

kody simpson has some tutorial for it

torn oyster
#

guys i only just started using lombok

#

and i gotta say

#

how did i not discover this sooner

icy laurel
#

Nice, looks like BuildTools changed my git config, and now I've commited as "BuildTools" for several weeks on github. wtf?

dusk scroll
#

💀

torn oyster
icy laurel
#

WHY does is change profile configs?

torn oyster
#

intellij puts a little "BuildTools" thing on top of my methods

dusk scroll
#

just buildtools

torn oyster
#

didn't know what it meant but now i think i know

icy laurel
#

yep I've disabled that since "I only work on this project, don't need VCS history". Yeah nice, 20 commits with freaking "BuildTools"

#

can't it just use start arguments?

dusk scroll
#

lmao

#

im just gonna keep using github desktop

icy laurel
#

Ahhh nice, and I've added a project to github. With fucking "BuildsTools" in EVERY commit. jesus it's so annoying

dusk scroll
#

😂

wet breach
icy laurel
#

yep, for the last commit. But not for 20 - 30 commits.

dusk scroll
#

buildtools been doing so much work on that project

#

should get a raise

wet breach
#

if you need to do it for more then one commit

#

its not all that difficult

#

and that should resolve your buildtools as author problem in your project 😛

icy laurel
#

didn't work, BuildTools authored and TaskID committed 1 minute ago
love it. why would something like BuildTools change your fucking global git username and email

#

ah nice, found another project I made a few weeks ago, with 51 commits from "BuildTools".

#

everything I did on GitHub since I used build tools 2 months ago is from "BuildTools"..

torn shuttle
torn shuttle
dusk scroll
wet breach
torn shuttle
#

it was a lot of "fun" to correct

wet breach
#

well I do recall a majority of that could have been avoided if you had listen to some

#

since you know it was advised to you to do it differently for some things XD

#

but hey, I suppose that is what keeps you in business 😛

torn shuttle
#

did that happen? don't remember that

wet breach
torn shuttle
#

feature creep ends up being the reason my code gets so scuffed anyhow, the reason why I was doing it all on constructors originally was because there were only 4 fields to fill in

#

and they were actually mandatory

#

just counted, the bosses now have 57 different fields

#

things just creep up on you

wet breach
#

lol

torn shuttle
#

certified no enums moment

vocal cloud
#

certified missing a sweet voiceover

torn shuttle
#

didn't want to overcomplicate it, I'll be making a full on video tutorial on how to use these anyway

tender shard
#

1.17 was the first version where --remapped is avaiable

lament sorrel
#

how can i make a command with cooldown

#

cause i have a command but without cooldown

tender shard
#

You basically just create a cooldown object, like

private final Cooldown cooldown = new Cooldown();
#

and then you can do stuff like cooldown.setCooldown(somePlayer, 20, TimeUnit.SECOND)

#

and cooldown.hasCooldown(player)

lament sorrel
#

wait what im new at developing plugins sorry

tender shard
#

the general idea is to have a Map<Object, Long> or something

#

Long is a timestamp, either when you last ran the command, or when it's about to expire

torn oyster
#

how would i set the target of an entity

tender shard
#

and then you can simpl.y check if the current time is >= the entry in the map

wet breach
#

the question that must first be answered is this. Do you want the timer to be tied to the ticks of the server or actual seconds of the world

lament sorrel
#

seconds of the world

wet breach
#

then mfn's cool down stuff should work

tender shard
#

it's made with ❤️ and booze

lament sorrel
#

im confused

tender shard
#

you could just copy/paste the whole class and try to understand what it does

torn oyster
#

also i only just started using lombok and i have to say, i don't think i'll ever make a project without it now

tender shard
#

and then you can instantiate "Cooldown" objects with new Cooldown()

tender shard
#

it also has some pretty shitty stuff like SneakyThrows lol

torn oyster
#

@Getter and @Setter is good

#

that's my main use lol

wet breach
#

until you want to make some unit tests

torn oyster
#

i didn't read any docs i just experimented

#

there may be other useful things

tender shard
wet breach
#

the arch nemesis of lombok is unit testing lol

torn oyster
#

are minigames easy to make in your opinions?

wet breach
#

depends on the minigame in what functionality it requires

tender shard
#

I still need to finish my chess minigame with stockfish

obsidian lynx
#

Hi guys

torn oyster
#

Hi

obsidian lynx
#
<?php
    $_POST['search'] = "worldedit";

    $ch = curl_init();
    $endpoint = "https://api.spiget.org/v2/search/resources/" . $_POST['search'];
    $params = array('field' => 'name', 'sort' => '-likes', 'fields' => 'name,likes,file,rating');
    $url = $endpoint . '?' . http_build_query($params);
    curl_setopt($ch, CURLOPT_URL, $url);
    $result=curl_exec($ch);

    echo '<pre>',print_r($result,1),'</pre>';
    
?>
lament sorrel
#

@tender shard but where do i put the command that i want to have the cooldown

tender shard
#

in your commandexecutor, you check the cooldown

obsidian lynx
#

i tried the rating{count} also the rating.count also the rating[count]

#

but nothing helps

lament sorrel
#

LIKE THIS

#

sorry caps

torn oyster
tender shard
#

public class CommandKit implements CommandExecutor {

private final Cooldown cooldown = new Cooldown();

public boolean onCommand(CommandSender sender, ...) {
  if(cooldown.hasCooldown(sender)) {
    sender.sendMessage("You need to wait before running this again!");
    return true;
  }
  
  cooldown.setCooldown(sender, 20, TimeUnit.SECOND);
  
  // Do your stuff
}
lament sorrel
#

ok thank u

torn oyster
tender shard
#

yeah well internally it ofc also uses a HashMap 🙂

warm flume
#

hello guys i run into problem

torn oyster
warm flume
#
java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
tender shard
#

download more ram

warm flume
#

i have enough on my dedicated server 256gb ram , epyc 7502

torn shuttle
#

dedotate more wam

tender shard
#

then allow java to use it

warm flume
#

it doesnt use full cacipity even.

tender shard
#
java -Xmx8G -jar spigot-1.19.2.jar
#

this would allow it to use 8 gb

warm flume
#

the server is allowed to use! if it had to do something with the server i would ask in help-server right?

tender shard
#

maybe

#

do you currently only get the full json as output? If so, you gotta use some json parsing lib

obsidian lynx
#

like jQuery?

tender shard
#

PHP has "json_decode" builtin which should be more than enough

obsidian lynx
#

i know that

#

but tbh i need sort it by rating.count

lament sorrel
#

@tender shard

tender shard
#

basically you could something like this:

$json = '{what you get from spiget}';
$jsonObject = json_decode($json);
$rating = $jsonObject->{'rating'};
$count = $rating->{'count'};
tender shard
#

so, the method you should already have in your command executor class

warm flume
#

?paste

undone axleBOT
obsidian lynx
warm flume
obsidian lynx
#

well

#

ill try

tender shard
#

not 100% sure but it should work at least sth like that

obsidian lynx
#

yeah i know

#

thanks !

tender shard
#

otherwise, maybe try $jsonObject["rating"]["count"] or sth

#

havent used json_decode in 10 years or so lol

torn shuttle
#

he'll be sad if you don't

warm flume
tender shard
#

?paste the full log

undone axleBOT
warm flume
dense crow
#

hey, someone know how i can grab a offline player and use it to compare it to a list? wanna make a "whitelist" smilliar thing and im getting all time a nullpointer from the offline player

obsidian lynx
#
focus@DESKTOP-2HVCSQJ:/mnt/g/Developing/Web$ sudo php -S localhost:80
[sudo] heslo pro focus: 
[Sun Oct  2 10:54:28 2022] PHP 8.1.2 Development Server (http://localhost:80) started
[Sun Oct  2 10:54:30 2022] 127.0.0.1:50950 Accepted
[Sun Oct  2 10:54:30 2022] 127.0.0.1:50952 Accepted
[Sun Oct  2 10:54:30 2022] PHP Warning:  Attempt to read property "rating" on int in /mnt/g/Developing/Web/index.php on line 14
[Sun Oct  2 10:54:30 2022] 127.0.0.1:50950 [200]: GET /
[Sun Oct  2 10:54:30 2022] 127.0.0.1:50950 Closing     
[Sun Oct  2 10:54:30 2022] 127.0.0.1:50956 Accepted
torn shuttle
dense crow
#

the thing is i want add them when they are not online, and thats the prob

#

im already Storing UUIDS

tender shard
#

maybe show your stacktrace, then we'll see

grave vale
#

Hey, I'm having a problem in which whenever I try building, it says it's finished and all. But when I look into my projectRoot/builds folder, nothing's there.
(PS: I did setLibsDirName("../builds") in my build.gradle)

Why does that happen?

warm flume
#

theards dont work like if All theards are busy it goes into queue instead of attempting to create another theard?

#

or is there way to force plugin to use fewer theards? instead of creating new each time?

tender shard
grave vale
#

Because IntellIJ Idea builds in projectRoot/build

tender shard
#

I thought you used gradle to build?

#

do you use gradle or intellij to build?

grave vale
#

IntellIJ Idea builds using gradle..

remote swallow
#

if you want to change the output location, get shadow and add destinationDirectory = file("./build/")

grave vale
#

Oh wait holy shit it's there

tender shard
#

IntelliJ's build system is totally different from gradle. what does it say if you hit control twice quickly, then enter gradle properties?

grave vale
#

Nevermind, I don't know how it finally got in my builds folder but it's there

tender shard
#

thats handy

grave vale
#

Let's just hope it keeps working

undone axleBOT
chrome beacon
warm flume
#

what do you mean use spigot?

chrome beacon
#

You're using a fork right now correct?

warm flume
#

true

chrome beacon
#

Yeah don't

warm flume
#

How bad are forks?

chrome beacon
#

Forks will use more threads for better performance

chrome beacon
#

I wouldn't go further than Paper

warm flume
#

i cant believe its able to use 128 theards by the same time

#

and ask for more

chrome beacon
#

I doubt it's using 128 threads

#

If it is you have a real bad fork

warm flume
#

i found it by debugging

#

is my event not opitmized ill switch to default spigot as well rn

chrome beacon
#

You could probably use Paper

#

Though expect no support since you're 7 years out of date

torn shuttle
#

everyone keeps wanting to make and use forks, I'll be the first one to make a spork of spigot

warm flume
#

like i pay for a war machine epyc 7502 running out of theards how

chrome beacon
#

Epyc CPU for mc 💀

warm flume
#

thanks alot man you saved my ass i guess i hope its the right soluation to stay away from this syntetic spigot forks

warm flume
#

i would switch to ryzen 5900x

wet breach
warm flume
#

sec

#
java -Xms128M -XX:MaxRAMPercentage=95.0 -Dterminal.jline=false -Dterminal.ansi=true -jar server.jar
torn shuttle
#

hey wasn't it 128 gigs

remote swallow
#

128 threads

warm flume
#

well it allows up to 95% of max memory

remote swallow
warm flume
#

i did timings

#

nothing really i think Olivio was right those people who try to enchance it just make a syntetic drug from herb (fork , spigot)...

torn shuttle
#

how much mem do the timings say you have?

#

I've had some fun experiences with java not reading how much ram my pc had correctly in the past

warm flume
#

243200

#

its not about memory once again its about theards

remote swallow
#

is it still not happy using spigot/paper?

chrome beacon
warm flume
chrome beacon
#

Hm?

#

What fork are we talking about now

warm flume
#

nah i talk about the forks

#

that they are probably really bad

#

its offtopic Olivo thanks alot i hope the problem will be solved

chrome beacon
green prism
#

Does a bungee 1.19 plugin work in 1.8?

chrome beacon
#

Yes

wet breach
#

google aikars flags and use those and you don't need to use more then 10GB

#

assigning more ram without modifying other things for the JVM will result in negative performance

#

but because you didn't assign a max, java has a maximum setting in regards to allocation

#

it doesn't automatically use the amount of ram you have for the system, think it defaults at 2-4GB

torn oyster
#

?paste

undone axleBOT
wet breach
#

well I should be more technical, it really depends on how it is coded

#

but also depends if the 1.19 plugin was compiled for java 17 or not

manic furnace
#

Is there a way to sent a respawn packet to an player without resetting his inventory?

wet breach
torn oyster
manic furnace
wet breach
#

you wouldn't need a packet, you will need to listen for the event of when they die and take stock of their inventory

#

when they spawn again give back their inventory

opal juniper
#

is api-version 1.12 - 1.19 ?

chrome beacon
#

1.13

echo basalt
torn shuttle
manic furnace
orchid portal
#

Help how to manage an entity? After half a day of googling, I came up with this class, but over 90% of what I found online doesn't work with Minecraft 1.19.2. (NMS class connected)

echo basalt
#

Just mongodb, redis and influxdb working together

chrome beacon
torn shuttle
#

calm down my poor heart

#

I'm having too much fun

chrome beacon
sacred mountain
#

i got mongo and redis working for cross server, what's influx?

orchid portal
sacred mountain
#

velocity? or make it move as if it were using it's ai

#

then you need to use pathfinding

pearl zephyr
#

Is there a way to power redstone or change the state of a piston?

torn oyster
#

ah, my mobs aren't spawning on the negative axis

#

which is really weird

orchid portal
#

So that immediately after spawn, he leaves at certain coordinates

echo basalt
#

So I can go on the server, spam left click and see how long it takes to raycast a single pixel on a client-sided image board

tardy delta
#

me who never used any of these :)

echo basalt
#

time is in microseconds, thousandths of a milli

#

async because I'm paranoid

tardy delta
#

async better /j

echo basalt
#

and yes, invite codes work

#

cross-server, across restarts

tardy delta
#

does that use a Random?

echo basalt
#

yeah

#

I'll worry about unique codes later

#

probably just using a stripped down uuid

#

as of right now it's literally just this

molten hearth
tardy delta
#

ah lol i'd do random.nextInt('Z') + 'a' in a loop or smth

#

then smth with numbers

echo basalt
molten hearth
#

what in the e-roleplay

torn shuttle
echo basalt
#

I only have 3

#

and they're tiny

#

except for skintype but we don't talk about that

tardy delta
#

smoll

torn shuttle
tardy delta
#

i once made an enum where every constant held like 15 booleans

#

😢

torn shuttle
#

this is what enums were made for

torn oyster
torn shuttle
#

to fix the fact sometimes spigot should be using enums but doesn't

tardy delta
#

generic enums when

#

rust has them 🥲

echo basalt
#

magmaguy is using enums? HEH?

#

every time I see you chatting I can't stop thinking of Mister Choco...

torn shuttle
#

forgive me sensei, I must go all out just this once

echo basalt
#

it is not funny anymore

torn shuttle
#

don't blame me if my bangers are earworms even 5 years after release

echo basalt
#

I like how our entire relationship is just us bashing at each other about enums and shitty code in a very funny way

#

you ping me at mf 4am to display some shitty code and then I'm forced to just not sleep for the rest of the night

torn shuttle
#

what do you meaaaaaaaaaaaaaaaaaan shitty code

#

check this bad boy out

echo basalt
#

why are you creating a firework effect for each iteration

torn shuttle
#

because i do good code

echo basalt
#

oh yeah I forgor

tardy delta
#

lmao streams, normal for loop and ::forEach

echo basalt
#

I gotta order some eye protection I'm starting to go blind

torn shuttle
#

why use many method when single method work

echo basalt
#

this code is like looking at the sun, it just blinds you

torn shuttle
#

yeah I've been told I am bright young lad

echo basalt
torn shuttle
#

I could put all of that in a single line

#

probably a single method too

tardy delta
#

why is the classroom aware of its storage lol

echo basalt
#

haha nesting go brr

echo basalt
#

every single operation messes with the caching database

tardy delta
#

brr

orchid portal
#

I found this, but there are errors

echo basalt
tardy delta
#

oh god

torn shuttle
# echo basalt haha nesting go brr

this makes me want to open a charity where people can contribute to your education by helping pay for the electricity bill of the tazer that will taze you every time you write code like this

tardy delta
#

never used CF::allOf actually

echo basalt
#

It's a pain but it all worky cross-server cross-machine

torn shuttle
#

imagine being such a redditor the only way you know how to communicate is by saying the name of subreddits

#

bet you have an enum of subreddits somewhere in your codebase

echo basalt
#

fuckin ell

torn shuttle
#

don't go trying to hide that greasemonkey script you made with subreddit pseudo-enums

#

hm I forgot what I was fixing

#

oh right target tracking

pearl zephyr
#

Is there a way to power redstone or change the state of a piston?

torn shuttle
#

oh man this is going to be fun to implement

echo basalt
#

want me to roast you all the way through?

torn shuttle
#

can't be done, my code is unroastable

#

it is, after all, coded in my image

echo basalt
#

mans got the uno cards up his sleeve

torn shuttle
#

it's like trying to roast my beard, many have tried and all they've gotten out of it is falling in love

torn shuttle
#

I think I'll just cache the locations / entities after the wait time and before the repeat

#

that probably makes the most sense

#

oh man this is actually made more complicated by the fact that different actions would require one of two caches but not both and just generating both is a bit expensive

#

ew I might have to store that info in the enum, I am becoming that which I hate most

echo basalt
#

I could predict this from miles away

#

kilometers*

torn shuttle
echo basalt
#

it's fine

#

just right click

#

and hide the tooltip

torn shuttle
#

mama didn't raise no coward, I will face the code I wrote like a man

tardy delta
#

i'd just inline false

echo basalt
#

since you'll probably expand

#

make the braces another like

#

example

#
SPAWN_REINFORCEMENTS(
  true
),
#

looks prettier :)

torn shuttle
#

just when you thought it couldn't get worse

#

I'd rather be reminded that I'll probably die alone in some remote location in canada

echo basalt
#

you'll die in a portuguese coffee shop

torn shuttle
#

a fate worse than death

echo basalt
#

after the coffee you sip gives you a heart attack

#

the old men around you laugh, thinking you're just joking

torn shuttle
#

I'm on my third energy drink today

echo basalt
#

but the scenery soon becomes dreadful

torn shuttle
#

and second coffee

#

it's 12:15pm

echo basalt
#

I haven't eaten anything today

#

I gotta get something to eat I'm hella hungry

#

part of me vividly believes that magmaguy would tase me if we ever met up

#

in broad daylight

torn shuttle
#

dang

#

and here i thought I was underplaying it

#

to hide that

echo basalt
#

actually

#

magmaguy would look around in his community and tase anyone similar to my profile pic

#

in hopes to get me one day

twin venture
#

Hello , good afternoon ..
i want to use protocollib packets to spawn armortands , and rotate them ..
will this be any better than useing bukkit methods?

echo basalt
#

well it won't tick

#

but you'll have to manage it all yourself

twin venture
#

its for a lootbox plugin , its now working with bukkit and without nms

#

but its getting laggy because of rotating

echo basalt
#

are you sure

twin venture
#

yes

#

the animiation should be 1 tick , or it will be to laggy for player's

echo basalt
#

maybe there are some things you can optimize first

twin venture
#

and iam working on 1.8.8 version , i can't update my plugin depend on 1.8.8 , i have added support for newer version and i can do that too
i just want to know if rotating armorstand using packets , will be better for performance

echo basalt
#

this really doesn't sound like a bukkit issue

twin venture
#

ram / cpu

#

its getting so much usage after hours of running the server

urban kernel
#

how do i setup a placeholderapi placeholder

echo basalt
#

I mean yeah but it's probably something else in your code

echo basalt
twin venture
urban kernel
tardy delta
#

arent you supposed to be dead?

torn shuttle
#

illusion you should come to Coimbra one of these days so I can tase you so we can hang out like bitter rivals normal people

urban kernel
echo basalt
#

You should come down south so I can show you around the ghetto

torn shuttle
#

this entire country is a ghetto, I'll be out of it next year

echo basalt
#

you only have a year to come down south

torn shuttle
#

there's no way I'm going to give up homefield advantage for our showdown I'm going down south

echo basalt
#

your city is too nice for me

#

I'd prefer the knowing what parts of the sidewalk are fucked to my advantage

torn shuttle
#

you're going to eat some calçada portuguesa, à maneira de Coimbra

sacred mountain
#

hey anyone know how to check if player has clicked in the direction of another player?

echo basalt
#

dot product

sacred mountain
#

trying to make some sort of target-lock using a ray trace or sym

urban kernel
#

how do i setup a placeholderapi placeholder

sacred mountain
#

for instance this, (i know the other player is null, just the bottom line im thinking about )

#

does hasLineOfSight work

echo basalt
#

uh

#

pretty sure hasLineOfSight is just a rephrased canPathfindTo

#

code internally just checks

sacred mountain
#

oh

echo basalt
#

worlds aren't the same? -> false
Distance above 128? -> false
Blocks clip? -> false

#

so basically it's just a huge 128 raycast

sacred mountain
#

i might just try to make a box matrix in the direction of the player

#

and see if the other player's hitbox intersects

echo basalt
#

you could just like

#

raycast with a set fov

sacred mountain
#

i don't want it exact, or players wont be able to hit each other

#

so like if they click more or less close enough

#

to another player within like a 30 block range

echo basalt
#

yeah so you make the fov more than like 15º

#

or around 20 deg

sacred mountain
#

ooo

torn shuttle
#

alright this is at least mostly working, gotta go

sacred mountain
#

returns the hit entity if available

torn shuttle
#

@echo basalt try not to be a bad influence on the youth while I'm gone

urban kernel
#

how do i setup a placeholderapi placeholder

echo basalt
urban kernel
#

cool

#

but

#

google isn't helpful

sacred mountain
#

💀

echo basalt
#
double fov = 30; // 30 degrees
double fovRadians = Math.toRadians(fov);
double range = 30; // 30 blocks

Location playerLocation = player.getEyeLocation();
Vector playerVector = playerLocation.toVector();

for(Player target : Bukkit.getOnlinePlayers()) {
  Location targetLocation = target.getEyeLocation();

  if(targetLocation.distanceSquared(playerLocation) > range*range) {
    continue;
  }

  Vector targetVector = targetLocation.toVector();
  double intersectionAngle = playerVector.angle(targetVector);

  if(angle > fovRadians) {
    continue
  }

  // do something with your target
}
sacred mountain
#

20 seconds? ish

tardy delta
#

im on same page ye

urban kernel
#

i dont fucking understand shit from that

#

(:

sacred mountain
tardy delta
#

whats difficult about it

sacred mountain
#

its literally

#

spoonfeeding

#

every line of code

#

there is literally nothing there you can mess up

urban kernel
#

uhhhhhh

#

except from

#

how to actually

#

register the placeholder

#

and set it

#

??

tardy delta
#

create a placeholder or use one?

sacred mountain
#

bruh

echo basalt
#

You aren't trying..

sacred mountain
#

wouldya look at that

sacred mountain
#

no way, it tells me how to register a placeholder expansion

urban kernel
tardy delta
#

then follow link i sent above

urban kernel
#

how do i set data to it???

sacred mountain
#

then whats the problme

#

set data?

tardy delta
#

what data

sacred mountain
#

is that class inside your plugin

urban kernel
#

yes

sacred mountain
#

and did you register it

urban kernel
#

no.. idk how

#

i have the class created with required data changed

echo basalt
#

fucking hell

sacred mountain
#

brub

tardy delta
#

dang

sacred mountain
#

skill issue

#

too slow

urban kernel
#

ok ok ty

sacred mountain
#

deveroonie

#

u spent like no time searching

echo basalt
#

I generally just prefer to have a map

sacred mountain
#

map of what

#

method references

echo basalt
#
private final Map<String, Function<Player, String>> placeholders = new HashMap<>();

public Whatever() {
  placeholders.put("name", Player::getName);
}

@Override
public String getIdentifier() {
    return "test";
}

@Override
public String getAuthor() {
    return "Illusion";
}

@Override
public String getVersion() {
    return "1.0";
}

@Override
public String onPlaceholderRequest(Player player, String params) {
    if (placeholders.containsKey(params))
        return placeholders.get(params).apply(player);

    return null;
}
urban kernel
sacred mountain
#

your constructor

#

where

tardy delta
#

uhh bruh

sacred mountain
#

LevelExpansion send code

echo basalt
#

so %test_name% would just return the player's name

sacred mountain
#

in paste

#

?paste

undone axleBOT
echo basalt
#

this dude doesn't even understand dependency injection I'm done

urban kernel
hazy parrot
#

?learnjava at this point tbh

undone axleBOT
sacred mountain
#

where is ur constructor

#

u dont even need it for rthat tbh

#

just remove the 'this'

urban kernel
#

i just copied this

sacred mountain
#

if you dont understand how that works then idk what ur doing. Your expansion doesnt even do anything and will probably break

#

thats the base structure bruh

#

it literally says at the top

echo basalt
#

funny how he labels himself as a "developer" on his bio

urban kernel
#

Your expansion doesnt even do anything
wanna bet

sacred mountain
#

yes i do.

urban kernel
echo basalt
#

You'd understand basic concepts regardless of what language you're working with

#

HEHEHEHAW

sacred mountain
#

🗿

urban kernel
#

html / css / js

echo basalt
#

if you call css a programming language imma whoop your ass

#

how tf do you write database code in css

#

Same for HTML, it's just glorified xml

sacred mountain
#

bro what

#

html

sacred mountain
#

crying

urban kernel
echo basalt
#

js is understandable

#

but like

static ingot
#

damn, y'all gatekeepy fr

echo basalt
#

copypasting code

sacred mountain
#

javascript is not for sane humans

echo basalt
#

hell naw

tardy delta
#

got two hours basic programming in college tmrw :(