#help-development

1 messages ยท Page 96 of 1

lost matrix
#

Format the String.

#

%.6f

gray merlin
#

Anyhow, this is the current code...

dire marsh
lost matrix
#

I know. Format the String.

gray merlin
lost matrix
#

And you wont find a method which takes an Object as a parameter

gray merlin
lost matrix
gray merlin
#

When you display the data, you display it as a string, so whilst displaying it as a string, you format it so it can fit the rest of the numbers.

#

"Format the decimal to six points of float precision"

lost matrix
#

The methods signature is

ItemStack createStack(NBTTagCompound)

This means a reflection should search for a method with this signature.
So

Method method = itemStackClass.getMethod("createStack", new Class[] {nbtTagClass})
#

The Class[] represents the types of the parameters which are passed to the method

gray merlin
lost matrix
#

But this looks like you are using 1.8 so thats all the help you gonna get from me

gray merlin
#

I see, thank you, still

lost matrix
gray merlin
#

Ah, I missed that. I will try it that way, seems good.

#

Wait, no that's the same as I had prior with a variable declaration added
Also: Turns out I didn't debug properly and the issue seems to stem for somewhere deeper

#

Due to mismatched parameters, since I left an "Object" somewhere

#

Thank you smile, that opened my eyes to this.

quaint mantle
#

How do you pass through your plugin instance to a dependency so that it can use it to call spigot methods?

tawdry cedar
#

Old code: ((EntityVillager)nmsVillager).a = Integer.MIN_VALUE;

New code: ((net.minecraft.world.entity.npc.Villager)nmsVillager).a = Integer.MIN_VALUE;

How do I find the alternative to .a_?

sterile token
#

?1.8

undone axleBOT
tawdry cedar
#

From 1.8

#

bruh

#

I need to just find out wtf .a_ means

#

And what the alternative for it is now

#

Trying to update this old plugin

#

From 1.8 -> latest

#

Yes

#

it makes an npc

eternal oxide
#

odd to use a villager as an npc as they are not skinnable

tawdry cedar
#

Thanks

#

But I don't wanna have to recode this if someone who knows a shit ton about NMS could explain it

hasty prawn
#

Also what is the new version you're porting it to

tawdry cedar
#

And yep all I wanna know is what it is

#

Like I genuinely have no idea how to find out what a_ does or what it is

eternal oxide
#

there is a website with mappings, but I can;t remember its name.

tawdry cedar
#

Obviously, EntityVillager no longer works and is now called Villager, I found that out on a site. But like idk how to find the new name for a_

tawdry cedar
eternal oxide
#

yep thats it

tawdry cedar
#

Yeah thats how i found out that EntityVillager has a new name

#

But on that website I cannot find anything about a_ under EntityVillager

hasty prawn
#

I don't see any obfuscated variables with a_ in Villager

eternal oxide
#

what is the .a you are currently setting?

#

wel 1.18.2

tawdry cedar
#

There isn't any a_ in Villager

hasty prawn
#

I just checked 1.19.2 and that doesn't exist lol

tawdry cedar
#

But there was in EntityVillager

tawdry cedar
#

There used to be a .a_ in EntityVillager

#

But EntityVillager is now just Villager

tawdry cedar
#

Yeah

hasty prawn
#

Still no a_ lol

eternal oxide
#

yes there is

#

there 2

#

one takes an EntityPlayer as an arg, the other takes an ItemStack

tawdry cedar
#

Ye ^^

#

I have seen that already

#

But I cannot make sense of it

hasty prawn
#
Old code: ((EntityVillager)nmsVillager).a = Integer.MIN_VALUE;

New code: ((net.minecraft.world.entity.npc.Villager)nmsVillager).a = Integer.MIN_VALUE;

Seems like they're looking for a field though, no?

eternal oxide
#

so what are you passing to a_ in your 1.8 code?

hasty prawn
#

Not called a_ though so I have no clue anymore.

eternal oxide
#

ah just a then

hasty prawn
#

There's no a field in 1.8.8 so I'm lost PeepoShrug

tawdry cedar
#
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import net.minecraft.server.v1_8_R1.EntityHuman;
import net.minecraft.server.v1_8_R1.EntityVillager;
import net.minecraft.server.v1_8_R1.PathfinderGoalInteract;
import net.minecraft.server.v1_8_R1.PathfinderGoalSelector;
import org.bukkit.entity.Villager;

public class Util {
   public static void neuterVillager(Villager villager) {
      try {
         Method getHandleMethod = villager.getClass().getDeclaredMethod("getHandle");
         Object nmsVillager = getHandleMethod.invoke(villager);
         Field goalSelectorField = findField(nmsVillager.getClass(), "goalSelector");
         Field targetSelectorField = findField(nmsVillager.getClass(), "targetSelector");
         goalSelectorField.setAccessible(true);
         targetSelectorField.setAccessible(true);
         Object goalSelector = goalSelectorField.get(nmsVillager);
         Object targetSelector = targetSelectorField.get(nmsVillager);
         Field bField = goalSelector.getClass().getDeclaredField("b");
         bField.setAccessible(true);
         bField.set(goalSelector, new ArrayList());
         bField.set(targetSelector, new ArrayList());
         ((PathfinderGoalSelector)goalSelector).a(0, new PathfinderGoalInteract((EntityVillager)nmsVillager, EntityHuman.class, 3.0F, 1.0F));
         ((EntityVillager)nmsVillager).a_ = Integer.MIN_VALUE;
      } catch (Exception var8) {
         var8.printStackTrace();
      }

   }

   public static Field findField(Class clazz, String name) {
      try {
         Field field = clazz.getDeclaredField(name);
         field.setAccessible(true);
         return field;
      } catch (Exception var3) {
         return clazz != Object.class ? findField(clazz.getSuperclass(), name) : null;
      }
   }
}```
#

That is the whole class

#

How I found it

hasty prawn
#

R1

#

1.8.8 is R3

tawdry cedar
hasty prawn
#

Could be why

eternal oxide
#

its a in goalSelector

tawdry cedar
#

How the fuck do I find R1 stuff then

raven fern
#

is there a way to detect what item or fish someone fishes up?

#

Im still pretty new to all of this but this was my attempt at it

#
public void onPlayerFish(PlayerFishEvent e) {
        if (e.getState() == PlayerFishEvent.State.CAUGHT_FISH)  {
            e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&eYou caught a " + e.getCaught()));
        }
    }```
#

all ive touched is eventhandlers

eternal oxide
#

It looks like all that code does is clear their goals

#

and set the targetSelector to EntityHuman

tawdry cedar
#

I have no idea how you're even able to make sense of it haha

drowsy helm
#

do you guys think it would be a bad idea to use a database to manage cross-server parties? It's either use a db or use a dedicated party manager

#

just not sure how efficient it would be on a db

eternal oxide
#

parties?

drowsy helm
#

yeah like player parties

#

im trying to think of a system that works cross server that doesn't require a central management server

echo basalt
#

redis

drowsy helm
#

yeah might use redis

worldly ingot
#

