#help-development
1 messages · Page 1614 of 1
what
oh wait, sorry
@covert valve ./.m2/repository/org/spigotmc/minecraft-server/<server version>',
Mojang -> Obfuscated is "maps-mojang.txt"
Obfuscated -> Spigot is "maps-spigot.csrg"
ok thanks
And then theres the maps-spigot-fields too
Did you build Spigot with BuildTools
no i grabbed the NMS mappings from the codemc repo but it's identical
im just trying to figure out what PacketPlayOutAutoRecipe is
otherwise i'm just going to go back to spigot mappings
Oh lmao I can tell you
which one
is there an event to detect that rain falls on a block?
I can't seem to find it apart from MoistureChangeEvent, but that's good only for soil
Try ClientboundPlaceGhostRecipePacket
ahh thanks
i hate that spigot ever had spigot mappings over nms mappings
because now i need to relearn the entire nms internals
great
If that doesn't work the other packets relating to recipes are ClientboundRecipePacket and ClientboundUpdateRecipesPacket
Yeah it's frustrating but being able to use Mojang's names is kinda nice
Once you figure it out anyways
yeah
in recipes, do spaces represent nothing?
does reflection work with mojang mappings?
Believe it works with paperweight, no?
as if paperweight has reflection support 😂😂
can i even use the mapped ones then if i can't use reflection? i use it quite often
¯_(ツ)_/¯
anyone experience with ByteBuddy Advice ?
how do i use reflection with it then? i can't use both mojang and spigot mappings
You need one reflection for before 1.17 and another one for 1.17+
that's fine
i mean can i use reflection with the mappings?
lemme show you
@Override
public void modifyPacket(@NotNull final Object packet) throws NoSuchFieldException, IllegalAccessException {
ClientboundPlaceGhostRecipePacket recipePacket = (ClientboundPlaceGhostRecipePacket) packet;
ResourceLocation key = recipePacket.getRecipe();
ResourceLocation newKey = new ResourceLocation(key.getNamespace(), key.getPath() + "_displayed");
Field fKey = recipePacket.getClass().getDeclaredField("recipe");
fKey.setAccessible(true);
fKey.set(recipePacket, newKey);
}
actually ill check the mapped output
Oh fuck nvm https://github.com/PaperMC/paperweight/issues/35
Yeah when using reflection you have to use the Spigot mappings names. yay
you have to
great
that means i'm basically fucked
i think
or i have to use 2 modules for my 1.17 NMS
Why
1.17 only has Spigot mappings for classes methods are unmapped iirc
Eh I don't really mind. Mojmaps are great
Some of the methods are renamed I think, like playerconnection.sendPacket is now connection.send iirc
they suck if i can't use reflection
which i need to do
to accomplish a lot of stuff
P, a, r, a, m, s (:
Parchment
You can use reflection, you just have to use the names that the Spigot JAR uses and not Mojmaps
How complete is parchment?
but since the classes are different
i just can't
You can
They're working on it. How complete was the other mappings
You're supposed to remap your JAR at compile time
No
Oh yeah good point olivo
i have the special gradle plugin it's being remapped
Method names are more useful than param names
param names are extremely useful if you for instance have 2 int params
Saves a lot of time (:
Thus yarn 😌
🤨
i can't do what i need to do
i can't use reflection
which means i have to use unmapped as well
You can. I've done it lmao
Why 2 modules?
Lemme get it
how many times do i have to say it
one to use moj mappings
one to use reflection
i feel like a broken record
You don't need 2 modules though you just have to figure out unmapped names
Yeah well you don’t have to but I guess it saves hella lot of time
The fact you can't get title after creation of a custom inventory after it's created is some serious bullshit
There's no good reason to not allow access to it, I've looked at the source
Because everyone is moving to Mojmaps
Is there no reflection to access it?
i can't figure out unmapped names because the classes are different
Do you want to identify an inventory by title?
some classes just don't exist
There is, but it's stored in minecraft
For events etc
bruh just make a getter
No, serialize it
Ah okay good
NMS to get an inventory name?
and the stuff doesn't exist at runtime anyway
Is it not serialisable by default
so what's the point
Spigot should make a getter
No.
Oof, can't find where I used reflection.
can you link your repo
Mojang should rewrite the server code
So there's no inventory.getName()?
and also add a transfer packet
CustomInventories have their own instance where they could ridiculously easily store the string title, what a shitshow.
It's not public otherwise I would
🤦♂️
Does nms inventories store it liquake?
Yes
Yeah probably spigot api flop
Cuz mojmaps good (:
It was removed due to inventory views not being connected with titles for all things.
At the server I work for, our utils use NMS inventories because spigot-api is limiting
I see no reason for spigot-api to remove Inventory#getTitle
Because it used to exist
so i have to download the non-existent mappings
Someone just decided to yeet it illusion lol
@ivory sleet However - the custom spigot ones should have their name stored. It has it stored in their NMS implementor
in order to use these non-existent mappings
so i can run some non-existent code
to do something
I haven't used 1.17 yet
They just wanted to break all plugins checking for title
just store it yourself then
Take a look at CraftInventoryCustom for more details
Lmao kinda a justified reason
this feels like it was intentionally done to make NMS as tedious and inconvenient as humanly possible
Don't control all inventories coming into my API
NMS isn't that hard
Mojang had no reason to yeet the multi_block_change packet and rewrite it entirely
I hate that every tutorial ever tells you to identify your custom inventory by title
Yeah Liquake IdentityHashMap<Inventory,String> maybe altho Idk if spigot creates delegates sometimes
make a new one
Luzifer I want my code review
I gotta make a yt tutorial some day
send it again i was in vacation
I should but idk if my method is the correct one either lol
"Illusion's masterclass - Colorful language towards static abuse (EP 1)"
I store them by reference in a manager
And remove when there are no viewers left
Here
@ivory sleet Literal excerpt:
public class CraftInventoryCustom extends CraftInventory {
public CraftInventoryCustom(InventoryHolder owner, InventoryType type) {
super(new CraftInventoryCustom.MinecraftInventory(owner, type));
}
public CraftInventoryCustom(InventoryHolder owner, InventoryType type, String title) {
super(new CraftInventoryCustom.MinecraftInventory(owner, type, title));
}
public CraftInventoryCustom(InventoryHolder owner, int size) {
super(new CraftInventoryCustom.MinecraftInventory(owner, size));
}
public CraftInventoryCustom(InventoryHolder owner, int size, String title) {
super(new CraftInventoryCustom.MinecraftInventory(owner, size, title));
}
static class MinecraftInventory implements Container {
private final NonNullList<ItemStack> items;
private int maxStack;
private final List<HumanEntity> viewers;
private final String title;```
what method do you mean?
Would be so ridiculously easy to add a getter
It's a hashmap between inventory and a set of players iirc?
oh
Myeah liquake
Hold on I'll find it
i would not say its wrong. its better than identifying by the title. but i would prefer implementing inventoryholder
We gotta join forces and make "GoodSpigot" with a built-in Custom Entity API and easy access to pathfinders
And then we have the inventory view comparison developers
how do i make it stop saying im typing
😌
modified discord client
á ripcord
Olivo https://pastebin.com/ZF3fcric review!
not recommending it since its not alowed from discord
true
0/10 using pastebin
Don’t judge bin 😦
pastebin only good for standalone files
yo what the fuck
Saw this so I avoided it
Yeah this need some work
Ikr, awesom3!
ik, saw that too. but it works and is a clean method to do it
Kinda bs
Since half the classes in spigot api are not
The InventoryHolder api has been in the spigot api forever, doubt it’s subject to change for a long time
My hidden soft spot!
also, where is that noted by bukkit itself?
Again though
is there any api-note in the javadocs to avoid using it to create custom guis?
Can't force incoming inventories I serialize to implement it
For now I've just added an overloaded method to provide the title seperately
If you need it saved
It’s a functional interface iirc
But again, it's a joke spigot doesn't just have it for createInventory results.
If someone who's done a PR before wants to add it, please do
if it works, its fine. but it doesn't really look like OO or even right. if you already have your customgui, why not just let implement it InventoryHolder?
found this on github a few years ago
🤣
before github had dark mode
What a fine memory
this line errors me "Operator '==' cannot be applied to 'org.bukkit.block.data.BlockData', 'java.lang.String'"
if (e.getBlock().getBlockData() == "7") {
Lmao
Yeah
lol...
okay thanks, but could you help?
BlockData isn't a number, it's an object
== is for primitive equality or instance/reference equality whatever you’d call it
I have a feeling you're trying to use old magic numbers.
Learn about the blockdata stuff, as it's how things are done now by mojang
what the fuck is that

Copypaste go brr
It sent a different login message depending on your game version
Except it was like 400 lines of copypaste
And when I made a PR to lower it to 1 line it got refused for "didn't work"
this have to be a troll
🥲
Commission work is fun
I made 60$ in 1hr by just doing a basic trade gui
you gave 5 cobble and got 1 iron, for example
Oo money in the bag 
With configurable recipes or whatev
Nowadays I just charge a flat hourly fee and waste 8 hours debugging an int
LOL
please tell me thats a joke
so i tried this, but that didnt do anything either
Ageable age = (Ageable) e.getBlock().getBlockData();
if (age.getAge() == 7) {
I legit found it like that on github
It's not
😌
ProtocolLib doesn't use half the data wiki.vg/Protocol gives
you gotta decompile the packets and watch the fields
using pastebin, ew
your instance and class vars looks horrible. a not static method above your constructor, which does not belong to the factory method pattern? EW
you ever heard of the final keyword when instantiating instance vars right away?
at least you use a switch instead of spaghettinating
EDIT: nvm
unnecressary comments, burn them.
i cant even look at what you are doing there with your files
split your code into several methods.
your code further down seems like you abused your CTRL+C/V
sometimes you use this, sometimes not ??
your formatting is bs
EventManger#getPlayer what da actually 
that looks like my teacher's code
😌
how long has it been since you did that
at least 5 minutes
i mean my first spigot commission looked way worse than this
My first spigot commission was basically a shitty +-*/ math parser
Location newPoint = point.clone().add(0, 1, 0);
System.out.println("Location " + newPoint);
System.out.println("Drops " + newPoint.getBlock().getDrops());
System.out.println("Max " + maxAmount);
if(point.getBlock().getDrops().size() < maxAmount)
{
final Item droppedItem = newPoint.getWorld().dropItem(newPoint, item.amount(amountToSpawn).build().make());
droppedItem.setVelocity(new Vector(0, 0, 0));
}
Why does Drops print an empty array if there are actual drops? If I go 1 location down the list contains only the actual block (It are slabs)
Didn't know inventoryholder could be extended lol
mine was some faction shit to upgrade your pickaxe. i didn't even know what a loop was so i copy pasted one code block 1000 times to just change one int value up
its an interface, ofc you can extend it
So is pretty much anything in the API but 90% of it breaks
this is all confuzzeling, just get a friend to make the plugins for you
das wut i did
I'm the friend that codes plugins lol
get your friend to code it then say its you
XD
simple
pass along the job XD
Also reading up on InventoryHolder it's apparently supposed to only be used for blocks and not designed to be implemented?
idfk
Generally what I do is
i get friends to do the plugin making then say i made it
Create a class that extends InventoryHolder
and use it as the holder
You can do your checks
Anyone knows how to fix it?
But proper use is to make a menu class that implements InventoryHolder
And then just check if inventory.getHolder instanceof Menu
for that we have the BlockInventoryHolder
but yes, its to identify f.e. if the inventory is a chest
newPoint vs point
Print is one thing rest of code uses another
Yes, if I go 1 down it is point
If I print point, then it prints the actual block as 'drops'
So it should be pretty easy to switch from the implementation I have to using inventoryholders
Yeah
But I will print both
In my listener check if the holder is my base class and then call onClick() in my CustomGUI
yeah
I'll give it a go when I'm back home ty
if(e.getView().getTopInventory().getHolder() instanceof LogGUI) {
LogGUI logGUI = (LogGUI) e.getView().getTopInventory().getHolder();
logGUI.handleEvent(e);
}
[20:19:13 INFO]: Drops [] //newPoint
[20:19:13 INFO]: Max 12
[20:19:13 INFO]: Location old [ItemStack{SMOOTH_STONE_SLAB x 1}] //Point
@chrome beacon
Yeah I don't see what the problem is
So any way I could detect rain falling on specific block types?
Bug report?
For what. I don't know what you're having issues with
Like what are you expecting
I am expecting some iron ingots, but the list is just empty
What block drops iron ingots?
.-.
is there a way, with the spigot api, to keep a chunk loaded? at least for a period of time, not forever
Chunk Loading tickets iirc
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Chunk.html#addPluginChunkTicket(org.bukkit.plugin.Plugin)
and then unload it after you are done
You know how you can get a plugins version from a url (https://api.spigotmc.org/legacy/update.php?resource=_____), is it possible to get this value in HTML for a website?
dont use the legacy api
I just downloaded Ubuntu and when I tried to test my plugin it didn't work.StringBuilder sb = new StringBuilder(); sb.append("jdbc:sqlite:"); String path = Bukkit.getServer().getPluginManager().getPlugin("PrivateVaults").getDataFolder().getAbsolutePath(); sb.append(path); sb.append("\\privateVaults.db"); url = sb.toString();
and this won't work on ubuntu only on windows
because windows uses for path \ and ubuntu uses /
how do I fix it?
but will the / work on windows?
Ok, I'll try
How I can disable phycics (sand, gravel etc.)
Cancel BlockPhysicsEvent
How I remember this don't work ;/
It's buggy on client side iirc
At least cancelling EntityChangeBlockEvent is
PhysicsEvent gets called very often (every block update i think)
I'm confused, I have a hash map with an int and a player, I want to get the integer using the player, how can I do this?
nvm, I'm being stupid
Wait, no
No, I just want to get the integer the player is related to
is there a reason you have integer first?
It makes it easier to check if they player has something selected
The EntityID for the NPC
Okay
Only when they select a different NPC
gotcha
why is this running every tick? i literally specified every 12000 ticks
new BukkitRunnable() {
public void run() {
System.out.println(fillRtpLocationsTimer * 20L);
fillRtpLocationsTimer();
}
}.runTaskTimer(this, fillRtpLocationsTimer * 20L, fillRtpLocationsTimer * 20L);
[17:07:19 INFO]: 12000
[17:07:19 INFO]: 12000
[17:07:19 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:21 INFO]: 12000
[17:07:21 INFO]: 12000
Why are you running fillRtpLocationsTimer?
bc thats another function that does a lot of stuff
one of them, starting a new different timer, is that a problem?
or i cant start more than one timer per plugin or something like that? that would be bad
Naming it the same thing as the interval you're trying to run right now possibly is
^
right
youre right
im stupid, i didnt realize
but why isnt intellij saying anything about that?? wtf
Also, instead of multiplying it three times, make a variable that does it once
that will just be multiplied once, and the print is temporary
and multiplication isnt a problem nowadays
i cant believe how i cant use integers in conditional checks, but mutiplying a function is totally fine
Any ideas?
I don't as a map should technically be the other way
I thought I had a util for it but I checked and didn't have one
Okay
it stills the same
hmm
Try making a variable with that multiplication and see if it changes anything
hey i have a question
can i Bukkit.getOfflinePlayer(their uuid) to get an offline user, despite having them join or not?
because i imagine that's for every single mc player based off UUID
where Bukkit.getServer().getOfflinePlayer(etc)
gets the SERVER offline player
or am i stupid or
Bukkit is just a wrapper for server
thats what i thought
They do the same thing
Don’t try it (:
anyone know where i can get spigot -> mojang mappings?
Can you actually do that? LOL
i'm trying to find MojangsonParser
i'm gonna look in Skript's source code
Believe so
because when i used skript you could do "uuid string" parsed as offlineplayer
despite if the user has joined or not
so
therefore
yes
Sounds like a terribly good idea
Maybe minimappings got that?
hey how should i get an OfflinePlayer of somebody who has never joined before 😳
By name or uuid
that returns Null for me
I have a little question:
How can I do that you execute a method but the code continues underneath
um
what
Cap
no cap no cap i send screenshot
Elaborate
Make sure you put the right info
UUID.from("uuid string")
waitwaitwaitwait
im using Bukkit.getOfflinePlayer(
should i be using something else
No
yeah im getting them by UUID
actually in this specific instance i believe by name
i'll double check
main() {
print("a");
b();
print("c");
}
b(){
print("b");
}
You're aware thats already how it works?
That returns a b c
k theres my code:
what is when the b() has a loop
Same thing
thats something you as programmer would know
it can't find what IChatBaseComponent is
alternatively you can call the method b as a sceduler task
Methods are reusable instructions composed of other instructions
?paste
?pastemd
ah
TextComponent maybe?
👍
Well, I think I got it, but it's probably a complete mess
so idk why getName() is null
Cuz the name was never cached
owo?
getName only works on players that have played
oh yikes
how should i get their name then
there's gotta be a way
You will have to use MojangAPI
ahh i c
Wait
first time using JSON stuff :o
whaaat
Yeah what olivo said and maybe create your own cache?
^^
idk how to do that
anyone have the txt file that spigot uses in special-source?
Ah rip
Wish I could help but won't have access to my PC for another week
nvm its TagParser
CombatLogX does need some rest after all
How disable phycics?
Wearing as in armor/an offhand tool?
There's no armor equip or remove event
So you have to either use another plugin that adds an armor equip event
||Paper||
Or like I did, make a loop that runs every second and checks for my enchantment
Yeah, but not everyone uses it
True but many do
I was wondering if you could somehow see if the server the plugin is running on is Paper so I could use Paper's event for it
How is magic stored? Lore?
Might i suggest keeping a map of online players and running a Sceduler function every 20 ticks instead? I'd imagine that would reduce the load massively
running anything once per tick isnt a good idea
I was checking meta (if the player had a chestplate at all) every second and it didn't take much
that times twenty? If it's not supposed to happen per tick dont put it in a onTick event...
Also i now cant help but wonder what is called once per tick, aside from random ticks
that whole message sounds stupid
will look ar
t
at
Should grabbing data from a db be async?
Always
Always always
ok thanks
how can i send message to player?
Player#sendMessage
thx man you made my day
@lost matrix since i'm getting multiple values from the player in the db that is under the same column I should be saving them in a list or array ?
Why ping?
Neither. Object orientation.
Create a class for your player data and then use a manager class
which contains a Map<UUID, DataClass>
you presumably want to associate your player data with a player
see what I was doing before was using Getter and Setters
which is done with a map
Couldn't you do the same though with getter and setters?
you don't want to run to your db every time you want to get something
you should cache it in memory
every request to the db can potentially take a round trip around the globe and several dozen ms to complete
and to cache the things, you need to associate the things with a player
which you use a map for
perimeter?
Sorry parameter
what parameter
Value
what
the shit in the <>
yea
close enough
it means that the keys will always be UUIDs
and the values will always be DataClass's
hey there is there way for somebody to explain why this error exists? this is my class A:
public class A
{
System.out.println("Hello world");
}
and this is my class B
public class B
{
public static void main()
{
A a = new A();
}
}
``` for some reason im getting a `NoClassDefFoundError`
the only difference is that they are in different packages!
what kind of data does the player have
you don't
you create a class that has a field for each of these bits of data
and then put instances of that class in the map
The player has a cooldown name and a time
?learnjava
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.
then the data class should have 2 fields, a name and a time
i just made that as an example
i assumed "cooldown name" was a single entry
no
well, 3 fields; cooldown, name, and time
so i dont need to show my full class and complicate more
your player probably can have multiple cooldowns as well
Yes
you dont have to, just follow those links
what are your cooldowns identified by
does Sound.valueOf("") for THE_SOUND_ENUM_NAMES_LIKE_THIS or the.sound.names.like.this
ok
i speak englihs i promise
A String
is that the name?
Yes the name of the cooldown
so then you have a field in the player data class that holds a map
fair
that holds name -> cooldown data entries
huh
you're probably having an aneurysm right now
yea
this is because you're trying to convert relational data from a relational database to an object oriented type of data
it takes some hammering around to get it to turn from one to the other
and is the biggest pain with managing databases
really
in the db you have rows and columns
yea
in java you have maps and fields
you can consider each table of the db a map
and the primary key of the table is the key in the map
and all of the rest of the columns of the table are shoved in a single class
say you have a table with columns [playerId, playerName, lastPlayed]
in oop that'd correspond to a Map<UUID, PlayerData>
there UUID is the playerId
and the PlayerData class holds playerName and lastPlayed in fields
Can i mp anyone just to giving my screenshoot ? i just need information
?
consider learning english
he's insult my BIUTIFULLY english ?
😬
now is PlayerData method?
PlayerData is a class
public class PlayerData {
String playerName;
long lastPlayed;
}
PlayerData data = map.get(playerId);
String name = data.playerName;
I think im understanding this a bit better with your examples
i do give examples, i just keep them to a level that isn't spoonfeeding
NNY has a crush on me that's why
Guys, who know how can i write here ? ^ screenshot top (i dont want spam screen)
Player#sendMessage
sendMussage
for sending message, i want write where point arrow
Rename the item
oh
Player#sendMessage
No he wants to change the item name
and you're complaining?
lmao
maybe it's just a really good plugin
^
maybe someone downloaded it 21,000 times
Yes, but with command blocks we can write here, so maybe we can with plugin
ay you never know
https://prnt.sc/1i68lz8
i want write here, but without rename item
action bar?
not exactly but pretty close
oops
the itemname bar is afaik completely clientside
lmgtfy
so you'll have to make do with actionbar
when would you make an event final and when wouldn't you? What's the benefit of making it final?
why is it .app
literally just java
the benefit is that it can't be extended if it's final
it makes no difference
as for what that means for the particular event, who knows
Ok
i was fake pinged ? xD
unless you're registering the subclass, the method is gonna be called for the superclass
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(msg));
i finded !
...
spigot, hiding things under obscure .spigot() methods since 2015
why tf do you have spigot() in player.sendMessage?
because that's where the sendMessage method for actionbars is declared
Player::spigot returns some sort of a spigot player or something
someone had the brilliant idea of putting some random methods on that object instead of the actual player object
i'm sure there was some kind of reason for it initially
but was it a good reason... No.
All of Mojang's changes in a nutshell
Anyway, why tf does my plugin not see my config was changed? I'm calling another function, waiting 20 ticks, then reloading the config and getting the field in a new variable after it was changed.
are you pulling the value fresh from the config
Pretty sure, I'm reloading the config 20 ticks after the other code of the function it's in runs, then putting the config value that should be updated in a new variable
by "putting the config value in a new variable", you mean you are grabbing the config from the plugin with plugin.getConfig()
and then calling config.getWhatever
Custom config, I'm pretty sure the reload code is fine
show code
public void reloadConfig() {
if (this.configFile == null)
this.configFile = new File(this.plugin.getDataFolder(), "NPCstorage.yml");
this.dataConfig = YamlConfiguration.loadConfiguration(this.configFile);
InputStream defaultStream = this.plugin.getResource("NPCstorage.yml");
if (defaultStream != null) {
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream));
this.dataConfig.setDefaults(defaultConfig);
}
}
and you are retrieving the fresh instance from this.dataConfig
and calling getWhatever on it
and storing the return value in a field
Should be, I am, and I am
it should by all means work then
Is the class containing this method a singleton?
you and your singletons
No
Then make it one. If you create an instance of this class and save it in a field then the fields of that instance wont be updated if you call reloadConfig() on another instance.
But I'm trying to get the updated config from the other functions
what bratwurst man is trying to convey is "are you creating more than one instance of this class"
How many instances of this class do you create. (by using new YourClass())
Pretty sure none

brilliant
Everything in it is used by a command or another function
let's take a step back and make sure you know what instance means
Show one example of this pls
For when someone sets look at nearby players to true with the command
if (args[2] != null && args[2].equalsIgnoreCase("true")) {
file.set("data." + npc + ".look", true);
Bedwars.saveData();
player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.AQUA + ChatColor.BOLD + "BW" + ChatColor.DARK_GRAY + "] " +
ChatColor.BLUE + "NPC will now look at nearby players");
NPC.reloadNPCs(player);
FileConfiguration file = Bedwars.npCstorage.getConfig();
Caused by: java.lang.NoSuchMethodError: 'org.bukkit.util.Vector org.bukkit.util.Vector.rotateAroundY(double)'?
it seems to be fine, no errors in the code
no idea what i did wrong there
Server and development version dont match
are you compiling against the correct version of the api
inb4 you're building against 1.16 but running on 1.8
the server is 1.8.8 and that's what i'm building against
hi
i believe so
Dont. 1.8 is going to be decade old soon. And support was dropped half a decade ago.
my server version is 1.12.2
imagine if literally anyone was up to date
You forgot @EventHandler
emm where need i added?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
cry... have error
reloadNPCs is the thing that isn't seeing the updated config
ik but i just do it for the pvp.
is that the reason why i'm erroring?
i'm sure crying will help
- Dont expose non final fields like that.
- Should be fine
Well
I think 1.8 doesnt have this method. You need to do the tedious vector math yourself. Means you are probably not building against 1.8
Hey guys I have some trouble rn with getting an Service class of mine.
This is how I do it:
RegisteredServiceProvider<MyService> serviceProvider = Bukkit.getServicesManager().getRegistration(MyService.class);
if(provider != null) {
this.someService = serviceProvider .getProvider();
}
I am running out of ideas, the serviceProvider returns null but I printed out Bukkit.getServicesManager().getKnownServices() which contains my services class
There are plugins that remove the cooldowns
Well, it doesn't work
but muh KNOCKBACK
Make sure the plugins properly depend on each other and the service registration is opened in onLoad and registered in onEnable
and muh TNT CANNUNS
I need more information on this. Could you explain to me again what you expect to happen and what you observed?
?paste
expect to happen: it work
observed: it not work
I am registering the service like this:
Bukkit.getServer().getServicesManager().register(MyService.class, this.someService, this,
ServicePriority.Normal);
is that correct?
What do you mean by onload in 1.16 I could do the registration in the onEnable as well as getting the service, did that changed in 1.17 ?
then:
if(!isWorking()) {
doWorkAgain();
}
killed by watchdog
https://paste.md-5.net/akuyajocij.pl how to solve?
Make an instanceof check before you randomly cast classes around.
learning java is a good first step
Emm have wiki?
DuckDuckGo. Privacy, Simplified.
I also have the Plugin which contains the service in the depend section of my plugin to use
So when this runs, the map I have for storing NPC selections gets cleared, if you have an NPC selected and the NPCs get despawned, then they get respawned by another function. 20 ticks later, it reloads the config to make sure it gets updated, then puts the new NPC entity ID and player back in the map so it's like nothing changed for the user.
Because the function doesn't get the updated config for whatever reason, the values are still the same and it just does nothing when you try to run a command to modify an NPC again
randomly cast classes? emm
@lost matrix any idea?
Respawning an NPC will most likely change its entity id
Did you consider that?
That's why the config not seeing the changes is an issue
i dont know xD
Try getting the registration in the onLoad() method and actually register it in the onEnable()
can tell me add to where before?
so get the service in onLoad and registering the service in onEnableif I got that right
Before you cast something -> check if what you cast is actually the proper type
You can do this by checking if the object you are about to cast is an instance of the class you are about to cast to.
This can be done using if(object instanceof TheCastClass)
Is it maybe using the value from entityIdOld for entityIdNew because they're getting the exact same thing? Ignoring that the second one should have been updated.
why are you even saving the eid in a config
Easier to get it and update it with the new ones that way
eid is transient
Im sry but the code is quite convoluted and i dont know how your data is structured. Its hard to help with a problem if you dont have proper separation of concerns. The bug could be at a lot of places.
config is persistent
So
if(obj instanceof Double) {
int DH = Integer.parseInt(DefaultHealth);
player.setMaxHealth(DH);
}```?
the two shouldn't go together
Anytime the eid changes, the config is updated with the new eid for the corresponding NPC
Couldnt be further from that
what
learn java
Also: Player#setMaxHealth(double) is deprecated. Use attributes instead.
What spigot version are you on?
@lost matrix still getting the same result
Spigot 1.12.2 and Spigot API 1.12.2
data:
'1':
x: x
y: y
z: z
pitch: pitch
yaw: yaw
world: world
name: name
texture: texture
signature: sig
look: bool
lastEntityID: last eid
?paste
Hm. Mind showing both registering and retrieving the service provider?
That's what is run if it sees the player running one of the commands has an NPC selected
Registration:
Bukkit.getServer().getServicesManager().register(PlayerRegisterService.class, this.registerService, this,
ServicePriority.Normal);
Getting the service:
@Override
public void onLoad() {
System.out.println("known services: " + Bukkit.getServicesManager().getKnownServices());
RegisteredServiceProvider<PlayerRegisterService> provider = Bukkit.getServicesManager()
.getRegistration(de.schmidi.playerRegistration.services.PlayerRegisterService.class);
if (provider != null) {
this.playerRegisterService = provider.getProvider();
}
}
1.12.2
loadNPC creates an NPC with the skin and whatever from the yml
Dont get the service in onLoad(). At that point no service will be registered.
Registration in onLoad(), lookup in onEnable()
Also tried it in onEnable() already
oh okay
why that dont work ?
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
Entity entity = e.getEntity();
if(entity instanceof Arrow){
if(e.getHitEntity().getType() == EntityType.CREEPER) {
e.getHitEntity().isDead();
}
}
}
@Override
public void onLoad() {
System.out.println("Registering service");
Bukkit.getServer().getServicesManager().register(PlayerRegisterService.class, this.registerService, this,
ServicePriority.Normal);
System.out.println("regostering done");
}
like this right?
isDead doesn't do what you think it does
Player#setMaxHealth() uses a double. You dont need to cast that.
again, consider learning english
isDead doesn't make the entity dead
it asks the entity "are you dead"
and returns whether the entity is dead or not
i just try, how kill him ?
.remove()
lol, and remove entity that correct english ? XD
You is ded now 
but thx
So what i need cast?
You dont need to cast
Yeah, "get entity that was hit then remove that entity"
Show the whole method in question pls
?paste
At least in English Java understands lol
What IDE do you use?
Eclipse IDE
Then go into your class and press Ctrl + Shift + F pls
but if i want entityType.player
can i again use remove ? xd
I mean, the commands that use this would just reload the config, but the loop that is moving the NPCs heads also isn't getting the updated config
Here:
((JavaPlugin) player
A Player is not a JavaPlugin. So you can not cast a Player to a JavaPlugin.
So what i need to do?
Not casting a Player to a JavaPlugin
((JavaPlugin) player). <- Just remove all of this
No, for players it would be setHealth(0) lol
i can't just make damage ?
You can set how much damage something should do iirc
iirc ?
i remove that but same have error
If I recall correctly
can you just not go and learn java and try again when you have even an inkling of a clue as to what the fuck you are doing
@reef wind I am the most racist man
NNY so in my player data class what should I consider having in it?
what kind of data do your players have
Player UUID, Cooldown, Time
what do cooldown and time represent
Right now I have it so when the player joins their data is loaded
Cooldown is the name of the cooldown and time represents the time of their cooldown
but the player can have more than one cooldown at a time, yes
Yes
assuming there is no other data, your PlayerData class would only have a single field, then
that field holding a Map<String, Long>
that is, Cooldown, Time
each player can have multiple cooldowns; each cooldown has a time
uuid is the key
you can put that in the playerdata class too
but it isn't necessary
we already know the UUID, because we use the UUID to get the data
so am I just holding variables in the player data class?
that is its purpose yes
that doesn't work
ah ok
it holds data
still getting the same result
before this
((org.bukkit.entity.LivingEntity)e.getHitEntity()).setHealth(0); like this ?
wtf
map.put inserts data correct?
yes
now I'd have to use that when the player joins
myes
that work but idk if u want to make it like this
so their data can be added
but if I have PlayerData in the type parameter do I just pass the class through it?
oh yeah
if you have PlayerData in the type parameter, it means that the values can only be instances of PlayerData
I need to replace UUID to string
no, use an UUID
you may be storing it as a string in the database, but you should convert it to an UUID in your object code
what can I use to return a uuid with ResultSet?
UUID.fromString(string)
So, anyone have any idea why it just doesn't get the updated config contents?
I'm looking to add a single line to a player nametag using armor stands. Does anyone know of an in depth tutorial of how to do this? I've searched endlessly for answers. I've tested with passengers and various entities like slimes. If something does happen to space correctly, like a slime of size -1 with a small armor stand, I can still hit the slime to kill it. Do I need to make it invisible with packets? Not sure.
Can anybody help me with my issue? It's still about registering a Service?
Elaborate please
So NNY this is how I should be putting data when the player joins ```java
DataManager data = map.get(e.getUniqueId());
map.put(UUID.fromString(res.getString("Cooldown")), data);
So this is how I register my service:
@Override
public void onLoad() {
System.out.println("Registering service");
Bukkit.getServer().getServicesManager().register(PlayerRegisterService.class, this.registerService, this,
ServicePriority.Normal);
System.out.println("regostering done");
}
This is how I am trying to use it
RegisteredServiceProvider<PlayerRegisterService> provider = Bukkit.getServicesManager()
.getRegistration(de.schmidi.playerRegistration.services.PlayerRegisterService.class);
if (provider != null) {
this.playerRegisterService = provider.getProvider();
}
Problem is: the provider for the service when getting it is null, plugin is also running on the server and marked as a dependency in the plugin.yml
don't call it a manager
it doesn't manage anything
it just holds stuff
and isn't Cooldown supposed to be a name and not an UUID
@wild reef are you trying to make a cooldown manager?
Im adding their data when the player joins though
No? As I said I am trying to use a service from an other plugin
wait wrong @ sorry
when the player joins, you get the data from the db
right
then you take the player's uuid, which is a string in the database
and you convert it into an UUID
oh so im actually not using it in the map?
not yet
ok
UUID playerUuid = UUID.fromString(string from db)
OH Wait
then, you create a playerdata instance
I just noticed what I did
Still any idea how to fix it?
map.put(playerUuid, data)
mhm
I'm not familiar with services I thought you meant listeners sorry
next, you need to write some code in the PlayerData constructor
that actually grabs all of the cooldowns of the player
and puts them in the cooldown map
Is anybody else familiar with registering a service from an other plugin?
yes, in the PlayerData class
each player will have their own map
each player will have their own cooldowns
each player can have multiple cooldowns, and each cooldown must have data associated with it
hence; a map
so I'd want String, Long
yes
if your cooldowns had more data, you'd do the same thing you did with the player's data
you'd create a CooldownData class and make the map a <String, CooldownData>
but as the cooldowns only have one bit of data, the time, you can get away with just a long for now
ok
It should be a map of <UUID, Integer>
if cooldowns were identified by an uuid, maybe
but i guess they're identified by name
which, kind of subpar, but whatever for now
what do you mean they're identified by name?
what is the String
Cooldown
yes, but what does it contain
and that is the identifying part of the cooldown
one player can only have one cooldown with the same name
they can't have two "enderpearl" cooldowns
yea
which means they are identified by name
I have also the CONSTANT prim key btw on the cooldown and time I think
you mean constraint
that'd imply that the player can have multiple cooldowns with the same name
i have it on uuid and cooldown
right
Saving as a string can be corruptable in my experience
What else would I be saving it as?
it is not
UUID.fromString(playerUUIDString)???
also NNY in my PlayerData constructor I'm just passing through their uuid
yes, that is the player's uuid
which has nothing to do with the cooldown
what we have is effectively a Map<UUID,Map<String,Long>>
wait was I suppose to do that?
or Player -> {Cooldown Name -> Cooldown Time}
no, but that is what we have effectively
you could have done that but it would have been gay
nesting maps and collections is frowned upon
it leads quickly into unreadable and unmaintainable spaghetti
for the playerdata constructor, figure it out
you need the data of the player there somehow
so that you can put it in the cooldowns map
arrange it somehow
pass the resultset to it or do a db query or whatever
Having a cooldown system with my sql db
an object oriented cache for a db that stores cooldown information
so are you trying to save cooldowns to the database instead of a map?
he already has that part done
Yea
he's having problems with caching it in-memory in an object oriented way
okay let me think of a solution
the solution is to simply map the relational data into a reference based model
which he is well on his way with
okay but the problem he is having is that you are telling him 13 different steps at once
ok so I have both class done and the constructor
he can just read slower
it's not like you need to read the entire book all at once just because it's already written down
so what is the code you have so far?
alright so in my PlayerData class I have ```java
public class PlayerData {
public Map<UUID, PlayerData> playerMap = new HashMap<>();
UUID playerUUID;
public PlayerData(UUID uuid) {
this.playerUUID = uuid;
}
}
oh wait
that map doesn't belong in the playerdata class
the cooldown map goes in the playerdata class
since the cooldown map is part of the player's data
ok
public class CooldownData {
String cooldownName;
Long time;
public CooldownData(String cooldownName, Long time) {
this.cooldownName = cooldownName;
this.time = time;
}
}
``` CooldownData class
should I be making time equal to 0L?
in the constructor?
no so when you want to set cooldown
you do map.put(player.getUniqueId(), new CooldownData("cooldownname", time));
true