#help-development

1 messages · Page 1347 of 1

deft sedge
#

bc of how code works

quaint mantle
#

try that

deft sedge
#

ok i will

quaint mantle
#

I have never touched books

#

never crafted one either

sick ravine
#

i recommend

if (!item.getType().equals(Material.WRITTEN_BOOK)) {
    player.sendMessage(ChatColor.RED + "You have to hold your data book to start the game!");
    return true;
}

BookMeta meta = (BookMeta) item.getItemMeta();
String testPage = meta.getPage(0);
player.sendMessage(testPage);

else is redundant

deft sedge
#

yea

#

ik

sick ravine
#

And
😳 👉 👈

if (!item.getType().equals(Material.WRITTEN_BOOK)) {
    player.sendMessage(ChatColor.RED + "You have to hold your data book to start the game!");
    return true;
}

BookMeta meta = (BookMeta) item.getItemMeta();

[there was nothing here]

String testPage = meta.getPage(0);
player.sendMessage(testPage);
quaint mantle
#
if (meta.getPageCount() <= 0) {
    player.sendMessage(ChatColor.RED + "Book is empty!");
    return true;
}

String testPage = meta.getPage(0);
#

this is my favorite part

deft sedge
#

I got it working

quaint mantle
#

does it start at 1?

deft sedge
#

@quaint mantle u were right thanks!

#

yea it does

#

lol

#

ill improve code

deft geode
#

How can I make setFireTicks infinite? what value?

quaint mantle
#

wait can a written_book ever be 0 pages

#

I don't think so

deft sedge
#

no

#

i thought it could

quaint mantle
#

useless check

deft sedge
#

because sometimes 0 is one

quaint mantle
#

because even if it's empty it still has the 1st page

deft geode
deft sedge
#

because someone wanted to confuse ppl

#

yea i know but somethimes in programming the first index is 0

quaint mantle
#

yea

deft sedge
#

but not for books APPARENTLY

#

k thanks everybody

quaint mantle
#

well that's a minecraft thing

vocal cloud
#

Gotta throw an exception with a 'This is literally impossible how'

quaint mantle
#

you checked if it was the 0th page then opened the 0th page

sick ravine
quaint mantle
#

I have one of those mike

#

if I ever see it, I'll know something went severely wrong

sick ravine
#

BookMeta should be burned at the stake

quaint mantle
#

y2k21 or something

deft sedge
#

ok

#

i get it

#

i messed up

#

lol

#

thanks guy

#

s

#

have a good night everybody!

quaint mantle
#

yes man

#

you too

sick ravine
#

sorry for giving wrong code

quaint mantle
#

huh I wonder where my impossible check is

#

I write some funny stuff sometimes

#

aw I think I got rid of it

sick ravine
#

hm?

south onyx
#

I want to make it so that when a person puts an axe in a smithing table, and a blaze powder in a smithing table, it makes the result an axe that has all the enchants of the axe that the player put in the smithing table, but also with fire aspect x. how do i do this?

young knoll
#

If there is a PrepareItemSmith event or similar you can use that to copy the input item and add fire aspect

#

And then just register a simple smithing recipe so the event is triggered

south onyx
#

oh ok, ill try that

young knoll
#

If there isn’t an event for that you will have to use the inventory click event to determine when they put the two items in and manually set the output

quaint mantle
#

There is one

sick ravine
#

baka 😳

quaint mantle
#

Welcome to cancer:

    public net.md_5.bungee.api.ChatColor getColour(String clan) {
        java.awt.Color colour = new java.awt.Color(DyeColor.valueOf(clanData.getString("clan." + clan + ".colour")).getColor().asRGB());
        return net.md_5.bungee.api.ChatColor.of(colour);
    }

        ...
        
        format = getColour(clan) + clan + ChatColor.DARK_GRAY + format;

DyeColor.getColor() returns a org.bukkit.Color

topaz atlas
#

Is it possible to import all the things you need to make a plugin without actually making the plugin jar file like importing org.bukkit.plugin.java.JavaPlugin ?

#

I am asking because it will save me alot of time

limber dust
topaz atlas
#

Yes. Like you pretty much need to import the jar file including like the module

#

unless I am mistaken.

#

@limber dust

limber dust
#

i am so confused on what you mean

topaz atlas
#

I want to make a plugin without putting it in a jar file

#

I am sort of new to this and i think it would be faster. I am not making it public.

limber dust
#

wait, so code the plugin, but not compile it and run it on a server?

#

no

#

not possible what so ever

#

if thats what you mean

young knoll
#

Sounds like an API

#

Kind of

topaz atlas
#

So you cant do import org.bukkit.plugin.java.JavaPlugin outside of a plugin jar file

young knoll
#

I mean you can

#

But it won’t do anything

topaz atlas
#

even it its a regular clas file

#

oh

young knoll
#

Plugins are regular class files

topaz atlas
#

So I can make a plugin without making it public?

sick ravine
#

The JVM loads the code from .jar and recompiles it to program 0 1

young knoll
#

Do you want a private plugin for your server?

topaz atlas
#

Yes

young knoll
#

If so just don’t release the jar to anyone

topaz atlas
#

Ok thanks

limber dust
#

then just don't send the jar to anyone or post to spigot

topaz atlas
#

any software recommendations to make it?

limber dust
#

intellij, or eclipse

#

i personally use intellij

sick ravine
#

I still don't quite understand what was going on here xD

limber dust
#

i didn't understand the first part either

drowsy helm
#

Coming from using primarily eclipse, i woudl recommend use IntelliJ

#

eclipse is pretty outdated and intelliJ offers a bit more

limber dust
#

don't let choco hear ya

drowsy helm
#

im immune to dogman

quaint mantle
#

yes, the dogs own the human

deft geode
#

Why doesn't the RIGHT_CLICK_AIR Action fire when a user isn't holding anything? is there a way to get around this

quaint mantle
#

they have to hold something

deft geode
#

darn

#

it works for LEFT_CLICK_AIR tho

#

and is there a way to get around this? another event fired?

drowsy helm
#

can we get some context

#

what do you need it for exactly

#

might be some work arounds

deft geode
#

I'm doing this little affect where when they right click it throws a projectile

#

