#help-development

1 messages · Page 1945 of 1

thorny python
#

idk if it consume too many memory tho :v

lost matrix
#

WorldGuard actually just did this for the longest time without any major problems XD

thorny python
#

oops

#

ya indeed easy solution

lost matrix
#

Calculating if a vector points in a BoundingBox is quite cheap.
You can easily do several hundred checks in a tick without noticing it.

thorny python
#

hm

#

I have to check the problem size first, thanks

midnight shore
#

Is it possible to check it a player is in a box region?

midnight shore
#

How?

lost matrix
#

His location is just a vector. Check if this vector is in the BoundingBox

thorny python
#

x > x1 and x < x2 and z > z1 and z < z2

thorny python
#

:v

lost matrix
# midnight shore Ok

Something like

  public boolean isWithin(final Player player, final Location cornerA, final Location cornerB) {
    return this.isWithin(player.getLocation(), BoundingBox.of(cornerA, cornerB));
  }

  public boolean isWithin(final Player player, final BoundingBox box) {
    return this.isWithin(player.getLocation(), box);
  }

  public boolean isWithin(final Location location, final BoundingBox box) {
    return box.contains(location.toVector());
  }
charred blaze
#

how can i use " in messages?

#

nopermplayer.sendMessage(ChatColor.translateAlternateColorCodes('&', "Unknown command. Type "/help" for help."));

#

this gives me error

hollow bluff
#

Send the error then

charred blaze
#

Multiple markers at this line
- help cannot be resolved to a variable
- Syntax error on token "" for help."", delete
this token

charred blaze
#

how to

glossy venture
#

you need to escape quotes in strings

#

otherwise java will think its not a string anymore

#

and treat it like code

charred blaze
#

thanks.

next stratus
lilac dagger
#

what class name do you think is appropriate for the start/stop methods?

next stratus
tardy delta
#

so no errors in your pom?

lilac dagger
#

hmm, a service is actually what i was looking for thanks

tardy delta
#

hmm ._.

simple summit
#

What's the most efficient way to test if a world object instance is still loaded? There isn't an obvious World::isLoaded method.

lilac dagger
#

Bukkit.getWorld

#

uuid

tardy delta
#

try getting a location of it?

spiral light
#

Bukkit.getWorld() != null

glossy venture
#

maybe get a spawn chunk and check if its loaded

tardy delta
glossy venture
lilac dagger
#

yes

simple summit
#

I was hoping for a way to avoid the hashmap lookup - and to be able to tell the difference between a world ref that hasn't been unloaded and one that just happens to be for a world that was unloaded and loaded again

lost matrix
simple summit
#

no, i can call Bukkit::unloadWorld and just because I hold onto that world object doesn't keep it loaded

#

i mean, yes the object still exists in memory - but that's not what i mean

ivory sleet
#

It’s a bit annoying in your case assuming you rely on world objects themselves, as they’re not instantly removed when unloaded, rather they just get queued for collection whenever there are no hard/phantom references left. The lookup method is probably your safest bet.

lost matrix
#

Spigot just dereferences it

simple summit
#

ok - here's the situation. Plugin to create an arena world. I want to reset that world from time to time and I don't want the performance overhead of calling Bukkit::getWorld(String) shitloads

lost matrix
ivory sleet
#

Wat

#

the lookup isn’t gonna be the issue here

#

That’s a regular HashMap call at most

simple summit
#

hash lookups are slow vs just using an object ref

#

and if i'm calling a function for every block in a chunk - it adds up

ivory sleet
#

You’re just doing premature optimizations now

lost matrix
ivory sleet
#

HashMaps are incredibly fast

#

Sure an object reference is faster

#

But they have different use cases

simple summit
#

yes they are, but 3ns is slower than 0

#

anyway - not the real point

ivory sleet
#

I’m out

tardy delta
#

lol

simple summit
#

question was about a way to test if a word has been "unloaded" or not - and the answer is no

#

not directly

ivory sleet
#

Yes

#

Server::getWorld

simple summit
#

have to go through the Bukkit world map

ivory sleet
#

I mean the answer is yes still

#

It’s doable

simple summit
#

ya, that's fine - i'll deal with it, just didn't want to miss anything "better"

ivory sleet
#

And you should be thankful it’s a hashmap and not some shitty linked list

#

Which would be even worse

simple summit
#

actaully a LL is faster than a hasmap for small object counts

ivory sleet
#

Not rly

simple summit
#

there's parts in the standard libraries that do full scans if under 5k entries

tardy delta
#

a what

ivory sleet
#

LinkedList scale extremely bad

simple summit
#

i forget what i was looking at when i saw that TBH

ivory sleet
#

Yeah especially when searching

lost matrix
simple summit
#

actaully, hashmaps seem to cache too

ivory sleet
#

Yes

simple summit
#

so the first call is "slow" vs successive calls for the same key

ivory sleet
#

It’s backed by an array

simple summit
#

anyway, have the info i came for - thanks

ivory sleet
#

Well should be said, a K type with bad hashCode implementation leaves you at O(n)

#

but since it’s String/UUID

#

It’s not gonna be a bad K type

#

