#help-development

1 messages · Page 485 of 1

tender shard
#
depend: [NameTagAPI] # or however it's spelt
stiff knot
#

how do i check exactly how it's spelled?

#

i keep getting errors in console because i dont have the right plugin apparently

tender shard
#

/plugins

stiff knot
#

oh nvm i was messing with the formatting its loading now

#

im still getting the same error though

hazy parrot
#

And you added it in plugin yml

stiff knot
#

yeah

hazy parrot
#

And that namtagedit or whatever is loaded when you do /plugins

stiff knot
#

ya

#

this is just causing errors for some reason

hazy parrot
#

It's probably because it was not able to find plugin

eternal oxide
#

You are probably shading the plugin into yours

#

?paste your pom

undone axleBOT
stiff knot
eternal oxide
#

yep add a provided scope

stiff knot
#

i do not know what that is

eternal oxide
#

<scope>provided</scope>

#

add to the nametagedit in your pom, the same as you have on spigot-api

stiff knot
#

alright

#

oh it works now

#

thanks ❤️

tender shard
river oracle
#

does gradle support nested multi module projects yet

remote swallow
#

maybe?

tender shard
#

it would be very disappointing and surprising if it would NOT support that

vivid skiff
#

What is CraftPlayer#getHandle().b.a.k in the remapped mojang nms version?

eternal oxide
#

It should. It's mainly down to teh IDE if it supports nested

river oracle
#

ahh ok

tender shard
#

?switchmappings

remote swallow
vivid skiff
tender shard
#

no

remote swallow
#

set it to spigot mappings

tender shard
#

CraftPlayer#getHandle() returns a ServerPlayer

remote swallow
#

intellij has been dying for random reasons recently

#

like multiple times this week its opened and then said "String isnt String" or other classes

#

yeah

tender shard
#

did you also start it through toolbox?

#

uninstall the manually installed version

#

then start the 2023 version

#

but yeah IJ starts to suck more every day

#

I also noticed that

#

e.g. CVS -> Share on Github -> all files are empty on github until you push stuff again

#

it's funny that the files are not completely empty though

remote swallow
#

cvs pharmacy?!?!?

tender shard
#
public class MyClass {
  private String something;
}

then after VCS -> Share on GitHub, on gh it looks like this

public class MyClass { }

like wtf lol

vivid skiff
#

Found it

remote swallow
#

have you had ij start to say a class isnt a class

tender shard
#

do you still ahve it open lol

earnest lark
#

im using a Listiner in my command and when i try to give it my main class for the plugin it says that it is not a enclosing class

somber night
#

im trying to add custom items that get consumed when used, but they get consumed in bulks of 5 instead of 1 by 1, why could that be? code (line 170 is where the onUse is): https://paste.md-5.net/bizezivude.java

remote swallow
#

i would deffo delete the mc dev plugin if someway to create a gradle project with specific build.gradle existed

earnest lark
#

k

#

?paste

undone axleBOT
earnest lark
undone axleBOT
#

The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.

For example, only executing code if the main hand was used:

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
        return; // do not progress past this point  |
    }
    // provide functionality
}
earnest lark
#

yea thats what im doin

hazy parrot
#

Also why creating new anonymous listener every time command is executed

earnest lark
#

Pluggg is my main class

hazy parrot
#

Don't do that

hazy parrot
earnest lark
#

wait i got it

undone axleBOT
earnest lark
#

i thinl

hazy parrot
#

But don't register listeners like that dynamicly

vivid skiff
earnest lark
#

how would you reccomend to do it

hazy parrot
#

And if player is in set, execute logic

earnest lark
#

wait what

#

so like just have a thing of all the players then only they get through the Event

hazy parrot
#

What

dawn spire
#

What's a good way of storing worlds/groups of chunks to be persisted for skyblock-type worlds?

hazy parrot
#

Not add new one every time command is executed

#

As it can be really slow

earnest lark
#

yea i can understand that

#

but i want there to be a specified y lkevel that will teleport the player

#

and i dont know how else to do that

remote swallow
#

anyone know of an ij plugin that lets you create a gradle project with customiazble params? or just something that allows me to create a gradle project with a custom build.gradle

tender shard
echo basalt
#

schematics or .slime

#

you basically want something like my Cosmos project (WIP)

remote swallow
tender shard
#

gradle only has gradle init but that only lets you choose project type (application, etc) and group id etc

eager crater
#

Who can help me to
Rank :
Default
User :
User
Money :
Money

eager crater
#

Like at the rigth

remote swallow
#

a scoreborad

eager crater
#

Like

remote swallow
#

thats called a scoreboard, find a plugin online or lookup how to make scoreboard

echo basalt
#

ayy clout

eager crater
#

I have do

tender shard
eager crater
#

I use SimpleScore

remote swallow
#

wrong channel

somber night
#

how would i do that, i tried something and didnt work

weak meteor
#

Helpoooo

Code: ```java
@EventHandler
public void PlayerScoreboardEvent(PlayerJoinEvent event){
ScoreHelper helper = ScoreHelper.createScore(event.getPlayer());
YamlConfiguration config = new Scoreboard().getConfig();
ReplacePH placeholder = new ReplacePH();
if (event.getPlayer().hasPermission("naohcf.scoreboard.staff")){
String title = config.getString("staffScoreboardTitle");
title = PlaceholderAPI.setPlaceholders(event.getPlayer(), title); // 64
title = placeholder.replaceAllPlaceholders(title, event.getPlayer().getUniqueId(), event.getPlayer().toString());
title = ChatColor.translateAlternateColorCodes('&', title);

        helper.setTitle(title);
        List<String>slots = PlaceholderAPI.setPlaceholders(event.getPlayer(), config.getStringList("staffScoreboard"));
        for (int i = 0; i < slots.size(); i++){
            String slot = slots.get(i);
            slot = placeholder.replaceAllPlaceholders(slot, event.getPlayer().getUniqueId(), event.getPlayer().toString());
            slots.set(i, slot);
        }
        helper.setSlotsFromList(slots);
    } else {
        String title = config.getString("scoreboardTitle");
        title = PlaceholderAPI.setPlaceholders(event.getPlayer(), title);
        title = placeholder.replaceAllPlaceholders(title, event.getPlayer().getUniqueId(), event.getPlayer().toString());
        title = ChatColor.translateAlternateColorCodes('&', title);
        helper.setTitle(title);

        List<String>slots = PlaceholderAPI.setPlaceholders(event.getPlayer(), config.getStringList("scoreboard"));
        for (int i = 0; i < slots.size(); i++){
            String slot = slots.get(i);
            slot = placeholder.replaceAllPlaceholders(slot, event.getPlayer().getUniqueId(), event.getPlayer().toString());
            slots.set(i, slot);
        }
        helper.setSlotsFromList(slots);
    }

}```

