#help-development

1 messages · Page 1610 of 1

grim ice
#

Oh well

#

i read all w3school thing about java

#

its not enough apparently

#

they didnt even have constructors did they

#

1s imma check

chrome beacon
#

Well you always keep learning

grim ice
#

well i hope i can learn the basic stuff at once so i dont get screamed at here everyday for not knowing java

queen niche
#

https://0bin.net/paste/FhdkRJt5#mchwLCG+ytgoggNSR9QlwXuN05g7Y7dp8VbjhTRlj4a

LOG:
[20:24:42 INFO]: Checked if the sender is a commandblock
[20:24:42 INFO]: checked if the command is /attractie
[20:24:42 INFO]: whatever line 25 does

It seems like it stops at line 27.

the temp at level 27 is greyed out. dont know if that could be it, idk it is since its just a translator.

high pewter
#

I have a Discord bot running on Bungeecord but I want to listen for the player entering certain areas on one of the servers. I know there's a way for Bungeecord to send messages to Spigot and recieve feedback, but I don't want to spam requests asking for each players' location constantly. Is it possible for Spigot to instead send Bungeecord a message and I can use a PlayerMoveEvent to do all the processing on that side before messaging Bungeecord? Or can Bungeecord intercept the packets to find the player's location from them? All I can think of is using a file or database that Bungeecord listens to which Spigot writes to whenever it needs to send a message but that sounds messy

chrome beacon
high pewter
#

I was looking at a few pages on that but as far as I can tell, it's only one-way

chrome beacon
queen niche
#

https://0bin.net/paste/FhdkRJt5#mchwLCG+ytgoggNSR9QlwXuN05g7Y7dp8VbjhTRlj4a

LOG:
[20:24:42 INFO]: Checked if the sender is a commandblock
[20:24:42 INFO]: checked if the command is /attractie
[20:24:42 INFO]: whatever line 25 does

It seems like it stops at line 27.

the temp at level 27 is greyed out. dont know if that could be it, idk it is since its just a translator.

queen niche
hasty prawn
#

Are you supplying all the arguments in the command block? You need 6 of them.

queen niche
#

No, some only use the first 3 some only the first 4 etc

hasty prawn
#

You have to supply 6, you're not checking for the argument length.

queen niche
#

It works like this : /attraction warpname attractionname.

hasty prawn
#

Or replace "args[1] + args[2] + args[3] + args[4] +args[5]" in the TextComponent with temp

#

Considering you're not even using temp. I imagine that's what it's supposed to be for.

queen niche
#

Ah okay. It was first supposed to be used for a broadcasts message since I based it off a broadcast plug-in tutorial. But I can try that!

manic bison
#

i added the method but when trying to call it I get this error:
Cannot make a static reference to the non-static method teleportBypassed(Player, Location) from the type CommandTuto
with the code
CommandTuto.teleportBypassed(player, one)

so i tried doing
new CommandTuto().teleportBypassed(player, one);
outputs no error but doesnt't work in game

chrome beacon
#

I recommend learning some Java basics before starting with Spigot

manic bison
#

i know javascript alredy

#

i'm trying to learn directly to code with spigot

tacit drift
#

Inventory#addItem adds the item to the first empty slot that it finds?

quaint mantle
#

javascript has nothing to do with java

minor garnet
#

borat

tacit drift
#

InventoryDragEvent responds when clicking items in an inventory too?

quaint mantle
#

only when you place down an item into a slot

tacit drift
#

oh ok

fierce swan
#

This is probably a really basic question but which library would you guys recommend for JSON storage? I tried Jackson but found I couldn't save an ArrayList of my User objects despite following multiple examples to the dot. I've tried GSON before but had troubles with it, although that might just be because I was unexperienced at the time. Any recommendations?

quaint mantle
#

oh

#

well still, its really easy

#

i can help

fierce swan
#

I'll give it another shot and if I have any troubles I'll be sure to ask

#

Thanks

quaint mantle
#

np

atomic sierra
quaint mantle
#

what isnt working

#

i think Gson is probably the easiest

#

personal preference tbh

ivory sleet
#

Simplejson BES_Clown

minor garnet
#
 public float y = 0;
    public void update() {
        Bukkit.broadcastMessage("value :" + y);
}```

the value return me 0.0;
```java
    GunManagement.recoil.values().removeIf(value -> value.y < 0);
        }
    }``` but is removing if is 0 why ?
ivory sleet
#

Cuz that floating point might have lost some precision

quaint mantle
#

use double

minor garnet
#

i need float..

quaint mantle
#

why?

minor garnet
#

nms

quaint mantle
#

you can cast it back to float

minor garnet
#

nah

#

so how i can remove if value < 0 ?

quaint mantle
ivory sleet
#

Vinny use BigDecimal

#

And then convert to float when u need to

main dew
#
@EventHandler
    public void click(PlayerInteractEvent e) {
        Bukkit.getScheduler().runTaskAsynchronously(Main.plugin, () -> {
            ResultSet resultSet = //SQL QUERY
            if (resultSet.next()) {
                //do something
                e.setCancelled(true);
            }
        });
    }```
#

as e.setCancel (true) is in runTaskAsynchronously not working
how I can fix this

quaint mantle
#

running db queries on the interact event duke

#

setCancelled doesn't work because the event is already over

#

you are scheduling a task

#

the task will run later

#

the task will be run sometime in the future, and the event, by that time, will have already finished

main dew
quaint mantle
#

by not trying to do db queries in the interact event

main dew
#

so many query?

#

don't worry before I check Material

main dew
hasty prawn
#

That's how you fix it, don't query inside the interact event.

tacit drift
#

how do i replace an item in a inventory

#

i forgot

opal juniper
#

replace?

#

so what at a certain index?

tacit drift
#

so i get a clicked item in a inventory

#

and i want to replace it

#

do i need to #setItem(item-slot,replacement-Item) ?

opal juniper
#

Yup

tacit drift
#

and do i need to update the inventory or something?

opal juniper
#

nope

#

it does it all auto-magically

granite wasp
#

im a bad dev, im not sure exactly what the problem is, but im trying to launch players, and my code isnt working

tacit drift
#

send it here

#

lol

granite wasp
#

ive checked around a few areas, and it shows the same thing

#
@EventHandler
    public void OnBlockBreak(BlockBreakEvent event) {
        int min = 1;
        int max = 5;
        Player player = event.getPlayer();
        World world = player.getWorld();
        Location location = player.getLocation();
        location.add(0, 1, 0);
        player.teleport(location);
        player.setVelocity(new Vector((int) Math.floor(Math.random() * (max - min + 1) + min), (int) Math.floor(Math.random() * (max - min + 1) + min), (int) Math.floor(Math.random() * (max - min + 1) + min)));
    }
tacit drift
#

any errors?

granite wasp
#

nope

#

just doesnt send the player anywhere

#

trying to make it launch a player when they break something as a challenge for me and my friends

opal juniper
#

does it teleport them?

granite wasp
#

nope

opal juniper
#

Is the listener registered

granite wasp
#

thats what i tried adding, in case they needed previous velocity in order to change it

granite wasp
opal juniper
#

try doing player.teleport(location.add(0, 1, 0));

granite wasp
#

theres one more thing ill try in a bit, if you have any ideas though, id like to try them first

opal juniper
#

i forget whether location is mutable

granite wasp
tacit drift
#

oh nvm

maiden cape
#

What does DragonBattle#respawnCrystals do?

quaint mantle
#

Hey there! I need some help with an error. I am working on a furniture system using itemframes to hold an items and optionally armorstands for seats.

#

This worked pretty well until I refactored by code, and I don't understand why it broke

#

This is my error

#

It only occurs when I place a furniture with a seat (so with an itemframe AND an armorstand)

iron condor
#

