#help-development
1 messages · Page 2134 of 1
Is this feature availble in 1.8?
of course not
yo
hey
Should I be using PDC instead of Names?
I'm making the plugin in 1.8 because of the PVP, so that wouldn't be possible then
basically nothing is available in 1.8 api
generally data should be in the PDC, display name and lore are for visuals only
not even chunk, list and set
Ah
just move on to 1.18.x
would be cool to create a object implements ConfigurationSerializable, create a custom pdc, make the primitive be byte[] and use the BukkitObjectOutputStream to get the byte[]?

okay okay so pdc for checking what type of sword it is?
Is there a way to integrate 1.8's PVP to 1.18?
there are many plugins doing that
if you have custom sword types, ye
sweet thanks
You might get spamclicking back by having weapons with a very low recharge time, but I think the changes are more nuanced than that
my first windows was windows 3.1 >.< I definitely do not miss those days
so windows 98
I don't understand what it says Cannot resolve method 'registerEvent(getCoinsEvent, Economy)' when I try to register my event
the line with the problem is getServer().getPluginManager().registerEvent(new getCoinsEvent(),this);
registerEvents
?
your method name is wrong
what
Bruhs
bruh this isn't rocket sicence
😥
Thats funny tho
*You're
When I'm using lettuce redis pub sub should I use connection pool for that?
rekt
yes
Does the configuration api deserialize the classes when calling YamlConfiguration#loadConfiguration, or only when calling the get(path, class) method
So long as you correctly registered the class before saving/loading
how does it know that part of the file IS your class
because you correctly implemented ConfigurationSerializable
not the first line btw
the whole object is serialized
any line with ==:
!?
test:
==: custom-object
a: b```
ah
read teh javadoc on implementing https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/serialization/ConfigurationSerializable.html
I am talking about DEserializing
this answered
see https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/serialization/package-summary.html for more info
declaration: package: org.bukkit.configuration.serialization
Ok, so one question, what is wrong here:
private GenericObjectPool<StatefulRedisPubSubConnection<String, String>> pool = ConnectionPoolSupport
.createGenericObjectPool(() -> redisClient.connectPubSub(), new GenericObjectPoolConfig<>());
private void foo() {
try (StatefulRedisPubSubConnection<String, String> pubSubConnection = pool.borrowObject()) {
pubSubConnection.addListener(new ExperimentalListener());
pubSubConnection.async().subscribe("experimental");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private void bar(String message) {
try (StatefulRedisPubSubConnection<String, String> pubSubConnection = pool.borrowObject()) {
pubSubConnection.async().publish("experimental", message);
} catch (Exception e) {
throw new RuntimeException(e);
}
}```I can install a listener and subscribe a channel, but I can't publish a message
this is probably not gonna do it for me, because I want to only load them not save, and I don't want the user to have to type ==:
i want to know too
but I'll figure something out
you must
it is just a ==:
not thisIsAFuckingCustomObjectFromABukkitClassBecauseTheDeveloperCreatedAClassThatImplementsConfigurationSerializableDidYouUnderstand: custom-object
if you are not going to save them you are going to have to manually deserialize them then
literally read data from config and create yoru object via its constructor or a Builder
only because of a ==:
whats even the main advantage of using "Lettuce" over something more known like Jedis?
🤡
Someone advised me to switch from the Jedis to the lettuce, lettuce is rumored to have better dealing with async compared to jedis, but I don't know exactly that
did he give any actual arguments?, i have never had issues with this
how do I put a stack of a custom item inside a custom inventory?
because the setAmount is void so it'll change the amount of the item
I want it to not be changed
what?
Create another ItemStack using yourItemstack.clone();
oh
Then set the amount of the new one
And there you have
thank you
in general you shouldn’t be using just one instance of an itemstack though
😄
does anyone know what this means
that you should install the updates
reload your maven on the top right
nothing happened
that means that it didnt download the dependency yet. it should do it once reloaded
otherwise force install
im not sure i follow
or terminal -> mvn install -U -> enter
ohh
and one for plugin update
And I think the install might work but not sure
install do i right click and run maven build
Just double click
What
I have no idea then
Probably something is broken where it gets Java path mostly
But Mac OS I have no idea
paste your entire pom
wdym
?paste
is your project set to use java 17
that shouldn't be needed
his pom is saying to use 17, but his project is building with a different java version
go to File > Project Structure and double check what the SDK is set to
16.0.2
17 i guess
then you will need to download java 17, add it to Intellij, then switch your project over to 17
because your project is trying to use java 16 to build, but you told maven you want to use 17, so there is the conflict
hence the "invalid target release"
ok i want to use 16 then is there a easier way?
go to your pom, change <java.version>17</java.version> to 16 instead of 17
this is the code of this slot if (event.getSlot() == 9){ player.getInventory().addItem(event.getCurrentItem()); player.sendMessage(ChatColor.GREEN + "You got 64 coins"); event.setCancelled(true); }
and also
always click to refresh maven
your pom loads fine for me
it is still happening if (event.getSlot() == 9){ ItemStack clone = event.getCurrentItem(); player.getInventory().addItem(event.getCurrentItem()); event.getClickedInventory().setItem(event.getSlot(), clone); player.sendMessage(ChatColor.GREEN + "You got 64 coins"); event.setCancelled(true);
?????
Bro your not even cloning it
You just named an item stack clone
md_5 is owner
spigot ?
did you change anything else besides the java version?
so just put .clone() like this? ItemStack clone = event.getCurrentItem().clone();
thank
Yea 
^
What is md_5's real name?
what is your real name?
paste your pom again
yeah yeah i saw and it worked. idk why i didn't put the .clone() in the first place. my brain is dead after my math exam
thx
Sha
did you try to invalid cache and restart? everything is fine here
how do i do that i know it seems like im rushing you so sorry for that but its because i have a server waiting lol
so how do i invalid cache or restart
it's under File
I think it might be cuz of java.version being 16
mines 1.8
Hello,
In command, how to express multiple arguments?
example
/cmd [<value1>] [<value2>] [<value3>] [<value4>] ... more available
there are some tutorials out there that can explain better than people can in a chat
but to answer your question you use String args[]
Not code
yes
you use string builder
String command = "";
for (int a = 0; a < args.length; a++) {
command += args[a] + " ";
}
how do I get an itemStack variable of a used material in an OnCraft event?
indentation is messed up
Any built in method to run code at the very beginning of a tick before anything is processed or happens? wanna know before I patch
I didn't mean code.
Just command expression in english like /cmd <value>
I dont understand what you mean
i had an issue with this a while ago [09:24:38 WARN]: java.lang.NoSuchFieldException: knownCommands https://paste.md-5.net/jeqagekolo.cs
hey so i have this class (my main class) and idk why but when i try creating an other class and extending it to the first class it doesnt work :
Error:
cannot acces HunterHunterUhc
I want to know how to express variable arguments to english command like /cmd <a1> <a2> <a3> ...
This command can be used like these
/cmd hi
/cmd hi hello
/cmd hi hello by goodbye yes
Is this Skript or something?
This is used for plugin command
or do you mean like String...
.
what exactly are you trying to make? I dont get it
Cannot resolve method 'getItem' in 'CraftItemEvent'
u if it doesnt work, take the item in the crafting inv at the crating slot
if you want to get that class you can do HunterHunterUhc hunter = HunterHunterUhc.getPlugin(HunterHunterUhc.class)
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ahh constructor
@river oracle maybe you know?
is this a bad way?
Dependency injection is the best practice makes your project more portable and easier to trouble shoot di is also an industry standard for Java
I know linux express like this for variable arguments
But how to express the plus?
yeah but the thig is that for every other project i ever had i just did
public class playerEffect extends HunterHunterUhc implements Listener{
}
why doesnt it work this time?
Horrible practice
Do you know what extends does
Your abusing a great aspect of java
May I suggest learning some more 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 it better to keep your sqlite Connection object in a field and reuse it or create and auto-close a new one every time
Wassup
Depends on how often you're making requests
does anyone know?
realistically max 1 per 10 secs
please
declaration: package: org.bukkit.event.inventory, class: CraftItemEvent
definitely keep it in a field
close in ondisable then?
aight ty
oh wait
he said sqllite not mysql
in that case it doesn’t matter as much as i thought
don’t really see the harm though of keeping it in a field
if you get the connection out of a pool it doesnt matter anyways
it will even be more save to just close it
since it sents it back to the pool for reuse
maybe
hey, ive always been coding in 1.16.5, but rn for a project i have to use 1.8.8 (before u ask, i cannot change version.
So i ve always used :
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskTimer(this, task -> {
}, 20L, 20L);
but rn i need to use
Runnable run = new Runnable() {
@Override
public void run() {
if(getRole(player) != null){
}
}
};
getServer().getScheduler().scheduleSyncRepeatingTask(this, run , 20L, 20L);
is there a better way for 1.8.8?
if not, how can i stop the task like i did with : task.cancel();?
is 1.8.8 using java 8?
ye
ye think so
runTaskTimer is returning a bukkittask
new BukkitRunnable(){…}.runTaskTimer(plugin, delay, interval)
java 8 supports lambdas?
yeah
so why not using a lambda??
i mean
i typically find that just making a bukkit runnable is easier than using the scheduler
i dont think that
yeah i ve always been used to using scheduler
they’re pretty much the same really
like this for instance?
new BukkitRunnable(){
@Override
public void run() {
}
}.runTaskTimer(this,20L, 20L);
and how could i cancel the Runnable?
from outside of it?
yeha ik i was just testing rn
nope inside
why not just
Bukkit.getScheduler().runTaskTimer(this, task -> {}, 20, 20)```?
error in 1.8.8
ah lol its the api which doesnt support it or what
deosnt recorgnize runTaskTimer
i thought you were talking about language specs
scheduler does work in 1.8 but i still just prefer bukkitrunnables
let me check something where i used it
yeah
new BukkitRunnable(){
@Override
public void run() {
if (getRole(player) == null) {
this.cancel();
}
}
}.runTaskTimer(this,20L, 20L);
k
and just to be sure, amplifier of 0 in 1.8 for an effect means like level 1 right (Like Weakness 1 for instance)
yea i think so
how could we prevent the default join message
u can also set it to a custom one
Hi i am making a ban type plugin and i want it to have player head with player skin
https://paste.md-5.net/ukevuhifuq.java
this is my code how do i do it?
dont compare inventory names
use inventoryholders instead
and use ?di instead of that ugly singleton
is it to me?
ye
Hey so we're trying to program a temporary wall in front of the player however if the wall hits a chest(or any of the blocks that can have items in them), the items stored inside that chest are completely erased upon the resetting of the spell.
Is there a simple fix for this?
you mean that the wall blocks are replacing the chest and after some time the blocks come back?
i had an issue with this a while ago [09:24:38 WARN]: java.lang.NoSuchFieldException: knownCommands https://paste.md-5.net/jeqagekolo.cs
The wall replaces the blocks, then when the blocks come back, they are completely empty.
ofc
what?
you are just setting the block to be a chest, youre not restoring its contents
I tried using blockdata, but that didn't work.
uh just store the contents and set them back
Yeah, that is what we are trying to do.
onely need to have players face now rest i do my self
?
packets might be a better idea honestly
depends on what you’re using the wall for
why not just make the temporary wall ignore chests? when you place the wall just don't place a block if there's a chest in that spot
The wall is meant to protect the player from anything ranging from an arrow to a fireball nuke.
or just have a runnable to restore all blocks after you used the spell
don't need inventoryholders i need the face of all online player to show up so it's not yust stive heads
I have zero clue when it comes to packets.
Already do.
well in this scenario they probably won’t be useful after all
Thought about. Just worried it might weaken the wall.
im saying dont check if an inventory is the inventory you want by checking its name
idk, chests are still blocks and the odds of something going through the tiny gaps between a block and a chest are like 1 of 1000
random numbers
and how do i do that?
.
best thing is to make a gui class which has an inventory as field and implements the InventoryHolder interface, then check in the event if the holder is instanceof your holder
Yeah, it just makes the spell look less impressive whenever you can just use a chest or a furnace to completely disable the spell.
not replacing the chest just removes the pain of having to deal with edgecases like "what happens if the server crashes? what type of storage do we have to set up for saving the data of the replaced chest's contents?"
True
We might just use the not replacing method as a temp fix, and later on when we've learned more about spigot and java. We'll go through and implement a more advanced method.
did not under stand a singel thing
why not check its type?
what type
I mean all you gotta do to get the contents is to check if the block is an instance of chest, then get the inventory of the chest, then store the contents of said inventory in a list then do whatever with that when resetting the blocks
Hey, why is the title blinking the number of times I have used this feature? (Until restart)
https://www.toptal.com/developers/hastebin/okijupidij.lua
And, can i set title's fadeout with 1.8 api? i don't have function with fade arguments, only with title and subtitle
nvm
uhm wth
instance checking for inventories is usually the best checks
And advices are welcome, this code is terribly overcomplicated lol
if (set.contains(p)) return;
set.add(p);```
is the same thing as
```java
if (set.add(p)) {}```
huh`?
brother if you can't read that, then nobody can help you. it's so simple
(responding to blobsky)
so checking contains before removing is redundant
nobody's gonna spoonfeed you some code
is it to me?
and store a set of uuids not of player objects
it is for a moment
?
Why should I use uuid when the player won't change in a few seconds anyway?
anybody help me weith the crate reloaded plugin?
no need to store players
okay
Yeah, but we also gotta do it for furnaces, shulkers, double chests, dispensers, droppers, hoppers, and anything else containing specifc nbt.
i need help putting more crate keys as a prize for a crate in cr
declaration: package: org.bukkit.block, interface: Container
uh, and i don't have waitingPlayers.remove/add where i could remove contains
Thanks
Where is my error? Its Doesnt Set Item Diamondsword on GUI
hey i am trying to add that api (https://www.spigotmc.org/resources/actionbarapi-1-8-1-14-2.1315/) to my project, so i added the library, and on this page found the dependency https://github.com/ConnorLinfoot/ActionBarAPI/blob/master/pom.xml but i cant seem to find the repistory. Anyone knows?
why are you using a static inventory
it’s almost never a good idea
and probably causing your problem
Oh yeah... But How Can I use my GUI on another class Then
in what other class?
you don’t just want one instance of an inventory
everyone will be using the same inventory in that case
also it doesn’t even look like you’re ever calling the method to set the item
oh..
about what i asked earlier, in general, how to get the repistory of an api
I have made a command, and I would like to know
do I need to do player.getInventory.getIteminmainhand();
or getItem or getItemInHand
why people shouldnt watch yt tutorials smh
(tbh that should work fine)
anyone?
public static void main( String[] args ) {
String test1 = "asd";
String[] test2 = { "asd" };
System.out.println(test1 == test2[0]);
}
^ this prints "true", but it will probably fail if you have many, long strings
:bruh:
?
wat do I do?
well, what are you trying to do?
im trying to give the item to the player
then use Player#getInventory()#addItem
- method name: getDiamondSword()
where does it add the item tho
to the player's inventory?
into the first free slot
?
what do I put in the ()
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
the required parameters, obviously
you must learn basic java, otherwise noone here can help you
simple words please
I need help optimizing this code, since right now it teleports me like 50 times and crashes the server.
public void onPlayerTeleportEvent(PlayerTeleportEvent event){
Player player = event.getPlayer();
World fromWorld = event.getFrom().getWorld();
World toWorld = event.getTo().getWorld();
if(!(fromWorld == toWorld)) {
if(!(config.getLocation(player.getUniqueId()+"."+toWorld.getName()) == null)) {
player.teleport(Objects.requireNonNull(config.getLocation(player.getUniqueId() + "." + toWorld.getName())));
}
config.addDefault(player.getUniqueId()+"."+fromWorld.getName(),event.getFrom());
config.options().copyDefaults(true);
saveConfig();
}
}
you are teleporting someone in the teleport event
so it keeps teleporting you
does not work
i hope you know what Objects.requireNonNull does
it's like this:
- TeleportEvent ->
- Your code runs ->
- You teleport someone ->
- Teleport Event ->
- ...
ae
How do I teleport only once? I made a check that if the world is different
I don't but the ide told me to put it there so i did
probably clicked the intellij warning when it popped up about something being null
exactly
Have a boolean field like "ignoreEvent = false";
Once you teleport someone, set that boolean to true BEFORE you teleport them
In the event listener, immediately return if the boolean is true
After you teleported the person, set the boolean to false again
so many people do this
and it just ends up breaking their plugin
yesj i believe so
damn, imma remove these
just add a null check instead
private boolean ignoreTeleportEvent = false;
@EventHandler
public void onTeleport(PlayerTeleportEvent event) {
if(ignoreTeleportEvent) return;
// ...
ignoreTeleportEvent = true;
event.getPlayer().teleport(...);
ignoreTeleportEvent = false;
// ...
}
Incompatible types. Found: 'java.util.HashMap<java.lang.Integer,org.bukkit.inventory.ItemStack>', required: 'org.bukkit.inventory.ItemStack'
O
ok
seems pretty self explanatory
a HashMap is not an ItemStack, what a surprise
tip: enter ?learnjava, then read the bot's reply and click on one of those links
guys i folowed what was on that website to add an API (and i also downloaded the Library) https://github.com/ConnorLinfoot/ActionBarAPI/wiki/Maven
here is what is in my pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://shmezi.github.com</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.shmezi</groupId>
<artifactId>ActionBarAPI</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--Bukkit API-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
But i get an error :
Could not find artifact com.github.shmezi:ActionBarAPI:pom:1.5.4 in jitpack.io (https://shmezi.github.com)
Hey short Question: i tried to make a command which places a chest with persistent data at the location from the Player.
I also made a Listener to check if a chest which is opened by the player has the persistent data:
https://www.toptal.com/developers/hastebin/jijosagehe.csharp
If yes the Chest opening event should be cancelled and an other inventory should open.
But it doesnt work and the console dont give an error.
Does somebody know what i did wrong?
im not sure, its just the inventory which isnt opening instead the chest
spaghetti code lol
try to open the inventory one tick later
wait why are you opening an inv in the interact event
i want to cancel the chest opening and open an other inv instead
the jitpack url is wrong
any idea how i could find the right one?
i have now tried to output the persistant data at the end of the command:
player.sendMessage(container.get(key, PersistentDataType.STRING).toString()); but i dont get a message if i use the command
thats what i used
if you used it, the url would be correct
<repository>
<id>jitpack.io</id>
<url>https://shmezi.github.com</url>
</repository>
use this URL <url>https://jitpack.io</url>
jitpack is known to cause problems all the time
simply try to do mvn clean package -U
Hello ! I'm trying to do with my economy plugin a Bank System, I'm searching for how to get the number of a specific item in the player inventory, then save it and then remove from the inventory of the player ! How is that possible ? thanks for reading have a good day !
loop over all the items in the player inventory and then count them
so i make a for() and after add in an int ?
still same problem when i use <url>https://jitpack.io</url>
Could not find artifact com.github.shmezi:ActionBarAPI:pom:1.5.4 in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--Bukkit API-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.shmezi</groupId>
<artifactId>ActionBarAPI</artifactId>
<version>1.5.4</version>
</dependency>
</dependencies>
I don't know why people keep using jitpack, it always causes problems lol
i was using ActionBArApi.1.5.4
where can i download an other version
easiest solution: clone the ActionBarAPI repository, then do mvn install. Now you have the correct (latest) version in your local repository, and you can use it without jitpack
exactly
?
no, not the pom.xml directly
clone the whole repository
then open it in your IDE and do "mvn install"
if (KitData.get().get(kitname) == null) { how do i make it so it doesnt check for caps?
oh i see
now you can use it
make "what" not check for caps?
we don't even know what KitData.get() returns, so noone can answer it
this : ?
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
it returns a string
if KitData.get() returns a String, then KitData.get().get(kitname) makes no sense
new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
ItemStack item = new ItemStack(Material.WOODEN_PICKAXE);
player.getInventory().addItem(new ItemStack(Material.WOODEN_PICKAXE));
@tender shard does this work?
- In IntelliJ, do File -> New Project -> From Version COntrol
- Paste the GitHub link to the ActionBarAPI
- Let it download everything
- Double click on maven -> install
- when it's done, you can use it in your other project
why are you making the itemstack twice
what?
Please stop pinging me, I've already told you to learn basic java since noone can help you if you don't have the slightest idea about how java works
?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.
seems like you’re forgetting something
i have no clue what your problem is in first place
you are making a itemstack variable for no apparent reason
I want to add an item via a command, and I was told that I have do to this
this link : https://github.com/ConnorLinfoot/ActionBarAPI
? (and oh i didnt know u could do it like that)
.addItem
they don't know the difference between variables and instantiated objects, which is why I keep sending them the ?learnjava command, which they ignore
bro
@quaint mantle you should really look at some of the links in ?learnjava
there are like 50 links
there are 5 actually
idk
i did everything u said but when i try to add it, it doesnt work :
did you even follow any directions you were told
but shouldn't it be possible without it? After all, the event from before is cancelled.
all of them
it is in my intelJ
just try and see, maybe my tip is bullshit
you don't even have the ActionBarAPI in your pom.xml ?
Ho is it with Inventory holder? on this post for long time ago it should be removed https://www.spigotmc.org/threads/what-is-the-inventoryholder-interface.342812/#post-3185954 .
Hm it not allow me to post everything here, because of language (you should fix the bot).
it won't get removed, but it was never meant to be implemented by yourself
try this https://pastebin.com/Zm7vpWsi bot not allow me to post
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I not use bad words even
anyway, using a title to identify inventories is a very bad idea
simply keep track of the open inventories in a collection or map
I ofc don´t use title, I have to set metadata on player (for know location as one example)
Is something some not work if you not make your own inventory holder. For example when player close inventory I need to know location (and the InventoryCloseEvent for example only will return player loc (if you use custom inventory))
location of what?
In this case a custom container player clicked on and open custom inventory (I solve it with set temporary metadata on player). But also to know if it right inventory player click on and is not normal chest or other custom inventory from other plugin.
no but if you make your own inventory holder can you fix that
but some say you should not use that
You could use Inventory#getLocation() if the player is using something that returns an inventory. (Chest, Dropper, etc) Then compare if that location is your custom block.
would it make sense to do permissions like these?
well yeah by he says he’s making a custom inventory
so it won’t have a location
is not have location or any data at all, as normal continer have.
only if you implement inventoryholder and fix it self. but some say you should not use that.
like this post
You really shouldn’t be using it though.
I usually find the best way of making custom inventories is to make an abstract class with methods for clicking, opening, closing, etc that extends CraftInventoryCustom
What’s the logic here? A player clicks a custom block/container and it opens a custom inventory?
The custom inventory just being Bukkit#createInventory()?
lol are my permissions making sense?
it has custom propriety and yes it store items also.
But will it be tied to a block in the world? Meaning if the player broke the custom container, all of the items would drop? Or?
currently yes, not find better method for it.
You could omit plugin from the permission node.
yes or it will stay in "chest or other container you have chose"(save it as metadata on the item) . Will be fun if player break chest with 500k items XD
ye i know its just an example
why are you tying it to a block in the world if it’s not directly related to that block?
i’m so confused
Is this similar to shulker boxes?
it seems like you’re using block locations and player metadata as a weird hack for checking the type of inventories
Yes it is but the block (in this case a chest or barrel) but it have no items (only a placholder/dummy).
you cant open an inventory in an inventory event
What? Yes you can.
I added spigot to the project but for some reason it doesn't work
it’s not an inventoryopenevent though
it’s playerinteractevent
name is kind of confusing i guess
try it
It depends on the inventory event does it not?
You can open another inventory in the inventory click event.
I hope this is ok https://youtu.be/fiJW6ZTgyVA made fast video. I save the items on close event (is way need location).
You can if you close the inventory and then open another one I believe
ok so i have got unregistering commands working, but i would like to know how i can register this command again? (if player reloads config)
I actually think we're talking about when a player clicks on a chest block to open it's inventory, cancelling that, and opening a different one, which is definitely possible. Honestly have no idea how we got to talking about inventory events lol
yes you can do that in click event or any event you want XD
Yeah, I'm not the one who asked the question though lol
ok so the chests and barrels are actually important for how the plugin is supposed to work right
or use playermoveEvent XD
they aren’t just there as a way of checking the inventory
Delays aren’t even necessary in some cases though
why
what?
?jd
ik that the click hasn’t actually happened
but i haven’t had any problems just opening inventories on click events
and delaying inventory opens can occasionally cause issues
That’s odd.
I have opened inventories without delays and just updated the players inventory right after and haven’t ever had an issue.
currently yes (but can use any container some support inventory move event really (if not it will not work add items to the container and need make custom code for that)).
same here I use it on click event to 🙂
was a joke on open inventory every time player move 🙂
@eternal oxide could this be one of those javadoc comments that are actually meant for older versions and never got removed? I haven’t had issues with just opening one right after the other.
Close the inventory gui before you open a second one.
maybe, but i’ve found an insane amount of dupes on pretty big servers just because they delay closing/opening inventories by a tick
Also if you close and then open an inventory, your mouse gets reset to the center of the screen.
That isnt that bad is it 😛
You can;t dupe with delaying an open. You can with delaying close
Trust me it is. nothing but pain
I have had issues with opening inentories if not delayed before
I have to agree, is not fun at all I think #updateInventory do same thing (i think is way I never use it).
i mean i’ve found a lot before because they delayed opening by a tick
I've never had any issue with a delayed open
Hi, I've been testing the EntityDamageByEntityEvent event for a while and I want to know if the player shot (damaged) the sheep with a bow
This is what i have for now
yes thats how
Do you have some idea here? I use PlayerInteractEvent so player never open the real inventory.
if you miss my post before so is the plan only use containers (so I don´t have to do custom code to add items)
I have a problem now, I want to kill the sheep directly or make it disappear without leaving drops
You could just cancel the interact event if they click on that certain location then open the inventory.
I'm doing an event for a youtuber and I need that
#remove()
o
Or clear the drops
let me try
looks like i need to use other event for that
If you still want the death animation.
nah i don't need it
Like this then?
yea
Okay tysm
you check if the entity is a sheep right?
won’t show the death animation though like shadow said
ofc
is what I do, but when for example player close inventory I need to know the location of were player clicked and is way I use metadata. I could cache it but can be fast messy.
nah no problem
I'll playsound the player to indicate that
Oh
lol
yes sure
i almost forgot it
tysm
like this then
Well, there are workarounds. You cloud store the player and the inventory in and object and work with that.
You could get the block the player is looking at.
You could try using Inventory#getLocation(). This may not work unless you can also set the location.
o
that works too
@EventHandler
public void onDamage(EntityDamageByEntityEvent event){
double damage = event.getDamage();
if (!(event.getDamager() instanceof Arrow)) {
return;
}
Arrow arrow = (Arrow) event.getDamager();
if (!(arrow.getShooter() instanceof Player)) {
return;
}
Player shooter = (Player) arrow.getShooter();
if(event.getEntity().getType().equals(EntityType.SHEEP)){
Sheep sheep = (Sheep) event.getEntity();
EntityDamageEvent.DamageCause cause = sheep.getLastDamageCause().getCause();
if(cause.equals(EntityDamageEvent.DamageCause.PROJECTILE)){
sheep.setInvulnerable(true);
sheep.remove();
shooter.playSound(shooter.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 10, 1);
}
}
}
I got this
Guys do Streams in Java preserve order?
@EventHandler
public void onDamage(EntityDamageByEntityEvent event){
double damage = event.getDamage();
if (!(event.getDamager() instanceof Arrow)) {
return;
}
Arrow arrow = (Arrow) event.getDamager();
if (!(arrow.getShooter() instanceof Player)) {
return;
}
Player shooter = (Player) arrow.getShooter();
if(!(event.getEntity() instanceof Sheep)){
return;
}
Sheep sheep = (Sheep) event.getEntity();
sheep.setInvulnerable(true);
sheep.remove();
shooter.playSound(shooter.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 10, 1);
}
done i think
first one I only need player and location in the cache I think (can then get player on close event and see if it exist in the map). I not really need the inventory (I get that from location (is how my custom system work, location is key do access all data to inventorys)).
second one can you be unlucky and player not look on right block when close inventory (I think you can look on wrong block when open a inventory in some cases (yea you can if you get moved)).
last one sadly not work on custom inventory's if I not use inventory holder.
How would I know that
why
hold on, booting up my ide
i mean
if it’s like a mini game or something it would make sense to only play it to the shooter
to indicate they hit it
his followers will enter and shoot sheeps
It would be a chaos that play the sound for everyone
do you mean the order the collection was in before it got to the stream?
I'll make a message in the chat too i think
i made a team system then i can message all the team at the same time
like &a+1 or something like that
yes im just starting it
there's no point in not doing so.
I have this code: https://paste.md-5.net/uvitugoner.php
it's for reflection mostly
because of my mappings and stuff, and I use the Index of a method for example, to decide which one I want to execute, which is a better way of doing it then specifying for example, methods with names such as a, b, c, d, e, f
streams do have a sorted() method so you could use that
I just can "disable pvp" from EntityDamageByEntityEvent right?
if the order before the stream was already sorted, then it should be no problem using the sorted() method on your streams. that should preserve the order it had before
this is worthless..
I mean the order of the ArrayList
could make your own Comparator maybe? not too sure what would be the best way to do it
no I can't
because there's no way to compare the methods
at that point I might as well just search for a method with name x, and parameters y, which defies the point of even using indexes
System.out.print("Hello World");
i recommend using Arrays.asList(arr) instead of Arrays.stream(arr).collect(toList())
I just can "disable pvp" from EntityDamageByEntityEvent right?
I was bored enough to do it that way..
or do everything stream related in one go:
List<Method> methods = Arrays.stream(cls.getDeclaredMethods())
.filter(method -> (method.getReturnType().equals(returnType) || method.getReturnType().getSimpleName().equalsIgnoreCase("void") && returnType == null) && Arrays.equals(method.getParameterTypes(), parameters))
.collect(Collectors.toCollection(ArrayList::new));
eh Ig thank you.
this is prob the best approach
well I don't think I want to use streams if they literally ruin the point of using indexes.
and do not keep the order of array lists.
???? that's cap?
since it returns an Arrays.ArrayList, not an arraylist
yes i know
Hey guys, can someone please tell me how to change the attack damage of an ItemStack? With the ItemMeta?
use attribute modifiers
might be a stupid question, but what does String... aliases do in a methods arguments?
I know but how?
so would i do method("thing 1", "thing 2")?
ok
void someMethod(String... args);
someMethod("test");
someMethod();
someMethod(new String[]{"test", "hello"});
// all of these are valid```
itemMeta.addAttribute(Attribute.GENERIC_ATTACK_DAMAGE,
new AttributeModifier("<name>", /* strength */ 1,
AttributeModifier.Operation.ADD_NUMBER /* operation */
)
wow ty
you might want Operation.ADD_NUMBER
ty!
i prevented but people still can execute it
also @vague swallow u might want to use Operation.ADD_NUMBER
with groupmanager
yes thank you
What's the different between MULTIPLY_SCALAR_1 and ADD_NUMBER?
the operation specifies how the provided strength/amount influences the source number to get the result
so its kind of in the name
MULTIPLY_SCALAR_1 adds 1 to the strength and multiplies it by the original value
ADD_NUMBER just adds the strength to the original value
hey, so i have this very simple code :
@EventHandler
public void onPlayerClick(PlayerInteractEvent event) {
Player player = event.getPlayer();
Bukkit.broadcastMessage("click");
}
that i made just to test things, but when a player clicks on the right, right clicks or anything, i dont get any message in chat. any idea why?
register it
did you register the listener
in your main class
competition be like
java.awt kekw
how strange
i can unregister a command in the start of the server, but not during runtime? and i also cant register a command at runtime.
then the plugin couldn't even start
BRO LMAO I USED A LOT of other events and they worked but rn my onEnable just disapeared
yes it could
ctrl z time
without and OnEnable method?
frick i had code in my onenable
dont need an on enable
ctrl z
I mean yes but the plugin couldn'T do anything
you can register a command at runtime with reflections and the commandmap
yes i have that but its not working
let me try if i can register in start
ur tryin what?
yeah you do lol
unregister the command then register it in the on enable metod
ok yeah i can register and unregister in the on enable but not anywhere else?
think u gotta update the entire thing
@tardy delta
cuz onEnable is the only thing thats called at startup
i guess if your command is present in the plugin.yml in the jar, you can still register it at runtime
PluginCommand#setExecutor
yes but i have in my reload command, if the config says enable this command enable it. otherwise disable it
read the config and depending on if its true or false, register the command
show code
hey im not very smart can i get some help please
?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!
are you getting the config from another plugin or smth?
no
why asking it to the pluginmanager then
gtg to next period be back in a bit
just grab your plugin's instance
so im just starting making plugins but for some reason whatever im doing isnt working. Im making a 1.18.2 plugin and imported everything, but i cant import org.bukket.plugin etc. Its saying 'The package org.bukket is not accessible'. I have imported the module though.
shhhhh
?bootstrap is maybe something
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
cause it works
if it aint broke dont fix i
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
use that instead of that crappy shit
well thats not the issue
oh i already have that
Gosh dang can't get a break around here
They are searching our classroom with a drug dog
Hey. So i swapped to 1.18.1 and added the jar file but its still not importing?
@tardy delta soooooo this happened
when i enable it
i assume i need to set an executor
uhm yes?
hey little question, i have a text that is written with like "&6text" but when i try to for instance player.sendmessage it, it doesnt work. How do i do it? (ps : i need it this way, cuz normally i use ChatColor but this time text is already prepared)
mb thats when i disable it
but also how would i set the executor
try using ChatColor maybe?
...can u read my message
no sorry
ChatColor.replaceAlternateColorCodes('&', "&4text")
i usually use ChatColor but i am making a plugin for a server and they already have text prepared
thxx
ChatColor.translateAlternateColors('&', "&c No");
bruh
thx
@tardy delta do i set the executor before or after registering, or does it matter?
wdym registering?
I think player.getTargetBlock(null, 5)
like adding it to the commandmap
ok
is it possible to apply velocity while still having gravity disabled
floating thro space uwu uwu
ok but now why after unregistering it, does the command cease to exist?
Hey short Question: i tried to make a command which places a chest with persistent data at the location from the Player:
https://www.toptal.com/developers/hastebin/hoyarucabe.php
I also made a Listener to check if a chest which is opened by the player has the persistent data:
https://www.toptal.com/developers/hastebin/aqaxixafec.csharp
If the clicked Chest has unique persistent Data it should cancel to open the chest and open an other inventory instead
i added a message which will send to me when i use the command. But if i use the command the chest is set but i dont get the message from the server. Also if i click on the chest it opens normally and not the inventory i created though i cancelled the event to open the chest normally.
Probably something with setting the persistent data in the command went wrong.
Can maybe somebody help me with that?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
idk
it still works fine if done in the onEnable
no need to update the state btw
?
when I use event.getInventory() in OnCraftEvent do I get the 9x9 inventory of the crafting recipe?
How can I create a pastebin link with a specified text from my minecraft plugin? I want to give player a sort of item sharing by using some commands that will be listed there in the pastebin
it has something to do with the set executor, it unregistered fine before
look at pastebins api
using the pastebin api prolly
guys what java version require 1.8.9 spigot?
can i modify the name of the name of the item in the hand of a player directly like that :
player.getItemInHand().getItemMeta().setDisplayName(ChatColor.GOLD + "Paume de Zéro");
?
or do i need to give it again
give it again
ye
how
Inventory#setItem(int, ItemStack)?
k
get the main hand slot first i guess
okey lemme try
is there a way to disable entity ai while keeping gravity
how do i get it?
Ok lemme check
PlayerInv#getHeldItemSlot iirc
...yeah i m stupid lmao didnt see it
just 2 sec google
that's a really cool idea ngl
i especially like the stackable "big chest" container
?paste
anyone have java 8 download link?
yeah and is working with hoppers to (both take and pull in items). You can limit amount you can have in the container (if you left it to unlimited you can store billions of items (only your jdk (java) implementation and ram can stop you)).
how do I use input stream and put it into a file?
you open an output stream to a file, transfer the bytes using inputStream.transferTo(outputStream) and then close both of them
i think i got another way
Ancient one
can u give me link please
Java 8
do not java 11 also work to start 1.8.8?
Reader targetReader = new InputStreamReader(in);
FileConfiguration fc = YamlConfiguration.loadConfiguration(targetReader);```
https://java.com/en/download/ this one?
Sure
That should be in a try-with-resource block
oh you meant to load its as a config
yeah I think I started 1.8.8 with 11 🙂 thanks you confirm it.
https://paste.md-5.net/ikuqiwoqaz.java why this doesnt work if its not in the onenable
hey i have a question
i have one too
ask me
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'm comparing an array of 9 ItemStack variables like this and it returns false when it should be true.
for (int i = 0; i < items.length; i++){
if (items[i].isSimilar(Coins.one) && items[i].isSimilar(Coins.ten) && items[i].isSimilar(Coins.hundred) && items[i].isSimilar(Coins.twoHundred) && items[i].isSimilar(Coins.fiveHundred) && items[i].isSimilar(Coins.thousand) && items[i].isSimilar(Coins.twoThousand) && items[i].isSimilar(Coins.fiveThousand) && items[i].isSimilar(Coins.tenThousand)){
return true;
}
}
return false;
}```
``` public boolean isSimilar(ItemStack first,ItemStack second){
boolean similar = false;
if(first == null || second == null){
return similar;
}
boolean sameTypeId = (first.getType() == second.getType());
boolean sameDurability = (first.getDurability() == second.getDurability());
boolean sameAmount = (first.getAmount() == second.getAmount());
boolean sameHasItemMeta = (first.hasItemMeta() == second.hasItemMeta());
boolean sameEnchantments = (first.getEnchantments().equals(second.getEnchantments()));
boolean sameItemMeta = true;
if(sameHasItemMeta) {
sameItemMeta = Bukkit.getItemFactory().equals(first.getItemMeta(), second.getItemMeta());
}
if(sameTypeId && sameDurability && sameAmount && sameHasItemMeta && sameEnchantments && sameItemMeta){
similar = true;
}
return similar;
}```
lmao
how is it going to be equal to all of the ones then
hey i am making a plugin and want to check if the player doesnt have an armor.
I did this :
if(getRole(player) == Role.Geru){
if (player.getInventory().getHelmet().getType() == null && player.getInventory().getLeggings().getType() == null && player.getInventory().getBoots().getType() == null && player.getInventory().getHelmet().getType() == null){
player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 20000000, 0));
}
}
But it doesnt work (it checks it every second if u want to know)
that’s just gonna throw a ton of npes
wow wtf damn
so just player.getInventory().getBoots()
== null?
yes
it's 3 am for me my brain is dead
loop the armorcontents
if (container.get(type, PersistentDataType.STRING).equalsIgnoreCase("common_cow")) {
SpawnCommonCow scc = new SpawnCommonCow(this.plugin);
scc.spawnPet(player, 2);
} else if (container.get(type, PersistentDataType.STRING).equalsIgnoreCase("common_cat")) {
SpawnCommonCat scc = new SpawnCommonCat(this.plugin);
scc.spawnPet(player, 2);
} else if (container.get(type, PersistentDataType.STRING).equalsIgnoreCase("common_dog")) {
SpawnCommonDog scd = new SpawnCommonDog(this.plugin);
scd.spawnPet(player, 2);
}
My code is filled with these, is there a way to better put this? I need to implement more of this.
how can i check when it becomes day?
add a name value to all of the pet classes
stream all pet values, check if the string is equal to one of the name values
I'd have to look up how that works
public interface HandleableUIContainerView<T extends UIContainer<? extends UIContainerView<T>>> extends HandleableUIView<T>, UIContainerView<T> {
}
now this is what i call generic lol
thats a lot of extends
but it works
.
that's legal
world.getTime();
thanks
its in ticks
https://minecraft.fandom.com/wiki/Daylight_cycle#24-hour_Minecraft_day
This will help also
20 ticks = 1 sec.
alright
im setting group managers default permission but players still can execute the commands i didnt put
its basically the same value you use in /time set vanilla command
24000 is the highest
24 hour * 1000 = 24000
why does it return long though if the maximum value of the time in minecraft is 24000
When I use an inventory of an anvil slot[2] should be the right slot of the anvil, right?
because yes
yes
ok
Should be the result slot
yeah
hey
Im having a problem with my plugin and am not sure why...
[19:46:04] [Server thread/ERROR]: Error occurred while enabling Testing v1.0 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.doctorleaf.testing.Testing.getCommand(String)" is null
at com.doctorleaf.testing.commands.helloCommand.<init>(helloCommand.java:15) ~[?:?]
?paste the hellcommand class
Class<?> main = Class.forName(ebr.hasBlockYml().mainclass);
How do I check if the class extends ExtensionBlock?
And if it does, how do I get the ExtensionBlock form of it
if you're registering command with command map, in order for getPluginCommand() to find your command object instance it needs to be instanciated via PluginCommand concrete class, which is final and cannot be extended afaik, so you'll need reflections probs
I'm attempting to iterate through an item's lore and insert a line at a certain point.
int insertIndex = 0;
for (int i = 0; i < lore.size(); i++) {
if (!(lore.get(i) instanceof TextComponent component)) {
continue;
}
String text = component.content();
System.out.println(text);
if (text.startsWith(" ")) {
insertIndex = i;
} else {
lore.add(insertIndex, Component.translatable(ChatColor.DARK_GREEN + " Nightmare Infused"));
}
}
This creates an infinite loop for some reason, and I have absolutely no idea why; am I missing something?
Feel free to tell me I'm stupid (I probably am).
nqkoi moje li za plugini?
english pls
either your lore.size() method returns garbage value or something's wrong but not here
from my perspective
Shouldn't that throw a CME?
you add a new line everytime
lore.size() increases everytime