Config: ```yml

Default scoreboard

no permission needed

scoreboardTitle: "&b&lNaoHCF &7(Map I)"
scoreboard:

  • "&7- &b&lKills: &7%kills%"
  • "&7- &b&lDeaths: &7%deaths%"
  • ""
  • "&7- &b&lHome: &7%home%"
  • "&7- &b&lFocus: &7%focus%"
  • ""
  • "&7dsc.gg/voidciroo"

Staff scoreboard

Use naohcf.scoreboard.staff permission.

staffScoreboardTitle: "&b&lNaoHCF &7(Map I)"
staffScoreboard:

  • "&7TPS: &b%tps%"
  • "&7Vanish: %vanish%"
  • "&7Gamemode: %gamemode%"
  • "&7Players: %players%"
  • ""
  • "&7dsc.gg/voidciroo"
#

There's no Placeholder in the title btw...

#

Maybe its that?

tender shard
#

what's onJoinEvent line 64?

weak meteor
#

title = PlaceholderAPI.setPlaceholders(event.getPlayer(), title); // 64

tender shard
#

title is null

weak meteor
#

scoreboardTitle: "&b&lNaoHCF &7(Map I)"

#

it isnt

#

String title = config.getString("scoreboardTitle");

tender shard
#

print out the value of title

weak meteor
#

k

small timber
#

how can I listen to an anvil breaking? (running out of uses, not broken by a player)

weak meteor
#

never appears

#

maybe it is null

tender shard
#

so what was the value of "title" when you printed it out?

weak meteor
#

null

tender shard
#

there you go

weak meteor
#

but what can i do then

tender shard
#

erm

hollow birch
#

Im still working on my block breaking thing and ive got here so far

            Pickaxe pickaxe = Utils.getPickaxeFromItemStack(player.getInventory().getItemInMainHand());
            Ore ore = main.getMiningEvent().getOreLocations().get(e.getBlock().getLocation());

            long speed = (long) pickaxe.getMiningSpeed() * ore.getHardness();
            @Override
            public void run() {
                e.getPlayer().sendMessage(String.valueOf(speed));
                if (!blockProgress.containsKey(e.getBlock())) {
                    blockProgress.put(e.getBlock(), 0L);
                }
                blockProgress.replace(e.getBlock(), blockProgress.get(e.getBlock()) + (speed / 10));
                player.sendBlockDamage(e.getBlock().getLocation(), blockProgress.get(e.getBlock()) / 10f);


                if (blockProgress.get(e.getBlock()) < 0L || blockProgress.get(e.getBlock()) >= 9) {
                    Bukkit.getPluginManager().callEvent(new BlockBreakEvent(e.getBlock(), player));
                    blockProgress.remove(e.getBlock());
                    this.cancel();
                }
            }
        }.runTaskTimer(main, 0L, 1L);```

I dont know why it only works when speed is 10 and not when its 5
small timber
#

that isn't a thing

#

entitychangeblockevent?

mortal hare
#

what a great addon

tender shard
mortal hare
#

HighlightBracketPair for Intellij highlights brackets of the selected scope

#

so you can tell easily if your code is within the scope you're looking to have

weak meteor
hazy parrot
#

Doesn't intellij do that by default?

mortal hare
#

Sublime had something like this

weak meteor
#

now it prints out

mortal hare
weak meteor
#

but:

mortal hare
#

with this you can click anywhere in the scope block

#

and it will highlight

weak meteor
#

now the error is mine

#

k

mortal hare
#

the brackets

hazy parrot
mortal hare
#

it even works for function arguments

#

and array init lists too

tender shard
tender shard
weak meteor
#

nah

weak meteor
#

just fixed

#

it was a replace thing i removed from config

#

lol

tender shard
#

I checked the NMS source code

weak meteor
#

Now

#

the join event

#

doesnt give a error

#

but now i dont see scoreboard

#

im using this resource

#

and im creating the scoreboard

small timber
#

if there's one thing im not in the mood for it's packets

weak meteor
#

nvm

#

it worked

tender shard
mortal hare
tender shard
#

although ofc it might also be that a player has broke the anvil in the same tick as someone used it

#

but I guess that's pretty rare. and to prevent that you could also listn to BlockBraekEvent

mortal hare
#

well it kinda does work on clion but not exactly like on intellij i showed in this picture

earnest lark
#

im using Bukkit.getScheduler().runTaskTimer but i cant seem to throw the main class for the first paramater

remote swallow
#

you have to pass an instance

earnest lark
#

how bc i am stumped

remote swallow
#

?learnjava

undone axleBOT
earnest lark
#

i have passed the instance and it just issnt working

remote swallow
#

so give the code

earnest lark
#

oh forgot new

#

my b

remote swallow
#

you will get an error if you do new MainClassName()

earnest lark
#

ive been struggling on this for like an hour now

#

im not

hazy parrot
#

Pass the instance, not create new one

orchid trout
#

i love 2:30 am coding

hollow birch
#

i woke up from 2:30 am coding this morning and had no clue what i was looking at

orchid trout
#

i like going to bed and instantly falling into a dream

hollow birch
orchid trout
#

print the block progress

hollow birch
#

counts up 0-9 for regular

#

stays at 0 for enchanted one

wise mesa
#

in acf how do I specify a player name as an argument

#

right now I have this

#

but when I run it the invitee is just the player who ran the command

tender shard
#

use String, and then @Completion("@players") or sth like that

wise mesa
#

ah

#

so are there certain types that can be passed in as an argument

#

or is it all only strings

tender shard
#

well String, int, etc ofc works. If you want to directly get actual class instances passed, you have to setup erm

#

whats it called again

remote swallow
#

you can pass most things, if its a custom class you have to setup a context handler iirc

tender shard
#

it's called a COmmand Context

remote swallow
#

close enough

tender shard
#

Player should definitely work btw

remote swallow
#

it is a context handler

tender shard
#
public void onCommand(Player sender, @Flag("other") Player target)
wise mesa
#

ah thank you

tender shard
#

Or just use OnlinePlayer

#

Player sender, OnlinePlayer theOtherPlayer

#

Easiest way ^

#

@wise mesa just use OnlinePlayer

wise mesa
#

thanks

hollow birch
hollow birch
#

5

#

but the 10 isnt set to f either

#

its good practice to set them as floats but that wouldnt be the difference in one working vs another

hollow birch
#

ok so i kinda fixed it

#

only thing now is im using .runTaskTimer(main, 0L, Math.round(100f / speed));

#

that to calculate speed

#

and it looks really weird

hollow birch
#

it doesnt show the damage always

#

only when it updates

hollow birch
#

fixed it by sending the packet instead of sendBlockDamage(

weak meteor
#

Im developing a mini staff mode, how tf when you use /staff and disable it continue with the same inventory you had when you activate it?

#

i really dont know how to

hollow birch
#

save the inventory when they activate

#

and when they disable set their inventory to the saved one

buoyant viper
#

theres no way w/o listening to packets see if a player has text displayed in their actionbar right?

#

?jd-s

undone axleBOT
buoyant viper
#

whats the event for when a player sneaks out of whatever theyre riding

quaint mantle
#

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class ping implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender thePlayer, Command mycommand, String s, String[] strings) {
        Player p;
        p = (Player) thePlayer;

        int theplayerping = p.getPing();

        if(thePlayer instanceof Player){

            p.sendMessage(ChatColor.DARK_PURPLE + "Your Ping :" + " " + theplayerping);
            return false;
        }else{
            p.sendMessage(ChatColor.DARK_RED + "[Error] : You cant use this Command !");
        }

        return false;
    }
}
``` Hi , sorry but what is problem of my code , because in the game is not worked ! ?
river oracle
#

O

#

We'd need an error

#

also what is "not working"

#

what do you intend to happen

quaint mantle
quaint mantle
river oracle
#

?paste

undone axleBOT
river oracle
#

I need everything

#

paste it in the link and send the whole error

#

everything

river oracle
buoyant viper
#

what

#

yes it does

river oracle
#

how are you not getting an error in your IDE

#

Caused by: java.lang.NoSuchMethodError: 'int org.bukkit.entity.Player.getPing()'

buoyant viper
#

oh not in his version okay

sullen marlin
#

Compiling against new API running on old server

dark arrow
#

why i get an error here

public class testCommand implements CommandExecutor {
    public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
        if(sender instanceof Player){
            Player player = (Player) sender;
            player.getLocation();
        }
        return true;

    }
``` i remember is was a method
#

