#help-development

1 messages · Page 700 of 1

tribal quarry
#

same for getItemInOffHand()

gilded granite
#

Oh yeah i used mojangs itemstack

signal kettle
#

ItemStack item = player.getInventory().getItemInMainHand();

tribal quarry
#

watch kody's tutorial, you're probably serializing yaw in a wrong way (Im not sure).

gilded granite
#

Thats why its want working

signal kettle
#

this btw work

gilded granite
#

nice

signal kettle
#

thank you very nice ❤️

gilded granite
#

i just asked chatgpt breh

tribal quarry
#

but why you need that?

#

for what?

gilded granite
#

to get items in chat

#
        ItemStack stack = new ItemStack(player.getInventory().getItemInMainHand());
        TextComponent component = new TextComponent();
        component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, ItemContent.from(stack)));```
tribal quarry
#

and mirror it as nms itemstack

#

or just get the handle field (if itemstack is a CraftItemStack)

gilded granite
#

I dont need to use nms itemstack

#

I just use the bukkit one

tribal quarry
#

So I don't see any issue here, nvm

gilded granite
#

No there is no issues breh

#

the only issue is that it displays an empty messgae

slender elbow
signal kettle
quaint mantle
#

thats p cool

kindred sentinel
#

Backpack

signal kettle
kindred sentinel
#

I think it's working a bit with lags?

quaint mantle
#

isnt that a lot of packets

#

and heeavy on playermoveent?

kindred sentinel
remote swallow
#

item with custom model data?

kindred sentinel
signal kettle
#

I mean it’s HMC Cosmetics plugin and its work fine for 100+ players with other heavy plugins like custom blocks, mobs etc without bigger issues so I think it inst that bad

#

somehow it’s optimised, idk how but if its work well without issues

signal kettle
gilded granite
#

any1 know how do it fix
Required type:
Objective
Provided:
ObjectiveArgument

#

and
Required type:
FriendlyByteBuf
Provided:
Score

signal kettle
# kindred sentinel Or CIT

nah I want to make as much feels like moded server without need to use any mods, even optifine, so players ca join, download resource pack and have fun

hexed kettle
#

Does someone know if you can spawn a block display and set a state to interpolate to in the same tick, because when I try that it instantly goes to the 2nd stage without an animation. Delaying setting the state to interpolate to by a Bukkit runnable works tho (kinda dont want to tho). Ty for the answer in advance.

remote swallow
#

use the spawn method with a consumer

mortal hare
#

why intellij so dumb

#

nvm im dumb it returns previous value 😄

#

not the current one in the map lol

hasty prawn
#

Yeah usually you're the wrong one if you think IntelliJ is dumb KEKW

mortal hare
hasty prawn
#

I've never seen it do it in Java iirc

#

Rust is a different story however

mortal hare
#

it usually with custom boolean getters

#

and then it complains that value is not checked

#

while using object getter after checking the boolean value from the method

#

and it makes sense because it doesnt know that the boolean getter method is somehow connected to the object

#

but in that case i would like to be it less agressive

quaint mantle
#

what should I do

hexed kettle
mortal hare
#

configurer.getName() returns a nullable

#

it throws warning for it

#

but it would get checked anyways in the .addCommandCategory() method above

remote swallow
#

intellij doesnt check othermethods

#

or think "this method will get called first"

mortal hare
#

intellij is too agressive on warnings sometimes

compact haven
#

bro what

#

do not say "too agressive on warnings"

#

it's literally a runtime error vs. a helpful squiggly to remind you something may be wrong

#

and yeah no IDEA does not recursively check each method for assertions, that's ridiculous

pseudo hazel
#

I mean it can still fail if you call the second method manually

#

nvm

#

i read it wrong

#

but still I agree with dominick

vital sandal
#

Anyone know what is the char code for that ?

worldly ingot
#

For what?

#

The ping icon? Because that's just a vanilla game sprite

pseudo hazel
#

a char code couldnt have this many colors anyways

worldly ingot
#

Huh? You can colour characters any way you'd like

pseudo hazel
#

well I just mean with the vanilla resource pack/font

next zinc
#

?paste

undone axleBOT
next zinc
#

I've tried debugging, checking console for errors, etc and can't find any reason why no particles are spawning

#

The event itself doesn't seem to be called at all

opal carbon
#

if so

#

make sure you registered listener

#

and make sure you did the @EventHandler annotation

next zinc
#

It is registered and had the annotation

#

omg

#

it didnt have an annotation

#

wow

#

ty for the help

#

lmao

plain plaza
#

Anyone knows the problem why my ServiceManager is not registering on time or in order?

Main.java (onLoad)

this.api = new API(); // API implements InterfaceAPI
this.getServer().getServicesManager().register(InterfaceAPI.class, this.api, this, ServicePriority.High);

Main // plugin.yml

name: MainPlugin
version: '${project.version}'
main: xyz.apollo30.arcane.Main
api-version: '1.19'```



**SecondMain.java** (onEnable)
```java
ServicesManager servicesManager = plugin.getServer().getServicesManager();
if (servicesManager.isProvidedFor(type)) {
     RegisteredServiceProvider<T> provider = servicesManager.getRegistration(type);
     if (provider == null) return;
     this.service = provider.getProvider();
     plugin.getLogger().info(String.format("Successfully hooked into %s!", name));
} else {
     plugin.getLogger().severe(String.format("Could not hook into %s. This may cause major errors in the plugin.", name));
}```



