#help-development

1 messages · Page 86 of 1

green prism
#

geol

#

how can I change my name

quiet ice
#

Those also have capacitors

ornate mantle
#

how would you clean it 💀

green prism
#

on discord

quiet ice
#

Change your name on spigot?

#

?donate

green prism
#

no, here

quiet ice
#

FECK

waxen plinth
#

Once you're verified your nickname is set to your forums username

green prism
#

nono im poor for that

ornate mantle
#

would an earbud and some alcohol clean it properly

cerulean jasper
#

Hey guys. code origination from external pom.xml package from github (via jitpack) is suddenly giving me noMethod error after new compile.. yet I dont think I recently changed anything, what do I do? I use IDEA
I tried updating the version but I am still on the latest "tag"

ancient plank
undone axleBOT
#

Name changes on the forums are granted to those who have donated to the project. Donations are processed manually and generally take up to 24 hours. The donation widget can be found on the home page of SpigotMC at: https://www.spigotmc.org/.

cerulean jasper
#

originating*

eternal oxide
ornate mantle
#

do i just clean it best i can and hope it works?

cerulean jasper
#

hmm actually... oh.

#

Name/user changed

green prism
cerulean jasper
#

but their docs

#

reccomend same so, let me try new name regardless

cerulean jasper
ornate mantle
#

EDGAR

#

ONE LAST QUESTION

#

DOES ETHANOL SANITISER EVAPORATE

green prism
#

EDDGALR
ONE MORE QUESTION

ornate mantle
#

nevermind i forgot google exists

cerulean jasper
#

wait no

green prism
cerulean jasper
#

jitpack cares about git name

#

ok got it

quiet ice
#

.-.

ornate mantle
#

doin ur mom doin doin ur mom

quiet ice
#

I'd stop there before the mods come by

waxen plinth
#

@green prism do you actually want a code review

green prism
#

it's bad ik

waxen plinth
#

Link repo

#

Also my suggestion is add pronoun support

green prism
waxen plinth
#

It just makes sense for that kind of plugin

green prism
#

Like an undefined gender?

#

X Gender?

waxen plinth
#
    @Override 
     public void onDisable() { 
         for(Player p : Bukkit.getOnlinePlayers()) p.closeInventory(); 
     }```
#

This seems bad

waxen plinth
#

It could force them out of inventories unrelated to your plugin

waxen plinth
#

Pronouns don't necessarily have to be related to gender

green prism
waxen plinth
#
        if(ConfigLoader.name) 
             new NameInventoryListener(this);```
#

I would use braces

quiet ice
waxen plinth
#

It's always recommended

quiet ice
#

Or better said minecraft

tall dragon
#

@green prism i noticed you have a seperate Listener class for all your inventories. that can easily be reduced to just 1 listener

quiet ice
#

Unless you use the reload command

waxen plinth
#

And what's personHashMap used for?

quiet ice
#

But as I said, reload command bad

ornate mantle
#

ive cleaned it

#

turning on the plug now

#

god im fucking scared

quiet ice
#

There is not much that can go wrong outside of a short-circuit

green prism
quiet ice
#

So the worst thing that can happen is a small fire and a triggered breaker

waxen plinth
#

            Person playerIdentity = personHashMap.get(player.getName());

#

Oh..

#

You should really use UUID for that

ornate mantle
quiet ice
#

Yes, people miss out a lot from me when I do not show up

ornate mantle
#

lmao

waxen plinth
#

This class has tons of whitespace between some methods

green prism
waxen plinth
#

There also seems to be a lot of static abuse going on here

green prism
#

wher

waxen plinth
#

Lots of public static maps

#

Throughout the plugin

green prism
waxen plinth
#

?di

undone axleBOT
tall dragon
grim ice
#

@waxen plinth uh

grim ice
#

suppose hashmaps

green prism
grim ice
#

had in their constructor

waxen plinth
#

Look at the link the bot sent

grim ice
#

uh

#

wait

#

ok

waxen plinth
#

It's a better way to design object oriented projects

grim ice
#

is having a public static variable in ur main class bad even if the variable type is a class that's only initialized once

eternal oxide
#

make it final and you are good

waxen plinth
#

Static abuse makes your code more inflexible, and harder to unit test if you want to do that

grim ice
#

what if its initialized in onEnable for example

ornate mantle
#

i cant fucking do it

grim ice
#

u cant make it final

eternal oxide
#

nope

green prism
#

im confused

ornate mantle
#

im too scared

green prism
#

im both

grim ice
#

????

waxen plinth
#

Dependency injection is simple

ornate mantle
#

i need some reassurance

waxen plinth
#

Rather than using static fields

ornate mantle
#

that nothing will go wrong

waxen plinth
#

Pass dependencies into their dependents

green prism
grim ice
waxen plinth
grim ice
#

are u talking about my example

#

or this guy

green prism
green prism
ornate mantle
#

my name is walter hartwell white

green prism
grim ice
#

is having a public static variable in ur main class bad even if the variable type is a class that's only initialized once

waxen plinth
ornate mantle
#

omg gas stone and fridge

grim ice
#

no, it's not

waxen plinth
#

But for just about anything else you should avoid static fields

grim ice
#

but if u try to make 2 instances of the object

#

itll throw an exception

green prism
#

what if I create a new class with that static abuse and initialise that from the onEnable?

waxen plinth
#

No

waxen plinth
#

It makes your code inflexible

grim ice
#

whaats special

#

about the plugin one

#

why is it fine

waxen plinth
#

The plugin is never going to be extended

#

It's instantiated once and anything that needs it needs that one specific instance

#

Now, ideally you should still inject it

grim ice
#

so the requirements for having a field static and public

#

is

green prism
#

what about that
@Getter
private HashMap<String, Person> personHashMap;