Is there a way to "auto complete" a command for player from an event? (ex: interaction event types for the player a predefined text in the chat ready for him to press enter to send it)?

quaint mantle
#

here is what the code looks like

maiden cape
#

What event is fired when you punch an ender crystal?

quaint mantle
#

punch thing event

#

Probably EntityDamageByEntityEvent

high pewter
#

I have a Discord bot running on Bungeecord but I want to listen for the player entering certain areas on one of the servers. I know there's a way for Bungeecord to send messages to Spigot and recieve feedback, but I don't want to spam requests asking for each players' location constantly. Is it possible for Spigot to instead send Bungeecord a message and I can use a PlayerMoveEvent to do all the processing on that side before messaging Bungeecord? Or can Bungeecord intercept the packets to find the player's location from them? All I can think of is using a file or database that Bungeecord listens to which Spigot writes to whenever it needs to send a message but that sounds messy

quaint mantle
#

both having the server push updates to bungee and having bungee intercept the move packets are possible

#

but the former is probably the easier to implement

high pewter
#

Ah awesome! I have no idea how intercepting packets is done in Bungee or how to work with them, though, so do you know of a good tutorial or wiki page for this?

quaint mantle
#

i'd go with the pushing updates from the backend to the proxy rather than doing that

high pewter
#

Oh wait former not latter, sorry I misunderstood

quaint mantle
#

there are bukkit tutorials for sending the plugin messages i'm sure

high pewter
#

Someone on another server just found me a good thread about it so I think I understand how to do that now. Thanks!

granite wasp
#

anyone know how to kill all entities that are dropped on the ground through a plugin?

#

like the way /e kill@e[type=item] does

quaint mantle
#

why do you want to do that

#

you aren't making another bootleg clearlag are you

#

borat send me a spgiot sql tutorial

#

easy one

#

implying one exists

#

dumbified one

#

i don't know any tbh

#

ping elgar and ask him to spoonfeed you

proud basin
#

o:

quaint mantle
#

Gotta love how all the examples are sync

#

what does it mean when my resting heart rate is 200

#

thats why im not using that tutorial

#

i dont trust

quaint mantle
#

that doesn't seem healthy

digital plinth
#

call 911 now

#

lul

quaint mantle
#

it uses a connection pool and prepared statements

#

it looks 'fine' at a glance

#

and does mention that you probably want to do the queries asynchronously

ivory sleet
#

That wiki is actually decent

#

And it also redirects to some async shit if you want that iirc

quaint mantle
#

oK

#

tf

#

Ok

granite wasp
#

im not getting clearlagg lol

shadow gazelle
#

How can I refresh tab for every player?

#

Or just hide NPCs from tab?

granite wasp
#

i feel bad for doing this, i just want to know what would make this not so laggy

#

lol

#
 @EventHandler
    public void onHit(EntityDamageEvent event) {
        int min1 = 1;
        int max1 = 5;
        Player player1 = (Player) event.getEntity();
        Location location = player1.getLocation();
        location.add(0, 1, 0);
        player1.teleport(location);
        player1.setVelocity(new Vector((int) Math.floor(Math.random() * (max1 - min1 + 1) + min1), (int) Math.floor(Math.random() * (max1 - min1 + 1) + min1), (int) Math.floor(Math.random() * (max1 - min1 + 1) + min1)));
    }
}
fierce swan
# quaint mantle i can help

I've gotten all the way to the point where I need to deserialize it. Serializing it works just fine but deserialization is kicking my butt lol
For some reason when I'm deserializing this ArrayList of my sign objects, it's erroring saying com.google.gson.JsonSyntaxException: duplicate key: null despite my json being seemingly perfectly fine:

[
  {
    "uuid": "f5ee70fb-aeec-41d6-8cf2-219f51d1bbc7",
    "lines": {
      "jp": [ "", "", "", "" ],
      "en": [ "", "1", "", "" ],
      "de": [ "", "", "", "" ],
      "es": [ "", "2", "", "" ]
    },
    "loc": {
      "world": "a491aaa7-6aff-42e4-856f-7c67b1343ce6",
      "x": 100016.0,
      "y": 5.0,
      "z": 99992.0,
      "yaw": 0.0,
      "pitch": 0.0
    }
  }
]

This json was made by gson.toJson() so I'm not sure why it's having trouble reading it. I don't think it's anything to do with my deserializer because even if I change it still has the same error.

fierce swan
#

The thing is too that it says the error is on the line ArrayList<LangSign> signs = gson.fromJson(reader, new TypeToken<ArrayList<LangSign>>(){}.getType()); and not in any of my deserializers

shadow gazelle
#

I tried connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, npc)); which I found on the forums, but it removes the skins

#

Put it in the wrong function 🤦‍♂️

fierce swan
#

Oop

shadow gazelle
#

And it still shows them in tab

quaint mantle
fierce swan
fierce swan
quaint mantle
#

gson serializes it reflectively

shadow gazelle
#

This is annoying

#

How do I remove NPCs from tab?

#

Everything I've found about it on the forums does something like removing the skin

#

Or is from 1.8 nms

lean gull
#

anyone know why i can only use integers in playSound?

#

player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 1, 1.5); has a red line under it in IntelliJ

#

not under the player.playSound doe

#

and the semi colon

lean gull
#

to the person that just said something, i have you blocked so don't bother msging on this topic

#

(i'm floofsy btw)

quaint mantle
#

isnt this the asshole who rejected everyone's help like 3 weeks ago

shadow gazelle
#

This is so annoying

#

Has anyone used NMS with NPCs before?

#

I'm trying to remove them from tab, but the NPCs are Steve and Alex when they're removed from tab

torpid zinc
#

Hey does anyone know the maven repo for com.sk89q.worldedit.bukkit.selections.Selection ? I added worldedit-bukkit in my pom.xml, it fixed all import beside this one

lost matrix
#

You can just call runTaskLater with incremented time

shadow gazelle
#

So a tab plugin should hide them?

lost matrix
#

There is a trick with packets to make them not show in the tab list. But in most cases its just easier to let them be shown for 1 tick.

dusk flicker
#

^ quick note; TAB is open source so you don't have to pay for it

lost matrix
#

Thats basically it. Filling the tablist with filler profiles.

quaint mantle
#

it would help the dev though

lost matrix
#

Back then i made a nice API for myself so i can dynamically change every column/row in a tab list ^^

shadow gazelle
#

How does Citizens do NPCs and keep them from showing up in tab if you basically can't do it with NMS?

dusk flicker
#

Might be packets

lost matrix
#

There are several packets that get sent when a player joins. You can instantiate a Player entity without it being added to the tab list. This requires a separate packet.

shadow gazelle
#

Bruh

#

What's that packet called?

lost matrix
shadow gazelle
#

Okay, that I can work with

lost matrix
#

Wait. Player Info has to be sent before spawn player can be sent or the client doesnt spawn the player thonk

shadow gazelle
#

Wait

#

What

lost matrix
#

Maybe a second player info packet is sent right after the first one while containing this property:

#

player info -> add
spawn player
player info -> remove

#

Not sure if the client accepts them in one tick

shadow gazelle
#

Wouldn't be surprised, these are the same people that decided the client should handle flight while on a server

waxen locust
#

Sorry for interrupting, but is there anything i need to use specifically to store data in spigot?
like would a .txt file be fine or should i go for a .yml file? also do I need a specific additional library for interacting with .yml files?

lost matrix
waxen locust
#

alr tysm!

lost matrix
waxen locust
#

ah ok

#

would i need any other libraries or can i just read yml similarly to txt files wait nvm i just saw config library ill check that out

lost matrix
#

Heck how do i get an instance of WorldServer in 1.17 ? Any quick hint?

shadow gazelle
lost matrix
#

Ah nvm got it.

lost matrix
#

Spawned NPCs without them showing in the tab list

#
  private void spawnNPC(final Location location) {
    final MinecraftServer minecraftServer = ((CraftServer) this.getServer()).getServer();
    final WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
    final GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "Bob");

    final EntityPlayer entityPlayer = new EntityPlayer(minecraftServer, worldServer, gameProfile);
    entityPlayer.setLocation(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw());

    final PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.a, entityPlayer);
    final PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
    final PacketPlayOutPlayerInfo playerInfoPacketHide = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.e, entityPlayer);

    Bukkit.getOnlinePlayers().forEach(player -> {
      final PlayerConnection connection = ((CraftPlayer) player).getHandle().b;
      connection.sendPacket(playerInfoPacket);
      connection.sendPacket(spawnPacket);
      connection.sendPacket(playerInfoPacketHide);
    });
  }
