#help-development
1 messages · Page 1907 of 1
is it bad to run something asyncRepeating then run some part of syncDelayed with 0 delay to run it on the main thread?
that's NOT the same source code as from the error you sent
oh hastebin my love, what the fuck
hahah
The mysterious }
player probably died from natural causes and youre not checking if they actually died to a player
yeah i tried fall damage
what
you have to recompile your stuff again... then try it again and then send the correct error message
The whole error
yeah and an error that actually belongs to the source code and not some other version
wait ill send again like 48 is somth diffrent haste bin being weird
well
also im sorry INCREASE_DAMAGE... wtf bukkit
it's because you removed all the imports
- Do not exclude anything
I asked what line 48 is and you then just uploaded part of your code lol
You're making it very difficult to help you with a very simple error
https://paste.md-5.net/ligohuqewe.java it decided removing my imports was a good idea
it doesnt remove imports, u do
if(killer == null) return
yeah ill do that
Why I using that whole ass create method?
Can't it be just FireRestistance,1,1
nah that dosnt work for me
Well this one doesn't seem to work either 😂
it does
player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER,duration,amplifier));
this does definitely work
yep
i always use createEffect
._.
works fine but think it has somth to do with Integer.MAX_VALUE
Maybe try a tad lower value
if u want a perm effect i think something like 32767 would do it
its in ticks
yeah
so 32767 * 20
i think Drop2InventoryPlus couldnt check for updates
1.8 ;-;
🏓

