#help-development
1 messages · Page 1699 of 1
on an armorstand
hopwever
gravity is disabled for the armorstand
and that breaks everything
Cause if i dont make setmarker true
then the player is hovering over the ground
rather than being on the ground
how would i get a number between for example 3 and 7? ive tried Random random = new Random(); return random.nextInt(lower +(upper)); which i found on a forum but its just giving me numbers that i didnt define
try this
100% working
:DDDDD
just joking lol
👾
fixed it btw ignore this
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(ExpBottleEvent e) {
Projectile ent = e.getEntity();
ThrownExpBottle b = (ThrownExpBottle) ent;
ProjectileSource s = b.getShooter();
Player p = (Player) s;
if(!(ent instanceof ThrownExpBottle))
return;
if(!(s instanceof Player))
return;
e.setExperience(0);
p.sendMessage("Тут может быть ваша реклама");
}
is it possible to check here with what name the player threw a bottle of experience?
hey, how is called an item on the floor?:o
.
.
p.getName
okay, thanks
how do I check the name of the bottle of experience that is in the inventory?
are you making a custom bottle of xp
so it's impossible?
?
get name
from inventroy
You make custom item?
Compare the distances between the previous location, which u checked and the new location
the bottle I throw has a name and lore
how do I check which bottle I'm throwing?
are translators that bad
how do I check which bottle I'm throwing?
okay
one sec
if (!item.getItemMeta().getDisplayName().equals("123))
return;
that is what i want, how to compare, if i can compare then i will check which is the nearest one
Location#distance(Location)
yea man but then how to save them into a variable if i do this?
wait arraylist?
wow thanks
put them into an array or an hashmap... seems kinda good
let me think
are you saving by name
yeah
U can do that as well
put them into an hashmap... compare them...
Map<String, Location> (HashMap)
hmmm
oh thanks everyone i think hashmap still the best option
Check which is the smallest distance between the previous and the new location, and if previous location distance is greater then new location distance then set the nearest location to be the new location
how is called when an item falls down on the ground?
or how can i know if an item is on the ground?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityDropItemEvent.html
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerDropItemEvent.html
declaration: package: org.bukkit.event.entity, class: EntityDropItemEvent
declaration: package: org.bukkit.event.player, class: PlayerDropItemEvent
i'm using that event, but i wanna get the location when it hits the ground
getItemDrop()#getLocation()
i just can get the location when it drops
that's what i'm talking about
it throws me the location where the item is right after the player presses Q
that's why i'm searching a way to get the items on ground
is this conditional or is it for all items
are the items gonna be dropped regularly?
hello i just wanted to know how could i add tab completion to a plugin's command
google "spigot plugin tab complete"
there should be a wiki on it
hi
if (BREAKABLE.contains(block.getType())
try this maybe @quaint mantle
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
event.setCancelled(UNBREAKABLE.contains(event.getBlock().getType()));
}```
?paste
https://paste.md-5.net/icoluyazad.java @shut wave
you can use simplechunk to store the chunk/itemschedule
if the chunk isnt loaded, remove it
when an item is dropped, if its in a custom hopper chunk, (SimpleChunk) add it to the itemscheduler associated with it
wait, did you just do this?
awesome, thanks
someone help me making configurable gui from config.yml pls
look at the source of some gui plugin ✅
copying code is legal?
*learn code is legal
Obviously he didn’t mean going to some open source code and steal everything with a copy pasta (:
Instead of copying I generally prefer transcribing
like looking at the code and typing it myself
what is this
https://paste.md-5.net/diguwufude.md
it's something with an ssl certificate
Everyone, is there a de facto update-checker snippet/library? What do you use?
choco has a gist
anyone know why this code
public static HashMap<UUID, Zombie> zombiePets;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
Zombie z = (Zombie) p.getWorld().spawnEntity(p.getLocation(), EntityType.ZOMBIE);
zombiePets.put(p.getUniqueId(), z);
z.setTarget(p);
return true;
}
is giving me this error?
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.HashMap.put(Object, Object)" because "instarespawn.instarespawn.zombiepet.ZombiePetCommand.zombiePets" is null
at instarespawn.instarespawn.zombiepet.ZombiePetCommand.onCommand(ZombiePetCommand.java:25) ~[?:?]
line 25 is zombiePets.put(p.getUniqueId(), z);
wait
it might be cuz i didnt initialise the hashmap
oh my god
it is
lesson learnt LOL
pro tip: don't make your map static
y tho
A static variable implies it will always be accessible and loaded in memory (and potentially cache)
People often just see it as "I can access it from anywhere" while in reality it's meant for stuff like constant values (Example: TICKS_PER_SECOND = 20;)
So just follow common design patterns like dependency injection
and make getters
PersistantData
The PersistantDataContainer API is a lot more recent
And generally made for persistant stuff
metadata might not save correctly
Hey so I am trying to create a mob corpse but then its super hard for me because I dont think mobs use craft player https://pastebin.com/N3XF41u8 this is my player corpse code
does this check if a player is using their firs
fist
if (p.getInventory().getItemInMainHand() == null) {
also how do i check if a block is a crop
System.out.println(e.getBlock().getType());
if (e.getBlock() instanceof Ageable) {
System.out.println("is a crop");```
only prints "WHEAT"
am i missing something
i've imported the right ageable
a Block will never be an instanceof Ageable
oh yea
block.getBlockData
i need to checks tate
look what interface Ageable is deriving from
yea mb
it's blockdata
should do
alright thanks
ill see how it goes
works
if (crop.getAge() == 7) {
b.getWorld().dropItemNaturally(e.getBlock().getLocation(), new ItemStack(crop.getMaterial()));
}
e.setCancelled(true);
crop.setAge(0);```
crop is an Ageable
why doesnt that work
hey I need some help
I am making a plugin and this is my first plugin
what the plugin does is that it stores all player chat in a file
named chatlog
String message;
message=(e.getMessage());
String finalmsg;
finalmsg=((e.getPlayer().getDisplayName())+": "+message);
write("chatLog",finalmsg);
}```
try{
String content = msg;
File file = new File(System.getProperty("user.dir")+"\\"+filename+".txt");
// If file doesn't exists, then create it
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file,true);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(content+"\n");
bw.close();
}
catch(Exception e){
System.out.println(e);
}```
but this doesnt work
does anyone know how to make actions work on 1.17 heres the vid looking for that (I put a time stamp) https://youtu.be/sdHi5N7-Yqk?t=247 ||answer previous question from Lenny first||
Did you register the listener?
System.out.println("=================================\nDiscord bot plugin has been detected and enabled successfully!");
System.out.println("Updating you if it is running or not, give me a second.");
getServer().getPluginManager().registerEvents(this, this);
}```
umm ig
Did you add @EventHandler
on your class ofc
.
yea that is done
Uhh is there a way to give an NPC armor?
(craftplayer)
cause I only have "getArmor()"
not set
I want to set the armor
hmm bro take a look at https://www.spigotmc.org/threads/spawn-armor-stand-with-protocollib-packets.234848/
He doesn't want Protocollib
oh hmmm
if the action in a PlayerInteractEvent is == phyiscal
is e.getClickedBlock() gonna have the thing that u trampled/pressed
I'm trying to modify log levels programatically (for hibernate (an ORM) and c3p0 (a connection pool tool)) :
What I've done :
private void modifyLogLevels(Level logLevel) {
Properties p = new Properties(System.getProperties());
//c3p0 connection pool logging level redefinition
p.put("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog");
p.put("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", logLevel.getName());
//hibernate logging level redefinition
p.put("log4j.logger.org.hibernate.SQL", logLevel.getName());
System.setProperties(p);
}
It works for c3p0 but not for hibernate. How to define hibernate log level in the context of a spigot plugin ?
My test is simply to start my server and to check if those "[INFO]" are still visible
Uhh is there a way to give an NPC armor?
(craftplayer)
cause I only have "getArmor()"
not set
I want to set the armor
Thank you
hi can i ask a little help? i am trying to code a plugin like discordsrv but when i try to run the plugin it says invalid plugin.yml but i have it
the problem is not that you don't have it. It probably contains an error (indentation / content). Try to validate your file using http://www.yamllint.com/
(or another validator https://www.google.com/search?q=yaml+validator+online)
um ok
Second option: your plugin.yml file is not included in the final jar file. Open your jar file using zip/7Zip/ another tool to check that it is there.
this is my plugin.yml
name: XDDCraft-Discord-Plugin
description: This is xddcrafts discord linking with minecraft plugin!
author: Hasibix
main: net.hasibix.xddcraftdiscord
version: 1.0
and the file is located in src/net/resources/plugin.yml
I personally always use /src/java/ressources/plugin.yml. The fact you have /net/ may underline another issue.
First, did you check that your built MyPlugin.jar contain the plugin.yml file ?
Is this actually your plugin class? net.hasibix.xddcraftdiscord
yes and folder is like this src/net/hasibix/xddcraftdiscord.java and the main class is also defined like xddcraftdiscord
so yoru main is actually net.hasibix.xddcraftdiscord.xddcraftdiscord ?
use java naming conventions.
If plugin.yml contains:
main: net.hasibix.xddcraftdiscord
Your class should be:
src/main/java/net/hasibix/xddcraftdiscord.java
But please use CammelCase as it is an important part of the good practices:
"XddCraftDiscord.java"
so in your plugin.yml
"main: net.hasibix.XddCraftDiscord"
classes start upper case
something like this i did
packages are all lower case, classes are capitalised.
?paste the full error and we can tell you instantly what your real issue is
I think you have you have all the informations you need here.
done
are you building with maven?
no?
then generally exporting will not export the resources folder
thats a maven/gradle thing
if you are building with Artifacts in InteliJ your yml files should be in the src folder I believe
oh how can i export resouces with eclipse
you are using eclipse?
oh
no but my idea is to use eclipse
ye me too
Then what are you using rn??
Ftr, IDEA works better than Eclipse most of the time.
(no one asked)
Pick whatever IDE you want/prefer to use then get help here when you are stuck
We recommend you use a built tool such as Maven or Gradle though. Both are built into Eclipse and InteliJ
secret thing for coding purpose because i dont have visual studio and my laptop cant handle visual studio or visual studio code my laptop can handle but not for much time my laptop crashes
We can;t help you with a "Secret" IDE
this fine?PacketPlayOutEntityEquipment am = (PacketPlayOutEntityEquipment) player.getInventory();
cause it doesnt seem to work
ok i use replit just to code then i will push it to my github then i will download the project and export it to the main plugin from my laptop (i am comepletely not sure that my laptop can even handle eclipse or InteliJ)
i will push in github after its done all coding thing then download in laptop because when i download the project directly from replit it removes some important files but when i use github it keeps the important files of the project
how would I go about detecting what files are in a folder?
help i cant find eclipse 32 bit version ;-;
ty
OHHHh
i forgot about that-
is your laptop only 32 bit?
yes ;-; thats why i always cri
yeah good luck with that, 32bit is mostly dead
yes ;-; also windows 7 which is completely out of support
I'm on win7 (64) best windows OS
oh
@eternal oxide
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(ExpBottleEvent e) {
Projectile ent = e.getEntity();
ThrownExpBottle b = (ThrownExpBottle) ent;
ProjectileSource s = b.getShooter();
Player p = (Player) s;
if(!(ent instanceof ThrownExpBottle))
return;
if(!(s instanceof Player))
return;
e.setExperience(0);
p.sendMessage("Тут может быть ваша реклама");
}
is it possible to check here with what name the player threw a bottle of experience?
e.getPlayer()
i have a win10 64 bit pc but its destroyed my pc motherboard have short circuit problem so sometime my pc starts and sometime it does not the problem is from like march-april and its still not fixed
No. Name bottle
its an ItemStack so get the name from its meta (probably)
You can't cast random objects into completely different ones
ExpBotrleEvent?
This entity
are you trying to get this name from an item in your inventory or the bottle in the world?
oh yeah I found out I coudl just
corpse.getBukkitEntity().getInventory().getArmorContents();
but like I wanna assign it to my Player player
it needs a itemstack
is InteliJ available for 32 bit?
Afaik no
so i just researched
an item stack only contains items
so i get it
but then how do i get the item stack of the players armor
Wat
Inventory
then its an ItemStack, get its meta and read its display name
all i can get is player.getInventory().getArmorContents
but apparently thats not a item stack
cause it doenst work
contents is an array
Okay, thanks
will do!
well then i think the get armor contents will be array
I recall that from command blocks
yes!
bruh
bruh tf ur doing on a 32 bit system
you cant rly run much development related under 4gb ram
ye lol
oh
even intellij loves eating like 2gb ram
so got it working only to find out it wont render it
i see that
bc it has an inv
i have 4gb in my laptop ._.
so it gives me the helmet i was wearing
go ham and install a 64 os
if it even lets you anymore..
a boy needs to buy a ram stick theyr cheap af
its a 32 bit laptop, not a lot of point in upgrading it.
you can install manually a 64bit os yourself
ik
its just.. torture for the laptop unless you buy ram
not if the CPU is 32 bit
i know to upgrade win7 32 bit to win10 64 bit
The 32-bit processor was the primary processor used in all computers until the early 1990s.
wut
i doubt ur laptop is 32bit locked
What make/model is the laptop?
is this bc of opti? heres my code for only the helmet corpse.getBukkitEntity().getEquipment().setHelmet(player.getEquipment().getHelmet());
its an npc
its not packet based right?
so it doesnt have getEquipment
it is
yeah.. that wont work
and my point..
no i know how to do but actually its my dad's laptop so he doesnt gives me permissions to do it ;-; he thinks if we change windows every data will be lost ._.
you cant just getbukkitentity on a inexistent entity
wdym
you have to send the armor through packet
1 sec
public static Packet sendEquipment(int entityId,EnumItemSlot slot, org.bukkit.inventory.ItemStack item){
List<Pair<EnumItemSlot,ItemStack>> equipment = new ArrayList<>();
Pair<EnumItemSlot,ItemStack> pair = Pair.of(slot, CraftItemStack.asNMSCopy(item));
equipment.add(pair);
PacketPlayOutEntityEquipment equip = new PacketPlayOutEntityEquipment(entityId,equipment);
sendToAll(equip);
return equip;
}
1 piece of item it should have yes
want full armor just call it 5 times
however this returns a packet so just send it after
thats sendToAll method
remove sendToAll method then call the method itself while sending
playerConnection.sendPacket(sendEquipment(....))
oh ok
I have a bunch more problems here
let me try to fix them first
btw on "pair" shoudl I import it from minecraft or bukkit?
just comment it in the ide?
isnt it CraftPlayer
((CraftServer) Bukkit.getServer()).getServer(),
((CraftWorld)player.getWorld()).getHandle(),
gameProfile);
corpse.setPosition(player.getLocation().getX(),player.getLocation().getY(), player.getLocation().getZ());
Arrays.stream(player.getInventory().getContents()).forEach(itemStack -> {
corpse.getInventory().pickup(CraftItemStack.asNMSCopy(itemStack));
});```
why when i use dropItemNaturally method, if item has any enchantments it wont get applied
nvm i saw the code your going nms route
are you sure your properly setting the enchantments?
ye
let me try adding it to inventory
guys can i install gradle in 32 bit windows 7?
as i said.. are you properly setting the enchant?
you will get limited support for gradle.
post the code
i can't spot any difference but it doesn't act the same
i'm trying to analyse it
oh boy the statics
i should make it cleaner woops
then what should i use to make plugin in a 32 bit windows 7?
eclipse may let you
stack.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
wait
ItemMeta
bruh worked thanks
what should i use to make plugin in a 32 bit windows 7?
32 bit was dropped by almost everyone long ago
probably a legacy version of eclipse
you can upgrade to win10 64bit for free you know
yes but i dont have permission to
the newest 32 bit version I can see is from 2010
then dont code if its not your own hardware..
will not support maven
Hiya, I'm using 1.8.8 and the Player#sendTitle() method does nothing. Am I doing something wrong?
Newest I can find that supports maven https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2018-09/R/eclipse-java-2018-09-win32.zip
can you show code
using 1.8.8 might be what you are doing wrong 👍
hmm yeah error after error
uhh
any other way?
player.sendTitle("Hello!", "This is a test.", 1, 20, 1);
found this example on spigot from
its likely changed in 1.17 for the name
1.8.8 ver only takes 2 params
my apology
i should have checked doc
.
i made some code there looks very similar but
it does different things
how do i spot the tiny difference in my code?
p.sendTitle(ChatColor.YELLOW + String.valueOf(countdown), "");
I need to lol
hmm thats strange
will Title packet work for you maybe?
i quit it does not work
If I can use ChatColor.YELLOW + String.valueOf(countdown), then yes
But examples of that I've seen can't do that
it is possible yes
Could you send me a code example?
hmm 
?
gonna be hard to find a code example for 1.8.8
+1
almost 7 years old lol
im surprised spigot didnt fully drop 1.8 yet like paper
like the dependency?
oh yeah
because 1.8 should be dead
Everyone what is the most prefer way to make command?
the normal way?
I've found this:
IChatBaseComponent chatTitle = ChatSerializer.a("{\"text\": \"" + text + "\",color:" + ChatColor.GOLD.name().toLowerCase() + "}");
PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, chatTitle);
PacketPlayOutTitle length = new PacketPlayOutTitle(5, 20, 5);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(length);
How can I create the IChatBaseComponent from just a string?
I use ACF
that.. was cringe..
very
I'd've made my own compile-time-based framework by now but I'm too lazy.
👎
I did that myself but i honestly dont see any benefit over using ACF
ACF basically does everything and anything you need
Reduced reflection costs?
IChatBaseComponent chatTitle = ChatSerializer.a( String here?);
No dependency on an external library?
Simplicity and customizability as it is your own code?
eh
I'm a bit of a performance junkie so like, reflection is the bane of my existence sometimes.
Which is why annotation processors are beautiful ❤️
(For another example: Dagger > Guice)
.
use it then why you asking us lol
Because I don't want to have to create it with JSON
Actually I don't think that's JSON.
It might be SNBT :)
^^
gimme a sec to test
to be 100% sure
still
AKA
"Mom can I have JSON?"
"We have JSON at home"
JSON at home: SNBT
So why not use the api
wasnt working for them
I have no idea how I'd do that
Oh well dead versions
For this particular thing
Sounds like you neee to learn some Java then?
?java
I mean you have most of the code already
It's learnjava
99% of the code is there you just have to wrap it in a function
No. My Java is fine. I just don't know how to go about creating a function for this particular use-case
Just put a variable in a string of json
that is a func
(Snbt)
public sendTitle(Player player, String text, ChatColor color, int a, int b, int c){
IChatBaseComponent chatTitle = ChatSerializer.a("{\"text\": \"" + text+ "\",color:" + color.name().toLowerCase()+ "}");
PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, chatTitle);
PacketPlayOutTitle length = new PacketPlayOutTitle(a, b, c);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(length);
}```\
simples
stromg
What about for multiple colors? I'd have to modify my function for every ChatColor
stronk
you just include chatcolor in the parameter?
Just use the old color codes
With translateColor or what ever thats called
But if I want a string that has multiple colors...
You're on a legacy version so use legacy stuff
That work work for SNBT
oh colour is a thing in the snbt
yes
Yes
do i smell 1.8.8
*won't
Chat messages are snbt too ya know
Ok I've had an idea:
Can I just add a , to the SNBT to add more or is it more complicated than that?
can't you just use colour codes
You can
no
?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.
why send that ._.
Unless I can just remove the color part from the SNBT and then add the color codes to the text string?
thats what we've been saying
True although iirc guice tries using unsafe unless you’re doing something like field injection, tho Ig the counter intuitive errors guice may yield isn’t nice 😄
org.bukkit.plugin.AuthorNagException: No legacy enum constant for FIRE_CHARGE. Did you forget to define a modern (1.13+) api-version in your plugin.yml?
Getting this error when I try to start my plugin
isn't the error pretty self explanitory
idk what to do i am new
api version: <spigot_api_version>
I put this in plugin.yml?
ok
e.g. 1.16.5 would be api-version: '1.16'
well what is the error
java.lang.IllegalArgumentException: Plugin already initialized!
it doesn't show any other error
Shows this in the error line
where do i do that?
You don't. you already are
PacketPlayOutTitle in 1.17?
Easier to just use the API methods past 1.12 for sending title.
How would I be able to override a custom inventory from opening?
public void onInvOpen(InventoryOpenEvent event) {
if(event.getInventory() == CustomInventory)
event.getPlayer().closeInventory();
}
hey so i couldnt find any player event that removes set amout of levels from player there is only set can some1 tell me how to remove
just send part of the code please
what EnumTitleAction.TITLE changed to in 1.17?
Levels?
You mean EXP?
yes
What are you trying to do exactly??
when player click in gui (already done) it removes like 5 levels off the player
or xp
Plugin Version?
What do you mean?
What Minecraft version is your Plugin for?
1.17.1
?jd
[14:44:00 WARN]: Nag author(s): '[]' of 'SimpleHeal' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[14:44:00 ERROR]: Error occurred while enabling SimpleHeal v1.0 (Is it up to date?)
java.lang.IllegalArgumentException: Plugin already initialized!
@formal prawn uhh need help? 😂
yeah 😦
?paste the full error
Free to call? I can help quickly
It’s a pretty simple warning
You’re using System.our/err when you should be using the Logger
Like it literally spells it out
Is it your plugin that you coded?
ignore that, its not your issue
yeah
Your issue is you’ve seen to initialised your plugin twice
ohhhhhhhhhhhhh i just add minus in front of it
If you’re free to call I can help? Just easier to explain
my bad thanks
sure but i can't talk
No worries
how to make player shoot arrow just like from bow but without bow?
Player#launchProjectile
ty
?paste
I'm sorry to ask again but I can't find a solution to this issue:
I'm creating a lib I will use in multiple plugins and that connects to Hibernate : DatabaseLib.
I've made a simple plugin to test this lib: DatabaseLibTest.
Now I try to configure the log levels programatically (for hibernate (an ORM) and c3p0 (a connection pool tool)) :
I used System Properties and it works for c3p0.
I tried to do the same with hibernate. It does not work. https://paste.md-5.net/gesoqapuhu.java
How to define hibernate log level in the context of a spigot plugin ?
I don't even know on which logger hibernate based himself at runtime :/
I'm really lost with this issue :/
This is more of a Code editor thing but how do i selecet text and replace every like number in it with another
i got a few problems:
- right click not works when i clicking air with empty hand (i am using PlayerInteractEvent)
- It's kinda too fast, how to make it like normal arrow (i mean what is normal bow's arrow velocity)
ALT + J on intellij
Use another PlayerClickEvent
what editing software do you use ?
- don't know, do multiple tests to find out.
I noticed that the RIGHT_CLICK_AIR type of PlayerInteractEvent is not called when you right-click air while your hand is empty. Is there any way to...
With ALT + J
- Select the part of the text you want to replace in one line
- Press ALT + J as many time as required to select the text in every lines you want
- Write the new text
- Press escape to finish multiple edition
With CTRL + R in this file
With CTRL + SHIFT + R in multiple files
i was thinking like i paste text but replace the 6 with 7 at one
i am canceling EntityShootBowEvent but draw animation still playing
The client does not send a packet when it right clicks with nothing in its hand unless you are clicking a block.
nvm
Sure because shooting is not the same as drawing.
than how to make bow not work at all
Cancel the PlayerInteractEvent.
ok
still not working:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
if (item.getType().equals(Material.BOW)) {
event.setCancelled(true);
player.launchProjectile(Arrow.class);
}
}
- Hibernate already provides connection pooling.
- Hibernate uses SLF4j. Try setting the log level of "org.hibernate".
Is this event registered?
Get his inventory and add an ItemStack
yes, cus the launchProjectile working (it shooting arrow when i starting draw bow)
Hm. Maybe drawing a bow is client side.
Workarounds
- Set the bow to a different item for one tick
- Cancel the bow shooting instead of the drawing
i am pretty sure its is possible to do cus on hypixel's skyblock there is items like juju shortbow which shooting arrows and not drawing, and also canceling shooting not works, ill try 1st
Those are almost certainly not bows but other items reskinned as bows.
is there a method that checks the number of players on the server?
wdym, without any resource pack it looks like simple bow
Get the online player list and call .size() on it.
and its id is "minecraft:bow"
There seems to be some issue with colored displaynames being "seen" right
When I try to find this item in an event it doesn't "see it"
ItemStack sv = new ItemStack(Material.GLASS_BOTTLE);
ItemMeta svMeta = sv.getItemMeta();
sv.setAmount(1);
sv.addUnsafeEnchantment(Enchantment.LUCK, 1);
svMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&5Soul Vial"));
svMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
sv.setItemMeta(svMeta);
I have an exact replica in my inventory
But it never detects it as the same item
I'm pretty sure it's an issue with the naming because just checking the enchant, flags, and material works
Guess you can start printing values and see what's different
Is there a way to get all the metadata a player has ?
I've tried protocollib to make an eventlistener, but that didnt seem to work
The weird part is that I did and it's exactly the same
How are you comparing them
If ItemStack in hand isSimilar to ItemStack
Is there any inventory event if a player changes slot?
If they go from slot 9 to 0 for example
[17:12:09 INFO]: Player: Elephant_1214
[17:12:09 INFO]: Clicked Entity: ENDERMAN Age: 219
[17:12:09 INFO]: Item: ItemStack{GLASS_BOTTLE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"dark_purple","text":"Soul Vial"}],"text":""}, enchants={LUCK=1}, ItemFlags=[HIDE_ENCHANTS]}}```
Send the other item too
The ItemStack that it's supposed to look like?
Yeah, the one you're comparing it with.
This
The stack size can be ignored because isSimilar is there
Print it in the same format though, that's how you should compare.
Okay
I have the feeling that it'll have §d in the name or something stupid that should have been translated
- Hibernate documentation said that changing the connection pool is recommended in production. That's why I started using c3p0.
- I'm sorry but I'm not used to logging systems. Where to define such property ? In System.Properties I tried to define both org.hibernate and slf4j.logger.org.hibernate but it has no impact.
PlayerChangedMainHandEvent
That's for changing the main hand in the client settings
Ok thank you
#getNewSlot(), #getPreviousSlot()
Perfect
Can't think of a valid use case for it tbh but it exists
I also feel like PlayerItemHeldEvent could be named a little better but 🤷♂️
does anyone knows static method of ClassLoader -> registerAsParallelCapable()? what does it do? and also in the java docs its says register as parallel capable 🙄 (i admit sometimes java docs are useless)
since i seen the class PluginClassLoader in bungeecord source code does have it in static block
// taken from bungeecord source code
static
{
ClassLoader.registerAsParallelCapable(); # <----- THIS!
}
public PluginClassloader(ProxyServer proxy, PluginDescription desc, File file, ClassLoader libraryLoader) throws IOException
{
bump
Your TPS would drop every time you got it if you got all of it
that's another issue, but I'm wondering if there isnt a method that I could use to just get the meta of one specific player.
And the docs are confusing aswell, since they say that metadata is stored within nbt, but then it isn't ...
I don't see anything other than adding a custom meta tag and pulling it
It seems like Player has getMetaData
Nope, not there anymore
Wait
the player has #getMetadata(String s) and that "String s" part is the annoying bit, since I need to specify the name of the metadata, but then I'd need to make a listener for when the player gets metadata assigned (that was the Protocollib thing I was trying) and just store the name for later use, or get it some other way.
My dumbass is looking at player events
wait, so there was once a method to just get it all without specifying a name?
Ive used it to detect scrolling up and down for size selection.
No no I meant the switching of main hands
Ah
No, I was being stupid and looking at events that have Player
It's there
Why do you want a players metadata? Everything vanilla related can be changed via the API and data should be stored in his PersistentDataContainer or as ScoreboardTag anyways.
is this loop gonna check for every player on the server?
for (Player player: Bukkit.getServer().getOnlinePlayers())
I dont know who asked earlier but dont use this to count the players online.
actually how can i send a command in server console?
yeah i'm probably not
Bukkit.dispatchCommand
n0
?
🤔
Damn should have used that earlier, would have eased my suffering.
Thx
lol
Server#dispatchCommand 😎
Uhm. Thats literally the same. Bukkit uses the internal server instance to delegate the method...
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say hi");
Server is better idk
thx
How? It is literally doing exactly the same.
This looks like a waste of time to me:
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "say hi");
instead of just
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say hi");
@lost matrix they should give you the helper role
When no `` code blocks on mobile
bump
i want to make a command to activate a specific class and another one to deactivate the class
how can i do that
A class with events or something?
Either way, you could make a command register and unregister an event/command
no just a normal java class
That doesn't really make sense
i mean without events or commands inside
So what are you trying to make?
what's the best way to prevent a player from joining and displaying a message on their screen if they try?
im kicking the player in PlayerJoinEvent rn, which is not ideal, since a join message is still dissplayed and some other plugins go crazy if the player is kicked in joinEvent
I know, but activating and deactivating a class doesn't really make sense
I also can't think of any use for that since you have to call a function in it to use it anyway
i want a class to run the code inside it until i use the disable command
specificly a class that have a timer and a timerTask
How do you retrieve the key/value pair from the Configuration (Bungeecord)?
Currently I'm retrieving the section I need, like this:
commands = configuration.getSection("commands");```
but I can't get specific key/value pairs/ iterate through them
Activating and deactivating a whole class doesn't even make sense
Nothing in there is being run until you call it
bump
iirc this one https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/AsyncPlayerPreLoginEvent.html
declaration: package: org.bukkit.event.player, class: AsyncPlayerPreLoginEvent
#setLoginResult() and #setKickMessage()
ty!
It does return null
getKiller() only returns a Player so if a Creeper or natural causes killed the entity, it's null
thanks
Any help with this, can't find much online
what do you mean
you mean getting something like
hello: "hi"
?
ore a section
and loop through it
I have this yaml file
commands:
- discord:
command: /discord
types:
- TEXT
text:
- 'Click here to join our Discord server!'
hover:
- 'linktodisc'
link: 'linktodisc'```
I would like to retrieve all the commands inside "commands" and their details
i guess the method getKeys will work
Haven't used strict languages in a while so I'm confused 😄
I tried getKeys but when I try to iterate, I get
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class net.md_5.bungee.config.Configuration (java.util.ArrayList is in module java.base of loader 'bootstrap'; net.md_5.bungee.config.Configuration is in unnamed module of loader 'app')
Object lists are always awkward to work with.
There should be a getList() method, though I'm not entirely familiar with Bungee's config API
A List<?>
i remember intellij turning this in to other symbols and making it cool
was there a theme or something doing it that is removed ?
is there any method to add xp or i should just get the current xp and + it ?
put there player.getExp + amount
GetList worked well. Thanks a lot
this.commands = this.configManager.getConfig().getList("commands");
for (Object command : this.commands)
{
getLogger().info(command.toString());
}```
👍
then to add them to the command suggestions use the PlayerCommandSendEvent
if the size is 0, does it return null or smthng
so Im going to make a revive plugin
after u die u are put in crawling mode for 10 seconds
if no one revives u die
to revive u sneak near downed player
but how do I set a player to crawling mode
like is it
player.setanimation
oh wait ill use the "internet"
You should be able to answer that yourself by looking at the return type and/or the javadocs of java.util.Collection:
https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html#size--
Ill send you a util class that handles experience.
'1':
PosX: 54345.0
PosZ: 4999.0
Border: 100
LetPlace: false
LetBreak: false
LetHurtMobs: false
LetHurtPlayers: false
LetHurtTeamMembers: false
LetOpenDoors: false
LetInteractAllBlocks: false
Exceptions:
c2c9cf65-4ccf-4733-a0c0-d2378a5bd5f5:
LetHurtMobs: true
LetHurtPlayers: true
LetHurtTeamMembers: true
LetOpenDoors: true
LetInteractAllBlocks: true
``` is it better to have keys for each value or convert '1' to a map
is there a way to force a plyer to swim with no blocks needed
dont do flags like thatoˇ
just use lists
- CAN_PLACE: false
etc
you mean maps right
i mean dont make flags like that for regions
I dont really understand anything from that
so I will make a map for this
is it ok
You have 2 Options.
Either properly implement ConfigurationSerializable and just use a List of your Object
or have meaningful keys for your Object. Indexing the values like this is not a clean approach.
How does your data look at runtime?
Ok lets take a step back. What are you trying to achieve here?
Protecting areas?
yes
Ok how do you check if a certain Location is within an area?
Math.abs(blockLoc.getX() - borderBeaconData.getInt(key + ".PosX")) <= 100 && Math.abs(blockLoc.getZ() - borderBeaconData.getInt(key + ".PosZ")) <= 100)
thought this would be better than vectors
Very first thing you should do:
Dont use FileConfigurations on runtime.
When the server starts -> Load all data into variables and use those instead of getting values from the config over and over again.
Do you have more than one area?
yes, a file per world ```java
File[] perWorldFiles = {x};
FileConfiguration[] perWorldData = {YamlConfiguration.loadConfiguration(perWorldFiles[0]), YamlConfiguration.loadConfiguration(perWorldFiles[1]), YamlConfiguration.loadConfiguration(perWorldFiles[2]), YamlConfiguration.loadConfiguration(perWorldFiles[3]), YamlConfiguration.loadConfiguration(perWorldFiles[4])};
public FileConfiguration getWorldData(int i) { return perWorldData[i - 1]; }
public void saveWorldData(int i) {
try {
perWorldData[i - 1].save(perWorldFiles[i - 1]);
} catch (IOException e) {
getLogger().severe("WORLD DATA SAVE ERROR");
}
}
this is in the main class
I use these everywhere
Yes. Dont do that.
Still not able to configure hibernate log level in my library / in the plugin calling my library.
:/
Performance. Maintainability. Readability. Key veracity. There are a lot of problems when working with configs on runtime.
Is there another place than system properties where I should define logging levels ?
Tried something like this?
Logger.getLogger("org.hibernate").setLevel(Level.OFF);
If this is that simple I will laugh and cry at the same time 😄
Will try
Object orientation. Create new classes.
For example
Create a class called Area which has fields like Location middle and int borderX etc. Then use proper Objects instead of
rummaging around in your config all the time.
Not working :/
Maybe try "org.hibernate.SQL"
If that doesnt work then i would have to search around.
Using NMS?
I dont know about 1.15 but the general Idea is:
- Tag the ArmorStand as invisible
- Get its DataWatcher
- Create MetaData packet
- Send it to player
EntityArmorStand entityArmorStand = ...
entityArmorStand.setInvisible(true);
boolean forceFullUpdate = true;
PacketPlayOutEntityMetadata metaPacket = new PacketPlayOutEntityMetadata(
entityArmorStand.getId(),
entityArmorStand.getDataWatcher(),
forceFullUpdate
);
// Send packet to a player
@quaint mantle
Why ping me .-.

