#help-development
1 messages · Page 1381 of 1
lol, it works here
ill send what i did
Yeah I had a small feeling this wasn’t the issue
?paste
I tested with a single item and multiple in different slot
I imagine spigot has a way to keep created inventories referenced
What spigot version are you on
And is it up to date
1.16.5
Why does it have to be a Fireball?
idk, but i probably downloaded it at latest a month ago
can someone help me with detecting and cancelling number key shortcuts
downloaded
inventoryclickevent doesnt seem to detect it
So what are u suggesting i do?
You can also use other projectiles and disable their gravitiy. Then listen for the ProjectileHitEvent and create an explosion.
so it can be reflected
I see...
First try the exact code I just sent you. Ensure it works.
ok
And your problem is that the flying fireball is on fire, right?
yes
I added a login event so the inventory opens as soon as you join the server
I convinently forgot how tomake a new project
edfdsfdfefs
also i might've selected paper plugin in creation but idk
I'm using intelij btw
i do have a paper plugin tho
you can put that code in yrou current plugin
the class has events registered so just put it in exactly as I gave you
it's working for me if I switch but only in my own inventory. if I hotkey from my inventory into a chest or other container it's not firing
there is a seperate event for that...
what's the event?
looking
Um, I guess not. Old age moment. I could have swore there was a specific event when transferring between inventories
hmm
@lost matrix so are there any alternatives?
I'd test if it fires for a player too
Im thinking of one where you basically listen for left clicks, ray trace one block, check if the hit entity is your custom entity and then reverse its velocity,
it is actually firing inventoryclickevent but cancelling it does nothing
nope can do it in creative and survival
creative has its own events
also snowballs act weirdly underwater and cant be increased in size, which is what i need
Yeah I think the server puts more trust in creative players
Do you use maven?
I use gradle
@eternal oxide it's ur trigger, it works perfectly but it's basically the same WTF is wrong with mine?
i do forge modding as well so used to gradle
but maven and gradle are similar right?
I've never worked with crafting inventories. I'm guessing its a scope issue as my code has the GUI scope in teh same class.
ok, so should I put the command and the other thing in the same class?
Yes. You need to change the artifact id from spigot-api to just spigot.
And make sure the BuildTools ran once on your machine so spigot is installed
in your local maven repo
you could as its all related
ok
Could not find org.spigotmc
1.16.5-R0.1-SNAPSHOT
i ran buildtools, but still doesnt work
Can i get a chatcolor from a string that is like
&x&f&f&f&f&f&f
I need to get a chatcolor from a toStringed ChatColor basically
once I implemented it in the same class as the command, the first slot works, but only if it has to return one item stack 🤦♂️ @eternal oxide
for me it works with any number of slots occupied
it was because .getCurrentItem() returns null for some reason if you hotkey
@eternal oxide if it's not too much trouble, can u try urs with the command as the trigger, that seems to be the only difference
?paste
https://paste.md-5.net/igoberitam.java this is my current code @eternal oxide
sec
does it all in one class
ok
scratch that im dumb @lost matrix
@eternal oxide Pls ping me if responding, im gonna be on my phone but i'll still read ur response
Testign now, it works fine
k thx, imma go to bed
kk
Having an issue, I have a bungee chatcolor(HAS to be bungee for what im doing)
And I am using the team api to do team.setColor
which wants a bukkit one
how i do
Would it be a bad idea to, in the onEnable() method, store getProxy() in a static variable so I can access it from a static context? I need someway to convert online player's usernames to UUIDs. I don't want to use the mojang api because its rate limited.
You pass your plugin instance via dependency injection
how to check if the block breaked in the BlockBreak event has been breaked by a player or a villager
Do you mean a fake player/NPC as villagers don't fire the blockbreak event. I don't believe they can break blocks
the event name tells you all you need to know
is villager considered by players
no
you may find villagers in https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityChangeBlockEvent.html
Will CompletableFuture resolve CME?
I have a method to create a data each player and save them to the SQL and then cache the data into a Map with async task but It's giving me CME.
Use a concurrent map or a syncronized one
you can;t modify from two threads without synchronizing
Can I save the data into sql with async and then cache them sync?
cache them sync?
I mean quite frankly you should probably use a concurrent data structure and just cache it on the same thread
use a Future to save/load to the SQL. then run sync to put it in your cache
CompletableFuture.runAsync(save/load).thenAccept(put in cache);
not quite, as the thenAccept is still Async
Wrap the callback with the BukkitScheduler like
.thenAccept(o -> {
Bukkit.getScheduler().runTask(plugin, () -> {
this.cache.put(...);
});
});
yep
pey (:
oh okay, i thought thenAccept is sync because there is thenAcceptAsync too.
its on the thread that completes the Future
ah okay
Well it’s sync with respect to execution of the supplier/runnable that is declared ahead of the callback you declare.
when you do YamlConfiguration#get() which returns an object I should be able to check the instance of that object right, when I use config.get("somename") on for example
somename: 30.0
will this object be an instance of a string or a double or something else
it will return an generic Object. use the correct getter for your type.
no i get that but im trying to generate abstract objects with configurable options for each and some of those options are string or doubles or lists
was wondering if i could just cast the generic object to the option type it needs instead of making a whole bunch of type specific abstractions
Is there a reason you are not using ConfigurationSerializable?
its not what im looking for
It has stuff like getString getInt getList alr?
But yes you should although it may be the case a boxed primitive is returned
That’s probably guaranteed
hey can someone take a look at smth for a plugin I'm developing and tell me if it seems like the best way to implement it
Sure
Alright 1 sec
this was all i needed so it'll be fine
Interesting
Yes you can instanceOf, but properly serializing your objects means you don;t need to worry about the primitives.
Ftr it’s pointless to reinvent the wheeel
it wont be an issue anyway with how its implemented
pls help
I need to add to my jar file which I have on my computer
not to the global repository
Instructions are on there about how to make your own patches
okay
So I have a save method and it will get a new connection, and it the method will run another method that will get a new connection, should I pass the connection on the parameter instead?
Do you use hikari ?
Ah well it may still be of your interest to have a look at hikari connection pool then
just have a getConnection(). In that method you check if the connection is good, if not create a new one.
alright, i'll look into that.
I'm not sure by what you mean, here's the method list https://paste.md-5.net/urekeqayuy.cs.
Elgar means you should have one connection at the time
And maybe change to something like this
public void insert(Connection connection, String uuid, String value){}
public void update(Connection connection, String uuid, String value){}
Then check if it’s a good one, if it is keep it else may wanna close and get a new one
Aglerr if all of those methods are in the same class then maybe it worth putting the connection into a field and use that field instead of passing it through method parameters
With yoru code you are not dealign with the connection or anything if it errors
It's on different class.
Now I'm confused xd
Then maybe inject the databasemanager instead passing the single connection ?
I'm currently moving everything to a manager class and let's see how it turns out.
Thanks for the help.
Hello im wondering if there is somebody that could help me make an Aspect of the End i have read online and i didnt find anything helpfull
someone plaese
Will anytime soon forge andspigot be as one ?
Hey, quick question about gui. How would you make it so the player can move items from their inventory, to only certain slots of the gui? (The slots where there are no items in it)
Nope, the Bukkit API was not made to consider Mods
look into Sponge if you want a Plugin API that works with mods
Hello im wondering if there is somebody that could help me make an Aspect of the End i have read online and i didnt find anything helpfull
someone plaese
Check the slot, if the slot is not the defined slot, cancel the event.
you could use
Thermos (1.7.10)
Magma / Mohist (1.12.2)
Arclight (1.16.x)
wait how would I get the slot number?
Magma is hell of a lag maker
Player player = event.getPlayer();
player.sendMessage("1");
if (event.getAction() != Action.RIGHT_CLICK_AIR || event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
player.sendMessage("2");
if (event.getItem() != null && !event.getItem().getItemMeta().getDisplayName().equals(CC.GREEN + "Server Selector")) return;
player.sendMessage("3");
openSelector(player);
why is this not working? It prints one but not two or three.
i have normal server working with 100ppl
The second check is most likely always true @crude charm
no no not modded
what can I do to change that, intelliJ isn't flagging it
then why are you comparing magma to a vanilla server with 100 players?
Instead of ||
ok
Actually the first check
tnx for help
Sry my bad not the second one
public static void sendTitle (Player player, String title, String subtitle, int fadein, int stay, int fadeout) {
IChatBaseComponent chatTitle = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', title) + "\"}");
IChatBaseComponent chatSubtitle = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\"}");
PacketPlayOutTitle t = new PacketPlayOutTitle (PacketPlayOutTitle.EnumTitleAction.TITLE, chatTitle);
PacketPlayOutTitle s = new PacketPlayOutTitle (PacketPlayOutTitle.EnumTitleAction.SUBTITLE, chatSubtitle);
PacketPlayOutTitle length = new PacketPlayOutTitle (fadein * 20, stay * 20, fadeout * 20);
((CraftPlayer) player).getHandle().playerConnection.sendPacket (t);
((CraftPlayer) player).getHandle().playerConnection.sendPacket (s);
((CraftPlayer) player).getHandle().playerConnection.sendPacket (length);
}```
is that wrong?? it doesnt seem to be working but I dont understand why
?paste
VERSION
I need to be able to control fade in and out
why
Its a necessity I have for this plugin
How do i give a player speed?
okey
You can use InventoryClickEvent for that and get the slot by event.getSlot().
yup, use a switch and default so u dont get an error
How do I make a GUI with multiple options for a Punish/Admin GUI? E.g Press on green wool > How long > Silent Punishment etc.
I have tried it before and I am really confused so I scrapped the idea.
Hey, I tried that, but it didn't work. When I try to add items from my own inventory to the gui, it doesn't let me. How can I fix this?
You need to check If the clicked inventory is the top inventory first.
If the clicked inventory is the top inventory, then proceeds.
https://paste.md-5.net/suzocozori.java Heres my code. I think I am checking which inv it is...
You're just checking the title.
how do i wait 5 seconds in java?
if (title.equals((gui.inv_name))) {
if(event.getClickedInventory() == event.getView().getTopInventory()){
``` Try this maybe.
k thx
Or
if(event.getClickedInventory().getType() != InventoryType.PLAYER){
Can I have some help, please?
thx a lot 🙂
@cunning cloak you can just open new menus/redraw your current menu with different items and stuff
no problem 🙂
How would I do that?
Set an item to green wool and use your method of checking for a click, then the click method will be to open a different gui or just change the items of one gui if you dont want your mouse resetting, and then treat the second opened gui as a standalone thing where you can click anything you want
treat them like folders on a desktop, you can open a folder then it shows you a whole list of new folders to open
Why is this line not working?
player.setWalkSpeed(player.getWalkSpeed() + 0.2)
Okay thanks I'll use that idea :)
I recommend redrawing the menu, some people open new menus and it's very annoying as the cursor resets
Can you explain what 'redrawing' means please
Basically just keeping your current gui instance and changing all the items in it to make it look like a completely new gui
your cursor just resets, if you close the last inventory
yeah which is why i recommend redrawing
close current -> open new -> cursor reset
don't close current -> open new -> cursor don't reset
most of the time you'll have to close the instance if you have clickables because it'll probably bug tho
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
how do i save the data from a hash map to a config file called playerdata.yml
org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.xrokz.orgins.Main'
```why ?
```yml
name: Inferno
version: 1.4.1
description: This plugin is so 31337. You can set yourself on fire.
author: CaptainInflamo
authors: [Cogito, verrier, EvilSeph]
website: http://forums.bukkit.org/threads/MyPlugin.31337/
main: com.xrokz.orgins.Main```
for example: PSEUDOCODE
var File file
var Config config//your config
var HashMap<UUID, Integer> hashmap //your hashmap
// your method
public void saveToConfig() {
//do your stuff
file = new File("dir", "playerdata.yml");
config = YamlConfiguration.loadConfiguration(file);
for(UUID uuid : hashmap.keySet()) {
config.set(uuid.toString(), hashmap.get(uuid));
}
config.save(file);
}
what does the main class look like
does it extend java plugin
plugin yml is in wrong place
it is in src
no
needs to be in resorces
if you are using maven then yes
i tried to move it it says name conflict
show us your structure
it needs to be in the src
it is in src.com.xrokz.orgins
just drag it onto the src package
wait, click on the arrow to the left of com.xrokz.orgins
did your main class extend javaplugin?
⬆️
ok, thats good
yes
public class Main extends JavaPlugin {
private static HashMap <UUID, OrginsManager> players = new HashMap();
@Override
public void onDisable() {
// Don't log disabling, Spigot does that for you automatically!
}
@Override
public void onEnable() {
// Don't log enabling, Spigot does that for you automatically!
// Commands enabled with following method must have entries in plugin.yml
getCommand("mymana").setExecutor(new GetManaCommand(this));
}
}```
thats how its been i didn't move a thing
sorry 😄
just unzip it and take a look 😛
how are you compiling?
and there’s your problem 🙂
in eclipse > export > JAR file
I don’t use eclipse, but on that page there should be an option to select what to add to the jar
your actual java files are in selected
^^
un*
in intellij its like http://prntscr.com/11kr50f
yuhuh
im ngl, idk how to use eclipse
never used it since years
never used it full stop
https://prnt.sc/11kqyod If I now right-click on a stone, how can I loop blocks in the radius from there and only get the first layer of stones without not touching the stones behind.
send the full window
is ther anyone that can help
i mean, you can just get all the blocks nearby and check that one of the faces is touching air
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
could be of importance
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
just check them all and see what works
yeah, i didn't know if it means the uncopiled files tho
Yes, that's right, but it can also be that there can be air behind the stones
already sent this example @humble heath
I need something like Sphere, like painting blocks with a tool
i dont understand that i hjave sent my 3 classes
its literally the solution
i mean, idk if there is anything you can do about this. You could just do it in two halves. So, for example, in 1, if the south side of a block is air then it is gonna be inside, and in two it is the north side
so... does it work?
welp. dunno what to tell you I don't use eclipse, so you're gonna have to google it
what is it
Hello, is it safe to leave the connection to an SQLite database opened the whole time when the plugin is running ? Because i'm currently connecting / disconnecting everytime I need to access it, but it takes a bit of time to connect
umm, maybe just open and write to it every minute or so. have like a buffer that you clear
[15:13:23 ERROR]: Could not load 'plugins\orgins.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: com/xrokz/orgins/Main has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:141) ~[patched_1.16.5.jar:git-Paper-595]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:397) ~[patched_1.16.5.jar:git-Paper-595]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:305) ~[patched_1.16.5.jar:git-Paper-595]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.5.jar:git-Paper-595]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:251) ~[patched_1.16.5.jar:git-Paper-595]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1065) ~[patched_1.16.5.jar:git-Paper-595] at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-595]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_281]
Caused by: java.lang.UnsupportedClassVersionError: com/xrokz/orgins/Main has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_281]
update your java or get an older jdk
your JRE is 8 but you compiled it with 15
im using java 1.8 64-bit
not for compiling
1.8 = 8
you can probably change it somewhere in eclipse
in theory it is fine, however not a great idea
i have found it can be a pain changing jdk
PSEUDOCODE
JavaSE - 1.8 ?
So like when I open it, I leave it opens for a minute or so, or do I periodically connects / disconnects (with a bukkitRunnable i think)
?
Oh no ok sorry I didn't understood
Yeah, like every minute or two open it (a bukkitRunnable would work) and purge the buffer to the file
you would typically use something like hikaricp to manage this for you
I would look into it if I were you
im not familar with databases, however that is how i would do it 😄
Ok I will check it now 😄
keeps the data saved in case of a crash, as well as not calling the db too much
Thanks for your help 😉
can someone help me plz
nope
[15:19:13 INFO]: [Inferno] Enabling Inferno v1.4.1*
[15:19:13 ERROR]: Error occurred while enabling Inferno v1.4.1 (Is it up to date?)
java.lang.NullPointerException: null
at com.xrokz.orgins.Main.onEnable(Main.java:31) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-595]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.5.jar:git-Paper-595]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.5.jar:git-Paper-595]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:501) ~[patched_1.16.5.jar:git-Paper-595]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:415) ~[patched_1.16.5.jar:git-Paper-595]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:591) ~[patched_1.16.5.jar:git-Paper-595]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:280) ~[patched_1.16.5.jar:git-Paper-595]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1065) ~[patched_1.16.5.jar:git-Paper-595]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-595]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_281]
[15:19:13 INFO]: [Inferno] Disabling Inferno v1.4.1```
In computer science, pseudocode is a plain language description of the steps in an algorithm or another system. Pseudocode often uses structural conventions of a normal programming language, but is intended for human reading rather than machine reading. It typically omits details that are essential for machine understanding of the algorithm, suc...
com.xrokz.orgins.Main.onEnable(Main.java:31) tells you where the issue is
so you will need to send that class and line 31
getCommand("mymana").setExecutor(new GetManaCommand(this));```
package com.xrokz.orgins;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class GetManaCommand implements CommandExecutor {
// private static OrginsManager playerData;
public GetManaCommand(Main main) {
// , OrginsManager cplayerData
// this.playerData = cplayerData;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String arg2, String[] arg3) {
if(!(sender instanceof Player)) return false;
String cmdName = cmd.getName().toLowerCase();
if (!cmdName.equals("mymana")) {
return false;
}
return true;
}
}
getCommand("mymana") has returned null, which only occurs when you don't specify you command in plugin.yml
is there some function that does something like gui.getitemslot(Item_slot_number).getBlockType?
inventory items are ItemStacks not blocks, but both have a Material
Your map key is a string
private void register(Command command)
{
Bukkit.getServer().getPluginCommand(command.getName()).setExecutor((sender, cmd, label, args) ->
{
command.onBukkitCommand(sender, command.getName(), args);
return true;
});
Bukkit.getServer().getPluginCommand(command.getName()).setTabCompleter((sender, cmd, label, args) -> command.onTabComplete(sender, command.getName()));
}
The registering works, but if I type the command I will get /command in the chat. Command: https://paste.md-5.net/upivamuvub.java
You hashmap is null
And indeed you save a string not an UUID. Use UUID.fromString()
How can I make a prefix over the player's head taken from the group like the TAB plugin does (I mean more like making it in the player's nametag)
hm i think that works thanks
java.lang.NullPointerException: null
at com.xrokz.orgins.Main.onItemUse(Main.java:69) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor66.execute(Unknown Source) ~[?:?]```
im getting this
line nice int playerMana = players.get(p.getUniqueId()).getPlayerMana();
@EventHandler
public void onItemUse(EntityShootBowEvent e) {
Entity p = e.getEntity();
ItemStack bow = e.getBow();
String bowName = bow.getItemMeta().getDisplayName();
if(bowName.equals("Thunder Bow")) {
if(!(p instanceof Player)) e.setCancelled(true);
p.sendMessage("Item: Thunder Bow!");
int playerMana = players.get(p.getUniqueId()).getPlayerMana();
p.sendMessage(bowName);
Entity thunderArrow = e.getProjectile();
thunderArrow.setCustomName("Thunder Arrow");
p.sendMessage(thunderArrow.getName());
p.sendMessage(thunderArrow.getCustomName());
if(playerMana < ThunderBowMana) {
p.sendMessage("Not Enough Mana");
e.setCancelled(true);
}
} else {
p.sendMessage(bowName);
}
}```
Likely hasn't been done before, but does anyone know any gradle plugins that allow for removal of methods (ideally based on an annotation)?
You mean like compile time removal?
Yeah, though it should still be available for linking. Basically I want to link to superclass members that are not there at compile time, but may be there at runtime (without having to resort to reflections since I'm using hot code)
getBow()could return null which could also cause problems in the future- Two things could be null here. Either the
playersfield or the returned UUID could be null. (Happens if its not in the Map)
This makes no sense to me. You can not compile if you need to inherit from a class. You would need some very nasty bytecode injection for that.
I guess so
Btw ThunderBowMana -> thunderBowMana or if constant THUNDER_BOW_MANA
How can I make my plugin support all versions?
Import Bukkit multiple times or just hope that bukkit will do that for you
Bukkit usually does an adequate job in that
What about Spigot?
Use an old API and use only methods which are forwards compatible.
So basically writing for 1.8 makes the plugin work for all versions if you dont use any NMS.
But i would not go through the pain of writing a plugin for 1.8...
Can a spigot?
Spigot = Bukkit for anything that is newer than 6 years
ok
is there a way of commenting out a chunk of code other than using // each line?
/*
Multi
Line
Comment
*/
cheers
is there a way to delete the drops when an entity dies? my current code
for(World w : Bukkit.getWorlds()){
for(Entity e : w.getEntities()){
if(e instanceof Pig){
((Pig) e ).damage(1000);
}
}
}```
im trying to delete the drops from an ender dragon
ah i was looking at https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/EntityDeathEvent.html
declaration: package: org.bukkit.event.entity, class: EntityDeathEvent
thx
Hello everyone !
Would it be possible to have some help please?
I would like to make a tool (like in WildTools) with a durability system visible in the lore of the item.
Something like that :
This item allows you to do something!
Durability: XX
I just have one big issue for me: How do I get the remaining durability of the item?
And how could I modify it?
This question seems easy, but I would like it to be done by being fully configurable in the config ...
But I have no idea which method to have ...
Thank you !
Do you mean the durability which is displayed below the ItemStack or a custom one in the lore.
Either way i would go with the PersistentDataContainer of the ItemStack and store the values there.
how come my code isnt working? ```if (cmd.getName().equalsIgnoreCase("hastytimer")) {
for (Player player : Bukkit.getOnlinePlayers())
if (player.hasPermission("hastytimer.work"))
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 1200, 1));
Plugin plugin = null;
Bukkit.getScheduler().runTaskLater(plugin, () -> {
// code
}, 20L);
}
}
}
- This is useless unless you have that CommandExecutor registered for multiple commands:
if (cmd.getName().equalsIgnoreCase("hastytimer")) - Define "isnt working" (Any errors? What happens?)
I mean a custom durability in the lore of the item
I don't know what's PersistantDataContainer, gonna look at this
i dont get it, to me java is so much different than spigot programming, what am i doing wrong?
- Define "isnt working" (Any errors? What happens? What doesnt?)
it has one error
java: reached end of file while parsing```
i know alot of java programming but spigot doesnt make sense to me. how can i learn spigot programming?🤔
By doing it also trial and error like most stuff
Spigot is just java. There are some higher concepts but if you know "alot of java programming" then you will get there by just trying a bit.
There are 3 fundamentals that are a bit different from spigot programming then usual java programming.
-
Your entry point is not defined by a main method. Your entry is either the onLoad() or the onEnable() method inside of your JavaPlugin class.
The JavaPlugin class has one instance that is bootstrapped by the spigot classloader. Meaning you never create an instance yourself but use the one accessible in the onLoad() or onEnable() -
Event based programming. Its a bit hard to grasp how the event handling works if you dont know reflections and the actual purpose of the EventHandler annotations.
All you can do is read up on how to use the event api and learn as you go. -
You only program against an API and dont really have any classes but only abstraction to program against.
There is also a lot happening in the background regarding the plugin.yml
Commands are actually one of the things which are quite easy to understand if you know java quite well.
Now to your problem: Your java file is malformed. Meaning you are probably missing some brackets. This can be avoided by writing cleaner code.
i can get the location of my click in the event of clicking on a block, not being the player's location but where the aim is
Define "where the aim is"
You can get the clicked BlockFace quite easily.
The direction (vector) if the click is basically the direction of the players eye location.
If you want an exact intersection then you might need to ray trace.
can i make custom enchants ?
Yes
how ?
Currently bans and mutes are stored like this. what would be the best option to check if the current date is > EndDate. i was thinking to get all values from EndDate loop them put em on an array or are there better ways to do this ?
You extend the Enchantment class and register it using the same class. You would need to set a boolean in the class via reflections before. There are def tutorials out there.
Im assuming that you query the database when a player connects anyways. So i would just wait for a connection, get the data and check if the ban is still active.
If not then remove it from the database and let the player connect.
That's a great idea thanks
is using url shortners allowed?
mainly stuff like adfocus
Regarding what exactly?
for posting resources
https://developer.spotify.com|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| https://kurwa.club/u/h9d8F.png
No. It has to be a direct link to the resource.
Supposedly,
yes
for(World w : Bukkit.getWorlds()){
for(Entity e : w.getEntities()){
if(e instanceof EnderDragon){
Bukkit.getLogger().info("test");
((EnderDragon) e ).damage(100000000);
}
Bukkit.getLogger().info(String.valueOf(w));
Bukkit.getLogger().info(String.valueOf(e));
}
}```
why does this work for pigs but no ender dragons?
?jd
package index
am i missing something?
the dragon has like 6 entities or smtng iirc
How do I check if a consumed item is a carrot? This is what I have so far
if (playerItemConsumeEvent.getItem() == )
I'm not sure what to compare it to, as I can't compare it to Material.CARROT because they're different types, but ItemStack doesn't seem to allow something like ItemStack.CARROT
So I'm pretty sure it needs to be compared to an ItemStack but not sure how to write it
getItem() returns the consumed ItemStack. You can get the Material of it using the method ItemStack#getType()
This returns a Material enum constant which can then be compared using ==
For example with Material.CARROT
guys, World.getFullTime() returns a long, is that in ticks or something? jdoc is unclear
i need to compare current world time with an older time
The relative time is in ticks. So a full day is 24 * 1000 ticks
The absolute time is the time since creation. Also in ticks.
thanks! very appreciated
how can i change item damage ?
i want diamond sword to deal 17 damage instead of 7 without enchants or strength
Change the attribute modifiers of the ItemStack
how
The ItemMeta contains the attribute modifiers that can be changed and/or replaced.
item.addAttributeModifier() ?
item.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, AttributeModifier.???);```
what is the best way to support multiple storage methods such as yml, Mysql, SqlLite ,MongoDB ect
Write the persistence layer against an interface. Then implement that interface for different backends.
Use a different implementation depending on the users settings.
ok
what did you click
Project Structure > Artifacts > Output location > Desktop
Did you built artifacts ?
yea
no thats where you tried to save it
?
sorry slow responses, my dogs mashing her face against my keyboard -_-
are you using maven or no maven/gradle
ok i might sound dumb for this. i dont know what maven is
Nice
:sobs_in_project_management:
Did you put the "compile output" into the jar (on the left)
Cough cough use Gradle
String[] newArgs = new String[args.length];
if(args.length > 1)
System.arraycopy(args, 1, newArgs, 0, args.length - 1);
The problem: I try to copy my arguments to a new list, and want to drop the first argument (args[1] old will be args[0] new), this works, but my list will get an extra null value at the end ([arg, null])
id recommend converting your project to maven cause it saves your sanity, but you should be able to do it by clicking Ctrl + F9
Gradle ^^
maven ^^^
Import everything by yourself ^^^^
Have you considered using ArrayUtils?
No
Ok I can try
didnt work
Then it returns a new array
what is maven?
You’ll need Apache commons, (spigot provides it its shaded)
are you sure the extra null is because your array is 1 bigger than the args its supposed to fit?
Project manager
its a build management tool
how do i use/get it?
Create a pom.xml
Uh
In your project root
if youre using intellij you can rebase the project onto it in its file structure
I just fixed, had to do new String[args.length *-1*]
What packet/packets the server send to a player when the player is being damaged by another player?
why dont you use the EntityDamageByEntityEvent?
I was going to say that haha
quick question: Am I allowed to do this:
recipe.setIngredient('%', Material.SUGAR);
recipe.setIngredient('B', Material.GLASS_BOTTLE);
recipe.shape("B%B","%B%","B%B");
i want to simulate an hit from a fake entity
ah, let me try and find it
i don't want to know which packet the client send, but the server
i think Entity Animation and Update Health
yeah but how to see what player was hit though is what I cant find
there's client events for it, but o_o
I'm trying to get into making Spigot plugins but for some reason it doesn't register the plugin, I've followed the example on how to set one up
plugin.yml put into resources
name: TestPlugin
version: 1.0
main: frogge.the.dude.testplugin
author: Frogge```
main in frogge.the.dude:
package frogge.the.dude;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class testplugin extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("onEnable is called!");
}
@Override
public void onDisable() {
getLogger().info("onDisable is called!");
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
if (label.equalsIgnoreCase("bruh")){
Player player = (Player) sender;
player.sendMessage("Ligma balls");
}
return false;
}
}```
also i can't send PacketType.Play.Server.ANIMATION with ProtocolLib because it doesn't find the byte
lol
how would I convert an ItemStack into a Material?
ItemStack .getMaterial() ?
im trying to change item attack damage
item.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, AttributeModifier.???);
but idk how to use the AttributeModifier
I think the plugin is registered
but your plugin class doesn't implement command executor
and you're also not getting the command and then setting it to your plugin instance, additionally your command is not registered in your plugin.yml
How can I show a fake player in the tablist? I have never done anything with modifying packets before so I don't have a clue what I'm doing. I don't mind using something like ProtocolLib. I've had a look around online but the stuff I found doesn't work (probably because I am not importing the NMS stuff which I don't understand) and I couldn't find anything about how to do it with ProtocolLib. Can someone give me an idea on how to do it (and explain what I need to import etc)?
player.getWorld().playEffect(loc, Effect.POTION_BREAK, new Potion(PotionType.POISON));
``` how do I play the actual green poison potion break effect as if you were to throw a splash potion? The code above results in black particles instead of green.
i tried this
item.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier("generic.attackDamage", 10, Operation.ADD_NUMBER));
and it didn't work
I have no clue how to send that packet but I'll work it out
my only knowledge of how to do it involves minecrafts packets, cant find the way you do it with protocollib
id be able to find out if spigot developers helped people out on the forums, instead of incessantly arguing over bumping
@fading lake Adding a user to the tab list requires the PacketPlayOutPlayerInfo packet with the ADD_PLAYER action to be sent.
Refer to:
https://wiki.vg/Protocol#Player_Info
oh wait fuck im getting things mixed up, ignore me @quaint mantle lmfao
Okay, but how would I send that? Would I use ProtocolLib?
How do i get the max data stored in Items? in the screenshot it would be two.
you mean the amount of items in Items?
for that'd be config.getConfSection("Items").getKeys(false).size()
Protocollib could be used to construct such a packet independent from the spigot version.
Ill give you a short example of how to construct such a packet.
something like that
Thanks
YamlConfiguration/FileConfiguration#getConfigurationSection("section").getKeys(false).size(); yeah
You just go through all fields from top to bottom of the packet and then try to fill each field with the right data.
Note: In some cases the actual packet doesnt quite match with the one represented in the protocol.
In this case (normally discovered through "not such field" exceptions) you would need to look at the actuall structure of the packet in the nms source code.
its sayig that required is particle and provided is void
And once I have built the packet, how would I send it?
public static void sendPacket(final Player player, final PacketContainer container) {
final ProtocolManager manager = ProtocolLibrary.getProtocolManager();
try {
manager.sendServerPacket(player, container);
} catch (final InvocationTargetException e) {
e.printStackTrace();
}
}
But thats all covered on the ProtocolLib site.
Thanks
Particles are not actual objects on the server. Particle is just an enum type. If you spawn a particle then only a particle packet is sent to the client. The server doesnt have any Particle object that is actually spawned there.
So the method just returns void
oh then how do I fix it? since I want to remove it after a few seconds
You cant. Particles are client side and have a fixed life span.
I can't remove them?
I dont think so. Particles dont have any identity. They are just an effect that the client can display on a certain location.
oh ok
another question
I have period set asan int in the pharentesies, and I want to remove 1 from it, how would I do that? I tried int p = period, and then removing it like that, did not work
More context pls...
Looking at the page for player info, the last field (Player) is pretty complicated. How would I put all of that data into the PacketContainer? This is the bit I am confused at: https://simplecomputing.ddns.net/data/🤣🛸🤱🌓🧧.png
Protocollib might have a WrappedPlayerInfo or something similiar for this...
But that looks like some work
Also, what is the action field? I see it is an integer, but what does the integer represent?
0: add player
1: update gamemode
and so on...
Ahhhh that makes sense.
Then you need a scope where you can hold a mutable integer.
I still need more context.
ok so
you can set period to any amount, every second it will deduct 1 from the initial value, if the value is 0, code will run
Can anyone tell me how I make a tablist that looks like the one from hypixel skyblock?
theres no more context I can give
Could you send the code so i can copy and modify it.
public void sendBloodEffect(String world, Location location, int amount, int period, long delay) {
new BukkitRunnable() {
@Override
public void run() {
System.out.println(p);
if (p > 0) {
new BukkitRunnable() {
@Override
public void run() {
Particle.DustOptions dustOptions = new Particle.DustOptions(Color.RED, 1);
Bukkit.getWorld(world).spawnParticle(Particle.REDSTONE, location.getBlockX(), location.getBlockY(), location.getBlockZ(), amount, dustOptions);
}
}.runTaskLater(plugin, delay);
} else {
cancel();
}
}
}.runTaskTimer(plugin, 0L, 20L);
}``` - here ya go
Using the header/footer methods for Player and probably some packets for the different slots. Could you send a screenshot of the tablist?
I have no perms... dm?
Why public static void?
public void
Not static
Is there a way to retrieve the event when a player smith an item? like CraftedItemEvent?
I dont know
public void sendBloodEffect(final Location location, final int amount, final int duration) {
new BukkitRunnable() {
private int currentCount = duration;
@Override
public void run() {
System.out.println(this.currentCount);
if (this.currentCount-- > 0) {
final Particle.DustOptions dustOptions = new Particle.DustOptions(Color.RED, 1);
location.getWorld().spawnParticle(Particle.REDSTONE, location, amount, dustOptions);
} else {
this.cancel();
}
}
}.runTaskTimer(plugin, 0L, 20L);
}
But this will send the blood particles on the same location every second. Regardless of the entities position.
Do you want to have a particle task that follows the Entity?
Guys i wanna authenticate mc server join session myself any idea where to get access token when loginevent?
You need to be a bit more specific. Do you want to authenticate a user with the mojang server?
Use ProtocolLib to send the encryption handshake and verify if the response from player is valid with mojang api?
Im actually not sure if there is a reliable way for this. Do you need it because your server runs in offline mode?
Yes its offline mode
Its not my server im their dev
We are making our own auth system
I just want the key used to verify login
Oh so you dont need any information from mojang then?
No, another dev made a launcher and the launcher should give token like mojang but instead of mojang one our own and we want to verify it ourselfes
From server side
for some reason that sounds like breaking tos to me idk why
Then you should either use the plugin messaging channel to communicate on a custom channel or...
You can have fun with this:
https://wiki.vg/Protocol#Login
Ye how to get the verify key on loginevent? Thats all i want
In the login event the handshake and authentication is long over. You need to do that way earlier.
I would probably go for Bungeecord here. Im not sure if there is an event earlier than the
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/AsyncPlayerPreLoginEvent.html
Yeah
But could you explain a bit more what exact token is sent and what you are actually trying to achieve?
and you are here asking for help
also im rather unsure about creating ur own mojang like authethication server
might get you blacklisted by mojang
Does anyone know where Bukkit OBC or NMS stores Inventory container UID at which gets sent to the client via packet?(edited)
can't find it anywhere
I really dont care
One moment i had the same problem a while ago
Oh i didnt mention that we are also editing the client?
I just wrote something like this
well do anything malicious or sketchy and you will get more than mojang on ur head
just so you know,you cant do w/e you want with something
that's a big ass spider on its period
We are making our server secure and at the same time cracked
Also we are making android launcher not pc launcher
private static final BlockData RED_STONE_DATA = Bukkit.createBlockData(Material.REDSTONE_BLOCK);
public void sendBloodEffect(final UUID entityID, final int seconds) {
new BukkitRunnable() {
private int currentCount = seconds * 10;
@Override
public void run() {
if (this.currentCount-- > 0) {
final Entity entity = Bukkit.getEntity(entityID);
if (entity == null) {
this.cancel();
return;
}
final World world = entity.getWorld();
final Location particleLocation = entity.getLocation().add(0, 0.5, 0);
final int amount = 2;
final double offset = 0.25;
world.spawnParticle(Particle.BLOCK_DUST, particleLocation, amount, offset, offset, offset, SpigotCore.RED_STONE_DATA);
} else {
this.cancel();
}
}
}.runTaskTimer(this, 0L, 2L);
}
I personally would do it different but this works.
nice bleed effect
Use Bungeecord or fork spigot. You need to dig very deep for this.
Bungeecord
doesnt mcmmo have something similar?
ftw
Ok np thx
even if its not network
based
i will still use bungeecord based proxy for security
both for packet attacks and ddos attacks against the main server supplying it with other outside protections
Ok ty
i would store the bukkitrunnable inside the static field
that way i wouldn't need to create runnable everytime
or implement it
or just create one task
and then provide it runnables and such
or custom ones with a long ticks
to control the tick count
Btw look into the net.minecraft.server.v1_16_R3.Containers class
There you can follow the breadcrumbs for net.minecraft.server.v1_16_R3.Container which contains the windowId field.
either slap the jar as dependency or add it to maven
Maven, Gradle, Import jar by using IDE build system, Classpath's
please
choice is yours
well for start say waht you code in
what IDE are you using
so you are not a dev
true
but i need a api in it so i can get in on my scoreboard in minecraft
true
is that a problem ?
well to connect a api someome has to code it
if the plugin doesnt alrdy have that feature you need someone to code it in
either plugin store page or if its mentioned somewhere
if not you cant rly look into a file to figure out
if it has it then simply having the api in the plugin folder should do the trick
example scoreboard to use placeholderapi..
nothing more than having both in the plugins oflder
not it in so the owner lies
idk if you wanne do it
but would you code it in it for me ?
please
wc
wc ?
wrong chat
java.lang.IllegalArgumentException: Name cannot be null
at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.Material.matchMaterial(Material.java:656) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at me.kian.Factions.Items.CustomItems.spawnCustomItems(CustomItems.java:36) ~[?:?]
I keep getting this error and i have no clue what to do. I know it says Name cannot be null and it shouldn't be. any help would be great!
Declaration:
String dName = (String) plugin.getConfig().get("Items." + i + ".customName");
ChatColor cColorN = (ChatColor) plugin.getConfig().get("Items." + i + ".chatColorN");
line 36: meta.setDisplayName(cColorN + dName);
mariomax can you help me ?
no
please
i dont even know how to code
and stop begging people
and if you are gonna beg atleast pay the dude
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
gave up on taking requestes for a long time
Apparently Spigot only recognises java class files up to 52.0 but mine are compiled in 58.0, how can I downgrade to 52.0
It depends on what java version the server uses. You can just start the server with java 15 or 16. Then it should work
How can I start with 16
@viscid dune google how to add a maven/grade dependency to your project
Sorry I can’t code so
That doesn’t make much sense fir me
Does it takes long time to do ?
?
Si what do I paste and where ?
@viscid dune google how to add a dependency it’ll explain everything
You'll have to add some debug messages to check what's null. If you want more help send the whole class in a paste
what ide are you using
Idk where do I find
what actually is your goal
yeah i know but i don’t understand his goal he said he can’t code so why would he need to do that
@lost matrix i found a protected method that changes whether its on fire or not
in entityfireball
how can i change that?
Reflection would be one option
who are you responding to?
@viscid dune why do you need to add a dependency
So I can type %tokens% on my scoreboard
if to me, i tried to but not sure how to
you need placeholderapi?
Yes
Yea that was to you. Could you show us what you tried?
Yes but what is the api the
How do I make my plugin "encrypted" which means if someone opens up my code it doesn't expose the raw code there? This is needed due to a license checker, API Keys etc coming in the future.
drop placeholderapi jar in your plug-ins folder
that’s it
Inhale it
@cunning cloak can use an obfuscation method
What next ?
that’s it
How would I do that?
And where do I see the api
look into it and find one that suits you
you don’t need to find anything, it’ll just work
Nope
fireballClass.getDeclaredMethod("W_");```
Inwint het in on my scoreboard or I type %tokens%
is papi loaded?
is papi loaded?
You use an obfuscator. Everything will still be readable it will just make it harder. Don't store API keys that you don't want people to have
It won’t load
there’s your issue
Hm did discord remove my reply?
So how to fix
i have no idea about any logs or anything just try fix it by double checking everytging
K
How I can save structure to file?
Move to #help-server
ProGuard I guess...
+1
there’s not really much point obfuscating a plugin if someone wants to find out how it works, they’ll find out how it works no matter your obfuscation method
just make it open source
Yeah but I just want the person to be slowed down a bit.
Like ^
@chrome beacon here
Yeah I gtg. I recommend looking at a reflection tutorial online
How can I start a minecraft server with java 16
No one response
It’s just a command in minecraft right ?
No
But if you want you can help me
My problem is that i idont know hiwntonload placeholder api
Np
Then wait. This is the wrong channel
I can’t help you to srry
Did you make a plugin or are you just using one
public void onEnderDragonDeath(EntityDeathEvent event){
if(event.getEntity() instanceof EnderDragon){
Bukkit.getLogger().info(String.valueOf(event.getDroppedExp()));
event.setDroppedExp(0);
//Bukkit.getLogger().info("canceled");
}
//Bukkit.getLogger().info("not canceled");
}```
does anyone know why this keeps droping exp?
the if condition doesnt work
i checked the docs
declaration: package: org.bukkit.event.entity, class: EntityDeathEvent
theres a setdropedExp int
The dragon might have a special case for xp drop
Not sure
You need to make sure you load the worlds on server start
i dont think so, its still an entity
how can i force the return value for a method?
its currently true, i want it to be false
then return false?
What exactly are you trying to do?
so theres a method that basically determines if the fireball is on fire or not
i got the method using reflection
but i dont know how to force it so that the method always returns a certain value
EntityFireball.class? Whats the method called
W_
protected boolean W_() {
return true;
}```
public void tick() {
Entity entity = this.getShooter();
if (!this.world.isClientSide && (entity != null && entity.dead || !this.world.isLoaded(this.getChunkCoordinates()))) {
this.die();
} else {
super.tick();
if (this.W_()) {
this.setOnFire(1);
}
MovingObjectPosition movingobjectposition = ProjectileHelper.a(this, this::a);
if (movingobjectposition.getType() != EnumMovingObjectType.MISS) {
this.a(movingobjectposition);
if (this.dead) {
CraftEventFactory.callProjectileHitEvent(this, movingobjectposition);
}
}
this.checkBlockCollisions();
Vec3D vec3d = this.getMot();
double d0 = this.locX() + vec3d.x;
double d1 = this.locY() + vec3d.y;
double d2 = this.locZ() + vec3d.z;
ProjectileHelper.a(this, 0.2F);
float f = this.i();
if (this.isInWater()) {
for(int i = 0; i < 4; ++i) {
float f1 = 0.25F;
this.world.addParticle(Particles.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z);
}
f = 0.8F;
}
this.setMot(vec3d.add(this.dirX, this.dirY, this.dirZ).a((double)f));
this.world.addParticle(this.h(), d0, d1 + 0.5D, d2, 0.0D, 0.0D, 0.0D);
this.setPosition(d0, d1, d2);
}
}```
tick code
Oh thats bad. It doesnt return a field. So you have 2 things you could do.
- Extend EntityFireball and overwrite the W_ method
- Inject bytecode that changes the return value of that method.
found the problem. i was using the config.yml to get my data even though it isn't stored in there. Only took my 4 hrs lol
@lost matrix when i override i get an clashing error
public abstract class Dodgeball extends EntityFireball implements SizedFireball {
protected Dodgeball(EntityTypes<? extends EntityFireball> entitytypes, World world) {
super(entitytypes, world);
}
@Override
protected boolean W_() {
return false;
}
}
Changing that method doesnt help
No idea. There is probably a class that should be extended rather than EntityFireball.
I just realised that EntityFireball is abstact
entity dragon fireball overrides W_ and that makes it so that there is no fire
oh wait
maybe i can add listener for entity combust event
and then cancel it if its my specifi fireball
Already tried that. Doesnt help
Is there a chunk move event less expensive than normal move event?
No. But you can make the detection of moving over a chunk border pretty cheap
One moment pls im writing
@EventHandler
public void onMove(final PlayerMoveEvent event) {
final Location from = event.getFrom();
final Location to = event.getTo();
if (to == null) {
return;
}
final int fromX = from.getBlockX() >> 4;
final int toX = to.getBlockX() >> 4;
final int fromZ = from.getBlockZ() >> 4;
final int toZ = to.getBlockZ() >> 4;
if (fromX == toX && fromZ == toZ) {
return;
}
event.getPlayer().sendMessage("You crossed chunk from [" + fromX + " | " + fromZ + "] to [" + toX + " | " + toZ + "]");
}
how can i inject the bytecode?
If overwriting the method doesnt work then injecting bytecode wont help either.
Interestingly enough i can make a dragon fireball burn by overwriting the W_ method but not the other way around.
huh seems broken
is it less expensive that the normal move event
So there must be another method that ignites the fireball without checking for the W_ method
yeah, but where is it is the question
This is the "normal move event"
Just used in a very inexpensive way
so it's less expensive right?
Less expensive than what?
Its def not less expensive than not using the event at all...
is there a better way
actually im trying to use vehicle move event
im trying to make a minecart limit
so players cant spam minecart into chunks
Yes but im deliberately not telling it to you so you have to use bad code that lags your server.
why wont you tell me!??!!?
sarcasm 🤦♂️

2nd one
whats the difference?
it just looks better
no difference?
yes
early return pattern makes the code more clear. No performance difference
i need a little help ^^
about ShapedRecipe
I don't know what I should do. Can anybody help?
Use the non deprecated constructor that also takes a NamespacedKey
hey, I created a custom recipe with a custom command (/createrecipe) and I stopped and started the server again. When I started it again, the recipe did not work. Any suggestions?
it's the first time I've heard of non deprecated constructor . Can you tell me how it's done?
You need to persist the recipe. Recipes dont need to be registered again when the server starts.
How would I do that?
declaration: package: org.bukkit.inventory, class: ShapedRecipe
No. You should generally avoid deprecated methods because they are subject to change like removal in the next version.
Think of a nice way to serialize then deserialize recipes.
Understood. Now; I don't know what to write to key. -_-
Its of type NamespacedKey and not of type String
So you need to create an instance of NamespacedKey with NamespacedKey::new(Plugin, String)
think i found a solution, i can make an entity that overrides the tick method for dragonfireball to remove all the potion stuff
but i dont know how to make custom entities
It's probably wrong, but I did something like that. Do I have? I'm sorry I'm new at this
Looks good to me
public class Death implements Listener {
Timer timer = Main.getMain().getTimer();
@EventHandler
public void playerDeath(PlayerDeathEvent event){
final Player player = event.getEntity();
for (final World world : Bukkit.getWorlds()) {
world.setGameRuleValue("showDeathMessages", "false");
}
Bukkit.broadcastMessage(" ");
Bukkit.broadcastMessage(" ");
Bukkit.broadcastMessage("§c✞ §6" + player.getDisplayName() + " §7has §6died§7. §cFeelsBadMan §7in Chat! §c✞");
Bukkit.broadcastMessage("§8» §e§oReset the World with§r §6/reset §e§o.");
Bukkit.broadcastMessage("§8» §6the seed was §e" + Bukkit.getWorlds().get(0).getSeed());
Bukkit.broadcastMessage("§8» §6Time: §e" + Main.shortInteger(timer.getTime()));
Bukkit.broadcastMessage(" ");
Bukkit.broadcastMessage(" ");
for (final Player all : Bukkit.getOnlinePlayers()) {
all.setGameMode(GameMode.SPECTATOR);
}
}
}``` for some reason, this disables my plugin?
Just dont forget to set the ingredients and register the recipe
Yeap, i know that ^^ thanks a lot ❤️
This cant disable your plugin. You probably have a stack trace in your console. Send it
at net.dxkyy.duckyschallangesv2.Listeners.Death.<init>(Death.java:14) ~[?:?]
at net.dxkyy.duckyschallangesv2.Main.onEnable(Main.java:46) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:494) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:408) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:435) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:218) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:809) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at java.lang.Thread.run(Thread.java:834) [?:?]```
Main.getMain() returns null
ohhh
you can't use those symbols
for recipes
read the stacktrace
to see what symbols are allowed
Oh yeah. Didnt read your key. It should be something descriptive like "custom_glass_recipe"
so a-z 0-9 and /._-
read 👏 the 👏 stacktrace
Yes. The namespace has to contain only lower case characters, numeric digits and some special chars including _
I get it, thanks ^^
that world is hella fucked lol
Im not saying that i got bored and wrote a listener that creates an explosion on each block that was destroyed by an explosion but
somehow this recursive explosion chain ate through my world...
hm?
anyways I haven't been able to test a plugin in months
the best I can do is test my mongo code
Arent there free mc server options?
there are
i got custom entity working YAY!
Nice. But does it work?
Regarding the ignition
Because for me it didnt
That is really complicated. You would need to register it with the right IRegistry class.
You dont need to unless you want your entity to be persistent.
Except for the book's title and the author, other codes are working. Why didn't he give me the other information?
config.set("Ranks.1.itemNames", "['Paladins Headgear', 'Paladins BreastPlate', 'Paladins Chausses', 'Paladins Sabatons']");
Is this the correct way of setting an array in a yml?
Yes. Just throw it as a list in there.
How would i do that?
@lost matrix didnt work :(
actually i think if i register an entity type itll work
public void saveAsList(final FileConfiguration configuration, final String path, final String[] content) {
configuration.set(path, Arrays.asList(content));
}
But you can also try and just throw the array in there and see if it works.
so @lost matrix how can i register an entitytype?
u need writtenbook not writtablebook
could someone tell me why this event cancel isint working please?
it works with any other entity, but the ender dragon
what do u mean by isnt working
probably cuz the ender dragon has a special case where it just spawns the xp orbs instead of the standard way
yea it spawns the exp orbes a few times, not like normal entities
i cant cancel the exp orb drop
yea do you know how?
and override the method where xp is handled
is that fr?
yup
more work than usual. if you want, you can make a feature request for the api
maybe they will add an event for it or something
i mean theres an event, event.setDroppedExp(0) but it only works with normal entities
cries in "Priority: Minor"
make a new issue and link it to that one
you will help not only yourself but others 😄
question about objects
if i may interrupt
so I talked a bit about this yesterday, but I'm working on an RPG-engine plugin-thingy and I need a way to serialize and load data to and from a file
There are objects like Quest which might contain information like the level required, objective list, etc
In addition to this, the ender dragon actually dies over the span of 200 ticks (10 seconds), and drops experience each of these ticks.
could i use that and make a loop that runs for 10 seconds to delete all exp orbs?
use gson
gson is a wrapper for json that lets you serialize and deserialize pojos
there are also objects like Creature which specify information about a certain mob, like its health, defense, what have you
ah, alright, but i have a little more to explain, sorry
what's to stop me from creating one object that pairs a String with JSONObject
the String acts as a key for the JSONObject, and each JSONObject is grouped into a bigger one when the server shuts down
instead of creating a Creature and Quest and Enemy and Item with their own respective getters and setters
let me paste some code here as an example
something like this
public class JSONKeyComponent {
private String key = "";
private JSONObject obj;
public JSONKeyComponent(String keyName, JSONObject json) {
key = keyName;
obj = json;
}
public String getKey() {
return key;
}
public JSONObject getObject() {
return obj;
}
public int getInt(String keyName, int defaultValue) {
int value = defaultValue;
if(obj.containsKey(keyName)) {
value = Integer.parseInt(obj.get(keyName).toString());
}
return value;
}
public String getString(String keyName, String defaultValue) {
String value = defaultValue;
if(obj.containsKey(keyName)) {
value = obj.get(keyName).toString();
}
return value;
}
}
is there a reason for that?
using gson you could have something like:
PlayerData (class)
--> Quests
--> Stats
--> Inventory
you would then serialize PlayerData into a file, and it'll contain Quests, Stats, Inventory all serialized as well
then you can deserialize the file back into PlayerData
hey uhhh,
does anyone know what this error means?
console:
Cannot load configuration from stream
org.bukkit.configuration.InvalidConfigurationException: while parsing a block mapping
in 'string', line 24, column 1:
Gamemode:
^
expected <block end>, but found '<anchor>'
its an error in my config but idk what it means
send the config
is it possible to turn a playerhead itemstack into a block?
your Gamemode: node has no value
not the issue
but i want to set it on player's command
Key: is perfectly fine yaml
oph I see