Mix of both. Communicating parties between servers quickly could be easily done with Redis, but persistent storage of parties would best be done in SQL

drowsy helm
#

hm yeah might do that

#

all i really need is list of uuids nothing else

echo basalt
#

usually if redis gets wiped

#

it means the machine itself rebooted

#

I don't think that parties would need machine-reboot levels of persistence

wet breach
worldly ingot
#

I meant more that if parties are to be persistent across restarts, which some people do want

echo basalt
#

I think that's more of a guild system than parties themselves

desert frigate
#

what is a CraftItem? i already tried filtering java Predicate<Entity> pr = entity -> (entity instanceof Player && (!(entity instanceof LivingEntity))); but i still get java java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_18_R1.entity.CraftItem cannot be cast to class org.bukkit.entity.LivingEntity (org.bukkit.craftbukkit.v1_18_R1.entity.CraftItem and org.bukkit.entity.LivingEntity are in unnamed module of loader java.net.URLClassLoader @7aec35a)

wet breach
#

I personally wouldn't use redis though for such a system

#

you only need the proxy

eternal oxide
#

its impossible for it to be a Player but not a LivingEntity

desert frigate
#

ill just use iterator then

#

would it be possible to make a item break certain blocks faster?

lost matrix
#

I personally also use Redis as a read through/write behind cache. Its my single entry point for data access.
This assures full data consistency across several instances.

tawny otter
#

EntityPotionEffectEvent returns null for instant harm/heal, how can I detect if a potion someone uses is a instant harm/heal?

lost matrix
tawny otter
#

yeaper

lost matrix
#

Then just check the PotionEffectType

#

Also: wtf is this documentation

tawny otter
#

on?

young knoll
#

Lol

lost matrix
young knoll
#

It used to only be the bottom line

tawny otter
#

ahhh

young knoll
#

I PRed better docs for a few effects a while back

tawny otter
upper tendon
#

How can I make it so only certain players can see certain blocks?

upper tendon
#

Wow ok - is this permanent?

#

as in like the block won't switch back to what it was before?

lost matrix
#

No. If the block updates in any way then the original is being sent to the player again

upper tendon
#

Ok, thank you!

tawny otter
#

@lost matrix im trying to SOUT the event.getModifiedType(), its not even printing anything

    public void onPotion(EntityPotionEffectEvent event){
        if(event.getEntityType() == EntityType.PLAYER){
            System.out.println("-----------------");
            System.out.println(event.getModifiedType());
        }
    }

this is total bruh moment

lost matrix
#

Do an error elimination procedure

tawny otter
#

I was trying it before the Player if Statement

lost matrix
#

Does it fire?

tawny otter
#

um, does not seem too

lost matrix
#

Drink a normal potion. Do you see anything then?

tawny otter
#

it was earlier heh?

#

one sec

tawny otter
#

not even printing the -----

#