Using this currently ```java
if(event.getAction() == Action.LEFT_CLICK_AIR) {
Player sender = event.getPlayer();
if(arrowPowerManager.getActive(sender.getUniqueId())) {
sender.launchProjectile(Arrow.class, sender.getLocation().getDirection().multiply(2)).setFireTicks(Integer.MAX_VALUE);
}
}

quaint mantle
#

that works, but you will need packets for empty right hand click

deft geode
young knoll
#

Iirc it fires as cancelled by default

#

But that may have changed due to mojang changes

deft geode
#

it makes sense that an empty right click wouldn't be sent to the server

#

so are there good docs for packets

quaint mantle
#

i dont know if protocollib actually has the packet

#

ItemStack itemstack = this.player.inventory.getItemInHand(); boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit if (packet15place.face == 255) { if (itemstack == null) { // <----- return; } // CraftBukkit start int itemstackAmount = itemstack.count; PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack); if (event.useItemInHand() != Event.Result.DENY) { this.player.itemInWorldManager.useItem(this.player, this.player.world, itemstack); }

old bukkit forums craftbukkit code

#

horribly formatted

young knoll
#

If it doesn’t trigger the event it probably doesn’t even send a packet

#

But you can try

deft geode
#

I'll live with left click

#

another question: what's the best velocity vector for a completely straight path?
Like a fireball path, it doesn't fall

sick ravine
#

my eyes

#

where is

#

this will fix all problems

deft geode
quaint mantle
#

oh you mean completely straight

deft geode
#

As in no falling whatsoever

#

unaffected by gravity

young knoll
#

You can set no gravity on any entity

quaint mantle
#

Player#launchProjectile(Fireball.class);

deft geode
young knoll
#

Call the method

deft geode
#

I can't affect the entity with Player.launchProjectile

young knoll
#

Sure you can

deft geode
#

oh wait

#

it returns it

#

nevermind

young knoll
#

It returns the projectile

deft geode
#

badbrain

#

i should probably try things before asking you guys because I end up answering it myself sometimes

quaint mantle
#
Arrow arrow = (Arrow) player.launchProjectile(Arrow.class);

arrow.setGravity(0);
young knoll
#

It’s a Boolean

#

Can you implicitly cast int to Boolean? I’ve never tried

drowsy helm
#

no you cant

limber dust
#

only if you could and it would do 0, 1

#

XD

young knoll
#

Sounds like a way for people to make code even harder to read

limber dust
#

isn't that the fun part

quaint mantle
sick ravine
young knoll
#

It returns a generic

drowsy helm
#

anyone wanan see a super ugly method that needs refactoring

quaint mantle
#

so it isnt redundant

young knoll
#

You don’t even need it as an arrow since the method is from entity

quaint mantle
#

if you wanted arrow class methods

drowsy helm
#

its returns Arrow

sick ravine
young knoll
#

Indeed

limber dust
#

it returns the class you put in

quaint mantle
drowsy helm
#

type erasure

#

sexy thang

quaint mantle
#

ugly

deft geode
quaint mantle
#

😳

deft geode
#

finna make me act up

sick ravine
#

😳

quaint mantle
#

horny police

young knoll
#

Can I get uh
A few more pixels

quaint mantle
limber dust
#

XD

deft geode
drowsy helm
#

millennial memes

deft geode
quaint mantle
#

gif game too strong

drowsy helm
#

gifs are a very millennial thing

deft geode
#

walk it like i talk it ima big steppah

sick ravine
#

you like this?

deft geode
#

this does bring a smile to my face

drowsy helm
#

is it possible to Class#cast(x) with type erasure without needing a reference to Class<T>

quaint mantle
#

Ernest Khalimov

deft geode
drowsy helm
#
        if(field.getAnnotation(Serializer.class) != null) {
            VariableSerializer<T> serializer = ((VariableSerializer<T>)field.getAnnotation(Serializer.class).value().getDeclaredConstructor().newInstance());
            value = (T) serializer.serialize((T) field.get(data));
        }```
I have this abomination
deft geode
#

go to horny jail

#

worledit commands it

drowsy helm
#

that i needa fix

sick ravine
#

(the inscription means nothing)

topaz atlas
#

How do you make a event that detects when a player moves and get the players new position?

drowsy helm
#

PlayerMoveEvent

quaint mantle
#

PlayerMoveEvent

quaint mantle
#

getPlayer().getLocation()

topaz atlas
#

Can you send me the docs for player please

sick ravine
#
    @EventHandler
    public void onMove(PlayerMoveEvent event) {
        Location to = event.getTo();
    }
topaz atlas
#

Location to = event.getTo(); Is the position of the player?

young knoll
#

It’s where they are moving to, yes

#

The old position is getFrom

sick ravine
south onyx
sick ravine
#
    @EventHandler(priority = EventPriority.HIGHEST)
    public void onMove(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        player.teleport(new Location(player.getWorld(), 0, 50, 0));
        
        Location to = event.getTo();
        Location yourLocation = player.getLocation();
    }

these locations will be different (I think)

sick ravine
#

send a screenshot with line numbering

south onyx
#

ok

topaz atlas
#

It is confusing Location inLocation to = event.getTo(); for a module that I need to import

#

What varible type is it?

#

Like is it an int

south onyx
#

@sick ravine

sick ravine
#

um

#

lore is null?

south onyx
#

hmm

#

yea maybe

sick ravine
#
if (!meta.hasLore()) {
    //meta no has lore
}
south onyx
#

yeah but the thing is

#

line 59 is on a whole other event

#

and that event is EntityDamageByEntityEvent

#

and also why would that kind of an event cause a problem with the smithing table event?

sick ravine
#

ym

#

EntityDamageByEntityEvent has been triggered

#

xD

south onyx
#

oh

#

wait how

sick ravine
#

see if there will be a bug in the code now

south onyx
#

ok

topaz atlas
#

Hey, are you available?

drowsy helm
#

whos you

topaz atlas
#

Full code: ```
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin {

@EventHandler
public void onMove(PlayerMoveEvent event) {
    Location to = event.getTo();
}

}
``` The system thinks location in Location to = event.getTo(); is a module I did not import yet

#

What type of varible is it

#

Like why am I getting that error

sick ravine
#

um

drowsy helm
#

just import it then

topaz atlas
#

Its not a module inside bukkit

sick ravine
#

what IDE you are using

topaz atlas
#

eclipes

drowsy helm
#

modules are javascript, it's import in java

#

press Ctrl shift O

sick ravine
#

import org.bukkit.Location;

topaz atlas
#

org.bukkit.Location?

#

oh ok

sick ravine
#

replenishing this by hand is tragic

topaz atlas
#

'to' inside Location to = event.getTo(); is invalid

sick ravine
#

?

#

send screenshot

topaz atlas
#

The error says 'The value of the local varible is not used'

#

@sick ravine

sick ravine
#

