#help-development

1 messages · Page 740 of 1

vast ledge
#

So, ive ran into a bit of an issue, im trying to utilise Vaults Economy API, Ive copied the default setup from Vaults APIs github https://pastebin.com/c0FfnpFm,

#

Ive also set the Plugin to print the running services, in which i only get the Metrics and Permission

lost matrix
#

ClientboundPlayerInfoUpdatePacket

lost matrix
#

Yeah looks like rubbish to me. No idea, i dont use external libraries.

quaint mantle
lost matrix
vast ledge
#

Does that not come shipped with the default?

lost matrix
# vast ledge Does that not come shipped with the default?

No Vault is just an empty communication pipeline for plugins. You need a plugin which actually implements the Economy interface.
You could also create your own Economy. Its only a few lines. The biggest part is storing and loading the data.

lost matrix
vast ledge
#

Thanks anyways 😄

lost matrix
quaint mantle
lost matrix
# quaint mantle Perhaps you have a clear example?
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
List<ServerPlayer> players = List.of(this);
ClientboundPlayerInfoUpdatePacket packet = new ClientboundPlayerInfoUpdatePacket(actions, players);
serverPlayer.connection.send(packet);
remote swallow
#

ignore the dumbness of this but is my brain correct in saying to see if its been like 20 min since an instant, i do thatInstant + 20 min is after now instant

lost matrix
#

You mean.... Instant?

remote swallow
#

yeah

lost matrix
#

Yeah an Instant is a point in time. So if you look at it after 20min then it will be 20min in the past.
If you add 20 min then it will be in the present. If you create a new Instant and add 20 min then it will be in the future.

kind hatch
#

@remote swallow For some reason, the advancement registers, but it doesn't display the toast. When I set "announce_to_chat" to true, I get that message, but setting "show_toast" to true results in nothing.

remote swallow
remote swallow
lost matrix
remote swallow
#

yeah

ivory sleet
#

Caffeine perhaps

remote swallow
#

idk if caffiene is worth it here because there isnt really much data being handled

ivory sleet
#

You can opt for guava’s cache

#

Since guava is shipped w spigot

lost matrix
# remote swallow yeah

That could be one approach

if(lastGiven.isBefore(Instant.now().minus(20, ChronoUnit.MINUTES))) {

}

Or you can use Duration for this. Its maybe more clear to read:

Duration duration = Duration.between(lastGiven, Instant.now());
if(duration.compareTo(Duration.ofMinutes(20)) >= 0) {

}
remote swallow
#

i completely forgot about duration

lost matrix
#

The comparator of Duration is maybe a bit weird to read. I often fall back to millis because of that.

remote swallow
#

nothing on its time senitive and shouldnt cause bugs if its late a minute or so

lost matrix
#
    Duration duration = Duration.between(lastGiven, Instant.now());
    long durationMillis = duration.toMillis();
    long twentyMinutesInMillis = Duration.ofMinutes(20).toMillis();
    if(durationMillis >= twentyMinutesInMillis) {

    }
lilac dagger
#

this is definitely better

lost matrix
quaint mantle
lost matrix
zealous scroll
#

How do I transform a block display to rotate around the y axis but pivot the translation at the center of the block?

I currenty have this, but I can't seem to get the right rotation matrix to get the translation to account for the rotation offset

display.setInterpolationDelay(0);
display.setInterpolationDuration(tickInterval);
display.setTransformation(new Transformation(
  translation,
  new AxisAngle4f(angle, 0, 1, 0),
  display.getTransformation().getScale(),
  new AxisAngle4f()
));
quaint mantle
# lost matrix How does a team spawn an NPC?
public class TestCMD implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        Player player = (Player) commandSender;
        GameProfile gameprofile = new GameProfile(UUID.randomUUID(), "test");

        gameprofile.getProperties().put(
                "textures",
                new Property(
                        "textures",
                        "%value%",
                        "%signature%"
                )
        );

        new NPC(player.getLocation(), gameprofile);

        return true;
    }
ivory sleet
#

LuckPerms has a data structure that revokes entries lazily

#

But caffeine can do it eagerly if you ask it to

lost matrix
# ivory sleet No not really

On a Caffeine cache? Im almost certain that entires are only updated on access unless you specify an Executor in the builder.

lofty badge
#

who can how to make ai cover?

lost matrix
ivory sleet
#

