#help-development
1 messages · Page 2191 of 1
how will this affect the code?
Right now you delay nothing
The delayed code is supposed to be in the Runnable
this block of code is inside a runnable
The delayed code should be in the {} after the runnable
public class MyRunnable: Runnable {
override fun run() {
// some runnable stuff
Bukkit.getScheduler().runTaskLater(Bukkit.getPluginManager().getPlugin("Mobwars")!!, Runnable {}, 20)
}
}
wait let me compile and ill be back
Is it spigot? Why is there "!!"
cause .getplugin() can be null
What?
this is kotlin
Ok
"?" for nullable "!!" for not null
@thorny dawn did what I told you help?
yeah im reloading the server
Ok
this code doesent work but there are no errors, i want it to be so that when a player joins the get teleported to the spawn etc
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if(event.getPlayer().hasPermission("unnamed.joinmessage")) {
Location location2 = new Location(Bukkit.getWorld("lobby"), 220.500, 53, -1.500, 0, 0);
event.getPlayer().teleport(location2);
getServer().broadcastMessage(ChatColor.GOLD + "[un.named] " + ChatColor.WHITE + ChatColor.BOLD + event.getPlayer().getName() + ChatColor.WHITE + " joined the hub.");
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 10, 0);
}
}
}```
i got some weird result but ill try rearranging some stuff and see if it will work
@harsh totem no it just does it all at once
does what at once
it doesnt wait execution
what's your code?
it does it instantly
class CountdownInit() : Runnable {
override fun run() {
for(world: World in Bukkit.getWorlds()) {
val worldconfig: YamlConfiguration = YamlConfiguration.loadConfiguration(File("${world.name}/gamedata.yml"))
if(worldconfig.get("gamestate") == "STARTING") {
val wrld: World = world;
send("Begun countdown on ${world.name}")
world.players.forEach { plr ->
PlayerJoin().createScoreboard(plr)
}
for(i in 30 downTo 0) {
worldconfig.set("gamestate", "STARTING IN ${i}s")
worldconfig.save(File("${world.name}/gamedata.yml"))
Bukkit.getScheduler().runTaskLater(Bukkit.getPluginManager().getPlugin("Mobwars")!!, Runnable {
world.players.forEach { plr ->
PlayerJoin().createScoreboard(plr)
if(i == 20 || i == 15 || i == 10 || i == 5 || i == 4 || i == 3 || i == 2 || i == 1) {
plr.sendMessage(ChatColor.translateAlternateColorCodes('&', "&eStarting in &a$i &eseconds."))
}
PlayerJoin().createScoreboard(plr)
}
}, 20)
}
break
}
}
}
}
idk i'll search for a sec
kk
Class implements Listener? event registered?
why don't do if(i % 5 == 0 || i == 4 || i == 3), etc?
Are you sure that this is the onRun method you are implementing and not the init block?
(I have almost no knowledge of kotlin, so forgive my incompetence)
try a delayed task
maybe a 10 ticks delay or less if not try above
public static HashMap<UUID, Inventory> cachedInv = new HashMap<>();
//after some time:
p.getInventory().clear();
p.getInventory().setContents(RestoreCommand.cachedInv.get(p.getUniqueID()).getContents());```
Any ideas why this is not restoring the inventory?
that is what they are doing
how would i do that?
getScheduler#runTaskLater
Okay, I am blind
got confused but no worries
?scheduling
delay it by 1 tick
first of all, encapsulation is a thing, search it up. second, dont store the whole inventory in there. third, how/where are you storing it?
@harsh totem after a bit of debugging around i realised that it waits the first time in the for loop and then executes it all at once
so like this or something? what do i put next?
getServer().getScheduler().runTaskLater();
it accepts the plugin instance and a bukkit task consumer
and delay (Long) ^
wdym with how / where am I storing it?
this?
getServer().getScheduler().runTaskLater(Long);
no
(im new to this)
getServer().getScheduler().runTaskLater(Plugin plugin, new Runnable {}, Long delay)
?scheduling
^ read this
hey am i in the right place to get support in in the middle of editing the spoigot.yml
ok
Use #help-server
Use lambdas
no, this is for developing plugins. #help-server
How would I remove testplugin:tpa while keeping tpa?
getCommand("tpa").setExecutor(new TpaCommand());
edit the CommandMap manually
you can also set your server to stop sending namespaces as tab complete
how would i do that?
in spigot.yml:
commands:
send-namespaced: false
and have you fixed it?
how do i add config in bungee
that breaks my whole plugin - lol
send-namespaced: false
tpa:
description: Teleport to a player
usage: /<command> <player>```
Is this correct?
yep
alternatively you could get the SimplePluginManager's CommandMap and remove the namespaced entries for your command
it worked thanks
how do i use bungee's config api
let me dig out one of my old bungee plugins
?paste
Is there a better way of doing something like this?
private HashMap<UUID, ItemStack[]> cachedInv = new HashMap<>();
private boolean restoreInventory;
cachedInv.put(restoreInventory ? target.getUniqueId() : null, target.getInventory().getContents());```
Hello World !
I have a little problem, I need to use my DataBase (MySql) for do a license system but my plugin will by release at clients. I don't want to give the password (obvious I think) and i wan't to know if it's possible to connect to a DataBase without password and just get the informations return by the dataBase :)
how can I make emerald ore drop experience, this doesn't work and changing the event.getExpToDrop() to some int like 3 doesn't work too
if(event.getBlock().getType() == Material.EMERALD_ORE) {
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
event.setExpToDrop(random.nextInt(event.getExpToDrop())+event.getExpToDrop());
}
how do i cancel a runnable?
Bukkit.getScheduler().cancelTask(yourRunnable);
ok ty
if i want to implement this line inside my runnable do i put this in yourRunnable?
Do you have a repeating task?
yeah its a runTaskTimer()
Can you show the code?
Bukkit.getScheduler().runTaskTimer(Bukkit.getPluginManager().getPlugin("Mobwars")!!, Runnable {
if(count > -1) {
gameconfig.set("gamestate", "STARTING IN ${count}s")
gameconfig.save(File("${player.world.name}/gamedata.yml"))
this.createScoreboard(player)
count--
}
}, 0, 20)
``` (written in kotlin if youre gonna point out any syntax mistakes)
then how would i cancel dropping the emerald?
Bukkit.getPluginManager().getPlugin("Mobwars")!! why are you not just referring to your plugin instance?
cause di is complicated as fuck in kotlin
oh
u dont exactly have static variables in kotlin unless u use a hacky way which isnt really good
Well, I've never used it like this but I guess u can just do
BukkitTask task = Bukkit.getScheduler().runTaskTimer(..........)
Bukkit.getScheduler().cancelTask(task);```
it's on 1.8
what if i want to cancel the runnable inside the runnable body?
should i use "this"?
save it as int (that task) and then use Bukkit.shcheduler canceltask
"this" refers to your class and not the runnable you're in
and paste in the task
bungee config api
or
Bukkit.getScheduler().runTask...(plugin, task -> {
// stuff
task.cancel();
return;
}, delay stuff)```
does someone know how I can declare an annotation parameter
like I want to have a custom annotation
@MyAnnotatino("someValue")
public static void something() { ...
@interface MyAnnotation {
String value();
}```
oh that easy?
lol
thanks
yay
so?
seems too complex
i hope you specified the retentiontype
can u tell me how to use
obvciously that can't work
because you cancelled the event
well how do I remove the emerald that drops?
you can get the ConfigurationProvider using ConfigurationProvider.getProvider(YamlConfiguration.class)
how would i cancel inside the runnable's body?
cancel the event and manually drop the XP
how can I drop it manually
by using cancel()
Anyone willing to help me make a plugin by 1st of July? DM me if you are interested.
can u help me in my thread
this is what i got so far:
val runnable: BukkitTask = Bukkit.getScheduler().runTaskTimer(Bukkit.getPluginManager().getPlugin("Mobwars")!!, Runnable {
if(count > -1) {
// do stuff
} else {
// do stuff aswell
// CANCEL RUNNABLE HERE
}
}, 0, 20)
where does
ConfigurationProvider.getProvider(YamlConfiguration.class)
``` go
save it in a static final field
huh
cancel();
?
kotlin aaa
?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.
?howtfdoiusestaticfinal
learn basic java
static variables are variables that belong to a class not a specific instance x-)
i can confirm that the first link does not teach you how to do that
codecademy is literally a good resource to learn lol wym
isnt BukkitTask#cancel a thing?
i mean it does not teach you how to do it
it teaches you how to make classes and print to console
new BukkitRunnable() {
@Override
public void run() {
// Your code here
cancel();
}
}.runTaskTimer(this, 0, 20L);
}
It is
Ceryth
@thorny dawn
You do it like
@thorny dawn
can someone help me #982967814589652992
do not use a lambda
So you can use the Consumer<BukkitTask> with BukkitScheduler
if you'd be using a proper language it would be so easy to just create an anonymous BukkitRunnable
yep
Bukkit.getScheduler().runTaskTimer(this, task -> {
task.cancel();
}, 0, 20L)
i dunno kotlin anyways
alr ty ❤️
You should learn (3
val runnable: BukkitTask = ... like bruh
@tender shard what is it?
like string etc
what is what?
you probably don’t need to define the type explicitly
i hope so
ConfigurationProvider.getProvider(YamlConfiguration.class);
as I already told you twice, it's not a String but a ConfigurationProvider
private static ConfigurationProvider yamlConfigurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
public static void main(String... args) {
Configuration myConfig = yamlConfigurationProvider.load(new File("config.yml"));
}
?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.
does it go in onenable?
it goes whereever you need it
lmao a file of all my emails
how do i ead from it
and how do i put config.yml into wherever it needs to be
it's in esources
Configurtion#get
how do i put it in the "data folder"
the plugin I sent you has all the code you need
it even has a saveDefaultConfig method
did you even look at it?
yes
well then just use the methods I sent
it's fking confising
not really
getProxy().getScheduler().schedule(this, this::showDebugOnDiscord,2, TimeUnit.SECONDS);
eh discord??
obviously you do not need that
try to look at the names of the methods
if a method is called "saveDefaultCOnfig" then this is probably the method to save the default config
?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.
you have no idea about the basic prinicples of this language
for example stuff like variable scope
and visibility
so you should learn that
alright then welcome on my block list, too
why
don't wanna waste my time talking to people who don't even want to try to learn java
Is EnumHand.a in 1.18 same as EnumHand.MAIN_HAND
just because i blocked a bot?
You have blocked @undone axle and discord will prevent showing the message...
yeah
Why 😦
it pisses me off
Our innocent 🤖
I sent them ?learnjava a few times because they have no idea about variable visibility and scope and other basics
anyway i fixed the error with yamlconfigblah
and they refuse to try to learn it
:/
the only message cafe gives which people don;t like is the learnjava one. Getting annoyed at that is silly. Just learn Java
fixed :D
the only message cafe gives which people don;t like is the learnjava one.
why is this not generating?
cafe has a lot of other messages we use to help people
the schematic
?pdc
just ONE example
why would anyone besides you post it on spigot anyway?
the schem is supposed to be generated in the air but it isn't
i meant i shd not post it
you have to complete() the operation
wrong link
i'm in the version 6
is it the same?
how would I use scoreboard names in chat?
and here is being pasted...
@tender shard it created the directory but didnt put the file in it
how do i make it move config.yml to the data folde
save it 🤷
how
saveDefaultConfig() in your onEnable
saveDefaultConfif(); in the onEnable
Hello World !
I have a little problem, I need to use my DataBase (MySql) for do a license system but my plugin will by release at clients. I don't want to give the password (obvious I think) and i wan't to know if it's possible to connect to a DataBase without password and just get the informations return by the dataBase :)
whats slot number for helmet ?
you still didn't use Operations.complete(...)
declaration: package: org.bukkit.plugin.java, class: JavaPlugin
but I had other schematic which was being created
is this license system for a spigot plugin?
bruh
and the saveDefaultConfig is copy pasted from one of my bungee plugins
it takes a File and a String (the resource file name)
wait what string does it want
"filename.extension"
saveDefaultConfig("config.yml");
File: the file where to save the default config
String: the name of the default config in your resources
no. the string will be config.yml and the other one will be a file object
but the file object is config.yml?
where can i post code
I really don't understand why you just don't look into my code and see how I'm doing it
on this md5 board
?paste
?paste
this is all you need when you use my methods
@EventHandler
public void onInventoryClose(InventoryCloseEvent event)
{
if (list != null)
{
for (int i = 0; i < Admin.vanishList.size(); i++)
{
list.next();
list.remove();
}
}
}
Configuration config = loadConfig("config.yml");
why does this cause the error whenever someone can't resolve the server ping properly
it happens when a ping to the server in the server list isnt resolved properly
in startup event
you cannot remove from this kind of list
some lists don't allow removing stuff. for example the list generated by Arrays.asList
i actually just want to decrease the amount of displayed players
show the code where you create the list
hm?
show the code where you declare "list"
do i put this in startup or?
kk how do i decrease the amount of listed players otherwise
the callback doesnt provide much
i'm done with you ffs
yes
kk ty just good to know that it doesnt work ill just remove that for now then
that's not allowed
why ?
you put that, as I already said, whereever you need it
its not like an integral part of my plugin
because it's not allowed
:-(
just look at the code I sent >.<
but it's my plugin
sure, no problem. but then you cannot upload it on spigot
oh no
so Configuration config = loadConfig("config.yml"); would go in a cmd class
i don't release him on Spigotmc.org
if I was you, I'd save the config as private static final field in the main class and then create a public static getter for it
whats a getter
a method that returns a field
oh ok
private static final Object myObject;
public static Object getMyObject() {
return myObject;
}
this is a getter
right
does getlivingentities count players aswell?
a player is an entity too so i guess ye
do i remove world player count to get mobs only?
Configuration config = loadConfig("config.yml");
https://i-own-a.blacklisted.store/MmZyjhob
yes
Are you using spigot config api?
bungeecord
cursed maven
why don't you finally start to learn java?
am trying to cancel event if player tries to put off helmet
@EventHandler
public void onPlayerInteract(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();
int slott = e.getSlot();
player.sendMessage(String.valueOf(slott));
if (e.getInventory().getType() == InventoryType.PLAYER){
if (e.getSlot() == 39){
e.setCancelled(true);
}
}
}```
but its not cancelling event
you should use my ArmorEquipEvent instead
it just letting player put of helmet
ohk thanks
@tender shard why both ignorecancelled true and checking if its not cancelled?
because I took over this project from Arnuh and they did it like this lol
and I didn't double check every line
but yeah it's not needed and I'll remove it, thx
x)
it even still uses ItemStack#setDurability
yes
but
IIRC the logic would change
because you can set a Damageable's damage to the max damage value so that the item has 0 durability but it won't break automatically
setDurability will automatically break the item
ah
so I'll use the deprecated method until it finally gets removed
you can even make items with negative damage lol
Damageable is a bit weird
implementing player is a bad idea. every other week there's like 3 new methods lol
Why do u need to implement player 8)
it's used for stuff like "silent" permission checks
e.g. "can a player build at XY" without the actual player getting messages from worldguard like "You cannot build here" etc
I know nothing about particles, is there a resource online for which I could use to make a circual particle spin around this respawn anchor?
you gotta use a runnable and then use some math involving sinus and cosinus
didnt you pay attention in math classes? ;P
oh good god,
yeah I wish could help but my math classes were 10 years ago lol. but you definitely simply need some sin/cos to get the correct location from your center point
and then just do that in a runnable
what is t?
so pi?
it will go out in lenght?
ahhh
so then I just generate numbers until it completes
by lioke +1
Maybe like plus 10
ok ok
Or just increment in pi/x
Alternatively, you can figure what is 2pi/36
im noting this all down lmfao
Which is pi/18
This is in radians already
okay okay
for (double angle = 0;angle < 2pi;angle+=pi/18)
Basically your loop looks lile that
And angle is t
In the eqn from above
alright
Btw did you get scoreboards working?
Thank you so much 😄
no 😦
Did u work on it?
I tried adding the player to all the player's previous scoreboards to no avail
No u gotta add all the players to the new players scoreboard
As well
U have to do both
oh wait lemme test
I've been using MockBukkit + Surefire since months for my library but now, without having changed anything, I suddenly always get this message when running tests:
https://paste.jeff-media.com/?5d3455623f18c9b4#5uKZJiuLeftezZ1UH4nXhZYn1t7ttGWvZ8Jpo8e6ZCcx
Does anyone have any idea on why this happens? Source code is here: https://github.com/JEFF-Media-GbR/JeffLib
what is the ladder of event priority?
Lowest to highest
LOWEST, LOW, ... HIGHEST, MONITOR
so yeah LOWEST is first, HIGHEST is second last and MONITOR is last
somethings working, i can only see my prefix but it doesnt matter who joins
still cant see others
for (Player onlinePlayers : Bukkit.getOnlinePlayers()) {
setNametag(onlinePlayers, p);
setNametag(p, onlinePlayers);
}``` join event ^
```java
public void setNametag(Player player1, Player player2) {
Scoreboard scoreboard = player2.getScoreboard();
if (scoreboard.getTeam(player1.getUniqueId().toString()) != null) {
scoreboard.getTeam(player1.getUniqueId().toString()).unregister();
}
Team team = scoreboard.registerNewTeam(player1.getUniqueId().toString());
team.setPrefix(ChatColor.translateAlternateColorCodes('&', "eee"));
scoreboard.getTeam(player1.getUniqueId().toString()).addPlayer(player2);
}``` setNameTag function ^
I'm gonna try
knock yourself out 😄
Does the flying speed attribute in spigot apply to all entities? MC wiki says only bees and parrots
Sending messages from Bungee to Spigot works, but Spigot never seems to receive the messages
SpigotSide:
getServer().getMessenger().registerOutgoingPluginChannel(this, "ArenaPlugin");
getServer().getMessenger().registerIncomingPluginChannel(this, "ArenaPlugin", new BungeeMessenger());
@Override
public final void onPluginMessageReceived(String channel, Player player, byte[] data)
{
try
{
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(Base64.getDecoder().decode(data)));
JsonObject message = new JsonParser().parse(inputStream.readUTF()).getAsJsonObject();
System.out.println(message); //not working
String task = message.get("task").getAsString();
Bungee Side:
public static void sendToBukkit(String task, JsonObject message, ProxiedPlayer player)
{
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
DataOutputStream dataOutputStream = new DataOutputStream(outputStream);
try
{
message.addProperty("task", task);
message.addProperty("player", player.getName());
dataOutputStream.writeUTF(message.toString());
}
catch(IOException e)
{
e.printStackTrace();
}
player.sendData("ArenaPlugin", Base64.getEncoder().encode(outputStream.toByteArray()));
}
Tried with prints before, works
Yes, me
is possible to make 2 entities mount on a player, explaining my reason is that I want each of the players to view a specific entity mounted on a player, I thought about using packetplayoutentitydestroy but that just makes the entity disappear from the world , but keep it there invisible
example, in one player seat there would be a creeper, for the other player view, the player seat there would be a zombie, sorry bad translator
player.getServer().sendData seems to work
does colored wool exist in 1.12?
bc I don't see any spigot materials for colored wool in my 1.12.2 plugin
Oh ok
How does one solve LinkageError for duplicate class definition even tho I inspected the jars and only one class definition exists
there's like a 10% chance on startup for the linkage error to occur and the other 90% of the time works good
efficiency is always Enchantment.DIG_SPEED right? also for axes, right?
are you shading dependencies?
if yes, you should ALWAYS relocate them into your own package
I am shading a utility class but I have 3 plugins that I'm communicating with
send the full error pls
it's weird that the error only occurs like 10% of the times I start the server up
Yes
that might have sth to do with the order of plugins being loaded, which is random
thx
I'm hard depending on the plugin I'm taking the class from tho
most useful class ever
?paste the full error
Linkage error on startup or restart?
on startup
I'm trying to get the error rn lol
could it be the utility class clashing tho,
Show the error else its all guesses
welp had no other way but to copy local spigotmc local repository from my ubuntu and put it in window maven local repository
very weird
you should report that error
homecome my code isnt translating the color codes of op'd players? everything else works fine : java String format = p.isOp() ? lvltxt + ChatColor.translateAlternateColorCodes('&', Tazpvp.chat.getPlayerPrefix(p)) + "%s " + ChatColor.WHITE + "%s" : lvltxt + ChatColor.translateAlternateColorCodes('&', Tazpvp.chat.getPlayerPrefix(p)) + "%s " + ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', "%s"); e.setFormat(format);
my eyes 😵💫
good code 
yep now i can access nms
1.8 best version
.ban @vocal tundra heresy
thats the benefit of ternary operator 😄
uhm my last braincel just died
what
i guess im officially braindead now
i dont see any benefits for using that unreadable code
lol
but why
no??
changing spacing doesnt do anything
you literally do the same thing except for the last part
idk how thats bad code
just store the base part as a variable
fun createWorld(): String {
Bukkit.unloadWorld("mbw_prototype", true)
val worldname = GetUniqueWorldName().getWorldName()
File(worldname).mkdir()
File("mbw_prototype").copyRecursively(File(worldname), false)
val gamedataFile: File = File("$worldname/gamedata.yml")
gamedataFile.createNewFile()
val world: World = Bukkit.createWorld(WorldCreator(worldname))!!
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false)
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false)
val fileconfig: YamlConfiguration = YamlConfiguration.loadConfiguration(File("$worldname/gamedata.yml"))
fileconfig.set("gamestate", "WAITING")
fileconfig.set("waves", "0")
fileconfig.save(File("$worldname/gamedata.yml"))
return worldname
}
why does this shoot a null pointer exception at val world: World = Bukkit.createWorld(WorldCreator(worldname))!!? *the second time i execute it
fineeee
i dont think people really understand how important variables are now for reading code
but i love having long method calliong chains
it makes my code so much more unusable!
then that's not good code craftsmanship...
lol
what if your friend wanted to read that
what friends
String fmsg = lvltxt + ChatColor.translateAlternateColorCodes('&', Tazpvp.chat.getPlayerPrefix(p)) + "%s " + ChatColor.WHITE;
String format = p.isOp()
? fmsg + ChatColor.WHITE + "%s"
: fmsg + ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', "%s");
e.setFormat(format);```
tjere
theer
happy?
😳
wait i think i did it in the wrong order
arent you supposed to swap the statements of the ternary?
yep
thats the reason why it didnt work
look in the picture here #help-development message
why tf combing char codes and colorcode enum
idek
not even using string.format
correct
When I apply damage to a player with Player#damage it gets reduced by armor and the protection on it. Is there a way to add damage without this reduction but with damaging properly and not setting the health?
Player#setHealth?
setting the health won't make totems etc work
You want code of a line that I already explained?
player.damage(whatever);
I just had issues that when the player has full netherite armor with prot this damage is reduced significant
so u want them to receive true damage and ignore armor?
My code just killed the player by damaging the current health and it didn't work with full prot armor. I just set it to max integer value and it works fine now but I'd like to know how to do it properly ^^
(Full netherite prot 4 causes 3,5 hearts instead of 10)
yes
i thought player#damage ignores armor
I also thought that
it doesnt?
Idk if they changed that but it seems something doesn't work properly there
this should have killed me there
people say "I use kotlin because it's not as verbose as java"
meanwhile me:
do you unironically comment your code?
I do comment my code
otherwise I wouldn't know what it does in a week
u might have to calculate it yourself
how can i use essentialsx in my plugin? i am coding in 1.8.8 spigot atm and i want my plugin to depend on essentials and use its commands
aka
nah I can just put the max integer value and it works fine but it is weird
make players execute essentialsx commands
you can make players execute commands using BUkkit.dispatchCommand
wdym weird?
any command as long as it exists on the server?
that it worked fine for like forever but now it just doesn't want anymore
sure
oh
okay how can i check whether essentials plugin exists on the server
i dont really know
Maybe something changed in 1.17-1.18 but i have really no idea
check if Bukkit.getPluginManager().getPlugin("Essentials") is null
okay ty
val world: World = Bukkit.createWorld(WorldCreator(worldname))!! why is this null sometimes?
my death chest plugin
why the full path
I can also use
depend:
- Essentials
in plugin.yml
ye?
sometimes intelliJ is so weird. it doesn't recognize McMMOUtils until I type it out. Then suddenly it knows about it
daddy
does your totem get stuck or smt
so I can do
if(Daddy.allows(...))
but sometime it was stuck in an endless loop
so I renamed Daddy to Stepsister
because we all know that stepsisters tend to get stuck in awkward places
myes
i love this community
Is there a way to damage a player while ignoring his armor?
Player.damage
It doesnt ignore the armor
huh
Player#damage(float) deals exactly the given amount
no matter what armor they wear
?paste
How can I use the custompermscommand string from the commandexecutor in my event listener?
early returns are a thing
whats that
if (!(sender instanceof Player)) {
sender.sendMessage("only players");
return;
}
if (args.length < 1) {
sender.sendMessage("incorrect usage");
return;
}
// etc
// do all your stuff```
It should be a field
it doesn't recognize the custompermscommand string inside my event handler
yes, that's why it should be a field lol
how do you make it a field?
private String custompermscommand;
Then in your command you would set the field to be what you want it to be
if the field isn't set yet you return on the event
Is there any plans to make Bungeecord and spigot FML2 compatible?
it says that private modifier is not allowed here
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.
fml meaning forge?
yes
no
bungee has forge support
I have no idea what that even is lol
meaning getModList etc of forge doesn't return anything as the channel Bungee communicates to the client in is outdated
Hello ! I come to you because I have an NBT String from an ItemMeta. How can I load it into my item? Do you have an idea? Thank you in advance.
Ah thanks you
@tender shard bro this so fascinating. I can how see how everything plays out. Although most of the nms code is obfuscated for 1.8.8
:v that's not nms code tho
FML2 is 1.13+ forge iirc
:v u need to get buildtools for nms code
Well at least to use it
Let me find some nms code
Jesus what decompiler is that? IntelliJ-decompiler?
Bukkit and CraftBukkit are on stash. NMS can;t be hosted as it belongs to Mojang
@EventHandler
public void onDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
Player killer = player.getKiller();
double mh = player.getMaxHealth();
if (killer instanceof Player) {
double kmh = killer.getMaxHealth();
player.setMaxHealth(mh - 2.0);
killer.setMaxHealth(kmh + 2.0);
}
if (!(killer instanceof Player)) {
player.setMaxHealth(mh - 2.0);
}
if (mh <= 2.0) {
Bukkit.getBanList(BanList.Type.NAME).addBan(player.getName(), "Straciłeś wszystkie serca!", null, null);
}
}
help
this ban is not working
This code will never trigger if (!(killer instanceof Player)) {
Ye why
it does
impossible
try then
I have a TextComponent. It contains placeholders. I want to replace the placeholders to a custom TextComponent (multiple placeholders and multiple custom components). This creates an TextComponent[] which I can send to the player
How to do this as efficient as possible?
You assume the killer IS a player right at the start. If it is not it will throw a ClassCastException and exit the method
why would you create a text component before replacing the placeholders
how to replace this then?
Good idea to not do it, but then I still need to replace the parts in a string to a custom textcomponent
You only treat anything in an event as a Player AFTER you test that it is a Player
Oh I see what you mean. Sorry this is the PlayerDeathEvent. The Entity will always be a Player
ok looking over your code you try to ban the player if his max health is 2.0 or below. However you read the max health (mh) before you adjust it. so this should only ban the player when he actually hits 0 max health
However, bans by name are no longer supported
getBanList by name now returns null
is there a banlist by uuid then?
yes
wwhere
Um, good question. I assumed there was as the javadoc says there is
hehe
getBanList
@NotNull
public static BanList getBanList(@NotNull
BanList.Type type)
Gets a ban list for the supplied type.
Bans by name are no longer supported and this method will return null when trying to request them. The replacement is bans by UUID.
Parameters:
type - the type of list to fetch, cannot be null
Returns:
a ban list of the specified type
wait what class is that
I just checked 1.18.2 and no UUID type
That javadoc is from teh link I posted above
I want to make a custom tab list, but somehow I can't get the right order when there are real players, how do I solve it
https://www.toptal.com/developers/hastebin/dodohujolu.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
lol
I'm going to hope the javadoc is just ahead of itself and it doesn;t yet return null
How to create a NPC via protocollib?
poor dude has to smell so much ass
¯_(ツ)_/¯
I need via protocollib
doesn't protocollib have a discord?
I bet that 99% of people here have no idea about protocollib
protocollib sucks anyway
count me in
it makes everything like 300% more complicated than just using NMS
https://github.com/JEFF-Media-GbR/JeffLib/blob/master/spigot_1_18_R2/src/main/java/de/jeff_media/jefflib/internal/nms/v1_18_R2/NMSHandler.java I always just use NMS packets
?jira
whas that
no
What packet should I use to close a book gui?
oh
how i can get a entity from an unloaded chunk? i have the UUID but Bukkit.getEntity() returns a null instance
something i can do?
load the chunk the entity is in I guess ?
thanks ;D
gotta get a packetcontainer channelduplex varint packetadapter to send one packet with protocollib
yeah lol
protocollib is so overly complicated that the whole purpose of it is useless
I mean it's okay to listen to incoming packets
but if you just wanna send an outgoing packet, protocollib just makes everything so complicated
lol
is it possible to intercept packets going out to open a new inventory and instead just send the items in the inventory?
so it doesnt reset the cursor
if not, it's fine because i really dont want to change the contents of the inventory
you woul dhave to keep inventory size and name in mind as well
?paste
i dont have anything to paste cuz idk if it's even possible
dont believe it is
considering the client would be in a different inventory client side than server side, which would make the transaction id invalid
you would have to listen to incoming packets as well, and manually call inventoryclickevents
yeah
it could also be exploited by the client to make them pretend to be in a certain inventory when they arent actually
do u put them in the list?
Yes of course xd
u should use a concurrenthashset btw
since asyncplayerchatevent is on another thread
always Threadsafe if you can. Future proof code is good
agree
so it sends not in the list somehow?
I'll debug the list after adding them
print the list on player chat
Also known as ConcurrentHashMap#newKeySet
yep
(or KeySetView)
Why it doesn't work?
int CustomModelData = 6370006;
item.getItemMeta().setCustomModelData(CustomModelData);
need to set the item meta back
So youll have to store the ItemMeta in a variable temporarily
I don't quite get it, is there some sample code?
Yes just google how to set custom model data for items
int customModel = 100;
ItemMeta mt = item.getItemMeta();
mt.setCustomModelData(customModel);
item.setItemMeta(mt);
You need to store a reference to the ItemMeta
Modify that,
( come on it's 4 lines, how is that spoonfeeding )
And then placing the thing back
Thanks
I'm kinda confused
ooh yeahhh
(also, that arraylist should be final)
it should be a set
@iron glade that's the issue
More pay for me
haha u get to "optimize" later
If you want something optimized you have to start from the very start with that in mind
Optimizing something later usually does not work
If you want to get it "finished" don't be concerned with optimizing much.
Yeah that is true, all of my overly optimised stuff never went into production
Especially because it takes ages to come up with anything and after a while the motivation is drained
Is stash trying to use a different account to jira?
I just get a no permission to access BitBucket when trying to view PRs
yeah separate accounts
how can i check if a player is vanished by Essentials's /vanish using my plugin?
use teh Essentials API
link pls?
No clue
does the bungeecord Configuration have something like ConfigurationSerializable from bukkit?
Did you sign the CLA?
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
public class BackpackInventory implements InventoryHolder
{
protected UUID holder = null;
protected Inventory inv = null;
protected int rows = 0;
public BackpackInventory(UUID holder, int rows)
{
this.holder = holder;
this.rows = rows;
this.inv = Bukkit.createInventory(this, 9 * rows, "Backpack");
}
public UUID getHolder()
{
return this.holder;
}
public void setHolder(UUID holder)
{
this.holder = holder;
}
public int getRows()
{
return this.rows;
}
public void setRows(int rows)
{
this.rows = rows;
}
public Inventory getInventory()
{
return this.inv;
}
}
```is this causing a memory leak per call?
^^^^^^^^^^^^^^
no
it causes a memory leak however if you store references to your BackpackInventory class that you don't need anymore
lol why r u setting the object to null if you set it in constructor
ok i have this now @tender shard
looks good
no i check it and upcast it like this
do i need to change the class that gets imported ?
no
nope. I'm not attempting to make a PR. just view them
maven-shade-plugin changes it automatically for you
You can only view PRs if you have signed the CLA
woah Allman style
can someone hel p me test plugin
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
public void onInventoryClose(InventoryCloseEvent event)
{
if (event.getInventory().getHolder() instanceof BackpackInventory)
{
BackpackInventory inventory = (BackpackInventory) event.getInventory().getHolder();
...
}
}
```@martin
i dont see the damn codespaces tab lol
no you're downcasting
so its not only in the constructor's local scope?
upcasting = Player > CommandSender
downcasting = CommandSender > Player
in 99.9% of cases you only need downcasting
i suppose i get it right that if the inventory gets closed by the last viewer
the inventory gets removed from memory
and the BackpackInventory instance gc'd?
yeah then it'll get GCed
kk ty
@granite owl can i see how you implement backpackinventory?
basically just like thos
this
One more question. Why it doesn't work?
ItemMeta meta = e.getItem().getItemMeta();
int customModelData = meta.getCustomModelData();
e.getPlayer().sendMessage(String.valueOf(customModelData));
if(customModelData == 10);{
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
public static void onRightClickAbility(Player player, ItemStack is)
{
if (!CustomItems.itemCooldown(player, is)) return;
ItemWrapper item = new ItemWrapper(is, null);
if (item.getItemStack() != null)
{
if (item.isCustomItem())
{
if (item.getItemType().equals(Backpack.getItemWrapper().getItemType()))
{
BackpackInventory inv = new BackpackInventory(player.getUniqueId(), item.getItemInteger("item_rows_current"));
if (item.getItemBytes("item_inventory").length > 0)
{
//fill inventory
}
player.openInventory(inv.getInventory());
}
}
}
Yeah
remove the ; after your if statement
its a bunch of wrapper classes to access PDC flags
then creating the backpack inv
and making the user view it
@tender shard there we go
Ohh so ur only using it to "mark" that it's your inventory
if ur using my method
be aware thoi
its not reload safe
so u need to force players to close this inventory on reload
thats why i typecast it
wtf are you doing
why don'T you just use PDC
hmm
alex i changed the version in the .txt file on github and it still says its the latest
i have certain standard flags that are always the same across all custom items
and what's your plugin version?
and thus ive written a simple wrapper for those flags
and i put the itemstack in a wrapper instance for easier access
the message you sent is from Vault
the itemwrapper instance goes out of scope anyway and the item itself persists
what's your plugin version? and what version did you save on github?
what link did you pass to the update checker?
it does
@humble tulip
public static void onRightClickAbility(Player player, ItemStack is)
{
if (!CustomItems.itemCooldown(player, is)) return;
ItemWrapper item = new ItemWrapper(is, null);
if (item.getItemStack() != null)
{
if (item.isCustomItem())
{
if (item.getItemType().equals(Backpack.getItemWrapper().getItemType()))
{
BackpackInventory inv = new BackpackInventory(player.getUniqueId(), item.getItemInteger("item_rows_current"));
if (item.getItemBytes("item_inventory").length > 0)
{
ItemStack[] items = (ItemStack[]) NonReflectables.deserializeBukkitObjectFromByteArray(item.getItemBytes("item_inventory"));
inv.getInventory().setContents(items);
}
player.openInventory(inv.getInventory());
}
}
}
}
lmao
unless github isnt letting it get the version.txt file
to implement backpacks
why are you only using early returns in the first line
cooldown
as it pmuch says
@tender shard i can send the code in my onEnable if you want
so u cant spam item right click effects
yo guys
do early returns for the other checks then too lol
if i want to connect my server to my bot
public void onEnable() {
getLogger().info("Enabling");
(new UpdateChecker(this, UpdateCheckSource.CUSTOM_URL, "https://raw.githubusercontent.com/oliver194/Mecha-Plugin/master/src/main/resources/version.txt"))
.setDownloadLink("https://github.com/oliver194/mecha-plugin/releases")
.setNotifyOpsOnJoin(true)
.setUserAgent((new UserAgentBuilder()).addPluginNameAndVersion())
.checkEveryXHours(2.0D)
.checkNow();
int pluginId = 15385;
Metrics metrics = new Metrics(this, pluginId);
getCommand("heal").setExecutor((CommandExecutor)new HealCommand());
getCommand("feed").setExecutor((CommandExecutor)new FeedCommand());
getCommand("fly").setExecutor((CommandExecutor)new FlyCommand());
getCommand("mecha").setExecutor((CommandExecutor)new MechaCommand());
}```
is this a good idea
wait i cant send images
lemme get the prnt sc
If I want to make a stats command about my server, is this a good idea to do it?https://prnt.sc/ir5LU3Ok3nys
!verify
Usage: !verify <forums username>
oof i dont think that D is meant to be there
wdym with server stats
Amount of players in the server, ram etc
and maybe a hastebin of the all the players in the server
Do u just create an inventory and use the methods that u override from inventory to call them back on in inv you create?
How can I prevent a snowball from getting destroyed on ProjectileHitEvent?
I'm not sure thats possible. But you could try canceling the hit event and zeroing out the snowballs velocity
I found a way by spawning a new snowball at the same location, and then assigning my new velocity to it.
how can i use a string from my override method inside of my eventhandler method in the same class?
@tender shard ahhh
provide more code than that
🤔
package me.deveroonie.essentialsk.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.Bukkit.*;
public class Broadcast implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
Bukkit.broadcastMessage(args[1]);
return true;
}
}
essentialsk
ok done
click merge
yeah i did
well done
why [1]?
🤔
/command args[0] args[1] args[2] ...
i thought it was ]1]
thats how commands are
[1]
Are you doing that on purpose?
i didn't realist [0] existed
ignoring the first argument
no
args[0] doesnt even have to exists
Exactly
so check args.length