it says getLocation is not defined

quaint mantle
river oracle
#

💟 omg its md_5 please give me head pats!!!

river oracle
quaint mantle
river oracle
#

so your API version isn't targeting 1.12.2

quaint mantle
#

i use java 1.12.2 because my java version is 8 xD

river oracle
#

update java

quaint mantle
#

i know but i not have time to update

#

xD

river oracle
#

it doesn't take that long

#

surely you have time to update java if you have time to code a plugin as well

quaint mantle
river oracle
#

if you are too lazy just change your api version in your plugin

#

warning a bit of your code will probably break

#

I reccomend updating however

quaint mantle
#

ok , no problem so in new version is have this ? what version ?

river oracle
#

You should know your own server version...

#

1.12.2 is your server version 1.19.4 is latest

quaint mantle
river oracle
#

No just use 1.19.4

#

There's no reason not to

quaint mantle
#

ok , xD

dark arrow
#

?nms

quaint mantle
#

hello guys i was working lately on an plugin from some reason the gui is always empty and i cant find the reason

#

?paste

undone axleBOT
quaint mantle
#

cloud anyone tell me where i messed up what cloud i do not correctly?

#

"playerData" is the way i accses playerData quickly via hashmap of player , custom object containing all data is nessecary...

dark arrow
#

i get this error
https://paste.md-5.net/vohupufiru.bash
on executing this code
class Scared Zombie

public ScaredZombie(Location location){
        super(EntityType.ZOMBIE , ((CraftWorld) location.getWorld()).getHandle());
        this.setPos(location.getX(),location.getY(),location.getZ());

    }```
class testCommand:
```java
public class testCommand implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if(commandSender instanceof Player){
            Player player = (Player) commandSender;
            ScaredZombie scaredZombie = new ScaredZombie(player.getLocation());
        }

        return true;
    }
}```
i am unable to know what went wrong
#

on chat it just says internal error

quaint mantle
#

hm

#

maybe send full class

#

and not half?

#

the command wont work

#

because u didnt do a constractur

#

between the main class and the testCommand class

#

so a singleton between them would solve the problem

#

as well register the command in plugin.yml , if you want u can either make commands work using asyncchatevent and change first char for example commands on .

dark arrow
#

i did register it

#
public class ScaredZombie extends Zombie {
    public ScaredZombie(Location location){
        super(EntityType.ZOMBIE , ((CraftWorld) location.getWorld()).getHandle());
        this.setPos(location.getX(),location.getY(),location.getZ());

    }

}
``` full class of the zombie
#

i dont think anything is wrong with command as when i changed it to send a message 'hello' it worked

#

there must be smething wrong with my zombie class

rugged gust
#

hey can someone help me i wanna make a riddle plugin thingy so there are 2 command, command A and command B. so, command A is a command which can be run by an admin to enable the riddle and command B is used by players to get the riddle info so how do i make it so only when a admin runs command A then players can run command B

dark arrow
slim wigeon
#

Anyone here, I need help with this event.getCurrentItem() and event.getCursor()?

dark arrow
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

slim wigeon
#

I creating a farming rod like EpicFarming but more realistic that does not multiply items. I try to place/remove a item to/from its inventory, it does not do anything? Most of the time and I think my code is broke

dark arrow
quaint mantle
#

try it like this

slim wigeon
#

Wait, I see what is happening. Its nothing wrong with these 2 functions. Just forget about the gui, its more for player.getTargetBlock(). How do I get the end rod I use for the farming rod thru plants like WHEAT, CARROTS and all that you farm?

quaint mantle
#
public class ScaredZombie extends Zombie {
    public ScaredZombie(Location location){
        super(location.getWorld().spawnEntity(location, EntityType.ZOMBIE));
}
}
#

tell me if it works now

slim wigeon
#

I have this code``` Set<Material> farmSet = new HashSet<Material>(); farmSet.add(Material.AIR);
for( Material material : farmBlocks ) { farmSet.add(material); }

    Player player = (Player) event.getWhoClicked(); Block block = player.getTargetBlock(farmSet,10); FarmLib farmLib = new FarmLib();```
quaint mantle
#

about the api go thru docs

#

?docs

quaint mantle
slim wigeon
#

It does not always detect the end rod (Farming Rod) when my cursor is right on it

quaint mantle
#

is this a new itemstack or something?

slim wigeon
#

...

#

Just look at EpicFarming, you will see what I talking about. I cannot upload images

quaint mantle
#

u use someone else API its not related to this chanel..

slim wigeon
#

Songoda

quaint mantle
#

go contact the creator of EpicFarming its not related to here...

dark arrow
dark arrow
# quaint mantle does it work?

'spawnEntity(org.bukkit.Location, org.bukkit.entity.EntityType)' in 'org.bukkit.RegionAccessor' cannot be applied to '(org.bukkit.Location, net.minecraft.world.entity.EntityType<net.minecraft.world.entity.monster.Zombie>)'

slim wigeon
#

But its using the official API, player.getTargetBlock() is apart of the API. I searched everywhere for hours

quaint mantle
#

u just try to spawn custom mob?

#

thats your goal?

dark arrow
#

yah

quaint mantle
#

make the class abstract to not implement all the not nessacery shit

#

extend it as zombie

#

and make summon method in it

#

and later just call the method

#

later you can make a bit more advanced like modifing things for example depending on int level set hp * lvl..

dark arrow
#

*idea

quaint mantle
#

weird it didnt force to implement all the methods the way you did it before

#

i tried rn and i didnt even let me compile lol without adding 3k lines of that shit

dark arrow
#

hm

#

nms packages always change so much , i tried using my last code but it due to so many changes it does not work

#

now i have to find more way to do the code , idk why do they make things so complicated

rugged gust
quaint mantle
#

mojang 😆

quaint mantle
#

..

#

public field

dark arrow
quaint mantle
#

an check if admin executed change it

rugged gust
#

yeah i got it thanks guys!

quaint mantle
#

and learn java at least... dont try to fly straight forwards those things are simple to do i see you can use your imagenattion

#

there so many ways to do it

#

for something static use yaml config to make it static so restarts wont affect it

#

else if its liike condom used only once per restart then keep it that way using an boolean

dark arrow
#

yah fresh entity

slim wigeon
#

Ok, I looked at the whole source code of EpicFarming. I cannot even find where they use InventoryClickEvent like how they get the end rod. I also joined their server and noticed I not allowed to ping anyone there or send PMs so its only here it seems. While I not trying to make the exect copy of EpicFarming, I like to access the farming rod (End Rod) from any angle. I had to disable access to farming rod while sneaking due to this issue

quaint mantle
#

we wont help you with someone else resource API

slim wigeon
#

I can look at the farming rod (End Rod) and player.getTargetBlock() returns Material.AIR or Material.WATER while the bounding box of the farming rod is shown

quaint mantle
#

imma just ignore u legit x y problem