yellow notifications are information about unnecessary code or bad practice. (you haven't used this variable yet, if you use it this notification will disappear)

#

yellow notifications are not errors, but warnings that something can be done better, but not required

topaz atlas
#

Hopefully, the last question for the day. Location is not a varible so I cant log the players location

drowsy helm
#

to is your variable

#

Location is your type

sick ravine
#

@topaz atlas
Learn to program in java. (Basics of Object Oriented Programming)

dusty herald
#

OOPs 8445_TemmieSmug

sick ravine
#

@topaz atlas

quaint mantle
#

wtf

#

my mother tongue

#

ive never heard that before

#

wheres that from

sick ravine
#

language?

quaint mantle
#

ye

drowsy helm
#

you've never heard someone say that before? lmao

quaint mantle
#

i havent

#

its usually my native language

#

or my pot of tea

sick ravine
#

yy

quaint mantle
#

wow

topaz atlas
#

Name of automatic module 'craftbukkit' is unstable, it is derived from the module's file name.

#

Am I using the wrong jar

drowsy helm
#

are you using maven?

topaz atlas
#

No

#

It was a normal java project

sullen marlin
#

What are you doing with modules?

topaz atlas
#

I am using craftbukkit-1.16.5.jar

#

Code: ```package me.SpiderUnderUrBed.chunkRenderSys;

import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin {

@EventHandler
public void onMove(PlayerMoveEvent event) {
    @SuppressWarnings("unused")
    Location to = event.getTo();
    System.out.println(to);
}

}

patent bloom
#

hey guys, this may be a stupid absolutely moronic question, but i'm reading the whitelist.json file in my server, what is the proper name of the player object? Just player?

topaz atlas
#

md_5?

patent bloom
#

thanks!

sick ravine
#

md5 is deprecated

drowsy helm
#

or you could use OfflinePlayer depending on your usecase

topaz atlas
#

oop

drowsy helm
#

how did you import it

topaz atlas
#

I click add external jars then added it

drowsy helm
#

is it a warn or an error

topaz atlas
#

warn

#

I guess it does not matter then

#

I get errors for thismain: me.SpiderUnderUrBed.chunkRenderSys.Main name: customChunkRenderSys version: '1.0' author: SpiderUnderUrBed

#

Missing property "api".

drowsy helm
#

on launch?

topaz atlas
#

is the only error

#

The ide is telling me it

drowsy helm
#

thats your plugin.yml right

#

not named something else

topaz atlas
#

Yep

drowsy helm
#

try and add
api-version: 1.16

#

your ide shouldnt give you errors on your plugin.yml though

topaz atlas
#

When i added api: '1.16' to the top it stopped

#

Will that ruin launch?

drowsy helm
#

possibly

#

try and compile and see if it works

topaz atlas
#

Ok. Im new to eclipes where is the compile button?

drowsy helm
#

right click

#

export

#

then JAR file

topaz atlas
#

Jar file or runnable jar file

drowsy helm
#

jar file

vapid oyster
#

Hey, I'm trying to read data from my first config file, but struggling to understand how. Here's an example of my config.yml Mode: STRING I want to be able to identify what String is next to Mode: I tried final boolean methodString = plugin.getConfig().getBoolean("Mode.STRING", true); which doesn't seem correct.

sick ravine
#
Mode:
  STRING: true
topaz atlas
#

I get this error:```[05:52:24] [Server thread/ERROR]: Could not load 'plugins/chunkRenderSys.jar' in folder 'plugins'
2021-03-29T05:52:24.882962+00:00 app[worker.1]:
2021-03-29T05:52:24.884933+00:00 app[worker.1]: org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/SpiderUnderUrBed/chunkRenderSys/Main has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 52.0
2021-03-29T05:52:24.884935+00:00 app[worker.1]: at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:137) ~[server.jar:2991-Bukkit-f3f3094]
2021-03-29T05:52:24.884935+00:00 app[worker.1]: at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:393) ~[server.jar:2991-Bukkit-f3f3094]
2021-03-29T05:52:24.884935+00:00 app[worker.1]: at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[server.jar:2991-Bukkit-f3f3094]
2021-03-29T05:52:24.884936+00:00 app[worker.1]: at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:381) ~[server.jar:2991-Bukkit-f3f3094]
2021-03-29T05:52:24.884936+00:00 app[worker.1]: at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:179) ~[server.jar:2991-Bukkit-f3f3094]
2021-03-29T05:52:24.884937+00:00 app[worker.1]: at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:787) ~[server.jar:2991-Bukkit-f3f3094]

vapid oyster
#

Thanks

topaz atlas
#

What version?

#

lower than 10?

sick ravine
candid galleon
#

59 is Java 15

topaz atlas
#

so I need java 10?

candid galleon
#

you're running 52 (Java 8)

#

correct

sullen marlin
#

Is that heroku or something

#

You can't run a Minecraft server on that lol

candid galleon
#

is there any effective difference between
(T) obj vs clazz.cast(obj)

drowsy helm
#

(T) throws an exception

#

sorry not exception, a warning

vapid oyster
# sick ravine ```yml Mode: STRING: true ```

This is my config.yml Mode: STRING: true CHARS: false INTS: false and this is one of my variables, which keeps causing the plugin to fail to start. What am I doing wrong? private boolean methodString = plugin.getConfig().getBoolean("Mode.STRING", true);

candid galleon
#

is there an error log?

sick ravine
vapid oyster
#

Sorry I assumed my variable had something obvious wrong with it, which is why I didn't include error

candid galleon
#

can we see line 15 of the Commands file

sick ravine
#

de.joeakeem.spigotmc.plugin.template.commands.Commands.<init>(Commands.java:15) ~[?:?]

candid galleon
#

it's a NPE, so something is null

vapid oyster
#

This actually is line 15 private boolean methodString = plugin.getConfig().getBoolean("Mode.STRING", true);

candid galleon
#

ah

sick ravine
#

um

#

xD

candid galleon
#

so that's outside of a constructor

drowsy helm
#

plugin probs null

quaint mantle
#

^

candid galleon
#

or method lol

dusty herald
#

plugin is null DogKek

sick ravine
candid galleon
#

so plugin is null cause it's being called before the constructor

#

because it's outside of it

vapid oyster
#

Ohh ok, thanks

topaz atlas
#

I cant find a download for JavaSE-8

#

And I need that for my plugin

#

eclipes does not have JavaSE-8 by default

#

or maybe its my computor

deft geode
#

is there a way to get if the player is crouching

lunar wigeon
#

if (player.isSneaking())

dusty herald
#

Player#isSneaking

deft geode
#

thanks

#

Event fired when player switches their mainhand to a different inventory slot?

#

nvmd

vivid cave
#

when does MapRenderer.render triggers?
Can i have accurate details about its trigger time.
And yeah, i know it is "when a map renders", but the question is "what are the conditions for it to render, what is the time interval between each render if the conditions are met, for how long does it keep rendering"

topaz atlas
#

System.out.println(to); Does not log the string to the console

woven coral
#

why is there no deathcause.,...

topaz atlas
#

Here is the rest of the code

#

