#help-development
1 messages · Page 1662 of 1
it's your personal opinion, it doesn't mean "should" it means "can"
It says serious questions
main: com.thechemicalworkshop
such a pointless debate
Yes, and if he didn't understand the google answers he can as well ask it here
An ItemStack has an ItemMeta. Of this ItemMeta you can get the display name or the lore.
Someon also suggested to use the ItemStack#isSimilar(ItemStack) metod.
And even if it is not in the channel description it’s common sense, even something discussed in the staff channels iirc
okay, what should it be? im following a tutorial from spigot...
Yes 2Hex but then he could point out what he didn’t understand
yes i edited the meta of my item
the path to your main class AND your main class
"common sense", you could define that to people, not everyone has your exact "common sense"
main needs the full qualified path to your JavaPlugin class. Including the classes name.
Anyways if you want to continue debating this go #general
and he did
Sure
i cant use this method
Then compare the display name of the two ItemStacks.
dangerous, but given the circumstances better than nothing
I suggested PDC but he is a beginner.
The display name will be pretty reliable anyways
PDC is easier than DI
package com.thechemicalworkshop;
import org.bukkit.plugin.java.JavaPlugin;
public class App extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("Hello, SpigotMC!");
}
@Override
public void onDisable() {
getLogger().info("See you again, SpigotMC!");
}
}
main: com.thechemicalworkshop.App
name: BlankPlugin
version: 0.1
sorry if im stupid, i never had to compile a language they all would compile at runtime...
except if he joined today he would know how to use it, thats my opinion
What is DI?
Dependency Injection
But why the hell would you want to use DI here
Looks good
can you even compare this?
I dont see what those two have in common...
two itemstacks?
mosty, no. PDC is pretty complicated once you go into the path of custom date types, otherwise it is easy. The same thing applies to DI, there are instances of Dependency Injection that are far more complicated
i just have one
how tf is pdc complicated bro
its like 2 lines of code (they should be more if you don't want to have bad practice)
I mean. Check the display name of one ItemStack. I just assumed there that you created one prototype ItemStack that you can give to people and that you can use for checks.
Lines of code != complicateness
theey can get away just with copy pasting as 7smile7 said in a conversation yesterday
Incorrect
let's hope the spigot docks are well written... not beeing able to run and debug = rip
How so?
just add comments lol
if it's 2 lines you probably would figure it out soonly
its like reading a textbook
Then dice the code up
Code shouldn’t be made for beginners, it should be made for the readers who knows how to code
but add some info and divide it
code should just be more readable
that is completely false 2Hex
dont care about the receiver/reader
Most beginners find it as I stated
Indeed luzifer
this confused me
but i still have this opinion
You can run & debug, but it is complicated to do without a proper IDE (and heck, even I have no idea how to do it). That being said, Java's stacktraces will help you out in most cases
But if the code is big and complicated but offers future proof and extendability then let it be that way
Spigot docs are pretty good though
you will figure it out in a way shorter time if it's small code
if it's huge, you will take long to even read it
easy
Not always
Yes always, except if you're coding nms 
to understand extracted code which is splitted into several methods also takes its time. most of the time goes in just clicking through the methods
i need bruatally simple things, like "op on join" or "spectate on death" or "run X after 10s"
Yeah, then the System.out way of debugging will be sufficent
i checked the display name
You have to compensate for being small in code also, everything is done with less lines so you can’t always express yourself richly, the code is less likely to be future proof for additional features.
is everything asynchrous by default? i have lots of wait statements and stuff...
Short != trivial
Example:
OptionalDouble av = IntStream.rangeClosed(-100, 100).boxed().mapToInt(Integer::intValue).limit(20).mapToDouble(i -> i / 2.0).average();
or
public static int rangeBitwiseAnd(int m, int n) {
return m < n ? rangeBitwiseAnd(m, n & n-1) : n;
}
Most beginners would have literally 0 idea what any of this means.
Doesn't ruin my statement by any means
second one variables are killing java principles, so forget it
No. Minecraft runs on one thread. And so does spigot. If you wait then the server will stop. If you wait long enough then it will even crash.
Complicated != code length
1 letter variables are fine in 80% of cases
In most cases that is not true
that is one example
Also you’re incorrect, 2Hex a variable only has to be meaningful in the scope they live in
Yes, and "e" or "p" has no meaning
I go by Robert B. Martin there. If they are used in 3 consecutive lines and have a clear defined scope then they are fine.
oh... how im supposed then do smth after like 10s?
I know this is just a warning, but i don't understand why i don't get that kind of warning for e.g. the TAB Plugin (https://github.com/NEZNAMY/TAB) which also use the channels
imo, no
Spigot has a scheduler for that. You can schedule runnables after N ticks there. One tick is at least 50ms (more if your tps are low)
numParam would be also good
Hm, could you show code?
hm
F
another F
so maybe num
yeah tell that to yourself 
argc, fight me
pointing out the obvious is just filling your code with garbage.
okay i feel like this will be painal... let me first compile the easy plugins
That's ignorant
ofc its a number and ofc its a param. This is worse than m
The code of my plugin or of TAB ?
I basically do the same, register the channel and send data 😅
2Hex, you really shouldn't be arguing here. You are still learning Java...
Yes, but these are opinions
it’s not
Yeah. The BukkitScheduler is a bit hard to grasp at first.
TAB ones, but seeing yours too wont hurt either
conventions != opinions
A variable should only be meaningful in the scope they live in
conventions are opinions that you have to go with
90% of people here are against you
either way, it's getting unnecessarily toxic so ill take my leave
@ivory sleet it was a fun argument :D
A pointless one too
It’s principles and theories (arguably theorems)
no
saving stuff (multiple times)in config file in runtime is also a convention ?
only beginners say its toxic
cause they refuse to learn
lol
I am learning
More about an optimization and a way to address a problem
You arent if you are already arguing about your own opinions without even learning proper conventions and usages first
I actually learn more stuff everyday I use the spigot api, so I consider my self learning
Because writings and reading to the disk can be resource taking
Could you specify further?
That’s good
You don't learn Java specific usages
Maybe teach that skill to every beginner that tends to drop in here
well, conventions won't break your code so I find them opinions, and that's my opinion
conventions arent opninions tho
if your opinion isn't same as mine no need to force it into me
i have so many questions but don't wanna ask here because then it's like ya'll wrote the code for me...
Yes, and it's the opinion of the devs 
It's not?
i'm not gonna name names but an expert here was saving temporary stuff in the config file multiple times in runtime (so always opening/closing the file to save and load information) instead of using a data structure
you should follow the conventions
Then you can go up to your first interview and show them "your opinion" and see how they react
Lol
They will break your code indirectly by introducing hard to track bugs
they;re gonna kick you out
That is true
instantly
Java calls them out as java naming specifications also
Usually you only load on onEnable and save on onDisable though
but what I meant is, they won't break your code, so they're not 100% necessary, I would say it's 99.99% :P
The config itself is just a Hashmap, so it isn't that big of an issue
they can actually in certain scenarios
"certain"
We work with most not certain ;)
Lol
how can i equal player.getItemInHand() to a custom item
.equals
ur ide would tell you to change it i guess

💩
"it compiles!"
so the IDE is an opinion
poop
right?
except if you're using vsc or something, lol
saying custom item
ig applications have opinions now?
.equals
Get the display name of your custom item and compare it with the name of the current item.
Ideally you would use the PDC but i think the name is ok for now.
The thing is that the official sun java conventions date from 1997. Even though many have different opinions nowadays.
no, if it changes how the code runs / makes it run its not an opinion
how is it not an issue? opening and closing a file multiple times consecutively and concurrently instead of using a data structure?
Prime example are space vs tab conventions
Anyways Pulse, geol and 2Hex let’s just stop with this nonsensical opinion claim
#isSimilar
wdym by current item
oh well my messages arent sending
You use tabs while im with you and you get a slap on the hands
dont use tab please
32 gigs of ram isn't enough to dev... rip, need a 2nd pc
As I said, you usually only save the config once and load is once
Pulse how’s emc
sure you can use it for indents as long as it gets converted to spaces lol
its fine

obviously ...
player.getInventory().getItemInMainHand().isSimilar(customItem);
although its reccommended to use PDC if the item ever changes
The item you want to test. You get its name and check if the name contains or equals a String you specified.
Which invalidates the opening and closing files argument.
7smile7 recommending checking custom items by name 
The only thing is that the bukkit config wrapper imposes some overhead, but it isn't too drastic
it's multiple times during the execution not once per enable and disable , it's dumb wtf
He is a beginner. And ive seen this from others so i thought this is the simplest approach. isSimilar will break a lot of ItemStacks.
thats why i said use PDC
better to start off the beginners with some knowledge imo then let them start easy
imo
i dont have an item to test im just trying to equal the item on players hand to custom item
Then that is not the recommended way of doing it unless you keep the file actually open (for example this is highly recommended for really big files, but then, these wouldn't be configs)
isSimilar is prob better
.equals or .isSimilar
isSimilar ignores the item amount @kindred valley
alright how to identify the custom item class to the event
use DI
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
custom item class?
FileConfiguration is just a MemorySection which uses a HashMap.
You can read from a FileConfiguration at runtime without many problems.
You have a bit of an overhead when parsing the path but its light years faster than
reading it from disk. Its just very error prone because everything is referenced by Strings.
i made item package and im putting the items on it by classes
like, do you extend ItemStack
imagine is it fine if I edit DI?
Why. Explain.
Loov yo
i mean
cant u just change the item name
and that will break the whole thing
??
if you just use new ItemStack, there is nothing to worry about you "custom" item class (though that class would be more of a storage class)
Hey so, my target item is still duplicating with https://paste.bristermitten.me/fyvizodibi.php I can't work out if I have a client side bug or if it's in the code what can I do to test?
It will also break isSimilar. Your point?
public class CustomItemListener implements Listener {
private final ItemStack customItem;
public CustomItemListener(ItemStack customItem) {
this.customItem = customItem;
}
}
@kindred valley this code can work in many different ways
If so, the asker will notice it and ask us later for how to better identify the stack
lol no u dont get it
i can get a wooden stick, change its name to the custom item name
Not if it contains a color char
then i get the stuff of the custom item
it also breaks isSimilar and .equals
@lost matrix How did you manage to get the code to work so easily on your system but on mine it causes issues non stop? 🙂
thats why you use PDC
You don't get it too
if u change a wooden stick to a custom item name
Fucking hell
ok
u wont get the abilities of the custom item
No idea. I just have a clean setup i guess.
you make no sense
I mean, I'm barely doing anything else from what you did and It won't work.
yes, but right now we are discussing equals vs isSimilar
Then include the color tag in the name. You cant use those when renaming ItemStacks in an Anvil
I got nothing else in the plugin to affect it I don't think.
It works fine in survival mode but in creative no luck.
You must have something. We otherwise have the same setup so thats the only variable.
Infact you don't get it, others did
"you make no sense" replace that with "I did not understand you"
what are you even on about 💀
Hmm, if someone had a plugin to change names with chatcolors it would break
I'm copying the survival code which works into the creative to see if that fixes anything.
Creative is evil for that kind of stuff. Dont rely on it as the ItemStacks are handled client authoritative in creative.
or if 2 items have the same name
Should I only test in survival?
its basically the same as comparing inventories with their title, isn't it?
yeah
.
Sure. But this fact alone makes the name comparison several times more robust than isSimilar.
if 2 items have same name
it would completely break the thing
isSimilar way better imo
yep creative messes it up survival doesn't. great !
thats why plugins should always use PDCs, its like SQL injection for minecraft plugins
thanks for the help by the way
too bad not all versions have pdc
update bozos
well yes but actually no lol
Makes no sense. I think i made my point clear. Use PDCs if you know what you are doing and infos retrievable from the ItemMeta instead if not.
tell that to server owners 
too bad these versions dont support Java 16
you get what i mean
tell that to server owners too
Anyways, gotta compile it with Java 16 and noone will complain
Ooh!!! we should call it
"Item Injection"
devs r prob gonna follow what server owners want
nah, I'm following what I want
You need to be egoistic in life and not follow the sheeple
And I want the latest java version
very wise words, well done my guy
PDCs are not ItemStack exclusive.
Display Injection
Maybe NBTInjection
you usually wont care about money anyways if PDC is your issue
na we call it "injectdataintostuff"
Because the PDC is just stored in the PersistentDataHolders NBT data.
ez
Because if you were to care, then you could use libraries
pdc tbh speaks for itself, so u might as well just use that name
PersistentDataContainers 2.0
ez
mno
i created a class for identify the custom item and i created an event class and i want to use that custom item on event class
It might be best if you could show your classes, as we would otherwise be basing ourselves on false assumptions
Create an instance of your item identifier and pass it to other classes via their constructor for example.
package com.thechemicalworkshop;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.EventHandler;
public class App extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("Hello, SpigotMC!");
}
@Override
public void onDisable() {
getLogger().info("See you again, SpigotMC!");
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
e.getPlayer();
getLogger().info("See you again, SpigotMC! " + e);
}
}
the eventhandler does not do anything... no errors compiling....
Hello so i'm asking for how to set speed potion time
my code:
Potion p = new Potion(PotionType.SPEED, 2);
ItemStack item = p.toItemStack(1);```
it's show as Sped II (1:30)
how to set it as Speed I (8:00)
and thanks
you didnt register the event
oh deer, how do i do that...
change the constructor to ... , 1); to change the level/strength of the potion to 1
You need a custom PotionMeta for that. The second argument here just changes the tier of tier of the potion.
i tried that
okay 1m
meta.addCustomEffect(arg0, arg1); ? @lost matrix
d1
you also didn't implement the Listener interface
Bukkit.getPluginManager.registerEvents(this, this);
Anyone know what causes this: java.util.FormatFlagsConversionMismatchException: Conversion = c, Flags = In ASyncPlayerChatEvent.setFormat?
type it onEnable @gaunt saffron
im super lots
Example (didnt test)
public ItemStack createCustomPotion(final PotionEffectType type, final Color color, final int tier, final int duration) {
final ItemStack potion = new ItemStack(Material.POTION);
final PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
potionMeta.setColor(color);
final PotionEffect customEffect = new PotionEffect(type, duration, tier);
potionMeta.addCustomEffect(customEffect, true);
return potion;
}
okay sir , i'll test it
i can't meta.setcolor @lost matrix
Is this important?
Then you use an outdated spigot version i suppose?
Not important.
Ah...
for pvp servers btw xd
I figured...
if you want 1.8.x why are you not using 1.8.9
or are you making the plugin for someone else
bcz spigot not supporting 1.8.9 i think
only 1.8 - 1.8.8
yes i'm making plugin for someone else
i'm dev on other server i don't want to adv
and he using 1.8
oh right
i forgot
Quick (and potentially dumb) question: is it "safe (ignoring the recommendation status)" to extend ItemClass to store data on an itemstack?
just moved my kitpvp server to another vps and there is this A symbol in every item in kits and npc wich i renmed and it fixed but if i try to rename them all this would take long time any fix?
https://media.discordapp.net/attachments/880433197610041415/880516605287739482/unknown.png?width=852&height=479
version: spigot 1.8.8
Change start args
1.8.9 was a client only update
Forgot how it was called
for example what should i edit in it?
ItemClass is not a class in spigot. Do you mean the ItemStack class?
just add that and it will fix
how are you setting item names
oh lol, yes, I meant ItemStack
best not be "§cString"
my brain is starting to rot I see
yea
its &like : &a&lname
ok
Because it wont persist in any way. Spigot completely throws the ItemStack away when interacting with the NMS backend.
So everything you do to that interface will just be discarded.
Is the vps on windows server?
yes
Yeah if u add that in server start args it should be fine 👍 👍
ok
So you cant implement ItemStack nor extend CraftItemStack (which is final anyways) to make any changes to an ItemStack or persist any data in it.
Best you can do is wrap the ItemStack in a custom class and use the PDC underneath.
it's show as Water Pottle @lost matrix
k. I didn't want to store data persistently anyways, but if CraftItemStack exists then yea
You can store data about an itemstack in a Base64 string
ItemStack item = new ItemStack(ItemsAPI.createCustomPotion(PotionEffectType.SPEED, Color.RED, 2, 30));
Yeah i forgot to set the ItemMeta back on the ItemStack.
Do that and also change your line to:
ItemStack item = ItemsAPI.createCustomPotion(PotionEffectType.SPEED, Color.RED, 2, 30);
ooh
what hte fucc
spam, most likely
its not spam
?paste use that instead
-D options go before the executed jar and after the -jar command. @quaint mantle
It is, it took an entire screen. Even if the intentions were noble
my bad i did not read the code
thx btw
@tacit drift https://paste.md-5.net/toqayaroca.diff fix this!!!
ok
what about this one
:|
im so much lucky :|
You missed a " there
it's still waterbottle i set the itemmeta @lost matrix
Hm. Let me test my code ^^
okay sir
take your time
it's give me the speed effect when i'm drinking it .. but the item show as water @lost matrix
Works great for me.
Maybe a problem with your very old spigot version ^^
yes maybe , btw thank you so much for helping me @lost matrix
is it actually possible to kick a player if he has a certain fabric-mod installed? i see people using the absolutely dumb coded mod Tweakeroo mod on my server
Uhm. Fabric sends the clients mods to the server through some custom channel iirc. Its a bit complicated but possible.
it's so insanely dumb that people publish mods that are not made to hack, but allow stuff like freecam on servers
i'll ask on their dc tho
I dont think that fabric published the mod list in any way
I know that quilt will allow this, but fabric does not. Or at least it used to be like that not long ago
I know that forge does it. Fabric should be the same, no?
Nope, fabric is not.
How does fabric then check if the client has the proper mods installed to join a server?
Surely the client does not decide that.
apparently it does it based on the registry
I. e. it connects and hopes that all stars align well
There must be some communication happening. Ill go ask on the fabric discord.
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
@still wing
second
do keep in mind that if you intent to stay paper-only this event might not be a good option for you given paper's absurd component refractor
replace it..
what exactly?
wdym?
I'll ask mcdevs too while we are at it
?
what do you mean?
translation may not be correct due to the fact that I use google translator
String.replace
he should know that, if he doesn't then he should learn java.
Yeah
🤨
?
just started teaching today
=
we write + like yes
you are going to have to learn it for a few months if you want good knowledge
don't make a plugin the first day you start learning
Stop trying to code plugins and go learn java
yes i started
you’re teaching Java?
so stop making the plugin and learn java first
yeah
Learning*
Google translate mixes up the two
sorry
you should learn the language first, not make shit the first day.
sorry
no problem, but you are going to have problems upon problems if you don't learn it properly first.
tbh
what proud desk is saying is 100% the truth
but
personally, i find java really boring so im learning both spigot api and java atm
but i cant go so far in spigot api until i learn more java
but its better to learn both at the same time if u can :P its also fun
ANYWAYS
how to get the player seeing a placeholder
offline player doesnt seem to work
public class PresencePlaceholders extends PlaceholderExpansion {
/* *** SNIP *** */
@Override
public String onPlaceholderRequest(Player player, @NotNull String value) {
// Code ...
worked brilliantly for me in the past
i might be a little stupid here but why can my yaw be anything between around -870 and +870
Works for relational placeholder only iirc
i have
@Override
public String onRequest(OfflinePlayer player, @NotNull String params) {
// Compute and return your placeholder here
UUID uuid = UUID.fromString("");
for (UUID key : BaseCommand.leaders.keySet()) {
if (BaseCommand.leaders.get(key).contains(player.getUniqueId()))
uuid = key;
}
return getTeamIndex(uuid);
}```
hmh, this plugin is a bit strange
public String getTeamIndex(UUID leader) {
Set<UUID> keySet = BaseCommand.leaders.keySet();
ArrayList<UUID> list = new ArrayList<>(keySet);
return String.valueOf(list.indexOf(leader));
}```
public abstract class BaseCommand implements CommandExecutor {
protected static JavaPlugin plugin;
protected static LinkedHashMap<UUID, List<UUID>> leaders = new LinkedHashMap<>();
protected static List<UUID> toggledChat = new ArrayList<>();
}```
from which class does your override stem from?
That's just 150.
the pitch makes sense but the yaw just seems broken
can someone help me
dunno
hm?
Try implements https://extendedclip.com/javadoc/placeholderapi/me/clip/placeholderapi/PlaceholderHook.html#onPlaceholderRequest-org.bukkit.entity.Player-java.lang.String- but uh, idk if that works after the note from smile
Like 870, 570, 150 are all the same yaw I'm pretty sure.
i get these kinda numbers
meaning my character either doesnt have a functioning neck, im stupid or im being given weird numbers
You can safely clamp them down into your desired range afaik
The protocol accepts out-of-bounds yaw/pitch wouldn't be surprised if it wasn't different with the bukkit api
Does the protocol clamp them if they're out of bounds?
?paste
I swear I read something about out-of-bounds rotation somewhere.
how would i clamp the yaw?
idk
that is the player parameter
<unclamped> % 180
I do not see what the issue is
870 % 180 in your case gives 150, and -870 gives 30
u mean OfflinePlayer player?
yea
ah kk
im extending PlaceholderExpansion
im assuming % 90 on the pitch to keep it fixed?
Then according to the javadocs it should be Player player, but if it compiles ¯_(ツ)_/¯
Well if you want it fixed you should just set it to whatever the fixed amount is
Otherwise, yes % 90
ye kinda said it wrong
but thanks
getCommand("kelepce").setExecutor(new Kelepceler());
`'Kelepceler(org.bukkit.inventory.ItemStack)' in 'com.limpeex.Items.Kelepceler' cannot be applied to '()'
what can i do
It wants you to give it an ItemStack
what
there is no Player
i said im extending PlaceholderExpansion
it does not accepting itemStack either
I bet it does. Try
import com.limpeex.Plugin;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
public class Kelepceler implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (commandSender instanceof Player) {
Player player = (Player) commandSender;
ItemStack kelepce = new ItemStack(Material.TRIPWIRE);
ItemMeta meta_kelepce = kelepce.getItemMeta();
meta_kelepce.setDisplayName(ChatColor.GRAY + "Kelepçeler");
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.DARK_BLUE + "Polislere Özgüdür");
lore.add(ChatColor.DARK_BLUE + "Kişileri Kelepçeleyip Soymaya Yarayabilir.");
meta_kelepce.setLore(lore);
meta_kelepce.addEnchant(Enchantment.PROTECTION_FALL, 1, true);
player.getInventory().addItem(kelepce);
player.getInventory().addItem(getKelepce());
}
return true;
}
private ItemStack kelepce;
public Kelepceler(ItemStack kelepce) {
this.kelepce = kelepce;
}
public ItemStack getKelepce() {
return kelepce;
}
public void setKelepce(ItemStack kelepce) {
this.kelepce = kelepce;
}
}
sorry
im trying to do something really wild here for fun, but i first want to know how and if it'd be possible
Send the code where you're trying to give it the ItemStack
there is no empty constructor so you can;t instance it without an ItemStack
id'd like to make kind of an eloquent system like the laravel php framework has, would it be possible to create a custom collection class where i could iterate through and instance of it? like Collection users = User.getAll(); and then be able to put users straight into a for loop for example
i suck so please don't beat at me
my friend gave me this:
package com.thechemicalworkshop;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class App extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("Hello, SpigotMC!");
getServer().getPluginManager().registerEvents(new MyEvents(), this);
}
@Override
public void onDisable() {
getLogger().info("See you again, SpigotMC!");
}
}
public class MyEvents implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e){
Player player = e.getPlayer();
e.setJoinMessage(ChatColor.AQUA + player.getName() + " joined the server!" );
}
}
i assume i should put the public class MyEvents into a file, should it be next to app.java or where?
public void onEnable() {
getServer().getPluginManager().registerEvents(new XPBottleBreakEvent(),this);
getServer().getPluginManager().registerEvents(new EggThrowEvent(),this);
getCommand("god").setExecutor(new GodMode());
getCommand("feed").setExecutor(new Feed());
getServer().getPluginManager().registerEvents(new PoliceBlockBreakEventAnnonation(), this);
getCommand("911").setExecutor(new NineNineOneCommand());
getCommand("vault").setExecutor(new vault());
getCommand("flymode").setExecutor(new FlyCommand(this));
getConfig().options().copyDefaults();
saveDefaultConfig();
getCommand("tpbow").setExecutor(new TeleportBowCommand());
getServer().getPluginManager().registerEvents(new TeleportBowEvent(), this);
getCommand("kelepce").setExecutor(new Kelepceler(this, this));
}
}
and placeholderexpansion extends placeholderhook
i made a constructor to handle it
but ingame command doesnt work
no, because you are trying to create a new instance without an ItemStack
what should i do
Sorry to say, but learn java
Your method constructor requires an ItemStack so you can;t create it without one.
and you are telling me that i need to create a constructor with itemstack
to use i need to use the reference right?
holy fucking shit
elgar is telling ppl to learn java
this is a special case
bro ur case is really bad if elgar tells u to learn java
..
i dont care
look at your register command line
try adding "" to your entries
getCommand("kelepce").setExecutor(new Kelepceler());
should be like this?
no
i cant use itemstack constructor
where you are callign new Kelepceler
show code
you are trying to use an empty constructor
but you don;t have a no args constructor
- ?paste
- wtf...
do i need empty constructor?
- why do you have this itemstack shit in ur command class
it looks ugly
move it to a itemstacks class
if you want to instance it with no args, yes
public Kelepceler() {
}
should be like that right
yes
because he has one that takes an Itemstack so he has ot have an empty one to use a no args
?paste
Has nothing to do with papi.
UUID.fromString("")
Just doesnt work because... an empty String is no UUID.
i changed it tho
UUID uuid = UUID.fromString("");
for (UUID key : BaseCommand.leaders.keySet()) {
if (BaseCommand.leaders.get(key).contains(player.getUniqueId()))
uuid = key;
}
holy fuck bro
errors this @eternal oxide
do you guys know why falling blocks spawned via packed do not show? I can see the particle when it lands but the block itself isn't there
UUID uuid = UUID.fromString(""); <- This method call here throws your exception.
LOL
i see
thank you ill try to figure it out <3
What packet do you use?
PacketPlayOutSpawnEntity
Do you also send the MetaData afterwards?
yes
@Override
public String onPlaceholderRequest(Player player, @NotNull String params) {
// Compute and return your placeholder here
for (UUID key : BaseCommand.leaders.keySet()) {
if (BaseCommand.leaders.get(key).contains(player.getUniqueId())) {
return getTeamIndex(key);
}
}
return "";
}```
smile u think dis will work
This is how i do it with my class which extends EntityFallingBlock
public void showTo(final Player player) {
final PlayerConnection connection = ((CraftPlayer) player).getHandle().b;
connection.sendPacket(this.getPacket());
connection.sendPacket(new PacketPlayOutEntityMetadata(this.getId(), this.getDataWatcher(), true));
}
Because i remember having the same problem
So i just grabbed the packet from the EntityFallingBlock
I send the entity directly to the client don't create a new class that extends it
i need help
getPacket() is public. Use this packet instead
It is a spawn entity packet. Its just prepared by the class.
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
Spigot plugins generally should work on paper.
7smile7, do you think this is better?
@Override
public String onPlaceholderRequest(Player player, @NotNull String params) {
// Compute and return your placeholder here
for (UUID key : BaseCommand.leaders.keySet()) {
if (BaseCommand.leaders.get(key).contains(player.getUniqueId())) {
return getTeamIndex(key);
}
}
return ChatColor.translateAlternateColorCodes('&', "&cNONE");
}```
Yes
i code using spigot?
pog
You code with whatever you want. If you want to to write a spigot plugin, write with spigot.
If you want to write a paper plugin then write using paper. But spigot plugins will run on both.
They just use some magic inside
I don't think it is public tho
ok
can't find it
What version?
1.16.5
Look for a method that returns Packet<?>. Maybe its obfuscated.
okay
Might not even return packet if it’s obfuscated
I cant open spigot 1.17.1.jar
Only inner classes are obfuscated iirc. And Packet is for sure not. Or what do you mean by that.
Yeah I forgot class names were never obfuscated
You are also not supposed to open the jar.
oh
But it has cookies inside!
the block is still is invisible sadly
where do i put it then
idk why it would be tho
Show some code plz
cod of the jar
yeah one sec
Get a decompiler
one sec
The proper way would be to generate the mojang mapped jar via BuildTools. Then you can just traverse it with your IDE
Why do you want to see the code?
Open or launch
launch
Ah.
CafeBabe (Bot)
https://www.spigotmc.org/wiki/spigot-installation/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say hi");
what do i need to import to be able to use this/is there a better way?
i just wanna send a message to a player..
player.sendMessage
player.sendMessage("hi")
Or if you want to tell it to everyone on the server:
Bukkit.broadcast("hi")
if i do bukkit. i get error, what do i need to import?
org.bukkit
getCommand("kelepce").setExecutor(new Kelepceler()); empty constructor doesnt work for execute the command
can someone help me
Only a type can be imported. org.bukkit resolves to a packageJava(268435843)
Huh? Just let your IDE import your stuff.
dont have that option, at least dont see it
VS Code
Oh no
yes im not gonna switch IDE due to 1 language
I mean there might be a plugin for it
I've just added bungecord to my server. And the bungecord has to be running in online mode and the subservers in offline for the proxy to connect. But the thing is.
My SMP has been running in Online mode all this time
So me turning it to offline has reset everyones stats claims
like evreything
Help ahah
Anyway for the proxy to run with online mode?
I have 3 instances, proxy, smp and lobby. in the spigot.yml bungecoord is true
But dedicated java ides exist for a reason
lol. I literally use one specialized IDE for every language.
well, my efficiency would go too much down
C# -> raider, C++ -> CLion, Python ->PyCharm, Js -> WebStorm, Java -> IntelliJ
yeah, i did try eclipse and it was tererible
Yes 😄
did try arduino ide, also terrible
Anyone?
But CLion honestly needs some more time
I sometimes use IntelliJ for web dev if I'm doing a java webserver
plus don't even have space for that ahahah
how would i do colors? can i use &c?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Bukkit.html
Here is the import for Bukkit. I guess you just need to have this open or find a way to let your IDE resolve the imports.
declaration: package: org.bukkit, class: Bukkit
?jd ChatColor
thanks
Nope. The color identifier char is § You can however translate color from every char
ChatColor.translateAlternateColorCodes('*', "*eHi")
Ideally you should use the ChatColor class
eh i guess i'll use the function ot top..
Can get a bit clunky though
well do if i want red-blue in 1 line..
oh jeez
lets see if java supports painless multiline..
CharColor.RED + text1 + ChatColor.BLUE + text2
or TranslateAlternateColorCodes with &aText 1&9Text 2
can you help
If you use the latest version then yes
this
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i found like 10 ways... which one is the best/most used?
https://www.baeldung.com/java-multiline-string
The top one with “”” is probably the easiest
Also TIL you can do that in modern java, nice
to explain and show me the steps
Only took them 10 years
Heh
7smile
okay i have no idea lol, im used to \ or + too much
The website describes the steps pretty meticulously. If you know how to do
the basic things with your computer like writing a text file then you should
be able to do this. There are also a million videos for this.
- will concat strings in java
+ is ok. I usually go for that. Just dont concat Strings outside of a declaration.
whatever that means
concat = concatenate = connect two strings together
IE: "Hello" + "World" = "HelloWorld"
yeah
player.sendMessage(
ChatColor.RED + "aghh you died !\n" +
ChatColor.RED + "you can spectate others or use" +
ChatColor.GREEN + "/lobby " +
ChatColor.RED + "to go back");
how do i make it red AND bold?
ChatColor.BOLD
The operator + is undefined for the argument type(s) org.bukkit.ChatColor, org.bukkit.ChatColorJava(536871072)
🙄
okay, this is weird, then i might just add it for all tbh
oh yeah i remember it like 8 years ago you had to add tostring ot EVERYTHING
Java doesn't like implicitly calling toString on both sides of the + I guess
it has to start with a String or it can;t work out what it is adding
eg you can do ""+ ChatColor.RED + " strings"
are there tools to make a plugin more lightweight? im very conserned about size/performance usage
get what you want to do working, then worry about size
okay, the stuff works, it tells the message but then it tells me i died... i assume i need to wait a bit? how long/how?
What are you trying to do?
would it be possible, to run a command as a player on a spigot server, beeing a bungee command?
then a user dies, make them spectator and let them know they can use /lobby
this has to go on like 3 servers (for now) which get indefinetly scaled
basically they get replicated and destroyed, depends on number of users...
Smells like docker
yupp
i wrote a lot of logic and people from docker and ptero argued with me for hours saying this aint possible....
i have a system, indefinetly scalable, just need to call orcale and it's indefinetly, indefinetly scalable
i'll leave last step since im broke and limit to like 8 cores 48 gigs of ram
You could try and listen for the EntityDamageEvent and check if the final damage
will kill the player.
Then cancel the event and make him a spectator. But this will prevent all PlayerDeathEvents from being handled if thats ok.
And you would need to write your own death messages.
nah i can't do that, because they are handles by another plugin
so PlayerDeathEvents it is
You can fire the PlayerDeathEvent yourself.
even tho another plugin has the custom message? i can delay it?
You could even delay it. But not recommended.
well yeah, not gonna do
this
and this
and i'm done with one plugin, like few more togo
Why would you ever import an enum statically?
well, i found this somwehere
Anytime you use wait, you're going to cause the whole server to wait. You need to learn runnables/threads. The delayed task might be useful in your case.
?scheduling
Ive learned ^^
this?
I had not paid attention to this and simply adopted it as suggested by the programme.
oh jeez... this is complicated
so i have imported
import org.bukkit.block.data.type.Stairs;
and
import static org.bukkit.Material.BRICK_STAIRS;
so far
i wish there was await wait(10)...
the await keyword is pretty strange imo
Is this javascript?
Ew
Its to wait for promises, right? Im not much of a js guy.
If people would replace sync/async with off-thread/on-thread and blocking/non-blocking it would be much easier to understand
example...
python has similar thing...
and I never got around to python
Yeah but then it would not be technically correct anymore. Because async does not mean multithreaded.
Something can run async but still be executed on the main thread.
Correct, which is why I implied that async could have two meanings that look the same at the surfact but are radically different
well but async is huge step forward...
Yeah. I still remember when i tried to wrap my head around that
For example it is impossible to write anything multithreaded in python because of the global interpreter lock yet they have this???
well there is threading...
You can't say there is threading if the language can only compute one instruction at a time, huge waste of processing time given that nowadays we have multicore
Sure, it does fit the definition of threading
but I do not really like it
I mean you can spawn multiple system threads in python. I remember programming something in python 2 years ago and managed to make it run on all cores.
true, but if you care about performance you shouldnt be using python
okay is easy way to make this python stuff be delayed?
Using the scheduler isnt that bad.
package com.thechemicalworkshop;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.entity.HumanEntity;
import org.bukkit.GameMode;
import org.bukkit.Bukkit;
public class MyEvents implements Listener {
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
Player player = e.getEntity();
// System.out.println(player.getName());
player.setGameMode(GameMode.SPECTATOR);
player.sendMessage(ChatColor.RED.toString() + ChatColor.BOLD.toString() + "aghh you died !\n"
+ ChatColor.RED.toString() + ChatColor.BOLD.toString() + "you can spectate others or use "
+ ChatColor.GREEN.toString() + ChatColor.BOLD.toString() + "/lobby " + ChatColor.RED.toString()
+ ChatColor.BOLD.toString() + "to go back");
// Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say hi");
}
}
so far im here, thought of doing it like as title or smth but eh
You should try to respawn the player directly using player.spigot().respawn();
nothing
Nothing
okay
the compiling... jeez
like 1min wasted to test the code 🙄
plus i dont have mc on my machine
so i need to cp..
okay
so i did /kill and it spawned me at the spawn as spectator and it killed me.... lol
i think delay?
maven compiles everything in under 10 seconds max in my experience
yeah but server restart
Yeah delay it by 1 tick
and copying over
can i have easy to understand code?
You can try hotswapping (most use /reload though)
Make a script that
stops the mc server
compiles using mvn
cp to the server
starts the server again
profit?
cant
Honestly, spigot is so unstable with their api :/
becuase MC and Maven are on different machines
i have all my coding on a VM
sometimes i do debugging of malware and yeah....
also weird imports and weird stuff
Bukkit.getScheduler().runTaskTimer(this, () -> {
// COde
}, 1, 1);
That runs it every tick, but the system will be similar
Example? In my experience the API is very stable and in most cases the devs just fked up.
plus when i stream i prefer not to show my stuff
every? or after?
I mean, the thing you were helping me with today you can get it to work but it's not working for me :/
what's first 1 and what's 2nd 1?
Hm. This will run the code every single tick
why .toString() chatcolours?
Thats because you fked up 😄
yea, it will be different but I have no example of it on my head
But I don't know how I'm making it go wrong :/
if i dont i get errors
this @quaint mantle
bc ur not doing it right
then tell me pls?
I seriously can't work out where I'm going wrong
ChatColor.RED + "string"
Chatcolor.COLOR + “” + ChatColor.BOLD + “message”
int delay = 1;
Bukkit.getScheduler().runTaskLater(this.plugin, () ->{
}, delay);
You need to get an instance of your JavaPlugin into the class this is called from.
Bukkit.getScheduler().runTaskLater(this, () -> {
// Code to run one tick later
}, 1L);
this
@gaunt saffron
ah dang it, you beat me
is your spigot / paper up to date
ye it should be
okay, is converting to string more ineff?
very sussY
I'm on 1.17
well it either is or isn’t
Do you have the right import?
spigot can still have versions past that
Want me to download the latest on the site?
Right because toString() is implicitly called for every Object that gets concatenated to a String.
run /version and it will tell you
Yea
You need to get an instance of your JavaPlugin into the class this is called from.
i dont understand
1.17
Are you using the forbidden site?
No its literally the same
probably?
?
Idk, someone told me it was worse
I used to use it with to string
yes but it will say how many versions you are behind
Man why hasn’t spigot enabled threads
but i didn't think it would cause this issue even if i'm a bit behind tho
Its just unnecessary. toString() gets called implicitly.
well it works for smiley face over here and my own implementation in a different plugin which is similar to yours also works
It wont. Its 100% an issue with your code.
But I legit can't work out where I'm going wrong
package com.thechemicalworkshop;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.entity.HumanEntity;
import org.bukkit.GameMode;
import org.bukkit.Bukkit;
public class MyEvents implements Listener {
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
Player player = e.getEntity();
// System.out.println(player.getName());
int delay = 1;
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
player.setGameMode(GameMode.SPECTATOR);
player.sendMessage(
ChatColor.RED + "" + ChatColor.BOLD + "" + "aghh you died !\n"
+ ChatColor.RED + "" + ChatColor.BOLD + "" + "you can spectate others or use "
+ ChatColor.GREEN + "" + ChatColor.BOLD + "" + "/lobby " + ChatColor.RED + ""
+ ChatColor.BOLD + "" + "to go back");
player.spigot().respawn();
// Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say hi");
}, delay);
}
}
is this correct? yeah i know i can remove some ""...
Survival it works absolutely fine
But when it comes to creative, it fucks up using the exact same code
Show the code pls. Write a test plugin that only uses the code ive sent to you to make sure this actually is a problem with your code.
Nvm let me just compile and send you my jar.
I find it weird how survival it works, but creative it breaks.
Dont rely on creative. Just forget the idea that you will be able to support creative clicks. Unless you want an extra layer of headaches.
So only test in survival and drop creative mode support?
that's perfectly fine with me only testing in survival
okay does not work
[23:21:14 ERROR]: Could not pass event PlayerDeathEvent to BlankPlugin v0.1
java.lang.Error: Unresolved compilation problems:
plugin cannot be resolved or is not a field
Lambda expressions are allowed only at source level 1.8 or above
at com.thechemicalworkshop.MyEvents.onPlayerDeath(MyEvents.java:19) ~[?:?]
source level? how do i even change this i only could choose upto 1.4
You can rename an Emerald with this. Just click an Emerald with a named ItemStack on your cursor. Its 1:1 the same code.
*16 actually, 17 didn't realease smh
whats thhe difference? also, where
i do
in your pom.xml source and target. I think ive seen it already in your pom. Just for 1.7
Change it to 16
The difference IS a decade of development
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>```
question is, if i load this plugin into 1.12will it still work?
just changing the stuff from latest to 1.12
wherever it is
No, for that you need to use Java 8 (I. E. 1.8)
so i need to recompile just to use one for 1.12?
1.12 is Dum and can't handle Java 9+
jeez
well i found nice plugin in 1.12 i wanna use... so
idk
okay compalingf for 16..
But you need to recompile anyways for 1.12 use due to the mat refractors
yeah screw 1.12 for now then
[23:27:43 ERROR]: Could not pass event PlayerDeathEvent to BlankPlugin v0.1
java.lang.Error: Unresolved compilation problem:
plugin cannot be resolved or is not a field
at com.thechemicalworkshop.MyEvents.onPlayerDeath(MyEvents.java:19) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor1.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.17.1.jar:git-Paper-85]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.17.1.jar:git-Paper-85]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.17.1.jar:git-Paper-85]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:624) ~[patched_1.17.1.jar:git-Paper-85]
i assume this line...
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
just this?
Instead of this.plugin
ok
he method runTaskLater(Plugin, Runnable, long) in the type BukkitScheduler is not applicable for the arguments (MyEvents, Runnable, int)
you sure?
That being said, this is as Long as it is in the Main class, otherwise you need to do DI
thanks for your help @lost matrix I think i got it all working
Dependency injection it is then
it's not it's a seperate file
You basically needd to give it you plugininstance
No, No need to Import anything. Imports in Java dont so anything
They even get removed after you compile it
oh so unused imports arent an issue?
Or you could just make a static field in ur main class
No really
if dependency injection is not an option
package com.thechemicalworkshop;
import org.bukkit.plugin.java.JavaPlugin;
public class App extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("Hello, SpigotMC!");
getServer().getPluginManager().registerEvents(new MyEvents(), this);
}
@Override
public void onDisable() {
getLogger().info("See you again, SpigotMC!");
}
}
this is my main file
Why do you need your main class instance? Runnables?
Change the constructor of MyEvents to MyEvents(JavaPlugin) and Pass this into the constructor
getServer().getPluginManager().registerEvents(new MyEvents(JavaPlugin), this);
i assume
private JavaPlugin plugin
public MyEvents(JavaPlugin plugin) {
this.plugin = plugin;
}
Then use that instance you passend through the constructor to Set a field, which you will use

now idk whom to listen
we are saying the same thing xD
woh..
No, use new MyEvents (this) here
I simply posted the constructor required for that class
getServer().getPluginManager().registerEvents(new MyEvents(JavaPlugin), MyEvents(this));
