#help-development
1 messages · Page 1534 of 1
supplying the folder as a Javadoc location it expects an unzipped javadoc set of folders. You need to set a jar location not a directory
How do I detect a player holding right click
You can detect the right click, you can;t detect holding
Yeah but then you hold in an item
huh?
I am pretty sure you hold in an item while performing the holding click
Hold in an item?
In which detecting a holding click is possible
actually @eternal oxide , @ivory sleet ...
It's possible, just give me a moment to check the relevant cocde
*code
as i already said -> store the MSs between each click and compare them. if they are each time 199-201 ms apart, the player is probably holding right click
You can check a holding click through hacky PlayerInteractEvent and some other events but it’s a workaround
hmmmm
Not really a supported way of doing it
maybe I won't
Maybe I'll make it so it activates on right click and cancels if you scroll off of it
.....
That said you will be introduced to a lot of things which might break that
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)){
ItemStack s = player.getInventory().getItemInMainHand();
}```
there is the solution. other workarounds are redundant
That’s a single click
Not a holding click
That only detects a Click, it doesn;t detect Holding a right click
i see
i'm feeling ignored
Here's what I'm making:
for what do you need the rightclick here?
holding rightclick*
It sounds like he's tryign to do a sniper scope on held right click
I wonder if the spyglass events could do that
In that case, @hybrid spoke 's solution might actually be the best. The javadoc states that the event fires under specific circumstances which translate to 'event gets triggered ~ once/15 ticks, or with every right click', but from what i can see checking the duration without specifically storing it elsewhere is not possible
There are no spyglass events yet, but possibly

From experience, a map is a far better solution than the stuff with armor stands. That would trigger a different event (PlayerInteractWithEntity) but pure code that has to NOT run on the server (directly) is much faster
I know @hybrid spoke you're feeling ignored, because to be honest, with my current system, it'd be pretty hard to do that. I wanted to make it so you had to hold right click (it'd be pretty OP if you could do other things while rejuvenating), but I think I'll make it so that you click it once, and then you can't scroll off of the item or else it will cancel the rejuvenation.
already had this topic because of my anti autoclicker plugin since holding rightclick causes 5 cps
is it possible to get the top kills with Statistics.PLAYER_KILLS
its not pretty hard to do that. not even to integrate it. just checking if he scrolls off would actually be more work ig
well if he wants to keep it active until item in hand changes
use a map and sort it by the value
just log that he right clicked and set it to false when that events triggers
ok so it is then
How can I copy a world folder into my plugins directory?
the integration would probably be the same by having a boolean if he still clicks/holds it or not
Ok so I have an interface that is opened that displays crafting recipes. The interface is opened via a Knowledge_Book, and it is name and has a lore, and is enchanted with luck for the enchanted effect... However when i open the book it displays an error in the console. https://hastebin.com/gokuluheti.rust
I was wondering if there was a way to bypass this.?
@stoic osprey per plugin or manually
i.e From ./world to ./plugins/myPlugin/world
plugin
...mind jumping in a vc for that?
fair enough
Files.copy(world.getWorldFolder().toPath(), plugin.getDataFolder().toPath().resolve("world")) or smtng
Just curious, if u know a way to bypass id appreciate it
Can someone help me with Json onEnable/onDisable please, cant make it work
public void onDisable() {
Map<UUID, Collection<Vector>> map =Territory.getAllTerritories().asMap();
Gson gson = new Gson();
String json = gson.toJson(map);
}```
so I have this but it's onDISABLE
Why not use a Multimap
Also you need to write that into a file
yea no idea what i'm doing actually lol
and use GsonBuilder instead
I believe Gson adds guava collection type adapters by default
Or yeah mb that’s the builder
wdym adding it to a file ? another class ?
no writing it to an actual file
sorry guys im big noob about it
it doesnt just stay in memory after restart
No you need a file to store the data like between arbitrary server instances
ah ok so I need to create a "json" file with the name I put it when I call json command, right ?
wait
the file must be in the server
not in the plugin
https://github.com/Itzdlg/RegenBlocks/blob/master/src/main/java/me/schooltests/regenblocks/RegenBlocksAPI.java#L42
this shitty plugin of mine has an example of reading json
but you need write, one sec
ah thanks will look into it see if it helps
Im really confused
so 1st of all I need to write in my plugin a command that will create a file in the server disk, right ?
yes a physical file
public static final Gson GSON = new GsonBuilder()
.setPrettyPrinting()
.enableComplexMapKeySerialization()
.disableHtmlEscaping()
.create();
...
try {
File file = new File(dataFolder, "territories.json");
FileWriter fw = new FileWriter(fw);
GSON.toJson(Territory.getAllTerritories().asMap(), fw);
} catch (IOException e) {
e.printStackTrace();
}
well dont just copy it, learn what it does
yea
the first part creates a static object called GSON, all static final constants should be uppercase by convention
Your plugin might leak memory if you copy paste that code considering that it doesn’t close the file writer.
then we create a builder for the Gson object, enable pretty printing which puts different keys on new lines, enables map key serialization which serializes map's properly, and disables html encoding which prevents your json from being fucked up
you should use that new Gson object everywhere, dont copy paste that code to every file you use gson in
hmm okay so all those methods are Gson methods, like the core methods of Gson to copy my shit into json file, right ?
thats why it's statically available
now we create a try catch which is for FileWriter
because it throws IOException in some odd cases
then simply toJson serializes the object to a json string and then writes it to the FileWriter (fw) provided
hmm
so
File file = new File(dataFolder, "territories.json");
this create an actual file in a folder somewhere ?
dataFolder needs to be your plugin data folder
so get the instance of your plugin then call #getDataFolder()
Is there a way to check of the message author is a player or a bot? If yes, can someone please give me an example?
event.getMember().isBot()
My plugin has no folder being created when you load it into a server is that what is meant
I'm assuming you mean JDA since you give no information at all
do I need to create a such a thing ?
It's javacord
oh
lmao
never used javacord
JDA all the way (:
Jython 🥴
🥲
if (!getDataFolder().exists()) getDataFolder().mkdir();
saveDefaultConfig();
will this create a datafolder ?
yes
thanks
You don't need to create the data folder it will do that for you
thanks guys really appericiate the help!
isnt the data folder pregenerated?
I think not in older versions
no datafolder
Oh
not sure what is meant by older version but ive downloaded all this shit recently so
maybe only some IDE do that
no IDE does that
IDE doesn't have anything to do with this
what does then ? isnt it from templated code by IDE ?
Spigot should create it when you save the default config
ah I use paper, maybe it's that
you don’t need to check if it exists
how do you create a default config?
saveDefaultConfig() followed by
reloadConfig() iirc
oh
Then you need a config.yml resource
So I can create that manually?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Thanks
Always check the wiki before asking here in the future
It contains a lot of substantial spigot concepts
Guys I'm not sure what to input to retrieve the file onEnable
Map<UUID,Collection<Vector>> map2 = GSON.fromJson()
File file = new File(getDataFolder(), "territories.json");
FileWriter fw = new FileWriter(file);
GSON.toJson(Territory.getAllTerritories().asMap(),fw);
} catch (IOException e) {
e.printStackTrace();
}
this is where I built it on disable
When reading you need a FileReader instead
ah ok
so similar to above but with a reader
also
FileWriter fw = new FileWriter(file);
is "file" as input, correct here ?
it's hard for me to tell because the IDE doesnt refer the type that should be as inputs
Multimap map = new Multimap()
FileReader reader = new FileReaded(new File(...));
map = GSON.fromJson(new TypeToken<Multimap<UUID,Location>>().getType(), reader);
Hmm thanks ! so Gson will translate its own file directly into the Map, amazing!
Yeah should work I think
Hmm I get an IDE error "expression expected" before the Map<xxx>
@quaint mantle
player.sendMessage(Message.getMessage(player.getUniqueId(), "prefix") + Message.getMessage(player.getUniqueId(), "message_ETC_price").replace("{amount}", money_formatter.format(API.ETC_price)));
}else if(args[0].equals("balance") || args[0].equals("bal") || args[0].equals("check") || args[0].equals("info")){
lol it made it spoiler bc of |
it would be args[0].equals("bal") with || at start and end
?paste

Line 42, 62, 97
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.
we need a higher quality version
you are in school?
no, i graduated, but my sister has a hotspot from her school which is what we use because we live in the country and the only other internet we have is satellite and its dog shit
so whats the problem with this code?
probably its formatting 
looks like fucking spaghetti
cannot find symbol variable ETC_price
how about you show us the file that actually declares that variable :)
show us your API class
page not found
as again
case again
case sensitivity is a thing
https://wiki.vg/Server_List_Ping#Handshake
On this page it says an incoming server list ping contains data about the client's protocol version
How can i get this in a ServerListPingEvent?
yeah, there isn't a method to it
isn't it possible to get a handle to the actual packet object itself? (idc about nms)
not from the event, I don't think
well, let me check
yeah no the bukkit event doesn't retain that information
and nms doesn't have an event bus that you could hook into easily afaik
consider using protocollib and listening to the incoming packet
yes thats what i wanted
PaperServerListPingEvent has getClient().getProtocolVersion()
so guess i'll have to use protocol lib
or paper :fingerguns:
most people do
i build against paper exclusively because I want my things to actually be performant
but I usually add a fallback dependency for spigot
for those poor fucks who still run splögget
Lmao
Hi, can I make a spigot plugin from a gradle project? (I want to use firebase so I needed a built.gradle file and this seemed the easiest way to get one.)
spoogle
how does one write to a .yml file in code
new FileOutputStream 😎
Like any other file or use the yamlConfiguration set() method
?paste
that pops up when i launch server with plugin https://paste.md-5.net/nahayucegi.coffeescript
but i added 1.17 library
alright ill check it out tysm
check your plugin.yml
Pls help me
yes, the build tool you use, if any, doesn't matter
you can use notepad and javac if you're gay enough
java is java
love is love 😂
I've told you what to do twice
me?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Thanks
Yeah sorry for being a bit rude... I realised I forgot to send that
LOL THATS THE FIRST RESULT ON GOOGLE
.
It is yes
And also exactly what he needs
can anyone recommend me a hosting? i want it to be good and cheap as possible. its for plugin development.
What do you recommend to learn how to create plugins?
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.
my ram isnt enough
pls help me with that
Hey, is it possible to give a custom loot when someone gets a fish? like could I replace the fish with an item of my choice?
If you don't have enough ram to host a home server you don't have enough to develop plugins
i use 80% of my ram to develop plugins
and minecraft
How much ram do you have?
8 gb's.
But you are going to have to be choosy over what you use. No Intelij, Only Eclipse
i have just intellij and minecraft open, and i cant open the server with 2 gbs.
Yeah, with 8 gig total you shoudl drop InteliJ
he needs OS, MC, IDE and Server
in 1.12.2, yeah but 1.16.5 ... 🤷♂️
1.16 is ok for testing with 1 gig
i always used 1.12.2 in the past
u can run 1.16.5 with 1gb
its possible
but only for testing your plugins
and i ran a 1.17 server on 1gb just to test my shit
Or you could save the money you would be spending on a host and instead buy more ram.
its a laptop
They do make laptop ram
i use 4x2 ram
they also make it in 8 gig sodimms
not really
Hi, I created a build.gradle project, I copied the code from is link(https://www.spigotmc.org/wiki/spigot-gradle/) to the build gradle, I added some java also to test the plugin. BUT after I built the artifact and started the server, it thrown me error that says "cannot find a plugin yml". I have an plugin.yml file but I don't know where should I paste it where the program can find it
I test my plugins on a vps kek
you forgot plugin.yml in the resources
that pops up when i launch server with plugin https://paste.md-5.net/nahayucegi.coffeescript
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
need some help here
also dont just copy and use
private String kitName;
private ItemStack[] kitItem;
private Enchantment enchantmentName;
private int enchantmentLevel;
private String requiredPermission;
public KitManager(String kitName, ItemStack[] kitItem, Enchantment enchantmentName, int enchantmentLevel, String requiredPermission) {
this.kitName = kitName;
this.kitItem = kitItem;
this.enchantmentName = enchantmentName;
this.enchantmentLevel = enchantmentLevel;
this.requiredPermission = requiredPermission;
}
public String getKitName() {
return kitName;
}
public ItemStack[] getKitItem() {
return kitItem;
}
public Enchantment getEnchantmentName() {
return enchantmentName;
}
public int getEnchantmentLevel() {
return enchantmentLevel;
}
public String getRequiredPermission() {
return requiredPermission;
}```
right so I have
then make a class for each kit
have KitManager extended and have this
```public t() {
super(kitName, kitItem, enchantmentName, enchantmentLevel, requiredPermission);
}```
but now I'm thinking about it and I don't know if this is actually gonna work how I want it to work. So any suggestions?
actually read
!!!!!!!!!!!!!!!!!!!!!!!!!!
is kit manager abstract
no
you need it to be abstract if you want to extend it 🤣
wait do you actually?
yep
When I use it in the resources folder it also says that "cannot find a plugin yml in the jar file"
then your doing something wrong
idk
i dont use gradle
I try to center both, for the green line I expect the full line is 127 pixels (and start centering from behind with spaces). The blue line is line 1 of the motd and I also expect here 127 pixels and it starts with spaces at the front
maven is better to me as in user friendly and more easier to use
A class doesn't have to be asbstact to be extended, but you can;t instance abstract classes
it doesnt?
i thought it does
no
You can actually do new Class() {} even if abstract
Can I use maven in IntelliJ?
Exactly as the error sais, you have a null object
yh if every1 ignores me
doesnt mean you spam
learn to read a stacktrace
idkidk123123 now the reason I was thinking is that this won't work how I want it to is because there will be multiple items that will be in the kit
You spamming us makes us just want us to fucking ignore you even more
read the thing @rocky glacier ALSO show code
who beat me
Not sure
😢
but go to ur command class and change the return to true
next time read the stack trace and wait for help
did ya read my response?
¯_(ツ)_/¯
If you are unable to read a stacktrace you can always post your link and ask how.
They are fairly simple once you understand it.
i forgot how to fix this
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
can someone tell me
XD
Set file encoding in properties
alt-F4
how?
ive done it before but i forgot how
which IDE?
intellij
Maven error though
then set it in yoru pom
do i just add <project.encoding>utf-8</project.encoding>?
in the properties or what is it
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
thanks
how would i go about always displaying my actionbar?
bukkit scheduler ?
so just making a loop?
and making it display to the player every 5 second or something?
yea but i'd like it to be displayed always
bukkit scheduler
who worked with the neural network?
idk
how can i detect if a player got off a vehicle
what event doe
use the searchbox
VehicleExitEvent
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
VehicleExitEvent
oh
lol
f i fucking hate that intellij detects typos
LIKE WTF
I DONT WANT TO KNOW MY TYPOS
Hey, how can I get the itemstack of a mod?
AND IF ITS SOMETHING NOT A WORD IT LIKE FUCKING MARKS IT AS A TYPO
i really hate it
oh i can disable it
f
lol
I love that feature I'm very good at making typos
lol
if i am creative and creating new words this thing says they don't exist
and i don't like that
lol
What's the enchantment called for unbreaking
f paper really hates running with 1gb ram
whats the smallest size someone's made a plugin with just one command?
cuz i making a plugin and rn its got 1 command but its like 3.64kb xd
doingSomethingWithAverages best method name i had by far now
its giving a player an custom item i made
but when i look at the logs
it sais
Caused by: java.lang.IllegalArgumentException: Item cannot be null
it doesnt do this on my hub server
send the full error
25.06 15:04:27 [Server] ERROR null
25.06 15:04:27 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'giveblindnessitem' in plugin Blindness v1.0
25.06 15:04:27 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:826) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.PlayerConnection.handleCommand(PlayerConnection.java:2185) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:2000) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1953) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:49) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:7) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:35) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1266) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1259) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1220) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1134) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at java.lang.Thread.run(Thread.java:829) [?:?]
25.06 15:04:27 [Server] INFO Caused by: java.lang.IllegalArgumentException: Item cannot be null
25.06 15:04:27 [Server] INFO at org.apache.commons.lang.Validate.noNullElements(Validate.java:364) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory.addItem(CraftInventory.java:293) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO at icalling.blindness.Commands.Commands.onCommand(Commands.java:19) ~[?:?]
25.06 15:04:27 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
25.06 15:04:27 [Server] INFO ... 19 more
f paper fixes alot of plugins
<t:1624648060:R> someone posted a pretty wall of error
whats on line 19
we need spigot to include paper patches now
in Commands
player.getInventory().addItem(ItemManager.blindnessball);
how does paper solve plugins but spigot the plugins are broken on 1.17
wait how did you timemark this
ItemManager.blindnessball is probably null
do you want the code
<t:unix timestamp:R>
huh
i dont understand
u need to put the unix timestamp
ahh
<t:1609477200:R> was New Years
so
its not tho because how can it work on 1 server but not the other
it is
what is blindness ?
since your error says its null
looks like custom plugin
public static ItemStack blindnessball;
public ItemManager() {
createblindness();
}
public ItemStack blindnessball() {
return blindnessball();
}
private void createEffectClearer() {
}
private static void createblindness() {
ItemStack item = new ItemStack(Material.INK_SAC, 1);
ItemMeta meta = item .getItemMeta();
meta.setDisplayName(ChatColor.YELLOW + "Blindness Ball");
List<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "This is Ghanaman's cool partner item");
lore.add(ChatColor.GRAY + "When you hit a player with this item they receive blindness");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK, 1 ,false);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
blindnessball = item;```
im not a java expert
ItemMeta meta = item .getItemMeta();
this part
theres a space
it probably breaks the thing
ah
package org.powder;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Bee;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import java.util.Objects;
public final class Main extends JavaPlugin {
@Override
public void onEnable(){
System.out.println("[Powder] --- Enabled");
getCommand("bee").setExecutor(new SpawnBee());
getServer().getPluginManager().registerEvents(new ListenerBee(), this);
BeePacket();
}
private void BeePacket() {
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(
new PacketAdapter(this, PacketType.Play.Client.STEER_VEHICLE) {
@Override
public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer();
if (p.getVehicle() instanceof Bee){
Bee b = (Bee) p.getVehicle();
b.setRotation(p.getEyeLocation().getYaw(), p.getEyeLocation().getPitch());
b.setVelocity(new Vector(e.getPacket().getFloat().read(0), 0, e.getPacket().getFloat().read(1)));
}
}
}
);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
``` my main gives me a null pointer exception
?paste
...
show me where you create an instance of ItemManager
in what line?
i am using 1.16.5
java.lang.NullPointerException: null
at org.powder.Main.BeePacket(Main.java:28) ~[?:?]
at org.powder.Main.onEnable(Main.java:23) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:494) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:408) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:435) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:218) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:809) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
28 and 23
?paste
so manager is probably null
how can i fix that?
do you have protocollib as a soft dependency?
assert manager != null; /s
well i have it on my pom.xml and i have no clue what you are talking about
i also have it in my plugins folder
you can add plugins which your plugin depends on to your plugin.yml so your plugin will just be loaded if the dependency is loaded
declaration: package: org.bukkit.plugin, class: PluginDescriptionFile
softdepend:
- ProtocolLib
```like this?
most likely
also, ```
[22:14:48] [Server thread/WARN]: [ProtocolLib] Loaded class com.comphenix.protocol.ProtocolLib from Powder v1.0-SNAPSHOT which is not a depend, softdepend or loadbefore of this plugin.
[22:14:48] [Server thread/ERROR]: Could not load 'plugins\ProtocolLib.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:139) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:383) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:185) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:809) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:199) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:52) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at com.comphenix.protocol.ProtocolLib.<init>(ProtocolLib.java:58) ~[?:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_291]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_291]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_291]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_291]
at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_291]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
... 7 more
Caused by: java.lang.IllegalStateException: Initial initialization
at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:202) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:52) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.powder.Main.<init>(Main.java:16) ~[?:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_291]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_291]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_291]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_291]
at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_291]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]
... 7 more
?paste
maybe since i already have protocollib inside of my plugin?
no
hm
Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
hm
what does this mean
i have one clue
my plugin initalized it first and spigot tried to initialize it again
other way around
Oh?
since you have it as a softdepend
you dont need to initialize it since it's already initialized
when i got this error
i didnt
i didnt test it with the softdepend in the plugin.yml
you initialize it somewhere in your code.
probably in the spawnbee or listenerbee constructor
although i guess in the error above since it's not a softdepend you initialized it first
so i should add it as a softdepend and try
you should not initialize it in your code
what is powder
its the name of the plugin
org.powder.Main.<init>(Main.java:16)
i just typed random shit
16 is ```java
public final class Main extends JavaPlugin {
so you are somewhere creating a new instance of your own plugin ig
what should i do to fix it then??
wait is this a bug or this intonational when you make a static method in intellij it says its being used when it isnt?
Used/unused checks for intellij is definitely far from good in my experience
okay no errors
I think there was a config option to consider static methods entry points by default
What’s bad about it
falses
it works lol
EventListeners always appear in unused
Makes sense ?
Yeah it can only predict compile time shit obv
They are invoked using reflection lol
Hello, so I need to log information into file, and I will also use it as for 'history' command, what file type should I choose? I was thinking yaml, because its easier to read and write values, but it's more like for configuration stuff
How is intellij gonna now
Magic 🪄
:5head:
For just logging you can use a text file
actually probs not in 1.17
cuz reflection doesnt work in java 16
Omg why is everyone saying reflection doesn't work in java 16
It works, but differently…
it doesnt work?
Unless the code access is encapsulated by a module
And your plugin isn't
Neither is the server internals
I mean I avoid it so idrk but I have heard that you have to change stuff so that was the basis of this ^^
Or craftbukkit, spigot or paper code
can anyone tell me why maven thinks this is bad str.replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase(); it says uses unchecked or unsafe operations.
im using it to convert camel to kabab
A wild regex matching exactly 2 characters XD
kebab-case
jesus
Oh sorry lmao
np lmao
I didn’t notice the hyphen
yeah but why does it say that it uses unchecked or unsafe operation.
wild, my intellij says nothing when trying to call this method
https://paste.md-5.net/maregozuxi.java
the controls work
but the rotation doesnt
for some reason
@eternal night should i just ignore it i mean its just a warning
it doesnt stop it from building
idk
what is the maven warning
[WARNING] /C:/idk/src/main/java/test/idk/idk/Main.java: Recompile with -Xlint:unchecked for details.```
and you are 100% sure this is caused by the specific line ?
i dont really want to update maven
This is not giving you an unchecked warning
it is
cuz after i added it
can you recompile using -Xlint:unchecked
it says this
https://paste.md-5.net/maregozuxi.java
the controls work
but the rotation doesnt
for some reason
uh when i did before it did but now it doesnt
🤔
That line is a simple regex replace, it doesn't cast anything
Nothing unsafe about it
oh f i think i figured it out
i cast some other class somewhere to a T which is passed in through the class using these <T>
but it wasnt causing a warning before
so idk why it is now?
Hey quick question: Is it possible to query the display name of an item not whether it has a certain full name, but only whether a certain word occurs in the item?
I mean, there is just String#contains
Which works
ok and what would be the best way to include this in event.getCurrentItem().getItemMeta().getDisplayName()?
a) you are missing a bunch of null checks there
b) getDisplayName().contains("my substring")
Store that in an variable?
For further use
But i dont know If U need that
If Not use Lynx's answer
This is not the full code of this paragraph. It is the following:
if(event.getCurrentItem().hasItemMeta()) {
switch(event.getCurrentItem().getItemMeta().getDisplayName()) {
a switch statement is not an if and does not allow partial checks
switch doesn't work like that
I don't think I need it. But thanks for the tip
switch is just a pretty form to express a lookup table in code
I already thought so
Tf u want to achieve with thay
switch on strings works with hashcodes for anyone interested
What is more suitable for this?
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.
Doesn't it also just works with normal strings ? why use hashcodes. afaik java 7 introduced string switches
guys
i need to move the vehicle
with rotation
it rotates fine
but it doesnt move in the rotated direction
ok thank you
this is not how steer packet works
read up on what the values represent
then why are you passing these values as x and z velocity values into the velocity
if you know xD
Well dis not gonna work
just, be vary on storing a) half a database on them and b) 100% do store the item meta you are reading them off. getItemMeta is a very very expensive call.
wot
10€ a call
I never heard that getItemMeta is expensive?
it copies
i know that i should read it 🤦♂️
I personally store my coins not on my mysql. I store em on my items lol
:5head:
then maybe do that next time before asking, if you knew it already 😉
it is
When u take wallets to seriously in minecraft
like it could be implemented in any version, not just 1.14
mmm?
the API very specifically does not allow generic nbt modification
right
e.g. you couldn't modify the items display name with it
any better way than what i have done XD java public static String kababToCamel(String str) { String result = ""; String[] strings = str.split(""); for (int i = 0; i < str.length(); i++) { if (strings[i].equals("-")) { result = result + strings[i + 1].toUpperCase(); continue; } else if (i == 0) {} else if (strings[i - 1].equals("-")) { continue; } result = result + strings[i].toLowerCase(); } return result; }
use a StringBuilder
my small brain cells cant understand it.
idk how to use that
the values in the packet only represent if the player pressed the forward,backwards or left and right buttons
not actually the rotation
you will need to calculate the vector from it
smooth
java.lang.NullPointerException: Cannot invoke "org.bukkit.World.getBlockAt(org.bukkit.Location)" because the return value of "org.bukkit.Location.getWorld()" is null
getting this on startup despite having load: POSTWORLD because it's loading before the worlds for some reason... any ideas for a fix other than delaying it by a tick?
Seems more like a question as to where your location comes from
I think getting world before the world is there is bad
Or am I smooth brain
Yes, the locations world. I can create a location at runtime that doesn't have a world assigned to it
the location includes the world.
it's just that the plugin enables before the worlds
oh
it might be that i need softdepend on multiverse
one sec
i still do not understand, i dont think i will either
then maybe look for existing plugins to do what you are trying
yep, it was because the plugin was enabling before multiverse loaded custom worlds
thanks for all your help guys 😉
Even though we did nothing yeah sure 😂
exactly
From a mentally unstable person
isnt looping slow?
Seems reasonable
public static String kababToCamel(String str) {
String result = "";
String[] strings = str.split("");
for (int i = 0; i < str.length(); i++) {
if (strings[i].equals("-")) {
result = result + strings[i + 1].toUpperCase();
continue;
} else if (i == 0) {} else if (strings[i - 1].equals("-")) {
continue;
}
result = result + strings[i].toLowerCase();
}
return result;
}``` can someone help me revamp this XD
Stringbuilder says henlo
thing is idk how to use that
why not split via "-"
^^ could just uppercase each array start
if youre trying to get the characters why not use toCharArray
i wanna make sure i get all the characters correctly uppercased and lowercased
word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase()
?paste
Some code I found online
kabab-case
Minecraft commands naturally suggest stuff like "[<level>] above the message when there's no tab complete and all. How can I do the same?
Pattern.compile("[-_](\\w)").matcher(input).replaceAll((r) -> r.group(1).toUpperCase());
How do I get UUID of an offline player by just their Name?
call getOfflinePlayer with the name
note that it can and probably will make a blocking network request to mojang
so you don't want to do it synchronously on the main thread
i don't know how to put it any clearer
isnt that deprecated ?
call getOfflinePlayer
pass the name as an argument to it
it is deprecated but it is still a perfectly valid operation, not subject to removal, and fine to use
read the deprecation note
its just deprecated cause it sends the request to mojang
lol
i still have no idea how
bukkit deprecations aren't real deprecations
not sure if iterating over the offline players would make more sense
or if getOfflinePlayer already checks them
it does
ah good
it uses the local usercache if the name is cached
in fact paper has a specific overload or a variant that does not make the network request
and only checks the usercache
gosh just help me
what even is your issue
and no, I can't see replies
you'll have to put some actual effort into it and cuntpaste the thing instead of .'ing it
guys
https://paste.md-5.net/qesogamada.java
i need to move the vehicle
with rotation
it rotates fine
but it doesnt move in the rotated direction
why?
~ Core
what is that supposed to mean
Thanks! I got it to work
and he doesn#t understand that the packet does not send the actual rotation but rather boolean style int flags what keys were pressd
nn why cant u see replys?
i am not sure how you can rotate something without rotating
wait
what version is it
1.16.5
probably 1.8
its a bee damn it
were boats even in the game in 1.8
NNY is obviously famous for living the life of ripcord
...maybe?
if you spec them in spec mode you can see that they still are looking into the direction like before
whats ripcord
dunno bout minecarts
couldn't find a fix yet but probably didn't looked deep enough into it
give up i suppose
No
c++ rewrite of discord client for the toasters out there that cannot do elektron
i placed a minecart before and it was rotating so weirdly
MEIN NEIN ELEKTRON
hello
are you waiting for a "hello" response before you're going to ask your question
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
well i have the griefprevention plugin but the /trust isnt working
oof
unless you are the developer of griefprevention, this isn't the right channel
sorry
myes
i don't actually know a word of german
i just pull from a catalogue of nazi german associated words
must be a brit then
how do i cancel drops with EntityDeathEvent?
clear the getDrops list
...
ok ty
you have to kill the drops
Tf Electrons related to Germans?
:)
wait
what lynx said
electron isn't related to germany, I wouldn't think
nvm
it is closely related to shit, though
That's what I think as a German lol
Well nuclear bomb I guess
that is anti german
But the Americans did it so more related to em
apparently this works java StringBuilder s = new StringBuilder(); char[] chars = str.toCharArray(); for (int i = 0; i < chars.length; i++) { if (chars[i]=='-') { s.append(("" + chars[i + 1]).toUpperCase()); continue; } if (!(i==0) && ("" + chars[i - 1]).equals("-")) { continue; } s.append(("" + chars[i]).toLowerCase()); } return s.toString();
you could probably deep search it. already tried the nms and normal way. good luck. @ me if you found smth
built by the amerimutts and conceptualized by a jew
Well then good
about as not german as you can get
Good it wasn't dropped here ;7
how i can get CustomModelData from armorstand's ArmorItems in spawner?
:)
is this your first plugin
if I'm correct this should give a speed potion
ItemStack potion = new ItemStack(Material.POTION, 1);
PotionMeta potionmeta = (PotionMeta) potion.getItemMeta();
potionmeta.setMainEffect(PotionEffectType.SPEED);
potion.setItemMeta(potionmeta);
p.getInventory().addItem(potion);
me or someone else?
maybe, dunno; potion meta and shit has been changed since 1.8
i don't know how the new system works, and I don't remember how the old system worked
neverheard
declaration: package: org.bukkit.potion, interface: PotionBrewer
it a interface tho so it might not be how you do it
lol it got deprecated cuz it doesnt work XD
I guess you play with getDrops()
also for the snake to camel conversion, on java 1.9 this should work
Pattern.compile("[-_](\\w)").matcher(input).replaceAll((r) -> r.group(1).toUpperCase());
will convert it to lower camelcase
uh
Pattern.compile("([-_]|^)(\\w)").matcher(input).replaceAll((r) -> r.group(1).toUpperCase());
will convert to upper camelcase
that way might be better than what i have done it but im gonna stick to the way i have currently
just please cache the compiled pattern
of course you don't want to compile the pattern every time
yes
but that is for the sake of brevity
yeah i dont understand regex so ima stick to loops and stuff XD
even if its bad idrc
newbie mistake, done that a few times while learning and I had a headache
Doesn’t it get optimized?
i doubt there is any internal caching going on in there
I don't think JIT would actually cache yea
Hmm fair then
mmm
not sure if the compiler does anything about it
JIT might do something about it
what if the string changes and you want to do it like every time you ran a command?
the string doesn't change, if you mean the regex string
no way JIT caches instances of pattern
if you mean the input string, you call pattern.matcher(input)
where pattern is the precompiled pattern
and input is your input
oh
Help
yeah i dont understand regex so i might just use for loops and stuff
can't see embed txts
you are running outdated java
I cant figure out what to do in the ide
yeah i know im not using hte right version but i dont know which one to use
it probably says that
LOL
Ohh okay
or java 16
Thanks
java 16 is evil tho
it. really isn't
to me it is
Are you modifying static final fields using reflection ?
anything past 8 is
what is this CraftComplexRecipe and CraftSmithingRecipe?
a complex recipe and a smithing recipe, respectively
I'll start a list of people that like java 8
the concrete classes part of the craftbukkit server implementation that each implement the corresponding bukkit api classes
java 1.8
how fitting
how come huh
not really but in java 16 i would like to have it ;-;
and you cant do that in java 16
anvil? yes?
no the smithing bench thing i think
whatever it's called
i don't think anvils use recipes
if you ever run into that issue, be a useful person and PR a change.
idk some people say that mojang made packets have final fields and they need them to not be final so they can make packet listeners idk
your mom
?
but you need it for some things
not really
reflections are a bad usage except your are doing your own framework
¯_(ツ)_/¯
Yeah kinda agree with luzifer, shouldn’t be used unless you have a decently justified reason for it
its just fucking facin south. i am having the same problem as https://www.spigotmc.org/threads/set-body-rotation-of-a-livingentity.46377/
maven is such a bitch, just sayin
what is this CraftComplexRecipe?
So i did ```java
ItemStack potion = new ItemStack(Material.POTION);
PotionMeta potionmeta = (PotionMeta) potion.getItemMeta();
potionmeta.setMainEffect(PotionEffectType.SPEED);
potionmeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 3600, 0), true);
potion.setItemMeta(potionmeta);
p.getInventory().addItem(potion);
So now im just wondering should I just get console to give them it
PotionMeta#setColor
nope
what do you mean "nope"
lmao