Hence why it’s fast and reliable (:

lost matrix
#

I think unloading/loading might not be the best way to restore a world.
Depending on the size it would probably produce less lag to just use FAWE api and a schematic for that.

simple summit
#

async world edit?

ivory sleet
#

Smiles workload distributor guide 😌

lost matrix
#

😄

#

Or if its for your own project then a Docker setup is also a consideration.

simple summit
#

and no, it takes milliseconds to "restore" several region files with an unload load

#

wtf is FAWE?

tardy delta
#

fast async worldedit

lost matrix
#

async world edit?

tardy delta
#

it sucks

ivory sleet
#

Yeah well Ross are you deleting the regions files themselves or what?

simple summit
#

yes

ivory sleet
#

Ah makes sense

simple summit
#

i delete then and restore them from a zip

lost matrix
ivory sleet
#

Fair, well anyhow conclusively getWorld is ya best bet if you wanna check whether a world is loaded or not

simple summit
#

it causes a long tick in the 80-150ms range, it's not ideal but doing it once an hour or so is good enough

lost matrix
ivory sleet
#

Also 1 nano second is equal to 0.001 milli second and is equal to 0.000001 second

simple summit
#

nope

#

milli micro nano

ivory sleet
#

Oh yeah

simple summit
#

you missed 1000x

lost matrix
#

Happens

ivory sleet
#

Then it’s even more negligible!

simple summit
#

that it does

#

milli micro nano peco fempto

lost matrix
#

pico

ivory sleet
#

Ross anyhow it’s good you prove our point that the map call is negligible (:

simple summit
#

but it's really not lol

ivory sleet
#

Literally is

#

Have you benchedmarked?

simple summit
#

and it's not the map so much as the string function calls

ivory sleet
#

wat

simple summit
#

look, you can't argue to me that a map call is faster than just using an object reference

ivory sleet
#

String::hashCode

simple summit
#

and to lower

ivory sleet
#

well, for IdentityHashMap then they may actually be equally fast

simple summit
#

but the world map is strings to worlds

#

anyway

ivory sleet
#

So?

lost matrix
#

You can do it several hundreds of thousands times in a single tick and wouldnt notice a difference.

simple summit
#

I'm not saying that the map is too slow for me to use

ivory sleet
#

So whats the issue then for getWorld?

simple summit
#

just that if there was some World::isLoaded i'd use it lol

ivory sleet
#

No that wouldn’t work

lost matrix
#

Btw detecting when a world is unloaded is quite the hassle

ivory sleet
#

Unless you create some super shady proxy adapter design

midnight shore
#

Hi again, how can i set the display name (above the head) of an EntityPlayer? (I'm trying to rename an NPC)

lilac dagger
#

would it be better to restore the chunk files in order to reset a world?

tardy delta
#

that goes brr

lilac dagger
#

i was thinking of creating an implementation for that

ivory sleet
#

Probably Freestyler

#

Altho it sounds quite dangerous

#

Unless you’re wiping all of them

simple summit
#

the nasty part is not corrupting shit

lilac dagger
#

yeah, all of them

simple summit
#

and not confusing clients in render range

midnight shore
lilac dagger
#

it's for a minigame

ivory sleet
lilac dagger
#

so the players won't be on the map

ivory sleet
#

If it’s about data management corruption is probably gonna be a pivot

simple summit
#

it's about taking stuff out of a zip and putting it in the world

#

for me anyway

ivory sleet
#

In your case yes

#

Yeah

lost matrix
#

Maybe this works

  public CompletableFuture<Void> unloadWorld(final String worldName, final boolean save) {
    Preconditions.checkArgument(Bukkit.getWorld(worldName) != null);
    Bukkit.unloadWorld(worldName, save);
    return CompletableFuture.runAsync(() -> {
      while (Bukkit.getWorld(worldName) != null) {
        try {
          Thread.sleep(100);
        } catch (final InterruptedException e) {
          e.printStackTrace();
        }
      }
    });
  }
dire marsh
#

what the fuck

#

that looks cursed

simple summit
#

or just listen for the WorldUnloadEvent event and wait a tick

tardy delta
#

final 😶

ivory sleet
#

I am not sure but maybe a PhantomReference/WeakReference of type World would be fine where you register the reference to a reference queue and then later callback

lost matrix
ivory sleet
#

Yeah, then it’s probably a rotten idea to do it like that

lost matrix
#

Hm the method above might not work as intended. I think you actually need to check the file handles on the world and if they are released.

ivory sleet
#

Yeah, should probably also use a custom thread pool to not slow the common pool down 😅

lost matrix
# midnight shore please

NMS is not part of the API. Its undocumented and if you use it you are on your own most of the time.
I would just look into other peoples plugins and see how they did it.

#

Or look at the protocol and reverse engineer how vanilla does it.

simple summit
#

Humm, could the session.lock file be watched... seems like the sort of thing it should exist for actually

tardy delta
#

there's probably a better way to rename an npc

#

just respawn it with another name?

ivory sleet
grim ice
tardy delta
#

public variables ew

ivory sleet
blazing scarab
#

That breaks encapsulation and turns objects into passive data bags

tardy delta
#

then normal people just create a getter

blazing scarab
ivory sleet
#

Lol

#

Ye

lost matrix
# simple summit Humm, could the `session.lock` file be watched... seems like the sort of thing i...

Might work like this. I dont think there is a better way to check if a File is locked.

  public CompletableFuture<Void> unloadWorld(final String worldName, final boolean save) {
    Preconditions.checkArgument(Bukkit.getWorld(worldName) != null);
    Bukkit.unloadWorld(worldName, save);
    final File worldFile = Objects.requireNonNull(Bukkit.getWorld(worldName)).getWorldFolder();
    return CompletableFuture.runAsync(() -> {
      while (this.isLocked(worldFile)) {
        this.busyWait(100);
      }
    }, Executors.newSingleThreadExecutor());
  }

  private void busyWait(final int millis) {
    try {
      Thread.sleep(millis);
    } catch (final InterruptedException e) {
      e.printStackTrace();
    }
  }

  private boolean isLocked(final File file) {
    if (file.isDirectory()) {
      final File[] children = file.listFiles();
      if (children == null) {
        return false;
      }
      for (final File child : children) {
        if (this.isLocked(child)) {
          return false;
        }
      }
      return true;
    } else {
      return file.canWrite();
    }
  }
ivory sleet
#

Well you could ask yourself who wrote some of the java classes

blazing scarab
#

Also pretty sure "out" is stateless, which is, eh, acceptable

ivory sleet
#

Is it?

grim ice
#

i mean

tardy delta
#

lol

grim ice
#

the opposite of final

ivory sleet
#

I mean generally speaking, any method that returns void must have a side effect in principle

grim ice
#

thats what i meant

blazing scarab
#

I think is uses some native implementation which is not shown to us

ivory sleet
#

Ah fair

blazing scarab
#

State doesnt means it has no side-effects, as said before, good objects should represents real life entity, the state object itself encapsulates is just real life entity coordinates

ivory sleet
#

Well, anything that is stateful generally has side effects, whilst stateless things do not.

blazing scarab
#

Oh wait

#

Yeah ur right

lost matrix
blazing scarab
#

I messed up definitions

ivory sleet
blazing scarab
#

Passive data bags!!! Sometimes useful ngl

ivory sleet
lost matrix
#

Shouldnt side effects be avoided everywhere? Stateful or not? Mabye we have a different understanding about what a side effect is...

ivory sleet
#

I think of side effect as a change to the system

#

Whatever that change might be

lost matrix
#

For me its an implicit change to the system

#

So a setter has no side effects for me. But a setter that also increments a counter does.

ivory sleet
#

Ah, well I from my point of view, a setter changes the state of the system, else it would be no point in calling it as it returns void

simple summit
#

CPP has a better construct for this discussion than java - there you define a method as const if it does not change any member state

#

aka is purely a calculation - or IIRC purely external side effects

lost matrix
#

I think java has annotations for that. Contracts and what not.

ivory sleet
blazing scarab
#

aka procedure

simple summit
#

I don't think java (stock) has a way to say this method doesn't change member state - but there's probably an annotation for it in some library... and hey the language keeps evolving

ivory sleet
#

And even Haskell has purely external side effects… pretty much unavoidable

lilac dagger
#

final does that @simple summit

simple summit
#

no it doesnt

lilac dagger
#

along with an immutable view of whatever you want

#

if you want the return itself to not change

simple summit
#

final on a method means you can't override it

#

not that the method can't change member state

tardy delta
#

on class that you cant extend it

lilac dagger
#

and reset it too

#

you can't file = newFile;

ivory sleet
#

Ross believe they meant for variables

#

In which it’s true unless you use sth like unsafe or reflection

full elbow
#

anyone know how to disable elytra?

simple summit
#

Anyway in the spirit of this discussion - avoid public static (non-final) things as a rule and use singletons VERY sparingly. Otherwise the best way to create robust extensible software is to follow a test-first practice (I prefer BDD myself). Testability of an implementation will really guild you to good encapsulation of concepts and motivate you to use more dependency injection instead of dependency creation (it's healthy to avoid newing complex things within your member initializers and constructors.

ivory sleet
#

I mean singletons won’t really destroy your testability

simple summit
# full elbow anyone know how to disable elytra?
    @EventHandler(ignoreCancelled = true)
    public void onEntityToggleGlideEvent(EntityToggleGlideEvent event) {
        if (!config.roofPreventElytra)
            return;

        if (!(event.getEntity() instanceof Player))
            return;

        final Player player = (Player)event.getEntity();
        if (player.getWorld().getEnvironment() == World.Environment.NETHER && player.getLocation().getBlockY() > 127) {
            event.setCancelled(true);
            player.setGliding(false);
            tellCantDoThatHere(player, "glide");
        }
    }
ivory sleet
#

I do both BDD and TDD

#

Sometimes even DDD

simple summit
#

singletons are cancer - they have their place but they are a pattern of last resort

ivory sleet
#

Nah

#

Sure it’s more of a procedural pattern to some extent

#

But really no

#

They are good

simple summit
#

it's the coupling they cause that is the problem

ivory sleet
#

Well

#

You can for one just pass the instance to the constructor

simple summit
#

you're much better off to have a singelton factory than 20 different singletons

#

that's all i mean

ivory sleet
#

Or if you need some sort of lazy init, a supplier that returns the singleton instance can be used

#

What

#

Where does factory come in play here xD

#

It’s not impossible to mock singletons either

simple summit
#

it allows you to break the coupling problem

ivory sleet
#

We have libraries and other stuff

#

There is no additional coupling problem if you design your system correctly

#

As said

#

You can still pass the instance through a constructor

#

Explicitly or with a Supplier

simple summit
#

lol, i don't disagree - it's just easier to fuck up your system design by overusing singletons than to use them with extreme caution

ivory sleet
#

Additionally, if you want to create abstractions, wrap the singleton with an adapter

#

Yeah Ross you’re right

#

I just don’t believe it couples your system

simple summit
#

I'm talking to a "new programmer" you're talking to me about an academic argument.

ivory sleet
#

At least not from my experience

#

Well, all things considered, new programmers usually don’t get the concept of tight coupling

simple summit
#

my point is you're not wrong and I don't disagree - just that new players will screw themselves with it

ivory sleet
#

Indeed

simple summit
#

anyway, back to code 😉

ivory sleet
vocal cloud
blazing scarab
#

mstbe that lazy init but i never had any usecases for such solution

brave sparrow
#

There's definitely valid uses for singletons

blazing scarab
#

for example?

buoyant viper
#

programs 😎

ivory sleet
#

Don’t know if it was well designed, but it was definitely the best choice of design in my case

hasty prawn
#

I still stand by using a Singleton for the plugin instance blushi_bonse

ivory sleet
#

That’s arguably fine

simple summit
#

I agree that singletons are not "necessary" - they are however "beneficial in some situations". Static state is always a coupling disaster waiting to happen.

ivory sleet
#

Altho JavaPlugin::getPlugin

hasty prawn
simple summit
#

they must be used with care

blazing scarab
simple summit
#

and not be the default "i'm lazy so i always use singletons" lol

#

a static utility class is not a singleton

blazing scarab
#

I use singletones as well for persistent daya types

ivory sleet
#

Ah fair

#

I mean all singleton says is that we should at compile time ensure only one instance exists, and it should have a global access point

simple summit
#

there's nothing bad about static helper methods - the contamination comes from mutable static state

blazing scarab
#

We know right

ivory sleet
#

I mean I consider static state doable sometimes, but mostly it fucks you up in multithreaded environments

simple summit
#

I'm clarifying for all readers - not just those active in this conversation 😉

grim ice
#

thats also why some people dont like singletons cuz like u have to type out ur class and method name every time

brave sparrow
grim ice
#

but cant u just

#

import static

brave sparrow
full elbow
#

wait what is the best website to code for beginner?

chrome beacon
#

Any website

#

Do what you want to

neon minnow
#

if i use Collection<Player> players.add(p) will go red, and just say unresolved reference

young knoll
#

Pass Bukkit.getOnlinePlayers to the constructor of an array list

neon minnow
#

I will try

young knoll
#

new ArrayList<>(Bukkit.getOnlinePlayers())

neon minnow
#

add is unresolved reference.

#

players.add(p)

young knoll
#

You don’t need a loop if you do that

wet breach
#

you could use addAll() if you are just going to add all the players

young knoll
#

I don’t see a new

wet breach
#
ArrayList<Player> players = new ArrayList<>();
players.addAll(Bukkit.getOnlinePlayers());

one way of doing it if you want your own array for all online players

young knoll
#

You can just use the arraylist constructor

wet breach
#

Think you could even do new ArrayList<>(Bukkit.getOnlinePlayers);

young knoll
#

Mhm

young knoll
wet breach
#

ArrayList<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers);

young knoll
#

No idea how to translate that to Kotlin though

#

I don’t use Kotlin

wet breach
young knoll
#

No idea

wet breach
#

like you I don't use Kotlin either

sullen dome
#

is there an easy way to create spawn egg recipes without creating one for every spawn egg?

#

as they are all different items

wet breach
#

probably could use an enum

#

place all the spawn egg items in said enum then you could easily apply the recipe regardless of which egg it is

young knoll
#

Yeah you could loop over a list of the spawn egg items and do it that way

wet breach
#

well with an enum wouldn't need to do any looping, just check which it is

young knoll
#

I think they want 1 recipe for each item

#

But don’t want to specify 50 recipes or whatever

wet breach
#

yeah, place all the eggs in a single enum

#

then it wouldn't matter which egg it is, just need to check that it is an egg of sorts

mortal hare
#

does anyone have issues with intellij

#

it spins up to 99% CPU usage

#

for no apparent reason

#

after a while

wet breach
#

this is what I am talking about, you can put more then a single value in one enum

#

Now what I don't know is if you could register a recipe just using one egg, might have to create your own methods for checking?

#

but with an enum, could easily still do it I suppose, technically would be registering multiple recipes but just more easily done instead of typing out every registration XD

young knoll
#

It should

#

I would use a set but yeah

midnight shore
#

Hi, i'm doing a trail with blocks and this blocks disappear after a few seconds. I tried getting the player location but that block is just in the middle of the player, so i tried subtracting to the location, but weirdly the block appeared up the player and not down

young knoll
#

Yes

#

Also that isn’t a valid config path you are using

#

Config paths can’t end with .

midnight shore
#

this is my code

young knoll
#

Set

#

HashSet to be specific

wet breach
#

positive values make it go up

#

subtracting or negative values make it go down

midnight shore
#

but i'm subtracting, not adding

young knoll
#

Subtracting 1 should be the block below the player

lost matrix
#

I need to write a text file with common responses...
You should not read a config while the server is running. Rather read it once the server starts or a player connects (if its player specific data)
and store the data in properly named variables. Configs are there for persistence. They do not exist to be abused as data objects.

young knoll
#

I mean

#

It’s basically just a map

wet breach
midnight shore
#

yes

lost matrix
young knoll
#

I always use map<String, Object>

#

Fields are for nerds

lost matrix
wet breach
# midnight shore yes

instead of using the getTo for the location, try getting the players current location instead. using event.getPlayer().getLocation()

midnight shore
#

okay

#

i'll try ty

wet breach
#

I only say try that, because some things with the events

#

they haven't quite happened yet

#

from appearance it shouldn't make a difference but you never know lol

lost matrix
wet breach
#

as they move

#

for some reason instead of the block going down using the subtract method it made it go up more?

lost matrix
#

add(0, 1, 0) gives the block above

young knoll
#

They are using subtract

lost matrix
#

Thats why i would use getRelative. Its more concise.

Block below = event.getTo().getBlock().getRelative(BlockFace.DOWN);
wet breach
#

That may work too

lost matrix
#

But i would heavily filter this event

brave sparrow
#

That’s not going to solve it if the subtract is returning the block above

#

That means the getTo is messed up somehow

#

Try setting that block with no offset and see what happens

wet breach
#

which is my theory

young knoll
#

Also I would use sendBlockChange

#

Don’t want people getting a ton of gold

lost matrix
# lost matrix But i would heavily filter this event
  public void onMove(final PlayerMoveEvent event) {
    final Location to = event.getTo();
    final Location from = event.getFrom();
    final int toX = to.getBlockX();
    final int toY = to.getBlockY();
    final int toZ = to.getBlockZ();
    final int fromX = from.getBlockX();
    final int fromY = from.getBlockY();
    final int fromZ = from.getBlockZ();
    final boolean blockPassed = toX != fromX || toY != fromY || toZ != fromZ;
    if (!blockPassed) {
      return;
    }
    // What happens if player goes from one block to another
  }
lost matrix
brave sparrow
#

We’re not there yet lol

#

They need to make it work before they can optimize it

midnight shore
wet breach
sullen dome
young knoll
#

They do with minecraft-heads

brave sparrow
#

Which block gets changed?

sullen dome
#

yea but that would be a kind of complicated thing

#

i just wanted to make eggs craftable with their heads lol

lost matrix
#
Block below = event.getTo().getBlock().getRelative(BlockFace.DOWN);

This has to work

brave sparrow
#

That’s the same as subtract

midnight shore
wet breach
#

well it could be how the event works, I don't have my IDE opened to look at the implementation

brave sparrow
#

Very interesting

brave sparrow
#

Also you’re not jumping or anything right?

midnight shore
brave sparrow
#

Ok so yeah print it out for us

#

Also what spigot version are you using

midnight shore
brave sparrow
#

Ok

#

This is so weird

lost matrix
#

getTo gets the location at the players feet

wet breach
brave sparrow
#

Lol

#

It makes no sense

wet breach
#

only scenario I can think of for that happening is somehow a negative is getting in there

lost matrix
brave sparrow
#

Nope

#

subtract(0, 1, 0)

#

It’s bizarre

lost matrix
#

What version is he using?

wet breach
#

1.17

lost matrix
#

Weird

wet breach
#

the only way I can see a positive doing that

#

is if they are subtracting from 0

brave sparrow
#

I just looked at the stash and there weren’t any changes

wet breach
#

that is if the player is already at 0

brave sparrow
#

What?

midnight shore
#

can someone come in vc?

#

please

brave sparrow
#

0-1=-1

#

Not 1

#

Lol

wet breach
# brave sparrow Not 1

I am aware of this, but if the server expects it to be positive at all times for y, this would cause some issues if it was absolutes

neon minnow
#

what is DANDELION_YELLOW for material.

#

cant find it

young knoll
#

YELLOW_DYE

#

I assume

neon minnow
#

ty

#

hm no

midnight shore
young knoll
#

Version?

neon minnow
#

1.8.8

brave sparrow
young knoll
#

Lol

midnight shore
#

something weird is happening

neon minnow
young knoll
#

INK_SAC with meta

#

Don't remember which number is yellow, good luck

neon minnow
midnight shore
#

the block gets placed and then it gets unplaced but for some reason also placed again

brave sparrow
midnight shore
wet breach
young knoll
brave sparrow
wet breach
#

I would have to look later at the server code though

lost matrix
#

It could be a problem with the objects that are being used. Do changes to the Location
retrieved by getTo reflect to the game state?

wet breach
#

but that is the only thing I can think of that would cause such a thing

#

I don't know of anything else that would

lost matrix
#

Mabye he just moves the player down

midnight shore
brave sparrow
#

You are

#

Here’s what’s happening

#

They move

#

You set it to gold and cache the old state to be reset after x time

#

Then they move again over the same block

#

You set it to gold and cache the old state, which is gold because you already set it

midnight shore
#

oohhh i see the point

brave sparrow
#

Then you have it reset at x+1

#

Now after x it goes back to stone or whatever

#

And after x+1 it’s gold

wet breach
#

since the location from the event is in relation to the player lol

midnight shore
#

how do i stop that from happening @brave sparrow ?

midnight shore
#

oh

#

my bad

#

ty

lost matrix
#

This still doesnt fix the issue with revisiting

brave sparrow
#

True

#

You’d need some sort of Set of blocks you’ve changed and haven’t reverted yet

midnight shore
#

my goodness all of this just for a dumb trail of gold blocks

lost matrix
#

Hm im cooking up something with a PriorityQueue...

#

Ok i stopped writing this. Way too spoon feedy. But this is actually not a trivial problem.

grim ice
#

Aw

#

wanted to see it

midnight shore
#

i'm trying using a hasmap

lost matrix
#

Some fragments:

  private final Map<Block, RevertableBlock> revertableBlockMap = new HashMap<>();
  private final PriorityQueue<RevertableBlock> revertableQueue = new PriorityQueue<>();

  ...
  @RequiredArgsConstructor
  private static class RevertableBlock implements Comparable<RevertableBlock> {
    private long lastVisit;
    private final BlockData originalData;

    @Override
    public int compareTo(@NotNull final SpigotSandbox.RevertableBlock other) {
      return (int) (other.lastVisit - this.lastVisit);
    }
  }

Then polling every tick until current time is reached. Revisiting -> edit timestamp then re-insertion into PrioQueue.

midnight shore
#

😖it doesn't work

tardy delta
#

i see weird stuff there

midnight shore
#

?

#

i got it working i think

#

just adding a check to see if the block is gold

tardy delta
#

im not really following what you are doing

mortal hare
#

and why it is not for example Deque used here

midnight shore
#

Done! it is working just pertect

ivory sleet
#

PriorityQueue is basically that every element has a priority associated to it dovidas

mortal hare
#

is it something similiar to tree

#

with levels

#

also

#

due to how its sorted

#

isnt it a slow

#

queue

#
// Java program to demonstrate the
// working of PriorityQueue
import java.util.*;
  
class PriorityQueueDemo {
    
      // Main Method
    public static void main(String args[])
    {
        // Creating empty priority queue
        PriorityQueue<Integer> pQueue = new PriorityQueue<Integer>();
  
        // Adding items to the pQueue using add()
        pQueue.add(10);
        pQueue.add(20);
        pQueue.add(15);
  
        // Printing the top element of PriorityQueue
        System.out.println(pQueue.peek());
  
        // Printing the top element and removing it
        // from the PriorityQueue container
        System.out.println(pQueue.poll());
  
        // Printing the top element again
        System.out.println(pQueue.peek());
    }
#

i found this example

#

output:

10
10
15
#

this means that it pulls values sorted by lowest values

young knoll
#

Surly you just need a simple FIFO queue?

mortal hare
#

nah, im just researching

#

I would've used Deque if i needed it

tardy delta
#
An unbounded priority queue based on a priority heap. The elements of the priority queue are ordered according to their natural ordering, or by a Comparator provided at queue construction time, depending on which constructor is used.```
mortal hare
#

i've just never seen this class in my life

#

an element with maximum ASCII value will have the highest priority.

#

maximum ASCII value is 255

tardy delta
#

theres a constructor where you can pass in a comparator

mortal hare
#

then why the it is printing lowest numbers instead

#

in the example

tardy delta
#

aah food on my keyboard

mortal hare
#

rip

tardy delta
#

why am i even eating here

mortal hare
#

its so weird

#

that highest priority values in PriorityQueue are not at the head of the Queue

tardy delta
#

i never used a queue 😳

#

is there some way to avoid this shit tho?

mortal hare
#

put the variable inside anonymous func

#

or create a new final variable

tardy delta
#

Variable 'user' is accessed from within inner class, needs to be final or effectively final

#

smh this sucks

eternal night
#

I mean, you would want to join the completable future if you need its value on the current thread

tardy delta
#

im in the async pre login event

eternal night
#

Well then join the completable future ?

tardy delta
#

lets wonder what that does

eternal night
#

it holds the current thread until the completable future is done

tardy delta
#

wew thats good to know

quiet ice
#

Or just use AtomicReference

eternal night
#

dunno how creative an atomic ref is if you need the value afterwards

quiet ice
#

I think you could use WeakRef too however pretty sure that that will get GC'ed, but under some circumstances it might be a better option than a full blown atomic ref

ivory sleet
#

Really depends on what FourteenBrush wants, if it’s to use the value instantly in coordination linearly to the snippet they are showing us a mere ::join might be sufficient, but yeah if he wants to store it in some reference non blocking definitely AtomicReference.

tardy delta
#

i want to load the user from the database and cache it after that

#

to log him in when the actually joins

#

i think thats better to do it in the playerjoin instead of asyncprelogin

young knoll
#

I load them in the asyncprelogin

#

Maybe I shouldn't since they can still be denied access

tardy delta
#

hmm

ivory sleet
#

FourteenBrush no

#

A dos attack could make the server crash if you used PJE

lavish hemlock
tardy delta
#

heh?

young knoll
ivory sleet
#

Assume a lot players are spam joining

tardy delta
#

ah that way

ivory sleet
#

(And leaving)

#

Yeah

young knoll
#

I assume disallowing the login event does not fire the quit event

lavish hemlock
#

Probably not

ivory sleet
#

Yeah probably not

lavish hemlock
#

Since quit likely happens when a player has joined already

young knoll
#

Hmm, does it fire any event?

tardy delta
#

but whats an alternative then conclure?

ivory sleet
#

iirc tho, disallowing the APPLE event won’t cancel execution of PLE or sth weird like that

#

I mean just load em in APPLE

tardy delta
#

now were talking about apples

young knoll
#

I load data in the APPLE

ivory sleet
#

Yaa

young knoll
#

But If they get disallowed in that event, the data will stick around

#

Since the data only gets unloaded in the PQE

tardy delta
#

this sounds weird going from dos attack to apples 🤡

lavish hemlock
ivory sleet
#

var dto = repository.getOrMake(event.getUniqueId())

storageInterface.loadUser(dto).join();

#

or sth

tardy delta
#

what would dto even be?

#

im loading them based on an uuid

ivory sleet
#

the user object from the cache

tardy delta
#

if they join they arent in cache yet

ivory sleet
#

Basically you have a cache object which is capable of creating objects on its own

#

Well the method would create a new user and put it into the map for the UUID given

wet breach
# tardy delta i think thats better to do it in the playerjoin instead of asyncprelogin

not sure why you are wanting to do it on the prelogin, I would recommend login event for getting DB stuff, but it depends what exactly the data is and what it is for. If the stuff in the DB isn't to be used right away but is just needed for some things, then use the join event. If you kind of need it right away then best to do it at the login event. In either case make sure your DB calls are done on another thread.

ivory sleet
#

and then return it

#

APPLE does not use the server thread frostalf

#

So assuming he is declaring a callback for APPLE, it should be fine

wet breach
#

don't know what apple is

young knoll
#

AsyncPlayerPreLoginEvent

ivory sleet
#

^

wet breach
#

Ah ok

young knoll
#
    public void loadUser(UUID uuid) {
        User user = loadUserData(uuid);

        this.userMap.put(uuid, user);

        Bukkit.getScheduler().runTask(this.plugin,
                () -> Bukkit.getPluginManager().callEvent(new UserLoadedEvent(user)));
    }
#

That's what I do

tardy delta
wet breach
#

in either case prelogin is a bit iffy for DB calls though, because a lot can happen where the player doesn't make it to the login event 😛

ivory sleet
neon minnow
#

How to set an item in inventory that is enchanted? thanks

ivory sleet
#

It’s just architectural layering at its finest to some extent

#

Let me give you a class of mine

young knoll
#

In my case I need to load the data that early, because I may disallow connection based on that data

#

I just need to make sure I somehow unload it if the player never makes it to the Join event and thus the Quit event doesn't get called

tardy delta
#

it depends on data or it wouldnt make sense to exist

wet breach
ivory sleet
#

FourteenBrush I see, it’s hard to explain but let me try

tardy delta
#

xd

young knoll
#

Wonder if an existing impl of that exists that expires every X seconds unless a condition is met

lavish hemlock
#

There's also Caffeine

#

Which is based off Guava afaik

wet breach
#

in is actually quite nice using it because you don't have to worry about it in the end if it isn't needed

#

the queue will take care of it once it expires 🙂

#

it expires when it isn't being used 😛

#

or you could have a pre-determined time to expire everything

lavish hemlock
#

If you just wanna check if the value is still be used

#

I'm pretty sure most caches support weak keys/values

wet breach
#

yeah in guava it has a method to get it again if it expired in the cache

young knoll
#

Yeah I want to expire if Bukkit.getPlayer(user.getUUID) == null

wet breach
#

you could easily make a runnable to do that

#

check the cache for any non-valid things and then force expire them

wet breach
#

but since the cache items will expire anyways at some point

tardy delta
#

to keep the cache up to date

wet breach
#

you could just simply let the cache mechanism handle it

young knoll
#

Ah crap some users may not actually be a player

#

That may be an issue

tardy delta
#

conclure do you mean that final fields in my case would be bad wo i better use setters to set stuff when loading the user

#

i better wont interrupt you typing the bible

lost matrix
#

Unless you specify a scheduled executor

ivory sleet
#

So usually we have certain classes which are serving the purpose of transferring data between two points (could be two methods, two classes or what not).

We then have a repository, or well a lookup map.

Thing is, in this situation we want to isolate the data transfer object itself from the repository. This is done by not letting the data transfer object know about the repository. However it is fine to let the repository know about data transfer objects, although make it minimal. For instance we could do sth like:

class UserRepo{
  final Map<UUID,User> map;
  final Function<UUID,User> factory;
  
  Optional getIfPresent(UUID id):
    yield ofNullable(map.get(id));

  User getOrCreate(UUID id):
    yield map.computeIfAbsent(id,factory);
}

class User {
  final UUID id;
  AtomicReference<UserSnapshot> ref;

  void set(UserSnapshot s):
    ref.set(s);

  UserSnapshot get():
    yield ref.get();

  void update(UnaryOperator op):
    ref.updateAndGet(op);
}
class UserSnapshot {
  final SomeData;
  final OtherData;

  UserSnapshot(
    SomeData someData,
    OtherData otherData
  )

  //one of these methods for OtherData also
  UserSnapshot setSomeData(SomeData d):
    yield new UserSnapshot(d,this.otherData)

  SomeData getSomeData():
    yield this.someData
}
#

In this case User objects are able to live without a direct data fetch from your database

#

However that has many benefits

#

For instance testability

#

And the fact that your user isn’t coupled to the persistence layer / storage

#

When you update userdata here, it’s done atomically using User::update

#

(UnaryOperator<T> is just a Function<T,T>)

#

Anyhow

#

Essentially you also have a database implementation maybe something like:


interface UserStorage {
  CompletableFuture<Void> load(User user);

  CF<Void> save(User user);
}```
#

CF - completablefuture just lazy

#

Now assuming you might have a class MySqlUserStorage implements UserStorage (to implement the proper load and save)

#

This way you can load any user object at any given point of time, which helps with a lot of things in terms of testability and scalability

young knoll
#

I think I just had a stack overflow reading all that

modest garnet
#

how do i get server tps as an int

tardy delta
#

my brain is hurting

young knoll
#

Is getTPS exposed yet?

ivory sleet
#

Maybe I should write a complete example FourteenBrush?

tardy delta
#

so i would save the actual data on the usersnapshot?

ivory sleet
#

Cache it is a better word

young knoll
ivory sleet
#

essentially yes tho

#

The UserSnapshot is an immutable data carrier which represents the user data at a given point of time, it’s very nice and thread safe

#

In this way we reduce the amount of mutations (by having as said, a snapshot which we delegate all the data responsibility to)

modest garnet
young knoll
#

NMS

#

Wonder if MD would allow TPS to be exposed

tardy delta
#

but when creating an user, it should have a snapshot or it wouldnt make sense to make a user if you cant request data on it?

ivory sleet
#

well, just instantiate a UserSnapshot and set it on the user?

young knoll
#

So a user may exist with no data

ivory sleet
#

Yeah I forgot the getter methods

#

My bad

elfin atlas
#

Does someone know how I can fix this error? (Protocollib)

com.comphenix.protocol.reflect.FieldAccessException: No field with type [I exists in class PacketPlayOutEntityDestroy.
        at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:365) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:345) ~[ProtocolLib.jar:?]
        at me.katze.av.utils.VirtualEntity.destory(VirtualEntity.java:77) ~[av-0.1.jar:?]
        at me.katze.av.utils.VirtualEntityManager$1.run(VirtualEntityManager.java:47) ~[av-0.1.jar:?]
        at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Paper-233]
        at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[patched_1.17.1.jar:git-Paper-233]
        at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1559) ~[patched_1.17.1.jar:git-Paper-233]
        at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:479) ~[patched_1.17.1.jar:git-Paper-233]
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1475) ~[patched_1.17.1.jar:git-Paper-233]
        at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1274) ~[patched_1.17.1.jar:git-Paper-233]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-233]
    public void destory(Player viewer) throws InvocationTargetException {
        PacketContainer packet = main.protocolManager.createPacket(PacketType.Play.Server.ENTITY_DESTROY);
        packet.getIntegerArrays().write(0, new int[] {this.entityId});
        main.protocolManager.sendServerPacket(viewer, packet);
    }
