#help-development

1 messages · Page 744 of 1

mortal hare
#

am i the only one who found out the use for the labels in java?

lilac dagger
#

empty or null?

#

because if null, it's already filled with them

mortal hare
#

i never would ever think that i would say that labels sometimes results in more readable and cleaner code

lilac dagger
#

in the i loop add a cells[i] = new Cell[size];

mortal hare
#

i managed to remove 5 lines of useless checks

ocean hollow
mortal hare
#

just by adding label for outer loop

lilac dagger
#

i still haven't found a use for labels

smoky oak
#

arent they null by default

mortal hare
#

Objects are null by default Java doesnt populate objects with garbage values

lilac dagger
mortal hare
#

like in C/C++

lilac dagger
#

otherwise it's null at the first index

young knoll
#

There's also Arrays.fill

lilac dagger
#

or this

#

wait, but can you tell the fill that each i needs a new cell array?

young knoll
#

not sure

mortal hare
#

cool trick i've stolen from stack overflow like one year ago:
if you want an easy one liner to loop backwards from array's size, not index, you can use

while (size --> 0) {}

it looks like a real operation, its readable, one line, no more size-- in the while loop itself, neat

lilac dagger
#

it looks nice

#

is it size--?

#

or am i tripping

smoky oak
#

yea it is

mortal hare
#

yea its technically while (size-- > 0) {} but it looks cleaner when you make it an arrow

smoky oak
#

you just need to grab size in a var beforehand

eternal valve
#

I found a problem with the delux menu inventory hiding plugin, can you help me? The problem is very simple, when someone opens the "shop" gui with deluxemenu, his inventory does not appear, but he takes the items thrown on the ground into his inventory and disappears when he closes the "shop" gui.

Plugin source : https://pastebin.pl/view/e33d116c

#

What I want to do is to hide the inventory when the market opens

hazy parrot
#

i would assume some version missmatch

kindred sentinel
#

how to make player hit entity using plugin?

young knoll
#

Player#attack

kindred sentinel
#

ty

kindred sentinel
smoky oak
kindred sentinel
#

another question... how to change weapon/damage of attacking entity using player#attack

#

hmmm i need something like entity.dealDamage(damage)

mortal hare
#

does command executor run if i dont have permission in the server?

#

or it doesnt execute it at all

#

?

young knoll
kindred sentinel
young knoll
#

Has to be a living entity

kindred sentinel
#

oh

#

ok thanks

kindred sentinel
young knoll
#

Attributes

kindred sentinel
#

oh.. Item.getItemMeta().getAttributeModifiers().get(Attribute.GENERIC_ATTACK_DAMAGE)?

young knoll
#

mhm

#

Unless it doesn't have attributes applied

kindred sentinel
#

ok thanks

young knoll
#

Then you can to use Material#getDefaultAttributes

kindred sentinel
#

it's ok, i need damage even with additional attributes

#

like final damage

spark lynx
#

is there any ways to keep a plugin that extends a NMS class can maintain multi-version compability?
like the constructor of ServerPlayer.class changed in 1.20.2
can i use some method to make it runnable for both 1.20.1 and 1.20.2?

eternal oxide
#

maven modules

#

or reflection

smoky anchor
#

Heyo, I need to know what portals are linked (or will be linked)
I do not mind NMS
I don't even know where I should begin with this

kindred sentinel
#

i still can't figure it out how to get damage of an item using

leftItem.getType().getDefaultAttributeModifiers(EquipmentSlot.HAND).get(Attribute.GENERIC_ATTACK_DAMAGE)

it returns [AttributeModifier{uuid=..., name=Weapon modifier, operation=ADD_NUMBER, amount=5.0, slot=HAND}]

smoky anchor
#

amount=5.0
?

quaint mantle
kindred sentinel
#

yeah but it returns Multimap and i don't know how to get amount from multimap

young knoll
#

getAmount

#

to get the amount

kindred sentinel
young knoll
#

Since it's a multimap get() will return a collection

#

Loop over it

