#development

1 messages · Page 99 of 1

leaden sinew
#
  1. That’s what return false does
#

You shouldn’t return false in onCommand

strange remnant
#

So what should I use?

proud pebble
#

return true

topaz gust
#

@strange remnant replace all your return falses with return trues the purpose of return false is in case they used it incorrectly you can fast send the correct usage kinda redundant

#

for (Player player : Bukkit.getOnlinePlayers()) {
if (!(p.hasPermission("flipsmc.sc")));
player.sendMessage(mess);
return false;

        }
#

And for this you need to use continue if they don’t have the permission and continue also if they do

#

No return!

#

Any questions please lmk

strange remnant
#

@topaz gust imma change it right now

#

Your amazing @topaz gust

topaz gust
#

Your welcome

#

Staffchats is a good start plugin so nice to see

high edge
#

what in the is that code

sharp hemlock
#

Anyone got experience in the luck perms api, i can't see to find on how to remove all parent groups from a player if they match my filter

#

How would i remove that group from the player?

warm steppe
#

you have to use nodes i believe

#

wait ill show u an example on what i used

dense drift
warm steppe
#
    public static List<String> getUserGroups(String player) {
        ArrayList<String> groups = new ArrayList<>();
        net.luckperms.api.model.user.User user = plugin.api.getUserManager().getUser(player);

        if (user == null) return new ArrayList<>(Collections.singleton("null"));

        for (Node group : user.getNodes(NodeType.INHERITANCE)) {
            groups.add(group.getKey());
        }

        return groups;
    }
#

with this you can find all groups that user has

#

if you change it a bit you can make it remove group from user

lyric gyro
#

you can do something like```java
user.data().clear(NodeType.INHERITANCE.predicate(inheritanceNode -> {
// your filter
}))

sharp hemlock
#

i just tested my code and it works well, but this looks like its more cleaner

lyric gyro
#

btw you can get the User in other ways;
UserManager#modifyUser(UUID, Consumer<User>) will load it and save it after running the function you pass to it
If you have a Player you can use the PlayerAdapter (LuckPerms#getPlayerAdapter) to simply convert a Player into a User (or get other kinds of cached data)

sharp hemlock
#

Yeah this works, thank you

#

its a bit weird they use a node system though

lyric gyro
#

how come?

formal crane
#

Why can't i use these imports?
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity;
import net.minecraft.server.v1_12_R1.EntityInsentient;
it cant find craftbukkit & minecraft

pure crater
#

If you want to use NMS, then you have to install the NMS into your local repo

formal crane
#

whats nms?

pure crater
#

net.minecraft.server

#

the second import at least is NMS

formal crane
#

where can i download those file to put in my plugin?

distant turret
#

I must be doing something wrong, but when using the AutoSellAPI ```Multiplier multiplier = AutoSellAPI.getMultiplier(e.getPlayer());

returns null
dense galleon
#

In general, is it good practice to ALWAYS have a priority level next to an event handler?

dusky harness
#

no

graceful hedge
#

next?

dusky harness
#

at least not that im aware of

#

theres a reason why theres a default value :))

graceful hedge
#

Oh

dusky harness
graceful hedge
#

Well probably personal preference

dusky harness
#

maybe

dense galleon
#

I mean

dusky harness
#

but it adds extra verbosity

dense galleon
#

Yeahh sure but

dusky harness
#

its also like doing ignoreCancelled = false

dense galleon
#

If I got a pretty big plugin

#

Which has multiple classes handling the same event in different ways, then it's a good idea to give them different priorities

#

To make sure things run as I expect them to

graceful hedge
#

Sure

#

Or just have one event handler

dense galleon
#

Nah that'd be way too messy

graceful hedge
#

And then have x amount of observers which you invoke in that event handler

dusky harness
#

what i do is have a class ex PlayerJoinListener and have the actual listener handling in there

dense galleon
#

I don't want one event handler to handle 4 different things related to how arrows behave when they hit an entity

graceful hedge
#

Assuming it’s the same priority and same ignoreCancelled state

dense galleon
#

Ah I have different listeners based on what they handle

graceful hedge
dusky harness
#

¯_(ツ)_/¯

dense galleon
#

So EntityListener, ItemListener, WeaponListener (for some stuff in my plugin), InventoryListener, MiscListener

graceful hedge
#

You could diminish the amount to 1 and then have something like dkim or like an array of Consumers with that event type

dense galleon
#

What

#

I have not touched consumers yet

graceful hedge
#

Oh

dense galleon
#

And I probably won't until I got more time in my hands

graceful hedge
#

It’s similar to Runnable

#

But it takes an argument also

dense galleon
#

These days I got time to just do small changes to my plugin, not big refactors that may take a few hours but yeah I need to look into those

digital nova
#

How can i check if an hook exist?

dusky harness
#

what hook?

pure crater
#

You look at your bedroom door

#

and try to find a hook behind the door

#

if there isnt one, you can't hang your clothes

robust flower
graceful hedge
#

Just if they all happen to be with the same priority and ignoreCancelled state, why not just use one direct Bukkit event handler and then delegate?

robust flower
#

I see, well, yes, I have already done both ways

graceful hedge
#

Yeah, I usually do it due to the reflection (invocation) overhead which is usually negligible but yeah

robust flower
#

all those methods are extensions for my custom InfernalDeathEvent event

graceful hedge
#

Ah

#

Looks good

dusky harness
graceful hedge
#

High level!

#

I’ve tried ext funcs with Lombok and that was quite nice and hella confusing

brittle thunder
robust flower
graceful hedge
#

Hmm yeah

#

I really don’t know what’s best

#

Just using a static method where you take the instance as an argument

#

Or that

brittle thunder
#

Extensions are probably the better way to go in kt

graceful hedge
#

Yeah, but just generally?

brittle thunder
#

Yes

graceful hedge
#

I mean if we disregard language

#

Is it considered more clean?

robust flower
brittle thunder
#

Not sure if there will be any proper answer if we disregard language

graceful hedge
#

Hmm yeah language is probably playing a major role in it

brittle thunder
#

Extensions here would serve the same purpose as the static functions except making it easier to see where its invokable

graceful hedge
#

Ah true

graceful hedge
#

Then we would just call dropMobLoots(event)

robust flower
graceful hedge
#

Uh yes

#

event.getInfernalType() probably

#

Etc

robust flower
#

but why static though? would this method be on the same class as the listener?

graceful hedge
#

Yeah well if it doesn’t require any variables from the listener instance (or methods)

#

Then why not make it static

#
  • invokestatic is supposed to be a little bit faster than invokevirtual (if we made it an private instance method for example)
robust flower
#

sure, in Java, why not, but I'm usually lazy a bit careful with static cause sometimes it might throw the reader off a bit (or at least I get thrown a bit sometimes by it)

graceful hedge
#

If you get thrown of by it, you can use the class name before invocation like
ListenerClass.dropMobLoots(event);

leaden sinew
copper spear
#

im i high or when i press k it wont work

#

for i in range(360):
# setting pace with a modulus
if keyboard.on_press_key == "k":
print("test")
break
if i%6==0:
pyautogui.moveTo(X+Rmath.cos(math.radians(i)),Y+Rmath.sin(math.radians(i)))

#

where tf is my key

#

omg

#

this keyboard dont have it

#

i cant do the three keys

cerulean birch
#

`

leaden sinew
#

`

pure crater
#

`

shell vessel
#

`

brittle thunder
#

