#help-development
1 messages · Page 1768 of 1
Hey you?
That one
im sure it is right
okay
The first
public void connectMySQL() {
String host = getConfig().getString("mysql.host");
int port = getConfig().getInt("mysql.port");
String database = getConfig().getString("mysql.database");
String username = getConfig().getString("mysql.username");
String password = getConfig().getString("mysql.password");
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(10);
config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
config.setJdbcUrl("jdbc:mysql://" +
host + ":" + port + "/" + database + "?useSSL=false");
config.setUsername(username);
config.setPassword(password);
hikari = new HikariDataSource(config);
}
this is my final code Conclure
i guess it is right
im getting this error
if you are on the main class (the one that extends javaplugin), only use
Logger logger = getLogger();
You need a runTaskTimer method
okay
Here there lot of people talking
the credentials is correct i connect with mysql command in terminal
Bukkit.getServer().getScheduler().runTaskTimer( Your main class instance , () -> {
Code to print timer;
},0, 20);
Like this each second you’ll run this task and so if you decrease by one an integer that’ll be the timer you’ll have a timer
Ok thank you
Then set a runTaskLater(); task that’ll stop the runTaskTimer() task
Else it will go negative
how would it be possible to convert an advancement name into the real user readable one
^
That is also true
and how would i get the value then
no
how would it have any idea what the name is
does it just...know somehow or
sure
also how would i create the hashmap with all of these
would it just be loads of puts
oh yeah a yml would be good
anyone know why this error occurs?
error: https://paste.md-5.net/ulemayumaq.md
main menu gui class: https://paste.md-5.net/ohawuxahos.java
main class: https://paste.md-5.net/nuvaqetuba.java
Hey, I'm currently having a bit of an issue
I'm trying to detect if an entity attacks another, even if it doesn't do any damage by default (shield blocks an attack, for example)
EntityDamageEntityEvent doesn't fire in the case, how can I go around it?
The method you're calling on your constructor relies on your plugin instance, which isn't set yet
bloodMoonHelmet.getItemMeta().setUnbreakable(true);```
when i use this line, the helmet which is dropped from the mob isnt unbreakable
You have to re-set the meta to the item
I was exporting my plugin to Eclipse but when I export it I get this error
JAR creation failed. See details for additional information.
Exported with compile warnings: ArpionRP/src/module-info.java
Exported with compile warnings: ArpionRP/src/xyz/arpionmc/arpionrp/Main.java
Resource is out of sync with the file system: '/ArpionRP/src/xyz/arpionmc/arpionrp/plugin.yml'.
Resource is out of sync with the file system: '/ArpionRP/src/xyz/arpionmc/arpionrp/plugin.yml'.
ItemStack item = ...;
ItemMeta meta = item.getItemMeta();
meta...
item.setItemMeta(meta);
Oh, thank you!
meta.setUnbreakable(true);
bloodMoonBoots.setItemMeta(meta);```
is this a valid example
Yes
Some1 can help?
why does it throws me the stackoverflow exception?
https://pastebin.com/rcwhLZ1Q
probably wrong topic but how would i get advancement icon url's, like the completed ones
man I'm super confused
so I have two locations
and just for easy usage I put them in a location array
but when I do that randomly their y coordinate changes
These two locations have the same X and Z, just one is on top of the other
Can you send the code?
Send code we cant guess
Probably just a matter of cloning the loc
yeah I think I figured it out
apparently if I set one location to another one, if I use the add() method on the 2nd location it adds to both of them
I fixed it by doing this:
location2 = new Location(location1.getWorld(), location1.getX(), location1.getY(), location1.getZ())
instead of:
location2 = location1
Stackoverflow Error
err could this just be a misuse of =, when I should use ==?
You thought right
For instance with:
location2 = location1
If I was to later do:
location2.add(0, 2, 0) it would also add that to location1
Your issue is that if you make it so location 2 is equal to location1 it changes the y values?
this was my problem
I only wanted to change location2, not location1
for my config.yml file to just be a copy of a file in my jar, do i save it in the same location as my plugin.yml before calling this.saveDefaultConfig()
Put in the resources folder config.yml
thought so ty
And the config file will be the one in the resources folder
Np
so i dont need to call this.saveDefaultConfig() if the user doesnt need to edit?
No you should call it anyway since it’ll create the folder
At least I think/remember so
Can some spigot god confirm or disagree?
Hey guys im trying to make a double drop for ores and when I try to add the drops 2 times to a block it still keeps it as the normal 1x drop what am I doing wrong?
e.getBlock().getDrops().clear();
for (ItemStack item : e.getBlock().getDrops(player.getInventory().getItemInMainHand())){
e.getBlock().getDrops().add(item);
e.getBlock().getDrops().add(item);
}
then clone the location1 before assign it to location2
there is a method called clone for Location objects
Theres a clone() method
package me.lasse333.chatwebhook;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerEvent;
import java.util.Set;
public class ChatWebhook extends JavaPlugin {
@Override
public void onEnable() {
getServer().getConsoleSender().sendMessage(ChatColor.DARK_PURPLE + "[ChatWebhook] plugin is enabled");
}
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.DARK_PURPLE + "[ChatWebhook] plugin is disabled");
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
String message = event.getMessage();
String user = event.getPlayer().getDisplayName();
getServer().getConsoleSender().sendMessage(user);
getServer().getConsoleSender().sendMessage(message);
}
}
:(((
event doesnt pickup
Implement listener
I suggest you to do so anyways
And register the listener
?
thank u
ahh
Not sure if you guys saw this but I cant seem to get this to work ^
This wouldn't be the case with primitives, such as int.
Do I have to actually make my own custom drop because the only thing I can think of is that im not actually setting the block drops to that but instead making a list with the drops and not actually doing anything with it
It only works this way with location1 and location2 as they are reference types.
Meaning they do not store values but instead references to object instances (e.g. new Location)
It actually does make sense if you understand all the logic behind it.
(A lot of other languages require references be explicit, as in location2 = &location1, but Java was made for dumbasses security and ease-of-use)
c/c++ right
Yeah, pretty much any low-level language.
use Location#clone
yeah
also maow do you know how to run code after all plugins have loaded
like after all plugins have had onLoad called
Uhh, is there an event for it?
ohhh
Otherwise, probably not possible.
no i think you can only listen to and dispatch events after onEnable
or technically before
as it prepares it
but whatever
Unless you were to have a repeating task that checks to see if each plugin registered was loaded (if you can see whether or not a plugin has been loaded), but that may cause some minor to major issues.
immutable locations when
Make your own.
Then have a method called toMutable().
extend it and make it throw UnsupportedOperationException
on every set method
not that convenient
That works too.
I mean that is the main point of UnsupportedOperationException.
And is also what Guava does for immutable collections.
hello spigot god
(Plus, for API, deprecate all set methods to show that they shouldn't be used on an immutable type)
Technically references are already this, they are primitive wrappers around addresses for some location in the heap.
The main difference is that low-level languages like C or C++ will keep the type those references refer to (as it is available information at compile-time) meaning you can dereference rather easily, while something like Assembly would have references as plain 64-bit (unsigned?) integers, and you'd have to fetch from the heap manually.
honestly its just easier to use dumb mutable locations instead of doing wrappers or extending stuff by myself
(Fun fact: in Java, you can store primitives as pass-by-reference if you use Unsafe, as you can allocate a primitive to off-heap memory and get its memory address as a long in return, then pass that long to other methods which can use Unsafe to dereference the value in off-heap memory)
onLoad is called for every single plugin before onEnable is called
(What's the point of this? There is no point! It's incredibly unsafe and doesn't yield that much performance increase over something like a Ref class wrapper, but it's a fun thing to do if you're bored)
Eventually, I might make a Java-esque JVM lang that uses Unsafe for shit like this though :)
&int :)
I am demonic :)
ok
Anyway that was ✨ Maow rambles about memory and Unsafe for half an hour ✨
hope you learned something
I need help, I'm stuck, I've been trying to map the materials from minecraft and stuff.. and uhh.
basically I've been doing this for quite sometime but I've got stuck on banners, does anyone know how a STANDING_BANNER (1.12) gets it's color?
it's not by the magical byte value.. somehow that only changes rotation..
BlockState (tile entity) presumably
Because they store patterns
that's nice
md do u have any plans of releasing spigot prereleases?
@eternal night what’s so funny?
spigot has not published any pre-releases for any of the last versions. Neither snapshot nor pre-release builds. Everytime a version is released people spam for an ETA, so asking for a pre-release is like the nice evolution of that
they take longer to release the main version than mojang takes to make the snapshots so it would be in no way worth it
I still don’t see how it’s funny, it was a genuine question if there were plans to share builds which would help speed up plugin upgrades ^^
No
Also speeds up development in any of the chains attached to spigot ^^
People would use them, break stuff, and then complain
are netty channel handlers handled asynchrounously
if so i would need to send synced task to server's main thread to sync it
?
also how would you ever "update your plugin" if mojang might just release something else
e..g what benefit would you have in a version that might just break
you don’t seem to understand, its pretty much what alpha releases are for. Doesn’t mean you release a new version on spigotmc, it allows you to keep up to date with the latest changes so you don’t have to rush everything at once when the actual release comes out 🙃
I mean I could maybe see MD releasing them to trusted devs
But meh, probably not worth it
I am fairly certain spigot is already being worked on for 1.18 don't get me wrong
but there is no reasonable point in releasing a snapshot build
that wouldnt work since the snapshot builds could be miles apart from its previous codebase, thus its not worth it to redo things which might be broken in the next snapshot
but this question was a simple yes/no question for md, i don’t see the point of discussing it here ^^
in order to do something like this, server software needs to follow fabric's path
Fabric modloader updates very fast while its fabric api takes more time
its still the same.
Sorry if i'm being an annoying noob. If anyone can help, what's wrong here? I'm getting Index 1 out of bounds for length 1
https://paste.gg/p/anonymous/e23b2c1af794494da133eedc3db4067c
but it allows the developers to develop mods without using it, thus it allows mod developers to develop things on their own, rather than wait for fabric api to roll out, but that of course is harder to do.
arrays as 0 indexed in java
you should also check that the array even has that many items
it has 1
yea so your item would be at index 0 👍
Java and most of the computer languages count from 0
I wonder if there's some languages that doesnt
fortran 🙏
bruh just this gives me the same error
if(cmd.getName().equalsIgnoreCase("item")) { player.sendMessage(args[1]); }
Lua
oof
oh god
im just so so so so stupid
Max args is args[0]
i think ill get confused even more with languages that counts from 1
I wanted to make a discord bot connected to minecraft, but when I put the JDA dependency in the pom.xml it appears "Dependency net.dv8tion.JDA: 4.2.0_208 not found" does anyone know why?
the pom.xml
Do you have the repository aswell?
repository?
Java wrapper for the popular chat & VOIP service: Discord https://discord.com - DV8FromTheWorld/JDA
Jda doesnt use maven central
So you need the repository
I put the same thing as this and I get an error, "element repository is not allowed here"
any ideas how can i get ConcurrentIdentityHashmap implementation on java
There's only IdentityHashmap implementation
ofc i could synchronise my methods
is it smart to store a currency inside a players PDC?
true
but cannot instanciate concurrent identity hashmap sadly
hola me ayudan soy nuevo como me uno a un pais
?paste
https://paste.md-5.net/inabetuwat.cs here's a code for setting skin to a player, how to apply the skin without recconecting to server?
english only please
if I've done load default config, I can’t add new stuff to the default config right?
As it said it wouldn't replace current config
Hey there, somebody knows a better optimization way for PlayerMoveEvent? I dont care if this one moves one block, I care if player moves his camera, some suggestion please?
Check if the x y and z are the same, if they aren’t then ignore the event
blockx etc
But then you will still process small movements in the same block
Probably want to compare the raw values, and make sure to account for percussion errors
Yes percussion
Actually, that sounds like the reverse of what most want
most want to limit to teh same block, but allow camera movement
i only want make some very sensitive mechanics when Yaw and Pitch have changes 😄
I doubt you can be very precise with pitch/yaw
it doesn;t send that often for camera movement
I think i will just create a default List of integers and make checks if yaw and pitch contains these numbers, and ofc optimize it if they are the same as before(cancel the event)
when I am programming, what is the library that I need?
buildtools?
(for spigot 1.8 server development)
did this when I was younger but I forgot a lot of it
I recommend using a build system like maven or gradle, it makes it much much easier to manage dependencies
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.get(), new Runnable() {
@Override
public void run() {
}
}, (ticks));```
is there a better way to do this?
better in what way
cleaner code
which part is not clean
it's just super chunky
aside from the random () around ticks it's how I would write it
can i smoosh it down into like 2 lines
sure, you can use a lambda for the runnable
ye
if it's like
() -> singleMethod()
but, if you can, use method references
this::singleMethod
(note: do not make another method just use method references)
I'd rather see builder style scheduling
I made a util for my private projects as it gets a bit cluttered
builders dont make sense when all the options are required
because you're shifting validation to runtime rather than compile time
Is requesting my config fine or is converting to a hashmap better
its basically just a hashmap underneath
Ah nice ty
What do you mean
well i have a method that uses the spawn living entity packet
now i need something to destroy that packet
but i dont want the kill animation packet, just to remove the packet entity
the entity.remove() method?
Are you using a method or a packet
packet
Then why are you asking about entity.remove
im not
public void chickenPacket(Player player, Location loc) {
World world = ((CraftWorld) player.getWorld()).getHandle();
EntityChicken chicken = new EntityChicken(EntityTypes.l, world);
chicken.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(chicken);
((CraftPlayer)player).getHandle().b.sendPacket(packet);
}``` how do i destroy this packet after it's been sent to the player
you need to send an entity destroy packet
Have you tried this
that.... was my question
also the wiki mentions an array
where would i get an array from since it's just one entity?
just create an array of one element?
it seems that it supports removing multiple entities at once but you can just create an array with the desired entity id you want to remove
I am doing a plugin on custom enchantments... I want to add the potion effect speed based on the level of the enchantment... this is my code so far ```java
@EventHandler
public void onMove(PlayerMoveEvent e) {
Player player = e.getPlayer();
if(player.getInventory().getBoots() != null
&& player.getInventory().getBoots().containsEnchantment(Enchantment.getByKey(Main.Speed.getKey()))) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, /*I don't know what to put in here...*/))
}
}```
Get the meta of the boots and use getEnchantmentLevel
iirc, you don't really have to fetch the meta unless you're performing more than one call
There is a convenience method on ItemStack
yes
(though it gets the ItemMeta so if you intend on getting more than one enchantment or performing other ItemMeta calls, just get ItemMeta and operate on it instead)
Ah I thought the getLevel was only on meta
example:
may not be the best way to do it but this is what I used in my most recent plugin
Would ideally make a single call to getEnchantments(), but yes
but there is also ItemStack#getEnchantmentLevel() that returns 0 if not present
didn't know about that one
Yes
gonna go do some quick updating slurp
Custom enchantments via the Enchantment class are still very weird
int fortuneLevel = item.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS);
pog this is nicer
so i wanna make a method that throws a fishing rod hook when you right click a carrot on a stick, but how do i specify things like the line/bobber owner and such in the PacketPlayOutSpawnEntity method?
Spawn entity accepts a data int and for fishing rods that int denotes the owner's entity id
PDC doesn’t apply the enchantment glow
Though hopefully Mojang adds something similar to the visual fire NBT tag that they added to entities
True
my onPlayerConnect event isnt getting triggered, I dont know why. java @EventHandler public void onPlayerJoin(ServerConnectEvent e) { String type = CustomConfigFile.getConfig().getString("config.join-type"); ProxiedPlayer pp = LobbySystem.getInstance().getProxy().getPlayer(e.getPlayer().getUniqueId()); DatabaseUtils.initialJoin((Player) e.getPlayer()); ServerInfo sv; if (type.equals("RANDOM")) { sv = LobbySystem.getInstance().getRandomLobby(); } else { sv = LobbySystem.getInstance().getProxy().getServerInfo("LOBBY2"); } System.out.println(ChatColor.AQUA + "[LobbySystem] >> " + ChatColor.GOLD + "New Player Connected. Sending them lobby " + sv.getName()); e.setTarget(sv); } and yes, it is registered in my onEnable
while doing this I got an error can someone help me with it? [20:30:48] [Server thread/ERROR]: Error occurred while enabling Speedboots v1.0 (Is it up to date?) java.lang.IllegalArgumentException: Plugin cannot be null at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at org.bukkit.NamespacedKey.<init>(NamespacedKey.java:72) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at com.nerdxd.plugin.speedboots.SpeedEnchantment.<init>(SpeedEnchantment.java:11) ~[?:?] at com.nerdxd.plugin.speedboots.Main.onEnable(Main.java:20) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:514) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:428) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:619) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:266) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1010) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7] at java.lang.Thread.run(Thread.java:831) [?:?]
what is "ServerConnectEvent" 
ye
it was working
idk bungeecord stuff
but it seems like every time i get something working, when I add the next thing it breaks the other
someone help?
code for speedEnchant where error is happening?
here is the code, I can't figure out what is wrong with it... https://paste.md-5.net/ehubivoqub.java
Main.getInstance is probably null
how can I fix?
are you making the return value of getInstance set to this in your onEnable?
k
that should fix it
like this? java public Main plugin = this;
sounds like a lot more effort and complexity than needed tbh
What does
Nah, just add what I had, exactly. You have to give plugin a value before you try and access it
And you already initialized the variable, if you do it again it might cause issues
like this??? cause this throw error java public static Main getInstance() { return Main.plugin = this; }
No no no
holy...
In your onEnable
idk java either
onenable
Main.plugin = this;
Yes
EntityFishingHook hook = new EntityFishingHook(EntityTypes.bj, world);
hook.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity(hook);```
whats the method for the extra data? im doing it like this instead of the method with every param inside of it
can you like tell me where and what to type exactly?
They just did
cause now I did this... java Main.plugin = this; litterally in my onEnable
Do this
That should work
OH
Try it
we got there eventually folks
IN MY ONENABLE
Ye
like this? ```public Main plugin;
@Override
public void onEnable() {
System.out.println("Speedboots plugin is now activated...");
registerEnchantment(Speed = new SpeedEnchantment());
Main.plugin = this;
Bukkit.getPluginManager().registerEvents(new EnchantmentListener(), this);
}```
Yeah
that thorws error
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Put that as the first line
what's a java 
:sc_zerotwo_think:
me too
Surely if you have an EntityFishingHook you don't really care about version dependence and can just call hook.setShooter(((CraftPlayer) player).getHandle())
Should handle that for you
return this?
No
I don't get it... it keeps giving me errors
im not sure what youre trying to do
thats the function i use to crab an instance of my plugin

public void rodThrow(Player player, Location loc) {
World world = ((CraftWorld) player.getWorld()).getHandle();
EntityFishingHook hook = new EntityFishingHook(EntityTypes.bj, world);
hook.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
hook.setShooter(((CraftPlayer) player).getHandle());
PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity(hook);
((CraftPlayer)player).getHandle().b.sendPacket(packet);
}``` no errors are coming back but the fishing rod just isnt showing up
and i debugged it to make sure the function was getting executed, and it was
Due to your impatience, I'm not helping you
unlucky
Put plug-in = this ; as the first line in the onEnable
I am so sorry... I know Java... I just have been concentrating on tests that I had today... I am very sorry... I fixed the problem with this... ```java
public Main plugin = this;
@Override
public void onEnable() {
System.out.println("Speedboots plugin is now activated...");
registerEnchantment(Speed = new SpeedEnchantment(this));
Bukkit.getPluginManager().registerEvents(new EnchantmentListener(), this);
}
@Override
public void onDisable() {
try {
Field keyf = Enchantment.class.getDeclaredField("byKey");
keyf.setAccessible(true);
HashMap<NamespacedKey, Enchantment> byKey = (HashMap<NamespacedKey, Enchantment>) keyf.get(null);
if(byKey.containsKey(Speed.getKey())) {
byKey.remove(Speed.getKey());
}
Field nameField = Enchantment.class.getDeclaredField("byName");
nameField.setAccessible(true);
HashMap<String, Enchantment> byName = (HashMap<String, Enchantment>) nameField.get(null);
if(byName.containsKey(Speed.getKey())) {
byName.remove(Speed.getName());
}
} catch(Exception e) {
}
}
private void registerEnchantment(Enchantment enchantment) {
try {
Field f = Enchantment.class.getDeclaredField("acceptingNew");
f.setAccessible(true);
f.set(null, true);
Enchantment.registerEnchantment(enchantment);
}catch (Exception e) {
e.printStackTrace();
}```
I am just being dumb
yes I probably should... BUT NOT NOW I AM GOING TO SLEEP SO I CAN MAKE MORE PLUGINS TOMORROW BYE YALL!!!!!!!!!
how can i display the balance of a player from shop gui using the vault plugin to the scoreboard of deluxe hub
please. dont spam it
@silk tiger
There... Ctrl + F find vault please.
Do you have to spam every channel
then you should get mute
i dont fkin care anyways im leaving
how would i get the display name of an item? ItemMeta.getDisplayName() and getLocalizedName returns an empty string for an item without any kind of changes to its name
The simplest way is to get the material and convert it to title case
Yeah you would have to also account for if it has a display name in the meta
ItemMeta#GetDisplayName shouldnt be returning empty though
So maybe you’re getting yhe wrong meta
i try broadcasting it and all i get is ""
i did all i did was use getItemMeta on the itemstack
and try getting the display name from that meta
public String getDisplayName(ItemStack item) {
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
return item.getItemMeta().getDisplayName();
}
StringJoiner out = new StringJoiner(" ");
String[] split = item.getType().toString().split("_");
for (String s : split) {
out.add(s.charAt(0)).add(s.substring(1).toLowerCase());
}
return out.toString();
}```
This should do the trick
huh
Assuming >1.13
👍
i just thought this would work though
ItemStack item = plr.getInventory().getItemInMainHand();
ItemMeta meta = item.getItemMeta();
assert meta != null;
Bukkit.broadcastMessage(meta.getDisplayName());
anyways thanks
getDisplayName will be null if the item has no name
while the code in this class works when you are moving in either water/rain, it does not work if you stand still in either water or rain. Anyone know any ways to get around this?
Should be a runnable instead
Or cache their pos and if it’s no longer in acid dont damage them
Also your class and method names are super ambiguous
guys
i was code in 1.16.5
but the almost of all codes are updated
so cant code in 1.17 any more
im so sad
pls help me
for ex
CraftPlayer disappear
disapear
stop
writing
like
In
this
Messae
Write normally, not one or two words on each line😐
sorry
Is this using a String array or something
String list
what did equalsIgnoreCase change to???
I can assure you String.equalsIgnoreCase has not changed
try coding your plugin against the API, not nms
no it's true they changed equalsIgnoreCase in java 17 now it only checks for uppercase numbers instead of letters
but String is changed
Elaborate please
yo why does the economy reset on my server every now and then. is it caused by my plugin or the server?
we're gonna need slightly more details
such as?
What eco plugin would be a good start
im sry i just checked String did not changed
shocking
LoL
League of Legends
😕 lost boy
i wrote that cause of the capitalization
https://paste.md-5.net/vazesulalo.bash I always get theses errors when i start my server. From what i can see it tries to load 1.17 items even tho my server is 1.16.5 is there a way to fix this?
im not sure because i co own the server
so possibly my friend might have installed a datapack
my bad
also i found the datapack thanks!
how can i get the true target block of a player? since player.getTargetBlock(transparentBlocks, 5) returns the glass pane in a situation like this:
.getTargetBlockExact is better
oke ty!
recreating Hypixel SkyBlock crystal hollows?
well the concept yes
good luck
but quirks like this
have the mining system already implemented?
parts
nice!
pls dont murder me for using an unsupported version, but is there an alternative in pre-flattening versions?
Kill him
btw im still figuring out why the economy resets on my server every now and then, I use Vault and EssentialsEconomy and i believe its my plugins' fault
but idk what part of it
the TabComplete event is broken in 1.17.1 it never gets called
Does anybody know why PlayerItemHeldEvent might trigger twice?
I have debug printing right when the listener is registered, and debug when the event is triggered. Register debug plays once, itemHeld plays twice.
The version of nms I'm looking at shows that canceling that event doesn't call the event again, so I am a little baffled
who me?
You’re doing something wrong then
Once for main hand, once for offhand
Fair, fair. Did not expect for it to call PlayerItemHeld for the offhand every time, but makes sense
Actually, wait
Not sure thats right, I think buobuoo is confusing with interact event
Yeah
Is your plugin an economy plugin
There could be a million factors it’s most likely a plugin
it fetches stuff from the economy
If you send through your code id be happy to comb over it
it only fetches if a player has enough money to buy the certain thing
i can send you the tutorial i followed
Code would be better
ok sure
Im not gonna watch through a tutorial lol
Smooth dm slide :p
so.
this is the class variable(?)
private static Economy econ = null;
private boolean setupEconomy(){
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
econ = economyProvider.getProvider();
}
return ( econ != null );
}
public static Economy getEconomy(){
return econ;
}
}
this is the setupeconomy thing
if (!setupEconomy()) {
System.out.println("Disabled due to no Vault dependency found!");
getServer().getPluginManager().disablePlugin(this);
return;
}
and this is in onEnable
i just made the event with eventhandler on a class thats registered. But it never gets called also the supervanish plugin uses it to remove vanish people from tab-completions which doesnt work in 1.17.1 probably because the event is broken
Economy economy = FastWands.getEconomy(); The way i get the economy
double playerBal = economy.getBalance(e.getPlayer()); this is the player bal
i made a command like /msg then tab-completed and it didnt get called
Can you just send the whole class in a pastebin will be far faster lol
im using viaversion tho idk if that might cause it
its huge and you will die from the ineffectivence
Yeah no idea what viaver does
It’s fine lol
When were tab completions implemented in mc?
since 1.13
Id assume any ver before wont send the packet
yeah its caused by viaversion :/
wait @drowsy helm what you need paste of?
Just the class where you interact with the economy
1.12.2 on a 1.17.1 server and the event doesnt get called but it still sends all the tab completions
in 1.17 client it gets called
so the place where i make the player balance variable?
ok can i explain? thats faster
pretty much, i made custom items (kinda custom), which you can get by buying them.
So because you have to buy it you need to setup economy
ok i will
lets move this to a thread
Sure
help
get true target block pre-flattening
how would u block a username from tab-completion as using viabackwards sends it using some custom packet or something so none of the events get called. Maybe like hide the user from the server so using any method of getting online users wont return it
else if (a == Action.RIGHT_CLICK_AIR)
{
EntityPlayer player = ((CraftPlayer) p).getHandle();
PlayerConnection connection = player.playerConnection;
PacketPlayOutAnimation armSwing = new PacketPlayOutAnimation(player, 3);
connection.sendPacket(armSwing);
connection.a(new PacketPlayInArmAnimation(EnumHand.OFF_HAND));
}
um
what do i have to use instead of playerConnection;
;-;
What are you doing
Also isnt there Player.swingHand or something
No packets required
event.getClickedInventory().getName()
how do I do this on 1.17?
getView.getName or something
i found
aight
getView.getTitle idk
um the answer was b
thanks
xD
Documention suggests so
wow nice
public class Bossbar {
private final BossBar bar = Bukkit.createBossBar("Progress", BarColor.BLUE, BarStyle.SOLID);
private final String ENDPOINT = "https://assets01.teamassets.net/json/donation_total.json";
private final Listener listener;
private final Runnable timerTask;
public Bossbar() {
listener = new BossbarListener();
timerTask = new BossbarTimerTask();
}
public Listener getListener() {
return listener;
}
public Runnable getTimerTask() {
return timerTask;
}
private class BossbarListener implements Listener {
/**
* Adds player to the scoreboard map when player joins.
*/
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
bar.addPlayer(event.getPlayer());
}
/**
* Removes player from scoreboard map when player quits.
*/
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
bar.removePlayer(event.getPlayer());
}
}
private class BossbarTimerTask implements Runnable {
@Override
public void run() {
HttpResponse<JsonNode> response = Unirest.get(ENDPOINT).asJson();
if (response.getStatus() == 200) {
Integer count = Integer.parseInt(response.getBody().getObject().getString("count"));
bar.setProgress(count / 30_000_000);
}
}
}
}``` Boss Bar not updating.
// Bossbar
Bossbar bossbar = new Bossbar();
pluginManager.registerEvents(bossbar.getListener(), this);
getServer().getScheduler().runTaskTimer(this, bossbar.getTimerTask(), 0, 3 * 20);```
i know
oh
shit that was so long ago
lol
yo md5 is there a way to run code after all plugins have loaded
so after all onLoads have been called
declaration: package: org.bukkit.event.server, class: ServerLoadEvent
i think ServerLoadEvent is called after startup
this just screams bad design
wait cant you only register listeners in onEnable
what do you want to do
load extensions
most things should be done onEnable
i mean i could put it in onEnable
not really extensions
but ill do it in onEnable i guess
it'd help if you explained what you want to do
but onEnable is probably the correct choice
i basically have a library plugin
and it has components which would be useful to have per plugin
for safety and stuff
shouldn't the plugins just depend: library, and then tell the library what to do?
Seems like you're having the library try and do things on its own
yeah the library is loaded first
at least it should be
yes
I'd probably use PluginEnableEvent then in the library
because the library should be reacting to each plugin, not all plugins
alternatively switch it around and have the plugins call into the library, that would be more normal use of a library
but its supposed to run before all onEnables
make the plugins using the lib depend on it
well the library onEnable will run before the onEnable of plugins which depend on it
yeah thats already the case
it enables/loads before the others
but it iterates over all loaded plugins in onEnable
sounds like dependency inversion, I guess is the word
protected List<Ingredient> ingredients = new ArrayList<>(9);
``` also why is this giving me an index out of bounds exception at index `0`?
because you didnt put anything in the list
its like automatic dependency injection
oh
i have to fill it?
yes
use an array then
Arrays.asList(new Ingredient[9]) or something
just new ArrayList<>(Arrays.asList(new Ingredient[9]))
ye that
Lists.newArrayList(new Ingredient[9]); 🙂
i tried but it didnt work
well i tried this new ArrayList<>(Arrays.asList(new Ingredient[9]))
your still getting out of bounds?
now im just using simple for loop
was
i was first doing new ArrayList<>(9)
then tried new ArrayList<>(Arrays.asList(new Ingredient[9]))
and now im filling it with a for loop
just use Arrays.asList(new Ingredient[9])
why so
same err?
it seems like im doing something terribly wrong because the collection filling doesnt work either
im using set(int, T)
of ArrayList
where are you iterating over it?
?
like where its throwing the error
public static <T> ArrayList<T> defaultedList(T t, int c) {
ArrayList<T> list = new ArrayList<>(c);
for (int i = 0; i < c; i++)
list.add(t);
return list;
}
``` this was my attempt
to create list
Idk maybe collections just wasnt intented to work with nulls
no the area where you actually iterate over it
not iterating over it
im using set(int, T)
where was it throwing the index out of bounds error then
on it
in ArrayList#set(int, T)
yeah
does Arrays.asList(new Ingredient[9]) not work?
.
ill try that
not expandable
oh
interesting didnt know it was fixed size
i know from experience
Its like a proxy for array
i always wrap it in new ArrayList()
yeah
still doesnt work
OutOfBounds?
yeah
are you sure you're referencing the same list
yeah
yeah
ill send it
and the error
/**
* The list of ingredients (shaped).
*/
/* 27 */ protected List<Ingredient> ingredients = Lists.newArrayList(new
Ingredient[9]);
/* ... */
/* 70 */ public Craft ingredient(int i, Ingredient ingredient) {
ingredients.set(i, ingredient);
return this;
}
``` code
its a bit messy
added in line numbers
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
at java.util.ArrayList.set(ArrayList.java:441) ~[?:?]
at io.orbyfied.bucket.craft.Craft.ingredient(Craft.java:71) ~[?:?]
at test.BucketCoreTest.lambda$onEnable$1(BucketCoreTest.java:42) ~[?:?]
at io.orbyfied.bucket.craft.CraftRegistry.craft(CraftRegistry.java:48) ~[?:?]
at test.BucketCoreTest.onEnable(BucketCoreTest.java:39) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot.jar:3203-Spigot-18c71bf-aa69d1c]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot.jar:3203-Spigot-18c71bf-aa69d1c]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot.jar:3203-Spigot-18c71bf-aa69d1c]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:505) ~[spigot.jar:3203-Spigot-18c71bf-aa69d1c]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:419) ~[spigot.jar:3203-Spigot-18c71bf-aa69d1c]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:604) ~[spigot.jar:3203-Spigot-18c71bf-aa69d1c]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:266) ~[spigot.jar:3203-Spigot-18c71bf-aa69d1c]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:995) ~[spigot.jar:3203-Spigot-18c71bf-aa69d1c]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:303) ~[spigot.jar:3203-Spigot-18c71bf-aa69d1c]
at java.lang.Thread.run(Thread.java:831) [?:?]
error
wouldnt it be easier to use a Int2Object map here
hello! how do i register a placeholderapi class?
it's supposed to be like this but give an error
Or replace nulls with Some sort of Ingredient.EMPTY
yeah im a bit lost maybe List.newArrayList trims nulls?
what error
iirc no, it’s simply just invoking ArrayList::new
It yields a compile time error, is PointsExpansion in need of any dependencies?
bumping this again, is there any alternative to getTargetBlockExact in pre-flattening?
Write your own getTargetBlockExact
all of the 1.13 exact stuff is based to CraftWorld#rayTraceBlocks, would i have to do all of that myself?
Yes or find if Vanilla has an NMS implementation
pretty sure its only in 1.13 there also
brilliant
that's probably gonna land me in a bunch of nms bs isnt it
i would if i could
consequences of supporting old versions lol
i guess
is there no replacelast on a string?
Because the code ezexutes only if you have 2 args
^
ah that way
struggling with args length for a tabcomplete
lmao
about 20 lines now
(use command framework)
writing a crafting system is such a pain
matching sort of works
but when you craft it the ingredients multiply?
it is fast tho
How do I make particles spawn only at the players feet and not fly everywhere like this? https://i.badlion.net/69qCqLLTPr6MTvPtTLqUDT.png
Spawn short term particles constatly at player's feet
how do I make particles "short term"
theres a duration variable when you spawn them
how can i make this particle same to player direction? it always on Z direction
https://pastebin.com/UAeBTGds
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
code: https://pastebin.com/UJzXe7nj
debug output: https://pastebin.com/EPk1Adc7
Why does the keys in my map have the same values if I put in it not the same values?
uhm no
vectors ig?
if a player has permission to execute a command (example /chatchannel) but the subcommand (example moderate) also has a permission that that player doesnt have, is a tabcomplete for /chatchannel moderate triggered?
can any one help
i need the maven repository for luck perms i have the dependency for the pom.xml but not the repo]
ask them ^^
it has no repo
that is all it gives
well it looks like they use normal maven repo
i only have a dependency and it works
so how do i fix my dependency
reload ur local maven
i have ```yml
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.3</version>
<scope>provided</scope>
</dependency>
What’s even broken?
heh that can happen?
just reload ur local maven
how
Yes unless you do checks in your tab completer
(another reason to use command framework)
ah then more checks..
Maven > Reload All Maven Projects
At the right corner
Same values
thank you
np
Hey how can I set a specific line in an itemstacks lore
ItemStack item = ...;
ItemMeta meta = item.getItemMeta();
List<String> lore = meta.getLore();
lore.set(numberOfString, "text");
meta.setLore(lore);
item.setItemMeta(meta);
set not get lol
edited
hello guys
i needed a bit of help
when i give permission to deop players to open shop.all of shopgui they can open the shop but they are unable to open the shop sections please help me with this issue
wrong channel
#909049062215544862 - pls, help
String ownerName = Bukkit.getOfflinePlayer(owner).getName()
Why does this return me a uuid?
it willl return a name or null
it reutrns a uuid.
it can't
well it sure does though
String name = setX.getString("name");
String owner = setX.getString("owner");
final String[] bound = setX.getString("bound").replace("[", "").replace("]", "").replace(" ", "").replace("\"", "").split(",");
String locked = "false";
if(setX.getInt("locked") == 1) {
locked = "true";
}
final String lockedFinal = locked;
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskAsynchronously(myPlugin, task2 -> {
String ownerName = Bukkit.getOfflinePlayer(owner).getName();
String[] successful = getString("messages.info.successful").split("\n");
for(String s: successful) {
sender.sendMessage(s.replace("%owner%", ownerName).replace("%locked%", lockedFinal).replace("%name%", name).replace("%x%", String.valueOf(posX)).replace("%y%", String.valueOf(posY)).replace("%z%", String.valueOf(posZ)).replace("%world%", world));
}
if(getString("values.show-bound").equals("true")) {
for(String s: bound) {
String p = Bukkit.getOfflinePlayer(s).getName();
sender.sendMessage(getString("messages.info.bound").replace("%name%", p));
}
}
});
return true;
See for yourself
mysql data
info:
usage: "usage"
not-player: "not-player"
invalid-block: "invalid-block"
not-point: "not-point"
successful: "Owner: %owner%\nLocked: %locked%\nName: %name%\nPos: %x% %y% %z%\nWorld: %world%" # %owner%, %locked%, %name%, %x%, %y%, %z%, %world%
bound: "&6%name%"
values:
min-name-length: 3
max-name-length: 10
create-cost: 100
bind-cost: 20
lock-cost: 1000
transfer-cost: 500
icon-cost: 100
distance: 20
delay: 3
parse-names: "true"
show-bound: "true"
```Config
mc output
how do I stop the armorstand I spawned in from appearing for a split second before the armorStand.setVisible(false); kicks in?
spawn it somewhere else, set it invisible, then tp it
wtf is that method
seriously its impossible for an OfflinePlayer object to return a UUID a the name
Use the spawn method that takes a callback
but how do you explain this then
i read on the forms and they said use somethign like overloaded method with consumer and i dont get it
Hello, is there a way to increase the stack size of a specific material?
your code is quite messy and you are probable displaying some other data and confusing yourself as to what is being displayed
I triple checked already
it is correct
It litterally impossible for an OfflinePlayer to return a UUID as its name. For one its too long to even be accepted as a name
names are limited to 32 characters
16
I thought 16
16 even
-.-
You are displaying some field from your sql and not teh OfflinePlayer name
no I am not
ok
String ownerName = Bukkit.getOfflinePlayer(owner).getName()
yes, very good, but your sysouts are all over the place
I'm betting your are printing name and not ownerName or somethign like that
what you are describing is literally impossible.
I get the string that is the UUID from the MySQL
String owner = setX.getString("owner");
I turn it into the playername
String ownerName = Bukkit.getOfflinePlayer(owner).getName();
I print that ownerName
sender.sendMessage(s.replace("%owner%", ownerName));
you can not deny that this is corect
yes, you also do lockedFinal).replace("%name%", name)
name is the name of the warp point
no
well I'm not going to dig thorugh every bit of yoru code, but the answer to your question... No it is impossible for an OfflinePlayer#getName() to return a UUID string instead.
read what I sent above
.
those ar ethe only references done to it
read what I said. its impossible
can getOfflinePlayer be run async?
seems like it
Only the version that takes a string is blocking
is blocking?
can perform a Mojang lookup
then its doing a name lookup with a string not a UUID
kill m.e.
it works now
is it still recommended to perform the getOfflinePlayer with UUID's asynchronously?
not for a single player
getting an OfflinePlayer by UUID is going to cause less lag than displaying the details in a message
getting the actual player will not be the cause of a performance drop
kk
if you are processing hundreds at once then yes it could be laggy
NMS probably
What do you mean by increase the stack size?
teh current amount, the maximum amount?
I want to make minecarts stackable
Yeah you can do it with NMS
there is a plugin called StackableItems which does this
But it’s still buggy
it is very configurable and works really well for survival mode, not for creative
Well yeah for creative you'd need a mod
how
No never
For the record, bukkit’s forum is full of bs
Find where the server sets the stack size and change it
Change the max stack size of the Item using reflection iirc
Sure, im going to read the entire mc server code now
Why would you need to do that...
Then you look at the refrences
ItemStack, Item, nms Item or CraftItemStack or something else?
NMS Item
Ok, and how do I get a instance of that?
Items.X
Thanks 👍
is there any skript java guy?
im making a method, which includes fetching stuff from a skript(ed) skript
so how can i fetch stuff and send the variable to a player (for debugging)
well i have imported the skript thing
we don't use skript here in development, you need to reverse engineer things yourself.
just research the source code of the skript
and see what you need to hook into
it does have addon support
so it shouldn't be that hard to hook into
its not as if skript doesn't have any API for addon developers
yeah true
ew skript
no one asked for your opinion regarding skript
talking about it in this server is cursed
is there a better way than checking for console every time except for 'moderate'?
https://paste.md-5.net/lufomefinu.cs
forgot to remove it but yea
I have tried to change the final field but it doesnt work lol
The field just not changes
Anyone knows how I can fix that?
is there an event to detect when the player stops mining a block?
public class Test {
static class A {
private final int CONST = 20;
}
public static void main(String[] args) throws Exception {
A a = new A();
Field field = A.class.getDeclaredField("CONST");
field.setAccessible(true);
field.set(a, -20);
System.out.println(a.CONST);
}
}
```This prints out 20, makes no sense 🙄
seems, unlikely
java 16 removed modification of final fields
thats the reason why retrooper was fussing over packets not being able to made over reflection
cause there was the constructor and you have to use it cause the fields are final
The other way, of course, is to use Unsafe to modify it
I believe that would get inlined tho
bit shit
so even if u could modify it at runtime it wouldn't help
yeah its cause they are moving to "safety"
Whats inlined?
I changed my project compiler to java 8 but that doesnt change anything
is there any particular reason to why an enum's constructor can't access static objects of the enum?
class SourceVersion {
static final int l = 321;
static void print() {
Sytem.out.println(l);
}
}
class CompiledVersion {
static final int l = 321;
static void print() {
Sytem.out.println(321);
}
}``` @old cloud
idk if is during compile time or jit time
but regardless, the value is inlined
before any reflection thingy is able to do something about it
also is it bad to workaround it by making an inner static class?