shadow gazelle
#

Bruh

#

Thanks

quaint mantle
#

you always have an example

lost matrix
quaint mantle
#

off the rip???

lost matrix
#

^^

quaint mantle
#

two spaces?

lost matrix
#

Yes 2 spaces. i want more code on my screen. i would be fine with 4 spaces but if you use tabs then im out.

quaint mantle
#

nobody uses tabs anymore

lost matrix
#

I would really like to update my lib to 1.17 but im just not satisfied with the whole mapping approach. And writing code with the obf jar (like above) is just too much of a hustle.

#

All i need is ProtocolLib because i have no idea how to properly inject my own packet handler into netty. So i just wrote to the dev of plib and asked him if
he could make it run in a mapped environment XD
This way i can just run my server with the moj mapped jar and also dev with it.

shadow gazelle
lost matrix
shadow gazelle
#

1.17 go brr

quaint mantle
#
private final @Getter String legacyName;
private @Getter final String legacyName;
lost matrix
#

Ew

#

How about you annotate like everyone else?

quaint mantle
#

@Getter private final

#
@Getter
private final String legacyName;
lost matrix
#

Above the field... like a sane person

quaint mantle
#
@Override
public @NotNull String getCommandForPlayers() {
@Override
@NotNull
public String getCommandForPlayers() {
lost matrix
#

Hm...

#

For me both look fine

quaint mantle
#

ew

#

1st ftw

lost matrix
#

With the second you would have more space for argument annotations ^^

#

But the first one looks good

young ore
shadow gazelle
#

2013, yikes

lost matrix
shadow gazelle
#

When you start Fabric with your Forge mods

shadow gazelle
lost matrix
#

Block is an interface. Be more specific pls.

shadow gazelle
#

I almost just want to just make my itemshop a command then have it get run by a Citizens NPC on right click at this point

lost matrix
#

Citizens is utter trash

shadow gazelle
#

It would at least do what I want

lost matrix
#

You mean a block variable? Because that depends not on the class but the state. Is it final?

#

Then you can just redeclare the variable. Doesnt matter if its a Block or a Server or a SpaceShip variable.

#

You can redeclare a String or a Player variable...

#

You can redeclare all non final variables. Doesnt matter whats in them.

shadow gazelle
#

Onto things that are actually possible with what I already have, I have a config and I want to get the first key under categories in it so I can access everything in it, what should I use to do that?

itemshop:
    mainsize: 27
    stuff:
    categories:
        blocks:
            stuff:
        weapons:
            stuff:
lost matrix
#

The path would be itemshop.categories.blocks

shadow gazelle
#

But if the user was able to change it?

#

I guess a more foolproof way to do it would to use numbers instead of names like that

shadow gazelle
#

Then how can I get the first thing there?

lost matrix
#
    ConfigurationSection section = configuration.getConfigurationSection("itemshop.categories");
    Set<String> categories = section.getKeys(false);
    for (String category : categories) {
      
    }
shadow gazelle
#

But I don't want look through the categories because that I want separate GUIs for every category

#

Wait

lost matrix
#
    final ConfigurationSection section = configuration.getConfigurationSection("itemshop.categories");
    final Set<String> categories = section.getKeys(false);
    for (final String category : categories) {
      ConfigurationSection stuffSection = section.getConfigurationSection(category + ".stuff");
      
    }
shadow gazelle
#

I might be brain dead from trying to figure out the NPC tab stuff

#

I can't wrap my head around how that would work with separate inventories rn lol

lost matrix
#

Do you want to have one Inventory for each entry under "categories"?
So in your example: One inv "blocks" with the content being "blocks.stuff" and one inv "weapons" with the contents being "weapons.stuff"?

shadow gazelle
#

Yeah

#

I'd also still have to be able to call that inventory to open it

lost matrix
#
  public Map<String, Inventory> loadInventories(final YamlConfiguration configuration) {
    final Map<String, Inventory> inventoryMap = new HashMap<>();
    final int inventorySize = configuration.getInt("itemshop.mainsize");

    final ConfigurationSection categorySection = configuration.getConfigurationSection("itemshop.categories");

    if (categorySection == null) {
      return inventoryMap;
    }

    final Set<String> categories = categorySection.getKeys(false);
    for (final String category : categories) {
      final String inventoryName = categorySection.getString(category + ".name");
      final List<String> content = categorySection.getStringList(category + ".stuff");
      final List<Material> materials = new ArrayList<>();
      for (final String entry : content) {
        materials.add(Material.getMaterial(entry));
      }
      final Inventory inventory;
      if (inventoryName == null) {
        inventory = Bukkit.createInventory(null, inventorySize);
      } else {
        inventory = Bukkit.createInventory(null, inventorySize, inventoryName);
      }

      for (final Material material : materials) {
        inventory.addItem(new ItemStack(material));
      }

      inventoryMap.put(category, inventory);
    }
    return inventoryMap;
  }

This will load a Map<String, Inventory> out of the following structure:

itemshop:
    mainsize: 27
    stuff:
    categories:
        blocks:
            name: "Block stuff"
            stuff:
            - STONE
            - IRON_ORE
        weapons:
            name: "Weapon stuff"
            stuff:
            - DIAMOND_SWORD
            - IRON_AXE
#

Where the key is the category.
So blocks and weapons in this example

shadow gazelle
#

Ohh

#

I'm going to finish the shop tomorrow, I'm afraid I'm going to screw something obvious up rn lol

lean gull
lean gull
#

it does not

#

there's nothing about different pitches in there, just how to use the pitch

lost matrix
#

Take a good look at the argument types

lean gull
#

yeah so it's float

lost matrix
#

What types qualify for usage in float variables?

lean gull
#

numbers

lost matrix
#

No

lean gull
#

wait it's integers?

lost matrix
#

Thats one

lean gull
#

is float just a type of integer

lost matrix
#

Nope

lean gull
#

then it's a type of number

lost matrix
#

Yes

lean gull
#

ok so why isn't it working

lost matrix
#

But not all numbers are the same

lean gull
#

what do you mean

lost matrix
lean gull
#

1.5 is a float

lost matrix
#

No

lean gull
#

how so

lost matrix
#

That is one of the first things you learn normally...

float x = 0.15F;
double y = 0.15D;
double z = 0.15;

short a = 100;
int b = 100;
long c = 100L;

Floats are 32 bit numbers. Same goes for ints.
Doubles and Longs are 64 bit numbers.

You can put a 32 bit number in a 64 bit field but not vice versa because 64 is too big to fit into a 32 bit field.

In java if you dont append an F to your floating point number then it defaults to being a double.

lean gull
#

i understood none of that

#

but what i did understand is that i have to put an F after it

lost matrix
#

Thats at least something...

unkempt peak
#

Learn. Java.

lean gull
#

be. gone.

unkempt peak
#

Why do you try to code plugins without basic Java knowledge

lean gull
#

simple: it's fun this way

unkempt peak
#

Your never going to get anywhere without learning the basics of Java first

lean gull
#

of course i will

unkempt peak
#

Well don't waste people's time for simple Java questions if you aren't willing to learn the essentials

lean gull
#

there are many ways of learning, i'm not gonna stop asking because you disagree with one

#

now if you're gonna be mean again, d o n ' t

unkempt peak
#

Ok please at the very least watch a beginner tutorial video on YouTube before you continue, I am not asking you to take an entire java course but please, for your sake and everyone else's just watch a couple vidoes.

lean gull
#

i have

shadow gazelle
#

I think I'll make a forums post tomorrow and see if anyone can help with the NPC in tab issue

shadow gazelle
#

With keeping skins

#

Just removing the NPC gets rid of the skin

#

Every forums post I've seen is either some obscure thing that hasn't existed since 1.8 or removing them, which doesn't work with 1.16 or something

lost matrix
#

Other than filling the tab list with placeholders

patent horizon
lost matrix
patent horizon
#

hmm intellij bullied me for using that earlier

shadow gazelle
hasty prawn
#

What are you trying to do Elephant?

lost matrix
hasty prawn
#

I managed to make NPCs so whatever you're doing is probably possible.

lost matrix
shadow gazelle
lost matrix
hasty prawn
#

Oh

#

Just a sec

lost matrix
patent horizon
#

EntityInteractEvent

#

i'm using action to check when an entity steps on a pressure plate

lost matrix
hasty prawn
#

@shadow gazelle put PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, <npc entity>) in a runTaskLater.

#

Mine has it set to run 15 ticks after

shadow gazelle
#

:thonk:

#

And that works for you?

patent horizon
hasty prawn
#

Minecraft has some arbitrary rule where they have to be in tab for a little before you can remove them

lost matrix
patent horizon
#

is there any way i can check if an entity steps on a certain block or pressure plate

shadow gazelle
#

The brains of Mojang devs

hasty prawn
lost matrix
hasty prawn
#

They HAVE to be in tab when they're spawned, that's why even on Hypixel you can see them in tab for a second before they're removed.

#

If you remove it immediately everything goes wrong 😂

shadow gazelle
#

I tried like two seconds and it still yeeted their skins

lost matrix
hasty prawn
#

Hm, mine is on 1.16.4 so something could've changed in 1.17 I suppose

lost matrix
hasty prawn
#

How are you spawning it

lost matrix
#

Just made a quick mock up for elephant earlier.

  private void spawnNPC(final Location location) {
    final MinecraftServer minecraftServer = ((CraftServer) this.getServer()).getServer();
    final WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
    final GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "Bob");

    final EntityPlayer entityPlayer = new EntityPlayer(minecraftServer, worldServer, gameProfile);
    entityPlayer.setLocation(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw());

    final PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.a, entityPlayer);
    final PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
    final PacketPlayOutPlayerInfo playerInfoPacketHide = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.e, entityPlayer);

    Bukkit.getOnlinePlayers().forEach(player -> {
      final PlayerConnection connection = ((CraftPlayer) player).getHandle().b;
      connection.sendPacket(playerInfoPacket);
      connection.sendPacket(spawnPacket);
      connection.sendPacket(playerInfoPacketHide); // Ill try delaying this
    });
  }
