#help-development
1 messages · Page 230 of 1
the event is not me making the class
implements TabExecutor
uh ok
this is bungee
instead of listener or botg>
not on bungee
both
i tried bungee
i decided to try and make a command
couldn't figure it out
then gave up
commands are not hard on bungee
m
can you just give me an example class of a command being tab compleated?
im confused
private final ServerThings plugin;
public MS(ServerThings plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
String noPermission = this.plugin.getConfig().getString("No-Permission-MSG");
if (sender instanceof Player) {
Player p = (Player) sender;
if (sender.hasPermission("server.multisummon")) {
if (args.length >= 2) {
try {
EntityType entity = EntityType.valueOf(args[0].toUpperCase());
int amount = Integer.parseInt(args[1]);
for (int i = 0; i < amount; i++) {
p.getWorld().spawnEntity(p.getLocation(), entity);
}
p.sendMessage(colorize("&aYou've spawned &e" + args[1] + " " + args[0] + "s"));
} catch (IllegalArgumentException e) {
p.sendMessage(colorize("&4This is not an entity."));
}
} else {
p.sendMessage(colorize("&4/multisummon [mob] [amount]."));
}
} else {
p.sendMessage(colorize(noPermission));
}
} else {
sender.sendMessage(colorize("&4You cannot do this. "));
}
return true;
}```
I want to make this less arrow
wdym
instead of wanting to check if its correct, checkif it isnt and if it isnt return
yes thats a good way
eg if (!(sender instanceof Player)) return
but that makes it where if u wanna do smthing after then it wont work
if those return true
tf is it returning
return true;
xd
it pretty much just ends the method there
but I want it to send a message
so add the {}
so like
if (!(sender instanceof Player)) {sender.sendMessage"tfamIdoing" return true};
return true in the {}
if (!(sender instanceof Player)) {
sender.sendMessage"tfamIdoing";
return false;
}
iirc return true sends the sender the usage
dumb mfs
i'm the only dumb mfs here
thats a lie
maybe
That's make two of us
Return false sends the declared command usage
theres 3 actually
yeah y'all have been speaking nonsense for the past 20 minutes
i thought it was the other way round lul
correct
no
that's why I have return true; in my thing
I have no idea how to do the little code box ;- ;
thing
this
?
no
`this`
2 `
`hi/
this
i learn new thing
this is werid
xd
damn this is cool
return true;
yooooo special text
t
><+-.,[]
whatever this thing is !()
H O W T O T A B C O M P L E T E O N A B U N G E E C O R D P L U G I N
if (!(sender instanceof Player)) {
sender.sendMessage(colorize("&4You cannot do this. "));
} else {
Player p = (Player) sender;
if (!(p.hasPermission("server.multisummon"))) {
p.sendMessage(colorize(noPermission));
} else {
if (args.length >= 2) {
try {
EntityType entity = EntityType.valueOf(args[0].toUpperCase());
int amount = Integer.parseInt(args[1]);
for (int i = 0; i < amount; i++) {
p.getWorld().spawnEntity(p.getLocation(), entity);
}
p.sendMessage(colorize("&aYou've spawned &e" + args[1] + " " + args[0] + "s"));
} catch (IllegalArgumentException e) {
p.sendMessage(colorize("&4This is not an entity."));
}
} else {
p.sendMessage(colorize("&4/multisummon [mob] [amount]."));
}
}
}```
I think this is a little less arrow
how to not type like an idiot
but still some arrow
what
not possible
you can use return statements to avoid nesting
nesting?
yeah
if (staircases) {
falldown();
}```
always use this if possible, nesting hurts my eyes 🥲
you can instead do
if(!something) {
return;
}
if(!somethingElse) {
return;
}
both conditiomns are true
conditiomns

wait I can just put ! instead of having it in it's own parentheses
nesting is cool 🤩
for a few statement yes, for a lot like doing a state machine.. no :'/
I really hate one part of advanced programming
nesting is pretty much unavoidable when dealing with futures and multithreading
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
String noPermission = this.plugin.getConfig().getString("No-Permission-MSG");
if (!(sender instanceof Player)) {
sender.sendMessage(colorize("&4You cannot do this. "));
} else {
Player p = (Player) sender;
if (!p.hasPermission("server.multisummon")) {
p.sendMessage(colorize(noPermission));
} else {
if (!(args.length >= 2)) {
p.sendMessage(colorize("&4/multisummon [mob] [amount]."));
} else {
try {
EntityType entity = EntityType.valueOf(args[0].toUpperCase());
int amount = Integer.parseInt(args[1]);
for (int i = 0; i < amount; i++) {
p.getWorld().spawnEntity(p.getLocation(), entity);
}
p.sendMessage(colorize("&aYou've spawned &e" + args[1] + " " + args[0] + "s"));
} catch (IllegalArgumentException e) {
p.sendMessage(colorize("&4This is not an entity."));
}
}
}
}
return true;
}```
alr illuminati guy I have no idea what i'm supposed to be doing
just look at this
if (item2 != null) {
if (item2.getType().equals(Material.NETHER_STAR)) {
if (item2.hasItemMeta()) {
if (item2.getItemMeta().hasDisplayName()) {
if (item2.getItemMeta().getDisplayName().equals("§3§lMenu §8(§7Click§8)")) {
event.setCancelled(true);
}
}
}
}
}
beautiful
This looks like a rifle
i can't read that
WAIT NO HES COMPARING ITEMS
oh you've seen nothing

