#help-development
1 messages · Page 1696 of 1
i have to clarify the file path every time
@unkempt peak
i finally got the test command working
i managed to make an armostand
and sit on it
hey
uh, how do you make custom exception messages get thrown in java
since the exception constructor isnt working for me
it forces me to make a try/catch block so it never uses my custom exception messages
so.... how should i play sounds in a radius
do i just play the sound for the WORLD?
World.playSound()
and change its volume....?
orrrr what
should i https://tryitands.ee/ ?
i'll try it and see
yeah so WOrld#playSound plays it to the entirew orld i guess, flew away a lot and same things
so not too sure
location#playSound?
maybe
thats a thing?
Maybe
it is not
Huh
are ytou doing world.playSound(location, sound, volume)
There's Player#playSound
This method doesn't play it to the entire world
But it can carry extremely far if you set the volume high
I thought so
what should i set the volume to
its only at 1.5
😐
Definitely doesn't play to the entire world
odd LOL
Should i teleport an entity, or set the velocity of an entity?
i could hear it at around 50 blocks away..
For a vehicle
with velocity comes fall damage
Probably set velocity so it's smoother
for (Player player : location.getNearbyPlayers(/**/))
player.playSound(...);
You can set fall distance to reduce or disable fall damage
so i have Chunk ec = (Chunk) p.getLocation(); for (Entity entity : ec.getEntities()) {, how can i get the ammount of entities in the loop? .getSize doesnt work
.size()
Cannot resolve method 'size' in 'Entity'
nope, doesnt work still says Cannot resolve method 'size' in 'Entity' Chunk ec = (Chunk) p.getLocation(); for (Entity entity : ec.getEntities()) { ec.getEntities().size(); break;
What is the general point of your code
agree
get the ammount of entities in a chunk
so why do you need а loop
to loop the entities in the chunk?
Chunk#getEntities returns an array
But you don't need it if you just need to get siE
You get its size with .length
Looping just to get one value and immediately break is very pointless though
ah thanks
I have implemented a feature that allows end crystals to be turned into sentries which attack hostile mobs. I do this by using a listener for a right click of the crystal which triggers a runnable. How can I make it so that crystals which become sentries retain their sentry-status persistently? Should I add a list of crystal coordinates to a data store and then use those coords upon server startup to re-create the runnables? What is the best course of action here?
i would, then on chunk load not server startup
Cause if you try to access unloaded chunks you get an NPE
Oh smart
But how should I trigger the runnable creation?
Is there an on chunk load event?
ye
I have a long that is < 0 for left > 0 for right, and another thats the same thing but for foreward and backward
how would i translate that into like changing velocity
public void onPacketReceiving(PacketEvent event) {
Player plr = event.getPlayer();
PacketContainer packet = event.getPacket();
float sideways = packet.getFloat().read(0);
float forward = packet.getFloat().read(1);
}
If I want to check if there is an EnderCrystal in event.getChunk().getEntities(), do I need to iterate with a for loop and check if every entity is an instanceof? Or is there a better way?
alright thank you
np
if its in that chunk there shouldn’t be that many entities?
so it shouldn’t be a problem
wdym that chunk? It runs for every chunk
does anybody know which part of the EntityHorseAbstract class
has the player ride code
im trying to apply it to other custom mobs
everything online is outdated
ok
do you think that will cause performance issues
I have implemented a feature that allows end crystals to be turned into sentries which attack hostile mobs. I do this by using a listener for a right click of the crystal which triggers a runnable. How can I make it so that crystals which become sentries retain their sentry-status persistently? Should I add a list of crystal coordinates to a data store and then use those coords upon server startup to re-create the runnables? What is the best course of action here?
No way to do it?
yes
i said
on chunk load
declaration: package: org.bukkit.event.world, class: ChunkLoadEvent
yes I know what you said, @alpine urchin stated that running on every chunk load would be a bit heavy
oh awesome I will use that
Can anyone help me out with MobArena, I made some changes to the mob spawns and now it's not working 😢
please be more specific 🙂
(:
Well, I'd like to be lol I'm not sure what I screwed up. It was all working fine until I edited something, now its not working at all.
"Internal error has occurred"
I'll keep looking. It all looks like its set up right, I'm not sure what I'm missing
no
Does every entity have a persistent UUID I can store and use to get the entity later?
For example do ender crystals have uuids which will remain the same on server restart?
yea they should
but
when their in an unloaded chunk
you cant access them
the joy of entities 🙂
Yes I know I plan on putting them in the chunks PDC
smart
What is the method to get the entity with the uuid?
then check every chunk on load and check if it has PDC
yep
if it does, check if its form your plugin
Entity.getUUID()
pretty sure
perfect thank you
smthng like this could be searched in https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/util/Vector.html
declaration: package: org.bukkit.util, class: Vector
people yelled at me a lot for it
and its helpful since i dont have to ask for help a lot
java.lang.NullPointerException: Cannot invoke "org.bukkit.plugin.Plugin.getDataFolder()" because the return value of "org.bukkit.plugin.PluginManager.getPlugin(String)" is null
at advancedchatmanager.chatmanager.CustomConfig.BannedWords.setup(BannedWords.java:16) ~[?:?]
at advancedchatmanager.chatmanager.ChatManager.onEnable(ChatManager.java:14) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:511) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:425) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:619) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:266) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1010) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at java.lang.Thread.run(Thread.java:831) [?:?] ```
whats the issue someone help
from this code:
int inc = 0;
for (Entity ce : ec.getEntities()) {
inc++;
ce.remove();
if (inc >= removal) {
break;
}
}```
im getting this error:
```Caused by: java.lang.UnsupportedOperationException: Calling Entity#remove on players produces undefined (bad) behavior
at org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer.remove(CraftPlayer.java:2263) ~[patched_1.16.5.jar:git-Paper-786]
at com.nesanco.disneywishes.commands.optimize.onCommand(optimize.java:44) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-786]
... 19 more``` which is the ce.remove(); line, how can i fix this?
Check if the entity is a player.
Show code
what? im making a thing that deletes entities in a chunk the player is in, not deleting players in a chunk?
You need to check if the entity is a player and not run remove on them.
so check the entities, if the entitiy is a player, not remove them?
package advancedchatmanager.chatmanager.CustomConfig;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class BannedWords {
private static File file;
private static FileConfiguration BannedWordsConfig;
public static void setup() {
file = new File(Bukkit.getServer().getPluginManager().getPlugin("Advancedchatmanager").getDataFolder(), "BannedWords.yml");
if (!(file.exists())) {
try {
file.createNewFile();
}catch(IOException e){
//This plugin was made by Shayam Sharma
}
}
BannedWordsConfig = YamlConfiguration.loadConfiguration(file);
}
public static FileConfiguration get(){
return BannedWordsConfig;
}
public static void save(){
try{
BannedWordsConfig.save(file);
}catch (IOException e){
System.out.print("Error Occuered will trying to save the file");
}
}
public static void reload(){
BannedWordsConfig = YamlConfiguration.loadConfiguration(file);
}
}
Bukkit.getServer().getPluginManager().getPlugin("Advancedchatmanager") is null
how is it null
i have put the value
?paste
Protocollib
Im trying to get the first 2 Floats
manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.ENTITY_HEAD_ROTATION) {
@Override
public void onPacketSending(PacketEvent event) {
Player plr = event.getPlayer();
Entity entity = plr.getVehicle();
if(entity == null) return;
PacketContainer packet = event.getPacket();
Float yaw = packet.getFloat().read(0);
Float pitch = packet.getFloat().read(1);
entity.getLocation().setPitch(pitch);
entity.getLocation().setYaw(yaw);
}
});
why?
The NMS objects are not equal to the documented raw packets in the protocol
im trying it rn
wait
yea
yea
it just breaks everything
ye
then give me a sec
which packet is this
that isn't the entity head rotation then
what does wiki.vg name it
Oh shit
so
Its player movement
but
in the IDEA
it doesnt give me the option for player rotation
or position
x=-889.6268060091414
y=69.0
z=-913.1163306813386
yRot=-177.49936
xRot=9.450546
relativeArguments=[]
id=50
dismountVehicle=false
1.17
this is in the console
for Server.POSITION
it might be entity head rotation
but one sec
nope
its not
on wiki.vg, entity head rotation is called entity head look
Ye
I want what the player is facing
So
when the player moves their camera
The armostand their riding moves with them
i see
Serverbound no?
thats for server-bound packets
ProtocoolLib PacketType.Play.Client stands for client-sided
yes
thats when thec lient moves and rotates
LOOK is when the client only rotates, but doesn't move
so yea
still errors....
POSITION is when the client moves, but doesn't rotate
so what data do u wanna read
from the packet
?paste
you can use getFloats()
before there was a misunderstanding and were trying to read the wrong packet
manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.POSITION_LOOK) {
@Override
public void onPacketSending(PacketEvent event) {
Player plr = event.getPlayer();
if(plr.getVehicle() == null) return;
Entity entity = plr.getVehicle();
PacketContainer packet = event.getPacket();
float yaw = packet.getFloat().read(0);
float pitch = packet.getFloat().read(1);
entity.getLocation().setPitch(pitch);
entity.getLocation().setYaw(yaw);
}
});
also
those errors only show up when im moving, and rotating
@alpine urchin