`

steady ingot
#

`

steady ingot
#

Is there a way to present an api in a api (third party dependency in my api) without shading it?

lyric gyro
#

Maven or gradle?

steady ingot
#

Gradle

lyric gyro
#

Thank god

#

The API module/project would use the java-library plugin instead of java, and the exposed dependencies you'd include as api/compileOnlyApi as opposed to implementation/compileOnly

#

The "internal" dependencies would stay as implementation/compileOnly

#

Anyway goodnight uwu~~\✨

lyric gyro
cerulean birch
#

Besides length of the build script

dense drift
#

compilation speed of gradle is above maven's for example

graceful hedge
#

Gradle is more configurable without the need of plugins

#

(Which in itself takes time to write from my experience)

rugged bane
#

As someone who recently moved from Maven to Gradle, Gradle is insanely faster

cerulean birch
#

So would it be worth my time to learn to use gradle

rugged bane
#

Around 0.6-1s compile time

#

Yeah

cerulean birch
#

Hm aight

rugged bane
#

I was a maven fanboy for ages, but can’t lie Gradle is pretty nice

#

And fast to compile

#

I won’t ever go to that Kotlin crap though

cerulean birch
#

Any downsides/things to know about or watch out for when switching?

rugged bane
#

With your current maven script, what do you use? Just dependencies?

#

If you’ve got something complex like a full on task, then a bit harder

#

If you’re just compiling against spigot for example isn’t too bad

cerulean birch
#

Default build script made by Minecraft plugin and yeah dependencies/repos

rugged bane
#

Then you’re good to go, next level up would be shading libraries and relocating, which isn’t that complex once you get your head round it

#

I recently started moving projects to Gradle

#

Got many projects to go yet tho 😅😅

graceful hedge
sudden sand
#

gradle > maven for speed @cerulean birch

#

and it's 10x easier

#

and it's way more configurable

graceful hedge
#

I mean maven isn’t harder than gradle necessarily

sudden sand
graceful hedge
#

Idk I mean they’re arguably at the same difficulty level, though for sure gradle is more concise.

rugged bane
#

Yeah maven is more in huge blocks, Gradle is more condensed

dense galleon
#

Alright this is I guess a bit of a stretch

#

I got this default method in my interface, which I want to return a different class based on the provided parameter

#
    default SoulState getSoulStateIfPresent(SoulStateType type) {
        switch (type) {
            case MARKED -> {
                return (Marked) getCurrentSoulStates().getOrDefault(type, null);
            }
            case DAZZLED -> {
                return (Dazzled) getCurrentSoulStates().getOrDefault(type, null);
            }
            case HASTED -> {
                return (Hasted) getCurrentSoulStates().getOrDefault(type, null);
            }
            default -> {
                return null;
            }
        }
    }```

I have no idea how to have it return `Marked`, `Hasted` or `Dazzled` based on the `SoulStateType`
#

Do I need some wildcard? Or a generic?

#

Is it like this...?

    default <T extends SoulState> T getSoulStateIfPresent(SoulStateType type) {
        return (T) getCurrentSoulStates().get(type);
    }```
#

I am getting a warning about an unchecked cast though

pure crater
#

it kind of defeats the purpose of the interface cause its implementation specific

dense galleon
#

Where should I have such a method?

#

Just in a util class?

pure crater
#

Inside SoulStateType enum

#

or something

#

i need to know the full details

dense galleon
#

Oh yeah that makes sense

pure crater
#

the point of interfaces is to try and generify stuff. By adding that switch statement for implementation specific method it gets rid of that generality

#

so its bad

#

cause anything should be able to implement the interface

dense galleon
#

Do I not need to declare a generic next to my class name

dense galleon
#

So this:

    public static <T extends SoulState> T getSoulStateIfPresent(Soul soul, SoulStateType type) {
        return soul.getCurrentSoulStates().containsKey(type) ? (T) soul.getCurrentSoulStates().get(type) : null;
    }``` just as a static method in my enum class
dense drift
#

is better to use get and do a null check instead of containsKey and get

#

because that's basically what containsKey does

pure crater
#

or just literally only do soul.getCurrentSoulStates().get(type)

#

lmfao

#

no need to check

#

as soul.getCurrentSoulStates().get(type) will already return null if key doesnt exist

dense drift
#

not sure how casting null works but sure

dense galleon
#

Yeah that's the thing, casting null seems sus

warm steppe
#

why*

heavy wadi
#

Am I right to assume that the constructor and the getters are completely redundant here?
I can basically remove the whole body of the class and just use possibleDrops() instead of getPossibleDrops() when working with the object?

public record CustomDropSet(Integer xp, Map<CustomDrop, Float> possibleDrops) {

    public CustomDropSet(Integer xp, Map<CustomDrop, Float> possibleDrops) {
        this.xp = xp;
        this.possibleDrops = possibleDrops;
    }

    public Integer getXp() { return xp; }

    public Map<CustomDrop, Float> getPossibleDrops() { return possibleDrops; }
}
graceful hedge
#

But it’s preference at most

lyric gyro
#

Also FYI record classes are meant to be "immutable data carriers"; that means that, ideally, none of its components should be mutable too

#

Basically: the record type is the data, so the map should not be modifiable, it just holds data (also you can just use int lol)

vale spindle
#

Hi, I've an issue with registering a custom placeholder.

I have this in my main class:

        if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")){
            PlaceholderAPI.registerPlaceholderHook(this, new PluginPlaceholders());
        }```

And it says the following in the console:
```XML
[17:10:07 INFO]: [TAB] Expansion BedWars is used but not installed. Installing!
[17:10:07 INFO]: Failed to find an expansion named: BedWars```

How can i fix this?
lyric gyro
#

I'm assuming you're using your own expansion in TAB?

#

You might need to add TAB as loadbefore in your plugin.yml

#

To ensure your plugin, well, loads before tab

vale spindle
#

I will try

lyric gyro
vale spindle
#

Nope, didn't work.

heavy wadi
# lyric gyro Basically: the record type *is* the data, so the map __should__ not be modifiab...

Thanks for your reply 🙂 I believe I'm using the record correctly. I set the data when I'm initializing it, but I'm not modifying it afterwards, I'm just using getters to work with the data.

The Integer is nullable, that's why I'm using the object as opposed to just int. I actually have it annotated with @Nullable in my code, but I simplified it a bit because I didn't want to post huge ass code block in here 😄

prisma briar
vale spindle
prisma briar
#

Check the papi wiki to register the expansion, I can't give it to you I'm in my phone rn

#

@vale spindle

tight junco
#

barry said no

molten wagon
#

I have counter a issue. When download a project from github change one method and push it to github it take whole class (it first remove all methods and imports and add that back). Only happens when push that class first time. Even if I only change one method or add 1 space.

forest jay
odd prawn
lone saddle
#

@odd prawn Change the .get to .getDouble for yaw and pitch

lone saddle
#

remove the extends main

odd prawn
strange remnant
#

Then my HashMap wont work

lone saddle
forest jay
lone saddle
strange remnant
#

It gives an error

odd prawn
lone saddle
#

show ur code

strange remnant
odd prawn
strange remnant
native tide
#

Hey everyone 👋
I'm having some trouble with Gradle building a plugin. I've tried searching the issue online, but to no avail.

FAILURE: Build failed with an exception.