severe folio
quaint mantle
#

true

#

since it never starts the loop

#

lmao thanks i wasnt able to notice that ;/

#

thanks alot KonijkiNoYami you cant imagine how much time i was staring thru it and not finding a realistic reason why it works like that

slim wigeon
#

So there is no way to get any block in view using spigot?

quaint mantle
#

wdym any block in view

#

there many ways

#

from player cross?

#

you can getDirection and do some math and check if block is air

#

till u hit non air

#

and then return the block

#

while loop

#

and do max distance so wont be infinity loop

spare radish
#

I am now trying to add a custom block. I have created these codes for that purpose.

CustomBlock class

import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.Material;

public class CustomBlock extends Block {
    public CustomBlock() {

        super(BlockBehaviour.Properties.of(Material.STONE).strength(1.5F, 6.0F));

    }
}
#

CustomBlockRegistry class

package ponme.nonameplugin.blocks;

import net.minecraft.core.Holder;
import net.minecraft.core.MappedRegistry;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.Material;
import ponme.nonameplugin.biomes.OriginalBiomeBase;

import java.lang.reflect.Field;

public class CustomBlockRegistry {
    public static Holder<Block> addBlockTest() {

        ResourceKey<Block> newKey = ResourceKey.create(Registries.BLOCK, new ResourceLocation("ponme", "test_block"));

        MappedRegistry<Block> registry = OriginalBiomeBase.getRegistry(Registries.BLOCK);

        Holder<Block> holder = null;
        try {
            Class<?> registryMaterialsClass = Class.forName("net.minecraft.core.RegistryMaterials");
            for (Field field : registryMaterialsClass.getDeclaredFields()) {
                if (field.getType() == boolean.class) {
                    field.setAccessible(true);
                    field.setBoolean(registry, false);
                }
            }

            holder = registry.register(newKey,new CustomBlock(),com.mojang.serialization.Lifecycle.experimental());

            registry.freeze();

        } catch (ClassNotFoundException | IllegalAccessException e) {
            e.printStackTrace();
        }

        return holder;

    }
}
#

I used this CustomBlockRegistry and tried to add it with the onEnable method.
Then I get this error on startup.

java.lang.IllegalStateException: This registry can't create intrusive holders

chrome beacon
#

Why are you trying to register a block

#

The client will have no idea what it is

spare radish
somber night
#

im trying to add custom items that get consumed when used, but they get consumed in bulks of 5 instead of 1 by 1, why could that be? code (line 170 is where the consume code is): https://paste.md-5.net/orulaxojug.java
for whatever reason the item with the namespaced key "kick" only consumes one

wet breach
#

nvm, your math is fine read it wrong, but your issue is actually quite simple

#

you have 5 if statements to check for custom items, if all 5 match, then it will reduce by 5 since all 5 statements reduce by 1

#

so to fix that, add a return statement

somber night
#

where would i add it?

wet breach
#

at the end of the block of code that did something, or re-organize your code in such a way where if it enters one of the if blocks and it doesn't exit out to move to another one

#

so, using if else for example

somber night
#

but it shouldnt move to another one, the namespaced keys are different on each if statement

wet breach
#

well, you have 5 if statements that remove items

#

and you said that items are being reduced in 5's

#

so seems like you need to check your items out then

#

or you didn't account if an item could have all 5

wet breach
#

otherwise we wouldn't need a namespaced key 😉

#

but at least now you know why the problem is happening and can now work on resolving the issue or figuring out why more then one key is being assigned to the item if that isn't what is meant to happen

somber night
#

yeah, thanks

icy beacon
#

evidently, checking instanceof on a generic is not possible. what workaround could i use? or should i abolish the default method overall and let the dev do it?

tardy delta
#

pass in a class

#

or do T extends EntityEvent if it really can only be that

#

or make it a method to implement yes

icy beacon
#

i want to allow EntityEvent and PlayerEvent, because for some reason PlayerEvent doesn't extend EntityEvent

#

probably will just make it a method to implement

tardy delta
#

we learnt about interfaces in college this week

#

i nearly fell asleep 💀

icy beacon
#

bruh what college is that

tardy delta
#

idk learning basic java

#

still got 14/17 on my test 😳

kind hatch
#

I'm finding out the more and more I work on this interchangeable database storage system, the more complicated it gets. Is it normal for monolithic interfaces to have unused methods in some implementations?

tardy delta
#

wondering what i was doing again 😳

grizzled oasis
#

Class: https://sourceb.in/5NbTcSzGE4
Error: java.lang.ClassNotFoundException: javax.activation.UnsupportedDataTypeException

Runner:

BlendCameraAnimation animation = null;
                try {
                    animation = BlendCameraAnimation.parse(new File(AlixAPI.getInstance().getDataFolder(), "test.animation")); //Line where's the error is
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }

                BlendCutscene cutscene = new BlendCutscene(animation, player.getLocation());
                cutscene.play(player);
grizzled oasis
tardy delta
#

why are you throwing a UnsupportedDataTypeException

grizzled oasis
tardy delta
#

line 84 in the code you sent

grizzled oasis
#

but the file that i made im sure is the one who supports it

tardy delta
#

looks like you made it wrongly then

tender shard
#

just use a proper exception, e.g. IllegalArgumentException

grizzled oasis
#

but how can i fix this?

tender shard
#

just use a proper exception, e.g. IllegalArgumentException

grizzled oasis
tender shard
#

then send the full stacktrace, and it'll reveal what the cause is

grizzled oasis
tender shard
#

Where did you send the stacktrace?

compact haven
#

then you can’t forget what you’re doing because it’s verbose :)

tardy delta
#

you dare to challenge me hmm?

compact haven
#

dare

grizzled oasis
tender shard
#

Ok good luck fixing it then

kind hatch
tardy delta
#

me trying to figure out why i cant iterate over 0..2 💀

#

counter is supposed to go -2 -1 0 but it goes -1 0 -1 1 0 💀

icy beacon
#

feeling stupid today, how do I get the type of the generic?

compact haven
#

you can’t throw an UnsupportedDataTypeEzception because javax isn’t included by default in the jar, only at compile time. Same reason why you can’t use Pair and have to make your own

#

@grizzled oasis

icy beacon
compact haven
#

so instead of being lazy and just finding some random exception that’s named like what you want, make your own

icy beacon
#

perhaps i should review my approach and not use a generic

compact haven
#

like I do that myself sometimes, but seriously ? javax?

tardy delta
#

or maybe instanceof RegisterableTrigger<Whatever>?

icy beacon
#

what do you mean?

#

i should probably elaborate

tardy delta
icy beacon
#

i want to see if in this list there's already a RegistrableTrigger with its type matching the type of this new registrable trigger

#

so i don't know the generic type of neither

tardy delta
#

ah you dont

icy beacon
#

yep

#

i'll just not use a generic

tardy delta
#

or you have a class field

icy beacon
#

i don't really have a need for it tbh (generic)

#

not sure why i went with it lol

compact haven
#

you can do plenty of hacky shit

#

kind of ironic that the answers to that SO post have literally nothing to do with the question though

tardy delta
#

damn my program was working but it was just me outputting twice

compact haven
#

what were you evrn coding, and in what

tardy delta
#

printing an array

compact haven
#

Were they JVM opcodes or something else?

tardy delta
#

made smth custom

compact haven
#

ah okay

icy beacon
#

design question: should I return silently or throw an exception?

