#help-development
1 messages · Page 1510 of 1
I think it already did
quite possibly
do I have to add it? I get the vector that I'm rotating by Vector locv = loc.add(0,3,0).toVector(); and rotate it every 5 ticks
loc contains the location of the block I'm looking at
what is all presnt in a vector. Im trying to teleport on top of an entity after right clicking it which pulls in a vector and need it as a location for the teleportation part.
Vector#toLocation(World)
Vector has x,y,z and direction
how would u extract the x y z from a vector
getX(), getY(), getZ() 😛
ok
Or, if you want a Location, use the method I identified above
I'm loosing my mind, how tf do I fix this?
I know its caused by the class having 2 overloaded constructors
https://i.imgur.com/Mz6fpvL.png
nms
Well AreaEffectCloud is a Bukkit interface
Which isn't instantiable
If you want the NMS one, it's an EntityAreaEffectCloud
Ok, so Im trying to decompile the server jar, without spigot or bukkit atm, i just dont know where else to ask this
can you do unit tests on spigot plugins
no that is illegal
or its way too much hassle to do them
Usually not worth the effort but there are projects like MockBukkit
omg thats alot of messages
what if i want to test something not specific to Bukkit API, like some kind of configuration system
If you don't really require a running server at all then you can just make tests as you would normally
Obviously things like World#spawnEntity() would require something like MockBukkit
I'm 21
9+10
is there any way to set maven home path for project initalisation?
in linux
it always inits project in /home/ directory
How do I get the type of the broken block in the block drop item event?
I keep getting air even if I use event.getBlockState() first
just use block break event
I'm modifying the drops though
If isDropItems in BlockBreakEvent is set to false, BlockDropItemEvent event won't be called
event.getBlock().getType()
try this ^^
are you using newer than 1.13 version of minecraft?
1.16
what's your api-version number
in plugin.yml
sometimes that causes these kinds of issues
api-version: 1.16
Hahahahaha
lets start that forEach is slower than for (Location loc : locations) {} since its basically anonymous function being called every time
This caught me off guard
at least in C that would be slower
its not
would prefer the syntax for-loop too, but forEach is not slower than that. its just more useful in the context of collections
it could be very very slightly slower
forEach is literally implemented like this
for(int i=0; i<size; i++)
action.accept(elements[i])
due to the method call, yes, but nearly not noticeable
it calls the method every iteration
the difference is negligible if even existent
it adds up
Reflections are kinda slow in Java, do you do Reflection checking in "runtime" (every time method is called)?
i don't know what you're asking about but I almost always cache my reflected methods
unless it's only done once in which case i don't bother
I wanna say no but I could be wrong. The link to the class is in the message.
@wraith rapids any idea why my BlockBreakEvent stopped working after I added PlayerDropItemEvent?
https://paste.md-5.net/uyihiseniq.cs
Okay
not enough cpu cycles to go around for opening that in a browser
what am i looking at
Ah yeah cause its different blocks... I can't cache 1m blocks of data lol
You don't need to.
Asking me?
You only needto cache the only one Field/Method
why are we using reflection to get the material of a block
is there some sort of Map where it uses 2 keys? (In my case, a Block/BlockState/Location and a Player/UUID)
in this case it gets the field or method object, which is slowest thing in reflection every time it runs
which is inefficient
yes, a Map<Key1, Map<Key2, Value>>
ah true, should go to bed... its late
Oh wait I see.. I was thinking blockdataclass was subclasses of BlockData
alternatively you can create a specific Key class that holds those 2 elements
and implements hashcode and equals
this seems simpler
might do that in the future tho
it would be significantly more space efficient
^^
but depends on your use case
multimaps are Map<Key, Set<Value>>
well this method right now already works fine and I see no performance impact at all with just me, but idk if its 10 or 20 players or more
or Collection<Value> instead of set
is guava not exposed through spigot?
the performance impact will not be visible, or if it is, it won't be attributable to your map easily
i dont remember actually, i think its mojang's dependency
but, the nested map may use up to an order of magnitude more memory
it would merely be one entry per player, maybe max 2
in that case an order of magnitude is not that big
so it shouldn't be to bad memory wise
that wasn't the problem mentioned, it was about the nested maps using up much more memory than a Key that uses 2 objects.
It's saying this is always false?
if (event.getPlayer().getInventory().getItemInMainHand() == null)
Oh
intellij is smart
it may, however, return an itemstack that is AIR
it reads annotations
Same thing
also eclipse too
Man I'm not fast enough of a typer to sound smart in these conversations
@mortal hare how would you cache the results? Cause They way I'm thinking is its using a new NMSBlock each time so if i cache it thats alot of data.
methods/fields exist per-class
not per-instance
you'd only have to cache the relevant methods and fields for each class involved
not each instance involved
calling the actual methods isn't slow
nvm, I was just being stupid and wasn't actually getting the type
it's finding the methods/fields through reflection that takes the most time
searching of the actual method is fucking slow
so you need to cache the Method object somewhere
so anything beyond the per-class caching I mentioned is probably redundant
or, not redundant, but unnecessary
Ok. Ill do some testing
the real question is
why the fuck is reflection involved to begin with
Idk if this is preference but I like MethodHandles for specifically method related operations
he could just use interface method
methodhandles are slightly faster
Yeah
that way it could use Spigot API
iirc methodhandles have almost the same performance as native method calls
Its a 4 year old plugin that I just copy and paste the methods to use new versions. I'm using reflection because its cleaner.
I heard it uses lambda shit? Not sure
i'm a j8 guy so I haven't really fucked with methodhandles at all
if there are it's super limited
what's the difference between Method object and MethodHandle
aren't they're doing the same
Ones faster
i remember trying to do something with them in a plugin because reflection was fucked in j9+ but ran out of effort because my j8 environment didn't have the necessary classes and shit
MethodHandle tho is more suited only for methods specifically tho, unlike reflection and methods that stuff
Player.sendBlockChange() is deprecated whats the new one?
have you read the deprecation note in the javadocs
i sure haven't, but it's a good place to start looking for the new alternative
MethodHandles can be faster than using reflection as there is more direct support in the JVM e.g they can be inlined. It uses the new invokedynamic instruction.
🤔
that's kinda cool ngl
its only deprecated if you use material and byte instead of blockdata so I guess its half deprecated lol
well yeah, the old block damage values have been deprecated for ages
yeah ive definetly been working on spigot for ages
so basically from what i see that MethodHandle and Reflected Method object are like roughly (in c'ish terms):
Method* method;
MethodWrapper wrapper;
am i right?
Ok I've modified it and got it from 25ms to 9ms
https://pastebin.com/J4Nfajac What else would you recommend I change?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
isLegacy() can be computed in construction time in constructor
take a spark report and see which parts are using the most time
that way you would only return the boolean
or plug it into an actual profiler
and not the use for looping contains everytime with regex
For some reason spark profiler doesn't show my test plugin... at all xD
@EventHandler()
public void onBlockBreak(BlockBreakEvent event) {
if (event.getPlayer().getInventory().getItemInMainHand().getType() == Material.AIR)
return;
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
return;
if (!event.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasEnchant(Enchants.TELEKINESIS))
return;
if (event.getPlayer().getInventory().firstEmpty() == -1)
return;
if (event.getBlock().getState() instanceof Container)
return;
event.setDropItems(false);
Player player = event.getPlayer();
Block block = event.getBlock();
Collection<ItemStack> drops = block.getDrops(player.getInventory().getItemInMainHand());
if (drops.isEmpty())
return;
player.getInventory().addItem(drops.iterator().next());
}
What's wrong here? It drops the item from the block on the ground even if the item I have has the enchantment.
fake
have you registered it?
As a MC enchant?
yes
Yes
have you tried debugging enchantment map
Wow... the .contains check was causing a shit ton of lag. Thanks for the help
The code was working before
yea because the .contains is literally for loop of every character until it matches the regex
regex is slow af too
Damn.... well I gotta work out how to check for certain materials then xD
cause I have a list of logs leaves etc... and use .contains
excuse me its not regex but sequence of characters
well maybe you can do it async
but there may be better ways
Yeah I'll work on async after speed.
Still need to make sure the speed of my lumberjack recode matches the speed of my test plugin
why wouldnt you use the map instead?
Hello
?
nvm
so I got mcp set up on intellij, but it's giving me like 50+ errors on imports
I asked a client question before, and it was answered. also
neither vanilla injection modding
^
what are the errors then
hey
for example: src\minecraft\net\minecraft\util\ResourceLocation.java:3 java: package org.apache does not exist
more info - less hassle
do u prefer kotlin dsl or groovy dsl for gradle?
Wasn't MCP not even updated beyond 1.12?
basically the same error - but with different imports
import the apache dependencies
it lacks the dependencies
ah, this sounds dumb, but how?
ok
it's literally just one import: import org.apache.commons.lang3.Validate;
however, the errors are spread throughout different files
it's not all about apache either, google as well
Wdym?
try to output the enchantments
to the logs or the chat
and see what the map contains
there's method to get all enchantments
of the item
in itemmeta
i think
honestly it lacks info
all of the dependencies are underlined red in intellij
yes
you need them to import it
via intellij build system or via maven or via manual classpath or via gradle
in your case i see you're using intellij build system
alright
@mortal hare if I add System.out.println(event.getPlayer().getInventory().getItemInMainHand().getEnchantments()); to
if (!event.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasEnchant(Enchants.TELEKINESIS)), it works as intended. But I only see this in console [INFO]: {}
if there nothing inside the brackets
there are no enchantments on it
have you tried outputting iteminmainhand
method?
But NBT Explorer even shows there's an enchant there and it works anyway
event.getPlayer().getInventory().getItemInMainHand() ?
yes
ItemStack{NETHERITE_PICKAXE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, lore=[{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"Telekinesis"}],"text":""}], Damage=21}}
Why can't it find the enchant?
This also has it, but it doesn't show up there
ItemStack{DIAMOND_PICKAXE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, lore=[{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"Telekinesis"}],"text":""}], Damage=44}}
This is that pickaxe in NBTExplorer
w h a t
Does Paper have something against "unsafe" enchantments?
wtf
now my chestplate with the flight enchant isn't working
idek anymore
is there a way to make intellij detect the jars automatically instead of adding them all one by one? there seems to be a libarary folder in mcp, can't I just use that?
use Gradle or Maven makes like 10x easier
Why would this return an NPE?
I know but what
i don't know
you have literally all of the relevant information
maybe share some of it
It says that
what is line 107
that is not the full error
then the code that is running and the code you're looking at aren't the same
They are thats literally the class its refrencing
c function isnt returning anything
not returning anything doesn't throw a NPE
can you even do for loops like that in java?
yes
without { }
Ok this should hopefully be the last problem
so - Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
I've looked it up but I don't think I see a straight answer
Full error:
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:871)
at java.lang.System.loadLibrary(System.java:1124)
at org.lwjgl.Sys$1.run(Sys.java:72)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:87)
at org.lwjgl.Sys.<clinit>(Sys.java:117)
at net.minecraft.client.Minecraft.getSystemTime(Minecraft.java:3030)
at net.minecraft.client.main.Main.main(Main.java:39)
at Start.main(Start.java:11)```
Someone
@stuck kindle Are you trying to make a minecraft client?
I think so, you're in in the wrong discord server for help with it. Read channel description
Is there a plugin that lets you change the tab menu in 1.9+?
it says, ask other questions here
Where? I don't see that
at the top of the channel, the description
I only see Serious Spigot and BungeeCord programming/development help
Serious Spigot and BungeeCord programming/development help | Ask other questions here
I don't see the last part hold up lemme restart discord
Right next to the channel #?
I might be bugged
well, if anyone knows, please tell me
I think I remember a discord server that is dedicated to this stuff
Please send me the link if possible, problem is most other discord servers are dead
anyone know how to make all hostile mobs prefer a certain player more?
@EventHandler
public void onClick(PlayerInteractEvent event) {
Player target = (Player) event.getPlayer();
if(event.getPlayer().getInventory().getItemInMainHand().hasItemMeta()) {
if(event.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().contains("Search the pockets of")) {
if(event.getAction() == Action.RIGHT_CLICK_AIR) {
event.getPlayer().openInventory(target.getInventory());
}
}
}
}
}```
Hey guys so this code is suppose to open the inventory of the person i right click on but it doesn't work when I click them but it works when I right click the air but it opens my inventory not theirs
because when you right click someone, Action.RIGHT_CLICK_AIR isnt fired
also event.getPlayer() gets the rightclick-er not the rightclick-ee scratch that you're using target.getInventory()
probably the lore check
yeah that lore check hurts my soul
What version of mc?
this event doesn't allow the .getaction
1.8.9
Go to your run configuration and send a screenshot of that
Of course not
alr
The only action is right clicking an entity
Not a screenshot because I can't send those - but the VM option is -Djava.library.path=versions/1.8/1.8-natives
hm try changing it to -Djava.library.path=versions/1.8.9/1.8.9-natives/
AY
ohhh you're right and thank you it works now but I get an error if i right click a none player
Add an instanceof check
@EventHandler
public void onClick(PlayerInteractEntityEvent event) {
Player target = (Player) event.getRightClicked();
Player player = event.getPlayer();
if (target instanceof Player)
if(event.getPlayer().getInventory().getItemInMainHand().hasItemMeta()) {
if(event.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().contains("Search the pockets of")) {
event.getPlayer().openInventory(target.getInventory());
}
}
}
}```
like this?
anyone had this issue? I've been working off a branch of my github project. Today finally finished the branch and merged it into the master.
Soon as I switched to master branch on my github desktop, all the code hasn't changed but it's complaining about almost every single function or variable in there.
It's saying things like it can't find a function I'm referencing when it is right below it in the same class
I cannot for the life of me figure out wth is wrong with it
where can i go if I want to create a minecraft forge mod
it underlines target if put the ehck before player = target
?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.
which link did you use?
You can use any
Hello! I am looking for help with saving blockstates between restarts.
I have a plugin, in which you can blow stuff up. Then, over the course of a handful of minutes, the blocks all regenerate. I do this by saving the blockstates of those blocks in a list and creating a bukkitrunnable which simply updates them back to their original state over a period of time.
HOWEVER, what if the server crashes? Oh no! Then, we'd lose the bukkitrunnable, which means the terrain wouldn't regenerate. Terrible!
So, I need some way to preserve the list of blockstates (or, something which holds all the block's information) between crashes.
Could also just quickly run through all the runnables and finish piecing everything back together before the server shuts down
My main concern is that a crash might not allow that.
Though that assumes the server stops gracefully. If it crashes, you're SOL whether you're saving to file or not
Yeah
thank you I did it
Yeah, so I need some way of saving everything to a file during the first tick when it's destroying everything.
I just don't know
How to do that
I could save the locations and blockdatas for everything, since those I can parse from strings
Well you can save block data extremely easily but you get into more complicated territory when it comes to states. i.e. inventories
yah
inventories
thats the prob
i need some way to preserve those
and i dunno how
any tips, masterman?
is using an eye of ender considered a throw event?
Is there a sample of using a IChatBaseComponent somewhere?
I can't fine one using google.
Trying to get it format & characters for color
public class Formatter {
private static final Pattern pattern = Pattern.compile("(?<!\\\\)(#[a-fA-F0-9]{6})");
public static String format(String message) {
Matcher matcher = pattern.matcher(message);
while (matcher.find()) {
String color = message.substring(matcher.start(), matcher.end());
message = message.replace(color, "" + ChatColor.of(color));
}
return message;
}
public static String colorize(String message) {
return org.bukkit.ChatColor.translateAlternateColorCodes('&', message);
}
}
@EventHandler
public void chat(AsyncPlayerChatEvent e) {
e.setMessage(Formatter.colorize(e.getMessage()));
e.setMessage(Formatter.format(e.getMessage()));
}
supports & and #hex colors
That's cool, not what i am look for.
i am trying to translateAlternateColorCodes to a IChatBaseComponent for entity names
I believe you need to do fromLegacyText
Actually that’s for the API version, no idea for NMS
oo not a bad idea, i can hook into bukkkit layer from nms and see if that will work since i was in the nms layer
how can I check if an item's PersistentDataContainer contains any key in a namespace
ayo~ is there a way to make like,, cosmetic armor? as in the player is wearing one set of armor but it appears they're wearing a different set to other users
you can make an ItemStack with the desired set appearance and then change the attributes to make it the same as a different set
hm, i see. but currently no way to, say, wear diamond armor in the inventory but appear to be wearing iron armor to other players/F5?
Not that i have found yet
(this is a very niche use case i am aware, if it isnt possible, fine)
that's exactly what you said were looking for.
"Trying to get it format & characters for color"
using IChatBaseComponent
not as a string value
translateAlternateColorCodes does not work on a IChatBaseComponent it does not change the color of the value and it still shows the &
you never specified that until after I answered you
my bad
i did say using IChatBaseComponent
i just did not add that translateAlternateColorCodes does not work.
I got it thx
You can if you mess with packets
monkaS
This method stops working (seemingly freezes) after the last line calling getNearbyEntities. I call it using Bukkit.getScheduler().runTaskAsynchronously in onEnable. am i doing something wrong
public static void playerNearCow()
{
for (Player player : Bukkit.getOnlinePlayers())
{
World world = player.getWorld();
//all lines up to here work
List<Entity> entities = player.getNearbyEntities(explodingCowRange, explodingCowRange, explodingCowRange);
//all lines after here dont get called since getNearbyEntities() is breaking or freezing somehow
It is not-advisable to call Bukkit API within runtaskasync
how should i do async then
You have to do it in the main server thread for that line, no other way
You can try adding a nested BukkitRunnable for that line
And runtask
is there a more convenient way to continuously check for player conditions without an event triggered
Depends on what conditions you need
whenever a player is in range of a cow
no
player.getInventory().addItem(CustomItems.magicStickKB);
}```
When i go to run this with all the correct listeners and code within main class, it outputs the error : java.lang.IllegalArgumentException: Item cannot be null
Not sure why tho
It runs onPlayerJoin
MagicStickKB is null
check to find what makes magicStickKB null
no it is an item that i created in a seperate class
Evidently it’s null
Are you using scheduleAsyncRepeatingTask or sth like that, if so, thats prob the best way
ill try it
I think it is called runTaskTimerAsynchronously now
Keep in mind you can’t access most of the API async
But you prob still need a nested runnable to run that task on main server thread
Yea that was the problem he raised
also just random, when u add an enchant on a material, if u say true then it follows minecrafts standard rules, and if you say false it follows the non standard max levels? correct?
That is addUnsafeEnchantment
o
what is true and false for? wether it shows or doesnt show effect?
like enchantment glow
minecraft sets enchantment level caps, false disables it
im p sure thats what it is
thats what i though
Oh
Then this is for incompatible enchants then
How can I update GUI title? Like change it every x seconds.
Packets
[04:46:46 WARN]: java.sql.SQLException: No value specified for parameter 1 when value 1 is my id field
Iirc sql starts at 1 rather than 0
correct
i've noticed that an InventoryClickEvent is sent 4-5 times just for one click, is there anyway to limit this?
Does Inventory#containsAtLeast check for the ItemMeta too?
public static void onPlayerConsume(PlayerItemConsumeEvent event) {
Player player = event.getPlayer();
ItemStack item = CustomItems.enchantedDiamondApple;
PotionEffect jumpEffect = new PotionEffect(PotionEffectType.JUMP, 3600, 4);
PotionEffect speedEffect = new PotionEffect(PotionEffectType.SPEED, 3600, 4);
PotionEffect nightvisionEffect = new PotionEffect(PotionEffectType.NIGHT_VISION, 3600, 4);
PotionEffect invisEffect = new PotionEffect(PotionEffectType.INVISIBILITY, 3600, 4);
if (event.getItem().getItemMeta() == item.getItemMeta()) {
player.addPotionEffect(jumpEffect);
player.addPotionEffect(speedEffect);
player.addPotionEffect(nightvisionEffect);
player.addPotionEffect(invisEffect);
}
}```
When i go on minecraft and eat the "echanted diamond apple" it does not give the player any effects. Is there something wrong with this code?
are you registering the event?
yes
Just if(event.getItem().isSimiliar(CustomItems.enchantedDiamondApple)
ok
what version?
?jira if 1.17, i'd report it here
im on 1.16.5
odd, i swear that doesn't happen to me
if you log to console every time it is sent, you'll see 4 msgs
latest spigot? /ver
ask on the paper discord then
!sender.hasPermission(plugin.getConfig().getString("adminperms")))```Am i doing something wrong. I have the permission in the config
Gonna need more than that
if (!sender.hasPermission(plugin.getConfig().getString("adminperms")) || !sender.isOp() || !(sender instanceof ConsoleCommandSender)){
sender.sendMessage(Utils.formatChat("&cNo permissions"));
return true;
}```
only does what it is supposed to if im console
does it send if the sender isn't an op?
if (!sender.hasPermission(plugin.getConfig().getString("adminperms")) || !sender.isOp() || !(sender instanceof ConsoleCommandSender)){
shoud be
not even a needed check tbh, I'm pretty sure op's have full perms
actually you don't need the sender instanceof check since console's isOp returns true anyway
Spigot has deprecated Enchantment#getByname and can someone tell me how exactly to use Enchantment#getByKey?
You shouldn’t hardcode a command for ops anyway
This worked only when they were op. I checked to see if they had the permission via logging it and they did and it didnt work .
Thx alot finally get to sleep
@EventHandler
void onSmallAxeRightClick(PlayerInteractEvent event){
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
if(event.getItem().equals(itemManager.smallAxe.getItemMeta())){
Player player = event.getPlayer();
player.setInvulnerable(true);
player.getWorld().createExplosion(player.getLocation(), 5, false);
player.sendMessage(ChatColor.GOLD + "You Have Stuck The Ground With The Holy Power Of The Gods!");
player.setInvulnerable(false);
}
}
}
public static void smallAxe(){
ItemStack item = new ItemStack(Material.NETHERITE_AXE,1);
ItemMeta meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName(ChatColor.GOLD + "Holy Godly Axe");
List<String> lore = new ArrayList<>();
lore.add(ChatColor.AQUA + "The Holy Godly Axe Used By The First lander Of The Overworld ");
lore.add(ChatColor.AQUA + "Only The Worthy Used To Wield, But Now It's Yours!");
meta.setLore(lore);
meta.addEnchant(Enchantment.ARROW_INFINITE, 1, false);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
smallAxe = item;
}```
Nothing happens with this...
like, when i right click the ground on a block it doesnt do what i told it to do lol
if(event.getItem().isSimiliar(smallAxe))
You're checking an item stack against item meta
and that too ^
ohh lol, that would make sense just way to early for this lmao
well instead of an explosion what about striking an entity with lighting when left and or right clicked? i looked and didnt see no clicked entity action
probably a separate event
@EventHandler
void onSmallAxeEntityHit(EntityDamageByEntityEvent event){
if(event.getEntity() instanceof Player && event.getDamager() instanceof Player){
Player whoHitEntity= (Player) event.getEntity();
Player whoHit = (Player) event.getDamager();
whoHitEntity.getWorld().strikeLightning(whoHitEntity.getLocation());
whoHit.setSaturation(20);
}
}
``` i came up with this, now if used on the weapon how could i do that..
im trying the get item, but i get red underline on it
and what's the error you get from that?
nothing
did you register the event
yeah
it works
it strikes lighting
but my problem is making it work only with the axe, i just dont know how to do that with a entitydamagebyentityevent
Check the item that the damager holds, if the item is the axe, then strike lightning
everytime i hit tab on getInventorywith detDamagerit adds a lot of stuff like this extra
(Player) ((Player) event.getDamager()).getInventory()
``` and when i remove the extra player im getting an error and when i finish what i am writting i still get that red line
what IDE
im using IntelliJ but dont worry about it im just a idiot
i was trying to reference that in a variable
instead of an if statement
player.setSaturation((short) 20);
``` And does this like not work
or is saturation like the health and its actually 10
are you trying to set the player's food?
It's actually Player#setFoodLevel
then what is saturation lol
I don't know haha, but this is from the javadocs.
Saturation is a buffer for food level. Your food level will not drop if you are saturated > 0.
so like you ate to much at dinner
so it doesnt work with the faster full hunger regen, any way to make that work?
what i mean like is if you eat food till your full it used more hunger to heal you faster
what is the max size a inventory can have?
54
alright thanks
you mean chest inventory right?
player is 9x4
yes, to create a gui
what is fortune called in the code
LOOT_BONUS_BLOCKS
SO I made it where I can get the item and ect ,I just need help to give the item from the command to another person. example
/give Billybob24 dirt 64
very weird, but thank you
declaration: package: org.bukkit.enchantments, class: Enchantment
when i am creating recipes will they show up in the green book?
and is there a way to add so my custom gold pickaxe can break anything
does anyone use maven in terminal here
without any IDE integration
how can i change maven project init root path
it always set the maven project in /home/ directory
player.addPotionEffects(Collections.singleton(new PotionEffect(PotionEffectType.FAST_DIGGING, 120, 1)));
``` When using this it only gives for 5 seconds instead of 120
is there a specific reason of why that is happening ?
its probably measured in ticks
mhm
20 ticks * 120 seconds = 2400 ticks per 120 seconds
try this
im not sure tho
check the docs
😃 good thinking lol
you will save CPU cycles
yeah it was in ticks
Hey quick question:
I would like to program a villager which, when clicked with a book written on it, changes its customname to what is on the first page in the book. Does anyone know how to query the string of the first page in the book?
So far I have already written the following:
if(NPC.getCustomName().equals("Villager")) {
if(player.getItemInHand().getType() == Material.WRITTEN_BOOK) {
if(player.getItemInHand().hasItemMeta()) {
}
}
}
thank you in advance
Cast ItemMeta to BookMeta, then String getPage(int page)
ok so should I make a new itemstack which is cast as bookmeta and corresponds to player.getItemInHand ?
ok i will try it
create a new itemstack
when using NMS which compiled jar is okay for distribution?
plugin.jar
plugin-remapped.jar
plugin-remapped-obf.jar
original-plugin.jar
with a book
Remapped
Ah, f*cking 1.17
thank you
If you have TagAPI on packets or NPC on 1.17 - say me
how can i add my custom recipes to the green book in 1.17
would that be correct?:
ItemStack Book = player.getItemInHand();
ItemMeta Bookmeta = (BookMeta) Book.getItemMeta();
String Name = Book.getPage(1);
because getPage gives an error cannot resolve....
that is because that's not how that works
number one
naming conventions
book, not Book
bookMeta, not BookMeta
number two, book is an ItemStack, and does not have book related methods
bookMeta does
that's the whole reason why you're getting it in the first place; to access the book related methods
- javadocs for you
i think they did try it and did see a compilation error
what is the best way to wait in an event handler
in the event wait x seconds between calls
wait i worded that weird
on event triggered, wait x seconds within the call to the event handler
Runnable doesn't work?
idk how to use it
when exp bottle breaks, take all the exp orbs around the exp bottle (up to a few ticks after the bottle has broken) and summon lightning on them
Oh
Yeah just a simple runTaskLater runnable
int timeTicks = 40;
Bukkit.getScheduler().runTaskLater(plugin, () -> {
// Code to run later here
}, timeTicks);
ty
what did it change to now or is this bork atm? It worked in 1.16.5 and earlier
org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.Levelled
ref Cauldron btw
lets say i have a yaml file i want to use as my config.yml saved in the resources folder or smth:
thing: true
another_thing: 9 # this is a comment yay!
idk:
subthing1: "hello"
subthing2: -5.8```if i were to use `saveDefaultConfig()` or smth wold it make this the default config?
sry for very basic question
hey guys,
not sure where I should post that, but what can I do ?
<plugin_name> has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Update Java on the server or downgrade the target version when you compile the plugin
?java16
Install Java 16 at https://adoptopenjdk.net/?variant=openjdk16&jvmVariant=hotspot
Are you on Windows
yeah
So what you need to do is change the path enviromental variable
oh well just add it then it's fine
You have to put your default config into the src folder named config.yml and calling the saveDeafaultConfig(); will copy it to the plugin folder, if it doesn't exist yet.
Add a new entry with the path to the bin folder of your Java 16 installation folder
^^
so i have to put it in the src folder
not the resources foldder
but the resources folder is in the src folder
Yes
where in the src folder must it be put?
The one you have plugin.yml in
but that is the resources folder
about to cry
requires java 16
its installed?
is that 1.17 or 1.16
1.16
guess i gotta move
im hating cauldrons today
Then put it there
The config.yml, you want to be default
What version of spigot are you using?
it's ok i changed to 1.17
Aight
Yes
im trying to build with maven but i get this error
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project Test: Fatal error compiling
try addding ```xml
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
nope
You need to find the full error
how would i get that?
it will be in teh build log
@eternal oxide
theres more to it than that. Thats just the summary
invalid target release: 11.0.10
Are you sure you added this
nm, its all in one silly line
where do i find it?
?paste your pom
No that's it
paste your pom
uhhhh, im gonna be honest. its not exactly a spigot plugin :/ but tis still maven
im just really stuck
it has to be your java.version
Fatal error compiling: error: invalid target release: 11.0.10
Any idea on if you're able to do a custom mob spawner item or do i need to use NMS for that 🤔
so do
<java.version>11.0.11</java.version>
?
11.0.x is nto a valid java version
11 doesnt work either so just making sure
delete the config section from you compiler plugin
you have a source and target in yoru properties already
you deleted the whole config section from your compiler plugin?
the
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
part right?
yes
yea didnt work
Now this is wrong
is the error now exactly the same or different?
Set it to 11 or 1.8
he's deleting that
same
still saying 11.0.10 in the error?
it said that?
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project MinestomAirConditioner: Fatal error compiling
thats the only error in the final part
what is the very next line?
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project MinestomAirConditioner: Fatal error compiling: java.lang.NoClassDefFoundError: com/google/gson/JsonParseException: com.google.gson.JsonParseException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
i found more text
thats better. Its a different error
maybe i shouldve slept before going into a help channel
because 99% sure that error was there the whole time
i just added
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
and it worked
its not actually my plugin so no idea if it used that
teh compile error says it does
From what I can tell NMS has to be used... rip
It's like that with spawn eggs and stuff too
This is probably off topic, but anyone worked with the Streamlabs socket API before?
I've tried to update my plugin to 1.17
But I get the error while building the artifact:
class file has wrong version 60.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.```
`java: cannot access net.minecraft.core.BlockPosition`
Is there anything I can do?
what's the difference if creating a spigot plugin using Maven and not using Maven?
Thats a java version error
I've updated my JDK to 16. Do I have to do anything else?
what IDE?
IntelliJ
No idea on IJ, but have you updated to use 16 in your pom?
16 is required for MC 1.17
I don't use Maven lol
then ensure your project is configured to use 16
tbh I dont know how to configure it to 16
Open project settings
The error is saying he's using 52 and the class (an MC class) is using 60)
Does not show any heads in the gui, why so?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
nvm found cause
nvm yet again still aint no heads
how can I change the colour of item lore
like as in ChatColor.XYZ?
you don’t need to create a new array list for the players, you can just iterate directly over that collection
and strip it before
well yeah
and also your for loop is wrong
@fiery inlet
meta.setOwningPlayer(player)
yeah i fixed that part
but new problem
it doesnt like plugin.yml xd
well that’s descriptive
name: BarrySk
version: ${project.version}
main: me.barry.barrysk.MainClass
api-version: 1.16
authors: [ barry ]
description: First plugin
commands:
gui:
description: hi
gravity:
description: hi
@Override
public void onEnable() {
getServer().getConsoleSender().sendMessage("DEBUGGER: 02FE");
getCommand("gravity").setExecutor(new BanCommand());
getCommand("gui").setExecutor(new GUICmd());
getServer().getPluginManager().registerEvents(new OnKick(), this);
}
and what’s the problem?
does it exist in the compiled jar
i guess it doesnt anymore lol
well you can check
yes
Using Maven or artifacts?
as in that’s the task you’re executing?
u sure it's here?
are you actualy using the maven menu in InteliJ? Many use Artifacts and don;t realize that doesn;t run maven
under lifecycle in teh Maven menu (right of screen)
and i use original or not original jar file?
I guess you are not shading anythgin so orginal
wat
for the skinvalue to be the player or?
for the skin to be the player's skin, yes
doesnt seem to be a thing
declaration: package: org.bukkit.inventory.meta, interface: SkullMeta
you might need to cast to SkullMeta first
yeah because you're casting back to ItemMeta
^^
ye
and
what about the get Itemmeta thing
SkullMeta meta = pHead.getItemMeta();
and getSkullMeta no difference, doesnt work with it
oh nvm
SkullMeta meta = (SkullMeta) pHead.getItemMeta();
Hello! Can I have net.minecraft.server maven repository?
It’s your maven local repo
Player whoToKick = (Player) e.getCurrentItem().getSkulMeta(SkullMeta).getOwningPlayer();
this is what ive got now, doesnt seem to work
how do i get the owner of the skull in the inventory click again
that's not what you've got.
getSkulMeta is spelled wrongly and doesn't exist so that wouldn't compile
theres a .getSkullMeta ??
Nope
😔
SkullMeta meta = (SkullMeta) e.getCurrentItem().getItemMeta();
Player whoToKick = meta.getOwningPlayer().getPlayer();
maybe this
well if that current item has a player assigned through setOwningPlayer that would work, yes?
ima try
haha it works great
so smart xd
How is it devs make it so that on startup, it checks for new updates and updates automatically
you write a BukkitTask or Runnable that checks the SpigotMC API for the latest version on their site
then match that against the JavaPlugin plugin description
link to the api btw https://github.com/SpigotMC/XenforoResourceManagerAPI
It's 46 lines in my project
ah still later project
only testing
someone said something about optimizing this
ArrayList<Player> list = new ArrayList<>(p.getServer().getOnlinePlayers());
yes
Depends
getOnlinePlayers return a Collection, you don't really need to make a new ArrayList from that
If it’s just a temporary usage then it’s technically fine
im basically only using it to get the index and whatever player is in that index
u know, to put in gui
Well do u keep the list for a long time?
well after i set the owner then no
why care about the index though?
#getOnlinePlayers has no specific order
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
That’s why he uses an array list?
for (Player p : p.getServer().getOnlinePlayers()) {
}
so now i use p instead of i?
you can just do
for (Player p : Bukkit.getOnlinePlayers()){
}
Uh well the variable for Player needs to be smtng else but yeah
What?
You have the player now
just replace list.get(i) with p?
His p variable is already declared to be his plugin instance
1 letter variable names 😬
was just for a quick example 🤷♂️
changed it to player
wat
basically:
don't name your variables by single or by a small amount of seemingly random characters
call a Player variable a player or give it some extra description
like the player who clicked the block in an event, call that playerWhoClicked or something like that
mhh im used to doing that in skript
but i see alot of people using p and small stuff but ok ty
still bad practice
will do forth
Don’t follow random peoples code
were technically random people too
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
what you thinking now
Hmm yeah that’s true I guess
remove ArrayList<Player> list = new ArrayList<>(p.getServer().getOnlinePlayers());?
it's not used
Also Barry the p in the for loop, name it to like tempPlayer or smtng 
one thing thats very annoying though, is it keeps saying stuff is deprecated
im sorry did I miss something? p.getPlayer()
onlinePlayer would fit best here
huh oh yeah i know
changed
there we go
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
new one
oh that's a function inherited from OfflinePlayer, lmao
yeah I mean doesn't that look quite a bit nicer?
mhh i used it for some reason cuz i looked at the array as strings or somethng
even though i parsed through as player object
mrs darth hello
Tomato ideally you might have to provide the library classes yourself which can be done with shading it in
@fiery inlet I'm not telling you to use it, but Player#getDisplayName exists, which will return the modified name of a player, possibly including colour or whatever, if you want to use it.
Declare it as a dependancy
He probably already declared it in his compile classpath
just not shaded correctly probably
?
doesnt that also include prefix/suffix
yeah, I think so
i aint want dat xd
mhh i know (: ty
Isn't it javacv-platform?
i want to change color of the POTION_SWIRL in 1.8.8, how can I?
but does it run? no it does not
how i can add color to potion_swril help (1.8_
anyone know why alot of stuff is just deprecated for me
it works fine but im just getting tired of stuff being deprecated
stop using 1.8 if you want support
cause it's deprectated. Hover over it with intellij or eclipse and it'll tell you why it's deprecated and what the replacement for it is.
1.8 bad
but i have no idea what that question is anyway
particle api pretty bad and is even worse in 1.8
isnt it literally messing with packets for 1.8
im remaking hypixel and 1.16 is ew.
remaking hypixel
why are you remaking hypixel
heard it ten thousand times
yep
fun
if you want to remake hypixel make it on 1.16 so it's actually playable
@fiery inlet Those are not deprecated for me. Are you maybe using an older or special Spigot version, or using Paper or such??
and actually make something uniquee
1.16.5 paper
paper api uses adventure components
that's why it's deprecated
theres no point in remaking hypixel for 1.8 when hypixel exists
how about remake hypixel for and with 1.16/1.17 features
soo nothing to do?
know SBS
?
you can ignore it or use components
what is components though
well you can use adventure, if you really don't want to see the stuff deprecated
you have no power to change anyone mind and never will
well if i code in spigot it will work in paper anyways most likely right
so how can you "add" color to like potion_swirl in later version of bukkit/spigot API
like 1.16 for example
you are right, the primitive stupidity of 1.8 will always exist
@fiery inlet They completely replaced all the BungeeCord Chat API stuff with Adventure's Components.
if you are not a hypixel fan, 1.8 always bad, but if you ask public about what version they want to stay on, they will said, 1.8
since you dont want to change your mind about using 1.8 why do you want help for 1.16? It wont translate to 1.8.
i play hypixel, I use 1.17
ew
very useful for parkour houses by the way
A new Minecraft Version should really just add some switch for players to be able to use the 1.8 pvp system.
Just so that all these people still using 1.8 just don't have to
1.8 is so badly outdated
it still good for vanilla gameplay
about 25% of hypixels playerbase use the latest version according to hypixel themselves
nope
why every community lose their players when updating
like cubecraft for example
6 years old
"not outdated"
cubecraft didnt lose all their players?
almost