@lost matrix in despair I ended up testing everything with no result : https://paste.md-5.net/alevimapeq.js
how could I access a getter without filling in the values for the constructor?
since they are already set
https://paste.md-5.net/otociqelip.cs i getting this error on thread how can solve it
Do you have an instance. If not they aren't set yet
(Assuming they aren't static)
yes
well what I have is an interface
which holds ```java
String name();
String description();
Category category() default Category.UTIL;
@lost matrix
https://paste.md-5.net/alevimapeq.js
It's incredible to have so much issues with simple logging. I feel like shit :/
who?
I even tried to force jboss to use "jdk" as logging provider (as specified here : https://medium.com/@scadge/how-to-enable-hibernate-logging-dc11545efd3d )
but deserves a break lol
sorry. my despair made me forgot that simple but important things !
Since he is the only one trying to answer my painful question he is a light in darkness 😄
You could just use Category.UTIL directly
well im trying to get the name
well you see this is how I am doing in, in the class I have @Module(name = blablabl.NAME) and that's how I am setting the name
Well get the instance of that annotion
I'm not sure how they work but you would need it
Hey so this is probably a dumb question but i can't seem to figure out why this recipe isn't working
ShapedRecipe recipe = new ShapedRecipe(key, item);
recipe.shape(" S ", " T ", " T ");
recipe.setIngredient('S', Material.STICK);
recipe.setIngredient('T', Material.SMOOTH_STONE);
Bukkit.getServer().addRecipe(recipe);```
when i sysout Bukkit.getServer().addRecipe(recipe) i get true and in the docs it says that it returns true if the recipe was added but when i try to craft it ingame nothing happens
if your wondering item is stone sword and material is also stone sword
well I have multiple classes that use that annotation so would it be possible for me to get all of the names?
Try setting those system properties:
# This is only for decoration
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n
# This is will make log4j only log errors
log4j.rootLogger=info, stdout
log4j.logger.org.hibernate=error
Also try to set those properties as early as possible.
So in your JavaPlugin#onLoad() method.
Thank you very much. Will try that !
my IP got banned for something i'm not sure all i ever did was download buildtools is there any appeal form i can submit?
nvm i was using my VPN thats why
is it possible that this prevents a player from moving?
public static void setCantPush(Player player) {
Team team = player.getScoreboard().getTeam("NoPush");
if (team == null) {
team = player.getScoreboard().registerNewTeam("NoPush");
team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
team.addEntry(player.getName());
}
}
No, not at all
how do i check if a player is near another player
cringe
well i think it was this
Player player = event.getPlayer();
player.setCollidable(false);
you mean the permission.
uhh use luckperms i would say :kekw:
I am not finding the solution in the internet
how do i add more explosiveness to fireballs?
First step would be not to use pex but lp 😛
e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 10);
I tried this but doesn't work
though I believe you can use the vault api to manipulate permssions for both plugins
https://paste.md-5.net/tudogiwabe.java
For the full method
If anyone can help
goggle?
increase yield
@EventHandler
public void onThrow(PlayerInteractEvent fbt)
{
if(fbt.getAction().equals(Action.RIGHT_CLICK_AIR) || fbt.getAction().equals(Action.RIGHT_CLICK_BLOCK))
{
Player thrower = fbt.getPlayer();
if(thrower.getItemInHand() != null && thrower.getItemInHand().getType().equals(Material.FIRE_CHARGE))
{
Fireball ball = thrower.launchProjectile(Fireball.class, thrower.getLocation().getDirection());
}
}
}
How do I do it
Is it possible to cancel the Packet completely when I hit the player?
I want to avoid the sound and particles when hitting the player
I don't want the Sprint to be interrupted
e.setCancelled(true);
With this, I can only prevent damage ...
How do you get/set facing direction on a banner using the blockdata method so not to use depreciated methods?
Have you tried getting its BlockData and casting it to Directional?
no, but I will try that now 🙂
hello
hewwo
Hello ! 🙂
assist is showing me the methods i need now, thanks, this should work.
Hi, I need an advice 🙂
What method would you use to store data on a player such as new attributes, a custom leveling system, etc...
"Persistent Data Holder" or an external database such as MySQL ? Or may be a combination of these two ? 😛
If you want to permanently store player data I would reccomend MySQL
Wew
^^ pdc is sweet for small things, like flags etc. Complex data structures like a leveling system should be in an external database
This
How do I do it so that the Fireball gives knockback to entities when hitting to any entity
ProjectileHitEvent
yeah but what do i write in that
Ok thanks for your advices, I will go with an external database 😉
Projectile is fireball > set power or launch player
Can you show the command
I'm not going to spoonfeed you
Use the ProjectileHitEvent check if the entity is an instance of Fireball then launch the player
Really depends on your setup. If you have multiple instances of one type of server then an external DB.
Otherwise PDC is fine.
If you have a more specific question feel free to ask
What is the command to launch the player 😦
Its called a "method" in java. You should set the players velocity.
oh ok
I would highly recommend learning basic java before you continue if you haven't already
?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.
Alright thanks
public void onProjectileHitEvent(ProjectileHitEvent e)
{
if(e.getEntity() instanceof Fireball)
{
e.getHitEntity().setVelocity(new Vector(0, 100, 0));
}
}
I tried this but it doesn't work 😦
Sadly it does not work either. I tried every solution I can think of ...
Thank you for your help anyway !!
Error?
Also why are you using new Vector(0, 100, 0)?
that would just yeet the player up 100s of blocks
unless thats what you want...
thats what i want
which is not happening
This should work and catapult the target directly into space.
Did you add the EventHandler annotation and also registered the Listener?
*This approach only works if your directly hit an entity with the FireBall
No errors its just not yeeting the player into space
Is there any way I can set the radius of the fireball for it to yeet the player
Is it possible to make a player look like he's doing the bow drawing animation, but they don't have a bow in their hand?
Hiya, I'm getting the java.lang.IllegalStateException: Asynchronous player tracker clear! error when running this code p.teleport(spawnLocation);
I think you have to run it sync or something like that so try running it as a Bukkit task
I'm using a TimerTask because what I'm doing is precise
you cant run any bukkit api method outside the main thread
Oh.
Anyone?
What can I do then?
run it as a bukkit task
indeed
I can't do that though as it's a time-specific operation
.-.
the operation will get processed at the next tick
Bukkit.getScheduler().runTaskTimer(Main.getinstance(), new Runnable() {
int count = 0;
@Override
public void run() {
if(count == 1)
count = 0;
switch(count) {
case 0:
wardrobemenu2.setItem(2, Items.dark_blue_helmet(p));
wardrobemenu2.setItem(11, Items.dark_blue_chestplate(p));
wardrobemenu2.setItem(20, Items.dark_blue_leggings(p));
wardrobemenu2.setItem(29, Items.dark_blue_boots(p));
wardrobemenu2.setItem(3, Items.dark_gray_helmet(p));
wardrobemenu2.setItem(12, Items.dark_gray_chestplate(p));
wardrobemenu2.setItem(21, Items.dark_gray_leggings(p));
wardrobemenu2.setItem(30, Items.dark_gray_boots(p));
wardrobemenu2.setItem(4, Items.blue_helmet(p));
wardrobemenu2.setItem(13, Items.blue_chestplate(p));
wardrobemenu2.setItem(22, Items.blue_leggings(p));
wardrobemenu2.setItem(31, Items.blue_boots(p));
wardrobemenu2.setItem(5, Items.gray_helmet(p));
wardrobemenu2.setItem(14, Items.gray_chestplate(p));
wardrobemenu2.setItem(23, Items.gray_leggings(p));
wardrobemenu2.setItem(32, Items.gray_boots(p));
wardrobemenu2.setItem(6, Items.black_helmet(p));
wardrobemenu2.setItem(15, Items.black_chestplate(p));
wardrobemenu2.setItem(24, Items.black_leggings(p));
wardrobemenu2.setItem(33, Items.black_boots(p));
wardrobemenu2.setItem(7, Items.white_helmet(p));
wardrobemenu2.setItem(16, Items.white_chestplate(p));
wardrobemenu2.setItem(25, Items.white_leggings(p));
wardrobemenu2.setItem(34, Items.white_boots(p));
break;
case 1:
wardrobemenu2.setItem(2, Items.dark_gray_helmet(p));
wardrobemenu2.setItem(11, Items.dark_gray_chestplate(p));
wardrobemenu2.setItem(20, Items.dark_gray_leggings(p));
wardrobemenu2.setItem(29, Items.dark_gray_boots(p));
wardrobemenu2.setItem(3, Items.dark_blue_helmet(p));
wardrobemenu2.setItem(12, Items.dark_blue_chestplate(p));
wardrobemenu2.setItem(21, Items.dark_blue_leggings(p));
wardrobemenu2.setItem(30, Items.dark_blue_boots(p));
wardrobemenu2.setItem(5, Items.blue_helmet(p));
wardrobemenu2.setItem(14, Items.blue_chestplate(p));
wardrobemenu2.setItem(23, Items.blue_leggings(p));
wardrobemenu2.setItem(32, Items.blue_boots(p));
break;
}
}
count++;
}
}, 0, 10);
any help xd?
...
...
?paste
...
Actually I think the best thing I can do is have my time-specific thing set a variable when it can execute and then have a bukkit task
use a paste bin or code block
Is there any way I can set a radius for the Fireball to launch the player?
hmm you might be able to listen to explosionprimeevent
You would have to get nearby entites when the projectile lands
ProjectileHitEvent would work for that
It works, thank!
declaration: package: org.bukkit.entity, interface: Entity
loop through the list check if the entity is player then launch
Jesus fucking christ
Have you ever heard of loops? Arrays? Come on
public void onProjectileHitEvent(ProjectileHitEvent e)
{
if(e.getEntity() instanceof Fireball)
{
List<Entity> hitEnt= e.getEntity().getNearbyEntities(5, 5, 5);
if(hitEnt instanceof Player)
{
((Player) hitEnt).setVelocity(new Vector(0, 100, 0));
}
}
}
Still doesn't work 😦
Did you register the listeners and add @EventHandler
yes
sysout in the event and see if its running
alright lemme try that
uh how do i check if a player is near a npc
Yeah the event is running
player#getNearbyEntities
.setVelocity(hitEnt.getVelocity().setY(100));
try that
wait I get it but then how do I use it I want to check if there is a player next to my corpse
get(1,1,1)
right?
and then
get as list and loop through it
1, 1, 1 would be all entities 1 block or less from the player
oh
that is the x y and z range
oh got it
List<Entity> entities = player.getNearbyEntities(x, y, z);
then loop through entities
ahh the list part confused me thanks!
@EventHandler
public void onProjectileHitEvent(ProjectileHitEvent e)
{
if(e.getEntity() instanceof Fireball)
{
List<Entity> hitEnt = e.getEntity().getNearbyEntities(5, 5, 5);
if(hitEnt instanceof Player)
{
((Player) hitEnt).setVelocity(((Player) hitEnt).getVelocity().setY(100));
}
}
}
Still doesn't work ahhhhhh
ok
hitEnt is a List. its never going to pass on the instanceof test
If I remove instanceof condition will it work?
if(e.getEntity() instanceof Fireball)
{
List<Entity> hitEnt = e.getEntity().getNearbyEntities(5, 5, 5);
ListIterator<Entity> player = hitEnt.listIterator();
if(hitEnt instanceof Player)
{
((Player) hitEnt).setVelocity(((Player) hitEnt).getVelocity().setY(100));
System.out.println("WORK PLUGIN WORK");
}
}
Now what
No, sorry but learn java
?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.
is there any way to detect player collision because the event for that does not exist?
format
no
Hey quick question. I want to get the "Killer" of an player. I am using the PlayerDeathEvent.
Right now I am using this:
event.getEntity().getLastDamageCause().getEntity()
But this Entity seems to be the player who died, so is there any easy way to get the actual killer entity?
Use getKiller
Returns a player though if that's what you want
Ah alright, thank you
sad
Do you only want player on player collisions?
I want to detect if a player collides with a block of any kind not with other players if that's what you meant
i dont think theres any event for that
package me.loudbook.testingplugin.commands;
import me.loudbook.testingplugin.Main;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.inventory.Inventory;
public class Commands implements CommandExecutor {
private Main plugin;
public Commands(Main plugin) {
this.plugin = plugin;
plugin.getCommand("spawnskeleton").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player p = (Player) sender;
Location loc = p.getLocation();
for (int i = 0; i < 20; i++) {
World w = p.getWorld();
w.spawnEntity(loc, EntityType.SKELETON);
}
return false;
}
}
Anybody see anything wrong with this?
it is a client side feature I think and server cant do anything I think
i mean you could check for sudden velocity change between ticks
but thats probably the best way you can do it
still super hacky though
lol maybe
did you get an error or it just dont wanna work
The command shows up as a possibility but when I run it nothing happens
No error
Just to be sure; you are creating an instance of your commands class in the main class, right?
probably not
yea no im not