tardy delta
#

but i thought why not implement the parsing and runtime in java 💀

#

it gotta be c++

compact haven
#

First mistake, but yk who cares

tardy delta
#

my c++ knowledge is shit so thats why

compact haven
#

good design is to throw an exception

icy beacon
#

or maybe even make a RegisterResponse enum

#

would that be better?

compact haven
#

definitely not that, an enum lmao

tender shard
tardy delta
#

streams 🥰

compact haven
#

throw an exception, it’s fine

#

just annoying to catch

icy beacon
icy beacon
compact haven
#

since it’s not checked though I’ll be the first to ignore coding the catch ngl

icy beacon
#

wdym?

compact haven
#

it’s not a checked exception so you don’t need to code the catch, it’s not forced

icy beacon
#

oh like, do you mean that I should put it in the signature

compact haven
#

no definitely don’t

icy beacon
#

not sure what you mean by checked exception haha

compact haven
#

yeah that’s okay just ignore me

icy beacon
#

well you got me curious now

compact haven
#

a checked exception is something that’s in the method signature like: public void ignore() throws IOException. You NEED to use a throw/catch since IOException is a checked exception. IllegalArgumentException is not a checked exception, so you don’t need to write the throw catch, instead if it’s thrown then the program will exit

icy beacon
#

oh I see

#

yeah i got it ty

#

would it be a better practice to use a checked exception in this case?

compact haven
#

I don’t even know that you can

#

can you even put IllegalArgumentException in the throws line

icy beacon
#

i mean you probably can but is it useful

#

one ssec

#

yeah it's possible

compact haven
#

ah okay, yeah just don’t

#

no one enjoys writing try catch in Java

icy beacon
#

true haha

compact haven
#

just realized I’ve been saying throw catch, I’m so fucking tired

#

I’m going sleep

icy beacon
#

though i also wonder why you suggested to not use an enum

#

wouldn't that be easier to handle

#

just a switch

compact haven
#

that’s like returning an Integer where 0 is success and 1 is fail, it’s just not right

icy beacon
#

not sure i'm following, integers are magic values and enums are named

compact haven
#

the proper way to handle this problem is an exception, every API with registration uses exceptions to prevent double registries

#

What I’m saying is that it’s equally silly

icy beacon
#

alrighty, thanks a lot, i'll take your help into account and code my api with it in mind

compact haven
#

take inspiration from other libraries, just not ones predating dinosaurs, when doing that

#

gl

icy beacon
#

ty 🙂

tardy delta
#

hmm ye sql

icy beacon
#

lmao

#

dumb code language detector

#

it's clearly haskell

tardy delta
#

hmm my parser doesnt really want to work

#

trying to read from memory indexed by a register value but its like nah ill give you the register value instead

rough drift
tardy delta
#

i thought it was javascript but it seems to be sql

#

hmm time to really not copy the c preprocessor

#

i somehow want to write this in rust but i dont know much rust 🤔

onyx fjord
#

hey lets say green chunk is the chunk im in, how can i get chunks marked as red?

quiet ice
night verge
#

I'm trying to make the tool in player's hand change its value of "tooldurability" tag whenever the player break a block.
But nothing change eventually.
Take a item having 300 as its "tooldurability" at first for an example.
output test1 is 299
but output test2 is 300
Is there any wrong with my code?

@EventHandler
    public void ToolEffect(BlockBreakEvent event) {
        ItemStack tool = event.getPlayer().getInventory().getItemInMainHand();
        if (tool != null && tool.hasItemMeta() && tool.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(plugin, "tooldurability"), PersistentDataType.INTEGER)) {
            ItemMeta item_meta = tool.getItemMeta();
            int durability = tool.getItemMeta().getPersistentDataContainer().get(new NamespacedKey(plugin, "tooldurability"), PersistentDataType.INTEGER) - 1;
            tool.getItemMeta().getPersistentDataContainer().remove(new NamespacedKey(plugin, "tooldurability"));
            tool.getItemMeta().getPersistentDataContainer().set(new NamespacedKey(plugin, "tooldurability"), PersistentDataType.INTEGER, durability);
            System.out.println(durability + "test1");
            System.out.println(tool.getItemMeta().getPersistentDataContainer().get(new NamespacedKey(plugin, "tooldurability" + "test2"), PersistentDataType.INTEGER));
            tool.setItemMeta(item_meta);
            event.getPlayer().getInventory().setItem(event.getPlayer().getInventory().getHeldItemSlot(), tool);
        }
    }
tardy delta
#

ever heard of variables

tender shard
#

all you do is change a clone of the itemmeta, then you set it back to the original, unchanged meta

#

instead of calling getItemMeta() all the item, use your already stored item_meta

night verge
dark arrow
#

i have created an entity class using nms , how can i spawn it ? by a command or event

echo basalt
quaint mantle
#

Using the prepare smithing event how can i make it so the current recipe yields no result

tardy delta
#

thats what she said

chrome beacon
#

You sure

echo basalt
#

lmao

chrome beacon
#

Why are you throwing out of memory error 💀

echo basalt
#

I wonder if I can make my scripting engine overflow somehow

#

I already handle stack overflows by copying over variables to a temp cache and dumping the stack

tardy delta
#

ofc they hide all the nice utility methods in some jdk.util package

#

not my code btw

echo basalt
#

well

tardy delta
#

no more overflows

echo basalt
#

stackoverflows happened when I had a recursive script play for too long

#

so when I play a script, I copy the variables from this script to the other

#

and dump the stack

#

and then play it

tardy delta
#

lol

tardy delta
#

since when does an arraylist have an empty array by default

#

i dont see any ten

tardy delta
wet breach
zinc lintel
#

i got a problem with my plugin,
If i join i can not take anything out of any inventory while only it needs to be turn off for the bangui

#

This is the code i used for it

chrome beacon
zinc lintel
#

this is how i learned it with kody simpson

#

how i betther do it then?

wet breach
#

compare the inventory objects

zinc lintel
#

how i do that?

wet breach
#

reason for not using the name is because someone could send a packet with the inventory name

#

do you not know what an object is?

zinc lintel
#

im in my learning fase

grave sparrow
#

the way I did it back in like 1.12 was I created a custom invholder and then I could just compare the invholder w that

wet breach
#

now hold a reference to it, maybe in your main class

#

anytime you come across an inventory compare the inventory objects

#

if its not yours they won't match

zinc lintel
#

i don't get it

grave sparrow
wet breach
grave sparrow
#

obv you don’t need a custom class for each gui tho

chrome beacon
#

Storing a reference is fine

wet breach
grave sparrow
#

tomato tomato I guess, if you’re tryna improve performance though there’s no way that’s advantageous

wet breach
#

in what way?

#

I don't see how it wouldn't be optimal other then taking up a few more bytes of memory

#

otherwise it would be fine

grave sparrow
#

well it just doesn’t scale very well at all

wet breach
#

yes it does scale if you use classes to organize your stuff

#

in what way does it not scale?

chrome beacon
#

^

grave sparrow
#

what happens when you’re running like a 400 person server with each of them trying to interact with different inventories

chrome beacon
#

That's 400 things in a list or set

wet breach
#

there shouldn't be 400 copies of your inventory

grave sparrow
#

why wouldnt you try minimise the memory you’re consuming?

chrome beacon
wet breach
#

because memory is cheap first off, and the amount of memory consumed is not as much as you think it is

