#help-development
1 messages · Page 1898 of 1
I think it allows you to determine the type at runtime without needing it to be defined in the called class
ohhh
Wally explain
Like the type doesnt need to be defined by the class for it to be able to be used
ok
Because thing is, when you create these type templates you cannot know about which type is passed
couldnt you just do Object then? then do "object.class"
Only the very minimum
WOW I LEARNED SOMETHING NEW
in redlib, to load/save a config, you need to pass a class for the target like so: config.target(targetclass).saveDefaults().load();. i want to make a method so that i don't have to go through the steps of running that method and one other every time i wanna grab data from a config, so i just wanna pass a class and a file path
file path?
in case i explained it bad, the target/targetclass thing does smth similar to the config interface you showed me conclure im pretty sure
yeah
and you want "targetclass" to be the class correct?
i probably should
Generics is eventually just object orientation at type level
and with a lot of inference
i've found that recently, my 3 years of primitive code is holding me back
Which makes it hard to get a deeper understanding of
I learned generics like a few weeks ago
bc I wanted to get a better understanding of nms
wasnt that hard
I mean like fully understand everything of it, including stuff like reified types, type inference contracts etc
I ment like
and generic inheritance
the VERY basics
(=
is there a video that explains it in a human way?
I felt like I understood them
lol
What’s "human way" for you ?
yea
i dont think anyone really learns anything from the oracle docs without reading it over 7 times
WOAH
Then conclure brought out some made up words smh
DO NOT READ THOSE
lol
learn from a video lol
the dude I linked explains everything in a great way
my dad tried shoving java down my throat back when i was like 10 through the oracle docs
Yeah Wally, right now you just wanna get the gist of it, so that video is probably gonna suit you more or less
very sad moment in my life
Lol
oh god
now that is torture
What do javadocs taste like
Is morphia still used for Mongo or is it a no?
whys the man in the video doing Integer instead of primitive int
because you have to extend a class
Cause you cant use primitives as types
int is not a class
the input MUST extend Object
integer is
Yeah
aka it MUST be a class
^
I mean primitives got their classes
String is an example of a class, int/double/long/char are all primitives
Integer/Double/Long/Char are the classes for those primitives
(aka wrappers)
char.class or Char.TYPE exists
wrapper classes*
int.class
yes :)
umm no
yeah
Y E S
Integer%TYPE just points to int.class, no?
its the same thing but Integer.TYPE is fancier
exactly
🌞
makes you look cooler
XD
so my first question, in the video, the dude accesses the following code by doing Integer whatever = new IntegerPrinter(23). how does java know he's talking about the public IntegerPrinter(Integer whatever) method when he's just called the class?
That’s a constructor
hold up
you cant extend Integer
excuse me?
Not with that attitude!
its final right
Yeah that’s a constructor
watch the video longer, he explains it
it takes a int
I think hes giving an example of the incorrect way to do generics then giving you an example of how to do it right
what is that?
yeah but say i made 2 almost identical methods that took in integers. if i made a new instance of the class and just passed 23 into the class constructor, how would java know which method to pick from?
Idk
exactly
autoboxing is when it automatically changes the type basically
Probably never pulse
like when you create strings you dont do String str = new String("string");
Well the one matching the class name would be the constructor
I mean
Their signature will have to be slightly different
Wait what happens if you have 2 identical methods one taking int and one taking integer
oh so the method that's the same as the class name is it's constructor?
Const(int) vs Const(Integer) (given both exists)
if you do new Const(1) Const(int) is used
if you do new Const(Integer.valueOf(1)) Const(Integer) is used
int num = 5;
System.out.println(num + "") enjoyers
VS
System.out.println(String.valueOf(num)) enjoyers
pretty sure it would still work
wheres the num.toString() enjoyers