kindred sentinel
#
leftItem.getType().getDefaultAttributeModifiers(EquipmentSlot.HAND).get(Attribute.GENERIC_ATTACK_DAMAGE).forEach(el -> {
damage = el.getAmount()
})
```?
lilac dagger
#

so multimap isn't a multiple key paired value?

#

i never got to use it

worldly ingot
#

One key, multiple values

lilac dagger
#

oh, so the other way around

worldly ingot
#

It's basically a cleaner Map<K, Collection<V>>

lilac dagger
#

that does sound useful

#

i have a few usages of collections as values

#

i'll see if i can simplify them

fallen lily
eternal valve
#
   @EventHandler
   public void onPlayerPickupItem(PlayerPickupItemEvent event) {
       Player player = event.getPlayer();
       if (this.preventItemPickup.containsKey(player.getUniqueId())) {
           event.setCancelled(true);
       }
   }

dont work help

young knoll
#

?notworking

undone axleBOT
#

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

eternal night
#

Wild guess would be this thing is in a Class that is also a CommandExecutor and you create two instances of it

eternal valve
eternal night
#

You are missing an import ?

eternal oxide
#

missing the Map?

eternal valve
#

I can give you the full version if you want.

eternal valve
# eternal night You are missing an import ?
package divan2000.menuaddon;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.inventory.ItemStack;

public class EventListener implements Listener {

   private Map savedInvs = new HashMap();


   @EventHandler
   public void onGuiOpen(InventoryOpenEvent event) {
      if(event.getInventory().getHolder().getClass().getName() == "com.extendedclip.deluxemenus.menu.MenuHolder") {
         Player player = (Player)event.getPlayer();
         this.savedInvs.put(player.getUniqueId(), player.getInventory().getContents());
         player.getInventory().clear();
      }
   }

   @EventHandler
   public void onGuiClose(InventoryCloseEvent event) {
      if(event.getInventory().getHolder().getClass().getName() == "com.extendedclip.deluxemenus.menu.MenuHolder") {
         Player player = (Player)event.getPlayer();
         if(this.savedInvs.containsKey(player.getUniqueId())) {
            player.getInventory().setContents((ItemStack[])this.savedInvs.get(player.getUniqueId()));
            this.savedInvs.remove(player.getUniqueId());
         }

      }
   }

   @EventHandler
   public void onPlayerPickupItem(PlayerPickupItemEvent event) {
       Player player = event.getPlayer();
       if (this.preventItemPickup.containsKey(player.getUniqueId())) {
           event.setCancelled(true);
       }
   }

   public void giveAllInvs() {
      Iterator var1 = this.savedInvs.keySet().iterator();

      while(var1.hasNext()) {
         UUID uuid = (UUID)var1.next();
         Player player = Bukkit.getPlayer(uuid);
         player.getInventory().setContents((ItemStack[])this.savedInvs.get(uuid));
         
      }

   }
}
eternal night
#

I mean

#

you literally don't define a map called preventItemPickup

#

¯_(ツ)_/¯

eternal valve
eternal night
#

this.preventItemPickup

#

you are trying to access a field called preventItemPickup

#

that field does not exist

eternal valve
#

What I want to do is I want to prevent him from picking up the item on the floor.

eternal night
#

okay ?

eternal night
#

the class literally does not have the map you reference

hybrid spoke
#

shouldnt the ide tell you

eternal valve
hybrid spoke
young knoll
#

Eclipse tells you...

eternal oxide
#

My bet you created the Map in your main class and copy/pasted code

smoky oak
#

given that material is no longer an enum, is it still fine to use Material as key in mappings, or should i use the strings representing the materials?

young knoll
#

It's fine to use

smoky oak
#

k

young knoll
#

Also it's still an enum

smoky oak
#

wat

#

i thought that was changed wth

young knoll
#

That PR hasn't been merged yet

#

Also it doesn't even change material anymore, it just deprecates it

ivory sleet
#

for how long is the mat enum gonna be deprecated (along w/ other enums)?

smoky oak
#

at least one major version i recon

young knoll
#

Probably forever

#

MD doesn't intend to remove things unless they become a maintence headache

#

See: Material data

tranquil dome
#

How do I load classes from inside the jar? Currently I've got this (without exception handling), but it throws a ClassNotFoundException on Class#forName(). The class it can't find does exist and the path shown in the exception is the same as the path to my class.

        fun registerListeners(plugin: Main) {
            val packageName = plugin.description.main.substring(0, plugin.description.main.lastIndexOf('.')).replace('.', '/') + "/listeners"
            val jarFile = JarFile(plugin::class.java.protectionDomain.codeSource.location.toURI().path)

            val entries = jarFile.entries()
            while (entries.hasMoreElements()) {
                val entry = entries.nextElement()
                val name = entry.name

                if (name.startsWith(packageName) && name.endsWith(".class")) {
                    val className = name.dropLast(6)

                    val clazz = Class.forName(className, true, plugin::class.java.classLoader)
                    if (Listener::class.java.isAssignableFrom(clazz) && clazz != Listener::class.java) {
                        registerListener(clazz.getDeclaredConstructor().newInstance() as Listener, plugin)
                    }
                }
            }
mortal hare
#

this is kotlin?

tranquil dome
#

It is indeed kotlin

mortal hare
#

usually classes are loaded using classloaders on java, idk on kotlin though

tranquil dome
#

I'm not really sure either but I'm getting the classLoader from the main class that extends JavaPlugin

mortal hare
#

i think i know what's wrong but im not sure

#

you've used / as a path separator

#

Class.forName() expect package path not file path

#

you need dots instead of / probably

smoky oak
#

is there a simpler way than
for(Material m : Material.getEntries) m.toString.equals(key)
to check if the key is a string that would get accepted by valueOf ?

tranquil dome
#

I had tried many other ways, and the first one had me replace all dots with slashes

mortal hare
#

well that's probably because for jarfile retrieval you do need normal file path

#

unless its inside the plugin's .jar file

#

in other words, are included by plugin's classloader

smoky oak
#

i dislike try/catch

pseudo hazel
#

oh does it throw when the string is invalid?

smoky oak
#

yes

mortal hare
#

if you want to load .jar file from outside the plugin's jar file boundaries you need to use URLClassLoader or something custom, but for simple cases (when you want to read something from the plugin's jar file itself), Class.forName() does well

tranquil dome
#

I'm pretty sure I used that in the first place, but the path was invalid because it contained a colon character

#

Because of C:\

smoky oak
#

AH FUC
i just hit F4 on material

tranquil dome
#

But I'm glad it works now

smoky oak
#

someone told me that try/catch is to be avoided when possible

young knoll
#

Don't use valueof then

#

use matchMaterial

mortal hare
smoky oak
#

not here

pseudo hazel
#

its only inevitable if the api made it so

#

but yeah matchmaterial works fine

mortal hare
#

bukkit api is a big nms hack so i wouldnt be surprised if that would be impossible to do, but I guess you've found an optimal solution

unborn dew
#

Question:

If I had a list for allowed-worlds in my Config File and I wanted to allow users to specify * or all as the first item in the list, to allow all worlds by default, is it as easy as doing:

        allowedWorldList = getConfig().getList("allowed-worlds", null);
        if(allowedWorldList.get(0) == "*"){
            allowedWorldList = getServer().getWorlds();
        }

Or am I missing something?

smoky oak
#

you can call contains i think

chrome beacon
#

Kind of inefficient doing it that way but it would probably work if you convert those worlds to their names

unborn dew
#

Ah yeah that I forgot but just more asking if that is the correct way to do it.

smoky oak
#

i mean

#

it would check if the first entry is specifically "*"

#

but contains would check if its anywhere

#

depends on what behaviour u want ig

unborn dew
#

Yeah thats what I was thinking of mostly

#

Cheers for the help 😄

pale pulsar
#

hello can you help me I'm trying to create a cliam plugin for claime in 16x16 but it makes me a fool who can help you?

 RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(World));
org.bukkit.command.CommandException: Unhandled exception executing command 'claim' in plugin ShopCountry v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchCommand(CraftServer.java:987) ~[paper-1.20.1.jar:git-Paper-196]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NullPointerException
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:889) ~[guava-31.1-jre.jar:?]
        at com.sk89q.worldedit.bukkit.WorldEditPlugin.getInstance(WorldEditPlugin.java:501) ~[ShopCounty-1.0-SNAPSHOT-all.jar:?]
        at com.sk89q.worldedit.bukkit.BukkitWorld.<init>(BukkitWorld.java:117) ~[ShopCounty-1.0-SNAPSHOT-all.jar:?]
        at com.sk89q.worldedit.bukkit.BukkitAdapter.adapt(BukkitAdapter.java:123) ~[ShopCounty-1.0-SNAPSHOT-all.jar:?]
        at me.shopcountry.claim.Commandclaim.onCommand(Commandclaim.java:27) ~[ShopCounty-1.0-SNAPSHOT-all.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        ... 23 more
chrome beacon
#

(and worldedit)

pale pulsar
# chrome beacon Make sure to softdepend or depend on WorldGuard

build.gradle


repositories {
    mavenCentral()
    maven { url "https://maven.enginehub.org/repo/" }
    maven {
        name 'Bukkit'
        url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
    }
}

dependencies {
    compileOnly "org.spigotmc:spigot:1.20.1-R0.1-SNAPSHOT"
    compileOnly 'com.sk89q.worldguard:worldguard-core:7.0.0'
    implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.9'
}
pale pulsar
# chrome beacon in your plugin.yml
name: ShopCountry
version: 1.0
main: me.shopcountry.ShopCountry
api-version: 1.19
depend: [WorldGuard]
commands:
  claim:
    description: "claim"
  unclaim:
    description: "unclaim"

chrome beacon
#

Now add WorldEdit to depend

pale pulsar
chrome beacon
#

Yes

pale pulsar
# chrome beacon Yes

console

[17:58:57 ERROR]: [WorldEdit] 
**********************************************
** /!\    SEVERE WARNING    /!\
** 
** A plugin developer has included a portion of 
** WorldEdit into their own plugin, so rather than using
** the version of WorldEdit that you downloaded, you
** will be using a broken mix of old WorldEdit (that came
** with the plugin) and your downloaded version. THIS MAY
** SEVERELY BREAK WORLDEDIT AND ALL OF ITS FEATURES.
**
** This may have happened because the developer is using
** the WorldEdit API and thinks that including
** WorldEdit is necessary. However, it is not!
**
** Here are some files that have been overridden:
** 
** 'World' came from 'ShopCountry (file:/home/container/plugins/ShopCounty-1.0-SNAPSHOT-all.jar)'
** 'EditSession' came from 'ShopCountry (file:/home/container/plugins/ShopCounty-1.0-SNAPSHOT-all.jar)'
** 'CommandManager' came from 'ShopCountry (file:/home/container/plugins/ShopCounty-1.0-SNAPSHOT-all.jar)'
** 'Actor' came from 'ShopCountry (file:/home/container/plugins/ShopCounty-1.0-SNAPSHOT-all.jar)'
**
** Please report this to the plugins' developers.
**********************************************
ivory sleet
#

Might be

ivory sleet
#

Ur redis wrap lib uses a different netty version

kind hatch
ivory sleet
#

Not impossible id presume

pale pulsar
ivory sleet
#

Altho feels like a different error would yield in that case, no?

slender elbow
#

change implementation to compilrOnly in your build script

#

for worldedit artifact

kind hatch
#

or <scope>provided</scope> if using maven

pale pulsar
slender elbow
#

fix my typo

pale pulsar
#

yes

slender elbow
#

yes

pale pulsar
#

thanks is working

valid burrow
#

if i catch the same event in 2 different plugins is there a way to make sure 1 of them catches it first

hazy parrot
#

@fresh templetHandler(priority=...)

#

Sorry for ping ig

valid burrow
#

thx

#

does 1 have a higher priority or 2

#

like what way does it go

#

higher first or lower first

tall dragon
#

its not a number

valid burrow
#

oh

#

what is it then

tall dragon
#

higher = called later

jade oracle
#

how to set ItemMeta in minecraft 1.20?

tall dragon
#

its an enum

young knoll
#

Same way you have done it for years

jade oracle
#

ah thanks

valid burrow
#

if i only set the priority in one of them will the one with priority be called first or the one without

tall dragon
#

depends on the priority you set

#

by default they are on "NORMAL" iirc

valid burrow
#

which ones are there

tall dragon
valid burrow
#

alright thank u

#

and lowest will be called first right?

tall dragon
#

yes

valid burrow
#

thanks a lot

grim ice
#

wait no

#

monitor will be called first. no?

#

@tall dragon

remote swallow
#

No

#

Whats the point of monitoring an event if you dont get final outcome

young knoll
#

lowest is called first

#

monitor is last, and should only be used for monitoring

worldly ingot
#

aka if you change the state of an event under monitor priority, I'll break your kneecaps

#

in game

young knoll
#

Clearly we just need more priorities

valid burrow
worldly ingot
#

Hear me out

#

LOWEST, LOWER, NOT_QUITE_AS_LOW, LOW, BELOW_AVERAGE, NORMAL, ABOVE_AVERAGE, HIGH, NOT_QUITE_AS_HIGH, HIGHER, HIGHEST, and MONITOR

valid burrow
#

should add Bedrock at the start

worldly ingot
#

Right because nothing is lower than bedrock

#

I like your thinking

remote swallow
#

Why is not quite as high after high when its not quite as hide

worldly ingot
#

For the same reason not quite as low is lower than low

#

It's lower than low but not quite as low as lower

#

Make sense?

valid burrow
#

should just make it bedrock, diamond, gold, iron, copper, coal, stone, wood

young knoll
#

We need to add those for monitor too

#

LOWEST_MONITOR, etc

valid burrow
#

but at that point you cant really change anything anymore anyways

#

so what difference is it gonna make

young knoll
#

Gotta make sure your monitor is after the other plugins monitor

slender elbow
#

BigDecimal for priority

eternal valve
#

When the inventory is hidden, the player's armor is also hidden, what should I use?

#

if you look at the foot, the armor set disappears and comes back when you close the market

young knoll
#

what

eternal valve
#

market = shop

#

gui

#

gui open armor hidden problem

young knoll
#

Well yeah

#

It has to hide it so it doesn't show over the gui

eternal valve
young knoll
#

Yes it will

#

Any items in the inventory will

worldly ingot
#

It uses the top inventory plus the player's inventory to show its contents

#

And if this specific GUI doesn't then it likely just does it for all inventories as a precaution

young knoll
#

That one definitely does

#

As you can't see the player inv

worldly ingot
#

Yeah I mean there's no player inventory so

#

:p

eternal oxide
#

utf8 read as txt

grim ice
#

bro

#

is intellij paid now

#

wheres the community version

tall dragon
#

right there

grim ice
#

lmfao

#

u have to scroll down

dry hazel
#

it was always like that

tall dragon
#

its alrdy visible not scrolling? XD

grim ice
#

yeah

#

im just stupid

alpine inlet
grim ice
#

2.8gb for the intellij .exe

#

damn

lethal coral
#

I mean it's an app

grim ice
#

usually apps are 500mb to 3gb

#

but this is an installer

#

not the app lmao

shadow night
#

It probably contains the app then

eternal valve
#

My inventory hiding plugin hides all slots, including armor slots, that is, it takes the background, it takes the armor to the background, so I don't want it to be hidden, I don't want it to be hidden, can you write me syntax or playerArmor ... what should I use?

tall dragon
#

with a custom backbround

alpine inlet
#

I like ur background

river oracle
deep herald
#

does anyone know how to get the first part of the command?

young knoll
#

What do you mean get?

deep herald
#

like in that

#

i want to get the first part of the cmd

#

not the whole thing

young knoll
#

split on space

deep herald
#

so if i do item ids like minecraft:bedrock

#

then it wont trigger

deep herald
#

i dont have an idea of how

zealous osprey
tribal nebula
#

how i install bukkit in replit to create one plugin

torn oyster
#

how do I create an anvil that falls from the sky but doesn't do any damage when it lands?

young knoll
#

FallingBlock has methods to set damage

hazy parrot
tribal nebula
#

To test. But how do I do that?

#

@hazy parrot

deep herald
alpine inlet
#

Hi guys, can someone help me with something?
I want to compile my minecraft mod but it's not working.

This is the output:
17:22:23.382 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] The daemon has finished executing the build.
17:22:23.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
17:22:23.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
17:22:23.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
17:22:23.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Where:
17:22:23.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Initialization script 'C:\Users\alces\AppData\Local\Temp\ijresolvers1.gradle' line: 208
17:22:23.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
17:22:23.381 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
17:22:23.381 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] A problem occurred evaluating initialization script.
17:22:23.381 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > No signature of method: org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.whenReady() is applicable for argument types: (SetupUtpTestResultListenerAction) values: [SetupUtpTestResultListenerAction@da9f2887]
Possible solutions: whenReady(groovy.lang.Closure)
17:22:23.381 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
17:22:23.381 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
17:22:23.381 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
5:22:23 PM: Execution finished ':classes :testClasses --debug'.

deep herald
halcyon hemlock
#

No need to check if starts with /

deep herald
#

oh

halcyon hemlock
#

In my method it gets both command and args

deep herald
#

yeah i just need the cmd

#

thx tho

#

lemme test this rq

halcyon hemlock
#
        String[] split = event.getMessage().split(" "); 
         String command = split[0].substring(1);  // Remove the leading "/" 
         String[] args = Arrays.copyOfRange(split, 1, split.length);
deep herald
#

so itll know if its a cmd?

halcyon hemlock
#

It's a command event

#

Not a chat event

deep herald
#

oh

halcyon hemlock
#

It's only triggered on commands

deep herald
#

mb

grand flint
eternal valve
river oracle
#

Ask here and wait

nocturne coral
#

i'm trying to set up kotlin in my plugin, when i build it using intellij, the kotlin stdlib is inside the main output jar as other .jar files so it doesn't get loaded, what should i do?

#

using maven

eternal valve
# river oracle Don't take help in dms

There is a plugin for Deluxemenu that hides the player's inventory when the deluxemenu guis opens and restores it if the player closes the guis.But there are no updates, I found 2 errors and no other errors:

  1. The armor on the player also hid this undesirable
  2. When a player dies or is killed with the deluxemenu gui open, their inventory does not drop and disappears

Original java file of the plugin :

#
package divan2000.menuaddon;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;

public class EventListener implements Listener {

    private Map<UUID, ItemStack[]> savedInvs = new HashMap<>();

    @EventHandler
    public void onGuiOpen(InventoryOpenEvent event) {
        if (event.getInventory().getHolder().getClass().getName().equals("com.extendedclip.deluxemenus.menu.MenuHolder")) {
            Player player = (Player) event.getPlayer();
            this.savedInvs.put(player.getUniqueId(), player.getInventory().getContents());
            player.getInventory().clear();
        }
    }

    @EventHandler
    public void onGuiClose(InventoryCloseEvent event) {
        if (event.getInventory().getHolder().getClass().getName().equals("com.extendedclip.deluxemenus.menu.MenuHolder")) {
            Player player = (Player) event.getPlayer();
            if (this.savedInvs.containsKey(player.getUniqueId())) {
                player.getInventory().setContents(this.savedInvs.get(player.getUniqueId()));
                this.savedInvs.remove(player.getUniqueId());
            }
        }
    }

    @EventHandler
    public void onPlayerPickupItem(PlayerPickupItemEvent event) {
        Player player = event.getPlayer();
        if (this.savedInvs.containsKey(player.getUniqueId())) {
            // Oyuncunun market açıkken alınan eşyalarını iptal et
            event.setCancelled(true);
        }
    }
}
chrome beacon
#

?paste

undone axleBOT
torn oyster
#

how would i trigger auto gg mods?

sterile token
#

Yeah i know that but the issue is that i cant use the any of my event which extends MenuEvent

young knoll
#

You’d have to look at what the mods trigger on

sterile token
hazy parrot
sterile token
hazy parrot
#

Sure ig

sterile token
#

would be better hehe

#
@FunctionalInterface
public interface MenuAction {

  void run(MenuEvent event);

}
#

Thats how looks my action interface

#

But my "issue" is that i throws syntax error with any of the events extending MenuEvent

hazy parrot
#

Can you snow it

sterile token
#

Yes

#

1m my vm connection went down fkg remote coding

sterile token
#

Im not sure why, because if i check the MenuClickEvent it extends MenuEvent

drowsy helm
#

Is it supposed to be a lambda function

sterile token
#

yeah i know that

drowsy helm
#

Thats a question

#

Is it supposed to be

sterile token
#

oh yeah

#

Yes should be lambda

#

I was told this thing specific are lambda typed arguments

hazy parrot
#

I mean why are you even having it, why not just (event) ->

drowsy helm
#

Why not take a generic consumer

#

Doesnt have to be your own impl

sterile token
#

because i need to create 2 consumers, one for drag and other for click

#

With this, you can use any of them without using different code

#

Just replacing its type of the obj in the lambda

drowsy helm
#

Seems like unnecessary extra steps

sterile token
#

na its good dont worry about, just need to find the issue hehe

#

I remember i made it work but not sure where*

drowsy helm
#

It would make sense if you were casting click event to menu event

#

But you cannot other way around

sterile token
#

what?

drowsy helm
sterile token
hazy parrot
#

How can you be sure that it will be MenuClickEvent but not some other MenuEvent

#

In that lambda

sterile token
#

will add actional logic for checking it

hazy parrot
#

That is why it's throwing

sterile token
#

what?

hazy parrot
sterile token
#

"Typed lambda expressions" are lambda expressions in which the compiler can infer the types of the arguments, meaning you don't need to specify the argument types explicitly. This is possible because the compiler can deduce the type based on the context in which the lambda expression is used.

Here's an example of a "typed lambda expression" in Java:

List<String> names = Arrays.asList("John", "Maria", "Peter", "Sophia");
names.forEach((String name) -> {
    System.out.println("Hello, " + name);
});

In this example, the lambda expression ((String name) -> { ... }) is a "typed lambda expression" because the type of the argument name is automatically inferred as String due to the context in which it's used. It's not necessary to specify String name explicitly; the compiler can deduce it.

Using "typed lambda expressions" simplifies code writing by eliminating the need to explicitly repeat data types when they are obvious.

hazy parrot
#

¿

#

You are uppercasting which isn't safe

#

Compiler is complaining about that

sterile token
#

hee?

#

the events that appear there all subtypes of MenuEvent

#

I just 100 it was working like this before somewhere else

#

Because i have seen it in another library but cant find it. It was where i initially take the idea

hazy parrot
#

Your interface is defined as MenuEvent, not menuclickevent

#

You can't expect it to 100% be MenuClickEvent without instance of check

#

That is what compiler is complaining about

#

You can do (MenuEvent event) -> {
If (event is MenuClickEvent)
}

sterile token
#

yes that how it works, because if i do it as menuclickevent then you are oblise to only using that one

#

🤔

hazy parrot
#

Or just use generic consumer as already suggested

sterile token
#

so a consumer<MenuEvent> ? Is the same im doing with a functional interface 😂

hazy parrot
#

Consumer<MenuClickEvent>

sterile token
#

but that cant vary the event bro

#

I need to have multiple of them

#

let me use the translator this is too much messy

hazy parrot
#

Seems like you are missing inheritance fundamentals tbh

#

You can't be sure MenuEvent will be instance of MenuClickEvent, idk what is not clear here

#

That is what compiler is complaining about

#

You can just make it MenuEvent, and inside of lambda do a cast

sterile token
#

It happens that I need to make a functional interface that accepts any sub object of an Object (MenuClickEvent, MenuDragEvent are sub types of MenuEvent). And I need to do it with a functional interface, this way using the same action you can create it for the click or for the drag.

Do I understand?

hazy parrot
#

You can also make it be generic

sterile token
#

yeah

#

i tried too

#

i find the problem im too dumb haha

#

😡

ivory sleet
#

wtf

sterile token
ivory sleet
#

dont do that lol

sterile token
#

that the fucking issue haha

#

i didnt realize i did a void

ivory sleet
#

but why do u type construct at method level?

sterile token
#

Its for my menu action system

#

My goal is to use the action as a "lambda typed arguments"

ivory sleet
#

ur doing it wrongly tho

sterile token
#

oh could you help ?

ivory sleet
#

well

sterile token
#

I seen in another menu system they did this its was where i taken the idea but cant find it the code

ivory sleet
#

it doesnt make much sense to begin with that u enforce urself to use higher order functions

#

triumph gui prob

#

or if

sterile token
#

na dont start like that i wanna fix my code

#

😬

ivory sleet
#

well idk what ur goal is

#

mind clarifying

sterile token
#

right 1m i will type it

#

with proper english

sterile token
# ivory sleet mind clarifying

I have been researching for a while about menu apis, precisely how to comfortably create the actions to the items.

Re searching I found a very interesting way using lambda typed arguments, where they used a functional interface with a parent object and sub types.

That way at the moment of creating the action, you could use the drag or click. Something like that

MenuItem item = new MenuItem(stack, (SubEvenType event) -> {});

#

I finddd where i taken the example 💪

#

@ivory sleet sorry for tagging

ivory sleet
#

oh so u overload withListener(lambda) with different callback types

sterile token
#

yeah

#

That are called exactly lambda typed arguments atleast in Java

ivory sleet
#

ugh

#

thats one way to call it ig

sterile token
#

oh right

#

i think Goski miss understand what i was trying to do or i explained too bad

ivory sleet
#

prob not

#

Id do it like

@FunctionalInterface interface InventoryClickCallback {
  void onClick(InventoryClickEvent event);
}

void withListener(InventoryClickCallback callback) {

}
#

etc

sterile token
#

hmn but not exactly how i would like

ivory sleet
#

u dont wanna have a <T extends Blah> void onClick(T e);

sterile token
#

rright, so would be MenuEvent instead

ivory sleet
#

ugh

sterile token
#

Like my initial code

#

But the IDE complains that MenuClickEvent is not sub type of MenuEvent

ivory sleet
#

yeah

#

thats fine

sterile token
#

Thats what fucking me up

ivory sleet
#

make MenuClickEvent derive MenuEvent

sterile token
#

yes im 100%

#

I also checked the package everything matches

sterile token
#

java has it weird days lmao

covert silo
#

sorry to bother, but I still need help in my thread, thank you. it would mean a lot

ivory sleet
ivory sleet
#

is gonna cause problems

sterile token
ivory sleet
#

send MenuAction

sterile token
#

current one?

ivory sleet
#

yes

sterile token
#

Also nice yo see you again in the stuff i miss you a lot my friend 🤝

#

This one conclure

#

So far gpt is saying everything should work

ivory sleet
#

yeah you cant assume its always gonna be MenuClickEvent

sterile token
#

right

#

but why?

#

If MenuClickEvent and MenuDragEvent are sub types of MenuEvent

#

🤔

ivory sleet
#

thats the issue

#

(MenuClickEvent event) -> ...

#

only works if void run(MenuClickEvent event);

sterile token
#

Hmnn

#

right i seen it working

#

But im sure this guy of the repo updated the code but no the sample

cursive kite
#

Hello! using #performCommand() and passing /buy throws unknown command, any solutions?

hazy parrot
#

Have you typed it without slash?

cursive kite
#

Yeah I tried just passing "buy"

sick edge
#

How can I change drops of a block if a specific player breaks it? I saw that the BlockDropItemEvent doesnt allow adding new drops

hazy parrot
sick edge
sterile token
cursive kite
#

Yup

#

Well i changed it to use Player's #chat function and chat("/buy") works

#

I dont get why performCommand won't

young knoll
#

Or change the existing items

sick edge
#

BlockDropItemEvent the block is type air for me even though it was a diamon ore ist that normal?

sick edge
potent atlas
#

Hi, I am writing a plugin that uses custom heads that I create, but the heads lose their name and lore when placed

#

I'm using the PlayerProfile interface and I have persistent data types

young knoll
#

Store it in the pdc of the placed head

potent atlas
#

Yeah, I've been trying to do that

#

Would I use the block place event?

young knoll
#

Yes

potent atlas
#

Ok so I'm on the right track. I need to check if the placed head is the same one I created

#

That's where I'm stuck

echo basalt
#

?blockpdc

undone axleBOT
potent atlas
#

alright I will. thanks!

young knoll
#

You don’t need block pdc

echo basalt
#

@tender shard btw if I click on the update checker link it brings me to morepdc

young knoll
#

Heads are tile entities

potent atlas
#

ok

#

what about comparing the url for the texture?

young knoll
#

?

#

Just use pdc to identify them

potent atlas
#

I'll be back in a bit, sorry

#

Idk what to do at this point lol

young knoll
#

I don’t understand your issue

sage dragon
#

Currently trying to find a way to check if a player hit the head of a zombie when using melee attacks.

Any tips that will save me some time?

young knoll
#

Ray trace and see where it hits the bounding box

echo basalt
#

something something dot product

#

is the quicker way

sick edge
#

Does someone know what the PlayerAdvancementCriterionGrantEvent is? Its not in the spigot api and it firest constantly...

kind hatch
#

Sounds like paper api to me.

sick edge
#

Yeah I'll ask on their discord thx

grand flint
#

If I want to fork spigot, do I need to get permission first?

kind hatch
#

No, Spigot is GPL.

grand flint
#

So I can juts decompile the jar and fork it, also redistribute it right?

kind hatch
#

More or less. Just don't redistribute/label your fork as Spigot as that would be a copyright violation.
Also, just download the source off of stash. No need to decompile.

grand flint
#

Okay, thank you very much, of course wouldn't be doing that

grand flint
#

Yeah, I'll release it as Spigot2 instead 👍

sterile token
#

Bro what the fuck doesnt make sense my issue

#

i cant understand why because MenuClick is a sub type of MenuEvent

fading gull
#

Do you need to downcast it?

sterile token
#

they called lambda typed arguments

#

Works for functional interfaces

fading gull
#

I rmb I'd just type event -> ....
Not menuclickevent event ->

sterile token
#

i cant

#

menu event is abstract

#

i have seen thats posible what im doing but now now why now id doesnt work

echo basalt
#

Seems like bad design

#

that could be fixed with generics

echo basalt
sterile token
#

Im still not sure how it worked

potent atlas
#

I'm back. My issue is that I don't know how to get the data out of the placed head

sterile token
potent atlas
#

I'm sorry, I don't know what you mean

remote swallow
#

what data do you want from the head

sterile token
potent atlas
#

yeah that holds the display name and lore, right?

remote swallow
#

placed heads dont save name or lore, only way to get that is if you save it there

echo basalt
potent atlas
#

hmm. I know this is possible because I've seen it done. when I place and break a custom head the display name and lore disappear

sterile token
echo basalt
#

I'm thinking of making a custom tile entity api

sterile token
#

but not undderstand what Saidy wants to do

#

If yoo could be more specific it would better

echo basalt
#

sigh

potent atlas
#

yes I have the display name and lore stored when the head is created in a persistent data container.

echo basalt
#

When you place a skull you're placing a player head tile entity with the data of the skull owner

#

Tile entities do not track what itemstack they originated from

#

So.. the original item is lost to time

#

You need to track the original item in the skull's pdc

#

got it?

potent atlas
#

uh- there will be quite a few of them since they drop from mobs

echo basalt
#

yeah so just make a really simple one that works for all ofthem

potent atlas
#

completely lost. I'm sorry >_<

#

thanks though

#

ok. I think what I need is the value of the placed head.

quaint needle
#

does this code succesfully resets a map while keeping some of it right

#
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public class MinecraftMapReset extends JavaPlugin {

    private static final String WORLD_NAME = "MinecraftMap";
    private static final String BACKUP_WORLD_NAME = "MinecraftMapBackup";
    private static final int RESET_INTERVAL = 5 * 60 * 20; // 5 minutes in ticks

    @Override
    public void onEnable() {
        getLogger().info("MinecraftMapReset is enabled.");
        backupWorld();
        Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> resetWorld(), 0L, RESET_INTERVAL);
    }

    @Override
    public void onDisable() {
        getLogger().info("MinecraftMapReset is disabled.");
    }

    private void backupWorld() {
        World world = Bukkit.getWorld(WORLD_NAME);
        if (world == null) {
            getLogger().warning("World " + WORLD_NAME + " not found.");
            return;
        }

        World backupWorld = Bukkit.getWorld(BACKUP_WORLD_NAME);
        if (backupWorld != null) {
            backupWorld.save();
            Bukkit.unloadWorld(backupWorld, false);
        }

        try {
            File worldFolder = world.getWorldFolder();
            File backupWorldFolder = new File(Bukkit.getWorldContainer(), BACKUP_WORLD_NAME);

            if (backupWorldFolder.exists()) {
                FileUtils.deleteDirectory(backupWorldFolder);
            }

            Files.walkFileTree(Paths.get(worldFolder.getPath()), new SimpleFileVisitor<Path>() {
#

i'm not sure it runs or nah

echo basalt
#

?paste

undone axleBOT
echo basalt
#

half the code isn't even there

#

Keep in mind that world files might be saved on another thread so I'd try deleting after like 5 seconds

#

or operate with a copy while the other one deletes

quaint needle
#

kk

#

ty

weak meteor
#

idk what to do, i wanna make a plugin but now idk what to do

#

even any proyect

#

im out of ideas

quaint mantle
#

I want to make a script in the plugin (skript) in which when I type the command
"""/command <player>"""
it spawns a custom npc mod npc on top of the player's head and stays there until i give the command again,

Plugins used: SQuery, Skript

Version Minecraft :1.7.10

#

help plss

compact haven
#

1.7.10 and you're posting in a channel meant for development with the Spigot API (supposedly in Java)

#

ask in the SkUnity discord, but i doubt you'll get support on such an old version

quaint mantle
#

thank you

wet breach
#

Lol mc 1.7

#

doubt many here even have the api docs for it XD

quaint mantle
#

how do i get a player profile from a string?

sullen marlin
#

example string please

quaint mantle
#

?

sullen marlin
#

what does the string look like

#

and what do you mean player profile

quaint mantle
#

1 sec my ide is loading

#

it is just an argument

sullen marlin
#

to what method

quaint mantle
#

sorry to ask this but, what is a method? today is my first day coding in java so idrk much

river oracle
#

you should probably learn a little more java before using spigot

#

like atleast what methods arguments, constructors etc are

quaint mantle
#

its ok i know enough

river oracle
#

what is a method

quaint mantle
#

not everyone knows that!

river oracle
#

which is exactly why I reccomended sitting down and learning some basis

#

if you want to become semi-profficent in the basics it would take idk 2 weeks maybe if you go hard at it, otherwise just learn some lingo and throw together some basic non spigot projects and then try spigot again

quaint mantle
#

ok but how do i make a string a playerprofile

river oracle
#

no one knows what you're talking about

#

why do you even need a player profile

sullen marlin
#

question doesn't make sense

#

what is the string

quaint mantle
quaint mantle
river oracle
#

the only thing I can think of is
Bukkit#getPlayer(String)#getPlayerProfile()

sullen marlin
#

so the string is a player name?

river oracle
#

?jd-s

undone axleBOT
quaint mantle
#

so basically

quaint mantle
#

say i set the arg to notch, although notch hasnt joined my server, i still can set my playerprofile to notch

#

but idk how to make it notch

sullen marlin
#

?nocode

undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

river oracle
#

you should probably be using Bukkit#createPlayerProfile(UUID) instead of Bukkit#createPlayerProfile(String)

quaint mantle
#
    public boolean onCommand(@NotNull CommandSender sender, org.bukkit.command.@NotNull Command command, @NotNull String label, String[] args) {
        if (sender instanceof Player p){
            Object username = p.getName();

            if(args.length == 0){
                p.sendMessage("§cPlease set a skin to set!");
            }
            else{
                String arg = args[0];
                if (username.equals(arg)){
                    p.getPlayerProfile().getProperties().clear();
                }
                Bukkit.createProfile(arg).complete();
                PlayerProfile profile = p.getPlayerProfile();
                profile.setProperties(Bukkit.createProfile(arg).getProperties());
                p.setPlayerProfile(arg).getPlayerProfile();
                p.sendMessage("§aSuccessfully set skin to" + arg + "!");
            }
        }
        return true;
    }```