grave sparrow
wet breach
grave sparrow
#

that’s better, but does vary with the type of inventory

#

what if it’s like a randomised mini game or something

wet breach
#

as I said it isn't going to take up as much memory as you think it would

#

at most with 400 copies of an inventory, you are looking at anywhere between 100-200mb of memory

wet breach
#

probably

#

I was estimating at the extreme 😛

grave sparrow
#

wasted memory nonetheless no?

#

why wouldnt you try engineer it the best you can

wet breach
#

because that is a waste of time

#

if you want the best might as well just drop to asm only

#

nothing else

grave sparrow
#

lmao

chrome beacon
#

Keeping things in a set isn't going to take hundreds of mb

wet breach
#

but then your time for making something exponentially increases. So its a trade off. You shouldn't waste your time on micro-optimizations unless that is all you have left to do and it is needed.

tardy delta
#

lets just do that java stuff in c++ lol

wet breach
#

mmm yes with some opcodes as well

#

just wait till you learn how to utilize extensions

tardy delta
#

kinda sucks that you cant store values in c++ enums

compact lily
#

i want to summon lightning couple block in front of me, how do i do that?

there's ^ ^ ^ symbol in minecraft command whenever i want to summon thing on my eye level, but i dont know how in here

sry bad english 😭

terse ore
young knoll
#

Get the players look vector, normalize it so it has a length of one, then multiple it by how far you want the lightning to be in front

#

You can then add said vector to the players location

tardy delta
#

always fun when creating a new project and you dont know how you're gonna call it

#

so now its "untitled"

shadow night
#

I usually just hit my keyboard so half my projects are "adsfdraadsafes"

somber night
#

ive got this problem i cant fix, my custom items get used 5 times in one tick and i dont know why/how to stop it, if you could help itd be very appreciated
code (line 193 for the "onPlayerInteract" method):https://paste.md-5.net/epacuseged.java

eternal oxide
#

line 50, 117, 136, 155, 172.

frail gale
#

Does someone know how to get a superclass instance from a class?

#

For now I have gotten only the class, but without the instance

hazy parrot
#

With reflection?

frail gale
hazy parrot
#

.newInstance or whatever

frail gale
#

yeah, but I need the instance of the superclass

#

I already have the instance of the base class, but I need the superclass instance

#

if I do that then I just get an empty new instance

#

I need the one from the base class provided

hazy parrot
#

Oh you have base

#

Just call getSuperclass lol

#

And call newInstance on it

frail gale
#

I need to just get one field from the super class

#

which field is declared on the base class

hazy parrot
hazy parrot
#

And call field.get(baseObject)

#

It should work

frail gale
somber night
frail gale
eternal oxide
#

you are registering 5 listeners

#

you have ONE listener, register once

somber night
#

oooh

#

5 listeneres makes 5 items consume

#

im stupid

hazy parrot
frail gale
stiff knot
#

Does anyone have any information on how to create custom configuration files? I ideally want to have a file that saves a list of player warp locations which I can read and write to

frail gale
stiff knot
#

yeah sounds good

hazy parrot
frail gale
# hazy parrot can you show your code

Field[] anvilContainerFields = ReflectiveUtils.getPrivateFields(container.getClass().getSuperclass()); for(Field field : anvilContainerFields) { System.out.println(""); System.out.println("Field: " + field.getName()); System.out.println(ReflectiveUtils.getPrivateField(container, field.getName())); }

hazy parrot
#

dk what is ReflectiveUtils

#
Container obj = ...;
Class<?> superclass = obj.getClass().getSuperclass();
Field field = superclass.getDeclaredField("foo");
field.setAccessable(true);
Object bar = field.get(obj);
#

this should work

frail gale
frail gale
tardy delta
#

varhandles 🥰

frail gale
hazy parrot
#

and that wouldn't really work

frail gale
#

yes you're right I need to do some tweaking a little bit. They work perfectly for normal classes and instances, but not for subclasses

hazy parrot
#

glad it worked 👍

tender shard
#

IJ drunk again

#

(and yes, I know the method calls itself, it's still bullshit to say that it's unused)

eternal oxide
#

not surprised its confused with an infinite loop.

frail gale
wet breach
somber night
#

how can i add explosion power to a fireball?

rare rover
#

Ig I could just remove the contract

somber night
#

oh wow i really am stupid, been looking through that but couldnt find it

#

tyvm

tardy flame
tender shard
#

nah it's passed as parameter

#

it'll be on the stack thousands of times lol

vale veldt
#

how to get an EventPriority from a String in bungeecordApi?

obsidian plinth
#

whos a nerd who can help me rq?

pseudo hazel
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

steady wasp
#

how i can set ItemStack nbt?

inner mauve
#

Im having trouble with external inventories/commands. Im getting these errors, the first is the /ec command(not opening) and the second is a different plugin for a vault plugin(null inventory screen/no gui access)

quaint mantle
ivory sleet
#

or use nms

#

or even better, pdc :)

hasty prawn
#

Hard to really point you to a direct problem without seeing the code

inner mauve
#

where do i see the code for it, ive looked and I have no idea where im looking

hasty prawn
#

./ec command as in the /enderchest command from EssentialsX?

inner mauve
#

yes

hasty prawn
#

You might just have to take that up with them specifically

#

Just make sure your version is right

obsidian plinth
#

ok i really need help lol who can vc with me semi soon.

inner mauve
#

im sorry im dumb, is the other one something that is a spigot

hasty prawn
#

The second one just looks like the name of the inventory is "nul"

inner mauve
#

it also just has me take things out of it, instead of opening a new gui

#

its a player vault plugin

hasty prawn
#

Same thing then, try the plugin author, they'll have a way better idea what's going wrong.

inner mauve
#

alright thank you

#

im horrible at this stuff

steady wasp
#

player.getInventory().setItem(itemSlot, CraftItemStack.asBukkitCopy(net.minecraft.server.v1_7_R4.ItemStack.createStack((NBTTagCompound) MojangsonParser.parse(tag))));
why this not works?

#

item... immediately removes from inventory after changing nbt

tardy delta
#

this is fun

#

not cry when i have more than 16 of them

worldly ingot
#

If I'm not mistaken (and honestly I might be), you can do this

enum OpCode : uint8_t {
    HLT = 0x00,
    MOV,
    ADD,
    SUB,
    MUL,
    DIV,
    INC,
    IN,
    OUT,
    JMP,
    JP, // 0x0A
    JPZ = 0x0A,
    JNE,
    PD
}
tardy delta
#

hmm?

worldly ingot
#

The following constants will just increment

quiet ice
#

Two opcodes have the same value

tardy delta
#

ye

worldly ingot
#

Yeah, that's why I set JPZ to 0x0A

tardy delta
#

ah bruh cant even count in hex

worldly ingot
#

I'm like 40% sure you can do it twice

quiet ice
#

I completely disregarded that autoincrement thing

tardy delta
#

what have i been doing in college

#

kinda intresting approach to go from java to c++

#

cant even store data in an enum here so no idea how ill get a functional interface in there

#

a class ig

worldly ingot
#

You don't, yeah

#

enums are very primitive in C++

quiet ice
#

How do you have two projects opened at the same time in IntelliJ?

worldly ingot
#

What you're doing with an enum in C++ is nothing more than restricting a set of numerical values

worldly ingot
quiet ice
#

Oh my god...

tardy delta
#