its a primitive
exactly
Interger.valueOf(num).toString();
unless you make it Integer
no for methods
Lol
that return
Hmm Idk what to use honestly
is used to signify the ending method in a thing right?
or is it just used for methods
Like
is for javadocs
:: is for method references but doesn’t make a good job in differentiating static vs non static
% is sometimes used for static
So just went with that
I'm casting ItemMeta to SkullMeta and doing setOwningPlayer() and It's not setting the skull owner. Is there a different way to do it
im just gonna shutup an watch the video cus he just answered a question i asked ._.
Some people use the following
String.valueOf (dot for static methods)
String#substring (# for non-static methods)
Yea
would
object.someMethod().anotherMethod();
be
object.someMethod()#anotherMethod();
or
object#someMethod()#anotherMethod();
I always see this
In javadocs probably the bottom
got it
help plz
but all three are different if you use pulse’s convention
Might wanna show us some code
are you doing itemStack.setMeta(meta);?
after setting the meta to skull meta
... thats a thing
ok well theres my issue
Yeah you need to set the meta after changing it
kk thx
THATS A THING?
Unofficial
oh
I use method references because they are used in jeps sometimes
So more official than what pulse talked about
since primitive types dont work with generics
is there alternative objects for primitve types
You’d use the boxed variants
yes
like Boolean
bro you are in this discord, mod dev discord, AND python discord with me?
Yes
Possibly lol
wow
yep, Boolean, Integer, Double, Short, Long, Byte, etc..
I haven't seen anyone like that
Sadly I write Python and I enjoy it
Banned
🥲
non OOP languages 🤮
python is fun 🥲
It’s multi paradigm tho
yee
?google the multitude of guides on this
Google your question before asking it:
https://www.google.com/
Lol
when I try to add a custom recipe, it doesnt appear in game
its time to look at my code and see what I did lol
opening...
intelliJ
did you try player.setCustomName(""); then player.setCustomNameVisible(true);?
lol thx
in the recipe book?
OH RIGHT that exists
Ive never used that but I think that might be a way to do it
unfortunate
and when i try the pattern i set it doesnt work
HAHA I FOUND IT
like the recipe doesnt exist
show code?
omg thx
Bukkit.addRecipe();
it wont appear in the recipe list
oh... i did that
bruh
thats all clientside
Not true
can you show code?
Recipes are synced to the client
oh is it really? can u add it to the list with packets then?
how do i give a player a recipe
show ur code man
Pretty sure it’ll already be in the list if you register it with Bukkit
did you do something like this? ```java
ShapedRecipe sr = new ShapedRecipe(new NamespacedKey(this, "Gun"), is);
sr.shape(
"ADA",
"BEB",
"ADA");
sr.setIngredient('B', Material.BOW);
sr.setIngredient('D', Material.DIAMOND);
sr.setIngredient('E', Material.EMERALD);
sr.setIngredient('A', Material.ARROW);
Bukkit.addRecipe(sr);```
But not unlocked
"is" is an itemstack
its a recipe to give players exra hearts
public class Main extends JavaPlugin {
public static ItemStack heart;
@Override
public void onEnable() {
heart.getItemMeta().setDisplayName(ChatColor.RED+"Heart Fragment");
Recipe r = new ShapedRecipe(new NamespacedKey(this, "heart_fragment"), heart).setIngredient('1', Material.OBSIDIAN).setIngredient('2',Material.NETHERITE_INGOT).setIngredient('3',Material.OBSIDIAN).setIngredient('4', Material.TOTEM_OF_UNDYING).setIngredient('5',Material.PLAYER_HEAD).setIngredient('6',Material.DIAMOND_BLOCK).setIngredient('7',Material.OBSIDIAN).setIngredient('8',Material.ENCHANTED_BOOK).setIngredient('9', Material.OBSIDIAN);
r.getResult().setAmount(1);
Bukkit.addRecipe(r);
}
}
Yeah that’s not how you recipe
oop
yee
You never defined a shape
... wat
Do something like this
Follow this
ohhhhhhhh
eclipse theme on intellij I love it much <3
this right here explains my frustration with python:
lol sorry i had to
I do like how you can use commas for string separation in PyThon
it makes sense tho
I mean any sane python developer just uses formatted strings
yeah logically it does, but in the sense of java behavior where the process of type conversion is very picky, it doesnt
python is too aloof i guess
i also dont like how it's indention sensitive
That’s just a language semantic
all fun and games until some shitty website shoves a zero-width character into a code snippet you copy pasted
That could happen in java also
Lol
hence why you dont just copy paste code
^
lol
unless its ur own obv
intelly jelly just needs a paste without formatting option like google docs
Ye
for spacing?
for ctrl v-ing code
No like
for all characters
kinda like the .normalize() method
just scraps out any characters you wouldn't find on a keyboard
Depends on what keyboard you have
thats kinda character-phobic man
I must say...
zero-width character lives matter
if you're a programmer and your keyboard has non-programmer friendly characters... 
Poor non-English keyboards
i got a mac recently and the worst part about it is the fact that they replaced the ctrl key with a useless button that pops up the emoji keyboard
like they couldnt find a better place to put that
i hate mac keyboards
yeh
dont they replace the ctrl key with some tic-tac-toe looking bs
they call themselves a company for lifestyle-fitting devices and then go and screw over anybody whose used a keyboard before
code?
args start at 0
Arrays start at 0
so if i had a command like
"/command arg1 arg2"
arg1 would be args[0]
args.length would return 1 if the only arg is join
args.length has to equal 2 if you want another arg after join
Yeah you probably want >= 1
^
Since with that elseif it’s impossible for args[1] to exist
It's not a terribly complicated API tbh. Just consists of 3 static methods. wordWrap() will wrap a string according to the specified width, and the paginate() methods will just give you a subsection of the string formatted more nicely that you can iterate over and send to the player
The British keyboard is also completely non-standard with symbols in completely different places
is this correct?
The British keyboard is weird
alphabetical keyboard enjoyers
They get an extra key
What key
a special apostrophe for their speaking
bo'l'o'wah'uh
These? ' "
its meant to replace letters they dont pronounce
The vertical bar

