#help-development
1 messages ยท Page 96 of 1
Anyhow, this is the current code...
why don't you save the item as base64
I know. Format the String.
It is saved with base64, but I'm switching the methods to use reflection
Where is CLASS coming from?
And you wont find a method which takes an Object as a parameter
Inside the class, in a static method, here...
private static final Class<?> CLASS = getNMSClass("ItemStack");```
Object is just a placeholder, due to this issue
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"
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
Indeed, but since i'm reflecting the code, the nbtTagClass would be a Class<NBTTagCompound>, which isn't an NBTTagCompound
But this looks like you are using 1.8 so thats all the help you gonna get from me
I see, thank you, still
Look at the variable names again
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.
How do you pass through your plugin instance to a dependency so that it can use it to call spigot methods?
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_?
Please dont use 1.8 spigot
?1.8
Too old! (Click the link to get the exact time)
I'm trying to update it
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
odd to use a villager as an npc as they are not skinnable
Thanks
But I don't wanna have to recode this if someone who knows a shit ton about NMS could explain it
You just want to know how to find the new value of a? I'm not sure what you're asking, maybe I missed something you said.
Also what is the new version you're porting it to
a_sorry ye and latest version so 1.19.2
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
there is a website with mappings, but I can;t remember its name.
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_
I might be on that website already not sure
yep thats it
Yeah thats how i found out that EntityVillager has a new name
But on that website I cannot find anything about a_ under EntityVillager
I don't see any obfuscated variables with a_ in Villager
what is the .a you are currently setting?
the current mappings https://nms.screamingsandals.org/1.18.2/net/minecraft/world/entity/npc/Villager.html
wel 1.18.2
yeah exactly what I'm saying
There isn't any a_ in Villager
I just checked 1.19.2 and that doesn't exist lol
But there was in EntityVillager
Yeah
Still no a_ lol
yes there is
there 2
one takes an EntityPlayer as an arg, the other takes an ItemStack
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?
so what are you passing to a_ in your 1.8 code?
Not called a_ though so I have no clue anymore.
ah just a then
There's no a field in 1.8.8 so I'm lost 
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
It was a typo before, I've edited the original message, I meant a_
Could be why
its a in goalSelector
How the fuck do I find R1 stuff then
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
It looks like all that code does is clear their goals
and set the targetSelector to EntityHuman
I have no idea how you're even able to make sense of it haha
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
parties?
yeah like player parties
im trying to think of a system that works cross server that doesn't require a central management server
redis
yeah might use redis
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
I mean
usually if redis gets wiped
it means the machine itself rebooted
I don't think that parties would need machine-reboot levels of persistence
or the redis process died
I meant more that if parties are to be persistent across restarts, which some people do want
I think that's more of a guild system than parties themselves
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)
That can never pass.
its impossible for it to be a Player but not a LivingEntity
oh yeah im stupid
ill just use iterator then
would it be possible to make a item break certain blocks faster?
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.
EntityPotionEffectEvent returns null for instant harm/heal, how can I detect if a potion someone uses is a instant harm/heal?
Both for the new and old effect?
yeaper
on?
Lol
EntityPotionEffectEvent -> getModifiedType()
It used to only be the bottom line
ahhh
I PRed better docs for a few effects a while back
its speaking dolphin
How can I make it so only certain players can see certain blocks?
declaration: package: org.bukkit.entity, interface: Player
Wow ok - is this permanent?
as in like the block won't switch back to what it was before?
No. If the block updates in any way then the original is being sent to the player again
Ok, thank you!
@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
Do an error elimination procedure
I was trying it before the Player if Statement
Does it fire?
um, does not seem too
Drink a normal potion. Do you see anything then?
yeah nothing
not even printing the -----
its working for all the other potions = (
Did you add an EventHandler annotation? Did you register the listener?
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
Well then the event is simply not fired for instant effects. Kinda meh.
= / maybe its a different event
Well there are several events that are being fired in this instant. EntityRegainHealthEvent and EntityDamageEvent (just as an example)
I can do the Instant Harm using the EntityDamageEvent and . . . yeah that
@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
You need to type cast the CallbackPacket
MECallbackPacket<MECallbackResponsePacket> callbackPacket = (MECallbackPacket<MECallbackResponsePacket>) activeCallbackPackets.get(uuid);
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
just grabbing some links
finally, got my redis packet system working
can query all players on the network pog
What do you mean by query a player
do you store all packages? idk wut
that sounds kinda cool
pretty neat
Sounds like 10 lines of work...
this is for more than just that lmao
Are you using Redisson?
gonna be used for alotta stuff
just setting up the building blocks
nah jedis
never heard of redisson
smh
lmao
Redisson has a ton of utility
https://github.com/redisson/redisson/wiki/6.-distributed-objects/#67-topic
pub sub is really clean with this
doesnt look nuch different to jedis
Jedis only supports sending Strings through channels iirc
With Redisson you can directly send objects if you use the right codec
any algorithmic way to figure out fill inside block lines
this is for a spigot plugin
Sure. As long as you know how to check the constraints you can do a simple flood fill algorithm.
I mean you can just continue in each direction until it hits a block
thinking about generating random shapes and fill them in
Is your problem checking if a block is inside your shape?
How can I get the minecraftkey from a nms enchant
just needed to know if the filling is inside the lines
What do you need this for anyways?
exactly
Fun and challenge
Do you want the internal type? Because Bukkit's Enchantment implements Keyed so you can just call getKey() to get a NamespacedKey
what do you know
like what is the information you have when you make these shapes
Yeah getting the minecraftkey from the net.minecraft.world.item.enchantment class
Right but why? What's wrong with API?
Getting it with nms to add custom enchant to the enchant table
Thank you (Saving this!)
Btw this is not a trivial problem
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
Okay second question looks like there are mappings I can use... Where can I find those?
I'm updating someone elses from 1.18
Thank you
Nice, now I can "map" all the possible block spots inside
Okay last question (I think) is there any way I can easily just convert my current code to use the mappings?
Not that I'm aware of
Alright thank you
is it possible to have spigot doc in your eclipse?
i forger
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
hmmm ๐ค
can you do directly in ecplise?
Just with classpath dependency you mean?
i wanna be lazy
but at the same time i guess you could just run maven
Oh are you just wanting to open a browser in your IDE?
I mean you can open a browser with Ctrl + 3, then writing "Open Browser"
Then just navigate to the Javadocs
?jd
just wanna be able to see then i'm typing
Like a fancy pants
and check doc
Okay, so how are you depending on Spigot? Maven? Gradle? Or classpath?
Yeah
.
Have to be depending on the spigot-api dependency though because that's the one with attached Javadocs
do i have to get Maven Project for that
or can i just run maven project file
inside of my project
Well your project has to be using Maven
wtf is p suffix in java
indicates a hexadecimal floating-point literal, where the significand is specified in hex.
How do you pass through your plugin instance to a dependency so that it can use it to call spigot methods?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
// 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
Anyone here know of someone that can make Skripts?
Lord if you want someone to make skripts ๐ please just hire an actual java developer to make a plugin for you
Skript is pretty much worse in every fassion
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
@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.
skript is not more light weight
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
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
is giveBow in your plugin.yml
Yes?
giveBow:
description: Give test bow
usage: /<command>
customEnchant:
description: enchant item
usage: /<command>
aliases:
- ce```
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
Oh I see
Is it possible to force a player to swimming pose?
Player#setSwimming I believe
if that doesn't work how you want it next best option would probably be packets
declaration: package: org.bukkit.entity, interface: LivingEntity
entities other than humans can swim? 
all the way down to LivingEntity can
including drownd etc
I think drowned is the only other entity that can swim
though I may be wrong
like with a real swimming animation?
yea
I saw another spigot thread that said to use this and everyone else said it was buggy asf
But I haven't tried it yet
so I'll see
Nope removing it still gives the error
wtf
maybe its case sensitive
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?
If you tp a player to An unloade chunk, it Starts falling right
Wondering if the same thing happens with entities
Is there a way to detect when a player sneaks but not when they release the sneak key?
Player#isSneaking and PlayerToggleSneakEvent iirc
Thanks!
They don't actually start falling server side, it's because the client doesn't know the hit boxes
Oh
I'm pretty sure entities just float in place
y eclipse
should i cache the logger or should i call plugin.getlogger every time
doesnt matter, probably results the same anyways
version
on 1.19.2
Data generators
I'm using packets to simulate block breaking but Idk how to reset it...
Probably by sending a packet that places the block again
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
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
doesnt the player class have a issneaking method
declaration: package: org.bukkit.event.inventory, enum: ClickType
There is SHIFT_LEFT and SHIFT_RIGHT
you can get a ClickType from the InventoryClickEvent
Ah yes. My favorite shift. Right shift
that too
lol
Anyone know how to get a net.minecraft.world.level.block.Block from a org.bukkit Block object?
Why aren't you simply using the Spigot API https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#sendBlockChange(org.bukkit.Location,org.bukkit.block.data.BlockData)
declaration: package: org.bukkit.entity, interface: Player
Can this be used to change the block destruction stage?
(CraftBlock) block
Yes there's also a sendBlockDamage method
assuming remapped
Oh nice
I know, it's kinda impressive that they have an API for that. Couldn'r believe it myself the first time
player.sendBlockDamage(block.getLocation(), 0);
Still can't seem to reset block damage progress
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);
}
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
You need to update your Java runtime
You need to tell it to use Java 8 when compiling
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);
}
How can I do that?
if I don't compile it with java 16 I can a cannot access error
Could you send that error?
yep give me abit
wait the error you sent earlier happens when compiling or when launching your server?
running in server
then uhh change your server version (java) or am I dumb?
yes
its not for my server, its a plugin for all versions and for all java versions
Ohh
progress = 0?
Yeah, I am trying to reset the progress of a damaged block
I fixed it another way because I'm a fucking genius. Have a good day
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
If I use the players entityId it seems to work, it's just very buggy
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);
}
PROTECTION_ENVIRONMENTAL is normal protection right?
math weird
tf ur doing
just wondering why 100^some big number prints Infinity to console
some times
mye
I'd like defined behaviour please
it is defined in some contexes
seems like Math::pow checks for infinite stuff
no Infinity is caused by classes/wrappers
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));
}
}
}```
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
normalize makes it between 0 and 1
multiplying by 1 makes it same
you want to multiply by like 1.5 or higher
How do I stop this happening when I relocate my NeoConfig lib?
org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.neomechanical.neoconfig.NeoConfig'```
-how the fuck
?paste
code
just got ouf of my bed
this is my pom https://paste.md-5.net/famiwakoro.xml
are there any good inventory apis? i hate the bukkit one with passion
it replaced the dot with a plus
well its not the math, its the parser which creates operands which goes brr
Ah
use mine, its god tier
mind sending a link in dms?
send it here
eh ok
na use this https://github.com/TriumphTeam/triumph-gui
thats not mine
its better i think
the moment he stopped believing in his power
the only thing about copilot is that idk if it works
lol
71KB :/
what?
Eh i'll make a miniscule lib
the one u sent
class legitJava{;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;public static void main(String[] args){
;;;;;;;;System.out.println("HelloWorld");;;
;;;;};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
OH I FOUND THE ONE I LIKED ALL THE TIME
this one was my fav https://github.com/Phoenix616/InventoryGui
phoenix does good shit
like mindown
tho iridium color api is superior for its size
like 10kb shaded i believe
yes im expert for sure ๐
[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
do u relocate a plugin or what
yes
did in the past
maybe theres a variable though
is that ` symbol in the config
file
whatever
if yes remove and try again
i wondered how those variables work in plugin.yml
what variables?
maven just replaces all patterns with values from pom.xml
it's a string replacement
that maven runs on resources
wouldnt you be able to replace main: with variable from maven or something
idk, you know more than me
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
whats this for?
which part
all of it
thats the plugin yml
but why?
sans commands and permissions
i don't understand
so ur lib is a plugin?
yes
why is that
reasons
yes
looks kinda bloat
there is no good reason to use your own plugin as a lib, people would you are just being lazy
ur tripping
why might my lib not be working now when it was a week ago? Very little was changed.
They don't unless you enable filtering
Otherwise it is the good old ${property}
What did you change
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
Exclude the plugin.yml file in the shade plugin
hey, is there an api to convert worldedit .schematics to .obj?
there r gui tools for that i believe
ngl
cobalt cape is awesome
better than all the minecons
except 2015 and 2016
theyre both cool
cobalt cope?
k
||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
๐คจ
yeah thanks, but thats the wrong direction, maybe this works: https://www.spigotmc.org/resources/voxelvert-ingame-3d-converter-file-browser-and-downloader-1-12-1-13.50383/
switch to ij ๐
how do i implement a custom event without implementing it twice
Is that eclipse?
yes
eclipse ppl are W
havn't downloaded it yet 
Old school lol
its still getting updates
Old school
professional devs also use vim or emacs
Notch
old tools indeed, but not dead
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
IntelliJ Project Directory and building jar has left me confused when I first tried it
^^
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
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
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
vsc looks nice if you know how to set it up
if
gotta tinker
When I was setting it up had me contemplating just moving to Code::Blocks
my vsc looks hot
RS? Rust?
yes
its a text editor
i forgor what rust?
mozilla language
mine hotter, what distro tho
the crab
Myb
windows ๐
Eclipse uses it for a smarter keybind
bad
mozilla is just sponsor
What bind?
need help to import spigot doc into eclipse
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)
rust be like
threadpool in rust only took me 105 lines lol
Damn
Threadpool in java only took me one line
lol
shuuuu
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
Executors.newFixedThreadPool(4);
smh i mean impl
@round finch failed to connect to support
try agein
Why reimplement
anyways eating time
what rust language for?
Web iirc
neat
wat
systems programming language
okay so either im stupid or adding a character doesnt modify the message sent
what
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
like the little warning symbol next to chat message?
only shows if ur focused in chat btw
EventChangeChatMessage cannot be triggered asynchronously from another thread.
?
that wasnt in the event api tutorial
just send as system ๐
whats preview
that doesnt really help me here
also what stops the unverified message thing
how do i fix that error
yeah idk what EventChangeChatMessage is
thats custom
the issue is
all it does is providing a event hook so that the playerAsyncChatEvent can be handled by another plugin
Does running 2 bukkitrunable loop worse than 1
most of the time yes, but its not really noticeable
why cant i call package abstract
Code ?
probably can by editing the bytecode tbh
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
what symbol
cuz i have seen code break a many time by trying to insert a symbol into the code directly
How ?
i like the section sign in code
0x20
because it doesn't translate well between eclipse and intellij
thats just a space
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
Crtl B or Cmd B to see it sources
bruhlol
do i need packets to retrieve client brand?
it replaces the zero width space with
โโโโ
โZWโ
โSPโ
โโโโ
i only know it by its old packet name but it /should/ be CustomPayload iirc
ive no idea what you did but when i type in &ctext it says in chat &ctext
ChatColor.translateAlternateColorCode or watever it is
any way to run code on a minimessage click event instead of having to run a command?
iunno
sheesh
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;}
}
I dont get what you mean ..
you cant go out of that and access files outside that folder
also
do the dataFolder assignment in the onEnable
can i have enum value return something else?
what was the thing called? enum map?
I'm quite new to plugins how can I do that ? ๐
well you can split variables in creation and assignment
Who can create cheats?
just do private File dataFolder; in your class, and do dataFolder = this.getDataFolder(); in your onEnable
do i have to explicitly mention that in the onEnable ?
I swear skript made me call events by their actual names
ah right gotcha
just trying to make sense of what i do
eh thats fair
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
It provides constant values whilst abstracting underlying code
labels ๐
I think i am abusing hash map :l
public enum Color {
RED("FF0000");
private final String hex;
Color(String hex) {
this.hex = hex;
}
public String getHex() {
return this.hex;
}
}
For example
This is better example
enums are great for constant options
lol literally made something like this 5 minutes ago
I have tons of hash map like
Hashmap<Object,HashMap<Object,HashMap<Object,Object>>>
Is that a good option
ew
๐
i mean if you need it, fine. But what is it storing? normally you can extract a middle layer or two
that looks like you don't wanna use oop
oop ?
object oriented programming. Classes that have a state
oop is consentiual torture
it's better than functional programming. Especially when using an ide
at which login event do we get the actual player
prelogin afaik doesnt give you the player
PlayerLoginEvent ?
actually ๐คฆโโ๏ธ i already have a listener
I do use oop but for auto-maintain values so i use hashmap :L
but why do you need a 3 times nested hashmap?
Saving playerdata :l
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
Hmm that is lot more work than just declearing like my code
but itโs wayyyy more readable :)
I dont think so :))
yes lol
Why don't you create a class called playerdata and store it in there?
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>
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
I don't wanna sound rude but a 3 times nested HashMap with Object is far from "data structure"
I mean how my data is structed =]]
might want to fix this
probably because you didn't know better. And that's fine. I constantly refactor my code when learning new good pratices
It was 2 times in this week that i refactor my code :l
One for database purposes and another is profiles system
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
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
ah ok
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
Well you just refactor these functions/classes, too
Seem painful
Not more painful than working with a 3 times nested hashmap that makes code pretty much unreadable ๐
And is there a better way to save data like player inventory/classes with data without encoded it into a string
By save you mean persistent?
mehh
I mean you could have a binary format
Ofc that can also be represented as a string
? What does that mean
Or if you wanna use sql
^
If you wanna save it during runtime or over restarts
Playerdata is save after logout and load after login
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)
well in a relational database you would make a data model for them
:l that is no better than encode it to string
It is
How is that not better?
Because you dont have to work with blobs necessarily
is there the same thing as python pickle in java
You can only update parts of your data representation without having to fetch unnecessary data (w/sql)
it serializes an entire object, and then can be reloaded
I wanna sure so i want to update all the data :l
Well yeh
Save the data to yml, then zip that file and shove it in the database /s
but for the times unzipping takes too long you should also save it as a clob for quicker access /s
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
My datastruct is much confusing than just normal :l
use gson and save the base64 json contents into the database
It have childs of childs of childs
I mean thats common
Tried but not for mines
Runtime is when the application is running. Means while your server is up and your plugin is loaded you are at runtime. As soon as the plugin/server is shut down it ends the runtime
Alright, so when players are playing on the serveur, we are at runtime ?
yes
This makes sense now, I thought it was the starting of the server or so
Thank you ๐
even when the server is empty you are at runtime because your server and plugin is still running
It depends on the conext
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
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
its gson
im doing my shit like this
looks good, but cache your GSON instance
I would create a class that handles your file and caches the FileWriter and Gson etc. Besides that, yes that's pretty much how it works.
Files.writeString(file.toPath(), jsonString) hehe
how do u run chunks of code in ij
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
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
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?
yeah
had to write three typeadapters to be able to let gson serialize my player wrapper ๐
lmfao
i like to think my wrappers are clean
they all end up back at simple stuff or primitives
i stopped using gson cuz i had to write too many adapters
why would you need adapters? Aren't javas default data types enough for you?
dont
You can create a new PersistentDataType<ItemStack> and then use it
i did it once
tho lists are pretty unsupported
the resulting mess was impossible to untangle
there are libraries out there that do all of that for you
i only use pdc for carrying data
nah like it doesnt know how to serialize a weakreference, records, and weird classes
small bits
nearly half a mb of junk data cuz i messed up a loop
skill issue ? xD
for instance the shooter of a fireball in a custom gamemode
jk jk
ah I see. Makes sense
iirc uuid isnt even working with gson cuz there is no String field in UUId class or smth
intelligence issue
how can i save my database into the world pdc /j
pick one
then you get PersistentDataType<?, List<ItemStack>> ITEM_STACK_LIST = DataTypes.list(DataTypes.ITEM_STACK); (for the decalium one)
as easy as that
Do scoreboardTags still make sense since pdc exists?
ScoreboardTags are more of an ancient feature these days, right?
yh
I wrote a universal type that simply throws everything into an uber Gson instance.
I can serialize whatever i want.
dam
fun question, are plugins which require a fork or spigot to run allowed on spigot?
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
yeah that's what I figured
If they do not work on craftbukkit or outdated versions noone will care
Then it isn't allowed
lmao
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
isnt there mojang goal navi
I myself have a few plugins that depend on adventure, they never saw the light of day on spigot
that is nms, which has it's downsides
i have a plugin that had a different purpose on every single server type
it was very fun
it plays snake standalone too
If you control the event constructor, just make it throw if it is called too often
paper it was some custom zombie stuff, spigot was throwable tnt and fireballs, worked a mod but that took a while
Although that wouldn't prohibit re-calling the event
So just a nice cooldown and nothing with means?
.
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
list of all custom entities, loaded when chunk loads. iterate that list
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
Try Pho
If it is just a hard cooldown, then just use a singular Instant that is updated whenever it is fired
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?
This si what I mean with deque
I'll just write some code since this is being asked rather often
Check its age
(Breedable) entity).canBreed()?
Try nms
or spigot forum
@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
hmm made smth related
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
I believe I had written a more optimized version of it
If it isn't my optimized version of it already
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?
mye stopped using it for a while cuz the bukkittask broke when reloading
long startMilis = System.currentTimeMillis();
V Bukkit scheduler running every second
String humanTime = formatSeconds(((System.currentTimeMillis() - startMilis) / 1000));
this unfortunately increases instead of decreasing
just pass in millis lol
i need it to lower lol
what
wdym
formatseconds wants seconds btw
thats why i divide those
wdym brah
kinda sucks to do conversions everytime
long startMilis = System.currentTimeMillis();
String humanTime = formatSeconds((((startMilis + offset) - System.currentTimeMillis()) / 1000));
im using date api lol
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
i have my own thing for that stuff
Instant != Duration
it dynamically gives hours minutes and seconds depending on input
it works, im not changing it
the problem is my calculations rather
๐
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
Duration.between(LocalDateTime.now(), LocalDateTime.ofInstant(Instant.ofEpochMilli(48546496), ZoneId.systemDefault())).toString()
get it right nerd
๐ฎ thanks
Yes - which is ZoneId.systemDefault()
Iโm confusing myself with my own code
cool kids hardcode their timezone to UTC
Timezones just suck
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
@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
Thanks!
no
oh well then the JRE converts it to the timezone of choice
its simple math
look
The ISO instant formatter that formats or parses an instant in UTC, such as '2011-12-03T10:15:30Z'.
Uh, it will print it to the UTC timezone
33% is enough for me
So either you are lying with it changing the value when the timezone changes or you are not using instants
i believe i asked that before but whatever
is doing clock async safe?
(accuracy doesnt matter)
Clock as in what?
Wait what do you mean by vector you multiply by?
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
new Vector(1.5, 1, 1.5)
can be simplified i believe if you do all directions
Ah
If you are using things like AtomicLong or AtomicInteger it is thread safe
here is my DataHolder how can i encode this effectively :l
And for other things a volatile int might suffice too
lets not expose everything lol
