#help-development
1 messages ยท Page 2079 of 1
wut
actually minecraft supports multiline msgs but it has to be declared as char '\n' and not as appended string "\n"
I already see this but, how or where can i download protcollib?
just figured
if you just cancell the event why is the animation still there?
Chest open
public static String parseFormattedString(ArrayList<String> args)
{
String s = "";
Pattern p = Pattern.compile("#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})");
Matcher m = null;
for (String str : args)
{
m = p.matcher(str);
if (m.matches())
{
s += ChatColor.of(str);
}
else
{
s += str;
}
}
return s;
}
```can arraylists like this cause memory leaks?
when going out of scope
Don't think so, but avoid using string concatenation on a loop
StringBuilder is O(1)
Cast to lidded, use the open method
declaration: package: org.bukkit.block, interface: Lidded
thats just taking a bunch of strings and reformatting valid color codes tho
Yeah but its processing time increases exponentially
its just an example tho cause i dont want to cause memory leaks
to then regret it later
even if its not the question at hand you should seriously use java naming conventions
?conventions
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
Yes but in this code :
Event.setCancelled(true);
Chest chest = (Chest) block.getState();
chest.open();
Inventory inv = chest.getBlockInventory();
player.openInventory(inv);
It doesnt work
It does the same
~~can I somehow use wget to download plugins? my upload speed is being fuzzy and i dont want to wait
root@localhost:~/server/plugins# wget https://www.spigotmc.org/resources/viaversion.19254/download?version=443043
--2022-04-09 18:52:02-- https://www.spigotmc.org/resources/viaversion.19254/download?version=443043
Resolving www.spigotmc.org (www.spigotmc.org)... 2606:4700:21::681b:c35f, 2606:4700:21::681b:c45f, 104.27.195.95, ...
Connecting to www.spigotmc.org (www.spigotmc.org)|2606:4700:21::681b:c35f|:443... connected.
HTTP request sent, awaiting response... 503 Service Temporarily Unavailable
2022-04-09 18:52:02 ERROR 503: Service Temporarily Unavailable.
```~~
nvm :(
well you are calling chest.open
We cannot cancel the animation with that?
for whatever reason they are only spawning in one specific chunk https://paste.md-5.net/ucuvudobig.java
any ideas?
on why its happening
wdym
they spawn in no other chunks
only that one
even when the chunk is unloaded
yes, thats what im talking about
you need to find the issue to fix it
and debugging is the only way
is it somehow possible to activate spawners programatically?
normally they have a player activation range
i could not rlly find a way to do this
even upon creating a new world, it still spawns only in the chunk of 8 11
NPCs are the only way to do that ig
java.lang.NoClassDefFoundError: org/bukkit/plugin/messaging/PluginMessageListener
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at net.md_5.bungee.api.plugin.PluginClassloader.findClass(PluginClassloader.java:152)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at net.md_5.bungee.api.plugin.PluginClassloader.loadClass0(PluginClassloader.java:66)
at net.md_5.bungee.api.plugin.PluginClassloader.loadClass(PluginClassloader.java:59)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at net.md_5.bungee.api.plugin.PluginManager.enablePlugin(PluginManager.java:340)
at net.md_5.bungee.api.plugin.PluginManager.loadPlugins(PluginManager.java:250)
at net.md_5.bungee.BungeeCord.start(BungeeCord.java:271)
at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67)
at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
Caused by: java.lang.ClassNotFoundException: org.bukkit.plugin.messaging.PluginMessageListener
at net.md_5.bungee.api.plugin.PluginClassloader.loadClass0(PluginClassloader.java:103)
at net.md_5.bungee.api.plugin.PluginClassloader.loadClass(PluginClassloader.java:59)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 13 more
bungeecord plugin lmk if more info needed
pretty sure npcs dont activate them either
could be wrong
you cant use bukkit api in your bungee plugin
if you add the NPC to the world it does
For something like this, what would I do if I wanted to extend Projectile which would then take new parameters?
clientside npcs wont active the spawners ofc
np
I'm using this to simplify having multiple constructors like so
however I'm worried this will inhibit my ability to use inner classes like ```java
new Porjectile(){
@Override
project(){
//do new stuff
}
};
is there a safety check for valid numbers? I'm getting this when trying to calc a K/D ratio
java.lang.ArithmeticException: / by zero
at net.plexpvp.core.misc.npc.Stats.open(Stats.java:87) ~[PlexPvP-1.0-SNAPSHOT-all.jar:?]```
```java
Util.format("&8ยป &eK/D: &f" + data.getKills()/data.getDeaths())```
cant devide by 0
could you just check if data.getDeaths() == 0 before doing it and otherwise display something else?
what's spring?
uses floats
?paste
https://paste.md-5.net/zikoxaqawu.java
who wants to read my shitty class ๐
and figure out this bug
whenever multiple people are in the server, it spams the "You have entered a nest" to all players inside of a nest
whenever 1 person is in the server it works fine
How would I prevent elytra damage? It doesn't count as fall damage and I don't see a damage type for it.
i'm rewriting this whole damn thing ignore this
lol gl
lol
anyone?
why is this barely lasting any time at all
((Arrow) event.getProjectile()).addCustomEffect(new PotionEffect(PotionEffectType.LEVITATION, 10, 3, false, true), false);
like it lasts about 1 tick
even though its 10 second duration
or is it in ticks
its in ticks isnt it
it's in ticks, not seconds
fsuihufhdsjfhsdkdhfjdshkf
lole
it's always in ticks ๐
I think... I have found the answer to this question...
so it works...
kinda
however I have to make stuff public/protected if I want to be able to do this
why the sendTitle dont work
i tried with sendMessage and it worked
this is inside a sync runnable which is executed every tick
I think you need to provide a title as well, not just an empty string.
Np
Maybe you can do a static builder getter instead of calling directly the builder class
is there a javadoc macro to the effect of 'same javadoc as that method'?
using the PlayerItemHeldEvent event what's better?
A. using the newSlot number and getting the item using inventory method something like:player.inventory.getItem(newSlot
B. just use player.inventory.itemInHand?
How can I automatically deploy jar to my server after building? (best using intellij idea deploy tool)
yeah true. I still have to make the constructor of the Projectile class public tho
smth like:
public static SubClass builder() { return new SubClass(); }
can't do new SubClass()
without making the constructor public
has World::getNearbyEntities a spherical or cuboid area
I would assume spherical
probably finds magnitude of the difference between position vectors
which would result in spherical
that's true
is there a stack trace
?paste send it
how can I change join messages now that .setJoinMessage is deprecated?
that's paper, not spigot
bruh moment
no, just Component
Well uh that's a mess. Anyways try without adding PathfinderGoalAvoidTarget
You are? Line 57
Or is it in a comment?
Hey I search to make a sellchest plugin but I want wen i place a chest a sign get automatically place on the face of the chest do you know how I can do that ?
Is there any way to automatically deploy jar to the server after building?
Yes you can set the output folder
Theme ?
Oh, I mean hosted server, not local
That would be unsafe
Why?
Custom theme
Can I have it please ?
up pls ๐
check block place event, see where the player looks if they place a sign, move the sign if it's on a chest to the front
Yes but how I can get the front ?
How many versions are you targeting with your plugin?
Yeah that code is pretty much only going to work with 1.17 and maybe 1.18
damn reuse some code won't you
You can. You just need even more. You cannot import any NMS classes
You are
import net.minecraft.world.entity.ai.goal.PathfinderGoalAvoidTarget; import net.minecraft.world.entity.ai.goal.PathfinderGoalRandomStrollLand; import net.minecraft.world.entity.ai.goal.PathfinderGoalZombieAttack; import net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget; import net.minecraft.world.entity.monster.EntityZombie; import org.bukkit.Bukkit;
And CraftWorld
then remove it
Why it would be unsafe?
Uploading jars automatically to your server is a bad
Are you just using it for testing?
Yeah
Then I guess it's relativly fine just make sure to use sftp
how could i get a java class by it's name? and not the entire class directory, just the class
what event should i use for during the dragons pillar respawning phase on each pillar
like is there an event for when a crystal gets respawned
Yeah, sftp is the best way for me. I found in Deploy tool sftp options, but:
- How can I upload only jar
- How can I deploy automatically after building
oh no why
ew
scary
ahhhhhhh
but how do i detect if its spawned from the respawn phase
cuz if someone places a crystal during that phase, itll also think that it's spawned from the phase if it just check the current phase
Hey do you know how I can do somthing like this ?
if(block.getRelative() == BlockFace.NORTH)
what are you trying to do basically
me?
nah mr54180
I want to place a sign on the front of a chest
maybe i have to check smth with the handlers?
but idk what
You can listen to the entity place event and ignore those entities
im not trying to do it for when someone places it tho
im trying to do it during the dragon respawn phase
like when the beams of the 4 in the center respawn a pillar
Yeah but you wanted it not to do something with other entities so you add them to the ignore list
Block block = event.getBlock();
if (block.getBlockData() instanceof Chest chest) {
BlockFace face = chest.getFacing();
block.getRelative(face).setType(Material.OAK_SIGN);
}
try this
but it doesnt rlly place the entities in that event
EntityPlaceEvent i think only registers when the item is used to place it
Correct
also understand the code i gave you idk if the term spoonfeeding exists anymore
well its not using an item
Use the EntitySpawn and PlaceEvents together
Thats not wrok
I have the same problem with my way where I try with player YAW
Yes but is that my problem x)
I don't know how I can do that
I'll have to get some sleep now so I will make this quick..
Listen to the place event and add the entities to an ignore list or use pdc
Listen to spawn event and if the entity isn't ignored and is spawned during the correct phase do your logic
Block block = event.getBlock();
if (block.getBlockData() instanceof Chest chest) {
BlockFace face = chest.getFacing();
Block signBlock = block.getRelative(face);
signBlock.setType(Material.OAK_SIGN);
signBlock.setFacing(face);
}
@cursive loom
ok ig i already had the pdc thing for crystals lol
Not really I'm on that since 22h00 (France)
but how will i know which event is triggered first
do i just
like
runnable?
xD
So I'm tired and I didn't see the problem so that didn't work
cast signBlock to Directional and then call setFacing
Block signBlock = (Directional) b.getRelative(face); Like that ?
uhh no cause you have to set the type
so
signBlock.setType(Material.OAK_SIGN);
((Directional) signBlock).setFacing(face);
inline casts are ugly
but you can change it
how i can get from - 'PROTECTION_ENVIRONMENTAL:4' number 4? I made this but i have error with it
for(String enchants : this.instance.getConfig().getStringList("shop." + item + ".enchants")) {
String enchant = enchants.split(":")[0];
int enchantLevel = Integer.parseInt(enchants.split(":")[1]);
}
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
That don't work
Ok wait I error with the Directional line
BlockFace face = chest.getFacing();
BlockState sign = block.getRelative(face).getState();
sign.setType(Material.OAK_SIGN);
sign.setFacing(face);
sign.update();
did you check if there even is an index 1?
is this my problem or just spigot being spigot
no, but i dont have any idea how to do this ;/
what's purpur
Line 39 = ((Directional)sign).setFacing(face);
you imported the wrong thing it seems
show your imports
also you're running paper
if(array.length > 0){
// then you define your stuff with the arguments
}```
you should be asking in paper
change array to whatever array ur using
spigot fork, just for better optimization
Yes I use paper
import com.songoda.skyblock.api.SkyBlockAPI;
import fr.herllox.hinitial;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.DoubleChest;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.type.Chest;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
error is in that
Do you watn go in private for don"t spam here ?
tbh it probably might be because of this
no this is fine
im just trying to figure out why that wont work
still the same
I uploaded my first coding tutorial today ๐
Ok thx , I have try lot of things but now I literally 0 option
?paste
You try to find the problem or you want I try to ask the forum ?
Np
by dull i mean dark
(i cannot verify yet because i just locked myself out of my spigotmc account, and then my gmail account)
oh man
i love reverse engineering
i crashed 50+ times today because assembly debugger uses base 16 instead of base 10
while IDA uses base 10 for disassembly
all i needed to change: add esp, 12 -> add esp, C and it started to work
im crying
How can I find the slot that an item ends up on when either shift-clicked or moved manualy using the InventoryClickEvent?
by handling each one individually
if it's clicked manually, event.getSlot while the cursor is not null
if it's a shift-click, you need to loop through the opposite inventory, check each item in order for a match, or locate an empty slot
The manual part should be easy however the shift click is different because I need to see if the item ends up in a specific slot by using getRawSlot(). If I understand your reply correctly, you are saying where the end slot can be.
getRawSlot provides the slot clicked on, not the slot it will end up at
Right. It would only work if you moved it manually. Although after testing it isn't very reliable. Sometimes it is works and sometimes it doesn't.
getRawSlot returns the clicked slot but taking into account the clicked eventory
this is a sloppy demonstration
if(clickedInventory.equals(view.bottonInventory))
rawSlot = clickedSlot + view.topInventory.size;
in reality it's kinda calculated the opposite way iirc
I have a question:
If i have a structure (.nbt format like vanilla structure blocks), How might i replace certain blocks in that file upon loading it
Say white glass into cyan glass
(currently i'm using structureblocklib to load it)
I just have a basic util to match blocks
That doesn't tell me much of how to go about it
then you can paste a schematic or set the block types
But hmm
Since you want to replace data written in files, rather than when pasting it
you need a hex editor
I'm okay with doing it when pasting
Well, there's also ChunkLoadEvent and things like that
I mostly do my block matching with this class
Closest thing I have to your problem
Hey guys so I am saving arrayLists to a yml file to keep data between server close and startup is there a way to display the arrayList in one line instead of the one per line format its in right now?
This is how it is showing now:
Completed:
- false
- true
- false
- false
- false
- etc...
I am looking for something like this:
Completed:
- false, true, false, false, etc...
The top part is how arrays are normally stored
So im assuming there is no easy way to convert it other than formatting it myself?
i mean why keep it on one line
pretty much yes you can do [true, true, true] but idk how to save it that way via code
try converting it to an array
I was just looking for a cleaner way to sort everything because I currently have 3 lists being stored in this file
well its not like youll be manually editing them
your code will just be storing them and loading them
i mean if you're really that picky you can store them as ones and zeros in a string
completed: "0100"
thats true just figured I would check just to make it more appealing I guess
Thats actually a good idea I might do that but I guess Burchard has a good point to where I wont really be editing it as I have it updating through the in game
you could do what imajin did up above ^
sometimes someone might need to manually edit a value but in all reality if its just for storing stuff between restarts its fine
if you want it to really look nice you could store it using a json lib like gson
those have one-liner arrays (or try casting the List to array as imajin said for YAML)
Yeah at the end of the day I already have it setup in Yml so I wont be too picky
Also with notpad ++ I am able to collapse the tabs so I guess thats a good way to look through easier
It is strange because in creative mode it works great but in survival mode it doesn't work very well.
Now would it be too intensive to live update a file when something is done in game? I was told it might be better so people dont lose progress on a crash or if something like that occurs
or would it be a better system to just every 5 min do a save instead of when something occurs
yep this is a better option
and save on server close ofc
dont do server closing saves async, there is a chance if saving takes too long it wont finish and wont save
other saves can be done async
creative mode is a clusterfuck to say the least
i havent heard that word in a while
clusterfuck or async
both

i need to get back into plugin development
i still have all of my knowledge, i just lost motivation
#961533327435788348 Is the perfect way to do it!
make a plugin that gives mobs ninja tactics
make a plugin that allows mobs to backflip
I will stand behind my opinion of Bukkit being shit
recode when tbh
I had an idea for a modified server that would allow you to use a special kind of plugin called an "extension."
These would allow you to use Mixin to directly modify shit and could allow for multiple API support
e.g. it comes with some more modern API but you can also add a Bukkit extension
I would love to use a platform that has the performance boost of Paper with mixin support
That way you can use Bukkit plugins on the server and avoid having to completely switch ecosystems :)
the performance difference is the only reason I don't put my servers on fabric
It would also allow you to customize the server to your liking if you wished
So yeah, cool concept in my eyes
Also server jars would use Yarn mappings so NMS wouldn't require reflection
MCP is outdated, and Mojmap is illegal
So, Yarn suffices
Fabric is pretty fast though
'specially if you use Lithium
Is it?
someone recode a minecraft server in rust
Yeah
Maybe I've just been looking for excuses to not run a fabric server
It's quite lightweight compared to something like Forge
It loads way faster, uses less memory, and results in higher FPS
I should give it a shot. I've been wanting to write my own AI for mobs for a long time and other server-side mechanics for a long while now
Also has better FPS mods
Is that a request or statement?
well im making a multiplayer game purely in rust rn
There is a Rust-based Minecraft server
already?
It's just not complete at all
repo?
this will actually be extremely influential if it gets completed
i wanna contribute ๐ค
go mc server when
There's also some custom client implementations
They've been worked on for literal years
and...
are barely finished.
Yeah the from-scratch client scene is fucked, it's impossible to reimplement all of Minecraft without a fucking team of people.
I met the dev of one, his client uses Swift and is quite impressive, but not playable
is it possible to put a return statement in a scheduled task
i want to repeat a method every time it finishes it's course
Is it possible to get a player's maximum health capacity including health boost if any? I mean using get attribute only returns 20 and doesn't account for health boost.
are you calling getDefaultValue or getValue?
ah that makes sense thanks.
you gotta make a fancy scheduler util
You could probably create a custom scheduler yeah
Is there any way to get around this?
guys, do anyone know a way how to reduce the total of semicolons as well as keeping the functionality in if(killer == null || killer.isDead()) { cancel(); return; } by using the following methods?
https://github.com/Luziferium/the-cipher-project/blob/master/src/main/java/we/are/project/cipher/InfiniteCode.java
#961763801869451335 gimme suggestions
I am trying to create a temp map to remove keys/values from to prevent myself from picking duplicates out of it but when I remove a value/key from the temp map it also removes from the map I create the temp map from. I am assuming the temp map is still pointing to the main map how do I make them entirely different maps? This is what im doing right now:
temp.putAll(QuestCreator.questMap);
Would I have to loop through and put each value in on its own to separate them or am I doing something wrong
wtf are you doing
So I have a map <Int, Quest> and I want to make a temp version of it that I can remove keys out of to prevent myself from choosing duplicates from my random number gen but when I try to make the temp map and remove key/val from it it removes it from the other map aswell.
Quest is an object I made just to be clear
Ok forget what I asked I see what im doing wrong
Whats the name of the event for block state changes
i cant remember it
i guess i have to use PlayerInteractEvent sad
what are you trying to achieve
Trying to tell when a state of a noteblock changes, would of assumed theres some type of block state change event but ill just use interact event
NotePlayEvent ๐ค
ohhh
well thing is
would that trigger on right clicks too?
Since its technically changing the note
it doesn't fire in the CraftNoteBlock class
yeah just thought of that
ill try that event few mins
so it works for left clicking
well
kinda
oh my loader isnt loading my blocks lmfao
fucking hell im an idiot
"Why the fuck arent these loading"
doesnt spell my own name right
yeah the NotePlayEvent only works for left clicks as by the time the note block plays the actual notes different than the previous one
Hello! I am making a plugin similar to LifeSteal but instead of hearts its time that you steal. I already have almost the entire plugin done but I need help with some things that I cant seem to figuring out. How the plugin works is as you play on the server you gain time that you can use to speed up and slow down time (Potion effects). The longer the time the longer the effects. When you kill someone though you can steal 15% of their time. I am having trouble adding a cap to how long the potion effects can be and adding the stealing part. Can anyone help me?
Math.max
What about the time stealing part though?
its actually really easy
i cant really explain it without like making the plugin for you
ok basically load them from however you gonna store there time
you can use a config for this
then add them to a hashmap
and whenever you wanna access that time
well
Right now im using the built in statistic
playtime?
doesnt really work like that but okay
i think your time calculations are a bit off
Oh ok
How do I get Player from HumanEntity?
How would I do the config and hash map thing. Iโve never really done anything like that
You would cast it
who pinged?
Sorry, was checking something. What would I use to cast it?
You would cast Player to your HumanEntity variable/instance you have
not even sure if default yaml has a option for that
Ty.
Would making it so the server adds the player and a number to a file work? Every time the player is killed the number goes down and every time they kill someone it goes up then we just add that number to their current time on the server
You would need to store 2 things:
MaxTime = (killNum * timePerKill) + defaultTime
TimePlayed = timeCurrentlyPlayed
so yes doing that would work
Ok
I haven't touched Java for a while, anyone know how to fix this?
make getPlayerPrefix static?
well... yeah but like how, i forgot how to do this stuff lol, and google isn't really helping
you need to get an instance of Chat
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
yo, so let's say i have an instance of PlayerMoveEvent, and im simply trying to amplify the direction that they are going in with a vector, but not reliant on where they are looking. So for example, if a player presses A, they'd be launched in that direction with a vector
my knowledge on vectors are pretty sad so if anyone could help out that would be appreciated
e.getPlayer().setVelocity(e.getTo().subtract(e.getFrom()).toVector().multiply(5));
could you quick just explain this for me?
you would need to cancel the event and then right after apply your vector in the direction you want them to go in instead
or in this case you just want to amplify how far they go. Also keep in mind that you have to be mindful about the server configuration as if you make them go to fast the server may complain
no ye i get that but, what im trying to understand is the vector logic here: e.getTo().subtract(e.getFrom())
well at least you were honest about understanding vectors
so the method you are asking about, is to just get a vector in where they are going, and then it multiplies it by a factor of 5 thus launching them
unless you want to launch them in the air
in which case you need to do a bit more math
all a vector is, is a direction and velocity in the given direction
right okay
can someone help me please, im trying to make a plugin that adds custom chickens to the game and that removes all other mobs, but everytime a chicken dies, a couple of new one spawns at the same place, i think this has something to do with the item drops but im not sure. this is my code: ```java
@EventHandler
public void onMobSpawn(EntitySpawnEvent e){
Entity mob = e.getEntity();
if (!(mob.getType() == EntityType.DROPPED_ITEM || mob instanceof Player || mob instanceof Chicken)){
Location loc = mob.getLocation();
mob.remove();
ExplodeChick.createChick(loc);
}
}``` and this is my other code:
new BukkitRunnable() {
@Override
public void run() {
if (!chick.isDead()) {
if (chick.getTarget() == null) {
for (Entity entity : chick.getNearbyEntities(10, 10, 10)) {
if (entity instanceof Player) {
Player player = (Player) entity;
chick.setTarget(player);
}
}
} else {
LivingEntity target = chick.getTarget();
if (target.getLocation().distanceSquared(chick.getLocation()) < 25) {
chick.getWorld().playSound(chick.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 5, 5);
chick.getWorld().spawnParticle(Particle.SMOKE_LARGE, chick.getLocation(), 1);
Bukkit.getScheduler().runTaskLater(main, new Runnable() {
@Override
public void run() {
chick.remove();
chick.getWorld().createExplosion(chick.getLocation(), 5, false);
chick.getWorld().dropItemNaturally(chick.getLocation(), drops);
chick.getWorld().playSound(chick.getLocation(), Sound.ENTITY_CHICKEN_HURT, 5, 5);
cancel();
}
}, (2 * 20));
}
}
} else {
cancel();
}
}
}.runTaskTimer(main, 0L, 20L);```
Well, if you kill a chicken, it's going to spawn another one.
mob instanceof Chicken
no i dont want a chicken to spawn if it dies
That is the biggest stack overflow ever
Yeah I know. But you're telling it to do that.
Infinite chickens seems pretty cool
where am i doing that?
ahh that's okay, i multiplied the vector by -1 first and then did my changes to the final velo
isnt this pretty redundant
Oh wait I read EntitySpawnEvent as EntityDeathEvent, hang on.
depends
Are you listening to EntityDeathEvent anywhere?
no
Well I don't think any of the code you sent is doing that
public static void bitwiseMultiply(int n1, int n2) {
int a = n1, b = n2, result=0;
while (b != 0) // Iterate the loop till b==0
{
if ((b & 01) != 0) // Logical ANDing of the value of b with 01
{
result = result + a; // Update the result with the new value of a.
}
a <<= 1; // Left shifting the value contained in 'a' by 1.
b >>= 1; // Right shifting the value contained in 'b' by 1.
}
System.out.println(result);
}
here is how you multiply using bitshifting ๐
in case the other way was too easy
this is my other piece of code:```java
public final class Main extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new ExplodeChick(this), this);
getServer().getPluginManager().registerEvents(new PreventMobs(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}```
the main class
Incredible
recommend people save that snippet of code
literally the fastest way to multiply without using much resources ๐
but most people don't know math like that
if anyone is curious to understand the math behind it, let me know ๐
want another one?
this one is bitwise adding
public static void bitwiseAdd(int n1, int n2) {
int x = n1, y = n2;
int xor, and, temp;
and = x & y;
xor = x ^ y;
while (and != 0) {
and <<= 1;
temp = xor ^ and;
and &= xor;
xor = temp;
}
System.out.println(xor);
}
if you want division or subtraction, you just do the opposite of these two I have shown
That is quite interesting
and that concludes this weeks snippet of codes that may be useful ๐
i think ive to start all over again >_<
get out of here with your math bullshit frost
:p
long seed = Systen.nanoTime();
public long randomLong() {
seed ^= (seed << 21);
seed ^= (seed >>> 35);
seed ^= (seed << 4);
return seed;
}
anything else? probably didn't think I had one ๐
you would just have to check the result is between the numbers you want it in
And is calling System.nanoTime() resource-intensive, or should i store it on program startup
nanoTime() is just used as an example
howdy guys, may I ask what are any examples of itemstack who doesn't auto generate their meta
my bad
you can literally use anything as the starting point
i wroded this horrible
i meant, a random between 2 ranges with that
ie between 1 and 4
wym?
new ItemStack() auto generates a blank meta
I added a not null validation to my event and it got triggered since the meta is null
show the event your using
And what ItemStack are you using? i normally make things like that return null if the metas null
Nah meta can be null at times like with Material.AIR
do you have bitwise square root?
short isqrt(short num) {
short res = 0;
short bit = 1 << 14; // The second-to-top bit is set: 1L<<30 for long
// "bit" starts at the highest power of four <= the argument.
while (bit > num)
bit >>= 2;
while (bit != 0) {
if (num >= res + bit) {
num -= res + bit;
res = (res >> 1) + bit;
}
else
res >>= 1;
bit >>= 2;
}
return res;
}
wait i have a meme for this
very well, appreciate it, I can make a wrapper for it but was just lazy
So, we got multiplication, addition, XORShift, and now square root in bitwise operation ๐
you can copy paste mine if you want ๐
it's just boilerplate bs to make item stacks easier to work with
yeah great thing, I used to make one of those on my previous plugins that I already archived
i make an API for my plugins that way i never lose stuff like this
might add frost's stuff to it
and credit as my own
jk
same lmao
Lol
actually ngl frost imma make a MathUtils class now
wouldn't bother me ๐
i bet you can't make cube root
I didn't make a wrapper for it since the items are retrieved from the mainhand in the entity damage event and is only used by the gem enchantments I made, I could just add a null check for now
You can, I don't have any pre-made for that though
so will have to give me a bit to adapt some code ๐
In which version was implemented sending resource packs to the players?
or is there somewhere I can check that?
Frost whats your github
iirc 1.13?
you can check javadocs for Player object for 1.8 1.9 etc
frostalf and frostalf-games
can I send texture packs in 1.8?
read that message again
"You can check javadocs for Player object for 1.8 etc"
IR check javadocs for sendResourcePack(String)
or w/e the name of the method is
i dont quite remember i think thats it though
uhm oki ty
frostalf the one with ServerTutorial forked and arctic code vault badge right
i just wanna link you in this class
before i commit
๐
speeeed
lowkey
have no idea wtf this is doing but imma take your word its faster
also fun fact about using bitshifts
it is required on hardware that doesn't support floating points
what hardware wouldnt support that?
you would be surprised
but the fact that you can however still do FP arithmetic in the way I showed however, technically the hardware still supports it. And the reason bitshifting is faster in Java then if you were to use normal math operations is due to the fact you are cutting out the middle in what happens
so, in Java, if you do math related functions, it has to go through the jvm then to native code to the cpu to compute. Bitshifting cuts all that out, and essentially you are doing what the cpu would eventually do. You are just having the program go ahead and do it.
some of the downsides of using bitshifting is you can lose readability, however in others you can increase it
well maybe not readability, but make it harder to understand for those who don't know how to do binary math
wont ever have to read or learn it if you shove it in a library 
god damnit why isnt there a state change event for blocks
economy.depositPlayer(offlinePlayer, plugin.moneyLinker.get(p)); ``` the 2nd line gives me an error, moneyLinker is a hashmap that returns a Double.
I get economy like this:
``` Economy economy = plugin.getEconomy();
whats is p and whats the error
i did
Bukkit.getOfflinePlayer(uuid)
send the error
Is vault installed on your server
...
thats likely the error as it cant find vaults classes
It is indeed not installed ๐ค sorry for disturb
Another day another moment to learn 
lmao
i guide others to a treasure i cannot obtain, functional code
I'm coding a robbery
//parity check returns true if odd, false if even
public boolean parity(int n)
return n&1==0;
}
to add to your utils
probably can reduce this to one line lmao
updated it, I think that should work
might be missing something
lol
comment might be fixed
or change the 0 to a 1 instead
it is the fastest way to check if a number is even or odd
nono like
so you have all these methods currently
now a equals using bit math
ie ==
lmao
i doubt theres nothing faster tbh
lol
bitshifting is really handy
I mean you seen my color compressor ๐
it compresses hex or rgb into 8bit colors
and even rounds the color to nearest best match ๐
all with bitshifting
Looks good to me! time to release this shit
the debugging for this must of been aids
So I have this static inner builder class:
trying to do something like this however
can't access cause it's private, even though the Builder class is a member of the Projectile class
anyway I can get around this without making the Projectile constructor public?
Ideally it wouldn't be so it can only be accessed through the builder
make a method in your Projectile class and called it Builder with a Builder value, and make it return a new instance of Builder
soi basically have to make a getter in the parent class for the subclass
//fast exponentation
public long calculate(int a,int b) {
// initialize ans with 1
long ans = 1;
while(b>0) {
// check if last bit 1
if((b&1)==1){
ans = (ans * a);
}
// update value of a by a*a
a = a*a;
// right shift b by 1
b = b>>1;
}
return ans;
}
here is another for you
so lets say you want to know what 2 to the power of 3 is
this will calculate that in a fast way ๐
why tf you so smart
also b&1 -> to parenthesis idk if your ide is showing those errors to you haha
this method is O(log n) time
super speed ๐
awe ๐ฆ
feel free to benchmark the differences
its fast regardless ๐
also I don't have an IDE, just pulling these things from my snippets library I have saved lol
now if only
i could make this work without flickering
i rly hate the interact event in spigot
what does the code look like?
just been trying this
I don't think it lets me do this though
I can't do java new Projectile() { //new stuff }
sec
as constructor is still private
and can't change what's in the builder cause I can only get a new builder by calling the static getter method
i dont think your understanding me right
sec
eew annotations
class Something {
public MoreStuff MoreStuff(someStuffInstancehere) {
return new MoreStuff(someStuffInstanceHere);
}
static class MoreStuff {
MoreStuff(someStuff) {}
}
}```
and you use Something.MoreStuff(someStuff)
wait no im retarded
cause you have that
wait nah
i see
this is hurting my brain lmao
new Projectile().ThatBuilderThing
your calling new Projectile.Builder() and you cant do that because Builder is private
So make a public constructor?
but I don't want to give projectile a public constructor
cause the whole point is that is has a private constructor and is built by the builder
so then Projectile.getBuilder() and no new in front of it
your calling new on something thats already returning a new instance
but then I can't edit the builder with a static inner class cause the method creates the builder
gimme a sec
?paste
sry needed that
its at line 24, i cant called setCancelled() or else it cancels the block place in this case
so i just reset the BlockMetaData and then place a block against its block face
why do you need the block to be placed?
also you didn't send the link
@noble lantern so this is what I'm trying to do
it works as long as I have the projectile constructor public
and give the builder fields getters
I guess making the projectile constructor public isn't the end of the world
the only point of the builder is to make the constructor of the projectile class simpler
my keyboar dbugged
idk why it didnt paste lmao
thats not a builder
idk what that is
builders are done like
Gson gson = new GsonBuilder().setPrettyPrinting().build();
.build() returns a new instance of a class
for some reason your overriding project()
so why exactly does the block need to be placed?
which should be your actual building
haven't quite answered that part o.O
Its basically to allow block to be placed on interactable blocks (IE noteblocks) to allow placing without crouching
sorry i was doing 3 things at once
had to do something in cipher too
no I mean why can't you just cancel the event?
I mean you can still place a block even though you canceled the event o.O
because then it will cancel any blocks for some reason im not sure why (for right click interactions)
lemme try to cancel and not reset data again
ill see if it still does it
yeah that's what I' m doing
well, without cancelling you won't be able to prevent that glitch without resorting to NMS
but you can place blocks IE change air to a block even though you cancelled the event
ok having these 2 variables both called project is confusing
I'm just rename to build
tbh i think i can actually cancel this event now
since im placing the block on my own
normally you dont have b = Projectile.builder
you make b a Projectile
and use builder to construct a Projectile
ie
build() returns a projectile class
ie like so
make all your setters
returns this
right right
so you can chain them
well with this b.build() wouldnt do much since its value isnt being used
the constructor of the Projectile spawns the projectile itself
i see
so by calling build I've set the projectile in motion
I could prob just do this all in the projectile class itself couldn't I
rather than making a static builder
class Projectile {
public Projectile doSomething(int one) {
// do stuff
return this;
}
}
yep
and you could chain newProjectile().thingOne().thingTwo().build();
build being the method that spawns the projectile
im not entirely sure IMO, i dont use inner classes a whole bunch
doesn't seem particularly helpful tbh
and tbh being able to change the things like the entityTraceFilter half way through a projectile's life span seems like it could be useful
main reason I was doing this shit was just to experiment
but it seems like it's quickly becoming convoluted
if you really want to seperate it into classes you could create a ProjectileBuilder class that has a method that returns Projectile but you would be right, you wouldnt be able to entityTradeFilter on it once its created
same with gsons builder
ayyyy frost i did it lmao
hi alex
very pog
henlo :3
I like the code being writtn out
oh wait thats what hes talking about
I mean, it's just a bunch of setters that after that call your constructor
Mye idk
sout, or a logger ๐
that requires me going to my console and checking the logs
Player sendmessage
nooo
broadcast
is where its at
unless you make a debug logger for production with true false settings
True false setting?
ie
debug: true in config
and itll log debug in console
ill do that for prod but when testing
Ahh
broadcastMessage() is the best
ill literally fight anyone in here who says differently
dev/null is better
why do so many people hate it?
they like to add time to development
lol
because unit tests
also, people like me who don't like annotations
over use of annotations can take away from readability or simply understanding what is going on since it moves that from the source code to compile time
I don't know
I really don't get it
lombok is just awesome
have you tried @ Data classes?
only Getter and Setter so far
i just tried it out earlier this week
it's basically Getter & Setter on every variable (unless it's final ofc) + hashcode + toString
oh and it also adds the required constructors
interesting
i dont see to much of a use for me as i dont use data in this plugin currently
but the other ones i defo will
those poor sould
stuck on outdated versions using java 16
almost feel sorry for em
but Java 17 is awesome, I wouldn't use anything less
I always code for java 8
nope not me
jdk 16 bare minimum for me
:<
when i make plugins
Now down to this
i only make them with latest version in mind
Java 17 has native unix socket support ๐
fuck anything else
doesnt that mean 1.16 doesnt go with your plugins?
nope
a java 8 compiled plugin will run in ANY environment java 8 or later
not true
was trying to do with the java 16 one
what's not true about this?
if it uses reflection it won't work in Java 11+
java 16 means MC 1.17+ only
it does work
I use reflections a lot
works fine in java 11+
not if you use certain reflections
yeah thats what I meant, just woke up XD
what are those "certain" reflections?
I e.g. access sun.misc.unsafe using reflection, no problem at all
tell that to your bathroom mirror ๐
most use peanut butter
lol that was random
sorry the inner rust player in me came out for a sec
I have better tips
XD
innocent 12 year old american: "why is everyone talking about female dogs :o"
your bitches so fat they don't even fit on discord in compact mode
maybe i like em fat
Sheit
cushion for the pushin
you will have to look, this is the primary reason why certain plugins compiled for 1.8 java don't work on later versions of java and have their respective equivalents
still confused af about this if anyone is able to help me out
i think even 9 year olds use that work now lmao
I never experienced any problems though, so I really what wonder what reflections are broken lol
but I would never compile for java 8
delete old file and recreate to replace
true lol
I remember when I was playing GTA:VC and killed bitches the whole time, yet I didnt even know what that term meant
I don't support old stuff that is a decade old with no updates lol
I am sort of new to files and file.delete() didnt work as I thought it would
well 1.16 is only one year old ๐
if (file.delete())
that's the "oldest" version I support
a lot of file stuff needs to be used in a boolean
1.16 does't use java 8
it does
It should
i can confirm this
well, I still wouldn't compile for java 8
i manually set my jdks for 1.17 and 1.18
you should
jdk 8 works everything else
I tried this but it still does the thing. weirdly it only does that on /rl not on normal reastarting servers
mc 1.16 can be ran on java 17
I got a .bash_aliases file for java versions
gib pls
way im doing it is aids
same
$ cat ~/.bash_aliases
alias java8='/c/Program\ Files/Java/jdk1.8*/bin/java.exe'
alias java11='/c/Program\ Files/Java/jdk-11*/bin/java.exe'
alias java14='/c/Program\ Files/Java/jdk-14*/bin/java.exe'
alias java16='/c/Program\ Files/Java/jdk-16*/bin/java.exe'
alias java17='/c/Program\ Files/Java/jdk-17*/bin/java.exe'
alias java='/c/Program\ Files/Java/jdk-16*/bin/java.exe'
alias deobstack='java -Xms128m -Xmx512m -cp ~/.m2/repository/com/allatori/allatori/8.1/allatori-8.1.jar com.allatori.StackTrace2'
you can do the same in windows
Average wsl user
Winbian
I don't use wsl
me neither, just git bash
any idea which file specifies which nms classes (that aren't already patched) to be present in the Spigot-Server src directory? I want to edit a class that isn't already there.
well if I want linux, I run a proper environment lol
I tried it cause setting up a different partition seemed like a pain
But it sucks and now its just there
are you using remapped?
None of the tutorials I could find actually worked
If so, classes have different names
with build tools
you don't need to dual boot to have linux on windows
could have just ran a VM
Lag moment
virtualbox
I do have virtual box and the experience feels like team viewer
yee vbox
all my servers are virtual machines
VMs really don't have any performance loss
well maybe 3%
I don't install GUI linux
all my linux VM's are headless
proxmox โค๏ธ
I could do that but also that introduces pain
it definitely is when you're not used to it ๐
I need kali for work I'd rather not pull up a github and find out what parameters I need each time instead of getting a gui
Well for what supports a gui anyway
you do realize that using a terminal doesn't mean no GUI's at all right?
CAp
I can launch any GUI application I want from the terminal
I use putty
but I mean I can run applications on a headless VM or even dedicated box
and the only thing you need is redirect its output to some remote place
IE your desktop ๐
Unnecessary pain
no that is just laziness on your part
nothing painful about it, nothing difficult either
Well no when you could just be normal and have a gui why would you decide to go ahead and do it the hard way
Sounds like it is lol
sounds like doesn't mean it really is