ikr
idk why isnt it working, i tried every possible thing
do /pl and check if the plugin is enabled

but it still doesnt change the armorstands facing direction
yes it is
Then try capitalizing
tried everything
file = new File(Bukkit.getServer().getPluginManager().getPlugin("AdvancedChatManager").getDataFolder(), "BannedWords.yml");
if (!(file.exists())) {```
you can with any entity
still dosent work
wait
then i dont think we are using the right packet
there is a separate packet for when the player steers a vehicle
yea?
But i need the "Vehicle" to face the direction the player is looking
wdym, show me

how can i use firework nbt in a command? for example i do /fireworktest <nbt of firework> then it summons a firework with that nbt?
can someone help me setup mojang mappings on spigot 1.17 with gradle
yo so haha this doesnt exist 😭
Like there is no way not just that method
hey
uhh
dig a little harder
🙂
declaration: package: org.bukkit.entity, interface: Entity
@turbid tiger
HOW DO I ROTATE THE FUCKING ARMORSTAND
because I am storing the uuids in pdcs
If a chunk is unloaded then the entity "doesnt exist"
i am storing the uuid in the chunk pdc.
I will create a chunk ticket, get the uuid from the pdc, then get the entity with the uuid
why not just store a custom UUID and have the stats of that sentry tied to that UUId so when the chunk loads just create the sentry
Yea do this
But re-create the sentry with the settings you saved to the UUID
yes
Bukkit.getPlayer(uuid)
ok
nevermind
lets gooo
granted i believe all that does is iterate over them
it was said that there is an internal map of each uuid to its entity (as per the 4th comment here: https://hub.spigotmc.org/jira/browse/SPIGOT-826)
what? no it doesn’t
md explicitly said that there is no map and you should use a for loop
i was then looking for it
it seems to be coming from an nms class
or not
i’m blind
When was player#sendTitle added? Which mc version
the comment after MD's...
I think you need the entity metadata packet
Probably
I've never messed with this before was just guessing
You're spawning it in the world and sending it as a packet
What's the point of the packet part
I know
What he means
is that
you are actually spawning the cow
so why send packets
cause the server handles that itself
Although it doesnt look like you are actually spawning it...
what

wait
it wont move or anything tho
is he spawning the cow on the server and also sending packets?
misunderstood this lol sorry
The minor amount of performance this might gain is not worth the effort
final PacketPlayOutEntityMetadata metaPacket = new PacketPlayOutEntityMetadata(nmsEntity.getId(), nmsEntity.getDataWatcher(), true);

lol
thats all you need tho?
then just send it
Oh well server still needs to keep track of the entity
oh rite yeah i forgot about that
It will eat ram if you spawn too mant
^ but no ticking
what olivo sed
there is some code further down
although the fields probs changed names
cause 1.17

He's 1.15
^
u said
at teh start
i hate javafx
cant seem to make it work
yeh there is a gist class (which has been saved as a txt for some reason)
I made a plugin you can shout water sources with. But if there are exactly 5, 7, 9, 11,.... Blocks between me and the target its not getting hit. That means the water is not being placed on every block on the vector between me and the target. How can I fix that?
https://gist.github.com/ItzJustNico/0de94ce7dce1c64294a278a875fbc9e4
Hi, I'm constantly getting world null in my location. Can you please help me?
My log:
https://pastebin.com/n6e5puGG
ok
also, we were looking for an event listener for the join event based on that error
currentLocation where is this assigned
^^
in the same class as join
show
what is all this static???
thats for db, inventory saves, etc
when are you creating the BoomPVP instance?
right in the main
So where are you setting the location
in GetFirstMap()
it looks to the list of locations
and picks one
coords are right
but the world is null
public static List<Location> listLokace = new ArrayList<>(List.of(
new Location(Bukkit.getWorld("world"), 11, 52, -0.5),
new Location(Bukkit.getWorld("world"), -2, 54, 502.5),
new Location(Bukkit.getWorld("world"), 24.5, 52, -492),
new Location(Bukkit.getWorld("world"), 497, 18, 492)
));```
yes
When are you calling that
a static nightmare
very
yep, i know
I gave up trying to trace it. all the static and back and forth is a mess
you call getFirstMap() but you didn;t show the code for that
Make your plugin load post world
This
the code is here
oh
There is no getFirstMap() in your posts
public void GetFirstMap() {
BoomPVP.currentLocation = BoomPVP.listLokace.get(new Random().nextInt(BoomPVP.listLokace.size()));
}```
ok
ok does your onEnable print the world at startup?
System.out.println(Bukkit.getWorld("world"));
does it actually show in the log?
Try making the plugin load post world that's all I can say
If not, you are exploding on the Objects.requireNonNull
so missing boomkit command in the plugin.yml
does anyone know how to detect if a passenger triggers a jump while riding an nms mob
the old field has changed
i looked in entityhorse but it looks like it sbecome more complex
wondering if anyone knows the answer 🙂
NMS is a mess and generally unsupported since none of us here knows every class and how things work
Reverse engineering and using Google are the best approaches here
ya
You could also listen to packets sent with Protocollib
Anyway when asking for NMS help you need to specify what Minecraft version you're on. We cannot help without it
1.17
ill do some reverse engineering, if i find it ill defs post it
1.17.1 or 1.17
You need to be specific
getLogger().info((Bukkit.getWorld("world") == null) ? "null" : "not null");
It seems to be the way you wrote it will give an error
I didn't write it. and thats not the point
and no it would not error, it would either print null or it would print the toString()
i had a similar issue
worked when @eternal oxide told me to do something
this.minigamesManager = new MinigamesManager(this, getWorld());
ended up doing this
this.world = getServer().getWorld("world");
(onEnable())
How can I send a message to a player on TextComponent click event?
How would I go about making a /cleararmor command? I want to have the option to specify a player, but I also want the option to be able to put a * to clear all online players' armor.
for (Player pl : Bukkit.getOnlinePlayers()) {
Have a method that clears the armor of one player then in your command check if "*".equals(args[0]), then loop through all online players and invoke the method for each one of them.
Ok, thank you!
@ivory sleet
how can I allow putting a block in private blockplaceevent?
region
worldguard
If it doesn't work can I post my code here so you can see what is wrong?
Idk maybe through some permission @quaint mantle ?
you can't use priority?
you return true from your onCommand
erase a line in spigot. yml?
nvm I've solved
I was trying to catch commands that weren't actually registered as commands.
Field field = null;
try {
field = EntityLiving.class.
getDeclaredField("bn");
field.setAccessible(true);
if(field != null && this.getPassenger() != null){
return field.getBoolean(this.getPassenger());
}
} catch (NoSuchFieldException | IllegalAccessException noSuchFieldException) {
noSuchFieldException.printStackTrace();
}
return false;
}```
if anyone is interested in checking if their passenger is pressing the spacebar, here you go 🙂
if(this.hasSinglePlayerPassenger()) {
return (EntityLiving) this.getAllPassengers().iterator().next();
}
return null;
}```
(1.17.1)
then commandpreprocess
how can I cancel the left hand if there was a press in the right hand?
@eternal oxide
I can't answer that as your questions are never what you actually want. It takes about 30 minutes to find out what you really want to do.
Pls can anybody help I asked 4 times already plss
cancel the left hand if the right hand was used
cancel the left hand if the right hand was used
blyat, ya ebal
public static List<Block> getBlocksInBetween(final Location from, final Location to) {
Preconditions.checkArgument(from.getWorld() != null && from.getWorld().equals(to.getWorld()));
final World world = from.getWorld();
final Vector start = from.toVector();
final Vector direction = to.toVector().subtract(from.toVector());
final int distance = (int) Math.floor(direction.length());
final double yOffset = 0;
final BlockIterator blockIterator = new BlockIterator(world, start, direction, yOffset, distance);
final ArrayList<Block> blockList = new ArrayList<>();
blockIterator.forEachRemaining(blockList::add);
return blockList;
}```
that gets every block between two locations
I use two hands when pressing in two hands. how can I make sure that only the right hand is used?
what does that even mean
ahhahahahah
Oh thank you! And do you know why my method is only getting every second Block?
if (e.getHand() == EquipmentSlot.HAND) {
p.sendMessage("HAND");
item.setAmount(item.getAmount() - 1);
p.getWorld().spawnEntity(loc, EntityType.PRIMED_TNT);
} else if (e.getHand() == EquipmentSlot.OFF_HAND) {
p.sendMessage("OFF_HAND");
alternate.setAmount(alternate.getAmount() - 1);
p.getWorld().spawnEntity(loc, EntityType.PRIMED_TNT);
As I said yesterday pressing two hands at the same time does NOT fire in the same event. It triggers two separate events.
how can this be fixed?
line 48 you are incrementing startLocation
clone if you don;t want it altered
Hello, I'm trying to find a way to code a minecraft plugin on my Chromebook, can anybody help me out?
I was interested in customrealms.io but I notcied itś open source.
tehnically.. you can code in notepad
If you are clicking with both hands then an event will be fired for each hand, one after the other. There is no way to tell which is the click you want as theres no way to be certain which order they fire in
programming on a chrome book, interesting
why? some plugins have fixed this
what event is that?
Yeah my school has my Chromebook locked down can't run Intellij
We have programming lessons in Java
they likely provide theyr own way of doing it
Web browser it is my guy
i usually fully despite combining equipment thats not personal
thank god I have my own PC
public void mainHand(PlayerInteractEvent e) {
if(e.hasItem()) {
if(e.getItem().hasItemMeta()) {
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(e.getItem().getType() == this.material) {
NBTItem nbtItem = new NBTItem(e.getItem());
if(nbtItem.hasKey(this.pl.getConfig().getString("WithdrawItems.XpBottle.NBTLore")).booleanValue()) {
if(e.isCancelled() && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
e.setCancelled(true);
} else {
e.setCancelled(true);
boolean offHand = false;
if(this.pl.isServerVersionAtLeast(Version.V1_9) && e.getItem().equals(e.getPlayer().getInventory().getItemInOffHand())) {
offHand = true;
}
this.pl.getServer().getPluginManager().callEvent(new BottleRedeemEvent(e.getPlayer(), e.getItem(), nbtItem.getInteger(this.pl.getConfig().getString("WithdrawItems.XpBottle.NBTLore")).intValue(), offHand));
}
}
}
}
}
}
}
bruh bruh bruh
please learn to use code blocks in Discord
how?
,,,123,,,
<!DOCTYPE html>
hmm
google ?
```java
//code
```
how send?
//
public void mainHand(PlayerInteractEvent e) {
if(e.hasItem()) {
if(e.getItem().hasItemMeta()) {
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(e.getItem().getType() == this.material) {
NBTItem nbtItem = new NBTItem(e.getItem());
if(nbtItem.hasKey(this.pl.getConfig().getString("WithdrawItems.XpBottle.NBTLore")).booleanValue()) {
if(e.isCancelled() && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
e.setCancelled(true);
} else {
e.setCancelled(true);
boolean offHand = false;
if(this.pl.isServerVersionAtLeast(Version.V1_9) && e.getItem().equals(e.getPlayer().getInventory().getItemInOffHand())) {
offHand = true;
}
this.pl.getServer().getPluginManager().callEvent(new BottleRedeemEvent(e.getPlayer(), e.getItem(), nbtItem.getInteger(this.pl.getConfig().getString("WithdrawItems.XpBottle.NBTLore")).intValue(), offHand));
}
}
}
}
}
}
}```
oh
Ok, your event is going to be fired twice, once for each hand that you pressed.
this is not my code, but it works correctly
you can't tell if the other hand is clicked or not in a single event
each hand should have its own action, but it would not be easy to ignore a left click if a right click came before
or vice versa
Not really possible
as you may want to only process the right click if both are clicked. However, you may receive the left click event first.
You have no way of know if a right click is going to follow your left click
How would I loop through all online players?
how is this done in other plugins? it works correctly for them
for (Player pl : Bukkit.getOnlinePlayers()) {
Well from what you have described I'd say it would be really REALLY hard. You would need to delay processing a click for a certain number of ticks to wait for any other clicks.
Thanks 🙂
But I don't believe you have described what you really want to do so we are likely talking about two different things
the translator is bad
Its always bad
I need to pick up an item from the right hand if the click was in the right hand
also with the left hand
so what exactly do you want to happen? If a player clicks BOTH hands, you want to ignore the left and only process the right?
but if the click was in both hands, pick up the item only from the right hand
yes
"pick up an item" = remove 1 from the stack?
pick up 1 item from the stack
I'm going to assume "pick up" means remove
The only way to do it reliably is to delay any left clicks
if 2 hands?
you may be able to achieve it by delaying a tick or two
how?
You never do anything with the inventory if its a named player
and line 16 you should return false so none of the rest of the code runs
kk
you are trying to blank out inventory slots 100 to 103 of a player?
You'd be safer to use teh armour methods available from the player
@eternal oxide
how can I allow a block to be placed in the region if it is dynamite?
private void clearArmor(Player player) {
player.setHelmet(null, true);
player.setChestPlayer(null, true);
// etc
}```
I don;t use worldguard
I was told that this can be made a priority
No clue, I don;t use worldguard
and if spawn-protect is in server. properties?)
if you want to override all protection plugins and always allow the placement of TnT then run it very last and un-cancel the event
how?
theres no getting past spawn protection, other than you placing the block in code, but the explosion will not break blocks in spawn
it depends on what is protecting the region
worldguard/spawn-protect
run HIGHEST and if the event is your place and the event is cancelled event.setCancelled(false);
zero 🙂
yep, default for a player without any action is stationary
but lets say normall
speed
then
walking is 0.2
So would this be the code?
nothing hard coded in spigot as its a value set by Mojang and could change at any time.
Thats some of the code. That should point you in the right direction and get you started
its a utility method
add the missing set armor lines for the last two slots
then you call that from your command passing the player you want to clear the armour on
So do I not need the inventory variable?
And where would I put that private void thing?
What part in the code?
?
You put that method in teh same class as your onCommand
You are a very beginner at java it seems
yes lol
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I'd really recommend learning some basics.
at least take a few beginner tutorials so you understand classes, methods and variable scopes
Ohhh wait I think I know how to do it.
Do I add the private void thing below public boolean onCommand?
not inside onCommand, but below
dude learn java basics first please
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class BannedWords {
private static File file;
private static FileConfiguration BannedWordsConfig;
public static void setup() {
file = new File(Bukkit.getServer().getPluginManager().getPlugin("AdvancedChatManager").getDataFolder(), "BannedWords.yml");
if (!(file.exists())) {
try {
file.createNewFile();
}catch(IOException e){
//This plugin was made by Shayam Sharma
}
}
BannedWordsConfig = YamlConfiguration.loadConfiguration(file);
}
public static FileConfiguration get(){
return BannedWordsConfig;
}
public static void save(){
try{
BannedWordsConfig.save(file);
}catch (IOException e){
System.out.print("Error Occuered will trying to save the file");
}
}
public static void reload(){
BannedWordsConfig = YamlConfiguration.loadConfiguration(file);
}
}
Whats wrong in the File(Bukkit.getServer().getPluginManager().getPlugin("AdvancedChatManager").getDataFolder(), "BannedWords.yml");
[11:55:15] [Server thread/INFO]: ºaAdvanced Chat Manager Enabled !!!
[11:55:15] [Server thread/ERROR]: Error occurred while enabling ChatManager v1.1 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.plugin.Plugin.getDataFolder()" because the return value of "org.bukkit.plugin.PluginManager.getPlugin(String)" is null
at advancedchatmanager.chatmanager.CustomConfig.BannedWords.setup(BannedWords.java:16) ~[?:?]
at advancedchatmanager.chatmanager.ChatManager.onEnable(ChatManager.java:14) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:511) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:425) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:619) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:266) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1010) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[server.jar:3241-Spigot-6c1c1b2-1492826]
at java.lang.Thread.run(Thread.java:831) [?:?]```
It throws this error
i tried every possible way but dosent work
?di use it to pass a plugin instance
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
wut
pass a plugin instance not Bukkit.getServer().getPluginManager().getPlugin
I'm getting this error, I looked a bit but can't seem to find it's cause. Maybe it's because my server is in 1.8.8? I found some people saying that older versions might get this kind of error.
if your server runs 1.8 you will need to also depend on spigot 1.8
In the pom.xml?
yea
... not true
?
well you can depend on spigot 1.7 I guess ?
I'm confused now
I use 1.17.1 as the depend base for one of my plugins. But I support down to 1.8.8
that is plain stupid
using 1.17 as your base for development when coding on 1.8 means you have to guess for every method if it existed in 1.8
yea that should be 1.8.8
Alright thanks!
Not really. I also do forwards compatability lol 1.8.8 up to 1.17.1
Yea but then you should be using a modular layout for version specific features you need
compiling a single plugin that only runs on 1.8
with 1.17 is just not a good idea
I use reflection for versionless.
great, does not change the fact that a plugin that targets a 1.8 server should be compiled against spigot 1.8
Nope
So I build against 1.17.1 because I support 1.17.1 down to 1.8.8 and if the code doesn't function on a certain version I adjust accordingly.
and how exactly does that relate to a "I am running a single 1.8 server I am coding against, should I use 1.17 api or 1.8" ?
if your plugin will only ever run on 1.8, choosing 1.17 as an API version is just not a clever idea
You said "if your server runs 1.8 you should depend on 1.8" that's not true you can depend on any version just won't be able to use some methods not found in your servers version
if you want to properly do multiple versions, you will create individual modules that are loaded based on the server version
those can depend on the respective version
Preference.
sure /shrug. I'll look forward to seeing your approach in your next releases 👍
Been the same every year(release) lol
Whats the event when a fire source destroys a block?
I am trying to create a plugin where fire spreads through the forest without actually destroying the trees
BlockBurnEvent
no worries
use getBukkitEntity()
at that point dont use the pdc or anything else,go straight with the entity id
packet entities cant rly do much.. only the id is unique about them
the entity never exists
this psecific method will only work if your converting a entity into nms then back,not for packet entities
Could someone help me/give advice on how to use AmberWats font ?
How would I check the broken block in a BlockDropItemEvent?
event.getBlock?
then its up to you to find a solution if its not spigot related
go ask in theyr support
I need to 'forward' the blockbreakevent
you can get the block from the event as i said,just pass it?
How would I pass it? Are you able to give an example close to what i'm doing for reference? I know how to pass params like if If I do public void printLn(String string) system.out.println(string)
if your at that stage dont even think about using an api yet..
Maybe i'm overthinking this
hm?
use eyelocation
will always be in front of him
or i guess if ur not in need of it,you can still use the eye to determine the angle between player and block
to figure out where the block is compared to the player face
why does @Override not work in 1.17 - whenever i try to type it it autofills to @java.lang.Override and then says cannot resolve symbol 'java'
it worked for me in 1.8.9 so im confused
I'm having this problem now that the java runtime isn't compatible, I didn't really do anything except just add things to my code. Any help?
it says at the top i think its cuz wrong version u using
Yeah as I said i didn't change anything in the pom.xml or plugin versions, so are there any ways to fix it?
i had that error before and i think all i did was switch jdk cuz i was using wrong version.
you should be using jdk 8
I'm fairly new to intelliJ, can you please explain how to do that? Is it in like the java.version in the pom.xml?
uh no
u download the jdk 8
online
and then u go to project structure when u hover over the files tab
click sdks
and then the plus button
click add jdk
and then go to where u saved the jdk 8
and then apply and build again
also u might wanna delete other jdk versions u already have installed idk if that will interfere
Add jdk?
yeah
Ah ok
Check if the projects java version is the 1.8 jdk
Ah I seem to have found it
it was on 11
I don't know how that could have happened though
Anybody know why @Override autofills to @inner rock.lang.Override using spigot 1.17.1 api?
oops
i means java.lang.Override
why are you making an annotation named "Override"
for the onenable and ondisable
?
?
sup?
then says java is not identifiable or smt
That's what you want though
sorry that was an accident i meant to say @inner rock.lang.Override
java*
not wilsoon
@inner rock.lang.Override
no
!?!?!?!?
i meant to type java.lang.override
he meant java.lang.Override
that was a typo
didnt see it before
nope
i have a BukkitRunnable problem
just delete the java.lang part
it wont work if i do that
Cannot resolve symbol 'Override'
?
i have an " ')' excepted " error
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.
still doesnt work
then add a ) at the expected location
So um even though it's set on 1.8 it still gives off the same error, even if I clicked Apply and reloaded the server; the plugin won't show up
or remove 1
check the console see why it fails to load
theres errors
Even in the pom java is 1.8
I already sent the error
i finally fixed, thanks
the plugin was compiled by a more recent version of the java runtime , it tells you that
i fixed mine by setting the compiler to 8
well it just is this now:
I changed the jdk to 8 but it won't work
now it works correctly
it will
kk ty
java 52 = 8
use openjdk 11 to start the server
A higher version of minecraft?
no
Because I need it to be 1.8.8 or 1.8.9
what
i fixed it without corretto , that seems convoluted
yea idk why you'd need corretto xD
he can solve this easily by updating the runtime version so dont care about the compiler
i meant he should update his java on his server
does spigot 1.8 even allow running with java 11 ?
idk but im running spigot 1.12 with java 16
thats most likely your problem
If you're using IntelliJ, go to Settings > Build,Execution,Deployment > Compiler > Java Compiler, and set 'Target bytecode version' and 'Project bytecode version' to 8
Then go to your project structure,
Here, ensure that:
1- Project Settings > Modules > Sources: is on '8 - Lambdas, type annotations etc.'
2- Project Settings > Project > Project Language level: is also on '8 - Lambdas, type annotations etc.'
well how to obfuscate my plugin
change all your class names to abc
👀
this is how i made lore in 1.8.8 but it doesnt work in 1.17.1 any solutions?
someone who learned a bit java should be able to deobfuscate it
I cannot publish my purchased plugin without obfuscating
I did all that, still does not work. I really can't get over this lol
so update your java on your server
alr
So wait how can I do that? I'm not used to handling all this java version changes things :/
well in the end it must follow the obfuscation rules on the forum
"You are allowed to obfuscate your resources, however the decompiled code must be somewhat legible by staff."
This is the error i get
not publishing on SpigotMC
so set JAVA_HOME to jdk 8 then
this may works
"C:\Program Files\Java\jdk-15.0.1\bin\java.exe" -Xmx5G -Xms3G -jar server.jar -nogui
PAUSE
idk its where i downloaded the jdk 1.8
oh wait
wrong jdks
but i still get this error:
I also switched to the right jdk and this is the error i got form building:
@idle cove just delete that java folder and let intellij install it for you
intellij can install it by itself?
yeah
so delete the whole folder
and intellij will install it automatically
oh nvm i see
so i installed it using intellij and tried building again:
deleted then installed i should say
did you select it
yeah
it wouldnt let me build otherwise
since it prompts me to choose an sdk when i try to build when i havent chosen one
try updating intellij
and if that doesnt work press file / invalidate caches/restart
hey guys, im trying to detect when a player drags an item into the slot in the hotbar that they are currently holding, I cant make sense of which inventory event achieves this, anyone know which one it is?
Hey everyone, I just tried to integrate JDA bot with discord, and I got an error and apperantly, it has to do with the classloader of bukkit. Any ideas how to proceed?
I need to have a solution to send messages in discord from the plugin
Lol
Yea, @eternal night , actually doing that yes. Do you think that causes it?
It's because I'm developing the plugin
When using, It would not be the case
yeah, replacing a jar while it is actively being used and not all classes are loaded from that jar might explode
how do i detect when an item burns?
should be a normal entity damage event
for the events, EntityCombustByBlockEvent and EntityCombustByEntityEvent
is there any way to grab the itemstack of a bucket from before it was emptied using PlayerBucketEmptyEvent? or do I juse use PlayerInteractEvent?
i updated it and it didnt work then i did invalidate caches and it didnt work
what does this even mean anyway
it means what it reads
it cant determine the file path to tools.jar