* What went wrong:
Could not find spigot-api-1.17.1-R0.1-SNAPSHOT.jar (org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT:20211030.233838-4).
Searched in the following locations:
    https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.17.1-R0.1-SNAPSHOT/spigot-api-1.17.1-R0.1-20211030.233838-4.jar

As I understand this is typically a failure to find the specified dependency in the maven repo. I've went ahead and added these guys to the repositories section. No change in build result.

repositories {
    mavenCentral() // Added
    mavenLocal()// Added
    maven { url = "https://dl.cloudsmith.io/public/arcane/archive/maven/" }
    maven { url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } // Added
    maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' } // Added
    maven { url = 'https://oss.sonatype.org/content/repositories/central' } // Added
}```

What should I try next? I keep searching things but at this point I feel like I'm not going anywhere. This is a nearly unmodified public repo btw, in case anyone wants to take a look: https://github.com/VolmitSoftware/Iris
lone saddle
#

@strange remnant Make something in your main like

public static Main instance;
public static Main getInstance() {
        return instance;
    }

then you can go in your Freeze class and change the plugin.frozenPlayers to Main.getInstance().frozenPlayers

lone saddle
native tide
strange remnant
#

this.getCommand("freeze").setExecutor(new Freeze());

#

This gives me an error now

#

for idk what reason

topaz gust
#

?di

neat pierBOT
lone saddle
strange remnant
#

I didn't make an command class

topaz gust
#

You can see what I mean with the dependency injection part above

lone saddle
#

was easier to type on phone

topaz gust
lone saddle
#

Alright, but thanks for the info for him and also me

topaz gust
#

Also sorry if it sounds harsh just a pet peeve of mine

lone saddle
#

naah all good haha, i appreciate that, would have needed that type of persons when i started to learn to code haha

strange remnant
strange remnant
#

Thanks for all the help this time
I fixed it all myself 😉

#

`` Main plugin;

public Freeze(Main freeze) {
    plugin = freeze;
}``
#

This was the only problem

topaz gust
#

Yeah that looks like dependency injection so good

warm steppe
dusky harness
warm steppe
#

who?

dusky harness
#

u

topaz gust
#

^ wrong name but it’s technically fine

strange remnant
#

Hate all you want but I still fixed myself?
I am a beginner so don't judge lmao

dusky harness
#

although again thats also preference

topaz gust
#

I assume that’s what he meant

dusky harness
#

¯_(ツ)_/¯

#

ye

topaz gust
#

Technically it’s more logical, but it’s just a variable name

dusky harness
#

¯_(ツ)_/¯

warm steppe
#

how u know my pronoun ???

#

ok jk

topaz gust
#

I just use he cause I’m old

#

If I offend you I apologise. But it’s not done with ill intention

warm steppe
#

im just fucking around, i didnt mean that

strange remnant
#

then open your mouth and don't just ignore it

#

tf

dusky harness
#

i just saw ur message

warm steppe
#

this dude lmao

topaz gust
#

Developers are lazy what can I say

dusky harness
warm steppe
#

pastes his code without any problem description

topaz gust
#

Indeed

strange remnant
# dusky harness 🤢

first you want to laugh at it. And now you want to be the good guy with next time give us the error, If you scroll up I gave the error but nvm dude

warm steppe
#

no

#

u didnt

strange remnant
topaz gust
#

It’s fine we were all beginners once. As for your code I can’t fully assess it but from that snippet you seemed to have read what I asked the bot to send.

dusky harness
strange remnant
#

-_-

#

Oke

graceful hedge
#

For instance generally all the fields should be above constructors and methods

dusky harness
#

this is what i would see

  • none of your messages besides the one with the code
  • other people
  • your message not in a reply

conclusion: you're not in a conversation

sorry that I didn't see it, mb

warm steppe
#

main class named Main tho

#

dont do that

#

pls

graceful hedge
#

Yeah should probably consider a refactor there

dusky harness
graceful hedge
#

Dkim I think he heard you

warm steppe
#

ok he is probably new here

topaz gust
#

It’s okay dkim I understand why you got confused so I presume he has also now

warm steppe
#

dont be rude dkim, we all have our hard days or smth, just chill

strange remnant
warm steppe
#

boyss just stop it

graceful hedge
#

Anyways Flips, dkim is nice if you just get to know him (: I promise

warm steppe
#

this is development channel

#

and bye guys i go to sleep

graceful hedge
#

Sleep tight and good night

warm steppe
#

😋 ✨ ✨

topaz gust
#

Anyhoo, some tips for your next project or you can refractor like conclure suggested.

  1. Try and avoid naming your main class main (it’s messy when you start working with dependencies)
  2. Try and use getters and setters as your public variable accessors and keep the variable itself private.
  3. Try to keep up Dependency Injection it will help you out a lot in the long term
strange remnant
topaz gust
#

And from my time in this discord if someone doesn’t smack me in the first minute my advice was probably not awful

strange remnant
#

I mean a spigot thing

graceful hedge
topaz gust
#

So an example would be your freezePlayers map

strange remnant
#

And really learning

#

so Main was just easy

graceful hedge
#

Yeah, keep fighting (:

topaz gust
#

Instead of having that variable public instead have it private and create some getters and setters to modify it.

#

Example:

private List<UUID> playersIds = new ArrayList<>();

public List<UUID> getPlayerIds() {
return playerIds
}

#

Done on phone so don’t smack me too hard guys

dusky harness
#

ex in java public HashMap<Player, Location> frozenPlayers = new HashMap<>(); the variable is public - which means that you can do plugin.frozenPlayers (accessing the variable directly)

a better way would be ```java
private HashMap<Player, Location> frozenPlayers = new HashMap<>();

public HashMap<Player, Location> getFrozenPlayers() { // a getter method
return frozenPlayers;
}
```which you would have to do plugin.getFrozenPlayers() instead (and since frozenPlayers is private, if you try doing plugin.frozenPlayers, it'll error out)

an example from the spigot api would be Bukkit.getWorlds() instead of Bukkit.worlds

strange remnant
#

I just read a small explanation about Private and Public

#

It's just basically Private cannot access other classes in the same package
and public can

#

that is it right?

dusky harness
#

oops

#

didn't mean to send that yet

strange remnant
strange remnant
#

Wait can you copy that message and send me that privately?

strange remnant
#

Yes so I can read threw that if I need it

dusky harness
#

sure

strange remnant
#

Should I test myself tomorrow and send you the end result of that?

#

Because it's a bit late today for me

strange remnant
#

Ok I will if I have enough time to go on my pc a lot of tests this week and learning Java.

#

Is a lot to do at the same time

dusky harness
# strange remnant that is it right?

private and public doesn't have to do with packages (although if you don't put any modifier then it's package private I think - which is what you might be finding out about)

private means that it can't be accessed from any other classes - packages don't matter with private

public is correct - for example if getWorlds() in Bukkit.getWorlds() was private, then it would error when you tried to do Bukkit.getWorlds(), since Bukkit is a different class than what you're calling it from

and if you don't want to read all that xD:
tldr: you got it correct except private means cannot access from any other class, not just from package

strange remnant
#

but if I make it a private HashMap it needs another line to call that HashMap and that needs to be public so it can be accessed in any other class

dusky harness
strange remnant
#

so in my freeze class I will need to change it to example "plugin.getfrozenPlayers"

dusky harness
#

yes

#

remember that methods always have () (which are used for parameters) - plugin.getFrozenPlayers()

#

ex ```java
private HashMap<Player, Location> frozenPlayers = new HashMap<>();