shadow gazelle
#

That's pretty much what I had

hasty prawn
#

You're not even setting the skin 🤔

shadow gazelle
#

Ignoring that the packets were in another function

#

And the skin and whatever

hasty prawn
#

I request the skin properties from Mojang and apply them to the GameProfile

shadow gazelle
#

Me too

#

And when the server stops/starts they're pulled from a yml

#

then loadNPC runs and set the skin and whatever

#

then sends packets with another function

hasty prawn
#

How are you setting the skin

#

Wait does the skin work if you don't remove them from tab

shadow gazelle
#

It does work

shadow gazelle
hasty prawn
#

Yeah if it works before you remove them from tab that should be fine

#

Lemme convert mine to 1.17 and see if it still works

shadow gazelle
#

I'm using 1.16

hasty prawn
#

oh

#

Can you send where you remove them from tab

shadow gazelle
#

It was right after the NPC packets were and it was spawned

#

I gtg, I'll tell you if it works or not tmr

hasty prawn
#

Okay.

hasty prawn
#

I actually listen for PacketPlayOutNamedEntitySpawn, check if the ID is an NPC, and then send the InfoPackets

#

I listen for the spawn packet because if you leave the range of the NPC, and it despawns, you have to manually re-spawn it when they're close enough

#

So I just let the server manage that for me and then do the tab stuff whenever the client gets sent an NPC

lost matrix
#

Removing the player 1 sec later works for me

hasty prawn
#

Yeah it's just some weird quirk with Player entities ¯_(ツ)_/¯

lost matrix
#

Wont happen to me because i usually just fill the tab list with profiles and mirror real players in when they join.

hasty prawn
#

Well yeah that's one way to do it I guess LOL

lost matrix
#

Ofc i wont name them "index x" but have some icons etc in there XD

hasty prawn
#

Those textures are cool

lost matrix
#

Thx 😄

hasty prawn
#

:D

hasty prawn
# lost matrix

Also gonna ping @shadow gazelle for this so you can see it when you come back, delay should fix your issue.

lost matrix
#

You can actually do some really cool stuff when you are able to generate the resourcepack with a plugin and hook into that

hasty prawn
#

Yeah that's super cool

#

If only it didn't take 7 years for resource packs to load

lost matrix
#

:/

hasty prawn
#

Doesn't Bedrock just natively support custom models and such?

lost matrix
#

Idk but it has quite a bit of data driven models. Especially custom textured entities.

hasty prawn
#

Not sure, all I know is that when you go onto a Bedrock server they do things Java couldn't even dream of

lost matrix
#

All i want is:
Adding custom mob models
Adding more blocks
Adding new gui schemes

Then we'll be able to do everything that forge does.

hasty prawn
#

Yeah adding Items/Blocks with custom Textues and Models would be absolutely amazing

lost matrix
#

I mean you can do items already

#

But not with custom durability...

hasty prawn
#

Well, without the help of a resource pack I mean

#

Being able to send the client all the information about a custom item

lost matrix
#

How should the client get the textures then?

#

Ah.

hasty prawn
#

Just send it to them when they connect

lost matrix
#

But thats basically what resourcepacks do...

shadow gazelle
lost matrix
#

You can force a user to accept a resourcepack

hasty prawn
#

Just wish it was more seamless

lost matrix
#

Yeah

hasty prawn
#

The loading screen for resource packs is so intrusive

paper viper
#

its cause there are like 5 year old kids prolly and mojang doesnt want any sketchy stuff

#

that they want to see

#

but yea i personally dislike how you have to go through the menu and options too

#

its a hassle

hasty prawn
#

Don't you have to accept the resource pack like everytime too

paper viper
#

even like sending custom sounds is a pain in the ass

paper viper
#

you can set it to auto

hasty prawn
#

Yeah but the user has to do that

paper viper
#

well yea

hasty prawn
#

Such a pain

paper viper
#

ofc

lost matrix
hasty prawn
#

And isn't it per-server?

paper viper
#

are OGG's more compressed than mp3?

lost matrix
#

texture and sound streaming would be nice to have

paper viper
#

in terms of storage

shadow gazelle
lost matrix
paper viper
#

yeah

shadow gazelle
hasty prawn
#

They do seem to be good at that

paper viper
#

OGG provides super well tho actually with low kilobits per second

#

in fact the quality actually seems to better than mp3 for lower kilobits

lost matrix
#

Still feels like a lot

shadow gazelle
#

@lost matrix are you just manually setting IntelliJ as an activity in Discord activity settings?

lost matrix
#

No i have a plugin that does it for me

#

Is it broken?

shadow gazelle
#

Seems to be

#

I've only ever seen the crap one I had before, doing that