ij and clion

worldly ingot
quiet ice
#

Yep I'm out of there.

tardy delta
#

dont ask me why bruh

#

you should've seen alex' taskbar

worldly ingot
#

fwiw I suppose IJ can dedicate more resources to just a single project as opposed to Eclipse's workspace, but even still, I close like most of my projects if I'm not actively working on them

tardy delta
#

saying i wouldve spent all the ram on my old pc already 💀

quiet ice
#

I upgraded to 32 Gb a year ago.
It was much needed - no idea how I survived with 16 Gb

worldly ingot
#

I need an upgrade bad

tardy delta
#

16 gigs uwu

round finch
#

16 weak

tardy delta
#

its a laptop though

#

it already costed enough

round finch
#

oh shet laptop hardware expensive thb

tardy delta
#

and my battery somehow broke

chrome beacon
#

I'm starting to need more ram since everything is chrome in disguise

quiet ice
#

I mainly need ram to counteract the memory leaks present in large minecraft modpacks

tardy delta
#

ye firefox is chrome in disguise

#

idk why i even switched, probably because of the crashes

quiet ice
#

I have no idea how people manage to make java use 20 Gb of RAM even with -Xmx9G in the first place to be entirely honest

#

Though the last few days I've spent on just fixing bugs on a single medium-sized mod and sometimes I question the sanity of mod devs

tardy delta
#

hmm lets just make my enum a struct and put some constants of it in a cpp file

quiet ice
#

You don't you use a function pointer array?

tardy delta
#

chatgpt told me about that, i was using a std::function before

quiet ice
#

So you map each opcode to an index on that array and here you have your "functional interfaces" (completely disregarding that those are not functional interfaces)

tardy delta
#

well it said smth like: have a struct with your data and a function pointer, then have a map to map a hex value to that struct

quiet ice
#

I'd just use a global array

tardy delta
#

actually lets use a simple array

obsidian plinth
#

anyone wanna hop in a vc rq and help me debug something

quiet ice
#

Chances are we don't need to be in VC for that

obsidian plinth
#

100% do

tardy delta
#

debug what

#

say that first

obsidian plinth
#

my turn switching method is broken for armourstands only but it says its working with the debug

#

so it calls the mthod right but doesnt allow the other player to do their move/turn

quiet ice
#

Then just paste the method

#

Also what is "the debug"

obsidian plinth
#

the method works for other moves

#

just not this one

#

all call it the same

#
    public void switchTurns(UUID playerUniqueId, UUID opponentUniqueId) {
        if (playerExtraTurns.getOrDefault(playerUniqueId, 0) > 0) {
            playerExtraTurns.put(playerUniqueId, playerExtraTurns.get(playerUniqueId) - 1);
            Bukkit.getLogger().log(Level.INFO, "Player " + playerUniqueId + " has extra turns. Not switching turns.");
        } else if (playerSkippedTurns.getOrDefault(opponentUniqueId, 0) > 0) {
            playerSkippedTurns.put(opponentUniqueId, playerSkippedTurns.get(opponentUniqueId) - 1);
            Bukkit.getLogger().log(Level.INFO, "Opponent " + opponentUniqueId + " has skipped turns. Not switching turns.");
        } else {
            currentTurn = opponentUniqueId;
            Bukkit.getLogger().log(Level.INFO, "Switched turn from player " + playerUniqueId + " to player " + opponentUniqueId);
        }
        playerUsedFireworks.put(playerUniqueId, 0);
        playerMoves.put(playerUniqueId, null);
        playerMoves.put(opponentUniqueId, null);

        // Inform players about the turn switch
        Player currentPlayer = Bukkit.getPlayer(playerUniqueId);
        Player opponentPlayer = Bukkit.getPlayer(opponentUniqueId);
        if (currentPlayer != null && opponentPlayer != null) {
            currentPlayer.sendMessage(ChatColor.YELLOW + "It's now " + opponentPlayer.getName() + "'s turn.");
            opponentPlayer.sendMessage(ChatColor.GREEN + "It's your turn!");
        }
    }
tardy delta
#

thats a lot of puts bruh

obsidian plinth
#

as i said vc would be 1000% easier

#

this isnt some simple thing

tardy delta
#

nah just clean up your code

obsidian plinth
#

this is clean for what it does

tardy delta
#

have a gameloop which handles everything

obsidian plinth
#

i remove one line and it breaks

obsidian plinth
quiet ice
#

what line is it?

#

that breaks it?

obsidian plinth
#

Ok its either yes i can help or no i can not help

quiet ice
#

I mean I can help but I'd like to avoid vc

#

I've never seen a problem where I had to use vc to be entirely honest

tardy delta
#

german music on the background uwu

#

that would be perfect

obsidian plinth
#

it only breaks for this move

#

it works for the rest

obsidian plinth
#

bc the rest rely on block places not entity place/spawn

quiet ice
#

Chances are some preconditions are not set

quiet ice
#

You are missing return;s in your two if statements

obsidian plinth
#

that block works for every other move

quiet ice
#

actually, it's more complicated than that

obsidian plinth
#

imma just be lazy and make it think its a block im placeing when i place a armor stand.

quiet ice
#

regardless playerExtraTurns and playerSkippedTurns is a bit flawed

obsidian plinth
#

how so?

#
    public void addExtraTurn(UUID playerId) {
        int currentExtraTurns = playerExtraTurns.getOrDefault(playerId, 0);
        playerExtraTurns.put(playerId, currentExtraTurns + 1);
    }

    public void skipTurn(UUID playerId) {
        int currentSkippedTurns = playerSkippedTurns.getOrDefault(playerId, 0);
        playerSkippedTurns.put(playerId, currentSkippedTurns + 1);
    }
#

i mean that also works lol

#

the move that skips the opps next move works

quiet ice
#

if any of the two values are > 0 then the players are still reminded of the turn switch

#

Actually wtf how can this method work in the first place

obsidian plinth
#

Ok i go in i place a cake it goes to my opp i cant place summion drop anything my opp can. and it just works

#

so either u dont know what you are talking about or sum

#

bc it works lol

#

just having a problem with the entity swaping turns

quiet ice
#

The message that is sent always remains the same

#

Unless you swap out playerUniqueId and opponentUniqueId somewhere else

#

but at that point you could just not make use of currentTurn

obsidian plinth
#

ok explain to me how my code works for everything else but u are saying it doesnt?

#

i can go in and play a whole game only use block moves and it works

quiet ice
#

ugh fine.
I'll go to vc and see if you can explain it that way

obsidian plinth
#

Naw u clearly dont know tf ur talking about.

#

"doesnt work at all"

#

i just did the lazy thing and trick it into thinking the Armor stand was a block.

quiet ice
#

I am just talking with the info I know at the very moment

obsidian plinth
#

works the same

quiet ice
#

But if your switchTurns method ends up to be broken you'll remember me

#

No whining on that front

tardy delta
#

hmm smth like this ig

obsidian plinth
quartz gull
#

e

obsidian plinth
#

works fine for blocks.

quiet ice
#

AH I get it

#

but then you are using a very nonstandard form of flow-control

#

And the method name is called misleadingly

#

Should be onSwitchTurns

#

Or full enterprise-style name: informPlayerOnChangedTurnsOnPostSwitchTurns

unborn sigil
#

What?

quiet ice
#

