#help-development
1 messages Ā· Page 1592 of 1
technically I just wanted runtime (as classes are loaded) ASM transforming - which would allow mixin support
Well that goes over my head, good luck if you ever decide to make that into reality š
so wat
Well, I have already created a "working" prototype, but bukkit plugin classloading is throwing a rock at me
Hmmm, maybe I got an theory. All unobfuscated fields/methods are the one, that are from Entity or Living entity and not from Mob
Any1 with experience using bungeeapi and willing to make me a simple plugin for free pm me
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
you should say what you want also
ye
Yes, I can write a plugin that bans every joining player
how to get the player's xyz coordinates but all separately?
player.getLocation().getX()
rinse and repeat for the rest (perhaps even cache the location object)
other question
@EventHandler
public void onHit(EntityDamageByEntityEvent e){
if (e.getEntity() instanceof Player){
Player player = (Player) e.getEntity();
if (e.getDamager().equals(Guard)) {
player.sendMessage(ChatColor.GRAY + "You got hit! - " + ChatColor.RED + "Admin Tools");
}
}
}
my player gets hit by my Guard entity but it does not send the message
Did you register the listener?
how would i make it so a player has a potion effect active if theyre using an item
i cant find anything for it
How would I go about restarting/reloading a bungeecord plugin? (Without restarting the server)
That requires some karma shit or sum
wait i didnt, how to do that if the event is not in my main class?
U dont gotta be toxic man
cant you disable and enable the plugin
Tried to do it once but I couldnt
that is an overly interesting point of view
Best way it to restart. If you really need to reload you might have to setup hotswapping I'm not sure if there's a better way
oh and that won't work perfectly either
pass the plugin instance along until you can use it
Whatās are yāall feelings on @Unmodifiable
I know what it does, but what do you guys think about it?
If a player breaks a post of sugar cane, will BlockDropItemEvent be called on each of the canes?
from where does the annotation stem from?
ah jetbrains. Pretty stupid annotation then because it is highly likely not enforced
I mean its probably a good-contract-breaking-be-aware annotation
like if you'd provide an immutable impl of List
Guys, I'm having a certain "error" that I can't describe very well. Basically, the player does not get the title packet the first time it is run after entering the server. Does anyone know what can it be?
Show code
What do I send you? It has a title API and the part where the player uses a test command
All of it in a github repo would be good
It's good
Similar to the @NotNull and @Nullable annotations
Which are also pretty good
no. it only calls for the block that is broken by the player itself.
So the javadoc lies? š¤
ive already
and?
but it works as youve said for some reason XD
And im thinking of how can i handle that then
which event do you use?
BlockDropItem
oh i were dumb
i thought you were using BlockBreakEvent lol
dumb me
BlockDropEvent should call for everything that drops, so in your case in chain-breaking too
But... this prints the player only once
Am i dumb and doing something wrong or what
the chain-blocks are not broken by a player tho
well
lemme see smt
it's annotated as notNull. dunno fully how that works tho, but i think thats why it just prints nothing
the blocks are broken from the chain-reaction tho, not by a player. so thats why they cannot have any player associated
how can i null check on an InventoryClickEvent?
null check on what exactly?
on what item the player clicks
if (blah == null) {
//TODO
}
yes ik but i tried to check if the material != null and it didnt worked
well
^^
check if the item that's in the slot is null
should be event.getItem(slot) iirc
if(event.getCurrentItem() != null) this should work
It's the clicked item
nvm yeah, it's currentItem
so yeah, this is right
š
So i cannot handle that properly then?
depends on what you wanna do
Im trying to automatically sell all the items that player break with a specific tool
And with what i have for now, it does not work with chain-breaked blocks (as they are not broken by a player)
complicated
well... how should the server tell who the chain-reaction belongs to
as the block that you break is handling everything afterwards
Sadness
for which blocks does it apply?
?
like... it wouldn't be that hard for stuff like sugarcanes, but it'd get hard for example for these weird building bridge things, dunno their names rn
scaffolding
yea
i don't think that i would need to sell them XD
here's something i wrote quickly, that should work for sugar cane and stuff... didnt tested it tho...
@EventHandler
public void test(BlockDropItemEvent e) {
Player p = e.getPlayer();
Block b = e.getBlock();
int x = b.getX();
int z = b.getZ();
for (int y = e.getBlock().getY(); b.getWorld().getBlockAt(x, y, z).getType() == b.getType(); y++)
b.setType(Material.AIR); // if you want to set it to air...
for (int y = e.getBlock().getY(); b.getWorld().getBlockAt(x, y, z).getType() == b.getType(); y--)
b.setType(Material.AIR); // if you want to set it to air...
}```
i guess that is what you wanted? if not tell me :/
how can i listen for any event that triggers?
With many listeners
?event
nvm
isnt there a command? lol
ĀÆ\_(ć)_/ĀÆ
https://www.spigotmc.org/wiki/using-the-event-api/
i guess you want this? :o
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
w/o makints tens of listeners
ah
you could try to listen for the super class Event
btw for info: Block#isPreferredTool is just checking if pickaxe/axe/shovel/etc
so not quite what i wanted.. sad
yeah so i found something
And this is why they use reflection jank
the spigot event bus is reflection jank to begin with, anyway
you guys have an idea out of the head how long the goldenapple-absorption lasts? don't have my mc open rn
true, dumb me. ty :)
just for my interest... is there any difference between those two? :o
Bukkit.getOnlinePlayers().forEach((p) -> p.sendMessage("Message"));
Bukkit.getOnlinePlayers().forEach((p -> p.sendMessage("Message")));```
idk how to place that one bracket... does it actually matter?
intellij says both are right
then it's ok
Even this works Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage("a"));
thats why i wonder... is there any difference?
You dont need any extra brackets
intellisense made this automatically:
Bukkit.getOnlinePlayers().forEach((p -> p.sendMessage("Message")));
Bukkit.broadcast
does broadcast appear in console? I don't remember it doing that
No brackets is apparently the preferred way
iirc it does
brackets are redundant; you can have them or you can not have them
generally with any operation
oh
adding more brackets doesn't change the semantics, beyond grouping multiple operations together
i actually refered to #broadcastMessage
What minecraft version did PersistentDataContainer get added??
1.13 iirc
Ok
?pdc
1.14
a good counter
i'm tired... lemme get some ā
so 1.14?
for example, String nwo = "jews" is functionally identical to ``String nwo = ((("jews")));```
yep
oh ok
i got it, thanks :3
guys. what is your favourite theme in material ui? need a new one...
(dark pls)
red and black
Does anything look wrong here? The persistentdatacontainer is not working, when I try to get the data back I get null
no, you are overwriting the pdc with the other meta
getItemMeta always returns a clone
so I need to set the new pdc?
no, just get the pdc from the meta you already pulled
what you are doing right now is getting a itemmeta and then throwing it away
When would you want to use the scheduler's async functions?
when you want to schedule something to run asynchronously
Oh wow, really..
what did you expect
I'm asking if there are common use cases
yes, there are always use cases
I use it for packets, and when you have heavy code that you want to run async, then resync at the end
File IO, Timers, Database Access
literally anything that you want to run off the main thread is an use case
ExecutorServices though
Good list. Fetching textures online, update checking, and online stuff too
Yeah that makes sense
Things that would otherwise block you
And you don't need to wait for
just make sure not to be a 1.8 anticheat developer and go overboard
doing a 1+1 computation off the main thread for the sake of doing it off the main thread is retarded
I'm gonna make the async async!
Lmao, leaving the main thread and coming back would have more overhead
significantly so
You know what
Screw it
I'm making a plugin in JNI
Jk but I wonder how that would actually go
You canāt make a plugin āin JNIā. You āuse JNIā to execute native code within the JRE at runtime
And also, you canāt even do anything really tbh because itās for modifying arrays and certain things.
There are pointers and stuff obviously, but for the most part
You canāt do anything like interact with the api in C++
Only certain data types
Anyways, it would be a fuckmess
You know I mean that, cmon man
No, because what you said kinda makes people think JNI is some sort of environment
It isnāt tho tbh
Itās not at all
I did it one time. Itās kindaā¦fun, actually, but I wouldnāt use it seriously
And itās discouraged anyway unless you want to do something truly platform dependent or the efficiency from the natives outweighs their overhead when switching between
In my case, I was using it for performance to dither an image
Sounds good
Yeah I was looking into processing a video through ffmpeg and I found a cpp library which actually looked pretty clean
I considered using the interface
@paper viper still there
Yes
I actually use ffmpeg too in my app lol. Except I actually run the binary file. Vlcj is a java framework which has the binds for VLC binaries
So you can run a video using C/C++ in java, itās pretty cool
Nice
Hey bot developer ?
im looking for support on a error im having that is preventing my server from starting
uh huh
Hello! I am trying to set an item frame rotation according to a player orientation. Do you know how I could achieve the conversion between my orientation vector and the Rotation enum?
Lol if you do anything with jni in mc itās client side.
Youāll probably have to make that?
Make a function to divide the orientation by 8 sections and spit out a proper rotation
Based on what numbers it falls between. Roughly expressed, but you get the idea
yeah but I don't get how to do that
may be something like that:
private Rotation getRotation(double x, double y) {
if (x > 0) {
if (y > 0)
return (y > x) ? Rotation.NONE : Rotation.CLOCKWISE_45;
else
return (y > x) ? Rotation.CLOCKWISE_135 : Rotation.CLOCKWISE;
} else {
if (y > 0)
return (y > x) ? Rotation.FLIPPED : Rotation.FLIPPED_45;
else
return (y > x) ? Rotation.COUNTER_CLOCKWISE_45 : Rotation.COUNTER_CLOCKWISE;
}
}```
but it looks pretty ugly
Oh lol, I'm trying to find workarounds to use Native code in Java, can you explain more about? ;p
Like ffmpeg?
For a custom native library, JNI is probably too basic level. What you want is likely JNA
But if there arenāt any bindings for it, yeah uh, you have to do that yourself
For ffmpeg I was lucky that it had an executable version I could execute via terminal
So I just used a Process and executed the command with necessary arguments and got what I want
I was looking over JNA and I don't really know what's the difference, what I have is already written in JNI
If you already have JNI, go for it
JNA is done java side, JNI is done native side, but they both do the task
So yes, JNA would be slightly slower than JNI, but itās easier to use
Wait
Hold on, you want to take yaw and pitch into account? Both?
So JNA is something like Kotlin Native?
Kind of
no just the player orientation
here I used the orientation normalized vector
but I should use yaw, you are right man!
Yes
Then It's probably more interesting for me
Any tutorial?
Guide or documentation?
Or a snippet
private Rotation getRotation(double yaw) {
return Rotation.values()[(int)(yaw*8/180)];
}```
so something like that? @unkempt ore
its pretty nice to setup too
just extend the Library class then get the necessary methods
and you are good to go
I think it is normalized by default
(load it obviously)
thanks o/
np
and using modulo for angles would be a pretty bad idea
Go ahead and prove that to yourself
An angle is a number. I don't see the problem
You'll want to normalize to 0-360, then divide by 45 and floor
What's the easiest way to sort players by rank in tab? so Like Owner players, then Admin players etc....
Pretty sure that's a self imposed thing, sooo ^^^
How so
What the
So it's useless
Can NMS hack it
public class PlayerTeleport implements Listener {
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer();
if(event.getCause() == PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT) {
if(player.getItemInUse().getItemMeta().getDisplayName().substring(0, 4).equals("warp")) {
event.setTo(new Location(player.getWorld(), player.getLocation().getX() + 5, 80.00, player.getLocation().getZ() + 5));
}
}
}
}
can someone pls explain how setTo() works to me so i can find out why this doesn't work?
s-so do i use it on event or something else?
do i use event.setTo() or smtElse.setTo()? since what i'm trying doesn't seem to work
i've tried different methods like cancelling the event and using player.teleport but that also doesn't work, but it does if it's an ender pearl
i printed it and it's true?
oh yeah i've done that
it goes through all the code and the player.teleport prints true but i'm not moved
it does work with an enderpearl
Bukkit.getScheduler().runTaskLater((Plugin) this, () -> {
player.teleport(new Location(player.getWorld(), player.getLocation().getX() + 5, 80.00, player.getLocation().getZ() + 5));
}, 1L);
i've commented that out since it also failed :(
however
It is more the opposite the chorus fruit works as intended while the enderperl (as well as PLUGIN, NETHER_PORTAL, END_PORTAL and END_GATEWAY) teleportation is broken. Only CHORUS_FRUIT, SPECTATE and COMMAND work right.
If you look into the java docs of PlayerMoveEvent#setCancelled(boolean) it says that:
Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins
If a move or teleport event is cancelled, the player will be moved or teleported back to the Location as defined by getFrom(). This will not fire an event
Which means after you teleport the player and cancelled the event the player got teleport back to the from location. Which is the intended behaviour of the event.
someone did try helping me with this answer but at that point i was too nervous of being annoying for a long while so i don't fully undrstand it
it's the last bit that i don't get
@paper viper hey, I have another question, I've seen a little how JNA works, it creates a proxy class which abstracts the methods of the Library you're targeting to load. Is there any prebuilt library abstracting the JNI methods?
Or JNA wasn't even meant to use JNI but any other C/C++ library
I mean, if there is any approximation on the jni.h methods
In a JNA interface I mean
I don't reaally think i'm right but i have a suspicion spigot missed something about the chorus fruits
reasking from a few days ago, anyone have any idea if it is possible to load worlds on onload instead of onenable?
how can i play a sound at a specific location? I want to reduce the sound when player goes far away from the source of the sound
-
Is it possible to send a message to the individual consoles of my bungeecord network? From a bungeecord plugin :)
-
Is it possible to modify join/leave messages from a bungeecord plugin?
Prob not, but is there a way to broadcast custom sounds to players? I want to make a song for my server (totally not gonna be a rickroll...)
You could make something with noteblocks with like I think its called NoteblockAPI
You may be able to also do it with a custom resource pack but that would require people to download it
How can I prevent an entity from moving?
I'd like to avoid using NMS if possible.
I've managed to accomplish this with a repeating teleporting task, but it isn't the best solution IMO.
Hello !
I have a little question about Spigot API :/
What is exactly an InventoryHolder ?
I'm creating a GUI and I'm wondering If I should implement it so I can check easily if player is using my custom GUI
I believe classes that implement InventoryHolder have inventories. For example, players, chests, horses, etc. any block/entity with an inventory will implement InventoryHolder as seen in the docs https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/InventoryHolder.html
declaration: package: org.bukkit.inventory, interface: InventoryHolder
Oh I see thank you, so I guess my idea is not that bad
Yeah you are on track. Players being InventoryHolders just means that you can use getInventory().
soooo besides using player.teleport(), setTo(), or player.teleport() but delayed by a tick, how can i change where a chorus fruit takes you? (and yes i cancelled the original event beforehand but not for setTo)
do none of those methods work?
How do I change a gamerule in the spigot API?
I saw world.setGameruleValue("keepInventory", "true"); somewhere, but it doesn't work, and Itellij idea doesn't show a class to import.
why cant i use the PlayerChatEvent? Its deprecated
AsyncPlayerChatEvent
and what is the difference?
Ones async
okay and what is async?
asynchronous, not running on the server thread
which all chat has been since 1.8(?)
async is not sync, it means that its not waiting for the previous task to complete before executing another
and what are previous tasks for example?
Any thing on your server thats running that isn't async xD
^
okay
(I know this isn't really spigot but) I've extended the EntityMagmaCube class from NMS and cleared its pathfindergoals, but when the server closes, the entity (when spawned) is destroyed, is this normal behaviour?
Sorry for the late reply, none of the methods work but they do when it's with an enderpearl
is there a way to get the last opened Inventory of a player?
you could store a map of player to inventory, updated by the InventoryOpenEvent or someth
theres no real way tho
^^^^ Except use InventoryCloseEvent
thats a better idea
okay because i work on a plugin that opens a Inventory with /admin and there is a item named kill when you click on it the inv closes and the player should write a name of a player and that player should be killed then. But i dont know how i just can Listen to the AsyncPlayerChatEvent when the player clicks this item does anyone know how i can do this?
hi, i want to delete a plugin that i create and post in the web page, could you help me how can i do that?
what web page?
report the plugin and be like I want it removed
spigotmc .org
oh ok idk
then spam @ Optic_Fusion1 and he will remove it
so, thats mean that i need to report my own plugin to be remove of the spigot web?
yes
does anyone know a solution?
shit, ok thanks
i work on a plugin that opens a Inventory with /admin and there is a item named kill when you click on it the inv closes and the player should write a name of a player and that player should be killed then. But i dont know how i just can Listen to the AsyncPlayerChatEvent when the player clicks this item does anyone know how i can do this?
which tutorial?
Any, but iirc they api was not exactly the most straightforward
but what do i have to search on yt?
Spigot Conversations Api Tutorial
oh okay thx
is there no easier way?
@opal juniper
can i create a List and put a String inside of it when the player clicks the item and then i check if the string exists and if it does the item was clicked if it doesnt the player can type anything?
chrome decided you know what im gonna use all your memory cuz im a big fat ram eater chrome goes yum yum yum and eats all my fucking ram and then mc cOuldnt get anything and it crashed :_:
How can i use the bungee api to send a player a resource pack when they join? There doesnt seem to be any methods like in spigot.
Incompatible types. Found: 'org.bukkit.util.Vector', required: 'java.util.Vector' im getting this error, how do you fix this?
what method is that coming from?
cause all bukkit methods need org.bukkit.util.vector, not the java one
from .getDirection()
Probably got the wrong import
so i would remove import java.util.Vector?
Myes
Myes
Myes
you can't, you'd have to use the bungee message channel and have a plugin on all of the servers to load it
this might be helpful https://github.com/Phoenix616/ResourcepacksPlugins
Had a theory i would have to do that, well thanks for the help
?paste
Conversation is the easiest way
You can try deduce what each class do from the conversation API
ive done it with a ArrayList now xD
uhm and one question what is this exception? https://paste.md-5.net/numayaxehi.cs
You can't kill people async
It is written right there
@chrome beacon and how can i get rid of it?
you can use conversation
Go back to the main thread using the scheduler
^ or this
okay ill try
@near crypt must the player input a valid string? Is there a prompt (if the string is invalid)?
from when do you stop listening to the asyncplayerchatevent? is there a timeout? what if the player leaves the game/arena?
Soo im trying to get a players ping from a /ping command but it just sends and error when i run the command
I ask all these because Conversation API solves these for you
if (event.getItem().getItemMeta().equals(itemManager.bote.getItemMeta()))
``` is there a way that the if statement will get satisfied no matter what the durability of the item is?
because when durability is changed, the if statement is not being satisfied
ty
clone these items, if #getItem() doesn't already give you a copy, and refill durabilities
tysm
also consider using ItemStack#isSimilar
ItemStack.isSmiilar()
ill check more about that in documentation, thanks
not with ItemStack.isSimiliar()
oh?
/**
* This method is the same as equals, but does not consider stack size
* (amount).
*
* @param stack the item stack to compare to
* @return true if the two stacks are equal, ignoring the amount
*/
@Utility
public boolean isSimilar(@Nullable ItemStack stack) {
if (stack == null) {
return false;
}
if (stack == this) {
return true;
}
Material comparisonType = (this.type.isLegacy()) ? Bukkit.getUnsafe().fromLegacy(this.getData(), true) : this.type; // This may be called from legacy item stacks, try to get the right material
return comparisonType == stack.getType() && getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true);
}
oh wait
this makes no sense
this code makes no sense
Oh thought it checked dura. Well just copy that and take off the dura check š
whats the limit for the length of PersistentDatatype.STRING ?
I would assume the maximum NBT component size - 5 or so
And whats the maximum NBT component size? xD
thx
eh wait it makes sense, look closer to where the predicate is haha
(hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true)
8 TAG_String ... A length-prefixed modified UTF-8 string. The prefix is an unsigned short (thus 2 bytes) signifying the length of the string in bytes
So somewhere around 65k bytes
that being said, the region format will be a limiting factor here - it does not allow for infinitely large regions
why do you even check if stack is equals to this?
Because its the itemstack class
Not if its not the same class
?
I'm really confused here XD
^^^^^
and how can i get back to the main thread?
The code has it's inefficencies - but it 100% works as intended
Doesn't that method already exists in Bukkit?
This IS that method
because isSimilar accounts for durabillity
?scheduling
isSimilar basically just checks whether two itemstacks can be merged, though sometimes you want to get less specfic than that
Example;
ItemStack item = new ItemStack(Material.STICK);
item.isSimilar(item);
//will return true because its the same class.
don't know why would you change it
that is the whole point of isSimilar, yes
but the asker does not want to care about the durabillity
not only that
There is still the rest of the item meta to check
^
Hey! How can I convert a Rotation enum to yaw (float) ?
switch-on-enum! ... jk
Bukkit.getScheduler().runTask(Plugin, Runnable)
Hello good evening. Does anyone know how to manage inventories from arraylist?
I added several but at the time of obtaining them I do not know how I can use them. Thanks!
so then it not runs it asyncron?
the scheduler will run it synchronously in the server thread
okay
unless you tell it to #runTaskAsynchronously
yeah ik thx
you can even put this in your async operations or CFs
I'm sorry suddenly.
I want to create an Anvil GUI with Spigot 1.12.2, but nothing works. I would like someone to tell me how to create an Anvil GUI.
I tried WesJD's Anvil GUI but it didn't work.
you mean retexture it? or use it for some custom mechanics
u dont need anvil
or just to prompt user with input
declaration: package: org.bukkit.inventory, interface: Inventory
You can also try merchant's recipe
just prompt the user for input.
yup then like what 2Gramsin said create an inventory, say of type InventoryType.MERCHANT
since MerchantRecipe prompts the player about the input
Okay
then cast it to MerchantInventory:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/MerchantInventory.html
thank you for telling me both
Hey I'm trying to make furnitures that you can sit on using horses. I disabled the horse IA but sometimes it still moves when I mount them, any idea to fix it?
I have never used a scoreboard before, I want to create something like this:
<ServerName>
24/07/2021
<empty>
&cR &fRed: 1 (You)
&cG &fGreen: 2 (You)
<empty>
website.com
Also I would like to add the players to team Red or team Green and also show that in the tablist
Nope. Just gotta keep track of the entity.
Im just wondering how sitting on a mini armorstand would look like
Maybe can try using armorstand instead?
Like once per tick ?
isn't it gonna be laggy ?
hes got another solution but it might not be laggy as long as you arent doing much every 1 tick
Yeah but if there's a lot of them
Depends on your code. But you're keeping track of an entity so š¤·
you would have 1 normally
and keep track in a map
probs
load configuration files static or dynamic?
I see
then you wont need 1000 of it
Wow haha
Can't be worse then PlayerMoveEvent lol
yeah but bukkit makes it a little better
so it doesnt count the slightest movement
like 1 pixel
???? PlayerMoveEvent activates on cursor movement and player movement
it does
but its got a little limit
on it
so it doesnt active on the slightest
When was that added?
of movement
been forever??
If you move your mouse 1 pixel it activates the event.
oh you're right.
Still can cause issues when there are 10+ players all spinning in circles xD
69 lol
xD
How do i read in a baked in config? This code does not seem to work
private FileConfiguration getBakedConfig(String configFile){
FileConfiguration ret = YamlConfiguration.loadConfiguration(new File(dataFolder, configFile));
InputStream defConfigStream = this.getResource(configFile);
if (defConfigStream != null) {
ret.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8)));
}
return ret;
}```
IE it returns an seemingly empty configuration file
saveDefaultConfig();
...
getConfig().etc```
its not the default config
First of all, try with resources, is this a resource of just a file?
then saveResource(path")
hey, is an entity id preserved between restarts?
probably
saveResource("structure.yml",false);
YamlConfiguration.loadConfiguration(new File(dataFolder,fileName));
saveResource isnāt static
do you mean you don;t want to explode the resources. Just keep them in the jar?
no i meant the ressource file wont change and as such i dont want to write it twice
yes
You donāt tho?
i only want it in the jar like elgar said
what you're saying is write it down and read it
Reads it from your jar,
copies to plugin data folder,
reads it there and maps to file config
Oh right
Yes you can do that, I forget how. I'll have to fire up my IDE
getResourceAsStream("structure.yml") then
^
import?
its not
It is
Oh nvm getResource
you can then FileConfiguration test = new FileConfiguration(). loadFromString(String) or load(Reader)
It calls the getResourceAsStream from the class loader or something for you now when I think of it
correct
'FileConfiguration' is abstract; cannot be instantiated
Use YamlConfiguration then
FileConfiguration test = new YamlConfiguration();
try {
test.loadFromString(String);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}```
FileConfiguration ret = new YamlConfiguration();
try {
ret.load(configFile);
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
return ret;```
that
returns
an
empty
config
imma try the string method
Is the config file empty or no?
well
getkeys returns an empty set
thats how i test it
because there about 60 entries in it
Empty too
Have you got yrou resource as a String?
yes
its this now
FileConfiguration ret = new YamlConfiguration();
try {
ret.loadFromString(configFile);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
return ret;```
but it still gives me [] when i attemt to do getKeys
I'm pissed htat the only way i can get a working config is by saving it
wth are ressources for
What is the config even?
so direct key -> value mappings?
its
KEY1:
- "+XXX+"
- "X+++X"
- "+XXX+"
like that
the thing is
if i save the file
it WORKS
And the stream is returning the file's contents as inteded?
wait let me check
um
[Sat, 24. Jul 2021 12:53:46 CEST WARN] org.bukkit.configuration.InvalidConfigurationException: Top level is not a Map. [Sat, 24. Jul 2021 12:53:46 CEST WARN] at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:61) [Sat, 24. Jul 2021 12:53:46 CEST WARN] at io.github.moterius.ofmagic.Echo.getBakedConfig(Echo.java:115)
FileConfiguration test = new YamlConfiguration();
StringWriter writer = new StringWriter();
try {
IOUtils.copy(getResource("test.yml"), writer, StandardCharsets.UTF_8);
test.loadFromString(writer.toString());
} catch (InvalidConfigurationException | IOException e) {
e.printStackTrace();
}```
it doesnt find IOUtils what import is that?
You will need to add a dependency xml <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.6</version> </dependency>
Sorry I don;t use InteliJ
If you use maven there should be a button to refresh it
If you edit the pom it should pop up in like the top right in the editor
yes
k
if you are using Java 9+ you can just use String contents = new String(stream.readAllBytes(), StandardCharsets.UTF_8);
I really love readAllBytes
I cant do that now its blocking me with the update window
Most of my projects are Source 8, so I can;t use it š¦
well luckily the plugin im working on is for 1.17 but
It's a shame they did not introduce it earlier
I'd much rather have something that works on java 8 too
but for now I'm gonna settle with 'works at all'
good plan
even with that code?
i cant run it yet
its still updating
something tells me the repo is about a GB in size
did you just download the entire repo?
How do I check if clicked block is cauldron with water?
if(e.getClickedBlock().getType().equals(Material.CAULDRON)) { Doesnt work if cauldron has water.
by accident
that will take several days
it tells me its half done tho
ah
dammit
im updating the maven2 repo
crape that wont work
This is kinda math related, but if I have something like this:
/ Fireball
/
/
/
--------- Player
The fireball is going to be shot above the player's head. If I simply just do fireball.setDirection(player.getLocation().getDirection())
It'll do this instead
--------- Fireball
--------- Player
How do I adjust the direction so the final destination of the fireball's direction is the same as the player's?
If i had to guess trace the sight line of the player until it hits a block, draw a vector from that block to the locatoin of the fireball and send it flying along that line
the player has no such thing as a final destination
I know, I just don't know the word for it. The direction or whatever it is
That's extremely laggy, I'm pretty sure this can be done with pure vector maths
wouldn't you simply need to add to the y part of the velocity vector of the fireball?
you only need to do it once tho
nah just forget about that
also you need to get where the player is targetting one way or another
Location loc = player.getLocation();
fireball.setDirection(loc .getDirection().add(0, loc.getY() - fireball.getLocation().getY(), 0))
Something like this?
you would need to use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Entity.html#getVelocity()
declaration: package: org.bukkit.entity, interface: Entity
okay, actually no
Current traveling velocity of this entity
Here, using no extra imports. Tested and working```java
FileConfiguration test = new YamlConfiguration();
try (Reader reader = new InputStreamReader(getResource("plugin.yml"))) {
String text = CharStreams.toString(reader);
test.loadFromString(text);
} catch (InvalidConfigurationException | IOException e) {
e.printStackTrace();
}
System.out.println("KEYS: " + test.getKeys(false).toString());```
Are you sure that test.getKeys(false).toString() works?
[12:16:17] [Server thread/INFO]: KEYS: [name, main, version, api-version, author, website, description, softdepend]
huh
is there a good way to work out which colour a location is in?
it actualy does work
that was more of a PoC
thats a new one
Hello. I'm so confused using Maven. I'm working in a plugin with Intellij and I want to add an API (https://github.com/SpigotMC/BungeeCord) (I want to use "net/md_5/bungee/connection/LoginResult.java"). I want that Intellij download it to get what I want from the class above. How could I set that?
FileConfiguration ret = new YamlConfiguration();
try {
ret.loadFromString(configFile);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
return ret;```
@mental girder that does not work
x >>= 4:
z >>= 4;
if (x > 7) {
if (z > 7) {
} else {
}
} else {
if (z > 7) {
} else {
}
}
I think
You could
eliminates a String I guess
FileConfiguration test = new YamlConfiguration();
try (Reader reader = new InputStreamReader(getResource("plugin.yml"))) {
test.load(reader);
} catch (InvalidConfigurationException | IOException e) {
e.printStackTrace();
}```Cleaner
wont this just do the corners?
ie
that looks like c++ code
not diagonally but split it up into 4 squares
yep, left over
i meant the one liner
ah
void org.bukkit.configuration.file.FileConfiguration.load(@NotNull Reader reader) throws IOException, InvalidConfigurationException
one eye closed and a big nose? š
possibly
public static YamlConfiguration loadConfiguration(@NotNull File file) {
Validate.notNull(file, "File cannot be null");
YamlConfiguration config = new YamlConfiguration();
try {
config.load(file);
} catch (FileNotFoundException ex) {
} catch (IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
} catch (InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
}
return config;
}```
its baked in
same for reader
just wihtout filenotfound
[08:32:55 WARN]: java.sql.SQLException: ResultSet closed
[08:32:55 WARN]: at org.sqlite.RS.checkOpen(RS.java:63)
[08:32:55 WARN]: at org.sqlite.RS.findColumn(RS.java:108)
[08:32:55 WARN]: at org.sqlite.RS.getObject(RS.java:387)
[08:32:55 WARN]: at net.redewhite.DataAPI.API$1.run(API.java:133)
[08:32:55 WARN]: at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:59)
[08:32:55 WARN]: at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
[08:32:55 WARN]: at org.github.paperspigot.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:23)
[08:32:55 WARN]: at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[08:32:55 WARN]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[08:32:55 WARN]: at java.lang.Thread.run(Unknown Source)
actually, yes
Why is my scoreboard not showing up? https://paste.md-5.net/sitayovugo.java
final ResultSet result = statement.executeQuery("SELECT * FROM `wn_data` WHERE uuid = '" + player.getUniqueId() + "';");
Boolean i = null;
while (result.next()) {
i = true;
Bukkit.getScheduler().runTaskAsynchronously(Main.getInstance(), new Runnable() {
@Override
public void run() {
for (VariableAPI api : Main.dataapi.keySet()) {
try {
Bukkit.broadcastMessage("Loaded: " + api.getName() + " - " + result.getObject(api.getVariableName())); // ERROR IS IN THAT LINE <<<<<<<<<<<<<<<<<<<<<<<<
} catch (SQLException throwables) {
throwables.printStackTrace();
}
}
}
});
}
huh, ok thanks then
arent they?
The last one is the link I copy from the other link a posted it before. Is it like this what you said?
diagonally would be something like
if (x > z)
if (x + 8 > z)
or something like that
okk
I am trying to change a gamerule, someone sent me this, but I can't seem to get it to work GameRule("KEEP_INVENTORY", "true"); I have also tried world.setGameruleValue("keepInventory", "true"); but "world" doesn't exist and it doesn't suggest an import.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameRule.html
declaration: package: org.bukkit, class: GameRule
I'm not too sure myself. That is what i found when i had to update earlier, but i cant tell you how to register the spigot api. I believe it was by dropping the api.jar file onto 'External Libraries'
world is a variable
Bukkit.getWorld
i made a plugin but i cant remove [ ] of the string in the config, i'll post 2 more sreenshots of the code that do that. How can i remove it?
&k will lead to it being the gibberish you see
how make this?
this is the problem
PlayerAPI.this
oh thanks
that works too I guess
Lmao
I tried making sense of this https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameRule.html
declaration: package: org.bukkit, class: GameRule
I am not that good with java docs
you should read the world docs and the gamerule related methods
Did you extend JavaPlugin anywhere?
Would be a good idea to learn how to read docs
Oh
public static List<String> homeDefaultItems;
AddHomeCommand.homeDefaultItems = config.getList("default-home-items");
i get Incompatible types. Found: 'java.util.List<capture<?>>', required: 'java.util.List<java.lang.String>', how do i fix it?
i tested it with sendMessage and sendRawMessage and both works with [ ] when it doesn't exist. i don't understand nothing of this
Bukkit does not make use of the magic static main(String[]) method, so your entrypoint is invalid, which is a more serious issue than your code not compiling
static main is for Apps. Plugins are not apps
If you actually understood java you would realize that it's not a string value
?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.
And spigot itself
it compiles and works so, it create [ ] in the message when the plugin send it to the player
Instead, you need to have a class that extends JavaPlugin and define that class in the plugin.yml (which behaves kinda like the MANIFEST.MF, but is mostly bukkit only)
The bukkit wiki one is the most comprehensive tutorial
That page doesn't even exist for me lol
yea, the bukkit one is the best one on the market, even if it is severely outdated
In intellij there's a plug-in made to automatically start a project related to minecraft
it's very useful
Never to be used by a beginner
I used it as a beginner lol
... no comment š
even if i kit &k (magik), it work as bad as with it
How do I change the gamerule to true?
Stop using your IDE auto code suggestion
declaration: package: org.bukkit, interface: World
^ look at teh javadocs and see what methods you should be using
ye
there is even a search box on the javadocs to find anything you need
search for gamerule and see what it shows
import org.bukkit.World;
add ()
you need a World instance not a static object reference
it's a method, not a property
exactly
Just told me that
you have to create an instance of the World
Not trying to be rude here, but if you took a few java lessons (online) this would all make sense to you.
Oh, I know how to create an instance I'll try that.
You need to GET a world instance, not create one
You need to learn basic java dude
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.
?learnjava take a few courses and make your life easier
yes, sorry xD
with the keyword new i guess
Hint : Instances are often got with methods such as getTheObjectYouWantToGet()
So you can search for these in the javadocs
cant he just create a new World Object world and then do world. ?
They shouldent
idk his purpose but i think he can
No you goddamn can't
Should use the method to get the instance of the world from Bukkit
well, actually you could š
yes
But it wouldn't work
Would it fire some errors? Probably
yeah but there's no point in doing that ???
^
I think I tried that. I know most of the basics of java, I am a bit new with the spigot api.
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.
I know about that, someone sent it earlier.
Bukkit.getWorld(worldNameHere). or Bukkit.getWorlds() and find the world you want from teh returned Collection.
Using https://github.com/hfoxy/Spigboard/blob/8f07b186cff3d6285630e3776875e94cecb204f7/, but no scoreboard visible
@Override
protected Spigboard getDefaultScoreboard()
{
Spigboard scoreboard = new Spigboard(new Component("&6DogLeader"));
scoreboard.add(1, "test", new Component(DateTimeFormatter.ofPattern("dd/MM/yyyy").format(LocalDateTime.now())));
scoreboard.add(2, "test2", new Component("&a"));
scoreboard.add(3, "test3", new Component(DogLeaderTeam.HUNTER.getPrefix().toLegacyText() + " &f: &ap-hunters y-hunter"));
scoreboard.add(4, "test4", new Component(DogLeaderTeam.RUNNER.getPrefix().toLegacyText() + " &f: &ap-runner y-runner"));
scoreboard.add(5, "test5", new Component("&b"));
scoreboard.add(6, "test6", new Component("&eplay.mcmanhunt.com"));
return scoreboard;
}
//Inside another method
this.scoreboard = getDefaultScoreboard();
for(org.bukkit.entity.Player player : Bukkit.getOnlinePlayers())
this.scoreboard.add(player);
oh @eternal oxide already wrote it sry
maybe to much characters in one line?
I can try using less characters for testing
try it
add players to a scoreboard using their name. add Entities using their UUID
I only have players
1.8 I guess then
how make this?
No 1.17
bruh
then player.getUniqueId()
Ok
make it?
sorry player.getDisplayName() or somethgin like
yeah, returns a error
Ok I will try it
how make this works?
so it throws an exception?
?paste and paste your class inside
thx
no the class with the AsyncPlayerChatEvent
there is the exception i guess
@final monolith
Hello. I have a block from PlayerInteractEvent and I know that this block i placed from a itemstack. Now I want to get the custom model data from the block, the item stack had before. Is that possible? If not: What else could I do?
Which method?
I didn't find it. What do you mean exactly with this?
i think you dont can call Bukkit.broadcastMessage(String) in an async Event... so use a scheduler to get back to the main thread
you mean spigot docs...
I said PlayerInteract Event
"PlayerInteractEvent"
can you call Bukkit.boradcastMessage() in a async Event?
I want to get the itemstack from the block, that is touched
Not the item in the hand
I wouldn't write here, if it's not.
For example: block.getItemMeta().getCustomModelData()
That is what I would need.
Okay. Any innovations?
Okay. Thanks.
ItemStack is the item you are using to break the block. Entity would be the Player
But is the CustomModelData still the same after breaking it @eternal oxide ?
Thats resource pack data
has anyone worked with aikar commands before? I have the issue of it not allowing me to run a give command via the console and was wondering if anyone would know a fix?
Followed https://www.spigotmc.org/wiki/making-scoreboard-with-teams-no-flicker/, still no board visible
PlayerJoinEvent -> setScoreBoard, and for every player online updateScoreBoard
lol hastebin thought it was cpp
If I wanted to move something 16 blocks with a vector, what is the way to calculate the vector?
hastebin isn't the best for working that out, aha.
Yup kinda weird
Ok
you mean add?
Totally not NNYa š
Good to see you back
lol hes gonna get banned again
I saw when you got banned, caught md on a bad day smh
does md_5 actually talk in this discord?
occasionally
just search and you will see
last message 6 days ago
Just depends if you are worthy
i havent talked to md_5 yet only once
he normally ignores me 
oh well i need help to run 1.8 on java 16 cuz i had to cuz all the plugins didnt support newer versions lmao and he said to disable this thing and it worked
So, I'm setting up my commands using the acf-paper or whatever it's called I have https://paste.bristermitten.me/yryxaxepix.less but somehow console can't run commands? Any clue on a fix?
š
i make my own
and i use commandmap
xd
i made a thing to add and remove commands lmao
it was pretty bad tho
aws does website hosting š
and theres a thing thats always free
loll
they've done that for a while?
never seen it
to bad i dont want to enter my address to signup and i dont have a credit card
what is aws?
Because youāre an 8 year old
amazon web services
yea
no
databases from amazon?
its like vps
Yes
pretty much anything
i didnt know about it cuz i dont use aws
it is just hosting from amazon essentially
you can dynamically buy more / less servers
and its a database?
so people like netflix use them
okay
it can be i guess
It can be, but itās not just that
okay
What is the best way to make a gui plugin?
just think of it as a computer
theres free stuff in it to
make a gui plugin
what is the best way to make a plugin?
i`m gay
I want to make an inventory and click system for personal use.
Let it be as optimized as possible.
and amazon says its invalid
You don;t exist
inventorey.getname is bad?
example.
What would you recommend to check the correct inventories?
instance
WTF
I tried to make instance of inventory, but to no avail.
your menuManger doesn't even inherit inventory holder
fucking pussy
Would it be better to switch or use ifs to check inventories?
i dont have a fucking credit card bruh
lol
how to?
Wtf do you expect?
like this @mental girder?
vector = new Vector().normalize().multiply(16);
oh
chargeback?
no, that vector will be zero
Itās to stop 8 year olds like you from abusing the platform and to verify youāre real
oh yEAH
im not 8
lmao
You act 8
You spell like you're 8.
Lol
so i just make one that is (1,1,1)
I want to learn. I'm developing my server, I could just download other people's plugins.
im not fucking 8
š©
You are 8 lol
Itās so they can verify your identity so that they know that their users arenāt 14 year olds
So itās working
kk
you need a vector that actually points in a direction
no
yeah
Vector directionVector = targetLoc.toVector().subtract(source.getLocation().toVector());```
You might as well be
no
mhm
Sir this is help development
no
you make it obvious you're 8
Still no scoreboard visible, 3th post I am trying https://www.spigotmc.org/threads/scoreboard-problem.180625/#post-1904042
bro im not 8
but you are
DevBukkit, idkidk please stop this nonsensical debate