lost matrix
#

Updated it

shadow gazelle
#

There you go

quaint mantle
merry kindle
#

Hey, if i wanted to do something like minehut what would be the best way to store server data?

lost matrix
#

With file system mounts

#

Wait minehut is this thing where you can just get a server for free right?

merry kindle
#

Yeah you can get a server for free and pay to upgrade it

lost matrix
#

Ah. They probably use some sort of container framework

high pewter
#

What plugin channel should I use for sending messages from Spigot/Paper/Tuinity to BungeeCord/Waterfall? When Googing, I see several places saying you have to use "Bungeecord", others saying "Bungeecord:main", others saying "bungeecord:main" and others saying to use a custom one, and I don't really understand what it means ngl. I tried a custom one but got an error saying it must contain a colon so not sure if I just put ":main" after that too, or if I go with the Bungeecord one, or if there's a different one I need to use if using a fork of Bungeecord or something

lost matrix
high pewter
#

So it doesn't really matter, as long as there's a colon?

#

God damn it it's gotta be lowercase too lol

#

Ok, you have to register it too, but I can only find how to register it for BungeeCord and listening on Spigot for some reason. How do I register a channel to send on with the Spigot end?

quaint mantle
#

hey im bad at math im sorry for asking this

#

how do i check if a number would be divisible by 10

#

im overthinking it

#

im just trying to check to see when i can actually give the player some money when they level up exp

#

okay

#

thank you

#

sorry

#

i thought it was something like that, to make sure it equaled 0

#

LOL

#

idk

#

i just overthink math a ton

ionic reef
#

How would I get all the chunks between 2 locations (basically like inside a region)

quaint mantle
#

i know how to see if blocks are within certain points

#

idk about chunks but i can send you the boolean for stuff

#

the boolean i use atleast, that works

ionic reef
#

i need all of the chunks that are inside of the of the area

quaint mantle
#

ahhh

ionic reef
#

as i then need to go through them to look for certain types of blocks (As ChunkSnapshots so i can run it async)

high pewter
#

I've got my code to not give errors but the proxy doesn't seem to be receiving Spigot's messages. My proxy is receiving messages intended for other plugins but I'm printing the tag and definitely none of them are the ones my plugin is sending. Here's the code for the plugin installed on the Spigot server. Any ideas why it's not working? https://paste.helpch.at/ruwabihedo.java

dense goblet
ionic reef
#

so i think i get steps 1 & 2
it would look smth like this

int minX = minLoc.getBlockX() >> 4;
int maxX = maxLoc.getBlockX() >> 4;

int minZ = minLoc.getBlockZ() >> 4;
int maxZ = minLoc.getBlockZ() >> 4;
#

wt would the loop look like

#

i get the idea of it for going through locations (like each block in an area) but not a full chunk

echo basalt
ionic reef
#

would it be like

for (int x = minX; x < maxX; x++) {
  for (int z = minZ; x < maxZ; z++) {
      // i have a chunk
  }
}
echo basalt
#

Don't add 16

#

You're looping through chunk coordinates

ionic reef
#

oh

#

OH

#

lmao

#

so would just be x++ correct?

echo basalt
#

Yes

ionic reef
#

right yeah i think that makes sense

echo basalt
#

Make sure that getChunk uses chunk coordinates

#

And you're set

ionic reef
#

awesome, tysm

#

yeah that makes more sense now haha

echo basalt
#

Also z++ on the second line

ionic reef
#

oops

#

tysm tho

echo basalt
#

No worries

dense goblet
#

It rounds towards zero

#

Whereas bitshifting truncates

#

It's dumb but yea

dense goblet
#

Then array[x-minX][z-minZ] = getChunkSnapshot(x,z);

echo basalt
#

He might not be doing a world generator

dense goblet
#

Actually the loop is not right, it should be <=

ionic reef
dense goblet
#

The array is just to efficiently store and access the chunk snapshots

ionic reef
#
for (int x = minX; x <= maxX; x++) {
                for (int z = minZ; z <= maxZ; z++) {
                    ChunkSnapshot snapshot = i.getWorld().getChunkAt(x, z).getChunkSnapshot();

                }
            }
#

thats what im doing

#

i dont need to store them

#

just need to process them then move on

dense goblet
#

Ah ok

#

Sure

#

What type of processing are you doing

ionic reef
#

tysm for all the help btw

dense goblet
#

sure thing :)

ionic reef
#

checking how many blocks of a certain type are in the chunk

#

which ill be doing async

dense goblet
#

Ah cool

ionic reef
#

which is why im getting the chunksnapshots

dense goblet
#

Yea that's good

ionic reef
#

yea thought that would b the best way

dense goblet
#

I think using streams would make it faster than a normal loop over each block

#

Since they can easily do it parallel

ionic reef
#

hmm yeah possibly. i dont have much experience w/ streams so what would that kinda look like

dense goblet
#

It's really simple

ionic reef
#

oh oof- i really need to look into them

dense goblet
#

Though the ChunkSnapshot doesn't seem to give you access to the full array of blocks hmm

#

It's probably possible to use streams anyway to call getBlockType(x,y,z) in parallel

ionic reef
#

yeah that might b best

#

now how do i umm.... make a parallel stream :P

dense goblet
#

Streams are parallel automatically

chrome beacon
#

No?

dense goblet
#

You just need to make sort of a converter so that the stream knows how to iterate (or ig spliterate?) over a chunk snapshot

#

Thought they are

chrome beacon
#

Only parallel streams are parallel

#

Oh and streams are slightly slower but make for cleaner code

dense goblet
#

Doesn't java figure it out by itself

#

Like if I do someArray.stream().xyz() it would do it in parallel

chrome beacon
#

No that will be done sync

dense goblet
#

How would I do it parallel then

chrome beacon
#

It will do things parallel if you tell it to be a parallel stream

dense goblet
#

ik .forEach() is done in parallel since it causes errors if you're not careful

#

So I thought same would be for .stream()

ionic reef
#

Will look into that

#

tysm

dense goblet
#

As for parallel streams Olivo knows better

chrome beacon
dense goblet
chrome beacon
dense goblet
#

Ofc that's kind of a useless example but the point is the stream didn't read from the place it writes

#

So .forEach didnt work where a normal for loop did

#

Doesn't that imply it is parallel

#

At least in modern versions of java

chrome beacon
#

The .forEach uses the collections Iterator to simply go through all values

dense goblet
#

Then it should be equivalent to a for loop and not cause errors where a for loop doesn't

#

But, at least in Java 16, that wasn't the case

ionic reef
#

also another question, for when im looping through the x, y & z (am going to do that just for now until i have time to properly learn how to use strings). Should I be doing x << 4 to convert it back to a normal coordinate which I can then input into snapshot.getBlockData(x,y,z);

dense goblet
#

x & 0b1111

#

Though actually nah

#

In your case you don't need to bit mask cause you're not gonna be using the same coords

#

Your x and z variables are chunk coords

#

You need another triple loop for local coords

high pewter
ionic reef
#

as rn i dont think i have any clear way of getting them for the specific chunk

dense goblet
#

They're just in range 0-15 or, for Y, 0-255 (keep the Y min/max as a variable since world height can be higher in 1.17+)

#

But there is a problem

#

Since you want to only loop the blocks between your 2 corners

#

It's easier to handle if you store the snapshots in an array

chrome beacon
ionic reef
dense goblet
#

Then after generating the array you exit the double loop for chunks and start a triple loop for x,y,z between your global min/max corners.

#

use a 2D array

#

new ChunkSnapshot[maxChunkX-minChunkX][maxChunkZ-minChunkZ];

ionic reef
dense goblet
#

If you scroll up I gave the code to store the snapshots in the array

ionic reef
#

