#help-development
1 messages · Page 1853 of 1
can someone help?
What do you mean it’s not banning them
its not banning him
he vcan join back
and its not doing anyhting
when i trxy to do it
i dont understand im using a command block not coding a plugin
Ah
Well, #help-server
Also no, the plugin would have to support it as far as I know
agh
Player#setBanned()
That’s not a thing, at least not in 1.18
Huh, it isn’t a thing, could’ve swore it was
hmm,
Bukkit.getBanList()
only takes Type.NAME and Type.IP
You might be able to do something like
Bukkit.getServer().getBannedPlayers().add(Bukkit.getOfflinePlayer(player.getUniqueId()));
player.kickPlayer("You are banned");
Not sure if it'll work though
@rotund prawn
declaration: package: org.bukkit, interface: BanList
@NotNull
String target,
declaration: package: org.bukkit, interface: BanList
and the only way to get the banlist is by doing
Bukkit.getBanList(Type.NAME)
or
Bukkit.getBanList(Type.IP)
Which is fine if the player is online since their name won't change.
If they're offline you're going to have to do a name lookup with Mojang's servers
So what's the issue?
I guess nothing. idk why there's not a UUID Type
declaration: package: org.bukkit.event.player, class: PlayerLoginEvent
Just use that
The api has a method for getting ips
That's fine if you want to IP ban someone
I think you might be able to stick the uuid in as a string and have it work
Why wouldn't you ip ban?
Bans are weird
Some people have siblings
Does an IP ban also player ban? Or can I pull out my phone hotspot and jump right back on with my same account?
nope, doesnt work
Maybe, I've literally never tried playing with bans
You could always do old reliable
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ban " + player.getName() + " You are banned!");
There has to be a better way than passing a player name as the argument, but I'm loading into a Tarkov raid rn
Not a fan of executing console commands in a plugin but maybe it would work
getting errors
Same, but it works and I'm starting a raid
doestn owrk
Bukkit, not Plugin
You can easily make your own system using the login event and a file to save uuids
The name ban list is the same as the uuid ban list
Yeah, but why reinvent the wheel when the ban file already does that
still doestn work
So shoving a uuid in as a string works
So the Argument* will take UUID and not name?
API is still Type.NAME
Yeah you don't have to use spigot/minecrafts banning system
Or do you need to shove the name in still
Yes, should
What’s spigots thoughts on duplicate stuff with better names
IE adding Type.UUID that just redirects to Type.NAME
would be nice to be more descriptive in code
player still seems vague enough to mean UUID or Name
Renaming is a breaking change
so its just Type.PLAYER and Type.IP
Spigot avoids breaking changes
Be the change you wish to see in the world
Oh yeah
ezpz PR
Can’t tell if that’s an invite to PR a breaking change :p
then make it not breaking
Just add another type that then calls NAME
Or you know just add a ban method to the player class so you don't have to deal with all that
What if player is offline
Yeah that’s another option
does anyone know how to prevent the timer becoming negative i tried doing ```
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
public void run() {
countdown --; //Taking away 1 from countdown every 1 second
final Score score = plugin.o.getScore(ChatColor.of("#fe6f5e") + "Time Left:"); //Making a offline player called "Time:" with a green name and adding it to the scoreboard
score.setScore(countdown); //Making it so after "Time:" it displays the int countdown(So how long it has left in seconds.)
if(countdown == 0) {
for(Player p : Bukkit.getOnlinePlayers()) {
p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
if(countdown == -1) {
countdown = countdown - countdown + 20;
p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
}
//plugin.getServer().getScheduler().cancelTasks(plugin);
}
```
If you don’t want to PR it, at least consider making a Jira issue
looks good to me
Im not sure what the problem is then.
@foggy estuary if countdown is less than zero
^
i tried that
countdown = countdown - countdown + 20;
p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
}```
is what i did
i can also do < 0
but it doesnt change it
Change it to <=
ok
Anyone know how to detect if a player left clicks twice?
@snow stratus found the problem. it was a nullpointerexpection
@next zinc store a bool for first click second click, depends on what event
Im using PlayerInteractEvent
That works, though for some reason the countdown becomes x2 speed
and Ill try that and see how it works
hey guys, i tried to make a class configurationserializable, but it's not working very well
it gives a noclassdeffound error before i even load anything
My countdown always counts twice as fast.
Thus, not 60, 59, 58 ... but 60, 58, 56.
It happens after i do this if(countdown <= 0) { countdown = countdown - countdown + 20; for(Player p : Bukkit.getOnlinePlayers()) { p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
What have I done wrong?
and the noclassdeffound error is for a class that does exist
and can be used
what r u tryna do
also
maybe just post the entire snippet
this
and not just parts
countdown -= 20 :p
?paste btw
The other guy told me to do <= so i listened
so you don't know for yourself what you're doing?
No i needed help with that
in the check where you check if it is 0, is where you should be resetting it
you shouldn't be checking if it is -1 because you shouldn't be allowing it to get that far
I know i changed it to 0 after
countdown = countdown -= countdown + 20;
this is very redundant
using -= is the same as doing countdown = countdown - (number)
so you can just collapse that down into a single =
countdown -= 20
https://paste.md-5.net/kiwuzegifo.cs#L46
on this line, we don't need to check if it is less than 0. If you really want to check if it is less than zero it should be an error check because you only care if it hits 0
the error check if it runs means something went really wrong XD
anyways once it hits 0, at the end of everything you want to do on 0, should be where it resets the timer or whatever else
<= means if it is less than or equal to
since it is a loop we shouldn't have a scenario where 0 gets skipped and now at -1 unless again something went really wrong
from what is this:
Trying to mark a block for PostProcessing @ MutableBlockPosition{x=380, y=0, z=327}, but this operation is not supported.
while generating structures like villages/swamphut/stronghold ?
Is there a way to freeze Bukkit.getServerId() so it doesn't change?
store it somewhere that doesnt change 😎
is there an onChat event or some
theres AsyncPlayerChatEvent
oh thx
*PlayerChatEvent
doesnt that actually wrap back around to the Async counterpart
yes and no, it is for things that can't be async
even then you can make them sync by running bukkitschedular ^^
public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
ItemMeta meta = item.getItemMeta();
if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if (p.getInventory().getItemInMainHand().equals(Material.PLAYER_HEAD)) {
assert meta != null;
if (meta.getDisplayName().contains("Infinity Gauntlet")) {
e.setCancelled(true);
} else if (p.getInventory().getItemInOffHand().equals(Material.PLAYER_HEAD)) {
if (meta.getDisplayName().contains("Infinity Gauntlet")) {
e.setCancelled(true);
}
}
}
}
}
}```
Hey I am trying to deny player head placement of a specific item, but it says
"'equals' between objects of inconvertible types 'ItemStack' and 'Material'"
I'm pretty new to Java so if my code looks bad, you know why
not necessarily no
if something is sync in the implementation your async scheduler isn't going to magically make it async
nono...
in asyncplayerchatevent
if you need to place blocks for example ... you can call a BukkitSchedular
Ah ok
I have a bit of a dilemma, a while back I added this method as a PR https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Bukkit.html#craftItem(org.bukkit.inventory.ItemStack[],org.bukkit.World,org.bukkit.entity.Player) I use it to add autocrafting to my plugin, but I've ran into an issue when trying to do the autocrafting for offline players, since it obviously takes a Player instance and I don't have that whilst the player is Offline. The player instance is used to send a PrepareItemCraftEvent. I'm thinking I'm going to need another method that just crafts vanilla recipes without the PrepareItemCraftEvent
declaration: package: org.bukkit, class: Bukkit
You could make a fake player object
you don't need the object to make it appear they are online, you just need to construct enough of the player object to satisfy what you need 😛
How can you craft offline players???
What's the format for a clickable link again
however in terms of a PR, not sure why it would be a useful thing in the base code
2 wood, a player head, and an iron chestplate
^^
What do you mean by craft offline players? The original method crafts an item as if it were the player, I.e using their inventory, the PrepareItemCraftEvent manipulates the result for custom recipes etc. Obviously this isn't possible for an offline player.
That's actually a good idea tbf, I did wonder about that, there will just be a shit load of empty methods
of course, didn't say there won't be problems or anything just in terms of what the server cares about for a Player object it isn't hard to create one 😛
and beware of any plugin which listens to the craft event and wants to do something with the player
^
So my plugin allows you to create auto-crafting tables using chests above a crafting table as the ingredients, and you set your recipe in the table. It then runs even if the player is offline etc
seems player is pointless in that scenario then
wouldnt 'public static ItemStack craftItem(@NotNull ItemStack[] craftingMatrix)' be sufficient for you
well that'll never work
.
look at ComponentBuilder, should be obvious
this is a development channel
Yeah exactly, it just sucks that I will lose the custom PrepareItemCraftEvent recipes that some plugins use. (It is possible to create Recipes properly if I remember though right?)
oh
yes there is addRecipe
Okay so if anyone complains I can just tell them to use the API correctly then 😄
the craftItem() method is probably going to work best then
those questions seem unrelated, why do you say or
Sorry, didn't know that existed so no it wasn't obvious
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@sullen marlin what would your recommendation be for replacing NMS for NBTTagCompound without reliance on PDC?
either i can use the chat event and see if the first char is a / or if there is a cmd event already
..what
why
use pdc
Why did you reply to me
PlayerCommandPreprocessEvent
PDC Doesn't stretch over to all the items I want use, I want to remove reliance upon NMS
what
I can do that, but how do i just make it restart if i do /start again
make it restart countdown from 20 again
manually
I know this isn't quite "spigot", but can anyone help me with a Jitse NPCLib issue? If an NPC is created while a player is offline, but then is shown for that player when they join, the NPC won't show with no error. link: https://github.com/JitseB/NPCLib
you can take a look at how it creates packets and stuff there if you're not familiar with it
I've had a brain fart for a month
I can’t find anything about links in there
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
?jd
Also @sullen marlin when I'm running CraftBukkit inside IntelliJ I always get a crash because Bukkit.getConsoleSender() returns null but is marked as @NotNull, changing it to Nullable fixes the issue for me 🤷♂️
I'm not sure why running in IntelliJ causes it to return Null though, but it also means that the Null check isn't needed if it's supposed to be NotNull 😄
Is this the right place to ask for BossShopPro help?
Nope, probably best to ask on their GitHub. Can't seem to find a discord for them at a glance: https://github.com/Blackixx/BossShopPro/issues
Okay thank you:)
This is a beautiful message
Sorry if this is "so obvious" but how would I sent it with broadcastMessage?
broadcastMessage does not support components
so how on earth do so many servers use links
declaration: package: org.bukkit, interface: Server, class: Spigot
The Spigot class 
editor is telling me broadcast is 2 strings not components
my server object is an org.bukkit.Server
.spigot().broadcast
Huh, why did I assume that didn't exist
I guess because .spigot stuff is still kinda weird :p
Has deprecating .spigot and merging it into bukkit ever been considered?
its complicated, and also a bit pointless
because if you want to support any older version you'll just use the old method anyway
I forget there are spigot additions since I just depend on Bukkit
which hasnt been supported for a long time now
True
we dont even publish bukkit to the maven repo since 1.15
.spigot() stuff comes from the days when spigot and bukkit had different maintainers :p
Maybe I am using spigot then
I think this was also shortly after dinosaurs went extinct
Ah yeah <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.14.4-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency>
When I run a plugin it gives me this error in server console
[22:15:55 ERROR]: Could not load 'plugins/GrinchSimulator.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `ro.Fr33styler.GrinchSimulator.Main'
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:75) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:419) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:322) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1233) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:322) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
at java.lang.Thread.run(Thread.java:831) ~[?:?]
Caused by: java.lang.ClassNotFoundException: ro.Fr33styler.GrinchSimulator.Main
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:153) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:105) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:466) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:73) ~[patched_1.17.1.jar:git-Purpur-"4ff0630"]
... 8 more
org.bukkit.plugin.InvalidPluginException: Cannot find main class ro.Fr33styler.GrinchSimulator.Main
youre not running spigot
your missing your main method?
Also
smth like that
patched_1.17.1.jar:git-Purpur
bla bla bla
I am running purpur 1.17
Man as a plugin dev all the derivatives of Bukkit really cause a lot of headaches, so many times I've had to completely change an event because Paper disables it or something similar 😄
for some reason i cant figure out a way to cound this array to display on the tab footer, is there a better way of doing this?
sorry for cutting in
A List isn't an array use .size()
u can just call .size from getOnlinePlayers
It's not? That is what I downloaded
yes well I was coding the plugin for spigot
does the class exist?
You may want to update that as it says HoverEvent(Action, BaseComponent) is depreciated, and (Action, String) doesn't exist, what do I use then?
is the package correct?
it might deprecated for being new, like the hide/showPlayer stuff
So if it's depreciated what am I meant to use?
?paste
the components
Read the javadocs
what
They tell you why something is deprecated
i can’t though, it says "JavaScript is disabled" when it isn't
its like how Player#showPlayer and hidePlayer are deprecated, but theyre new methods
On bungee ones, not the spigot ones
so it could be something like that
now send ur main plugin class
hidePlayer and showPlayer aren't deprecated when you use the correct one
?paste
I'm not using that though
nop
are the right ones not the currently deprecated ones?
declaration: package: org.bukkit.entity, interface: Player
the package is wrong @half spoke
package ro.fr33styler.grinch;
vs
ro.Fr33styler.GrinchSimulator.Main
does this make sense?
yes
oh it takes a plugin argument now hmm
So what am I meant to use
if the constructor HoverEvent(HoverEvent.Action, BaseComponent[]) is depreciated and the bungee javadocs don't like any browser I use
look around otherwise mayb some1 else knows ¯_(ツ)_/¯
It's not deprecated
Let me guess, you are using the Paper API
So the ?jd is the wrong link?
as the bungee one there doesn't include hover event at all
But the one you sent does
no its the correct link
?jd
its the bungee chat api
what is a java.lang.NoClassDefFoundError
exactly what it says
and error stating java couldnt the class
java couldnt the class
let me guess. you only set the value once and never update it
classn't
the java classn't
jaclassn't
?paste
How exactly do I even construct Content when it's empty
https://paste.md-5.net/midavuzayu.java anyone know why when the entity is dead the other mob doesnt spawn?
Like I don’t know, a string?
or anything
check the javadocs, Content is an abstract class
it has subclasses, e.g. Text
new Text("string") is a Content
does your code even run to the point where you spawn a ravater?
i put it in the same function that loops the different headers i have set, but i cant call it from the main class now
what is Players? a class?
Hey, I am quite a newbie to MC java development. When building an artifact it builds without faliure. However when I check the directory it is set to there is no jar. Any ideas?
how do you build it? maven?gradle? ...?
I think maven
it's by default in the "target/" directory
just an int
Players is going to be out of scope outside of the run() function so you can't access it?
then you shouldn't call it it "Players" but players
also this ^
create a static variable in your class probably
ugh no not at all
I set it to a folder on my desktop, yet didn't any jars built, Ill grab some screenshots.
why would you want to store the amount of players the server had on startup instead of updating it every second or everytime a player joins leaves?
why don't you just directly use Bukkit.getOnlinePlayers().size()?
no need to cache that in some static variable that you will then have to update everytime
so you set it up in your pom to save it to your desktop?
This, I assumed they needed it for something else
yeah but still, doing "int players = ..." will never update automagically, which is what they are probably expecting^^
oh sorry I meant gradle
where did you set the output path? in your build.gradle file?
Hmm it appears to be empty
if your build.gradle is empty, you probably are not using gradle ^^
if(evok.getHealth() <= 0) {
is this right though?
if it dies
I doubt the damage will ever be 0 when you set it to 749 like one line above
well do you know why once i kill it the ravanger doesnt spawn...?
the if will always be false
y
because 749 is not <= 0
how do i make the other mob spawn once the evok dies
by stopping to set the evoks health to 749 before checking whether it's dead
i dont understand, thats what i did. no?
this wont work either
you probably only run this code once and then ever again, correct?
yea
That won’t work
as I said, it will never update then
The number of players online changes
should i loop it or rerun this function periodically
it's like writing down your age on a piece of paper and then looking at it next year. the number won't have changed unless you write down your new age again
Or placeholder API, it could handle this
how can i declare this to be used in the footer
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.
and about spigot scheduler programming
alr
e.g.
Bukkit.getScheduler().runTaskTimer(yourPlugin, () -> {
// Everything here runs one per second (every 20 ticks)
}, 20L, 20L);
?scheduling
everything inside of that will run once per second
hey, i wanna get into bungee development and i'd need to create multiple instances of the same server and it's pretty annoying that everytime i need to change something in the spigot servers i need to go ahead and copy paste it multiple times. Is there a better way to manage it?
I just have symlinked all my .jars and their configs
what do you mean?
all plugins and their configs aren't actually inside every server's plugins/ folder but inside another folder
and all server's only have "symbolic" links to the actual files
so all servers share the same plugin files
o
Huh
how can you do that?
Does that apply to the plugin data too
on linux: ln -s [target] [linkname]
depends on the plugin and what file. e.g. you can easily symlink WorldEdit's config but you shouldn't also symlink WorldGuards region storage^^
Ahh
e.g. ln -s ~/servers/lobby/plugins/WorldEdit.jar ~/plugins/WorldEdit.jar
Shame,
now WorldEdit is actually at ~/plugins/ instead of inside ~/servers/lobby/plugins
Why can’t I just symlink the world itself :p
and you only have to update one .jar file or config and all servers get the update
dam i need to learn to use bash
java not enough 😔
e.g. if you have 5 servers:
for server in server1 server2 server3 server4 server5; do
ln -s ~/servers/$server/plugins/WorldEdit.jar ~/plugins/WorldEdit.jar
done```
sooo I am experiencing this weird ass thing
new Location(Bukkit.getWorld(a.split(" ")[3]), x, y, z).getBlock().setType(Material.HEAVY_WEIGHTED_PRESSURE_PLATE);
This sets a specific block to iron pressure plate
but it actually doesnt even if i fire this 1000 times
Unless i restart the server
is there a way to make it work by reloading the plugin instead of restarting the whole server? it seems to fire correctly without any errors but it doesnt physically work until server is restarted
i mean in general
recently i've found many cases where i need it
also rn i'm on windows since i'm testing in localhost
I’d love to have a survival setup that is fully synced
But that would not be an easy task
git bash 🙂
you can easily get git bash and learn shell on windows
I use it all the time to do stuff much faster than in explorer
so i can use bash command on windows?
sure
o useful
We bring the awesome Git VCS to Windows
thanks
np 🙂
but of cuurse you won't have ALL the typical linux commands
stuff like find, top, ps, grep is of course included, but you won't find stuff like systemctl
but i could do this
couldn't i
yes on 2 lines though
yup like println
i kinda know the basics because i used to make those shutdown files to mess with my friends
:p
you can also easily do stuff like this
for file in logs/*.gz; do rm logs/$file.gz; done
so it also supports glob expanding (the * thing for files) and much more
np
no
~ is your home path
e.g. /home/mfnalex or C:\Users\mfnalex
the current path is just a dot:
rm -rf . deletes the current directory and all it's contents
and .. is the folder above your current path
~ is just short for $HOME
Wait I can figure this out
It deletes all .gz files in logs
yep
I’m a Linux
?paste
https://paste.md-5.net/oyezajuyuj.java coll do you know why my ravanger and sound arent coming up when evok health is <= 0 ?
Is there any other way to do this? because new HoverEvent(action, componentbuilder) is deprecated:
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Klik hier om te joinen!").color(ChatColor.GOLD).create()));
and can I assign a var to a path so i don't have to keep on copy pasting it?
?jd
I already told you that 20 times: health will never be 0 when you set it to 749 two lines above
yes, use Text content
Oh wow discord butchers that
new Text(new ComponentBuilder(....))
var=some value
echo $var
a easy
Thx md_5!!
oke lemme do some big brain coding
""
if(e.getEntity().hasMetadata("Vin")){
if(ent.isDead()) {``` ok well i did this too and nothing happend
Debug it
what's the pause equivalent of bash
Where does the code stop, add some print statements
sleep
Or attach an actual debugger if you want to be fancy
pause for time or pause for a keypress?
keypress
read
-p switch
read -p "Enter Text: " var puts the entered text into $var
just read simply waits for you to press enter
ok bash weird fr
you can't have spaces before and after the =
Because a bash script is literally a series of lines as you would write into your shell
echo = hi =
for example should print "= hi =" instead of assigning a variable
var = a
it would take arg0 as 'var' and try to find a program calledl 'var' in your path
with = and a as arguments to the program 'var'
Is it possible to give a falling block a name and check if it landed?
a visible name?
yes
oke ima give it a look and stop annoying yall
thanks for the help
not sure about that, just try it, they are regular entities
okay
you're not annoying, just open a thread if you have questions
how do I check if he landed?
if the entity is missing?
Entity#isOnGround
or do you mean when it has turned into a solid block?
oke
if so: Entity#isValid should work
yes
if it's no longer valid, it's either dead or has despawned for other reasons, so that should work
When he fell
yeah as long as it has turned into a solid block, it probably is not valid anymore
so FallingBlock#isValid will be false once it landed
Do you want to code one
how do i stop named entities from being logged in the console on death?
I have alot of named entities and its spamming the console when they die
I don't think you can besides replacing the logger
maybe you can also add a filter to the existing logger
If you aren’t coding it yourself
pizdabol))
This isn’t the right channel
player.sendMessage(TextComponent); is deprecated.
Does someone know how i can convert a ChatComponent into a Component so i can send it non deprecated?
there is no Player#sendMessage(ChatComponent) in spigot
Oh i meant TextComponent
Player.spigot().sendMessage
yeah but they said they use Player so I thought they must be using paper api or sth ^^
Adventure Capitalist worst game ever
Quick question does the PDC Persist between Item and Placed state?
no
blocks do not have a PDC
TextComponent message = new TextComponent(".. .. ..");
TextComponent.fromLegacyText("...");
Did you see this?
Text only extends Content which is no Component
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new ComponentBuilder("Klik hier om te joinen!").color(ChatColor.GOLD).create())));
I used it in my hover event
if you need a PDC for blocks check out my tiny lib https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
and that's deprecated?
what is "message"?
ah a TextComponent I see
and on what are you calling sendMessage on?
Player p = (Player) sender;
TextComponent message = new TextComponent("[FloppieSMP] Klik hier om de discord te joinen!");
message.setColor(ChatColor.GOLD);
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new ComponentBuilder("Klik hier om te joinen!").color(ChatColor.GOLD).create())));
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "discord invite link lol"));
p.sendMessage(message);
Full code
Inb4 paper API
still deprecated
Ah nvm it turns out there is a config option in spigot.yml for named entity logging
no it isn't
@tender shard The blocks I'm using it on stem from TileState
Then you can just use normal pdc
But it won’t automatically transfer when you place an item
Just running into weird issues porting some nms code into PDC items
if it has a PDC it will be consistent, but as said you have to set it yourself to the placed block
Use the BlockPlaceEvent
p.spigot().sendMessage(message);
@tender shard take a poke:
@EventHandler
public void onPlayerPlaceBlock(final BlockPlaceEvent e) {
Player p = e.getPlayer();
if (!(e.getBlock().getState() instanceof TileState))
return;
else {
if (e.getItemInHand().getItemMeta().hasLore()) {
NamespacedKey k = new NamespacedKey(LabToolsPlugin.getPlugin(LabToolsPlugin.class), "cid");
PersistentDataContainer co = e.getItemInHand().getItemMeta().getPersistentDataContainer();
CraftableBlock c = CustomBlocks.get(co.get(k, PersistentDataType.STRING));
String uid = co.get(k, PersistentDataType.STRING);
TileState state = (TileState) e.getBlock().getState();
PersistentDataContainer con = state.getPersistentDataContainer();
con.set(k, PersistentDataType.STRING, uid);
state.update();
c.Place.Run(p, state);
}
}
}
paper!
Wait does it matter or not?
you are using paperAPI, they have everything marked as deprecated, go to paper discord's or stick with what spigot API tells you is deprecated and which isn't
maam this is a spigot discord
yes paper marks 50% of stuff as deprecated
Paper deprecated all bungee component methods
Oh okay thx!!!
of course they will still work, they just want to use their system instead
but since they want to be compatible with spigot, they will never actually remove spigot methods
Pretty sure as I set my item on creation (through crafting, I set the cid (which previously worked in NMS)) on the object but then transfer the pdc state on block place to tilestate
Hard fork™️
I don't think getBLock().getState() will work because the block wasn't placed yet
you have to run it in a task instead
Hmm, it's a pretty weird state tbh I've had it working with NMS
I'm switching out all my NBT Tag compounds to be PDC
@tender shard I'll give it a go
tbh it's still easier to use my library
because you have block PDC's regardless of the block's state
so you can just instantly set a PDC value to the block, regardless of it was already placed or not
I'll defo take a look!
you can just do
PersistentDataContainer pdc = new CustomBlockData(yourBlock, yourPlugin);
then you have a PDC for that block 🙂
I assume it uses chunk pdc
ofc
In the back end
Nice
Ayy awesome
World PDC when
the default world has a PDC
Does it
So NBT
non mojang mapped:
WorldServer fromWorld = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
WorldPersistentData persistentData = fromWorld.getWorldPersistentData()
MinecraftKey key = new MinecraftKey("cuve")
NBTTagCompound storageNBT = new PersistentCommandStorage(persistentData).a(key)
yeah actually just NBT
well but you could also just abuse some spawn chunk's PDC for a world PDC 😄
hi, is the if statement return immediately if the first operand is true? or does it check all the operands before it returns true?
no idea, never did any D:
depends on | or || or & or &&
||
|| = lazy, it stops once the first is not true
It will short circuit
| = continue to check all anyway
I hate using | or & because it always looks like some bash commands
well, ive been getting null errors recently
anddd the only problem i can se is in the if statement
if(object == null || object.someMethod())
can NEVER throw an NPE
unless you run it async and have very bad luck
npe?
nullpointerexception
can easily throw an NPE if modules is null or enableDisable is null
how do I do it?
args.length
oh
Granted that would not be an NPE, but still
yeah it would be ArrayIndexOutOfBounds. Maybe show the actual error you got @gentle oriole
null
then either modules is null or enableDisable is null
yes.
ok so i tested with it a bit (1 am shell o.o) with text files and i couldn't get it to work with symbolic links
Ugh the NBT Tag Data is 10x more versatile than the PDC
So what actually implements PersistentDataHolder? TileStates, Entities, and Chunks?
no. PDC can store ANYTHING
and ItemMeta
when i edit a text file the other one doesn't change if i use -s as an arg
In fact PDC is NBT
Ahh gotcha
It’s just a wrapper
what exactly didn't work?
when i edited a text file the other one didn't change
let me check
while -f worked just fine
But the PDC is rubbish at actually being Persistent, I had NBT Tag Data that could Persist from a precrafted state where as the PDC is wiped upon creation of a new Item on Crafting
Some things simply won't work with symlinks
e.g. vim cannot read symlinked .vimrc configuration files
You can easily copy the data yourself
oh yeah, seems like windows doesn't properly support symlinks then
let's see about hard links
I don’t think NBT is automatically copied when crafting
hard worked
It is in smithing tables though
at least with text files
im still getting null error. ive already changed it to
(args[0].length() != 1 && args[1].length() != 1) || !modules.contains(args[1]) || (!enableDisable.equalsIgnoreCase("enable") && !enableDisable.equalsIgnoreCase("disable"))
@young knoll it's crazy but it did
just use ln without -s
windows doesn't support symbolic links properly
you can create hard links instead
That’s more wrong
yeah sad
ln file1 file2
Drop the indexes, it’s just args.length
works fine
ah
i've added the -f so i don't have to delete the files if i need to rerun it for any reasons
Your hostname is jagermeister
also does it persist through restarts?
That's actually great lol
Any ideas on Persisted Data from a Precrafted to a Crafted State (Without NBT)
you mean just args[0].length()?
No
yes, my servers have organ names instead 😄 kidney, lungs, ...
I UNDERSTAND
Hello, I want to use class from my manager plugin, but it seems like the class has two instances. Anyone knows how to fix this? (I'm sure I'm not shading anything from the manager plugin)
Error:
java.lang.ClassCastException: class ManagerPlugin cannot be cast to class ManagerPlugin (ManagerPlugin is in unnamed module of loader 'Manager.jar' @737ced05; ManagerPlugin is in unnamed module of loader 'plugin_im_usimg_the_api_in.jar' @9f2c1d3)
My code:
(ManagerPlugin) Bukkit.getServer().getPluginManager().getPlugin("ManagerPlugin")
make a static method in your manager plugin main class to get its instance
and call that
I tried that too
show the full stacktrace pls
hm strange
I've abstracted a lot of the item creation process, for example to create a new custom item all I have to do is use this CraftableItem item = new CraftableItem(Material, Name, Lore, UniqueObjID, Material{} Recipe, ExecutionCodeOnUse()) in that same regards previously the NBTTag Data could persist as a part of the metadata container as it was treated as the same, whereas the PDC is not maintained between a precrafted and a crafted state, any suggestions on circumventing this would be bril
its still erroring null...
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String enableDisable = args[0];
String module = args[1];
if (args.length != 2 || !modules.contains(args[1]) || (!enableDisable.equalsIgnoreCase("enable") && !enableDisable.equalsIgnoreCase("disable"))) {
System.out.println(1);
sender.sendMessage("Usage: /" + command.getName() + " [enable|disable|list] " + modules);
return false;
}
Use the craft item event to copy the PDC to the output
show the full stacktrace
so i wanna make my plugin combatible with lands plugin it says to add ```java
private final LandsIntegration landsIntegration;
public IntegrationExample(Plugin yourPlugin) {
// view methods of this class: https://github.com/Angeschossen/LandsAPI/blob/4.8.17/src/main/java/me/angeschossen/lands/api/integration/LandsIntegrator.java
this.landsIntegration = new LandsIntegration(yourPlugin);
}
// just a test
void test(Location location) {
// get a land area from a location
final Area area = landsIntegration.getAreaByLoc(location);
// check is a location claimed
final boolean isClaimed = landsIntegration.isClaimed(location);
}
Hmm I'll take a look
that definitely does not belong to your plugin.yml
thats all i need to add
it says its happening here: String module = args[1];
oh ok
that can't be unless args is null in which case the line above would have already thrown an error
show the full stracktrace pls
?paste
oh btw @misty current when installing git bash, there's an option enable support for real symbolic links
It does inside say array index out of bounds
Alternatively, you could install Linux
I'll change tomorrow
That should have been a reply, blah
C:\ProgramData\Git\config
you can enable it in that file
that's no NPE, that's ArrayOutOfBounds because you only have 1 argument instead of 2
i dont have any arguments?
Yeah
i only did /ad
alternatively, u could install Linux
you do, otherwise args[0] would throw the exception already
It does?
How can i send TextComponent with ClickEvent with the MessageRaw Channel? I dont get it
It says index 0 out of bounds for length 0
i dontttt????
sure, /command returns an array of length 0
so what's "enableDisable" then?`...
its either enable|disable
but i didnt put anything in there when executing the command
so you have an argument
ah yes I see, this time the error was thrown in the line where you do enableDisable = args[0]
because you access the first element of the array (args[0]) although there is no first element
There is no spoon
check the length of the array before accessing it's contents
god imagine per-chunk difficulty
I mean
so I just put the if statement higher, and change all the variables to args
The game does kinda have that
its per world iirc
Local difficulty exists
yes
Controls stuff like the chance for mobs to wear armor
the longer you stay inside one area the harder it gets there
^
what is line 19?
You can see it in F3
String module = args[1];
line 18 is String enableDisable = args[0];
Both of those won’t work if you have no args
then your .jar doesn'T match your source code
you changed your code without recompiling and restarting the server if line 19 is the one with args[1]
your stacktrace cleary says that line 19 is the one with args[0]
ah maybe it happened when I formatted it
oh right
ah it finally worked
if(args.length < 2)
// tell player "you need at least 2 arguments" and return
// now you can access your stuff
String val1 = args[0];
String val2 = args[1];
so String val1 = null; null error?
No that’s valid
no
eh?
You just can’t do something like val1.trim() if the string is null
String val1 = null; // fine
val1.toLowerCase(); // NullPointerException. "null" doesn't have a toLowerCase() method
Yes but It wasn’t null
yes, but you didnt have any nullpointerexception...
it wasnt?
As I already said 3 times, you had an ArrayIndexOutOfBoundsException
ooohhh
Any variable can be null just fine (except primitives), you just can’t invoke any methods on said variable
the "null" at the top is just the missing exception message
oh, I understand now.
thanks a lot
np^^ next time pls instantly send the full stacktrace 😛
DId you define a ServerManagerPlugin class inside both of your .jars or maybe even shaded the one into your other?
because if so of course they have the same name but they don't extend each other or sth
Nope. I checked the jar.
Its even on the same java version
Players that first join have a death bug.. I have 3 plugins. My first plugin teleports them to the new world at 0, 68, 0. The second plugin has an EventHandler that picks up on the change of worlds and teleports that player to the center of their plot. The third plugin is the plot plugin. I don't know why people are dying when they get sent to that world for the first time, once it happens once it never happens again..
But this is java code
@young knoll you free to jump in General to help me out with the CraftItemEvent?
maybe listen to the PlayerDeathEvent and see why it says they're dying...? maybe cancel if during the first few ticks of the player's existence...? idk
That is a patch for sure
what MC ver?
1.18.1
mmk
Using paper-109 but it's been around a bit
?paste
Anybody got an idea of comparing a CraftItemEvent to a ItemStack?
i hate my code and life lmfao
seems odd. I'd try that first thing I said to maybe try and debug why they're dying
How do you convert from a DataWatcher to SynchedEntityData?
SynchedEntityData sed = npc.getEntityData();
It keeps giving me errors saying its a DataWatcher object, but there is none for the new Mojang Mapping itself
I keep getting NullPointerExceptions too because of it
ArrayList<String> disabled = Modules.disabled; if I modify disabled, will Modules.disabled get modified as well?`
What? You can’t compare an event to an item
What is disable
*disabled
Yes
typo
@young knoll more so extracting the result of the event in order to track down which custom it is to apply the pdc data I need to it
Happy to jump in general and show you where I'm stuck lol
Hello, I have a problem. So firstly, I have two ArrayList String in class Modules. One of them is modules and the other one is disabled. Secondly. I have imported both said ArrayList into my Commands class.
ArrayList<String> modules = Modules.modules;
ArrayList<String> disabled = Modules.disabled;
Thirdly, I have a command that if I type /ad disable all, disabled = new ArrayList<>(modules); will execute. Causing Modules.modules to my knowledge to update. Fourthly, I have !disabled.contains("playerSlipped") in another class imported again using ArrayList<String> disabled = Modules.disabled;, The problem is !disabled.contains("playerSlipped") still returns true after executing /ad disable all. Fifthly, It only returns false when I reload confirm the server after executing /ad disable all
The inventory should have a getResult
Your third assumption reassigns what the local variable “disabled” points to
It seems that the task never works or is created, but no error is generated,
and the code in the previous line works normally. Is there any way to solve this problem?
Here is a full code of event and Task.
https://paste.md-5.net/pifirayosa.java
yes, I want to copy the values of modules into disabled
See array list clone method
Clone() doesnt work
Well it does
im confuused
cast it
@young knoll no joy
I would need a test user to join for it to work. The bug is possibly because the player doesn't own the plot for that tick, or a schematic being pasted at coordinates can kill someone idk. Maybe I should just have a delay between teleports
Object thing = new ArrayList<String>;
doTheFunctionThing((ArrayList<String>) thing);
or a more readable way
int someInt = 1;
float castedToAFloat = (float) someInt;
ArrayList<String> disabled = Modules.disabled;
disabled = (ArrayList<String>) new ArrayList<>().clone();
System.out.println(disabled);
System.out.println(Modules.disabled);```Why doesnt it sync?
Because .clone
yes but isnt it supposed to sync with Modules?
when I reloaded it, thats when it synced. but disabled isnt syncing
how do you report a spigot plugin for using your code but making no mention/credit anywhere?
and i'm talking 90% of the codebase is my code not a little bit
Ughh pdc
Use the report button
the only report button I see is titled "Report Resource Update" which seems specific to an update or is that also just a general report button
@young knoll am I not setting an Items PDC Correctly?
@EventHandler
public void onPlayerCraftItem(final CraftItemEvent e){
List<CraftableItem> val = new ArrayList<CraftableItem>(CustomItems.values());
List<CraftableBlock> CustomBl = new ArrayList<CraftableBlock>(CustomBlocks.values());
Bukkit.getConsoleSender().sendMessage("Craft Event");
for(int i = 0; i < CustomItems.size(); i++) {
if(e.getInventory().getResult().equals(val.get(i).Item)) {
NamespacedKey k = new NamespacedKey(LabToolsPlugin.getPlugin(LabToolsPlugin.class), "cid");
e.getInventory().getResult().getItemMeta().getPersistentDataContainer().set(k, PersistentDataType.STRING, val.get(i).UniqueName);
e.getWhoClicked().sendMessage(val.get(i).UniqueName);
}
}
for(int i = 0; i < CustomBlocks.size(); i++) {
if(e.getInventory().getResult().equals(CustomBl.get(i).Item)) {
NamespacedKey k = new NamespacedKey(LabToolsPlugin.getPlugin(LabToolsPlugin.class), "cid");
e.getInventory().getResult().getItemMeta().getPersistentDataContainer().set(k, PersistentDataType.STRING,
CustomBl.get(i).UniqueName);
e.getWhoClicked().sendMessage(CustomBl.get(i).UniqueName);
}
}
}
}
Should be general if you do it from the main resource page
getItemMeta is a copy
You need to use setItemMeta after modifying it
Can anyone join this server to see if they die lol not advertising but this death bug is the death of me
Bout to fix a tonne of code @young knoll
y cant u join n test?
can someone help me
I just wants this task to repeat every 30 ticks and cancel itself.
It was only happening when a player purchases a plot for the first time
I already have mine and don't wanna start up a giant test server it's a super weird bug
Hi, I'm trying to spawn a entity with type player but it wont, can someone suggest a method for this please?
hmm
I love reading code without syntax highlighting
@ancient plank ayyy
If it ain't precompiled jars being opened in notepad it aint worth it
Microsoft word
Never switching between NBT and PDC ever again lol
Just never use NBT again
Pretty much
It's a personal project more than anything
But better to use best practices instead of trying to take the easy way out
Ayy my wireless redstone is working again
This time not just in 1.17
how to get spigot?
@swift adder Build tools
oh okay
Is there a masterlist of all the NameSpacedKeys for all the registered recipes?
I want to make something that will "discover" all recipes for a player on join but I can't find the list to iterate from, or how to populate my own list.
i understand, thanks
is there a right click mob event or somthing like that or detect when damage is applied to certain mobs
Currently i think not... Only the defaults recipes
There's Iterator<Recipe> in the Server class
I was looking at that.
It returned a Recipe object.
Would I have to populate a list of ItemStacks, then iterate off of that?
Bukkit.getServer().recipeIterator()
In docs not say only return vanilla recipes? Or i missing the method
Should return all recipes
Assuming they have already been added
Thanks, I'll look into it some more
thats not a real link
atleast dont work for me
use the PlayerInteractEntityEvent
And EntityDamageEvent when they're damaged ^
get the player then get the entity type
I looked into the Recipe iterator, however I can't figure out how to turn that Recipe object into a NSK I can use for the #discoverRecipe(NameSpacedKey) function
Check if Keyed, cast
Iirc there's still at least one type of recipe that isn't Keyed
In what case a recipe are not keyed (?
Oh, I didn't realize recipes were a NSK. Thanks!
Or well maybe tomorrow can see what typw of recipe its not keyed xd
Merchant is a recipe?
I edit this class and dont remember xd
implements*
I'm probably not understanding right.
(recipe instanceof NameSpacedKey) gives me an inconvertible type error.
the only function off of recipe is #getResult() -> ItemStack
Keyed
Thank you, I found the NSK!
Can someone Help me?
Did you register the event
yeah i did
According to the debug message, it can be seen that up to line 16 is working normally.
But putting debug messages inside run() doesn't work either.
When I compile a Maven project, does it import the dependencies automatically?
or do i need the .jars in the same folder or some
It does it automatically
then idk y im getting the err im getting. NoClassDefFoundError
Did you shade
If it's not a library used by Spigot, you have to shade it.