#help-development
1 messages Β· Page 82 of 1
So you're making paper?
people always use this to try and edit spigot tho lol, you have to clone the repos manually to do that
Well I mean, if you can build it
it works?
It's not
It's not
Because obfuscation is stupid
yaeh but then-they rerun buildtools to compile and their work goes 
LMAO
Trust me, people wanting to see your code is a good thing
Ike
Then I realized I am on a version with records
Write a JSON parser
It's quite easy actually
Isn't a json parser the easiest thing in the world
could make it somewhat easy
I first want to get this portal thing I am working on functioning
It's a good learning experience for optimization
im just thinking, you can push on the {, [ and pop on the }, ]
It's not the easiest thing ever but it's pretty easy
Here's my most recent one
Really dead simple, I love how it reads like a description of json's format
I'd go with a tokenizer then parser impl
I have that too
One sec
Yeah I would go
Tokenize everything
Make AST with Parser
Use AST to make objects
I am going to copy your code into my clipboard
π
Hello I want to make a gui which when a player puts or takes an item it does so for every player who has this gui open without having to close and reopen it so that the cursor stays in the same place does anyone know how to do that?
Sent to my buddy already
Do you guys like my codeπ ?
package com.github.MyPlugin;
public class Main extends JavaPlugin{
public static void main(String[] args) {
Bukkit.getPlayer("StoneSword").sendMessage("gello");
}
}
Gonna send it to the FBI too
Reopen puts the cursor in the middle
i know
Wow no way that looks exactly like my plugin that I just wrote
Hey, I want to make a 3d map generator that uses small armor stands to make a round map.
How would I do this?
How
i want to update it without reopening it
It's my code
Oh
You can't sue me
then it's easy
You must be mistaken
Stone how old are you
store the inventory, if you update the item in the opened inventory it auto updates
.
oh rip
you just got owned
guys i run into wierd problem
Ok so how old are you
the database (mysql says it registered it)
but later when i try retrive the data i cant
13?
it returns the null (i set null if null..)
You're not able to perform though
in general why it can happen i use hikaricp
ye but how do i do the auto update part
hello, i found this example
.then(RequiredArgumentBuilder.<CommandSource, String>argument("argument", StringArgumentType.word())
.suggests((ctx, builder) -> {
proxy.getAllPlayers().forEach(player -> builder.suggest(player.getUsername(),
VelocityBrigadierMessage.tooltip(Component.text("lol", NamedTextColor.DARK_GREEN))));
return builder.buildFuture();
})
but i don't understand when Component.text("lol", NamedTextColor.DARK_GREEN) will show?
print("Hello world!")
``` guys dont copy my code pls
you mean our code
Yes
Any ideas?
// Β© Redempt 2022, all rights reserved
package com.github.MyPlugin;
public class Main extends JavaPlugin{
public static void main(String[] args) {
Bukkit.getPlayer("Redempt").sendMessage("gello");
}
}```
question about brigadier
I registered it with the registry of code copyrights
and it worked
I bet you didn't so it's mine now legally
Your code wasn't licensed
Thats some good lookin code you wrote π
lmao
#general
Thanks friend
For $100 it could be yours
Deal
tyty
i think hes trolling lol
It's not even worth stealing
Level of Humor < 0
I thought the same until the "your mom" joke
He must be 12
Or 11
Or 10
can you talk somewhere else?
Or 9
lolmaooooo
Lmao
ok so
@worldly ingot pin that pls?
I'm trying to make a plugin where other developers can make addons for it
There's some public classes that I would like to keep public for myself, but I don't want others using
is it possible to hide these classes from others
like should i just declare everything as class instead of public class
Interesting
π’
whats interesting?
Ur mom
She was the killer all along
Good
The more we use it the sooner it replaces us
nah it made mistakes all over the place as soon as it wasnt a common problem
laughs in student developer plan
wait i have that
And the more you use it, the less of those mistakes it will make
how do i activate it
you can get it for free
its
somewhere on the copilot page
theres a small link
to claim it for free if your a student
I am going to post code but pls promise no steal!!!
if i wanted to publish a maven repository would I have to pay for hosting
public static void main(String []args) {System.
out
.println
(
"""
Hello, world!
"""
)
;
}```
host it privately
or use jitpack
privately as in self-host
alright
I have a maven server
I would let you use it
But that would give you an arbitrary code execution exploit
So I won't
anyways bump
^
and docs π to explain the api
in general otherwise its 3rd party addons which arent really addons
Other plugins can depend on yours
to use your api
like a completely separate project?
And they can call its public methods and whatnot
yeah
ah I see
No in the same project
completely sperate
Just add javadocs
Redempt how good are you with mysql?
hold on im getting two different responses
Pretty good, why
okay1204 our both answers are the same..
so you're saying i can't really hide my classes from others, I should just create some static classes that are meant to be used?
top quality documentation
Yes
You can hide classes
But any public ones are accessible to other plugins
ah so
just make api/impl modules
sorry im so confused lmfao
if you really want to hide them
the API would be a seperate project then?
so here:
https://github.com/olijeffers0n/PatheticAPI
https://github.com/olijeffers0n/PatheticAPI/blob/master/pathetic-api/src/main/java/xyz/ollieee/api/pathing/result/Path.java
This interface has no method bodies, then you implement it here:
https://github.com/olijeffers0n/PatheticAPI/blob/master/pathetic-model/src/main/java/xyz/ollieee/model/pathing/result/PathImpl.java
well, if you make it a plugin library and only give them the api dependency, they wont know the others exist as they arent on the classpath
I have a bunch of files for the plugin itself, but I only want like 2 of them to be visible to the public for other developers to use
well why do they need to be hidden?
because i dont want them to mess with the base plugin itself
for example they could potentially do some weird shit if they get access to my JavaPlugin instance
or mess with the commands or whatever
does anyone have an example for how this works
for example Lib's Disguises has some way of doing it
where Lib's Disguises is a plugin on its own that server owners can use
but other plugins can add integrations with it
When I add Lib's Disguises as a maven dependency I only see 3 classes that it provides
which most are static classes too
you will never stop people from being able to do something with your plugin
so not sure why you are worrying about it
this is almost along the same lines of trying to stop people from decompiling
i hate these stickers
Java is not designed to stop either of these things
JavaPlugin.getPlugin(YourCoolProtectedPlugin.class)
therefore stop worrying about it and just setup your project in a way where it shows how it is intended to be used, and for those that misuse it, then its their fault lol
how can i make it so its like a solid line without gaps
What is your current code?
You make the gaps smaller
but that ^
You can't make it perfectly solid
decrease the distance between the particles
New pfp
But I also want to make sure a ton of unnecessary classes are not in the maven dependency
ok got it thanks sorry
I don't want their IDEs autofilling stuff that they shouldnt use
i was changing the wrong thing
you can filter classes out using some maven plugins
Don't worry about that
The size is negligible
Techically you could try incrementing by using the smallest possible double value. But then you would creation billions of particles per block
sounds funny
ah okay
but the client would just die
public class WandEvents implements Listener {
@EventHandler
public void onRightClick(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
if (event.getItem() != null) {
if (event.getItem().getItemMeta().equals(ItemManager.wand.getItemMeta())) {
Player player = event.getPlayer();
Location end = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(15));
Location start = player.getEyeLocation();
Particle particle = Particle.ASH;
int particleCount = 20;
double d = start.distance(end) / particleCount;
for (double i = 0; i < 20; i = i + 0.5) {
Location l = start.clone();
Vector direction = end.toVector().subtract(start.toVector()).normalize();
Vector v = direction.multiply(i * d);
l.add(v.getX(), v.getY(), v.getZ());
start.getWorld().spawnParticle(particle, l, 20);
}
}
}
}
}
}```
just made the for loop a double and change it to +0.5
oh yeah u need to do like 0.1 or sommin
so I'll just include the usable (for other devs) static classes in my plugin itself then
for a "solid" line
im not that good with vectors and all and not sure if i even should use a vector but im trying to get infront of the eyes and not directly the eye location
Location start = player.getEyeLocation();
How do i make this so it gets like idk 0.5 infront of the eye
add the eye direction * 0.5 to the eye location
Hello I want to make a gui which when a player puts or takes an item it does so for every player who has this gui open without having to close and reopen it so that the cursor stays in the same place does anyone know how to do that?
Let them open the same Inventory
I did this so it opens the inv on a command so it uses the items from an arraylist
public static Inventory otchlanGui() {
Inventory inv = Bukkit.createInventory(new OtchlanGuiHolder(), 54, ChatColor.WHITE + "" + ChatColor.BOLD + "OtchΕaΕ");
int index = 0;
for (Iterator var8 = OtchlanManager.getClearedItems().iterator(); var8.hasNext(); index++) {
ItemStack item = (ItemStack) var8.next();
inv.setItem(index, item);
}
return inv;
}```
Create only one instance and let all player open the same inv
Also this looks decompiled
wdym?
one instance?
You can take that quite literally. One instance of Inventory.
isn't that one?
oh
no its not cause it adds the items every time someone opens it right?
There was a topic
About the handling high prioritied threads
Can someone send the spigot link
i tried that but it spawns it funky
show some code
create table users (name string, age integer)
insert into users values('Ike', 5)
```Just made a couple helper functions to generate this from a class
Vector startAdd = start.getDirection();
double dx = startAdd.getX() * 0.5;
start.add(dx, 0, 0);
its only when its going diagonal
I think you are supposed to multiply the whole vector, not only the X
but I haven't seen the question I might be wrong :P
Code and pictures dont correlate. Nothing we can help here with.
How come when using getClickedInventory on a InventoryClickEvent it gets the inventory before the item is picked up and how can I get the inventory after it's clicked
might need to use radians
Events are fired before something happens so cancellations arent rollbacks but rather actual interceptions of an action.
Check the inventory one tick after the event.
@EventHandler
public void onRightClick(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
if (event.getItem() != null) {
if (event.getItem().getItemMeta().equals(ItemManager.wand.getItemMeta())) {
Player player = event.getPlayer();
double BlocksToShoot = 10; //Number of blocks to shoot for if 10 the beam will be 10 blocks long
Location end = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(BlocksToShoot));
Location start = player.getEyeLocation();
Particle particle = Particle.ASH;
Vector startAdd = start.getDirection();
double dx = startAdd.getX() * 0.5;
start.add(dx, 0, 0);
double d = start.distance(end) / 10;
for (double i = 0; i < 10; i = i + 0.1) {
Location l = start.clone();
Vector direction = end.toVector().subtract(start.toVector()).normalize();
Vector v = direction.multiply(i * d);
l.add(v.getX(), v.getY(), v.getZ());
start.getWorld().spawnParticle(particle, l, 20);
List<Entity> near = l.getWorld().getEntities();
for(Entity e : near) {
if (e.getLocation().distance(l) <= 1.5D) {
if (e instanceof LivingEntity) {
((LivingEntity) e).damage(3);
}
}
}
}
}
}
}
}
}```
Oh boy
I dont get the addition of X here...
Before we continue: Can you please reduce the nesting by using safeguard statements?
if(!condition) {
return;
}
Next thing: Never check for equality on ItemMetas. Always use the PersistentDataContainer to check for custom items.
Im creating custom World Generator
And I want to create Forest of Trees
Ik how to spawn trees but they are all "long" distances apart, I want them to be stacked on each other, making sort of jungle
How did you spawned these?
via Block Populator
Use a much higher or much lower frequency for your noise.
Much higher will result in a continuous dense forest
Much lower will result in patches of dense forest
first time i see smile with a different pfp
change noise just for Tree Populator or forwhole generation
same
just for the population
wondering on how to do so
i thought of changing settings of Random but thats all
Couldn't find any other way to change noise values
Not sure how much is possible with just the spigot api
How does work the ignoreCancelled boolean from the @EventHandler annotation?
(I mean im recreating the spigot event-listener system)
"If ignoreCancelled is true and the event is cancelled, the method is not called. Otherwise, the method is always called."
If the event got cancelled by an EventHandler method before and your ignoreCancelled is set to true then your EventHandler method
wont even be called.
why the hell π
Hmn im still mixed up
I understand that if "ignoreCancelled=true" will be still called not matter if its cancelled or not right??
the other way around
ignoreCancelled=false
Is the default. This way the method always gets called.
ignoreCancelled=true
The method will only be called if no other method cancelled the event before yours.
It means ignored cancelled events
What's a good way to give multiple items abilities without switches?
what=
can you elaborate a bit more
I mean is there a good way to give items functions that trigger on right click without using switches to check for the item?
That i will dm you once i can fully test the library remake
Mapping
Create an object for your "SpecialItem"
On it create an abstract method which would be called in an InterrractEvent and retrieved by a custom PDC
ty
Map<Key, Ability>
Then in the PDC write one or many Keys.
On interact -> get all keys -> get corresponding Abilities -> cast Abilities
Where does key came from?
Is it from 1.16 up?
oh ok
Otherwise I know there are the MinecraftKey
How do I move a location forward? do I just add it's direction to itself?
Add a normalized direction and transform it to Location
The vector returned by Location#getDirection is already normalized
to move forward, you would just use the add() method on the location object, and you would either add 1 to the x or 1 to the z or the reverse where you subtract because you could be on the other half of the grid.
generally you would use the direction the player is going in as the indicator of moving forward
or you could go by cardinal directions as the basis
So vector.add(1, 0, 0) would move forward?
Vector step = new Vector(1, 0, 0);
dir = dir.add(step);
but for the most part you would either add or subtract from the x or z
to move in a particular direction
I need to get the blocks in front of a player (can't use BlockIterator as I need to run some calculations myself and BlockIterator would be too troublesome for this scope)
don't have to use a vector
Location.add(1,0,0);
So moving directly in front is my need
fair
since you have a player, then you know the direction they are moving by just monitoring their movements
I don't move the player
I have their camera dir
doesn't mean you can't listen to player move events
I... don't need to do that? Just the block the player's looking at
Well sort of
it's a bit more complicated, but that's the main thing
well then with that you can get the cardinal direction the player is looking and then you can use that determine which way on the planes to move the location
or if they are looking at a block
It's not bound to a cardinal direction?
just compare the values of where they are at and where the block is at and that gets you a direction too on a vector
alright you are making this harder then it needs to be
Just compare the location of the block they are looking at, with the location you have which I assume is the players, and with using vectors you can get a direction
That's what I want
How can I achieve that
Found it on a thread about spawning particles
those pictures are not really clear
The player is the big circle
the arrow represents the look direction
the small circle is the location I want
player.setVelocity(player.getEyeLocation().getDirection())
Again, not moving the player
you just want to spawn particles at the crosshair?
.
No
yes
you just add the direction to it
either that or add its own normalized value
I mean it depends
direction is yaw-pitch dependent
adding its own normalized self is relative to 0
Add to x sin(yaw) and to z cos(yaw)
but you have to multiply
by something, your welcome x)))
you could just use the player look method to get some location in front then
but as I have stated though if you already have a location in front, and just want the next location after
you can know the direction based on the players location and the location you do have
location.add(location.getDirection()) that's basically what I want, is it correct (moving forwards)
Problem is for diagonals
vectors work regardless of angles
this is basic vector math, the only thing is there is no velocity, but will just say there is a velocity of 0 going in the direction of the location in front of the player π
Angles don't mean anything in 3D but Vector will be different weither you look on the right or slightly on the right
Velocity is a Vector of movement
indeed which gives you a direction
Yes so where's the problem of using player direction ?
loc.add(Math.sin(loc.getYaw()) * .5, 0, Math.cos(loc.getYaw()) * .5);
Adding the direction normalized should give the front direction
not sure, they said it wouldn't work or something.
Mathematically speaking, should work
so the alternative is using vectors
Wait, weren't we speaking of Vectors ? x)
Yes but there is a method in the api to get the direction the player is lookin, but you could also figure that out with the two points yourself
was adding to a vec rather than loc
getDirection returns the Direction vector of the head, getVelocity represents the movement of the player (also called speed vector)
don't care about the velocity
its not important
they wanted to establish what forward was in an arbitrary way
anyways not sure why what I explained is so difficult to understand
I think you just got in a muddle ^^
not sure how, can't really explain how you get a direction anymore simpler then using a vector with no velocity
you can pretend it does have velocity though as it does make the math easier
Well I think you got in the muddle cause Velocity is not a math thing
velocity is the derivate from the position in physics
1+1=2 quicc maffs
- so like this?
public class WandEvents implements Listener {
@EventHandler
public void onRightClick(PlayerInteractEvent event) {
if (!(event.getAction() == Action.RIGHT_CLICK_AIR)) {
return;
}
if (!(event.getItem() != null)) {
return;
}
if (!(event.getItem().getItemMeta().equals(ItemManager.wand.getItemMeta()))) {
return;
}
Player player = event.getPlayer();
double BlocksToShoot = 10; //Number of blocks to shoot for if 10 the beam will be 10 blocks long
Location end = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(BlocksToShoot));
Location start = player.getEyeLocation();
Particle particle = Particle.ASH;
Vector startAdd = start.getDirection();
double dx = startAdd.getX() * 0.5;
start.add(dx, 0, 0);
double d = start.distance(end) / 10;
for (double i = 0; i < 10; i = i + 0.1) {
Location l = start.clone();
Vector direction = end.toVector().subtract(start.toVector()).normalize();
Vector v = direction.multiply(i * d);
l.add(v.getX(), v.getY(), v.getZ());
start.getWorld().spawnParticle(particle, l, 20);
List<Entity> near = l.getWorld().getEntities();
for (Entity e : near) {
if (!(e.getLocation().distance(l) <= 1.5D)) {
return;
}
if (!(e instanceof LivingEntity)) {
return;
}
((LivingEntity) e).damage(3);
}
}
}
}```
and this i dont understand
?pdc you can add a custom identifier to the item, which is hidden to players. So that you don't have to name it, have the same lore, etc
NotCeption
Instead of cloning the location all the time in the loop, clone it once, and add each time to it
one sec my code is broken after fixing the nesting
It is too a math thing.
Velocity in math is the direction and travel rate of an object
^
so just move Location l = start.clone(); out of the loop?
if it needs to more technical in regards to vectors, it is a vector defined function in which it has both magnitude (amount) and direction
so not sure how you can say velocity isn't a math thing lol
also why is this better than the method i used?
not to sound defensive just tryna learn
ItemMetas are first of all just context objects, whilst using PDC would mean that you define your behaviour based on a provided api functionality as opposed to just relying tightly on that the underlying design (aka implementation) conforms to your design. Also should be a bit more scalable.
In simple terms though, using PDC is more robust concerning your design's dependencies.
Is there anyway to know if a item is consumable?
I know there is Material.isEdible, which gives a big list of consumable items, but i wanted some way to include potions and whatever other stuff there is that can be consumed.
Don't all potions use the same Material value though?
Material.POTION
and if I'm not mistaken, I believe Material.POTION.isEdible() returns true
I'm not 100% sure on the last statement though, so take that with a grain of salt
Aren't splash and lingering different
You can add those in manually to whatever list you make
i got around by doing a list with all the potions and stuff
it's more manula but it works
manual*
Hey guys, how to spawn a FallingBlock with NMS? im trying to spawn one but doesnt spawns.
Yeah, glancing over the docs I don't really see any methods aside from isInteractable which I think also returns true for blocks that can be right clicked (like the crafting table and furnace etc)
ye
splash is just a throwable potion
lingering is a splash potion that ... lingers
ig every lingering potion is a splash potion (false if u consider ender dragons ball) but not every splash potion is a lingering potion
how can i make a 3d sphere with particles? i dont really know how to use cos and sin...
recipe.setIngredient('S', Material.STICK);```
is it possble to use a itemstack as a recipe instead of a material? cause i want custom items to be crafted too
and also a amount in the crafting table
What would the best way to learn packets be?
?
You likely would either need a custom crafter or you define the Item as a material prior to the recipe defining and then call it their.
i-
i was boutta do smth like this ```java
List<ShapedRecipe> recipes = new ArrayList<>();
ShapedRecipe enchantedOakLog = new ShapedRecipe(key, item);
enchantedOakLog.shape("EEE", "EEE", "EEE");
enchantedOakLog.setIngredient('E', new ItemStack(Material.OAK_WOOD, 1));
for (ShapedRecipe recipe : recipes) {
Bukkit.addRecipe(recipe);
}```
Quick question. I'm trying to add a players name into a set but when I put set.add(p.getName()) it says "Unchecked call to 'add (E)' as a member of raw type 'java.util.Set' Does anyone know if this means anything and or how to fix?
ahh
so im guessing hypixel uses a custom gui?
ugh
thats gonna be so annoying
honestly it doesnt matter π
cause i just want them to put 9 stacks of wood
so
no other room
but then for the other custom items, it isnt very efficent
sigh
i have to make my own gui
gonna be a pain
wait whattt
how u gonna do that
dispensers only have 9 slots
smart. but how would i get every crafting recipe without using my life getting each recipe
Gonna bump this.
use Set<String>
It will be
Your first thing Set<String> worked
https://www.spigotmc.org/resources/customcrafting-advanced-custom-recipe-plugin-1-16-1-19-free.55883/ might just use this
too much work making my own
Not doing hashmap because its very temporary storage
like stored for about 1 second per thing
yeah ik, ive already made guis in the past but with my 3 week java experience and no lessons its hard
my pc goes mad when i turn on shaders
i go from 2000fps to 60
What would be the best way to go about making a generation system like this? If anyone could give me any pointers or tips thatβd be great. Thanks! https://battleda.sh/dungeons/
I actually watched a fantastic video on this not long ago on the algorithms behind a 3D dungeon generator. It touches on 2D as well, but super informative
https://www.youtube.com/watch?v=rBY2Dzej03A
Read the original blog post here: https://vazgriz.com/119/procedurally-generated-dungeons/
Github repo: https://github.com/vazgriz/DungeonGenerator
This video describes an algorithm for procedurally generating 3D dungeons.
0:00 Intro
1:03 2D Algorithm
3:40 2D Dungeon Example
4:17 3D Algorithm
8:39 3D Dungeon Example
10 minute video but chalk full of information
Thank you SO much!!!
Hey, does anyone know what's causing the clickering whenever I render contents into an imageboard?
FYI, the frames and maps are client-sided, and the contents are being written to async
ihave a list can i add a string to it or do i have to get the list and add the obj and set the path
how often are they being updated
20tps
every tick
uhhh
wdym
how are there plugins like animatedframes doing it π€
check their src
like i have a StringList can i just add something to it or do i have to get the list add to it add(String)then add all the items to the path
Interesting video and very jam packed with information, Iβm still a bit unsure about how to make it so that the dungeon is all within a square with specified dimensions. Iβll have to look through some forums and the internet a bit more. Thanks again :D
i still ahve no clue what you're asking
but if you want to add to a list you just do .add(String)
and i dont have to re add it of ter getting it
could you give an example of what you're trying to do?
lowering tick rate to every 2 ticks seems to fix the flickering
but stuff aint updating now
add a namespace:id to my config from itemsadder
whats the difference between these
.getItemMeta().getDisplayName()
.getItemMeta().getLocalizedName()
getDisplayName() returns the itemβs display name, meaning if the item has been renamed with an anvil or has a custom name, thatβs what it will return.
getLocalizedName() returns the original name of the item even if it were to be renamed. Itβs also privy to the serverβs language settings, so if youβre using Spanish as server language, it will return the Spanish names for the items.
Does that make sense?
my dungeon generator looks something like this
For our purposes, we used pre-built rooms in various shapes and sizes
this generator does not require strictly square rooms
it was inspired by Zorbus
hello, anyone knows why this is happening?
prolly because its not in the package that houses all your classes and sub classes
some how that got moved out of where you place all that
Do Build > Rebuild Project
Usually fixes for me
^
not worked but thanks
For some reason this isn't writing/saving the player config. It reads it just fine though because if I set Start to true in the config it sees that and acts accordingly.
and why do i have to use hasLocalizedName for getLocalizedName
Why do you have to? What are you trust to achieve?
it says i have to use has
Trying*
Whereee
you need to check if the name is not null because some languages have glitched item names
kk thx gtg
Iβll miss u
this isn't working π
int sharpness = gameStorage.getSharpnessLevel(runningTeam).orElseThrow();
item = clampOrApplyEnchants(item, sharpness, Enchantment.KNOCKBACK, type,
SBAConfig.getInstance().node("upgrades", "limit", "Sharpness").getInt(1));```
Lets say I wanted to get the enchantments the selected item already has and ADD the efficiency this code is trying to give the stick
How would I do that?
(Ping in responses)
You would create an itemStack or if you are pulling it from say a player you need to do something like player.getInventory().getItemInMainHand().getEnchants that would get you the enchantments of the item in the players hand and then you would do something like player.getInventory().getItemInMainHand().addEnchant(Enchantment.DIG_SPEED, 1) to add the efficienc enchantment.
actually the code I think I'm supposed to edit should be this chunk
if (item.getType().name().endsWith("STICK")) {
item.addEnchantment(Enchantment.KNOCKBACK,
finalTeamSharpnessLevel);
}```
would it still be the same thing?
U donβt have an opening brace on the first if statement!!!
if (finalTeamSharpnessLevel > 0)
if (item.getType().name().endsWith("STICK")) {
item.addEnchantment(Enchantment.KNOCKBACK,
finalTeamSharpnessLevel);
}
if (finalTeamEfficiencyLevel > 0)
if (item.getType().name().endsWith("AXE")) {
item.addEnchantment(Enchantment.DIG_SPEED,
finalTeamEfficiencyLevel);
}
if (finalTeamEfficiencyLevel > 0)
if (item.getType().name().endsWith("SHEARS")) {
item.addEnchantment(Enchantment.DIG_SPEED,
finalTeamEfficiencyLevel);
}
}```
I mean it still works
Oh i didnβt see the forEach
Well it depends. What I gave you is for 1.19 if you are in a different version than no. Also from what I'm seeing it looks as though their are other variables and such that we don't know and therefore can't fully interpret the code.
I just downloaded the source code from another plugin and I'm editing it to apply different enchantments
its all good! the original message didn't have it
All you need to do then is change the Enchantment.ENCHANT to be the desired enchantment
Only issue is that it doesn't add the enchantment to the item. it sets it 1 to. so instead of being kb4, it goes from 3 to 1
Likely because they are basing the enchantment level appears to be set based on a variable that I would guess is based on the team upgrades.'
So you need to find how they set those variables and modify that as well to match your new enchants
Read the two messages above ^
Hello! Do you know if there is any class that identifies when any head is in the head of a player?
You would need to check the players head slot and see if the item material is a player_skull. from their you would then do whatever you want to do after checking that
Excellent thanks!
so something like player.getInventory().getHelmet().getData should return the itemtype.
I'll write it down thanks, I'm trying to create my first plugin XD
Word of advice. Try to read the docs if you can(if you aren't using the latest version of mc you can create the docs on your computer using the build tools. Also make sure to at least know basic java before you start. You can work without that knowledge but it will make life ten times easier.
Also if you need help you can always ask
Is their a way to create an iron golem that will act like a village golem except the protection would be of a specific player/entity rather than a village?
Yes very thanks!
The last thing he said (About the golem) was for me?
No I am just asking anyone about that
ahh okay
So if you know you can answer but otherwise you don't have to
are entity ids persistent?
by id i mean Entity#getEntityId(), idk if there are any kind of ids
not even across chunk loads?
they persist in memory but not between server restarts if thats what u mean
If the entity is removed by the server, it loses its id
That may include chunk loads
so, in theory, entities are "removed" when the chunk is unloaded
Yes i would assume so
so, how can i get a persistent id?
thats persistent even when restarting the server, or unloading the world?
Yes
ok that will do it then, thanks
can i safely teleport any entity? or just living ones?
i mean, if i teleport an item frame, an armor stand, a painting, will that work?
well, idk if paintings are entities
They are
Entity#teleport() isnβt restricted to the LivingEntity class but teleporting paintings and item frames might behave weirdly, Iβve never tried
For entities like boats it works as expected
I'm getting an error that I cannot add a value to a set because the set in question has a value of null(or thats what I interpret from the error). Does anyone know how I could fix? I define the set by doing Set<String> Dash; and then use Dash.add(); to add things.
Error is https://pastebin.com/abwHwRiR
So you create a variable but never define it?
yes and thats because for whatever reason I can't leave it as just an empty Set. I tried to define it but each time it just tells me I need to add an expression...
Thank you. I've never worked with sets. I was told to use them for something I was making when I asked a question and said another method I was going to use to store data(pdc). I then tried to research into sets but didn't find much on them(I read the java doc).
Set<String> dash = new HashSet<String>();
if i want to compare the worlds of location objects, should i do == or .equals?
World#getName()#equals()
== is generally used for comparing enums
Really dumb IDE question, but how do I remove this box? https://fwoostyhub.com/ππΊππ
Thank you very much!
you can also right click it and close it
Quick question. Is their a way to make it so that hidden players can take damage(when using .hidePlayer)
Or do I need to figure out how to use packets to make the player invisible instead
You would need to use packets or ProtocolLib I think?
Thereβs a hacky solution where you can use a mob suggested in this thread: https://www.spigotmc.org/threads/hide-player-but-still-allow-damage.279583/
to check if a list contains an uuid, is this enough? list.contains(entity.getUniqueId()), i declared this type of list, idk if there is another List<UUID> list = new ArrayList<>(), idk how the structure of the UUID is, i write java code once a year, so
βList<UUID> list = new ArrayList<UUID>();β and you should be set
Though Iβd suggest using UUID#toString() and making a List<String>
When you define a list, set, hashmap, etc the typical syntax is to specify the type on both sides
Because this will ensure only that type can be added to the list, set, hashmap whatever
Has anyone else added protocollib as a dependency recently? I went ahead and followed the protocolLib instructions of adding the repository and dependency values but it says that it can't find the dependency
It's on their spigot page..
And as I said. I followed those instructions and it isn't finding the dependency
I redid it a few times and reloaded my IDE a few times and now it seems to have finally found the dependency
is this enough for preventing any spawn on a world with that name?
@EventHandler
public static void onEntitySpawnEvent(EntitySpawnEvent event) {
if (Objects.requireNonNull(event.getLocation().getWorld()).getName().equals("some_world")) {
event.setCancelled(true);
}
}
its temporary, i know gamerules exist, or a better way to do that
likely yes
I apologize for pinging you but do you know how to use ProtocolLib?
How can i handle big prioritied threads
There was a topic
but i cant find
7smile made it
Why did you Objects.requireNonNull?
It it this?
Wha
Thats from your message earlier today that was also talking about what you just asked
I searched "big prioritied thread"
to prevent a warning
Man he just deleted it?
It can f*ck the view of code
Dont, just do a null check for the world, it will give a big ass exception if the world doesnt exist
How can i get a player address to check their alts?
Hello, may I please have some help with my plugin?
I am trying to use PlayerQuitEvent but it's not firing and I made extra sure that I registered it
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
What do I have to do to make the PlayerQuitEvent detect a player who clicks on Disconnect?
So far I have done:
Give it its own listener class
Register the event in OnEnable
Made sure to put EventHandler above the event method
I can't use print statements because for some reason nothing in that class happens when I quit
send code
here is the listener class
https://pastebin.com/buL7M1tm
main class
https://pastebin.com/2iJSFynT
and the command class it mentions
https://pastebin.com/mepEXRXC
I don't think QuitListener is being reached at all but why not?
because you never registered it
Are you sure? I registered it in the second pastebin
you didnt. you instantiated it and made it a throwaway
it says "new QuitListener(this);" under "public void registerEvents" and "registerEvents();"
but it never says Bukkit.getPluginManager().registerEvents(new QuitListener(this), this);
I read somewhere not to put that if you already have "new QuitListener(this);"
But I'm sure you're right
I'll put that in and test
then dislike the post
how will the server detect that you created the events
i mean the one that misleaded you
o: I should do that
must be in my history somewhere
LSoofiaa idk XD
I get confused because I register them in main
and think that's enough
I see why. Some of my listeners have it and some don't, yet they all work so idk :/
Anyways, adding that did not work, so back to the drawing board
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
ok ok
- the current state of your code
keep getting yelled at T-T alright lemme just ask really quick: where do I put that line? maybe I did it wrong
where did you put that line?
most likely you replace your QuitListener instantiation with it
in the listener class under
"public QuitListener(Main plugin) {
this.plugin = plugin;"
Registering a runnable as an event listener
I'm guessing that's wrong, it's giving me an error. Can you please tell me where to put it?
Unless you have other things you run in you onE noble function the line he gave you should basically be the only line their(at this stage)
alright I just need to loop through the list and everything should work
I'll confirm in a bit
Hi a question if i use the Material.Skull from 1.8 and set all the proprietaries will work on 1.19 or i need to do some check for version?
how can i remove this message? Plugin listener JoinListener took 97ms to process event PostLoginEvent(player=name)!
im coding antivpn
is it possible to set multiple slots in the same line?
so instead of
player.getOpenInventory().setItem(0, mat("LIGHT_BLUE_STAINED_GLASS_PANE"));
player.getOpenInventory().setItem(5, mat("LIGHT_BLUE_STAINED_GLASS_PANE"));
something like
player.getOpenInventory().setItem(0 and 5, mat("LIGHT_BLUE_STAINED_GLASS_PANE"));
Does something like this even exist?
You can create your own function that does this
Wrong event probably
then it's a 1 liner :p
bungee
i forgor bungee api
wrong event? wdym
you prolly looking for some async event
or might have to switch threads
cause i assume youβre makimg web requests that are blocking
the server thread
how do i make event async?
some events are just invoked async in spigot api atleast
but
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
how do i make event async?
I have fixed all my issues, thank you everyone!
Theres an async prelogin however that doesnt have a player var available
if i execute whole event's code like this
@Override
public void run() {
}
});```
will it be async?
yes
Shoot rays as a carpet
ok
i wanted to send that :c
i generally dislike assert statements as they are mis used by beginners as a way to stop their IDE moaning at them although all they are doing is moving the error
idk use asset
assert*
although that looks like an NMS error so you are probs doing some wacky shit
emm no i use nms for title sending only
are you setting the amounts of items
nope
The item i click I get it from a file
it works fine but that happens when I click it
it seems like this error sometimes comes from having -1 amounts, so idk
try printing this leave to console to check its valid
the path?
is it possible to save time until bukkit scheduler runs on restart for example?
Heya, do you have any recommendations for design patterns for event listening? I tried to make a factory for a player join event, just for fun, but passing the arg casues issues (I am still learning Java)
What do you mean by that?
lets say scheduler runs every 10 minutes but 5 minutes passed and server got turned off
i want to wait additional 5 minutes on start
in that case you need some kind of persistent storage that stores the time it last ran
then on restart you can pass the time left
Means if it ran at 10:00 and your server restarts and is up again at 10:03 then you would pass 7 minutes. If it's down for more than 10 minutes you can run it immediately
or like down over the 10 minute mark
You subtract the timestamp where it was run for the last time from the current time. If the rest is less than 10 minutes you run it with the resulting time left. Otherwise you can run it immediately
You usually never call the event urself. You just listen to it. What are you trying to achieve?
Hi guys anyone know how can i control the loggers out of the libraries shaded into my plugin, they do not show as my plugin instead the logger name, and people are confused
which libraries are the problem?
I have a simple raycaster, that moves one block in front each time, however it does get pretty slow if I ray cast say 100 rays with length 15, is there any way I can make it faster
dont cast as many rays?
i mean, theoretically u could reuse some of those rays
where are you sending them
I need to? Well I am trying to make a really good looking portal effect, so the best way to make it look good is rays
As I want it to keep going trough glass and stuff
i dont think that rays are the best way, but good luck!
i would just do pure angle math, between the eye and the pillar
the problem with glass portal frames is that it means that for a smooth effect there wouldn't be any border at all, ie turn the whole world to nether or whatever
try core shaders?
im just thinking of this https://www.spigotmc.org/resources/betterportals.75409/
try to parse the string as integer
ye try catch block with Integer.parseInt(str) and catch NumberFormatException
Good question.. A listener in spigot is like "an open port" I will have to assume, so it runs all the time. Without additional reruns and a simple event register line. I guess I just have it listen in a different class. And execute code in the factory method?
I just want to learn java + spigot with building good habits
public static void sendConfigMessage(String configValue, CommandSender receiver, String toReplace,
String replaceWith) {
if (!config.getString(configValue).equals("")) {
receiver.sendMessage(colorString(
config.getString(configValue).replace(toReplace, replaceWith)
));
}
}
i have this function thingy, can i somehow make it so toReplace and replaceWith can be added in unlimited amount?
That's why I would ask which kind of design patters are being used with spigot plugins, (I know it's very case specific)
you mean String[] values as an args?
Could use Stringβ¦
Where even arguments are the substitutes and odd arguments are the placeholders
Well
Its just a simple vararg argument
We dont have keyword arguments or anything to fancy like py or js
ye tho
No only once
But this
Can have only one and it has to be the last parameter
Or use sth like Pair<String,String>β¦
Design patterns are optional and differ from case to case. Basically you have a listener class that reacts to the event. In that class you can either handle the full logic or you just go with some checks like
'if(player.getWorld().getName().equals("Testworld"))' and then call a function of another class - that's up to you.
Listeners subscribe to events and get called each time the event occurs. I wouldn't call it "open port". I would compare it to the observer pattern - although it's not exactly that pattern
equals pls not ==
why is Material#isTransparent() deprecated
ye my bad ^^
and then i loop thru each pair?
Wouldnt say they are optional
You insinuate them everywhere in your code
Just not canonically necessarily
nevermind im fucking blind
What I meant by optional is that you are not forced to use them. Yes you should in specific cases but you can't generally say "use that pattern" if you don't know exactly what the goal is
anyone have alternatives to Material#isTransparent()?
Well you are technically forced to use them
Just that you might not be aware of them as their formal and canonical names and forms
i need to get every block that doesnt change the player's Y axis when they stand on it
like air, lava, saplings, crops etc
isSolid?
they all return issolid
Like for instance, almost every class is a facade thus can be deduced as using the facade pattern
isLiquid?
saplings and sugarcane and redstone dust and torches
how do they change the Y
when you stand on them
on a torch?
it doesnt
you just walk through the torch
thats kinda what i want
all the blocks you can walk through
maybe isOccluding
no
don't have any other ideas rn, maybe u have to create ur own set of materials
shows all full blocks
:(
That's true for some patterns. Facade is a good example that a lot of people implement without actually knowing it. For other patterns like singleton you are not forced to use it.
Even when there's only 1 resource of a type (like only 1 db connection for whatever reason) you can still avoid singleton by adding a static 'locked' boolean or whatever. I'm not suggesting that this is a good way - it does however make it optional
Yes but that would be classified as using the design pattern mono state
declaration: package: org.bukkit.block, interface: Block
Bro use the docs next time
kinda directed at mine but 
there a difference between !isCollidable and isPassable?
iscollidable is for livingentities
isnt iscollidable for entities
lol
Tho yes @flint coyote whether you wanna show intent by naming your components after the patterns is optional, but whatever you do you will be insinuating design patterns here and there inevitably
ok conclure i think i got it
ive made Pair<CharSequence, CharSequence>... and i loop thru those and set replace to left and replacewith to right
π΄
π₯²
That's pretty much what I tried to say. Best practice often goes hand in hand with design patterns. When using one (e.g. singleton) you don't use mono state (which I didn't know existed before, so thanks) thus making this one optional
Oh this might be a paper thing
now how 2 inline pair
Yes but again design patterns as a whole is are not optional at all
You use them whether you want to or not
Then yea you can choose between which ones to use
That does not warrant the optionality
I meant to say that each design pattern by itself is optional. Not all of them at once
so um, I had this bug with minecraft where any versions 1.18 and above would freeze every 1 second, meaning the graph would be some thing like this:
300 -> 1 - 250 -> 1..etc
so well i used some jvm args i got recommended which are:
-Xms2G -Xmx2G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1```
and that fixed it, however after 3 days the bug is back, but i realized something, when the bug was fixed i had 2gb allocated and it was using 2.7gb, but when the bug still existed it was using 2gb flat, so i thought maybe that was the problem, i just tried allocating 3gb or 4gb and no luck.
Myeah altho pair::of is more of a recent addition iirc
someone got an idea? this isnt about spigot or servers tbh but yes
gotta profit
how do i make a block object from a material
Although I guess you could technically avoid all design patterns by writing horrible code all in one class, not using functions etc.
without placing any block
unless there's a name for that antipattern aswell (spaghetti code? π)
You can't construct a block by regular means
In principle Id say no, because you still use delegation to some extent which is a vague design pattern to some degree
But yeah spaghetti code is probably a better label for that
bruh
What are you trying to do?
bruh
What's the context of what you're trying to do?
checking if the block is passable
why do you need a block
where are you using it? like in an event or what
its a 1.8 project which im trying to convert to 1.19.2
this guy handcoded every single block
oh no
in 1.8
im trying to unhandcode it
by adding stuff like "isoccluding"
rather than EVERY SINGLE FULL BLOCK
π
this code is in a method to get the top height of a block
like a full block would have 0 top height
while a half block would have 0.5
stairs would have 0 or 0.5 depending on where you're standing
I am trying to make a command that plays a sound but like a few second after the command was executed
scheduler
use a bukkitrunnable
?scheduling
theres 6 more files after this
all that wasn't there in 1.8 I guess?
you got my hopes up
bruh this server is literally 1984
cant even send death threats anymore
method dont work
rn you are programming against 1.19? Did I get that right
then you should have access to material#isCollidable
but wouldn't isCollidable return true for stairs while they are still passable?
did you run mvn clean package after changing the pom?
or updateProject in intellij?
and the error message from mvn clean package also shows the isCollidable error?
It would
and every single other block from 1.8 that got renamed or removed
Why a switch π
I think material#isCollidable is a paper only thing, sorry, forgot I'm on paper rn
pain.java I love this
as you can see
its 1.8
because we dont have "steps" or "diodes"
we have slabs and repeaters
theres also another method just like this
but for lower height
Hello. Is there a way to cancel the bypass of the WG regions using it's API?
Or do I have to cancel all the events manually?
how2 people make chance systems for loot?
what
Random numbers?
forgor π too much
how do I java? I forgor π
i tried using my free copilot to edit all these values
moon bigsystems
so um, I had this bug with minecraft where any versions 1.18 and above would freeze every 1 second, meaning the graph would be some thing like this:
300 -> 1 - 250 -> 1..etc
so well i used some jvm args i got recommended which ill send later,
and that fixed it, however after 3 days the bug is back, but i realized something, when the bug was fixed i had 2gb allocated and it was using 2.7gb, but when the bug still existed it was using 2gb flat, so i thought maybe that was the problem, i just tried allocating 3gb or 4gb and no luck.
the jvm args are here: https://pastebin.com/3mK9yZFf
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
shouldn't Material.isOccluding() be everything you need @ornate mantle?
why?π
lemme show you the scale of my problems
material.isoccluding only includes full blocks
there are blocks that occupy less than a full block
like slabs
0.5 elevated height
and farmland etc ye
How to remove World without getting ^ when shutting down?
0.5 nevermind