public HashMap<Player, Location> getFrozenPlayers() { // a getter method
return frozenPlayers;
}
```notice how the variable name is just frozenPlayers while the method name has getFrozenPlayers()

#

and if you remove the () from the method it'll start erroring 🥴

strange remnant
#

so it will be plugin.getFrozenPlayers().put

dusky harness
#

yep 👍

graceful hedge
#

Ideally we don’t expose virgin data structures like that but yeah it’s somewhat better than a mere public field.

dusky harness
#

lol

#

i think what conclure means is that instead of getFrozenPlayers().put it's better to do addFrozenPlayer(player, location)

graceful hedge
#

^

strange remnant
#

plugin.frozenPlayers.put(target, target.getLocation().clone());

#

I now have this

#

so I will need to do

#

plugin.addfrozenPlayers(player, location)

dusky harness
# strange remnant parameters are used to call for something, That's why we need that because we ar...

close - methods are used to call for something
this is a method: ```java
public HashMap<Player, Location> getFrozenPlayers() { // a getter method
return frozenPlayers;
}

and this is a parameter: ```java
()

an example of using a parameter in ur plugin is ```java
public Freeze(Freeze freeze) {
plugin = freeze;
}

the "method" is ```java
public Freeze(Freeze freeze) {
    plugin = freeze;
}
```while the parameter is ```java
(Freeze freeze)
```which are basically variables passed into methods
leaden sinew
#

No you Freeze, freeze

strange remnant
#

public Freeze(Main freeze) {
plugin = freeze;

#

its now this

leaden sinew
#

}

Would also be a constructor

dusky harness
leaden sinew
#

Should be this.frozenPlayers.put(player, location);

#

Come on Dkim

#

Never forget this

dusky harness
#

🥲

dusky harness
leaden sinew
#

No buts

dusky harness
#

what about static abusing 😌

#

no this required

#

ez

leaden sinew
#

I have a workaround

dusky harness
#

👀

leaden sinew
#

Sort of

bitter basin
#

i hate this

dusky harness
leaden sinew
#