import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin {
    
    @EventHandler
    public void onMove(PlayerMoveEvent event) {
        @SuppressWarnings("unused")
        Location to = event.getTo();
        System.out.println(to);
    }
    
}```
#

I need to log the players position

#

please help.

hasty lynx
#

Hello!

how can i get the name of an npc?

lost matrix
topaz atlas
#

Yes

#

When the server starts and the player moves

candid galleon
#

java.lang.ClassCastException: Could not cast 0 to int

topaz atlas
#

So besides @SuppressWarnings("unused") what else do i have to do?

lost matrix
summer scroll
lost matrix
candid galleon
#

well it's a misleading error first of all lol

#
public static <T> T cast(Object obj, Class<T> clazz) {
    if (clazz.isAssignableFrom(obj.getClass()))
        return clazz.cast(obj);
    if (clazz.equals(UUID.class)) {
        return clazz.cast(UUID.fromString((String) obj));
    } else if (clazz.isArray()) {
        if (obj instanceof Collection) {
            Collection<?> col = (Collection<?>) obj;
            return clazz.cast(col.toArray(new Object[0]));
        }
    }
    throw new ClassCastException("Could not cast " + obj + " to " + clazz);
}
#

I have a manual casting method

topaz atlas
#

import <path>

candid galleon
#

any ideas smile?

topaz atlas
#

Can you quickly tell me how to import the listiner?

#

@lost matrix

lost matrix
lost matrix
lost matrix
topaz atlas
#

I understand some parts. I need to know the path to import the module

#

Becuse I need the event listiner

summer scroll
topaz atlas
#

eclipes

hasty lynx
#

i.e. to obtain the name of an npc without the need of its api

lost matrix
candid galleon
#

@lost matrix fixed it by adding

else if (clazz.isPrimitive() && obj instanceof Number) {
            Number n = (Number) obj;
            return (T) n;
        }
hasty lynx
topaz atlas
#

@summer scroll Whats the path to import the event listiner?

#

Nvm i think a just found it

hasty lynx
#

@lost matrix

candid galleon
#

getName should return its name no?

lost matrix
candid galleon
#

ya

lost matrix
candid galleon
#

I'm running into another one now

#

java.lang.ClassCastException: Cannot cast java.lang.Integer to int

ivory sleet
#

What’s up 😮

daring sierra
#

The ceiling

candid galleon
#

LOL apparently this works

#
            Number n = (Number) obj;
            if (clazz.equals(int.class))
                return (T) ((Integer) n.intValue());
lost matrix
candid galleon
#

did that ty

ivory sleet
candid galleon
#

im going insane

daring sierra
#

dont worry i am too

candid galleon
#
return clazz.cast((Integer) n.intValue());
return (T) ((Integer) n.intValue());
#

what is the diff between those two lines

#

clazz is int

hasty lynx
#

I don't have it right now, I just came to ask what method it was.

ivory sleet
#

You cannot use the primitive classes and invoke #cast afaik

candid galleon
#

@hasty lynx Entity#getName

ivory sleet
#

Since it uses generics so it would auto box wouldn’t it

hasty lynx
#

@candid galleon ok not its entityType.getName();

candid galleon
#

if you have an entityType just use Enum#toString

ivory sleet
#

Either case both would autobox

candid galleon
#

i'm not familiar with Class#cast so idk

#

only one of those lines works @ivory sleet

#

which is just bizarre to me

ivory sleet
#

Still haven’t told me what you wanna do

candid galleon
#
public static <T> T cast(Object obj, Class<T> clazz) {
    if (clazz.isAssignableFrom(obj.getClass()))
        return clazz.cast(obj);
    if (clazz.equals(UUID.class)) {
        return clazz.cast(UUID.fromString((String) obj));
    } else if (clazz.isArray()) {
        if (obj instanceof Collection) {
            Collection<?> col = (Collection<?>) obj;
            return clazz.cast(col.toArray(new Object[0]));
        }
    } else if (clazz.isPrimitive() && obj instanceof Number) {
        Number n = (Number) obj;
        if (clazz.equals(int.class))
//                return clazz.cast((Integer) n.intValue());
            return (T) ((Integer) n.intValue());
    }
    throw new ClassCastException("Could not cast " + obj.getClass() + " to " + clazz);
}
#

I'm trying to have a "simple" method to cast a object to another

#

a serialized object*

ivory sleet
#

int to Integer
Integer#valueOf(int)

Integer to int
Number#intValue()

#

Well primitives are a bit special

candid galleon
#

yes exactly

#

hence all the extra if statements and headaches

#

effectively...

#

what the code is doing is casting an Integer to an int

#

but it somehow works by getting the int value, casting it to an Integer, then casting it back to an int

ivory sleet
#

Well you’re not really casting it but rather auto boxing and unboxing it

candid galleon
#

yeah that

#

i can't return the primitive itself because of the generic restriction

#

so I guess it somehow technically works?

ivory sleet
#

Hmm yeah

candid galleon
#
Number n = (Number) obj;
if (clazz.equals(int.class))
    return (T) n;
#

that also works

#

less casting lol

ivory sleet
#

Uh well I guess

#

!Primitives.isWrapperType() is also a thing

#

Maybe not what you want but the Primitives class can be handy fyi (:

lost matrix
# candid galleon ```java Number n = (Number) obj; if (clazz.equals(int.class)) return (T) n; ...

This is what i came up with

  private static final Map<Class<?>, Class<? extends Number>> PRIMITIVE_WRAPPER = new HashMap<>() {{
    this.put(int.class, Integer.class);
    this.put(long.class, Long.class);
    ... and so on
  }};

  private static Optional<Class<? extends Number>> getWrapperOf(Class<?> primitiveClass) {
    return Optional.ofNullable(PRIMITIVE_WRAPPER.get(primitiveClass));
  }

  private static <T extends Number> T wrapPrimitive(Object obj) throws ReflectiveOperationException {
    Class<?> primitiveClass = obj.getClass();
    Optional<Class<? extends Number>> wrapperOptional = getWrapperOf(primitiveClass);
    if (wrapperOptional.isEmpty()) {
      throw new RuntimeException("Not implemented: " + primitiveClass);
    }
    Class<? extends Number> wrapperClass = wrapperOptional.get();
    Constructor<? extends Number> constructor = wrapperClass.getConstructor(primitiveClass);
    return (T) constructor.newInstance(obj);
  }
candid galleon
#

yeah that's better than a bunch of elseifs i spose

#

what's the diff between that and Class#isPrimitive

#

oh i see

lost matrix
#

You dont get incompatible casts

candid galleon
#

that returns true for Integer, isPrimitive is for int

#

god you gotta love generics

#

if anyone wants to critique that class hmu

#