So like, with all the snapshots in a list, you then loop through all of the local cords, between the min and max variables from much earlier, get the corresponding chunk snapshot and then I have the x y &z to check it?

dense goblet
#

Nah they wouldn't be in a list

ionic reef
dense goblet
#

Yes

ionic reef
high pewter
dense goblet
#

So when you go through the block coordinates you can just bitshift the x,z and subtract the minimum chunk coordinate to get the position in the array that the chunk snapshot is in

#

e.g. if your minimum chunk X is 100 and the block's coordinate is 1624 then your chunk snapshot's x index will be 101-100 = 1

#

So it's at array[1][?]

#

And then the local coordinate is x & 0b1111

#

Which would be 8

ionic reef
#

That is extremely over my head Rn xD

hybrid spoke
#

whats the topic

ionic reef
#

If it’s not too much to ask could you write out some code/pseudo code with comments or smth

dense goblet
#

Counting blocks in a volume

#

I'm on phone rn but I'll try

#

So you know how to populate the chunk array?

ionic reef
#

I don’t want to get spoon fed code but I think if I have some finished code/semi-finished code I can try to understand it

hybrid spoke
#

and for what do you need a 2D array here?

#

if you just wanna count the blocks?

dense goblet
#

Storing the ChunkSnapshots

ionic reef
dense goblet
#

You could do it without

#

But it's easier and more readable and pretty much just as efficient to store in an array and then count blocks

hybrid spoke
#

for what do you want to safe the ChunkSnapshot? to keep it in cache?

dense goblet
#

So we can do the block coordinate loop outside of the chunk loop

#

You could get the chunk and count all the blocks but it's more complicated to figure out the start and x local coords

#

Say if your volume starts halfway through a chunk

#

And intersects 3*3 chunks

#

It's easier if you do the block loop after getting all chunks rather than figuring out where in a chunk to start and end at

#

Since you can do:

  1. Loop through chunk coordinates and populate snapshot array
  2. Loop through all coordinates in the volume and count blocks using the snapshots
chrome beacon
dense goblet
#

Rather than
Loop through chunk coordinates
--Get appropriate snapshot
--Figure out where the volume starts/ends in the chunk's local coordinates
--Loop through all coordinates in said sub-volume

high pewter
# chrome beacon And where are you registering the channel

I tried getProxy().registerChannel("stockblockjda.node"); in the onEnable() but it made no difference. afaik you only have to register the channel in Bungee if you're sending to that channel, not for listening to it, both because I can't find any method for registering a channel to listen to and because I'm receiving plugin messages from other plugins despite no registering them so why would I need to register my own

chrome beacon
high pewter
#

Oh sorry I meant a colon, I typed it manually on Discord

#

I used a colon in my actual code

dense goblet
#

@ionic reef pseudocode is:

figure out min/max chunk coords
declare chunk array of size [maxChunkX-minChunkX+1][maxChunkZ-minChunkZ+1]
//chunks loop (double for loop)
for each chunk coordinate between min and max X/Z inclusive:
    chunks[chunkX-minX][chunkZ-minZ] = getChunkSnapshot();

//blocks loop (triple for loop)
for each block coordinate in your volume:
    chunkX = x >> 4
    chunkZ = z >> 4
    localX = x & 0b1111
    localZ = z & 0b1111
    blockType = chunks[chunkX-minX][chunkZ-minZ].getBlockType(localX, y, localZ)
    //do your counting logic here
ionic reef
#

Hmm right

dense goblet
#

Let me know if you don't understand parts of it

ionic reef
#

The first bit I don’t quite understand (defining array & size of it and also what the chunkX-minX (& z) are

#

But everything after the // triple for loop i think understand

#

So yeah pretty much all of the first part I dont quite get (sorry!) but everything after the // triple loop I think I’m good with

dense goblet
#

so chunks[0] corresponds to chunk x=100 and chunks[3] corresponds to chunk x=103

#

I fixed the pseudocode now

#

Then the reason you do chunks[chunkX-minX] is because at the first chunk (chunkX=100) you would be doing chunks[100-100] = chunks[0]

#

And at the last chunk (chunkX=103) you'd be doing chunks[103-100] = chunks[3]

ionic reef
#

Right, and chunkX is the x variable in my for loops which gets the chunk snapshots right?

dense goblet
#

Yea

#

I also fixed an error in the bottom loop

#

Since it also needs to account for the array being "shifted" by the minimum coordinates

ionic reef
#

Oh right ty

dense goblet
#

Idk if it makes any more sense now

ionic reef
#

That does yeah

dense goblet
#

Nice :D

ionic reef
#

Am still a tincy bit confused on actually making the array

#

As I looked up 2D arrays and it seemed a bit odd

dense goblet
#

Have you used arrays before

ionic reef
#

Arrays yeah, not 2D tho

dense goblet
#

If an array is like a list of things then a 2d array is a grid of things

#

To make it you just do the same thing as a 1D array but add another []

ionic reef
#

Oh right that makes sense

dense goblet
#

So for a 3x4 array you'd do ChunkSnapshot[][] chunks = new ChunkSnapshot[3][4]

ionic reef
#

Wt is the maxChunkX variable tho, is that the bit-shifted boundingBox.getMaxLocation().getBlockX() that I did earlier

dense goblet
#

Yep

ionic reef
#

Oh perfect

#

Yeah I think I understand it now

dense goblet
#

Give it a go

ionic reef
#

U cool if I friend you in case I have any issues tomorrow?

dense goblet
#

Yea sure

ionic reef
#

Awesome, tysm man, I’ve learned a heap today haha

#

This kinda thing it outside of the usual plugins I make

dense goblet
#

Glad I could help :)

ionic reef
#

:D

summer scroll
#

How can you get EntityArmorStand object using their id?

grim ice
#

cant u use a persistent data container

#

or smth

#

to like store an id in it

summer scroll
#

It's a client side entity or nms.

#

When the entity is spawned, they will have a unique id, and I already have the ID, and I just need to get the EntityArmorStand object from the id.

dense goblet
summer scroll
dense goblet
#

What is it

summer scroll
#

int

dense goblet
#

Huh how do you get it

#

Is it your own thing?

summer scroll
#

its from nms

dense goblet
#

Oh then I don't know

#

I thought nms uses UUIDs

summer scroll
#

even if its use UUID, I can't get the entity using Bukkit.getEntity

#

because the server doesn't even know if the entity exist on the server

dense goblet
#

Can you store the references

summer scroll
#

Sure I can, but I want it to support multiple versions, so I can't really do that.

dense goblet
#

If it's a client side entity it doesn't persist between restarts right

#

Or even between the client relogging or unloading chunks

summer scroll
#

Yeah it doesn't persist, and I don't need it to be persist.

grim ice
#

anyone has ideas for a plugin

dense goblet
#

Btw I'm on train internet so apologies in advance

#

Where do the version problems come into play

summer scroll
#

I'm just gonna store the reference for now I guess.

summer scroll
eternal oxide
#

Then it only exists on the client and the ID is only known to the client and the code that spawned it.

#

If you restart the server it has no way of reobtaining the entity

#

even from an ID, it simply does not exist on the server

summer scroll
#

that's not what I want to do, I don't need the entity to be persist.

tacit drift
#

InventoryCloseEvent triggers only if the player closes the inventory?

summer scroll
#

So I spawned armor stand with packets, and I got the EntityArmorStand object, and you can get the id from that, and right now I want to get the EntityArmorStand using that id.

eternal oxide
#

I don;t believe you can. As you manually created the AS and spawned it for the client using packets it doesn't really exist on the server. Its just a fake object

dense goblet
#

Why do you want to reobtain it

summer scroll
#

Alright then, I'm just gonna store the reference.

summer scroll
eternal oxide
#

