#help-development
1 messages · Page 1922 of 1
Never heard of that one
You cannot mock Bukkit
(i dont btw)
what?
yes ofc
You cannot mock static methods from Bukkit class
if u help me with spigot dev hehehe
only if you pass plugin aswell
Do you want to show them to everyone or only to a specific player?
everyone
Both the Player and World class share a method called #spawnParticle(); If you want to show them to everyone, use World#spawnParticle() otherwise use Player#spawnParticle().
The methods have parameters for location and offsets. So use the location for the math.
Get the location of the projectile and spawn particles at that location. Since it will be moving, a trail will be created if you are using the scheduler for spawning the particles.
specialsource-maven-plugin problem
Still need help with this.
Could you show the code
the head you're getting is null
No
Thats the last leave, i need the last join…
I don't think it is. As when when I reopen the GUI it's fine. No NPE.
the serialized profile used to make the head is null
Which part?
The part where the error is
That's what I'm trying to figure out.
Thats the last leave, i need the last join…
Preferably the entire method
The error says it's something to do with my IconSet.getNext method, but the NPE points to a custom head issue as it's NBTTagCompound.
But 1 sec, I'll post some stuff.
I have to get some sleep now. If you can't solve it create a thread and I can help more tomorrow
public void EntityDamageByEntityEvent (EntityDamageByEntityEvent event) {
Entity e = event.getDamager();``` how can i tell if the eventdamager is a player
So, these are the methods I use to update the inventory. https://paste.md-5.net/nejinapezo.cpp
The ItemPair class: https://paste.md-5.net/elafitarim.cpp
The IconSet class: https://paste.md-5.net/basopiwofu.java
The ButtonSet class: https://paste.md-5.net/movurebefa.java
These classes are responsible for handling the item changes.
Check if the damager is an instanceof Player.
if(e instanceof Player)
i got that but i want to convert it to a player data type
You could try Player#getFirstPlayed(), but I'm not sure if that will get the time they first joined the server, or the last time they played.
its hard to explain
You need to cast.
if damager is an instanceof Player, then cast damager to Player
Player player = (Player) event.getDamager();
After you check if it's an instanceof a player.
oooohhh
That's the weird part. That method is used to create heads in other menus. Why is it causing an issue with this one head?
Method I'm referring to: https://paste.md-5.net/tobanobazi.cpp
Make sure you check its an instance of a player first
just reviewing my code and saw this https://github.com/r0wl/HCFPlus/blob/master/src/life/steeze/hcfplus/Objects/Claim.java line 19 should i make that static
no
Why not if it is the same across all instances
i just realized ive been stopping the claim at 0 also
so i have this ```java
@EventHandler
public void EntityDamageByEntityEvent (EntityDamageByEntityEvent event) {
Entity en = event.getDamager();
if (en instanceof Player){
Player player = (Player) event.getDamager();
if (TeamManager.isUndead(player) && !MorphManager.isPetNearOwner(player)) {
event.setCancelled(true);
}
}``` but how do i tell if the entity getting damaged is an item frame
Plugin is not statistically initialized
There's a principle called depenency injection
so the entity damaged by entity only cancels the event if it got item in the item frame how can i bypass that
also did this change recently
Did a thing https://i.kawaii.sh/4yG3xQ-.png
Finally got that shit working
Now my tables are annotation powered with automatic migrations
vibing
How can I disable armor from falling out of entity?
Are you doing an ORM
I used ebean which has migration generation and annotation table stuff. Took forever to get to work with spigot though
Weird class loader issues
Example ```java
@Entity
@Table(name = "players")
public class PlayerInfo extends Model {
public static PlayerInfoFinder find = new PlayerInfoFinder();
@Id
long id;
@NotNull
@Column(unique = true)
@DbComment("Mojang assigned UUID")
public UUID uuid;
@NotNull
@DbComment("Weather the user has verified their discord account linkage")
public boolean verified = false;
@NotNull
@Column(unique = true)
@DbComment("Discord snowflake ID")
public String discordId;
@Unique
@DbComment("ID of the discord message sent during verification")
public String verificationMessageId;
public PlayerInfo(
@org.jetbrains.annotations.NotNull UUID uuid,
@org.jetbrains.annotations.NotNull String discordId,
@org.jetbrains.annotations.NotNull String verificationMessageId) {
this.uuid = uuid;
this.discordId = discordId;
this.verificationMessageId = verificationMessageId;
}
public PlayerInfo setVerified(boolean verified) {
this.verified = verified;
return this;
}
}
You can get it with PlayerInfo.find.byUuidOptional(uuid)
The static is due to a finder. Its basically just```java
public class PlayerInfoFinder extends Finder<Long, PlayerInfo> {
public PlayerInfoFinder() {
super(PlayerInfo.class);
}
public Optional<PlayerInfo> byUuidOptional(UUID uuid) {
return query()
.where()
.eq("uuid", uuid)
.findOneOrEmpty();
}
public Optional<PlayerInfo> byDiscordIdOptional(String discordId) {
return query()
.where()
.eq("discord_id", discordId)
.findOneOrEmpty();
}
}
It depends on the current default database entered in the thread/classpath
still, global variables
so? Who cares about globals. If you dont abuse the fuck out of them then its fine
Also it support futures for async. ill prob convert to future based later
Have you ever heard about object oriented programming
Yes, ive used C++, C#, Java, Rust, and Kotlin before. All of them are object oriented (except maybe Rust)
OOP is fine but not everything needs to be a scoped instance like that
Global instances are fine and it depends on how you use it
If you are setting random stuff as global then it becomes a problem. If you are setting a logger or a finder as global then its fine
Thats the rule with OOP
Just because people say global variables are bad doesnt mean they are bad all the time. Global variables should be used in a way that doesnt over complexify your code and keeps it still running mostly instanced
In 90% of situations globals are bad but this code would be much more disgusting if i was to use instances
Nor does it overcomplexify anything or make a forever dependency
People say that they're bad for a reasons
People say they are bad but those people don't know what they are talking about. Globals are bad most of the time but there are good uses
Just because a professor or teacher who learned Java when it first came out in the 90s says its bad doesnt mean they are bad. It just means they are outdated
I mean, okay, logger. Anything else?
This case is specifically fine. It's known as thread local design. What the finder does is find an instance/connection only available on your current thread and uses it
Thread local design is like a global but its different depending on the thread
Which means if you spawn another thead and try to access the database it will be null unless you enter the database in that other thread
Actually this is threadlocal AND classpath global
so only in my plugin will the instance be valid, this prevents conflicts with other plugins using ebean
- Singleton violates SRP (Single Responsibility Principle) - the singleton class, in addition to actual responsibilites, also controls the number of its instances.
- Global state. When we access an instance of a class, we do not know the current state of that class, and who changed it and when, and this state may not be what is expected at all. In other words, the correctness of working with a singleton depends on the order of calls to it, which causes implicit dependence of subsystems on each other and, as a result, seriously complicates development.
- The dependency of class to singleton is not visible in the public contract. Since usually singleton is not passed in the method parameters, but is obtained directly, via GetInstance(), then to identify the class's dependence on the singleton, you need to get into the body of each method - just viewing the object's public contract is not enough.
- Singletones makes testing harder. If class depends on Singleton, you cannot easliy mock it.
This is not about the singletones only, but generally speaking about global variables.
not always true
depends on if you use singletons correctly or incorrectly
A DB is a connection with methods on it. You aren't modifying the state in the same way as a global static string
i disagree. That does not specificslly mean the jaba object state. Database itself has state too
a private state
Plus, its thread local. you dont directly access the database, you do it through finder implementations
Idk if it actually violates SRP, considering that SRP just states a class should have one major reason to change. So it merely depends on what we define as major xd
The way it works is classes like these
public class PlayerInfoFinder extends Finder<Long, PlayerInfo> {
public PlayerInfoFinder() {
super(PlayerInfo.class);
}
public Optional<PlayerInfo> byUuidOptional(UUID uuid) {
return query()
.where()
.eq("uuid", uuid)
.findOneOrEmpty();
}
public Optional<PlayerInfo> byDiscordIdOptional(String discordId) {
return query()
.where()
.eq("discord_id", discordId)
.findOneOrEmpty();
}
}
query() initializes a query with the current thread and calling classpath database instance
there is a global manager that keeps track of instances depending on thread and classpath that runs the query on the proper context connection
In this case its fine.
still implicit dependence
so? not like anyone is going to use it wrong
Just because an opinionated textbook says you cant do that doesnt mean its right
On top of that you arent using multiple databases in your program at the same time
Even if you are (in case of plugins) its thread/classpath based
The main issue in my point of view is testability
Let’s say you setup a unit test
Most likely you might need sth like mockito and power mocks
Which is just sloppy to every extent
Initialize the database and set it as the context database for thread. Then do DB operations in test
Can you now write plugins in c# or some shit? Someone told me you can now in javascript and c# etc.
as you'll for instance have old state repurposed into every test that gets instantiated
so then you're not just testing the unit
True, but you only have one database usually. Code portability is one thing but you need to copy the entire database class just to use it and then pass it in.
there's mostly just wrappers that invoke java under the hood afaik
fuck
Plus you could just drop the old state and start the new state, connect to an in memory h2 instance for tests
you know commas exist
can you give me any link to that? dunno where to find it
I don't know any myself.
I dont tgink there's anything decent
and I dunno about plugins specifically, but I should note I'm referring to the server software
which may or may not be helpful, lol
yeah i want to write server plugins
ya but not as easy when you want to isolate a unit with mocks x)
in those languages
you know who needs dis dumb tests anyways cuz just start the server
how can I remove all leads attatched to a player?
new PlayerInfo(sender.getUniqueId(), member.getId(), message.getId()).save();
.save is what inserts
ah true, I mean with ebean you can also have multiple named instances
that you can either pass by instance or get by name
yeah
If your doing tests that is useful
indeed
how do I reduce the durability of an item by more than 1 when an event is called?
it doesn't save at the end of the listener
Wait a tick
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
// your logic here
};```
Are you making sure you're putting the meta back into the item?
Otherwise your change is likely being overwritten by the result of the event
That too
Or set the listener to monitor mode which runs after the event fires
No it doesn't lol
Doesn't it?
You can cancel an event in the monitor phase, you're just not supposed to

that would make sense, I've been trying this for hours and could never figure out why it kept going back to +1 instead of the number I was putting
public void applyDamage(ItemStack item, int damage) {
ItemMeta itemMeta = item.getItemMeta();
Damageable itemDamageMeta = (Damageable) itemMeta;
int currentItemDamage = itemDamageMeta.getDamage();
itemDamageMeta.setDamage(currentItemDamage + damage);
item.setItemMeta(itemMeta);
}```
Huh I guess I gotta go test monitor mode again cause maybe it's messing some of my stuff up lmfao
what does -> do?
Makes a lambda
You're passing a Runnable
Runnable is a functional interface - an interface which only defines one abstract method
So you can do
Runnable run = () -> {
//stuff here
};```
And it's the same as
Runnable run = new Runnable() {
@Override
public void run() {
//stuff here
}
};```
But it's much shorter so you should pretty much always use the lambda syntax when possible
oh neat, I'll look into that more
does this already make it wait 1 tick?
still not working java public void applyDamage(ItemStack item, int damage) { Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> { ItemMeta itemMeta = item.getItemMeta(); Damageable itemDamageMeta = (Damageable) itemMeta; int currentItemDamage = itemDamageMeta.getDamage(); itemDamageMeta.setDamage(currentItemDamage + damage); item.setItemMeta(itemMeta); }); }
Why its not possible to add a Custom player (implements Player interface) to player list?
Maybe I'm blind but I don't see you adding the delay?
Why does this happen?
Weird NPE
public void applyDamage(ItemStack item, int damage) {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
ItemMeta itemMeta = item.getItemMeta();
Damageable itemDamageMeta = (Damageable) itemMeta;
int currentItemDamage = itemDamageMeta.getDamage();
itemDamageMeta.setDamage(currentItemDamage + damage);
item.setItemMeta(itemMeta);
}, 2);
}```
added delay, tried 1 and 2
unless delay is in seconds
where it would need to be 4
Its telling me that im providing CustomPlayer. But that interface its extending Player. So i have no clues :/
Try 20 or so that should work. Though 1s is a bit long
That's not going to work to add custom players.
You need to use NMS cause even if you got it to work you'd need to update the clients to know, which is NMS
I dont want the other player see this custom player
Its only to add a fake player to server. So plugin message detect it as online player
Im still trying to find a trick for using plugin message without real players onlines
I didnt understand the "you need to update the clients to know, which is NMS"
delay of 20 didn't work so i tried 100 and it didn't work
20 ticks = 1 second
When a player joins a server they don't just add them to a list they send packets to all users to give information on the player. Adding a player to a list isn't going to solve your issue
Why not?
they just explained it
I only need to bungee detect it as online player
Because I imagine the issue is more deep rooted than that
?xy
Asking about your attempted solution rather than your actual problem
I'll take a look later for you
?
Currently looking at @ancient jackal problem right now
read the bot output
I dont udnerstand the message
you are asking why something wont work, rather than what the actual problem is
Im only trying to find a way of adding a fake player to server. So spigot detect it online. And allow me to received and send plugin messages
Not going to be that simple
Oh
Def would be working with NMS
definitely*
So definitly working over Netty will be my best alternative
Depends on what you are trying to do
delay of 40 not working either
Thanks i wont lost more time trying to use that, that its not created for sending and receiving cross server messages (talking about plugin message channel)
Theres multiple other ways of doing stuff like that, such as redis, as you mentioned netty, I would personally go for Redis but thats up to you
I'm looking at it give me a moment.
The problem are my bosses
They have paid me for a core that they want to be independent from using Sockets and message brokers (Redis, RabbitMq, etc)
Yeah
lol we have this convo every day now it seems
no reason you should have accepted that lmao
And their arguments are that for doing that "they need extra resources"
Its more than 60 dollars. And it help me a lot
they should've had the resources they needed ready
fair enough, I feel like thats a bit low for a server core but its all depending on features
That my question. Why trying to do something they dont have infrastructure
🤡
They are exactly that emoji
Please help me
How can I check with .hasPermission() ingnoring ops?
(ignoring * permission too)
if has !perm || isop
So I wanna check if someone has EXACTLY that permission
No the problem is that even if a player doesn't has that permission and he is op, it'll return true
Ops get all permissions so the simple easy solution here is to not hand out op status like free candy
^
Hmm
permissions:
oranks.owner:
default: false```
This is exactly what I want
But I want it not to only be oranks.owner but oranks.* so for every sub permission
I guess the next best step would be to completely forget about this shearing plugin because item damage just does not work lol
What?
Wait are you testing in creative mode?
no
no matter the delay, goes down by only 1
Cause your code works for me
with shears on sheep?
Let me try
do you want to try my plugin? the compiled jar?
kar.
i want to display text above a players name, for example "Level 1" how would i do that? the only thing i can think of is have a named armor stand follow the player but not sure if thats the best way to do it
the armor stand will always lag behind a bit
you can use team prefixes if you're fine with using the same line
do you know of any apis that make it easier?
maybe you could also make the armorstand a passenger of the player, have you tried that?
You're not setting the item in the inventory
You should probably be doing that
Or if you are, you're not showing it to us
So I am calculating players which are in range of player A in radious of 40 blocks
and doing that for every player do get there players in range.
So currently I have runnable task for every player which is doing that every 5 ticks.
I am curious is it ok to have that many runnable repeting task or should I just make code in runnable as method and for loop thru all player and do it in one runnable?
but if a player punched wouldnt the armorstand get in the way? also is there a way to add offset to that because i want it to be slightly above the players name
It doesn't really make a difference
But having it be one task keeps it simpler
you can set it as marker and make it invisible, I thin kit doesn't have any hitbox anymore then
but the other things?
I'd rather use just one runnable
if you loop through all players anyway, no need for 30+ runnables
passenger setting will not work on player
oh. are you sure?
because they will fall of in water and player will not be alble to teleport
// Collects animal info
Entity originalAnimal = event.getEntity();
Location animalLocation = originalAnimal.getLocation();
// Collects player info
Player player = event.getPlayer();
Location playerLocation = player.getLocation();
ItemStack usedShears = event.getItem();```
```java
int damageToApply = 0;
for (Entity animal : nearbyEntities) {
// some stuff
System.out.println("shearing sheep");
damageToApply++;```
```java
onEventAlready = false;
applyDamage(usedShears, damageToApply);
System.out.println("Shears have " + ((Damageable) Objects.requireNonNull(usedShears.getItemMeta())).getDamage());
System.out.println("Listener ended.");
}```
you can set gravity to false
and dismount event is buggy
so u can't cancle it
plus there is no way to detect when teleport method is called to dismount passenger
I call applyDamage with usedShears which references event.getItem
and that will block you to teleport
so all essentials commands for tp will not work
Again the code works for me
with passneger on your head
@EventHandler(priority = EventPriority.MONITOR)
public void onItemDamageEvent(PlayerItemDamageEvent event) {
ItemStack itemStack = event.getItem();
applyDamage(itemStack,5000);
}
public void applyDamage(ItemStack item, int damage) {
ItemMeta itemMeta = item.getItemMeta();
Damageable itemDamageMeta = (Damageable) itemMeta;
int currentItemDamage = itemDamageMeta.getDamage();
itemDamageMeta.setDamage(currentItemDamage + damage);
item.setItemMeta(itemMeta);
}
Best option is packets and spawning passenger above head
but is there a way to add offset to the armorstand
nop
you can use snow balls
then that wont work for me
as entity
what
insted of armorstand set snowball as passenger
IIRC TAB has the ability to add new lines above a player head
so check out TAB's source code
snowballs fall
disable gravity
grevvitee
that wouldnt help though because i still cant add offset
check out tab's source code
I think tab teleports armorstand
around
I was looking in to it before
but not sure how they do it
ig ill need to do that then
receive: stream -> buffer -> bytes -> stream -> deserializer -> data
send: data -> serializer -> stream -> bytes -> buffer -> stream
Do you agree using that order for sending and receiving packets?
Even setting the damage using the event itself works
stream writes to a buffer which writes to whatever you're writing to which then runs through deserialization to then be used
so... it works?
I'm beyond confusion
Yeah I can't replicate your issue to be honest
can you send me the jar you compiled?
Yeah i will be sending and receiving class bytes serialized with Serializable interface
It's for 1.18 idk if that's useful
maybe something broke between 1.18 and 1.18.1
Nope. Explain how this is supposed to work
Me?
no
I'll take a look when I get the chance. I don't have a bungee test environment either atm
The listener gets the player shears sheep event
if the event is already running, just return to prevent a large shear chain
get the event entity and event player, the animal location and the used shears ItemStack
No problem. I only need ideas. Cuz it will be my first time working over Netty.
and save that good stuff to variables
collects a list of nearby entities in a 3x3x3 block radius from the sheared sheep
Yeah I copy pasted your code and it works just fine
loops through and if it's not a sheep or is the original sheep you sheared, continue
otherwise it applies 1 damage each iteration just like you were shearing sheep 1 by 1
at the end, set onEventAlready to false so the listener can run it's stuff again
so I was right to forget about this plugin then 😦
just doesn't work at all for me lol
painful lol
hello guy
I can not use 2 Java on my server, for example Java 8 and Java 17, but in the flag I specify which Java I want to run the server on?
i can?
You can choose what version of java to run by either setting the environment variable or using the path to the java install
Use the full path to java in place of java in your start command
Could do it on ItemDamageEvent I can't seem to get the PlayerShearEntityEvent to fire for some reason.
How to specify which java should server use on launch?
Pick your answer
I just use a .bash_aliases for different java versions
Unix
mfnal@J▒germeister MINGW64 ~/IdeaProjects
$ 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'
actually on windows 😛
i used centos 7
Yeah I’ll just do that, check if it’s the same shear
but flag?
you have a flag in your butt?
yes
I don't really understand this question 😄
For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.
java -Xms5G -Xmx5G -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 -Dusing.aikars.flags=https://mcflags.emc.gs/ -Daikars.new.flags=true -jar paper.jar nogui
yikes
so?
how to select java 17
For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.
i used java 8 but i cant start smp server for 1.17
I already told you - use a .bash_aliases and then use java17 instead of java
how would I go about doing that actually? I have a PlayerItemDamageEvent listener in place that'll return event
You can manually do /usr/lib/jvm/version/bin/java -jar xyz. I don't think this person should be using linux they don't understand it 
can eventhandlers use other eventhandler returns?
no
I'd make it so whenever a pair of shears takes damage to check the area around it for sheep to shear and just do what you already did. However, I'm not too sure why the shear event isn't working I assume it's a bug or not implemented yet.
Event handlers don’t return a value
event "handlers" are nothing else than methods that get called via reflection by the plugin manager
in theory they could return any value they like
but
the plugin manager doesn't care about that return value
Sigh
how would you check the area around the shears? I just checked the javadocs and you can't get Location
You get the player not the shears
For some reason on latest I can't get it to fire when shearing sheap
didn't realize the event also included Player, tried it but maybe I amde a typo trying it
Huh
shear event fires and everything works except durability
lol that's not my issue. Maybe time to rebuild spigot
show your FULL code pls
?paste
Sup all! right now I have this
private static final int RANDOM_NUMBERS = 3;
but I want it so it will random select a number between 1, 2 and 3, any simple ideas?
if you want it to change then you can't really make it final w/o a method call
ThreadLocalRandom.current().nextInt(1,3);
that easy?
Yes?
try to get the shears from player#getInventory() instead
Random number generation is quite popular in programming
maybe the shear event's getItme() returns a clone
who would have guessed
But thanks! Will try it!
would ItemInUse work?
ItemStack usedShears = player.getItemInUse();
I'm trying it
It’ll probably be null
I doubt it
I'd to this:
ItemStack shears = player.getInventory().getItemInMainHand();
if(shears.getType != Material.SHEARS) shears = player.getInventory().getItemInOffHand();
going to try to rebuild it, wasn't working at all for some reason
what do you actally want to do?
damage shears more than 1 when they are used to shear e.g. a sheep?
shear sheep in a 3 block radius from the sheep that was sheared, damaging the shears by 1 everytime
works except for damaging the shears but I'm still trying your solution
ah alright
I'll try something myself
it just doesn't work now, no console printing
wait it might've been a boolean I never set back to false
I can confirm that setting the event's ItemStack's meta won't do anything
for damage? isn't that how you set damage?
yes, it seems like PlayerShearEntityEvent#getItem returns a clone of the shears
private static final ItemStack getShears(Player player) {
ItemStack shears = player.getInventory().getItemInMainHand();
if(shears.getType()!= Material.SHEARS) shears = player.getInventory().getItemInOffHand();
return shears;
}
@EventHandler
public void onShear(PlayerShearEntityEvent event) {
ItemStack shear = getShears(event.getPlayer());
Damageable meta = (Damageable) shear.getItemMeta();
meta.setDamage(meta.getDamage() + 50);
shear.setItemMeta(meta);
}
@ancient jackal
this works, I tested it
the event indeed returns a clone
a painful discovery
Weird
@sullen marlin is this on purpose? wouldn't it make more sense to return the actual Item instead of item.clone() in PlayerShearEntityEvent#getItem() ?
I think the event should return the actual ItemStack, or at least the javadocs should mention that it's just a clone
"Returns:
the shears"
-Javadocs
Shear event won't even fire for me 
shearing sheep is just something different smh
I'm too tired for this apparently. I'm going to get some air
Air, cave air, or void air?
The kind that makes brain go brrrrrr
shearing sheep DOES DEFINITELY fire that event on 1.18.1
aaah, weed
No lol. I've been wondering why the event isn't firing and my test plugin has decided today is the day it no longer wishes to load on my server

oh I figured out why it wasn't running anymore
@fresh templethandler was deleted
oh, hi even
lol
lol what movie is this from
The room
whats best way to keep a certain item from going in a certain inventory slot
check if there's another slot to go in
Permission node and inventory slot check.
InventoryClick checks with equip checks
Yeah not a fun task
You could cancel the toggle gliding event instead
Yeah but that might end up poorly
has elytra
jumps
dies
Some poor sod kermits die cause they didn't know they couldn't
oh?
Don't do it Anakin
i will xd
for elytras? use the ArmorEquipEvent
yes, the lib
Fair enough
I like the cat
me too but the whole event thing is nice too
oh yeah that too
use the event I sent ^
this
Yeah don't cancel the flight event or people are gonna mald when they jump off a mountain and eat dirt
But that’s funny
Yeah if you're a moderator
Interface doesnt support synchornized void?
ok
that makes no sense
"synchronized" is an implementation specific thing
and interfaces of course do not directly implement anything
Nothing it had to add it where the interface its implemented
interfaces define WHAT something does, and not HOW it does it
and "synchronized" is about HOW something does sth
Ah allright
I didnt know that
Always when i ask something i always learn something new
:3
tbh I didn't know I was right, I just assumed it. here's an answer from stackoverflow which basically says the same thing that I said, though:
Because synchronized is an implementation detail. One implementation of the method might need to make the method synchronized, whereas another one might not need it. The caller doesn't care whether the method is synchronized or not. It's not part of the contract, which tells what the method does. Which synchronization technique, if any, is used to fulfill the contract is irrelevant.
how would i add it to gradle dependency
I have no idea about this weird gradle thing
I only use the one and only proper build tool called maven 😛
i like maven too but this plugin is in gradle
you could just copy paste all the classes of course
other than that - sorry, no idea about gradle :/
it's probably just
implementation "groupId.artifact"
like usual
What a lovely yet
🤔
I will give more oportunities to sockets and let netty alone
on the EntityToggleGlideEvent how do i get the entity thats gliding and turn it to player
tbh you should never ever care about sockets when doing SQL stuff
Totally stole config comments from luckperms
Sql?
erm wtf?
to get the entity?
.getEntity()
to turn it into a player? check if it's a player, then (cast) it
lemme google cast
Im not working with SQL. Im trying to do a simple socket sender and receiver. But with packets (serializable objects)
Are you using bungeecord/spigot?
Yeah
Yeah theres a way to do it then
@karmic grove ```java
public void onGlide(EntityToggleGlideEvent event) {
if(event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
...
Lemme find some code I did
Oh really thanks
but tbh that's basic java 😛
It will help me a lot. Because i always get the main thread lock or NPE exceptions when sending or receiving
oh okay sorry, I thought you were doing normal SQL stuff
Yeah i think the name confuses a lot
I dont know which name put cuz. Connection its already used by the interface
Here was something i did with cross server teleport
private void sendPlayerTeleport(ProxiedPlayer player, ProxiedPlayer target) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(player.getUniqueId().toString()); // User to teleport
out.writeUTF("player"); // Set teleport type to player
out.writeUTF(target.getUniqueId().toString()); // Teleport target
ServerInfo targetServer = target.getServer().getInfo();
targetServer.sendData(Channels.TELEPORT, out.toByteArray());
if (!player.getServer().getInfo().getName().equals(targetServer.getName()))
player.connect(targetServer);
}
this is bungee side
🤡 what
Nothin it weas wrong message
ah
what's your problem with this?
nah im giving him examples
oooh ok
he needed examples for using bungee-spigot
sorry lol
Can we /tpa the 1.8 users out of 1.8?
if (!channel.equalsIgnoreCase(Channels.TELEPORT)) return;
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
UUID fromUUID = UUID.fromString(in.readUTF());
Player from = Bukkit.getPlayer(fromUUID); // Will be null if player not in server yet
That why
I thought you mentioned me you have tcp exampled
With sockets
That why i get emocionated
Allright
future is a task queued
its basically like a async lambda
anything you tag onto the end of a future with .then or whatever you use for futures will also be queued with the result of the original future as params
futures ARE async
ah that why
https://www.spigotmc.org/threads/spigotupdatechecker-powerful-update-checker-with-only-one-line-of-code.500010/ I finally implemented Spiget into my UpdateChecker :3
that's dope
I'll add support for github release too now I guess
I use my own github api since I like to look at github releases instead of spigot releases
oooh
that's exactly what I want to add now
I'd be very happy over a pull request or if you could share your json code to extract the version from a github repo pls
mine takes a bit more to setup since it's not only for plugins
could you maybe DM me your code to get the version from a given github link?
that would be awesome
How can my config file support accented letters? When I save one to config it saves as this
i have no xp and im level 0 (xp) but when i use p.getExpToLevel() it says im level 7? why lmao
It meaning to next level you need how many experiences.
thanks
anytime.
I believe that the editor youre viewing that in isnt translating it properly
Hello how do i make it color ?
logger.info("[Spigot] Initializing...");
logger.info("[Spigot] Enabled");
save it as utf 8
either use ChatColor.translateAlternateColorCodes('&', message-with-color-codes) or use the § symbol before your color codes
so
logger.info(ChatColor.ChatColor.translateAlternateColorCodes('&', "&7[Spigot] &3Initializing...");
logger.info(ChatColor.ChatColor.translateAlternateColorCodes('&', "&7[Spigot] &3Enabled"");
for example
boolean hasSilkTouch;
try {
hasSilkTouch = tool.getItemMeta().hasEnchant(Enchantment.SILK_TOUCH);
} finally {
hasSilkTouch = false;
}```
why is hasEnchant nullable? this try statement still throws null pointer exceptions because hasSilkTouch is primitive
it returns a primitive value that is nullable
Boolean then?
but like why would you need the false in the finally statement
then it would always be false anyway
isnt it getItemMeta that is nullable
getItemMeta() can return null
it returns true if it has the enchantment and every other test I've done, it returns null
maybe it's itemmeta yeah
you didn't check if itemmeta is null before trying to check hasEnchant on it
how could one go about adding a custom potion effect, even if it requires NMS
or even just 'spoof' a potion effect through packet hackery
Even if you did manage to do it, you'd need a resource pack for the client to render it properly (and you might even have to replace a current one for it to do that, not sure)
I explored this like a year ago, I didn't have much luck
and my reason for wanting it wasn't that great in hindsight
nah, ya know how the game render the potions? default rsp has a texture that is gray-white-black for potions, and in the game, they will have the color nbt in each potions. doing so will help moj reduce the work for each texture for the potions. so like if you have a custom potion effect, you only need to add the color nbt in to make colors
they use the tint or something
I mean this
i see thank you
Hello?
Most people here don't use 1.8.8 so you'll have to wait
There isn't a SPRUCE_WOOD enum, it's just LOG with a magic value. @zinc spire
Dunno what that magic value is, sure you can find it somewhere.
I bet if you port it to 1.18 you'll find it 
true 
Hello so like I wanna make this heal soup thing in kitpvp. I got the healing and stuff down but what I dont know how to do is to clear the specific slot which contains the soup that was used
rip
check item in hand will do
But how do I clear that slot?
decrement item's amount
if getting item at hand returns a copy you can set the resultant item back to hand
Okk
hello. I'm currently trying to make a scoreboard using ScoreboardObjective, ScoreboardScore, and ScoreboardDisplay. I've attempted to follow the tutorial to a T and even used the exact code. I've received this error when using the exact code and using my own code:
DO NOT USE NMS FOR SCOREBOARDS
there is a perfectly good scoreboard API that does every single thing NMS does
and there has been since scoreboards were added to the game
spigot api
I'd rather not have to deal with teams
https://www.spigotmc.org/wiki/scoreboard-not-api/
does your message elude that this tutorial no longer works or...?
I can see at the top of the tutorial this was made before the api was ready
It'd just be easier to use the packets in my case
in which case do you need packets O.o for scoreboard teams
hi guys, i have a problem in my code that i made a heal and feed command but the doctor one works but not the feed one i copied pasted the doctor one and edited it to feed the player please have a look at the files
is there a way to check if a WorldCreator will create a new world or load an existing one?
is registering too many events bad for performance
so like
multiple blockbreakevents
etc
Depends on how heavy checks and operations they have.
Light checks first and heavy ones after
So you can exit the event early
What about it isnt working?
its just not feeding the player?
/doctor works but /feed doesn't
by feeding i mean
increasing it saturation to max
Why do you upload it as .txt
What's the problem?
saturation isnt their food level. try Player#setFoodLevel();
ok
I believe saturation is their health regeneration rate based on food
okay
and should i set the number to 20.0 or just 20
java should autocast 20 to 20.0
so ur code isnt registering ur command
if ur chat doesnt autocomplete ur command when u type it then it means its not being registered properly
No I meant like having multiple methods for events
all of them very light
but will having multiple methods part cause performance issues
I don't know what's wrong in this i retyped it but, still doesn't work
Not really but technically it adds another call. The difference shouldnt be noticeable unless youre doing some crazy shit
Yeah from looking at ur code im not sure whats wrong
maybe try loading the feed command first and seeing if that allows you to use it
Well, that shouldn't happen but, i'll try
Remove .equalsignorecase in ur command thing
yeah it shouldnt but you never know
And learn to creat commands, this is the second time mate with the same thing
yeah XD
okay wait
@surreal valve your command doesnt work because the equals is different from the command you registered
yeah i guess i am a starter after all
Yeah you can replace ur label#.equalsIgnoreCase checks with cmd.getname#equalsIgnoreCase
using aliases will still reference the same command
hmm okay
Where is his equals different?
Here
thats for his args not his command
Still wont work because he is probaby doing /feedmeplease
his command creates a clickable dialogue thing that makes him run the feedmeplease arg
i am doing /feed
ye
clearly doesnt work
Okay so explain why does /doctor works
I cant see why ur plugin isnt registering the command
even i copy pasted the doctor thing and edited it to feed the player
especially cause its basically a copy paste of the doctor command
hm
What does "relative" mean in player.setPlayerTime(long time, boolean relative); ?
doctor and feed doesn'thave much differnce
so i copy pasted
what's the error tho?
I honestly dont know, either im blind asf or idk
?paste the full class
Command class to feed
Any error in the console? @surreal valve
Nope
check when the plugin is loaded/enabled
How can I check the title of an inventory
Something like getView()#getTitle();
There is no gettitle func in an inventory
nor a getview
there is a getviewers func
tho
send ur code
I forget the object type you need
No but there is a getView in the inventory events
Im pretty sure its some issue in ur plugin.yml file
I honestly dont know
same
maybe try changing the name?
when you reload the plugin are you reload the server or just the plugin?
wait nvm ur "Launch" plugin also is reloaded
im assuming ur op'd
yeah i am not the nub
Yeah I know I’m just trying to brainstorm
Maybe ONLY register the feed command
And see if that works
ok
If anyone can help me i appreciate ^^
nope idk
why it doesn't work
i will check too
why are people so against using object#requirenonull
Very strange
May I ask when was Steerable interface added
It just throws an exception sooner
yeah so its good to use
Useful for things that should never be null I guess
But if you have something that may be null, don’t use it
yeah
thanks
there are branches for each version iirc
Bukkit
found it thanks
@chrome beacon So basically he is remapping to much ahaha, so i have some method that is from my nms interfaces but he is remapping that too, any idea on a way i can make so its not necessary to rename for another thing?
Inventory inv = Bukkit.createInventory(null, 9, "Stone Chest");
this creates a 3row inventory
create an inventory with only a row
just leave 9
im not sure about that
yeah it doesnt work
Oh?
What doesn't work
Are you by any change forgetting to make a player open that inventory?
it creates an inv with 3 rows
And?
i need it with only a row
pretty sure not since the inventory title is right
yh
make sure on that lol
^
Or just, you know
my ide already troll me several times with that
Try changing the title
And recompiling
is more easy
okay so
weird thing
when the event is cancelled
nothing happens
when the event is not cancelled
the inventory opens since im right clicking to a chest
but the title of that chest is stone chest
and yes it is compiled
hi, does anyone know what event should I use to "grab a spawner"? I need to set every spawner to spawner.setRequiredPlayerRange(20); I was thinking to do this when they are loaded but i dont know what event should I use?
Heyy uh I'm trying to like get a players empty slots and fill them up with items anyone care to help..?
just get the players inventory#add
Yea but like the whole inv
or well
just loop thru the contents
i have to add
the size of the varchar
how do i make it unlimited
or like 100k
its actually an int not a varchar
do i just do INT(100000)
how much text are you storing? mysql has 'TEXT' and 'LONGTEXT' which store off-table
a number up to a million
wait, its the amount of characters not the actual number
fuck im an idiot
it should be the amount of characters in it
right
so INT(6)
will be
999999
max
right
yep
int is weird in that the number shows how many characters will be read in the command line client
if its an int column itll always be 4 bytes
varchar is the amount of characters
no, int only affects the display
so is 7 ok
you can just use int without a constraint there though
anyone?
when they are loaded? ChunkLoadEvent probably, but maybe there's a better way
Why tf would you store a number as text
And yes that event is correct
There’s a method for getting only tiles so it’ll be fast
tiles?
Why would you want to truncate integer tho
Modify the remapper or change your interface names
idk
i saw that in a tutorial
how do i make no maximum for the int
Already changed the interface names, put a _ after the name ;_;
i mean it will have a max which is integer limit
Int has a maximum of 2 billion
you wouldn't store a number as text, you would store text of up to a million characters as text
So you really need more
nah 2bil is enough
but what aobut "motify the remapper" wdym?
Its not 8 characters
u are talking about sql?
just 'int' is enough
INT()?
but i think its for mysql only
yes it is mysql
so if you want to do cross sql idk if is good
() only changes formatting, it doesn’t change what can bestored
wow didnt know that!
alright
Longs have a max value of like 10^18, so they’ll certainly be long enough but I seriously doubt you need such a big value
nah int is good
Hi! How can I create placeholders that e.g. i write a killstats plugin and get the kills of a player, from my plugin, in the config of the TAB plugin on the scoreboard. (e.g. %kills%)?
item manager code
package com.jerry.com.jerry.Com.items;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class itemManager {
public static ItemStack wand;
public static void init() {
}
private static void createWand() {
ItemStack item = new ItemStack(Material.BLAZE_ROD);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("&4Ember Rob");
List<String> lore = new ArrayList<>();
lore.add("&4Coming Soon!");
lore.add("&4Test!");
meta.setLore(lore);
//Shaped Recipe
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("wand"), item);
sr.shape("B ",
" S ",
" S");
sr.setIngredient('B', Material.EMERALD);
sr.setIngredient('S', Material.DIAMOND);
Bukkit.getServer().addRecipe(sr);
}
}
from where did you deduce that the error came from your item manager?
give the error message a read
it is caused by an exception due to an illegal argument
for which the stacktrace provides the exact place where the exception is thrown
Psst you never set the wand variable
how do I do that?
really sorry for the ping
learning java
😬
so how do I do it tho?
he just told you
add an assignment statement
but i can't tell whether that's truly what you intended
for the most part you did correctly create the recipe
@EventHandler
public void openEnderChest(InventoryOpenEvent e){
if (e.getInventory().getType() == InventoryType.ENDER_CHEST){
e.setCancelled(true);
new EnderChestMenu(plugin, new MenuData((Player) e.getPlayer())).open();
}
}
Hi, I'm trying to cancel opening an enderchest and instead open my own GUI but my enderschest stays "open" after I close my GUI, how can I fix this?
anyone knows what function to use to set a mob spawner RequiredPlayerRange?
i need to increase the minimum distance required from the player to work
How can I assign an event to inventory click
but like the type where you just drag while clicking to equally put items
or like
right click to put one
it doesnt send a inventoryclickevent
drag items in inventory is InventoryDragItemEvent
getBlockState to MobSpaner or smth and setRequieredPlayerRange ?
technically, you should open the next inventory in the next tick. but that would mean the enderchest would close when you open your gui