(i'm also completely open to astonishment and "wow that's super cool") 😉

lost matrix
candid galleon
#

like for (Field f : getFields(obj.getClass())) { ?

lost matrix
#

Yeah

candid galleon
#

gotcha

#

what do you mean exactly by serialization depth of 1?

lost matrix
#

For serialisation you would normally use some sort of registry for complex type resolver.
Example: you cant serialise a class that contains another complex object.

candid galleon
#

ah gotcha

#

i'd use recursion for that right?

#

im not actually gonna but theoretically

lost matrix
#

Yes

#

You could make it iterative but the default approach is recursive

latent talon
#

how can i use placeholderapi in an animated tablist that runs (kinda) on onEnable?

maiden briar
#

10:31:14 [SEVERE] java.sql.SQLException: Operation not allowed after ResultSet closed

Why do I get this error?

private static EMCServer getDataBaseServer()
{
    ResultSet rs = MySqlConnection.executeQuery("SELECT * FROM Server");

    if(rs == null)
        return null;

    Map<String, EMCServer> servers = new HashMap<>();

    try
    {
        while(rs.next())
            servers.put(rs.getString(1), JSONConverter.convertServer(rs.getString(2)));

        if(servers.size() == 1)
            return servers.get("server");
    }
    catch(SQLException e)
    {
         e.printStackTrace();
    }
    finally
    {
        try
        {
            rs.close();
        }
        catch(SQLException e)
        {
            e.printStackTrace();
        }
    }

    return null;
}
candid galleon
#

because the Operation isn't allowed after you close it

maiden briar
#

But I am doing exactly what they want: Mapping the results and then look if it contains the correct one

candid galleon
#

no idea, you might be closing a connection somewhere

maiden briar
#

I am closing the connection only in onDisable

#

This is (a part of) the MySqlConnection class

public static ResultSet executeQuery(String SQL)
    {
        if(statement == null)
        {
            try
            {
                throw new Exception("First call the connect method!");
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }

        try
        {
            return statement.executeQuery(SQL);
        }
        catch(SQLException ex)
        {
            ex.printStackTrace();
            return null;
        }
    }```
limber dust
#

you can also check if connection is closed then reopen

maiden briar
#

Where can I make that if check?

#

At the start of the while?

limber dust
#

at the start of the method

maiden briar
#

Ok I can try

limber dust
#
        if(!isConnected()){
            connect();
        }
        //code
``` basic example
maiden briar
#

Ok thanks

#

That's unfortunately not the solution I keep getting the error

#

The solution: Use PreparedStatement, not Statement

#

Why this error? I had never problems with MOTDS

10:49:30 [WARNING] Event ProxyPingEvent(connection=[/31.201.249.78:56725] <-> InitialHandler, response=ServerPing(version=ServerPing.Protocol(name=BungeeCord 1.8.x-1.16.x, protocol=754), players=ServerPing.Players(max=5, online=0, sample=null), description=             Welkom bij EindjeMinecraft!
       7 bij 7 km van Eindhoven in Minecraft!, modinfo=ServerPing.ModInfo(type=FML, modList=[]))) took 328ms to process!
#

Oh now it dissapeared

graceful turret
#

what's the different between 'MinecraftServer#TPS' and 'MinecraftServer#getServer()#.recentTPS[0]'

lost matrix
graceful turret
#

always 20?

lost matrix
#

public static final int TPS = 20;

#

Or do you mean MinecraftServer#recentTps ?

lost matrix
graceful turret
maiden briar
lost matrix
graceful turret
#

there's no recentTPS

#

lmao

lost matrix
maiden briar
#

Oh that is easier

#

Thanks

lost matrix
graceful turret
#

getServer is just an instance

lost matrix
lost matrix
latent talon
#

I see

#

thanks

quaint mantle
#

Hello, how do I make it, that on a certain command it creates a player(from an argument) in config for it to store a number?

lost matrix
quaint mantle
#

it always adds 1 on each command in the config

quaint mantle
#

I know, but I dont know how XD

summer scroll
quaint mantle
#

dont know how to make it like that, I created a class for the command, but I dont know how to CREATE the playername in the config and then add 1 as a number next to it.

summer scroll
quaint mantle
#

Yea, I am just not good with configs yet

summer scroll
#

Ah okay, are you planning to use the default config? which is the config.yml

quaint mantle
#

yes

summer scroll
# quaint mantle yes

Okay you can just get the FileConfiguration with getConfig() method from the MainClass instance.

quaint mantle
#

already have that

#

getConfig().options().copyDefaults();
saveDefaultConfig();

#

currently im not in the main class

summer scroll
#

Pass the config to the command class.

quaint mantle
#

the same way?

summer scroll
#

You can use method FileConfiguration#set() to set a value in the config.

summer scroll
quaint mantle
quaint mantle
quaint mantle
summer scroll
quaint mantle
limber dust
#

onCommand(){
//code
}

summer scroll
#

So, for example, your config will look like this I guess.

data:
  player1: 1
  player2: 2
quaint mantle
#

yes

summer scroll
#

And then on command.

onCommand(){
  Player player = Bukkit.getPlayer(args[0]);

  config.set("path", value);
  saveConfig();
}
quaint mantle
#

OOOOOOOOH

summer scroll
#

But first, check If the path is null or not, If the path isn't null, get the value and then increment it.

quaint mantle
#

My dumb-ass was putting player.setConfig() uh nevermind

summer scroll
#
if(config.getInt("path") == null){
  config.set("path", 1);
} else {
  config.set("path", config.getInt("path") + 1);
}
#

You want to increase it every command right?

quaint mantle
#

Exactly

#

I will just put it starting 0 instead of 1

#

Also

summer scroll
quaint mantle
#

same goes for the first one

summer scroll
#

Pass your main class instance then, so you can save the config on other class.

summer scroll
#

Yes, something like that.

#
private final MainClass plugin;
public OtherClass(MainClass plugin){
  this.plugin = plugin;
}
quaint mantle
#

Yea I forgot to create plugin and getting confused, thx

quaint mantle
summer scroll
#

Like, you can't save the config without passing the main class.

quaint mantle
#

yea because saveDefaultConfig()

summer scroll
#

Use saveConfig();, you just called that on onEnable I think.

quaint mantle
#

Whats the difference between these two?

summer scroll
#
    public void saveConfig() {
        try {
            this.getConfig().save(this.configFile);
        } catch (IOException var2) {
            this.logger.log(Level.SEVERE, "Could not save config to " + this.configFile, var2);
        }

    }

    public void saveDefaultConfig() {
        if (!this.configFile.exists()) {
            this.saveResource("config.yml", false);
        }

    }
quaint mantle
#

So defaultConfig cant be changed

limber dust
#

save default should only be done on the server start or whenever you wanna create it, not used for saving

quaint mantle
#

I see

quaint mantle
limber dust
#

it's the "create file" method

limber dust
#

he just used OtherClass as a example

quaint mantle
#

Yea I did that but it seems weird

limber dust
#

it's a constructor

quaint mantle
#

Invalid method declaration

#

what does it mean?

limber dust
#

it's so you can pass a instance of your main class into your commands class

#

to use plugin methods like saveConfig

quaint mantle
#

Ok then

limber dust
#

eg my commands constructor

    public lpsCommand(LevelPoints lps, String command){

        lps.getCommand(command).setExecutor(this);
        lps.getCommand(command).setTabCompleter(new lpsTabComplete());
    }
``` i use it for setting the executer and tabcompleter
#

in your case you need it for main class instance

quaint mantle
#

I still have a long way I see

#

wtf

#

why does config still get unidentified?

#

in the OtherClass?

summer scroll
quaint mantle
#

this is mapsdone class

#

package astreansbuildsystem.astreansbuildsystem.commands;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;

public class mapsdone implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = Bukkit.getPlayer(args[0]);
if(p.hasPermission("astreans.mapsdone")){
config
}
return true;
}
}

#

this is the main class

package astreansbuildsystem.astreansbuildsystem;

import astreansbuildsystem.astreansbuildsystem.commands.menu;
import org.bukkit.plugin.java.JavaPlugin;

public final class AstreansBuildSystem extends JavaPlugin {

private final AstreansBuildSystem plugin;
public mapsdone(AstreansBuildSystem plugin){
    this.plugin = plugin;
}
@Override
public void onEnable() {
    // Plugin startup logic
    getCommand("menu").setExecutor(new menu());
    getConfig().options().copyDefaults();
    saveConfig();


}

}

summer scroll
#

You need to do the dependency injection on your command class.

#

And next time use this.

queen dragonBOT
quaint mantle
summer scroll
#
    private final AstreansBuildSystem plugin;
    public mapsdone(AstreansBuildSystem plugin){
        this.plugin = plugin;
    }
``` this one.
quaint mantle
#

Yes, its inside the main class, do I need to do something like this in mapsdone?

limber dust
#

not your main one

#

you put it in your commands class

quaint mantle
#

OOOOOOOOOH

#

well F

#

uuuh, no changes visible

limber dust
#

whats the code look like now?

#

and use ?paste

quaint mantle
#

which class?

#

main or the second one?

limber dust
#

well you said no changes visible so what are you referring to?

quaint mantle
#

config not getting detected

summer scroll
#

And now you can get it by plugin.getConfig().

quaint mantle
#

ooooh

#

Jesus I look stupid, thanks guys

#

Oh yeah, because plugin refers to the mainclass

summer scroll
#

Yup, now you can use all method in the main class basically.

quaint mantle
#

Yay

#

I just need to put plugin to refer to it

quaint mantle
eternal oxide
#

no :

#

if your entry in your yml is "data:" your path is "data"

#

if its yaml data: info: - test - testThen your path would be "data.info"

quaint mantle
#

Ok, ty

summer scroll
quaint mantle
eternal oxide
#

no, if its not there it will return null

quaint mantle
#

Well fuck

#

now what

summer scroll
#

If you use config.set() yes, it will create the path.

quaint mantle
#

but config.set() doesnt work

summer scroll
#

and overwrites if it's exists.

#

what do you mean doesn't work?

eternal oxide
#

you have to check if it exists first

summer scroll
quaint mantle
#

Oh shoot

#

no, config doesnt get detetcted, no I cant im just confused now

eternal oxide
#

if you make a change to the config you have to save it.

maiden briar
#

I have problems with messaging: Bungee does not receive messages
BungeeListener: https://paste.md-5.net/lofedafuxe.java, Spigot message sender: https://paste.md-5.net/anokocejew.java

Registering (The listeners are registered in the classes above):
Spigot:
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(this, "emc:channel");
Bungee:
ProxyServer.getInstance().registerChannel("emc:channel");

outer sorrel
#

if i used packetevents by retrooper how would i get when a player moves?

#

actually gtg sleep now :(

formal ferry
#

Okay so, I have a "resources/config.yml" (same path as bungee.yml) and I would like to paste it to my BungeeCord configuration file. How would I do this?

naive knoll
#

How to create this in reflection?

new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityPlayer)```

My point here is how to get this enum by reflection
tough zephyr
#

@naive knoll You can grab all the enums using <class>.getEnumConstants()

naive knoll
lost matrix
sick ravine
#

Siemka @naive knoll

naive knoll
sick ravine
#

@naive knoll w fg jest trochę refleksji może coś byś tam znalazł i się powzorował

#

i nawet ta sama klasa

naive knoll
sick ravine
#

hah

naive knoll
#

ale pisz po angielsku

#

bo to angielski dx

#

🙂

sick ravine
#

yes yes

#

english hello

naive knoll
#

XD

quaint mantle
#

say if I wanted to get the number of zombies killed by a player on a command, if I try and use:
int zombieKills = player.getStatistic(Statistic.MOB_KILLS, EntityType.ZOMBIE);
the MOB_KILLS enum can't specify an entity type, is there any other way to do this... or am I just going to have to make a database for this and update values on a mob kill?

sick ravine
#

em

lost matrix
# naive knoll but how can I do it?

Example:

  @SneakyThrows
  @Override
  public void onEnable() {
    System.out.println(this.getEnumFrom("net.minecraft.server.v1_16_R3.PacketPlayOutPlayerInfo$EnumPlayerInfoAction", "ADD_PLAYER"));
  }


  public Object getEnumFrom(final String className, final String enumName) throws ClassNotFoundException {
    final Class<?> enumClass = Class.forName(className);
    final Object[] values = enumClass.getEnumConstants();
    for (final Object object : values) {
      if (object.toString().equals(enumName)) {
        return object;
      }
    }
    return null;
  }
sick ravine
quaint mantle
#

ohhh

sick ravine
#

if it doesn't work then there is probably no such data

quaint mantle
#

because it is saved

sick ravine
#

so in this case you will have to log the number of killed zombies yourself

quaint mantle
#

you can clearly see that the entity kills are logged

#

its just accessing it

#

one second I am compiling and deploying to a test server

sick ravine
#

generally getStatistic a lot of bugs :/

quaint mantle
#

probably just better to save this all to a database then and have it updated upon a mob killed

#

and it means I know how to work with it then 😉

quaint mantle
#

yes it does work

#

kinda

quaint mantle
#

its an incorrect number saved hahaha

#

nope it works fine, I just obviously reset the statistics on the server

#

¯_(ツ)_/¯

#

thanks @sick ravine

graceful turret
#

how to get material by name i mean creating new material by string STONE

lost matrix
graceful turret
#

thx

young knoll
#

Probably want to use one of the special methods

#

Material.matchMaterial

quaint mantle
young knoll
#

There is a packet for it

quaint mantle
#

oh okay

#

thanks

empty oyster
#

guys i have a problem..., i dont know why the funtion is not working anybody can help me?

#
  @EventHandler
  public void onSpawn(CreatureSpawnEvent e) {
    LivingEntity entity = e.getEntity();
    if (!MobUtil.isStackable(entity))
      return; 
    
    if (e.getEntityType().equals(EntityType.PIG_ZOMBIE)) {
        if (entity.getCustomName() == "Gegner") {
            Bukkit.broadcastMessage("1§e-----§7§l" + entity.getCustomName());
            return;
        } else {
            MobUtil.tryToStack(entity);
            Bukkit.broadcastMessage("2§e-----§7§l" + entity.getCustomName());
        }
        return;
    }
    MobUtil.tryToStack(entity);
}
#

no error is coming

#

if (entity.getCustomName() == "Gegner") { <-- i Fink this is not working :/

ivory sleet
#

.equals

empty oyster
#

i try now if (e.getEntityType() == EntityType.PIG_ZOMBIE) {

ivory sleet
#

That should work

empty oyster
#

No not working

#

but yes to the entitytype...

#

if i ask the entitycostumname i gotn null back :/

opal juniper
#

?jd

ivory sleet
#

Means it has no custom name

opal juniper
empty oyster
#

yeah i give them..

opal juniper
#

What that means is that it is running the else clause most likely

#

Has it occurred that it may be running when other entities are spawning

#

Other than the one that you have spawned

#

@empty oyster

empty oyster
#

So I don't have a chance to get the name of the entity?

#

no no

#

only from piglen

opal juniper
empty oyster
#

sure

opal juniper
#

ok, so that rules that out

#

hmm, what about it you cast the entity to a PigZombie

#

im not sure at this point

empty oyster
#

No, I only spawn one

#

then the other one..

#

can i check how spawn (region) the piglen?

#

who*

opal juniper
#
if (e.getEntityType().equals(EntityType.PIG_ZOMBIE)) {
  PigZombie piglin = (PigZombie) entity;
  if (piglin.getCustomName() == "Gegner") {
    //etc etc ....
  }
}
eternal oxide
#

.equals for strings

opal juniper
#

^^

#

That is a point, use .equals() for strings and == for enums

empty oyster
#

now i will try

opal juniper
#

ok

daring sierra
opal juniper
#

ughhh, you are one of those developers...

daring sierra
#

one line needs fixing but it looks good so far

daring sierra
opal juniper
#

i kinda hate it when my console gets spammed with huge graphics as plugins load

daring sierra
#

its a small one tbh

#

And it's my custom plugin

opal juniper
#

ok, thats fine then, just i got one which was like a whole monitor once

daring sierra
empty oyster
#

@opal juniper no notworking

opal juniper
daring sierra
#

Sounds ew

empty oyster
#
  @EventHandler
  public void onSpawn(CreatureSpawnEvent e) {
    LivingEntity entity = e.getEntity();
    if (!MobUtil.isStackable(entity))
      return; 
    
    if (e.getEntityType() == EntityType.PIG_ZOMBIE) {
          PigZombie piglin = (PigZombie) entity;
          if (piglin.getCustomName() == "Gegner") {
              Bukkit.broadcastMessage("1§e-----§7§l" + entity.getCustomName());
              return;
          } else {
                MobUtil.tryToStack(entity);
                Bukkit.broadcastMessage("2§e-----§7§l" + entity.getCustomName());
          }
          
        }
    MobUtil.tryToStack(entity);
      Bukkit.broadcastMessage("3§e-----§7§l" + entity.getCustomName());
  }
opal juniper
#

it was because the version was one behind, so it freaked out

daring sierra
#

I only do custom shit on my plugins B) If I'm making one for somebody i'll just put "Enabled"

#

or somethin

opal juniper
ivory sleet
empty oyster
#

How ? =D, with || or ** ?

opal juniper
#

no, so you would do:

```java

daring sierra
empty oyster
#

ahh okey.

daring sierra
#

No idea

#

I just do

#

:/

empty oyster
#

thx i updated..

opal juniper
#

so:

if (piglin.getCustomName().equals("Gegner")) {

#

and, what gets broadcasted

empty oyster
#

Next Try: 1923987178923

#

😄 xDD

opal juniper
#

😄

empty oyster
#

at de.daniellainand.listener.MobStackEvents.onSpawn(MobStackEvents.java:36) ~[?:?]

------------------------------------------------------

36=:  if (piglin.getCustomName().equals("Gegner")) {

opal juniper
#

the full error please?

#

that doesn't tell the error 🤣

eternal oxide
#

npe as it has no custom name

opal juniper
#

yeah, probs a null error

empty oyster
opal juniper
#

there is something wrong with how you set the custom name

empty oyster
#

i come in 2min, i go smoke a ziggrat...

paper viper
#

what dafaq

#

lol

opal juniper
#

smh

ivory sleet
#

Lmao

#

Pro dev

vocal rain
#

Guys does anyone know why the spigot placeholder %%__USER__%% remains the same also after downloading the plugin?

paper viper
#

tell me if this is relatable or not

#

Me: learns new language.

#

Gets bored cause I can't code in that language

#

Also Me: returns to old comfy language

#

lol

empty oyster
#

im back

empty oyster
#

🚬

opal juniper
#

way to go

empty oyster
#

how old are you ? 😮

daring sierra
#

69

opal juniper
#

420

empty oyster
#

bruh

opal juniper
#

wait, misclick

daring sierra
opal juniper
opal juniper
empty oyster
#

sure

lost matrix
empty oyster
#
    public static void spawnEnemy(Player p) {
        Location l = CommandTank.loc;
        l.setY(CommandTank.loc.getY() + 0.5);
        PigZombie pigz = CommandTank.loc.getWorld().spawn(CommandTank.loc, PigZombie.class);

        pigz.setAngry(true);
        pigz.setCustomName("Gegner");
        pigz.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, Integer.MAX_VALUE, 2)); // (PotionEffectType.INCREASE_DAMAGE);
        pigz.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1)); // pigz.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
        pigz.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 10)); // pigz.hasPotionEffect(PotionEffectType.INVISIBILITY);
        pigz.setTarget(p);

        ItemStack is = new ItemStack(Material.DIAMOND_AXE);
        is.addUnsafeEnchantment(Enchantment.DURABILITY, 3);
        is.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 8);
        pigz.getEquipment().setItemInHand(is);
    }