Idk if it always (as in by default) update eagerly or lazily, but I know you can configure it to your likings at least (:

remote swallow
lofty badge
ivory sleet
#

Anyway smile the reason iirc they do it eagerly is because of RemovalListeners

#

since those need to be accurately invoked when an entry should be removed

lost matrix
lost matrix
lost matrix
#

But getting a diffusion pipeline going will take quite a bit of learning.

zealous scroll
lofty badge
#

I've already done it, no more needed

lone jacinth
mossy flume
grim hound
#

Is there a way to stop the server from loading certain player's nbt data?

lofty badge
#

guys, who can make for me plugin..? but.. i only have $8

lofty badge
lofty badge
lost matrix
# zealous scroll The translation isn't changed by the rotation though, so even after rotating the...
      Matrix4f transformationMatrix = new Matrix4f();

      transformationMatrix.set(new float[]{
          1f, 0f, 0f, 0f,
          0f, 1f, 0f, 0f,
          0f, 0f, 1f, 0f,
          0f, 0f, 0f, 1f
      });

      transformationMatrix.translate(new Vector3f(0.5f, 0.5f, 0.5f));
      transformationMatrix.rotate(new AxisAngle4f(angle, 0, 1, 0));
      transformationMatrix.translate(new Vector3f(-0.5f, -0.5f, -0.5f));

      display.setTransformationMatrix(transformationMatrix);
      angle += 0.15f;
hushed spindle
#

i came to a rather strange observation

#

splash potions of instant damage do magic damage right

#

thats normal

#

lingering potions of instant damage do entity attack damage

#

lol

lost matrix
#

That is rather odd

echo basalt
#

avg nms moment

zealous scroll
# lost matrix ```java Matrix4f transformationMatrix = new Matrix4f(); transformat...

How would I go about translating the display once again?

        if (pivotRotations) {
            final Vector3f translation = transformation.getTranslation();
            final Vector3f scale = transformation.getScale();
            // Apply rotations
            Quaternionf rotation = new Quaternionf();
            transformation.getLeftRotation().mul(transformation.getRightRotation(), rotation);

            Matrix4f transformationMatrix = new Matrix4f();
            transformationMatrix.translate(scale.x / 2, scale.y / 2, scale.z / 2);
            transformationMatrix.rotate(rotation);
            transformationMatrix.translate(-scale.x / 2, -scale.y / 2, -scale.z / 2);
            transformationMatrix.translate(translation);
            // Set transformation
            this.entity.setTransformationMatrix(transformationMatrix);
            return;
        }

This seems to mess up the rotation pivot once again

#

The rotation seems to work fine until I make the final translation

lost matrix
zealous scroll
lost matrix
#

hmm

zealous scroll
#

I want to make the block rotate around its axis (which I've achieved thanks to your matrix solution) but I also need to keep the original translation because it's needed in the interpolations made when the block follows the parabola

lost matrix
#

Ah and one more thing for the translation. I made a mistake for the pivot point.
first translate to -px -py -pz instead. And then with positive values back ofc.

#

Wait...

#

Nvm, just try composing of the matrices first

tranquil beacon
#

?mapping

#

?mappings

undone axleBOT
zealous scroll
#

I actually tried that but it made the translation exacerbate the rotation by a bunch

        if (pivotRotations) {
            final Vector3f translation = transformation.getTranslation();
            final Vector3f scale = transformation.getScale();
            final Matrix4f translationMatrix = new Matrix4f();
            translationMatrix.m03(translation.x);
            translationMatrix.m13(translation.y);
            translationMatrix.m23(translation.z);

            // Apply rotations
            Quaternionf rotation = new Quaternionf();
            transformation.getLeftRotation().mul(transformation.getRightRotation(), rotation);

            Matrix4f transformationMatrix = new Matrix4f();
            transformationMatrix.translate(scale.x / 2, scale.y / 2, scale.z / 2);
            transformationMatrix.rotate(rotation);
            transformationMatrix.translate(-scale.x / 2, -scale.y / 2, -scale.z / 2);
            transformationMatrix.mul(translationMatrix);
            // Set transformation
            this.entity.setTransformationMatrix(transformationMatrix);
            return;
        }
lost matrix
zealous scroll
lost matrix
#

isnt it m30 m31 m32

zealous scroll
#

it's row-column

lost matrix
#

Thats garbage notation. X comes first.

lofty badge
#

i need this commands for my plugin:

  • Useful commands (which I can write in more detail)
  • A system of currencies and ranks (ranks can be upgraded for currency and receive goodies for this, such as prefixes or increased income at work)
  • Works system
  • System of cases for currency
  • Donation privilege system
  • Authorization and protection system against bots
  • Regions system
  • Chat filter system

How many years do you think it will take to write such a plugin?

remote swallow
#

max like 6 to a year probably

zealous scroll
remote swallow
lofty badge
pale pulsar
#

This is my code it's the same one I sent is it still making an 8x8 claim, if not show me your code?

sterile token
lost matrix
# zealous scroll it's row-column

Alright then lets apply each operation using a full composition
t being our translation
p being our pivot point

| 1 0 0 tx |   | 1 0 0 px |   | R1 R2 R3 0 |   | 1 0 0 -px |
| 0 1 0 ty |   | 0 1 0 py |   | R4 R5 R6 0 |   | 1 0 0 -px |
| 0 0 1 tz | x | 0 0 1 pz | x | R7 R8 R9 0 | x | 0 0 1 -pz |
| 0 0 0 1  |   | 0 0 0 1  |   | 0  0  0  1 |   | 0 0 0  1  |

The main problem is finding the RX values because you would need to apply the Rodrigues rotation and
i dont remember how to calculate it. You need some sort of skewing for that...
Try to simply rotate the identity matrix instead of calculating the R values.

mossy flume
#

do you guys math

pale pulsar
sterile token
lost matrix
sterile token
lofty badge
zealous scroll
#

So something like this?

        if (pivotRotations) {
            final Vector3f translation = transformation.getTranslation();
            final Vector3f scale = transformation.getScale();
            final Matrix4f translationMatrix = new Matrix4f();
            translationMatrix.m03(translation.x);
            translationMatrix.m13(translation.y);
            translationMatrix.m23(translation.z);

            final Matrix4f pivot = new Matrix4f().translate(scale.x / 2, scale.y / 2, scale.z / 2);
            final Matrix4f pivotN = new Matrix4f().translate(-scale.x / 2, -scale.y / 2, -scale.z / 2);

            // Apply rotations
            Quaternionf rotation = new Quaternionf();
            transformation.getLeftRotation().mul(transformation.getRightRotation(), rotation);
            Matrix4f rotationMatrix = new Matrix4f().rotate(rotation);

            Matrix4f transformationMatrix = translationMatrix.mul(pivot);
            transformationMatrix.mul(rotationMatrix);
            transformationMatrix.mul(pivotN);

            // Set transformation
            this.entity.setTransformationMatrix(transformationMatrix);
            return;
        }
sterile token
zealous scroll
#

Getting the matrices independently then just generating the product of all 4?

sterile token
pale pulsar
odd lark
#

Hi Do you know a way to get the texture of an element in url png or byte (I'm not talking about the unfold texture but the visual one)

sterile token
lost matrix
halcyon hemlock
#

Fr

sterile token
#

But something to tell u, if yo get frustrated you wont do it. Have to do it little by little

lofty badge
halcyon hemlock
quiet ice
#

30 USD would be something that can be done in half an hour. There isn't much that can be done in that time.

odd lark
# lost matrix Just use ImageIO

I don't have the URL, I'm looking to create one

for example I have an itemstack and I want to obtain a visual of this item in image

lost matrix
lost matrix
quiet ice
quiet ice
#

Or just use a resourcepack which is simpler

quiet ice
lofty badge
#

lol

quiet ice
#

Then take the chance and do it yourself.

#

At 14 yrs old you can learn anything in pretty much an instant. Only issue is that you have next to no experience to build upon, but that is why you shouldn't delegate anything to other people

lofty badge
quiet ice
#

~ Uh that is not what I meant

sterile token
#

He means that you can start little by little coding it urself

sterile token
#

I meantion me as none english native speaker they translate waht ever

quiet ice
#

Your corrections make less and less sense by each correction

fallen lily
sterile token
#

I mean he asked how much time will take him to do that

quiet ice
#

?services It probably is a commision

undone axleBOT
sterile token
quiet ice
#

Considering the other responses, it is.

sterile token
#

Well i dont know what you mean

#

But what i suggest him is doing it little by little. Because at age you can fully start learning pretty well and you can be really indepdent if you start now

quiet ice
#

I wish I had learned non-coding stuff at that age 🙁

zealous scroll
sterile token
quiet ice
#

Being able to mod everything to smitherines and back is nice and all, but I'd really like to do the other stuff necessary for gamedev. Oh well, good thing I still have a lot of free time (a bit too much for my tastes).

hazy parrot
#

imo learning programming at such young age is not worth it

sterile token
hazy parrot
#

anyway probably most things you know now you learned from when you are teenager

sterile token
tardy delta
sterile token
tardy delta
#

i fully support you

warm wharf
#
 new BukkitRunnable(){public void run(){boolets=10;}}.runTaskLater(plugin, 20*2);
#

why is this not working

#

im new to making plugins

hazy parrot
#

what exactly isn't working ? You never declared boolets variable

sterile token
#

How to implement a proper equals() for finding my custom menus via my Menu Obj?

warm wharf
#

the plugin part is red

barren peak
#

does anyone know why this only spawns non-living entities such as a minecart and item frame, etc?

List<EntityType> entities = Stream.of(EntityType.values()).filter(entityType -> entityType != EntityType.PLAYER && entityType.isAlive()).collect(Collectors.toList());
int randIndex = ThreadLocalRandom.current().nextInt(0, entities.size());
return entities.get(randIndex);

warm wharf
undone axleBOT
#

You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {

}

}```
Becomes:

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {

    }
}```
hazy parrot
warm wharf
#

no this is exactly what i dont know how to do

sterile token
undone axleBOT
sterile token
#

Can you send code so we can see the context

hazy parrot
#

?di

undone axleBOT
warm wharf
#
public class listener implements Listener {

    // Declare boolets as an instance variable
    private int boolets = 10;


    @EventHandler
    public void onPlayerIntercat(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        ItemStack item = player.getInventory().getItemInMainHand();
        if (item != null && item.getType() == Material.NETHERITE_HOE && item.getItemMeta().getDisplayName().equals(ChatColor.RED + "maw")) {
            if (boolets == 0) {
                player.sendMessage("i need more boolets");


                new BukkitRunnable(){public void run(){boolets=10;}}.runTaskLater(plugin, 20*2);

                player.sendMessage("reloadau si ja nimas izbire");
            }
            if (boolets != 0) {
                Arrow arrow = player.launchProjectile(Arrow.class);
                arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
                //arrow.setVisibleByDefault(false);
                arrow.setVelocity(player.getLocation().getDirection().multiply(60));
            }
            decrementBoolets(); 
            player.sendMessage(String.valueOf(boolets));
            event.setCancelled(true);
        }
    }
    private void decrementBoolets() {
        if (boolets > 0) {
            boolets--;
        }
    }
hazy parrot
#

?conventions

hazy parrot
#

?di

undone axleBOT
hazy parrot
#

look at those two links, second one is explaining how you can pass your plugin instance

warm wharf
#

ok

sterile token
#

oh sorry for anwering i just realize. Discord is going to the fuck

hazy parrot
#

i mean its ok shrugging

sterile token
#

Because i till dont know better way to find the menus

hazy parrot
#

idk context, but that is more or less classic equals impl

sterile token
#

I just know i have to find them via == but not sure tho

#

Because i was told InventoryHolder is the worst option

#

What about using a Map<String, Menu> where key is a unique name

hazy parrot
#

why you dont just compare inventories with == if those are mc inventories

sterile token
#

That what i was asking which was better hehe

glad prawn
sterile token
pseudo hazel
#

didnt we tell you earlier to just use == xD

sterile token
#

Yeah i remember it, but didnt know a good aproach for implementing it

pseudo hazel
#

for implementing what

#

the == operator is already implemented by java

quiet ice
#

/shrug Just use equals

remote swallow
#

epic ¯_(ツ)_/¯ fail

quiet ice
#

I know that it is gone, but I couldn't be bothered to insert it myself

#

Back in the old days we had it easier

#

Hold on, that isn't valid english, is it? Whatever.

remote swallow
#

what is gone

pseudo hazel
#

¯_(ツ)_/¯

#

i guess

#

except its not

frosty acorn
#

hey guys i have a quick question. So I have a datapack generated nether that I want to import into my server to replace the current nether with. I took the DIM-1 folder and put it into the world folder but for some reason it did not work

#

anyone able to explain to me how I would do this?

pseudo hazel
#

are you just using spigot?

frosty acorn
#

paper

pseudo hazel
#

?whereami

frosty acorn
#

ya but yall know your shit so im sure you can give me a hand

sterile token
#

Paper has own support

pseudo hazel
frosty acorn
#

yer devs for crying out loud

sterile token
#

Paper 💀

pseudo hazel
#

well idk

frosty acorn
#

this is basic stuff pretty sure, merging dimensions

#

i just dont know how

pseudo hazel
#

paper uses separate folders for nether and end

scenic valve
#

Probably need to just put the datapack into the datapacks folder and let the nether folder generate a new version, like delete it

#

but yeah, datapack != spigot

pseudo hazel
#

that too

warm wharf
#
public class listener implements Listener {

    // Declare boolets as an instance variable
    int boolets = 13;
    private final Guna plugin;
    public listener (Guna plugin){
        this.plugin = plugin;
    }

    @EventHandler
    public void onPlayerIntercat(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        ItemStack item = player.getInventory().getItemInMainHand();
        if (item != null && item.getType() == Material.NETHERITE_HOE && item.getItemMeta().getDisplayName().equals(ChatColor.RED + "maw")) {
            if (boolets == 0) {
                player.sendMessage("i need more boolets");


                new BukkitRunnable(){public void run(){boolets=13;player.sendMessage("reloadau si ja nimas izbire");}}.runTaskLater(plugin, 20*2);


            }
            if (boolets != 0) {
                Arrow arrow = player.launchProjectile(Arrow.class);
                arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
                //arrow.setVisibleByDefault(false);
                arrow.setVelocity(player.getLocation().getDirection().multiply(60));
            }
            decrementBoolets(); // Call the method to decrement boolets
            player.sendMessage(String.valueOf(boolets));
            event.setCancelled(true);
        }
    }
    private void decrementBoolets() {
        if (boolets > 0) {
            boolets--;
        }
    }



}
#

how do i make it so players arent using the same boolets var

scenic valve
#

What, each player has their own booklets variable?

warm wharf
#

yes

remote swallow
#

map, pdc

scenic valve
#

^

sterile token
# warm wharf yes

Something to add, always use the modifiers and also constants (bullets in this casa) are defined as final

warm wharf
#

ok thanks

sterile token
#

They are small modifications which make code more cleaner and learning new things isnt bad

leaden helm
scenic onyx
#

How i can get ItemStack Fished??

mellow edge
#

why can't I change DragonBattle.getBossBar().setTitle("X Guardian");

blazing ocean
#

hello, I'm trying to add a player to a scoreboard team, tho Team#addPlayer and every other player-related method is deprecated and doesn't seem to work / doesn't add me to the team

#

how do I do that?

scenic onyx
#

How i can get ItemStack Fished??

blazing ocean
brisk estuary
#

Does anybody know any library that makes working with a relational database easier? Like switching between sync and async and so on

sterile token
#

translate it via deepl

fluid river
undone axleBOT
fluid river
#

?jd-s

undone axleBOT
fluid river
#

FishEvent

sterile token
fluid river
#

?

sterile token
#

i wish i could be you haha

sterile token
# fluid river ?

yoo have to much patient to help. I mean because he post the same thing liek 2 times, like asking fast help i ma quen

fluid river
#

i just opened this channel

#

jreefavalessons

sterile token
#

I remmeber you used to be all day giving some hands on this channel

modern spade
#

how to i stop block break progress reseting like save it

sterile token
#

I assume you saving them via some sort of Map right?

modern spade
#

for example when mining coal I want to progress of it to stay if i stop mining it

sterile token
lofty badge
#

I want to perform some action if the player breaks a block, what do I need to do for this?

remote swallow
#

a listener for block break event

modern spade
#

no for example lets say i am breaking a coal block and i broke it half of the way and stopped mining it would say as half broken

remote swallow
#

?eventapi

undone axleBOT
sterile token
#

Im not sure how to do that

lofty badge
#

@sterile token check dm

sterile token
# remote swallow ?eventapi

He wants to tell player like percentage of block break. So if they start mining and stop, tell the player how much is left - Thats what i have understand please confirm it @modern spade

remote swallow
sterile token
#

Well im not sure how to do what he wants could you Epic try to explain him

remote swallow
#

no verano , the eventapi link was for @lofty badge

#

i just didnt know the command so it got sent after

sterile token
sterile token
#
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
  Player player = event.getPlayer();
  Block block = event.getBlock();
  double blockHealth = 100; // would have to check how to obtain it
  int currentHealth = (int) (blockHealth - event.getDamage());
  player.sendMessage("Block state " + ((currentHealth / blockHealth) * 100) + "%");
}```
modern spade
#

ty

sterile token
#

You could start from there

#

Atleast you have a base

echo basalt
#

isn't the max block damage just 7

sterile token
kind hatch
echo basalt
#

iirc you had to unregister and re-register it with bukkit unsafe

#

.

#

.

#

apologies if I have pinged

kind hatch
echo basalt
#

something something what if you replace the map

kind hatch
#

How would I replace it? Reflection?

echo basalt
#

ye

kind hatch
#

Reflect on what class? The NMS one or is there a bukkit class that I can work with?

echo basalt
#

the one that's causing the exception

kind hatch
#

Field was public, so it didn't need reflection. :p

quaint mantle
#

is anyone really good at using interactiveboard?

#

idk why i bought it if there's only 1 plugin tutorial on it

#

but please any help would be appreciated!

rough drift
#

HOWTO: Removing a player's auras

echo basalt
fluid river
#

you need API help or help configuring the plugin

echo basalt
#

lmfao wtf am I seeing

remote swallow
quiet ice
#

Perfectly safe - nothing to worry about

#

(Though protip: Use Unsafe#allocateInstance next time)

slender elbow
#

or.. not?

#

Class#isAssignableFrom in shambles

quiet ice
#

Meh, the amount of performance I gain from doing that is much less than the time I need to spend to figure out in which order I need to call it again

slender elbow
#

when was this about performance again?

quiet ice
#

Is it parent.isAssignableFrom(child) or child.isAssignableFrom(parent)? I keep forgetting, so I wouldn't risk going that route and forgetting it.

#

Obviously, passing Class<T> instances is a flawed design anyways.

slender elbow
#

haven't had that problem in years

left pine
#

Hello, I wanted to know if the player's head could be obtained with the skin he has.

If so, how do I do it?

inner mulch
#

Does somebody know how I can make commands disappear from the tab complete, if a player doesnt have the permission to use/see them?

quiet ice
slender elbow
#

it is not

#

congratulations

#

or, well, depends on how you see it

quiet ice
#

So AbstractMap.class.isAssignableFrom(HashMap.class) yields false? See, that is why I am afraid of using that method call.

left pine
orchid gazelle
#

Imma ask here this time. I am trying to set a command's permission message. The issue is that it will just give me "unknown or incomplete command" even though I registered the message

hybrid spoke
slender elbow
inner mulch
# left pine ok
        ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
        SkullMeta meta = (SkullMeta) playerHead.getItemMeta();

        OfflinePlayer player = Bukkit.getOfflinePlayer(playerName);
        if (player.hasPlayedBefore()) {
            meta.setOwningPlayer(player);
        } else {
            meta.setOwner(playerName);
        }

        playerHead.setItemMeta(meta);

        return playerHead;
    }
}```

This should probably work
hybrid spoke
#

?spoon

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

slender elbow
#

like i said, i haven{t had that problem in ages

inner mulch
#

Does somebody know how I can make commands disappear from the tab complete, if a player doesnt have the permission to use/see them?

quiet ice
#

But that doesn't make much sense anyways.

HashMap x = new HashMap();
AbstractMap y = x;

works. Hence, AbstractMap should be assignable from HashMap?

slender elbow
#

if by parent you mean superclass then yes

orchid gazelle
#

if you just use #setPermission on your Command

quiet ice
slender elbow
#

sure then

#

so?

inner mulch
orchid gazelle
#

Sure thing ;)

quiet ice
slender elbow
#

okay lol

inner mulch
orchid gazelle
#

You can call #setPermissionMessage on a Command

#

Which should define the failure message you get

quiet ice
slender elbow
#

:WeirdChamp:

inner mulch
orchid gazelle
#

Well yes but then it won't hide the command and so on

#

And the API thing should just work

quiet ice
#

Though I wonder if using an instanceof on an Unsafe#allocateInstance is much worse performance-wise than straight-up using isAsssignableFrom

inner mulch
#

wait, why cant u hide it if you do it like that

quiet ice
#

Given that evidently the only difference of note is the performance impact as Unsafe#allocateInstance doesn't run the constructor.
And perhaps JPMS

orchid gazelle
#

Idk why but it does lol

#

I do not understand why setPermissionMessage is implemented even though it seems to not work

ivory sleet
#

geol are you sure you mean isAssignableFrom and not just isInstance (iirc the name)

quiet ice
#

isAssignableFrom for sure exists. isInstance would be new to me

ivory sleet
#

cuz Class#isAssignableFrom checks the class relation, while Class#isInstance is just iirc a glorified instanceof

orchid gazelle
quiet ice
#

I am basically asking how much slower it would be to run unsafe.allocateInstance(clazz) instanceof MyClass versus MyClass.class.isAssignableFrom(clazz)

ivory sleet
#

Oh

#

May I ask why do this?

quiet ice
#

Which uses Class#newInstance instead

orchid gazelle
# quiet ice Hm?

This project mentions that it's a reimpl with the reason listed that mixins badly support usecases that are not "intended"

ivory sleet
#

I can say for sure allocateInstance is faster than newInstance

orchid gazelle
#

So does this micromixin contain a loader for spigot or sth?

ivory sleet
#

But then you could prob identify the type of the instance by a switch or Map<Class,V> where u pass the class

quiet ice
orchid gazelle
#

Yes I know part 2

#

Damn sad I almost had some hope that someone wrote some Agent for that

quiet ice
#

However Starloader's classloading architecture is very similar to bukkit's classloading so as a fork of cb/bukkit it would work.

orchid gazelle
#

I am not talking about forking

#

I am talking about dynamic agents reloading classes to apply mixins

#

So basically no fork or startup args or anything, just a plugin lifting the work

#

/hotswapping

quiet ice
#

Given that I haven't encountered that problem while modding galimulator I haven't looked at it.

orchid gazelle
#

Hm sad

#

I have been thinking and asking about that stuff for 2 years now

#

I know it's possible but I know I would not be able to do it lol

chrome beacon
#

You'd need startup args

orchid gazelle
#

No

#

Dynamic Java Agent

#

You inject your agent at runtime

#

Which reloads/hotswaps classes

quiet ice
#

When using agents it is actually better to use the spongeian implementation than the micromixin impl as latter was explicitly coded for classloader-based systems.

chrome beacon
quiet ice
#

So the only two areas where micromixin shines at is Java 6 (perhaps even Java 5 since people requested that in the past) and classloader-first architectures

orchid gazelle
quiet ice
#

Yeah, but it won't last forever

orchid gazelle
#

The project is called "unfixer" lmao

chrome beacon
#

So ig it's possible if you to limit yourself to old versions

quiet ice
#

Afaik it is over prety soon with all these workarounds

#

but alas I should go to bed urgently

chrome beacon
orchid gazelle
drowsy cosmos
#

@lost matrix aw sucks 😔 Im hacking my way through it right now, but I thought to ask here in case I missed an API that could do that

chrome beacon
#

Also won't work on all systems

orchid gazelle
#

Works on linux/windows

#

So everything you need

orchid gazelle
#

If it works it works

chrome beacon
#

Using native code to forcibly inject a startup argument isn't supported

#

And if something goes wrong you can crash the entire jvm

orchid gazelle
#

It's just hacky

paper viper
#

Is there a way to set the block loot in code
something like
table.put(Material.Cobblestone, new ItemStack(Material.Dirt)); 1.12.2

inner mulch
#

Can someone help me on how to properly implement permissions into plugin.yml or link a tutorial?

chrome beacon
paper viper
#

i dont think they are avalible for 1.12.2

chrome beacon
#

you should have specified that you're on 1.12.2

#

Otherwise we'll assume you're on the latest version

paper viper
#

mb

chrome beacon
#

You can probably use nms

#

Take a look

chrome beacon
paper viper
chrome beacon
#

Loot table class probably

#

That's where I'd start

#

Alternativly look at where the loot table is used

wet breach
#

it depends what you are trying to accomplish. If you are trying to change what is dropped when a block is broken with random drops, then the loot table may be ideal

#

otherwise just use the drop method of blocks

quaint mantle
#

should I make a new class to set all the gamerules

spark osprey
wet breach
#

is this class only just setting up the stuff?

quaint mantle
#

nah the world will be like a bukkit world

#

it's basically a wrapper

#

imo

#

so it might have stuff like

wet breach
#

in that case I would probably make it an inner class

quaint mantle
#

sendToSpawn

#

sendToSpawn(Player player)

#

etc

spark osprey
#

nooonie i thought u were smart

wet breach
#

well those are commands

#

which commands I would keep separated

quaint mantle
#

like to what

#

In theory it's all part of the gameworld tho

#

ah but yeah nah wait

wet breach
#

in theory but not even the bukkit api has it setup like that

quaint mantle
wet breach
#

that is to spawn an entity

quaint mantle
#

it's a command

wet breach
#

yes but no

quaint mantle
#

if I branch

#

off to another class

#

how would that work

wet breach
#

easily because the api lets you listen for commands already and you just only need to check the world someone is in

#

unless you also want to support console stuff

#

then it may be a bit more involved

#

but do remember, just because myself and others may say different things

#

it is your plugin after all 😉

quaint mantle
#

ok but here

#

let's say

#

the Location spawn object needs to be passed around everywhere

#

cause player death

#

out of bounds

#

etc

#

I would rather dependency inject the entire world with all the data

#

than just a single object

wet breach
#

well it should be the other way around

#

also the world object should mostly be static unless there is time it will be removed?

river oracle
wet breach
#

that is why I added the question mark

quaint mantle
#

ok

#

im tryna stay awya from static

#

like what if I want two game worlds

spark osprey
#

smae

wet breach
#

it does have its advantages

quaint mantle
#

yes ik

#

but im saying is that

#

imo

#

this is better for future dev

wet breach
#

if you think so, as I said it is your plugin so whatever you decide goes and really it is you who has to work on it. So not everything has to be about efficiency or best ideals, but also easy for you to maintain lol

#

but this project is perfect for you to learn how to use statics though

quaint mantle
#

bro

#

@wet breach why would I use static for this

#

cause ik my server gonna be VERY popular ima need

#

multiple game worlds

river oracle
#

Multiple game worlds? IMHO you should really only use one

#

Setup bungee

wet breach
#

there is other rules, but they are dependent on the scenario

quaint mantle
quaint mantle
#

idk u might be right

#

actually now that I think of it

wet breach
#

you just have to learn to not use a bunch of statics is all 😛

#

but some occasional ones are fine

quaint mantle
#

i just avoid static when it comes to abstraction

wet breach
#

but then you have stuff like enums which are static

#

so if you want to use an enum, then you can't avoid the staticness XD

river oracle
#

Enums are great and so is static

#

The reaction of someone who doesn't know how to use enums and static

quaint mantle
#

ima make this implement GameWorld

#

and make it all abstract

#

so i cant use static

opaque scarab
#

Anyone know why i'm getting this problem when compiling with intelij and Maven? [ERROR] Malformed \uxxxx encoding.

#

I have checked my POM xml extensively, and it SHOULD work

#

May something be corrupted?

wet breach
#

where statics don't do good is in dynamic scenarios usually

quaint mantle
wet breach
#

only way I dealt with file encoding issues reliably is to delete the file and remake it, or use some option to ignore encodings

wet breach
#

they usually don't do good in those situations lol

quaint mantle
#

why

wet breach
#

because they are static and don't change, where as in a loop you are wanting change usually. It just depends on what it is that is static really

spark osprey
quaint mantle
#

what if i just make this class static

#

bruh

#

@wet breach

#

ok so i might just get rid of this whole class

#

but if I want to set the gamerules

#

idek atp

quaint mantle
#

or neither

wet breach
wet breach
drowsy cosmos
#

Excuse my ignorance. How do I get started with making PRs for Spigot? I'm trying to achieve this. Seems like there's no method for this.

left pine
#

Asks how to get the items from the player's inventory?

wet breach
#

the reason it removes all of them is because the remove method takes a type and doesn't distinguish between multiple of the same types

#

but if you want to start doing PR's with spigot you are welcome to

#

probably should start with the CLA

#

?CLA

#

?cla

undone axleBOT
echo basalt
#

epic fail

drowsy cosmos
drowsy cosmos
quaint mantle
#

make it a class?

#

an object that does everything

wet breach
#

so it should do so

lethal coral
#

The warning for add is saying that lore() may return null. however the code above that should assert that it can never be null. is there something I'm missing or should I ignore it

quaint mantle
#

I think it's cause it's annotated with Nullable

#

And u have to use a requirenonnull or directly check if it's not null something like that

wet breach
lethal coral
wet breach
#

while true, an empty lore is null

lethal coral
#

I don't get it

drowsy cosmos
drowsy cosmos
# lethal coral I don't get it

You should probably be best with changing your structure. Instead of adding lore like that. You should add lore using parameters. Not sure whether it is lore() or setLore().

You can also do itemMeta.lore() == null instead in the if checks, iirc. That should negate the warning from IDE.

lethal coral
#

ended up doing this

    public ItemBuilder withLore(@NotNull String... text) {
        Objects.requireNonNull(text);
        itemMeta.lore(Arrays.stream(text).map(miniMessage::deserialize).toList());
        return this;
    }
#

will still look fine

wicked quail
#

Is there a way to play a chest opening animation using the API? (I'm currently updating a plugin which used packets)

lethal coral
#

you're welcome

cyan oasis
#

Hi, I am in need of assistance please. I'm making a plugin where it changes mob attributes on spawn, and when I try spawning them in game, they don't. It makes the sound of them spawning in, just doesn't actually spawn them. I am trying to update this plugin, as I started working on it during 1.19.3, and it was working fine in that version. The version I'm trying this in is 1.20.1 on a 1.20 client w/ fabric mods (if that somehow matters). Here's an example case for Creepers:

#

Please let me know if any other details are needed, as I am relatively new to plugin coding.

#

Update: No mobs are spawning at all.

drowsy cosmos
cyan oasis
#

No errors are thrown in console for some reason

#

I'll check my logs

#

Nope

#

If it helps, I'm running Paper.

drowsy cosmos
#

Just something to check, but have you registered the Listener?

cyan oasis
#

Also other events work like players joining

cyan oasis
drowsy cosmos
#

Try to log something in the method, and check if its even running.

cyan oasis
#

Okay lemme see

drowsy cosmos
#

try to log the entityType as well

cyan oasis
#

I added this now let's see

#

Okay for some reason it is now logging and also spawning mobs correctly

#

I love java

#

Thanks for the help I guess lol

lethal coral
#

Why is the 1st parameter (String name) a string instead of an Attribute

wet breach
#

doesn't really matter on the order of the parameters

remote swallow
lethal coral
wet breach
#

oh

#

not entirely sure then lol

lethal coral
#

😭

#

apparently it's like your own id for whatever you're doing 🤷‍♂️

quaint mantle
#

How does dependencies via maven and bukkit even work I'm so confused

#

Does bukkit load all the projects into like one jar during runtime

#

like theoretically

#

a jar with a bunch if modules

#

Idk the analogy for ot

#

It

echo basalt
#

Y'know how each plugin has its own classloader

#

P sure that's involved

#

Basically it scans the yml file, downloads the deps into a cache folder and loads them accordingly

quaint mantle
#

Spigot does download deps from original jar?

#

@echo basalt so if I depend on something like luck perms how does that all work

#

and honestly what even happens when I depend in a regular maven project now that I think of it

#

like does it, during compilation, it compiles the dependency in the project

lethal coral
#

https://textures.minecraft.net/texture/e4d49bae95c790c3b1ff5b2f01052a714d6185481d5b1c85930b3f99d2321674 is this not a valid skin url?

lethal coral
lethal coral
lethal coral
#

Update the offline player constructor works just not the skin url constructor

echo basalt
primal goblet
#

Hey i am installing BuildTools with java 8 and selecting 1.8.8
sadly something weird happens here, can someone explain this?

#

the error says sh: 0: cannot open /usr/bin/mvn/bin/mvn: No such file the path should be /usr/bin/mvn

short pilot
#

Is there a way to check if the player is in combat? Like a sort of combat log API already existing?

fallen lily
short pilot
#

aw man

fallen lily
#

You can track combat with attack events

ivory sleet
#

would have to rely entirely on some api

fallen lily
#

It should be in mc

ivory sleet
#

there isn't really a way of telling whether someone is in combat or not, I mean you can define your own restrictions on what being in combat means

fallen lily
#

The game needs to know how you were killed to show the appropriate death message

#

Including player & entity combat

fallen lily
#

fall damage, fire, void

#

Etc

ivory sleet
#

death message has nothing to do with whether a player is in combat or not

#

its just how they died

fallen lily
#

Well you obviously haven’t read far enough

ivory sleet
#

?

#

are you trolling or what?

fallen lily
#

I’m not…

ivory sleet
#

there is literally no such thing as being in combat

fallen lily
#

I can solemnly swear there is a combat tracker in NMS right now

ivory sleet
#

show me

tall dragon
#

so how does knowing my ass dropped in the void help in knowing wether i am in combat

fallen lily
# ivory sleet show me

If you can wait about 12 hours for me to finish work and wind down that would be bless

#

To further prove my point, combat tracking is also essential in the entity AI subsystem

#

So yes it is “tracked”

#

How far, that isn’t known to me right now

tall dragon
#

which does not extend to players?

#

yea entities can be " targeting" something sure

ivory sleet
#

you are straight up lying

#

the ai system just caches targets and entities during runtime

#

has nothing to do with combat

#

and has never been

#

there is something called a targetSelector and a goalSelector, these two have a set of goals that constantly tick to check where the entity may move and what the entity may target

#

nothing to do with combat

#

stop coping

fallen lily
fallen lily
#

I am almost certain combat is tracked

ivory sleet
#

it doesn't matter when you take a look

#

everything you've said to this point is wrong

#

its okay to be wrong

fallen lily
#

Well I sincerely apologies for my lack of expertise

#

And your due unprofessionalism in resolving disputes

#

: )

chrome beacon
#

There is a combat tracker in nms

#

Though it's only used for death messages as far as I'm aware

fallen lily
#

^

ivory sleet
#

Yeah the one for death messages is a thing I suppose

drowsy cosmos
#

Is there any other potion effects getter than I'm currently missing out on?

lost matrix
hybrid turret
#

Soo, I'm trying to get to know PersistentDataHolder / PersistentDataContainer...
Now, I want to implement a key-system where you can just click on the iron door with the key in your hand and the door will open.
I kinda don't know how to start tho since I have absolutely no idea about PDH. I tried the guide but I kinda failed. I don't quite get how I will be comparing the data when clicking the door.

Oh right, I also want to store all the already used keys just so there's no duplicate keys created. (which is very unlikely, regarding every key has a 16 letter alphanumeric code, but anyway)

lost matrix
chrome beacon
#

It does

#

Or might be mobs too since they can show up in death messages

lost matrix
#

Only for direct kills (last hits)

chrome beacon
#

Code is written so it can work with all living entities

#

Haven't checked where the combat tracker is used

#

Alr just checked it tracks any damage

#

and it's source

lost matrix
hybrid turret
#

i'll look into that

#

thanks

#

when is a chunk deleted?

lost matrix
hybrid turret
#

oh

#

well that's nice then

#

that's really nice actually, damn

#

also since i only started with maven a couple of weeks/months ago, can u explain the relocation thing on the github-page for the api?

lost matrix
#

But chunks get regularly unloaded* If thats what you are asking

lost matrix
hybrid turret
#

nono, i just read in the readme for the api, that upon chunks being deleted no more data remains

lost matrix
#

Because it changes the classpath of the loaded classes. Meaning you will use your version of the lib
while others use theirs.

hybrid turret
lost matrix
hybrid turret
#

yea

#

this:

* When the chunk where the block is inside gets deleted, there will be no leftover information
lost matrix
hybrid turret
#

ahhhh that's pretty cool then

#

Also: Materials are the items inside your inventory, did i understand that correctly?

#

And blocks are, well, blocks

drowsy cosmos
lost matrix
hybrid turret
#

i see, thank you

#

And I'm guessing upon placing the ItemStack (if placable), like a door, the meta is copied to the block?

#

or rather to the chunk with the CustomBlockData api?

lost matrix
hybrid turret
#

okayyyy this is a bit more than expected, but sounds doable

lost matrix
#

Should be a listener and like 5 lines of code. Def doable.

vapid anvil
#

How would I get the ProtocolLib serialiser for a VillagerData metadata type?

#

is it just an int[]?

vapid anvil
#

I'd like to send a packet to change a Villager's type and profession

#

I've been able to do similar things purely through WrappedDataValues before, but is it possible here?

lost matrix
#

It only contains the Type, Profession and Level

#

Idk what you need

hybrid turret
vapid anvil
#

normally there'd be a built in serialiser for a compound type but there doesn't seem to be one for VillagerData

lost matrix
#

Does the villager data get sent via the metadata packet? Let me check the protocol...

vapid anvil
#

that's what I've been talking about

hybrid turret
#

right, lol serializing. i've been trying to do this with inventories but i can't get shit to work, well that's a topic for a different time though, lol

vapid anvil
#

I can't find a ProtocolLib serialiser for a VillagerData type

lost matrix
#

Have you tried getting a serializer for WrappedVillagerData

vapid anvil
#

not sure how I'd do that, that seems to be for a data watcher

lost matrix
# vapid anvil not sure how I'd do that, that seems to be for a data watcher

That would be my first approach:

    PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
    packet.getIntegers().write(0, this.someFakeId);

    List<WrappedDataValue> dataValues = new ArrayList<>();

    WrappedDataWatcher.Serializer villagerSerializer = WrappedDataWatcher.Registry.get(WrappedVillagerData.class);
    WrappedVillagerData villagerData = WrappedVillagerData.fromValues(Type.DESERT, Profession.ARMORER, 3);
    WrappedDataValue serializableVillagerData = new WrappedDataValue(18, villagerSerializer, villagerData);
    
    dataValues.add(serializableVillagerData);
    
    packet.getDataValueCollectionModifier().write(0, dataValues);
vapid anvil
#

yeah that's what I'm trying rn

#

appears to work

lost matrix
# vapid anvil yeah that's what I'm trying rn

Ah, you can also try

WrappedDataWatcher.Serializer villagerSerializer = WrappedDataWatcher.Registry.get(WrappedVillagerData.getNmsClass());

instead of

WrappedDataWatcher.Serializer villagerSerializer = WrappedDataWatcher.Registry.get(WrappedVillagerData.class);
#

Ah ok

vapid anvil
#

thanks for the help

lilac dagger
#

protocollib looks so ugly

vapid anvil
#

better than using nms lol

lilac dagger
#

eh, i'm more happy with nms

shadow night
#

Last time I used protocol lib, I didn't want to use nms, but I still had to use nms classes

lost matrix
#

I greatly prefer nms. But it breaks every version, so...

lost matrix
lilac dagger
#

yeah, this is the single benefit of prefering plib

#

offshoring work

shadow night
#

Need them

lost matrix
#

For what?

shadow night
#

It was the armor equip packet, I needed to set the armor to nothing for everybody else if some conditions match and it wouldn't let me do stuff like getItemStack(0) or whatever it was, so I had to use the getModifiers or whatever it was (I don't remember, haven't done this stuff in ages) which required me to pass nms classes

hybrid spoke
#

plib couldve made their public api way better

lost matrix
shadow night
#

But it returned null

vapid anvil
#

you need to do getSlotStackPairLists

lost matrix
#

Yeah this one

vapid anvil
#

now it's giving me a NullPointerException when I try to initialise the WrappedVillagerData

WrappedVillagerData villagerData = WrappedVillagerData.fromValues(
    WrappedVillagerData.Type.valueOf(villagerType.toString()),
    WrappedVillagerData.Profession.valueOf(profession.toString()),
    1
);
```(both those `WrappedVillagerData` enums are correct, I checked their values)
lost matrix
#

hm

#

Have you tried it with fixed values first?

vapid anvil
#

I'lll try that now

#

yeah still get the error

#

everything but the WrappedVillagerData initialiser's commented out

#
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:907) ~[guava-31.1-jre.jar:?]
        at com.comphenix.protocol.reflect.accessors.MethodHandleHelper.getFieldAccessor(MethodHandleHelper.java:83) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.reflect.accessors.Accessors.getFieldAccessor(Accessors.java:84) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.wrappers.EnumWrappers$FauxEnumConverter.getGeneric(EnumWrappers.java:957) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.wrappers.EnumWrappers$FauxEnumConverter.getGeneric(EnumWrappers.java:938) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.wrappers.WrappedVillagerData.fromValues(WrappedVillagerData.java:53) ~[ProtocolLib.jar:?]
lost matrix
vapid anvil
#

yep

lost matrix
#

Are you using 5.1.0?

vapid anvil
#

v5.1.0-SNAPSHOT-661

#

should I update?

lost matrix
#

5.1.0 had a release version for while now

#
<version>5.1.0</version>
hybrid turret
#

How do I fix the problem with the PlayerInteractEvent being fired twice when there is no item in their hand?

vapid anvil
#

huh I've got 5.0.0 in my pom

tall dragon
#

?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
}
hybrid turret
#

Thanks

#

So this will just ignore the offhand completly right?

vapid anvil
#

yeah newest version and newest dependency, still getting it

hybrid turret
#

No matter if i have an item in my hand?

lost matrix
hybrid turret
#

Perfect

mellow snow
#

The cooldown doesn't work

public class xrayEvents implements Listener {

    TheLogger plugin;

    private final HashMap<UUID, Integer> lista = new HashMap<>();

    private HashMap<UUID, Long> cooldowns;


    public xrayEvents(TheLogger plugin) { this.plugin = plugin; }


    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {

        Player p = e.getPlayer();
        //int current = lista.remove(p.getUniqueId());

        lista.merge(p.getUniqueId(), 1, Integer::sum);
    }


    @EventHandler
    public void onBlockBreak(BlockBreakEvent event) {

        this.cooldowns = new HashMap<>();


        Player p = event.getPlayer();

        Block b = event.getBlock();


        Material material = b.getType();

                if(material.equals(Material.DIAMOND_ORE)){



                    Integer blocchi = lista.get(p.getUniqueId());


                    if(!this.cooldowns.containsKey(p.getUniqueId()) || System.currentTimeMillis() - cooldowns.get(p.getUniqueId()) < 10000) {

                        this.cooldowns.put(p.getUniqueId(), System.currentTimeMillis());

                        if (blocchi <= 6) {
                            lista.put(p.getUniqueId(), lista.get(p.getUniqueId()) + 1);
                        } else {
                            for (UUID uuid : plugin.xraylog_list) {

                                Player staff = Bukkit.getPlayer(uuid);

                                staff.sendMessage("attention! " + p.getName() + " use xray");
                                lista.put(p.getUniqueId(), 1);
                                cooldowns.remove(p.getUniqueId());
                            }
                        }
                    }

                }

    }
}
#

ehm ok?

lost matrix
#

Nvm everything is

#

What is the purpose of your lista

mellow snow
#

check how many block break a player

#

lista is italian, is list in english

lost matrix
#

Why do you merge the player into the map when he joins?
This will cause the value to shoot up when a player connects several times

tall dragon
#

pretty bold to assume someone is using xray if they break >= 6 blocks of diamond within the span of 500 seconds too

lost matrix
#

Just add him

lista.put(p.getUniqueId(), 0);
mellow snow
#

in console spam: lista is null

lost matrix
#

cooldowns is null. lista isnt.

mellow snow
#

i try lista.put before insert the cooldown

tall dragon
#

also show where ur registering it

#

prolly creating 2 instances too

mellow snow
#

First I try without cooldown, and then I add it

lost matrix
#

And here is the problem.
Every time a player breaks a block you delete the old map and create an empty one.

mellow snow
tall dragon
mellow snow
#
    @Override
    public void onEnable() {
        // Plugin startup logic
        System.out.println(ChatColor.BOLD + "[TheLogger]" + ChatColor.GREEN + ChatColor.BOLD + "Enable!");

        //Commands
        getCommand("log").setExecutor(new logGroups(this));

        //Drop
        getServer().getPluginManager().registerEvents(new dropEvents(this), this);
        //Kill
        getServer().getPluginManager().registerEvents(new killEvents(this), this);

        //xray
        getServer().getPluginManager().registerEvents(new xrayEvents(this), this);

        this.saveDefaultConfig();
        config = this.getConfig();
    }

tall dragon
#

right thats fine

mellow snow
#

I remove it now

#

but It still not work

lost matrix
#
    private final Map<UUID, Long> cooldowns = new HashMap<>();

And then remove the map creation out of your listener.
If you create an empty map every time, anyone breaks any block, then you dont
have to wonder why your code doesnt work. You just delete all your data constantly.

tall dragon
#

because cooldowns is null ;d

mellow snow
#

and now the cooldown is infite

#

:D

lilac dagger
#

the cooldown doesn't change, you have to make it work

#

Sys currenttimemilis - cooldowns.get uuid >= 1500

#

do stuff

mellow snow
#

how many seconds are 1500?

lilac dagger
#

a second and a half

#

1000ms = 1 s

mellow snow
#

doesn't work

lilac dagger
#

but if the server is laggy, you might wanna consider a sync task

mellow snow
#

now the plugin doesn't send the message

mellow snow
lilac dagger
#

it's definitely something wrong with the code still

#

do some prints

#

it's a good learning advice, you'll end up understanding how debugging works

mellow snow
#

thank

#

but if I'm writing here it's because I didn't found help on forum discusses or google

granite owl
#

when i pass a string to a C api via the jni, can and if so should i explicitly null terminate the string or does jni handle it for me?

tall dragon
mellow snow
#

and it's useless for you to tell me that I have to learn java or tell me other things that have nothing to do with the help on the cooldown. Or even worse I would say that insults can be avoided. I'm here to learn and have fun, I just asked for help.

tall dragon
#

Sigh well can you post your up to date class?

hazy parrot
mellow snow
# tall dragon Sigh well can you post your up to date class?

    TheLogger plugin;

    private final HashMap<UUID, Integer> lista = new HashMap<>();

    private final Map<UUID, Long> cooldowns = new HashMap<>();


    public xrayEvents(TheLogger plugin) { this.plugin = plugin; }


    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {

        Player p = e.getPlayer();
        //int current = lista.remove(p.getUniqueId());

        lista.merge(p.getUniqueId(), 1, Integer::sum);
    }


    @EventHandler
    public void onBlockBreak(BlockBreakEvent event) {



        Player p = event.getPlayer();

        Block b = event.getBlock();


        Material material = b.getType();

                if(material.equals(Material.DIAMOND_ORE)){



                    Integer blocchi = lista.get(p.getUniqueId());



                    if(!cooldowns.containsKey(p.getUniqueId()) || System.currentTimeMillis() - cooldowns.get(p.getUniqueId()) <= 10000) {

                        cooldowns.put(p.getUniqueId(), System.currentTimeMillis());

                        if (blocchi <= 6) {
                            lista.put(p.getUniqueId(), lista.get(p.getUniqueId()) + 1);
                        } else {
                            for (UUID uuid : plugin.xraylog_list) {

                                Player staff = Bukkit.getPlayer(uuid);

                                staff.sendMessage("Attention " + p.getName() + " use xray");
                                lista.put(p.getUniqueId(), 1);
                                cooldowns.remove(p.getUniqueId());
                            }
                        }
                    }

                }

    }
}```
hazy parrot
#

In the general case this means one should never assume JNI returned strings are null terminated, not even UTF-8 strings.

granite owl
sick edge
#

Hi, what's the best way to prevent placing an Item into the Offhand? I already have a handler that cancels the PlayerSwapHandItemsEvent but it seems like there is no easy way to do it in the inventory

granite owl
sick edge
smoky anchor
#

wouldn't you just do
if (slot == offhand)
dont();

granite owl
#

because theres lots of different events

#

pickup, swap, drag, placing

#

well pickup only when an item already is in the offhand

#

still

#

🤷‍♀️ gotta catch em all

#

also

#

u cant just say inventory this event

sick edge
#

Alright thx guys and one other question does TextColor not work in gui names and only NamedTextColor s?

granite owl
#

u first gotta check if its actually a player inv

#

not an anvil chest or whatever

#

cause theyre all inventories

#

not every inventory has an offhand item tho

sick edge
granite owl
#

unless u want nullptr exceptions

#

im sorry, null exceptions

remote swallow
#

Dont recommended stuff that wont work

eternal oxide
#

everyone should be on at least Java 11 now

#

8 is not a good version to use these days

#

I'd also never recommend Oracle, but thats personal due to their attempt to copyright an API.

tall dragon
#

and your cooldowns.put should replace your cooldowns.remove

sick edge
#

Im on 17 xD
I want to get a start area in a world i generate? What is the best/most efficient method to do this? Should I create a structure file and somehow load it?

eternal oxide
#

it depends on teh size of your start area

sick edge
#

Not very big only like a 20x20 Glass Area

#

I could place the blocks directly I guess

eternal oxide
#

a couple of chunks, yeah create a Structure

sick edge
#

ok

#

And how would I load it do I like have to spawn a structure block and use it to place the structure or are there better ways?

eternal oxide
#

no, you can save it and it will create an nbt file for you. Include that in yoru jar

#

then load/place as you need

sick edge
#

With Spigot StructureManager?

eternal oxide
#

yes

sick edge
#

Perfect I think that didnt exist last time I tried this a few years back 🙂

mellow snow
tall dragon
#

the same as ur doing rn

vapid anvil
#

@lost matrix created an issue in the plib repo, will see how it turns out

hybrid turret
#

If I set the QuitMessage to null, do I get no message or an empty message? (I can‘t test rn and it‘s bothering me lmao)

lost matrix
#

No message

hybrid turret
#

Perfect, as I expected. Thank you

smoky oak
#

can you obtain the server time in ticks without relying on the overworld?

tall dragon
#

is there such a thing as server time?

#

don't all worlds have their own time?

smoky oak
#

ye thats why im asking

real palm
#

Well, just start counting away from server start and when stopping (or reloading) save it, after "boot up" load from config and continue counting and so on. And by the seconds going by you can see the server time (not really good when implemented later on tho)

smoky oak
#

maybe

#

different problem

#

why does this dependency break jetbrains @NotNull

            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20230227</version>
            <scope>shaded</scope>
</dependency>```
lost matrix
#

Better question: Why do you use org.json in the first place?

smoky oak
#

cuz of this java.lang.NoClassDefFoundError: org/json/JSONObject

#

its not or im using the wrong import

lost matrix
smoky oak
#

NMS is hard

#

im copying code for actionbar

lost matrix
#

And spigot comes with json simple iirc

smoky oak
#

also its not giving me the option to go for GSON

#

aaand my annotations package is still broken

lost matrix
#

There you go. Remove your dependency and import json-simple.
What are you doing in the first place. Gson is the better lib for most things you would want to do with json.

blazing ocean
#

hello, i'm trying to make an api like this:

// PluginAPI
public class MyClass {
   void doSomething();
}

and I would like to use MyClass#doSomething in my main plugin:

// PluginMain
public class Class {
   void something() {
      PluginAPI.doSomething()
    }
}

how do I do that?

smoky oak
smoky oak
lost matrix
blazing ocean
lost matrix
smoky oak
#

found some code by brunobelloni1 and am using that

#

and its saying classNotFound on the JSON again

#

wait

#

not the json

#

on IChatBaseComponent

#

bleh why is this not in the API

lost matrix
#

Because thats nms

smoky oak
#

oh this is interesting. does getServerVersion only return the major version?

#

.v1_20_R1. is what its trying to access but im on a 1.20.1 server

lost matrix
#

And not even actual nms. Thats an old spigot mapping class name

remote swallow
#

you can get the nms version from the craftbukkit package

#

but paper are planning to remove that

smoky oak
#

?whereami

remote swallow
#

so you have to convert getServerVersion to nms ver if you want paper compat

smoky oak
#

urgh

#

is there some way around this

lost matrix
remote swallow
#

not really

smoky oak
#

cuz actionBars are apparantly NMS, and the only piece of code i found so far parses JSON for that

remote swallow
#

action bars are available in the api

lost matrix
#

What version?

remote swallow
#

player.spigot().sendMessage

smoky oak
#

latest stable

smoky oak
remote swallow
#

no

#

you send action bars through it

young knoll
#

There's an option for action bar too

lost matrix
#

ActionBars are an api feature since 1.9 i believe

smoky oak
#

i see

remote swallow
#

ChatMessageType

smoky oak
#

does that work on paper? I'm using spigot with the hope that everyting on spigot works on paper

remote swallow
#

yeah

smoky oak
#

alright. Also, what's Type.SYSTEM?

#

the top right thing for archivements?

remote swallow
#

system chat message

silent slate
#

Hi im back and still dont know how to solve my issue, if someone has too much time i would really aprreciate if he could explain to me how to properly do a mute plugin 🙂

remote swallow
#

the advancement type messages probably

remote swallow
silent slate
#

ye i did that but im too dump to make it, i can still write although being muted

smoky oak
#

ah that makes sense. Is there a way to clear the actionBar text?

#

i want to display this for a specific time

remote swallow
silent slate
#

well the event isnt even called i dunno why

lost matrix
#

Did you register the listener my boi

remote swallow
silent slate
#

yes

#

i think to

#

Bukkit.getPluginManager().registerEvents(new PlayerListener(),this);

lost matrix
#

Did you add the EventHandler annotation

silent slate
#
public class PlayerListener implements Listener {


    @EventHandler
    public void onSpeak(AsyncPlayerChatEvent e) throws ParseException {
        e.getPlayer().sendMessage("Test works");
        if(!MuteUtils.muteCheck(e.getPlayer())) {
            e.getPlayer().sendMessage("is false");
        }
        if(!DataConfiguration.INSTANCE.getData().contains("Data." + e.getPlayer().getUniqueId())) return;
        e.setCancelled(MuteUtils.muteCheck(e.getPlayer()));
    }
}```
remote swallow
#

i doubt it will take it with the throws parse exception

silent slate
#

i had it with highest priority before but it didnt change much, its not even showing "test works" when i send something in chat

remote swallow
#

use try catch

lost matrix
remote swallow
#

also dont set cancelled the result of mute check

#

bc that will uncancel a cancelled an event

silent slate
#

muteCheck needs it tho

remote swallow
#

yes, dont set the result

#

it could return false and you now uncancel th eevent

silent slate
#

so if(MuteUtils.muteCheck(e.getPlayer()) == true} set event cancellled

remote swallow
#

good lord

#

go learn java before using apis

#

?learnjava

undone axleBOT
silent slate
#

what api?

remote swallow
#

spigot-api

silent slate
#

ye that wasnt code that was how i would code it

smoky oak
#

oh just send nothing yea that should work

lost matrix
remote swallow
lost matrix
smoky oak
#

was the actionbar always this high above the hotbar?

silent slate
remote swallow
remote swallow
# silent slate no

try catch what is throwing the error and remove the throws ParseException

silent slate
#

but i need the parse because of this

remote swallow
#

yes

#

catch it

#

and print the stacktrace

lost matrix
# silent slate no

Then send us your onEnable method. And also: Check your log when the server starts. Make sure the plugin is enabled without exceptions.

silent slate
#

Date endMuteDate = getDateTimeFormat().parse(DataConfiguration.INSTANCE.getData().getString(DATA + p.getUniqueId().toString()));

#

this needs parse