sullen marlin
#

there is no such thing as setPlayerProfile

quaint mantle
#

oh

river oracle
#

is that a paper thing?

quaint mantle
#

idk

sullen marlin
#

looks like chatgpt tbh

quaint mantle
#

i mean it isnt showing any errors

#

cap

river oracle
#

// Object username = p.getName();
Why are you setting teh username to an object

#

when getName returns string

#

just because String extends Object doesn't mean you have to use object

sullen marlin
#

probably because chatgpt

quaint mantle
#

no, i made a version in skript-reflect and now im tryna make it with java

sullen marlin
#

none of this code makes sense

river oracle
river oracle
#

there are so many things wrong with this code you could fix within a day or two of learning java basics

quaint mantle
#

ok

river oracle
#

?learnjava

undone axleBOT
river oracle
#

here are some resources

#

https://www.w3schools.com/java/default.asp you can also use w3schools

#

even though It sucks for any level of complexity

quaint mantle
#

that is what i use

#

w3schools

fading gull
quaint mantle
#

i used kody simpsons tutorials and intellij fixes

regal lion
#

Hi

river oracle
quaint mantle
#

how was i supposed to know that

#

i was suggested him

river oracle
#

not your fault just giving a heads up

#

imo the slippery slope with youtube tutorials is moreso not understanding what your writing vs the actual code being written itself