@Override
public void onEnable() {
    this.personHashMap = new HashMap<>();
waxen plinth
#

But exposing a static getter or field for convenience in API is fine

grim ice
#
  1. Enforcing that the field type is only initialized once
  2. Enforcing that the class that has the field cannot be extended
waxen plinth
grim ice
#

if you meet those two requirements u can make a public static field

#

right??

eternal oxide
waxen plinth
#

And the field should be a Map, not a HashMap

waxen plinth
#

For singletons it's fine to have a static getter or field though

green prism
#

public HashMap<UUID, Person> personHashMap;

@Override
public void onEnable() {
    this.personHashMap = new HashMap<>();
waxen plinth
#

Not public

green prism
#

adalikewmrfqapei

#

I need it in other classes

waxen plinth
#

HashMap -> Map

green prism
#

wa

#

did it

waxen plinth
green prism
#

why cant I use the hashmap directly?

#

map"

waxen plinth
#

You can, but you should generally not expose that kind of thing directly if you can avoid it

#

Think of it this way

green prism
#

oK

waxen plinth
#

You run a business in your home

green prism
misty ingot
#

player.addPotionEffects(new PotionEffect(PotionEffectType.getByName("BLIND")), 1, 10);
PotionEffectType#getByName requires a string but shows an error when I put the string there

waxen plinth
#

You invite people in and make them coffee

#

Would you give them the keys to your house to come in and ask for coffee?

#

Or would you have them ring the doorbell so you can serve them?

grim ice
#

So, if i have this:

public final class A {
    public static final B b = new B();
}

public class B {

    public B() {
        if (objectAlreadyInitializedBefore) {
            throw new RuntimeException("Initializing Failed");
        }
    }
}```

is having the field "b" as it is, okay?
waxen plinth
#

The singleton instance should be in its own class

grim ice
#

is it okay though

waxen plinth
#

Besides that yes

grim ice
#

since that's literally what bukkit does

#

lol

#

in this case B is the plugin and A is bukkit

waxen plinth
#

Singletons are basically the only time you should ignore DI principles

grim ice
#

so using public static is fine as long as these two rules are met

waxen plinth
#

Not always but they're a good rule of thumb

waxen plinth
#

What's worth noting is that you should only do that if you need the SPECIFIC instance

#

If any Plugin instance will suffice, inject

green prism
#

public Person getPerson(UUID uuid) {
return personHashMap.get(uuid);
}

public UUID getUUID(Person person) {
    for (UUID uuid : personHashMap.keySet()) {
        if (personHashMap.get(uuid).equals(person)) {
            return uuid;
        }
    }
    return null;
}
grim ice
#

I see

waxen plinth
#

e.g. registering listeners or similar

twilit roost
#

Im randomly spawning campfires
but I don't want them to be inside/on trees
should I try to scout some radius around the tree for free spot without trees or somehow remove the tree?

waxen plinth
green prism
#

maybe

waxen plinth
#

If not, don't expose it

#

If yes, store it in the Person object

ornate mantle
#

HOYLY CK

#

YSE

#

THE CHARGER WORKS

#

AND THE ELECTRICITY IS STILL HERE

#

this isnt shitposting i genuinely had troubles with my charger 💀

#

proof here

waxen plinth
#

Maik, feel free to start a thread if this channel is too chaotic

lusty forum
#

Hello guys, how can I make a city build plugin? I want to create one my own

ornate mantle
#

can u describe it a bit more

green prism
waxen plinth
#

Oh lol

#

I know that these design principles might seem just annoying on a small project

#

But they help make sure it can scale

green prism
#

whats that supposed to do?
main.getPerson(p.getUniqueId()).setAge(actualAge);

waxen plinth
#

When structuring large codebases it will keep things clean

green prism
#

it doesnt update the hashmap anymore I think

#

map"

waxen plinth
#

You mean for when the person doesn't exist?

#

You could have a getOrCreatePerson method

green prism
#

I mean, if I get the person and then do the age set, the person’s value in the hashmap is no longer up to date, right?

waxen plinth
#

It's returning the object

#

The object isn't copied in the process

#

It's the same one

#

So if you change it, it will be reflected in the map

green prism
#

So this will do something
main.getPerson(p.getUniqueId()).setAge(actualAge);

#

cool

#

lmao

waxen plinth
#

Yes

lusty forum
waxen plinth
#

Your command code can also be cleaned up a lot

green prism
waxen plinth
#

I can teach you

#

DM me

ornate mantle
lusty forum
granite burrow
#

Is it possible to programmatically remove the when player teleports using Player#teleport(location) spam console with "Player moved too quickly! (coords)"

grim ice
#

yes

#

but i dont recommend it

#

use System.setOut

#
        System.setOut(new PrintStream(System.out) {
            public void println(String s) {
                // here, we check if the message being written in console doesnt contain "moved too quickly", so if it does it wont be printed
                if (!(s.contains("moved too quickly"))) {
                    super.println(s);
                }
            }
        });```
ornate zinc
#

i want to spawn a mob without AI . can enyone help ?

granite burrow
grim ice
#

teleporting isnt actually teleporting

#

it just moves you extremely fast

granite burrow
#

oh wth lmao

grim ice
#

or

#

Look into the spigot.yml file for the following:
moved-wrongly-threshold: 0.0625
moved-too-quickly-multiplier: 10.0
Might need to adjust those higher for the first. Maybe increment by 0.0025 to see if it makes a difference.

mighty pier
#

import lombok.experimental.UtilityClass;
import me.frandma.soup.Soup;
import org.bson.Document;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.function.Consumer;

@UtilityClass
public class Kits {
    public void createKit(Player p, String kitname){
        Document document = new Document("kitname", kitname).append("displayitem", p.getItemInHand().getType());
        ArrayList<ItemStack> items = new ArrayList<>();
        for (ItemStack item : p.getInventory().getContents()){
            items.add(item);
        }
        document.put("items", items);
        Soup.kitCol.insertOne(document);
    }

    public void claimKit(Player p, String kitname){
        Soup.kitCol.find().forEach((Consumer<Document>) document -> {
            if (document.get("displayname").equals(kitname)){
                ArrayList<ItemStack> items = (ArrayList<ItemStack>) document.get("items");
                for (ItemStack item : items){
                    p.getInventory().addItem(item);
                }
                p.sendMessage("Claimed kit §b" + kitname + "§f.");
            }
        });
    }

}
```https://paste.md-5.net/qoqatokofa.bash
#

oh

#

did it the opposite way

ashen quest
#

me and my Gs just flip the electrons that represent the status of the server

ashen quest
#

ayo

ashen quest
#

?notworking

undone axleBOT
#

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

ashen quest
#

can u show this info please

delicate lynx
#

what's this line at me.frandma.soup.kits.Kits.createKit(Kits.java:21)

mighty pier
#

Kits.createKit(p, args[0]);

#

i did /kitcreate boat

#

with boat

#

in hand

#

{|

#

thumbs u]p

delicate lynx
#

oh

#

p.getItemInHand().getType() is probably the problem

mighty pier
#

why would it

#

maybe

delicate lynx
#

because it doesn't know how to save a material in mongo

mighty pier
#

yes

#

strying string

delicate lynx
#

you probably need to toString() it

mighty pier
#

arraylist itemstack

#

string too?

#

the ArrayList<ItemStack> items = new ArrayList<>();

#

ima try

#

might be

#

cause i connected to the mongodb database wrong

#
        MongoClient mongoClient = MongoClients.create("mongodb+srv://crackma:password@crackma.gasczoq.mongodb.net/?retryWrites=true&w=majority");
        MongoDatabase database = mongoClient.getDatabase("soup");
        playerCol = database.getCollection("players");
    }
    private void mongoConnectKits() {
        MongoClient mongoClient = MongoClients.create("mongodb+srv://crackma:password@crackma.gasczoq.mongodb.net/?retryWrites=true&w=majority");
        MongoDatabase database = mongoClient.getDatabase("soup");
        kitCol = database.getCollection("kits");```
#

i did it right yes?

agile anvil
mighty pier
#

i changed it

#

i realised

#

stupid moment

agile anvil
#

No worries ahah

#

:o making a soup kitpvp ?

mighty pier
#

yes

#

if i do .toString to an arraylist will it still be an arraylist?

eternal night
opal juniper
#

you have converted the object toString

#

it is now a String

#

its a string that looks like an arraylist

agile anvil
#

If you mean a string that can be converted back in ArrayList: no

grim ice
#

u can tbh

mighty pier
#

ok so

#

the problem is

#

i cant convert itemstack to string

#

for some reason

#

and its erroring

#

wrong image

severe oak
#

thats casting it to a string

mighty pier
#

castging

#

how do i make itemstack -> string?

agile anvil
urban kernel
#

is there any way to override the default bukkit ban message

severe oak
agile anvil
agile anvil
severe oak
mighty pier
#

what is serializing

severe oak
#

Changing an object into a form of data that can be stored for later

#

In your case, converting an ItemStack to a String.

urban kernel
#

is there any way to override the default bukkit ban message

honest echo
#
    at org.bukkit.inventory.ItemStack.addEnchantment(ItemStack.java:401) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]```

im trying to apply "sharpness" to a Material.BOOK
mighty pier
#

send code

honest echo
#
ItemStack outputItem = new ItemStack(Material.BOOK, 1);
outputItem.addEnchantment(Objects.requireNonNull(Enchantment.getByKey(NamespacedKey.minecraft("sharpness"))), 2);
fossil rose
#

you should use ItemStack#addUnsafeEnchantment

#

if you read the docs it is there

honest echo
#

ohk

fossil rose
#

yap

honest echo
#

thanks for help lemme test it

urban kernel
#

is there any way to override the default bukkit ban message

agile anvil
urban kernel
#

how

agile anvil
#

Have you tried bukkit.yml or spigot.yml ?

urban kernel
#

uh

#

i think it's from vanilla

#

(????)

agile anvil
#

Listen for prelogin

#

If banned

#

Set the message

#

Boom

#

Easy

urban kernel
#

how

#

do ik

#

if banned

fossil rose
#

hey I know this has probably more to do with the java language itself.
But since what I'm struggling with involves Events and the need for Events to be registered (therefore instantiating the class where those events are declared in), I think here is a good place to ask.

So let's say I want to create a different inventory menu for every player, where the inv's title is the player's name.
I create a class called Menu, declare a private Inventory inventory, use a constructor in that class to perform something like inventory = Bukkit.createInventory(player, 27, Component.text(player.getName())); and create a getter for that same inventory.

Now when I want to create that inventory and open it I would do Menu menu = new Menu(player) and player.openInventory(menu.get(player)).
This works fine, and I can pass this menu instance to whatever class I want it used, for example a MenuItem class to say create and add items to that menu.
Problem is: what should I do if I want to check if one of these menus has been clicked in by the player, using the InventoryClickEvent. I obviously can't pass the instance to the InventoryClickEvent class cause that's being registered in the onEnable() method in the main class.
Would a static HashMap where key is Player and value is Inventory make sense for this situation? Or is there a better way of doing this? Thanks in advance.

waxen plinth
#

Make the Menu itself a listener if you want

#

Otherwise a map is the best solution

#

But do a map by UUID, not Player

fossil rose
fossil rose
waxen plinth
#

Yeah it's pretty common

gleaming grove
#

How do I suppose configure this to run Server from Inteliji?

agile anvil
undone axleBOT
fossil rose
waxen plinth
#

Making it static would make sense

#

As long as it's not needed anywhere else

fossil rose
waxen plinth
#

If it's only used internally within that class, that's the ideal setup

severe oak
fossil rose
severe oak
#

That should be fine. Tbf its really your decision on your code design.

vernal basalt
#

Is there a way to check if a hostile mob can attack a player

severe oak
vernal basalt
#

Basically check if the mob is being farmed

#

I need a Boolean of if the entity has a path to the player

fossil rose
# waxen plinth I'd avoid it if possible

oh yeah? then how would you go about doing what I'm trying to accomplish? just go with registering the listener when menu is created?
if I do go with the Map route, how should I do it? sorry for so many questions, really want to get this matter taken care of in my head lmao

#

cause if I make the map static, that would be with the intention of then accessing it from other classes

severe oak
vernal basalt
#

Ok

waxen plinth
#

You can access it from other classes

#

It's not ideal design

#

But it's unlikely to matter

fossil rose
waxen plinth
#

Make a manager class

fossil rose
#

if you can summarize it

waxen plinth
#

That holds the map, you pass the manager around to whatever needs it

gleaming grove
bronze solar
#

Hey, so I was able to fix my config issue thanks to @waxen plinth's awesome library, but now I'm facing a new issue, essentially, I need to get offline players by their name or UUID, but the server that the plugin is being ran on is in offline mode to work with Bungee, but offline mode server's can't get offline players the same way as online ones, how can I go about getting an offline player on an offline mode server?

waxen plinth
#

Might need to invoke authlib

bronze solar
#

Yeah, that's what I thought, do you think there's any way to avoid something like that?

#

Output on offline mode server: [CraftPlayer{name=JohnnyGooodTime}]

Same output on online mode server: [CraftOfflinePlayer[UUID=fc1baadf-af0c-403b-a7f4-fa50f68d92f7]]

#

These are two different players, but you get the idea of the difference of how it works.

waxen plinth
#

?jd-s

undone axleBOT
lusty forum
#

Can somebody help me with my question?

lusty forum
waxen plinth
#

No

gleaming grove
lusty forum
#

Ik

gleaming grove
#

I think better to make extention for some plot's plugin then reinvent wheel

lusty forum
#

Ok

fossil rose
waxen plinth
#

You would create one and pass it around

fossil rose
#

oh right, forget it

#

I think it all makes sense now

#

thanks redempt

agile anvil
#

Did you ever seen that ?

grim ice
#

its definitely possible with packets or something

#

lets hope its not handled client side

#

i doubt the api has it

#

but maybe packets do

quaint mantle
delicate lynx
#

no

gleaming grove
#

Is it possible to create Crafting inventory?

tall dragon
#

pretty sure u need to call getView

#

and call getTitle from there

#

yup

delicate lynx
#

you shouldn't be checking titles for inventories, you should store the inventory somewhere else and check if it's the same one

gleaming grove
stone shadow
#

final ScheduledExecutorService executorService= Executors.newSingleThreadScheduledExecutor();
executorService.scheduleAtFixedRate(new Runnable() {
int count=0;
@Override
public void run() {
if (count==10)
executorService.shutdown();
player.sendMessage("working "+var);
player.getWorld().spawnEntity(player.getLocation(),EntityType.CHICKEN);
player.sendMessage("test");
count++;
}
},1,1, TimeUnit.SECONDS);

#

Hey I was trying to run the above part of the code but this spawnEntity line is giving some issues

#

the code works fine without that line

gleaming grove
#

You get error because spigot code need to be run on the spigot thread

#
      player.getWorld().spawnEntity(player.getLocation(),EntityType.CHICKEN);
      player.sendMessage("test");``` this chunk of code
tall dragon
lost matrix
#

Unless its specifically stated

stone shadow
#

umm .... any fixes possible... basically I need to spawn a chicken at a particular location every second for a minute

tall dragon
#

yea. make it sync

iron glade
#

?scheduling

lost matrix
#

?scheduling

gleaming grove
stone shadow
#

hmm

#

will check it out .... thnx for the help

lost matrix
iron glade
#
if (condition)
{

}``` looks so terrible
gleaming grove
lost matrix
#

You just made it worse

#

Just add more lines. If you want to edit an existing lore then you can use the methods of List to edit the lore to your liking.

#

In newer java versions you can also just do this

    ItemMeta meta;
    meta.setLore(List.of(
            "Line one",
            "Line two",
            "Line three"
    ));
iron glade
#

naming conventions

echo basalt
lost matrix
echo basalt
#

Yes

quiet ice
#

afaik Arrays.asList can be a bit cursed

echo basalt
#

It still exists on the later versions

#

Arrays.asList just calls List.of on java16

onyx fjord
echo basalt
#

actually depends

quiet ice
#

No, List.of is cursed

#

Arrays#asList is fine

echo basalt
#

Really depends on the version

#

On some java versions it's mutable

#

on others it's immutable

quiet ice
#

Although you can also make the point that List#of has better performance

echo basalt
#

Yeah but it's not compatible with older versions and all

#

not a thing on java 8 type deal

lost matrix
#

One more benefit

quiet ice
# echo basalt actually depends
Returns a fixed-size list backed by the specified array. Changes made to the array will be visible in the returned list, and changes made to the list will be visible in the array. The returned list is Serializable and implements RandomAccess.

I feel like that would break that contract

echo basalt
#

kinda wouldnt

#

because the stupid mfs that wrote the Arrays class made their own ArrayList class just to break consistency

quiet ice
#

oh lol

#

That being said List#of is unmodifiable in it's contract

#

So Arrays#asList cannot delegate to List#of without breaking it's contract

echo basalt
#

from what I remember

#

it's immutable

granite burrow
#

is there a way to detect if the player sent /kill in the entity damage event? Since /kill seems to send a void damage event, however, I'm trying to detect if the player is in the void

delicate lynx
#

you'll have to track that manually

granite burrow
green prism
#

guys, is it possible to make a 1.16 plugin compatible with 1.19?

#

seriously

chrome beacon
#

Yes

green prism
#

help me olivo

#

you're my last hope

chrome beacon
#

Depends

green prism
#

bruh

chrome beacon
#

Make a multimodule maven project if you're using nms

chrome beacon
#

One module per nms revision

green prism
#

what

chrome beacon
#

The package it all together and you're done

green prism
#

what's nms? can you speak in simple words

quiet ice
#

Then a 1.16 plugin already supports 1.19

chrome beacon
#

^

green prism
#

So my plugin already supports 1.19?

#

it is compiled in java 16

quiet ice
#

If you do not use anything that isn't public API mc versions do not matter starting from 1.14+

quiet ice
green prism
#

is that too cursed?

waxen plinth
#

Should still add pronouns

green prism
waxen plinth
#

A placeholder for those so you could have them show up when you hover over someone's name

green prism
#

I will in the update n'999

waxen plinth
#

That would be perfect

quiet ice
#

(screenshot of decompiled code for those that are too lazy)

ancient plank
#

I have code for that

green prism
#

I like the code. It is easy to understand

ancient plank
#

farming plugin where if you farm without a hoe its ass

quiet ice
#

Almost all of the event listener classes (probably are 40) are near identical

ancient plank
#

wilding

glossy venture
quiet ice
#

Yep.

glossy venture
#

do some math

#

no need to create 3 billion listeners

quiet ice
#

40 event listeners just for this

glossy venture
#

lmao

quiet ice
ancient plank
#

wtf

#

the math for enchantment level is so easy

#

there's a whole ass wiki page on it

quiet ice
#

And it hard-depends on claimchunk (which is a pretty obscure plugin imo)

glossy venture
ancient plank
#

what the fuuuuuuuck am I looking at

glossy venture
#

so what does it do per listener

#

like unbreaking 3 listener is the same as unbreaking 1 listener just less damage?\

quiet ice
#

Yes

Fortune 0 Beetroots = 1
Fortune 1 Beetroots = 1 to 2
Fortune 2 Beetroots = 1 to 3
Fortune 3 Beetroots = 1 to 4
same with rest

Unbreaking 0 Tool Damage 4
Unbreaking 1 Tool Damage 3
Unbreaking 2 Tool Damage 2
Unbreaking 3 Tool Damage 1 
glossy venture
#

broooo

#

thats the easiest math ever

#

lmaoooooooo

ancient plank
#

?paste

undone axleBOT
vernal basalt
#

i was able to use hasLineOfsight to check if the entity that was killed was farmed maybe using a grinder but how can i make a check for if they are in a hole or are stuck in flowing water where they cannot get to the player

glossy venture
#

and just get the material why there a diff listener for every item

ancient plank
#

😩

quiet ice
#

Do note that checking if the mob is spawned from a spawner (which is tracked by paper for sure, probably by spigot too) is a far safer and less resource-intensive way of dealing with player farms

vernal basalt
#

what about those big tall grinders people make using the dark to spawn all the mobs

quiet ice
#

Mob spawn caps do exist...

#

You are kinda solving a problem that doesn't exist with tools that make the problem worse

#

Spigot mappings is something from the past

vernal basalt
#

minecraft already knows if the pathfinding of a mob can hit a player so why can't i check if entity has a path to player

snow lava
#

¿paste

vernal basalt
#

?paste

undone axleBOT
snow lava
#

thanks

green prism
#

@chrome beacon thank you

#

geol

quiet ice
ancient plank
quiet ice
#

I kinda have the feeling that they are farming something on spigot

waxen plinth
#

Is this what happens when you never get anyone to look at your code

ancient plank
#

😩 bro

#

they made a million classes for subcommands to spawn every mob

#

and the only changes are things like "/spawner phantom" "/spawner pig"

quiet ice
#

Living the enterprise dream

vernal basalt
#

@quiet ice this guy wants a plugin that decreases drops on mobs that had no way to fight

#

basically if it was a free kill

glossy venture
#

this shit is so fucking annoying

ancient plank
#

I was like "tf this guy shade into a plugin --that is basically a simplified /give command for spawners-- to make it 125KB"

vernal basalt
#

minecraft already knows if the entity can attack the player

#

basically i need to check if the entity is locked onto a player

quiet ice
#

?jd-s

undone axleBOT
ancient plank
#

the only thing that changes in these classes are the api methods they don't even use

quiet ice
#

Unfortunately, bukkit/spigot does not expose any pathfinding/goal API

ancient plank
#

one day

quiet ice
glossy venture
#

what the fuck

#

my local servers icon is cursed or smth

#

looks like the optifine cape layout

#

thats localhost

quaint mantle
#

So in spring boot hibernate if I have a Car entity that have a Garage annotated with @ManyToOne so is it always necessary to annotate the Garage with @OneToMany as well?

opal juniper
glossy venture
#

mah

#

meh

quiet ice
#

Protip: In eclipse you can prevent packages from being auto-completed

green prism
quiet ice
#

As such in eclipse you will not have the issue that you will automagically auto-complete java.awt.List, because that class is in that list (for a while the entire java.awt package was in that list, but they removed it for making swing near unusuable)

glossy venture
#

yeah i occasionally import fucking java.awt.List

#

its one of those little things which are extremely annoying

ancient plank
#

Directional BlockFace Openable Bisected Orientable Waterlogged

#

able gang

green prism
#

hey adele

#

Im a good guy

ancient plank
#

nobody cares about your plugin

green prism
serene onyx
glossy venture
#

what the fuck is happening to my server icon

#

now its pillager texture

#

wtrf

quiet ice
#

default.png being messed up moment

glossy venture
#

yeah

#

but the other servers arent

#

its fine

quiet ice
#

huh, then either that is something specific to localhost, or your server software is a bit strange

glossy venture
#

its paper 1.19

#

idk

ancient plank
#

Imagine not setting a custom server-icon.png

glossy venture
#

bro World#dropItem isnt working

#

wtf

#

no items

glossy venture
glossy venture
#

oh the .setUnlimitedLifetime(true) was for testing

agile anvil
#

Discord Android 😏

glossy venture
#

lmao

#

but anyone know why the drops wont fucking spawn

#

i dont understand

hard socket
#

why I cant use the build in maven?

#

only 1.8 works

agile anvil
#

What do you mean? Do you have error?

hard socket
#

cant import it

#

onlt 1.8 works

agile anvil
#

Just input the version you want and update your pol

#

Pom

#

If doesn't work, run buildtool

hard socket
#

alr thx will try

tawny otter
#

so, im guessing I cant extend JavaPlugin here (Line 24)

public class Move extends JavaPlugin implements Listener {}

Error

[14:59:48] [Server thread/ERROR]: Error occurred while enabling OreIgin v0.1-BETA (Is it up to date?)
java.lang.IllegalArgumentException: Plugin already initialized!
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:225) ~[spigot-api-1.19.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:53) ~[spigot-api-1.19.2-R0.1-SNAPSHOT.jar:?]
        at me.teleputer.oreiginplugin.listeners.Move.<init>(Move.java:24) ~[?:?]
#

I just wanted to start a bukkit task for my Move event

delicate lynx
#

what is line 24

eternal oxide
#

java.lang.IllegalArgumentException: Plugin already initialized!

#

You can;t create a new instance of yoru main class

tawny otter
#

I already found the correct way to do it, thanks anyways

#

👍

desert frigate
#

is the default walk speed 0.2f?

tulip nimbus
wet breach
vivid skiff
#

?

delicate lynx
#

is this your plugin?

desert frigate
wet breach
delicate lynx
#

also 1.12 :/

boreal python
#
        /**
         * Apply enchants to item here according to TeamUpgrades.
         */
        switch (afterUnderscore.toLowerCase()) {
            case "stick":
                final var sharpness = gameStorage.getSharpnessLevel(team).orElseThrow();
                if (sharpness > 0 && sharpness < 5) {
                    newItem.get().addEnchantment(Enchantment.KNOCKBACK, item.getEnchantmentLevel(Enchantment.KNOCKBACK) + sharpness);
                }```
when I put "item.getEnchantmentLevel(Enchantment.KNOCKBACK)" "item" returns as an error. Any idea why?

Im trying to get the current knockback level of the stick that is selected and ADD it to the sharpness variable.

**FIXED**
changed "item" to "materialItem"
golden turret
#

pdc on players are saved?

delicate lynx
#

yes

#

you don't apply it like items, it will be saved automagically

quaint mantle
#

Big question, and yes I've googled it but the solutions all don't work or only show 4 events not every single event.
I want to know when any event in the entire game is fired but without creating a ton of event handlers just one that listens for all events.

#

(1.8.8 server version)

echo basalt
#

pluginManager#registerEvent(Class, Listener, EventPriority, EventListener, Plugin) will fix it

#

but given you're using 1.8 I suggest you make the listeners by yourself because clowns are supposed to make us laugh

quaint mantle
#

and also that would defeat my purpose of making the plugin im making

echo basalt
#

javadoc

quaint mantle
#

im making an custom event manager

quaint mantle
# echo basalt javadoc

Remove the entire purpose of making the plugin though, it'd be a huge waste of my time to just do that lol

#

example of what im making

#
EventManager.newEvent(PlayerJoinEvent.class, new Event() {
public void onEvent(PlayerJoinEvent event) {
}
})
desert frigate
#

would it be possible to skull.setOwningPlayer(); but using a png file?

quaint mantle
#

actually

#

yeah no u'd need a player name

#

with that skull

#

u could change ur skin

#

and get the texture id

#

and yeah

#

do that\

desert frigate
#

but what do i do with it

quaint mantle
#

game profile

#

let me rq look at the docs

desert frigate
#

alr

quaint mantle
#
public ItemStack getCustomSkull(String url) {

        ItemStack head = new ItemStack(Material.PLAYER_HEAD);
        if (url.isEmpty()) return head;

        SkullMeta skullMeta = (SkullMeta) head.getItemMeta();
        GameProfile profile = new GameProfile(UUID.randomUUID(), null);

        profile.getProperties().put("textures", new Property("textures", url));

        try {
            Method mtd = skullMeta.getClass().getDeclaredMethod("setProfile", GameProfile.class);
            mtd.setAccessible(true);
            mtd.invoke(skullMeta, profile);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
            ex.printStackTrace();
        }

        head.setItemMeta(skullMeta);
        return head;
    }
#

url would be texture

#
// Example
getCustomSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTc2MmExNWIwNDY5MmEyZTRiM2ZiMzY2M2JkNGI3ODQzNGRjZTE3MzJiOGViMWM3YTlmN2MwZmJmNmYifX19");
desert frigate
#

no way

#

it worked

#

omkg ty

quaint mantle
#

yw

desert frigate
#

no idea how it works but 🤷‍♂️

quaint mantle
#

game profiles is a json object

#

you are adding a key pair value

#

textures and then the url

#

then it sets the profile using reflections

#

to the gameprofile class

#

then it invokes method

#

setsmeta

#

returns head

quaint mantle
#

its public code

#

i think i got this code from a bukkit forum 2 years ago

#

i used it for a few plugins

onyx fjord
#

Eh ima assume it's GPL

eternal oxide
#

if you are using 1.18.2+ you no longer need to use reflection

quaint mantle
#

rlly

#

dang

#

i dont rlly use those apis

#

never relised

#

is there a method?

eternal oxide
#
/**
     * Create a Skull with a texture using the new PlayerProfile
     * Post 1.18.2
     * 
     * @param id        UUID to assign the skull.
     * @param name        a name for the skull
     * @param texture    a Base64 texture String
     * @return            Skull ItemStack
     */
    public ItemStack getHeadByProfile(UUID id, String name, String base64Texture) {

        ItemStack head = new ItemStack(Material.PLAYER_HEAD);

        PlayerProfile profile = Bukkit.getServer().createPlayerProfile(id, name);

        try {
            profile.getTextures().setSkin(new URL(getURLFromBase64(base64Texture)));
            SkullMeta meta = (SkullMeta) head.getItemMeta();
            meta.setOwnerProfile(profile);
            head.setItemMeta(meta);
            
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        return head;
    }
    
    private String getURLFromBase64(String base64) {
        
        return new String(Base64.getDecoder().decode(base64.getBytes())).replace("{\"textures\":{\"SKIN\":{\"url\":\"", "").replace("\"}}}", "");
    }```
quaint mantle
#

pretty cool

#

im a 1.8 main

onyx fjord
#

Spigot API W

quaint mantle
#

yeah spigot adds a ton of cool stuff

#

in new updates

onyx fjord
#

Library loading

#

😄

quaint mantle
#

and mojang mappings are insane

#

when they added them

eternal oxide
#

Yep I love mojang maps

quaint mantle
#

it made me use latest versions

onyx fjord
#

I never used nms

#

Tbh

quaint mantle
#

good for anticheats

eternal oxide
#

Majang maps made me have a play

quaint mantle
#

and a lot of thing

onyx fjord
#

There are libraries like packet events

#

Large anticheats use it

quaint mantle
#

even made a plugin if u send a packet u get kicked lol

boreal python
#
  @Override
    public Map.Entry<Boolean, Boolean> handlePurchase(Player player, AtomicReference<ItemStack> newItem, AtomicReference<Item> materialItem, PlayerItemInfo itemInfo, ItemSpawnerType type) {
        final var game = Main.getInstance().getGameOfPlayer(player);
        var gameStorage = SBA
                .getInstance()
                .getGameStorage(game)
                .orElseThrow();

        final var typeName = newItem.get().getType().name();
        final var team = game.getTeamOfPlayer(player);

        final var afterUnderscore = typeName.substring(typeName.contains("_") ? typeName.indexOf("_") + 1 : 0);
        /**
         * Apply enchants to item here according to TeamUpgrades.
         */
        switch (afterUnderscore.toLowerCase()) {
            case "stick":
                final var sharpness = gameStorage.getSharpnessLevel(team).orElseThrow();
                if (sharpness > 0 && sharpness < 5) {
                    newItem.get().addEnchantment(Enchantment.KNOCKBACK, ```**materialItem.getEnchantmentLevel(Enchantment.KNOCKBACK) + sharpness);**```
                }

                if (SBAConfig.getInstance().node("replace-sword-on-upgrade").getBoolean(true)) {
                    Arrays.stream(player.getInventory().getContents().clone())
                            .filter(Objects::nonNull)
                            .filter(itemStack -> itemStack.getType().name().endsWith("STICK"))
                            .filter(itemStack ->  !itemStack.isSimilar(newItem.get()))
                            .forEach(stick -> player.getInventory().removeItem(stick));
                }
                break;
            case "boots":
            case "chestplate":
            case "helmet":
            case "leggings":
                return Map.entry(ShopUtil.buyArmor(player, newItem.get().getType(), gameStorage, game), false);
            case "axe":
                final var efficiency = gameStorage.getEfficiencyLevel(team).orElseThrow();
                if (efficiency > 0 && efficiency < 5) {
                    newItem.get().addEnchantment(Enchantment.DIG_SPEED, efficiency);
                }
                break;
        }

        return Map.entry(true, true);
    }```

Any one know why "getEnchantmentLevel" gives: Cannot resolve method 'getEnchantmentLevel' in 'AtomicReference'
worldly ice
#

materialItem.get().getEnchantmentLevel

atomic swift
#

my tab completer isnt working this is what i have

public class TabCompletion implements TabCompleter{
    @Override
    public List<String> onTabComplete (CommandSender sender, Command cmd, String label, String[] args){
        List<String> completions = new ArrayList<>();
        if(args.length == 0){
            
            completions.add("reload");
            completions.add("clear");
            completions.add("edititem");
            completions.add("removeitem");
            
            return completions;
        }
        return null;
    }
}
getCommand("ahadmin").setTabCompleter(new TabCompletion());
eternal oxide
#

length == 1

atomic swift
#

thats it lol

worldly ingot
#

Yeah, you're operating on the first argument, args[0], which would be of length 1

#

It's a little counterintuitive at first but you get used to it

atomic swift
#

and do i need to use this to retrieve the output

getCommand("ahadmin").setTabCompleter(new TabCompletion());
getCommand("ahadmin").setExecutor(new AhAdmin());
boreal python
eternal oxide
#

you can just implement TabExecutor

#

then just set teh executor only

worldly ingot
#

You still have to register both, no?

eternal oxide
#

command and tab completer in one class

#

no

#

just executor

atomic swift
#

kk thx

worldly ice
#

enchant level*

boreal python
#

trying to get the enchants of an item in someones inventory

#

it the inventory of the shop

atomic swift
boreal python
#

it will be in someones storage the entire time

worldly ingot
#

No, I know that. There's a class called TabExecutor which combines the two

eternal oxide
#

implements TabExecutor

worldly ice
worldly ingot
#
    /**
     * Sets the {@link CommandExecutor} to run when parsing this command
     *
     * @param executor New executor to run
     */
    public void setExecutor(@Nullable CommandExecutor executor) {
        this.executor = executor == null ? owningPlugin : executor;
    }```
eternal oxide
#

Thats all I do in GM and it works fine. no need to set teh TabExecutor

worldly ice
#

if it'll be in someone's inventory, you are looking for an ItemStack

worldly ingot
#

Then you have some special handling or something because Bukkit doesn't do that

boreal python
# worldly ice `Item` refers to a dropped item
                        if (item.getType().name().endsWith("STICK")) {
                            item.addUnsafeEnchantment(Enchantment.KNOCKBACK,item.getEnchantmentLevel(Enchantment.KNOCKBACK) + finalTeamSharpnessLevel);
                        }``` so this would try to get the knockback level of a dropped item?
worldly ingot
#

Oop, nope, you're right

#
            if (completer != null) {
                completions = completer.onTabComplete(sender, this, alias, args);
            }
            if (completions == null && executor instanceof TabCompleter) {
                completions = ((TabCompleter) executor).onTabComplete(sender, this, alias, args);
            }```
#

TIL

worldly ice
boreal python
#

yeah

#

thats the point of both of these

#

its the exact same thing that needs to be done, just two diff conditions

boreal python
worldly ice
#

because you need an instance of an ItemStack

atomic swift
boreal python
eternal oxide
atomic swift
#
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (args[1] == "reload") {
            Ah.getInstance().reloadConfig();
            sender.sendMessage("[AH] Config reloaded");
        }
        return true;
#
getCommand("ahadmin").setExecutor(new AhAdmin());
drowsy helm
#

acf cough cough

eternal oxide
#

you shoudl not get a useage message if you return true

atomic swift
#

ik that

eternal oxide
#

also why are you checking args[1]?

#

args[0]

worldly ingot
#
  1. Probably want args[0]
  2. You should check the size of the args array first before accessing it
  3. .equals(), not == on a string
quaint mantle
#

also @desert frigate adding on to this ok, this is an example of a use of reflections (simple channel system for sending messages and receiving them)

        Reflections reflections = new Reflections(SciChannels.getClazz().getPackage().getName(), new TypeAnnotationsScanner());
        for (Class<?> clazz : reflections.getTypesAnnotatedWith(ChannelInfo.class)) {
            if (clazz.getAnnotation(ChannelInfo.class).name().equals(jsonObject.getString("channel"))) {
                Channel instance = (Channel) clazz.newInstance();
                instance.onMessageReceived(jsonObject);
            }
        }
#

i'd recommend learning it

#

it's very useful it you are making any sort of apis

#

and its just 100x easier in the long run it can help with big projects so you don't have to register commands or listeners

worldly ice
#

@boreal python after looking at your code for a bit, looks like you should be doing newItem.get().getEnchantmentLevel(blah blah blah)

quaint mantle
#

it does it for you

eternal oxide
#

If its an Atomic reference of an Item you probably shoudl be doing .get().getItemStack().getEnchantmentLevel...

worldly ice
#

or that

#

not sure what you're trying to achieve

boreal python
#

thank you so much

worldly ice
#

👍

desert frigate
#

I don't even know the basics of java

river oracle
undone axleBOT
river oracle
#

helpful links for those who don't know anything

ornate mantle
#

am I allowed to profit from a plugin that copies Hypixel skyblock in many aspects but it's not called Hypixel skyblock?

#

and it has many different things on top of the plagiarised content

tulip nimbus
#

Id think so if it’s not hypixel’s source code? But I’m also not a legal expert or familiar with how Hypixel licenses their work

#

Ping one of the Hypixel admins in here 😄

somber hull
#

@ornate mantle I’ve always wondered about copywrite and how that all works. I doubt you would get in trouble for it if you didn’t take any code.

tulip nimbus
#

Jk don’t do that.

somber hull
#

Also hypixle stole bedwars or smthng

#

I don’t remember

#

Something to do with hypixle and bedwars

#

And nothing came from it

#

So

tulip nimbus
#

It’s conceptually similar to egg wars but a lot of the content is original

ornate mantle
#

they stole bedwars from a Roblox game

somber hull
#

Lmao

ornate mantle
#

and Roblox stole some content from Hypixel back

#

and I think Simon said it's fine

#

fuck it I'm not gonna finish this plugin anyways 💀

somber hull
#

Lmao

desert frigate
#

they even said "inspired by hypixel"

#

is it possible to extend void setWalkSpeed(float value) bigger then 1? like make them go faster.

ornate mantle
#

I read somewhere that Hypixel can send you a cease and desist letter with fines

desert frigate
faint frost
#

i dont think im doing this right

#

fyi those lines are red because for some reason it's not setting/saving the player config

#

it reads it just fine tho

quaint mantle
#

hey guys. i coded a cutscene plugin that tps players 20 times a second. this is a tiny bit jittery. do u guys have any recommendations for a smoother alternative?

#

i tried velocity but when the player moves it somehow still affects velocity and the camera path changes

faint frost
#

i didnt even think that was possible

quaint mantle
#

which part xd

faint frost
#

basically yes

quaint mantle
#

xDD

faint frost
#

pretty clever using teleportation to make a cutscene

quaint mantle
#

yeah but its jittery

faint frost
#

i can imagine

quaint mantle
#

😦

#

anyone have ideas for alternative to make it smoother?

faint frost
#

im not sure if there is a whole other way to control a player plugin sided

quaint mantle
#

yeah

faint frost
#

id hope so, that sounds dope

quaint mantle
#

armor stands kind of smooth it out

#

but not really

#

it kinda just smooths the jitters a tiny bit, but you can still see them

faint frost
#

if I were you i'd make a thread here. id hate to see this get swept under

quaint mantle
#

hey guys i coded a cutscene plugin that

faint frost
#

👍

quaint mantle
#

thanks

faint frost
#

np

quaint mantle
#

bruh with armor stands you can't see blindness effects either

#

so it ruins it

#

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

faint frost
#

f

quaint mantle
#

i have one last idea

#

but if this doesnt work im giving up until someone else with big brain has idea

#

xDD

faint frost
#

.set() not setting or saving... why?

faint frost
vernal basalt
#

What is the best way to track the damages in an entity?

#

So basically check if x% of damages are from the following sources

vernal basalt
#

Would it be to make a list?

#

Or meta data

old cloud
vernal basalt
#

What about meta data

#

I just found that

#

How does that work does it actually attach to the nbt

old cloud
#

only until server shutdown iirc, so use pdc instead

vernal basalt
#

Also can you get how much an entity has regened or total damage ever taken

#

What is pdc

old cloud
vernal basalt
#

Ah I see

#

Is it built into spigot

old cloud
#

yes

vernal basalt
#

How do I use them

#

Never mind

old cloud
#

You can do Entity#getPersistentDataContainer

vernal basalt
#

The same as meta

#

How does it work

#

Is the name space for the plugin or for the value

#

Because it seems to take an object that contains 2 objects

#

After it

old cloud
#

However data is always stored in binary, thats why you always need to specify a PersistentDataType

#

PersistentDataType basically converts from type to byte[] and vice versa

scarlet creek
#

Hello, I’m testing out creating custom enchantments however it does not seem like it is registering


    public static final Enchantment TNTSHOOTER =
            new ModEnchants("tntshooter", "TNT Shooter", 1);

    // check if list contains enchantment otherwise register it
    public static void register() {
        boolean registered = Arrays.stream(Enchantment.values()).collect(Collectors.toList()).contains(TNTSHOOTER);

        if (!registered){
            registerEnchantment(TNTSHOOTER);
        }
    }

    // register method
    public static void registerEnchantment(Enchantment enchantment){
        boolean registered = true;
        try {
            Field f = Enchantment.class.getDeclaredField("acceptingNew");
            f.setAccessible(true);
            f.set(null, true);
            Enchantment.registerEnchantment(enchantment);
        }
        catch (Exception e){
            registered = false;
            e.printStackTrace();
        }
        if (registered) {
            System.out.println("Registered " + enchantment + " Enchantment");
        }
    }```

It’s printing out Registered Enchantment[minecraft:tntshooter, null] Enchantment
tardy delta
#

Lol no need for that boolean

#

Just print under adding the enxhantment

scarlet creek
#

Solved!

hard socket
earnest forum
#

have you installed java?

hard socket
#

9

#

8*

#

ig its not getting the java file how do I change the path

#

its not getting the java 8 file

shadow zinc
#

Have you got java 8?

hard socket
#

yes

shadow zinc
#

if so you need to find its location

hard socket
#

I found it

shadow zinc
#

for me it will look like this

#

/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -jar BuildTools.jar --rev 1.13 --remapped

#

so replace java with location

hard socket
#

alr thx

shadow zinc
#

np

hard socket
#

disk too right?

shadow zinc
#

well I'm using linux

#

but if you are using windows then yes

hard socket
shadow zinc
hard socket
#

''?

shadow zinc
#

"java location"

hard socket
#

oh

#

works thx

old cloud
#

Any idea why I sometimes get this log: net.minecraft.server.CancelledPacketHandleException: null. Seems to happen when receiving plugin messages.

shadow zinc
#

bro he fixed it

coral oyster
#

hi, is there a better way to write this code? Right now, you have to specify either one of the WorldTypes exactly as they are and if you don't, no code will run cos it doesn't match either of the two inputs. It just doesn't seem like using a string for a parameter that only takes 2 values doesnt seem quite right. Also just to confirm, this isn't gonna have anything to do with the Bukkit WorldType class.

    public static void addMinigameWorld(String minigameName, String worldName, String worldType) {
        if (worldType.equals("type1")) {
            //run some code here
        } else if (worldType.equals("type2")) {
            //run some code here
        }
    }
earnest forum
#

if theres only 2 options use a boolean

coral oyster
earnest forum
#

use an enum

zealous osprey
#

You could make an enum if you want to expand it and have the enum contain a lambda expression:

public enum WorldTypes {
  TYPE_1((minigameName, worldName) -> { // code }),
  TYPE_2((minigameName, worldName) -> { // code }),
  ...

  private final BiConsumer<String, String> action;
  WorldTypes(BiConsumer<String, String> action) {
    this.action = action;
  }

  public BiConsumer<String, String> getAction() {
    return action;
  }
}
coral oyster
zealous osprey
#

Though I would recommend not using BiConsumer<String, String> but rather creating an interface with maybe a function called onCall(String minigameName, String worldName) or smth

glossy basin
#

Hey I'm trying to build a listener that checks all commands that are executed. For example "//brush" from WorldEdit. I don't want to overwrite the command, but I want to execute certain actions when the command is entered. Is that possible somehow?

chrome beacon
old cloud
#

or PlayerCommandSendEvent

glossy basin
#

Awesome, thanks @chrome beacon and @old cloud

scarlet creek
#

I'm testing out vectors by making a bow that draws in entities to the arrow

Code:


    private final SurprisePlugin plugin;


    static final double rangeX = 5;
    static final double rangeY = 5;
    static final double rangeZ = 5;

    public VoidBow(SurprisePlugin plugin) {
        this.plugin = plugin;
    }


    @EventHandler
    public void onArrowLaunch(ProjectileLaunchEvent event) {

        if (event.getEntity().getShooter() instanceof Player) {
            Player player = (Player) event.getEntity().getShooter();

            if (event.getEntityType() == EntityType.ARROW) {

                    ArrowVortex((Arrow) event.getEntity());

            }
        }
    }

    public void ArrowVortex(final Arrow arrow) {
        new BukkitRunnable() {

            private int counter = 10;

            @Override
            public void run() {
                if (counter < 3 || arrow.isOnGround()){
                    arrow.remove();
                    cancel();
                    return;
                }

                Location arrowLocation = arrow.getLocation();
                List<Entity> nearbyMobs = arrow.getNearbyEntities(rangeX,rangeY,rangeZ);
                for (Entity e : nearbyMobs){
                    if (e.getType() != EntityType.PLAYER || e.getType() != EntityType.ARROW){
                        Entity entities = (Entity) e;
                        entities.setVelocity(entities.getLocation().subtract(arrowLocation).toVector().normalize().multiply(3));
                    }
                }

                counter --;
            }

        }.runTaskTimer(new SurprisePlugin(), 0, 1);
    }

}```

However it is giving me errors such as `java.lang.IllegalStateException: Initial initialization`
#

I'm not sure what's happening and am hoping if someone knew how to fix this issue...

agile anvil
#

Btw your runnable will work 0.5s

#

Even less

scarlet creek
scarlet creek
eternal night
#

new SurprisePlugin()

#

you cannot create a new instance of your plugins main class

#

use the one you pass through the constructor

scarlet creek
#

Oh I see I was confused with what It wanted

#

Thanks! It somewhat works now, just need to figure out the vector part

eternal needle
#

!help

#

!info

eternal night
#

?

eternal needle
#

hi i cant find out wait i can't stop player from taking it

    if (e.getView().getTitle().equalsIgnoreCase(ChatColor.WHITE + "Ban This Noob")) {
        Economy economy = Out.getEconomy();
        switch (e.getCurrentItem().getType()) {

            case EMERALD_BLOCK:
                Inventory clickedInventory = e.getClickedInventory(); // Get the clicked inventory
                ItemStack skull = clickedInventory.getItem(4); // Get the skull you made when you created the inventory
                SkullMeta skullMeta = (SkullMeta) skull.getItemMeta(); // Get the skull meta
                OfflinePlayer personToBan = skullMeta.getOwningPlayer();
                economy.withdrawPlayer(personToBan, 1000);
                if (personToBan.isOnline()) {
                    personToBan.getPlayer().sendMessage(ChatColor.GREEN + "Tatt 1000 fra deg for sandtak"); // If person is online, send them a message also
                }
                sandtak2.openfyll1(player);
                break;
        }
        e.setCancelled(true);
#

i did stop the player from taking it befor but rgt now i can take it from the inv and i can't do any thing with it

shadow zinc
#

?pARW

#

?paste

undone axleBOT
agile anvil
shadow zinc
#

and yes I ran this beforehand /usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -jar BuildTools.jar --rev 1.13 --remapped

#

the exact notice is Could not find artifact org.spigotmc:spigot:jar:remapped-mojang:1.13-R0.1-SNAPSHOT in spigot-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)

eternal needle
agile anvil
undone axleBOT
eternal needle
chrome beacon
#

Don't use inventory names to detect inventories

#

Use the inventory instance or the inventory holder

eternal needle
chrome beacon
#

?

chrome beacon
eternal needle
shadow zinc
chrome beacon
eternal needle
eternal needle
agile anvil
#

So the players can take every items ?

#

And nothing happens ?

chrome beacon
eternal needle
chrome beacon
#

There's your problem

eternal needle
#

no

#

or it does not do it

chrome beacon
#

It is

eternal needle
#

but

eternal needle
chrome beacon
#

The following should never be invoked by an EventHandler for InventoryClickEvent using the HumanEntity or InventoryView associated with this event:

HumanEntity.closeInventory()
HumanEntity.openInventory(Inventory)
HumanEntity.openWorkbench(Location, boolean)
HumanEntity.openEnchanting(Location, boolean)
InventoryView.close()
chrome beacon
#

You're not opening the inventory when clicking the barrier

agile anvil
#

It's not written "It won't work"

chrome beacon
#

At least not with the code you sent

eternal needle
grim ice
#

so um, I had this bug with minecraft where any versions 1.18 and above would freeze every 1 second, meaning the graph would be some thing like this:
300 -> 1 - 250 -> 1..etc
so well i used some jvm args i got recommended which ill send later,
and that fixed it, however after 3 days the bug is back, but i realized something, when the bug was fixed i had 2gb allocated and it was using 2.7gb, but when the bug still existed it was using 2gb flat, so i thought maybe that was the problem, i just tried allocating 3gb or 4gb and no luck.
the jvm args are here: https://pastebin.com/3mK9yZFf

eternal needle
eternal needle
agile anvil
#

Which one works and which one doesn't ?

eternal needle
#

i sad need more code?

eternal needle
agile anvil
#

So

#

Explain clearly your problem, and illustrate with error or something else relevant please

acoustic pendant
#
    public void onClick(PlayerInteractEvent e){
            if (e.getItem().isSimilar(totem)) {
                Player player = e.getPlayer();

                player.getInventory().removeItem(totem);
                    player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);

                    player.sendMessage(ChatColor.AQUA + "[SHENLONG] " + ChatColor.RED + "Has invocado a los dioses");
                    player.sendMessage(ChatColor.AQUA + "[SHENLONG] " +ChatColor.RED + "y tienes la oportunidad de revivir");
                    player.sendMessage(ChatColor.AQUA + "[SHENLONG] " +ChatColor.RED + "a alguien... ¡pero cuidado! Si desconocemos");
                    player.sendMessage(ChatColor.AQUA + "[SHENLONG] " +ChatColor.RED + "el nombre perderas todo derecho a comunicarte");
                    player.sendMessage("");
                    player.sendMessage(ChatColor.AQUA + "[SHENLONG] " + ChatColor.RED + "Escribe su nombre: ");
                    aSync.add(player.getName());
            }
        }```

When the first item is used, all works but the second time the server crashes, why?
iron glade
#

Dude just make a prefix variable

tardy delta
#

and do early returns

#

dont have a collection with player names but rather with their uuid

iron glade
#

Dry principle, you wanna be as „Lazy“ as possible

agile anvil
#

Life principle*

acoustic pendant
iron glade
#

btw is there a good reason to use CharColor.<Color> instead of just color codes?

tardy delta
#

if you use color codes you still gotta translate those so same thing

#

if you got a long string then i use color codes and pass that string to ChatColor.translateBlaBlaBla

acoustic pendant
iron glade
tardy delta
#

dont you have enough with this lol?

#

check if e.getItem is not null

acoustic pendant
#

It did before i believe

agile anvil
iron glade
tardy delta
#

reverse your logic and check if token.isSimilar(e.getItem())