**SecondMain // plugin.yml**:
```yml
name: SecondPlugin
version: '${project.version}'
main: xyz.apollo30.arcane.SecondMain
api-version: '1.19'
depend:
  - MainPlugin

MainPlugin is a dependency for SecondPlugin and it does load before it but I can't seem to fetch the registered service manager in the second plugin?

#

Anyone knows what's up?

slender elbow
#

is the second plugin shading the main plugin (api) ?

#

rather, make sure it isn't

plain plaza
#

doesn't look like it no

plain plaza
#

oh it probably is, one second

#

Yep that solved it, turns out I forgot to add the scope to provided.

#

Not sure why it's like that, but yeah thanks for the help.

warm light
#

event get called on this line

#

then how it going to check from next line if the event is cancelled or not?

river oracle
#

Yeah events are synchronous

#

So the is cancelled call will be next

warm light
#

but it get called already before cancel.
like if I do any task with the custom event, it wouldn't check if the custom event cancelled or not

rotund ravine
#

Excuse me?

#

Do you know how the system works?

#

You call the event

#

And let listener change the variables etc.

#

Then you handle the changed information

sterile axle
stray flare
#

https://paste.md-5.net/ujifuviguy.cs

The resetPortalFrames isn't working properly, I mean it doesnt work at all.
My intention was whenever a player used all of his eyes the frames should get a reset or override it by new frame blocks, I tried that but It doesn't really work.

sterile axle
#

As said in #general, add some log lines in your interact event and resetPortalFrames code. However, with that intention you just gave, that's not going to work. You're storing a global count for eyesUsed, meaning every player contributes to that counter whenever the interact event fires. Say you and another person throw one eye each, your listener will have eyesUsed = 2, not eyesUsed = 1 for both of you. You're going to need to use some sort of data structure (like a map or something) to map UUIDs to eyesUsed and check how many eyes each player has used that way.

Anyway the log lines will hopefully shed some light on what's going wrong, as your code should "work" -- but it won't work the way you're currently intending based on your description

stray flare
sterile axle
#

Sure thing

river oracle
stray flare
#

it was paper_and some numbers idk

#

and I have changed it by UUIDs that helped, thanks

simple schooner
#

E

kind hatch
#

Anyone know why maven throws these warnings and how to fix them?

tender shard
#

because those versions won't be compatible with maven 4 anymore, the warnings should be gone if you update them to the latest versions

#

you can also set maven.plugin.validation to NONE

sharp bough
#

is it possible to add a value at the end of the chain of tab completion? meaning that it would append to the list of any list of player list in a autocomplete tab, the idea is to add, for example "test" to every plugin trying to autocomplete the playerlist

kind hatch
#

I think you can do that with Player#addCustomChatCompletions()

sharp bough
#

the thing is it would need to have the lowest possible priority, run last, right before sending to the player
to append to the custom lists made by plugins

kind hatch
tender shard
#

the compiler plugin and resources plugin are inherited from the "super pom". you can either just set a version yourself without any configs, or disable the validation

#

though IIRC maven-resources-plugin, latest is 3.3.1 so probably not a big change lol

kind hatch
#

What's a super pom?

tender shard
#

that is the pom that every project inherits automatically

#

e.g. the one that defines the central repo

kind hatch
#

How would you set the version without any configuration aspects?

tender shard
#

why do you need two specialsource plugins?

kind hatch
#

Multiversion

tender shard
tender shard
kind hatch
#

It's multi module, but I'm using the specific version of special source that released with the version of MC in the appropriate module.

tender shard
#

the latest specialsource plugin usually works with all versions

#

at least for me that always worked. I just always used 1.2.2 lol

#

but yeah I'd just set the validation to NONE, it complains about many latest builtin plugins too sooo it's kinda pointless

kind hatch
#

I use different versions beacuse I had issues with 1.17. I don't care what anyone says, 1.17 was a scuffed release and the tooling was not on my side.

kind hatch
tender shard
#

maven 4 will break many things anyway

#

no more system scope 🥳

#

at least not to files within the project dir

tender shard
#

Automatic parent/dependency versioning
Finally

cursive kite
#

What is DirectMethodHandler error

steel spindle
#

hi, everybody, I've got a problem. Компилирую плагин через gradle, никаких ошибок нет. В build.gradle все зависимости есть

build.gradle:

dependencies {
    implementation 'org.luaj:luaj-jse:3.0.1'
    compileOnly "org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT"
}

but when the plugin is run on a minecraft server it causes this error:

[10:12:11 ERROR]: Error occurred while enabling MLua v1.0 (Is it up to date?)
java.lang.NoClassDefFoundError: org/luaj/vm2/lib/jse/JsePlatform
        at org.smokingplaya.mlua.MLua.onEnable(MLua.java:32) ~[?:?]

java class:

package org.smokingplaya.mlua;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.jse.JsePlatform;

public final class MLua extends JavaPlugin {
    @Override
    public void onEnable() {
        Bukkit.getConsoleSender().sendMessage("that works");

        String script = "print('hello, world', _VERSION)";

        // create an environment to run in
        Globals globals = JsePlatform.standardGlobals();

        // Use the convenience function on the globals to load a chunk.
        LuaValue chunk = globals.load(script, "maven-exmaple");

        // Use any of the "call()" or "invoke()" functions directly on the chunk.
        chunk.call();
    }
}
#

what should I do?

teal wagon
#

you should shade the library into your plugin

steel spindle
chrome beacon
#

Use the shadow jar plugin

steel spindle
#

@teal wagon @chrome beacon You guys are the best! Thank you so much! I was up all day yesterday trying to figure out what was wrong and how to do it right.

sage patio
#

is this:

sorting-types: '[GROUPS:owner,developer,admin,default]'

same as this in yml ?:

sorting-types:
  - GROUPS:owner,developer,admin,default
chrome beacon
#

Swap the ' and [] around

#

then yes

sage patio
#

like this :?

['GROUPS:owner,developer,admin,default']
chrome beacon
#

Yes

sage patio
#

this is what i'm doing with TAB plugin from my plugin

#

how?

small current
#

which repository does bStats belong to?

chrome beacon
small current
chrome beacon
#

That's an old version of bstats

#

Over 2 years old

small current
#

so i should implement the jar?

#

or implement it myself

chrome beacon
#

You should update

#

?

small current
#

no im trying to implement a plugin

#

compileOnly 'com.github.DevLeoko:AdvancedBan:v2.3.0'

#

i only got this

#

but bstats error

sage patio
small current
#

but in the github page

#

it said its on jitpack

sage patio
#

i'm using AdvancedGUI api in my plugin, this works fine for me

#

try this one

small current
#

aight

#

same error

#

when i implemented bStats myself it was fixed

sage patio
#

no idea, didn't used bStats over 2 years, all of my plugin are private
but the last time i used bStats it was a class to use in the project

#

try implementing the class instead of using gradle or whatever

livid dove
#

Bstats 1.5 aye? Pretty sure in those days it was just a class but nowadays u need ur plugin I'd too

#

Id

sweet sonnet
#

add dependancy, shade it, make new instance with your plugin id you get from the website

snow shadow
#

?paste

undone axleBOT
snow shadow
#

https://paste.md-5.net/tihicexoku.cs
This code does not give any error to the console. What it needs to do is run a method that will save the locations of the blocks that are placed and broken later and delete them. It saves locations and can delete and replace blocks whenever I want. But when I break a block I put myself, it puts it back in its place. How do I prevent this?

lost matrix
snow shadow
lost matrix
snow shadow
lost matrix
# snow shadow Sorry, I didn't fully understand that. Can you explain this a little more?

So you want to have an area which can be restored after players are done playing in it, right?
Then start by creating some Map<Location, BlockData> where you can store blocks.
Now if a block gets changed for the first time by events like:

  • BlockBreakEvent
  • EntityExplodeEvent
  • BlockFromToEvent
    etc. -> You store the block in the Map<Location, BlockData>.
    But after a block has changed once (for example if someone breaks a grass block) you dont save the data
    if the block changes again (for example if someone places another block there).

So before adding something to your map, you simply check if this location is already filled with original
block data. If it is then you dont overwrite this data.

snow shadow
#

Oh

#

Okay

#

Thank you 7smile7

smoky oak
#

If you use Collection<Object> as a parameter and do manipulations to the objects in that collection, would a list passed into the method retain it's ordering if the list itself is not changed, and iteration happens with a for(Object o: loop?

lost matrix
#

Generally speaking a collection does not change its order if the state of their elements are mutated.
But there are only a few collections which have an order in the first place. Sets for example are by definition unordered.

smoky oak
#

lright

#

Also relevant though for a completely different reason, does bukkit have any internal methods for vector math? I need to rotate a set of locations that 'point' towards 'north' by yaw and pitch

#

*around a specific point, not around 0,0,0

lost matrix
#

Yes, you can rotate a vector around any axis

rotund ravine
#

?j-dc

#

?jdc

#

?javadoc

lost matrix
#

?jd-s

undone axleBOT
smoky oak
#

well the axis for the second rotation changes with the first rotation doesnt it? Thats kinda why i asked if bukkit has some internals for that, i do recall java having vectors

rotund ravine
smoky oak
#

I'm not sure how to obtain the second rotational axis

lost matrix
smoky oak
#

a set of particles to align with player vision

#

the first rotation makes it so the second rotation axis no longer is a unit vector a la two 0 one 1

#

I dont recall the operation to obtain the correct secondary rotation axis

lost matrix
#

A rotation doesnt change the lenght of a vector...

smoky oak
#

i rotate by pitch and yaw. I can do either by rotating around 0,1,0 or 1,0,0, but the OTHER rotation axis changes if i do the first rotation

#

i need that second axis

lost matrix
#

What do you mean the other rotation axis changes?

#

You can rotate around 0,1,0 and then around 1,0,0

smoky oak
#

if you have a single vector, yes

#

*maybe

#

but if you want to rotate a bunch of stuff, the projection gets warped if you do that

#

the second rotation axis is perpendicular to y and the rotated vector

upper hazel
#

intellij became shit when it updated to the latest version what the fuck. Any idea how to enable autosave?

tall dragon
#

autosave?

upper hazel
#

yes

tall dragon
#

intellij always saves almost immediately

upper hazel
#

no

tall dragon
#

idk what u have done then

upper hazel
#

it reacts to events

#

close, run e t c

smoky oak
#

actually that axis is probably either the dot or cross of the 0,1,0 and the rotated vector lol

#

nvmind

upper hazel
#

intelji now freezes frequently

tall dragon
#

havent had issues with that just yet

upper hazel
#

you update last version?

lost matrix
upper hazel
#

if yes, then try to copy the name of material and paste and find out

smoky oak
#

ah

#

i need to rotate around both

#

to move a image thats projected 'north' to align with the player vision

#

i said AND not OR

#

also

#

pitch and yaw cause roll if you rotate 1,0,0 and 0,1,0 instead of the secondary shifted rotation

tall dragon
tall dragon
lost matrix
snow shadow
# lost matrix So you want to have an area which can be restored after players are done playing...
public class BlockRestorer {
    public static Map<Location, BlockData> originalBlockData = new HashMap<>();

    public void storeOriginalBlockData(Location location, BlockData blockData) {
        originalBlockData.put(location, blockData);
    }

    public BlockData getOriginalBlockData(Location location) {
        return originalBlockData.get(location);
    }

    public void clearOriginalBlockData(Location location) {
        originalBlockData.remove(location);
    }

    public boolean hasOriginalBlockData(Location location) {
        return originalBlockData.containsKey(location);
    }

    public static void restoreBrokenBlocks() {
        for (Map.Entry<Location, BlockData> entry : originalBlockData.entrySet()) {
            Location location = entry.getKey();
            BlockData blockData = entry.getValue();

            if (location.getBlock().getType() == Material.AIR) {
                location.getBlock().setBlockData(blockData);
                originalBlockData.remove(location);
            }
        }
    }```