Basically that enterprise-style name signifies three things

  • Players are informed that their turns have changed
  • Only called after turns have changed
  • The method does not act a form of flow-control but rather purely informational
crude cobalt
#

Hi everybody, does anyone know why when I click on a block, the event happens twice
Code:

@EventHandler
    private void PlayerInteractEvent(PlayerInteractEvent playerInteractEvent){
        if(playerInteractEvent.getAction() == Action.RIGHT_CLICK_BLOCK){
            if(Objects.requireNonNull(playerInteractEvent.getClickedBlock()).getBlockData().getMaterial() == Material.CAMPFIRE){
                playerInteractEvent.getPlayer().sendMessage(ChatColor.GREEN + "campfire");
            }
        }
    }
quiet ice
#

?playerInteractEvent

#

smh

remote swallow
#

?interactevent

undone axleBOT
#

The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.

For example, only executing code if the main hand was used:

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
        return; // do not progress past this point  |
    }
    // provide functionality
}
quiet ice
#

really people

remote swallow
#

yeah

#

were too lazy

crude cobalt
#

Thanks

idle iron
#

I am having problems with this code because it runs for the attacker and for the victim, so it runs twice and causes bugs. I tried using the EntityDamageEvent but I couldn't find a way to check if the attacker is a player.

   public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
       if (event.getEntity() instanceof Player) {
           Player victim = (Player) event.getEntity();
           
           startCombat(victim);
           Bukkit.getLogger().info("victim " + victim);

       }
       if (event.getDamager() instanceof Player) {
           Player attacker = (Player) event.getDamager();
           
           startCombat(attacker);
           Bukkit.getLogger().info("attacker "+ attacker);
       }
   }```
junior geyser
tardy delta
#

lol

idle iron
#

Or when I get hit

junior geyser
#

the startCombat fucntuion?

#

Yeah you are running it for the victim , and the attacker in your code

#

so thats twice

idle iron
#

My bad I meant the event happening twice.

#

one time because I hit the entity and one time because the entity got hit, I think I am not sure

junior geyser
unborn sigil
#

Who are you and who invited me here?

worldly ingot
#

¯_(ツ)_/¯

#

You're on SpigotMC. Minecraft server modding

unborn sigil
#

Thanks

#

Who invited me here?

quiet ice
#

You should know

idle iron
quiet ice
#

We do not know

tardy delta
#

does this looks good @quiet ice

quiet ice
worldly ingot
tardy delta
#

lets just say im new to c++

#

that doesnt count as an excuse but whatever

quiet ice
#

To be honest I have 0 experience with C++

#

But I wouldn't even dare to use C++ in any way similar to java

#

Well I'd probably just write plain C code at that point

tardy delta
#

hmm manually memory allocation, fun

quiet ice
#

Just don't use the new keyword

worldly ingot
#

Or if you do, delete it

jagged bobcat
#

Why write c when cpp is extension to c

tardy delta
#

last time i tried to delete a string literal

#

didnt really went that good

jagged bobcat
#
  • cpp compiles to machine code still
quiet ice
#

Basically OOP is not seen as a bonus but rather as a detriment to some. I share that opinion when it comes to working at such a low level

tardy delta
#

classes dont feel low level at all

hazy parrot
#

Why would you use extern in cpp

#

It's basically considered bad pratcice

#

And not object oriented

tardy delta
#

idk im still figuring out stuff

orchid trout
#

when i tried to learn cpp i got bored after 3 days

hazy parrot
#

/shrug I have to learn it for uni

#

Smh commands not working on mobile again

chrome beacon
#

Discord mobile is very buggy atm

sage dragon
#

Player#hideEntity is deprecated, is there a different way?

main barn
#

i think my server has a memory leak, i have used spark to create a heap dump, and looked at it, but i have no clue what could be causing it? can anone help me?

tardy delta
sage dragon
tardy delta
#

wdym deprecated

late sonnet
#

the deprecated are hidePlayer but also i think the hidePlayer now use the hideEntity then its the same..

tardy delta
sage dragon
late sonnet
tardy delta
#

what version u on?

hazy parrot
#

if i would have to guess i would say paper xd

sage dragon
late sonnet
#

oh i remember in what case is deprecated.. in olds build Deprecated was for "you dont need use this" and also "this method is draft-api or experimental then we advise"
in a few PR i make this use Experimental for make the difference

worldly ingot
#

hideEntity() was deprecated as draft API up until recently when we started using @Experimental instead

#

You can either update your API version or suppress the deprecation. That method isn't going anywhere

remote swallow
#

component pr when

late sonnet
worldly ingot
#

I'll see if I can get the motivation to do it in May after my gf goes home

frail gale
#

Does someone know how I can change the holder of the inventory?

sage dragon
worldly ingot
#

No

#

American

remote swallow
#

damn

#

chocos dating an outsider

frail gale
#

bump

quiet ice
frail gale
#

How can I change the holder of an inventory?

quiet ice
#

in normal circumstances you can just open the inventory with the new owner

#

But it depends on what exactly you wish to accomplish

frail gale
#

the inventory is already created

#

so I can't create a new one

#

it's for Anvil

quiet ice
#

Just do player.openInventory(inv) or something

frail gale
#

this is not gonna change the holder

#

I need to change the holder

#

InventoryHolder

remote swallow
#

most likely need to create a new inv with that holder

frail gale
#

But I can't create a new one

remote swallow
#

why not

quiet ice
#

?jd-s it's been ages since I touched that part of spigot though

undone axleBOT
frail gale
# remote swallow why not

because the inventory is created through NMS and then converted to Bukkit with a method which seems to not change the holder

quiet ice
#

Well I guess you can't change the holder

#

You shouldn't need a holder anyways - consider it an implementation detail

frail gale
quaint mantle
#

how can i open a bookpage in my gui and save the contents as a string when they click save thingy

quiet ice
#

I mean the extra logic that would be needed is only like 50 lines of code at the very most

fluid finch
#

Just wondering what is Ass-pressure?

young knoll
#

Lol

#

It tells you

remote swallow
#

what a javadoc

fluid finch
#

The term is still a bit foreign to me

worldly ingot
#

It's an old reference

young knoll
#

Are the examples not clear

remote swallow
#

ass presure

#

thats great

#

who made it

young knoll
#

It’s more so foot pressure

#

But I digress

remote swallow
#

pincher pressure

fluid finch
remote swallow
#

dayum

young knoll
#

Mojang employee says ass

#

Real

#

Caught in 4K exposed cops called

remote swallow
#

huh

#

so grum made the player interact event

remote swallow
#

literally just ass presure

worldly ingot
#

I don't remember what the original reference was. I wanted to say it was Monty Python but I don't think it is

remote swallow
#

contact mojang

#

have you ever spoke to either of the mojang staff from bukkit

worldly ingot
#

The idea though is that your ass is so heavy that it activates the pressure plate

remote swallow
#

our mc characters got a dumpy

worldly ingot
#

I've not spoken to them personally, but Dinnerbone was on the forums at a time

remote swallow
#

fast forward 2 years choco now works for mojang

#

choco if you got hired at mojank woud you revive the built in modding api

fickle mortar
#

import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.NBTBase;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagList;

Hello, can someone tell me why the import won't? I already have the code done and it still won't work

they turn red

young knoll
#

That’s NMS

#

Do you have the right dependency for it

shrewd solstice
#

how can I summon 2 item frame in the same place?

steady wasp
hazy parrot
#

net.minecraft.server