If an entity exists on the server with a location it will be automatically spawned for the player when they come in rang of that chunk. Your Entity never actually exists on the server so can't be obtained by its ID. Its fake.

dense goblet
#

Then just keep a reference yea

eternal oxide
#

You have to keep an Object reference for the AS, or recreate it after a reload

#

Can;t be done with just an ID as it doesn;t exist in teh server Entity list

summer scroll
#

I thought I can make it simple, you know creating 1 class for every version instead 1 class each version.

eternal oxide
#

You could serialize it

#

Then you could save any Entities you create to use later

summer scroll
#

I'm just gonna keep the reference, thanks anyways.

#

All I had to do is copy the class and just change the import xd

grim ice
#

e i need an idea

#

im rly bored

summer scroll
#

Can you wear helmet client side? so it doesn't take the helmet slot, just a visual display.

dense goblet
grim ice
#

idk

#

any idea

#

il try to figure it out if its hard

dense goblet
#

An actually good player shop plugin with a nice GUI

grim ice
#

playershop?

#

like with /shop or something

#

or an auction house

dense goblet
#

Nah physical

grim ice
#

wdym?

#

using like an npc or what

dense goblet
#

Anything you find fitting that a player can place in the world and if you right click it a (multi-page) gui showing all configured trades shows up

#

The owner can set up trades and stock the shop through a virtual inventory

grim ice
#

thats used way too much except the fitting thing

#

thats basiscally a normal /shop plugin lol

dense goblet
#

Idk all I experienced was shitty sign shops

#

Though I didn't play on survival servers for a while

#

And occasionally an auctionhouse which generally doesn't support item trades only economy

grim ice
#

eh

dense goblet
#

A good shop plugin imo would be:
You right click a villager and see a chest inventory with all the trades, and a sidebar for page traversal and owner options.
Owner options would be:
-Open trade configuration gui
-Open stock inventory
-Open vault inventory (where the payments go)
All inventories should be multipage to allow for easy bulk selling/buying. Optionally have different tiers of shop with different amounts of max pages to not allow for cheap and compact infinite storage

grim ice
#

uhh'

#

idk

hybrid spoke
#

there are already many shop plugins

#

you need something unique

opal juniper
#

yep - literally a billion of them

#

especially in premium

hybrid spoke
#

or something what doesn't exist that often

grim ice
#

i need a good idea

hybrid spoke
#

how experienced are you?

grim ice
#

just give me an idea

#

if it's not in my level

#

ill try to figure it out

#

doing stuff only at my level will slow me down

quaint mantle
#

how can I solve this lag

#

(without removing that method)

lost matrix
#

} catch(ClassCastException exception) {} <- Dont do this

quaint mantle
#

oh

ivory sleet
#

toto try catch is considered among the more expensive things

quaint mantle
#

Ohhhh

#

thanks you

#

everyone

lost matrix
#

But to be honest it should not cause too much lag.
What does Level.giveEXP(player, "farming", 10); do?

ivory sleet
#

But also chances are you’re casting something erroneously

exotic scroll
#

How to detect what direction the player is moving in Playermoveevent?

ivory sleet
#

Oh so you’re messing with IO also?

lost matrix
#

LevelDataFile.set(); <- Show this pls toto

#

I suspected IO

ivory sleet
#

🥲

ivory sleet
lost matrix
ivory sleet
#

Although iirc there’s a function which says their direction or maybe it was velocity

summer scroll
exotic scroll
#

😂

lost matrix
lost matrix
exotic scroll
ivory sleet
#

So you want the distance the player has travelled over some time or no?

lost matrix
exotic scroll
lost matrix
undone axleBOT
lost matrix
exotic scroll
exotic scroll
lost matrix
hardy pivot
#
    public void initTime(ProxiedPlayer player){
        long initialTimeMinutes = (System.currentTimeMillis() / 3600000);
        timePlayer.put(player, initialTimeMinutes);
        player.sendMessage(new TextComponent(convertSecondsToHMmSs(System.currentTimeMillis())));
        player.sendMessage(new TextComponent(String.valueOf(System.currentTimeMillis())));
        ScheduledTask task = plugin.getProxy().getScheduler().schedule(plugin, () -> repeatTime(player), 1, 1, TimeUnit.MINUTES);
        tasks.put(player, task);
    }

    public void repeatTime(ProxiedPlayer player){
        long timeRepeatMinutes = (System.currentTimeMillis() / 3600000);
        double bd = timeRepeatMinutes - timePlayer.get(player); //timePlayer is a hashmap which contains another currentTimeMillis from a previous method
        plugin.getDb().setTime(player, bd);
        player.sendMessage(new TextComponent(Double.toString(bd)));
        player.sendMessage(new TextComponent(String.valueOf(System.currentTimeMillis())));
        timePlayer.put(player, timeRepeatMinutes);
    }
exotic scroll
# lost matrix

How am I going to attempt it if I got no clue how to do it

lost matrix
hardy pivot
honest iron
#

Is looping all players ~100 players and sending them Tablist effect the performance in BungeeCord?

ivory sleet
#

I mean everything in bungeecord happens more or less async

#

Since iirc there’s really no main thread there

#

Which means probably fine

honest iron
#

Is this normal for BungeeCord?

opal juniper
#

depends

#

how many players / plugins etc

honest iron
#

160 players currently

opal juniper
#

what cpu

grim ice
#

what is the

honest iron
#

from Hetzner

opal juniper
#

is it exlusively for the bungeecord

honest iron
#

No, i share 8 servers with it

opal juniper
#

lmao

quaint mantle
#

wtf

honest iron
#

?

opal juniper
#

i thought you meant that bungee was using that

#

8 servers is quite a few tho

#

eh

#

that seems normal

summer scroll
#

Trying to make an armor stand rides player, but it only works on the first time, when I tried to make the armor stand rides the second time on the player, it's just won't ride. I'm using nms, and the method that I use is EntityArmorStand#startRiding

grim ice
#

WHAT IS the tzz sound effect made by the guardians called

dire marsh
iron condor
#

can someone explain how does the VillagerReplenishTradeEvent work?

#

When I tried to test and trade with villagers it prints nothing

honest iron
#

I'm just trying to know if the cause is looping around 150 players

dire marsh
#

if you want to use less cpu, velocity is the way to go

honest iron
#

oke

#

ill try it

tacit drift
#

how do i check if a slot is empty

#

Inventory#getItem(slot) == null?

grim ice
#

hey

#

how do i use pitch..etc in e.getPlayer().playSound

#

what do iset the volume and pitch to

opal juniper
quaint mantle
opal juniper
#

oh no

lost matrix
lost matrix
tacit drift
#

nah i am making a filler for a gui

lost matrix
#

Wow... you can get a full ryzen root server with 64Gigs of ram and all 16 cores (not v) for 10€ less

opal juniper
#

really?? thats cheap

lost matrix
#

And iirc this runs on an Epyc which is less than ideal for something like minecraft.
So im pretty sure you cant run >30 - 40 concurrent users on one server with this.

hardy pivot
#

60 euros monthly omg

grim ice
#

anyone knows a way i can make a feature have charges

#

like an item can only be used 5 times

#

then u have to wait an amount of seconds for it to recharge

hardy pivot
#

store the player witth the int value of used times

quaint mantle
minor garnet
#

@summer scroll so try debuging checking the passanger of the player

summer scroll
minor garnet
#

what

#

is server side or mod ?

summer scroll
#

client side

minor garnet
#

send me your method

minor garnet
#

what is the method you remove an armor stand?

summer scroll
# minor garnet what is the method you remove an armor stand?
    @Override
    public void destroyArmorStand(Player player) {
        if(!armorStandMap.containsKey(player)) return;
        System.out.println("Destroying backpack for " + player.getName());

        NMSBackpack nmsBackpack = armorStandMap.remove(player);
        sendPacket(new PacketPlayOutEntityDestroy(nmsBackpack.getArmorStand().getId()), null);
    }