```java
@EventHandler
    public void onBlockBreak(BlockBreakEvent e){
                    blockRestorer.clearOriginalBlockData(e.getBlock().getLocation());
                    e.getBlock().setType(Material.AIR);
    }```No broken blocks are renewed anymore 😃 What did I do wrong?
lost matrix
# snow shadow ```java public class BlockRestorer { public static Map<Location, BlockData> ...
  1. Make your map private, and non-static
  2. Make the restoreBrokenBlocks() method non-static
  3. Modifying a map while iterating over it will cause a ConcurrentModificationException
  4. Show the rest of the code

Also: This if clause will cause a ton of trouble. I dont see the logic behind it really...

    public static void restoreBrokenBlocks() {
        for (Map.Entry<Location, BlockData> entry : originalBlockData.entrySet()) {
            Location location = entry.getKey();
            BlockData blockData = entry.getValue();

            if (location.getBlock().getType() == Material.AIR) {
                location.getBlock().setBlockData(blockData);
                originalBlockData.remove(location);
            }
        }
    }

should be just

    public void restoreBrokenBlocks() {
        for (Map.Entry<Location, BlockData> entry : originalBlockData.entrySet()) {
            Location location = entry.getKey();
            BlockData blockData = entry.getValue();
            location.getBlock().setBlockData(blockData);
        }
        originalBlockData.clear();
    }
median fern
#

How do I serialize a ConfigurationSerializable Object

#

I registered it

#

Now what

remote swallow
#

Config.set

lost matrix
median fern
#

Ok

lost matrix
eternal oxide
#

your own objects, yes

#

must be registered before you attempt to touch yoru config

median fern
#

Yeah

snow shadow
# lost matrix 1) Make your map private, and non-static 2) Make the ``restoreBrokenBlocks()`` m...

The rest of the code:

