#help-development
1 messages · Page 1822 of 1
What version should I use here? I used buildtools to install the 1.18
1.18 is not 1.18.1
how can I check if a block is broken or not?
are you trying to do something whenever a block is broken by a player?
yeah, I want to check if a player actually breaks a block so that they can have a change to get a reward
listen to the BlockBreakEvent
I tried to do that and check if (the blocks location is air but it always returns as the same block
the blockBreakEvent is called whenever a player breaks a block. there are methods to see which block was broken
if you want to check which block was broken you can just check wether the event.getBlock() is of a certain material
I think its another plugin conflicting with my plugin
if what I wrote above doesnt work it just may be the case
also when I tried to check if its a certain material it would always return the same block that was there to begin with, not the broken block
explain
so like if I try to check the location of the broken block and check if that location is air it would always return the original unbroken block, not air
maybe the Block doesnt actually break until the event is over?
ah maybe
could you show the code? I could help you find any errors that may be causing that
Hi! I am new to plugin developement, or minecraft developement in general. Does anyone know how to build a project from pom.xml on Mac OS in intellij?
its basically this:
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
// Check if block is actually broken
if (!isBlockBroken(e)) { return; }
}
public boolean isBlockBroken(BlockBreakEvent e) {
Location blockLoc = e.getBlock().getLocation();
Block brokenBlockLoc = e.getBlock().getWorld().getBlockAt(blockLoc);
return (brokenBlockLoc.getType() == Material.AIR && !e.isCancelled());
}
wow im dumb, thats old code one sec
well it doesnt look wrong.... maybe try to debug by sending messages to see where you end up, change the code up a bit to see where it goes wrong. the event could be getting cancelled by another plugin and be replaced by air
I edited it to what is currently is
it does
the event is invoked BEFORE the block is broken
the block will be broken AFTER the event ran
so this
yup
could delay by a tick and then check?
most likely
oh dam okay ill try to do that
how do i check if a player is the victim in EntityDamageByEntity event?
check if the entity is a player
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity victim = event.getEntity();
if (damager instanceof Player && victim instanceof Player) {
}
}
}```
is that correct?
if you want to continue if the damager AND the victim are players, yes.
yes
ok ty
how do i check ifa command argument is a double?
i searched on google and the only thing i saw was command arguments as a string
Double.parseDouble
or something
and catch the number format exception
if it throws then the string is not parseable and therefore 100% not a double
Hey hey, wanted to ask if anyone has some good resources on making per-player-yml files for mass data storage and like a whole data manager class, which does all the lifting for the other features of the plugin. Have been trying out to get this to work for ages, but I couldn't get it to work. If anyone has any tips or resources, I'd love to hear them. Thank you
Hello. im trying to make a hologram plugin with packets.
but the hologram despawns when i get far
so i made something to prevent it from despawning, if player distance with the hologram is 50, despawn it and if it was close, spawn the hologram but the hologram kinda wont despawn and a new hologram will spawn on top of it, making it bolder
Code : https://paste.md-5.net/meviyopihu.java
what have you tried
Why not just use HolographicDisplays?
I do but it’s quite over engineered and multithreaded, if you’re interested still I could send you the code once I get home
making my own data manager class which has functions for creation, saving, editing of player specific yaml files. I'm stuck at the part where it creates, loads and deletes yaml files that are specific to UUIDs
if its a ton of data would you not be better off using json?
Json is a subset of yaml
but its faster no?
So valid json is valid yaml
is json easier, is the question
not really easier no
I can send you what i have so far, give me a second
?paste (:
alright
You can serialize objects easier i think
Still no
True yaml is just set and get
.
Only reason to use json over yaml is that it’s more strict in terms of syntax
@ivory sleet can you help me with this ?
I’m in phone so helping you with packet related stuff will be hard w/o the protocol specs reference
@ionic hatch are you able to get in a call?, then i might be able to explain it to you
uh, what exactly would you explain to me?
i cant share my screen on this server :D
ah, well then private call me
wdym protocol specs
im using nms
1.8.8
why
You’d need a method
static char randomElement(char[] arr);
Can you show implementation of this Variable?
chars are not objects
^
Someday this will not be an issue 🙏
you can always use Character instead of char
doubt
they can't do that unfortunately
vahalla will be glorious
Jep 218 right
Yea, one of the biggest parts of valhalla
urgh these projects just look so good
where is project loom when I need it
like, you cant use Character[] as char[]
he can replace that NUMERIC CHAR to be of Character[] type
that would fix his issue
Last updated 2017 😭
What's loom
like golang gorutines
if that makes sense
not a full thread, more like a lightweight one
they called it fiber I believe
e.g. scheduled on the JVM not the OS kernel
Is it fine to use Bukkit scheduler to remove expired cache entites? Have to do a custom implementation, cant use caffeine =(
Doesn’t guava have something decent
But yeah probably fine, altho might wanna go with a single threaded scheduler executor service + maybe a work stealing pool or just a cached one.
Hello. im trying to make a hologram plugin with packets (NMS not Pooplib).
but the hologram despawns when i get far
so i made something to prevent it from despawning, if player distance with the hologram is 50, despawn it and if it was close, spawn the hologram but the hologram kinda wont despawn and a new hologram will spawn on top of it, making it bolder
Code : https://paste.md-5.net/meviyopihu.java
Like, i can use caffeine, but idk how to efficiently utilize it in my case. I Cache clans by l 2 keys, user's uuid and tag, soo i have 2 caches <String, Clan> and <UUID, Clan>. When clan is loaded, it should be in both caches, to avoid unecessary loading. At this point, AsyncLoadingCache is really limited
Can i ask non spigot api questions in here? (about general java)
"how to aces varable from one class in another"
What is the best way to implement weighted selection?
elaborate
weighted selection as in probability of x being chosen with a given weight 20%
something like that
ah
something like {x : 20F, y : 30F, z : 40F}, where x y and z have a propability of being chosen by 20%, 30%, 40% respectively
use math
NavigableMap is good
new Random().nextDouble() will return a double starting from 0.0 and ending 1.0
if(v < 0.2) // 20%
else if(v < 0.3) // %30
It’s what I use for my WeightedRandom class
manya thats a 50 50 ish
with random you don’t have a 20% chance to get it
its a random number
but then I again
its out of 100%
just use a algorithm
thanks for this, is this the best way to do weighted selection?
Does someone have a plugin where you can control ore spawning?
Does this method send a request to mojangs api?
Im only using it on players who have player on the server before
Can someone please tell me why my modules are not loading in bungeecord? (commands like /send or /server isnt working)
yes
Im not getting the UUID
Im getting the OfflinePlayer so i can skin a player head to match a player
if the player is online it is fine
my god codacy is so strict
ah okay!
"You have one unused import, therefore your code is shit and not up to standard"
is it ok to set the main thread timeout to ~20 (default is 60)?
cuz when the server hasnt ticked for that long it's probably already too late
Doesn't Player extends LivingEntity ? cause in 1.18 it doens't seem to be the case
Need to cast Player to LivingEntity
Ok, just looked at the 1.18 doc and it does extends LivingEntity, but it doesn't seem to get the "setInvisible" method from a Player object
Very weird :/
No
Only the deprecated one which takes a String might make a request
but never the uuid
If the player has never joined
Then the name will be null
i need help ..
cannot access com.sk89q.worldguard.LocalPlayer
trying to update to 1.17.1
and i got this error while using worldguard
i already asked for help in discord server for worldguard but help is kinda slow there xd
Is it possible in the API to use the motion nbt for fireworks?
@ivory sleet Do you know how if there are some api that have been removed from the actual spigot jar (the one with nms), like io.netty or event the authlib from mojang
conclure
Yeah, the apache one is state in the actual thread md_5 did
do you know if setting the spigot watchdog main thread timeout to like 20 secs as opposed to 60s can cause issues?
But I can't find netty and the authlib so I can't get the GameProfile to get skins 😢
lvj no clue actually
But what’s the purpose of the spigot watchdog thread? If it has some coupled logic to a certain behavior then it might be unsafe
it has a loop that constantly checks if its being ticked
and if it hasnt been ticked for the timeout length
aka main thread is locked up
it kills the server
and tries to restart
on one hand if the server is lagging out really bad you might not want to restart after 20 secs
but if it actually hasnt ticked for that long its almost dead anyway
so
hmm I see
anyone help me ?
in that case 60s should be fine
cannot access com.sk89q.worldguard.LocalPlayer
given that there's no implementation which is coupled to the former 20s
java.lang.ClassCastException: class me.tvhee.packetlistener.PacketListenerAPI cannot be cast to class me.tvhee.packetlistener.PacketListenerAPI (me.tvhee.packetlistener.PacketListenerAPI is in unnamed module of loader 'PacketListenerAPI-1.0.0.jar' @17a38e5a; me.tvhee.packetlistener.PacketListenerAPI is in unnamed module of loader 'AdvancedReplacer-1.0.0.jar' @82e38a9)
??????
PacketListenerAPI packetListenerAPI = (PacketListenerAPI) Bukkit.getPluginManager().getPlugin("PacketListenerAPI");
packetListenerAPI.addPacketHandler(new AdvancedReplacerPacketListener(this));
System.out.println(packetListenerAPI.getHandlers());
Oh didn't set <scope>provided</scope>
how would I make mysql prevent insert if value and id are same as those in database
if some one could help with example statment
other way round
60 is default
20 is what i'd set it to
oke ty!
:p
https://paste.md-5.net/fovuvezibe.bash
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
{
SimpleCancellable cancellable = new SimpleCancellable();
Object packet = msg;
if(classPacket.isAssignableFrom(msg.getClass()))
{
SentPacket sentPacket;
if(this.owner instanceof Player)
sentPacket = new SentPacket(packet, cancellable, (Player) this.owner);
else
sentPacket = new SentPacket(packet, cancellable, (ChannelWrapper<?>) this.owner);
for(PacketHandler packetHandler : PacketListenerAPI.getHandlers())
packetHandler.onSend(sentPacket);
packet = sentPacket.getPacket();
}
if(cancellable.isCancelled() || packet == null)
return;
super.write(ctx, packet, promise); //262
}
What is wrong with this code?
@ivory sleet I can ping you?
is there aything I can use like PDC but like more temp
is there any way to convert normalized slot to raw slot of Inventory easily?
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import net.minecraft.server.v1_8_R3.EntityArmorStand;
import net.minecraft.server.v1_8_R3.World;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.event.entity.CreatureSpawnEvent;
public class Ball extends EntityArmorStand{
public Ball(World world){
super(world);
this.a(new AxisAlignedBB(0.0D,1.475D,0.0D,0.5D,1.975D,0.5D));
this.setSize(0.5f,0.5f);
this.setGravity(true);
}
public static Ball spawn(Location loc){
World w=((CraftWorld)loc.getWorld()).getHandle();
final Ball b=new Ball(w);
b.setLocation(loc.getX(),loc.getY(),loc.getZ(),loc.getYaw(),loc.getPitch());
((CraftLivingEntity)b.getBukkitEntity()).setRemoveWhenFarAway(false);
w.addEntity(b,CreatureSpawnEvent.SpawnReason.CUSTOM);
return b;
}
}
I made this in hope to create a custom entity that displays as an armor stand but has its server side hit box a 0.5^3 cube at its head. the hit box did become a small cube as arrows go thru it, and i did this.a(new AxisAlignedBB(0.0D,1.475D,0.0D,0.5D,1.975D,0.5D)); trying to raise the height of the hitbox but the hitbox is still at the armorstand's leg, what should i do?
nah i removed those bc of discord msg length limit
Hi, does someone knows where to find the "com.mojang" libs?
I think they are in .Minecraft/assests
do you want to know how to import them or where to find the docs?
Where to find the actual classes ^^'
?
you imported both spigot-api and spigot?
yes
did you already reload your ide?
now in "com.mojang" there is only brigadier and math
I been trying to make my code teleport to a set of cordninaest if its under y70. But i cant make it
can you tell us more about that? I am unsure what you mean
its a parkour and if you fall you should be teleported to your last chekpoint but i dont want the player to die
under y70 you should be teleported back to the checkpoint
either a sceduler or a player move event
then check height and if below 70 teleport back
thank you
I'd recommend a sceduler checkign every 100ms
it should be less computing intensive and can be async iirc
how can i get window ID of bukkit inventory view
Casting InventoryView to CraftInventoryView throws ClassCastException, and it makes sense
how can i get OBC version of CraftInventoryView then
Hey I wanted to ask how I can check if a player slept - and due to passing night gets up from bed. I know I have to use the PlayerBedLeaveEvent - pls correct me if there is a better option for that.
So do I check if world.getTime() is like 6000 or something? - if yes does anyone know the exact time when someone wakes up?
downcasting should work but is bad.
otherwise you can go over the CraftPlayer and get the activeContainer and those windowID
the thing is
the object that im trying to downcast
is derived from anonymous method
inside CraftContainer class
that's why downcasting doesnt work
its because it includes custom implementation of inventory view
Metadata
does this give me the chunk origin?
((int) location.getX()>>4)<<4
I'm trying to re-name items, but using the method
player.getInventory().getItemInMainHand().getItemMeta().setDisplayName("Test");
doesn't work. Anyone got an idea why?
to animate an armorstand's arm to go up and down, I guess i need to make some sort of complicated equation right?
you have to set meta back
what do you mean by that?
setItemMeta
ohh, thanks!
material has a #getHardness() method
You need to clone the item, make your changes, then update the player’s inventory.
And for 1.8?
not specifically
you can make keyframes, which could be precalculated
idk anything about 1.8
its faster and more performant approach since its a static animation
but long story short yes, you need some basic math knownledge
Alright. Thx for the help tho!
ok thx
how do i teleport a player to a location
player.teleport(location)
I know, but I'm recreating smth and 1.8 is needed
double final_damageamount = damageamount * 2;
Player all_Players = (Player) Bukkit.getServer().getOnlinePlayers();
all_Players.damage(final_damageamount);```
i want to deal damage to all online players and the damage should be doubled. this isn't working, can someone help me?
PDC is 1.14+?
If so, for backwards compat i should use NBT?
i tried it but https://i.imgur.com/Be5Dluv.png (send message to the player when he gets damage and the damage amount)
do you know java
Player all_Players = (Player) Bukkit.getServer().getOnlinePlayers();
all_Players.damage(final_damageamount);
you're casting a list to a player
oh, thanks
Drop backwards compat
If people want to use a version that's 7 years out of date, fuck em, it's not your problem
👍
how can i remove scoreboard from player?
how would i make updating a filled map every 500 milliseconds not cpu intense...
How do i make the computer know im under y70?
try updating it async (idk if it works) or packets
/help team modify basic color gives you /team modify basic color <value>, and when you write it as a command, you get a list of colours as suggesstions
Is it possible to emulate this with a custom command?
It looks like the suggestions mechanism is client-side, and sadly all of the builtin argument switches are hardcoded
did anyone translate this into 1.18 nms yet?
I've tried but so far did not succeed
https://www.spigotmc.org/threads/methods-for-changing-massive-amount-of-blocks-up-to-14m-blocks-s.395868/
i need to replace a lot of blocks but both bukkit and worldedit takes roughly the same time
which is 300-400 ms and far too long for what i need
Can somebody please help me add custom structures to 1.18?
Through datapack, plugin or any other way
see how this does it if you want to do a plugin with that, else just use it
is it possible to make the speed potion effect not add any speed? just so the player has it but it doesn't make him any faster
why
I will add the speed boost back but in a custom way. So that's why I want to know
For the zoom in ?
Nvm
anyone worked with mineskin client?
im dying rn
how to import it in gradle? (what's the repo?)
see the docs
public static void setBlockInNativeChunk(World world, int x, int y, int z, Material material) {
net.minecraft.world.level.World nmsWorld = ((CraftWorld) world).getHandle();
BlockPosition bp = new BlockPosition(x, y, z);
net.minecraft.world.level.chunk.Chunk nmsChunk = nmsWorld.l(bp);
IBlockData ibd = (CraftMagicNumbers.getBlock(material)).n();
nmsChunk.a(bp,ibd,false);}
500ns/block
thats an improvement over bukkit methods doing like 1ms / block
drawback is that it requires relog
yes but thats because bukkits method is safe to use
who cares about safety?
bukkits 'safe to use' methods are so slow that even replacing 6k blocks per second crashes the server
so no
im not gonna use those
yo im having a hard time understanding what an api is and why its used
you can distribute the workload rather than placing all those blocks in a single tick
which one
and what its needed for
fork/join framework? uwu



🐱
🐶
hmm I mean, application programming interface, an interface is something which only provides what you can do, it doesnt tell you how its done, application programming means its an interface for programmers and implemented by an application or smtng
have you considered that the server will still crash with your method, just with higher limits?
ye and I dont understand nothing that you said lol
sorry im dumb

man didnt do good in school
yeah thats quite normal
I think I know what causes this, I've had it before uhh
How do I set the yaw of a spawned parrot in API? [1.12]
hm
@lavish hemlock even if it does
IDC it'll work well enough
basically you/mr.compiler doesnt know what subtype of List<? extends Asset> to require
api is most of the time just interfaces
.setRotation(float, float)
Maybe mr compiler should figure it out 
wut
dude i told u im dumb
You aren't dumb you just haven't tried to learn
without bukkit api you cant send messages on a bukkit server
not something I can use in 1.12
colin u dont know my situation man
and an interface is something which tells you what you can do with it, not how its done, for instance a keyboard. you dont know how the keyboard and the computer talks to each other, but you do know what pressing the button 'Enter' will do
"everyone works different"

ok dude if I dont do good in ela or spanish how am i gonna do good in coding
I struggle with comprehending
those are not connected
spanisch..
I'm absolutely shit at Spanish but I'm decent at coding
i'm lucky i dont have spanish
I'm bad at math, I'm the best programmer in this room :)
yes. that happens in my 1mb ram server
can't you use teleport? just use its own X, Y and Z and edit yaw and pitch
ik how things work its just I dont have the time im distractable human being and most are
trying to know why
but its gonna be a struggle to even learn the basics
hat
I want a hat!
my teacher says i'm the best of the class on maths but in fact i'm soo bad
you don't get a hat
well then your classmates are clearly worse
true 😄
How can you be good at programming when you’re bad at maths
well im a typical programmer
I only copy and paste with some minor edits
well see im good in math and everything else just not comprehending
also programming doesnt necessarily reequires maths
easy you only have to do the math one time
because not all programming requires maths
Not everything is math in programming
simple: dont do maths
Yea right
programing requires copy and pasting and reading
But you need some math for programming
also java has a Math library
And logic as well
i cant do particles because i'm bad at math
mostly logic
Calc is fairly easy though so it's really not that bad
Calc is useless
I've been programming for 2 years and most of my libraries have little math but are still impressive
for what
what's calc?
@tardy delta i just kidnapped a math god for particles
oeh kinky
calculus
oh
lambda calculus 😌
i was thinking of a calculator
yes. we can use npm install is-odd and npm install is-even
npm install node.js gg!
the only correct way to check if something is even or odd is this:
(((int) a)>>1)<<1 == ((int) a)
functions are stolen from math smh
value % 2 == 0
yuh, programming bad
a lot of programming things are
You can't assign to rvalue
I wish compilers optimized most operators down to bitwise ops
bitwise is basically rapid division or multiplication by/through 2, and since it's cast to int the 0.5, if odd, is dropped. That way odd number -> shift 1 right -> int -> shift 1 left becomes even
would speed up a lot of non-JIT'd code
oh that was a joke
"That was a joke, lads."
bruh
01100010 01101111 01101111