quaint mantle
#

i kinda understand it

#

i can read it well but not really write it well

fading gull
upper hazel
#

hey i can use same events in listener class?

fading gull
#

most likely not necessary, but show some code so its more clear what you're asking

upper hazel
#

It’s not about the code, I’m just changing someone else’s code and I wouldn’t like to interfere with the code written by a person, but to make my own event

river oracle
regal lion
#

How much Java should I learn to code spigot

river oracle
#

I mean just do it properly

river oracle
regal lion
#

Ok

#

Tnx

fading gull
upper hazel
eternal valve
glacial narwhal
#

Hello, do anyone know how to add potion effect to a potion ?

#
public static ItemStack healPotion() {
        ItemStack item = new ItemStack(Material.POTION);
        

        return item;
    }
#

My plugin is in 1.8.8*

vital ridge
#

?paste

undone axleBOT
eternal valve
#

I made an addon to hide inventory using "onguiopen" and "onguiclose", but it also hides the armor on the player, how can I fix it, that is, when "onguiopen" it is saved and deleted in "hashmap", when "onguiclose" the inventory is restored, how can I make it save only inventory slots in "hashmap"?

vital ridge
#

Hey, I'm experiencing a problem, my "savedItems" list for some reason is null when my code reaches end(), which ends the game and gives the player back it's initial inventory before the game had begun
https://paste.md-5.net/tubinirepi.cs

