#help-development
1 messages · Page 88 of 1
idk how much it's in your country but putting your os on an m2 ssd is fire, should get one if you find it on sale ngl
they aren't that much more expensive than a normal ssd. Unless your board doesn't have a slot and you need a new one lol
get it when they are online?
yeah so when your mainboard supports it m2 > normal ssd 100%
what expression parser did you use?
my own
what if someone wants to ban someone if they havent even logged on the server before
or not even ban
One thing bothering me is that e.g. i remove a method in one class, all other classes are not highlighted in red showing an error because that method is now missing, any way to fix that?
just add them to some list
can get one for like 175$ in amazon, with shipping (1tb)
ye ofc. I also have 2.5tb of m2 and only half a gb of sd
ah fuck "11" gives me 2
and that has a rate limit
wat xD
oh meant to tag this one
that's nice! recently upgraded my 2tb with another 2, hope that's gonna last a while now :D
just use Bukkit.getOfflinePlayer(name) and add their uuid to something
if they havent logged on before the uuid will be incorrect
hmm now its 110 instead of 11
I didn't need the 2tb one. But I got it giga cheap due to a price error xD couldn't say no
it won’t
lololo where did u get it
now it works but wtf
so spigot calls the mojang api in the background?
yes
only when neccesary
oh
alternate
not in the background either though, on the main thread so you can really lag your server if you call it too much
is it possible to make it async
you can make it async
are you German by any chance?
"11234" became 122340 smh
yes I am
hahah nice, same
run it in a new thread/async bukkit runnable
oh k
ye idk a lot of people I meet online are german🤷♂️
just make sure to not use bukkit/spigot functions async
just io from requesting api
why not
isnt that a spigot function
you shouldn't have problem with that
For the default config?
Just do savedefaultconfig on startup
And then javaplugin.getConfig
hmm works
no im editing config
k
So like saving a value?
why are you storing something in config ?
use database for it
Like ConfigurationFile.set
its configuration for a reason
im not storing anything big
editing config from a mc command
Yea they have good points
you have no reason to run that async then
why
?
because I still need to use Bukkit.getOfflinePlayer(name)
@ornate patio just make a data file in json with gson
So you don’t have to deal with yank storage Jane
bruh why
thread blocking operations should be ran async, editing config shouldnt cause thread block
Jank
I'm just trying to change a couple values in the config automatically
don't advertise that, jsons are not made for data storage
Then what are they made for 👁👁
but Bukkit.getOfflinePlayer(name) needs to be run before it
sending data between servers
Well it works as data storage so 🤷♂️
its not scalable
^
txt also works as a storage
Maybe it’s 5 seconds slow on enable and when I save it. But it works
Tru
and it gets worse with the more data you store
Okay1204
whatever thats besides the point
I'm running it async because I need to get the uuid of an offline player
which causes the thread to block
int output = 0;
Arrays.stream(input.toCharArray()).filter((c) -> return !Character.isWhitespace(c) && c > '0' && c < '9').forEach((c) -> {
output+= (Character.getNumericValue(c) / 10);
output *= 1;
});
return output;```
@tardy delta
hehe got it to work
uhh wtf
lol
god you are gonna need a lot of unit tests
ahahaha
you can make function that is calling api async, and just use consumer to pass it to config
lets now try two operators
works too
it only doesnt know operator priority yet
thats the difficult part
yeah but whats wrong with just putting the config editing in the async task too
u makin a calculator?
yedterday i was thinking about some valuesstack and a operators stack
don't forget brackets
something like
callApi(Consumer<UUID> callback){
//calling api
callback.accept(uuid);
}
//and then
callApi(uuid -> config.save(UUID));
you can always try, if it works it works ¯_(ツ)_/¯
"3+2*3" is giving 15 instead of 9 so hmmm
but config is just yaml parser, it should work fine
k
cant u make an AI that solves operations
I already wrote a parser that can do +-*/% aswell as == >= <= || && and ^
it took me some time but now I can pretty much solve if expressions from a config file by replacing some variables and then throwing them through multiple expression parser before finally throwing it into a boolean parser
or is that impossible
3-4 hour project but it was fun. The brackets were the most annoying part. Especially since 3/((5-(3+1)+1)-1) etc. is a valid expression
i have an idea, basically loop through the whole chars
then
if u find a * or /
do the operation, then edit the input
so basically if u get 3 + 2 * 3
u make it 3 + 6
hmm what if theres no * or /
basically, simplify it
wasted time
then dont do anything
of course u will need to check if theres a * or / before looping
yesterday i was thinking about having two collections; one for the values and one for the operators
but that evolves looping twice too
and overhead
thats a pretty bad ideaa
i wrote my idea on three pieces of paper yesterday lmfao
Just do reverse polish notation - incredibly easy to implement
uhh dunno what that is
This didn't work, but the following code did. thank you tho
FileWriter fileWriter = new FileWriter(file);
fileWriter.append("i");
fileWriter.close();```
In programmers terms: The operands are put in a stack and when an opcode is encountered it is executed, where as the result is put in the stack again
mye easier to implement
but i wanted to make something that can parse readable expressions
My expression parser uses a lot of recursion lol
Even then that would be invalid due to ordering issues
like 5+(2+1)+1 will then call 2+1 recursively and lead to 5+3+1. Which will then recursively call 5+3 which leads to 8+1 and ends with that
You have to convert the more standard forumla to RPN anyways
What's the easiest way to check if a player is about to hit a cobweb - Or is already stuck in one?
Nevermind
Can I somehow add velocity to entity towards a different entity?
getNearEntities, maybe? >.<"
na na i have the entity
yes, subtract locations from each other, convert to vector, set velocity
make an example fabric mode, free decompiled minecraft soure code if you're lazy
Hello, how can I set a placeholder?
For the lobby server, I want to show players from other servers (PlaceHolderAPI)
Just wondering if anyone can help me make a loot box plugin. Loot boxes like this: https://www.youtube.com/watch?v=fcKXko-qp0k
No but you can check if it's an EntityDamageByEntityEvent
If it is, cast to it and see if the damager is an end crystal
If you have a specific question about something, you can ask it, but we're not going to go through the entire process of making a plugin
There are tons of online resources and tutorials to get started with making plugins
I didn't say u have to make it
Go find one
ur not gonna help lemme find someone else bye
Is it possible to make a castable player?
Example:
CustomPlayer player = (CustomPlayer) e.getPlayer();
I have a class that implements player, however, I get an error saying that I cannot cast to player
No
That's not how Java works
Player is an interface
CraftPlayer is the implementation
It's a different class
Casting doesn't actually change the type of the object
It can for primitives, but for objects it only lets you treat something as a type it already is, but wasn't stored as before
your code looks so clean and organized envy asf 😂
Is this for an expression evaluator?
If so, how does that do order of operations?
It doesn't seem to do it
he can
if the event is a custom event
he can do it anytime he want
or if he is firing an event with the custom player
That would be valid java syntax, yes. But would it bork other plugins? Ohhh yes.
only if the plugin uses craftbukkit
otherwise he is safe to use things within the api
If you pass that player object to any bukkit methods everything would get screwed
because the api methods uses the Player interface
Yes, and cb casts those instances to craftplayer
But internally they often represent it as CraftPlayer
?stash
(im just going to barge in here)
how can I change an Items Durability (setDurability has been deprecated and I cant find another way to change it)
Here one method that would instantly break other plugins
Unless you extends CraftPlayer - at which point fair play I guess
Granted that is the only example I can find - but they exist
I don't know what is he trying to do, but its 100% better to just use some utility class
Another one (which arguably is probably actually used): https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java#179
check if its in ItemMeta
someone said something about setDamage in ItemMeta, my IDE says its not a thing
then its probably this
declaration: package: org.bukkit.inventory.meta, interface: Damageable
cast to this and try
Bingo, this might work
Damageable dmg = (Damageable) item.getItemMeta();
dmg.setDamage(...);
item.setItemMeta(dmg);
try it
lab midi ?
?
what about midi?
for( : ){
}
i have seen people using the ":" in a for. How that works
If the thing on the right is an Iterable or Array it loops over that iterable or array
for arrays it will basically generate code similar to
for (int i = 0; i < array.length; i++) {
Element element = array[i];
// [...]
if you use
for (Element element : array) {
// [...]
For Iterables (which includes Collection, List, Set, etc.) it will go from
for (Element element : list) {
// [...]
to
Iterator<Element> it = list.iterator();
while (it.hasNext()) {
Element element = it.next();
// [...]
It's all syntactic sugar, so if you feel like not using them - you don't need to!
Although it is MUCH faster to use foreach (the name of this syntax) statements
Hello gradle nerds! How do I use
compileJava {
doFirst {
options.compilerArgs = [
"--add-exports", "org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer=de.geolykt.starloader.launcher"
]
}
}
for the javadoc task?
I'm soo close to using Method handles just resolve Mixin's JPMS bullshit
Okay, found the answer in this unclosed bug report https://github.com/java9-modularity/gradle-modules-plugin/issues/170
thanks
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onThrowEgg(PlayerInteractEvent event) {
PlayerInventory inventory = event.getPlayer().getInventory();
Player player = event.getPlayer();
player.sendMessage("test");
if (inventory.getItemInMainHand().getType() == null || !event.getPlayer().getInventory().getItemInMainHand().getType().toString().endsWith("Spawn Egg") || (event.getAction() != Action.RIGHT_CLICK_AIR) || (event.getAction() != Action.RIGHT_CLICK_BLOCK)) return;
event.getPlayer().launchProjectile(Egg.class);
}
}
i think i messed up somewhere
well i did probably
it will never be Spawn Egg
?
also this is the thinki preventing it from loading
[21:00:21 ERROR]: Could not load 'plugins/throwable-spawn-eggs-1.0-SNAPSHOT.jar' in folder 'plugins': uses the space-character (0x20) in its name
its an enum so .getType().name().endsWith("SPAWN_EGG")
ah yes i meant to check based on custom name your way is better
That too, you can;t have spaces in your plugin name (in plugin.yml)
what file can i change that in
plugin.yml
there we go thanks
I am writing a plugin (trying) to light up a given area with torches.
I am checking light levels prior to placing each torch to ensure they are only placed at or below a given light level, however... they are being placed fast enough I think, that they are only getting the pre-existing light levels, and not updating as they place.
Is there a way to force light updates before checking a block?
No simple way
is nms the only way?
if I were to slow down the placements to let the light updates happen naturally... what kind of speed would I be looking at?
No clue
yeah, same here. :\
you could always set a minimum distance
you know a torch will go X blocks
so don;t place any within that distance of another
currently, I am using that method, but, some corridors don't get lit because they fall between the min distance
You should compute the light level yourself I guess. It will be the simpler way to go
I figured this would be the answer based on everything I could find... but... was holding out for some secret call that could do it... xD
block.getState().update() is boolean, is it used to update a block and return success?
based on conversation, I'll assume that if it does an update, that it's only physics?
it will apply the BlockState back to teh Block
how can i launch a projectile with a data container
with physics, if there was a change
you mean a PDC?
use the launchProjectile method which accepts a Consumer
apply the PDC to the Entity in the Consumer
You can also add it after to the returned entity
you can, if it doesn't matter that it spawned without the PDC
what does the consumer look like
A consumer is a method that takes one argument and returns void
In this case the argument type is the entity you are spawning iirc
how can i make an egg entity
Depends on what you want to do with it
I have an interesting problem
I am making spawn eggs throwable
how can i store the data of the entity inside the pdc so that when it hits it spawns the right entity
so should i use an enum or something to store the entity
no
becuase i cant have an entity as a pdc unit i dont think
you throw the egg via the PlayerInteractEvent
its also better to use snowballs, from what I remember
public void onSpawnEgg(PlayerInteractEvent event){
ItemStack item = event.getItem();
if (item == null) return;
if (item.getType().name().contains("SPAWN_EGG")) {
Snowball snowball = event.getPlayer().launchProjectile(Snowball.class);
snowball... PDC stuff
snowball.setItem(item);
item.setAmount(item.getAmount() - 1);
}
}```
you don;t store it
then in your ProjectileHitEvent Listener you check if it has teh PDC data
the PDC contains the hatching type
using a snowball is best as you don;t risk accidentally spawning any chickens
?pdc
you just store a string
EntityType hatchingType = EntityType.valueOf(type);
to get it back
Are there any resources for ways to get the Terralith biome a player is in using a spigot plugin? (Kunfury)
This is for adding compatibility with Terralith for a fishing plugin.
It just returns "CUSTOM" they said.
That's all good, Spigot though right?
I'm not a plugin developer, but do you know of any other information I give them to help them?
one sec I'll see if I can find the post again
Thank you :D
Kudos! Thank you very much :D
Surprising we don’t have something for that yet
Even just a way to get a NamespacedKey of the custom biome
yeah teh Bukkit Namespaced keys are quite useless
This is a CUSTOM biome, that is a CUSTOM biome
Where can I find the source code of bukkit 1.12.2 ?
?stash
oh 1.12
yea
build it with BuildTools and use teh flag for javadocs/source
okay
I will try
I guess it would require a complete overhaul of the Bukkit biome system
But that sounds like it would break backwards compat
just needs a getCustomName() method to pull the NMS Registry name
True
Its about all its ever going to be used for
But I don’t think the biome enum has any way to get that
So it would have to be on Block or World
Not in CB no
@EventHandler
public void onEggHitEvent(PlayerEggThrowEvent event) {
if (event.getEgg().getPersistentDataContainer().has(EntityKey, PersistentDataType.STRING)) {
event.setHatchingType(EntityType.valueOf(event.getEgg().getPersistentDataContainer().get(EntityKey, PersistentDataType.STRING)));
}
event.getPlayer().sendMessage("Test");
event.setHatching(true);
}
any ideas the egg isn't hatching every time
what would be the best approach to making custom mobs/bosses
similar to the way hypixel does it ig
with the fake players
Fake players or armorstands
it seems like it requires a lot of nms
it is
but what's the best approach to designing things like targeting
or custom attacks
well custom attacks is easy
if you use FakePlayers you have to code all the AI
:(
couldn't i just use something else's ai?
like zombie
or steal pathfinding
i would expect someone to have made some kind of api for this stuff
does nms at least have a method to set the ai's block to pathfind to
not for fake players
how to change the entity model in spigot
you mean for the thrown Egg? setItem()
does anyone know how to get the direction a player is looking at
im trying to slowly move a particle in a certain direction
Player#getEyeLocation().getDirection()
I have used that but it does not work in my scenario
Then your code is wrong
It does not get me the intended outcome
that give you a unit Vector in teh direction the player is looking
why does it remove the spaces
Why does what remove spaces?
I am trying to do something similar to the ^ usage in commands
worlds:
- world
worlds:
- world
I only write plugins. I don;t use MC commands so no clue what ^ does
If you are saving a config, extra lines mean nothign to the config
only data and comments count
Not sure if spigot parser parse comments
it doesn;t read them but it will preserve them now
it gets the direction your looking at, not sure how to explain but it does positioning based off where you are looking, so like if you look straight up and make ~ ^5 ~ it will shoot 5 blocks behind you if that makes sense
or if you are looking straight forward, five blocks above you
can I set the direction it is going in though?
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
if (!(event.getEntity() instanceof LivingEntity) || (!(event.getEntity() instanceof Ageable))) return;
Ageable ageable = (Ageable) event.getEntity();
ageable.setAdult();
}
@EventHandler
public void onEggHitEvent(PlayerEggThrowEvent event) {
if (event.getEgg().getPersistentDataContainer().has(EntityKey, PersistentDataType.STRING)) {
String entityString = event.getEgg().getPersistentDataContainer().get(EntityKey, PersistentDataType.STRING);
entityString = (Objects.equals(entityString, "MOOSHROOM") ? entityString = "MUSHROOM_COW" : entityString);
event.setHatchingType(EntityType.valueOf(entityString));
event.setHatching(true);
event.setNumHatches((byte) 1);
}
}
@EventHandler
public void onThrowEgg(PlayerInteractEvent event) {
PlayerInventory inventory = event.getPlayer().getInventory();
if ((!event.getPlayer().getInventory().getItemInMainHand().getType().toString().endsWith("SPAWN_EGG"))) return;
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) return;
if (inventory.getItemInMainHand().getType() == null) return;
Entity entity = event.getPlayer().launchProjectile(Egg.class);
Egg egg = (Egg) entity;
egg.setItem(inventory.getItemInMainHand());
entity.getPersistentDataContainer().set(EntityKey, PersistentDataType.STRING, inventory.getItemInMainHand().getType().toString().substring(0, inventory.getItemInMainHand().getType().toString().length()-10));
}
I have my plugin working but I would like to only make entites full size or adults if they were spawned from an egg
that would magnify the Vector to a length of 5, you can then add that to a Location to move it
the direction you are looking
sorry for all the questions but im getting errors and im not sure how to solve them
Then cancel the event and spawn them yourself
p.spawnParticle(Particle.SPELL_WITCH, location.getDirection().multiply(5).add(location.getDirection()), 50); is my current code
other way around, add the vector to the location
location.add(location.getDirection().multiply(5))
they will all appear at once
yeah i know
going to try to find a work around
wait
wont they all appear in the same place
nvm
im dumb
not if you increase the location each time
yeah
to have it look like a moving particle you need to use a runTaskTimer
yeah I am not getting anything
use a simple particle to test, like redstone
nothing
going to try to use that, but how would i increase each time?
this I know works player.spawnParticle(Particle.FLAME, finalLoc, 1, 0, 0, 0, 0);
plug in yoru loc and see if it works. If not theres something else wrong with yoru code
in the for loop?
just get it to display first
what is finalLoc supposed to be
the location you calculate
what do I define it as
i just set it as my eye location
Location finalLoc = player.getLocation().add(player.getEyeLocation().getDirection().multiply(5));
player.spawnParticle(Particle.FLAME, finalLoc, 1, 0, 0, 0, 0);```
I need some help with NBT data. I'm not really sure how, but is there a way for the game to scan an item and add an CustomModelData tag to it?
for example im using a chest gui plugin so i can put in a regular pickaxe on one side of the chest and output a cooler looking pickaxe on the other side with all the same data already on it
is this possible?
?pdc
cant see the particle
to store data on a chest
thank you i love you
then your code is not getting to there, or you have particles disabled on your client
ohhhh
yeah
its not getting there because I did this
im not using the check for string thing
should i use that instead
you never start teh runnable
or schedule it
Get the meta of the item, setCustomModelData, then set the meta back
?scheduling
or just call its run() method to execute it now
i try to do run() inside this if statement if(cmd.getName().equalsIgnoreCase("shoot")) and it doesnt recognize it
its a method of the runnable
So I have to call it in there?
it depends what you are aiming for
trying to make a command run the run()
what exactly do you want this particle to do?
move forward and damage things
ok you are going to need more code then
you need a counter (lifeSpan) inside the Runnable (outside the run() method)
I can do the damage thing, i just cant figure out the particles
set to a value, of the number of times you want it to run.
you decrease teh value each loop
so a for loop?
how would i make an evoker with certain pdc spawn different mobs? the spell event doesn't provide mobs spawned, and the creaturespawnevent doesn't provide the evoker that spawned it
how do i call the loop
Particles
one sec
startup like luckperms
i've seen a ton of plugins that give server owners the option to use sqlite or mysql
is there some common library all of these plugins are using that im missing
if not what do you guys recommend i use
I’m sure there are libraries for it
Or you can just make two separate implementations of your storage handler
yeah but like
that takes effort to do
ive never even used mysql before i usually use postgres
You probably don't even need to
Likely all you'll need to do is change a few queries
is there a way to get the permissions from an OfflinePlayer object??
please tell me that's for my question lol
oh yeah
LP api is weird, it scares me with the future thingy :C
ugh
any workaround?
:c
it uses vault tho? or what?
alr, will check it up, thanks
Okay, final question for this stupid .java file
final var player = event.getPlayer().as(Player.class);
final var game = Main.getInstance().getGameOfPlayer(player);
final var typeName = item.getMaterial().platformName();
final var runningTeam = game.getTeamOfPlayer(player);
var prices = event.getInfo().getOriginal().getPrices();
if (!prices.isEmpty()) {
ArrayList<Component> lore = new ArrayList<>(item.getLore());
lore.add(
(LanguageService
.getInstance()
.get(MessageKeys.CLICK_TO_PURCHASE)
.toComponent()));
item = item.withItemLore(lore);
}
var maybeStorage = SBA.getInstance()
.getGameStorage(game);
if (maybeStorage.isPresent()) {
var gameStorage = maybeStorage.get();
final var afterUnderscore = typeName.substring(typeName.contains("_") ? typeName.indexOf("_") + 1 : 0);
switch (afterUnderscore.toLowerCase()) {
case "chestplate":
case "boots":
int protection = gameStorage.getProtectionLevel(runningTeam).orElseThrow();
item = clampOrApplyEnchants(item, protection, Enchantment.PROTECTION_ENVIRONMENTAL, type,
SBAConfig.getInstance().node("upgrades", "limit", "Protection").getInt(4));
break;
case "axe":
final int efficiency = gameStorage.getEfficiencyLevel(runningTeam).orElseThrow();
item = clampOrApplyEnchants(item, efficiency, Enchantment.DIG_SPEED, type,
SBAConfig.getInstance().node("upgrades", "limit", "Efficiency").getInt(2));
break;
case "pickaxe":
final int pickefficiency = gameStorage.getEfficiencyLevel(runningTeam).orElseThrow();
item = clampOrApplyEnchants(item, pickefficiency, Enchantment.DIG_SPEED, type,
SBAConfig.getInstance().node("upgrades", "limit", "Efficiency").getInt(2));
break;
case "stick":
int sharpness = gameStorage.getSharpnessLevel(runningTeam).orElseThrow();
item = clampOrApplyEnchants(item, sharpness + WHATDOIPUTHERE.getEnchantmentLevel(Enchantment.KNOCKBACK), Enchantment.KNOCKBACK, type,
SBAConfig.getInstance().node("upgrades", "limit", "Sharpness").getInt(1));
break;
}
}
return item;
}```
Based on the code above, what do I have to put at "WHATDOIPUTHERE" to get the enchantmentlevel of the selected item. I tried item and Item and they haven't worked
when i put "item" getEnchantmentlevel gives this error:
Cannot resolve method 'getEnchantmentLevel' in 'Item'
int maxLevel) {
if (type == StoreType.UPGRADES) {
level = level + 1;
}
if (level > maxLevel) {
item = item.withItemLore(LanguageService
.getInstance()
.get(MessageKeys.SHOP_MAX_ENCHANT)
.toComponentList());
if (item.getEnchantments() != null) {
item.getEnchantments().clear();
}
} else if (level > 0) {
item = item.withEnchantment(EnchantmentMapping.resolve(enchantment).orElseThrow().withLevel(level));
}
return item;
}```
actually
theres more of those
lemme see if I can find the original
yeah
trying to find it
hang on
this is my guess as to where the item variable comes from
var enabled = itemInfo.getFirstPropertyByName("generateLore")
.map(property -> property.getPropertyData().getBoolean())
.orElseGet(() -> Main.getConfigurator().config.getBoolean("lore.generate-automatically", true));
if (enabled) {
final var originalList = item.getLore();
final var isSharp = itemInfo.getFirstPropertyByName("sharpness").isPresent();
final var isProt = itemInfo.getFirstPropertyByName("protection").isPresent();
final var isEfficiency = itemInfo.getFirstPropertyByName("efficiency").isPresent();
final var game = Main.getInstance().getGameOfPlayer(player);
final var arena = ArenaManager
.getInstance()
.get(game.getName())
.orElseThrow();
if (isSharp) {
final var currentLevel = arena.getStorage().getSharpnessLevel(game.getTeamOfPlayer(player))
.orElseThrow() + 1;
final var limit = SBAConfig.getInstance().node("upgrades", "limit", "Sharpness").getInt(2);
if (currentLevel <= limit) {
price = String.valueOf(SBAUpgradeStoreInventory.sharpnessPrices
.get(arena.getStorage().getSharpnessLevel(game.getTeamOfPlayer(player)).orElseThrow() + 1));
}
}
if (isProt) {
final var currentLevel = arena.getStorage().getProtectionLevel(game.getTeamOfPlayer(player))
.orElseThrow() + 1;
final var limit = SBAConfig.getInstance().node("upgrades", "limit", "Protection").getInt(4);
if (currentLevel <= limit) {
price = String.valueOf(SBAUpgradeStoreInventory.protectionPrices.get(
arena.getStorage().getProtectionLevel(game.getTeamOfPlayer(player)).orElseThrow() + 1));
}
}
if (isEfficiency) {
final var currentLevel = arena.getStorage().getEfficiencyLevel(game.getTeamOfPlayer(player))
.orElseThrow() + 1;
final var limit = SBAConfig.getInstance().node("upgrades", "limit", "Efficiency").getInt(4);
if (currentLevel <= limit) {
price = String.valueOf(SBAUpgradeStoreInventory.efficiencyPrices.get(
arena.getStorage().getEfficiencyLevel(game.getTeamOfPlayer(player)).orElseThrow() + 1));
}
}
String finalPrice = price;
final var newList = itemInfo.getFirstPropertyByName("generatedLoreText")
.map(property -> property.getPropertyData().childrenList().stream()
.map(ConfigurationNode::getString))
.orElseGet(() -> Main.getConfigurator().config.getStringList("lore.text").stream())
.map(s -> s
.replaceAll("%price%", finalPrice)
.replaceAll("%resource%", type.getItemName())
.replaceAll("%amount%", Integer.toString(itemInfo.getStack().getAmount())))
.map(s -> ChatColor.translateAlternateColorCodes('&', s))
.map(AdventureHelper::toComponent)
.collect(Collectors.toCollection((Supplier<ArrayList<Component>>) ArrayList::new));
newList.addAll(originalList);
return item.withItemLore(newList);
}
return item;
}```
I have no idea 🤷♂️
I didn't make the plugin, I'm just editing it to suit my needs
😆
it works
no idea how
🤷♂️
nope
i'll keep guessing
same thing
Cannot resolve method 'getEnchantmentLevel' in 'Item'
for some reason it says its capital even though it isnt
its that line too
line 421 baby!
Hello, I've been trying to solve this for awhile now. I'm trying to register multiple enchantments but it keeps saying that the TNTSHOOTER enchanment is already registred even though it is not in the list of registred enchanments.
Code: ```public class ModEnchants {
public static final Enchantment TNTSHOOTER = new EnchantmentWrapper("tntshooter", "TNT Shooter", 1);
public static final Enchantment FORCE = new EnchantmentWrapper("vortex", "Vortex", 1);
public static void registerEnchantment(Enchantment enchantment){
System.out.println(Arrays.stream(Enchantment.values()).collect(Collectors.toList()));
boolean registered = Arrays.stream(Enchantment.values()).anyMatch(alreadyRegisterd -> alreadyRegisterd.getKey().equals(enchantment.getKey()));
if(!registered) {
try {
Field f = Enchantment.class.getDeclaredField("acceptingNew");
f.setAccessible(true);
f.set(null, true);
Enchantment.registerEnchantment(enchantment);
System.out.println("Successfully registered " + enchantment.getKey());
} catch (Exception e) {
System.out.println("No need to register " + enchantment.getKey() + " as it's already registered from before reload");
}
}
}
}```
Enchantment wrapper class:
private final String name;
private final int maxLvl;
public EnchantmentWrapper(String namespace, String name, int lvl) {
super(NamespacedKey.minecraft(namespace));
this.name = name;
this.maxLvl = lvl;
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), name, maxLvl);
}
... rest of the overrides
}```
Main plugin class:
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("Plugin started!");
ModEnchants.registerEnchantment(ModEnchants.FORCE);
ModEnchants.registerEnchantment(ModEnchants.TNTSHOOTER);
}
}```
The list of registered enchantments printed out only says that the vortex enchant is registred but the tnt enchantment is not
However it also shows that the TNTSHOOTER enchantment was already registered before the reload from the exception part of the modEnchants register method which is contradicting this^
I don't understand, I'm calling the registerEnchantment method 2 times for each enchantment on my main plugin class but I'm not sure which part you are referring to in my ModEnchants class where I am registering the enchants again
Ohhhh
Sorry I'm blind
Found it
Hang on, the name of the registerenchantment method is different from the one inside
public static final Enchantment TNTSHOOTER = new EnchantmentWrapper("tntshooter", "TNT Shooter", 1);
public static final Enchantment FORCE = new EnchantmentWrapper("force", "Force", 1);
public static void registeringEnchantments(Enchantment enchantment){
System.out.println(Arrays.stream(Enchantment.values()).collect(Collectors.toList()));
boolean registered = Arrays.stream(Enchantment.values()).anyMatch(alreadyRegisterd -> alreadyRegisterd.getKey().equals(enchantment.getKey()));
if(!registered) {
try {
Field f = Enchantment.class.getDeclaredField("acceptingNew");
f.setAccessible(true);
f.set(null, true);
Enchantment.registerEnchantment(enchantment);
System.out.println("Successfully registered " + enchantment.getKey());
} catch (Exception e) {
System.out.println("No need to register " + enchantment.getKey() + " as it's already registered from before reload");
}
}
}
}``` Perhaps this is clearer, I got confused with my own code 😅
But yea it still gives the error that the FORCE enchantment was already registered even though it is not in the list of enchantments
So from the main plugin class I’m putting the 2 public static final enchantments at the top into the parameters for the registering enchantments method which then checks if there are any conflicts or errors. However, the part that makes no sense is that the namespace id and name of the public static final enchantments are all different yet it still gives an exception error because it is already registered?
is there a method to check if block is a container?
or i need to create a list of them
Resolved
anyone know what the name of the mojmap packet for sending a toast is
none of the ones with Advancement in the name looks like the right one
If it's in the same package it won't work with the same name. But even in a different package - if you use both in one class you will have the complete path for one inside your code to specify which one you need.
In short: Technically yes but don't do it.
Instead name the Interface the name of the original class and name the class <Interfacename>Impl (if there's only one implementation rn) or just add an I in front of the classes name for your Interfaces name
gotcha thanks
so inteface is jsut the body and class implements methods it has?
just a pointer as far as java goes if a class implements my interface usually I name it SimpleInterfaceName
C# (Cringe) does an i infront of interfaces so you got shit like IThing
and then in that case you could implement IThing into Thing
Cringe sharp
c sharp more like c soft
C# more like microsoft java
Is there a way to make a placeholder in maven?
Something like {pluginServerFolder}
So I can work on my project from multiple places, where the server folder is different
and not have to go replace everything that uses the path with the current one
${plugin.basedir} i think but you must add the path after
plugin.basedir?
that is never defined
I want a custom one
which I can set myself
in maven pom
Does 0.22 affect player speed in player#setWalkSpeed or just 0.2 or 0.3
Can someon please explain why it can't find my lybrary while packaging while the code itself can...?
does anyone know what they mean with "development profile"?
because you didn't add it to your pom.xml
Do I need to do that aswell when I put the jar in??
My god.
well you did it the other way around
adding it to the pom is the only thing you need to do
NEVER EVER should you add any .jar files manually to your classpath
you simply need to add the worldedit repo and worldedit dependency to your pom.xml and that's it
Think I did it now 🙂
fair
So you would say using systempath is bad practise?
yeah
it destroys the purpose of maven
it's supposed to automatically get your dependencies
also systemPath will be removed from future maven versions
or at least systemPath inside your project root
Hi a question im using Bozar for obfuscating my plugin and it can't find org.bukkit net.md5.bungee etc i need to input the Server jar or Some spigot Api jar?
that obfuscator isnt allowed on spigotmc anyway
but yeah, you can either ignore that it cannot find that, or add spigot as library to your obfuscator
im using it on my server
i need to add Spigot jar?
I haven't used it yet but every decent obfuscator lets you add libraries to the classpath
yes that i know but i mean he needs spigot library what i need to put in there Spigot Jar or something else because he can't find org.bukkit and spigot classes
what MC version are you running?
1.8.9
then just add the spigot.jar as library in this section
ok the Server jar
yes i already done that
it must keep the original name and all the overriding names (onEnable, onLoad, onDisable, onCommand, ...)
oki
same the problem i have cannot find org.bukkit with the spigot jar with it
?paste the full log pls
you said you use 1.8.9 right?
because the classes it cannot find are 1.13+ classes
e.g. NamespacedKey
i have some dependency that are in 1.13
and works from 1.8 to 1.19.2
i need to add the 1.13 jar?
well normally, the obfuscator should just ignore the missing classes
but yeah I'd also add the 1.19.2 spigot-api.jar
the api.jar, not the normal spigot.jar
build it using buildtools
not the api jar
for 1.8 same or i need to use normal spigot?
but tbh I'd just use a better obfsucator. although I still wonder why you need to obfuscate it at all if you're not going to release it
i have some staffer that i don't trust really much
and some of them are leakers
as i found out
lol maybe get rid of those staff then 😛
owner think is only my mind
im a dev
what obfuscator i can use in case
well this obfuscator is pretty stupid and needs to have ALL classes in the classpath. so you will basically have to add all your libraries that you don't shade, as well
e.g. worldguard, worldedit, ...
(if you use those)
seems very tedious
i'd just use the demo version of allatori tbh
it has no problems with missing libraries
does sending packets (like inventory ones) need to be sync? Or async works?
there is no reason in doing it async since the server uses a queue to send them anyway
oh i don't have if u use inside intellij and maven an obfuscator but with some shit deobfuscator you can just open it
sending packets will never block your main thread anyway IIRC
Well there are quite calculations before packet gets ready 🤷
you can also always do your calculations async, then send the packet - if that fails, just schedule a new task only to send the packet
I think I should do that 🙂
Bukkit.runAsync(() -> {
int myNumber = calculateSomethingAsync();
sendPacket();
// If sendPackets() doesnt work async:
Bukkit.runSync(() -> {
sendPacket();
}
}
sth like this ^
i'd definitely just use allatori's demo, you can also integrate it into maven so you do need to use any weird GUI everytime
how?
Ye, and yes i saw you made one too 😂
I haven't implemented the order of operations yet
$290 for one license?
i got a license for 190$
but they can just use the demo version
since they don't even plan on publishing it
the demo version does the same as the licensed one, it only adds ALLATORI_DEMO to some method names, and it's not for commercial use
yeah so not usable for premium plugins?
exactly
that's all I need it for
for paid plugins you'd have to buy the single developer license for 190$
it's not on their website, you'd have to email them IIRC
i'm currently running a custom version they made for me, 8.2.1 lol
on the website there's only 8.2
in EUR it's 381,43
oh right, I forgot that they give you a discount to 190$ if you ask them too
but yeah, taxes come on top
Imma just ask if they can go down to 5 bucks
I can not see the event listener and i always have to write it my own
do you know why
i got it for 196€ including taxes
thats like -50%
reasonable price
but 380 damn
man you can have 3 weeks holiday with that money in turkey.
btw @tender shard I found your plugin on several leaking sites while searching for mine on them
idk if you're aware of that
I know
people regularly join my discord trying to verify their purchase, then leave again after 5 minutes
do you have a licensing system or smth like that?
this dude only lasted a minute
only for discord support, the plugins of course work without "licensing" since spigot rules say so >.<
Hey, I'm trying to check whether there is still text after a second ", so as to exclude the first case, which is not allowed.
Wrong: //mask "stone,dirt,sand 0"blablabla (detect the blablabla and delete it)
Wrong: //mask "stone,dirt,sand 0" blablabla
Right: //mask "stone,dirt,sand 0"
Does anyone know a quick way to do this?
My first idea was to split the string after the ", but for that I would have to somehow make it split after the second ".
probably for fun
or to get money from selling "premium accounts" on their shitty leaking website
that's sad af
help with this please
java.lang.ClassNotFoundException: com.neomechanical.neoutils.version.items.WrapperLEGACY
and this is the code getting the class
Class.forName(getClass().getPackage().getName() + ".items.Wrapper" + serverVersion).getDeclaredConstructor().newInstance();```
which is my class VersionMatcher
all the code is here https://github.com/KyTDK/NeoUtils
So my question is how do I get the class in a different maven module during runtime?
you have to shade it
your .jar probably doesn't include that class
open it with winrar / 7zip / whatever and check if the class is actually there
ah got you, how do I shade it, in my parent pom?
in your parent pom, you don't. you normally want to have a separate "distribution" module
check out how I did it: https://github.com/JEFF-Media-GbR/JeffLib
the structure is like this:
- parent
- dist
- core
- 1.19
- 1.18
- ...
the "dist" module depends on all other modules and shades them into one .jar
so yeah you wanna create a "dist" module or whatever, make it have all your other modules as dependency, then add the maven-shade-plugin to that one and then use the dist .jar file as your final plugin
man I wish there was an easy way of doing guardian rays
how do you version match like this? https://github.com/KyTDK/NeoUtils/blob/master/api/src/main/java/com/neomechanical/neoutils/version/VersionMatcher.java
https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/JeffLib.java#L262
Normally only the first Class.forName is needed. The second one is only needed if the .jar is obfuscated / relocated in a way where the JeffLib class is in another package which doesn't match the original package structure
ahh, but is my current way of doing it acceptable?
its really only for old versions that have different item names
sure
I haven't got into nms yet
run while you can
Yeah, I'm in no rush to learn about it lol
Hello, I was hoping if I could ask one last time for help with registering my custom enchantments.
I keep getting the java.lang.IllegalArgumentException: Cannot set already-set enchantment error.
?paste
don't flood the channel
Oh sorry, I didn't know about that 😅
😱
it means you aren't checking if that item already has the enchantment
Register enchantments class:
https://paste.md-5.net/pinecupeco.cs
Main plugin class:
https://paste.md-5.net/qiwutohoza.cs
Enchantment wrapper class
https://paste.md-5.net/waxegupoxu.java
you need check if x item has y enchantment, if so then return
example for you
public static final Enchantment Psychokinesis = new EnchantmentWrapper("pyschokinesis", "Pyschokinesis", 1);
// making sure it loads
public static void register() {
if (!(Arrays.stream(Enchantment.values()).toList().contains(Unsellable))) {
registerEnchantment(Unsellable);
}
if (!(Arrays.stream(Enchantment.values()).toList().contains(Psychokinesis))) {
registerEnchantment(Psychokinesis);
}
}```
sorry for the bad code and format, I wrote this a long time ago
This looks alot like how I started this
and was the beginning of hours of testing and getting the error
Yea, here it is
I could try this now though
yeah give it a go and see what happens
Are interfaces always objects?
yup unfortunately it doesn't work
so look i have an interace called MagnetGroup, which defines a configuration section, can i somehow define it as such?
first time trying the oop stuff
Is it possible to register commands dynamically instead of having to put it into the plugin.yml file?
I don’t think so, haven’t seen any at least
Ok so that is the only way?
Alright ty 👍
Here's the error
okay whats line 28?
what happened to checking if the enchantment exists?
Oh, you meant to put it inside?
Yea I did this
What enchantment are you trying to register?
You cannot register two enchantments under the same namespaced key
That results in that particular error precisely
you cant use it like that
getByKey requires the enchant to be already registered
Basically
why aren't you checking if it exists inside the register method, its more efficient and easier to maintain
Else indeterminacy is gonna happen
Ahhhh wait sorry I accidentally typed that when I moved, it was just originally enchantment
just use Enchantment.registerEnchantment(enchantment);
Yea It was like that when I got the error
May I inquire how ur implementation class looks
I didn't implement anything though, just extended the enchantment class
That is not how it should be done
First of all
you need to return name for the getName method
And you probably wanna use NamespacedKey.fromString(namespace+":"+name);
Instead of NamespacedKey.minecraft(namespace);
how do I iterate thru all files in my plugin's folder
You have getDataFolder().listFiles() or sth
Which returns a File[]
But that one sucks
Is there a version manager?
Whats that
to easily create classes for different nms versions etc
Gradle/maven
because I'm making one now and I wanted some inspiration
lol this seems too simple to work
public class Versioning {
private final Map<String, Class<?>> classMap = new HashMap<>();
private final String versioningName;
public Versioning(String versioningName) {
this.versioningName = versioningName;
}
public Versioning addClass(String classVersionIdentifier, Class<?> clazz) {
classMap.put(classVersionIdentifier, clazz);
return this;
}
public void build() {
NeoUtils.getManagers().getVersionManager().addVersioningClass(versioningName, this);
}
}```
Ye
I mean its just a builder
I don't need to be anything complicated
What else does it need?
Doesnt look like a builder
what does it look like?
gotta give it an inner class called Builder 😎
🙏
ffs ik, but it functions the same
No?
end result, I think so?
Nah
You’re just registering that instance to some manager facade class in that build method
facts
who cares about conventions, u have a goal and ur going to achieve it
one way or another
Omg, Thanks for solving a 2 day long problem with 1 word.
Nw <:
However doing this did give this error, but it's fine. Thanks!
well i reckon this.key is null
Hm
Yep
Thing is, the minecraft(name) method is a little bit reserved for minecraft’s stuff
Please refer to the meme above
Lol! Actually accurate!
daddyo this is now a builder https://paste.md-5.net/inepibegac.java
ohm,sadfs d
Almost
its not
nah
yyep build not working
Some adaptation of it
needs to return ssiz
The code is placing the schematic accordingly, but now I am trying to get it to place it block by block, does someone have experience with the WorldEdit API into being able to do this?
File file = new File("plugins/WorldEdit/schematics/"+getDisplayName);
ClipboardFormat format = ClipboardFormats.findByFile(file);
BukkitWorld world = new BukkitWorld(p.getLocation().getWorld());
System.out.println(file);
try (ClipboardReader reader = format.getReader(new FileInputStream(file))) {
Clipboard clipboard = reader.read();
try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world,
-1)) {
Operation operation = new ClipboardHolder(clipboard).createPaste(editSession)
.to(BlockVector3.at(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ())).ignoreAirBlocks(true).build();
try {
Operations.complete(operation);
editSession.flushSession();
} catch (WorldEditException ex) {
p.sendMessage(ChatColor.RED + "OOPS! Something went wrong, please contact an administrator");
ex.printStackTrace();
}
}```
KyTDK’s builder design pattern Ig
does fun stand for function
Yes
yeah
In kotlin
yeah that's what i was talking about
scala >
def method: Unit = {}```
I believe kotlin was created because both scala and java lacked some things
But ye scala is quite nice
Yeah, looks like a builder now
they call me bob the builder
they should add optional params to java
method overloading
easy to recreate but still
And null
yeah I know
what can kotlin do (on the jvm) that scala cant?
Idk I think its about compile time features
is Warren Loo is dead?
just wondering
did find an answer on it
but the guy dissapeared many years ago
from all his socials
How can you remove a Score from a scoreboard
Im randomly placing campfires ( programitacally )
But I don't want them to be on Trees
I tried nested For Loops and checking Type of Highest Block but didn't work
Any ideas?
Check if the block below the campfire is leaf
int radius = 8;
if(spawnpointLL.getBlock().getType().equals(Material.OAK_LEAVES)||spawnpointLL.getBlock().getType().equals(Material.OAK_LOG)) {
for (int x = spawnpointLL.getBlockX(); x < radius; x++) {
for (int z = spawnpointLL.getBlockZ(); z < radius; z++) {
Block highest = world.getHighestBlockAt(x, z);
System.out.println(WatchUtil.locationToString(highest.getLocation()));
if(!spawnpointLL.getBlock().getType().equals(Material.OAK_LEAVES)&&!spawnpointLL.getBlock().getType().equals(Material.OAK_LOG)) {
spawnpointLL = highest.getLocation();
break;
}
}
}
}
this is what I tried
spawnpointLL is location
you need to test the block below spawnpointLL
to actually know where the campfire will stand on
oooh
dumb me
How do people make guis what refresh? 🤨
what refresh?💀
don't use equals on material
Like you know when you have menus so if you click on something it'll update the lore with a new integer etc?
inefficient
then set the slot again wahtever
doesn't it automatically update when you change the content of a custom inventory?
No?
Not as I know of
I think it does. Has been a while since I made one
btw I think there are way more leaves than those you are checking for
should check if material ends on LEAVES or smth
doesn't work for the players inventory tho. There you have the updateInventory method
I mean, I'm trying to edit the top inv
Tag.LEAVES.isTagged(material)
It's hard to find examples of how to do it 😅
I mean you definitely have to set the item again. Like create the item again/get the old one and set it inside after you made changes
if it really doesn't work you can open the inventory again
you using a library or smth for your guis?
ye
which one?
RedLib
Never heard of sorry
it has a basic wrapper for guis and such
Personally, I'm using Triumph, easy to use and I try to just update the lore whenever possible
to not reopen the whole inventory
triumph is a cool one, my friend made it
props to him, using it in every plugin since I discovered it
bruh this is bullshit why is NONE of that deleting the file
I might look into trying to use it
are you trying to delete everything except config?
you won't regret it
correct
can't you like copy the config, delete everything and replace the config
I'm ashamed to ask for help normally I got it in my head that I know it all 😦
how do I delete everything tho
Why?
I know that sounds like a ego thing etc but that's how I legit feel.
have u tried just file.delete()
The == operator checks the type and makes a null-safe comparison of the same type of enum constants.
imagine writing .equals() every time instead of just ==
@iron glade Sorry for ping, but is any projects of yours using triumph open source at all?
I made custom Chunk Generator that only spawns Oak_Leaves
No
All g!
ah okay
do you need examples or smth?
using .equals() for enums is preffered imo
If you look at the source code for .equals(), it simply defers to ==
prove me wrong
mhm
and?
you can use both
.equals() is the standard for all java objects
lol, it legit does
just saying I don't know why I would write .equals() every time instead of just ==
making exceptions for a certain type gets dangerous
because that's the standard for java objects, as ive said
I didn't know that
since when
since java 1.0
well == is null safe so no need to reverse check
but other than that it's really up to your preference
why
java even adds Objects.equals on version 7
no sane man does a .equals on enums
for what reason?
I haven't seen anyone do .equals() on an enum either
Because it isn't necessary?
if you dont know why youre doing something, then revise
Incorrect
That's all the reason you need lol
same tbh
gonna revise waking up brb
How is it not necessary?
sometimes u gotta do it because it just works
I know about null safety etc but "not necessary" is more than enough
No
that's the definition of not learning
i bet 100$ u use snake case on class names just because it works
because equals does the same for enums and you just skip a method call lol
.equals() is the standard, you need a reason to not use it
im not a hooligan, ill take $100 plz
that's like asking "why you do 1+2 instead of 1+1+1"
it results in the same but with extra steps
why would you not use equals()