its working for all the other potions = (

lost matrix
#

Did you add an EventHandler annotation? Did you register the listener?

tawny otter
#

yes

#
[20:21:45 INFO]: PotionEffectType[12, FIRE_RESISTANCE]
[20:21:45 INFO]: [OreIgin] [STDOUT] -----------------
[20:21:45 INFO]: PotionEffectType[28, SLOW_FALLING]
[20:21:45 INFO]: [OreIgin] [STDOUT] -----------------
[20:21:45 INFO]: PotionEffectType[12, FIRE_RESISTANCE]
[20:21:45 INFO]: [OreIgin] [STDOUT] -----------------
[20:21:45 INFO]: PotionEffectType[28, SLOW_FALLING]
#

it only seems to work when I use the /effect command

lost matrix
#

Well then the event is simply not fired for instant effects. Kinda meh.

tawny otter
#

= / maybe its a different event

lost matrix
#

Well there are several events that are being fired in this instant. EntityRegainHealthEvent and EntityDamageEvent (just as an example)

tawny otter
#

I can do the Instant Harm using the EntityDamageEvent and . . . yeah that

drowsy helm
#
@Getter
public abstract class MECallbackPacket<T extends MECallbackResponsePacket> extends MEPacket{
    private final UUID target = UUID.randomUUID();

    public void respond(AbsPacketManager packetManager, T responsePacket){
        packetManager.sendPacket(responsePacket);
    }

    public abstract void onRespond(T packet);

}

I've got this class which has a type erasure

        if(packet instanceof MECallbackResponsePacket responsePacket){
            UUID uuid = responsePacket.getTarget();
            MECallbackPacket<?> callbackPacket = activeCallbackPackets.get(uuid);
            callbackPacket.onRespond(responsePacket);
        }```
Why would this not work? T is of MECallbackResponsePacket
lost matrix
drowsy helm
#

ah awesome

#

thanks

round finch
#

ignore this command!

#

?learnjava

undone axleBOT
round finch
#

just grabbing some links

drowsy helm
#

finally, got my redis packet system working

#

can query all players on the network pog

lost matrix
#

What do you mean by query a player

round finch
#

do you store all packages? idk wut

drowsy helm
#

was just a test packet

#

returns all the player names on the network

round finch
#

pretty neat

drowsy helm
#

just building towards a cross server party system

#

alotta back end lol

lost matrix
#

Sounds like 10 lines of work...

drowsy helm
#

this is for more than just that lmao

lost matrix
#

Are you using Redisson?

drowsy helm
#

gonna be used for alotta stuff

#

just setting up the building blocks

#

nah jedis

#

never heard of redisson

lost matrix
#

smh

drowsy helm
#

lmao

lost matrix
#

Redisson has a ton of utility

drowsy helm
#

oh looks pretty helpful tbh

#

i had fun making this atleast lmao

lost matrix
drowsy helm
#

doesnt look nuch different to jedis

lost matrix
#

Jedis only supports sending Strings through channels iirc

drowsy helm
#

yeah it does

#

i just use gson

lost matrix
#

With Redisson you can directly send objects if you use the right codec

round finch
#

any algorithmic way to figure out fill inside block lines

#

this is for a spigot plugin

lost matrix
#

Sure. As long as you know how to check the constraints you can do a simple flood fill algorithm.

compact haven
#

I mean you can just continue in each direction until it hits a block

round finch
#

thinking about generating random shapes and fill them in

lost matrix
#

Is your problem checking if a block is inside your shape?

sharp portal
#

How can I get the minecraftkey from a nms enchant

round finch
#

just needed to know if the filling is inside the lines

lost matrix
round finch
#

exactly

round finch
worldly ingot
compact haven
#

what do you know

compact haven
#

like what is the information you have when you make these shapes

sharp portal
worldly ingot
#

Right but why? What's wrong with API?

sharp portal
#

Getting it with nms to add custom enchant to the enchant table

round finch
lost matrix
worldly ingot
#

I'd be careful with that, but sure. Registry has a method to get the key of its registered type. It's something along the lines of IRegistry.ENCHANT.getKey(Enchantment.SHARPNESS); or something like that

#

Alternatively, CraftNamespacedKey.toMinecraft(Enchantment.DAMAGE_ALL.getKey()) (Bukkit's Enchantment)

#

I'd personally opt for the registry approach though

sharp portal
#

Okay second question looks like there are mappings I can use... Where can I find those?

sharp portal
worldly ingot
#

I'm sure there's a custom command for this, but I don't know it

sharp portal
#

Thank you

round finch
sharp portal
worldly ingot
#

Not that I'm aware of

sharp portal
#

Alright thank you

round finch
#

is it possible to have spigot doc in your eclipse?
i forger

worldly ingot
#

Maven will download and link them

#

Gradle does the same as well iirc

#

If they're not showing up, you can right click the project and go to Maven -> Download Javadocs

round finch
#

hmmm ๐Ÿค”
can you do directly in ecplise?

worldly ingot
#

Just with classpath dependency you mean?

round finch
#

i wanna be lazy
but at the same time i guess you could just run maven

worldly ingot
#

Oh are you just wanting to open a browser in your IDE?

round finch
#

what the difference here..

#

just wannna know ๐Ÿ˜…

worldly ingot
#

I mean you can open a browser with Ctrl + 3, then writing "Open Browser"

#

Then just navigate to the Javadocs

#

?jd

worldly ingot
round finch
#

just wanna be able to see then i'm typing

worldly ingot
#

Like a fancy pants

round finch
#

and check doc

worldly ingot
#

Okay, so how are you depending on Spigot? Maven? Gradle? Or classpath?

round finch
#

can you download spigot doc with maven?

#

some how

worldly ingot
#

Yeah

round finch
#

very cool

#

gotta check it out!

worldly ingot
#

Have to be depending on the spigot-api dependency though because that's the one with attached Javadocs

round finch
#

do i have to get Maven Project for that

#

or can i just run maven project file

#

inside of my project

worldly ingot
#

Well your project has to be using Maven

buoyant viper
#

wtf is p suffix in java

reef lagoon
#

indicates a hexadecimal floating-point literal, where the significand is specified in hex.

buoyant viper
#

player PDCs are persistent after death right

#

or are they per-life

quaint mantle
#

How do you pass through your plugin instance to a dependency so that it can use it to call spigot methods?

vocal cloud
#

?di

undone axleBOT
vocal cloud
#

Or, use a singleton

#

Or, fetch the instance from Bukkit

buoyant viper
#
// Plugin class
public class YourPluginClass extends JavaPlugin {
  @Override
  public void onEnable() {
    getServer().getPluginManager().registerEvents(new YourListener(this), this);
  }
}

// Listener class
public class YourListener implements Listener {
  private final YourPluginClass plugin;
  
  public YourListener(YourPluginClass plugin) {
    this.plugin = plugin;
  }

  @EventHandler
  private void onLogin(PlayerLoginEvent event) {
    plugin.getServer().broadcastMessage("stinky");
  }
}``` somethin like this
stark wagon
#

Anyone here know of someone that can make Skripts?

river oracle
#

Skript is pretty much worse in every fassion

#

?services

undone axleBOT
stark wagon
#

@river oracle Skript is more lightweight and usually easier to make, so I assumed I'd be luckier that way, so sorry I didn't think of asking your opinion first.

river oracle
#

it has much more overhead

#

if someone told you skript was lighterweight on your server they lied lol

#

just because it looks simpler and is less verbose definitly doesn't mean its more lightweight

scarlet creek
#

I don't understand what is wrong with the code at line 25
Code:

    public void onEnable() {
        // Plugin startup logic
        System.out.println("Plugin started!");
        ModEnchants.register();

        getServer().getPluginManager().registerEvents(new TntBow(this), this);
        //getServer().getPluginManager().registerEvents(new PushSword(this), this);
        getServer().getPluginManager().registerEvents(new PullBow(this), this);

        getCommand("giveBow").setExecutor(new giveBowCommand());

        getCommand("customEnchant").setExecutor(new CustomEnchantCommand());
    }```
#

It keeps saying it is null

river oracle
#

is giveBow in your plugin.yml

scarlet creek
#

Yes?

#
  giveBow:
    description: Give test bow
    usage: /<command>

  customEnchant:
    description: enchant item
    usage: /<command>
    aliases:
      - ce```
river oracle
#

hmmm well only time getCommand should return null is if its not in the plugin.yml

#

my guess is something about your plugin.yml is off

#

I've never seen /<command> before under usage but idk if that'd be the issue

river oracle
scarlet creek
#

Oh I see

desert frigate
#

Is it possible to force a player to swimming pose?

river oracle
#

Player#setSwimming I believe

#

if that doesn't work how you want it next best option would probably be packets

buoyant viper
#

entities other than humans can swim? duke

river oracle
#

including drownd etc

#

I think drowned is the only other entity that can swim

#

though I may be wrong

buoyant viper
#

like with a real swimming animation?

river oracle
desert frigate
#

But I haven't tried it yet

#

so I'll see

scarlet creek
charred blaze
fluid cypress
#

If i teleport an entity to an unloaded chunk, will it be there when i load the chunk? will the unloaded chunk be loaded just for the tp?

tardy delta
#

If you tp a player to An unloade chunk, it Starts falling right

#

Wondering if the same thing happens with entities

scarlet creek
#

Is there a way to detect when a player sneaks but not when they release the sneak key?

old cloud
scarlet creek
#

Thanks!

quaint mantle
tardy delta
#

Oh

quaint mantle
#

I'm pretty sure entities just float in place

reef lagoon
smoky oak
#

should i cache the logger or should i call plugin.getlogger every time

hybrid spoke
obsidian drift
#

Idk what to put for the Block ID

#

anyone know?

smoky oak
#

version

obsidian drift
#

on 1.19.2

smoky oak
#

hm

#

theres probably an internal map enum->id somewhere

#

try finding that

old cloud
obsidian drift
#

I'm using packets to simulate block breaking but Idk how to reset it...

old cloud
#

Probably by sending a packet that places the block again

obsidian drift
#

I'm using ClientboundBlockDestruction, the wiki says use any value that isn't 0-9 to remove it but that doesn't seem to be working

mellow edge
#

I am creating my own buy gui, creating a quick buy is a pain, how can I detect if someone is holding shift while clicking

smoky oak
obsidian drift
#

There is SHIFT_LEFT and SHIFT_RIGHT

#

you can get a ClickType from the InventoryClickEvent

vocal cloud
#

Ah yes. My favorite shift. Right shift

smoky oak
#

that too

mellow edge
#

ok

#

thanks

mellow edge
obsidian drift
#

Anyone know how to get a net.minecraft.world.level.block.Block from a org.bukkit Block object?

warm mica
obsidian drift
#

Can this be used to change the block destruction stage?

smoky oak
#

(CraftBlock) block

warm mica
#

Yes there's also a sendBlockDamage method

smoky oak
#

assuming remapped

obsidian drift
warm mica
#

I know, it's kinda impressive that they have an API for that. Couldn'r believe it myself the first time

obsidian drift
#
player.sendBlockDamage(block.getLocation(), 0);

Still can't seem to reset block damage progress

smoky oak
#

dont u need to tick that block too

#

or am i dumb

obsidian drift
#

I put a delay of 20 ticks

#

still nothing

#

I'm gonna try send the packet before I break the block in the world

#

that might be why

#

Still doesn't work ๐Ÿ˜ฆ

public void sendBreakBlock(Player player, Block block) {
                sendBreakPacket(-1, block);
                Bukkit.getScheduler().scheduleSyncDelayedTask(DarkCraft.getInstance(), () -> {
                        boolean success = player.breakBlock(block);
                        if (!success)
                                player.sendMessage("Could not break block.");
                }, 20L);
        }
shadow zinc
#

I need some help with this java [18:30:38 ERROR]: Error occurred while enabling NeoConfig v1.5 (Is it up to date?) java.lang.UnsupportedClassVersionError: com/neomechanical/neoconfig/neoutils/version/v1_17_R1/worlds/WorldWrapper1_17_R1 has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0

#

I need to compile stay class with java 16 otherwise it doesn't work

obsidian drift
chrome beacon
#

You need to tell it to use Java 8 when compiling

obsidian drift
# obsidian drift Still doesn't work ๐Ÿ˜ฆ ```java public void sendBreakBlock(Player player, Block bl...

sendBreakPacket

public void sendBreakPacket(int animation, Block block) {
                Bukkit.broadcastMessage("Animation: " + animation);
                ClientboundBlockDestructionPacket packet = new ClientboundBlockDestructionPacket(random.nextInt(), new BlockPos(block.getX(), block.getY(),
                        block.getZ()), animation);
                for (Player p : Bukkit.getOnlinePlayers())
                        ((CraftPlayer) p).getHandle().connection.send(packet);
        }
shadow zinc
chrome beacon
shadow zinc
chrome beacon
#

Could you send that error?

shadow zinc
#

yep give me abit

fiery prairie
fiery prairie
#

then uhh change your server version (java) or am I dumb?

shadow zinc
#

its not for my server, its a plugin for all versions and for all java versions

fiery prairie
#

Ohh

obsidian drift
#

Yeah, I am trying to reset the progress of a damaged block

shadow zinc
vivid cave
#

this worked in 1.15: TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)skull.getWorld()).getHandle().getTileEntity(skull.getX(), skull.getY(), skull.getZ());
Now the method getTileEntity() method doesn't exist anymore for CraftWorld.getHandle()