#

I'll do it and lyk if it fixes it

#

Why does it get nulled though?

#

Yeah Im thinking

#

it shouldnt get nulled

#

Im doing it somewhere accidentaly i think

#

I did, the debug messages return the list of itemstacks before the end() method

#

I'm testing it out

#

Now to think about it yeah ur totally right hashmaps would be a lot better

#

Than lists with a map

#

Lists with a pair*

glacial narwhal
#

How can i change the color off a potion ?

vital ridge
#

I'm rn saving itemstack and the slot.

#

Gotchu, thanks.

torn oyster
#

what's the packet to make an entity glow?

#

that's really helpful man especially when the only things that come up for "glow" are particles

#

and how do i do that

halcyon hemlock
#

My favourite minecraft website

glacial narwhal
#

Is it possible to make a potion itemstack splash ? (1.8.8) i am chearching for ages please help

chrome beacon
#

Read the forum posts ._.

glacial narwhal
abstract spindle
#

I want to open iron doors and trap doors with a specif item . My Item check works fine but if I set the door Open it does not open:

public void open(Block block) throws IllegalStateException {
        Openable openable = (Openable) block.getBlockData();
        if (!openable.isOpen()) {
            openable.setOpen(true);
            block.setBlockData(openable);
        } else {
            throw new IllegalStateException("Block is already open");
        }
    }