minor garnet
#

packetplayoutentitydestroy does not necessarily destroy the entity, it just makes other players see the invisible entity

summer scroll
#

what do you mean?

#

it's removing the entity for the players

minor garnet
#

yes

#

but it's still there, it just makes it invisible to other players, so the second time you add the passenger, the entity is still mounted on you

#

try .killEntity

summer scroll
#

ahh, got it

#

thanks, will try that

summer scroll
tardy delta
#

?paste

undone axleBOT
tardy delta
ivory sleet
#

Looks fine

tardy delta
#

i dont know if the removehome will work

#

i've never cleared things out of a file

quaint mantle
#

how can I detect if block is crop or not?

#

if (block instance of Ageable) not work

summer scroll
eternal oxide
#

if (Tag.CROPS.isTagged(block.getType()))

fluid cypress
#

i want to make a random tp plugin, and since the world will be regenerated every day, i want to pre-calculate pseudo random places when starting the server, a few, 10 or 20 idk, and then generate those chunks, before a player needs it, so it takes as little as possible to tp the player
how can i do that? generate a chunk. and after generating it, what would be the most efficient way to know which is the highest block? just a for loop in y? or maybe there is a "safespawn" of "safetp" method in the spigot api giving it a region or something, something that minecraft uses maybe

eternal oxide
#

Random X/Z then get highest block and test for a two block high space.

fluid cypress
#

getting a block from a certain location will automatically generate that chunk?

eternal oxide
#

yes

fluid cypress
#

then its easier than i thought, thanks

dire marsh
#

oh i thought you meant less than 10€ lol and i was like wut

fluid cypress
#

i want to store this into the config file

Map<String, Map<String, Map<String, Double>>> stuff = new HashMap<>();

but this doesnt work

getConfig().set(stuff);

it says MemorySection cannot be applied to that thing
i want something like this

key1:
  subkey1:
    subsubkey1: 1.0
    subsubkey2: 2.0
    subsubkey3: 3.0
  subkey2:
    subsubkey1: 1.0
    subsubkey2: 2.0
    subsubkey3: 3.0
key2:
  ...
eternal oxide
#

show the actual error

fluid cypress
#

wait im stupid, i forgot to send the name of the new section to set

#

ups

#

why cant it just say 'missing argument'

quaint mantle
#

thanks you guys!

#

who helpd me

grim ice
#

Help

#

how do i check how many items of an itemstack does a player have in their inv

#

and send that int to the player

hybrid spoke
#

either #getAmount or if you wanna receive every stack you probably have to loop over the contents

hybrid spoke
# grim ice how though

having an int
looping over the contents
verify if its exactly THAT itemstack
add the #getAmount on top of that int

merry kindle
#

hey

#

was wondering if its possible to make it so i can have a subdomain like pickles. insert rest here. then when i join it it takes me to a server kinda like minehut does it but like with one ip

tardy delta
#

how can i print all the entries of a file, this goes brr

tame coral
dusk flicker
tardy delta
chrome beacon
merry kindle
chrome beacon
#

I would take a look at how the bungee does it

#

Oh and you will have to setup SRV records and stuff

merry kindle
#

wym look how bungee does it? Will i have to make my own fork of bungee for this?

tardy delta
#

if i use getKeys(false) will that return the homes?

#

ow wait i need to get all the homes below the uuid

grim ice
#

I know this is java basics and this is not the place to ask this, but how do you put players inside hashmaps?

tardy delta
#

like "test" is a one

grim ice
#

that isnt helpful

opal juniper
#

.put(player, value)

grim ice
#

how to create the hashmaps though

#

HashMap<Player, List<Player>> list = new HashMap<>();

#

?

opal juniper
#

yeha

#

why call it map?

#

*list

grim ice
#

wait

grim ice
# opal juniper *list

HashMap<Player, Player> list = new HashMap<>();
list.put(e.getPlayer(), e.getPlayer());

#

is this fine

#

ik it shouldnt be namedl ist

#

list

#

just ignore the name

tardy delta
#

just use .put(key, value) where value is a list

opal juniper
#

yeah

grim ice
opal juniper
#

Map<UUID, Set<UUID>> playerMap = new HashMap<>();

tardy delta
#

hey but how can i get the second level of a configurationsection?

opal juniper
#

use this ^^

grim ice
#

okay

grim ice
#

how do i put

#

the player

opal juniper
#

playerMap.put(player.getUUID, new HashSet<>));

grim ice
#

thanks

#

Is there a way i can access the player in the hashmap from another class / method

opal juniper
#

make getters / setters

grim ice
#

okay

fluid cypress
#

can i get a block and read it (not modify it) and generate that chunk from another thread?

opal juniper
#

doubt u can

#

seeems like a main thread thing

fluid cypress
#

are u sure? i saw people saying that as long as you dont modify the world, there is no problem with using threads

grim ice
#

aaa

fluid cypress
#

but i dont want it to get corrupted or something, but idk if minecraft generates the chunk in the main thread anyway, or it would be generated in the new thread or something, idk

grim ice
#

im confusion

#

anyone knows how do i pass a player object from a method to another method

opal juniper
#

?learnjava

undone axleBOT
cold tartan
#

how do you get the items dropped with the BlockBreakEvent

grim ice
#

i know its java

#

bruh..

#

and none of these links have what i want

#

lol

opal juniper
cold tartan
tardy delta
cold tartan
grim ice
#

right

eternal oxide
#

why would that throw an error?

tardy delta
#

will this remove all lines from the homes?

private void removeHome(Player p, String name) {
        if (hasHome(p, name)) {
            for (String s : homesFile.getConfigurationSection("homes." + p.getUniqueId() + "." + name).getKeys(true)) {
                homesFile.set(s, null);
                Utils.message(p, "§aRemoved " + name);
            }
        } else {
            Utils.message(p, new String[] {"§cHome not found!", "§cYou can use /home list to see all your homes"});
        }
    }
eternal oxide
#

just set the root key to null

tardy delta
#

so change the true to false?

eternal oxide
#

what? I never said anythign about true nor false

grim ice
#

nvm

eternal oxide
#

if you want to remove all entries under "homes.uuid" you set that root to null

#

no need to do each individually

grim ice
#
    public static int getAmount(Player rightClicked) {
        ItemStack regular = new ItemStack(Material.REDSTONE);
        if (regular == null)
            return 0;
        int amount = 0;
        for (int i = 0; i < 36; i++) {
            ItemStack slot = rightClicked.getInventory().getItem(i);
            if (slot == null || !slot.isSimilar(regular))
                continue;
            amount += slot.getAmount();
        }
        return amount;
    }
//and in another method:
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.GREEN + "Taser Charges left: " + getAmount(clicked)));```
#

u think that will work?

tardy delta
#

just the keys under the name

#

in this case "test"

#

wdym null

fluid cypress
#

what will config.getInt() return if the path doesnt exist?

tardy delta
#

nullpointer

fluid cypress
#

really

#

why couldnt it just return Integer instead of int, so it can return just null

young knoll
#

I imagine 0

#

You can also pass a default

fluid cypress
#

i see

#

why intellij doesnt tell about that

grim ice
#

?paste

undone axleBOT
grim ice
#

question, will this work

craggy cypress
#

How can i leave the marked slots empty?
I tried to set the marked slots to null and air with .setitem(0, null), But if I use .additem it will still take slot 0.

grim ice
#

mentioning Regular() will return the ItemStack, right

young knoll
grim ice
#

^

#

anyways can some1 answer my question

#

its a java question so i bet most ppl know the answer help pls

young knoll
#

Yes

grim ice
young knoll
#

Yes

grim ice
#

YOOO POG

young knoll
#

I won’t comment on the poor naming