#help-development
1 messages · Page 545 of 1
I setup a clicking event to detect when a player clicks on certain items in a specific inventory, but whenver the player clicks on an inventory slot that has nothing in it, it sends the console an error. What can I add to remove this issue?
check if current item is not null
Like this?
if (event.getCurrentItem().getType() != null){
private static Main plugin; This is how I create my plugin
public static Main getPlugin() { // getter for the static plugin instance
return plugin;
}
why is this null
or how is it null
public static NamespacedKey key = new NamespacedKey(getPlugin(), "death_clock");
It's null if you never set it to anything
damn i thought they were one and the same person
but what do I set it to, is my question
Set it to your plugin instance
ill just do this or somethign
?di use this instead of the crappy approach
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
^^
Would this work in order to determine if the item they click in the inventory is null or not?
if (event.getCurrentItem().getType() != null){
read
hi i started a new project; whenever i build it with mvn package it gives me 3 files and each of them are >5kb
what should i do?
jar files?
iirc one contains your jar with the shaded stuff, one without and one with only the shaded stuff
i only see two tho
what does shaded mean?
i did
it wont work
that you compile stuff into your jar rather than providing it at runtime e.g. through a plugin
it says it has a wrong plugin.xml
show error
?paste it
it looks like this
you got resource filtering enabled in your pom.xml?
doesnt look so
where did you put your plugin.yml?
dunno if that stuff is enabled by default
since when does paper-plugin.yml work
wdym?
thought it was supposed to be called plugin.yml
so i should rename?
idk could try
ye, that was the problem... i have this "plugin" in intellij that can help u create a mc plugin, but i accidentally selected paper instead of spigot...
now it shows the right icon
plugin.yml works for paper too
@tardy delta
first
original is without shaded libs, shaded is just shaded libs so you need first one

Why the heck would you ever want just shaded libs
idk
I wanted to add an ActionBar to my player's screen that displays them their time when running a parkour course and was wondering how often I should have the action bar update to not impact server performance or if it won't even be an issue
So sending it once every tick will be fine?
ok cool
could I use setter injection
how can i get all the values for a key from a yml file
instead of dependency injection
for what
me or knight?
not you
https://bukkit.fandom.com/wiki/Configuration_API_Reference for you and loop over keys, calling getX on them
is this a good usage for dependency injection ^^^
ok
Don’t make it sta- ^
got you
D:
class Whatever {
private final XPlugin plugin;
public Whatever(XPlugin plugin) {
this.plugin = plugin;
}
}```
How do you set an action bar for a player?
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(timeInHms));
util classes shouldnt have dependencies
I used tyhis
im using instance
It’s weird that there isn’t a string version for action bar
dont tell that to paper
im waiting for string templates but in a different way, it would probably be able to colorize a string
actually... its good 🙂
?paste
this dosent even give me a cause
at me.creepinson.plugin.Main.onEnable(Main.java:107) ~[?:?]
I disagree
}.runTaskTimer(plugin, 1,timeInTicks);
no but caused by...
Hi
It’s caused by plugin being null
How to set my own item texture for itemstack item?
figured it out
set CustomModelData in the ItemMeta
How
ItemMeta#setCustomModelData
But it support only ints
hi i would like to know why my instance is not equal to my inventory can you help me
@EventHandler()
public static void onClick(InventoryClickEvent event){
Player player = (Player) event.getWhoClicked();
ItemStack current = event.getCurrentItem();
Inventory clickedInventory = event.getClickedInventory();
Inventory customanvil = Bukkit.createInventory(null, InventoryType.ANVIL, "anvil");
if (event.getView().getTitle().equalsIgnoreCase("anvil")){
Inventory anvil = Bukkit.createInventory(null, InventoryType.ANVIL, "anvil");
ItemStack paper = new ItemStack(Material.PAPER);
ItemMeta paper_meta = paper.getItemMeta();
paper_meta.setDisplayName("a");
paper.setItemMeta(paper_meta);
}
if (event.getClickedInventory() == customanvil) {
player.sendMessage("instance est egal");
}
}
I must create resource pack and one texture name for example "1"?
And how to import it to spigot plugin folder
how long max should a method name be?
you have to host the resource pack zip somewhere and send a url to the clients
Hello, I'm Geegaz ! As you may know, the first snapshots of the 1.14 introduced a new format for the JSON item models custom model data ....
why is this returning null
why is your method static?
.
How to add hed to my Itemstack item
we're not google
Why would that be an issue?
I cannot find it
It’s an event.
So?
Just like they can be private
but shouldn't be
Thing is slapping static on everything by default is a really nasty habit
Shouldn’t is irrelevant to the question. It wouldn’t cause that issue.
yeah his issue is that he's tryna check if it's an anvil by doing a title check but still
master the basics
Welp time to
Illusion Search Index - Asking for Help
Hey there, if you're seeing this, there's probably a chance that you've asked for help inefficiently. The goal of this post is to provide tips and tricks that will help you get help.
Let's say you want to create a textured skull item with no prior knowledge:
Before asking for help, it is important to research and attempt a solution towards your problem, I usually follow the following steps:
- Break down the problem into simple steps (In this case we want to first create an item, and them apply a texture to it)
- Research the steps individually, and understand how your steps work together (We'd figure out that we need to use the ItemStack class, and apply the texture to its meta)
- If you're struggling, google your problem. Make sure to efficiently use keywords, I usually just write
spigot, followed by a 2-3 word summary (spigot custom head itemstack) - No solutions? Look at how existing projects solve your problem (In this case I'd look at the source code of a plugin that messes with player heads, probably on GitHub)
- Still unable to find an answer? Now is the time to ask for help
When you're asking for help, it is important to describe your problem, what your solution is and any attempts you have made, as well as the expected result.
Here's an example of how to properly ask for help:
Hey there, I am currently trying to create a custom-textured skull ItemStack with a base64 texture value. I already tried using the SkullMeta class but this only allows me to pass a player instead of a base64 string. Here's my current code:
public ItemStack createSkullItem(String base64) {
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
// I'm stuck
return skull;
}
Here's an example of what not to do:
hello
how player head item works base64
When asking for help, there are a few principles that will help you get answered quicker, feel free to do research about the following:
- No Hello
- XY Problem
should I use saveConfig or saveDefaultConfig?
There is difference
saveDefault is writing from plugin resource folder
And just save is saving from memory
using savedefault will overwrite what the user might have changed?
If you have a config
why is this returning null?
Because I need variable for other class
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Use getPlugin not getProvidingPlugin
thanks
use none of those
Does anyone know how I can get player chat input from a gui?
Ex: input custom hex code as an option on a color selection menu
Use the conversation api
alright
public static void subtractTime(Player player, long hours) {
PersistentDataContainer pdc = player.getPersistentDataContainer();
Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
expires.minus(hours, ChronoUnit.HOURS);
pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
}
this isnt subtractng my time when I die
shouldnt you be working with System.currentTimeMillis() and TimeUnit.HOURS.toMillis()
uhh im doing real time
and the server stopd
many times
and I wanna change the time
to my ability
What I want my plugin to do is when the player takes lava damage, to teleport them to the corresponding teleport point. I am using event.setCancelled() to cancel the lava damage, but it seems when the player takes lava damage, they are now unable to move. Here is my code: https://paste.md-5.net/jewuhoyiju.java
disable inventory
onenventoryopened sor something
then do event.setCamceled
?spigotapi
package index
I use this
Very helpful
my brain is broken rn, do you guys know any way to traverse single dimension array columnwise?
without additional if checks
@rare aurora https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryOpenEvent.html
declaration: package: org.bukkit.event.inventory, class: InventoryOpenEvent
single dimension arrays dont have columns?
yea but you can simulate single dimension array as 2d one
your welcome
[1 2 3 4 5 6 7 8 9] =
1 2 3
4 5 6
7 8 9
-> 1 4 7 2 5 8 3 6 9
public static void subtractTime(Player player, long hours) {
PersistentDataContainer pdc = player.getPersistentDataContainer();
Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
expires.minus(hours, ChronoUnit.HOURS);
pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
}
this isnt subtractng my time when I die, How could I fix this
I'd say change your incriment level and then subtract a certain amount when it gets to one point to simulate a certain column, might need an if statement or two
was that to me?
method can only accept one event type
someone give me idea for check tripwire states ?
if players put tripwire to tripwire will not merge and change their faces
no for dovidas147
oh lol
public static void subtractTime(Player player, long hours) {
PersistentDataContainer pdc = player.getPersistentDataContainer();
Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
expires.minus(hours, ChronoUnit.HOURS);
pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
}
this isnt subtractng my time when I die (dont mind the duplicate im creating a thread!)
closest thing i've got is
for (int i = 0; i < size; i += rowSize) {
// code
if (i > size) {
i %= (size-1);
}
}
well smth like this
i swear sometimes iterating without 2d arrays like this is useful
especially when you can usage 2d arrays
in cpp for example there's no overload of [][] operator
so you can defined 2d shared pointers afaik
so you need to declare 1d instead and use it as 2d
yes I agree, using actual 2d arrays is so annoying
is there way to read code of packets in nms???
oh thx
you need to inject duplex channel handler
iirc
inside netty channel handler or smth like that
this sounds like hell to deal with
i've tried it
the worst of it all that its not thread safe
as the packets sent async
so you cant access the api which is not thread safe
bruh
cant u just use scheduler to do sync actions??
you can, but i dont remember if the registering of listeners are thread safe
prob it is
but its tick dependent
so if you have something which shouldnt depend on the tickrate its not an option
afaik there's nms server runnable method
that allows to execute in the main server's thread
without any delays
0-8 for the hotbar, 9 - 35 for the inventory slots, top left to bottom right
I am trying to make my plugin detect when a player takes lava damage, and when they do, teleport them to a specific location. For some reason, even thought java event.setCancelled(true) is after the part where I check to see if the entity is a player or not, boats are now unable to burn in lava. Here is my code: https://paste.md-5.net/piwojodake.java
hmm i cant find how ClientboundCommandsPacket is sent...
are you sure that your plugin is causing it ?
Let me try with my plugin disabled real quick
Oh I guess it wasn't my plugin lol
could be worldguard I guess
thanks!
i just want to know fields of ClientboundCommandsPacket in nms
like i cant find ClientboundCommandsPacket nowhere
public class playerJoinListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
UUID playerID = p.getUniqueId();
File playerDataFolder = new File(getDataFolder(), "playerData");
File playerFile = new File(playerDataFolder, playerID + ".yml");
if (!playerFile.exists()) {
playerDataFolder.mkdirs();
try {
playerFile.createNewFile();
YamlConfiguration playerConfig = YamlConfiguration.loadConfiguration(playerFile);
playerConfig.set("balance", 0);
playerConfig.save(playerFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}```
anyone know why this doesn't save?
most of it works, except for the part where it generates the file, but nothing is added to it
it only gens the file and sets the value if the file does not exist myea
it generates the file, but doesn't set the value
I'd use just new YamlConfiguration()
since ur loadConfiguration() call is useless
as the file is newly created anyway
bad naming convention
bad choice of name, else yea
YouNameClassesLikeThis
notLikeThis
yep
also
u usually add the suffix Listener, and not Event at the end of a class that implements Listener
cuz else u tell the reader that the class is a subclass of the org.bukkit.Event class
which it isnt
heya @rare aurora, you wouldn't by any chance have run a create modded server, right? Might be confusing you with someone
also, I like to have ur event callback methods public
noObviouslyThisIsHow
youpackagenamelikethis
yourVariableNamesLikeThis
YOUR_CONSTANT_NAMES_LIKE_THIS
YourClassNamesLikesThis
YoUrChIlDnAmEsLiKeThIs
also ithundxr, I should say u should bundle callbacks by functionality
anyone here good at using pdc and instances
public static void subtractTime(Player player, long hours) {
PersistentDataContainer pdc = player.getPersistentDataContainer();
Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
expires.minus(hours, ChronoUnit.HOURS);
pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
}
this isnt subtractng my time when I die
lets assume u write a really large plugin
obv the plugin is gonna have different "functionalities"
i want to save all of the resources inside a folder to the plugin's data folder
how could I intercept methods like ASM but in Spigot?
yeah, well then prob u can bundle everything in one listener
how could I access my plugin's jar file?
I want to loop through its resources
is there an easy way to get it's File or its Path
I need to intercept this guy here and I thought about intercepting the whole LivingEntity#travel method and recreating it
iirc u can use ZipFile
spigot doesn't really have intercepting afaik
youre meant to interact with the api
no mixins or anything
not by default at least
i do know there is a way to do it
idk if u can maybe use FileSystems
im just curious if there's some method that'll easily give me my plugin without just doing something like getDataFolder.parent.getChild(jarname)
Instant is immutable
ur minus returns a new instant
yep just fixed it
Why not just use getResourecesAsStream()?
oh that would work too
because I asked earlier and no one responded 😅
thought u wanted to loop through entries in ur jar file
yes
ooh
you use getResourcesAsStream() to get the data of a file in your plugin jar.
But if you need the jar as a file ig, you could use <Class>.getProtectionDomain().getCodeSource().getLocation() on some kind of "marker" class, which is in a very simple location relative to your jar?
hm
i want to loop through all resources in my jar
that's my goal
not all
most excluding some folders
then u just use ZipEntry::getName with getResource(AsStream)
The difference is less imports 😉
or the type is dynamic then, log(...) is what u'd use
Is there a way to check if a player has joined the server before or not?
hasPlayedBefore()
ty
Where's a good discord server to help get people onboard for a project
?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/
Well I feel like getTicksLived() wouldn't be accurate enough. A snowball could live longer than half a minute to be honest in case you would launch the projectile (snowball) from a high amount of blocks.
!snowball.isValid() doesn't work at all in my if case...
Also, getTicksLived() > 600 wouldn't be correct, as it would have to last at least half a minute I just noticed 😆
Also I'm strangely getting a bunch of errors when trying to use the ParticleEffect library:
https://bukkit.org/threads/1-8-particleeffect-v1-7.154406/
is there some method to get the optimal drops from a block, regardless of the tool? Diamond pickaxe is pretty good, but doesn't get everything.
I just copied both classes "ReflectionUtils" & "ParticleEffect".
What r u talking about? fortune 3?
no as in like
for most blocks, getDrops with a diamond pickaxe returns what I'd want
but an example of a problem is glass, it doesn't drop anything
I'm sure there are more examples I'm not thinking of yet either
I have a value in my customconfig.yml named waterbucketclutches and I want to get the value of it +1. How would I do this?
Hi!
Don't hate, im completly new to this.
In my pom.xml, this is red:?
<artifactId>spigot</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>```
Like, the red appears in between the <> things
Are you using IntelliJ?
Is there a little reload button at the top right of the code screen when inside the pom.xml?
Yes, in a sidebar thing :D?
I missclicked it, but something popped up, in the bottom of my screen :p?
Could not find artifact org.spigotmc:spigot:pom:1.18.2-R0.1-SNAPSHOT in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
This one?
you have the wrong artifactId
Heres a tutorial on how to do it: https://www.spigotmc.org/wiki/creating-a-plugin-with-maven-using-intellij-idea/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Thanks! :)
np
Wow, that was actually pretty easy, thanks!
Of course!
hi, whats the file path to a file inside the resources folder?
My @Override is red?
Cannot resolve symbol 'Override'
if you are in IntelliJ you can right click the folder that says resources and copy the path i believe
are you trying to load a resource from the jar
yes
you don't need to specify a path
ye but when i just typed the name (and extension) it still says no such file or path
you didn't include the file in your jar, or you kept it inside a folder
no? its inside the resources
there is no resources folder in a jar by default
and the size of the jar also changed
open teh jar with a zip tool and see if your file is there
alr
When i google it, i can't really find anything?
it is there
then how are you trying to read it?
you need to extract it to a file
You can however pack a dll in the jar and run that through a few hoops
Well running isn't really the right word though
and how can i get the path?
cuz if i run it somewhere else, the path will change
what do i have to do if its in the plugins folder?
you realize an exe will only run on windows
it is windows
wait so if its in the same folder (plugins folder) then i can still call it with the name?
yes
You can always use relative paths
and what exception will it give me if it cant run?
people are goign to be very suspicious of a jar extracting an exe and running it
how can i change player name colors for each player? like one player sees some guys name in red but a different player sees the same player with green? like for team differentiation
friendlies show up in green on tab, enemies show up in red
something like that
how could i go about making that
packets only
ok
sending fake teams
poggers
how can I make a regex that matches strings that start with "META-INF"
?xy
Asking about your attempted solution rather than your actual problem
im looping through a set of strings
and want to exclude ones that match certain things
like starting with META-INF
but idk regex
^META-INF(.+)?$
referencing META-INF sounds more like you are having issues creatign a working jar with shaded libs
but uh, java provides the String#startsWith method so I sure hope you cannot use that one
Also ^/?META-INF(.+)?$ is probably the better regex, but has slightly different behaviour to what you asked for
Here are the most common characters and their corresponding width. Now just find out how wide a book page is and from there it should be fairly easy
I am actually looping through a jar file and trying to save all resources that aren't code related
the jar file being my plugin's
Well, ignore that for simplicities sace.
and that's why I need to exclude some things
like meta-inf
or any file that ends in .class
it would probably be easier to specify the types of resources you want
Just ignore pom.properties, pom.xml, *.class and *.MF files then
Unless you use services for whatever ungodly reason
thank you
also ignoring any files that start with acf-
Let me guess: License files?
oh you mean my reason?
my team is making a rather complicated plugin for our server
with many data oriented parts
lots of json files and whatnot
or language files I guess. Noone seems to remember that it is required to include the license in your jar
instead of loading the resources directly
I want to load them from my data folder
so that they can be edited without recompiling
public static boolean hasExpired(Player player) {
Instant expired = Instant.ofEpochMilli(player.getPersistentDataContainer().get(PlayerJoined.key, PersistentDataType.LONG));
return Instant.now().isAfter(expired);
}This is not working
how can I fix this
how exactly is it not working?
like the boolean isnt true
Also it really looks like this can be done without the usage of PDC
Its designed to use PDC
are you sure that the timestamp that is stored in the PDC is in the future?
ya
like really sure?
does the players time show zero?
well if the timestamp is in the future
Just Sysout the instant (expired) for us
Yep that confuses me even more.
Either send the entire code or print expired and give out what the console has to say about it
fsr the night vision effect will flash (it's random, usually every 10-100s)
don't talk about how bad the code is lmao
public class ManualListener extends BukkitRunnable {
private final JavaPlugin plugin;
public ManualListener(JavaPlugin plugin) {
this.plugin = plugin;
}
@Override
public void run()
{
App.getInstance().getLogger().info("hello");
final FileConfiguration config = App.getInstance().getConfig();
List<String> players = config.getStringList("players");
for(String name : players) {
Player player = Bukkit.getPlayerExact(name);
if(player == null) {
continue;
} else if(name != player.getName() && player != null) {
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
}
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 255));
}
}
}
int timeInSeconds = 1;
int timeInTicks = 20 * timeInSeconds;
new BukkitRunnable() {
@Override
public void run() {
//The code inside will be executed in {timeInTicks} ticks.
for (Player p : Bukkit.getOnlinePlayers()) {
if(hasExpired(p)){
Bukkit.getBanList(BanList.Type.NAME).addBan(String.valueOf(p.getUniqueId()), "Clock Ran Out", null, null);
}
// set actionbar
Long Frt = Instant.now().until(getTime(p), ChronoUnit.MILLIS);
Duration duration = Duration.ofMillis(Frt);
long h = duration.toHours();
long m = duration.toMinutes() % 60;
long s = duration.getSeconds() % 60;
String timeInHms = String.format("%02d:%02d:%02d", h, m, s);
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(timeInHms));
}
}
}.runTaskTimer(JavaPlugin.getPlugin(Main.class), 1,timeInTicks);
private static NamespacedKey key = new NamespacedKey(JavaPlugin.getProvidingPlugin(Main.class), "death_clock");
public static boolean hasExpired(Player player) {
Instant expired = Instant.ofEpochMilli(player.getPersistentDataContainer().get(PlayerJoined.key, PersistentDataType.LONG));
return Instant.now().isAfter(expired);
}
and where do you store the instant?
like create it?
https://media.discordapp.net/attachments/1093949013847441528/1114663924827181136/image.png?width=2160&height=396 Why did there come an error, I registered my command, etc?
code snippet would be nice
public static NamespacedKey key = new NamespacedKey(JavaPlugin.getProvidingPlugin(Main.class), "death_clock");
No - where do you run player.getPersistentDataContainer().set(XYZ) (more or less)
do you want main class or command class?
can you please use syntax highling pls pls pls
command i guess
have no idea how to do that
Okay 1 moment please
that is your issue then. expired will always be the UNIX epoch then (i.e. somewhere in early 1970).
its literally a single line of code
Hes sets teh future time when the player joins if it's a first played
Read up on how to use the PDC properly and you should figure it out
if(!p.hasPlayedBefore()){
p.sendMessage(DIALOG + ChatColor.GREEN + "Welcome to the server!");
// set time
setClock(p,10);
and what is setClock
package com.meteoren.lobien;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
public class guicmd implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (commandSender instanceof Player) {
Player player = (Player) commandSender;
Inventory inv = Bukkit.createInventory(player, 45, ChatColor.translateAlternateColorCodes('&', "&e&lLobien"));
ItemStack close = new ItemStack(Material.BARRIER);
ItemMeta closeMeta = close.getItemMeta();
closeMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lLuk Menu"));
closeMeta.setLore(Arrays.asList(ChatColor.translateAlternateColorCodes('&', "&7| Klik for at lukke menuen")));
close.setItemMeta(closeMeta);
inv.setItem(45, close);
}
return false;
}
}
public static void setClock(Player player, long hours) {
Instant expires = Instant.now().plus(hours, ChronoUnit.HOURS);
player.getPersistentDataContainer().set(key, PersistentDataType.LONG, expires.toEpochMilli());
}
^^^^^
What? to me?
?jd-s
or
oh shoot i gtg now srry
Ah nevermind. I confused itemstacks with players
What?
whats the problem O.o
With itemstacks you'd need to set the itemmeta again, but you don't have the problem with players
Wait what
it is irrelevant for you. I made a mistake
this
You have a bad plugin.yml
show plugin.yml
me?
yes
Yes you
or atleast the command definition
Send the entire plugin.yml
name: Lobien
version: '${project.version}'
main: com.meteoren.lobien.Lobien
api-version: 1.18
commands:
test12:
description: Det her er pisse svært
usage: Du bruger ikke kommandoen rigtigt, dumme svin
?paste
there you go
Wrong spacing
indent the description and usage by 1 more tab
And the message is sent to the player? I recall hasPlayedBefore having funny (i.e. ambiguous) behaviour
it works
I see from actionbar
that makes it interesting then
I see nothign wrong with the code
other than it's untidy. you should keep all the clock code in the util class
it shoudl also be in it's own class, nothing else in it
how to check if instant expire
Yeah it should work from the looks of it
no listener, nothing
that is 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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
you are comparing teh stored instant to a new instant
What kind of strength would the snowball need to posses to fly for longer than 30s? Also isValid() checks if the snowball exists in a loaded chunk.
public static boolean hasExpired(Player player) {
Instant expired = Instant.ofEpochMilli(player.getPersistentDataContainer().get(PlayerJoined.key, PersistentDataType.LONG));
return Instant.now().isAfter(expired);
}
yes
but this exact code dosent work tho
Instant.now().isAfter(expired)
if expired is in teh past that will return true... I th9ink
But have the 10 hours passed since then?
check the javadoc on isAfter
you lose 1 hour if you die and gain one if you kill
Ah, show that code then
public class PlayerDeath implements Listener {
@EventHandler
public void PlayerDeathEvent(PlayerDeathEvent event) {
Player p = event.getEntity();
subtractTime(p, 1);
p.sendMessage(DIALOG+ ChatColor.DARK_RED +"You Died... this means you have lost one hour of your life!");
Entity n = event.getEntity().getKiller();
if (n instanceof Player){
Player np = (Player) n;
addTime(np,1);
np.sendMessage(DIALOG+ChatColor.GREEN + "You killed someone, you get 1 Hour!");
}
}
}
And the subtractTime and addTime methods?
oh, this wont solve your issue but you can say instanceof Player np, which saves you from typing a cast manually.
unless you are on java 1.ancient ig
I guess it is the same methods as sent by ElgarL?
public static void addTime(Player player, long hours) {
PersistentDataContainer pdc = player.getPersistentDataContainer();
Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
expires = expires.plus(hours, ChronoUnit.HOURS);
pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
}
/**
* Subtract time from a Players Deathclock.
*
* @param player the Player to remove time from.
* @param hours the number of hours to remove.
*/
public static void subtractTime(Player player, long hours) {
PersistentDataContainer pdc = player.getPersistentDataContainer();
Instant expires = Instant.ofEpochMilli(pdc.getOrDefault(key, PersistentDataType.LONG, Instant.now().toEpochMilli()));
expires = expires.minus(hours, ChronoUnit.HOURS);
pdc.set(key, PersistentDataType.LONG, expires.toEpochMilli());
}
noone, get verified
?img
Not verified? Upload screenshots here: https://prnt.sc/
?img
Not verified? Upload screenshots here: https://prnt.sc/
Yes
Did you check whether the player that died and the killer are the same? If so that might explain why time does not change
why would I need to do that
the problem is
I suppose to have 3 lores
but I only have 1
anyone know how to resolve this issue ?
./kill maybe
it is there
This is not spigot plugin development related, is it ?
@lavish vortex
Well my reasoning is that if somehow suicide makes killer = player that died the timer would not reset
thats not java so idk what it is
kk
it works
You should probably ask in #help-server if it's a command
/kill works
Try using \n instead of ;
Thats a good point, but his timer would not display as -28 minutes
public void PlayerDeathEvent(PlayerDeathEvent event) {
Player p = event.getEntity();
subtractTime(p, 1);
p.sendMessage(DIALOG+ ChatColor.DARK_RED +"You Died... this means you have lost one hour of your life!");
Entity n = event.getEntity().getKiller();
if (n instanceof Player){
Player np = (Player) n;
if(!np.equals(p)) {
addTime(np, 1);
np.sendMessage(DIALOG + ChatColor.GREEN + "You killed someone, you get 1 Hour!");
}
}
}
I fixed it
Well then the only possible cause that remains is that you fetch and set the death clock under different namespaced keys
the suicide problem
possible
But uh, in that case it should blow up somewhere else in the pipeline
This is why ALL clock methods shoudl be in a single class, with the NamespacedKey
So to be honest I am at a loss.
all of em are
NOT in your Listner
Even the #hasExpired method?
in your code you access the adTime methods etc non static
Because the #hasExpired method seems to reference PlayerJoined.key which may be different
they can;t be in their own class if you access them as local methods
would the two usages of creating a nnamespaced key variable be conflicting
you shoudl not be creating two keys
public class PlayerJoined implements Listener {
public static NamespacedKey key = new NamespacedKey(JavaPlugin.getProvidingPlugin(Main.class), "death_clock");
public class DeathClockUtils {
private static NamespacedKey key = new NamespacedKey(JavaPlugin.getProvidingPlugin(Main.class), "death_clock");
but no they shoudl not conflict
like this
Assuming that the plugin is the same, no - there should be no issues.
do not have anythign to do with the clock outside of the DeathClockUtils
PlayerJoined does not need the key
thats the problem maybe
ctrl shift f
I removed it
should work maybe
I removed it
now its doing this
we are using playerjoinds key
Using spigot or paper api?
I wouldn't say its deprecated in spigot
For latter it is something like NamedTextColor.BLUE
But uh, you'd need to use Components and all that jazz too
Yes but via Component.text(string, NamedTextColor.BLUE) (without any warranty of any kind) it should work
You need to start listening. NOTHING for the clock out side the util class
It has been almost a year since I last touched adventure so there might be slight changes you'd need to do as I could misremember stuff
all my function is in the util class
only 1 key, in the same class
yes fixed
ElgarL hi bro can u help me?
only in utils
or IK_Knight ?
what u tryna do
bro i wanna prevent tripwire rotations
i see
declaration: package: org.bukkit.material, class: Tripwire
god don;t use block physics
What exactly are you trying to do with a tripwire?
i wanna do custom plants and blocks with tripwire statements
i can set custom textures for tripwire states
hey there, whats the best practice to register a creaturespawn event listener before the dependency plugin's creaturespawn event listener?
so i do custom items and when click block set custom statated tripwires
but i put one more tripwire to near my main tripwire states changing
u mean use blockplace event _?
and control physics with update ?
yes, listen to blockPlace, if it's a tripwire, cancel the event and Block#setType(Material.TRIPWIRE, false)
alright i try i need afk brb
LESGOOO
nice
is there a way I could give someone time
you have to kick the player as well as ban. adding a ban will not kick them
thats the depricated version of it
no
they fixed it and made it better
oh but its working
are there any events for event registration?
only for services
why do I get a NoClassDefFoundError when using this api?
is it even on the classpath?
[00:10:44 WARN]: [Rpg] Plugin Rpg v1.0 generated an exception while executing task 24
java.lang.NoClassDefFoundError: xyz/xenondevs/particle/ParticleEffect
at de.rpg.classes.MageClass$3.run(MageClass.java:191) ~[?:?]
at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:52) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_372-372]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_372-372]
at java.lang.Thread.run(Thread.java:750) [?:1.8.0_372-372]
Or better said, did you install the lib as a plugin?
If not, did you at least shade it?
1.12.1 spigot jar? That is ambitious.
got both in the plugins folder
it's an older project
NoClassDefFoundError is usually preceeded by a ClassNotFoundException. Are there any other exceptions?
[00:17:53 ERROR]: Could not load 'plugins\particle-1.8.4.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:152) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:308) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:753) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.Bukkit.reload(Bukkit.java:525) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:651) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:637) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at java.lang.Thread.run(Thread.java:750) [?:1.8.0_372-372]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 14 more
reload
the api came without a plugin.yml, so this error is there as well.
it just means you gotta shade it
what do u mean with that xD
?shade
I was hoping 🙂
add maven shade plugin to your pom and set the dependency to compile scope
or
if using post 1.16.5 you can use the libraries entry in plugin.yml
how would that look like
Vector velocity = endVector.subtract(boss.getLocation().toVector());
does anyone know why this line changes the value of endVector
endVector is a bukkit vector
boss is an entity
for some reason this line changes the value of endVector
endVector is mutable
what does that mean
?google spigot maven shade pom
Google your question before asking it:
https://www.google.com/
msg choco (probably)
sry for ping i back and i tried
@EventHandler
public void onPlace(BlockPlaceEvent e) {
Block block = e.getBlockPlaced();
if (block.getType() == Material.TRIPWIRE) {
block.setType(Material.TRIPWIRE, false);
}
}```
this
cancel the event too
if it still doesn;t work you will have to setType 1 tick later
alright
as BlockPlace is a strange event. It actually fires after teh block has changed and undoes the changes if cancelled
Bukkit.getScheduler().runTask(()-> { block.setType(Material.TRIPWIRE, false) }, plugin);
;-;
Plugin plugin;
@EventHandler
public void onPlace(BlockPlaceEvent e) {
Block block = e.getBlockPlaced();
if (block.getType() == Material.TRIPWIRE) {
e.setCancelled(true);
new BukkitRunnable(){
@Override
public void run(){
block.setType(Material.TRIPWIRE, false);
}
}.runTaskTimer(plugin, 1, 1);
}
}```
i did this is wrong ?
not a timer
is cooldown ?
Have you ever initialized that plugin
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
does anybody know what is the statistic that contains all player travelled distance
step one or something
but it's like walk distancce + sprintr distance + swam distans etcc?
or should i add all together
I believe step one is all distance
okay i will check ty
but there's no step one, only WALK_ONE
could be
where can i learn this means ? can u give me doc ?
i did btw thx
I've been struggling since morning
Bukkit.getScheduler() docs it that what u need i think
?scheduling
?jd-s
[00:50:39 WARN]: [Rpg] Task #67 for Rpg v1.0 generated an exception
java.lang.IllegalStateException: Not scheduled yet
at org.bukkit.scheduler.BukkitRunnable.checkScheduled(BukkitRunnable.java:149) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.scheduler.BukkitRunnable.getTaskId(BukkitRunnable.java:143) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at de.rpg.classes.PriestClass$1.run(PriestClass.java:61) ~[?:?]
at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:739) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at java.lang.Thread.run(Thread.java:750) [?:1.8.0_372-372]
public void shootParticlev2(Player player, Particle particle) {
Location location = player.getEyeLocation();
Vector direction = location.getDirection();
Snowball snowball = player.launchProjectile(Snowball.class, direction);
snowball.setShooter(player);
snowball.setSilent(true);
snowball.setBounce(false);
int taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(Rpg.getInstance(), new BukkitRunnable() {
@Override
public void run() {
if(!player.getWorld().getEntities().contains(snowball)) {
snowball.remove();
player.sendMessage("§aSnowball landed");
/*for(BukkitTask task : Bukkit.getScheduler().getPendingTasks()) {
if(task.getTaskId() == this.getTaskId()) {
task.cancel();
}
}*/
//this.cancel();
/*if(Bukkit.getScheduler().isCurrentlyRunning(this.getTaskId())) {
Bukkit.getScheduler().cancelTask(this.getTaskId());
}*/
} else {
player.playEffect(snowball.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
}
}
}, 1, 1);
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(snowball.getEntityId());
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
Why can't I cancel that task?
All 3 ways which are in comment snippet don't work.
for the fix this i need use blockphysics event ?
works when block place but other features broke this
what features?
walk or ...
thats interact event
cancel the interact event if the block is tripwire
that looked like a normal block place to me
idk what first tripwire state changed
shoudl not happen if you cancel and manually place
public void onPlace(BlockPlaceEvent e) {
Block block = e.getBlockPlaced();
if (block.getType() == Material.TRIPWIRE) {
e.setCancelled(true);
Bukkit.getScheduler().r(plugin, () -> block.setType(Material.TRIPWIRE, false));
}
}```
no annotation?
i already cancelled
add a sysout to make sure teh code is running
Got a solution...
new BukkitRunnable()
{
public void run()
{
if(!player.getWorld().getEntities().contains(snowball)) {
snowball.remove();
this.cancel();
} else {
player.playEffect(snowball.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
}
}
}.runTaskTimer(Rpg.getInstance(), 1, 1);
holy sh1t
wait i upload video
if i right click the broken tripwire
fixing
Is there any way to overcome this?
like renovation
you need to cancel interact events with the wires
no bro
i mean tripwire shows like but actually tripwire state not changed this minecraft bug
just a client display bug then
i will explain u with 1 more video
yes
see ?
actually u was understand
yep
how do i prevent this?
probably can't
;-;
he does
but i was saw at some server
it's a client side bug. the block hasn;t actually changed, just th eclient predictive messing up
he's placing without physics so it never connects
oh, then send a update
can i detect block around blocks and update to blocks clone ?
I am thinking you probably could use sendblockchange in the api
to make the client correct itself
the issue is knowing which block gets messed up
just send them all
we can't diagnose problems in regards to other implementations
yes
and therefore we only concern ourselves here in regards to spigot
Its more likely just client. Nothign to do with server
can i do this ?
when blockplace or break can i detect around blocks and set clones to block locations ?=
not sure what you mean by clones
when you break you should detect it's a trip wire, cancel the event and break it your self
clone method
so again no physics
actually i do this with custom items so i don't use string for place tripwire
maybe this will fix
place, interact and break you should be cancelling all and doing yourself.
yes i do with custom item
i have question for you guys 😄
sry about that
how can i check block faces ? but all faces not only 1
getRelative()
i explain with video
BlockFace.getValues().forEach( face -> { if (face.isCardinal()) { code } } )
this is a paper i put everywhere
oke i do tomorrow this
but i have 1 question more
:DDDD
sry 😄
You may have to Arrays.stream(), depending on what getValues returns
but i wonder
i will do custom leaves with leaves distance
u guys know leaves distance ?
distance from log
this leaves is azalea leaves
if i cancel blockphysics event for this leave
works leave distances not changing
but leaves isnt does not spill
can i do this if leaves far from wood i will add scheduler and remove this leaves?
?paste
is their an easy way to remove the 0 that shows before the string and if u say some dumb shit about formatting i do not care as the sting works how i want it i just dont want the zero before it and i think im overlooking something
/giveTime <Player> <Time - Hours>
I want to use player which would be arg[1] im guessing
myb
arg[0]
0
I see
Hello,
I need some help from someone who knows NMS quite well. So I've got around 3 year old plugin which was written for me but I've never got the source code for it. Now I'm trying to modify the nms package and classes within it (it's the last thing to do actually) but my knowledge about multi-version is really poor, especially when it comes to NMS. I'm looking for someone who could modify my code and help me out with it overal (NMS).
Thanks!
Interface:
https://pastebin.com/kgnCmSqz
One of the classes (in this case it's the newest version but I can't figure out imports etc. (I installed buildtools for 1.19.4):
https://pastebin.com/rvtxv8Fd
if (sender instanceof ConsoleCommandSender) {
sender.sendMessage(DIALOG + ChatColor.DARK_RED + "You cannot run this command from the console! Bozo admin get dunked on");
return false;
}
Player player = (Player) sender;
if (args.length == 0) {
player.sendMessage(DIALOG + ChatColor.RED + "Wrong Usage! Do /giveTime <Player> <Time - Hours>");
return true;
}
if (args.length == 1) {
player.sendMessage(DIALOG + ChatColor.RED + "Wrong Usage! Do /giveTime <Player> <Time - Hours>");
return true;
}
// create code to give player time in hours using addTime method from DeathClockUtils
if (args.length == 2){
Player target = player.getServer().getPlayer(args[0]);
// player dose not have to be online
if (target == null) {
player.sendMessage(DIALOG + ChatColor.RED + "Player not found!");
return true;
}
Long Frt = Instant.now().until(getTime(player), ChronoUnit.MILLIS);
long h = Frt / 3600000;
if (h>=Long.parseLong(args[1])){
subtractTime(player, Long.parseLong(args[1]));
addTime(target, Long.parseLong(args[1]));
player.sendMessage(DIALOG + ChatColor.GREEN + "You have given " + target.getName() + " " + args[1] + " hours of time!");
target.sendMessage(DIALOG + ChatColor.GREEN + "You have been given " + args[1] + " hours of time by " + player.getName());
return true;
} else {
player.sendMessage(DIALOG + ChatColor.RED + "You do not have enough time to give!");
return true;
}
}
player.sendMessage(DIALOG + ChatColor.DARK_RED + "Some wierd error happened, I have no idea how to fix it either lmao do /giveTime <Player> Time");
return false;
Does this look good
even if theyre banned?
Player only exist if online
instead of banning you shoul dconsider forcing them into spectator
good idea
but thats not doing any good
they will be able to tell people where bases are and stuff
can I kick them
so they relog
force them into another world then
and get kicked again
this only works if they are online
is their an easy way to remove the 0 that shows before the string and if u say some dumb shit about formatting i do not care as the sting works how i want it i just dont want the zero before it and i think im overlooking something
You know, I think everything except the hologram creation has been added to the API.
Player#sendTitle() <--- Can be used for titles and subtitles.
Player#sendBlockChange() <--- You can include a Collection<BlockState> to cover large areas.
Player#setWorldBorder() <--- Only visible to that player.
Are you sure you want to continue using NMS for all of that? Cause if you do, you never really specified your issue that you have with it.
Well, there is Player#showEntity(), but I think that relies on real entities and not packet based ones. So you could just create a new armorstand and pass it through there.
Also, when it comes to holograms, we now have Text Display entities, so maybe there is something that could be added.
how would I create a void world and load it and then make a player teleport there
You're dealing with scoreboards, any existing data may have numbers in front because the way the scoreboard calculates order is done alphabetically. You also never showed a screenshot of the output you are dealing with.
Does someone know of a good scoreboard api for 1.19?
I like FastBoard, but other than that just the Normal one is fine
it was improved recently
finally hit my 300 line mark
Does anyone know this?
You need to create your own chunk generator and then create the new world using it. Then you can teleport your player after it's created.
banana
oop too much
oh well
public class WithdrawBalance implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player player) {
// Get the withdrawal amount from args[0] (assuming it's the first argument)
if (args.length > 0) {
try {
int withdrawalAmount = Integer.parseInt(args[0]);
Material itemMaterial;
String nbt = "";
if (withdrawalAmount >= 100 && withdrawalAmount <= 999) {
itemMaterial = Material.IRON_INGOT;
nbt = "Iron";
} else if (withdrawalAmount >= 1000 && withdrawalAmount <= 4999) {
itemMaterial = Material.GOLD_INGOT;
nbt = "Gold";
} else if (withdrawalAmount >= 5000) {
itemMaterial = Material.DIAMOND;
nbt = "Diamond";
} else {
player.sendMessage(formatMessage("&7Invalid withdrawal amount."));
return true;
}
ItemStack item = new ItemStack(itemMaterial);
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(nbt + " Withdrawal");
itemMeta.setLore(Arrays.asList(formatMessage("&7Withdrawal Amount: &a" + withdrawalAmount)));
itemMeta.getPersistentDataContainer().set(KeyConstants.WITHDRAWAL_AMOUNT_KEY, PersistentDataType.INTEGER, withdrawalAmount);
item.setItemMeta(itemMeta);
player.getInventory().addItem(item);
player.sendMessage(formatMessage("&aWithdrawal successful!"));
} catch (NumberFormatException e) {
player.sendMessage(formatMessage("&cInvalid withdrawal amount."));
}
} else {
player.sendMessage(formatMessage("&7Usage: /withdraw &a<amount>"));
}
} else {
sender.sendMessage(formatMessage("This command can only be executed by a player."));
}
return true;
}
}```
?paste exists for a reason
some part about the item meta here causes an issue
somebody right above me pasted one of the same size, so i figured i could
They got ignored though. lol
Look into guard clauses, your nested code makes it incredibly difficult to read.
What's your actual issue though?
it's my first so it's not exactly the best yet
the only issue I get in game is unhandled exception
the first part runs fine when the amount is under 100
I figure it's something to do with the PDC
What exception
it doesn't say
Do you have any sort of stacktrace?
only unhandled exception when the command is run
Can you show it
I can't show it, can't attach images
?img
Not verified? Upload screenshots here: https://prnt.sc/
Is that the entire thing or is there more?
How can I get the loc at where a player is looking? It has to be on a block...
there is more but it doesn't look like it'll help
Player#getTargetBlock()
it's hard to show all of this on feather
I already found this, but it requires 2 parameters...
Ok, what's the problem with that?
You could try using Player#getTargetBlockExact() as it only has one parameter. Although it may or may not ignore fluids. Hence the second method.
There is no method called like that..
Unless you are using an ancient version of the game, there is.
My compiler can't find one (no auto complete) 😉
What version of the API are you using?
So basically the first parameter can be null / empty or like an empty object and the 2nd one is the range. So if a player is targetting a block having a distance of 50+ blocks, and you insert in 2nd parameter an int of 20, the block will be empty?
1.12.1
What hold up did you get what to do from the paper dev help folk and then, when you hit an error , come to the spiggot discord?
Ngl I respect the chad play 😂😎
The point of that first parameter is to list the blocks you want to treat as transparent. Meaning ones that you want to ignore. Could be useful if you want to check if the player is looking at a block through a glass block or smth.
Or maybe through things like flowers or grass.
You can paste the entire stacktrace.
?paste
that's not necessary.
Location destination = p.getTargetBlock(new HashSet<>(), 20).getLocation();
p.teleport(destination);
I came up with this now..
Exact was added in 1.13.2
Can't really help you otherwise as your code looks fine, but without the full stacktrace, it's hard to pin down why you are getting the errors.
[03:11:55 ERROR]: Error occurred while enabling Rpg v1.0 (Is it up to date?)
java.lang.NullPointerException: null
at de.rpg.main.Rpg.loadCommands(Rpg.java:67) ~[?:?]
at de.rpg.main.Rpg.onEnable(Rpg.java:35) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:402) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:384) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:333) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:755) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.Bukkit.reload(Bukkit.java:525) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:651) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:637) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
at java.lang.Thread.run(Thread.java:750) [?:1.8.0_372-372]
Bukkit.getServer().getPluginCommand("trickster").setExecutor(new TricksterCommand(this));
🙃
This line of code is throwing an error
I wonder if maybe we can throw a more explicit exception here instead of returning null
The amount of times I see beginners fuck this up is crazy
how do I create a world and load it
In my plugin, could I have different package that handle different things have their own listeners? for example I if I have a lobby package with its own listeners and it checks to see if it applies to that package. Or is it better to just have one listener, and have some sort of way to give that data to the package that is going to be using it?
and then teleport a certain player there
p.teleport(Location location);
^^^
You're better off using this.getCommand() by the way
Does some sanity checks to ensure it's actually your plugin's command
Not really
What? Can you please elaborate more on that?
JavaPlugin#getCommand() calls Server#getPluginCommand() but ensures the string is lowercased, fallsback to namespaced commands if it's overridden by another plugin, and ensures that the command you get was actually registered by your plugin
Doesn't work by the way @kind hatch
Teleports me exactly at the same loc as the player has already been
Ok, so I have a minigame server that I am working on, where there are multiple different I guess zones that a player could be in, a lobby, or a minigame. I was thinking about making it so there was one player listener that passed down events to the code controlling the different zones (lobby or minigame) But I was wondering if instead each zone could just have it's own events registered and handle them internaly. (would make splitting it into seperate plugins easier later if I wanted to do that).
Well, I don't use those methods too often, but I think there's limitations to them. IIRC, #getTargetBlock() is limited to what you can reach, and #getTargetBlockExact() is unrestricted. (Obf if you are looking at the sky in the distance, you won't go anywhere.)
Could you use a raytrace?
how to force gamemode on a player
Player#setGamemode()?
thanks