#help-development
1 messages Ā· Page 2140 of 1
bro im using a forge instance and its still not logging shit
at least the error is mapped
they probably don't even know basic java so, if I was you, I'd send them ?learnjava instead, otherwise you're probably just wasting your time lol
yep
well
in 90% of cases
erm yeah sure
you mean for stuff like command completion or what?
do something like
so you want the actual command executor to do async stuff?
Is it possible to cancel all the scheduled tasks that were scheduled by my plugin? (without having to save the id)
yes, sure
BukkitScheduler#cancelTasks(YourPlugin)
are you sure you didn't change anything else? show your code pls
final Player player = ...;
CompletableFuture<V> future = ...;
future.whenComplete(value -> {
Bukkit.getScheduler().runTask(() -> {
player.sendMessage(value);
});
});
?
and have whatever async shit ur doing return a completable future
Oh that's very simple haha
Thanks !
i was just going to say that you could work with futures or callbacks x)
np š
completablefuture uses a threadpool internally x)
oh yeah
conclure once told me that i should use a ForkJoinPool for the database operations
@quaint mantle
public <V> CompletableFuture<V> getValueAsync(/* ... */) {
return CompletableFuture.supplyAsync(() -> {
// get value from database
V val = null;
return val;
});
}
public void sendValueToPlayer(final Player player) {
getValueAsync(/* ... */).whenComplete((val, err) -> {
if (err != null) {
// handle any error which occurred
System.out.println("Error while retrieving value");
err.printStackTrace();
return;
}
// run synchronously (on the server thread)
// required to use most of the bukkit api
Bukkit.getScheduler().runTask(/* plugin */ this, () -> {
// do whatever you want with the value
player.sendMessage("Here is your value: " + val);
});
});
}
such clean code should be pinned š
lmao
š
?paste
Why am I getting an error: 'Variable might have not been initialized' when trying to schedule the generator task inside the method?
When I'm doing the same thing outside the method it works for some reason?
https://paste.md-5.net/mixoyekunu.java
because you try to access "generator" when generator is still being initialized
Am I not doing the same outside the method though?
?
I mean, it works with 'ironGenerator', why is that?
no that too won't work
if you move the ironGenerators thing above, it will probably be angry at that part instead
It's only for the task inside the method, I have used the task outside the method and it works
For some reason it's a problem only inside a method
Wait nevermind I can just schedule a repeating task I don't know why am I overcomplicating thingsš
why my plugin can't get vault?
public void onEnable() {
getCommand("shop").setExecutor(shopCommand);
if (!setupEconomy() ) {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "Nie znaleziono Vault.");
getServer().getPluginManager().disablePlugin(this);
return;
}
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
econ = rsp.getProvider();
return econ != null;
}```
package net.havana.havanatest;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class Scoreboard implements Listener {
@EventHandler
public void setScoreBoard(Player player) {
}
}
Why does it underline "Player" after the public void? Also "import org.bukkit.entity.Player;" gets dark gray
Because you are creating an event handler instead of a normal method. Remove the @EventHandler
Or, pass an event instead
I will import script also that will ༼ ć¤Ā ā_ā ༽㤠your tokens
k
Probably have an older version of vault installed on the server. Try downloading it from spigot again.
package net.havana.havanatest;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.scoreboard.ScoreboardManager;
public class TestScore implements Listener {
ScoreboardManager manager = Bukkit.getScoreboardManager();
}
I got this code but "manager" after "ScoreboardManager" is dark gray
why?
That sounds like a question from somebody who has no clue wtf they are doing
so i have this code that sends a snowball
if(getMana(player.getUniqueId()) >= 40){
Snowball ball = player.getWorld().spawn(player.getEyeLocation(), Snowball.class);
ball.setShooter(player);
ball.setVelocity(player.getLocation().getDirection().multiply(1.5));
}
How can i check if it hit a player, and if yes get that player?
i am new to Java
Learn Java don't start with spigot if you can help it
itās your ide telling you you donāt use that field anywhere
we are not toxic lmao
It was just a question
Lmao
?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.
@river oracle
Learn java?
Canāt tell if this is a troll or not
projectilehitevent?
want an answer ?
WELL first, highlight depens on :
the what app ur using
what theme ur using
how ur writing
and a lot.
Like if u have an error, send the error, check the line, and try finding out whats wrong
also like
no reason to come to a help channel just because somethingās gray
just look it up or hover over it and itāll probably say
i am pretty sure itās just because itās an unused field
and check the sender? well then it would do it for every snowball that this player sends
well
you could add a metadata to the snowball with the player
then check entitydamageevent see if itās a snowball and has the player metadata
i think getShooter works as well
idk why but getShoiter is a funny method name
when i do setMetadata, what is the "key" vallue
a fixedmetadatavalue i believe
He's right
Ayo! How would I get a object list with the configuration api?
things:
- a: 1
b: 2
- a: 3
b: 4
Is it getMapList?
Or does getConfigurationSection work somehow?
okay, thanks!
setDropItems(false)
Hey, I was making a command for downloading files in mc to the servers directory (weird reason dont ask why)
I got it working, but basically every website gets mad at its Java useragent and all the ways i could find to fix it used different methods to what i wanted, for example openConnection and not openStream, and i didn't really understand to how to actually implement it in my code, can someone explain how I would set a useragent in this scenario, or how to edit the code so I can set a useragent for it?
else if (args.length == 2){
String fileurl = args[0];
String filename = args[1];
try (BufferedInputStream in = new BufferedInputStream(new URL(fileurl).openStream());
FileOutputStream fileOutputStream = new FileOutputStream(filename)) {
byte[] dataBuffer = new byte[1024];
int bytesRead;
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
fileOutputStream.write(dataBuffer, 0, bytesRead);
}
} catch (IOException ex) {
plr.sendMessage(Utils.chat("&aioexception"));
ex.printStackTrace();
}
}
a user agent is simply a text field in the header of your request
it tells the website what browser you are using
yes i know, how do i specify it here though?
websites see that a useragent with just "Java/1.8.0_301" as its useragent is very weird so they just respond with a 403 forbidden
try {
URL url = new URL("http://sessionserver.mojang.com/session/minecraft/profile/2643e076-2434-4994-bd91-cb076d57f941?unsigned=false");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(5000);
conn.setInstanceFollowRedirects(true);
conn.addRequestProperty("User-Agent", "Mozilla/4.0");
conn.setDoOutput(false);
try (JsonReader reader = new JsonReader(new InputStreamReader(conn.getInputStream()))) {
reader.setLenient(true);```
I don't see why people block stuff based on user agents, they are easily spoofable
mainly because they have to send slightly different responses depending on the agent
Ah right, stupid interop strikes again
i didnt need to at that time because the entity was ALWAYS a player
ok so if i remember corresctly, i was calling that fonction and inside i was checking if the role wasnt null. OR only players had role
so i didnt need to
how can i detect when a player throws a fishing hook?
the projectilefireevent seems to be more for arrows
oops my bad i admit lmao
yeah but this would call also when the hook catches something
but now i check it hehe
i only need when they throw
doesnt it create an entity? maybe check when it does
because i need to set the hook persistent data container
and if its the right entity
in order to make a custom fish mechanic
i thought this would cast a lot of time when the bobber is active
i just got back to making plugins and already have error setting up IntelliJ can anyone help me on this
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I get error: Cannot resolve symbol 'JavaPlugin'
I mean I guess my spiggot jar i put in the modules is not working properly, or is there something else that I'm missing. I just made a java project and put the spiggot jar in the dependencies but seems to not work.
Send a screenshot of what you did
cant sned pics here
You need to verify
I'd advice creating a maven / gradle project and let one of those handle your dependencies
I'm not really familiar on how IntelliJ handles manually managing dependencies like that
depends on who
if you want, but he doesnt have to reply
My only guess would be that you added the wrong JAR.
2 other notes though, you should be using Java 17 for 1.18.2, not 1.8, and your scope for the dependency should be Provided, not Compile
is java 18 ok
Uh probably
i just did this jar
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
Oh yeah no dont do that
oh
use that
And then read this
Ever wanted to know how to make Minecraft plugins for Java edition? In this new series we'll be starting with the basics and eventually diving into the advanced details of plugin development.
I've been developing plugins and running my own servers since 2013, so expect to see step-by-step tutorials with plain English explanations.
š Take my FR...
here so u can dislike it
done
you dont even have to run buildtools for this stuff lol
if you have maven
its like 6 lines of text
dont have should i do maven
How might i get an enchanted based on a string or something? Cause i did it with chat colours before but can i do something similar with enchants?
Cause i see getByKey
But i'm not sure what i do there
Ah ok so i can do minecraft:flame?
I don't have to use stupid ARROW_FIRE?
whatever the key's name is
So i have to use ARROW_FIRE?
idfk
Already looked at the docs. They aren't helpful
?stash
how to boil an egg?
with a pan
the magic -1
holy shit this is golden
yeah
it is probably fake anyway...m
dont have it, I found it in memes in a server xD
do u actally think that's real xD
The user brie does exist with that icon on stackoverflow, but no thread of that name
How do I use a particle without it flying away? I have a way to make shapes out of particles and am trying different particle effects. However, some particles (like flame) just fuqs off in mach 2.
I've seen stuff online where the particles stay where they are spawned
It depends on teh particle, but you can spawn stationary particles using teh correct method/data
Then flame for example, how do I make it stay?
show the code you are using to spawn it now
My class is like 500 rows, so here is this player.spawnParticle(particle, location, count, offset[0], offset[1], offset[2], data);
are all yoru offsets zero?
and yoru location has no vector?
Wat?
set the direction on the location to a new Vector()
Noop, still nothing
They still fuq off
what is yrou data component?
null
then you should have no movement in teh particles
?paste
You could try using a 0.0d instead of null
For the data?
Hey everyone, so ive made a gui that is suppose to save whatevers in it into a hashmap, Soo Ive tried to make an event that if the inventory clicked is the gui and the slots are not bla bla bla then it cancels the event(to make it so the player can only interact with specific slots) but it doesn't work :(. please help me
code: https://paste.md-5.net/fokedirali.cs
This is what I get btw, ```java
System.out.println("Offset: " + Arrays.toString(offset));
System.out.println("Location: " + location);
System.out.println("Direction: " + location.getDirection());
System.out.println("Data: " + data);
player.spawnParticle(particle, location, count, offset[0], offset[1], offset[2], data);
[22:47:32] [Server thread/INFO]: Offset: [0.0, 0.0, 0.0]
[22:47:32] [Server thread/INFO]: Location: Location{world=CraftWorld{name=world},x=8.455905032744974,y=246.39496591633343,z=-4.231074700814557,pitch=90.0,yaw=161.8615}
[22:47:32] [Server thread/INFO]: Direction: -1.9062553689038664E-17,-1.0,-5.818950509763047E-17
[22:47:32] [Server thread/INFO]: Data: null```
I'm gonna try 0.0d
First of all, what is up with the gui.setItem(x, glass);? Just do this:
for(int i = 0; i < 54; i++)
gui.setItem(i, glass); ```
ur right
:>
Also, this does not work as you want it to e.getClickedInventory() == e.getInventory()
You can't do == or .equals with inventories
You need to either save an NBT tag in an item and read that to identify your inventory, or just compare the items one by one (would not recommend the last option)
best thing is to compare the holder and then check items or something
so make your own InventoryHolder
That is kinda smart, never thought of that lol
I can't use a double tho
yo
It only accepts Void.class for it
i set up everything
its very clean setup rn
but my friend is having a problem
whenever he opens this
tab for mavne
it just closes
dissapears
haha xD
int double double double double double
I just get this :/ java.lang.IllegalArgumentException: data should be class java.lang.Void got class java.lang.Double
it take a primative double, not a wrapped Double
I used this data = data == null ? 0.0d : data;
So it is a primitive
I guess it wrapped itself?
I guess
try hard coding it as a test
just put 0.0d in teh spawn method call
Ahh, yeah. Hold on
I mean
Sort of
The particles don't fly away
However
They spawn like, 50 blocks away
From the location I enter
thats where your location is set then
Hmm
I guess I've done something stupid in my code
Well, the double seems to have done the trick
Thank you!
np
can meta.addEnchant do "unsafe" enchant levels?
how would i create blocks infront of the player with a command
Thanks
You could do something with player.getLocation.getDirection (if i remember correctly)
idk how to make the blocks though or make it into a shape
you dont create them, you set their type
blocks are always there š¤
im trying to make a funny command where if i do /penis it summons a bedrcok penis ik its weird but my friend wanted it
well, then listen for that command, get the shape and set the blocks
how do i get the shape tho
either use some complicated unnecessary math
or just go with a midpoint and blockfaces
or Schematics
or that
i mean schematics probably arenāt worth it for like like 4-5 blocks
tbh idk what the fuck that is
i found this
depends how big youāre trying to make it
just normal
not anything special
5 blocks
would this work?
or this
?
thats the midpoint of 1 block
yes but you dont have to deal with offsets manually
you can actually just get the opposite block to face X
get players direction -> add it to their location -> use the new location as the base point for your shape
iām not sure what happens if you try to get a block at a non-whole number so you might need to round if it doesnāt already
0~1 = the same block
yeah i figured
ok the thing im confused about are the actual functions in spigot to use
Player#getLocation, World#getBlockAt, Location#getDirection should be about all you need
how would i place the blocks tho
what if they dont exist
they do
yes
World#getBlockAt(location).setType(Material.BEDROCK)
there's an instance of a block for every location in the world
the ones that don't have anything are just of type AIR
that's why you can't create a new block
but another question sorry for being anoyoying but how do i like make the shape thjoughj lmao
in your case, the shape is small enough to where you can probably just hardcode the values on
ex: Location pos1 = new Location(world, loc.getX() + 1, loc.getY() + 2, loc.getZ() + 3)
etc
np
for loops
and depends on the axis too
I have 2 plugins, if Plugin B depends on a utility class in Plugin A, and then Plugin A is disabled/unloaded, is Plugin B still able to access that utility class in Plugin A or has all of the classes in Plugin A been removed on unload?
IS END_PORTAL_FRAME tile entity or not
yes
hm
got this error
12.05 22:54:52 [Server] INFO at net.beasteria.beasteriautilities.utils.nbtapi.NBTReflectionUtil.getTileEntityNBTTagCompound(NBTReflectionUtil.java:247) ~[BeasteriaUtilities.jar:?]
12.05 22:54:52 [Server] INFO at net.beasteria.beasteriautilities.utils.nbtapi.NBTTileEntity.getCompound(NBTTileEntity.java:36) ~[BeasteriaUtilities.jar:?]
12.05 22:54:52 [Server] INFO at net.beasteria.beasteriautilities.utils.nbtapi.NBTReflectionUtil.getData(NBTReflectionUtil.java:624) ~[BeasteriaUtilities.jar:?]
12.05 22:54:52 [Server] INFO at net.beasteria.beasteriautilities.utils.nbtapi.NBTCompound.hasKey(NBTCompound.java:513) ~[BeasteriaUtilities.jar:?]
12.05 22:54:52 [Server] INFO at net.beasteria.beasteriautilities.utils.nbtapi.NBTTileEntity.getPersistentDataContainer(NBTTileEntity.java:53) ~[BeasteriaUtilities.jar:?]
12.05 22:54:52 [Server] INFO at net.beasteria.beasteriautilities.listeners.TeleportPadsListener.onPlace(TeleportPadsListener.java:56) ~[BeasteriaUtilities.jar:?]
12.05 22:54:52 [Server] INFO at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor1655.execute(Unknown Source) ~[?:?]
12.05 22:54:52 [Server] INFO at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
12.05 22:54:52 [Server] INFO at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:git-Paper-317]
12.05 22:54:52 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
12.05 22:54:52 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:669) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]```
or wait
line 56 throws error
actually
i think im thinking of end portal
i dont think end portal FRAME is actually a tile entity
Any one else can confirm this
end portal frame isnt on here
Plugin B ideally would be disabled too since it's depend on Plugin A. If it's not depend on Plugin A, then Plugin B will throw an error while trying to use something from Plugin A.
How would one go about spawning in an entity with custom NBT data?
why would it need to be
i was looking at tile entities a while ago and i thought i remembered seeing end portal frame
but it turned out it was actually just end portal which is a tile entity for the particles for some reason
Does anyone know how to send a custom advancement like this?
thanks
There a way to make a command that cancels all tasks of a certain type?
Yeah, in my case if have a spherical border that I initiate with a command, and then use the timer scheduler thing to execute a display() and changesize() method within the border object I created with the command.
Currently the only way I have to cancel the border is by letting it shrink to a radius of 0 then it'll cancel, but is there a way I could implement a command which just cancels these timers?
srry for the essay lol
hi, does anyone know if there is a way to check an inventory for a specific item/stack (like a recipe basically) and if so remove it? I've managed to do this except it has to be the specific stack. Ie. 20 dirt wont be removed from a 64 stack but so it has to be exactly 20.
well you can just save a reference to the runnable somewhere and then use .cancel() on it in the command
how would one "save it somewhere..."
sorry ive never messed with saves
var
if itemstack.getAmount() == 20
it depends, are there going to be multiple of these runnables or just one? in the case of just one you would set it to a field, but if theres multiple you would probably want a map
presumably just one, if that makes it easier
should I just look into fields and maps in java
probably
iirc each scheduler have their id
obtain the id
then cancel it
I feel like if you arent 100% sure of fields and maps in Java you should really go over more of
?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.
pretty big part of Java
how would that fit in here? I'm essentially checking the players inventory to whether it contains whatever swordstack is
if (e.getInventory().contains(swordstack)) {
player.getInventory().removeItem(swordstack);
o
Okay, just checked it out, but to clarify:
I don't want advancements that trigger automatically based on criteria, I want to just show an advancement (visual only) through code. Should not save in the advancements tab or anything like that, purely visual
OK, will do. appreciate the pointers :)
Give it then revoke it?
may have to iterate through the contents searching for a itemstack of said type and amount
int mustHaveThisAmount = 20;
ItemStack stackIWantToCheck = new ItemStack(Material.DIAMOND_SWORD);
Inventory thePlayerInventory = player.getInventory();
for(int slot = 0; slot < thePlayerInventory.getSize(); ++slot) {
ItemStack currentItem = thePlayerInventory().getItem(slot);
if(currentItem.getMaterial() == stackIWantToCheck.getMaterial()
&& currentItem.getAmount == mustHaveThisAmount
) {
// remove the item here by inventory
// or set the currentItem type to AIR
}
}
doesn't matter
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
thats it
cool
š© ty- I've been trying to figure this out for like 2 days and I couldnt find anything. I tried making a temporary inventory for the player to put the contents in and check the inventory once it closes...but that didn't work out
good luck!
ig it is spoonfeeding but that is how I learn personally. Seeing this example will help me for future interpretations aswell. Also, this code isn't made for 1.14 spigot so it doesn't function so there is still some figuring out to do.
You can use ItemStack#containsAtleast too and then remove item
dear god you are running 1.14
isnt that legit the worst performing version of minecraft
the code is always different in the backend, just generally the api implementation methods dont change
1.13 imo is the worst performing
hi, do you mind explaining what this does?
ItemStack currentItem = thePlayerInventory.getItem(slot);
creates an itemstack which is the "slot" withint he players inventory. but slot is only defined as an int so it wouldnt create anything? orrr am I dumbdumb
Is this a learn java moment or a learn MC moment? Lol
not the latter I hope š
anyone know the alternative to getMaterial() for 1.14? š©
oh wait getmaterial DOES work for 1.14. why do I see it as depreciated
It never was deprecated as far as I'm aware.
Though you should be using matchMaterial() anyways
not sure what matchMaterial does but probably worth a try bc
if (currentItem.getType() == Material.DIRT && currentItem.getAmount() == mustHaveThisAmount) {
throws a hissy fit error
oh, you're doing a different thing
No reason for that not to work unless you're importing the wrong Material
I dont think the for loop is working correctly
bc it will only count if it is a continuous line of dirt blocks
player.sendMessage(String.valueOf(slot)); i used this to test
and yeah idk how weird
It only counts if the slot is occupied by something
Do you return anywhere?
Well, I should just ask for a snippet of the code you're using lol
can YAML configuration files handle record serialization and deserialization
I wanna serialize a list of data classes that are records into my config
and then get them back
If it implements ConfigurationSerializable, I don't see why not. You're the one implementing the serialization/deserialization
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.PlayerInventory;
public class WipeCommand implements CommandExecutor {
private boolean success;
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
Player player = (Player) sender;
if (s.equalsIgnoreCase("wipe")) {
if (player.hasPermission("wipe.player")) {
if (args.length == 0) {
player.sendMessage(ChatColor.RED + "Correct usage: /wipe <player>");
} else {
PlayerInventory inventory = player.getInventory();
inventory.clear();
}
}
}
return true;
}
}
is this correct?
Too vague
Get more specific
I do see problems with it
Like the unchecked cast to player
Lots of nested if statements instead of guard clauses
Why i am unable to use the pathfinderavoid target and pathfinderavoidplayer in villager class?(nms package)
Any way I could make a gui specific to a player?
I have a gui that the player can change, but if two players open it at the same time, they can change each other's
don't open the same inventory instance to both players
How would I do that?
don't open the same instance to both players lol
you have 1 inventory instance
for 1 player
1 inventory variable
per
Yeah but then how would I make my listener to work for each different inventory variables?
I can't send it sorry
But I have an OpenInventoryEvent
That checks the name of the listener
i have question how cna i do same thing? (dont mind the client plz)
not same but similar thing
Gotchu thanks <3
or just use another plugin
no one will go through that pain
make a class and store it into a hashmap Map<UUID, YourInventoryClass>
then everytime you open an inventory for someone then "put" the inventory instance with the player associate in to the map
.
.
or u can do a dirty trick by implement by the InventoryHolder interface then listen for it in the event
(ppl in here discourage using the inventoryholder because it's "soon"TM to be deprecated)
Alright thanks
i can use MOTD plugin but it does this whenever i touch Version
can you show your code
its default waterfall
and for MOTD im using AdvancedNMOTD
It does that to show the red X over ping
Disable that setting
Also if it's not your plugin use #help-server
hi, is there a way to remove blockbreakanimation cracks
what i mean is that if a block is damaged then remove the damage
i send this package and try with this to remove it PacketPlayOutBlockBreakAnimation animation = new PacketPlayOutBlockBreakAnimation(1,new BlockPosition(block.getX(), block.getY(), block.getZ()), 0);
It might or might not work since it is handled client side
(and ofc send the package)
but there always remains a little damage
this bit is always remaining
nvm i just have to set the value to 10
PacketPlayOutBlockBreakAnimation animation = new PacketPlayOutBlockBreakAnimation(1,new BlockPosition(block.getX(), block.getY(), block.getZ()), 10);
still thank you for your time
are you on 1.8 or what? o0
How do I cast an entity to an armorstand?
1.17.1
by casting it?
ye
ArmorStand armorStand = (ArmorStand) myEntity;
just ad (ArmorStand)
oh I just wondered because you're not using mojang mappings
ye
Oh I thought I might need to use some method from the entity
nope, its very simple
Thanks :D
Any number outside of 0-7 makes it uncrack
I'm surprised you're seeing the stage 1 crack with an id of 0
0-9
PacketPlayOutBlockBreakAnimation animation = new PacketPlayOutBlockBreakAnimation(1,new BlockPosition(block.getX(), block.getY(), block.getZ()), 10); and this is my final code
Or that
i just set to 10
Haven't touched that packet in years
hapens
this is why i am setting it to 10
because its reset on eny other number
and i wann reset it
so what are you trying to do
ye
whats your problem
no problem enymorwe
now
method of player
didnt saw that lol
its 0.0 to 1.0
Can you make armor stand visible to only players without packets?
specific players?
Yes I mean only specific players.
not really no
okay, thanks
yes
declaration: package: org.bukkit.entity, interface: Player
you'll have to hide it from everyone except for the player that should see it
it was added in 1.18.0
bump. here's code snippet for context. This works fine on local windows pc, but not on my Ubuntu VPS.
String pythonFilePath = "plugins/Craft/end_game_data/algo/updated_classifier.py";
ProcessBuilder pb = new ProcessBuilder()
.command("py", pythonFilePath, inputFilePath);
Process p = pb.start();
Gives me "invalid directory or file" thingy error on ubuntu only.
the "default directory" is the working directory of your already running process
if you pass a working directory, it probably has to be an absolute path, e.g. /home/yourname/yourserver/plugins/..."
Alright. is there a way to get current Spigot .jar location?
there's an easy workaround
one sec
@cerulean jasper Bukkit.getWorldContainer()
that returns the directory where all the worlds are located
in 99.99999% of cases that's also where the spigot .jar is located
Great. will check it out now
there are also some other alternative ways but I guess that's by far the easiest and as said, it's probably 99.9999% reliable š
e.g. you could get your plugin's .jar file and then just go one directory up
For example
myPlugin.getDataFolder().getParentFile().getParentFile()
And also is it possible to check current servers OS? (if its Ubuntu/Linux or Windows)
because on windows my current setup seems to just work š¤
Yes, sure. one second
thanks
myPlugin.getDataFolder() is the folder that is created in /plugins, right?
yep. e.g. myPlugin.getDataFolder() will be the file at C:\MyServer\plugins\MyPlugin
Nice
so if you get the parent file twice, it returns the actual server location
to get the OS:
System.getProperty("os.name")
š
btw
spigot includes apache commons
so you can also do stuff like this:
boolean isWindows = SystemUtils.IS_OS_WINDOWS;
they even have fields for every windwos version lol
yes
cool
paper includes everything that spigot includes
oh wait @cerulean jasper
what's your spigot version?
oh okay, no problem then
alrighty
iirc older versions like 1.8 include an older version of apache commons
Aha
but on 1.16+ this definitely works
Ah, I need it at least on 1.16.5
then you have to use packets
@tender shard LIGHT MODE
File separator
ok
I wonder why noone mocks md_5 or eclipse users for using "light mode"
eclipse users are famous?!
I doubt that lol
Eclipse users are already getting mocked for eclipse. No need to twist the knife
true, hadnt thought about that lol
Will shading something in maven will copy all the shaded files but with different packages name?
how can i set target for a specific compass?
no
it copies the classes with their original package name
but you can relocate them, and then it will indeed change the package names
for example, look at my "more pdc types" lib: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
it includes a part in the maven-shade-plugin to relocate the classes
if you don't add it, then all my lib's method would end up in com.jeff_media.morepersistentdatatypes
Ah yes, I meant relocating it.
But when I shaded my own libs, the package name doesn't got changed.
yep you have to add that part manually
I have add that
<configuration>
<relocations>
<relocation>
<pattern>com.jeff_media.morepersistentdatatypes</pattern>
<shadedPattern>YOUR.PACKAGE.morepersistentdatatypes</shadedPattern>
</relocation>
</relocations>
</configuration>
okay so your library is inside "me.aglerr.mclibs" right?
yes
then it should get relocated to "com.muhammaddaffa...." when you run "mvn package"
Oh, it will not changed on the IDE?
It only change on compile
no, in the IDE you see the "original" package name
it will only change it once you actually compile your stuff
Ah okay, for some reason it didn't got relocated and it throws ClassNotFoundException error.
Oh, one sec.
the relocation thing will always, ever, only change the package names of the shaded classes when you actually compile stuff
in your IDE, it will always show you the original class names
everything else would also make no sense tbh
?paste the full error message pls
I think it's because I use the libs on a modular project.
So I have a core module, basically it contains all of the code and another module for the cross-version support that depend on the core module , the core module has relocated the libs but not on the another module part.
what's the easiest way to implement action bar in 1.8 spigot?
upgrade to 1.18
I would if performance was equal to 1.8
Upgrade ur pc
If u can't run 1.18 what u doing wrong :P
Is ur using a 20 year old pc
For large servers newer versions are not optimised enough to run smoothly with large player counts and advanced gamemodes
Hm actionbar requires packets in 1.8 iirc
well even 200 players on a 1.18 server are easily possible with a cheap ryzen 5950
Um, how can I make armor stand follow player's cursor location and it should maintain the distance. This is my attempt and the distance is not maintained when player is looking up or down.
Vector vector = data.player().getEyeLocation().getDirection().multiply(3);
Location location = data.player().getLocation().add(vector.getX(), 0, vector.getZ());
Since it's multiplied, I thought the Y will be multiplied too so when I look straight the armor stand will be up several blocks.
Okay that works, thanks!
I wonder if getDirection is normalized by default
IIRC no
it isn't strictly normalized but the math seems to give a consistent result
Is there a way to save data from a ItemStack to a projectile fired from a dispenser?
I have custom arrows identified by lore, and am applying metadata to the projectiles using the EntityShootBowEvent
but the BlockDispenseEvent doesnt seem to provide the entity created so I cannot do this for a dispenser
That's a good idea, I'll play around with the two. Thanks!
how can you speed up
a fishing rod
the casting part
not the part when ur waiting for fish. the part when u cast it
Hello, anyone have ever used AsyncWorldEdit API?
what is the event for when an entity like a creeper or primedtnt starts its fuse
explosionprimeevent doesnt work
in the nms GameEvent there's PRIME_FUSE but its nms and probably will break smth
oh wait its not nms
Hey, how do I make this into a clickable chat message for the player it was sent to? Not sure where to go from here...
oh, didnt realize sendMessage could take in a component
thanks
how do i put colors in permission-message of a command
the color character doesnt work
it like hides the character but applies no color
Section separator or amperand?
§
it removes the characters for the color but adds no color
Just use & and translate
ok
iirc it doesnāt support colors
with section separator at least
so yeah better to handle permission check and message yourself
ChatColor.translateAlternativeColorCodes('&', "&aHello");
oh it does i just accidentally did §r
lol
Demeng
How did you do the verification for your grantX?
I don't want code, just HOW you went about doing it
oh I think & just doesnāt work lol but yeah ss makes sense
Verification for ?
Your plugins. To prevent piracy
I read on spigot that you are not allowed to use external databases
You cannot really do any anti-piracy measures
Why tho...
I have my custom licensing servers
Is that allowed?
It uses Spigotās anti-piracy placeholders
The best thing you can do is obfuscate the jar, but since you must be able to run without internet access you can just iptable block the server
i know this sounds dumb, but is there a way to make something final after modifying it?
^
Technically yeah, but as soon as you block those servers the plugin must run
like initialize it, then add values to it or smth, then finalize
Wait, so I could block Demengs verification server and use however many IPs I want for my plugin copy?
Is that what you are saying
You can only delay piracy
Yeah, in theory that is
Canāt prevent
I mean yeah, tho I just want to prevent 12 yo to giving it away to friends and prevent reselling of my plugin
Prevent -> Make it harder
fwiw, those 12 year olds that received the plugin would not have paid for it at all
can i do like a while loop and execute the code every 1 second?
Honestly itās been a while since Iāve cared about anti piracy tbh
Yes, use the Bukkit scheduler
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Bukkit.getScheduler().runTaskLater(YourPlugin, new Runnable() -> {code here}, delayBetweenIterations)
And just exit the runnable once the statement is false
Cancel the task when the value turns false, or just add an if statement at the start of each execution
runTaskTimer, but yes
k
Yeah, that. Sry ^
If you intend on cancelling the task you'll have to either use the consumer, or make use of a BukkitRunnable
Bukkit.getScheduler().runTaskTimer(plugin, task -> {
task.cancel(); // This will cancel the task
}, 0, 20);```
(20 being the interval in ticks)
Yeah, I'm just kinda paranoid. I've seen other plugins similar to mine that has like 1k downloads on piracy sites. But I've never seen yours, at least not recent versions
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
if("shop".equalsIgnoreCase(command.getName())) {
if(args.length == 0) {
player.sendMessage(ChatColor.GREEN + "Lista komend:\n/shop create [iloÅÄ] [cena] [s/b] [admin]\n/shop remove");
return true;
}
if(Material.CHEST != player.getTargetBlock(null, 5).getType()) {
player.sendMessage(ChatColor.GREEN + "Musisz patrzeÄ siÄ na skrzynkÄ na której chcesz zaÅożyÄ sklep.");
return true;
}
switch (args[0]) {
case "create":
if(args[1] == null) {
player.sendMessage(ChatColor.GREEN + "Podaj iloÅÄ.");
return true;
}
if(args[2] == null) {
player.sendMessage(ChatColor.GREEN + "Podaj cenÄ.");
return true;
}
if(args[3] == null) {
player.sendMessage(ChatColor.GREEN + "Podaj typ sklepu.");
return true;
}
}
}
}
return true;
}```
why am i getting null error in this code when i type /shop create?
test args.length not null
this works fine
Why would args.length be null
you're right lol
thats not what I said
he is testing if each arg is null thinking if there is no arg it will be null
thats not how arrays work
*test args.length size
you mean isEmpty() ?
player.sendMessage(ChatColor.GREEN + "Podaj iloÅÄ.");
return true;
}``` like this?
args.length
your code will throw an IndexOutOfBounds exception
if you try to access the second element of an empty array it will indeed do ^^
No java if (args.length >= 1) // you have an args[0] if (args.length >= 2) // you have an args[1]
i'm still getting that error
worldgen plugin ???!?!?!?!??!?!?
yes
hi, i have a problem: org.bikkit.craftbukkit.v1_12_R1.block.CraftBlockState cannot be cast to org.bukkit.block.Banner with code:
Banner b = (Banner) Settings.redFlag.getWorld().getBlockAt(Settings.blueFlag).getState();
the block isnt a banner i guess?
yes blockstate and .getstate returns block state
how can i compare 2 item metas which one of them is compassmeta but ignore its meta? like if i do compassmeta.setlodestone it changes its itemmeta so it no longer will return true if i compare it to a copy of its past(before using .setlodestone)
also please ignore the trash explanation lol
FB is saying there is likely no banner at teh location of your Settings.blueFlag
public interface Banner extends BlockState
@civic dagger trying to figure out what you're saying. if you mutate an item it will not be equivalent to the item it was before mutation
anyone have a resource for glowing specific entities for specific players
i had one ages ago
but lost it
you have to check if the state of the block you're checking actually is an instance of Banner (so you know the block is a banner)
how could i check if argument in command is null?
if(x < args.length)
an argument in a command will NEVER be null
not wokring
i guess hes talking about whether or not an argument is given
me dum dum
big methinks moment
yes block in getting position is a banner
Very
yea basically its args.length
What error are you getting
I already told him how to test length
What behavior do you want
null
no, air banners instant break floor is air
?paste
go on
show the code you're using to check that
send it there
You can't tho
nobody will hurt you
Stop giving one word replies
@daring lark not a null exception, a null pointer exception
^
Show us the error
should figure out what that means
Show us the FULL stack trace
same thing
And the full class where that error occurs
its abbreviated
Put it in a paste link
NPE is even shorter
i check banners instantly break if i place thanks you
Otherwise I can't help you
yea but saying null exception indicates u dont actually understand whats going on
dude
its just shortening
the
error
name
now
shut
and
send
us
the
error
Ike
what
?paste
That's obnoxious
Sorry
It's alright it just floods chat
Been annoyed at kids asking for help in my discord, so I am still annoyed
Yeah I get it
again, sorry
i was attempting to teach the man how arrays work in a computer and why he was getting an exception
what
People act like help is a thing they just get, not a collaborative process with the people trying to help them
sorry to you too
I already told you how to check the args length, and I asked you for the full error. Either give us what we need to help you or stop asking
nah I am just too tired to distinguish
i place banner in line 1 but banner instant break ( i place banner to air and block under banner is air )
imagine if i have 2 ItemMetas and both of them are casted to compassmeta, i use .setlodestone on of them and then compare it with the other one using .equals, it will return false but how can i make it ignore that .setlodestone, i can check for lore, enchantments, flags, displayname, etc but i dont think its the best way
i hope you get what i mean from "ignore .setlodestone"
skip it?
?paste the code cuz im not understanding anything of what you say
wdym by skip it
Write a method that sets the lodestone location of 2 compasses to null, then compares
BRUH WHY I DIDNT THINK OF IT
Settings.blueFlag.getWorld().getBlockAt(Settings.blueFlag).setType(Material.BANNER);
Banner b = (Banner) Settings.redFlag.getWorld().getBlockAt(Settings.blueFlag).getState()
;
b.setBaseColor(DyeColor.BLUE);
b.update();```
What method are you using to place it
BlockState#update? Block#setType?
Block#setBlockData?
Ok you're doing setType
if Settings.blueFlag is a Location you can simply use getBlock
Call update(true, false) instead of just update()
org.bikkit.craftbukkit.v1_12_R1.block.CraftBlockState cannot be cast to org.bukkit.block.Banner
@civic dagger
You imported the wrong Banner
might want to ask someone more familiar w spigot tho
cheers i fixed my code now
Or it's not a banner
but if you want .equals to only look at specific aspects of an item you have to override the function
when i say item i mean an object
he didn;t call update() before getting a new state, so he's still getting the old block the second time
to clarify
i dont think i need to go that far
is there a different way of splitting a map image to 7x4 maps than using BufferedImage.getSubImage(...)
.
Graphics2D#setClip
it will draw only within that clip
@agile marsh just get a copy from both of them and then .setlodestone(null)
they're just never going to be equal to eachother
why?
bc you've changed one
i mean changing both to null and then comparing should send a null pointer?
I think?
but yea i mean if they're both null they're obv the same
No
no the objects it self
yea
That will work
@waxen plinth ty not very versed in spigot
but first i need to get a copy from both of them because setting to null will just break them in-game
Block block = Settings.blueFlag.getBlock();
BlockState state = block.getState();
state.setType(MaterialBANNER);
state.update(true, false);
Banner banner = (Banner) state;
banner.setBaseColor(DyeColor.BLUE);
banner.update(true, false);```
shouldnt be that hard
This won't work if the block isn't already a banner
Need to make sure to do that first
Setting type on BlockState and then casting won't work either
You have to set it on the block before getting the BlockState
An object cannot change its type
if you are working on a State it should work
BlockState s;
s.setType(Material.BANNER);
Banner b = (Banner) s;```
This will not work
a State is a snapshot so long as you keep that state it will work
That's not the point
The point is that a BlockState is an object like any other
It has a type, and that type cannot change
A type in java
The class it is an instance of
Changing the material type will not change the class of the object
You have to change the material of the block and THEN get and cast the BlockState to Banner
yep
Block#setState or something?
won;t work as it updates at th eend of the tick
ah
And ensure that you pass (true, false) to update
That will prevent physics checks, allowing you to set a banner midair
thanks
Which one of these is called first?
{
}
static {
}```
the static block is evaluated on class load
Frick
yes, static is at class load, {} is at class instantiation
those blocks are called before constructor btw
Yeah and that ^
anyone have a packet guide for 1.18.2
i legit cant find a single one
uhh
protocolib is doing some weird error
i just wanna send a glowing packet to one player
just use my packet guide, which does cross-reference checks and all
happy 2 learn off smth
ok
how do i find it
i dont have forums acc do i need one
For glowing, you want to send entity metadata
yeah
PacketPlayOutEntityEffect eff = new PacketPlayOutEntityEffect(e.getPlayer().getEntityId(), new MobEffect(MobEffectList.fromId(24), 1000, 1, true, true));
((CraftPlayer) e.getPlayer()).getHandle().playerConnection.sendPacket(eff);
like this is like
That's via the potion effect route
entity metadata
Block block = Settings.greenFlag.getBlock();
block.setType(Material.BANNER);
BlockState state = block.getState();
Banner banner = (Banner) state;
banner.setBaseColor(DyeColor.GREEN);
banner.update(true, false);```
org.bikkit.craftbukkit.v1_12_R1.block.CraftBlockState cannot be cast to org.bukkit.block.Banner how fix this
same packet that sends info like the entity name, isOnFire
Check the import, it might not be a BlockState at all (BlockData is a different thing)
IS UR Guide for spawning players
You need to import another BlockState, I think?
dont you have to update it before casting it?
works for most entities, ymmv
elgarl did
any another blockstate is not in editor
how do you learn what data u need to write to the packet