young knoll
#

So you mutate the users data

ivory sleet
#

In principle just the reference to the data snapshot

young knoll
#

So you make a new DataSnapshot when you update anything?

ivory sleet
#

Yep

tardy delta
#

but the Function<UUID,User> factory; might be something like User::new so when caching it for the first time, the snapshot will be null until the db completed to set it?

young knoll
#

That doesn't seem ideal if you are updating stuff often

young knoll
#

Lot of Object creation

ivory sleet
#

Jvm handles that relatively good

young knoll
#

Fair enough

tardy delta
#

i was just planning on doing stuff with getters and setters

ivory sleet
#

Like this scales a lot better generally than having a big dto with a lot of volatile fields, which means you need to implement atomically safe methods for all of the fields

young knoll
#

Technically my data is one field

ivory sleet
#

Ah

young knoll
#

Map<String Object>

ivory sleet
#

🥲

young knoll
#

It needed to be easy for addons to add new data to the user

ivory sleet
#

Maybe not the ideal case then, like a ConcurrentHashMap directly in the User could be fine

#

Ye

lost matrix
ivory sleet
#

Anyways FourteenBrush assuming you want to get some data then you could do sth like:
user.get().name();

And for changing the name:

user.get().name(newName);

And if you increment the points of a user:

user.update(oldSnapshot -> oldSnapshot.score(oldSnapshot.score()+1));
(Could probably write a nicer method to increment but everything here would be thread safe and atomically safe)