#

how can i retrieve the SkullBlockEntity or TileEntitySkull at x,y,z in 1.19

obsidian drift
#

The animations disappears for a sec then comes back

#

I got it working!! You need to pass the block entity ID instead of the player entity ID. Get it using this:

    private int getBlockEntityId(Block block){
        return ((block.getX() & 0xFFF) << 20 | (block.getZ() & 0xFFF) << 8) | (block.getY() & 0xFF);
    }
mellow edge
#

PROTECTION_ENVIRONMENTAL is normal protection right?

obsidian drift
#

Pretty sure it is

tardy delta
#

math weird

smoky oak
#

tf ur doing

tardy delta
#

just wondering why 100^some big number prints Infinity to console

smoky oak
#

huh

#

id have guessed itd just wrap around

rough drift
#

deos

#

does

#

some times

smoky oak
#

some times

tardy delta
smoky oak
#

I'd like defined behaviour please

rough drift
#

it is defined in some contexes

smoky oak
#

some

#

great language there oracle

tardy delta
#

seems like Math::pow checks for infinite stuff

rough drift
#

no Infinity is caused by classes/wrappers

tardy delta
#

or smth

#

bruh never look at FdLibm.Pow.compute(a, b) (Math.pow impl)

#

my brain

scarlet creek
#

I'm trying to make mobs get pulled towards the arrow but it is only doing so for 1 direction. I'd appreciate if someone could perhaps tell me what is wrong or the proper logic to drag mobs towards the arrow

Code: ```Player p = event.getPlayer();

    if (p.isSneaking()){
        if (p.getInventory().getBoots().getItemMeta().hasEnchant(ModEnchants.FORCE)){
            Location playerLoc = p.getLocation();
            List<Entity> nearbyMobs = p.getNearbyEntities(rangeX,rangeY,rangeZ);

            for (Entity entities : nearbyMobs){
                entities.setVelocity(entities.getLocation().subtract(playerLoc).toVector().normalize().multiply(1));

            }
        }
    }```
smoky oak
#

that normalize might be cutting out the y component but i doubt it

#

try printing the loc-loc vector and the normalized vector to console

tardy delta
#

fucked up my math again

#

1.5 + 2 is now 8 ๐Ÿ™

rough drift
#

multiplying by 1 makes it same

#

you want to multiply by like 1.5 or higher

shadow zinc
#

How do I stop this happening when I relocate my NeoConfig lib?

#
org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.neomechanical.neoconfig.NeoConfig'```
grim ice
shadow zinc
#

?paste

undone axleBOT
smoky oak
tardy delta
#

just got ouf of my bed

shadow zinc
grim ice
#

its 1+5+2

#

wow

#

lmaooo

solid cargo
#

are there any good inventory apis? i hate the bukkit one with passion

grim ice
#

it replaced the dot with a plus

tardy delta
#

well its not the math, its the parser which creates operands which goes brr

scarlet creek
shadow zinc
solid cargo
rough drift
#

send it

#

nah just send here

onyx fjord
#

send it here

solid cargo
#

eh ok

shadow zinc
#

thats not mine

#

its better i think

onyx fjord
#

the moment he stopped believing in his power

tardy delta
#

the only thing about copilot is that idk if it works

shadow zinc
#

lol

onyx fjord
#

71KB :/

shadow zinc
#

what?

rough drift
#

Eh i'll make a miniscule lib

onyx fjord
#

the one u sent

