#help-development
1 messages · Page 2171 of 1
That was what I have been using, entityType and it didnt work when I tested it
not sure if that was the problem or not, but I have tested with entityType
whats the point tho?
just use EntityType.SPIDER
idk
good to have clarity
its useless
in ur code
just use EntityType.SPIDER
So as you said, entitytype is an enum, do i have to define spider within an enum?
its part of spigot
thats what I figured
no just do this: e.getDamager().getType().equals(EntityType.SPIDER)
dont use .equals
use ==
because its an enum
e.getDamager().getType() == EntityType.SPIDER
yea, but try to use equals for most stuff in Java
== for primitives and enums
alright
dont use .equals() for primitives and enums
@EventHandler
public void MobHitEvent(EntityDamageByEntityEvent e) {
if (e.getEntity() instanceof Player) {
Player player = (Player) e.getEntity();
if (e.getDamager().getType() == EntityType.SPIDER) {
player.sendMessage(ChatColor.DARK_RED + "You have been given poison from the spider bite!");
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 8, 1));```
can cause issues for some enums im pretty sure
Look good?
yea
yes that should work
you can change this:
if (e.getEntity() instanceof Player) {
Player player = (Player) e.getEntity();
}
```to:
```java
if (e.getEntity() instanceof Player player) {
}
if you are on a newer Java version
I just have one more issue, cant load the plugin to test server getting error: "Caused by: java.lang.UnsupportedClassVersionError: me/nuclearkat/custommobeffects/CustomMobEffects has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0"
I tried that yesterday and for some reason it kept spitting cant define method errors
thats amazing
how do i
not know that
xD
So the class file version error... I'm ont sure how to fix that, is it something in intellij?
which Java version are you using and which Minecraft version are you using
version 60 is java 17 im pretty sure
Java should be latest, minecraft is paper 1.8
maybe you need to change your Java version
ye
1.8 server?
I prefer 1.8 over others, just havent bothered to change it to 1.18
your Java is too new for 1.8
you can easily change that in intellij
change it in your gradle or maven file
and in the project settings
Should I keep using java 17 and just change server version to 1.18.2?
or would that even do anything
so I recommend to always use the newest version
That's probably what I would want anyways
probably
as long as u dont use nms nothing should change
actually no
some of the enum names change
Java 17 is 10000x better than 1.8
yada0 why would they change? I'm developing for 1.18.2 already
yea
a bunch of stuff changed in the api as well
its way harder to change version for mods than for plugins
atleast in plugins we have spigot to handle most of the backend nms stuff
im using protocollib :D
I guess I just don't understand why I wouldn't want to just change server version to 1.18
Since I'm already using spigot 1.18.2 api
lol
it makes no sense to use spigot 1.18.2 api for 1.8
I have via installed yes
if one spigot api version works for every mc version why releasing more than one api version lol
Why not just add features to the existing api
tested the custom mob effects and the spider still doesnt give poison when it hits me
Do I have to add a conditional that checks for the entitytype whenever a player gets hit?
can you show your current code
@EventHandler
public void MobHitEvent(EntityDamageByEntityEvent e) {
if (e.getEntity() instanceof Player player) {
if (e.getDamager().getType() == EntityType.SPIDER) {
player.sendMessage(ChatColor.DARK_RED + "You have been given poison from the spider bite!");
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 8, 1));```
Some features from the 1.18 API don't work on 1.8 and vice versa
you get the message in chat?
Neither
the potion effect or the message
What if I change, player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 8, 1)); to ((Player) e.getEntity()).getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.POISON, 8, 1));
I tested that and it does not work
what if you hit a Spider instead of you getting hit
I suppose that could work, if I did that I'd like to add an additional condition that checks if they hit the spider with their fist
That way if you have a tool or weapon you won't get the poison effect
Another plugin I wanted to make was one where if you take fall damage it will give you slowness to sort of simulate hurting your feet
if(target.getHealth() > 1) {
target.setHealth(target.getHealth() - 1);
target.playEffect(EntityEffect.HURT);
}
else if(target.getHealth() == 1) {
target.setHealth(0);
//do some other stuff
}```
why does that not kill the player -.-
It's in a repeating scheduler btw
If the player’s health is 1.1, it won’t deal enough damage, leaving them with 0.1
make sure to floor the target.setHealth(target.getHealth() - 1);
if the players health is 1.1 it wont do damage at all
yes thats why its a double
well yea., its just not displayed
yes
Think you can just change > 1 to > 0. I think you need to avoid setting the hp to negative, can’t remember if that causes problems
that fixed it, thanks
not the place
If I use EntityDamageByBlockEvent that returns the block that damaged the entity correct? And if so, does that apply to fall damage?
try it and see
it probably won't
since the block itself isn't causing the damage
Maybe says something for dripstone since that increases fall damage, but not sure.
I looked it up in javadocs, it "Returns the block that damaged the player."
Might just have to play around with it a bit
the player landing on the block is causing the damage
the block isnt causing the damage
like how say, a cactus causes the damage
right
if you want to find fall damage
you can use entity damage event
check if the cause is DamageCause.FALL
and then u can get the block under the player
Ahhhhh that is exactly what I need
make sure to check if the entity is a player
theres no player damage event
for some reason
I know that's what I was stuck on
I kept trying to look for/create a fall damage instance
.
classic case of https://xyproblem.info/ 😄
Asking about your attempted solution rather than your actual problem
It's more about the experience, I'm pretty new to spigot api so instead of someone writing the code I need I'd like to write it myself so I can learn
yes we're not gonna spoonfeed u
rarely anyone does here
just gonna give some pointers on how to get it done
telling u which event you need isnt really doing it for you
what to look at, etc
if (e.getEntity().getLastDamageCause().equals(EntityDamageEvent.DamageCause.FALL))
ok
because that gives u an EntityDamageEvent
So essentially just being more specific?
pretty sure EntityDamageEvent has an getCause, right now ur using the last damage cause instead of the one that comes with the event. those might not match im not sure
oh i meant this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityDamageEvent.html#getCause()
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent
yes
getLastDamageCause gives you an EntityDamageEvent
its weird
wait
nvm
you are using the EntityDamageEvent lol
just use e.getCause()
sorry
if (e.getEntity().getLastDamageCause().getCause().equals(EntityDamageEvent.DamageCause.FALL)){
((Player) e.getEntity()).getPlayer().addPotionEffect(PotionEffectType.SLOW.createEffect(5, 1));
((Player) e.getEntity()).getPlayer().sendMessage(ChatColor.DARK_RED + "You have injured your ankles and been given slowness for 5 seconds!");
```
When I did e.getCause it just gave me @NotNull error
also
if (e.getEntity()instanceof Player player){
}
do this
so you can just use player instead of casting again
every time
this automatically casts the entity into player variable
if ur in latest java
"Patters in instanceof are not supported at language level 8"
ok then dont do that
if (e.getEntity()instanceof Player){
Player player = (Player) e.getEntity();
}
class HandleWorlds: Runnable {
override fun run() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(Main().plugin, Runnable() {
send("Test message.")
},0,20)
}
}
i am currently fucking around with runnables but why isnt this doing anything?
the way you cast it like 3 times is annoying me
intellij did that automatically when i did e.getEntity().getPlayer
well ehh you know this is a runnable inside a runnable right?, did you start it?
how would i "start it"?
exactly how you are starting the one inside it. but i dont think u really want them nested?
does implementing Runnable not require me to use the run fun?
u could also send test message inside run
so if i remove the scheduling method how do i set delays etc?
you need to actually start it somewhere
for example your onenable
but instead of using Runnable, use the class name
https://wiki.vg/Protocol#Player_Rotation is this a serverside packet or a player packet? I want to update the players head rotation without teleporting so im using this packet and setting pitch and yaw on the players position
like reference it in the main class?
no
like call the Bukkit.scheduleSyncRepeatingTask somewhere
for example in onEnable
ye
thanks a lot mate
whats the difference between Bukkit.getScheduler() and BukkitRunnable?
you use the scheduler to start the bukkit runnable
e
fun createWorld(): String {
val worldname = "testworld"
val worldcreator = WorldCreator(worldname)
worldcreator.type(WorldType.LARGE_BIOMES)
worldcreator.generateStructures(false)
val world: World? = worldcreator.createWorld()!!
world?.worldBorder?.setCenter(0.0, 0.0)
world?.worldBorder?.size = 100.0
world?.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false)
File(world?.worldFolder, "gamedata.yml")
return worldname
}
is file in line 11 not being created because the world may have not fully been created yet?
im not really that familiar with kotlin but possibly
tried replacing world?.worldFolder with Bukkit.getWorld(worldname).worldFolder but it still did nothing
I want the player to stop flying even I am doing this its not stopping to fly:
if (!fly) {
Player p = (Player) sender;
p.setFlying(true);
fly = true;
p.sendMessage(ChatColor.GOLD+"Flying Enabled");
}else if (fly == true){
Player p = (Player) sender;
p.setFlying(false);
fly = false;
p.sendMessage(ChatColor.GOLD+"Flying Disabled");
}```
Why are you setting a variable? Use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#getAllowFlight()
me?
yes
oh ok
ok
You would want to do something like p.setAllowFlight(true/false)
^
Are you trying to make a /fly command?
yes
wait let me try that
IT WORKED
THANK YOU
No problem
hi, im trying to do a kit sorting. i have the general concept running. but im trying to add the items into a map, but the map is always empty, does anyone now why?
Map<Integer, ItemStack> newSort = new HashMap<Integer, ItemStack>();
@Override
public boolean onCommand(CommandSender s, Command c, String l, String[] args) {
Player player = (Player) s;
player.getInventory().clear();
KitManager.givePlayerKit(player, KitManager.getKit("tank"));
player.sendMessage("Sort test");
for (int i = 0; i < player.getInventory().getSize(); i++) {
ItemStack item = player.getInventory().getItem(i);
if (item == null || item.getType() == Material.AIR) {
continue;
}
newSort.put(i, player.getInventory().getItem(i));
}
return false;
}
@EventHandler
void onChat(PlayerChatEvent e) throws IOException {
for(int slot : newSort.keySet())
{
ItemStack item = newSort.get(slot);
Bukkit.getLogger().info("test");
}
//e.getPlayer().getInventory().clear();
KitManager.givePlayerKitWithCustomSort(e.getPlayer(), KitManager.getKit("tank"));
Main.yamlConfiguration.set(e.getPlayer().getName() + "tankkit", newSort);
Main.yamlConfiguration.save(Main.file);
}
Your theory is most likely right XD
in my main, the command works, but it doesnt add the items to the map
my theory is that you register your command and listener both with a new class
meaning its well a different instance
so the filled map is in another instance
Instance but yea ^
you also never return true from your onCommand so the command will always display an error
You don't have any call to create a new file. The constructor doesn't do that
the listener and command is in the same class so i think thats not the problem
no i mean instance
for example you register your command with new YourClass() and you do the same for listener
those are now different instances of the same class
oh ok i read that wrong xd
Either use teh same instance or make teh Map static
teh
can someone turn elgarl's pirate mode off?
not editing it 🙂
haha
oh it works now thanks
how would i fix that
Create a new file
File("$worldname/gamedata.yml").createNewFile() like this?
Yes. File is only a pointer. Nothing needs to exist at that location
Not until you create it.
gotcha
anyone knows what is inventory context 0x77 on 1.12.2???
How can I make a local variable for each player that would work with threads?
too vague a question
ah
does anyone know how to get a item of a map from a config?
example of the config: Koasyytank: 3: ==: org.bukkit.inventory.ItemStack type: POTION damage: 16389 amount: 3 so i tried to get the list, and then get the item from the list / map. but it wont work, does anyone have an idea?
That is not a valid serialization of an ItemStack
Why not just serialize it properly and you can read it easily
I don't even know how to put it differently. I'll try this: I have a variable that should count the number of squats a player has made over a period of time. It must be a local variable, because it must be different for each player. After I want to create a new thread using Bukkit.getScheduler.scheduleSyncDelayedTask(). But I can't use local variable in thread. What to do?
Wack I didn't realize that was serverside too
who do u think tells u the statistics
2:
type: FISHING_ROD``` something like this?
Thanks
Stuff like that could be completely client side too.
not if its persistent across (re)installs 😎
🤤
I've never really looked at that data. Same with advancements
is there even a way to create advancements with the api?
i thought it included creating json files too
I'm not sure if this will suit me, because I have to reset this variable
Use a database then
all you have to do is store teh current value when you want to reset
put it in the players PDC, then subtract that value from the statistic
Now I understand, thanks
can someone help me with writing yml files using yamlconfiguration? (non config file) the docs are really confusing for me and couldnt find anything online
Can anyone here help me with the LuckPerms api?
LP have their own help Discord
does anyone know to get a map from a config?
#getSection?
ConfigurationSection#getValues(true)
nearly :(
xd
oh thanks it now works 💙
I am asking because the wiki is minimally useful for this issue lol......
I already looked there
what are you trying to do?
Check if a user's in a group
Both the methods on the wiki don't seem to work properly
thats just Player#hasPermission
Yes but the issue is if a player is opped, they always return true
Deopping the players is not an option so instead I tried this
But it seems to return true 100% of the time
Or at least for any existing group, idk what happens if pass a group name that doesn't even exist
uh
Oh
I think I know what I did
Yeah it's my bad I'm braindead
Should have been g -> g.getName()
how can i simulate my own chorus fruit effect
you mean the teleportation ?
hi i have a problem with that i have a plugin that a have made but i crash the server after som hours
i think it's this code https://paste.md-5.net/apuceporuy.java
pls help me i don't get any error or somthing it just crash
public static void catcher(Zombie zombie , Location location){
zombie.setCustomName(ChatColor.RED+"Catcher");
for(Entity entity:zombie.getNearbyEntities(3,3,3)){
if(entity instanceof Player){
Player player = (Player) entity;
entity.addPassenger(player);
}
}
}```This is suppose to put player as a passenger on zombie but it does not do that
huh
you look for entities arround the zombie
then try to add the player as passenger of another player
so himself probably.
If you only have one message this code will loop indefinitely java while (nextMessage == lastmessage){ random.nextInt(messages.size()); }
oh yea
i have like 16 or somthing
ok, then this runnable is not crashing your server
its working
what kida things can crash the server?
doesnt this always loop infinitely as soon as you hit the last message?
too many entities
actually yes., as its just generating a random number, it never changes anything
wierd loops
that loop will never exit
yeah but i can crash after 8 hours and no one needs to be online
so it's this code that crash the server becus i am going to end of the list?
yes
problem is ur while loop is doing bassically nothing
it generates a random number and does nothing with it
how can i fix it?
ah well get the player location, add some random offset. check if its safe, teleport
First of all: Dont catch an catch(ArrayIndexOutOfBoundsException e)
second of all: don't create a new Random instance every time
Same goes for NPEs
does the levitation effect does not work if mob has a passenger?
What IDE are you using?
ide?
hi, ive recently created 2 different currencies using gemseconomy, and now im using moneyhunters for the players being able to get those currencies but i can only earn the defaul one, how can i set it to players to gain different currencies depending on the mob they ar killing/ore they mining? Thanks
so eclipse im guessing
is this something you are developing?
no intellij
like, with code
this the development channel
else ask #help-server
k ty
Then click into your class and press ctrl + alt + L
ok
Hello, hope everybody are good, i've one question, I would like to give every 5 min an item to all the players of the server, what should I use ?
?scheduling
You can also use a Timer and start a bukkit runnable every 5mins
Nice thank you, the bukkit runnable will affect the performance of my server ?
Everything can impact the performance if you use it wrong
why i have that error: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure when my connection method is: ```java
public Connection getConnection() throws SQLException{
if (connection != null){
return connection;
}
String url = "jdbc:mysql://localhost:3306/stat_tracker";
String user = "root";
String password = "";
this.connection = DriverManager.getConnection(url, user, password);
System.out.println("Connected to Stat Tracker Database");
return this.connection;
}```
Thanks you for your responses
Use a connection pool like HikariCP
ive noticed that creating an entire world with the server running is very resource heavy causing my server to fall behind. is there a way to avoid this?
hmm lets see here. dont?
Using Paper can help
i have made a zombie which forces player to sit on it but how can i make it so that it can fly
i am using paper
levitation effect does not work on enitties with passrenger
Then there's not much you can do
its basically freezing the server for like 4-5 seconds and then created a thread dump
why would you create a whole world im confused
Creating a single world should not lock up your server, unless your server is trash
that too
can we see the dump?
maybe theres not enough ram allocated to it?
kk wait
uh its too large to paste here ill make a pastebin
?paste
i have made a zombie which forces player to sit on it but how can i make it so that it can fly
i just want to fly vertically (no control )
Just set the velocity then
hmm
Entity#setVelocity(new Vector(0,1,0))
and can we also see the code?
maybe just give the player the velocity and spawn a falling block with the same velocity and periodically just teleport the player to the location of the falling block and readjust velocity
this way you have a smooth transition and the player has (nearly) no control
faling block , i want to do it with zombie
I need to get crafted amount from a craftitemevent, how can I do that (reply when you can)
then he wont move
result.getAmount()?
i am trying to make it so that there are custo zombie around which can catch the player and fly , then leave them at a height
good luck
result is an enum
getRecipe().getResult()
yes but I need what has been crafted
so like if you shift click bread and make 1 stack
i want 64
not 1
this event fires when a crafting recipe has been completed
in a crafting table
not when it has been crafted
you check the output slot for the result
mathfs
what math even is required
So just check if player is shift clicking and calculate
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/PrepareItemCraftEvent.html#getRecipe() wouldnt this event be better
declaration: package: org.bukkit.event.inventory, class: PrepareItemCraftEvent
as i think that is called when it is crafted
not when it is laid out in a crafting table
It's the otherway around
If shift clicking, check smallest stack size in Matrix
o smort
are you sure?
No 🙃
But it would make sense for it to be the other way around
Try it and see I guess
What if the player doesnt have enough inventory space?
PrepareItemCraftEvent is the correct one
the velocity launches at once
just compare the inventory before he crafted
and after he crafted
and calculate the difference
then you have the amount
Thats exploitable
how
One tick diff means you can in theory drop items in the tick you are crafting
if you calculate the amount of items could be crafted
with stuff in the crafting table
and the stuff that could be crafted after
you cant drop into a crafting table
You can always drop items on the ground
yea but it wouldnt go into the crafting grid
yea but it wouldnt go into the crafting grid??
if you calculate how much you could craft with the items in the crafting grid before and how much you could craft after
how about this post https://www.spigotmc.org/threads/get-accurate-crafting-result-from-shift-clicking.446520/ ?
though i don't think this post accounts for inventory space.
I created a custom item, which is a paper. The problem is that players can make books with it, how can I disable the use of the specific paper???
can you change a particles color?
from some particles yea
PrepareItemCraftEvent -> check if recipe is book -> check if any ingredient has the PDC tag
For redstone dust
Thank You
why not just checking the custommodel data?
they didnt mention that their item has custom modeldata
dunno why you would create custom items without a custom texture ;p
idk maybe its configurable or sth 😄
but yeah IF it has custom modeldata, that should be good enough
to prohibit crafting
ye i dont remember
Is there a way to convert a project to a maven project in intellij?
Hello team, i'm trying to do a Schuduler and i get a java.lang.IllegalArgumentException: Plugin cannot be null I don't know what to do, my class where the scheduler is : ```public class Salaire {
public static Valdara plugin;
public Salaire(Valdara plugin) {
this.plugin = plugin;
}
public static void salaireJoueur() {
for (Player p : Bukkit.getOnlinePlayers()) {
Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
@Override
public void run() {
p.sendMessage("Execute 1sc");
}
}, 0, 20);
}
hey, does anyone know how to fix an error. i have in my config a hashmap, everything works. but when the itemstack in the hashmap has a itemmeta, it wont work, does anybody why?
the config:
Koasyyassasin:
'0':
type: POTION
damage: 16389
amount: 3
'1':
type: DIAMOND_SWORD
meta:
==: ItemMeta
meta-type: UNSPECIFIC
enchants:
DAMAGE_ALL: 1```
my code:
```java
try {
@SuppressWarnings("unchecked")
Map<Integer, Object> map = (Map<Integer, Object>) Main.yamlConfiguration.getValues(true).get("Koasyytank");
System.out.println(map);
for (int i = 0; i < kit.getKitSize(); i++) {
if(map.get(i) != Material.AIR)
p.getInventory().setItem(i, ItemStack.deserialize((Map<String, Object>) map.get(i)));
}
} catch (NullPointerException ex) {
}```
why is your plugin static?
Didn't notice I just try something before ask but don't work
^
make plugin private
I try
I hope you know what static does and are not just abusing it
You are making a static access of salaireJoueur() when the plugin field is not set
static abuse hmm
lots
I know, but I'm also a beginner and I don't know how works scheduler like I asked earlier
?scheduling
I've read like they said earlier
You're on the right way with the scheduler
You are close, but your understanding of static is bad
don;t make things static simply because your IDE told you to do so
Thank you for the encouragement it's nice, it's help me, i will get more information about the static
Nice to know too for the static
Don't worry, we all started somewhere
Thanks you a lot
remove the static off everything
Good, i will do that
Yes
Add framework support i beleive
then access it as an instanced object
Salaire task = new Salaire(this);
task.salaireJoueur();```
Nice that what I needed i think, i will save that i have to do that next time in my little head with little brain x)
hey, does anyone know how to fix an error. i have in my config a hashmap, everything works. but when the itemstack in the hashmap has a itemmeta, it wont work, does anybody why?
the config:
Koasyyassasin:
'0':
type: POTION
damage: 16389
amount: 3
'1':
type: DIAMOND_SWORD
meta:
==: ItemMeta
meta-type: UNSPECIFIC
enchants:
DAMAGE_ALL: 1```
my code:
```java
try {
@SuppressWarnings("unchecked")
Map<Integer, Object> map = (Map<Integer, Object>) Main.yamlConfiguration.getValues(true).get("Koasyytank");
System.out.println(map);
for (int i = 0; i < kit.getKitSize(); i++) {
if(map.get(i) != Material.AIR)
p.getInventory().setItem(i, ItemStack.deserialize((Map<String, Object>) map.get(i)));
}
} catch (NullPointerException ex) {
}```
dont think that you should cast it to a map
why not just iterating over koadsyyassasin
because i just changed to make sure its not because of the map
then i noticed its because of the itemmeta
and then doing yaml.getItemstack(koadyasssasin + str)
@iron glade @eternal oxide thank you for your help
I put, the Salaire task = new Salaire(this); in my main classe and the task.salaireJoueur(); on my enable, but doesn't work, no error in my log, but i had to search why to the schedule don't work
The issue is you are running it in onEnable when no player are logged in
No players = no scheduled tasks
If you just used an integer itemstack hashmap to put it into the file initially, couldn’t you get the object and cast it back into a hashmap?
if you create a single task for all players, instead of yoru current setup where you are creating a task per player
Nice to know, better like this so ? ```public class Salaire {
private Valdara plugin;
public Salaire(Valdara plugin) {
this.plugin = plugin;
}
public void salaireJoueur() {
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
@Override
public void run() {
p.sendMessage("Execute 1sc");
}
}, 0, 20);
}
}```
If i do that, it work for all player already in the server
where is that player coming from?
But no for the new player wo join
public static void salaireJoueur() {
Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
@Override
public void run() {
for (Player p : Bukkit.getOnlinePlayers()) {
p.sendMessage("Execute 1sc");
}
}, 0, 20);
}```
Where am I supposed to find this "Add Framework Support" button??
Those explanations I found online are from like 2012
uhm, idk.
dont use that character
just change the encoding to something else
use the ChatColors
use chatcolors, or just change the encoding to Cp1252 something else
doesnt matter
I hate to write it out every time my strings get really messy
If you didn't save as UTF-8 you will get corrupt characters when you load it up as UTF-8
i never had problems with other encodings idk
yea change it to UTF-8 but that characters a lot more annoying to use
because u gotta copy paste it every time
It was an old eclipse project which I just loaded in intellij
You will when you start trying to use kanji or other Asian languages
yea, but my plugins are just private for my servers so. but yea thats true
wtf
ALWAYS USE UTF8
Alcohol rant inc?
when is UTF16 becoming a thing
when java switches to it by default
wait till we get so many emoji we are upto UTF128
https://en.wikipedia.org/wiki/UTF-32 skip to 32
UTF-32 (32-bit Unicode Transformation Format) is a fixed-length encoding used to encode Unicode code points that uses exactly 32 bits (four bytes) per code point (but a number of leading bits must be zero as there are far fewer than 232 Unicode code points, needing actually only 21 bits). UTF-32 is a fixed-length encoding, in contrast to all oth...
🥳
FIXED LENGTH?!
why fixed length
the big advantage of utf8 is that it's NOT fixed length
Nothing quite like wasting hard drive space