lost matrix
#

And your problem is?

opal juniper
#

he is trying to detect the custom name

vocal rain
opal juniper
#

however it is not working

vocal rain
#

the wiki says "Will get transformed and the various variables will be changed to the appropriate values."

opal juniper
#
@EventHandler
  public void onSpawn(CreatureSpawnEvent e) {
    LivingEntity entity = e.getEntity();
    if (!MobUtil.isStackable(entity))
      return; 
    
    if (e.getEntityType() == EntityType.PIG_ZOMBIE) {
          PigZombie piglin = (PigZombie) entity;
          if (piglin.getCustomName() == "Gegner") {
              Bukkit.broadcastMessage("1§e-----§7§l" + entity.getCustomName());
              return;
          } else {
                MobUtil.tryToStack(entity);
                Bukkit.broadcastMessage("2§e-----§7§l" + entity.getCustomName());
          }
          
        }
    MobUtil.tryToStack(entity);
      Bukkit.broadcastMessage("3§e-----§7§l" + entity.getCustomName());
  }

@lost matrix

lost matrix
paper viper
#

I never knew that

#

existed

vocal rain
lost matrix
opal juniper
#

yeah, i told him but i thought he said he changed it...

empty oyster
#
  @EventHandler
  public void onSpawn(CreatureSpawnEvent e) {
    LivingEntity entity = e.getEntity();
    if (!MobUtil.isStackable(entity))
      return; 
    
    if (e.getEntityType() == EntityType.PIG_ZOMBIE) {
          PigZombie piglin = (PigZombie) entity;
          if (piglin.getCustomName().equals("Gegner")) {
              Bukkit.broadcastMessage("1§e-----§7§l" + entity.getCustomName());
              return;
          } else {
                MobUtil.tryToStack(entity);
                Bukkit.broadcastMessage("2§e-----§7§l" + entity.getCustomName());
          }
          
        }
    MobUtil.tryToStack(entity);
      Bukkit.broadcastMessage("3§e-----§7§l" + entity.getCustomName());
  }