@EventHandler
public void onRightClick(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (!(e.getItem() == null)) {
if (e.getItem().getItemMeta().equals(itemManager.ultimateSword().getItemMeta())) {
if (!cooldown.containsKey(p.getUniqueId()) || System.currentTimeMillis() - cooldown.get(p.getUniqueId()) > 5000) {
cooldown.put(p.getUniqueId(), System.currentTimeMillis());
p.sendMessage(colorize("&aYou've used the Ultimate Ability!"));
p.getWorld().createExplosion(p.getLocation(), 15f);
} else {
p.sendMessage(colorize("&4You can't use this for another &e" + (5000 - (System.currentTimeMillis() - cooldown.get(p.getUniqueId()))) / 1000 + " &4seconds!"));
}
}
if (e.getItem().getItemMeta().equals(itemManager.ownerSword().getItemMeta())) {
p.getWorld().createExplosion(p.getLocation(), 20f);
}
if (e.getItem().getItemMeta().equals(itemManager.teliStick().getItemMeta())) {
p.teleport(p.getLocation().add(p.getLocation().getDirection().multiply(15)));
}
if (e.getItem().getItemMeta().equals(itemManager.ultimateTeliStick().getItemMeta())) {
p.teleport(p.getLocation().add(p.getLocation().getDirection().multiply(30)));
}
}
}
if (e.getAction() == Action.RIGHT_CLICK_AIR) {
if (Objects.requireNonNull(e.getItem()).getItemMeta().equals(itemManager.ultimateSword().getItemMeta())) {
if (!cooldown.containsKey(p.getUniqueId()) || System.currentTimeMillis() - cooldown.get(p.getUniqueId()) > 5000) {
cooldown.put(p.getUniqueId(), System.currentTimeMillis());
p.sendMessage(colorize("&aYou've used the Ultimate Ability!"));
p.getWorld().createExplosion(p.getLocation(), 15f);
} else {
p.sendMessage(colorize("&4You can't use this for another &e" + (5000 - (System.currentTimeMillis() - cooldown.get(p.getUniqueId()))) / 1000 + " &4seconds!"));
}
}
if (e.getItem().getItemMeta().equals(itemManager.ownerSword().getItemMeta())) {
p.getWorld().createExplosion(p.getLocation(), 20f);
}
if (e.getItem().getItemMeta().equals(itemManager.teliStick().getItemMeta())) {
p.teleport(p.getLocation().add(p.getLocation().getDirection().multiply(15)));
}
if (e.getItem().getItemMeta().equals(itemManager.ultimateTeliStick().getItemMeta())) {
p.teleport(p.getLocation().add(p.getLocation().getDirection().multiply(30)));
}
}
}```
AH
yes

LMAO WHAT NO

what's wrong

what in the unholy fuck am I looking at
the demon living inside my code
backrooms code
I'm speechless
who do we ask to get the code to no clip out of reality
public ItemStack ultimateSword() {
ItemStack ultimateSword = new ItemStack(Material.DIAMOND_SWORD, 1);
ItemMeta meta = ultimateSword.getItemMeta();
meta.setDisplayName("§4§kscary§1Ultimate Sword§4§kscary");
meta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);
meta.addEnchant(Enchantment.SWEEPING_EDGE, 10, true);
meta.addEnchant(Enchantment.FIRE_ASPECT, 10, true);
meta.addEnchant(Enchantment.KNOCKBACK, 10, true);
meta.addEnchant(Enchantment.LOOT_BONUS_MOBS, 10, true);
meta.addEnchant(Enchantment.DURABILITY, 10, true);
meta.addEnchant(Enchantment.MENDING, 10, true);
ultimateSword.setItemMeta(meta);
return ultimateSword;
}``` I also have this shit
NOPE
use OOP man
actually question
EVERYONE RUNNNNNNNNNNNNNNNNN
is there a way to get all those enchants inside one line of code
Yes
and how is that
use oop
declaration: package: org.bukkit.inventory, class: ItemStack
i fear oop
a map of Enchantment and int
Map.of.stream etc
this is my infamous one-liner
int i = Integer.parseInt(player.getInventory().getItem(36).getItemMeta().getLore().get(0).substring(12, player.getInventory().getItem(36).getItemMeta().getLore().get(0).toCharArray().length));
i have no clue how to use that at all
Well then don’t make it one line lol
boolean smile = potato.equals(potato2) ? true : false;
That hurts
Map<Enchantment,Integer> of ench and level
No checks at all
i've used like one thing that includes map.of.stream
return StringUtil.copyPartialMatches(args[0].toLowerCase(), Stream.of(EntityType.values()).map(Enum::name).map(String::toLowerCase).collect(Collectors.toList()), new ArrayList<>());
i hate that
WHAT'S WRONG WITH IT
its long
DO YOU EVENT KNOW WHAT IT IS FOR
also why are you args[0]#toLowerCase()
null checks amirite
it returns all entity types
so you don't have everything in uppercase when you tab complete
haha no
haha yes
nonononono
if it works don't change it
my man
my brain is going smooth again
I've been making plugins for 6 years
have over 400 projects on my ideaprojects folder
I have never seen something this fucked up
it's not that bad
it's one line
🥲
Not even @torn shuttle 's code is this bad
and it does the job
and we have beef
what about YandereDev
even his code is better than what ungodly fuck you have written
return StringUtil.copyPartialMatches(args[0].toLowerCase(), Stream.of(EntityType.values()).map(Enum::name).map(String::toLowerCase).collect(Collectors.toList()), new ArrayList<>());
this?
all
At least make it expandable, if it's too long extract method and name it properly.
Idk one liner is good for this
feast on this
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
String noPermission = this.plugin.getConfig().getString("No-Permission-MSG");
if (!(sender instanceof Player)) {
sender.sendMessage(colorize("&4&bYou can't do this!"));
} else {
Player p = (Player) sender;
if (!(p.hasPermission("eagle.unenchant"))) {
p.sendMessage(colorize(noPermission));
} else {
ItemStack item = p.getInventory().getItemInMainHand();
ItemMeta itemM = item.getItemMeta();
for (Enchantment ench : Enchantment.values()) {
itemM.removeEnchant(ench);
}
item.setItemMeta(itemM);
p.sendMessage(colorize("&aYou've Un-Enchanted your item!"));
}
}
return true;
}```
and this
```java
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, String[] args) {
String noPermission = this.plugin.getConfig().getString("No-Permission-MSG");
if (!(sender instanceof Player)) {
if (Bukkit.getOnlinePlayers().size() > 1) {
sender.sendMessage(colorize("&aThere are &e" + Bukkit.getOnlinePlayers().size() + " &aplayers online!"));
} else {
sender.sendMessage(colorize("&aThere is &e" + Bukkit.getOnlinePlayers().size() + " &aplayer online!"));
}
} else {
Player p = (Player) sender;
if (!(p.hasPermission("eagle.online"))) {
p.sendMessage(colorize(noPermission));
} else {
if (Bukkit.getOnlinePlayers().size() > 1) {
p.sendMessage(colorize("&aThere are &e" + Bukkit.getOnlinePlayers().size() + " &aplayers online!"));
} else {
p.sendMessage(colorize("&aThere is &e" + Bukkit.getOnlinePlayers().size() + " &aplayer online!"));
}
}
}
return true;
}```
plus my brain can't process that fast what the code does.
OH NOW YOU WANNA SAY IT'S NOT THAT BAD
return StringUtil.copyPartialMatches(args[0].toLowerCase(), Stream.of(EntityType.values()).map(Enum::name).map(String::toLowerCase).collect(Collectors.toList()), new ArrayList<>());
but somehow this is worse
LOL
tf are you doing my guy
i now use switches
who are you to judge
YOOOOOOOOOOOOOOOOOOOO NO!
them

did you wash it in the dishwasher
how about you show us your best heal command
never made a heal command
is there an event for like running into a block?
tf do you mean
i mean you can check if they have a block in front of them
imllusion ur typing quite the paragraph
no IDE ;)
this
how are you gonna use utils without an ide :kekw:
memory
I made the code I can recite it
no there isn't an event for that
ok xd
come to town and say every single letter without a single mistake without looking at anything
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch
illumanati my code is already written
public class HealCommand implements SimpleCommand {
private final MessagesFile messages;
public HealCommand(MessagesFile messages) {
this.messages = messages;
}
@Override
public String getIdentifier() {
return "heal.*";
}
@Override
public String getPermission() {
return "commands.heal";
}
@Override
public void execute(CommandSender sender, String... args) {
if(args.length == 0) { // target is the sender itself
if(!(sender instanceof Player player) {
messages.send(sender, "console-no-args");
return;
}
healPlayer(player);
messages.send(sender, "heal-self");
return;
}
String targetName = args[0];
Player target = Bukkit.getPlayer(targetName);
if(target == null) {
messages.send(sender, "target-not-found");
return;
}
healPlayer(target);
messages.sendMessage(sender, "heal-other", new Placeholder("target", targetName));
messages.sendMessage(target, "healed-from-other", new Placeholder("healer", sender.getName()));
}
private void healPlayer(Player player) {
double maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
player.setHealth(maxHealth);
}
}
idk
alr who is gonna have more than 20 health let's be honest
people with custom attributes
^^
you can't always assume the default nms values
i've tried using attributes 😦
because idiots like me like to change em around
imlllusion time to my abomination
if (!(sender instanceof Player)) {
switch (args.length) {
case 0:
sender.sendMessage(colorize("&4You need to specify a player!"));
break;
case 1:
Player t = Bukkit.getPlayerExact(args[0]);
if (!(t == null)) {
t.setHealth(20);
t.sendMessage(colorize("&aYou've been healed by the &eConsole&a!"));
sender.sendMessage(colorize("&aYou've healed &e" + t.getName()));
} else {
sender.sendMessage(colorize("&4This person is offline!"));
}
}
} else {
Player p = (Player) sender;
switch (args.length) {
case 0:
if (!(p.hasPermission("server.heal"))) {
p.sendMessage(colorize(noPermission));
} else {
p.setHealth(20);
p.sendMessage(colorize("&aYou've been healed!"));
}
break;
case 1:
Player t = Bukkit.getPlayerExact(args[0]);
if (!(p.hasPermission("server.heal.others"))) {
p.sendMessage(colorize(noPermission));
} else {
if (!(t == null)) {
t.setHealth(20);
t.sendMessage(colorize("&aYou've been healed by &e" + p.getName()));
p.sendMessage(colorize("&aYou've healed &e" + t.getName()));
} else {
p.sendMessage(colorize("&4This person is offline!"));
}
}
}
}```
actually it's not that bad
by the console
but being honest I'd probably add more to it
i mean you're kinda missing out on the messages
yeah yeah i know I just learned I can use ! without the !()
tf am I saying
i got confused reading my own writing
i forgot i was having a problem earlier and my brain still wont let me see whats wrong
Class: https://paste.md-5.net/giwaqakugo.java
DataConfig: https://paste.md-5.net/otasufemoy.cpp
When i break a Grass Block it runs giveOrDropItem 5 times, 4 times with amount 1 and another with amount 12. Only the amount 12 one should run because its the correct fortune level. But then if i break GRASS (with drop swap) it runs 6 times all with 1 amounts but gives me 3 pink banners and 3 grass somehow and i cant figure out why any of these are happening, attached a video of what i mean
no don't solve my heal thing if u gonna solve smth solve this
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
String noPermission = this.plugin.getConfig().getString("No-Permission-MSG");
if (!(sender instanceof Player)) {
sender.sendMessage(colorize("&4You cannot do this. "));
} else {
Player p = (Player) sender;
if (!p.hasPermission("server.multisummon")) {
p.sendMessage(colorize(noPermission));
} else {
if (!(args.length >= 2)) {
p.sendMessage(colorize("&4/multisummon [mob] [amount]."));
} else {
try {
EntityType entity = EntityType.valueOf(args[0].toUpperCase());
int amount = Integer.parseInt(args[1]);
for (int i = 0; i < amount; i++) {
p.getWorld().spawnEntity(p.getLocation(), entity);
}
p.sendMessage(colorize("&aYou've spawned &e" + args[1] + " " + args[0] + "s"));
} catch (IllegalArgumentException e) {
p.sendMessage(colorize("&4This is not an entity."));
}
}
}
}
return true;
}```
I think I know
same thing actully happened to me once
Technically can be one line lol
return Stream.of(new ItemStack(Material.DIAMOND_SWORD, 1))
.map(item -> Map.entry(item, item.getItemMeta()))
.peek(entry -> List.of(
Enchantment.DAMAGE_ALL,
Enchantment.SWEEPING_EDGE,
Enchantment.FIRE_ASPECT,
Enchantment.KNOCKBACK,
Enchantment.LOOT_BONUS_BLOCKS,
Enchantment.DURABILITY,
Enchantment.MENDING
)
.forEach(enchantment -> entry.getValue().addEnchant(enchantment, 10, true)))
.peek(entry -> entry.getValue().setDisplayName("§4§kscary§1Ultimate Sword§4§kscary"))
.peek(entry -> entry.getKey().setItemMeta(entry.getValue()))
.map(Map.Entry::getKey)
.findAny();
in this command
the SimpleCommand abstraction already handles this all
idk what you mean
so are you saying it's good
My implementation is good
LIke
You do realize I'm making bootleg photoshop as my gui engine, right?
i have no idea what you're talking about
illusion the big brain, any ideas lol
are you using stuff like for loops
god why is hastebin so small on 1440p
ctrl +
Epic
if ur gonna make something make a gui based item creator for java
i wanna see
I mean more like this
wait wait wait
yes that's how I make guis
you don't use themes?
tf is wrong with youu
no point, base ide looks good enough
dark purple is the only good theme
my ide is lively
What is that
all the colors
That's worse than all the code you've shown
those are distractions
not to me
How do you use yellow
rainbow brackets wooo
I'm fairly productive with my theme, I don't need more distractions
so blue and blue
avoid green at all costs
@undone kernel did you see this?
yes but I have no idea what the things mean
lol
.peek(entry -> entry.getKey().setItemMeta(entry.getValue()))
.map(Map.Entry::getKey)
.findAny();
wait this mf is making a stream
Lol
you know what can be 1 line?
Had to make it one line
also I meant the enchants not the whole sword ...
Oh well
ItemStack item = new ItemBuilder(Material.DIAMOND_SWORD).name("whatever").addEnchantment(DAMAGE_ALL, 10)...
Yeah but that's using an outside class
yeah
so?
Obviously if you were actually doing it you would use that
so i'm to lazy to figure out how to implment it
But this is just to show it in one line without anything else
do you actually think it's funny to rewrite your entire codebase every time you create a new project
Also new ItemBuilder
i only have 1 project
Instead of ItemBuilder.from or ItemBuilder.of
and i suck at it
imllusion help me with 1 thing
sad
added a few more debugs, its running giveOrDop the amount of strings in fortune application, im guessing i would need to put a break on it somewhere so it wouldnt run multiple times for 1 block
something tells me you actually gotta apply OOP principles on your config
and parse it into an actual object instead of reading it every time someone breaks a block
imllusion how do I use uh pdc
you read a tutorial
?pdc
Yes
By the way I don't actually do that lol
public ItemStack ultimateSword() {
ItemStack ultimateSword = new ItemStack(Material.DIAMOND_SWORD, 1);
ItemMeta meta = ultimateSword.getItemMeta();
meta.setDisplayName("§4§kscary§1Ultimate Sword§4§kscary");
meta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);
meta.addEnchant(Enchantment.KNOCKBACK, 10, true);
meta.addEnchant(Enchantment.FIRE_ASPECT, 10, true);
meta.addEnchant(Enchantment.DURABILITY, 10, true);
AttributeModifier dmg = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", 70.0, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, dmg);
ultimateSword.setItemMeta(meta);
return ultimateSword;
}```
No comment.
if (e.getItem().getItemMeta().equals(itemManager.ultimateSword().getItemMeta())) {
if (!cooldown.containsKey(p.getUniqueId()) || System.currentTimeMillis() - cooldown.get(p.getUniqueId()) > 5000) {
cooldown.put(p.getUniqueId(), System.currentTimeMillis());
p.sendMessage(colorize("&aYou've used the Ultimate Ability!"));
p.getWorld().createExplosion(p.getLocation(), 15f);
} else {
p.sendMessage(colorize("&4You can't use this for another &e" + (5000 - (System.currentTimeMillis() - cooldown.get(p.getUniqueId()))) / 1000 + " &4seconds!"));
}
}```
bc sword and event don't work together with attributes
but without the damag attribute it works
Yes lol
how can i make no message send for PlayerQuitEvent & PlayerJoinEvent
setQuitMessage() and setJoinMessage() iirc
There are methods on those events to change it
yall jealous cuz you anus
this is what beauty looks like
beautiful
No
oggly
Hey guys, How Can I get all effects from the potion item?
I tried like below but it's return empty
PotionMeta meta = (PotionMeta) value.getItemMeta();
Potion potion = Potion.fromItemStack(value);
System.out.println(potion.getEffects());
This is deprecated? should I not use it?
Set display name shouldn’t be deprecated
I fear your IDE might be infested with a demon
🤔

nani?
how to fix? xD
Use spigot-api or use adventure
This is an "issue" caused by paper pushing hard for their component API
I forgot to push my item factory to GitHub so I would've showed you
ah alr
what is this even for
stupid paper API deprecated the legacy text becuase its so bad guys
just ignore deprecation it works fine either way
alr
components are totally better
also totally annoying
yes
uhm I have no idea what are you guys talking about lol, I'm a total beginner in java
I just know how it works because I worked with js before lol
PlayerTeleportEvent may only be triggered synchronously. Can someone explain me this error?
you are trying to trigger it async i would guess
how can I trigger teleport synchronously? xd
?paste the code
How can I teleport a player when I call the method in a self created Thread?
ty
?whereami
It was sarcasm
Do Note that bukkit also has components
Or Well, Bungee but those are included in spigot
These suck, adventure components are nice however
Is it possible to get CustomModelData item in itemframe
Create an itemstack with custommodeldata
and set the itemframe content?
oh k
can I hire developers for my plugin (not server.) on this discord server?
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
why are you doing this the hard way?
also what is cost factor?
no I mean what is its purpose
is it suppose to be like added cost similar to that of taxes?
that didn't really explain cost factor
seems unnecessary
nope, just needed to know its purpose for the math
so basically you need to calculate the max you could buy right? And I assume you allow doubles or 2 digits past the decimal ?
Why are my Teams dont work?
cost * wanted quantity = wanted cost
max can buy = wanted cost / currently owned (rounded down on the third decimal since we allow 2 decimal places)
you don't know the cost of stuff?
how do you not know the cost of items
if you don't know how how much 1 item costs, you won't know how much 10 of them costs
alright, using that which is the cost
you would times that by the wanted quantity which is however much the user is trying to buy. So if that is for like an upgrade, and they want 10 upgrades and lets say the cost is 2.50
then its 2.50 * 10 = 25
alright don't listen to me
💀
and I messed up the formula up top, should have been currently owned/wanted cost
I gave you the formula above in calculating the maximum you could buy, it is a two step process. Basically instead of a nice formula you don't understand I have broken it down for you in simpler terms
you didn't specify that earlier
so I assume the cost factor is the exponential part?
that was why I was asking about it earlier
anyways fortunately it doesn't change the formula much
you still have the base cost
which is all you need
all that is needed so its fine
Why i get the error Cannot resolve the symbole b?
you could use modulo as well to do the decimal place math as it will give you the remainder.
(cost * exponent)wanted quantity = amount needed (round the second decimal place up if there is a third decimal place in result)
max can buy = currently owned / amount needed (round the decimal down for the second decimal place if there is a third decimal place in result)
the math doesn't need to be overly difficult 🙂
cost is the base cost
exponent is the factor
I wasn't referring to exponent as in an actual exponent
so once you get the max can buy
you just replace the top math where it says wanted quantity with max can buy
and that gives you the amount to deduct from their money
you might want to toss in a check in there if amount needed exceeds what they own
this way, once you have max can buy, you don't have to do the final calculation as you know they will have 0 for a balance lol
because it will still calculate what they could still buy
even though they wanted 10, the math above will still give you the amount they could buy which could be 8
if you really want to use the log method
this is how you do it
Math.log10(double a)
log 10 is base 10 also known as common log
if you want a custom base you would do this instead
Math.log(double logNumber) / Math.log( doube base)
@last temple
you shouldn't need custom log though, base 10 is generally what you want 😛
custom base is for things like you want it in base 3 or ternary
or maybe base 13
how do I stop players from being able to hit each other?
and how do I hide their name tags to certain other players?
well, the math functions I gave above removes the need for log. Using log isn't necessarily more optimal since a lookup table is needed for it to be so.
break down your problem
like
asking us for everything means you're not putting any thought into it
Would there be an event that fires when players hit each other? do some research
there is quite a few different solutions to that problem lol
Is the event cancellable, what happens if you cancel it?
^^
Asking us for a solution to a simple problem that has been documented and solved thousands of times just means you're not putting any effort in
currently I'm putting my players on teams for something else
using the scoreboard teams thing
and with that I can get rid of half of the problem (by turning off friendly fire for it)
but then players can hit each other across teams (which isn't so bad, I can probably use it for another thing I'm doing)
now I just need to find the event for players hitting each other
I will use the secret technique known only to programmers called "googling your problem"
oh wati
wait
wielding such power is unheard of
I think I used the event for something else earlier
EntityDamageByEntityEvent
ok I did it
now time to go back to the other thing I was doing (this project is so much bigger than I thought it would be)
how to sort tab ?
is there anyway to do smth like EntityDamageByEntityEvent.setDamage() but like overriding any modifiers
Hi , anyone useing this :
WesJD/AnvilGUI
Can someone explain me why this code doesnt work?
CompassBuffer.java
private List<PlayerCooldown> player;
public CompassBuffer(Server server) {
player = new LinkedList<>();
server.getOnlinePlayers().forEach(p -> {
player.add(new PlayerCooldown(p, LocalTime.now()));
});
}
public boolean getCooldown(Player p) {
LocalTime timeNow = LocalTime.now().plusSeconds(30);
for (PlayerCooldown pc : player) {
if (pc.getPlayer().equals(p) && pc.getCoolDownTime().isBefore(timeNow)) {
System.out.println(pc.toString());
return true;
}
}
return false;
}```
My code gets stuck on the if sentence because he thinks that the time from the constructor `for example: 17:14:07.896146292` is not before `for example: 17:14:53.114432111`
the gui open but i can't type anything :
update your spigot
update your spigot build
i can't
my plugin built on 1.8.8 ..
i know i know all that talk about its old and other things
i really know , but its stable for me , and for the features i want , why update xd?
For more features
someone know the issue?
Is there an error in the console?
Nope
What is it supposed to do?
It should ask if the time, the user executed the item was 30seconds ago when not then print "on cooldown" else the item should get used
Which part doesn't work?
if (pc.getPlayer().equals(p) && pc.getCoolDownTime().isBefore(timeNow)) {
System.out.println(pc.toString());
return true;
}```
the player is the same
but it tells that the time isn't before
Have you tried logging the values involved?
y
Because you can figure out what's wrong?
I printed both times
The times?
Wait a minute. Do you store the player object?
y in a DAO Pattern
the player object works
but the time doesn't work
PlayerCooldownDAO.java
package dao;
import java.time.LocalTime;
import java.util.Objects;
import org.bukkit.entity.Player;
public class PlayerCooldown {
private Player player;
private LocalTime coolDownTime;
public PlayerCooldown(Player player, LocalTime coolDownTime) {
this.player = player;
this.coolDownTime = coolDownTime;
}
public Player getPlayer() {
return player;
}
public LocalTime getCoolDownTime() {
return coolDownTime;
}
public void setCoolDownTime(LocalTime coolDownTime) {
this.coolDownTime = coolDownTime;
}
@Override
public String toString() {
return "PlayerCooldown [player=" + player + ", coolDownTime=" + coolDownTime + "]";
}
@Override
public int hashCode() {
return Objects.hash(coolDownTime, player);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PlayerCooldown other = (PlayerCooldown) obj;
return Objects.equals(coolDownTime, other.coolDownTime) && Objects.equals(player, other.player);
}
}
Player isn't persistent. If a player leaves and joins the object is invalidated. Why not store epochs instead of objects for the time? Then you can just time1 > time2
@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent event) {
buffer.addPlayer(event.getPlayer());
}
@EventHandler
public void onPlayerQuitEvent(PlayerQuitEvent event) {
buffer.removePlayer(event.getPlayer());
}```
xd
Ah well that works I suppose
oh i figured it out , i had to add an item first , then i can edit it hahah iam so dump xd
instead of using localtime use milliseconds instead
and then convert the milliseconds to time if you really need it
why milliseconds?
because it is accurate and will do what you want and there is Java API methods to get such things. You are not doing anything that would require local time
and uhh how do you mean it
well that's true
I just want to put an delay for 30seconds
yes, and grabbing milliseconds will allow that
just divide the milliseconds by 1000 to get seconds
30000 milliseconds = 30 seconds
this yes
k, tmm good question is how to implement this xd (dont have experience with currentTimeMillis)
so, the math to do it is like so
Time start = System.currentTimeMillis();
check = (System.currentTimeMillis() - start);
if (check >= 30000) {
//do something here
}
//another way to write
if ((System.currentTimeMillis() - start) >= 30000) {}
every time you invoke System.currentTimeMillis() the value is the current time of now.
30000 comes from delay * 1000
to convert seconds to milliseconds
@vague stone provided some example usage
the second way might be the preferred
since everytime the if statement is encountered it will check the current time now
instead of the former having to invoke check to update
kk
i once was storing a WeakReference<Player> and my ref got invalidated while that player was online 💀
that is why you need a system in place to re-validate it
i told myself to not do that again
well it is acceptable, you just forgot to have methods in place to re-validate it if it was invalidated
im now holding a player object in my user class
all references to that user ref get destroyed when the player leaves and so the player object too
as long that is ensured it should be fine, but why do you need to hold a reference to the entire player object?
if you need that why don't you just make a wrapper object
unless that is what your user class is
ye its some kind of player wrapper
dont want to do a map lookup every time i call a method on that user object
even when its just for the slightest thing
😬
see what I would do is just hold a reference to their UUID and then make a method that would return a player object from said UUID when it is needed
thats what people tell me yes
then you can make your user class invoke said method for the player object all the time
now you are not storing an entire player object reference and calling it when it is needed as needed
i am?
that lazy value thing holds a T ref and checks if its still valid on retrieving it
there might be better ways tho
I don't know your code base so can't really say. Personally I typically build off offlineplayer instead
as this allows my code to still function even if they are offline
I want to make a sword that charges up while in your offhand. What would be the best way of doing that?
runnable
im regretting asking md5 for adding 
I like it
i did
I like cats, so the more cat emojis the better
so will dogs and birds if they are not stuck in their cages
fuck
imagine getting eaten by a bird tho
couldnt be me
why havent i documented my code, now im looking at a mess which i dont even know what it does
am i able t oget with mongoDB an arraylist like this or like this?
.get("titles", ArrayList.class); or .get("titles", List.class);
or non of it?
is titles a ArrayList<String>?
if so i believe it knows how to deserialize a string so should work i think
or it might get converted to a Document
always useful to print out .get("titles").getClass()
Is that the only way? I heard runables are laggy
no
i mean if you want it to charge up with some visual animation on whatever you'd need a runnable, if you just want to set a cooldown on that item, comparing the last time used it is fine
runnables themselves are not costly at all
you have bad sources
threads are but thats something else
ahh
dont want a loss on precision but also dont want to use chunky bigdecimals 💀
threads aren't laggy o.O
at least not in of themselves lol
well depends really in what you are doing with them
in terms of amount of resources, yes but you shouldn't be creating and killing threads off constantly though
uhu
smh me creating a CharBuffer class even tho java.nio has one
that one might actually be faster as it uses unsafe
yeah well virtual threads can be wasted a bit carelessly tho
the unsafe usage is creating a buffer in memory directly
using native code
i see
love the coding style of some internal java classes 💀
and then a few hundred empty lines
side effects and naming makes this look like c/++
lmfao
depending on build setup, empty lines are not compiled in
typically in native code this is automatic therefore makes it quite nice using such to separate methods source viewing wise
well, native compilers just automatically look for anything that has empty characters on lines that have no non-empty characters. If such exists it automatically just ignores it in the compiling process thus doesn't show up in compiled code
Bro help me please
in Java however, spaces do matter sometimes as it can increase file size, so it is just dependent on your build setup if you have something to remove such things or to ignore it in the compiling process
but source viewing wise, it doesn't really matter it is just nicer to look at if methods are separated out like this
👀
If I add curse of binding to a block that's on the player's head, does the enchantment work normally? (as in does it still stop the player from removing it, or do I have to add something else to stop the player from removing the block)
some nice coding style
Quick question, is there a containsStringList in config?
or is it getStringList == null?
I'm not at my pc rn and I need it for later.
Wouldn't you just check for a key?
getStringList() never returns null right
tf is hi
its a testing thing
ah
You can check for a key. You don't need to check if it's a type
how is break unnessecary? doesnt that work in a while or smth?
.contains()
ah wait it interprets it as a break in the switch ig
how can i break out of the loop lol
label would work ig
u don't need a break on the last thing in the switch only on the things before it
well im trying to break out of the while loop, not the switch
loop: while and break loop works
Change a boolean in the while loop to true
ig ill jusst throw an exception when the buffer has no more elems
Just use a boolean called isEmpty or something
im disallowing any kind of invalid input so should be fine
calling this method with an empty buffer would mean we are in an invalid state anyways
lemme test
ppl rrl paying this much for intellij ultimate :kekw:
Imagine not realizing that's the org pricing not individual
wut
That's the org pricing
ok good
oh shat i'm dumb af
alr this is less bad but still that's alof of money for not alot of features
The db stuff is so important to me lol. I pay for intellij
Gross
im sorry
what's even the differences
I pay for the full product pack
i get it all for free for three years 
You get access to a lot of extra features like integrated db, the profiler, and others
database?
i love that db stuff
if not i have no idea what db is
Database Integration
bc when I used my trial i never saw that
The better question is what can't you do
It's a full database manager supporting almost every db out there that matters
well what can't you do
isn't it an array
without a map or array*
section(hi).getKeys(false).size()
there u go
thanks
hello to all, after several tries I still can't find the event that verifies the setting up of an item frame
what
if (homeConfig.getStringList("Homes.Players." + p.getUniqueId()).getkeys <----- error) {
its a section not a stringlist
i found this thing
Oh a section alr
can I use a higher java version for lower spigotmc-api versions
getSection(homes.players.id.hi).getKeys(false).size()
also I have no clue if this works at all
but u can try that for yourself
Cannot resolve method 'getSection' in 'FileConfiguration'
for example java 11 for the 1.13.2 spigot api.
getConfigurationSection
Thanks.
spigot does not offer it to me and puts it in error
well uh you can try paper maybe
nothing more
yeah there doesn't seem to be a way in spigot
and if ur gonna switch to paper be ready for alot of redacted things
not a lot.
well most important things with strings
like broadcastMessage
and and
other things
@sacred hamlet if you switch to paper
here's a demo of what u can try to do
sur internet je trouve "Hanging Place Event" mais l'événement ne me propose rien en événement. et ma console ne me répond pas Systeme.out.printer("ok")
what
french
uh english only
Rip sorry copy past
on the internet I find "Hanging Place Event" but the event does not offer me anything as an event. and my console does not answer me Systeme.out.printer("ok")
can I use a higher java version for lower spigotmc-api versions?
for example java 11 for the 1.13.2 spigot api.
i have no idea at all
What is your version ?
uh 1.19
but tell me ur version and I'll see if paper has smth for it
Me : spigot 1.19.2
yeah if you switch to paper the event will work
so wait there are events that don't even work in Spigot?
no paper added new events
Packagé io.papermc.paper.event.player ?
yeah as I said it's a paper event
also it has options
what u trying to do?
Idk I've never been unable to do something that a regular db manager can do
lincolm is tryna see what rotation an item frame is in spigot
do you have a link to download the io.papermc package?
uh go to papermc.io
yeah
I just want to detect when the player places it
damn I thought this meant what rotation
try using the BlockPlaceEvent
and have an if statement that detects if it's a itemframe
that should be way easier
nice
purple name
I launch my plugins but an item frame is an entity, isn't it?
yes
HangingPlaceEvent not responding in 1.19.2
you can only do event.get class and if you call your console (to check) it doesn't respond
idk bout u but it works
Non HangingPlaceEvent
i made this quick i don't need to do that bruh
how tf is intellij trash
vscode>>>
notepad>>>>>>>>>>>>>>>>>>>
Two keystrokes vs 1
Hello,
Is there a standard way of combining datapacks with plugins? I have a theory about how I can implement custom items using datapacks & resourcepacks and then keep the logic to plugins?
btw nodepad sucks
@EventHandler
public void onPosterPlace(HangingPlaceEvent e){
if(e.getEntity instanceof ItemFrame){
}
System.out.println("ok");
}
}```
Connor resolve symbol 'getEntity'
Also despite popular belief vscode does have auto complete
?basics
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.
No
or smth
Good luck 👍🏼
Do you think it will work?
he just said that wasn't and u think it's gonna work
Who knows sounds like a shitty idea bur you can do what you want
Why a bad idea?
Why even bother
you suck
Cannot résolve method 'getEntity' in 'HangingPlaceEvent'
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.
Notepad best ide
because you would have from there on 2 points to maintain
if (homeConfig.getConfigurationSection("Homes.Players." + p.getUniqueId()).getKeys(false).size() == maxhomes) {
Is seems this is just not running but I do not know why.
when you could literally either do all via a datapack OR via a plugin
not sure why you want to combine them
bruh it's getEntity() not getEntity
???
notepad++ 🙂
nah too much logic
No I cant, I want to interract with a database, thereby I have to use java, but I still want custom textures which, from what I know, you cannot do using bukkit?
you can. therefore you have the custom model data
Can you send me some links?
Yes but i my consol error is getEntity
?bing
Bing your question before asking it:
https://www.bing.com/
here the best link
if i can post a screenshot...
?verify
Get verified lol
😛
we neither
?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.
@EventHandler
public void onPosterPlace(HangingPlaceEvent e){
if(e.getEntity() instanceof ItemFrame){
}
System.out.println("ok");
}
} ```
Cannot resolve method 'getEntity' in 'HangingPlaceEvent'
i think u need a wide monitor
print the value of size()
then why is your code shrunk like that
font size 40
how tf do I shrink it
cause my phone cam sucks
or you are using unallowed software 
it seems to work for me
so I have no clud what you're doing
...
maybe it works for you but not me
maybe its bc my monitor curves
first mobile one as well
does anyone want cruchyroll premium
whats that
gift the gamepass to me 🙂
which one
the one that's a gift
gimme
6RDJY-64QDW-6JC92-XV67D-K9C4Z pc
damn
6XTJ3-RPQCW-2DMF7-D96MT-F923Z xbox
what shit is that lol
me not getting ultimate
wtf
Hello, lets say I want to make it so that strongholds wont spawn when i create and load the world, how would I be able to do that?
1KD6O9IMM9F5QSPA @tardy delta here crunchyroll premium
1KIJ1NZOZ6DD5C4Q
nah thank you
u also got the premium itz
its already enough that someone was watching anime in the train
nms prob or default minecraft settings
with the goddamn sound on
new emoji
you sound like a 40yr man
stfu
no
m&ms
who actually knows how to use nms
not me
also i have a copy of minecraft browser edition
wait just want to make sure, thats not a google site ?
no
alr
it's a site just not a google one
no shit\
Fuck
refactored 20 lines
how does it work
it runs 1.5.2 is how it works
is it open source
it was
js backend ig
smh
why don't u join my server 🙂
alr i'll dm u
also uh you gotta turn video settings all the way down
or else u get like 15 fps
What are you doing?
cool 👌
How can I check if a dropped Item from the PlayerDropItemEvent equals Dragon Egg?
check the material
love how jit optimizes the same method call from 28000µs to 163µs
Well can I check getItemDrop() against Materials?
I would recommend reading the api or reading/watching a tutorial if you are new to spigot dev
declaration: package: org.bukkit.inventory, class: ItemStack
why is it so slow
Hey sorry but I want that when a player joins my server it gives a message to everyone.... except that I want a custom message for 2 players but it does not work https://paste.md-5.net/nosebuqika.java
This seems like a bad idea to hardcode
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.
setting the join message to an empty string will actually still show an empty line to the players chat, use null to disable it
good idea thx
hi, is there a way to run a mc server from ide?
Yes, gradle can do it
mmhh is there a repo?
ok my new version is fucking up