abstract spindle
#

okay thanks

glacial narwhal
#

How can i apply a potion to a new entity ?

glacial narwhal
tall dragon
#

i dont understand what u mean

regal lion
#

Any free course or yt channel to learn plugin dev

#

??

glacial narwhal
regal lion
#

Is he good

glacial narwhal
tall dragon
glacial narwhal
tall dragon
#

ok so whats the problem

#

you would prolly need to construct an itemstack from it

#

and spawn it as Item

chrome beacon
#

Create a ThrownPotion entity

tall dragon
#

but id just use PotionMeta tbh

chrome beacon
#

Did it exist back then?

tall dragon
#

yes

#

it did

glacial narwhal
tall dragon
#

yea i know...

chrome beacon
#

It's a projectile so you can launch it

tall dragon
#

and you're gonna need to supply ThrownPotion with an itemstack

#

hence PotionMeta

chrome beacon
#

?conventions

chrome beacon
#

Also show us where you get item meta and material

#

yes

tall dragon
#

dear god

#

not even gonna touch this

chrome beacon
young knoll
#

Oh boy

regal lion
#

In all tutorial videos they types something how to know what that thing is

eternal oxide
#

watching?!

young knoll
#

Yeah I don’t quite understand that question

chrome beacon
#

?jd-s