lost matrix
#
        PigZombie pigz = CommandTank.loc.getWorld().spawn(CommandTank.loc, PigZombie.class); // <- Event is fired right here
        // Everything that follows is called after the event
        pigz.setAngry(true);
        
opal juniper
#

ohh,yea

lost matrix
#

This is the fix @empty oyster

    final PigZombie pigz = CommandTank.loc.getWorld().spawn(CommandTank.loc, PigZombie.class, preSpawnZombie -> {
      preSpawnZombie.setCustomName("Gegner");
    });
empty oyster
#

cant

lost matrix
empty oyster
#

sure

paper viper
#

🥶

opal juniper
#

arghhhhh

lost matrix
paper viper
#

lol

opal juniper
#

just set a delay in the event handler

empty oyster
#

i know.. .,.

#

ok i try

narrow furnace
#

imagine not playing 1.8 tho

opal juniper
#

?

outer crane
#

playing 1.8 is ok

empty oyster
#

but for pvp 1.8 is the besst......

outer crane
#

hosting a server on 1.8 is not

#

yeah if you like that more you can just use plugins on 1.16

opal juniper
lost matrix
narrow furnace
#

you got me

opaque mango
empty oyster
#

xDD

outer crane
#

thats like saying windows 10 is impossible to scale vertically compared to windows xp

opaque mango
#

where did I say it's impossible?

outer crane
#

not impossible but you get what i mean

empty oyster
#

@lost matrix hmmm maybe, but for potion pvp it is...

opaque mango
#

