#help-development
1 messages · Page 2158 of 1
i just dislike typeadapters
well
I see, thanks for the example!
serializing basically means "converting sth to a Map<String,Object>"
you aren't running bungeecord
you are running a weird fork of floodgate
oh yeah mb. floodgate is the weird version of geyser
you have a typo in your bungee.yml file @wicked remnant
it's "softdepend" and NOT "softdepends"
so just remove the "s" at the end and it should work
Is that what you needed?
It's alittle confusing bc of the databases but I think I could be able to use it.
You just wanna save the inv?
Correct
Check the itemstackserializer
how exactly did you compile this? you should use either "mvn install" or "mvn package"
In utils
wait
how i compile it?
I see, does that take a list of ItemStacks?
Yep
and I can just load those into a inventory gui?
Yep
and then on restart/quit I can save deserialize and save it to a yml file and vice versa?
Yes
Sweet, you're the best.
You're both the best 🙂
Its basically the same plugin ur making so it'll do the same stuff
I can live with that
then help me
on the right side of your IntelliJ window, there should be a tab called "maven"
open that and double click on "package"
He can't cuz I'm the best
light mode 💀
lmao
i dont have the window
if you double click that, maven will compile your plugin and put inside C\Path-To-Your-Plugin\target\
then right click on your "pom.xml" file and then click on "open as maven project"
ok
i love it when i google my question
find i literally asked the same exact thing 5 years ago
serialize/deserialize itemstack via json
Why do u wanna use json?
why is everyone trying to use json today
I convert the bytearray to base64
i cannot find the button
the whole point of json was the ability to use strings for redis pub/sub
but i now realize
redis has a byte array feature
i should just use that
Oh well that's even better
I dont know anything about json. All i know is that you can turn itemstacks to a byte[] like this: https://github.com/JEFF-Media-GbR/MorePersistentDataTypes/blob/master/src/main/java/com/jeff_media/morepersistentdatatypes/datatypes/serializable/ConfigurationSerializableDataType.java
yep im experienced with that sorta thing haha
How can I center text on a items lore?
I tried to create my own class but that was super wonky, most text was too far left or too far right.
Thats probably going to be a difficult one; probably going to have to make a method for it yourself
Lore length isnt set so centered is really a dependent on every case
yeah I tried to make one myself and got something that looks like this:
for some reason it just doesnt look right
this actually worked like a charm
itemstack maintains its hashcode and everything
in the case that its even you might have to pad an extra character
to make it odd
wdym even?
nvm
I know the little dividers are perfectly centered.
I dont know what the Click to view or Settings isnt tho
I didnt add the ChatColor.* to the string to centered
Anyone know why my depend order doesnt seem to be respected?
not sure what you mean by widen
If you don't know what I mean by "widen the horizontal bar" then you're beyond my help
I know how to do that, idk how the widen the wrapped text
I manually separated them
Ok
what does this mean?
that there is a warning
oh yeah nevermind xdd
My plugin.yml looks like this: But why the console say there is no one?
either its in the wrong directory
or your maven (Im assuming its maven but no idea) is screwed up
can you show your entire project directory?
your plugin yml needs to be in resources
so im trying to make a custom configuration file but i run into an error when enabling it
Cannot invoke "org.bukkit.plugin.Plugin.getDataFolder()" because the return value of "org.bukkit.plugin.PluginManager.getPlugin(String)" is null
How can I connect right to redis? because this redisClient = RedisClient.create("redis://localhost:6379"); throws this error Unable to connect to localhost/<unresolved>:637
can you show the code?
yeah one sec
use a singleton or di rather than the getPlugin and that will probably fix it
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
.⬆️
how do i use it in this situation?
file = new File(Bukkit.getServer().getPluginManager().getPlugin("playerData").getDataFolder(), "playerdata.yml");
yeah
thats not how that works
ik thts the problem
thats asking for a plugin name
replace Bukkit.getServer().getPluginManager().getPlugin("playerData").getDataFolder() with a reference to your main class
(which is generally a singleton or DI)
OH
I GET IT
i was following a tutorial but ig i was just being stupid
so do i use di?
do you have a instance variable/method in your main class?
uh
it gives an error when i dont make it static
then how you are referencing it is an issue
that code you sent is pure static abuse
what
You would store a variable in your main class of playerData, and in your onEnable set that variable to a new playerData with the plugin instance (in this case, this; then you would call variable.setup;
?learnjava Will help a lot
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.
so like in playerData i make something like
public playerData;
and then in onEnable i set the variable like this?
playerData = this;
the public playerData would be in your main class
okay
I'll pull up an example from one of my projects real quick
kk
Basically what you are doing, but I have it in the onLoad rather than enable.
In this case look at DatabaseManager at the top and in the method shown. You would also need a getter to actually get the variable from the main class, I'm using Lombok but your IDE can generate one
Guys. Why its telling me now RedisURI Already in use... Does that mean i can only connect one time to redis or what?
you should only need to connect once
also a view from the actual DatabaseManager https://cdn.rackdevelopment.tech/img/oUR6WPKLxI.png
?paste Show the code that you are using in a paste please
thats basically di right?
exactly what it is
are you running Jedis or Redis?
(for the api)
yeah
idk actually
should i just switch?
its still telling me to make it static
can you screenshot what exactly is saying that
up to you, I admit I like Lettuce a lot just my project was originally made with Jedis so when I discovered it I didnt bother converting over
upload it to imgur or smth
kk
ok but how can i fix it now :o
some one can help me setup grief prevention please
Would recommend seeing if they have a discord or something
your method is static so you cannot use a non-static variable
ah; get rid of static from the method and the File and FileConfiguration
yeah but it causes errors in main class
oh boi
then we will fix those in a minute
were working right now to fix the large amount of static abuse you got lol
ok lol
i like lurking in the chat and watching you :>
get rid of all static
alright
Most of them should be as simple as replacing the class callout with the variable you defined in your main class
theyre all the same
Im assuming its like playerData.get() or smth like that
Is that in your main class?
alright so you need a reference to your main class, and you are going to use that reference to replace playerData in that image
ye
Do it for all your classes. You don't need static in most cases.
Cannot resolve method 'get' in 'DinnerChad'
its getting the main instead of the playerData class
do you have an instance variable in your main class>
yeah get that, and then use that variable to get playerData
DinnerChat.getInstanceThingy.playerdata or smth
alr
lmao
could always verify
Only non-verified can see it (and staff)
lol
really should name those vars better tho
lol i dont know why im just very bad at naming
but it gets the job done
ok checking to make sure that this is correct
yes
otherwise NPE
pass 'this' into it
yeah ik
it automatically does it
when you concatenate it with string
ive learned a lot
thanks @dusk flicker :D
np
if (e.getCustomName() == null && e.getCustomName().equalsIgnoreCase("waystone")) return;
Kappa
is this fine right, the && means if the first one fails the second one won't be evaluated so no null pointer
right⸮
is that ok
what is the defualt pitch for a sound minecraft?
i put it as 1 and it sounded right
sounds too high
true but in this case it will throw an npe
why
since if the first is true, then you will be doing null.eqaulsIgnoreCase
it should be !=
yeah
coolio
yep
Google is your friend
do scoreboard prefixes no longer change the color of the player's name?
I'm setting the prefix, and the prefix shows, but the color doesnt go to the player's name
I printed the prefix to the console too to make sure no reset was added or anything, and it wasnt. It ends in §c yet the player's name is still white
please ping me if you reply
my playerinteractentityevents are not firing when i click an invisible armorstand
how can i get a right clicked invisible armorstand
kinda new to making custom pdc types, any things that could go wrong with this
it works though
same with this
That is scary ngl
yeah since im also catching a generic exception
but can u elaborate how scary that is
hog
It just seems like a lot of work to store stuff
oh unoptimized?
since doing straight deserialize and serialize of objects using stream
any way i can disable this warning?
even if I assign a max buffer size?
oops ping sorry
I don't mind. Idk I just usually find it interesting how people create crazy methods to serialize items to PDC
aight appreciate it
I might as well store the array byte input stream in a input or output buffered stream
@EventHandler
public void onUseItem(PlayerInteractEntityEvent event) {
final Player player = event.getPlayer();
final ItemStack usedItem = player
.getInventory()
.getItem(event.getHand());
// ...
usedItem.setAmount(usedItem.getAmount() - 1);
player
.getInventory()
.setItem(event.getHand(), usedItem);
player.updateInventory();
}
Trying to consume 1 item from the stack used in a player interact event. After the setItem method call, usedItem.getAmount() returns 0, so I must be misunderstanding these methods. What's the correct pattern to achieve this effect?
How about this one: hash the item, store it in a hashmap with the hash as a key and then you can retrieve it whenever and you dont have to put everything into the pdc
Unless of course you wanna restart the server and still get the item
Supress "Constant conditions" or something like that
Or use a database depending on the frequency of loads/unloads. You use a hashmap has a intermediate and then async save to the db.
At that Point you can Index it with an incrementing number
XD
not if the item is configurable in a yml and you dont want the wrong data to be decoded
people use PDC for the wrong things usually
it is convenient but it shouldn't be used for everything
just because the value can be configurable doesn't mean you can't use some key that makes it easy to know which you want
One thing I hate about PDC:
You can't get an OfflinePlayer's PDC
technically you can
hmm
someone should make a plugin which saves the PDC of any player to a file
welp, there go my usual weekend plans for next weekend
that's already done
spigot just does not let you get it
XD I figured
you can create a fake online player object for limited uses
Fair enough
time to make that
Actually, should I release my plugin core?
Its in a half working half broken state, but some stuff could be useful if you wanna see impl (It's also bad code lmfao)
if you think it would be useful to others, sure. But ultimately it is up to you
for now its meant to work, I'll make it pretty later
I have gists and git repos public for various things regardless of what state it is in
no one ever said that a repo must be in a working state
but honestly making a yml file for PDCs which other plugins could access sounds like a good idea for a free plugin/dependency
No need
no it doesn't
the player .dat file has it iirc
I thought it was somewhere encoded and not retrievable
too many developers rely on libs for their plugins as is and don't bother coding their projects in such a way that their plugins still work without those dependencies
fair enough
I make the dependencies from 0 with pure java, ain't no way I am using a 3rd party lib lmao
most libs developers use are minor ones and that is what my comment is more directed at 😛
(Unless strictly needed ofc, like extremely complex ones)
things like protocolib are an exception of course
ye
its now public
not all of the packages are done
go ahead and tell me everything that's wrong
Apart me not following SRP
you can add documentation on some finished classes and functions
and the use of lombok getters
would make your code a lot cleaner
eeew lombok
Code looks clean w/o lombok
Lombok adds complexity to your code if anything tho
It just virtually makes code disappear, it doesn’t make code cleaner generally speaking, tho it might eliminate illusions and verbosity
I am never a fan of auto generated code you can't see before hand
well I think it is fine to have methods that do that
as long as it isn't removing methods that provide verbosity
Yeah, I mean the java enhancement proposal had very specific goals in mind when proposing
Good point
I am all for the Java devs in trying to support all types of people
just as long they are not favoring one group over another 😛
I think what makes Java great is how dynamic it really is though
unlike other languages where that just simply isn't the case
I like Java because it added the most necessary things, didn’t add a billion utility features that just bloat the language and to some extent arguably does neither belong to the solution set.
yeah
I do look forward to when Java gives a bit more freedom over the JVM though
that would be an interesting thing to see
Hi I want to make an Entity move to a specific location (coordinates) in SPigot/Bukkit? How can I do that?
Entity#teleport()?
Well but teleport does that in a millisecond
Thats not smooth at all
I want it to walk
if i have to guess then you have to work with server tick
hello i want create placeholder
I want replace:
TimeUnit.MILLISECONDS.toSeconds(combat - now)
to
%time%
in config please help
TimeUnit.MILLISECONDS.toSeconds(combat - now) is anti logout time
.replace dont working
wait what, there arent any methods??
I mean that cant be true
well from top of my head with normal bukkit api. you can use scheduler that run every tick.
or you can use paper api which it called TimeUpdate or something
i dont work with player npcs
i mean methods that directly do what you want
theres stuff that allows you to do it, like the scheduler above but you will have to look into it further
you want the npc to walk to a point, with animation and all right?
Yesss
I want to hand over some coordinates and want it to walk towards them
I mean there must be something right
try some googling
If you want pathfinding you will need to use NMS
Paper has some Pathfinding API
or use PathethicAPI
maybe someone will eventially PR an entity api method to set a location for entities to navigate to
anyways the only way to do it is to use NMS to change its pathfinding
feels bad you gotta have to access these on nms
Yeah i imported it but somehow with 1.18 you cannot resolve every method
How did you import it and what methods are you trying to use
I used this video
But for example if I use the getNavigation method its marked red and it always says method not ressolved
I assume you're not using mojmaps
So the method will be a(), b(), c() etc
To use mojmaps read the 1.18 release post
Well yes but inside the getNavigation method is being used
`
public PathfinderGoalWalkToLoc(EntityInsentient entity, Location loc, double speed)
{
this.entity = entity;
this.loc = loc;
this.navigation = this.entity.getNavigation();
this.speed = speed;
}
public boolean a()
{
return true;
}
public void c()
{
PathEntity pathEntity = this.navigation.a(loc.getX(), loc.getY(), loc.getZ());
this.navigation.a(pathEntity, speed);
}
}
`
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
?
Because I use maven as dependency in my project although I dont even know what it makes
Please its urgent
if you import it with maven properly, you shouldn't have an issue in resolving methods
don't depend on both the server jar and the api
since you are going to be using NMS, you only need the server jar as a dependency as it has the api
yeah in dependcies i switched from spigot-api to spigot
Could you please help on voice chat
I don't do voice
and I don't do personal help either. Here is fine
there is plenty here who can help 🙂
did you run buildtools with --remapped?
Whats remapped
you didn;t read the 1.18/1.17 post
?bootstrap Read the post, but also read the 1.17 post that it links to
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
this is normal as the player move packet doesn't get sent until they move. Teleport doesn't send this packet
you could send a player position packet update
to all the others
you could probably try using the api to send a chunk update maybe?
that is one of few methods that will cause some packets to get sent, not entirely sure if doing that would work
but worth trying though
no, the event is generated when the client sends a packet to the server that it moved
not the other way around
ah bummer
yes but one could just call this event oneself
if u teleport the player and then send the player move event
the packet
should be fine
if the anti cheat is shitty, then yes
however every proper anti cheat has an API you can just cancel their "violation detected" event
yeah but it says maven handels this automatically
and we are using maven
I suppose it is another thing someone could try
I doubt it will work though
I haven't really read what the conversation was about
I thought they just wanted to teleport a player but still "tell other plugins about it"
the person is having a problem when you teleport a player, they are invisible to everyone until they move
that's weird
so the goal is to try and get the server to send out packets without using NMS
hm weird, never heard of this problem
its always existed
one of those nuances with minecraft
typically it isn't really an issue for most things 😛
Exception in thread "main" joptsimple.UnrecognizedOptionException: j is not a recognized option
Buildtools runs exception
java -jar BuildTools.jar --rev 1.18.2 --remapped
Yeah probably
?paste
?paste
where can i find that
there should be a .log file in the buildtools folder
in the same directory as buildtools jar
BuildTools.log.txt
Loading BuildTools version: git-BuildTools-1fbeb7f-147 (#147)
Java Version: Java 17
Current Path: C:\Users\SpigotBuildTools\BuildTools.
Exception in thread "main" joptsimple.UnrecognizedOptionException: j is not a recognized option
at joptsimple.OptionException.unrecognizedOption(OptionException.java:108)
at joptsimple.OptionParser.validateOptionCharacters(OptionParser.java:633)
at joptsimple.OptionParser.handleShortOptionCluster(OptionParser.java:528)
at joptsimple.OptionParser.handleShortOptionToken(OptionParser.java:523)
at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:59)
at joptsimple.OptionParser.parse(OptionParser.java:396)
at org.spigotmc.builder.Builder.main(Builder.java:164)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)
is that all there is?
yes
using git bash?
or using command console?
if you are using command console, recommend trying with git bash instead
Delete your buildtools directory and start fresh.
?bt
talk about inventory. I haven't touch packet for a while.
I wonder how can I stop the player able to drag the ghost item out of the inventory?
When I try to cancel the packet, well the server not process it anymore.
So player can drag the ghost item out and throw it away.
Is the SetSlot the solution for this?
why packets? Spigot has a drag event
the better question, is how are you getting a ghost item?
Well I send them fake equipment item.
But that without having to touch the SetSlot packet. Because the SetSlot packet have the parameter called stateId which I'm not sure what that's about
I want to disguise a few thing.
First of all. I can do the normal way yes
Well SetSlot indeed work, but I wonder if it's the correct solution to cancel the ghost item, seems like everytime I cancel something in player inventory. Spigot send a few SetSlot packet
does anyone know anything about chatcolor2? i need some help
i cant get the permissions for people to use colorcodes in chat right as i want
if im making new items derriving from emeralds as base item, serious question because idk in the servers scale,
should i hard/-softcode new items crafting recipe, behavior etc?
its going to have quite extensive custom behavior though
not like "ignite on hit" rather like loot boxes from mob drops etc
should i hard/-softcode new items crafting recipe, behavior etc?
no
I always let people define crafting recipes using a yaml file. the code is a bit ugly but it's working fine lol https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/RecipeUtils.java
recipe files then look like this: https://github.com/JEFF-Media-GbR/JeffLib/blob/master/examples/RecipeUtils_getRecipe.yml
hard or soft coding something is dependent on what you are trying to allow
if you want the ability to change the recipe to something else then soft coding is the way to go
but if you are certain that isn't something that is needed then hardcoding it shouldn't be an issue
is there a plugin that lets PLAYERS define custom crafting recipes?
I mean not letting the admin decide, but letting the actual players create new recipes lol
eg 1 dirt -> 1 netherite pickaxe
Can ServerPlayer ( NMS ) send Plugin Messages?
no
so there's no way of sending plugin messages from server when noone is on them
pub/sub is a beautiful thing
why i have that error?
i want to use a boolean, not a string
my yaml:
//Seteaza true daca ai nevoie sa folosesti vault impreuna cu pluginul
vault-economy: true
//Daca ai setat true, scrie mai jos cati bani sa coste folosirea comenzii pentru activarea modului
Money: 10000
//Mesaje
passive-activate: '&bAi activat modul passive, ai platit &4&l-&a&l{bani}'
passive-disable: '&4Ai dezactivat modul passive.'
no-vault: 'Dependenta negasita, adauga Vault + un plugin pentru economie. Ex: EssentialsX.'
Sorry for language 🙂
Your file should look like this
# Seteaza true daca ai nevoie sa folosesti vault impreuna cu pluginul
vault-economy: true
# Daca ai setat true, scrie mai jos cati bani sa coste folosirea comenzii pentru activarea modului
Money: 10000
# Mesaje
passive-activate: '&bAi activat modul passive, ai platit &4&l-&a&l{bani}'
passive-disable: '&4Ai dezactivat modul passive.'
no-vault: 'Dependenta negasita, adauga Vault + un plugin pentru economie. Ex: EssentialsX.'
oh, what stupid am i
lol
@wet breach @tender shard only recipes and behavior defined by me. any user craftable items use vanilla mechanics like enchanting
like ive made obsidian tools derriving from iron tools with custom behavior
being repaired by "obsidian ingots"
which are actually obsidian blocks smelted into iron ingots with a resource pack and behavior to seperate the 2 ingots
i'D make it configurable anyway
hey i have a question. i have a bungee plugin for coins and token and i need to somehow make a spigot plugin to request balance from the bungee and get a response
how would i do that with the custom plugin messaging
can't you just store the balance in a mysql db or something? that's probably the easiest way
maybe this? https://github.com/twitch4j/twitch4j
yeah i could seems easier
do you ever need to send "messages" without any player online?
if yes, you cannot use plugin messaging anyway
people commonly use redis to send "messages" between servers
but as said, simply storing your balances in a sql db is by far the easiest way I guess
hm yeah might be true. sorry I don't know anything about twitch lol
Hey everyone so I'm trying to run a command for an offline command through console and it seems I can't do it. I'm presented with an error. If anyone knows a fix I'd appreciate it.
>[14:07:09 WARN]: Unexpected exception while parsing console command "givelootbox Boryte" org.bukkit.command.CommandException: Unhandled exception executing command 'givelootbox' in plugin KyodoHub v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-21fe707-741a1bd] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-21fe707-741a1bd] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot.jar:git-Spigot-21fe707-741a1bd] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot.jar:git-Spigot-21fe707-741a1bd] at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot.jar:git-Spigot-21fe707-741a1bd] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot.jar:git-Spigot-21fe707-741a1bd] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-21fe707-741a1bd] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-21fe707-741a1bd] at java.lang.Thread.run(Thread.java:833) [?:?] Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_8_R3.CraftOfflinePlayer cannot be cast to class org.bukkit.entity.Player (org.bukkit.craftbukkit.v1_8_R3.CraftOfflinePlayer and org.bukkit.entity.Player are in unnamed module of loader 'app') at me.boryte.kyodohub.commands.GiveLootboxCommand.onCommand(GiveLootboxCommand.java:40) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-21fe707-741a1bd] ... 8 more
you can't cast an OfflinePlayer to a Player
Right so this is wrong.
Player target = (Player) Bukkit.getOfflinePlayer(args[0]);
What should I do it instead? I've never worked with offline player before
Nvm I'm dumb
I think I got it
You can only get a Player object if they are online
OfflinePlayer target
^ this. To get an "online" player, just use getPlayer on the OfflinePlayer object
which will of course return null if the player isn't online
so yeah offline players cannot run commands
makes sense
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]); Player onlinetarget = Bukkit.getPlayer(args[0]);
This is my current code
I'll see if it works
looks good
but make some checks before if the getOfflinePlayer(args[0]); or getPlayer(args[0]); cannot be found
if (args.length == 0) { p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cUsage: /givelootbox <player>")); return true; }
Oh I get what u mean
can i make black color more readable?
you can use hex colors
to use basically every color you like
how
im trying to register an event in the OnEnable() and it says Cannot resolve method 'registerEvent(MuteEvent, Minecraft)'
Idk why this is happening.
oh
What event will call when entity Item was removed?
is there any plugin i can hide players nametags through walls
I love this
I have this in an event @EventHandler public void OnPlayerChat(PlayerChatEvent event){ Player player = event.getPlayer(); FileConfiguration config = Minecraft.getPlugin(Minecraft.class).getConfig(); System.out.println(player.isOp()); System.out.println(globalMute.getIsMuted()); if (!player.isOp()){ if (globalMute.getIsMuted()){ player.sendMessage(ChatColor.RED + String.valueOf(config.get("The chat is currently muted!"))); event.setCancelled(true); } } } and I have this in my main: ```public final class Minecraft extends JavaPlugin {
public FileConfiguration config = getConfig();
public FileConfiguration getConfig(){
return config;
}
@Override
public void onEnable() {
// Plugin startup logic
this.getCommand("globalMute").setExecutor(new globalMute());
getServer().getPluginManager().registerEvents(new MuteEvent(), this);
config.addDefault("GlobalMuteMessage", "The chat was muted!");
config.addDefault("GlobalUnmuteMessage", "The chat was unmuted!");
config.addDefault("PlayerMutedMessage", "The chat is currently muted!");
config.options().copyDefaults(true);
saveConfig();
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}```
I don't think I used the config correctly, can someone explain me what I should do?
I added the comments to that javadocs page lol
show your config file
GlobalUnmuteMessage: "The chat was unmuted!"
PlayerMutedMessage: "The chat is currently muted!"```
looks good. where's the problem?
I actually don't understand what i've done with config
how do i get it from the key?
ok
Cannot invoke "org.bukkit.configuration.file.FileConfiguration.addDefault(String, Object)" because "this.config" is null what?
Wdym?
public FileConfiguration config = getConfig();
public FileConfiguration getConfig(){
return config;
}
@Override
public void onEnable() {
// Plugin startup logic
this.getCommand("globalMute").setExecutor(new globalMute());
getServer().getPluginManager().registerEvents(new MuteEvent(), this);
config.addDefault("GlobalMuteMessage", "The chat was muted!");
config.addDefault("GlobalUnmuteMessage", "The chat was unmuted!");
config.addDefault("PlayerMutedMessage", "The chat is currently muted!");
config.options().copyDefaults(true);
saveConfig();
}```
so i was interested in creating a tool which can publish plugin updates for me so my question is, is there a rest api or some way to make an http request to update a resource on spigot
so just put it like this? public FileConfiguration config;
I think that the plugin just doesn't know what file is the config but idk how to fix it
Shouldn't all the stuff after FileConfiguration config = getConfig(); be in the OnEnable()?
Idk I tried searching and there doesn't seem to be an error even tho it doesn't work
when the plugin is loaded it crashes and the console says Cannot invoke "org.bukkit.configuration.file.FileConfiguration.addDefault(String, Object)" because "this.config" is null
I have redis now running. Now i have one question: How can i publish values? I found only ways to subscribe channel (what i already did in my plugin) BTW: I use lettuce
you got the client
open a pub sub connection and register a subscriber
if you also wanna write messages, you'll have to open a second connection
hi would anyone know why the values im grabbing from inside the croupier class are returning null? they have default values of 0
omg that format
ouch
and then?
What is in PlayerCroupierData ?
I mean then you invoke publish on the second connection
I have an example if you need
please
-<
Thats it, isnt it?
yes
Then the null is not coming from that
ah wait async => asyncWrite
show the error
?paste
PlayerData.java:29
public int getCoinflipWins() { return this.croupierData.coinflipWins; }
?paste your PlayerData class
Okm the error makes no sense to me. You must have failed to update teh jar on your test server
The code you have show should not be possible to generate that error
afraid I have to go for now though
thats exactly what i thought
that code's been there for like a month, and all the sudden I can't reach those values without hitting null
?paste
please show the listeners code
yeh i think im thinking what ur thinking
well the error doesn't relate to the code you showed
i mightve called for the data before the class is loaded
I sent a redis message but i didnt get the output. Why? https://paste.md-5.net/wezuyinabe.java (I didnt)
if you use the async thing, if you test you might wanna join the future
When using BuildTools for craftbukkit it seems that it doesnt create the actual jar...
https://i.gaeta.me/gzBjf is the logs
it just says that but the file doesnt actually exist
wdym?
i have to use sync?
https://paste.md-5.net/ofatepisuw.java it's around line 137
show the full log please
its too big how should i send it
so that you can test the code predictably
what do you mean with this sentence
nervermind i have to go now
publish(..., ...).toCompletableFuture().join()
where do you get that object from?
the croupierData
I don't see where you are setting it in that class at all
which is what this refers to
can I see this class PlayerCroupierData
you don't see a spigot.jar in the same directory?
nope im telling it to compile craftbukkit not spigot anyways yk
that is why
craftbukkit no longer supported and isn't put in the directory with the buildtools jar
only spigot.jar which is what you should be using anyways
even with --compile craftbukkit
yep even with that
Please use spigot
@wet breach
theyre in PlayerData
as seen in this picture
ok I know the issue now
Ik im still using spigot but i need craftbukkit/bukkit for testing etc. Why would they stop allowing it even if https://www.spigotmc.org/wiki/buildtools/#compile-craftbukkit still says its supported
Why do you need it for testing
the way you are calling the variable in that other class you are doing it via a static way and the variable isn't classed as being static, thus it isn't really initialized.
Im creating an inline cli for my linux servers that would allow me to swap jar types on the fly
so it is therefore null
The reason it's probably not allowed to be done anymore as it's an unsupported version, that no one in their right mind should be running
And why do you need CB for that rather than Spigot?
so set the class and values inside of it static?
if you need those jars, look in the work directory under their respective directories
either do that, or make a method to return those values in that class and use the method
wouldn't that be the getters and setters?
basically, but your getters and setters are in a different class which doesn't quite work the same
are u talking about https://i.gaeta.me/pj44MraFCieg
That link doesn't look sketch at all
craftbukkit-1.14.2-R0.1-SNAPSHOT.jar or original-craftbukkit-1.14.2-R0.1-SNAPSHOT.jar
its my image server sry
using sharex
the one without the name original is the one yo uwant
Oh I know it's just sketch lol
original is before shading
lol u can put .png etc in front but its just more work.
ty
will it always have R0.1-SNAPSHOT on all versions?
I don't think I've ever seen one with anything else there for those lol
pain
does anyone know a good delaunay triangulation library? The one i have tried doesn't yield the best results
what are you trying to accomplish if you don't mind me asking?
can i ask why they dont make an announcement when doing a change like that or even change the docs
It was announced a year ago
o
i have found an interesting method to generate dungeons online that consists in generating rooms, creating a triangle mesh and getting the minimum spanning tree to generate the corridors
you weren't around for it, sorry 😛
lol but i mean like announce it the day they removed it permanently
i wanted to try out the concept for fun and i soon realized its not as easy as it seemed
and the lib im using doesnt work very well
alright so you want to generate the corridors that would lead to other dungeons right?
yea the other rooms
and in the picture above, how is it you are testing it?
https://www.youtube.com/watch?v=rBY2Dzej03A&t=209s lol this video?
Read the original blog post here: https://vazgriz.com/119/procedurally-generated-dungeons/
Github repo: https://github.com/vazgriz/DungeonGenerator
This video describes an algorithm for procedurally generating 3D dungeons.
0:00 Intro
1:03 2D Algorithm
3:40 2D Dungeon Example
4:17 3D Algorithm
8:39 3D Dungeon Example
There is many ways for pathfinding
yeh i saw it awhile ago and thought it was interesting
So, what kind of pathfinding are you wanting for your dungeons?
least distance? Most optimal?
crazy wacky way that does whatever XD
i need to create a triangle mesh to know where i would like my corridors to generate
if you watch the intro of the video wally sent you'll probably understand what i am going for
well you don't necessarily need a triangle mesh, you could go with a diamond mesh
or an octagon mesh
not really sure if that would be easier to implement lol
Well, they allow for doing certain things. Triangle meshes give you more granular control, but sometimes such fine control isn't really needed
thus a different polygon that uses up more space for the rendering can be better
so for instance, in MC a corridor is optimal in a 2x2 configuration but you can have corridors that are 1x2
in a 2x2 configuration, diamond or hexagon would be more optimal and do the job while using less resources
however meshes are really not that hard. In coding the polygon is essentially an object that contains a set of points to describe its area it takes up
the larger the polygon the less information you need to store
i guess i could try doing that too
just giving you more information so you don't think you need to find something that strictly uses triangle meshes and that other kinds of meshes do exist 😛
more than the final outcome i was interested in creating a delaunay triangle mesh but thats still useful to know
but it also helps to understand when and why to use one type of polygon over another
while it is true you can fit more triangles in a given area, you are also most likely storing more information then what is necessary
in other words sure you got super high level of control, but unnecessary for your objective 😉
if this stuff interests you which it seems like it
recommend researching game theory and the related 😄
if i want to store a list of things in the world and a string and xyz for each one, should i just store it as a file or should i use a database
aight thanks
should i use csv or a database
so i should use a whole ass db just to look up the name and position of at most 50 armorstands
SQLite
is that really optimal?
i will do it but what benefits does it pose over just using json or csv
for something as simple as this
keep in mind it's as simple as this
hello guys what the hell is skript
Are you loading the values from the file into memory where the file will never be touched again, or using the file as the pet ant location
Permanent*
the file is loaded, read, very rarely written to
but it will be written to sometimes
about as often as a player might place a lodestone
Where will the values be saved when loaded from the file
they will be written back to the file
i just need some really really minimal persistent storage
That sounds like a use case for flatfile
I agree mineplex developer
Lol
:p
pogu i don't have to learn database!!1
I mean you’ll still be better off learning it in the long run
You just shouldn’t use it for this
I mean it is a nice skill to have as said above
yes i will use one eventually
so i just use csv/json for this right?
there's no fancy .flatfile right?
Maybe even yaml sure
Before I learned SQL I only used yml Lol it got me through the early days
o shid i will need to learn how to make it so when u drop the jar in the server it makes a folder just for that plugin with all its associated files ://
is that easy
Yes
what section of spigot docs is that
it’s actually a File class from Java to create them
:v ?
ye i was hoping it was that
As opposed to a database
but alex do u know what im talking about now
the part where the jar puts itself in a folder with associated files
like a config
Use YamlConfiguration, it’s already inside spigot
Alex does that classify a SQLite as a flat file storage
Default configuration and whatnot
No, you’re interfacing with it through SQL, not as a file being written raw
Ah yea just making sure
ok so this defaultconfiguration thing is specifically for saving a config file
im trying to create an optimized version of StringBuilder
it seems that my allocations are slow
I mean StringBuilder is fast and optimized
like it uses copyarray from System for instance
so do i
yeah but thats the biggest significant optimization
public void growShift() {
char[] newBuffer = new char[this.buffer.length << this.shiftBy];
System.arraycopy(this.buffer, 0, newBuffer, 0, this.buffer.length);
this.buffer = newBuffer;
}
public void append(char c) {
if (this.size == this.buffer.length) {
this.growShift();
}
this.buffer[this.size] = c;
this.size++;
}
StringBuilder does more checks though, so why is my version slower?
iirc jvm and compilers may do some optimizations when it comes to StringBuilder since thats a known class in the jdk
ugh i hate that
so basically its optimized to the max already
got it
@Override
public AbstractStringBuilder append(char c) {
ensureCapacityInternal(count + 1);
if (isLatin1() && StringLatin1.canEncode(c)) {
value[count++] = (byte)c;
} else {
if (isLatin1()) {
inflate();
}
StringUTF16.putCharSB(value, count++, c);
}
return this;
}
because theres no way in hell that this is faster than my implementation
Yeah, StringBuilder is hotspot instrinsic
Or at least a candidate for being instrinsic
i hate java.
I dislike C++
we all do
my code is better :/
@IntrinsicCandidate // <-- beware this annotation
public StringBuilder append(char c) {
i didnt know what intrinsic meant
that being said there are instances where JIT outperforms instrinsics, System#arraycopy is a nice example there
this server is really good for help because people reply and nobody is like "nOt eNoUgH iNfO" and gatekeepy
a for loop can copy certain kinds of arrays faster than arraycopy
anyone who knows protocol; can you answer a quick question of mine?
For field indexes, are they the index of all fields, or just the fields of the type (e.g. boolean)
what do you mean with field indexes?
yee
Could you link a packet or something where this is used?
im looking at https://wiki.vg/Protocol#Player_Info
in protocollib, you get firlds by their index, right?
not that I think
I believe that this is an exclusive or basically
So either the packet is "addPlayer", "updateGamemode", "updatePlayer", etc. What is what is defined by the "action" field
There are no indices there (outside of the indices in the array)
hm, so then how do I get the different fields?
i had this all figured out a few months ago but i lost the code i was using 😭
How you do it is beyond me as it is highly library dependent
im using ProtocolLib
sorry i meant to put ProtocolLib instead of protocol in my original message 😄
ok, looking at some things it looks like the index is different for each "type"
im sorry im sadly not that great with java first off so pls no bashing for this basic question, so with PDC i can give an interface as parameter like this PersistentDataType.STRING, however ive seen its using a template system, PerisistentDataType<T, Z>. how can i now use this in a fashion like this PersistentDataType<java.lang.String, java.lang.String> instead ? im having a function thats supposed to take an Object as parameter since every class including primitives are derriving from that class and then resolve the Object into its type and give it as param for the PersistentDataType interface
that its practically working like this
public boolean setItemData(String key, String value)
{
if (this.is != null)
{
if (this.is.hasItemMeta())
{
ItemMeta meta = this.is.getItemMeta();
meta.getPersistentDataContainer().set(new NamespacedKey(main.getPlugin(main.class), key), PersistentDataType<value.getClass().getSuperclass(), value.getClass().getSuperclass()>, value);
this.is.setItemMeta(meta);
return true;
}
}
return false;
}
if that shouldnt be possible ill simply serialize everything to a byte array and treat them equally
same
i hate people who dont use early returns
can you create a world that never ends up in the disk?
early returns > else
but that code style is bad indeed
if else be like
:{
spaces boiiiiiiiiiii
You mean store it in ram?
i doubt it would be possible to use a world without ever saving it to the disk/other data source, you could just delete it whenever you’re done with it though if that’s what you’re looking for
Does someone know how i can do if a player gets hit that he stays on the ground and not make a little jump in the air?
Like a smoothattack or something
maybe cancel the event and deal the damage yourself?
Its not about the damage itself but that the attacked player goes backwards without going in the air
is persistent data only for items? or can i add persistent data to entities as well?
yes you can
cancel the event, set the knockback to the knockback they would have taken except the y attribute of the vector is 0?
Hmm i can try that, thanks!
np, hope it works
if String isn't a primitive object, how come I can get it without needing an import statement?
the words primitive and object clash imo
its in the java.lang package
which is imported by default
?learnjava moment
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.
wheres the w3schools one tbh
w3schools isn't that great for java last time I checked (which must be a few years ago now)
for beginners it can be but ye
Bukkit.addRecipe(new FurnaceRecipe(new NamespacedKey(plugin, "recipe_furnace"), new ItemStack(Material.EMERALD, 1), (RecipeChoice) new ItemStack(Material.EMERALD), 1, 200));
```does this work to create a cooking recipe from a specific itemstack?
instead of just material
i want a recipe with explicit matching material
better question how do i make it work
because ive seen recipes hold a value
setInputChoice
You can;t cast an ItemStack to a RecipeChoice
RecipeChoice.ExactChoice choice = new RecipeChoice.ExactChoice(new ItemStack(Material.DIRT));
```think ive figured how
thats being accepted by the api
its being accepted by the frontend
its demanding explicit nbt data now
so u can make crafting recipes with custom items without using the api wow
smelting*
lol this is just working fine without cancelling events, vanilla base item that the custom item is derrived of is not recognized as source material```java
Bukkit.addRecipe(new FurnaceRecipe(new NamespacedKey(plugin, "furnace_diamond"), new ItemStack(Material.DIAMOND, 1), new RecipeChoice.ExactChoice(DiamondDustPile.getItemStack()), 1, 200));
when ive been asking...
oneliners aaaaaa
item.getItemMeta().getDisplayName(); why tihs not return item name?
whats it returning then?
nothing
or is it throwing a npe?
that doesnt explain why no one has ever told me explicit smelting recipes are a thing when ive been explicitly asking at multiple occasions. ive only found this by chance when digging trough the api
like empty string
for a different thing
and then thinking
wait thats a thing?
with the general answer being
"nah you can only give a material for furnace recipes"
when this is clearly not the case
What's the max bow durability?
?
p.getinv,getiteminmainhand.getmaxdurability
or p .getiteminhand
thats literally on the wiki...
I think cntrl+H for tooltips
durability is hardcoded and dura changing enchantments dont even touch it directly
includes duribility in lore
or that
if the itemstack doesn't have any custom name, so it renders the default minecraft name that will return "". to get the name you should use the material i guess
the name would return correctly only if there is a custom one
im playing with a /fix command that im struggling with atm
setting item duribility to max durability sets it to 0
So why isn't this setting the durability in chunks of 3?
can you create a world that always stays in ram and that doesnt get saved to disk?
define "always"
when the server is closed it is gone
i know i could delete it when my plugin is disabled but i was wondering if there was the better option of making the world not save at all
Hello guys, who can help me with plugin RPchat?
anyone know this the following code sets durability to 0
ItemStack inhand = p.getInventory().getItemInMainHand();
short maxDurability = inhand.getData().getItemType().getMaxDurability();
inhand.setDurability(maxDurability);
p.updateInventory();
sender.sendMessage(prefix+ChatColor.WHITE+" Repaired item in-hand");
Durability is more of a damage indicator. 0 = a new weapon
whats the best way to go about getting the repair command done
if you want to repair an item, set durability to zero
did itemstack overrides equals()?
two stacks of different sizes will not be equals(). Use isSimilar to compare stacks
oh thanks man
and yes ItemStack overrides equals()
okay nice explicit items with nbt data as crafting material also works for crafting recipes making manual checking at runtime obsolete
great
nice
quantities require runtime solutions
needing more than one of an item
like look m8
//Diamond Dust Recipe
ShapedRecipe recipe_diamond_dust = new ShapedRecipe(new NamespacedKey(plugin, "recipe_diamond_dust"), DiamondDust.getItemStack());
recipe_diamond_dust.shape("CCC", "CCC", "CCC");
recipe_diamond_dust.setIngredient('C', new RecipeChoice.ExactChoice(new ItemStack(Material.COAL_BLOCK)));
Bukkit.addRecipe(recipe_diamond_dust);
//Diamond Dust Pile Recipe
ShapedRecipe recipe_diamond_dust_pile = new ShapedRecipe(new NamespacedKey(plugin, "recipe_diamond_dust_pile"), DiamondDustPile.getItemStack());
recipe_diamond_dust_pile.shape("DDD", "DDD", "DDD");
recipe_diamond_dust_pile.setIngredient('D', new RecipeChoice.ExactChoice(DiamondDust.getItemStack()));
Bukkit.addRecipe(recipe_diamond_dust_pile);
//Furnace Recipe for Custom Items
Bukkit.addRecipe(new FurnaceRecipe(new NamespacedKey(plugin, "furnace_diamond"), new ItemStack(Material.DIAMOND, 1), new RecipeChoice.ExactChoice(DiamondDustPile.getItemStack()), 1, 200));
Bukkit.addRecipe(new BlastingRecipe(new NamespacedKey(plugin, "blastfurnace_diamond"), new ItemStack(Material.DIAMOND, 1), new RecipeChoice.ExactChoice(DiamondDustPile.getItemStack()), 1, 100));
```bad coding its just a test ik, this already makes a fully functional system to craft diamonds from coal
this, can easily be put into a softcoded loader system
yes