undone axleBOT
regal lion
tacit veldt
#

Why I use this code will give all changes to ScoreBoard for all players

@EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        List<SerializeScore> scoreboardLines = QUEST_SCOREBOARD_MAP.get(player.getUniqueId());
        Scoreboard playerScore = player.getScoreboard();
        clearScoreBoard(playerScore);
        Objective questScore = playerScore.registerNewObjective(SCOREBOARD_NAME, Criteria.DUMMY, "进行中的任务");
        questScore.setDisplaySlot(DisplaySlot.SIDEBAR);
        if (scoreboardLines == null) {
            return;
        }
        for (SerializeScore score : scoreboardLines) {
            questScore.getScore(score.getName()).setScore(score.getValue());
        }
    }
#

I want to change only this one player's scoreboard

young knoll
#

They likley all have the same scoreboard

tacit veldt
#

Is there any good way to copy a scoreboard and put it back in set?

#

I understand if they are all of the same class

silk ore
#
package me.kurtu.main;

import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.enchantment.EnchantItemEvent;

public class main extends JavaPlugin implements Listener{

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onEnchant(EnchantItemEvent event) {
        if (event.getEnchantsToAdd().containsKey(Enchantment.MENDING)) {
            event.setCancelled(true);
        }
    }
}```

I coded a plugin that blocks the repair spell, but it doesn't work. why
regal lion
young knoll
#

by default anyway

supple elk
#

Can anyone help me send a respawn packet with protocl lib?

#

I found this code online, but it's giving an error 'Field index 0 is out of bounds for length 0' for the line writing to the world keys. How can I figure out what I need to write and where?

young knoll
supple elk
slender elbow
#

wiki.vg does not reflect what protocollib sees anyway, you'd need to check the source with the actual packet java fields

supple elk
#

This is what the nms packet takes

#

problem is I have no idea what half of those are

young knoll
#

So it wants a resource key for the world

#

Not the entire world

tribal quarry
#

Isn't it just better to check actual code of NMS to see how it instantiates this packet and provides the parameters that needed?

young knoll
#

probably

supple elk
young knoll
#

That isn't Mojmap

tribal quarry
#

If you stuck somewhere in NMS and there is absolutely no info on internet and wiki then you may have to read the actual code that represents it, I suggest to have always a remapped buildtools folder in your projects, so you can search about stuff there

#

I usually do like: grep -rnw ./buildtools/ -e 'new Packet...'

supple elk
#

right

#

ahh packets are a pain

tribal quarry
tribal quarry
#

Molding Devs mostly rely on reading/modifying codes rather than just asking, because mojang doesn't provide them anything at all

#

And as md5 mentioned, if there is a way to do it in spigot, that would be a better decision, because spigot is made to simplify things

supple elk
#

Yeah I can't do it within spigot

young knoll
#

Then you can open a feature request

#

:p

sick edge
#

IS there a quick way to revoke all advancements of a player (like the revoke everything command)?

scenic onyx
#

?paste

undone axleBOT
supple elk
#

For some reason a player's death location only updates when they receive a respawn packet

#

I need to change a player's death location on the client without killing them

young knoll
#

Why

scenic onyx
supple elk
young knoll
#

I see

supple elk
#

as that is the only compass which works in the nether and overworld

#

well there is also the lodestone compass

#

but that changes the nbt data when you update the direction

young knoll
#

So setLastDeathLocation doesn't update the compass

supple elk
#

meaning it reappears in the hand which looks wack

supple elk
#

I have to do that, and then send send a respawn packet afterwards

young knoll
#

Ah yeah I see it in the docs

supple elk
#

yeah

tribal quarry
#

There is a setcompass method

supple elk
tribal quarry
#

I use it for bedwars

supple elk
#

it does not work in the nether

young knoll
#

And the respawn method doesn't work on players that aren't dead

#

I assume

supple elk
#

I need my compass to be crodirectional

supple elk
#

good question

#

wait there's a respawn method?

young knoll
#

yes

#

In player.spigot()

supple elk
#

hmm, I can test it but I suspect it might cause some bugs

#

I saw this warning somewhere

#

which makes me wonder where in wiki.vg that actually is

#

cause maybe there's more info there

tribal quarry
supple elk
#

So I probably wouldn't want to use player.respawn()

#

and instead send 2 packets

young knoll
#

mmm

tribal quarry
supple elk
#

Right so it wouldn't work anyhow

tribal quarry
#

Or maybe

supple elk
#

I'm just stuck on figuring out how to send this packet is all

tribal quarry
#

Just try to read what's in there:
CraftPlayer->Spigot

scenic onyx
supple elk
#

Yeah

#

they must be dead

tribal quarry
#

Seek for the packet

#

Or

#

Idk

supple elk
#

Ok it's quite long

#

there is this line lmao

#

entityplayer1.c.a(new PacketPlayOutRespawn(worldserver1.aa(), worldserver1.ac(), BiomeManager.a(worldserver1.A()), entityplayer1.e.b(), entityplayer1.e.c(), worldserver1.af(), worldserver1.z(), (byte)i, entityplayer1.gm(), entityplayer1.ar()));

young knoll
#

You should mojmap

tribal quarry
#

Run buildtools with --remapped flag

supple elk
#

So just add --remapped in here?

tribal quarry
supple elk
#

running

#

then how do I actually use that in my ide?

eternal oxide
#

?nms

supple elk
#

ty

#

ok great

#

done that

#

entityplayer1.connection.send(new ClientboundRespawnPacket(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), (byte)i, entityplayer1.getLastDeathLocation(), entityplayer1.getPortalCooldown()));

#

so that's the repammed version of the respawnpacket packet which is sent in the respawn function

#

ok great I think that's given me what I need

#

How do I change the dimension though?

quaint mantle
#

where can i look for collaborators to work on a project ? i would love to make a team since i have a great idea in mind

young knoll
#

?services

#

mayhaps

undone axleBOT
quaint mantle
#

it will be something open source and non paid, does it still count as a service ?

young knoll
#

Sure

quaint mantle
#

thanks ! :)

mortal hare
#

why doesnt gradle support java 21 😭

young knoll
#

Are you on the latest

mortal hare
#

8.4

#

it supports only compiling java 21

#

but not running gradle with it

supple elk
#

oh dear lol

mortal hare
#

and now i need to redownload java 17 once again

supple elk
#

so I've got the respawn packet 'working'

mortal hare
#

hooray

supple elk
#

unfortunately it removes everything in the hotbar

#

and glitches when moving

#

it's like it's teleporting you lol

young knoll
#

oof

#

Did you do it to another world

supple elk
#

no

#

will try that

mortal hare
supple elk
mortal hare
#

on like 1.15

supple elk
#

How do I actually change the dimension here?

supple elk
#

it still seems to think the item is there

#

but I can't see it

#

ah

#

probably cause client doesn't think it's there but server does

mortal hare
#

that's because server resends item packets

#

yea basically

young knoll
#

Is there a way to just send an update death location

#

Or does the protocol not have that

mortal hare
#

why tf does minecraft run on tcp

#

this is such useless transport protocol for a game

#

udp should be used

young knoll
#

bedrock runs on udp

supple elk
#

I think there's just the respawn packet

mortal hare
#

since there's no need for a client to be guaranteed that server sent data is correct

young knoll
#

¯_(ツ)_/¯

#

Go ask 2012 notch

worldly ingot
#

End of the day it doesn't really matter

supple elk
# supple elk

Anyone know how i actually change the dimension here?

mortal hare
#

my precious 2 SYN packets

#

how dare minecraft client to send them

worldly ingot
#

At least lets us do things like bundling packets together if necessary

young knoll
#

Well

#

Only recently :p

sick edge
#

Hi, my problem is i want to deactivate (normal) advancements and atm I'm handling the playeradvanceementdoneevent and revoking the first criteria again directly. This means that the advancement can be achieved again and again but is revoked directly which is why it doesnt show up but it seems unefficient that for example the every time a wood is clicked/picked up it hast to be revoked again and again but I cant seem to find a better way
Thx in advance

drowsy cosmos
#

How do i get the default /help menu style in vanilla?

young knoll
sick edge
pseudo hazel
#

you can turn off advancements from the server config

#

but not easily in your own plugin only

pseudo hazel
#

🤷

sick edge
#

Yeah I mean I think they will as its just client packets but do I have to do it through spigot.yml or can i do it through my plugin?

young knoll
#

You can probably do it with code

brisk estuary
#

Should I use a varchar or a text type in mysql to store an encoded itemstack?

eternal valve
#

when the player dies or is killed, the "armor slot" and "off hand" items that I have separated from the hashmap are dropped, I just want them to be dropped in the hashmap, can you help me? : https://paste.md-5.net/ajemagaxun.cs

young knoll
#

I would store itemstack as byte[]

#

aka blob

brisk estuary
#

Alright, thanks

young knoll
#

You can convert from and to with BukkitObjectOutputStream

brisk estuary
#

Am I correctly storing the blob? XD

@Override
    public <S extends Emblem> Promise<S> save(S entity) {
        return database().executeAsync("INSERT INTO Emblems VALUES (?, ?)", ps -> {
            ps.setInt(1, entity.getId());
            byte[] encodedItemStack = InventorySerialization.encodeItemStack(entity.asItemStack());
            ps.setBlob(2, new ByteArrayInputStream(encodedItemStack));
        }).thenApplyAsync(p -> entity);
    }
young knoll
#

Just store the byte array

sterile token
#

Yeah why is such a Mess working with ítems outside spigot yaml seriliazer?

young knoll
#

?

sterile token
#

Mc code sucks

river oracle
#

Not as bad as mine 😎

sterile token
#

I know You already helpme too much

river oracle
#

Nah busy atm

sterile token
#

It's okay np

young knoll
#

Methods to go to and from bytes for various things could be added tbh

sterile token
#

What are the best way for doing platform independent code. It's mainly abstracting right?

young knoll
#

Only problem is somehow getting the data version in there

weak meteor
#

how do i should work with .schem?

#

like schematics

#

for small islands

young knoll
#

Worldedit api

#

Or you can build your own

weak meteor
#

gradients are only for 1.16+ right?

young knoll
#

yes

weak meteor
#

k

quaint mantle
#

guys

#

does bukkit have an abstraction for events that have an entity that has an inventory

#

ok wait nvm

#

I think PlayerEvent is good enough

ivory sleet
#

You can’t listen to PlayerEvent tho

#

Since it doesn’t have a HandlerList singleton

quaint mantle
#

nah im just making a util method

ivory sleet
#

Alr

quaint mantle
#

so i pass an event theough it

#

but i might just make it so u have to event.getEntity() or /getPlayer

ivory sleet
#

Then you gucci :)

#

Another way is to pass a Supplier<extends Entity> or Function<super Event, extends Entity>

#

Dk what exactly is going on but yeah depends on what exactly ur needs are

sick edge
quaint mantle
#

super Event?

glad prawn
#

🤑

ivory sleet
#

But as said

quaint mantle
#

would it be extend?

ivory sleet
#

If you dont need those lambda types dont use them

quaint mantle
#

oh you dont litterly mean event do u

ivory sleet
#

I do

quaint mantle
#

how

#

isnt Event like the top alrdy

ivory sleet
#

it should be super Event

#

yeah but you can choose PlayerEvent instead if u want

quaint mantle
#

how would I even use the function

#

if it's super event

ivory sleet
#

Oh that part

#

Its because an object of type Function<Object, Player> should be passable

#

if event is an object of type Event
then you should be able to invoke
Function<Object,Player> as much as
Function<Event,Player>

quaint mantle
#

but

#

how

ivory sleet
#

Wdym how

quaint mantle
#

im so confused

#

so like

#

if I were to pass in idk EntityDamageEvent how would that work

ivory sleet
#

Function<Event,Player> assumes you already have an event

#

ofc

quaint mantle
#

why would I use that function

#

btw

ivory sleet
#

Never said you should

quaint mantle
#

here how abt this

#

what would I use that function for

ivory sleet
#

the Function interface?

quaint mantle
#

this

ivory sleet
#

Yeah thats the Function interface

quaint mantle
#

no like

ivory sleet
#

Its used in Optional#map CompletionStage#thenApply
Stream#map
etc

quaint mantle
#

why would I use that function

#

what would it be used for

#

if it was super Event extend Player

ivory sleet
#

I mean anything

#

There are really a lot of things

#

Everything depends on what design you wanna use when you write your infrastructure

sterile token
#

Why 😡 i was told by a dev this must work and have it done too before