@EventHandler
    public void onBlockBreak(BlockBreakEvent e){
                    blockRestorer.clearOriginalBlockData(e.getBlock().getLocation());
                    e.getBlock().setType(Material.AIR);
    }```

```java
  public boolean onCommand(blah blah){
      //... blah blah again
        if(args.length == 1){
                if(args[0].equalsIgnoreCase("restart")){
                    for(Player players : Bukkit.getOnlinePlayers()){
                        players.sendTitle(Utils.color("&6&lEvent Restarting..."), Utils.color("&eYou Are Teleporting"), 10, 20, 10);
                        new BukkitRunnable(){
                            @Override
                            public void run(){

                            }
                        }.runTaskLater(plugin, 20 * 2);
                    }
                    restoreBrokenBlocks(); 
                    clearPlacedBlocks();
                }
            }
}```

```java
private static Map<Location, Material> placedBlocks = new HashMap<>();

    public BlockPlaceListener(RestartMap plugin) {
        this.plugin = plugin;
    }

    public static void clearPlacedBlocks() {
        for (Location location : placedBlocks.keySet()) {
            location.getBlock().setType(Material.AIR);
        }
        placedBlocks.clear();
    }

    @EventHandler
    public void onBlockPlace(BlockPlaceEvent e){
        placedBlocks.put(e.getBlock().getLocation(), e.getBlock().getType());

    }```
Also, after doing what you said, intellij gives 2 errors.
1st : `Cannot resolve method 'restoreBrokenBlocks' in 'EventCommand'`
2nd: `Non-static field 'originalBlockData' cannot be referenced from a static context`
lost matrix
#

Havent used this in forever.

lost matrix
snow shadow
near mason
#
public class PluginName extends JavaPlugin {
  private BlockRestorer restorer;
  @Override
  public void onEnable(){
  restorer = new BlockRestorer();
  }
}
snow shadow
#

🤦

median fern
#

So how do I use that Serialization stuff

snow shadow
#

be ashamed

lost matrix
# snow shadow I'm sorry for not understanding many things and asking questions all the time, b...

A class is just a blueprint which describes functionality. It can do nothing on its own. You cant call anything in it and dont use its variables.
If you want to use it you need to create an instance of this class. This means you 'build' or 'construct' an object using the new keyword.

BlockRestorer someVariable = new BlockRestorer();
BlockRestorer blib = new BlockRestorer();

This code snipped created two instances of your BlockRestorer class.
They each have their own methods, own maps and are completely independent from each other.

snow shadow
#

Thank you

#

Also you are so handsome

#

😃

lost matrix
cobalt thorn
#

I got a question based on an Scp (Scp-294 or the coffee machine), its possible to pull of all the possible material in existence and give them something they do like in the wiki is written “anti-water” and pull it off inside the game or any other real life material as a water bottle and give them effect based on the name

quaint mantle
#

yes if you make it ofc

snow shadow
#

But in order to use it in other classes, shouldn't I make it public static instead of private? Now I deleted the BlockRestorer variables that I created in other classes and nothing changed 😄

cobalt thorn
cloud knot
#

Guys Is there any plugin that if a player sends a Chat the nearest player will be the only one to read it and so the other players who's far off from the Player who Sends the chat it will not be visible

quaint mantle
#

then do it

cobalt thorn
#

But never worked with ai and java is probably not the best for it

quaint mantle
#

then learn how to work with ai

echo basalt
lost matrix
# snow shadow But in order to use it in other classes, shouldn't I make it public static inste...

You need to pass this instance around. Every class needs to store a variable which contains this instance.
This should be done in their constructors.
For example

public class RestoreListener implements Listener {

  private final BlockRestore restore;

  public RestoreListener(BlockRestore restore) {
    this.restore = restore;
  }

  @EventHandler
  public void onPlace(BlockPlaceEvent event) {
    Block block = event.getBlock();
    Location location = block.getLocation();
    ...
    if(!this.restore.hasOriginalBlockData(location)) {
      this.store.storeOriginalBlockData(location, block.getBlockData());
    }
  }

}
snow shadow
lost matrix
# snow shadow I did this class but I have to shyly ask something. What are we doing now? 😄 In...

You need to overhaul quite a bit of your plugin if you abused static before and are now switching to proper dependency injection.
You onEnable might need to be updated to something like this:

public class RestorePlugin extends JavaPlugin {

  @Override
  public void onEnable() {
    BlockRestore restore = new BlockRestore();
    BlockRestoreListener listener = new BlockRestoreListener(restore);
    BlockRestoreCommand command = new BlockRestoreCommand(restore);

    Bukkit.getPluginManager().registerEvents(listener, this);
    getCommand("restore").setExecutor(command);
    ...
  }

}

And no worries, we are in this channel to help. If i get bored i can just leave smileybolb

#

So remove all the static methods and variables and replace them all with calls on an actual instance of a class.

lost matrix
snow shadow
lost matrix
snow shadow
#

oh okay

#

give me a second

#

😭

#

3 new errors

lost matrix
#

Lets see them

snow shadow
#

I did what you said in classes with errors
There is no change in the old errors, but the new ones are as follows: Variable 'plugin' might not have been initialized & Variable 'restorer' might not have been initialized & Cannot resolve method 'restoreBrokenBlocks' in 'EventCommand'

lost matrix
#

Show the classes pls

snow shadow
#

?paste

undone axleBOT
snow shadow
lost matrix
# snow shadow okay please check dm
    private final RestartMap plugin;
    private final BlockRestorer restorer;

    public EventCommand(RestartMap plugin, BlockRestorer restorer) {
        this.plugin = plugin;
        this.restorer = restorer;
    }

Change what you have to this.

snow shadow
#

Well, is there a solution to other errors?

Cannot resolve method 'restoreBrokenBlocks' in 'EventCommand'
Non-static field 'originalBlockData' cannot be referenced from a static context

lost matrix
snow shadow
#

oh okay

lost matrix
#

And the second one is from a different class i assume

snow shadow
#

Yeah

#

From BlockRestorer

#

I can send it

#

?paste

undone axleBOT
lost matrix
#

I think i can imagine the problem

snow shadow
lost matrix
#

Your method is still static

snow shadow
#

bro

#

..

lost matrix
snow shadow
#

im stupid

#

🤦

echo basalt
lost matrix
#

This will show another problem. I think you can solve that

echo basalt
#

only problem I see is using locations instead of blockvectors or whatev

snow shadow
#

The IDE is not giving any errors now

cobalt thorn
snow shadow
#

I'm really ashamed to say this, but the situation is still the same. The blocks I break do not come back.

echo basalt
#

show code

snow shadow
#

BlockRestorer: https://paste.md-5.net/esicanohav.cs

    public class BlockBreakListener implements Listener {

    private final BlockRestorer restorer;

    public BlockBreakListener(BlockRestorer restorer){
        this.restorer = restorer;
    }
    @EventHandler
    public void onBlockBreak(BlockBreakEvent e){
        restorer.clearOriginalBlockData(e.getBlock().getLocation());
    }```

```java
  @Override
  public boolean onCommand(blah blah){
  ...
  this.restorer.restoreBrokenBlocks();;
}```
upper hazel
#

help who has a tutorial or piece of information related to the topic of schematic file regeneration

round finch
#

1 you could use worldedit api or 2 you could make a custom schematic file system

eternal oxide
#

Bukkit already has schematics

round finch
#

besides that there is regions

round finch
#

the more you know

round finch
#

wow

#

lol i must have forgotten

upper hazel
#

what thre registry

upper hazel
#

oh

#

give pls)

echo basalt
upper hazel
#

thf

echo basalt
#

bit complex but makes minigames easy

#

You just make a grid and templates

upper hazel
#

there is everything related to the regeneration of the schematics?

echo basalt
#

uhh

#

Just unload and re-paste

#

It doesn't really "regenerate" them as much as it just nukes everything

upper hazel
#

oh

echo basalt
#

otherwise you have problems with entities and weird blockstates

upper hazel
#

everything is much easier than it seemed lol

#

does the automine connected with trees also work?

echo basalt
#

no clue what you're on about at this point

upper hazel
#

bruh translate sack

#

this traslate really sack

#

and the plugin for the auto mine where the trees appear also regenerate so?