smoky oak
#
class legitJava{;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;public static void main(String[] args){
;;;;;;;;System.out.println("HelloWorld");;;
;;;;};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
solid cargo
#

OH I FOUND THE ONE I LIKED ALL THE TIME

onyx fjord
#

phoenix does good shit

#

like mindown

#

tho iridium color api is superior for its size

#

like 10kb shaded i believe

shadow zinc
#

kacp any idea about my pom?

#

relocate = no main class found

onyx fjord
#

yes im expert for sure ๐Ÿ˜‚

shadow zinc
#
[19:14:29 ERROR]: Could not load 'plugins/NeoPerformance-1.13.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.neomechanical.neoconfig.NeoConfig```
#

its strange because it happens after relocation but it wasn't doing it before

onyx fjord
#

do u relocate a plugin or what

shadow zinc
#

yes

onyx fjord
#

that will not work

#

plugin.yml points to main class

shadow zinc
#

did in the past

onyx fjord
#

maybe theres a variable though

smoky oak
#

file

#

whatever

#

if yes remove and try again

shadow zinc
#

nope

onyx fjord
#

i wondered how those variables work in plugin.yml

shadow zinc
#

what variables?

rough drift
#

it's a string replacement

#

that maven runs on resources

onyx fjord
#

wouldnt you be able to replace main: with variable from maven or something

shadow zinc
#

idk, you know more than me

smoky oak
#

as for the rest```yml
api-version: #mc version
author: #you
depend: [] #required plugins for this to load
description: #text
load: POSTWORLD #this is default, alternative: STARTUP
loadbefore: [] #those should load AFTER this plugin loaded
main: #qualified path
name:
prefix: #Logging prefix
softdepend: [] #required for full functionality but not essential
version: #version

onyx fjord
#

๐Ÿ˜‚

#

STOP THE CAP

smoky oak
#

which part

shadow zinc
#

all of it

smoky oak
#

thats the plugin yml

shadow zinc
#

but why?

smoky oak
#

sans commands and permissions

shadow zinc
#

i don't understand

onyx fjord
#

so ur lib is a plugin?

shadow zinc
#

yes

onyx fjord
#

why is that

shadow zinc
#

reasons

tardy delta
#

looks kinda bloat

shadow zinc
#

there is no good reason to use your own plugin as a lib, people would you are just being lazy

onyx fjord
shadow zinc
#

why might my lib not be working now when it was a week ago? Very little was changed.

quiet ice
#

Otherwise it is the good old ${property}

shadow zinc
#

I only added modules

#

I found the problem but I don't know how to fix it

#

shading in my plugin lib into my plugin replaces my plugin's plugin.yml with the libs plugin.yml

chrome beacon
#

Exclude the plugin.yml file in the shade plugin

onyx fjord
#

i have this thingy

#

thats default from mc plugin in ij

#

cool af

novel vine
#

hey, is there an api to convert worldedit .schematics to .obj?

shadow zinc
#

what isn't doing it by default then?

#

I got that mc plugin

onyx fjord
#

it does it only for version

#

tho im using gradle

#

do what olivo said

smoky oak
#

an obj is a vertex file

#

for stuff lilke blender

onyx fjord
#

there r gui tools for that i believe

smoky oak
#

i can offer obj to schematic tho

grim ice
#

ngl

#

cobalt cape is awesome

#

better than all the minecons

#

except 2015 and 2016

#

theyre both cool

onyx fjord
#

cobalt cope?

grim ice
#

cape

#

only 16 people have it

onyx fjord
#

k

round finch
#

||not better then the red creeper cape||

#

||it goes way back||

#

How do i get Spigot Doc with maven?

#

i have been testing for hours

#

and setting up maven + searching

round finch
#

how do I make it so it says info about spigot (doc)

tardy delta
#

switch to ij ๐Ÿ˜

round finch
#

REE

#

intellij nah

smoky oak
#

how do i implement a custom event without implementing it twice

sonic sky
#

Is that eclipse?

onyx fjord
#

let em use what they use

#

just get the fucking dark theme

round finch
onyx fjord
#

eclipse ppl are W

round finch
sonic sky
#

Old school lol

onyx fjord
#

its still getting updates

sonic sky
#

Or beginner, no inbetween

#

I'm guessing old school

onyx fjord
#

professional devs also use eclipse

#

well

sonic sky
#

Old school

onyx fjord
#

professional devs also use vim or emacs

round finch
onyx fjord
#

old tools indeed, but not dead

sonic sky
#

No not at all

#

I don't have a problem with the IDE, I like the simplicity

#

Personally, moving to IntelliJ took a while to get used to

round finch
#

IntelliJ Project Directory and building jar has left me confused when I first tried it

sonic sky
#

^^

round finch
#

didn't return

#

lol

sonic sky
#

Keybinds make IntelliJ worth it

#

Haven't seen many IDEs which allow Ctrl+Shift + Arrow to move code

#

Generators in IntelliJ also save a lot of time, not sure if Eclipse has them

onyx fjord
#

ij tree is ass

#

it takes so much space

#

im in luck with a large monitor

#

not everyone is though

#

sure i can use packages tab, but then i dont see build.gradle

sonic sky
#

True, I'd only use IntelliJ for Java and any configurations related to the project

#

VSC for C++ is quite nice, but takes ages to set up - if you set it up well it does wonders

onyx fjord
#

vsc looks nice if you know how to set it up

sonic sky
#

if

onyx fjord
#

gotta tinker

sonic sky
#

When I was setting it up had me contemplating just moving to Code::Blocks

tardy delta
#

my vsc looks hot

sonic sky
#

RS? Rust?

tardy delta
#

yes

sonic sky
#

And VSC is just such a smooth ide

#

So nice to look at

tardy delta
#

its a text editor

round finch
#

i forgor what rust?

buoyant viper
#

mozilla language

onyx fjord
buoyant viper
#

the crab

sonic sky
#

Myb

tardy delta
quiet ice
rough drift
onyx fjord
#

mozilla is just sponsor

sonic sky
round finch
#

need help to import spigot doc into eclipse

quiet ice
#

Using Ctrl + Shift + Left/Right for highlighting an entire token is much more intuitive (i.e. merging the functionalities of Ctrl + Arrow and Shift + Arrow)

tardy delta
#

rust be like

sonic sky
#

Fair play, certainly down to opinion

#

Some C code makes me nauseous to look at

tardy delta
#

threadpool in rust only took me 105 lines lol

sonic sky
#

Damn

rough drift
#

Threadpool in java only took me one line

sonic sky
#

lol

tardy delta
#

shuuuu

quiet ice
#

Ctrl + Shift + Up/Down is also a very nice keybind in eclipse. It moves the cursor to the name of the next/previous field or method or class declaration

rough drift
#

Executors.newFixedThreadPool(4);

tardy delta
#

smh i mean impl

round finch
#

@round finch failed to connect to support
try agein

rough drift
#

Why reimplement

tardy delta
#

anyways eating time

round finch
#

what rust language for?

sonic sky
#

Web iirc

round finch
#

neat

buoyant viper
#

wat

sonic sky
#

systems programming language

smoky oak
#

okay so either im stupid or adding a character doesnt modify the message sent

buoyant viper
#

what

smoky oak
#
char prefix = 0xE2;
playerChatEvent.setMessage(prefix+playerChatEvent.getMessage());
#

but i can still chat report it

#

apparantly

#

how do i change color again anyways

#

oh wait it gives an error now after like a minute

buoyant viper
#

like the little warning symbol next to chat message?

smoky oak
#

yea

#

also

buoyant viper
#

only shows if ur focused in chat btw

smoky oak
#

EventChangeChatMessage cannot be triggered asynchronously from another thread.

#

?

#

that wasnt in the event api tutorial

onyx fjord
#

just send as system ๐Ÿ˜Ž

buoyant viper
#

just enable previews and show preview

#

ezpz

smoky oak
#

whats preview

onyx fjord
#

previews annoy me

#

cuz it has a delay

buoyant viper
smoky oak
#

that doesnt really help me here

buoyant viper
#

also what stops the unverified message thing

smoky oak
#

how do i fix that error

buoyant viper
#

yeah idk what EventChangeChatMessage is

smoky oak
#

thats custom

#

the issue is

#

all it does is providing a event hook so that the playerAsyncChatEvent can be handled by another plugin

vital sandal
#

Does running 2 bukkitrunable loop worse than 1

smoky oak
#

most of the time yes, but its not really noticeable

onyx fjord
#

why cant i call package abstract

vital sandal
buoyant viper
#

probably can by editing the bytecode tbh

onyx fjord
#

ij just wont let me create the package

smoky oak
#

um what character encoding does minecraft use

#

im typing in the character hex codes for one symbol in the code and it spits out another in chat

buoyant viper
#

what symbol

smoky oak
#

null space

#

i tried 0xE2 and 0x80, resulting in รข and the not found symbol

vital sandal
#

Why hex code ?

#

U can use lots lof symbol in mc

smoky oak
#

cuz i have seen code break a many time by trying to insert a symbol into the code directly

vital sandal
#

How ?

smoky oak
#

replaces everything with ?

#

dunno why

#

but it happens

vital sandal
#

Huh ?

#

Example ?

smoky oak
#

โ•ฆ for example

#

โ•‰ breaks too

buoyant viper
#

i like the section sign in code

reef lagoon
#

0x20

buoyant viper
#

because it doesn't translate well between eclipse and intellij

smoky oak
buoyant viper
#

had a lot of issues with people who sent me their code from eclipse to help and importing it into intellij just showed a question mark in a diamond

#

ticks

#

someone was doing stuff with it earlier

#

oh

vital sandal
#

Crtl B or Cmd B to see it sources

smoky oak
#

bruhlol

onyx fjord
#

do i need packets to retrieve client brand?

smoky oak
#

it replaces the zero width space with

โ”Œโ”€โ”€โ”
โ”‚ZWโ”‚
โ”‚SPโ”‚
โ””โ”€โ”€โ”˜
onyx fjord
#

im aware

#

my goal isnt to block hacked clients

#

yeah which one is it

buoyant viper
#

gonna go out on a whim and say its ticks

buoyant viper
smoky oak
# buoyant viper

ive no idea what you did but when i type in &ctext it says in chat &ctext

buoyant viper
#

ChatColor.translateAlternateColorCode or watever it is

shadow zinc
#

any way to run code on a minimessage click event instead of having to run a command?

smoky oak
#

iunno

reef lagoon
#

sheesh

onyx fjord
#

okay looks like i dont even need packets ๐Ÿ˜„

quaint mantle
#

trying to make a function to access plugin's data folder in other classes than main, am I doing the right thing ?

public class Main extends JavaPlugin {
  private  File dataFolder = this.getDataFolder();

  @Override
    public void onEnable() {
      // stuff here
    }

  public File getFolder() {return dataFolder;}


}
smoky oak
#

sounds about right

#

remember that u cant escape ur datafolder

#

also

quaint mantle
smoky oak
#

you cant go out of that and access files outside that folder

#

also

#

do the dataFolder assignment in the onEnable

onyx fjord
#

can i have enum value return something else?

smoky oak
#

enum can only return the enums in it

#

or null i think

onyx fjord
#

what was the thing called? enum map?

quaint mantle
smoky oak
#

well you can split variables in creation and assignment

crude coyote
#

Who can create cheats?

smoky oak
#

just do private File dataFolder; in your class, and do dataFolder = this.getDataFolder(); in your onEnable

quaint mantle
reef lagoon
#

I swear skript made me call events by their actual names

smoky oak
#

well if you dont it wont be assigned

#

and youll get null errors

quaint mantle
#

just trying to make sense of what i do

smoky oak
#

eh thats fair

vital sandal
#

I didnt get the use of enum

#

What can it be use for

smoky oak
#

well

#

an enum is a list of CAPS_TYPED words

#

its use is to declare what something can be

#

for example

#
enum Color{
  COLOR_BLUE,
  COLOR_RED
}
#

in this case, COLOR_GREEN doesnt exist and you cant call it

vital sandal
#

I mean what can it really do ?

#

We can just create a color class for that

opal juniper
#

It provides constant values whilst abstracting underlying code

onyx fjord
vital sandal
#

I think i am abusing hash map :l

opal juniper
#
public enum Color {
    
    RED("FF0000");
    
    private final String hex;
    
    Color(String hex) {
        this.hex = hex;
    }
    
    public String getHex() {
        return this.hex;
    }
}

For example

vital sandal
flint coyote
#

enums are great for constant options

onyx fjord
vital sandal
#

I have tons of hash map like
Hashmap<Object,HashMap<Object,HashMap<Object,Object>>>

#

Is that a good option

opal juniper
#

ew

flint coyote
#

๐Ÿ’€

opal juniper
#

i mean if you need it, fine. But what is it storing? normally you can extract a middle layer or two

flint coyote
#

that looks like you don't wanna use oop

vital sandal
#

oop ?

flint coyote
#

object oriented programming. Classes that have a state

onyx fjord
#

oop is consentiual torture

flint coyote
#

it's better than functional programming. Especially when using an ide

onyx fjord
#

at which login event do we get the actual player

#

prelogin afaik doesnt give you the player

vital sandal
#

PlayerLoginEvent ?

onyx fjord
#

actually ๐Ÿคฆโ€โ™‚๏ธ i already have a listener

vital sandal
#

I do use oop but for auto-maintain values so i use hashmap :L

flint coyote
#

but why do you need a 3 times nested hashmap?

vital sandal
#

Saving playerdata :l

opal juniper
# vital sandal I have tons of hash map like Hashmap<Object,HashMap<Object,HashMap<Object,Objec...

As an example:

Map<UUID, Map<Long, ChunkSnapshot>> snapshotsByWorld = new HashMap<>();
ChunkSnapshot chunkSnapshot = snapshotsByWorld.get(world.getUID()).get(chunk.getChunkKey());

Is kinda gross, so instead:

public class WorldDomain {
    private Map<Long, ChunkSnapshot> snapshotMap;

    public WorldDomain() {
        this.snapshotMap = new HashMap<>();
    }

    public Optional<ChunkSnapshot> getSnapshot(Long key) {
        return Optional.ofNullable(snapshotMap.get(key));
    }
}

Declare a world domain class, and then you can do:

Map<UUID, WorldDomain> worldDomainMap = new HashMap<>();
Optional<ChunkSnapshot> snapshot = worldDomainMap.get(world.getUID()).getSnapshot(chunk.getChunkKey());
if (snapshot.isEmpty()) return;
...
#

obviously there aren't any of the put methods, but you get the idea

vital sandal
#

Hmm that is lot more work than just declearing like my code

opal juniper
#

but itโ€™s wayyyy more readable :)

vital sandal
#

I dont think so :))

tardy delta
#

yes lol

flint coyote
#

And then you can create different classes for that one.
Like SkyblockData LevelData etc

#

Then you can do
getSkyblockData(player).getIslandLevel()

#

something like that

#

and you will only have one Map<UUID, Playerdata>

vital sandal
#

Actually i used to think about this but i am to lazy to destroy my data structure =]]

#

And there must be some reason for why i didnt do this :l

amber bronze
#

rewrite it to classess

#

plz

flint coyote
#

I don't wanna sound rude but a 3 times nested HashMap with Object is far from "data structure"

vital sandal
#

I mean how my data is structed =]]

tardy delta
#

might want to fix this

flint coyote
vital sandal
#

One for database purposes and another is profiles system

flint coyote
# tardy delta might want to fix this

Why don't you create a function that gives you random numbers and operators instead of always typing it urself? Would also be good for time testing it a few thousand times

tardy delta
#

i have my test methods

#

just testing syntax

flint coyote
#

well time for round 3 then. What you are doing is actively avoiding OOP. While it might be readable for you (now), anybody else will be like "wtf is that" and in a year you will, too probably

#

Also you will get used to good practices this way. Learning is a step by step practice

flint coyote
vital sandal
#

I may refactor that this night :l hope it doesnt broken others functions

#

That class is relevant to like 30 classes which i wont happy if it break

flint coyote
#

Well you just refactor these functions/classes, too

vital sandal
#

Seem painful

flint coyote
#

Not more painful than working with a 3 times nested hashmap that makes code pretty much unreadable ๐Ÿ’€

vital sandal
#

And is there a better way to save data like player inventory/classes with data without encoded it into a string

flint coyote
#

By save you mean persistent?

tardy delta
ivory sleet
#

Ofc that can also be represented as a string

vital sandal
ivory sleet
#

Or if you wanna use sql

vital sandal
#

^

flint coyote
#

If you wanna save it during runtime or over restarts

vital sandal
#

Playerdata is save after logout and load after login

ivory sleet
#

Well then you just take ur beans/pojos/data classes and write a sql statement parser that converts former to latter

#

(Also a parser for the converse maybe)

flint coyote
vital sandal
#

:l that is no better than encode it to string

ivory sleet
#

It is

flint coyote
#

How is that not better?

ivory sleet
#

Because you dont have to work with blobs necessarily

opal juniper
#

is there the same thing as python pickle in java

ivory sleet
#

You can only update parts of your data representation without having to fetch unnecessary data (w/sql)

opal juniper
#

it serializes an entire object, and then can be reloaded

vital sandal
#

I wanna sure so i want to update all the data :l

ivory sleet
#

All the time?

#

Then use a string format or binary format

vital sandal
#

Well yeh

young knoll
#

Save the data to yml, then zip that file and shove it in the database /s

flint coyote
rotund pond
#

I have a little question: How would you define what "runtime" means ?
I'm french, and this thing means so much things and nothing at the same time to me

vital sandal
#

My datastruct is much confusing than just normal :l

tardy delta
#

use gson and save the base64 json contents into the database

vital sandal
#

It have childs of childs of childs

ivory sleet
#

I mean thats common

vital sandal
flint coyote
young knoll
#

When I figured out how to turn items and entities into a blob

#

It was amazing

rotund pond
flint coyote
#

yes

rotund pond
#

This makes sense now, I thought it was the starting of the server or so

Thank you ๐Ÿ’

flint coyote
#

even when the server is empty you are at runtime because your server and plugin is still running

quiet ice
#

Runtime can be the entire lifecycle of the application but it can also be a very specific part of that lifecycle

#

But in spigot space the time between startup and shutdown is more or less guaranteed to be "runtime" outside of those micro-tasks that do not run in that timespan

sacred mountain
#

what's the best way to save a nested list of objects into a file

#

preferably something json or gson or bson or whatever it's called

opal juniper
#

its gson

sacred mountain
#

alright

#

how should i do so?

flint coyote
sacred mountain
#

alright

#

thanks

#

something lke this?

tardy delta
#

im doing my shit like this

opal juniper
flint coyote
tardy delta
#

Files.writeString(file.toPath(), jsonString) hehe

onyx fjord
#

how do u run chunks of code in ij

tardy delta
#

uhh what code

#

when its some random code, i just write a main method and run that

sacred mountain
#

holy thats clean

#

any changes i should make?

#

i'm not seperating it from the listener class just because. thats the only instance of me using it

#

or should i save the gson instance in the main class

flint coyote
#

You don't have to separate it in that case but you are still creating a new Instance during every event. You should create it outside of the event call

vital sandal
#

I want to create a new class as EntityLiving for storing entity custom data and how can i create a system which loop listen for datachanges without a Bukkitrunnable for every entity?

sacred mountain
#

yeah

tardy delta
#

had to write three typeadapters to be able to let gson serialize my player wrapper ๐Ÿ’€

sacred mountain
#

lmfao

#

i like to think my wrappers are clean

#

they all end up back at simple stuff or primitives

tardy delta
#

i stopped using gson cuz i had to write too many adapters

flint coyote
smoky oak
#

dont

lost matrix
#

You can create a new PersistentDataType<ItemStack> and then use it

smoky oak
#

i did it once

eternal night
#

tho lists are pretty unsupported

smoky oak
#

the resulting mess was impossible to untangle

eternal night
#

there are libraries out there that do all of that for you

sacred mountain
#

i only use pdc for carrying data

tardy delta
sacred mountain
#

small bits

smoky oak
#

nearly half a mb of junk data cuz i messed up a loop

eternal night
#

skill issue ? xD

sacred mountain
#

for instance the shooter of a fireball in a custom gamemode

eternal night
#

jk jk

smoky oak
#

no

#

i idiot just also saved zeroes

tardy delta
#

iirc uuid isnt even working with gson cuz there is no String field in UUId class or smth

smoky oak
#

intelligence issue

tardy delta
#

how can i save my database into the world pdc /j

eternal night
#

pick one

#

then you get PersistentDataType<?, List<ItemStack>> ITEM_STACK_LIST = DataTypes.list(DataTypes.ITEM_STACK); (for the decalium one)

#

as easy as that

flint coyote
#

Do scoreboardTags still make sense since pdc exists?

eternal night
#

meh

#

its a data type

flint coyote
#

ScoreboardTags are more of an ancient feature these days, right?

sacred mountain
#

yh

lost matrix
#

I wrote a universal type that simply throws everything into an uber Gson instance.
I can serialize whatever i want.

sacred mountain
#

dam

torn shuttle
#

fun question, are plugins which require a fork or spigot to run allowed on spigot?

quiet ice
#

If they REQUIRE a fork of spigot to run, no

#

If they RECOMMEND a fork of spigot to run, I believe that they are allowed

#

Or better said - If the work mostly fine on spigot it is allowed, but if they don't work at all on spigot no

torn shuttle
#

yeah that's what I figured

quiet ice
#

If they do not work on craftbukkit or outdated versions noone will care

sacred mountain
#

haahha. what if my plugins don't work at all

#

๐Ÿ˜

quiet ice
sacred mountain
#

lmao

torn shuttle
#

I have a project that relied on a fork for entity Navigation and goal editing right now, it's probably just going to teleport shit around every tick on basic spigot

#

really wish we had a better way to do it on spigot

sacred mountain
#

isnt there mojang goal navi

quiet ice
#

I myself have a few plugins that depend on adventure, they never saw the light of day on spigot

quiet ice
sacred mountain
#

it was very fun

#

it plays snake standalone too

quiet ice
#

If you control the event constructor, just make it throw if it is called too often

sacred mountain
#

paper it was some custom zombie stuff, spigot was throwable tnt and fireballs, worked a mod but that took a while

quiet ice
#

Although that wouldn't prohibit re-calling the event

#

So just a nice cooldown and nothing with means?

torn shuttle
#

I might still change the code to rely on mappings instead of the paper api, don't really know yet but it's a pain

smoky oak
# vital sandal .

list of all custom entities, loaded when chunk loads. iterate that list

quiet ice
#

If you want something with means, I'd go with the ArrayDeque and a bunch of Instant objects in it - the size of that deque is how often it was invoked in the period

#

And you remove all instants that are older than your wished period before polling

vital sandal
#

Try Pho

quiet ice
#

If it is just a hard cooldown, then just use a singular Instant that is updated whenever it is fired

tardy delta
#

why not just have once Instant field in your event class

#

dont understand the need for a deque

#

or is it per player or whatever?

quiet ice
#

This si what I mean with deque

#

I'll just write some code since this is being asked rather often

vital sandal
#

Check its age

tardy delta
#

(Breedable) entity).canBreed()?

vital sandal
#

Try nms

eternal oxide
#

often the search box on the javadocs has your answers.

tardy delta
#

or spigot forum

quiet ice
#

@quaint mantle

package de.geolykt.starloader.launcher;

import java.util.ArrayDeque;
import java.util.Deque;

import org.jetbrains.annotations.Nullable;

public class ReverseDelayedDeque<T> {

    private class ReverseDelayedObject<T> {
        private final long expireTime;
        private final T element;

        public ReverseDelayedObject(long expireTime, T element) {
            this.expireTime = expireTime;
            this.element = element;
        }

        public T getElement() {
            return element;
        }

        public long getExpireTime() {
            return expireTime;
        }
    }

    private final Deque<ReverseDelayedObject<T>> objects = new ArrayDeque<>();
    private final long period;

    public ReverseDelayedDeque(long period) {
        this.period = period;
    }

    public void addElement(T element) {
        objects.add(new ReverseDelayedObject<>(System.currentTimeMillis() + period, element));
    }

    @Nullable
    public T removeElement() {
        ReverseDelayedObject<T> object = objects.getFirst();
        if (object.getExpireTime() <= System.currentTimeMillis()) {
            objects.poll();
            return object.getElement();
        }
        return null;
    }

    public int getSize() {
        return objects.size();
    }
}
#

Basically a DelayDeque but a bit differently - I think

tardy delta
#

hmm made smth related

quiet ice
#

handling cooldowns

#

This is the thing I meant with means

quiet ice
#

Allows one to buffer cooldowns and whatnot

#

that wouldn't be smooth

#

Such an approach is what I call a hard-cooldown

#

Hence why I asked whether you wanted something with means or not

onyx fjord
#

i suck at math badly

#

okay

quiet ice
#

If it isn't my optimized version of it already

scarlet creek
#

Iโ€™m trying to make a bow that shoots arrow that attracts mobs to it. However while testing, when shot, the arrow only makes mobs go in 1 direction and not towards the arrow no matter which direction the arrow is shot from

Code:

                List<Entity> nearbyMobs = arrow.getNearbyEntities(rangeX,rangeY,rangeZ);
                for (Entity entities : nearbyMobs){
                    if (entities.getType() != EntityType.PLAYER && entities.getType() != EntityType.ARROW){
                        entities.setVelocity(entities.getLocation().add(arrowLocation).toVector().normalize().multiply(1.5));
                    }
                }```
#

Hoping if someone can help out and see whatโ€™s wrong?

tardy delta
onyx fjord
#
long startMilis = System.currentTimeMillis();

V Bukkit scheduler running every second
String humanTime = formatSeconds(((System.currentTimeMillis() - startMilis) / 1000));

this unfortunately increases instead of decreasing
tardy delta
#

just pass in millis lol

onyx fjord
#

i need it to lower lol

#

what

#

wdym

#

formatseconds wants seconds btw

#

thats why i divide those

onyx fjord
tardy delta
#

kinda sucks to do conversions everytime

quiet ice
#
long startMilis = System.currentTimeMillis();
String humanTime = formatSeconds((((startMilis + offset) - System.currentTimeMillis()) / 1000));
onyx fjord
#

but then it will be on minus no?

#

oh whats the offset lol

tardy delta
#

im using date api lol

quiet ice
#

If you want it to decrease you need to have a certain point of time where it is 0

#

And that certain point of time cannot be the past

#

Unless you want to display negative values

onyx fjord
#

i have my own thing for that stuff

quiet ice
#

Instant != Duration

onyx fjord
#

it dynamically gives hours minutes and seconds depending on input

#

it works, im not changing it

#

the problem is my calculations rather

onyx fjord
#

i set offset to the input (aka time of the said event) and it works

#

now gotta make fourteen happier

#

@scarlet creek i can give you vector im using for pulling

quiet ice
#
Duration.between(LocalDateTime.now(), LocalDateTime.ofInstant(Instant.ofEpochMilli(48546496), ZoneId.systemDefault())).toString()

get it right nerd

scarlet creek
quiet ice
#

Yes - which is ZoneId.systemDefault()

scarlet creek
#

Iโ€™m confusing myself with my own code

eternal night
#

cool kids hardcode their timezone to UTC

quiet ice
#

Do note that Instant is NOT timezone-specific

#

It is just that - an instant

river oracle
#

Timezones just suck

quiet ice
#

It gets neither

#

It only knows the epoch seconds and the nanoseconds within the second

#

Everything outside of that will throw an exception

#

Hence why you should use LocalDateTime

#

probably because you don't do maths with it

#

The JRE converts it to the UTC timezone when doing .toString

onyx fjord
#

@scarlet creek

player.getEyeLocation().toVector().subtract(
                item.getLocation().toVector()
        ).normalize().divide(multVector);

mult vector is the vector you multiply by

player.getEyeLocation() replace with entity locaion (your arrow i believe)

and item.getLocation() to entity location that you wanna pull

eternal oxide
#

no

quiet ice
#

oh well then the JRE converts it to the timezone of choice

eternal oxide
#

its simple math

onyx fjord
#

look

quiet ice
#

The ISO instant formatter that formats or parses an instant in UTC, such as '2011-12-03T10:15:30Z'.

onyx fjord
#

i passed math with 33% on exam

#

okay

quiet ice
#

Uh, it will print it to the UTC timezone

onyx fjord
#

33% is enough for me

quiet ice
#

So either you are lying with it changing the value when the timezone changes or you are not using instants

onyx fjord
#

i believe i asked that before but whatever

#

is doing clock async safe?

#

(accuracy doesnt matter)

quiet ice
#

Clock as in what?

onyx fjord
#

countdown from X to 0

#

it updates frequently

scarlet creek
vocal cloud
#

For clocks I much prefer storing the current time in millis + delay then comparing to that number for my countdowns. Prevents the need for moving parts so to speak

onyx fjord
scarlet creek
#

Ah

quiet ice
vital sandal
#

here is my DataHolder how can i encode this effectively :l

quiet ice
#

And for other things a volatile int might suffice too

tardy delta
#

lets not expose everything lol