The main disadvantage of UTF-32 is that it is space-inefficient, using four bytes per code point, including 11 bits that are always zero.
well it's not about hard drive but it's a problem for stuff like embedded devices that only have like 4kb or sth
Remember when we worked with Bits and Nibbles as most computers had 8k of memory. Those were the days.
The first computer I actually owned myself was in 1982. a Singlair ZX Spectrum.
Caused by: java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class org.bukkit.inventory.ItemStack (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; org.bukkit.inventory.ItemStack is in unnamed module of loader 'app')
Does anyone know why im getting this error?
What im trying to do is get an map from a Config that has ItemStacks, what i noticed it it works, but when the Item has a Meta, it wont work? Does anyone know why?
Here is some code:
public static void givePlayerKitWithCustomSort(Player p, Kit kit) {
try {
Map<Integer, Object> map = (Map<Integer, Object>) Main.yamlConfiguration.getValues(true).get("Koasyyassasin");
System.out.println(map);
for (int i = 0; i < kit.getKitSize(); i++) {
if(map.get(i) == Material.AIR) {
continue;
}
p.getInventory().setItem(i, (ItemStack) map.get(i));
}
} catch (NullPointerException ex) {
}
}```
if there is something wrong just let me know.
bruh why dont you iterate over the itemstacks?
you are trying to cast a HashMap to an ItemStack
(ItemStack) map.get(i) will always fail
instead of doing get, use getItemStack
deserialize it, or use config.getItemStack
like this?
try it and see?
still only works with the items that doesnt have an itemmeta.
reading a properly serialized inventory```java
List<Map<String, Object>> inventory = (List<Map<String, Object>>) map.get("inventory");
for (Map<String, Object> item : inventory) {
ItemStack stack = ItemStack.deserialize(item);
this.items.add(stack);
}```
Does an API or something exist to do custom inventory size and not have a multiplier of 9 ?
This is if you don;t use getItemStack
no
that's not possible
the client doesn't understand it
hmm looks kinda clean now
Nice thanks !
Forge 
Nice colours


i also want to get the slot where the item is for the kit sorter
wait nvm
i figured it out
what's wrong here Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)
Didn't use tab a single time
yaml uses spaces instead of tabs
used Tab to indent instead of spaces
use a yaml validator to check
no not the uwu cat
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
now it's getting funny
you DID use tabs
(/ω\)
where do you have your plugin.yml
It's snorkel time! ٩(- ̮̮̃-̃)۶ uwu :3
weird, what ide do you use
are you using maven?
°w°
it should normally be in /src/main/resources/
if you are using maven u have to put it in resources ig
-<
I rewrote it and there I didn't 100%
do you use maven?
plugin.yml belongs to /src/main/resources/
fix your errors smh
ah hell it got this project all messed when importing it from eclipse
bruh
eclipse's maven integration is so shitty
yep
the resources folder isnt even there lmao
bruh
create it then
hello
hi do you need help or smth xd
good morning
thanks u too
how are u
good u?
lol
im good too
noone asked me how I am :<
how are yu alex
oh, how are you? xd
hangover and hungry lol
i can use java 8 with newest versions?
no
1.18 requires java 17+
or are you talking about plugins?
Yeah, thankfully
yes
every version i think has a different class version so you need a other java version
you can compile a plugin against EVERY java version
You shouldn't though
I always compile and code my plugins for java 8
yay
i just switched to java16 for the patterns
most of cool things are in newest java versions
ye
yeah true but also tbh there's no real reason to use newer versions code-wise imho
like new switch system are cool
after java 8, nothing was added that's really like "required" or sth
yea
I mean sure there's some nice features but it's really not worth it if you still wanna support 1.16
Records are nice. Also instance of casts are nice.
yes
true, but both can be replaced with very similar things using java 8
just create another local var for instanceof
and just create your own data class for the records
obv they are just optimized version
indeed
you can only place classes on src/main/java
yeah but idk why it's only src
then your group id - artifacts
added the modules
it did a \ automatically
new > directory > main - java
weird
it doesn't do that for me
but anyway, you have to create a FOLDER, not a PACKAGE
if you upload your whole stuff on github I'll fix it quickly
Incoming PR
nah I want write perms lol


corect dir
I think I got it
👍
Until it crashes and throws a huge tantrum
now it says it doesnt find main class
it's the worst
it's basically 100% useless for spigot
it's good for forge and stuff
and it crashes my intelliJ like every day twice
still wrong
rightclick on the "java" folder, then do "mark as sources root"
NAHHHHHH
did you right click the java folder?
yes
its good for generate templates
right click your pom.xml. is there an option (at the bottom) like "Load as Maven project" or sth?
how would that change anything
it has nothing to do with this
rn yea
how does one instantiate a sql db when a plugin starts, do u open a connection and close it every query or make a connection and close it on plugin disable
basically, yes. but you should have more than one connection anyway. check out Hikari
HikariCP
that looks good!
whats the pros against jdbc
it keeps open a "pool" of connections and whenever you need one, it gives one to you. in JDBC you have to care about that yourself
I reloaded the project then it gave me the option to select as sources root
ah perfect. yeah it should be fine now
do you also have a resources folder now?
so I never have to worry about closing any connections?
oh wow i dont really remember how to setup an plugin lmao
oh no you still have to close them
oh aight
just create a pom.xml, add spigot as dependency, create a plugin.yml and a main class that extends javaplugin, and that's it
imagine using maven instead of Beautiful gradle
it's still saying it doesn't find main class wth
both are fine
but imho maven is WAAAY easier to use
tf, and why for me is hard asf
english seems to be hard too lol
it is
¯_(ツ)_/¯
:'
I have to use Gradle with forge and it's a
moment
yea lmao
I really dislike gradle because it uses a weird syntax, has a ton of integrated "lifecycles" that noone needs, always needs to download a huge 150 mb wrapper script that needs to constantly run in the background, etc etc
It's however also very powerful, sure
TL;DR: Both maven and gradle are fine and whoever prefers X will always dislike Y
but yeah both are totally fine to use
yea
i agree
I learnt maven first so maven is my boooi
me gradle
in fact I really hated maven at first lol
I had some discussion with someone about it on github
lol
and i just ruined everything lol
understandable lol
anyway lombok is cool!
No
most people here hate it for no obvious reason
tested it and i see it crash the server still
same
why
^
how to trigger people:
public class Test {
public static final Test INSTANCE;
private static Test getInstance() {
return null;
}
}
@Getter
im officialy the most stupid person on the earth, im wondering why the map is empty but i clear the inventory before i add them
oh nooo i said it!!!
r/wooosh would be better xd
the joke is that the field is public but the getter is private and that the instance is always null anyway
LMFAOOO
bruh i know xd
The only reason I don't like Lombok is cause it's Lombok
If it was Lombawk I'd be pretty ok with it
damnnn
aaaaa
lol
you gotta be shittin me, this thing set the package in the main class to main.java.me.minesuchtiiii.autoequip;
and exported without errors
oh wtf
you haven't seen anything
that's because you moved the files BEFORE setting the new directory as sources root
ah shit yea makes sense
just do Ctrl+Shift+R and replace all "main.java.me" with "me"
(long)int test = 1;```
this block only made the server crash 45 times when I tried to wrap CraftServer
;))
that's auto generated code
Waiting for the person who has yet to learn about for loops to post code
thanks, finally it's loading
yeah I know how you feel lol
had those problems myself way too often
it's always when people use eclipse, then switch to maven, and now you try to import in intellij
please tell me that's not always the case when importing from eclipse
}```
hihih
nope, as explained
wait i just fixed my error without even trying to fix it
it happens when you do "normal eclipse project -> maven eclipse project -> intellij"
which is better
for loop or forEach
depends
do you need the index?
no -> foreach
yes -> for
techincally both are the same
yea
javac internally still creates an index but you can't access it
the bytecode end up being the same
Iterator?
Collection::forEach kekw
yeah java 8 is heaven sent
who gonna use it?
an iterator?
iterator when you want to modify the Collection as you process it
yes
well for example if you iterate over collection and want to remove stuff
I didn't know how much of 8 I didn't know untill I watched an old video from the release of 8 on what was new
for example this won't work:
for(String string : myStringList) myStringList.remove(string);
you need an iterator for this ^
removeif which takes in a consumer or w/e it's called
yea i know that, but like when you code a plugin
yeah but sometimes you might want to loop and do other stuff as well
for example stuff like this
wait do you still need a case label in the new switch?
jdk 14
im probably confusing it with rust rn
no
ah im java17
im java8
the enhanced switch was added in java 12
wait i dont remember lol
Yeah the new switch is pretty slick.
i just read it somewhere
it's nice but you can do the same thing since like forever
at least for the syntax thing
it does offer some new things though that cannot be done in java 8
syntax is more sexy
well you need a case
but I dont remember which exactly
this wont work
yea
case 1 -> {
}```
that
that can be done
just the syntax is different
then upgrade
of course
java 16
still
case 1: {
}```
```java
case 1: //code
public static void main(String[] args) {
int myInt = 1;
switch(myInt) {
case 1:
System.out.println("one");
break;
case 2:
System.out.println("two");
break;
}
can run on 1.8
it's exactly the same thing
Hi guys, can I run plugins i created with Java 17/18 running a Server Version buildt in 1.8 for example creating a plugin in java 17 and using paper 1.12?
no
you should do your plugins in the oldest java version you wanna support
if you want to do a plugin that should run on java 8 (spigot 1.12) you must compile your plugin for java 8
make plugin in the newest version then make an wrapper for it
I ALWAYS code for java 8 unless I know this plugin is for 1.17 or 1.18+ anyway
good luck with that lol
that is ur options
Yeah i am trying to do stuff with NMS but on what i can see something is not working in older minecraft version... for example i have problems with npc textures
Just use that new Minecraft server rewrite that doesn't use any Mojang code
or make an thing that i dont remember cuz i dont have a good memory
well uh im trying to load an user from the database, and that user has alot of data like a list of homes, cooldowns, a kingdom. So should i load all of these within a new preparedstatement or what? im confused
you can download more RAM
DownloadMoreRAM.com - CloudRAM 2.0
what is that site even doing
nothing lol
fun
yea really funny
xdd
anyways give me an answer for my question lol
what was your question?
any english version?

it just says "32 days, 12 hours, ..."
i know xd
?paste
well i hate database
you can do it however you like. if you need all of that data often: load it all at once, when they join or sth. that also makes you don't have to worry about async stuff all the time
the databases hates you too 🙉
I'd definitely load their data on join at once
naahhh
i'm planning on loading all its data when they join and then cache it in the playerdata class
is there any way i can change intensity of rain maybe making it drop more water or smth
or am i delusional
yes that sounds like a good idea and I'd do it the same
im just wondering how to implement the queries as i need multiple queries from different tables
nope
the rain animation is 100% client side
where are java base code docs for be a good dev?
all the server does is to tell the client "it rains now"
so texturepack to make it look intense?
is that what i am limited to
yes
java base code docs? you mean the javadocs for "included" stuff like java.util.List?
yes
alr
well no
javadoc rules
to respect
like myMethod()
ect i dont really remember some rules xd
Is there any tutorial to make the custom items with texture packs
Java conventions 🤤
I don't know any but I could send you a tiny resource pack that includes a few songs and a custom model data for a music disc lol
thanks
anyway why ppl here hate static methods or fields?
i mean is it possible?
because they don't know what static means and when to use it and when not to
you can NOT create new items. all you can do is to make existing items look different when they have a certain integer value for "custom model data"
static are cool
:notreally:
Cant i make it via PDC
if you want custom textures, you HAVE to also set the customModelData value
static are for utils
not only for that
static is for stuff that regards the class itself
static is for stuff that doesn't change between instances of this class
example:
yes
public class Person {
private final static int MAX_AGE = 150;
private final String name;
private int age;
public Person(String name, int age) {
this.name = name;
if (age <= MAX_AGE) {
this.age = age;
} else {
throw new IllegalArgumentException("No one can be older than 150 years!");
}
}
public void setAge(int age) {
if (age <= MAX_AGE) {
this.age = age;
} else {
throw new IllegalArgumentException("No one can be older than 150 years!");
}
}
}
Person.MAX_AGE lol
MAX_AGE is common between all persons in this case
so it's static
bad example of course but you get what I mean lol
also singletons
yes xd
e.g. Bukkit.getOnlinePlayers()
yes its static
obviously you never have more than one server running
so yeah the server is a singleton
same for every plugin
yea
all plugins are singletons by design
gtg
so in theory, EVERY field in the main class could be static
cya
yes
is there a way to compare armor by its strength?
what exactly do you mean with "strength"?
i have problems taking signature of player (SKIN nms)
like gold armor is better than leather armor
just compare their maxDurability
but tbh there's only IRON, LEATHER, DIAMOND, etc
it's only 5 or 6 types anyway
I want to make a player automatically equip armor from ground if it's better than his current armor
okay but now imagine this
someone could have a leather chestplate that's insanely enchanted
so it's way better than iron armor
yeah true I guess I have to take that into consideration
wait, why not replace the duplicated method to the setAge?
yeah it was just an example
ah okay
I just wanted to show people that "static" isn't automatically bad
because MAX_AGE will always be 150 for every person
I know the example is stupid
yup
sTaTic AbUse