solid cargo
#
        at me.powerbutton.stuff.Stuff.checkForPluginSizeAndRestart(Stuff.java:136) ~[Stuff-1.0-SNAPSHOT.jar:?]
        at me.powerbutton.stuff.Stuff.lambda$onEnable$0(Stuff.java:93) ~[Stuff-1.0-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.20.1.jar:git-Paper-84]
        at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480) ~[paper-1.20.1.jar:git-Paper-84]
        at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1480) ~[paper-1.20.1.jar:git-Paper-84]
        at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447) ~[paper-1.20.1.jar:git-Paper-84]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1394) ~[paper-1.20.1.jar:git-Paper-84]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1171) ~[paper-1.20.1.jar:git-Paper-84]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-84]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassNotFoundException: me.powerbutton.stuff.RestartReason```
#

this is what happens when i use enum, but when i changed the restartreason to be strings it worked okay

tender shard
solid cargo
#

yes

tender shard
#

well then the .jar doesn't include that file

#

open your .jar, see if it's actually there

solid cargo
#

i decompiled it and its there

tender shard
#

in the same .jar?

sullen marlin
#

?whereami

solid cargo
#

uh oh

#

yeah its there

tender shard
#

are you referencing the class in onEnable the first time?

#

If yes, the classloader won't load new classes anymore

#

I mean in onDisable()

#

in onDisable you cannot load new classes anymore

solid cargo
#

nah my disable method is empty

tender shard
#

then show your Stuff class

solid cargo
#

thats the main class

tender shard
#

yes

solid cargo
#

?paste

undone axleBOT
solid cargo
#

TW its ugly

tender shard
#

how does Utils look like

remote swallow
#

why in the frick is utils a non static class

solid cargo
#

i have no idea

#

as i said its ugly

tender shard
#

add a field to your main class

private static final RestartReason DUMMY_RESTART_REASON = RestartReason.SCHEDULED;
#

that should fix it

solid cargo
#

got it

#

that did not fix it it looks like

sullen marlin
#

?whereami

solid cargo
#

🤓

#

ok ima switch to spigot big guy

quaint mantle
#

i do not recognize spigotmc

remote swallow
#

did you just nerd md

quaint mantle
#

and roles cache is still broken

remote swallow
#

leave and rejoin

quaint mantle
#

nah

remote swallow
#

yah

quaint mantle
#

nuh uh

small current
#

yuh uh

quaint mantle
#

nuh uh

small current
#

yuh uh

remote swallow
#

yuh uh

quaint mantle
#

no

#

anyways

solid cargo
#

are we friends now message digest five?

quaint mantle
#

you know how easy it is to spoof name of server engine

#

in f3

solid cargo
#

this is not one of these times

quaint mantle
#

how can we know tho?

solid cargo
#

you just know

austere cove
#

I always love how server brand is in quotes

#

like why

solid cargo
#

Instead of “your moms” server

round finch
#

your mom's server

onyx fjord
#

is there an event for when item gets added to inventory?

echo basalt
#

no

shadow night
#

I have made one before

tender shard
#

yaay my PR for the mvdev plugin was merged

sterile token
tender shard
#

then you're doing it wrong lol

sterile token
#

yeah, any recommendations? i Mean if i dont disturb you of course

tender shard
#

usually merges work 100% automatic unless the file was changed after the PR was opened

sterile token
#

Most of the time when im merging 2 branch togethers, it opens lost of issues related to same files changed

tender shard
#

if they don't, then you'll be shown an editor with a bunch of >>>>>>>>>>>>>>>>>>> lines and you'll manually have to merge it, then remove all those "merge" lines

#

that's called a merge conflict

sterile token
#

yeah i always have them

tender shard
#

that can only happen if you edit two branches at the same time or if the target branch has been changed after the pull request was opened

sterile token
#

oh right

tall dragon
#

does any1 know if its possible to "speedup" certain tile entities easily? say hoppers for example?

tender shard
#

there's settings for hoppers in bukkit.yml or spigot.yml

tall dragon
#

right there is. but i want to do with specific ones

#

not all of them globally

tender shard
#

that's not possible, they get ticked when they get ticked. IIRC the server loops over all TileEntities every tick and then if it's a hopper, does the hopper logic if the current tick number is dividable through the hopper speed or sth like that

#

I mean you could ofc manually loop over them and manually cause them to update

#

the NMS hopper should have a tick() method that oyu can call

tall dragon
#

pretty sure it just counts down an integer which spigot then sets to whatevers been set in its config after the hopper logic

tender shard
#

yeah but it doesnt do that for each individual hopper

tall dragon
#

possibly

tender shard
#

hm looks like cooldownTime is stored per hopper, not globally

#

so you could try to set it for individual hoppers

#

it's in TileEntityHopper

tall dragon
#

ah yea i did think so wasnt sure

#

though after each iteration of its logic, spigot will set it no?

tender shard
#

probably. I have only checked the craftbukkit code, which uses the hardcoded values and the pushitemsTick method seems to be unused

tall dragon
#

didnt you also have a post on using remapped spigot?

tender shard
#

?nms

tall dragon
#

cuz i havent rlly done that before

#

thanks

tender shard
#

np

#

I think the actual logic is the static method tryMoveItems in TileEntityHopper

tall dragon
#

yea pretty sure it is

#

it will check its time stuff every tick and then it calls that

#

il go and see if i can hammer something feasable out. thanks for the insight

tender shard
#

good luck!

grim hound
#

I just wanted to make a ping check

#

using keep alives

#

but for some reason the client doesn't really respond to them

slender elbow
#

well yeah, usually it goes the other way around

#

the client sends a keepalive that the server responds to

#

oh, hm, minecraft does it the other way around :thonkhmm:

humble heath
#

looking for coders to help with develepment on a new project

remote swallow
humble heath
#

make a compleate plugin has everything a server could ever need in

eternal oxide
#

lol

slender elbow
remote swallow
chilly hearth
#

e

#

so

echo basalt
#

make it 2 plugins

tender shard
#

Or one and a half

#

Two and a half plugins

wise adder
#

Make it so that this plugin can run other plugins in it

echo basalt
#

make a plugin that has a gui where you set your setup type and it downloads shit for you

chilly hearth
#

i created a command that spawns a entity i add that enitity into a variable and now i want to give the player a reward whoever kills it ofc that can be done by Entitydeathevent so how can i accsess that variable onto that event class

echo basalt
#

pdc

tender shard
#

Always pdc

#

Pdc best

chilly hearth
#

how does pdc will help

tender shard
#

You give the entity a pdc tag

chilly hearth
#

you mean i can store a key to that entity and how do i accsess to another class ?

tender shard
#

And in death event check if ot has that tag

chilly hearth
#

oh

#

smart

chilly hearth
quaint mantle
#

Ex you can enable spawn npcs and choose a spawn and it auto sets everything up

wise adder
#

Oh

#

I want that

remote swallow
echo basalt
#

Or if you really care, change your listeners to put your old block data onBreak and onPlace

dawn flower
#

how do i stop the vanilla mining animation in a BlockDamageEvent? i want to replace it with a custom one, do i just cancel the event

echo basalt
#

You really can't

#

or well

#

It's weird

#

Mining fatigue n all

dawn flower
#

i think mining fatigue -1 works but im not sure how ill give it before the actual animation pops up

#

i want to make custom mining

tender shard
# chilly hearth can u help me with taht pwease : )

or: Why you should NEVER use NBT tags again! Spigot 1.14.1 added the biggest improvement that (in my opinion) ever made it into the Bukkit API: The Persistent Data Container (PDC). It can be used to store custom data on Entities, TileEntities, and ItemStacks. Using a bit of math, it can also be used to...

echo basalt
#

you aren't the only one

#

ideally you give it permanently and rewrite all the block breaking logic

snow shadow
tender shard
# chilly hearth can u help me with taht pwease : )

basically you can just create a NamespacedKey in your main class, e.g. "is-my-custom-entity" as public final field. Then when you spawn the entity, you apply this with a random value, e.g. string or byte (or boolean when on 1.20), and when the entity dies, just check if it has that tag

#

or with a getter ofc

#

whatever

dawn flower
#

i really dont want to mess with the other blocks breaking logic

#

ill figure it out ig

#

ty tho

clever lantern
#

what to add in itemmeta so my listener can later recognize this item and it wont be visible in game

tender shard
# clever lantern what to add in itemmeta so my listener can later recognize this item and it wont...

or: Why you should NEVER use NBT tags again! Spigot 1.14.1 added the biggest improvement that (in my opinion) ever made it into the Bukkit API: The Persistent Data Container (PDC). It can be used to store custom data on Entities, TileEntities, and ItemStacks. Using a bit of math, it can also be used to...

sterile token
#

is it okay to update an scoreboard every 5 seconds?

eternal oxide
#

yes

sterile token
#

right, i mean because i dont cause server issues related to executing too many tasks and made it really periodically

clever lantern
tender shard
#

attribute modifiers change attributes, like generic armor, movement speed etc.

item flags are self explanatory, e.g. HIDE_ENCHANTMENTS will hide the enchantments, etc

clever lantern
#

ok tysm

upbeat fog
#

Hi! I need some help figuring out why my plugin doesnt detect this PiglinBrute entity.
Error: Caused by: java.lang.NullPointerException: Cannot invoke "com.dumbllama.halalboxcustombosses.mobs.Hellboss.getInstance()" because "this.hellboss" is null

Where I need to detect it:

  private HellBossManager bossManager;
    public Hellboss hellboss;
    PiglinBrute mob = hellboss.getInstance().boss;

    private int timeLeft = 10;

    public BossKilledTask(HellBossManager bossManager){this.bossManager = bossManager;}
#

I declared it here: (Different class)


  private Hellboss hellboss;

    public Hellboss getInstance() {
        return hellboss;
    }
   public PiglinBrute boss;

     public void Spawnmob(Location loc, HalalBoxCustomBosses plugin){
         boss = (PiglinBrute) new MobSpawn("§c§lHell Boss",500, EntityType.PIGLIN_BRUTE).spawn(loc);
         boss.getPersistentDataContainer().set(hellBoss, PersistentDataType.BOOLEAN,true);
         boss.setAdult();
         boss.getEquipment().setItemInMainHand(weapon);
         boss.setAI(true);
         boss.setImmuneToZombification(true);
         boss.setRemoveWhenFarAway(false);
         boss.setNoActionTicks(5);
         boss.setNoDamageTicks(10);
         boss.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(100);
         boss.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(.63);
         boss.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(10);
         boss.getAttribute(Attribute.GENERIC_ATTACK_KNOCKBACK).setBaseValue(5);
         boss.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(5);
lost matrix
upbeat fog
#

In a different class I declared the hellboss.

lost matrix
#

That just means your code ran before you set the field from outside.
PS: Never make your fields public.

upbeat fog
#

yeah I dont usally do that xD

#

I just needed to access the mob

#

in a different class

bitter rune
#

Just a note you can use ChatGPT for free and it'll literally create codes for you and fix your code, you can also have it completely explain in great detail how the code works. May help some

lost matrix
#

Ok. Still no reason to make it public.

upbeat fog
#

I just realized I created an instance for the class xD

lost matrix
bitter rune
#

You can have it use updated code you have to be precise in exactly what you want

upbeat fog
#

So how would you pass the mob to a different class so it won't return null?

lost matrix
tender shard
lost matrix
# upbeat fog So how would you pass the mob to a different class so it won't return null?

Create a custom mob manager which maps spawned spigot mobs to your custom mob classes.
Something like a

public class CustomMobManager {
  private final Map<Entity, CustomMob> spawnedCustomMobs = new HashMap<>();

  public void handleInteraction(Entity entity, Player player) {
    CustomMob customMob = spawnedCustomMobs.get(entity);
    if(customMob == null) {
      return;
    }
    customMob.interact(player);
  }

  ...

  public void handleDeath(Entity entity) {
    CustomMob customMob = spawnedCustomMobs.remove(entity);
  }
}

Then you create one instance of this manager in your onEnable and pass it
to your listener and command classes.

upbeat fog
#

so even if there's one mob at a time you'd still recommend using this?

lost matrix
#

What if you decide to use this system to spawn little minion mobs for your boss?
You wouldnt want to rewrite your code for that.

upbeat fog
#

Hmm yeah, that's a good point. Does a projectile also counts as entity?

onyx fjord
#

yes

lost matrix
#

But i wouldnt classify it as a custom mob

#

I would probably create a dedicated custom projectile manager for that 😄

upbeat fog
#

Cool, I'll try this method.

shell robin
#

Can you recommend a udemy course for spigotapi?

chrome beacon
#

Take a course in Java first

remote swallow
#

i doubt a udemy course exists, learn java first and learning spigot will take a few days

lost matrix
remote swallow
#

idk

river oracle
#

I wonder if it's any good though

#

I'd never pay to find out

true perch
tender shard
#

I still don't get why a List<?> is not considered to be a List<Object>

slender elbow
#

cuz variance

tender shard
#

variance?

slender elbow
#

covariance and contravariance

#

my people are calling me

tender shard
#

if I can loop over it like that, then why can't I declare it to be a list<Object>

#

oh yeah I couldn't add anything to the list

#

makes sense now

slender elbow
#

because that's the upper bound, but you don't know the exact type the list is holding

lost matrix
slender elbow
#

which is why you can't add elements to the list (except for null :^) ), because you don't know what exactly it's holding, you just know you can get {upper bound type}s out of it

lost matrix
#

i find contravariance to be handled very weirdly in java to be honest...

true perch
#

Anyone know how to change the glow color?

near mason
#

is potion effects better usage of api?

lost matrix
near mason
#

why

true perch
lost matrix
# near mason why

Because it does refers to an entity property and not the glowing effect

near mason
#

ye but it does make it glow

muted dirge
#

i have a problem when trying to get a declared field using reflection

#
Field dimensionsField = Entity.class.getDeclaredField("dimensions");
#

but this field exists

lost matrix
#

Is this the obfuscated name? Are you using mojang mappings?

muted dirge
#

deobfuscated mapping

remote swallow
#

you still have to use obsfucated probably

#

doubt paperweight remaps that

slender elbow
#

it doesn't

muted dirge
lost matrix
#

Then the runtime name might as well be something completely different.
Like "k"

muted dirge
#

my problem is i get NoSuchFieldException

lost matrix
#

Remapping reflections would be wild

muted dirge
#

but i know this field exists

remote swallow
#

use the obsfucated name

slender elbow
#

but it isn't called that

muted dirge
muted dirge
#

I'm gonna set entity AI by CompoundTag

#

this will work?

remote swallow
#

no clue

#

?tas

undone axleBOT
muted dirge
lost matrix
muted dirge
lost matrix
#

setAI(false)

lilac dagger
muted dirge
near mason
#

xD

muted dirge
#

i didn't know it

near mason
#

i think you should check the javadocs before using reflection

muted dirge
lilac dagger
#

but stilll you can just wipe away all the dev's work by setting the list to raw

#

and it'll work

muted dirge
#

omg im dumb

near mason
#

you can do ctrl f and search the method

muted dirge
remote swallow
#

or just use the brower and search for Entity.setAI

lost matrix
near mason
#

no they cant

#

i searched for that a lot back then

#

but except april fools snapshot

#

i dont know if spigot api has that

true perch
remote swallow
#

Glowing probably

true perch
#

Don't see any with glowing

muted dirge
near mason
#

glowing doesnt exist

muted dirge
#
EntityDimensions entityDimensions = (EntityDimensions) dimensionsField.get(nmsEntity);
EntityDimensions scaledDimensions = new EntityDimensions(entityDimensions.width * s, entityDimensions.height * s, entityDimensions.fixed);
lost matrix
muted dirge
#

I'm trying to do it

#

idk

lost matrix
near mason
#

i still dont get why not just Entity.setGlowing 😐

lost matrix
#

Because tinkering with the color requires teams

lost matrix
remote swallow
#

yea

near mason
#

btw

#

whhen you change the hitbox of entity with nms

#

does it change in client-side?

muted dirge
near mason
#

like can you see the change with f3+b?

muted dirge
#

can you send the method for me?

near mason
#

i dont remember it

#

hold on im searching it

muted dirge
#

thank you

true perch
#

How do you apply a potion effect to an Entity? I know you can do it to a LivingEntity, however I don't see any methods that allow this for an Entity.

near mason
#

oh there isnt a way

#

😐

echo basalt
#

Just do an instanceof check

near mason
#

there is this

true perch
echo basalt
#

glow colors are uhh

#

just scoreboard teams

near mason
#

but you can set the collision box

echo basalt
#

Entity glowing (contrary to what 7smile7 says) is ideally done with Entity#setGlowing, as it sets the field in the entity metadata packet instead of just using the potion effect which is gimmicky

true perch
#

Okay so

  • Make a team for every color I want items to glow
  • Upon receiving a drop of a certain glow color, assign the player to that team
#

correct?

echo basalt
#

Something like that

#

there are weird issues if you're using the TAB plugin but you can deal with those later

true perch
#

Unfortunately that means that all glowing drops will appear as the same color

echo basalt
#

Uhh no

#

You assign the entity to the team

#

Not the player

true perch
sage patio
#

EventPriority.LOWEST means it runs first or last?

tender shard
#

first

sage patio
#

thanks

tender shard
#

LOWEST, ..., HIGHEST, MONITOR

remote swallow
#

if you do event logic on monitor i will send chocos huskies and mds kangaroos after you

#

all active developers here will also raid your house

sage patio
#

i've 2 custom plugins

#

one which it is my custom armor plugin

remote swallow
#

high and highest

sage patio
#

and another one is a Revive system

true perch
sage patio
#

in both of them i'm checking for EntityDamageEvent
in revive: when damage is more than hp --> kill player
in armor: when damage is more than hp --> break armor else getArmor - damage

true perch
echo basalt
sage patio
remote swallow
#

if armor should take priority, have that on highest, then revive on high

sage patio
#

thats the problem, i don't know which one it should
when some one takes a damage way more higher than his hp, he does not gets knocked by my medic plugin and dies

distant wave
#

any idea how can i store multiple strings and integers like a hashmap in pdc?

remote swallow
#

more pdc or serialize to byte array manually

remote swallow
sage patio
#

he gets knocked, and dies after it immediately

remote swallow
#

id say players would notice if their armor is meant to block 50% of damage but get 1 shot by a 25 damage item

sage patio
#

i remove the remaining damage from player if his armor is not enough

remote swallow
#

@echo basalt whats the proper sollution for this

echo basalt
#

explain

#

I can't bother reading

remote swallow
#

2 plugins need to use entity damage event but they contradict eachother in what takes priority

echo basalt
#

uhh

#

Do you have control over both of them

remote swallow
#

@sage patio

sage patio
#

both of them are mine

echo basalt
#

yeah ok so

#

Think of what the intended goal is

sage patio
#

wanna the event codes?

echo basalt
#

and do it

sage patio
#

uh

#

what

#

the goal is if the player takes a high damage, whatever it is, get knocked instead of getting knocked and die
i don't know which one should take priority to prevent this

eternal valve
#

How can I add economyshopgui premium nbt? /// nbt_int: CustomModelData:1036 did not work even though I typed

remote swallow
#

are you using a beta version

echo basalt
#

Well

#

Are you cancelling the event when knocking the player

sage patio
#

it seems no, lemme test

eternal valve
remote swallow
#

might need to add it from nbt data

sage patio
muted dirge
#

@sage patio mano yadet miad?

sage patio
sage patio
muted dirge
mint plover
sage patio
muted dirge
sage patio
#

nice

#

gl

tall dragon
#

is there a way to get a tileentity from a block without reflection?

#

cant seem to find one

near mason
#

what are you trying to do?

tall dragon
#

tryna get an instance of TileEntityHopper

muted dirge
#

I failed

tall dragon
#

i did manage to do that but with reflection

muted dirge
#

somehow the entity's change scale is working but you cant see it

amber stump
#

How do I get the inventory of a chest?

muted dirge
lost matrix
amber stump
near mason
#

if ur trying to get the inventory

lost matrix
tall dragon
#

im not

#

im trying to speedup individual hoppers

muted dirge
#

whoa

near mason
#

idk then

tall dragon
#

yea i did it with reflection but was just wondering if there was a way without it

muted dirge
#

😭

#

@lost matrix you was right

#

its impossible

near mason
#

whats impossible?

#

scaling entities?

#

yes it is

smoky oak
#

I'd like to return the same type of set/collection I'm given. There a better way than doing this?

try{Set<Vector> rSet = locations.getClass().getDeclaredConstructor().newInstance();
        } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e){e.printStackTrace();}
smoky oak
#

like, other than clone, is there a way to just... copy... the type of the input set

#

actually clone wouldnt work

lost matrix
#

input of what

smoky oak
#

well I'm passing a Set<location> so that it doesnt only work on 'list of this type'

#

I'd like to return the same kind of set I'm passing in

lost matrix
#
  public <T> List<T> doSomething(List<T> inList) {
    List<T> outList = new ArrayList<>();
    // Do something
    return outList;
  }
smoky oak
#

the input and output types are different though? this wouldnt work

#

I'm doing math on a list of locations, which turns into a list of vectors

lost matrix
#
  public List<Vector> doSomething(List<Location> inList) {
    List<Vector> outList = new ArrayList<>();
    // Do your math
    return outList;
  }
smoky oak
#

thats....

#

a solution

#

not the one i was going for

lost matrix
#

I dont... understand what you are doing

scenic onyx
#

Hi, I've seen many tutorials on the internet but I still don't understand how to make a project that supports multiple versions. Could you help me?

smoky oak
lost matrix
lost matrix
echo basalt
#

That's way too much effort

lost matrix
lost matrix
echo basalt
#

True

lost matrix
echo basalt
#
public interface Transformer<K, V> {

  V transform(K key);

  default List<V> transform(Collection<K> keyCollection) {
    return transform(keyCollection, new ArrayList<>());
  }

  default List<V> transform(Collection<K> keyCollection, List<V> valueCollection) {
    for(K key : keyCollection) {
      valueCollection.add(transform(key));
    }

    return valueCollection;
  }
}

:)

twilit basalt
#

How to change where player has main slot?

echo basalt
#
public List<Vector> transform(List<Location> inputs) {
  Transformer<Location, Vector> transformer = Location::toVector;
  List<Vector> vectors = transformer.transform(inputs);
}
smoky oak
#

ah thats not exactly what i meant

#

like if i say List<Location> in my parameters

#

thats not a list, thats some class implementing it

#

my goal is to return a List / Collection of the same type that's thrown at the method

quiet ice
twilit basalt
#

nvm I have found out

echo basalt
#

:)

lost matrix
echo basalt
#

generic nightmare

#

can you even lambda an abstract class

scenic onyx
#

@tall dragon I have seen what is written, but what is the difference between the module: "core" and the module "spigot-1.9.4"?

near mason
#

thats why i hate BukkitRunnable

remote swallow
tall dragon
remote swallow
#

same thing applies

tall dragon
#

im so confused i have a common module that shades a library, then when my other module shaded the common module it shades that library again. so i end up with the same library twice in different locations

#

why is that happenin

lost matrix
lost matrix
#

^

remote swallow
#

in both places

tall dragon
#

rlly....

#

whyyyyyyyy

remote swallow
#

if you shade it in common, dont shade it in other

scenic onyx
remote swallow
#

yea

tall dragon
#

i dont even have it as dependency

#

but it still shades it

remote swallow
#

anyone know of royalty free svg pages

tall dragon
#

only common has it as dependency

remote swallow
#

transitive depdency then

tall dragon
#

what does that mean

remote swallow
#

another depdency also shades it

near mason
#

why is BukkitRunnable an abstract class

#

and not an interface

tall dragon
lost matrix
#

Because it has fields. It wraps the bukkit task it is creating

tall dragon
#

only common has xseries as dependency

#

or should i not be relocating in common then

#

only in core

shadow night
#

Doesn't BukkitRunnable have like .runTask() and stuff?

near mason
#

ok

twilit basalt
#

Do I have to register event (custom event) in main class?

twilit basalt
#

why is there method to do that then

lost matrix
#

You can register it wherever you like

near mason
#

oh you mean that

scenic onyx
#

Because is Otherwise?? i have do all...

twilit basalt
#

otherwise it should be deprecated and removed

lost matrix
shadow night
#

Bukkit API is amazing

#

Just so simple

lost matrix
twilit basalt
#

yeah I know how to call it

#

just why it is there also method to register events

shadow night
#

Ig to register a listener?

opal carbon
#

yeah

twilit basalt
#

I am talking about registerEvent

#

not about registerEvents

smoky oak
twilit basalt
#

oh nvm

#

I see

#

xDD

opal carbon
twilit basalt
#

yeah

opal carbon
#

javadocs hold the answer

twilit basalt
#

looks little useless to me but okay

lost matrix
#

You should pretty much always use the .registerEvents(Listener, JavaPlugin) method

#

There are certain cases where the other methods make sense

shadow night
#

I remember I recently coded in bukkit for mc b1.7.3 and it had a different implementation of event listeners

remote swallow
#

anyone got tips on how i could change this to not just be blank or have stuff non related

near mason
#

whats that?

smoky oak
#

fuck's a 'not thread safe' list

lost matrix
#

A list thats not thread safe. Most of javas collections are not thread safe.

smoky oak
#

wait is this that 'lock before editing' thing?

remote swallow
lost matrix
# smoky oak wait is this that 'lock before editing' thing?

You can create a lock. Its basically a ticket which lets a thread edit an object.
And only one thread at a time can have a ticket. If the others come and request
a ticket but another thread is currently in possession of this ticket, the other threads
block and wait for the ticked to be released. Then the next thread can come and obtain
this ticket.

#

This is known as a lock or mutex

remote swallow
#

im so confused

near mason
#

I remmeber that there was a thing like Collections.threadSafe(collection)

#

I saw it on johns video

#

About vectors

ivory sleet
#

u prob mean the synchronized wrapper

near mason
#

I dont remember

#

Vectors are thread safe

lost matrix
#

They are?

fervent robin
#

How do you set the ID of an item stack? before you could use #setDurability() but thats deprecated

smoky oak
#

pretty sure they're not

ivory sleet
#

java.util.Vector

#

they mean

#

+java.util.Stack

lost matrix
#

Ah. Those are kind of thread safe. But not really.

ivory sleet
#

they are thread safe

#

but not necessarily atomically safe

lost matrix
#

Well, dont they just have synchronized methods?

smoky oak
#

ah i was looking at the bukkit vectors

ivory sleet
#

i just know they are thread safe

remote swallow
#

web dev confuses me so much

#

like theres a white block that i cant figure out how to change the color of

smoky oak
#

oh now that im looking at the source

#

what's '@serializableas("Vector")' mean?

#

its not turning into one

remote swallow
#

it saves it as !== in config

#

serialize turns it into a map string that set can use

lost matrix
fervent robin
#

do they not do that on 1.20 anymore? I finally switched from 1.8 to 1.20

ivory sleet
#

well

#

yesnt

#

durability still exists

remote swallow
#

this looks better

ivory sleet
#

but like

#

for coloring and other stuff ItemMeta covers that

#

or different material types

#

since magic values bad

lost matrix
near mason
#

Why is reflection the last option?

#

Is it slow

#

Is it dangrrous?

mortal hare
lost matrix
#

Its, slow
I breaks easily
It relies on meta information

mortal hare
#

and its really not portable

fervent robin
mortal hare
#

it makes your code dependant on the names of the fields and methods

lost matrix
mortal hare
near mason
#

Thank you

lost matrix
#

If you are not careful then a single reflection can take upwards of 200ms and ruin your TPS all by itself

near mason
#

oof

#

Yeah but i heard spring boots uses reflection

fervent robin
mortal hare
lost matrix
smoky oak
#

Should i have one class named 'Shapes' procuding geometry for different shapes, or multiple classed each named after the shape the only method it would have would produce? I'm not sure which route to take here

near mason
#

Ok

mortal hare
river oracle
mortal hare
#

iteration 30 chars vs 1 32 bit integer check

river oracle
#

what about constants

ivory sleet
#

and runtime inlined local variables

#

by JIT

mortal hare
#

you should see this

smoky oak
#

i saw it

ivory sleet
#

yes dovidas data oriented programming is ofc a paradigm u have to consider

#

but like

#

readability is just really important

lost matrix
ivory sleet
#

especially when u deal with the amount of state minecraft has

lost matrix
#

Magic values are absolutely evil

ivory sleet
#

I mean sure object orientation sucks anyway

smoky oak
ivory sleet
#

but since minecraft now is object oriented we might as well do it good and not bad

mortal hare
#

i get it why minecraft switched from ids to namespaces, its due to make adding new blocks and states easiers for modders, so that they wouldnt rely on some strange id system like 2500:14:32

ivory sleet
#

not only

mortal hare
#

but still it wasnt really a problem that was very bad

smoky oak
#

hm that gives me an idea

lost matrix
#

Having to remember random numbers is a big problem when programming

mortal hare
mortal hare
#

for you to decide which is faster

smoky oak
#

i'm likely to generate more than one shape at once, so having an interface thats implemented by the classes and has a method named 'generate' or smth

subtle folio
#

namespaces are much needed

mortal hare
near mason
#

Spigot uses reflection to load plugins right?

ivory sleet
#

enums are evil

mortal hare
#

which have ordinal()

mortal hare
ivory sleet
#

yes

#

but it isnt spigots fault entirely

#

mostly bukkit

lost matrix
ivory sleet
#

well I think magic values are bad in general

near mason
#

Whats magic values

mortal hare
#

Magic values in an int type for me is bad, but when you have an Enum to denote those or preprocessor defines i dont see a problem with them

ivory sleet
#

myFunction(1,2,3,4,true,(byte)9,0x1111) etc

#

just pure scalars passed to a function

lost matrix
#

A number in code which has no associated name

near mason
#

Ok

ivory sleet
#

where u have no idea what those scalars will do

ivory sleet
river oracle
#

unsure why magic numbers would ever be a positive. They just create confusion. I always document magic numbers into well named constants

ivory sleet
#

I have had to recode half of my minecrafts recipe system in my mod just because stupid enums