young knoll
#

I realized something annoying in java recently

#

parseInt cannot throw a NPE, but parseDouble can

ivory sleet
ivory sleet
young knoll
#

parseInt will just throw a NFE if the input string is null

tardy delta
#

oh god youre on phone

#

wrote that whole bible on phone

ivory sleet
#

Lol ye

young knoll
#

parseDouble will throw a NPE if the input string is null

ivory sleet
#

Interesting inconsistency

tardy delta
ivory sleet
#

Yeah, ofc you could go with classic setters and getters, but it’s just that you’ll run into some pretty devastating issues when the plugin scales

young knoll
#

Just never add any new features

#

problem solved

ivory sleet
#

🥲

young knoll
#

This is why I still use Java 1

ivory sleet
#

Let’s remove JDK from JDK

tardy delta
#

is that even something jdk1

young knoll
#

No idea

ornate heart
#

When you do PlayerInventory#getContents does that include their armor?

tardy delta
#

well thanks for helping me somewhat further tho 🙉

modest garnet
#

how do you get a BukkitRunnable to stop repeating

tardy delta
#

.cancel()

ivory sleet
#

TechLewi you basically call cancel() inside run, or if you reference the BukkitTask object, invoke/call cancel() on that.

young knoll
#

I can find JDK 1.1 on oracles site