static Plugin THIS
THIS.frozenPlayers.put(player, location

#

Beat that

dusky harness
#

genius

leaden sinew
#

Oh wait

#

Actually

leaden sinew
#

Plugin should be named This

strange remnant
#

so I can find it easily

leaden sinew
#

This.frozenPlayers.put

#

@strange remnant its right here

strange remnant
#

click on my profile and rate my steam name

#

100% certified banned on 15 fivem servers for that

strange remnant
#

😒

#

hahahahahaha

dusky harness
leaden sinew
#

graceful hedge
#

Just don’t use the smile-…

leaden sinew
#

My emojis broke

#

💱

#

Fixed it

strange remnant
graceful hedge
#

Btw Flips are you familiar with the four principles of object orientation?

graceful hedge
#

Dkim for the sake of god

dusky harness
#

xD

#

sry 🥲

graceful hedge
#

That’s haunting me lol

dusky harness
#

FlipsMC r u still here

leaden sinew
dusky harness
#

😌

#

aw

#

bad barry

leaden sinew
#

Dang

dusky harness
#

barry isn't educated about the secrets of coding D:

graceful hedge
leaden sinew
dusky harness
#

skript = best coding/programming language

dusky harness
#

bad barry

leaden sinew
#

Un-bel-ievable

dusky harness
#

indeed

strange remnant
#

And I just fixed it so default players can't use the command without flipsmc.freeze 🙂

dusky harness
strange remnant
#

now if the don't have the permission the will get a nice message "You don't have the facilities for that!'

graceful hedge
strange remnant
#

over 2 days I am gonna learn about config's so I don't have to hard code it with my own prefixes

dusky harness
#

btw

#

a suggestion: don't store Players
instead store the player's UUIDs

when putting in map: map.put(player.getUniqueId(), ..) instead of map.put(player, ..)

and to convert a UUID to Player, use Bukkit.getPlayer(uuid)

#

reason: the Player might become invalid

#

ex if a player leaves the server

#

which will cause a memory leak 🙃 (not a noticeable one for now, but good practice to not storing Players)

pure crater
strange remnant
#

Memory leaks are just so nice on god

pure crater
#

XD

strange remnant
dusky harness
strange remnant
#

I tried there is nothing like getUniqueId

dusky harness
strange remnant
#

look for the screenshot

#

in pm

leaden sinew
# pure crater dont forget javaassist too

I haven't heard of it,
when would you ever want to do

ClassFile cf = new ClassFile(
  false, "com.baeldung.JavassistGeneratedClass", null);
cf.setInterfaces(new String[] {"java.lang.Cloneable"});

FieldInfo f = new FieldInfo(cf.getConstPool(), "id", "I");
f.setAccessFlags(AccessFlag.PUBLIC);
cf.addField(f);

Over creating a new class yourself?

#

Or is it for editing classes?

pure crater
#

luckperms uses dynamic class generation with bytebuddy i heard

#

i just said javaassist cause a lot of plugins have it shaded but dont know what it does

#

XD

leaden sinew
#

oh

#

When would you need dynamic class generation?

graceful hedge
#

Rarely

#

Most times we can just load a jar file with classes dynamically

pure crater
#

bytebuddy

#

it doesnt use java assist

#

The LuckPerms API has so many events you can subscribe to on the event bus that the implementation is generated at runtime

lyric gyro
#

❤️

strange remnant
#

@EventHandler public void onPlayerMoveBlock(PlayerMoveEvent e) { if(!frozenPlayers.containsKey(e.getPlayer())) { return; } if(e.getFrom().getBlockX() != e.getTo().getBlockX() || e.getFrom().getBlockZ() != e.getTo().getBlockZ()){ e.getPlayer().teleport(frozenPlayers.get(e.getPlayer())); }

I changed it based on UUID like @dusky harness told me to but now I fucked up my @EventHandler
Because it can't get the player out of the HashMap

dusky harness
strange remnant
#

I almost had it then because I tried that but

#

almost

dusky harness
#

and then teleport(frozenPlayers.get(e.getPlayer().getUniqueId()))

limber lagoon
#

😳

dusky harness
#

hi remence

limber lagoon
#

What happened

#

Hi dkim 😄

dusky harness
#

nothing

dusky harness
#

HI

#

:D

limber lagoon
#

What've you been up to

dusky harness
#

i'm just waiting atm for a server owner to test smth ¯_(ツ)_/¯

#

but they busy with uni and stuff D:

limber lagoon
#

Uni???

dusky harness
#

so today i did 0 coding

#

:(

limber lagoon
#

I thought you were 14 wtf

strange remnant
dusky harness
strange remnant
#

Stupid parameters

dusky harness
limber lagoon
dusky harness
#

wait remence

limber lagoon
#

Yeah

dusky harness
limber lagoon
#

Is that what I sent?

#

Wait a second

#

👀

strange remnant
#

I fixed a potential memory leak, That wasn't there yet

limber lagoon
#

Are you seeing what I'm seeing?

dusky harness
graceful hedge
dusky harness
#

sorry i had to show remence before i died

limber lagoon
#

Wow that's annoying 😂

strange remnant
#

alt + f4

limber lagoon
#

alt + f4 life

#

quit game

pulsar ferry
#

I see someone has been watching Demon Slayer

strange remnant
#

You know what its already so fucking late for me just let me try to fix the hashmap thing

pure crater
#

easy fix

limber lagoon
pure crater
#

no more memory leaks

#

EVER

limber lagoon
#

What did you think of Demon Slayer?

strange remnant
#

Would you look at that

tight junco
#

while (true) Thread.sleep(1000)

heavy wadi
steady ingot
#

for anyone that has done C++, are methods usually in PascalCase, camelCase, or snake_case? I heard that variables should be in snake_case.

bright pier
#

I've mostly been using PascalCase personally for variables and methods. But I guess it's personal preference

steady ingot
#

Rn, I'm using PascalCase for Classes, camelCase for methods, and snake_case for variables. Feels all over the place.

#
  • coming form languages where I never ever use snake_case, half my variables end up in camelCase :/
bright pier
#

I'm following an online course thingy (for game development with c++ and Unreal Engine) and i've been using PascalCase for everything. (apart from the usual prefixing bools with b or enums with e)

#

I personally think it looks better with c++ but for something like Java, it's PascalCase for classes, and camelCase for methods and camelCase and snake_case for variables.

steady ingot
#

Time to go clean up all my camelCase variables and change them into snake_case ones :/

bright pier
#

I guess it really comes down to personal preference. I like how it all looks with everything being PascalCase for c++

#

If I was going to use something else for variables and methods, Id pick camelCase for them unless its long, then i'd use snake_case for readability.

heavy wadi
#

I believe when I was doing c++ a while back, everything camelCase was the way to go.
Personally, I do actually prefer snake_case for variables tho. It's a little more annoying to write, but way easier to read imo.

lyric gyro
#

Oh god that was 7 hours ago lmao

heavy wadi
#

Hehe, I was just curious 😄

#

Question: How do you deal with NullPointerExceptions, unchecked casts etc. IntelliJ complains about that can only occur for example if the user deletes essential parts of the config file?
Do you just annotate them with @SuppressWarnings and call it a day?

prisma briar
#

But you should consider trying to fix that tho.

strange remnant
#

switching over to IntelliJ

#

how much + am I getting

prisma briar
#

are you asking?

strange remnant
#

yeah

prisma briar
#

well, there's a lot but the most important is you will code more faster and efficient

#

because of the auto-completions and lots of shortcuts

strange remnant
#

are there good plugins for IntelliJ

#

so what

prisma briar
#

I don't use plugins on IntelliJ.

#

Except the discord integration

heavy wadi
strange remnant
#

Eclipse

prisma briar
#

it will be so much better

strange remnant
#

Eclipse is easy to use but people keep saying that IntelliJ is gonna be beter

heavy wadi
#

It is much better. Just give it a shot. You can test the community version for free or even the full version if you are a student. The only reason not to use IntelliJ is if you have an old PC, because IntelliJ will eat considerably more RAM and be heavier on your CPU.

strange remnant
#

I guess I will be fine

prisma briar
#

you probably uses eclipse because the video tutorial that you watched is using eclipse

strange remnant
#

how to out zoom in IntelliJ

broken elbow
#

I use ctrl + wheel but I'm pretty sure I had to change it to use that. in the settings you should be able to set the keybinds

lone saddle
#

File - Settings - Editor - General and first setting Change font size with Ctrl+Mouse Wheel

steady ingot
dense drift
#

No?

#

If the value is not present in config it will return null or a default value specified by you or for instance 0 for getInt

steady ingot
#

I couldn't get it ho work with docdex, never properly used it before

vagrant bobcat
#

Can someone compile a plugin for me? Its with Gradle and Kotlin.

robust flower
#

why? compile it yourself, it's easy

vagrant bobcat
#

Im not a Developer

robust flower
#

no worries

#

open your terminal, cd "the path of the folder", run ./gradlew shadowJar and that should be it

if on windows, open your cmd, cd /d "the path of the folder", run gradlew shadowJar and that should be it

vagrant bobcat
#

.rar folder or a normal folder?

robust flower
#

extract the .rar into a folder

vagrant bobcat
#

Done

robust flower
#

then just follow the instructions

#

your jar will be located at "projectfolder"/build/libs/theJar.jar

vagrant bobcat
robust flower
#

are you using windows or linux?

vagrant bobcat
#

windows

robust flower
#

then navigate to the project folder (where you extracted the .rar), and click on this empty space, then copy the text that will appear, that's your path

#

I have some questions about permission management:

  • What is the easiest best way of temporarily giving or taking permissions from a Player? From what I've read, seems like PermissionAttachment is the way to go, but I never really used it so I'm not sure how it works, for example, does those "attachments" persist between server restarts (do I have to explicitly remove them)? How do they behave alongside permission plugins like LuckPerms?
  • If PermissionAttachment are not the best way of doing this, then does LuckPerms expose some kind of method to allow plugins to easily give or remove (temporary) permissions?

Btw, for the use case I'm looking into, all permissions can be safety reset when a player logs off, that's completely acceptable (and even desirable).

#

@vagrant bobcat send a pic of your project files, it seems like you're missing the gradle wrapper

vagrant bobcat
#

I will send it in a bit, eating rn.

icy shadow
robust flower
vagrant bobcat
#

Could not find or load it

manic saddle
#

In command sl, description & aliases have only 3 spaces. They need 4 spaces.

dense galleon
#

IntelliJ keeps telling me to convert a lot of my listener classes into records

#

Should I do that..?

lyric gyro
#

no

manic saddle
#

commands need 2 spaces, description and aliases need 4

#

`depend:

  • SL`
    Do you have on your server plugin called SL?
#

Do you know what for is depend?

lyric gyro
# robust flower I have some questions about permission management: - What is the ~~easiest~~ be...

do those "attachments" persist between server restarts
as far as Bukkit (no perms plugin) or w/ LuckPerms is concerned, no they don't
How do they behave alongside permission plugins like LuckPerms?
LP integrates with them nicely, it's just like another permission added but that doesn't save to storage
does LuckPerms expose some kind of method to allow plugins to easily give or remove (temporary) permissions?
it has a whole ass API so you bet it's possible
all permissions can be safety reset when a player logs off
again, with just bukkit or w/ LP that is the case; I personally don't know the behavior with other perms plugins (pex, groupmanager, powerranks, ultrapermissions, ...) because I'm simply not interested lol
seems like PermissionAttachment is the way to go
it's probably the least convoluted way; depending on how the other perms plugins work, it may or may not be a "one size fits all" solution

manic saddle
#

Are you using Eclipse/Intellij?

dense galleon
#

is there any way to check what is different between two items which seem identical to me?

#

It's something with the NBT tags for sure

#

But I have no idea what it could be, still

manic saddle
#

And where is your plugin.yml in your plugin?

#

Try to open the extracted .jar file with rar/zip and see if there is plugin.yml

robust flower
dense galleon
#

This is such an annoying warning that imo doesn't make any sense in the context of when I use such method

#

Is there any way to suppress the warning just for the setBaseValue() method?

leaden sinew
#

It may throw an NPE

robust flower
#

with KT you can easily use ?. to avoid that there should be a suppress for that, you only have to press your ALT + Enter key, press whatever arrow it is on the first option, then select "suppress warning for this method"

leaden sinew
dense galleon
leaden sinew
#

Why not null check?

robust flower
leaden sinew
#

And you shouldn’t be repeating code that much

dense galleon
#

It doesnt disable it just for setBasevalue()

robust flower
#

yes, isn't that what you want?

dense galleon
#

I might need it for other methods

dense galleon
robust flower
dense galleon
#

Yeah I know, but if I got a lot of methods that use that method... it's a lot of repetition

robust flower
#

then disable that shit on your project or class man

#

you have to choose the scope: line, method, class, package, project

dense galleon
# leaden sinew DRY

If I got 25 entities with different stats I have to repeat myself in order to give them different stats

#

Kinda unavoidable

leaden sinew
#

You can simplify it

dense galleon
#

Adding a method which takes 3 parameters like HP damage and speed I know

leaden sinew
#

setStats(1, 1, 1)

#

So why not do it?

dense galleon
#

I just got around to refactoring that I guess lol ops

#

Either way I am using that specific method in a LOT of methods in different contexts in different classes

#

That's why I was asking if there was a way to suppress a warning related to one specific method

leaden sinew
#

Just use null checks

forest jay
#

hi! I am trying to get all the current servers on a bungeecord network, when a command is sent. But it doesnt return any. I think I am not waiting long enough for the message to be send back, but I am not sure. The code is a bit separated but I can try and send the bulk of it

#

here is the code that runs the first function: java public Inventory createLobbyInv(Player p) { SendMessage.sendGatherLobbies(p); lobbyGUI = Bukkit.createInventory(p, 54, ChatColor.AQUA + "Lobby Selector"); for (int i = 0; i < lobbies.size(); i++) { lobbies.get(i).setAmount(i); lobbyGUI.addItem(lobbies.get(i)); } return lobbyGUI; }

dense galleon
#

I might be asking a bit much

dusky harness
#

👀

dense galleon
#

But I made a method which supposedly returns a 'safe' location for a mob to spawn in, can someone tell me if it's any good or if it's utter trash 😂

neat pierBOT
dusky harness
#

/paste = broken

dense galleon
#

Well that didnt work

#

Tried using it for the first time 😂

#

min and max are two corners of a square area

dusky harness
#

not allowing negative numbers
btw how come?

dense drift
#

There's Block#getRelative btw

dense galleon
#

Honestly now that I think about it I don't remember, I have made this method like 1.5 years ago and I am just now revisiting it to see how I can improve it

#

What's that..?

dusky harness
dense galleon
#

Oh that's cool I didn't know

#

so Block beneath = world.getBlockAt(spawnLoc).getRelative(BlockFace.DOWN); instead of Block beneath = world.getBlockAt(spawnLoc.clone().add(0, -1, 0));

#

Either way, the method is probably slow

#

But I don't know how else I could improve it..?

#

Also, you are telling me that with BlockFace I can technically get a block's surrounding 26 blocks?

wintry grove
#

is it posible to set the note and instrument on a note block?

#

if so how?

dusky harness
#

d;sub_interfaces spigot BlockState

uneven lanternBOT
#
Sub Interfaces:
org.bukkit.block.Banner
org.bukkit.block.Bell
org.bukkit.block.EndGateway
org.bukkit.block.Chest
org.bukkit.block.Dispenser
org.bukkit.block.Comparator
org.bukkit.block.BlastFurnace
org.bukkit.block.Conduit
org.bukkit.block.SculkSensor
org.bukkit.block.Sign
org.bukkit.block.CreatureSpawner
org.bukkit.block.CommandBlock
org.bukkit.block.Dropper
org.bukkit.block.Campfire
org.bukkit.block.Container```
dusky harness
#

hmm

proud pebble
#

blockdata

wintry grove
#

nvm found it

proud pebble
#

just search noteblock on spigot javadocs and you wouldve found it

wintry grove
#

ok so it changes the state, but then instantly it converts it back to a normal state, whats the problem?

leaden sinew
#

You have to do Block#setState if you didn’t

wintry grove
#

doesnt exist

#

is Block#setBlockData

#

and I did that

lyric gyro
wintry grove
#

my little brain cant understand it

lyric gyro
#

Get block state
Modify block state
Update block state

wintry grove
#

tried like that

#

nothing

#

and nothing is that it still instantly changes back to harp

formal crane
#

Why does this only run once?

            public void run() {
                vc.getManager().setName(getConfig().getString("channel_name").replace("{online}", String.valueOf(Bukkit.getOnlinePlayers().size()))).queue();
            }
        }, 0, 60*20);```
proud pebble
#

so it runs every minute?

formal crane
#

fixed it

#

discord was rate limiting

proud pebble
#

Discord do be like that sometimes

formal crane
#

yea

dusky harness
#

u should probably not send that every minute :p

#

it's api abuse iirc

fiery pollen
#

How would you get all the classes that implement an interface?

graceful hedge
#

That’s a bit problematic

#

Classes are loaded and unloaded dynamically at runtime

fiery pollen
#

hmm

dusky harness
#

if you're trying to register listeners then I can give a solution

fiery pollen
#

Not really no, but i found a better way of doing it

dusky harness
#

alr

fiery pollen
#

But thanks anyway

formal crane
#

idk where it came from

dusky harness
#

reload 👀

formal crane
#

restart doesnt change it

#

i think itsz my scheduler

dusky harness
#

show CorePacket class

formal crane
#

schedule.autoBroadcast(); is what i added recent

dusky harness
#

can u show me Scheduler class?

formal crane
dusky harness
#

extends JavaPlugin

#

you can only extend JavaPlugin in the main class

formal crane
#

really?

dusky harness
#

yes

formal crane
#

ty

#

fixed

dusky harness
#

np

formal crane
#

Why do i get this weird random A using "&a&lM&2&lN &f» &f"; ?

tight junco
#

invalid character

#

compile utf-8 into y our plugin

formal crane
#

how

tight junco
#

gradle or maven

#

praying gradle

formal crane
#

yea gradle

tight junco
#

compileJava.options.encoding = 'UTF-8'

#

add that somewhere near source compatibility or somethin

formal crane
#

like this?

java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    sourceCompatibility = javaVersion
    targetCompatibility = javaVersion
    compileJava.options.encoding = 'UTF-8'
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
}```
tight junco
#

i guess

formal crane
#

didnt change

tight junco
#

show your whole gradle file hmm

formal crane
tight junco
#

move it to underneath version then

formal crane
#
version = '1.0'
compileJava.options.encoding = 'UTF-8'```
didnt work
graceful hedge
#

How do you build?

formal crane
#

shadowjar

graceful hedge
#

Try clearing your cache first (./gradlew clean)

formal crane
#

where

graceful hedge
#

It’s a task also

#

Just like build or shadowJar

formal crane
#

used it

graceful hedge
#

Try again then

formal crane
#

oh its working ty

graceful hedge
copper spear
#

okay can someone helpo me with python minecraft coding?

#

i have this smp that me and my friends play in

#

im trying to make a script that breaks trees

#

but i just cant get the player to look where i want him too

#

i give it the right cordents but it just barly moves or just doeswhat i want it to

#

im so confused

#

if anyone understand what im trying to say

copper spear
#

it works when im not in minecraft but when im in game

#

it dosent

pulsar ferry
#

Python minecraft coding?

dusky harness
#
  • why
  • what library are you using
  • button='right' thonking
  • wouldn't the trees uh... disappear once you break them?
proud pebble
#

from the context theyre trying to make a script to auto break logs ingame, kinda like a macro

dusky harness
#

if you want something to break logs you'd need a hack client or a mod

#

aka Impact

#

🤡

marble nimbus
#

when using Gradle is it possible to specify isTransistive = false without using () around the compileOnly?

the FAWE API has this as an example compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit:1.17-<version>") { isTransitive = false }
but in my Gradle I don't use () around the dependency because I think it looks better, is there a way to specify it anyways?

#

it looks like this for me : compileOnly 'com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit:1.17-393'

leaden sinew
#

What logger should I use with a fabric mod?

shell moon
#

Someone knows a good regex to detect links?

wintry grove
leaden sinew
wintry grove
pulsar ferry
lyric gyro
#

Logger LOGGER = LogManager.getLogger(UrMumMod.class)

leaden sinew
#

Thanks

wintry grove
lyric gyro
#

"the same it has"

#

right..

wintry grove
#

in my own way to say it lmao

#

sorry if I didnt explain me well

lyric gyro
#

🙃

rigid mountain
#

Question, Sooo I have this idea where i want to make a miniture world basically, 10x10 chunks inside a void world and then spiral it outwards like skyblock islands. I have the spiral down, but im not sure how to generate only the 10x10 chunk inside the void world based off a central location. Can someone explain how i should go abt this

marble nimbus
rigid mountain
#

Ok

wintry grove
#

is there an easier way to get commands registered in the plugin.yml? I have got an entire custom system for the execution and so but for the plugin.yml thing is a pain

steady ingot
leaden sinew
#

How would I get the world name of a world with fabric? Sorry I'm new to making mods.

lyric gyro
#

World::resourceKey or something like that

leaden sinew
#

Thank you

limber hedge
#

How do I turn a UUID as a string into a players name?

dense drift
#

Bukkit#getPlayer(uuid)#getName() ?

void orchid
limber hedge
#

the string into uuid

#

if thay player is offline

#

the getPlayer doesnt work

void orchid
#

Read what I said

limber hedge
#

ty

void orchid
#

you're very welcome

wary void
#

There's this thing I've seen in spigot coding where there's an Entity enum, then inside of Entity they have a LivingEntity and inside of that they have a Mob category and a Monster category and its this whole tree. I want to use this in one of my plugins but I have no idea what this is called. Can someone point me in the right direction for what to look up?

#

If it helps, specifically what I want is an Enum called CustomSound which has both drum sounds and musical sounds. I want a function to specify if it takes a drum sound or a musical one. drum and musical sounds would both have the same information which is just a minecraft Sound

#

I already have the CustomSound enum I just dont now how to make the sub enums

void orchid
#

same information as a minecraft sound? mind elaborating on that one?

wary void
#
public enum CustomSound {
    HARP(Sound.BLOCK_NOTE_BLOCK_HARP),
    BASS(Sound.BLOCK_NOTE_BLOCK_BASS),
    IRON_XYLOPHONE(Sound.BLOCK_NOTE_BLOCK_IRON_XYLOPHONE),
    BELL(Sound.BLOCK_NOTE_BLOCK_BELL),
    BASEDRUM(Sound.BLOCK_NOTE_BLOCK_BASEDRUM),
    SNARE(Sound.BLOCK_NOTE_BLOCK_SNARE),
    HAT(Sound.BLOCK_NOTE_BLOCK_HAT);

    public final Sound sound;

    CustomSound(Sound sound) {
        this.sound = sound;
    }
}```

I have this an an enum. HARP, BASS, IRON_XYLOPHONE, and BELL are musical sounds but BASEDRUM, SNARE, and HAT are drum sounds. I was hoping there would be a way to categories them into categories like "drum" and "musical" and only take one of those categories in a function but I think I've realized that what I'm looking for doesn't actually exist :/
void orchid
#

If i understood you correctly, you could create two Enums, Drum & Musical. from there, move the appropriate sounds to their own respective category

#

hold on

#

right, apparently Enums could implement interfaces so, you could have those two Enums implement CustomSound and have a static? method on CustomSound which would take CustomSound as an argument?

wary void
#

That pretty much sounds like what I'm looking for, what would I look up to find how exactly to do that?

void orchid
#

which parts do you want me to elaborate on?

ebon whale
#

Public static -

wary void
#

I was mostly looking for the exact syntax which is why I was looking for what I could look up to find it

wary void
wary void
#

sorry I didnt mean to reply to that message like that

void orchid
#

I don't mind

wary void
#

I think at this point I've gotten enough to be able to find what I'm looking for? So thank you for this

void orchid
#

I hope that was the case, feel free to @ me if you couldn't figure it out

wary void
#

Alright I will

#

Thank you once again

void orchid
#

You're very welcome, good luck to you! :)

fiery pollen
#

Would i be able to give a potioneffect to a player infinitly?

lyric gyro
#

Yes give it max value length

warm steppe
#

Has anyone here ever user JDA? If so, then why does ShardManager not return any guild if the bot clearly is in one?

broken elbow
#

no. never heard of it

broken elbow
#

oh wait you didnt say null

#

fuck nvm

warm steppe
#

It just doesn't loop at all xd

#

like if there were no guilds

broken elbow
#

check the CacheFlags you've disabled

#

maybe there's one for that

#

also apparently that can return empty if the jda hasn't fully started yet or something like that

#

yeah. according to this post, guilds are always cached and another post said that JDA#getGuilds can return null or empty if the jda has not fully started yet.

warm steppe
#

ah nvm i had to do shard#awaitReady()

broken elbow
#

yeah. tho they recommend you use the ReadyEvent instead

#

u should join their discord. there's a lot of useful stuff there

broken elbow
formal crane
#

anyone here experienced with jda?

broken elbow
#

no

broken elbow
formal crane
#

because i am getting an error when disabling the bot

wintry grove
broken elbow
broken elbow
wintry grove
neat pierBOT
formal crane
#

I fixed it

broken elbow
formal crane
#

changed shutdown to shutdownNow

wintry grove
stuck hearth
wintry grove
#

what

#

dumb barry

wheat carbon
#

yeah barry is stupid

wintry grove
#

the point is that Matt's code is way too wonky and confusing for me

#

then I come to ask

robust flower
wintry grove
#

I was looking for how he did manage the annotations

#

I want to be able to use em for registering commands like you do in the plugin.yml

stuck hearth
#

There's literally a commented section that says "used to register in plugin.yml"

wintry grove
#

I'll check back later

#

I'm dumb

marble nimbus
#

how can I get the center of an AABB constructed by 2 vectors?

#

(I am shit at math btw)

pulsar ferry
marble nimbus
#

also does anybody know PacketWrappers for Protocolllib for 1.17?

#

or anything above 1.15

pulsar ferry
#

Very sadge

marble nimbus
#

so how does this: ```Java
int id = ThreadLocalRandom.current().nextInt(99000, 99999);
WrapperPlayServerSpawnEntityLiving wrapperPlayServerSpawnEntityLiving = new WrapperPlayServerSpawnEntityLiving();
wrapperPlayServerSpawnEntityLiving.setType(EntityType.ARMOR_STAND);
wrapperPlayServerSpawnEntityLiving.setEntityID(id);
wrapperPlayServerSpawnEntityLiving.setX(player.getLocation().getX());
wrapperPlayServerSpawnEntityLiving.setY(player.getLocation().getY());
wrapperPlayServerSpawnEntityLiving.setZ(player.getLocation().getZ());
wrapperPlayServerSpawnEntityLiving.sendPacket(player);

    WrapperPlayServerEntityEquipment17 wrapperPlayServerEntityEquipment17 = new WrapperPlayServerEntityEquipment17();
    wrapperPlayServerEntityEquipment17.setEntityID(id);
    wrapperPlayServerEntityEquipment17.setItem(EnumWrappers.ItemSlot.HEAD, new ItemUtils(Material.DIAMOND_HELMET).build());
    wrapperPlayServerEntityEquipment17.sendPacket(player);``` end up in this?
#

Is that a new Type of ArmorStand?

tight junco
#

that is such a long variable name holy shit

#

its also probably because of the entity id

marble nimbus
#

entityIDs matter?! I thought its just an int to keep track of the entity

pulsar ferry
marble nimbus
#

Matt hewp :c why I have a Ghast and not an ArmorStand with a diamond Helmet?

pulsar ferry
#

Matt is currently unavailable please leave your message
Jokes a side, idk sorry i don't really play around with packets that much

lyric gyro
pulsar ferry
#

Those don't exist anymore

marble nimbus
#

I think its caused by the Wrapper I am using? its last update was for 1.15.2

#

but there isn't anything newer

#

and building Packets from scratch is painful

lyric gyro
marble nimbus
#

the Wrapper does that, it takes the EntityType uses #getTypeId and puts that into the Packet

#

my guess is that something got changed in some update which causes the Wrapper to break

pulsar ferry
marble nimbus
#

let me try using EntityType Ghast instead of Armorstand 😄

lyric gyro
#

but that doesnt work

#

so

tight junco
#

are you spawning entities with packets

lyric gyro
#

he is

marble nimbus
#

Okay so using EntityType Ghast does nothing?

tight junco
#

that spawns a clientside entity

#

feelsShrugMan do with it what you will

marble nimbus
#

That is exactly what I am looking for buuuuut It has NMS :c

#

aka I need to add the bukkit dependency thing

#

which might even be easier then what I am doing

#

Do you think that will also work in 1.17?

tight junco
#

it does

#

if you convert it to 1.17 fingerguns

marble nimbus
#

also when getting the Entity from the Method making it invisible isn't a problem right?

lyric gyro
tight junco
#

that plugin has 1.16-1.17 support for it

neat pierBOT
#
📋 Paste Converted!
https://paste.helpch.at/uquweqeqos

A member of staff has requested I move your pastebin.com paste to our paste.helpch.at!

lyric gyro
#

why

#

you may try my old dirty fix

#

Ah that wouldnt work on 1.17 i thunk

marble nimbus
#

we will find out in about 10 sec

#

nope

#

ClassNotFound IRegistry

lyric gyro
#

that was expected

marble nimbus
#

I will just add NMS, it will probably be easier

#

what dependency do I need again?

#

craftbukkit?

lyric gyro
#

try using packet.getEntityTypeModifier().write tho!

marble nimbus
#

will do, can you tell me the dependency for NMS if that doesn't work

pulsar ferry
#

For NMS you need to run buildtools then add spigot instead of spigot-api

marble nimbus
#

but me use paper

#

no spigot

broken elbow
#

then paper instead of paper-api

pulsar ferry
#

You can still ad spigot for NMS but i think paper has a different way

broken elbow
#

also to add it to local maven is very easy

#

you need to run one command on the paper server jar

lyric gyro
#

yeah paper is different in this case

marble nimbus
broken elbow
#

yes. you run a command on the server jar

lyric gyro
#

Yes, paperclip

broken elbow
#

let me see if I can find the command

#

java -Dpaperclip.install=true -jar paperclip.jar

lyric gyro
#

But tho if you're on gradle you may just use paperweight-userdev to develop against mojang mappings!

broken elbow
#

paperclip.jar being the server jar you downloaded

#

but this only works on 1.16.4 or newer

marble nimbus
#

That is cool, all done. took one command, me like

#

ehh wait? net.minecraft doesn't exist?

lyric gyro
marble nimbus
broken elbow
lyric gyro
marble nimbus
marble nimbus
lyric gyro
#

ahh

#

Are you on gradle? Then use paperweight!

marble nimbus
#

ohh I will give it a look once I get this working

#

but currently struggeling with IRegistry

marble nimbus
#

just the entityCount field was wrong because it doesn't exist in Paper its called "b"
Field entityCount = Class.forName("net.minecraft.world.entity.Entity").getDeclaredField("b");

#

doesn't look sketchy at all

#

But I can't seem to Cast the returned entity to Armorstand ?

#

oh because you never return it lol

pure crater
#

md reverted all fields back into their obfuscated form

#

it used to be named properly like entityCount between 1.12 and 1.16, but in 1.17, md just decided to revert them to the obfuscated form

#

your code wont work for 1.12 - 1.16

#

but then again, 1.17 supremacy good

#

lol

marble nimbus
#

this doesn't seem like a good Idea nor a good solution: return loc.getNearbyLivingEntities(1).stream().filter(p -> p.getEntityId() == packet.b()).collect(Collectors.toList()).get(0);

marble nimbus
pure crater
#

Mhm thats why i dont think its a big deal at the end of the day XD

marble nimbus
#

okay so my solution did not work :/

#

let me upload to paste

dense drift
#

first().orElse(null);

marble nimbus
#

my current solution doesn't work because the List is empty

#

so I need a different way of getting the Entity

pure crater
#

because idk if spigot copies the uuid over, or sets it into the memory with like same value you know

#

print the ID's just in case

#

d;paper Entity#getUniqueUUID

uneven lanternBOT
pure crater
#

Nevermind

#

its an integer

#

bruh

#

just print out both ids regardless ig

marble nimbus
#

so neither using the entityid nor the UUID of the Entity I am able to get the Entity

#

it returns null

#

I am printing out the UUID and I get : fb9b705b-9a23-48fb-9992-d458e9f4aa91

#

is it maybe because its spawned using Packets so it doesn't actually exist?

lyric gyro
#

Hi, I'm trying to get an entity that is max 5 blocks away from a Player, I know I should use raytrace, but I couldn't find a raytrace entity method. can anyone help? I use spigot 1.17.1

pulsar ferry
#

d;spigot World#getNearbyEntities

uneven lanternBOT
#
@NotNull
Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z, @Nullable Predicate filter)```
Description:

Returns a list of entities within a bounding box centered around a Location.

This may not consider entities in currently unloaded chunks. Some implementations may impose artificial restrictions on the size of the search bounding box.

Returns:

the collection of entities near location. This will always be a non-null collection.

Parameters:

location - The center of the bounding box
x - 1/2 the size of the box along x axis
y - 1/2 the size of the box along y axis
z - 1/2 the size of the box along z axis
filter - only entities that fulfill this predicate are considered, or null to consider all entities

lyric gyro
#

the player needs to be looking at entity

dense drift
lyric gyro
dense drift
#

d;spigot livingentity#haslineofsight

uneven lanternBOT
#
boolean hasLineOfSight(@NotNull Entity other)```
Description:

Checks whether the living entity has block line of sight to another.

This uses the same algorithm that hostile mobs use to find the closest player.

Returns:

true if there is a line of sight, false if not

Parameters:

other - the entity to determine line of sight to

broken elbow
#

have you tried debugging?

#

ugh

pulsar ferry
#

foods.contains(event.getItem().getType()) btw, no need to loop

broken elbow
#

^ that

#

and also debug the sprinting

ocean raptor
#

and use enumset

leaden sinew
ocean raptor
#
    @EventHandler
    public void onFoodDrop(PlayerItemConsumeEvent event) {
        Bukkit.broadcastMessage("contains: " + foods.contains(event.getItem().getType());
        Bukkit.broadcastMessage("sprinting: " + event.getPlayer().isSprinting());
    }
#

@ashen sigil

#

= 3 food bars iirc

#

you cant run while your food bar is equal or lower than 3