boolean isOdd(int number) {
boolean even = false;
switch (number) {
case 0:
even = true;
break;
case 1:
even = false;
break;
case 2:
even = true;
break;
case 3:
even = false;
break;
case 4:
even = true;
break;
case 5:
even = false;
break;
case 6:
even = true;
break;
case 7:
even = false;
break;
}
return !even;
}```
btw it just accepts numbers between 0 and 7
lets go to 10000
rewrite it with if-else, it would be far more readable
You learned coding from YandereDev
oh no
can 69 be random?
is 2 even or odd? It's only divisible by 1 and itself
:kek:
even
a do while which decrements the number by 1 and checks if the final result is 0 or 1
🤡
do two threads both subtracting 1 until it's either 1 or 0
then if its 1 its odd and if its 0 is even
just check if its odd and if so add 1 so its not odd anymore
no, it may be not thread safe
thats the whole point
boolean isOdd(int number) {
if (number == 0) return false;
return !isOdd(number - 1);
}
we dont care about safety
since when are computers 100% accurate
yes that
with twothreads its twice as fast
it can be thread safe if atomic ints are used
yes
you may save a file with odd numbers and other file with even numbers
store them in a server
download them, and check if your number is in one of the lists
then use one of the codes above just to ensure that the number is odd or even
can anyone plz help, i can't figure out how am i supposed to depend on this: https://github.com/InventivetalentDev/MineskinClient
Plzzzzzzz
see pom.xml
I checked, but idk
you may compile the project yourself
git clone https://github.com/InventivetalentDev/MineskinClient.git
mvn install
does anyone know the maven dependency for nms 1.18.1?
the same of 1.18
Should I use it compileOnly or implementation?
implementation
compileOnly
and what might that be? what i have currently doesn't work, despite it working for previous versions
did you ran buildtools?
?buildtools
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
why would i need to do that
i thought it was in the maven central repository
i never had to run buildtools to access nms for any other version
then maybe you used a repository that had nms
and it got cached
to your maven local
if you ignore the maven local you will see that the dependency you used will be invalid
so i just run buildtools the same way i would if i just wanted a spigot jar, and it will also install nms to my maven local?
yes
Does not send updated blocks to player (requires a relog)
Does not work if specified coordinate is in a not loaded chunk```
But even after a reload it's still not changed?
elaborate the question
reload or relog?
relog
and im referring to the quick block set method i posted earlier
thing is
i get the chat message that it worked?
?paste
im running nms_1_set(world, chunk.getX(), chunk.getZ())
that number gets shown in chat
but even after relogging it is still not there
tried and failed since i dont know how to conpartimentalize loads
99% of the problems got solved
also on a unrelated note i just trolled myself
i did the same thing mojang did and decided to replace bedrock with deepslate
and i forgot
and now thought that i had to manually replace bedrock lol
How can I prevent a crossbow from shooting?
cancel the event
The PlayerInteractEvent?
PlayerInteractEvent -> if player.getInventory().getItemInMainHand().getType().equals(Material.CROSSBOW) -> if event.getAction().equals(Action.LEFT_CLICK_AIR) event.setCanceled(true)
Heyo, quick question: does AsyncPlayerPreLoginEvent#disallow fire a PlayerQuitEvent?
test and see if it works like that
probably not since technically the player hasn't joined in pre-login event? but ^^ https://tryitands.ee
it wouldnt
I'm trying to make a player with the OP permission exempt but I cant find the actual permission name does anyone know what it is?
np
Hey, does anyone know since which version player.sendTitle works?
I thought it came out in 1.8 but by it doesn't seem to be there in the spigot docs
it is
but the method is different
if you want to work in more versions, use packets (pretty easy to use)
for checking the client version?
public static void sendActionBar(Player player, WrappedChatComponent text){
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
PacketContainer chatPacket = protocolManager.createPacket(PacketType.Play.Server.SET_ACTION_BAR_TEXT);
chatPacket.getChatComponents().write(0, text);
try {
protocolManager.sendServerPacket(player, chatPacket);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
what
sendTitle exists in 1.8.8
idk about 1.8.0 but if youre using that youre in idiot
and if youre using packets you're also an idiot
nah I'm on 1.8.8, thanks @sullen marlin it just doesn't have the same parameters, that's why it wasn't working
.equals is redundant
doesnt really matter, it just does == anyway
really not as bad as people make it seem
Hey,
I made ender eyes fly to the nearest end frame if one is near.
It works without any problems, except that the portal doesn't light when all ender eyes flew into their place.
Anyone knows how to update the portal?
Can someone help me with this ?
I don't understand where should I get it... I already tried adding datafixerupper in my dependencies
But it seems that it doesn't find it :/
?xy
Asking about your attempted solution rather than your actual problem
If you have an idea for my little class problem, that would be lovely 😢
?xy
Asking about your attempted solution rather than your actual problem
Anyone know a way of enabling and disabling event listeners on a whim? Trying to write a bunch of minigames but don't wanna a ton of listeners that'll check and return
HandlerList#unregister
Just trying to update a lib from 1.17 to 1.18 that requires that class. And I don't find it anywhere, before it was directly in the spigot jar, now it does not anymore. That's why I'm trying to find the right nms repos to add to my dependencies (not sure it was that kind of explanation you needed)
- read the release notes on spigotmc.org
- I wont help unless you specifically say why
part 1 already done
Going to make something clear for the part 2, it's a bit draft in my head so you wouldn't understand
good evening everyone
Whats a way to send a message to the whole server i've looked at Bukkit.Broadcast but that seems deprecated for the most part,
I'm trying to get it so that it gets the players username and a message after then sends the message to the whole server
it's not deprecated
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Bukkit.html#broadcastMessage(java.lang.String) @proven river
declaration: package: org.bukkit, class: Bukkit
How would I use HandlerList.unregister to disable a class implementing Listener?
store listener in variable, pass to unregister
what do you want to unregister? Your own listener?
https://i.imgur.com/Tl4EP3y.png
and Server.broadcast dosent seem to work in my case
I'm writing Minigame's each with their own Listener class that I wanna be able to enable and disable on start and end respectively
where did you got this from? As you can see in the link I sent, Bukkit.broadcastMessage(String) is not deprecated
Paper
Just don't register listeners you do not need. You can also just check in the first line of your listener class whether you want to have it enabled or not
intelij's intelsense or whatever its called https://i.imgur.com/wyo8JoL.png
But how would I register them when I need then unregister?
Paper uses Components not strings. I recommend going to their discord
well just because paper says something is deprecated, it's not true. Use Spigot and Spigot's docs, or use Paper and check Paper's docs
Check out paper's discord if you have questions about their API
alright
wait that dosent make sense since i am using spigot?
You're using the Paper api
you just said you're using paper
you use paper -> ask on paper discord
ok nvm i'm getting confused with smthn else thanks for the help :D
np^^
why would you EVER need to unregister a listener?
I know there is a warning that most methods of the api are not thread safe, but, is world creation thread safe? I would really like to do it on the background
no
I highly doubt that
if you load it without spawn should be pretty quick?
To avoid having to do a ton of ex " if !player.isInGame() return"
md_5 can I DM you quickly? just a tiny question about a spigotmc rule
Listener test = this.gameListener;
HandlerList handlerList = new HandlerList();
handlerList.unregister(test);
``` Does this look like the correct use to unregister
HandlerList.unregister, its static
:/, are there any workarounds? a void world is taking 9 seconds on my local machine (the file copy takes nothing really, but bukkit world loading does)
It gave me an error saying I couldn't make a static reference to a non static method
maybe you'd like to explain what you're actually trying to accomplish
oh its not static
sure
so guess you gotta do it for each event
XYZEvent.getHandlerList()
no wait
there's unregisterAll which is static
I am creating a map loader utility to spin up worlds for minigame instances. Maybe 9 seconds is not bad? But I'm wondering if it will scale
Listener test = this.gameListener;
HandlerList.unregisterAll(test);
Or even just HandlerList.unregisterAll(this.gameListener);
does someone mind answering what i said in #help-server
Have patience
is your question about development? if not, this is not the right channel
It's not
yeah then please don't ask for it here^^ 😄
i was asking for someone to take a look at #help-server, didnt need them specifically to answer here
Still don't ask here
you will get an answer there. don't spam here pls
im not spamming?
does someone knows the initMenu, from the EntityPlayer, new name ?
this channel is for development
now stop asking for non-dev related questions here please
what do you mean exactly?
yeah have a nice day
thanks
In 1.17 there was a method called "initMenu" that takes a Container as parameter and that actually init a container to the EntityPlayer instance
sorry didn't meant to be rude. Just wanted to say, this is the wrong channel for that
are you using spigot or mojang mappings?
Or no mappings
mojang actually, I can swap to spigot's one, but I already did it all by mojang's ones ^^'
? spigot mappings = "no" mappings
well mojang mappings should be 99% consistent between versions
So, I have "a", "b", etc...
can you show us some code that worked in 1.17 but doesn't in 1.18?
so you're using spigot / "obfuscated" mappings
Isn't the original mojang map ?
The original is obfuscated
"original" is actually what the mojang mappings give you
but mojang obfuscates it before shipping the .jar
Add both the spigot api and the spigot nms dependencies
Version?
1.16.5
No
@opal sluice You should really switch to using the mojang remapped jar instead, it will save you much headache in the future
Well, time to rewrite it all with it then 😖
you won't have to worry about fields being called "a" or "b" or "c" anymore
yeah I know 😦 but once you've done it, you will be happy in the future 😄
Do you know more about it ?
Are you sure you are depending on the 1.16.5 api
sorry I can't help with your exact problem right now, but just in case you decice to switch to mojang mappings: https://blog.jeff-media.com/nms-use-mojang-mappings-for-your-spigot-plugins/
Set invisible does not exist for ItemFrames. Only living entities
Thanks, I already know how to use the mapped version ^^ It's just that it's a bit of a pain when you use externals libraries that don't use it ^^
it is for ItemFrames
oh okay sorry^^
Link it
o found it.
It's setVisible
but anyway: I can only recommend to switch to mojang mappings. it's a pain in the ass the first time, but you'll profit from it in the long run 🙂
I can only recommend to switch to the API
I'll do it ^^
Ah
Sometimes, there are thing we can't do with it 😢
that's not helpful when you need NMS
Then you PR
and a lot of the time you can and people use nms anyway
the amount of people using NMS for scoreboards is ridiculous
I'd love too but that's above my knowledge
indeed, true. but stuff like custom entities, is just not possible with spigot api
Then make a feature request
That's a bit more complicated than scoreboards here ^^', custom entities and some other packet things that need nms 😢
Hey does anyone know how to get a List object of all of the available items in-game?
probably 100 requests exist for it already. custom entities was just an example
I'd love to see a packet API
just Material.values()?
or something
not really the point of spigot tho
with objet you mean Materials?
If so: yes, Material.values
Packets are meant to be abstracted into various API methods
Ahh i was trying .getValues()
so what is the point of spigot in your opinion?
ty
What coll said above
And also tons of great alternatives exist like protocollib
and also who is going to spend the time
you can do it :p
i dont got that time
so you say "improving the API is not a good idea because there's already a plugin for that"? 😛
??
I know it won't happen
if u know its not going to happen, then there isnt really a point asking tbh. and whats wrong with protocollib even?
I was just answering to the person who asked for adding it...
TL;DR: we were talking about mojang/spigot mappings. I said "use mojang mappings, it will help you in the long run". then someone said "just use the API", to which we replied "but not everything is available in the API". to which someone replied "then create a PR". And I answered "won't happen for certain things"
in my opinion: I don't like to depend on third party plugins. I'm selling my plugins and when there's a new update, I don't want to tell people "yeah but it's protocollib's dev's fault that you can't use my plugins now"
also protocollib sucks imho
I'd love to see a packet API
i wonder how much version to version maintenance would be required for a packet api
new WhatEverPacketWrapper().setUUID(0,player.getUniqueId()).setString(0,someOtherstuff);```
and it'd (i assume) require backwards compatibility in most cases
We don't need more apis for packets ;/
I know that code doesnt make sense but you get what I mean
And not even all the packets are gonna work anyways for older versions
cause new features and shit
so you have to handle that too
thats why its not ideal
go to forge if you don't need proper APIs 😛
I have a project where I want to make an API around a version of a different game from 2005 to like 2010 🙂 i dunno a good way to do it for the last 4~ years
Forge is cool. Been working with it for the past 2 weeks
packet structure changes is annoying 😦
It's just something that had to happen
Makes it completely not ideal
It happened way too late
people are just too lazy to update their legacy code
switching to mojang mappings should have happened the minute they became available imho
Licensing was a bit off so people hesitated in the begining
Can you set a vanilla attribute on an armor piece that raises its defense?
GENERIC_ARMOR?
?
so i have a respawn event, and i’m trying to make it so when a player respawns, it gives them some kind of identifier so i can recall them in a block break event, is there any way to give tags or something like that
Those are persistent though
If you don't want/need persistence you should use a map
what’s that mean
It will stick around if the server restarts
Yes
same thing just remove instead of add?
Probably
its the literal same thing
(bracing myself) whew, here goes...
What about 1.8?
:)
You can't do it in 1.8 with the spigot api
How do I display the ban message on the players screen since the banlist reason is only for in files ?
I tried searching around but couldnt find anything useful on it
I believe you can do it in PlayerJoinEvent#setKickMessage or something
Oh wait
You'd just need to call kickPlayer(String) on the player
any difference between
this.getServer().getScheduler().scheduleSyncRepeatingTask((Plugin)this, (Runnable)new Runnable() {
and
getServer().getScheduler().runTaskTimer(this, () -> {
Is it possible to make custom entities/mobs in 1.18.1 with the Spigot API? Or do I need to grab another library
Why are you casting to Plugin, and also casting to Runnable???
The difference here is that
the first option means that the person doing it doesn't know what Java OOP is
why? :o
NMS
I would imagine
Sounds like fun
i always use scheduleSyncRepeatingTask, what wrong with it @paper viper
At least you have mojang mappings
what event triggers when a player leaves the server? I can't find it
PlayerQuitEvent
nothing wrong with the method, thats not what im talking about
look at the arguments...
yeah
he means the methods tho
ignore the wrong arguments
Whats the diff between scheduleSyncRepeatingTask and runTaskTimer
Repeating
Well the other is a timer
so is tasktimer
thanks!
(Plugin plugin, Runnable task, long delay, long period)
period -> repeating
is it not
and there is no different
Whats the diff between scheduleSyncRepeatingTask and runTaskTimer
Both are repeating
then why is there two?
@Override
public int scheduleSyncRepeatingTask(final Plugin plugin, final Runnable runnable, long delay, long period) {
return this.runTaskTimer(plugin, runnable, delay, period).getTaskId();
}
is the impl
One returns an int and one returns a task
I dont usually use the scheduler unless i have to work with ticks
like i even use the scheduledexecutor thing instead but thats what i do at least
Used to be another implementation back in the days iirc
But yeah now those methods are basically useless scheduleBlahTask
as runTaskBlah provides a much better context object
IIRC scheduleAsyncXXX was deprecated because people got confused between Async task and A Sync task
Someone thought people got confused
™️
SoonTM
Idk if people actually got confused
So there is confusion about the confusion
Regardless, the newer methods
runTask etc are much more succinctly named
So yeah much nicer to work with
if u get confused by that you should just stop programming lol. the s is small, u can tell the word starts at the A. thats def not a reason to deprecate a method
good to know, might switch to that in the future then
You'd be surprised how many got confused with the naming
👀 Depending on your font, s and S could look quite similar I'm sure
so i know there’s hidePlayer(), but how do i make it so they aren’t hidden anymore
okay i’ll try both
thread affinity is OS dependent, spigot is a java application. Unless it were to use JNI for native bindings this is not possible in java
will listeners be unregistered automatically after plugin disabled?
yes
ty!
when i have a class extending listener and create a scheduler in its constructor, does it stop when unregistering the listener?
no
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
it is an open project, feel free to contribute
public void onRespawn(PlayerRespawnEvent e) {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
Player player = e.getPlayer();
for (Player p : Bukkit.getOnlinePlayers()) {
player.addScoreboardTag("1");
player.setGameMode(GameMode.SURVIVAL);
player.setAllowFlight(true);
player.hidePlayer(p);
ItemStack item = new ItemStack(Material.COMPASS);
ItemMeta compass = (ItemMeta) item.getItemMeta();
compass.setDisplayName(Color.RED + "Teleportation Menu");
item.setItemMeta(compass);
player.getInventory().addItem(item);
ItemStack item2 = new ItemStack(Material.FEATHER);
ItemMeta feather = (ItemMeta) item.getItemMeta();
compass.setDisplayName(Color.YELLOW + "Change Flight Speed");
item.setItemMeta(feather);
player.getInventory().addItem(item2);
player.updateInventory();
player.setGameMode(GameMode.SURVIVAL);
player.setFlying(true);
}
}, 20L);```
"}, 20L);" is wrong and idk why
it says unexpected token
?learn java
?learnJava
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I personally would go with jetbrains academy 😅
which isn't even on that list
rip
also async chunk loading already exists in a fork of spigot called paper
codecademy is difficult
Can I explicitly check if an EntityDamageByEntityEvent was caused by a player's weapon?
Huh ?
like, if it was caused by an arrow or
why would u want that lol
the .damage method does not call events afaik
@Override
public void run() {
Bukkit.broadcastMessage("This message is shown after one second");
}
}, 20L);``` shorter version of what i sent but yeah the end part with ```}, 20L);``` says unexpected token
😄
?????
It doesn't?!?!
Well, I've got bigger problems now
lmao
nearly no methods call their respective events
if so, it is documented in the method docs
ok
I lied tho
with just good configs
the damage method is one of those that calls its event
chunk pregenerating is so useful
What is this method for?
...
damaging an entity ?
[02:16] LynxPlay: the damage method is one of those that calls its event
Ok, didn't read your message above.
yea
but generally, this is not a general API contract
e.g. setting a block or stuff won't call methods
modifying inventory
etc
okay, starting from scratch, how do i make a respawn event work? my friend said its cause i had to delay the event, but it didn't work, so how do i do this
(i tried my code with the respawn event and it didnt do a thing)
is there a way to get the damage modifier of a specific piece of armor?
Still really new to using maven, trying to use https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/ to start using NMS to develop some custom mobs and still have mappings but no luck so far. Can anyone help me understand where I'm going wrong? https://paste.md-5.net/xamajesayu.xml here's my pom
Error: Cannot resolve org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT
Anyone know what event triggers when a fireball projectile is moving? using EntityMoveEvent and checking if the e.getEntity() instanceof Fireball does not work... I also tried getting the entity type and still no luck
Eh I give up...
Just gonna use the API like a good potato
🙏
how do i get the attacker in this
(event.getEntity().getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK)
Did you run buildtools
I have, yes
Check if getLastDamageCause is an instanceof EntityDamageByEntityEvent and then cast
both with --compile craftbukkit and without
What about --remapped
...
cast what
I shall try it
The return value of getLastDamageCause
cast as entity?
Entity entiy = event.getEntity().getLastDamageCause();?
Check if getLastDamageCause is an instanceof EntityDamageByEntityEvent and then cast
getLastDamageCause
cast to what
EntityDamageByEntityEvent
Event event = (Event) event.getEntity().getLastDamageCause();??
i dont understand what u mean
Check if getLastDamageCause is an instanceof EntityDamageByEntityEvent, if it is cast it to such
and then use EntityDamageByEntityEvent#getDamager
if(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
if(event.getEntity().getLastDamageCause().getDamager() == )
}```
?
idk
how do i cast
Actually that only shows primitives, but it's the same idea
https://www.baeldung.com/java-type-casting Is probably better
if(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
Event xd = (Event) event.getEntity().getLastDamageCause();
if(xd.getDamager() == IronGolem) {
}
}```
?
Almost
But you don't want to cast to just event, you want to cast to EntityDamageByEntityEvent
what
what
What
What?
Shouldn't a new file be created normally?
Should i just make yml file?
i dont see any code in the interface listener how do it works then?
we need to implements it to use the events
but i dont see any codes in it
it just empty lol