#

No 1.0

lost matrix
#

Or get its id and tell Bukkit to stop the task with that id

modest garnet
young knoll
#

Oof

#

Some kind of listener on the logger?

modest garnet
#

because i dont want to dive into NMS yet and i need to get the server TPS, an alternative is to run the /tps command in console and get the response

young knoll
#

That is even more janky IMO

modest garnet
#

lol

undone axleBOT
lost matrix
ivory sleet
#

TechLewi not sure exactly

young knoll
#

I can PR a double[] getTps

ivory sleet
#

Like there are some ways of doing it

young knoll
#

But IDK if MD would accept it

ivory sleet
#

Though, none are perfect

young knoll
#

wait hold up

#

Nope, no getTPS in server.spigot either

modest garnet
#

well i can get the double of tps with
MinecraftServer.getServer().recentTPS however when converted to a string it gives me [D@73601f1d

young knoll
#

It's an array

#

TPS from last 1m, 5m, and 15m by default

lost matrix
#
@RequiredArgsConstructor
public class ScrapingCommandSender implements CommandSender {
  
  private final Consumer<String> messageConsumer;
  
  @Override
  public void sendMessage(@NotNull final String message) {
    this.messageConsumer.accept(message);
  }
  ... and a ton more

Then something like

    Bukkit.dispatchCommand(new ScrapingCommandSender(System.out::println), "/help");
young knoll
#

Huh

#

Less janky than expected

lost matrix
#
    Bukkit.dispatchCommand(new ScrapingCommandSender(msg -> doSomething(msg)), "/help");
modest garnet
#

hmm

young knoll
#

Although you still gotta parse the string output

#

And then worry about servers with different outputs

lost matrix
#

This can be used for example if you have a plugin that has a toplist in chat but no hologram support.
Just fill a hologram with the chat response ^^

#

Used this way back when i still used plugins from other people 😛

modest garnet
#

lol, i appreciate that however i think i just found a way by mistake lol

shy wolf
#

how to get the view in InventoryMoveItemEvent?

young knoll
#

there isn't one

#

That event is for hoppers

shy wolf
#

what

#

why

#

the

#

any way

#

than what is the event for move item for inv

young knoll
#

Click

#

InventoryClickEvent is generally the answer for anything to do with items in inventories

shy wolf
#

ok thanks

terse ore
#

How do I make an itemStack by an itemMeta?

jagged thicket
#

@earnest gyro

#

can u see this

young knoll
lost matrix
pearl bloom
#

Hello, I've been googling now for absolute ages. If someone could help me out with an issue, I'd be soo grateful.

young knoll
#

Oh BY an itemMeta

#

Yeah that isn't really possible

undone axleBOT
#

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

pearl bloom
#
NamespacedKey randomKey = new NamespacedKey(this,"ieyyyysssds");
        ShapedRecipe randomRecipe = new ShapedRecipe(randomKey, Items.getJoint());
        randomRecipe.shape(" P "," D ","LLL");
        randomRecipe.setIngredient('P', Material.PAPER);
        randomRecipe.setIngredient('D', Material.DIAMOND);
        randomRecipe.setIngredient('L', Material.LEATHER);
        Bukkit.addRecipe(randomRecipe);    

What is possibly wrong here

lost matrix
pearl bloom
#

Since I can't craft it 😄 (Spigot 1.16.4 btw)

lost matrix
#

Show the whole code and a screenshot of the crafting table pls. This looks fine to me.

pearl bloom
terse ore
#

?scheduling

undone axleBOT
pearl bloom
#

Idk what code part you want, the Items.getJoint()?

lost matrix
pearl bloom
young knoll
#

Iron ingot != paper

pearl bloom
#

My bad 😄

#

I can spawn the getJoint by command, so there should be no issues there

lost matrix
#

Show the method where you register the recipe in

pearl bloom
#

I've literally just thrown it into onEnable rn 😄

lost matrix
# pearl bloom

Hm. Does your plugin come up as green when you type /pl ?

pearl bloom
#

Yeah, a lot of other stuff I've written in the same Core plugin works. It's just this part

lost matrix
pearl bloom
#

Nope

lost matrix
#

Add a debug message after each recipe and check if its displayed in the console pls.

pearl bloom
#

The furnace recipe works

lost matrix
#

Add a debug message after each recipe and check if its displayed in the console pls.

pearl bloom
#

It's in the onEnable() Ofcourse it will show 😄

lost matrix
pearl bloom
lost matrix
#

And you are sure that you joint your local server?

pearl bloom
#

Yeah 😛

lost matrix
#

And no exception is being thrown at any time?

blazing scarab
#

Damn drug propaganda in minecraft

pearl bloom
#

None

#

So it's not just me being crazy xD

#

I've done thousands of recipes, now all of sudden it's not working. Super weird

lost matrix
pearl bloom
#

BuildTools

pearl bloom
lost matrix
#

I have no idea... Lets throw some random fixes at it.
Register the recipes 4 ticks later.

  @Override
  public void onEnable() {
    Bukkit.getScheduler().runTaskLater(this, () -> {
      // Register recipes here
    }, 4L);

  }
pearl bloom
#

Alright, Ima just test to run the server with only my plugin

lost matrix
lost matrix
pearl bloom
#

I am 😛

#

Now I'm removing the dependencies for my plugin

#

Still nada

#

Ill try to delay it

#

Delaying it didn't help either

lost matrix
pearl bloom
#

Alright, booting up. Let's see what it says 😄

#

o.O

lost matrix
#

Let me guess. Now it works.

pearl bloom
#

No

lost matrix
#

So...

pearl bloom
#

But it realises the recipe is there o.O

lost matrix
#

Either the result is null or another listener sets the result to null

young knoll
#

Or the result is air or has a stack size of 0

#

Or something weird

heavy temple
#

?scheduler

young knoll
#

?scheduling

undone axleBOT
heavy temple
#

Oh thns

#

Thnks

pearl bloom
#

Sure, u want the ItemStack?

tardy delta
#

@ivory sleet would it make any sense to replace an entire usersnapshot instead of using the getters and setters?

lost matrix
pearl bloom
#

I actually already tried what you're suggesting. I changed to a vanilla item instead of a custom

ivory sleet
#

Imo yes fourteen brush

lost matrix
#

*If recipe is not null

pearl bloom
tardy delta
#

ah on an user object creation

pearl bloom
#

Wow that was a tiny picture xD But the result is the actual Itemstack

lost matrix
# pearl bloom

Well then another listener is tempering with the PrepareItemCraftEvent

pearl bloom
#

Wdym?
Why would it be?

lost matrix
#

Set the result to null or something... no idea why-

#

Maybe recipes with permissions.

#

Are you op?

pearl bloom
#

Yeah

lost matrix
#

🤷

pearl bloom
#

I really appriciate the help atleast 😄

#

I've gotten a bit closer to the issue 😛

quaint mantle
#

Hi, how do i update plugin from 1.17.1 to 1.18? thanks

tardy delta
#

just change the version of your spigot dependency

pearl bloom
#

Anyone else wanna have a go why this doesn't work? :3

spiral light
#

did you test if the recipe exist and gets it shape and so on from the api after adding it

quaint mantle
tardy delta
#

using maven?

quaint mantle
#

yeah

pearl bloom
tardy delta
#

change the version in your pom and reload it

quaint mantle
#

ok thanks

spiral light
#

maybe its changing but not vissible or its changing but get deleted directly

pearl bloom
#

Interesting idea. I'll try it

mortal hare
#

do bukkit itemmeta objects use NBTTags internally?

pearl bloom
#

Nothing is literally changing ;-;

#

There is noo way... This is NOT working 😄

mortal hare
#

private NBTTagCompound blockData;

#

Yes it does

#

its a wrapper

#

i made nbt serializer for ItemStacks

#

its more user friendly than using yaml tags

blazing scarab
mortal hare
#

There's literally constructor

#

pointing to NBTTagCompound object

blazing scarab
#

Well, it stores the nbt. However, modification method like setLore does not touch the tag

blazing scarab
mortal hare
#
    @Overridden
    int applyHash() {
        int hash = 3;
        hash = 61 * hash + (hasDisplayName() ? this.displayName.hashCode() : 0);
        hash = 61 * hash + (hasLocalizedName() ? this.locName.hashCode() : 0);
        hash = 61 * hash + ((lore != null) ? this.lore.hashCode() : 0);
        hash = 61 * hash + (hasCustomModelData() ? this.customModelData.hashCode() : 0);
        hash = 61 * hash + (hasBlockData() ? this.blockData.hashCode() : 0);
        hash = 61 * hash + (hasEnchants() ? this.enchantments.hashCode() : 0);
        hash = 61 * hash + (hasRepairCost() ? this.repairCost : 0);
        hash = 61 * hash + unhandledTags.hashCode();
        hash = 61 * hash + (!persistentDataContainer.isEmpty() ? persistentDataContainer.hashCode() : 0);
        hash = 61 * hash + hideFlag;
        hash = 61 * hash + (isUnbreakable() ? 1231 : 1237);
        hash = 61 * hash + (hasDamage() ? this.damage : 0);
        hash = 61 * hash + (hasAttributeModifiers() ? this.attributeModifiers.hashCode() : 0);
        hash = 61 * hash + version;
        return hash;
    }
#

wtf is this

#

it seems like metadata version flag or some sorts?

lavish hemlock
#
  1. The fuck is Overridden
#
  1. That looks like a strangely-named hashCode
burnt raven
#

i am using lombok to simplify my development process and i the SLF4J logger in lombok is not outputting anything to the console, is there a way i can attach lomboks logger to the server console's one

lavish hemlock
#

Well the server logger uses Log4j, not SLF4J.

#

You'd probably need to import the SLF4J binding.

burnt raven
#

how?

#

also does this post relate?

lavish hemlock
#

I assume that would work.

burnt raven
#

ill try it

lavish hemlock
#

It's probably trying to call a method from a newer version of Log4j

#

(We don't support 1.8 anymore btw)

burnt raven
#

um

#

ok, but what version of the binding should i use then

chrome beacon
#

The one that 1.8 has

#

Which one that is idk

burnt raven
#

case in point

lavish hemlock
#

They use this version of Log4j

blazing scarab
#

lombok moment

burnt raven
#

so what version of the binding do i need

tardy delta
#

hey @ivory sleet would i do my caching stuff in the userrepo class too?

blazing scarab
#

How does your user repo looks like?

burnt raven
#

2.0?

lavish hemlock
ivory sleet
#

repo/lookup/caching manager/glorified map whatever you call it

tardy delta
#

ah okay

#

thanks 💗

ivory sleet
young knoll
#

I like Glorified Map

burnt raven
#

@lavish hemlock it doesnt error out but it says it failed to load class still

lavish hemlock
#

Hmm shit

tardy delta
#

i think my current cache interface isnt enough

blazing scarab
#

czn u give a link

burnt raven
#

wait @lavish hemlock the scope was just set to test, it initialized now and i get this error:

java.lang.NoSuchMethodError: 'org.apache.logging.log4j.Logger org.apache.logging.log4j.spi.LoggerContext.getLogger(java.lang.String)'
#

but the method exists

org.apache.logging.log4j.spi.LoggerContext.getLogger(String name)
#

@ivory sleet

modest garnet
#

how can i get an bit of code to sleep for x milliseconds

tardy delta
#

run it on another thread and call Thread.sleep(millis) on it maybe?

blazing scarab
modest garnet
#

hmm um well i have a bukkitRunnable which repeats every 5s but if tps is less than 15 then the runnable will cancel and the server will restart broadcasting at custom intervals?

modest garnet
frozen socket
#

Can anyone explain to me how to do queries or edit multiple regions at a time with worldguard/worldedit?

tardy delta
#

BukkitRunnable run task timer (1, 20 *5) probably

blazing scarab
#

what are you trying to do

wheat compass
#

I'm asking here because I can't really search the forums for it easily. (keyword function will talk about java functions instead of datapacks)

I'm making a simple plugin that has a custom command to run the vanilla /function command to run a datapack function
I know this isn't the best way to do things, but I'm low on time so I'm just adapting the datapack. Is it possible to do this? If so, it feels like it would be a single line of code solution.
Sorry if this is bothering

solid lion
#

I need some help if anyone wouldnt mind

so i rewrote all my code to one of my plugins and now when i toggle it, it always says [Plugin] Toggled "on" (it doesnt toggle off) also it doesnt do what its supposed to do (its and autosmelt plugin so it wont smelt the blocks just drops the ore naturally) all other commands work as intended. ALSO ive ran debug messages for each block and it is identifying the blocks correctly without error, just not smelting as intended

young knoll
tardy delta
#

isnt /function vanilla so you cant override the behaviour?

wheat compass
#

I want vanilla behavior

young knoll
#

They don't want to

wheat compass
#

Just need some way to call it within a plug-in. Thanks

young knoll
#

Ah that isn't even it

modest garnet
# blazing scarab what are you trying to do

its an autorestart plugin where when tps is lower than a certian amount it will restart the server, which you can set broadcast intervals about restart in a config, but i need to sleep the code or something or just get it to wait for next broadcast interval

blazing scarab
#

Use bukkit scheduler

young knoll
blazing scarab
#

Sadly there's no datapack api present at the moment

heavy temple
#

Who speak spanish?

modest garnet
lavish hemlock
blazing scarab
#

yes

modest garnet
#

oh ok

heavy temple
#

Oh raios

#

Xd

tardy delta
heavy temple
tardy delta
#

damn i know spanish

#

por favor

#

idk what that means

heavy temple
#

Pero si puedes entender más cuando alguien te escribe más texto mucho mejor

tardy delta
#

ah yes yes english only

modest garnet
# blazing scarab yes

wait so i would create a scheduler within a runnable and another runnable in the scheduler

tardy delta
#

you dont create it

#

?scheduling

undone axleBOT
heavy temple
tardy delta
#

ah

burnt raven
heavy temple
#

I can understand a little that speak here but i have only basic english level

chrome beacon
burnt raven
# chrome beacon Why don't you use your plugins logger?

well im using a utility i made that makes my plugin more optimized and i use lombok for logging in that util, and i need to port the plugin logger config into the lombok logger config so it doesnt look like your logging a logger

modest garnet
heavy temple
#

How I can connect the Twitch API that to send message when a streamer is on a live?

hybrid spoke
#

the api will tell you

earnest gyro
#

oh finally

#

i can see this channel

#

Hey guys, i'd like to ask something

Im trying to make a plugin which allows you to see your last 5 kills in sword lore.
The problem after 5 kills it stops registering kills in sword lore. (Thats because 5 line is allowed)
How can fix this? Where should i start?

young knoll
#

Delete the oldest one

earnest gyro
#

well i have think about that but i couldnt make it properly

#

Can you point me where should i look at for this?

young knoll
#

I would keep the last 5 names in the PDC and then modify that first, then use that to update the lore

#

That way you can remember which lore lines need to be changed

earnest gyro
#

i meant it as a link but thank you so much ur help

#

and your time

#

have a nice day/nightr

velvet dragon
#
[Server thread/ERROR]: Could not load 'plugins\mcPlugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: No public constructor

Im getting this error and im not quite sure why.

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

class Base extends JavaPlugin {

    public Base(){}
    
    @Override
    public void onEnable() {
        Bukkit.getLogger().info(ChatColor.AQUA + "onEnable" + this.getName());
    }

    @Override
    public void onDisable() {
        Bukkit.getLogger().info(ChatColor.AQUA + "onDisable" + this.getName());
    }
}```
This is all i have so far with my plugin.yml like this
```yml
name: JansFirstPlugIn
version: 0.1
author: MrUnkn0wn
main: Base

and this as my project strukture

#

nevermind cant send screenshots :x

#

forgive me if this is a stupid problem its my first time creating a plugin

earnest gyro
#

i guess "main: Base" this is the problem

velvet dragon
#

i thought so too but when i changed it it instead told me that it cant find the class

earnest gyro
#

you should use the whole class name

velvet dragon
#

so as far as i can tell it is finding the class atm

earnest gyro
#

then you should add the class name at the end