I'm saying it's an important task that needs to be done, while it wasn't that big of a deal in 1.8.

lost matrix
opaque mango
#

you get performance issues below 100 players as well on 1.16

lost matrix
#

The average server has way below 20 players on peak.

ivory sleet
#

Hmm a server I was deving on reached over 100 with no problems using 1.16 paper

paper viper
#

Why do people always pull out the "performance" card. It is much faster than you think.

#

in fact, 1.17 comes with many huge optimizations

opaque mango
#

is 1.17 out yet?

#

no

paper viper
#

But will it be?

#

Yes

narrow furnace
#

but its not

#

no

paper viper
#

so you should look forward to updating

opaque mango
#

do we know for certain that other changes won't degrade performance? no

paper viper
#

to higher versions

lost matrix
#

And if everyone would stop using old versions the we could focus on improving the newer ones without worrying for compatability issues with older ones.

opaque mango
#

I guess it makes sense to wait before deciding whether vertical scaling is needed or not

paper viper
#

if legacy was gone, imagine all the changes to the api

ivory sleet
#

1.8 fanbase💩

opaque mango
#

whoever supports old versions is their own fault, I don't see why that should impact new versions

paper viper
#

as a plugin dev, I always hate supporting 1.8

#

its always the limited

quaint mantle
#

I wonder why my plugin is so expensive

narrow furnace
#

people arent going to stop playing 1.8 because plugin devs want them to

#

i dont think they give af

empty oyster
#

7smile ich gebe dir ja recht nur das PotionPvP ist einfach das das noch sehr viele PotionSpieler haben wollen..

paper viper
#

with development

#

cause we have moved on from that years ago

opaque mango
#

fair enough

lost matrix
ivory sleet
#

I mean if the api is similar then why not pulse

empty oyster
#

Nooo this is not the reason, this is to much OP and the shield

paper viper
#

it's really not for people who ask about "custom mobs" which are apparantly the common thing being asked in spigot these days

#

like ai

#

and nbt tags

#

pdc

ivory sleet
#

Ye

quaint mantle
#

Does someone know why my plugin is on the top of my timings report?

lost matrix
quaint mantle
#

its the InteractEvent but it doesn't have much checks

lost matrix
#

And then the code

quaint mantle
#

It's MCFCore

#
    public void onPlayerInteractEvent(PlayerInteractEvent event) {
        if (event.getClickedBlock() != null) {
            if (event.getClickedBlock().getState() instanceof Container) {
                Container container = (Container) event.getClickedBlock().getState();

                StringBuilder inventoryString = new StringBuilder();
                for (ItemStack item : container.getInventory().getContents()) {
                    if (isLargeItem(item) || isCrashItem(item)) {
                        item.setItemMeta(null);
                    }
                    inventoryString.append(itemToString(item));
                }

                if (inventoryString.length() >= 150000) {
                    event.setCancelled(true);
                    container.getInventory().clear();
                }
            }
        }

        if (isCrashItem(event.getItem()) || isDangerousEgg(event.getItem())) {
            event.getItem().setItemMeta(null);
            event.setCancelled(true);
        }

        if (event.getItem() != null) {
            if (event.getItem().getType() == Material.TRIDENT) {
                if (event.getItem().getEnchantmentLevel(Enchantment.RIPTIDE) > 10) {
                    event.getItem().addUnsafeEnchantment(Enchantment.RIPTIDE, 10);
                }
            }
        }
    }```
That's the InteractEvent
paper viper
#

ur using tunity

#

lmfao

quaint mantle
#

yes?

paper viper
#

anything other than spigot is not supported here

ivory sleet
#

Lol I mean what’s the issue serverfilter

daring sierra
#

do people even run bare spigot anymore?

ivory sleet
#

Ye

paper viper
#

but anyways worldedit is causing the issue

paper viper
#

look on bstats

opal juniper
paper viper
#

a lot of people run spigot

daring sierra
#

Nice

paper viper
#

paper has a bit more than spigot

daring sierra
#

I didn't think it was still used that much lol

paper viper
#

but they both got like 47 percent

#

or smthing

midnight cradle
#

Hello, I know how to set a game mode for a specific player. player.setGameMode(GameMode.ADVENTURE);But does anyone know how I could change the servers game mode instead of just changing a specific players game mode?

opal juniper
#

?jd

quaint mantle
#

Bukkit.setDefaultGameMode(GameMode.CREATIVE);

summer scroll
midnight cradle
#

Thanks for the help

opal juniper
daring sierra
lost matrix
#

lol

paper viper
#

yea it always existed

#

i use it as a reference

daring sierra
#

o

#

coolio

opal juniper
#

well, i think i know who hosts it...

daring sierra
#

Sadge

quaint mantle
#

also is this correct

#

for (Map.Entry<Enchantment, Integer> ench : item.getEnchantments().entrySet()) {

supple marsh
#

Help, I am teleporting the player to the same location in two different occasions, one time is when he joins and another time is when he dies, but when he dies it teleports him a few blocks above, I debugged and saw it DOES teleport to the same X,Y,Z but it still teleports to different Y for some reason.

supple marsh
#

player.teleport

opal juniper
#

the whole thing

lost matrix
supple marsh
#

I did event.setRespawnLocation

lost matrix
supple marsh
#

and I also teleported in another place

#

to the same place

#

And in the messages I sent, it's the same location, but for some reason it teleports a few blocks above.

#

But when the player joins, it doesn't teleport a few blocks above

supple marsh
#

Yea, it teleports to above surface

lost matrix
supple marsh
#

Some kind of that, but it should be that, I am not trying to teleport the player inside a block or something...

quaint mantle
#

If I keep programming and learning everyday, how much time would it approximately take me, to master java?

ivory sleet
#

Define master java

#

Knowing everything about java and it’s stdlib

#

?

lost matrix
paper viper
#

you shouldn't know everything (and i mean everything) in the library thats unhealthy lol

#

by that point you should move to other languages

quaint mantle
paper viper
#

you will never be able to always do that

#

it takes time

ivory sleet
#

Oh that might take 3 months or smtng

cloud berry
#

wat 3 years xD

quaint mantle
#

I know people who can

ivory sleet
#

Like if you fully put in effort

paper viper
#

that just takes time

#

like if you had a huge ass plugin you wanted to make or something hard

#

prolly will take you a couple months

lost matrix
#

But you will never stop learning. When i started writing code for a company during my studies, i thought i was fairly knowledged.
But boy was i wrong. There is so much more to programming than just knowing the language features (of which i also learned a lot more there)

quaint mantle
#

I started working on a plugin, however my goals are beyong my understanding, I still cant use configs properly or know how to use worlds and autonatically create stuff etc.

lost matrix
cloud berry
#

bout 1.5ish years java

#

but liek 15+ c++

lost matrix
cloud berry
#

15

paper viper
#

my mom for some god damn reason says C++ is similar to java and im like wot

quaint mantle
#

I tried java 6 months ago, didnt understand shit, so I learned html css and a little js and linux and hacking, now im doing spigot for like 10 days

cloud berry
lost matrix
paper viper
#

yeah exactly lol

ivory sleet
#

C# tho

paper viper
#

C# conventions 🥲

ivory sleet
#

💩

cloud berry
#

c# same syntax fam