i knew this was coming
at least u know
Its a sw plugin what am i supposed to do
u say that like SW as a game-mode is version dependent?
Now go to modern versions of this game
Not ancient ones
Then code it 😂
no thats effort
That's an 5 Min thing
^
if snowball collide with entity take 0.5 dmg ezpz
;-; im not gonna port this code to 1.18
@EventHandler
public void onHit(ProjectileHitEvent event) {
if (!(event.getEntity() instanceof Snowball)) return;
Entity victim = event.getHitEntity();
if (victim == null) return;
double damage = getConfig().getDouble("damage");
boolean sound = getConfig().getBoolean("sound");
boolean animation = getConfig().getBoolean("animation");
if (damage > 0) {
if (victim instanceof Damageable) {
((Damageable) victim).damage(damage, event.getEntity());
}
}
if (sound) {
double pitch = ThreadLocalRandom.current().nextDouble(0.5, 2);
event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, SoundCategory.MASTER, 4, (float) pitch);
}
}
Even configurable 😂
i wont be porting it to newer version but.. double pitch = ThreadLocalRandom.current().nextDouble(0.5, 2); event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, SoundCategory.MASTER, 4, (float) pitch); thanks for the code lmao
i was looking for playsound
Well then ima just get the heck outa here
alr thanks for the help!
what's wrong with that code? never mind I was too stupid to read
You can also remove the playsound if needed 😂
or put the playSound into a sync repeating task that never stops lol
1 tick delay
I had another idea lol
199980 this is the value that i ned to set for the effects to work
haha this sound is awesome
32767 ticks is inf, aka 1,638.35 seconds
Jesus
Why wont videos on discord load
discord bad
isnt 250mb/s enough
Using 1.8 gives ya bad luck
tfw no minecraft effect is truly permanent
how would that even work
My anticheat doesn't support it for a reason
infinite -1 = infinite
idk it said **:** and then it started ticking down from 26:59
scared the shit outta me
mayb theres no permanent effect then 
Sync delayed task 1 tick. There ya go 😂
imma replace that 32767 with some higher value seeing as the effect is not inf
everything above an hour should be displayed as **:**
anything about 26 minutes and 59 seconds is displayed as **:** apparently
interesing
For simplicity sake ima code my plugins in Spigot Version: 1.4.7
why?
why 1.8?
weird
thats 32400 ticks
I'd do Inventory.first(Material), check if it's more than then the amount you want to remove, if yes: lower the amount of the remaining stack.
if no, remove the whole stack and go for the next one, etc
public static boolean removeX(Inventory inventory, Material toRemove, int toRemoveRemaining) {
HashMap<Integer, ? extends ItemStack> matchingStacks = inventory.all(toRemove);
for(ItemStack item : matchingStacks.values()) {
if(item.getAmount() <= toRemoveRemaining) {
toRemoveRemaining -= item.getAmount();
item.setAmount(0);
} else {
item.setAmount(item.getAmount() - toRemoveRemaining);
}
if(toRemoveRemaining == 0) return true;
}
return toRemoveRemaining == 0;
}
I'd do it sth like this
(haven't tested though)
np 🙂
this inly works for materials though
if you need it to match potion types etc you'll have to change it a bit
ezpz Predicate<ItemStack>
public static boolean removeX(final Inventory inventory, final Material toRemove, final int toRemoveRemaining) {
final HashMap<Integer, ? extends ItemStack> matchingStacks = inventory.all(toRemove);
return removeItemStacks(toRemoveRemaining, matchingStacks);
}
public static boolean removeX(final Inventory inventory, final ItemStack toRemove, final int toRemoveRemaining) {
HashMap<Integer, ? extends ItemStack> matchingStacks = getAll(inventory, toRemove);
return removeItemStacks(toRemoveRemaining, matchingStacks);
}
private static boolean removeItemStacks(int toRemoveRemaining, final HashMap<Integer, ? extends ItemStack> matchingStacks) {
for(final ItemStack item : matchingStacks.values()) {
if(item.getAmount() <= toRemoveRemaining) {
toRemoveRemaining -= item.getAmount();
item.setAmount(0);
} else {
item.setAmount(item.getAmount() - toRemoveRemaining);
}
if(toRemoveRemaining == 0) return true;
}
return toRemoveRemaining == 0;
}
public static HashMap<Integer, ? extends ItemStack> getAll(final Inventory inventory, final ItemStack item) {
final HashMap<Integer, ItemStack> map = new HashMap<>();
for(int i = 0; i < inventory.getSize(); i++) {
final ItemStack tmp = inventory.getItem(i);
if(tmp == null || tmp.getAmount() == 0) continue;
if(tmp.isSimilar(item)) map.put(i,tmp);
}
return map;
}
here's one method for removing X itemstacks and one for removing X materials
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
hm
does anyone have a good example for how to use this?
I am talking about the weird layout
after runTaskAsynchrounously, everything is bold and only in the leftmost <td>
^
There is a screenshot
I know
I know
to "fix" your layout
I just did that
Switching between those two buttons
Changes the view to what you have
And back
Oh
seems like someone forgot to close the <b> tag in the javadocs or sth 😄
Yeah
Time for my first pull request lmao
looks fine to me
spoke too soon
I am already glad I can get actually create javadocs at all lol
mvn site never works for me
I always have to do mvn javadoc:javadoc
how to detect when player hit primed tnt
How do I check whether a player right clicked or left clicked an item in the inventory?
InventoryClickEvent
maybe PlayerInteractAtEntityEvent
Ok, But how do I know whether the player right clicked or left clicked the inventory?
InventoryAction?
EntityDamagedByEntityEvent neither not work
It doesn't have a right click or left click event
use #getClick()
Oh, Alright thanks
oh you want to detect when the player gets damaged by tnt?
block destroy event?
primed tnt
idk maybe the only way is to check the players line of sight on interact and see if primed tnt is there
i woulnt know another way
maybe PlayerInteractEvent with a world.rayTraceEntities(player.getLocation(), player.getLocation().getDirection(), 3)
Should be just the block break event and check if the tnt blockdata is unstable
@EventHandler
public void onInteract(PlayerInteractEvent event) {
// check if it was a left click
if (event.getAction() != Action.LEFT_CLICK_AIR) return;
Player player = event.getPlayer();
// get head location
Location head = player.getLocation().add(0, 1, 0);
// will raytrace for entities in the world, from the players location
// in the players look direction with a reach of 3 blocks. also only
// selects primed tnt entities because of the predicate.
RayTraceResult res = player.getWorld().rayTraceEntities(
head, // location (from)
head.getDirection(), // direction (in)
3, // max distance (reach)
(entity) -> { return entity instanceof TNTPrimed; } // predicate
);
Entity entity = res.getHitEntity();
if (entity == null) return; // no primed tnt found
TNTPrimed tnt = (TNTPrimed) entity;
/* Your code */
}
i have no idea if it works
but you can try
Player#isBlocking returns true when shielding right
wait nvm im doing a general check for item use anyway
so just getItemInUse() != null should? suffice
?jd
what were some conditions for MC to stop a players sprint
using an item (bow, food, blocking) and sneaking?
pretty sure thats all of them
hunger hitting 3 or whatever it is as well
blindness I think ?
i think <7 food level and blindness still remove sprint @vocal cloud
so i dont need to care about them
writing some code to restore the old mechanic
Ah I see
bc it pisses me off that they changed something that small
If I wanted to compare an item that’s been created statically (via a config or whatever) and an item in game. How would I compare them if the item in game has been renamed via an anvil? I know it sounds stupid it does, I’ve tried everything and they just aren’t comparing. I’m using ItemStack#isSimilar. What would I put as the display name for the item in the config? Or do I need a different method to set it like an anvil name?
I'm confused are you comparing a vanilla item versus a spigot-created item or 2 spigot-created items where one has been renamed via an anvil?
I'm curious how you would get cause of death
Of a player
I'm on my laggy slow wifi phone ain't no PC access rn
You'd probably have to listen to the damage events to see what caused a players health to go below= 0
to cancel a BlockPlaceEvent should i use setCancelled(true) or setBuild(false)
Setcancel for prevent any change
But players can spam block below themselves near a wall to float up
ik
That's due to MC's client-server relationship and is unavoidable
just setCancelled should suffice for my case then
Interesting
CanBuild from what the docs seem to say is for spawn-like chunks so if a player tries to place a block in spawn? So if you mess with that you could accidentally mess with plugins that check for that
Is it possible to remove building ablity completely without adventure mode
only plugin on server is mine
small smp and i just make some little changes w a core plugin
Nice!
wouldn't {player} be prettier?
Their exactly the same items, just one has been named as ItemMeta#setDisplayName and one has been named as an anvil, everything else is the same. How would I make it so the spigot item is the exact same as an anvil named
hmm
Of %player%
That’s the most popular placeholder variable
Also if this is public, I suggest adding comments to your configuration to
same, wouldn't {player} be prettier?
small smp im running
I mean it’s personal preference and doesn’t really matter imo up to the person
Use the Persistent data container and add a string for your item and use that
Oh
%PLAYER% so we can be like cmd variables
Anvil does something different mb
So there’s not a way to name an item like an anvil
why shell
Nah same name
becos i run the server on linux
smh
jk shell would be $PLAYER
hence why i had $PLAYER*$*
lolz
ya, but do you use this configuration in linux commands?
nop
personal preferences
Doesn't the anvil italicize the name?
If you really only care about the item name try purging any formatting on it first.
only reason i wouldnt use %player% is bc if i needed to String.format before replacing for some reason
I’m not sure
jvm would yell at me
I think u could escape it haven’t tried it
I mean it’s up to you :)
{player} seems nice
think ive seen other things use { } as placeholders
like log4j
yeah because that worked so well for them 
he he
Hi, I have this code to blocking a lot of names in anvil rename
and I have a ArrayList of String named blockedNames in my main class
and this code does not work
public class PrepareAnvilEvent
extends InventoryEvent
Called when an item is put in a slot for repair by an anvil.
hm
I want to check the result's name
for example test is blocked
and i want if player rename a block like Stone to test, my plugin set the result to a unpickable barrier
I believe check for the click event
Check if the inv is an anvil
And get the name
And then cancel if whatever
pulling code from a bug report but https://hub.spigotmc.org/jira/browse/SPIGOT-6686 looks like you need to get the inventory from the event @sage patio
ok thanks, lemme try
Also the event doesn't have @EventHandler on it so that doesn't help either
how do i give the player a permission
oh yea i forgot that
That might help
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/AnvilInventory.html#getRenameText() looks like the exact thing you need lol
declaration: package: org.bukkit.inventory, interface: AnvilInventory
You'd still need a cancel in the anvil event tho I imagine?
i think hes setting the result to a barrier so
that might (effectively?) do the same thing
Sad, plugin does not Know itself
else if (!players_Currently_Flying.contains(player)) {
if (player.isFlying()) {
if (!player.isOp()) {
player.kickPlayer(ChatColor.RED + "You have been kicked for fly hack(s).");
}
}
}```
do cheats bypass checks like this?
haven't got the chance to test yet
yeah
Math
That's gliding i believe as well. The biggest issue is that clients not servers set the isflying variable
i think thats isGliding
wait
Rather it's
I have am array list for flying players
they are only added to the list via admin command
so it wouldn't detect elytra
I mean what you really want to do is download some hacked clients and do your testing with them
Wurst will bypass this lmao
alr, if so I'll look for other ways
Hacked clients developers are better than you think
anticheat isn't something I'm familiar with yet so I'm just messing around to see what works
I'm far aware
Math works
I've watched people make this stuff
wdym?
study player's travelling patterns
If you want a good vert check, check if the player moved the correct amount based each tick
You can make a bullet proof fly check if you do it correctly
Technically if performance isn't something you care about you could check when a player moves if the block under them is air and if they move and their y doesn't shift a lot they're probably hacking
Wurst doesnt get the credit it deserves
ty
its a great client for as bad as it is
is location spoofable
it is, although it's just the range of possibilities with wurst isn't good
Bypass via moving down only slightly each tick lmao
Yeah but it's a start and they only need to mess up once to get banned
Code doesn't mess up when made properly lmfao
^
he meant the "hackers"
This is what testing and formal verification is for
I mean no hacked client is going to make you move in a sin wave so
Factually incorrect
I mean it’s really hard to make sure your code is correct
Love to see it
It’s easy to make sure it’s not incorrect
formal proof
is your code politically correct?
anyone developing with vsc?
With the comments I have in there no
me, actually me
Making a client that moves you in a sin wave? Shit's easy lmao
I doubt that any current client that would join a server would by default do that.
was that to me?
yes
👍
vsc best editor
think so too
if u are, it's time to get intellij
I beg to differ
let's agree to disagree
facts are really just opinions that a lot of people share
there was a programming methodlogy module i took whose instructions are all for intellij (e.g. debug, build), and I survived it with vsc
although easier with intellij
factually incorrect
intellij also catches 99% more errors that vsc doesn't
facts are scientifically provable
just dont make mistakes
I catch all errors
a lot of useful things as well
what is science if not just a bunch of good opinions
it's just more convenient for me since I have it for free
intellij is free for all, why did you quantify your statement?
rather a bunch of theories and facts
Intellij also is a crutch for new learners who use alt enter to add Object.requiresnonnull to their objects then wonder why it's still throwing an error
intellij ultimate* for free
lmao
new learners -> vim
@hardy swan so I'm getting Cannot find a class with the main method in the folder - what may I have missed?
hell yeah
where did this error come from
show plugin.yml
show main class
?paste
A lot of facts
VIM? Bro just use VI
VI? Just flip the bits on your hard-drive with a magnet manually.
Magnet? wait for cosmic radiation to randomly flip all the bits in order
new QuantumComputer()
when/how did you receive this error?
That is a plugin.yml so bare it's illegal to be seen in public
"clean code"
I'm a newbie
Pft you use a hard drive? I actually just take a bucket of transistors and make the logic gates necessary to filter each address then return the value for the filtered address
you using any build tools? maven/gradle
not sure 😊
then how are you compiling/building your project/plugin
javac lmao
anyways that message isn't important, you don't need a main method anywhere
I think I'm using maven
my plugin commands to discord server integration?
pom.xml
maven
show pom
you opened the projects folder in vsc?
Whew almost had another Gradle user
I mean it's called getting nowhere fast and usually involves asking for help
after compileing it and running it on the server
I won't want to say that here
https://youtu.be/X8gDcyP0v70
This works for spigot on maven right?
If it works for spigot it works for maven maven can do literally anything that any other tool can.
Okay, that's useful
Thx
I don't think you need <sourceDirectory> config in your build config
Man Tutorial videos 🤮
this should be why vsc attempted to find main method
so can someone help me debug my code im dumb as and cant find the problem
Well we need to see the code before we can help
You can only learn by suffering
mvn clean
you are welcome
Can anyone help please?
Are you not running mvn package
can i dm i can share a intelij link
What why send a link? Just send a pastebin how bad can your error be
live share session?
there is no errors i fixed it
Then?
ye good idea
I'm confused as to why you'd share working code with me?
it not working as expected / i made it wrong 😢
you see, the vc is under-utilized
no streaming perms in it
oh f
f
Then send it in a pastebin
?paste
the whole code? lol
i think the server is boosted enough to allow streaming
And explain what exactly isn't working
u dont need to boost to allow screenshares
but there is a quality limit for boost levels
metrics probly or my fault idk
idk
Well it can't be that many files that have issues
well the mc server logs says just a warn but after running the commands i realized its not working
Send code in a pastebin then talk about what's going wrong with said code
Alright and so what exactly is the issue you're having.
- What you want to happen
- What's actually happening
i want the player to ride a ender pearl on the acutal path of the enderpearl
Alright, and where is the logic that makes that happen?
Or rather the code that is supposed to
- I'd like to win the lottery
- It didn't happen yet
I think it's more because you're using VSC
touché
the metrics part ?
how is metrics related?!
Well you said you want it so that a player follows an ender pearl?
or the command part in the first spot which is not working lol
ye like sits and rides it
Yeah okay what code do you have for that?
and i forgot that in commands ofc im dumb
Don't static unless need. Static bad
depends on if u abuse it or not
Static damage brain cause memory loss
if you abuse it, it is considered abuse
Ok another way ?
dont abuse it? idfk
think oop
Ok iuse it alot
Ineed good way ?
am i having a stroke
Good many words few not
why many words if less same
Few > many
< >
addPassenger?
Read the documentation?
?jd
?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.
the theory of everything
good idea
Alright I'm off to sleep for a few hours. Wake me if md_5 shows up to tell someone not to use NMS it's my favorite part of the morning
❤️
ah familiar env
fun facts: I had neither a jdk nor maven installed
how u forget both
yeah, I took a break from java for almost 4 years
wow
wb to shithole
knew i should've learned cpp instead
yes
it's a dumbed down version of c#
VB?
this
Hey, is there a Performance Gentle way to keep a BungeeCord Plugin on track where the players are?
Hello, I just crashed my server with a plugin I am making. Can someone read this stack trace and maybe give me some insight?
this appeared first
https://nekobin.com/rifujicuji
then this
https://nekobin.com/kevowamobu
any help would be appreciated it
?jd
?
https://nekobin.com/rifujicuji
at com.lucidaps.ChatFormat.SymbolRemoval(ChatFormat.java:112) ~[ChatFormat-1.2.jar:?]
at com.lucidaps.ChatFormat.chatFormat(ChatFormat.java:59) ~[ChatFormat-1.2.jar:?]
https://nekobin.com/kevowamobu
ChatFormat-1.2.jar//com.lucidaps.ChatFormat.SymbolRemoval(ChatFormat.java:110)
[11:33:10] [Watchdog Thread/ERROR]: ChatFormat-1.2.jar//com.lucidaps.ChatFormat.chatFormat(ChatFormat.java:59)
ye it stack trace
now find the line in your code which corresponds to the location in tims lol
ok now maven built hoverwars-0.0.2-SNAPSHOT.jar - how do I copy it somewhere?
I do that in build.xml, right?
oh wait, maybe maven deploy
Using spigot, how would I go about testing if a blockstate of a noteblock matched what I want
should i use intellj or eclipse
personal choice
Can someone help me with vault api?
https://paste.md-5.net/tesilimice.sql
p.sendMessage(String.valueOf(AsarSMP.getInstance().getPermission().playerRemove(null, p, oldPermission)));
p.sendMessage(String.valueOf(AsarSMP.getInstance().getPermission().playerAdd(null, p, permissionToAssign)));```
any idea on how to play custom noteblock music?
texturepack
hmm maybe
pretty sure thats the only way
damn
how do i add the premission operator to permissions: in plugin.yml so everyone with op can execute it?
An operator can use any command by default
permission: permision
yea but i cant remember what its called
?
* for all permissions
like permissions: *
what's the issue
getPermission() returns null
noteblockapi, noteblock plugins
ty
I copied the function from the git page
there is a permission plugin assigned to vault checked from /vault-info
show whole code
Bukkit does not understand wildcards. Your permission plugin should do that for you. Or in your plugin.yml, you have to define the * nodes and its children.
also just use luckperms
Hello everyone
Is it possible that a server blocks moving amorstands with velocity ?
I spawn a custom armorstand and I want to move it with vectors (i know how to do that), but it does not work. It works fine 4 months before but now no...
i have absolutely no clue how to use its api
Why use the api when you can just use Player#hasPermission(String permission)
because I need to remove/add permissions
checking the api brb
can this work permissions: permission*
everything is static so it is easy to use lol
it doesnt tell you what permissions there are
luckPerms.getPlayerAdapter(Player.class).getUser(player);
also just get the player from here
see not if you're as stupid as i am
go to permissions then handle it from there after
can i DM you abt it?
By that I mean you don't have to find the constructor to access every single part of it
Uh no, will go to bed after this lol
https://luckperms.net/wiki/Developer-API-Usage
anyways just get user, handle it from there
How can I get player dimension?
Player#getWorld()
There is nothing for the repo on the wiki idiot-proof enough for me
Thanks
like to add it
Player#getWorld()#getEnvironment()
nvm it is idiot-proof enough
does anyone know how to use noteblock api
Learn java
Again, learn java -> spigot -> u r good to go
how could I test for the note of a noteblock
Also use a music plugin instead
Left click if a literal note block
Play sound for sounds itself
And tonality is for the ticks or how high the note will play
I mean I created a plugin that tests if the player destroys a noteblock and grants items with nbt, which wasn't the hard part, what's difficult for me is figuring out how to test if the noteblock that is destroyed has a certain octave of note
lmao ill try learn java but for now how do i get maven pom in intellij idea
First, learn the basics
Hello world
And every other objects
IntelliJ also has a Minecraft Development plugin you can use which can make it easier for you.
You should either setup a clean maven project via IntelliJ
or use the MC Dev plugin to create a minecraft specific maven project.
You can get the BlockData of a Noteblock, then cast it to NoteBlock and
get the Instrument, and Note from that.
declaration: package: org.bukkit.block.data.type, interface: NoteBlock
alright cool ill try that
Hello, my server is crashing due to the ps.send(new ClientboundAddPlayerPacket(npc)); (1.18.1)
Crash report:
java.lang.NoClassDefFoundError: net/minecraft/world/entity/player/Player
When i try to import import net.minecraft.world.entity.player.Player i get an error: "No documentation found."
if you have any example of this it would be greatly appreciated
Sure one moment
?learnjava i think the pseudo-code is easy enough to do it yourself?
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.
How are you importing NMS. Maven or Gradle
Maven.
I believe its
((Noteblock)(Block#getBlockData()))#methods
if (block.getType() != Material.NOTE_BLOCK) {
return;
}
NoteBlock noteBlock = (NoteBlock) block.getBlockData();
Note note = noteBlock.getNote();
Instrument instrument = noteBlock.getInstrument();
much appreciated
You need to use the remapper. See the 1.18 release post for what you need
If your program against the remapped jar then you need to also run your server with that jar...
Or map it back using the special sources plugin
How can I send clickable text in chat?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I want my armorstand to go up, but it doesn't go up. Why?
@Override
public void animate() {
if(getSoulEntity().isDead()) return;
Vector vector = new Vector(0f, 0.5f, 0f);
ArmorStand armorStand = (ArmorStand) getSoulEntity();
ItemStack skullItem = new ItemStack(Material.PLAYER_HEAD);
SkullMeta skullMeta = (SkullMeta) skullItem.getItemMeta();
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(Main.getInstance().getConfigManager().getConfig().getString("SoulHeadOwner"))));
skullItem.setItemMeta(skullMeta);
ItemStack armorItem = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) armorItem.getItemMeta();
leatherArmorMeta.setColor(Color.fromRGB(Main.getInstance().getConfigManager().getConfig().getInt("SoulArmorColor")));
armorItem.setItemMeta(leatherArmorMeta);
armorStand.getEquipment().setItem(EquipmentSlot.CHEST, armorItem);
armorStand.getEquipment().setItem(EquipmentSlot.HEAD, skullItem);
armorStand.setVelocity(vector);
Bukkit.getScheduler().runTaskAsynchronously(Main.getInstance(), () -> {
float i = -180.0f;
while(!armorStand.isDead()) {
if(i >= 179.9f) i = -180.0f;
getSoulEntity().setRotation(i, armorStand.getLocation().getPitch());
i += 1.0f;
}
});
Bukkit.getScheduler().runTaskLater(Main.getInstance(), armorStand::remove, 5*20L);
}
I spawned an armor stand with a custom falling block as the passenger which creates a non-collisional block but how can I detect if a player went through the block? https://bit.ly/3fUcCWI
Which event is player's Inventory change?
There are several events that could lead to a player inventory to change. If he clicks something, picks something up or dies for example.
nms entities have a method that handles collision. How "custom" is your falling block?
Isn't there an event to detect changes to the player's backpack?
The velocity will be countered by gravity. Also your async method looks dangerous.
There are several events that could lead to a player inventory to change. If he clicks something, picks something up or dies for example.
look around and see if you can find out how collisions are handled
Why? :d
I could have a repeating task that would check if a player is near my custom falling block but I feel like that might lag the server considering I’m going to spawn a bunch of them.
Because your while loop is not bound to ticks. So it will run several thousand times per tick.
So you would get like 500 full rotations per second which the client would not notice at all.
Also calling spigot methods async almost always breaks.
Thats the hacky workaround. First you should look for a collide method
Ok, I will change it. Btw, I tried to enable and disable gravity for my armorstand and nothing changed
@EventHandler
public void onPlace(BlockPlaceEvent event) {
if (isInSpawnRadius(event.getPlayer().getLocation()))
event.setCancelled(true);
}
@EventHandler
public void onBreak(BlockBreakEvent event) {
if (isInSpawnRadius(event.getPlayer().getLocation()))
event.setCancelled(true);
}
@EventHandler
public void onMobSpawn(EntitySpawnEvent event) {
if (isInSpawnRadius(event.getLocation()))
if (!(event.getEntity().getType() == EntityType.PLAYER)) event.setCancelled(true);
}
@EventHandler
public void onPressurePlateActivition(PlayerInteractEvent event) {
if (event.getAction() == Action.PHYSICAL)
if (event.getClickedBlock().getType() == Material.OAK_PRESSURE_PLATE) {
Location spawn = Bukkit.getWorld("world").getSpawnLocation();
if (event.getClickedBlock().getLocation().getX() == spawn.getX()
&& event.getClickedBlock().getLocation().getZ() == spawn.getZ())
event.getPlayer().teleport(spawn);
}
}
public boolean isInSpawnRadius(Location location) {
if (location.getWorld() != Bukkit.getWorld("world")) return false;
return Bukkit.getWorld("world").getSpawnLocation().distance(location) <= spawnRadius;
}
is there a way to get the ID of a plugin (the resource id that comes at the last in the url of a plugin from the code
hey does anyone know why this prevents blocks that arent in the spawn radius from dropping items?
If I understand you correctly then...
I got .jar file with java -jar BuildTools.jar --remapped 1.18.1 command
no
unless they specified it somewhere easily accessible
is there a way to get the link of a plugin using resource id?
Yes. Items are Entities.
oh wow
Sure. If you have the ID then you can just scrape it. I also have something about an API for the website in my head...
package me.goldenred.raidspiders.listeners;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.world.entity.monster.EntityZombie;
import net.minecraft.world.level.World;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.entity.Zombie;
public class SpidListeners extends EntityZombie {
public SpidListeners(org.bukkit.World world) {
super(((CraftWorld)world).getHandle());
Zombie craftzombie = (Zombie) this.getBukkitEntity();
this.setBaby(false);
craftzombie.setMaxHealth(60);
this.setHealth(60);
this.setCustomName(ChatColor.RED + "hello");
this.setCustomNameVisible(true);
}
} Why cant i import the Entity from nms ?? it imports it from net minecraft WORLD ?? why and I don't have an option ?? who can help ?! I have to import the Zombie ?? H.E.L.P.
Why do you want to import the nms entity?
You can probably just use the one that you already imported
well it shows an error if i import it from mnw so i looked it up and i have to use nms
Show the error
Thanks a lot
to do what exactly?
im watching a tutorial
😐👍
so if i check if the entitytype is entitytype.dropped_item it will work?
Read the part about working with NMS and 1.17+ on this post:
https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/
Yes
thx
@EventHandler
public void InventoryEvent(InventoryEvent event){
Bukkit.getPlayer("whes1015").sendMessage("1");
}
you cant use InventoryEvent
Why it look like not work?
What event should I use instead of PlayerPickupItemEvent, because it is deprecated
This would also not cover deaths, picking up items etc
You cant listen to generalized events.
I move item in backpack
InventoryClickEvent ^^
Read the javadocs. EntityPickupItemEvent
how high is the chance that an new small event gets added ?
If you make a pullrequest and the event makes sense then quite high
BlockDamageStopEvent or BlockDamageAbortEvent ^^
On what basis would the detection of such an event stand?
an packet
thats already used to send BlockDamageEvent
ServerboundPlayerActionPacket
Thanks. Do you know how can I make player open grindstone? The method openInventory() accepts the Inventory or InventoryView parameter, which I'm not sure how to use. I've had a look at InventoryType enum, however I can't put it in openInventory() method
Thanks
NamespacedKey key = NamespacedKey.minecraft(advancement.toString());
AdvancementProgress progress = player.getAdvancementProgress(Bukkit.getAdvancement(key));
for (String criteria : progress.getAwardedCriteria())
progress.revokeCriteria(criteria);
``` Does anyone know why this wouldn't revoke the criteria?
should an new event use CraftEventFactory ?
Wym?
many events use CraftEventFactory to create & call an event ...
if i now try to add a new event to api ... should this use the factory ?
does any of you use YAML anchors
and know if its possible to use them inside string literals
by grabbing not the whole defined string literal but only a fragment of it
Believe they’re not interoperable with strings
not custom... new api via PR event
this works:
key: &whole-message |-
Hey! This is a new literal
I want to grab this one!
but this won't unfortunately
key: |-
Hey! This is a new literal
&grabbed-message I want to grab this one!
Myeah do that
Since the style is already sort of like that
Using static factory methods
even more classes to destroy xD
Yeah that won’t work
Maybe if you use sth like a sequence as value
You can transform it?
its not my code
but wait
I mean yaml is configurable
maybe it does
But not that configurable
Myeah it’s quite nice
oof
i mean there's other way
create a dummy key
and create an anchor there
but that's just overkill
Maybe not
should an event contain a time at all and if possible also gameTicks ?
currently thinking of stuff i dont want to miss while adding BlockDamageAbortEvent which gets called for player stops breaking a block (target another one or smth)
well then he can do it self or not ? xD
Why not just extend BlockEvent and provide everything that the Damage event provides
yeah but should i just create an PR and ask what should change exactly and then code it ? or will he someday just look at this: https://hub.spigotmc.org/jira/browse/SPIGOT-6910
BlockDamageAbortEvent should not have bool=instaBreak or itemInHand ...
but its just player.getInveotry().getItemInMainHand() .... but i think it can have it since the var already exists in the same class too
Ya
BlockDamageAbortEvent can also have multiple uses... like aborting if block breaks or if rly stops breaking ... but is this worth since blockbreakevent would cover the first use ?
this event doesnt appear to execute anything... any ideas?
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
this event ?
well thing
if(kills == maxkills){
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
onlinePlayer.sendTitle(ChatColor.DARK_RED + "HUNTER WINS!!!", "", 1, 60, 1);
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.ENTITY_WITHER_DEATH, 100000, 1);
onlinePlayer.getInventory().clear();
onlinePlayer.setGameMode(GameMode.ADVENTURE);
new BukkitRunnable() {
@Override
public void run() {
onlinePlayer.teleport(new Location(Bukkit.getWorld("lobby2"), 0, 65, 0));
kills = 0;
}
}.runTaskLater(Parkour.getPlugin(Parkour.class), 2L * 30L /*<-- the delay */);
}
}
?paste
it will run if kills == maxkills and there are players online ^^
hmm
@ivory sleet, why doesn't my armor stand go up?
https://pastebin.com/X2DC2bsp
i just want everything in the for loop to execute for every online player
And it will. If kills == maxkills
do you add it to the world or just spawn it with packets ?
it spawns in the world
Did you forget the EventHandler annotation? Did you register the event?
so you can let it fall down too ?
anything outside the for loop works fine
Show the whole class pls
wait
Yeah I'm not arguing it's usefulness, I think it's a necessary event as well. I've actually made it by listening to incoming packets 😛
dunno
and why you dont just add the pr then xD if so it would been part of api already
how do you spawn it ? code ?
Did you disable its AI or set it as marker? Because then gravity and velocity wont affect it.
Because I'm listening to packets completely differently than how Spigot would do it. It's arguably easier to add it to Spigot, I just haven't.
no
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
Player killer = event.getEntity().getKiller();
if(killer != null) {
if(generateChance(Main.getInstance().getConfigManager().getConfig().getInt("SoulChance"))) {
ArmorStand armorStand = (ArmorStand) event.getEntity().getLocation().getWorld().spawnEntity(event.getEntity().getLocation(), EntityType.ARMOR_STAND);
GhostSoul ghostSoul = new GhostSoul(armorStand);
ghostSoul.animate();
}
}
}
private boolean generateChance(int chance) {
return chance < ThreadLocalRandom.current().nextInt(101);
}
😭

did you test if animate() gets called ? maybe an ArmorStand is always dead 😄
yes, it is rotating and then getting killed when it's spawned
Dont read config files like that pls. Read everything from a FileConfiguration when a server starts and save it in properly named variables.
Anyways:
Show the GhostSoul constructor pls
and the animate method
it's a small plugin so ig that's not a problem, but ok, gotcha
public GhostSoul(ArmorStand armorStand) {
super(armorStand);
armorStand.setInvulnerable(true);
armorStand.setCustomNameVisible(true);
armorStand.setPersistent(true);
armorStand.setVisible(false);
armorStand.setGravity(false);
armorStand.setCustomName(pickRandomName());
super.setSoulEntity(armorStand);
}
@Override
public void animate() {
if(getSoulEntity().isDead()) return;
Vector vector = new Vector(0f, 0.5f, 0f);
ArmorStand armorStand = (ArmorStand) getSoulEntity();
ItemStack skullItem = new ItemStack(Material.PLAYER_HEAD);
SkullMeta skullMeta = (SkullMeta) skullItem.getItemMeta();
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(Main.getInstance().getConfigManager().getConfig().getString("SoulHeadOwner"))));
skullItem.setItemMeta(skullMeta);
ItemStack armorItem = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) armorItem.getItemMeta();
//leatherArmorMeta.setColor(Color.fromRGB(Integer.parseInt(Main.getInstance().getConfigManager().getConfig().getString("SoulArmorColor"), 16)));
leatherArmorMeta.setColor(Color.WHITE);
armorItem.setItemMeta(leatherArmorMeta);
armorStand.getEquipment().setItem(EquipmentSlot.CHEST, armorItem);
armorStand.getEquipment().setItem(EquipmentSlot.HEAD, skullItem);
armorStand.setVelocity(vector);
Bukkit.getScheduler().runTaskAsynchronously(Main.getInstance(), () -> {
float i = -180.0f;
while(!armorStand.isDead()) {
if(i >= 179.9f) i = -180.0f;
getSoulEntity().setRotation(i, armorStand.getLocation().getPitch());
i += 1.0f;
}
});
Bukkit.getScheduler().runTaskLater(Main.getInstance(), armorStand::remove, 5*20L);
}
small or big plugin is completly shit ... if you read values all the time again and again its unwanted lagg you can easy abort
well u r right
If nothing helps then just tp it every tick until its dead
Would setGravity prevent the velocity from being applied for some reason?
I wouldn't think so
Does anyone have a solution for this yet?
what was that .... if you use a jira request as base you have to name the fork of spigot/bukkit to the same id+name ? @ivory sleet
how do you run a plugin in the intellij console?
i saw the spigot server running in some peoples console window
You can use run-paper plugin by jpenilla if you're on gradle
oh maven :(
Then idk
Hi
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i think i need allowPublicKeyRetrieval set to true for my hikari pool which is connected with a mysql db
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed```
https://stackoverflow.com/questions/50379839/connection-java-mysql-public-key-retrieval-is-not-allowed/51132931
what if the server changes the values on fly
and the values need to be changed without server restart
Just update them?
but your variables are only update to the values you get on enabling
That's what reload sub commands are for
You can just update them by reading a file again. I dont understand the problem...
so the point is just not to access them directly
It also helps with a fail fast approach.
Its way more difficult to find errors after 10mins when the config gets eventually accessed instead of right when the server starts.
File access is also slow. You don’t want to be constantly hitting the file system in your main game thread if you don’t have to be
Example:
public class PluginConfig {
private final Supplier<FileConfiguration> configSupplier;
@Getter
private boolean portalsEnabled;
@Getter
private int messageTimeout;
public PluginConfig(Supplier<FileConfiguration> configSupplier) {
this.configSupplier = configSupplier;
reload();
}
public void reload() {
FileConfiguration configuration = configSupplier.get();
portalsEnabled = configuration.getBoolean("some.path");
messageTimeout = configuration.getInt("some.other.path");
}
}
@Override
public void onEnable() {
PluginConfig pluginConfig = new PluginConfig(this::reloadAndReadConfig);
}
private FileConfiguration reloadAndReadConfig() {
reloadConfig();
return getConfig();
}
imposter is writing...
why a supplier :C
So you can supply a FileConfiguration.
If you just pass it then there would be no change when reloading.
Doesnt that create a new instance of FileConfiguration?
Yeah but then you would have to update every PluginConfig instance you have injected into other instances
mwoa okay anyways is this an alternative to this code?
userMap.entrySet().removeIf(entry -> entry.getValue().getPlayer() == null);```
```java
for (Iterator<User> iterator = userMap.values().iterator(); iterator.hasNext();) {
if (iterator.next().getPlayer() == null) {
iterator.remove();
}
}```
Both do the same thing
i need an counter variable tho so im stuck to the second one :(
You can also have a counter for the first one.
Do you just want to have the total amount removed after the whole iteration or make the counter a condition?
i want to have the total removed entries
Then just calculate the delta of the userMaps size...
userMap.size()
userMap.entrySet().removeIf(entry -> entry.getValue().getPlayer() == null);
userMap.size()
wont that work
int before = userMap.size();
userMap.entrySet().removeIf(entry -> entry.getValue().getPlayer() == null);
int removed = before - userMap.size();
If you really want to count up:
AtomicInteger counter = new AtomicInteger();
userMap.entrySet().removeIf(entry -> {
if (entry.getValue().getPlayer() == null) {
counter.incrementAndGet();
return true;
}else {
return false;
}
});
int removed = counter.get();
Excuse me, I'm making a spigot plugin , but I got an error.
Here it is:
[16:45:46] [Server thread/ERROR]: Error occurred while enabling MBC-T2 v1.5.11 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "smile.main.mbct2.MBCT2.getCommand(String)" is null
at smile.main.mbct2.MBCT2.onEnable(MBCT2.java:23) ~[MBC-T2-1.5.11.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:564) ~[paper-1.18.1.jar:git-Paper-165]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:478) ~[paper-1.18.1.jar:git-Paper-165]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:727) ~[paper-1.18.1.jar:git-Paper-165]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:503) ~[paper-1.18.1.jar:git-Paper-165]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:313) ~[paper-1.18.1.jar:git-Paper-165]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1202) ~[paper-1.18.1.jar:git-Paper-165]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-165]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
My plugin's code:(main.java)
package smile.main.mbct2;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import smile.main.mbct2.commands.*;
public final class MBCT2 extends JavaPlugin implements Listener {
@Override
public void onEnable() {
System.out.format(ChatColor.AQUA+"MBC-T2正在加載..."+ChatColor.WHITE);
getCommand("mbc").setExecutor(new mbc());
getCommand("location").setExecutor(new location());
getCommand("locationall").setExecutor(new locationall());
getCommand("claimhelp").setExecutor(new claimhelp());
getCommand("shovel").setExecutor(new shovel());
}
@Override
public void onDisable() {
System.out.format(ChatColor.RED+"MBC-T2正在關閉..."+ChatColor.WHITE);
}
}
line 23 is getCommand("claimhelp").setExecutor(new claimhelp());
You forgot to add your command to the plugin.yml
probably
Is it possible to send a plugin message from bungeecord without any players online?
no
I found the mistake
Thank you👍🏼
how does it look?
https://paste.helpch.at/owabufupaz.java
also having the database impl and the cache in one class worries me
Was about to point that out
Any reason why you dont just use Caffeine?
LoadingCache for example.
Its a map that returns an element if it is present or loads it with the given loading function, then saves and returns it.
Also supports functionality to add a persisting function for when an element is removed from the map and
automatically lets entries time out after a period of time when they dont get accessed.
Honestly I wish we just had an auto-response when people post NPEs here
i was more thinking about the guava cachebuilder in my prev. design but anyways
Because 9/10 times it is the exact same oversight
It's especially bad because new NPEs literally show you exactly what is going wrong and people are still just help "pls halp how do fix"
And with newer java versions the NPE literally tells them: "A NPE was thrown because the field x/method y is/returns null"
Yeah
read stacktraces 
this looks about the same as the guava cachebuilder ._.
Cache<String, DataObject> cache = Caffeine.newBuilder()
.expireAfterWrite(1, TimeUnit.MINUTES)
.maximumSize(100)
.build();```
Is it possible to change the enchant glow color or would that be a texture pack situation? Ive been trying to find something like it but all I can find is texture pack related
resource pack. Minecraft doesnt have more effects for ItemStacks other than the enchantment glow
texture pack
alright thanks
why is this man putting backticks?
was that to prevent sql injection or am i wrong?
i remember those were ?'s but i dunno
At first glance
But it’s just so much more powerful
i remember backticks from js who were also powerful 🤡
To avoid conflicts? There's some reserved keywords in sql
hmmm how can i undo adding something in git.... somehow makePatches did not work but the file that i changed also does not exist anymore
like statistics or member
oh maybe he's living in the future
It's also a preference thing
Well it looks inconsistent if some of columns are in backticks and some of them not
I had worked with people that put backticks on their database and table names
e.g.
SELECT * FROM `database`.`thetable`
:(( why is there no good formatting on that
oeh fancy @Language
There's a code block! Use spaces! lol
does it hurt your eyes?
:(( yes
aah this does
And yeah, @Language is a Jetbrains annotation. Jetbrains IDE will actually interpret the string in that language and do some syntax validation for you
Kind of wish Eclipse would support that annotation
Use intellij :)
Well, joins result from 2 tables
i think if i would ever use eclipse something in my brain would break
yea looks weird
Yeah, it's a preference thing
i see bad sql design
why
Lots of null stuff. Perfect opportunity to make use of relational data structures
Thats just a view!
locations should be in a separate table for instance with a foreign key to the clan id
also saving everything in just 1 table is weird
Thats not a table! I use the view to load everything i with a single statement
.
what should i do instead
Cancel falling block conversion to item
you can use it ^^ but i used to code my own database with socket connection and stuff like that ... just for fun
🆗
Still don’t see a reason why you’d have to dislike sql because of that
its not because of that ^^
Then why do you dislike sql?
a reason is this ^^
Can I calculate the player's walking distance?

