#help-development
1 messages · Page 2123 of 1
Also modifying a private method does not break SemVer as the ABI of private methods can more or less be ignored
So differentiating between private and public method can have a large differences when it comes to API contracts
A private method is far more likely to change than a public one
oh ok
Geol so how would i use my thing
Now that you exlained that before i get mored dumb
You are on your own there, I have to go to bed now
I will send full code 1 sec
The only real way to make something plattform independent is to just rewrite the entire plattform to be plattform independent
Basically im designing a bosotrap system which allow me to code spigot and bungee plugins in the same way for registering events, listeners and commands
events?
those are heavily, extremely platform specific
but I mean
what you got so far?
I send code and you will understand
uh Ig
He is still stuck at the init logic
Yeah
ah good to know thanks
// Platform
public interface Platform<C, L, E> {
C getCommand();
L getListener();
E getEvent();
}
// Or boostrap
public interface Module<T extends Platform<?>> {
void onEnable();
void onDisable();
T getPlatform();
boolean fetch();
}
// Module
public interface BungeeModule extends Platform<Command, Listener, Event> {}
This is what i have at the moment
this entire thing seems kinda useless and yucky not to sound disappointing or anything but genuinely
Its okay many people told me
cause like you'd still need some class thats platform dependent on how listeners and commands are registered
What you can do is to create platform independent business logic/features
im curious about how thats supposed to work
but these small registration and bootstrapping abstractions are useless
and will help you diminishingly
I was trying to do something similar to lookperms
yes
But they logic its really complex
but this is not similar to what they do
cause they create platform independent logic
Oh its diff?
yes
for instance platform independent data model, data storage, api, scheduling logic, api implementation and collection utils
not bootstrapping
nor registration
that shit still goes into the spigot or bungee module
But thanks i apreciate
My big issue is that i need to create common class with a constructor argument of Platform
But them i need to pass the generics, and the generics differ if you are o bungee or spigot
So that the reason of getting stuck
mye?
is Platform, or Module gonna be the interface that the spigot plugin respective bungeecord plugin implement
not exactly clear
feels like you're circle depending two entry points here
The BungeeModule and SpigotModule will be implemented in the plugin
example?
Depeding if you want it for spigot or bungee
so whats the idea behind having this Platform interface then
To use it on library side
So then from therei can get the PluginManager and register the events, etc
🤔
That was my idea
uh
Im like super confused
cuz the registration logic could be incorporated into your Module derivatives
as thats pretty much platform depend logic
which Module derivatives are supposed to handle
according to your intentions at least
Yes
Its super mess
Because from Library side i dont know if you either using Spigot or Bungee
is this a library?
I dont know how to call it exactly
just explain the relation between this project and other conceivable dependents of this project
As maven or gradle dependency
My goal is to use on bungee and spigot plugins, it will contains commons things for them like Catching, User profile, Database
by the sounds of it you dont need to have anything regarding platform specific stuff
But for registering commands you need it
Oh ok
not everyone will want to have those commands of yours along with the rest of the classes right
And how would be done that part? Because i want to use same Command and Argument class on bungee and spigot
hey guys How Can I Use Config In My Main File In Another File?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
They ue brigadier
That why i didnt take as example
no they do not
No?
Thank You
Lol on their discord they told me that luckperms actually uses Brigadier
yes it uses commodore
but it doesnt rely directly on brigadier
it has its own command library sort of
which is then registered differently depending on platform
https://github.com/LuckPerms/LuckPerms/tree/master/common/src/main/java/me/lucko/luckperms/common/commands
https://github.com/LuckPerms/LuckPerms/tree/master/common/src/main/java/me/lucko/luckperms/common/command
Common
https://github.com/LuckPerms/LuckPerms/blob/master/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitCommandExecutor.java
https://github.com/LuckPerms/LuckPerms/blob/master/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitAsyncCommandExecutor.java
Bukkit/Spigot/Paper
yeah you use diff executors class
My goal is to have a common command and argument executor for bungee inthe same way
action handling and execution is written in common
Oh ok know i understan
then each platform executor just forwards it
Conclure
Why luckperms plugins are obsessed with threads, daemons, and things like that
wat
please can someone help me use this https://github.com/tchristofferson/Config-Updater
daemon just means like background process
a thread which runs as daemon doesnt have to be shutdown in order for the java program to terminate
threads are fundamental
especially when you want to optimize and scale data management horizontally
but also for things like talking to IO devices
such as file io or databases
can someone help
Oh ok conclure
Patient... You are not paying for instant support
i know
So if no one answer just wait
is there any ways to get translatable container inventory names via bukkit API
I may be a complete idiot, but I setup johnrengelman's shadowjar, and its not generating as a shadow jar.
Doesnt have you te method: Inventory#getName() or getTitle()?
Is there something wrong with my build?
Did you use maven-shade-plugin?
Where do I need to set that?
Im using Intelli
on the pom
that does return the title of the container inventory
but not the translatable key
what means him?
which client uses to determinine default locale name for unnamed container
gradle
dovidas, sorry but its there an option which return me a colored name but without the colors striped/take out
And that the problem
Maven and gradle are diff bulkshit
Should I send my build.gradle?
Crap
I tried gradle i get lot of errors and come back to my reliable maven
The error I recieve happens in the plugin startup code, and here is the error if this helps:
java.lang.NoClassDefFoundError: net/dv8tion/jda/api/hooks/ListenerAdapter
USE MAVEN
No
Just copy and paste your source code, into a new maven project and add the dependencies
Its simple
😂
Guys I wanna set boss.name to My Last message But How Can I get Varible from Chat Event (I have already chat event how can I set on config?)
is there any way to spawn a block to a location
yes
grap. I forgot how artifiactID works
how
nvm
That its wrong, config.Set() its a Void not a String
@sterile token Uhhh. Why is it forcing me in maven to use max 1.15.2???
oh hell no
Ah.... Then How Can I Get Varible From Event?
Sometimes dont listen to maven
I recommend reading the docs, because if not you wont never learn
But the methods its called Config#getString/int/()
Depending on what you need
If need a string config#getString() them, an int config#getInt()
Oh Thanks
?
?jd
this is what im searching (this is NMS class method remapped):
@Override
public Component getName() {
return new TranslatableComponent("container.inventory");
}
i want something like this but in bukkit api
what is this
to return TranslatableComponent
How to spawn a block
to make name of the item or the inventory correspond to the player's locale
where is the spawning method
eh, i'll just use adventure
Anybody here know gradle and shadow jars?
it has proper component support
Im not switching from gradle
Doesnt spigot support adventure?
because luckperms uses Adventure TextComponent and runs on every spigot version...
spawning it on world
www.google-is-your-best-friend
I checked google.
There is 0 results for my issue alone.
?
When I tried any results for my issue as well, for other searches?
0 of them fixed this.
I told you:
Location location = new Location(wordl, x, y, z);
location.getBlock().setType(Material.CHEST);
You can also use the ?jd to check what argument has a method
BukkitRunnable run = (BukkitRunnable) new BukkitRunnable() {
@Override
public void run() {
Location loc1 = new Location(Bukkit.getWorld("world"), 34, 2, 86);
Location loc2 = new Location(Bukkit.getWorld("world"), 34, 2, 88);
Location loc3 = new Location(Bukkit.getWorld("world"), 34, 2, 90);
Location loc4 = new Location(Bukkit.getWorld("world"), 36, 2, 86);
Location loc5 = new Location(Bukkit.getWorld("world"), 36, 2, 88);
Location loc6 = new Location(Bukkit.getWorld("world"), 36, 2, 90);
Location loc7 = new Location(Bukkit.getWorld("world"), 38, 2, 86);
Location loc8 = new Location(Bukkit.getWorld("world"), 38, 2, 88);
Location loc9 = new Location(Bukkit.getWorld("world"), 38, 2, 90);
loc1.getBlock().setType(Material.PUMPKIN);
loc2.getBlock().setType(Material.PUMPKIN);
loc3.getBlock().setType(Material.PUMPKIN);
loc4.getBlock().setType(Material.PUMPKIN);
loc5.getBlock().setType(Material.PUMPKIN);
loc6.getBlock().setType(Material.PUMPKIN);
loc7.getBlock().setType(Material.PUMPKIN);
loc8.getBlock().setType(Material.PUMPKIN);
}
}.runTaskTimer(Main.getInstance(),0, 100L);
This should spawn all the locations pumpkin right?
oh that is very repetitive
Bukkit.getScheduler().runTaskTimer(Main.getInstance(), () -> {
World world = Bukkit.getWorld("world");
if(world == null) return;
for (int x = 0; x < 6; x += 2) {
for (int z = 0; z < 6; z += 2) {
world.setType(new Location(world, 34 + x, 2, 86 + z), Material.PUMPKIN);
}
}
}, 0, 100L);
try this
@hasty prawn Do you have experience with gradle?
[15:41:31 INFO]: [EmeraldsPlugin] Enabling EmeraldsPlugin v1.0.0
[15:41:31 ERROR]: Error occurred while enabling EmeraldsPlugin v1.0.0 (Is it up to date?)
java.lang.NoClassDefFoundError: net/dv8tion/jda/api/hooks/ListenerAdapter
at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
at java.lang.ClassLoader.defineClass(ClassLoader.java:1012) ~[?:?]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:193) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:587) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:104) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:99) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
at me.emerald.emeraldsplugin.EmeraldsPlugin.onEnable(EmeraldsPlugin.java:29) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:525) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:439) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:262) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassNotFoundException: net.dv8tion.jda.api.hooks.ListenerAdapter
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:147) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:99) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
... 20 more
It keeps erroring for 0 reason
How do I shade it
@hasty prawn
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}
group = 'me.emerald'
version = '1.0.0'
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
maven {
name = 'jeff-media-public'
url = 'https://hub.jeff-media.com/nexus/repository/jeff-media-public/'
}
maven {
name = 'minecraft-repo'
url = 'https://libraries.minecraft.net/'
}
}
dependencies {
implementation 'org.projectlombok:lombok:1.18.24'
implementation 'org.jetbrains:annotations:23.0.0'
implementation 'net.dv8tion:JDA:5.0.0-alpha.9'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2.2'
compileOnly 'com.mojang:authlib:1.5.21'
compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT-shaded'
}
def targetJavaVersion = 17
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
You can see here I have it shaded
OH
somebody finally told me how to do it
ty
yes, also above
fixed
When I'm using redis to communication between the servers can I directly publish message to the certain server (server1 -> server2) or better way is doing it through the proxy (server1 -> proxy -> server2)?
public class Items {
public static ArrayList<?> itemClassList = new ArrayList<>(){{
add(new IronCoin());
}};
public static HashMap<String, ItemStack> itemList = new HashMap<>();
public static HashMap<String, ShapedRecipe> recipeList = new HashMap<>();
public static void newItem(String locName, ItemStack item){
itemList.put(locName, item);
}
public static void addRecipe(ShapedRecipe recipe){
recipeList.put(recipe.getKey().getNamespace(), recipe);
Bukkit.getServer().addRecipe(recipe);
}
public static ItemStack getItem(String locName){
if(itemList.get(locName) != null){
return itemList.get(locName);
}
return null;
}
public static HashMap<String, ItemStack> getAlLItems(){
return itemList;
}
public static void setupItems(){
try {
for(Object cls: itemClassList){
Class<?> mClass = cls.getClass();
Method m = mClass.getMethod("setupItem");
m.setAccessible(true);
m.invoke(cls);
Bukkit.getServer().getPluginManager().registerEvents((Listener) cls, EmeraldsPlugin.jp);
}
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException ignored) {}
}
}
It claims that itemList is null at itemList.put(locName, item);
any reason why?
static abuse what the fuck
so is the garbage collector
:/
can you just let me know what is wrong instead of making fun of me lol
itemList shouldn't be null, but locName might
more making fun of the garbage collector
but yeah holy mother of static
Am I wrong to think that server does not send translatable keys via packets to the minecraft clients? Since i can't seem to find inventory implementation which utilise TranslatableKey() inside NMS
depends, it does often
due to localization
wouldnt the client handle that
for example, client could handle localization just by knowing item namespace key
why would you send a translatablekey
When I'm using redis to communication between the servers can I directly publish message to the certain server (server1 -> server2) or better way is doing it through the proxy (server1 -> proxy -> server2)?
with redis you don't need proxies
redis acts as a type of proxy
just send the messages directly
Yeah I know
redis can't tell the difference between a spigot server, a proxy server and just some idiot java program
Lemme show you my statics lol:
public static Nameable CHEST_9X1 = Nameable.CHEST_9X1;
public static Nameable CHEST_9X2 = Nameable.CHEST_9X2;
public static Nameable CHEST_9X3 = Nameable.CHEST_9X3;
public static Nameable CHEST_9X4 = Nameable.CHEST_9X4;
public static Nameable CHEST_9X5 = Nameable.CHEST_9X5;
public static Nameable CHEST_9X6 = Nameable.CHEST_9X6;
public static Nameable BARREL = Nameable.BARREL;
public static Nameable DROPPER = Nameable.DROPPER;
public static Nameable DISPENSER = Nameable.DISPENSER;
public static Nameable HOPPER = Nameable.HOPPER;
public static Nameable BREWING_STAND = Nameable.BREWING_STAND;
public static Nameable ENCHANTING_TABLE = Nameable.ENCHANTING_TABLE;
public static Nameable MERCHANT = Nameable.MERCHANT;
public static Nameable SMOKER = Nameable.SMOKER;
public static Nameable SHULKER_BOX = Nameable.SHULKER_BOX;
public static Nameable FURNACE = Nameable.FURNACE;
public static Nameable BLAST_FURNACE = Nameable.BLAST_FURNACE;
these are enum emulation classes
its legal
just for you know
pov: Enchantment
lol
I'm really trying to figure this one out...
Like, for one, why? Secondly, surely that's not possible. Though I don't understand the context of this. Are these constants in an enum? Or are they referring to themselves?
That's referring to another statics
its basically emulating enum inheritance
but with classes
You guys are disgusted with enum static abuse
look at this nms then
?paste
Well yeah but that at least sort of makes sense
that's basically what i've did, but way less
They're constants of types not equal to themselves 
Is this in a different class?
If so, that really does lead back to my question of "but why" lol
It's not like you're restricting the type or anything
These static fields are pointing to the static fields of the inner class
which are instances of that class
Oh, okay, THAT makes more sense
these are basically convenient static fields
Without context I could not at all decipher that 
just for my lazy ass, to not write Type.Nameable.STONECUTTER and just Type.STONECUTTER
which both return basically the same thing, and by using this fake "enum" trick it can restrict particular "enums" from compiling due to how class inheritance works (compile time error checking, yay)
that way it looks from the IDE view more like an enum class
but with inheritance of methods
but ofc its fake
since its done via classes and enums cannot be extended sadly
in short terms, im doing the something similiar ProtocolLib does with their PacketType class
task = new BlockOutlineV2().runTaskTimer(this, 0,2); ... task.cancel()
does this do what i expect it to?
task = new BlockOutlineV2().runTaskTimer(this, 0,2); starts a task and gives task reference i assume
then task.cancel() cancels said task
i think task.cancel() is sufficient after looking at the code of what it does
==============
is Damageable supposed to have a getDamage() method?
ah i had the wrong Damageable
🥲
lol. is that because you've done the same thing or something else?
it’s just too easy to import the wrong thing
anyone have the server forks relations chart? i tried googling it but couldnt find it
hey rq sorry to bother
trying to come up with glitch prevention for a crop yield plugin
does anyone know difference between entity and block explosion event?
also, if you remove a block from the list generated by (ExplosionEvent).blockList, does that preserve the block?
i don't know if you Asked this
But here
This is the Usage
I want to create a shop inventory that updates based on the player's items (how much of a certain item they have). I want to update the inventory every time the player opens/purchases the shop. Should I store the inventory per player and update it that way or do something else?
render it once, update every time the player picks up an item, while the menu is active
damn no love
yes
BlockExplosion is for an individual block, EntityExplosion is a general explosion called from an entity (dragons walking through blocks are considered explosions too)
BlockExplodeEvent says that a block was broken via an explosion, EntityExplodeEvent says that an entity exploded x blocks
so if I open an inventory that is saved under the player, I can edit that in a different method and it will update right?
setting items on an open inventory will update in real time, yes
thanks
Hey so I am trying to share data from one plugin to other plugins, what would you all recommend to go about that? My data (for now) is just a list of words/phrases that aren't allowed in things such as nicknames, custom suffixes, etc.
register one plugin as a ServiceProvider
i've tried that already, whenever I try to get it, though, I get a null value
in your second plugin you have to get the provider after its been registered. so add a depend in your plugin.yml
still null
show code
getRegistration not load
oh yes I believe I have tried that previously as well, let me double check though
yep still null
does yoru second plugin have a depend entry for the first in its plugin.yml?
yep
Then no reason it shoudl not work
the debug msgs in that pastebin also give this:
[01:12:04 INFO]: blockedwordsinterface registered for: false```
that seems to say you are not registering yoru provider
Silly question but are you seeing the debug from your provider at startup?
yeah I have that debug as well, here it is:
[01:14:26 INFO]: BlockedWordsInterface.class.toString() == interface com.github.dripmh.dripapi.api.blockedwords.BlockedWordsInterface
[01:14:26 INFO]: org.bukkit.plugin.RegisteredServiceProvider@50585b58```
ok The only thing it could be otherwise is you are shading a copy of yoru first plugin into yoru second by accident. Thereby making the interface class not match
yeah I am shading it, how would I prevent that from happening?
you set it to provided so its not copied
yeah i love you so much mate
np 🙂
thanks ❤️
this might be a silly question, but is there a "standard" design for developing inventory menus?
no
The design is 100% up to you
The only "standard" is abiding by the rules in the InventoryClickEvent docs when processing it
alright. i guess i was hoping there was a tried and true design that was universal... oh well. ill just refactor my menu from scratch, because it's logic is messy
i was unaware of these rules. thank you for that.
Hey, how would I rotate a vector a little bit to the left or right
Vectors have a RotateAround method
Yeah, I'm confused a little on how to use it, I've tried rotateAroundX, but obviously, it just launches backwards when I'm facing north and launches to the side when I'm facing west/east
rotate around Y if you want to affect the Yaw
Axis can be thought of as masts. Y is a vertical mast (up/down)
Hmm, still seems to be a similar issue of it'll go backwards if your facing the opposite direction, have any suggestions?
what are you attempting to do?
Shooting an armorstand
I want to be able to alter the velocity so it shoots a little to the left or the right if I tell it to
for accuracy?
The opposite, to make it less accurate if they don't shoot when the bar isn't in the middle
Not sure what it's to simulate tbh lol, was told to do it tho
If its going backwards you are likely rotating it too much
No because when I face the other way it doesn't go backwards
It works the way I want it to when facing north
The rotateAroundY part is me trying to rotate it to the left
When I rotate it to the right, it's -3
3 is a LOT of rotation
Wait that might be the reason hold on lol
An example of using rotateAround https://paste.md-5.net/odonafubiv.java
there are two methods there, horizontal and vertical
Ah thank you very much I'll take a look
Yea it was too much lol
I need urgent help
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!
Im confing a server with mods and plugins using magma
and i configured the PermisionPex (and i used other plugins) but i cant see the prefix in chat
?ask Im configuring a server with mods and plugins using magma with bukkit
and i configured the PermisionPex (and i used other plugins) but i cant see the prefix in chat
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!
would there possibly be a way to make a player, be source of light, and create light for other players when it's dark?
This is for coding plugins. Try asking in #help-server instead.
what is it called when you use static {...}?
https://www.spigotmc.org/resources/lightapi.4510/ i think this library does that
found it. its just called a static initializer block
public static HashMap<String, ItemStack> itemList = new HashMap<>();
public static void newItem(String locName, ItemStack item){
System.out.println(itemList);
itemList.put(locName, item);
}
It claims itemList is null. Why?
The class is public, and I see 0 reason for it to be null.
you might need to use .putifEmpty
Whats that?
Also you are printing before putting anything in it
I was checking to see if it existed
It returns null when printing
does putIfAbsent work if its not absent?
oh yes that one sorry
No, I mean: Does it still work if its not null
it wont do anything if something is in it, i dont think
question out of curiosity. if you empty it after using put, will itemList return to null? (id assume not?)
that i’m not certain
Heres my question: Why is a HashMap returning null if nothing is in it
That makes 0 sense
And is completely stupid
null means nothing
Why not just return an empty HashMap?
that’s why it’s returning null
because nothing is in it
how would you represent an empty hashmap?
as [] or {}
and just allow people
to use .put
on it
:/
you’re gonna have to talk to Oracle about that
god damn I will
XD
lol. rebel against language design. :)
@hot fjord Okay your wrong, the variable itself is null
for some reason
just tested that, and its returning null
putIfAbsent means that it puts it IF the key is not existant inside the hashmap
java.lang.ExceptionInInitializerError: null
at me.emerald.emeraldsplugin.EmeraldsPlugin.onEnable(EmeraldsPlugin.java:35) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:525) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:439) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:262) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3359-Spigot-dbf4938-4f5d59a]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.HashMap.putIfAbsent(Object, Object)" because "me.emerald.emeraldsplugin.data.items.Items.itemList" is null
at me.emerald.emeraldsplugin.data.items.Items.newItem(Items.java:24) ~[?:?]
at me.emerald.emeraldsplugin.data.items.misc.IronCoin.<init>(IronCoin.java:45) ~[?:?]
at me.emerald.emeraldsplugin.data.items.Items$1.<init>(Items.java:17) ~[?:?]
at me.emerald.emeraldsplugin.data.items.Items.<clinit>(Items.java:16) ~[?:?]
... 12 more
well if you are printing that then the hashmaps tostring could be deceiving you? just guessing.... apparently completely wrong guess. lol
im not even using tostring when printing to console
im printing the hashmap directly
it is returning null
public class Items {
public static ArrayList<?> itemClassList = new ArrayList<>(){{
add(new IronCoin());
}};
public static HashMap<String, ItemStack> itemList = new HashMap<>();
public static HashMap<String, ShapedRecipe> recipeList = new HashMap<>();
public static void newItem(String locName, ItemStack item){
itemList.put(locName, item);
}
public static void addRecipe(ShapedRecipe recipe){
recipeList.put(recipe.getKey().getNamespace(), recipe);
Bukkit.getServer().addRecipe(recipe);
}
public static ItemStack getItem(String locName){
if(itemList.get(locName) != null){
return itemList.get(locName);
}
return null;
}
public static HashMap<String, ItemStack> getAlLItems(){
return itemList;
}
public static void setupItems(){
try {
for(Object cls: itemClassList){
Class<?> mClass = cls.getClass();
Method m = mClass.getMethod("setupItem");
m.setAccessible(true);
m.invoke(cls);
Bukkit.getServer().getPluginManager().registerEvents((Listener) cls, EmeraldsPlugin.jp);
}
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException ignored) {}
}
}
ignore my static abuse
im lazy as hell
this is my code
well im pretty sure java defaults to calling toString if the object has it when you print. though that's clearly irrelevant here 🤣
i do it too. though i dont know the better alternative
ah lol
i wonder if its cause im calling a Class < Different Class < Back To The Original Class
also i just learned about the reflection system the other day so that looks insane to me...
Your itemList is null?
Yes
can I update the name of an inventory without closing it?
Also, I just took the liberty
yes
With packets
public class Items {
public static ArrayList<?> itemClassList = new ArrayList<>(){{
add(new IronCoin());
}};
public static HashMap<String, ItemStack> itemList = new HashMap<>();
public static HashMap<String, ShapedRecipe> recipeList = new HashMap<>();
public Items(String locName, ItemStack item, ShapedRecipe recipe){
itemList.put(locName, item);
recipeList.put(recipe.getKey().getNamespace(), recipe);
Bukkit.getServer().addRecipe(recipe);
}
public static ItemStack getItemFromId(String locName){
return itemList.get(locName);
}
public static HashMap<String, ItemStack> getAlLItems(){
return itemList;
}
public static void setupItems(){
try {
for(Object cls: itemClassList){
Class<?> mClass = cls.getClass();
Method m = mClass.getMethod("setupItem");
m.setAccessible(true);
m.invoke(cls);
Bukkit.getServer().getPluginManager().registerEvents((Listener) cls, EmeraldsPlugin.jp);
}
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException ignored) {}
}
}
SERIOUSLY
WHY
DOES THIS ERROR
THERE SHOULD BE 0 REASON FOR IT TO ERROR
would it reset mouse position?
With packets, no
Unsure
I assume you are creating an item?
Creating an item Via a class, and saving it for later use.
@quaint mantle Somehow, I fixed it
Going to double check to see
But im praying it works
i didn't realize that making items have their own classes was useful in plugins tbh
this is going to sound strange, but refactoring is kind of fun
why does PlayerInteractEvent run twice
Once for each hand
ty
Check the result of getHand()
???
You should share some code?
Sure
public class InteractionEvent implements Listener {
//Values
Player p;
PlayerInteractEvent mainEvent;
ItemStack item;
ItemMeta itemMeta;
PersistentDataContainer itemPerst;
Block block;
TileState blockState;
PersistentDataContainer blockPerst;
//Event
@EventHandler
public void clickEvent(PlayerInteractEvent event) {
p = event.getPlayer();
mainEvent = event;
getItem();
getBlock();
switch(event.getAction()){
case RIGHT_CLICK_AIR -> handleRightClickAir();
case RIGHT_CLICK_BLOCK -> handleRightClick();
}
}
//Functions
private void getItem(){
item = mainEvent.getItem();
if(item != null){
itemMeta = item.getItemMeta();
itemPerst = itemMeta.getPersistentDataContainer();
}else{
itemMeta = null;
itemPerst = null;
}
}
private void getBlock(){
block = mainEvent.getClickedBlock();
if(block != null){
if(block.getState() instanceof TileState){
blockState = (TileState) block.getState();
blockPerst = blockState.getPersistentDataContainer();
}else{
blockState = null;
blockPerst = null;
}
}
}
//Handlers
private void handleRightClickAir() {
if(item != null){
Bukkit.getPluginManager().callEvent(new RightClickItem(mainEvent, "Air_Item_Off")); //Air clicked by Item.
}
}
private void handleRightClick() {
if(item != null && block != null && blockPerst != null){
Bukkit.getPluginManager().callEvent(new RightClickItem(mainEvent, "Entity_Item")); //Block Entity clicked by Item.
}else if(item != null && block != null){
Bukkit.getPluginManager().callEvent(new RightClickItem(mainEvent, "Block_Item")); //Block Regular clicked by Item.
}else if(item == null && block != null && blockPerst != null){
Bukkit.getPluginManager().callEvent(new RightClickItem(mainEvent, "Entity_None")); //Block Entity clicked by Nothing.
}else if(item == null && block != null){
Bukkit.getPluginManager().callEvent(new RightClickItem(mainEvent, "Block_None")); //Block Regular clicked by Nothing.
}
}
}
Here is the code that actually handles the event, to detect Right Clicks
public class RightClickItem extends Event {
private static final HandlerList HANDLERS = new HandlerList();
private final PlayerInteractEvent event;
private final String type;
public static HandlerList getHandlerList() {
return HANDLERS;
}
public RightClickItem(PlayerInteractEvent event, String type) {
this.event = event;
this.type = type;
}
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
public String getType() {
return this.type;
}
public PlayerInteractEvent getMainEvent() {
return this.event;
}
}
Using spigots eventApi, I made this
@EventHandler
public void onRightClickItem(RightClickItem event) {
Player eventPlr = event.getMainEvent().getPlayer();
ItemStack eventItem = event.getMainEvent().getItem();
System.out.println(event.getMainEvent().getHand());
if(eventItem == null)
return;
PersistentDataContainer itemPerst = eventItem.getItemMeta().getPersistentDataContainer();
if(itemPerst.get(NamespaceKeyList.getKey("coin"), PersistentDataType.STRING) != null){
eventItem.setAmount(eventItem.getAmount() - 1);
eventPlr.sendMessage(ChatColor.GREEN + "Gained 1 coin! Congrats!");
}
}
This runs twice, with getHand as "HAND" instead of "HAND" and "OFF_HAND"
@quaint mantle @waxen plinth
Sorry, I asumed you were apart of this help.
Only reason I pinged you.
Isn't it main hand and offhand?
It is, for 0 reason its returning hand twice.
Instead of hand and offhand.
I have 0 idea why
And did you check what Redempt said?
Yep, I checked the result obviously
First thing I did, and again:
Its returning hand twice, instead of hand and offhand.
This is really poorly written
I'm on mobile so I'm sure I'm not seeing all the things wrong
But why are you doing it this way to begin with
Because of how I handle my items.
You're writing methods that use instance fields instead of parameters when they should clearly be taking parameters
The event itself doesn't seem to have much reason to exist
And I'm quite sure the issue is in the logic of handling the event to call yours
What would be the issue with the logic however?
It seems perfectly fine to me
I'm on mobile
So I'm not going to try to read through it all with messed up formatting
Yes. It starts from PlayerInteractEvent.
then goes thru all of that.
Runs the event
etc
I just did this.
And explained this.
There are much more pressing issues with the code
It prints mainhand twice.
https://paste.md-5.net/vigujadive.cs ListenerEvent class.
https://paste.md-5.net/omowezagug.java RightClickItem class.
https://paste.md-5.net/deyikecusa.cs IronCoin class.
I just explained this-
whatever
I know that.
Im asking: Why is IronCoin running twice, but its hand is main hand wice.
intead of main hand and off hand
@quaint mantle What.
PlayerInteractEvent.
Its returning MainHand twice.
What the hell?
Yes, it is :P
Why is it firing twice?
Yes I Did.
I dont think you understand- Its returning main hand TWICE.
not offhand and mainhand each once.
hasdbads
Please
Read
I know.
Circles and circles
Im telling you, I checked.
Its telling me its main hand TWICE.
njasdijdsajdojasdaonlkjsjdsaokjdsa
seems like you both are stupid
I DID
Im trying to explain to you.
I chcked getHand.
When the event fires twice, it returns MainHand twice.
I said multiple times that the code quality is very poor
So doing a check for OffHand does nothing.
Clean code is easier to debug
I know this, at this time im redoing it.
Why don't you start by getting rid of your instance fields
Right now however, I want it to just function
None of them are needed
Terrible mindset
That's what gets you such bad code in the first place
Do not.
Guys calm down
The last thing I want is spoonfeeding.
hellow i have a question
Go on
I did, I tested, it returns Hand twice.
I also, tried doing a check.
It does the same thing
is dificult create a private plugin for sponge?
?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!
premature optimization bad
what is the discord sponge?
It's not premature optimization
is similar a bukkit but is for Mods and plugins
It has nothing to do with optimization in this case
Yea, its most likely not supported here
Also, I just did what you asked @quaint mantle
Writing code that is readable saves you effort debugging down the line
Big suprise! Its still runs twice.
At this point I just want to scrap this code altogether.
It sucks.
I think it’s spongepowered
I won't help people who have extremely messy code if they don't fix it first because otherwise they'll just keep writing bad code that is harder to debug
if(Objects.equals(event.getHand(), EquipmentSlot.HAND)){
switch(event.getAction()){
case RIGHT_CLICK_AIR -> handleRightClickAir();
case RIGHT_CLICK_BLOCK -> handleRightClick();
}
}
Intelli recommended I use Objects.equals
Get rid of the instance fields
but I may be wrong here
You are
== for enums
That will work but it's not needed
== works and that should be a guard clause
Ah
also, by remove all the instance fields
Do you mean completely remove ALL of them
or
Sure
return exists
The only reason this doesn't explode in your face is because Minecraft servers are single threaded
You also should not be using strings for your event
It's a collection of named constants
In other words, an emum
So make it one
Can someone tell me in easy words what a Set<T> is?
Parameterized type
A Set is not descriptive enough
What is in the set?
That's what T is
Yeah but what’s a set? 🤣
Set<Integer> is a set of Integers
Array/Map I assume
A set is a collection which cannot be indexed or store duplicates
You use an array if they're all the same type, and an object if they're not
But nothing you're doing should require that
okay gunna sound dumb
but how would I use it as an object
wait @waxen plinth
Didnt you say
That I should be passing parameters
Correct?
Right sorry
Yes you should be passing parameters
You don't even really need that many functions here
Why don't you just make an enum for your string constants and a method that, given the context needed, will return the right enum value
Then your entire logic can be just a few guard clauses and a few lines to dispatch the event
Sure
.-.
All I want is to be able to offer help without being pinged every 5 seconds
But we can't all get what we want
I'll be going now
An enum can be contained in a class, but can the class be contained in the enum?
Wait
does discord auto ping for whats it called
Responding?
Whatever its called
Sorry had 0 idea
Can i disable that somehow
Yes
Yes
@ off
Yes
I'm still going, I have to sleep
Don't try to force a solution by writing big messy code
Distill it to the simplest logic that can do what you need it to
It also cannot be indexed
In this case you don't need very many moving parts
Write an enum for your string constants
A method that can take the necessary context and return the correct enum value
And your listener method which has a few guard clauses and then dispatches your event
That should be all you need
Is this better?
Removed all redundant code and made it a bit more optimized
Intelli said that was better
idk lol
You can use an enum instead of strings
Was told this already, working on it
Ah yeah didn't see that
there
made it an enum
Hm, so it runs the event when using if(event.getHand() == EquipmentSlot.HAND){ once
... yet RightClickItem event is ran twice
when i use particles they just scatter randomly is there any way to make them stay at a place?
ah ok
ty
So.. my issue still keeps happening bruh
2 items are used instead of 1
compare enums with the == operator, not with equals.
can you show us your other class using your custom event again?
why even creating a custom event for that
ah for passing it to a custom item class
i would just handle the PlayerInteractEvent, assuming that some things are valid cuz they are checked by the 'parent' listener
hi guys, i'm trying to make interactive books in spigot 1.8.8, this is what i've tried:
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta bookMeta = (BookMeta) book.getItemMeta();
bookMeta.spigot().addPage(
(BaseComponent[])
new ComponentBuilder("")
.append("Amogus")
.create()
);```
But it says `ItemMeta.Spigot` (return type of `bookMeta.spigot()`) doesn't have `.addPage(BaseComponent[])`, any idea how to add page with BaseComponent?
Then don't use 1.8.8
The server needs to be at 1.8.8... I'm a dev at my frend's server
Time to learn NMS
quick crash course?
There are no good guides but we can help you import it to your project
The rest you will have to figure out on your own by looking at the Minecraft source code
oh god
Oh and using it will make your plugin version specific
does a physics event fire a block break event or no?
ima just find code from the newer spigot, thanks
yeah that wont be an enemies to lovers arc zacken, at least not in the near future
Hey Guys How can I open a gui that I created in another class in another class?
store it somewhere
refer to it
whatever
many ways
but its formulated very vague
how can i get the essentialsX documentation
?bing
Bing your question before asking it:
https://www.bing.com/
There is not method on world called settype
maybe because of my English maybe because of my bad but how can I store a data
can u help me
?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!
im trying to spawn a block on world somewhere but i couldnt do it its not running the code block
@Override
public void run() {
World world = Bukkit.getWorld("world");
if(world == null) return;
for (int x = 0; x < 6; x += 2) {
for (int z = 0; z < 6; z += 2) {
// world.getBlockAt(x, 2 ,z);
}
}
}
?google ?bing
Google your question before asking it:
https://www.google.com/
weird
give a bit more context
what is run()?
are u using BukkitScheduler?
yes
generics are so cool
whatever class you put in the first bit must be provided as the class for the consumer
where do u call the method
- are u sure the world isnt null? check it by printing
yes im checking
i need to call it somewhere?
Ofcourse
Also I do have a question, is there a way I can easily get a list of the all the events which extend PlayerEvent?
Yea
I don't mean from the docs or whatever
oof
where and how
which would prob just be easier
but if there's a way to easily generate a list that would be cool
hi geol 😮
well, ask it whereever u want, what ALSO, that line is commented so that might be an issue as well
ty for the help yesterday btw
By scanning the jars yes, otherwise no
sounds like a lot of work
I'll just create one
I'm trying to assemble a list of all the events which have some kind of getPlayer() function
There are a few libraries that allow for what you want, but Most of them are behemoths for No reason at all
I see
like BlockBreakEvent extends BlockEvent, but super doesn't have a getPlayer event
my code would be a lot nicer if it did ;-;
yo, i have created an economy plugin and i want to create a placeholder for papi. is that possible to do?
uh okay thanks
Can I have a capture of a class which extends some class and implements an interface?
I'd like a capture of a cancellable event
so like, Class<? extends Event, Cancellable>
Wdym
when do u want to run that code
Something like Class<T extends Event & Cancellable> but it May Not be a Wildcard
can't have &
can't extend more than one super class
Cancellable is an interface tho
you can both extend and implement
I need a wild card for a cancellable event
Class name extends Event implements Cancellable
Then it was Class<T extends Event & extends Cancellable> or something
as i said
u can't extend more than one super class
You cannot have a Wildcard there
This is Generics tho
It's defo & though, how to use it idk
doesn't seem to like the & 😔
tried that too
<T extends ClassA & InterfaceB>?
lmao
nah
omgg yesss
it is complete
for each player I keep a map which maps an event class to a lamda which takes said event
so now if I want to stop the player from being able to break blocks
I add the BlockBreakEvent.class to their map, with null as the result
now the event is cancelled for them
but I can also change what happens from the default by putting in a new consumer in the map
genericcssss
This does make it difficult to distinguish between dealing damage and receiving damage however since they're both EntityDamgeByEntity event
Ayo, so im doing some stuff with attribute modifiers, but sometimes I mess something up and then there is a permanent Attribute modifier I don't know of. It there a way to clear all attribute modifiers?
nvm found it
@Override
public void run() {
World world = Bukkit.getWorld("world");
if(world == null) return;
for (int x = 0; x < 6; x += 2) {
for (int z = 0; z < 6; z += 2) {
Block block = world.getBlockAt(x, 2 ,z);
block.getLocation().getBlock().setType(Material.PUMPKIN);
}
}
}
this should work right?
yes but u need to call run()
i called but not spawning the block
where did u call
where
is the world null?
no
i debugged with sending online players a message
and its working but not working with this code
weird
public static void spawnKoko() {
BukkitTask run = new BukkitRunnable() {
Location loc1 = new Location(Bukkit.getWorld("world"), 34, 2, 86);
Location loc2 = new Location(Bukkit.getWorld("world"), 34, 2, 88);
Location loc3 = new Location(Bukkit.getWorld("world"), 34, 2, 90);
Location loc4 = new Location(Bukkit.getWorld("world"), 36, 2, 86);
Location loc5 = new Location(Bukkit.getWorld("world"), 36, 2, 88);
Location loc6 = new Location(Bukkit.getWorld("world"), 36, 2, 90);
Location loc7 = new Location(Bukkit.getWorld("world"), 38, 2, 86);
Location loc8 = new Location(Bukkit.getWorld("world"), 38, 2, 88);
Location loc9 = new Location(Bukkit.getWorld("world"), 38, 2, 90);
@Override
public void run() {
World world = Bukkit.getWorld("world");
if(world == null) return;
for (int x = 0; x < 6; x += 2) {
for (int z = 0; z < 6; z += 2) {
Bukkit.getWorld("world").getBlockAt(x, 2, z).setType(Material.PUMPKIN);
}
}
}
}.runTaskTimer(Main.getInstance(),0, 100L);
}
wha
nvm about the top code
You realize this places at y level 2 right @kindred valley ?
yea
yes
hm weird
i have a commandregister method
btw, why are you using Bukkit.getWorld in the for loop again, you have a assigned variable 'world' already
minor detail
Bukkit.getWorld("world").getBlockAt(34, 2, 86).setType(Material.PUMPKIN);
Bukkit.getWorld("world").getBlockAt(34, 2, 88).setType(Material.PUMPKIN);
Bukkit.getWorld("world").getBlockAt(34, 2, 90).setType(Material.PUMPKIN);
Bukkit.getWorld("world").getBlockAt(36, 2, 86).setType(Material.PUMPKIN);
Bukkit.getWorld("world").getBlockAt(36, 2, 88).setType(Material.PUMPKIN);
Bukkit.getWorld("world").getBlockAt(36, 2, 90).setType(Material.PUMPKIN);
Bukkit.getWorld("world").getBlockAt(38, 2, 86).setType(Material.PUMPKIN);
Bukkit.getWorld("world").getBlockAt(38, 2, 88).setType(Material.PUMPKIN);
Bukkit.getWorld("world").getBlockAt(38, 2, 90).setType(Material.PUMPKIN);
wha
i thought this will change everything but no
you don't want to call run??
Is this a bukkit runnable or?
yea i mean running the rask
my guess is that getting the block and setting the type doesn't change the block
what kind of blocks is it possible to store state in?
ur choice
every type
it does
it should
kk
there is no setBlock method
its a reference to a block so setting the type will set it in the world
@kindred valley try putting a print statement inside and check ur console to see if it does actually run or not
then check to see if Bukkit is actually getting the world
you may want to use Bukkit.getWorlds().get(0)
like for placed blocks can I store a persistent data container in them?
bro
I'm was asking my own q
not about your q
c:
if its tickable yes,
is there an interface for such tickable blocks?
public final class AutoAd extends JavaPlugin {
private int currentIndex = 0;
@Override
public void onEnable() {
this.saveDefaultConfig();
this.start();
}
@Override
public void onDisable() {
}
private void start() {
List<String> list = this.getEntries();
BukkitTask task = new BukkitRunnable() {
@Override
public void run() {
for (Player p : Bukkit.getOnlinePlayers()) {
p.sendMessage("§7[§f§lPVP§4§lCorner§7] " + list.get(currentIndex));
currentIndex = (currentIndex + 1) % list.size();
}
}
}.runTaskLater(this, 120);
}
private List<String> getEntries() {
return this.getConfig().getStringList("ads");
}
}```
why does it only send one of the two messages?
it sends one message and than stops...
oh, how can i loop it?
runTaskTimer() I believe
what is the difference between long delay and long period?
delay is how long before it starts
period is the time between repeating
so a delay of 10 and a period of 1 will cause the function to run every tick, 10 ticks after it was called
tysm :)
np
getBlock.getDrops.add() sets the drops of this block right?
no
the getDrops is just a copy of the actual drops
and they are also from a copy
which is generated everytime
idk what im saying
but you cant simpyl add/remove drops for a block
how can i set a blocks drops
hmm how to spawn an item
Wait I think that I just found out the solution by sending this here xD , I will delete that
@EventHandler
public void blockDropping(BlockDropItemEvent e) {
if(e.getBlock().getType() == Material.PUMPKIN) {
e.setCancelled(true);
}
}
```this should prevent the pumpkin dropping right?
I don't see a problem here yes
its still dropping
Check that this event is being fired
When I cancel the death of a player in the PlayerDeathEvent and teleport them to somewhere else, their loot is dropped at the teleported position, any idea why? this is my code:
p.setHealth(20);
p.setGameMode(GameMode.SPECTATOR);
MiniGames.skywarsGame.getLstAlive().remove(p.getUniqueId());
teleportToLoc(main.getConfigName(p.getWorld().getName())+"-death-pos",p);
By canceling I mean setting their health back to 20
You May need to actually cancel it
There isn't a setCanceled method on the player death event
Otherwise you can actually Just clear the list of dropped items
But if I do that they won't drop at all
Oh, yeah then you need to clear
I want them to drop at the original location
Ah yeah, you May need to Teleport in the next tick
Set a scheduled task?
Yep
Ah I see, I will try that
The block is Pumpkin but this part of code is not running
if(block.getType() == Material.PUMPKIN) {
e.getPlayer().sendMessage("WORKING 2");
e.setCancelled(true);
}
This means that your event isn't firing, can you send your onEnable method?
event is firing i debugged
but this part is not working
Oh that's weird
Are you Sure that Pumpkin applies to Blocks?
This is probably because of the event you used, I just ran this and it worked:
@EventHandler
public void onPlayerDrop(PlayerDropItemEvent e){
if(e.getItemDrop().getItemStack().getType() == Material.PUMPKIN)
e.setCancelled(true);
}
what is it
I'd Check the javadocs, but 16 kbits
the dropper one is not player
Oh you want to cancel entities dropping pumpkins?
WHAT
Block buddy
@crude loom does Material.PUMKIN_BLOCK exist?
I don't believe it does, but you can check in the javadocs
There is SEED, STEM, PIE
why
Many questions Here need a look at the javadocs
I know many parts of the Bukkit API by Heart by Not everything
Should be
simple meths
Read the Docs to be Sure, But generally everything is in Ticks in mc space
Multiply by 50
No 50
20tps = 50ms per tick
1 second = 20 ticks
I have this burn command and when I use it I get this error: Please note that this command is not supported and may cause issues when using some plugins
try {
Player player2 = Bukkit.getPlayerExact(args[0]);
try {
int seconds = Integer.parseInt(args[1]) * 20;
player2.setFireTicks(seconds);
} catch (NumberFormatException nfe) {
player.sendMessage(ChatColor.RED + "That is not a valid number");
}
} catch (IllegalArgumentException e){
player.sendMessage(ChatColor.RED + "That is not a valid player");
}```
1s/20=50ms
do you use in schedules, 3 * 20 or 3 * 50?
seconds
then you would times it by 20
20*20ms=400ms=0.4s
guys please help
this message is for /reload boy
Thats when u try to reload ur server using /reload confirm
the server gives me this error and reloads itself when I use the command
wtf it doesn't now
commands.yml?
idk what happened but it now works
ik what is it