But yeah they move stuff around and have an entire extra key
Apple in their mighty wisdom thought a section symbol (§) was more important than a backtick and replaced it with that
Rip ~ and `
Ah yes and the good ol plus or minus sign
isnt that the color code symbol for yml files?
Very useful...
Tilde and backtick are next to shift
my recipe still doesnt work
Also this is Apple’s British layout
The difference being that the shift and caps lock are symbols not written out
oh they just reloacted the ~
Yeah
ah
Fortunately I'm used to switching between Apple's British layout and the actual British layout since the keybinds in macOS tend to be completely different anyway
tea is nice ngl lol
Overrated
I had just plain tea when I was there
Tasted like hot water that once saw a tea leaf pass by
How can I load the plugins folder / great it without creating a config.yml rn I’m just using / wanted a data.yml
Plugin#getDataFolder
That creates it too?
File#mkDirs
K ty
Lol
@quaint mantle It's me again. My recipe matches your layout exactly but wont work
Im working on a new project and have decided to take a look at design patterns to attempt to create code using best practices. Anyway I am creating a custom plant system that will require many PlantObjects to be tracked and continuously updated or tick()ed. Could anyone point me in the right direction for a pattern to help handle this. I started to use a PlantManager approach and loop through a list of plants and tick() each one of them but just thought I would take a look at a few other approaches. Any help is appretciated.
I mean
The choice of design patterns very much depends on what exactly you’re trying to do
But for the ticking part, observer is probably what you want
And also facade for the api to interact with the observer system
Obv might wanna stick to static factory just to decouple instantiation and creation
But take a look at the behavioral ones
wat
I copyed your layout exactly, but the recipe doesnt work
Lol
🥔
Thanks man I will take a look at all these
Yeah, like it’s quite hard to tell you but generally
For implementations we talk about behavioral ones
For api designs and layering etc we use the structural ones
public Class<?> getData(Class<?> target, String path) {
ConfigManager config = ConfigManager.create(Main.get(), path + ".yml");
config.target(target).saveDefaults().load();
return target;
}```
That does not take a type
PlayerData.class
ohh
<T> T getData(Class<T> target,String path);
When using the say command in console, the prefix is [Server]. Can I change this to something different?
@fleet imp this is everything I have in my onEnable() and it works fine for me... if it doesn't work for you idk what I can do about that ```java
@Override
public void onEnable() {
System.out.println("GUN PLUGIN IS ACTIVE... \n\n");
for(int i = 0; i < 10; i++) {
System.out.println("PLEASE READ THE PLUGIN PAGE BEFORE YOU PLAY THIS... THE ITEM IS ONLY OBTAINABLE BY CRAFTING!!! \n");
}
ItemStack is = new ItemStack(Material.GOLDEN_HOE);
ItemMeta isMeta = is.getItemMeta();
isMeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD + "Gun");
isMeta.addEnchant(Enchantment.DURABILITY, 20, true);
is.setItemMeta(isMeta);
ShapedRecipe sr = new ShapedRecipe(new NamespacedKey(this, "Gun"), is);
sr.shape(
"ADA",
"BEB",
"ADA");
sr.setIngredient('B', Material.BOW);
sr.setIngredient('D', Material.DIAMOND);
sr.setIngredient('E', Material.EMERALD);
sr.setIngredient('A', Material.ARROW);
Bukkit.addRecipe(sr);
}```
also @fleet imp have you tried making the item in the crafting table?
hold up
nvm
Isn’t using system println not preferred over logger
no i think i see what i did
Correct
[20:57:47 WARN]: Caused by: java.lang.NumberFormatException: For input string: "1642643863894"
[20:57:47 WARN]: at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
[20:57:47 WARN]: at java.base/java.lang.Integer.parseInt(Integer.java:652)
[20:57:47 WARN]: at java.base/java.lang.Integer.valueOf(Integer.java:983)
Any idea why this is an error?
looks like an int to me
rofl
Too big
Use a long
fuck
i want to give an effect to a player while hes in x radius of a block. I have the code working and its on the player move event but what should i change it to since doing it on the playermoveevent is bad? should i make a while loop or smth
most likely you'd schedule a task timer
ok cool
?typing
Does anyone know if it is possible to sort the player scoreboard (tablist) using packets? I would go with a teams approach, but I currently use teams for a clans plugin and would like to sort the board by rank/group instead of clan
you're a long
😳
don't be weird
I’m more of a short actually
I might be misremembering here, but does Minecraft have a feature where you can draw a line from one point to another that is visible to the player?
I guess as a last resort, I can spawn particles going in a line
^ if I use this method, anyone have particle recommendations for this? LOL
I think there might be something with the new debug stuff to do it
Not too sure, it would all be packet based at the least
ah ye i didnt think about making a runnable on startup to check every x ticks ty
I know structure block holograms are a thing, I'm not sure how useable they are though
lets say i have a runnable that is set to run in like 4 hours. How can i make it so even if the server reboots etc it continues after the server starts back up / the timer resumes and doesnt just go away or restart
If you will use it for players I dont recommend it
For player i will recommend using a Cooldown system + database
Answering your question
Not for players, what it does is it will remove a value for the data.yml after like 12 or 48 hrs or smth
What type of value?
Cuz for doing that i think they are not used schedules. I think you use Timestamps
a location
I will link you to some information
Kk
Wait me i will translate it all
A timestamp is basically a number (a date) that is stored and used to perform actions. For example Litebans, when you get temporarily banned it creates a timestamp with the duration of your ban. And every time you go in he checks it.
Ah Mk
I generally just store the time when it should be undone as a long
Yeah i use long
(aka in miliseconds)
as Java makes it easy with System.currentTimeMills or smth like that
So should I just store the timestamp of when it should be removed in the data.yml with it and then check that where? In a runnable on startup every like 5 seconds or-
I dont know how the people use it, but i use it in Mili-seconds and then for displaying it i have a Class for converting it to the format i want for example: seconds, hours, etc
I explain you
Kk ty
Generally how I do it, is I store when it should expire, if they do a certain action like join etc I check if its past yet, if it is I remove whatever restrictions were placed on, I also have a update event running every 5 seconds so I just listen to that and do the same thing
Kk ye so just make a runnable run every 5 seconds and check if the time has expired and if it has then run the function / remove it
They might but I just wrote my own lol
Easy enough ty
Your welcome
You dont prob need it every 5 seconds, but thats just what I do
Depends on the use tbh
Ye Ik that I just sayin 5 as example
For example when you set the location you set with it: the current milis + your expire time (millis). And then you check if the milis saved with your location its >= the current milis
That how i generally use it
Ah what I was gonna do is set the expire time in millis so for example 12k then check every 5 seconds if the current millis is >= expiremillis
I do a simple example
public class Timestamps {
private Long start = System.currentTimeMillis();
private Long end;
public Timestamps(Long duration) { //Mili-seconds
this.end = this.start + duration;
}
public boolean hasExpired() {
return System.currentTimeMillis() >= this.end;
}
public long getRemaining() {
return this.end - System.currentTimeMillis();
}
}```
There you have sir
Could use a HashMap
True
I dont recommend using it
I recommend creating the timestamp when you set the location, and save it like:
location:
x: ""
y: ""
z: ""
time:
Ye
I dont recommend doing it on hashmap, cuz you will have to add it, then if server goes down. You should loop it, save the timestamps with each location. Its mess
Saving it directly to file its easy and more secure, cuz if server goes down its already saved
Mhm
But they are only recommendations
Even better if you can make the saving async
Do you agree with my recommendation?
With CompletableFuture right?
Sure if you need a callback if some kind
Bukkit.getScheduler#runTaskAsynchronously#
What do you use if you dont need a callback?
You could just use this
A callback to inform you if the write fails though may be good
Also if you're running a task say 5h later why are you writing to file so often?
Do a cycle write the next to a file.
Can you explain why im getting the Remaning message sent 3 time like:
2 seconds left
2 seconds left
2 seconds left
1 second left
1 second left
1 second left
I mean you don’t even print out in that code
?
Where are you printing
Because the code you’ve shown us doesn’t send any messages, let alone 3 of them
In java terminal with Java#main()
Are you in a while loop?
Nop
Show code otherwise we're guessing here
But i mean cuz if i create a debug like this:
public static void main() {
Cooldown cooldown = new Cooldown("test", TimeUtil.format("1m"));
if (cooldown.hasExpired()) {
System.out.println(TImeUtil.parse("s", cooldown.getRemaining));
}
}
TimeUtil#parse(time char, milis) // Convert the long to the time char you want, if use seconds it will convert the long to seconds, and that with: hours, sseconds, etc
I dont know why i get all the reamaining messages are sent 3 time
I mean that's an overly complicated solution to a very simple problem
Why??
My cooldown class its really simplier
They're storing it in a config file right?
Something similar
Im storing it on PlayerProfile (Java object) that its loaded all data from my MongoDB
if you use a Instant this is all part of the instant clas iirc
I imagine storing just a value for when the time is over is easier and requires less classes
?
Less classes?
LMAO
its only 1 class
Hahaha
I dont understand you some time
The problem is that i cannot work out the class
If not i will have a mess then for convertir all the things, etc
I'm extremely confused to what exactly you're storing and why
Omg
I will explain
I a have player profile (Cuz its networking) where its has many data, and there its has a Set<Cooldown>.
All works great, the only thing is that when displaying the cooldown#getRemaning() its shown 3 times. Not only 1 time
Allright
So the message are not sent 3 time?
I think its an inssue while debugging with Java#main() method
I'm extremely confused. There is no way that it's called 3 times it's impossible
Like instead of sending:
Left 3 seconds
Left 2 seconds
Left 1 second
It send:
Left 3 seconds
Left 3 seconds
Left 3 seconds
Left 2 seconds
Left 2 seconds
Left 2 seconds
Left 1 second
Left 1 second
Left 1 second
Idk what happening
R u just running it once
?
The main file
How are you running it? Do you just click on run or is there something external calling the method
I do like this
has anyone used this before https://github.com/vectrix-space/ignite
seems pretty interesting ngl
When you execute a command im checking your profile, inside your cooldown if you have a specific cooldown. If you have it i send you back the message with remaning
If you are not on cooldown you execute the command, and then add again the cooldown to your profile
It depends how you're parsing it
To me it seems like that's where you're getting the issue.
Issue: I am trying to make this recipe only work IF the Diamond used in the recipe has the model data of 1 but I can't seem to find a way to do this. If you happen to know of a method that I might be missing to parse in this information or require it, I would greatly appreciate it!
private ShapedRecipe getCrownRecipe() {
ItemStack item0 = new ItemStack(Material.DIAMOND);//Diamond Item
ItemMeta meta0 = item0.getItemMeta();
assert meta0 != null;
meta0.setCustomModelData(1);
item0.setItemMeta(meta0);//setting Item's Model Data to 1
ItemStack item = new ItemStack(Material.GOLDEN_HELMET);//Crown Item
ItemMeta meta = item.getItemMeta();
assert meta != null;
meta.setCustomModelData(1);
meta.setDisplayName(ChatColor.GOLD + "Golden Crown");
meta.addEnchant(Enchantment.LUCK, 10, true);
meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 10, true);
item.setItemMeta(meta);//Pushing all the infomarion and setting the Model Data to 1
NamespacedKey key = new NamespacedKey(this, "Custom_Crown");
ShapedRecipe recipe = new ShapedRecipe(key, item);
recipe.shape(" ", " G ", "BBB");
recipe.setIngredient( 'B', Material.GOLD_INGOT);
recipe.setIngredient('G', Material.DIAMOND);//issue line
return recipe;
}
RecipeChoice.ExactChoice
Do note that requires the items to match perfectly, except for stack size
Thank you so much
?paste
https://paste.md-5.net/abirakihag.http any help?
org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.lumina.luminassw.LuminasSw'
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:66) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at java.lang.Thread.run(Thread.java:823) [?:1.8.0_272]
Caused by: java.lang.ClassNotFoundException: me.lumina.luminassw.LuminasSw
at java.lang.Class.forNameImpl(Native Method) ~[?:1.8.0_272]
at java.lang.Class.forName(Class.java:408) ~[?:1.8.0_272]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
... 7 more```
The named class is not in your plugin
this is my main class
are you sure it is in that package?
make sure maven is properly exporting the plugin.yml file.
how do i do that now
name: LuminasSw
version: '${project.version}'
main: me.lumina.luminassw.LuminasSw
api-version: 1.17
commands:
buy:
description: Gives kit with the argument of type
usage: /<command> <kit type>
aliases: [k]
nvm its 1.17 when it should be 1.8
was that the problem
idk
dint work
That shouldnt matter
?paste
Show main class
1 sec
package me.lumina.luminassw;
import me.lumina.luminassw.comands.buy;
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
final class luminassw extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("Lumina's Easy SW was initialised successfully.... ");
getServer().getPluginManager().registerEvents(this, this);
getCommand("Cobble").setExecutor((CommandExecutor) new buy());
}
}
package me.lumina.luminassw;
import me.lumina.luminassw.comands.buy;
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public class LuminasSw extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("Lumina's Easy SW was initialised successfully.... ");
getServer().getPluginManager().registerEvents(this, this);
getCommand("Cobble").setExecutor((CommandExecutor) new buy());
}
}
You say that your main class is me.lumina.luminassw.LuminasSw but there isnt even such a class
Thats why it complained
is it good now?
Yes try again
alr ty
I have had read a user guide that says its main class is Main.java
Main.jora
[ERROR] Error occurred while enabling LuminasSw v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
at me.lumina.luminassw.LuminasSw.onEnable(LuminasSw.java:21) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at java.lang.Thread.run(Thread.java:823) [?:1.8.0_272]
[INFO] Server permissions file permissions.yml is empty, i```
Ok great, a different message now, sign of progress
[ERROR] Error occurred while enabling LuminasSw v1.0-SNAPSHOT (Is it up to date?)
Guess the most important line here
That may lead you to the source of exception
what line u just replied to the whole thing
wym
Do you know what is a NullPointerException?
It is a crucial part of software development
You may want to search up of java exceptions
Yeah I think it would help if you knew exceptions
They're a big part of Java's error-handling and the language itself
I think i can guess that you didnt have a command called Cobble
(Also understanding how to read stacktraces)
Not crucial enough for the java course in my school.. we learn try catch but not how to read a stacktrace 
I'm glad I already know Java
Oh what lol
Well a stacktrace is just a trace of all the methods that were called up until the exception, essentially.
The top is the topmost method called, meaning the latest.
The direct "callsite"
Yeah
Fun fact: In Java 9+, stacktraces can be used to get the "caller method" efficiently
(e.g. what method called the method you're in right now)
It's not terribly important of a feature unless you're really strict about safety.
yoo its fixed i changed some small things
is there anything that could help me find out if a player breaks their fall damage by water bucket mlging?
maybe falling velocity
getFallDistance() seem interesting?
but very informative...
guys i made a plugin that randomtps
this plugin gets a region and then if a player gets to that region, he randomtps
i made a structure, for that
a player needs to jump of a "big hole"
and then it tps him
but when it randomtps he dies from fall damage
idk if i explained it right
how can i disable that?
teleports*
setFallDistance
not tps
setFallDistance(0)
i need to put that on an event?
playerteleportevent
?
yeahh
put that before it teleports the player
thanks, it works
You can just give the player Res 5 for one second
Why is it deprecated to use the BaseComponent in the HoverEvent constructor? What should I use instead?
package me.lumina.luminassw.comands;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Objects;
public class buy implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 0) {
Player player = (Player)sender;
if (player.isOp() == true){
if (cmd.getName().equalsIgnoreCase("Kit")) {
if (args[0].equalsIgnoreCase("Insane")) {
player.getInventory().addItem(new ItemStack(Material.ENDER_PEARL, 64));
}
}
}
else{
player.sendMessage("Sorry but your not OP!");
}
}
return true;
}
}``` i made a command the command should work it dosnt throw a error but dosnt give me 64 ender pearls when i run it
how do i do that?
args.length == 0
if args.length != 1
What if it's 2 or more then
args.length == 0 will only match if the args are empty
And then you check args[0] which won’t exist
send a list of available kits
Also player.isOp() == true hurts my brain
...for what? removing the == true?
it's a boolean, it doesn't need to be compared
I feel like removing is easier than adding though
ItemStack[] empty = new ItemStack[]{new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR)};
if (Arrays.equals(player.getInventory().getArmorContents(), empty)) {
``` Is there a better way to find out if player doesn't wear armor?
nope i dont think so
well
you could turn that empty array into a constant
e.g. private static final ItemStack[] EMPTY
so you don't have to recreate it over and over
wait now im confused, the 1st item in the array is still 0 ?
Yes
loop is unnecessary for this i think
Actually Arrays.equals probably loops anyway
and making my if statement to 1 is just check that my array list hast atleast 1 item right?
Yes
now I need to think of a reason why the player should die if it equips armor... any suggestions?
one sec
private static final ItemStack EMPTY = new ItemStack(Material.AIR);
private boolean isArmorEmpty(Player player) {
for (ItemStack stack : player.getInventory().getArmorContents()) {
if (stack != EMPTY) return false;
}
return true;
}
// then you just use 'isArmorEmpty' in your if statement
This would be cleaner ^
Probably faster too since it can short-circuit.
(short-circuiting is when a condition ends as soon as it's proven to be false, e.g. if one piece of armor isn't empty, then we know the armor isn't empty, which reduces how many times we must loop)
oh gosh, were now going into efficiency instead of simplicity
ok ill add it i guess
This is simpler.
At least, in my opinion.
It's easier to understand since you're using a method which details exactly what it does via the name.
efficiency is my nemesis
yeah thats what I thought
It's nice if the code is both efficient and simple.
AKA the exact opposite of an enterprise codebase.
Actually wait I don't know if you'd even need to create that EMPTY itemstack...
you could probably just do stack.getType() != Material.AIR
isnt getType a method and thus decreasing efficiency?
I mean they should be equal
yeah that seems a good idea would save u from some variable hassle
It's a difference between an invokevirtual and getfield instruction
afaik they don't have much overhead compared to each other
so you should probably just go for the simpler option
here's a tip: don't care about micro-optimizations when you're working on Spigot plugins
micro-optimizations are only important within embedded systems and other memory/performance tight applications
thats too much for my brain to handle. thanks anyways
Spigot is very performance tight
One microsecond too long and the user will hunt you down
oh no
hello!! block.getBreakSpeed(player); doesn't return 0.0 when player stopped breaking the blockkkk.....
Well because it is the modifier how fast he can break blocks
Like a higher value the faster he breaks the block
it returns 1.0 when he finished breaking the block
And when he does nothing?
something like 0.05 when just clicked the dirt
I have a delay of 70 ticks after the event fired
Why tho
if (enabledModules.get("PLAYER_BREAK_TOO_SLOW")) {
Block block = e.getClickedBlock();
if (block != null && block.getType() != Material.AIR) {
scheduler.scheduleSyncDelayedTask(plugin, () -> {
float progress = block.getBreakSpeed(player);
System.out.println(progress);
if (progress != 0.0 && progress != Double.POSITIVE_INFINITY) {
Utils.kill(player, "PLAYER_BREAK_TOO_SLOW");
}
}, 70L);
}
}
no, its to kill the player if he didnt break the block in 3.5 seconds
and if the player didnt cancel it
Prob just check if it's higher then 0.05
its the progresss
That wouldn't make sense tho 😂
the problem is it doesnt reset when player cancelled it
Why would the value be lower
because it takes longer to take to 1.0
it saves the highest value even though the player already stopped breaking it
@ivory sleet pong
Is there a way to check if a minecraft book's page is filled and next page needed?
my command isnt working i have implemented in plugin.yml and registered it in the main class all i get is the command dosnt exsisit but it used to?
Your plugin loaded correctly?
Show on enable registration
Why are you casting it to CommandExec does it not implement it?
it gave me a error doing this fixed it
yeah
it isnt really buy lol its sw kit selector which can be used by op, anyways
package me.lumina.luminassw.comands;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Objects;
public class buy implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 1) {
Player player = (Player)sender;
if (player.isOp() == true){
if (cmd.getName().equalsIgnoreCase("Kit")) {
if (args[0].equalsIgnoreCase("amp")) {
player.getInventory().addItem(new ItemStack(Material.ENDER_PEARL, 64));
}
}
}
else{
player.sendMessage("Sorry but your not OP!");
}
}
return true;
}
}```
What exactly is the error you get if you remove the cast?
also, instead of it returning 1. it returns Infinity. if this could help...
And it's telling you that the command doesn't exist in-game? No errors in console on load?
nope
mabe because K is capitalized in Kit... just maybe...
.equalsignoreCase is there
change (args.length == 1) to (args.length != 1) and put else {player.sendMessage(commandUsage)}
Wait. Try Bukkit.getServer.getPluginCommand("command") instead and register it through that
It's 3am I'm super slow lul
hmm
args[0] is amp right?
so if args is null or more than 1[0], it will send the usage
Bukkit.getServer.getPluginCommand("buy")
``` like this
does .length start with 0 or 1?
Yeah. With the .setexecutor to the new buy
Well getServer needs the ()
@Override
and you are also don't need to check command name if you used .setExecutor
package me.lumina.luminassw.comands;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Objects;
public class buy implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 1) {
Player player = (Player) sender;
if (player.isOp()) {
if (args[0].equalsIgnoreCase("amp")) {
player.getInventory().addItem(new ItemStack(Material.ENDER_PEARL, 64));
}
} else {
player.sendMessage("Sorry but your not OP!");
}
}
return true;
}
}
This is what your class should look like at best
so do i remove @override?
No it stays
I'm confused as to the issue here. Is the game telling you unknown command or are you just not getting output
getCommand("buy").setExecutor(new buy()); in onEnable()
show your plugin.yml
where you registered your buy command
name: LuminasSw
version: '${project.version}'
main: me.lumina.luminassw.LuminasSw
api-version: 1.8
commands:
buy:
description: Gives kit with the argument of type
usage: /<command> <kit type>
aliases: [k]
btw the api-version is not needed if your plugin is below version 1.13
oh?
it is!
show your onEnable()
and also learn java convention please🤩
you are should use getLogger().info("text here") instdead of sout
why is that better?
Sometimes it can cause problems and errors
like?
Put it under all the code too so that it actually runs everything else first so you know if it was enabled or not. I mean it'll crash but still
I mean spigot already has enabled messages
What does your command executor look like now?
why are you on 1.8? This is an old version, why stay on the old versions when there are new and much better!!!
skywars
he gets a message that is unknown command
At least on the newer versions it tells you that because you don't have perms
Doesn't it tells to 1.8? I don't know, I haven't used old versions for a long time. I am always on the latest stable version
It's 3am I'm tired lol I just tested it just gives the good old don't have perms
oops i was gone, im back now
Build a fresh version of your plugin make sure the message in console sends after the command registers and make sure it prints it out to the console. Run command as a server operator
show output
The biggest problem here is that at least in the latest version if it's in the yml it should at least return as if the executor returns false
oh no, naming..
I mean if you want me to be a real stickler you should include a Command at the end of the name BuyCommand
yes!
Da
Now shove it on the server and show the console output so we can at least know it's loaded properly on the server
Alright now try it
and then just the /help message
oop
Don't tell me that was the issue this whole time
lets test that make sure it works
Don't forget the yml as well
It's going to work
wait will /reload do the same thing as restarting the server?
Never use the /reload command under any circumstance as it is always unsafe and error-prone. It causes significant instabilities within the server and plugins. Reloading the server will create issues, especially if you've replaced any jar files. For more information: https://madelinemiller.dev/blog/problem-with-reload/
FULLY RESTART YOUR SERVER
Basically, but it's better restarrting the server.
it works!!!
god damn naming ruined it
thanks mike and sal!!
its just a process of adding items!
Ah now to go to bed. My life is complete
3hrs lmao
Why I can't remove passangers from list
p.removePassenger(pas);
p.getPassengers().remove(pas);
pas.remove();
they are removed from player visually
but if you do Player.getPassengers() size is still same
if was 5 before removing
it stays 5
Show entire code
for (Entity pas : p.getPassengers()) {
pas.setInvulnerable(false);
p.removePassenger(pas);
p.getPassengers().remove(pas);
pas.remove();
}
that is command
to remove them
I got armorstand on top of my head
Why are you doing it twice
I got runnable which check is player has passengers
and rotates passenger direction
to be same as players
Doesn't sound performant
wait is there a event for ender pearl throw?
well be my guest and use move event then which fires every tick
problem is if I am removing passenger in some cases
and adding new ones
old ones are still on getPassenger list
so for loop need to go thru more and more of them
Wouldn't this cause an error
Depends on how the remove methods works
True
no errors in console
I try to use only one method
of those 3 and
not even one works
I even looked in NMS
found list in CraftEntity class
you can't clear list
there is some exception saying action not allowed
or something
I would just make a copy of the getPassengers and loop that. Then use removePassenger
but what do I get with that
if I make a copy
still I will not remove passenger of player
or let me try
So I cloned passengers
and nothing
bananas
Projectileshootevent maybe
is there something like destroyBlocks()?
We got Block::setType
There’s also Player#breakBlock
I have found why was not working
xd
I was canceling EntityDismountEvent
because when players were entering water Passenger will dismount
Lul
is there a way to check
reason of dismounting
I will only need to cancel it when player goes under water
..
?google How to send title to a player *Spigot *1.8
Google your question before asking it:
https://www.google.com/
I thought it would automatically do something like this:
https://letmegooglethat.com/?q=How+to+send+title+to+a+player+*Spigot+*1.8
but ok
haha
I'm sure there are plenty of good SkyWars plugins for the latest versions.
Would be an idea to have this feature
Move on to the latest versions!🤩
Cafe need many features xd
Python
Oof
With the archived lib in python
@ivory sleet
Node? For this then java 
This method are for get speed and not progress?
it says progress in docs
Yeah...
“The returned value is the amount of progress made in breaking the block. When the total breaking progress reaches 1.0f, the block is broken.”
it returns Infinity when broken xd
Hmm if "never" return 0 then you can make a report in jira for check
The docs should specify it returns infinity if the block is broken though
smh it returns Infinity instead of 1.0f when broken
if (enabledModules.get("PLAYER_BREAK_TOO_SLOW")) {
Block block = e.getClickedBlock();
if (block != null && block.getType() != Material.AIR) {
scheduler.scheduleSyncDelayedTask(plugin, () -> {
float progress = block.getBreakSpeed(player);
System.out.println(progress);
if (progress != 0.0 && progress != Double.POSITIVE_INFINITY) {
Utils.kill(player, "PLAYER_BREAK_TOO_SLOW");
}
}, 70L);
}
}
Nice
Maybe can check the method and try a PR
Maybe for 1.19 (?
i dont think my brain can handle a PR
it can only handle so much
Maybe Later i can check
any one know how would I telport Player with Passenger
PlayerTeleportEvent is not called
so I can't dismount passanger
But if you can make a jira ticket for all this things
?jira ^
Dismount, tp, remount
Actually it’ll probably auto dismount so you can skip that part
nop
it wont even fire PlayerTeleportEvent
if you got passenger
on you