#help-development
1 messages ¡ Page 2015 of 1
well okay let me ask you, what are you going to do with the data?
Let say i will save a custom class object params into mongo
And when plugin enable load each class object data, with each mongo object data
oh okay
Understand?
so you have a data model in code which you want to represent the data from mongo?
I mean that makes things easier
Yeah
Mongo letâs you just directly serialize and deserialize POJOs
Hmn?
Please dont confuse more me
Im already really confuse
Conclure this my class object
serialize:
Taking your "class object data", transforming it into json
deserialize:
taking the json, transforming it into "class object data"
How would one have language options for their plugin? would an enum be the proper way of doing it with the selection for languages being in the config?
ResourceBundles is probably the best way
lombđ¤˘k
I'll look into it
Me?
no to Shreb
whats node?
Node is another object class
yay or nay
exposing a list grr
wat
Im saivng to mongo:
List<Rank> ranks = new ArrayList<>();
void save() {
this.ranks.foreach(rank -> Mongo#update("ranks", new Document().append("name", rank.getName()).append("nodes", rank.getNodes())));
}
But i dont know how read each object from mongo
may I ask what library you use
Mongo driver?
alright
So what i can do?
Im too much confused
I dont wanna skidd from a plugin the mongo part
I will prob search on github mongo examples
Yeah i know
then just ::find (which gives you a cursor)
I jsut send in that way to short the code
I already done, i just dont know how to loop through each document object
MongoDatabase#getCollection("ranks")#find();
And there i mstuck
okay so I looked it up, havent done mongo in some time
Allright no problem
but supposedly you should iterate over find
Hmn
so like
is 1.18.2 the same 1_18_R1 nms or not?
hey
public class HealMe implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
Player p = (Player)commandSender;
if(p.getHealth() <= 0.5F) {
if(command.getName().equalsIgnoreCase("healme")){
Bukkit.dispatchCommand(p, "givemoney hastane 2000");
Location hastane = new Location(p.getWorld(), 192, 4, 799);
p.teleport(hastane);
p.setHealth(20F);
p.setWalkSpeed(0.2F);
p.sendTitle("Iyilestin", "Durumun Iyi");
}
}
return true;
}
}```
good heal command
im trying to make if
i can control the situation player does not have money
try (MongoCursor<Document> cursor = find(new Document()).iterator()) {
while (cursor.hasNext()) {
Document document = cursor.next();
}
}
```@sterile token
maybe
Bukkit.dispatchCommand(p, "givemoney hastane 2000"); i want to control if player has 2000$ dollars
how can i
im using The New Economy
by using the api of the economy plugin
Hello, i'm trying to disable craft with custom items but it doesn't work, can someone explain me why ?
@EventHandler
public void craftItem(CraftItemEvent event) {
System.out.println("Testing craft item event");
CraftingInventory inv = event.getInventory();
for(ItemStack stack : inv.getStorageContents()) {
System.out.println(stack.getItemMeta().getDisplayName());
if(CustomPaper.contains(stack)) {
event.setCancelled(true);
}
}
}```
Does it print
Did you register the listener
Yup
just here
getServer().getPluginManager().registerEvents(new CraftSecure(), this);```
How would I make a falling chest spawn randomly in the sky near me
Is it possible to make any Item edible? In my case diamonds
wait, by on the server, do you mean on every server where the message is being received or just on the bungee server
On the server you want to receive
alright ty
So if you wanna receive messages on Lobby at least one player should be online
I am making a plugin that applies potion effects to players who are wearing armor, is it more efficient (server resources efficient, not time efficient) to check the armor of every player on the server every X amount of time or to use Listeners on all relevant events and check if the player has equipped the armor?
listeners
For checking player related things use listeners
Because they will be called once the player do something
And no everytime
how do I prevent ClassNotFoundException from happening between maven modules when dependencies look correct and I have the shade plugin included?
Can I set custom colors as a bossbar color (such as gold) in the createBossBar method, if so how?
Double check your shade configuration
In last version you can use custom color by it hex id
I think I'm just confused on how shade works, I'll look into that more
Send your pom in ?paste
Why doesnt work lmao
In this case, I would have to put listeners on InventoryClickEvent, PlayerInteractEvent, and DispenserArmorEvent wouldn't this result in me running code more often than just running a check on all players every 5-15 seconds?
I was looking up how to do versioned plugins and many people suggested to follow the example of AnvilGUI, and it has worked up until actually running the server in which case the exception happens
how would i call a method that removes an user after some time?
scheduleUserRemoval?
He?
Is it possible to make any Item consumable? In my case diamonds
yes, if you dont want it to make the eating animation its actually really easy
you just have to check the PlayerInteractEvent for the item, in your case a diamond, then upon right click or whatever you reduce the amount in the ItemStack by one.
after some time?
I don't think you can detect a player holding down a mouse button sadly
Thanks helps me a lot
np
you can enhance this by only making special diamonds consumable or things like that by checking the PDC for a special key or something you set at another time.
?pdc
public BigDecimal getHoldings(String identifier, String world) {
return TNE.manager().getAccount(IDFinder.getID(identifier)).getHoldings(WorldFinder.getWorldName(world, WorldVariant.BALANCE));
}``` i dont know how to really use this
hey im having trouble preserving comments in my file, how do i keep them when i set values
it keeps the first comment but not the rest
What version are you on?
This looks cringe
lore.forEach(s -> {
var ref = new Object() {
String toAdd = s;
};
String[] strings = s.split(" ");
Arrays.stream(strings).forEach(s1 -> {
if (s1.startsWith("%") && s1.endsWith("%")) {
s1 = s1.replace("%", "");
int number = Integer.parseInt(s1.replaceAll("[A-z]", ""));
Pet pet = pets.get(number - 1);
switch (s1.substring(1)) {
case "_player_name" -> ref.toAdd = ref.toAdd.replace("%" + number + "_player_name%", OpUtils.getNameFromUUID(pet.getOwnerUUID()));
case "_player_object" -> {
switch (leaderboard.getType()) {
case TOP_LEVEL -> ref.toAdd = ref.toAdd.replace("%" + number + "_player_object%", String.valueOf(pet.getLevel()));
case TOP_PRESTIGE -> ref.toAdd = ref.toAdd.replace("%" + number + "_player_object%", new PrestigeManager().getFilledPrestige(pet.getPrestige()));
case TOP_EXPERIENCE -> ref.toAdd = ref.toAdd.replace("%" + number + "_player_object%", String.valueOf(pet.getPetExperience()));
default -> throw new IllegalStateException("Unexpected value: " + leaderboard.getType());
}
}
default -> throw new IllegalStateException("Unexpected value: " + s1);
}
}
});
list.add(FormatUtils.formatMessage(ref.toAdd));
});
Any way to clear it up?
1.8
Ah
what the fuck is bigdecimal
Spigot doesnât support comments on 1.8
wait what
What
comments are based on spigot?
What
I'm trying to increase a players potioneffect but it stops when i run this line:
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 999999, player.getPotionEffect(PotionEffectType.REGENERATION).getAmplifier() + 1));
Am i doing something wrong?
With my custom file handler you can keep your commented messages - https://paste.md-5.net/ecedisedux.java
usage?
That looks to only be for copying the file out of the jar
Which should preserve comments anyway
holy shit
yeah no i can copy my values out, but when i set the values in that config they disaapear
I use it in PlayerInteractEvent. broadcastmessage before this line works the one after it doesn't get excecuted
Youâll have to search for a third party library
Yeah... update to 1.18 or create your own thing to add comments
why is ref.toAdd, why not just use s
using my merger
since you can't use lambda variable without declaring it final or doing like this
i probably could just do a final temp s
which could look better-
what is the best event to use to get the item in the main hand?
all of them,
anything that involves a player
lore.forEach(lambdaString -> {
final String[] finalString = new String[1];
String[] strings = lambdaString.split(" ");
Arrays.stream(strings).forEach(eachString -> {
if (!eachString.startsWith("%") && !eachString.endsWith("%")) {
return;
}
String replaced = eachString.replace("%", "");
int number = Integer.parseInt(eachString.replaceAll("[A-z]", "")) - 1;
Pet pet = pets.get(number);
switch (replaced.substring(2)) {
case "player_name" -> finalString[0] = finalString[0].replace("%" + number + "_player_name%", OpUtils.getNameFromUUID(pet.getOwnerUUID()));
case "player_object" -> {
switch (leaderboard.getType()) {
case TOP_LEVEL -> finalString[0] = getObject(finalString[0], number, String.valueOf(pet.getLevel()));
case TOP_PRESTIGE -> finalString[0] = getObject(finalString[0], number, new PrestigeManager().getFilledPrestige(pet.getPrestige()));
case TOP_EXPERIENCE -> finalString[0] = getObject(finalString[0], number, String.valueOf(pet.getPetExperience()));
default -> throw new IllegalStateException("Unexpected value: " + leaderboard.getType());
}
}
default -> throw new IllegalStateException("Unexpected value: " + replaced);
}
});
list.add(FormatUtils.formatMessage(finalString[0]));
});
@grim ice better?
AllOfThemEvent?
basically
Correct đ
ok thanks
you can always get a players equipment, which includes the main hand item
ye
How can i check if a player has an effect? My current try was (player.getPotionEffect(PotionEffectType.REGENERATION) != null)
Anyone have connected to Mongo atlas cloud, throw the mongo-driver-java because its telling me that the host is invalid
hi, i tried using the mojang mappings and my server keeps telling me java.lang.ClassNotFoundException for every import, any fix?
let me check
did not work should i use
ItemINeedEvent?
Check the 1.17/1.18 release posts for details
yes yes
?
Patient...
public void CompassClick(PlayerInteractEvent e){
Player p = e.getPlayer();
if (p.getInventory().getItemInMainHand().getType().equals(Material.COMPASS)){
p.sendMessage("hi");
}
}
its not saying hi
this should be the appropriate method
ok
How can I crewte a custom event? That can be listened and cancelled
By googling and selecting the first thing that shows up
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Its giving the ip address of the database, but them its saying its not valid
Its so amazing
hahaha
Let me get one of my handy links for you
I told you to check the 1.18 release post for info on how to remap
how to access uuid.toString
How would I make player data, which has economy in it ands saves?
I dont wanna use fault or anything to do that, cant find any tutorials on how to do it
Ty! That seems easy
Without vault or any of that]
Ty
You want your custom economy plugin?
First comment
I wanna crate a custom economy plugin correct
Just a value that players have
To view money
Creating player specific config files would seem the best imo
Any tutorials?
Or a hash map
Use a database. 
Agree
I have 0 idea how to use MySQL
And if dont use database is shity, because you cannot use it in cross server
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The best time to learn was yesterday. The second-best time is now
https://github.com/frostalf/ServerTutorial/blob/master/ServerTutorial/src/main/java/pw/hwk/tutorial/api/events/CreateTutorialEvent.java
https://github.com/frostalf/ServerTutorial/blob/master/ServerTutorial/src/main/java/pw/hwk/tutorial/conversation/CreateTutorial.java#L223-L225
Oh
Frost do you have experience with mongo driver?
First link is the custom event, the second one is how to use it
its not all that difficult đ
Because im so retarded that driver its telling me that the host is invalid. when the address is the same that provide me Mongo atlas cloud
đĄ
Ty very much
What do i need to put in the .contains()?
I don't really use mongo, but I am sure its probably no different then using SQL to set the host?
Yeah, the problem is that altlas cloud giveme an ip, that doesnt work or idk.
Can some1 tell me why the progress of the bossbar stays empty while setting it with setProgress(intWithMax100 / 100)
Because mongo driver thrown HostNotFoundExceotion
whatever you want to check for
So either im dumb or host is dumb
is the host suppose to contain a string or does the host object accept an ipaddress object?
also quite possible you need to specify the port too
mongodb://<username>:<password>@mongodb.aa6vu.mongodb.net:27017/database/?retryWrites=true&w=majority
is there any way with prepareitemcraftevent to chjeck if event.getrecipe is a vanilla recipe
Im really annoyyed
?jd
Find the event and read the methods it has. And you will find what you want
that domain isn't valid
theres nothing to compare it to a vanilla recipe on the docs
Cast the recipe to keyed and get the key
The key will be âminecraft:xyzâ for vanilla stuff
that helps tysm
Hmn
Idk that domain is what its giving me the atlas cloud
public void CompassClick(PlayerInteractEvent e){
Player p = e.getPlayer();
if (p.getItemInUse().equals(Material.COMPASS)){
p.sendMessage("hi");
}
}
ava.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.equals(Object)" because the return value of "org.bukkit.entity.Player.getItemInUse()" is null
doesn't mean it is correct
yea but im holding a compass
add not null check
Oh lmao im really stressed i wanna to finish this. Idk when you are already done all things are fucked complicated
That its what attlas say me
the domain is valid I looked it up in the sense that someone does own the domain, however in DNS it doesn't have any records to point anywhere as I get no host found.
What i can do?
setup your own mongodb?
Guys I am stuck: I want to create an algorythm pushing forward a string value in a stringlist
marge: a, list: [test1, test2, test3] should become list: [atest, 1tes, t2te, st3]
I wanna use atlas for test
then contact them and tell them
I can't do anything about a provider's service if they are down
Could I get your opinions?
I'm enabling players to set traps where if players walk over these traps, they are stuck in place for 5 seconds (I'll just set their walk speed to 0 for 5 seconds). To detect when these traps are used, I'm thinking of having it set a pressure plate server-side, then send packets to players to make it look like there's nothing there and listen for RedstoneBlockEvent or whatever you call it and make sure the source is a pressure plate then make sure the location matches and if so, find the nearest player (nearbyEntities of 1 or 2 radius?) or the other two alternatives are to make a runnable that runs every 0.5 seconds or so that listens for all trap locations for entities within the radius of 1 or 2 (whatever triggers it), or using PlayerMoveEvent
Which do you think would be most efficient out of those 3 methods?
Player p = e.getPlayer();
if (e.getItem().getType().equals(Material.COMPASS)){
p.sendMessage("Hi");
}else if(e.getItem() == null){
return;
}
still getting the error when not item in hand
ibruh
Have you read the jaavdocs?
If e.getItem() is null then using getType() on it will give you a NPE
ur doing that check before the second one
your if check is backwards
lmao
java doesnt read line 2 before line 1 lol
Or just
if(e.getItem() != null && e.getItem().getType().equals(Material.COMPASS()){} xD
Anyway any of you know?
if you don't want anything displayed, why even bother with a fake item to begin with?
you could just skip that and go based on location
I mean server-side pressureplate, client side nothing therefore it triggers the redstone event
you wont need that pressure plate if nobody is supposed to see it
you can activate redstone without the pressure plate
he means he wanna use the event when someone steps on the plate
not to activate something
setting the power on the block should do the same
but, I mean you could remove all that if its location based anyways
once the location matches where a trap is recorded to be, then do something
don't need the redstone even to do that
also don't need fake items
so doing all those things just adds unnecessary steps and complexity
if you want them to hear a sound, you can send a sound to the client to play based on the location as well
Let's say there's 50+ players online and there's 5 traps set somewhere in some game where the game has 16 or so people and the traps only apply to 9 of them as a scenario, I could use a runnable and check for nearby entities for those traps that meet the criteria, or I could use a player move listener that checks if they're in the same world then compares location distance as well as checking the criteria to make sure it applies to them, alternatively there's the redstone event I mentioned.
if the traps are in a specific world, then make a list of the players that could only be possible
to get back to the topic: i would probably go location based with a timer. PlayerMoveEvent is too frequently called for just location-checking/player and spamming the players with packets seems exaggerated and redundant
then in the move listener, if they are not those players in that world ignore them anyways
you don't need the redstone event for this, playermoveevent is sufficient
I got shade mostly working, and the log says that's including the other jars into the shaded jar, but when I open the jar file it only has the resource folder and pom đ
I guess, I'd need to do it every time they render the chunk anyway so just listening every half a second or so is probably most efficient
Just because the playermoveevent is called frequently doesn't mean you shouldn't use it or that it is inefficient
aka checking if they're in the same world or not, the event will still trigger whether they're in the world player list or not xD
I would opt for how regions are grouped in worldguard.
Create chunk buckets and BoundingBoxes. Then the PlayerMoveEvent will have only a tiny overhead even with a ton of players online.
hi am back, does anyone have a good tutorial on multiple config files? preferably ones that explains the code and what each line does
you can return from your event if the player isn't valid
in this case there is a better option which should be preferred. why would you spam your checks for x players * 3 traps if you could just loop over those 3 traps every 0.5 secs?
Not a bad idea, but I likely won't be using worldguard
No one said you had to
So basically like this but instead of having an IntSet you have a List<BoundingBox>
So you only check the chunk the player is currently in. Then its still O(n) for all boxes mapped to this chunk but
extremely fast on the global scale
because checking numbers isn't inefficient if you setup the checks right. First check is if the player is valid, not hard to setup the list of players valid for a given world, second you just check if the player that moved, is in the same location as a trap. Not hard to setup a map where the key is the location. How many times it runs isn't going to make a difference until it actually does something.
this is actually pretty good
And if you want to really squeeze out every last bit of performance you wouldnt use the PlayerMoveEvent but
use an evenly distributed runnable where every player gets checked every 20 ticks. So not all players at once
but each individual player has a delta of 20 ticks between each check
So instead of 100 players every 20 ticks you check 5 player every tick
you could do this, still don't think you need to go to this extreme though. Especially if you only need to care about a single world for this XD
yeah that was a cool thing to learn
Either way, you don't need to get super complex with this. Keeping it simple is the better way to go lol. 7smile7's way isn't super complex even for the distributed runnable
Yeah probably overkill. The method mentioned above had < 0.1% tick time on the PlayerMoveEvent with 70 concurrent players online and several hundred boxes on a world.
If there's multiple games running at once, it's not just a single world lol, anyway I'm just going to check every 0.5 seconds or so, maybe more/less frequently pending testing as well as once a trap is activated, check if any remain and if not, stop checking, continues when at least 1 other trap is placed down
there is many ways to optimize stuff
there is always a way to optimize stuff
maybe thats what u mean
however, most of the time you don't need the extreme optimizations unless you hit that point that is all you have left to do to improve performance on your server
that is, most people don't have large enough servers to warrant such extremes
can anyone link me to a resource for editing players names in tablist? all im finding is forum posts of broken code
do u wanna prefix it or change it
if (!(sender instanceof Player)){
sender.sendMessage("Only players can use this command");
return true;
}
if (command.getName().equalsIgnoreCase("ci")){
SelectionScreen gui = new SelectionScreen();
p.openInventory(gui.getInventory());
p.sendMessage(ChatColor.AQUA + "please make a selection");
}
should the bottom if statment be in the top else statment?
Yes 99% of servers shouldnt need to optimize much. People sometimes underestimate how powerful modern
CPUs are. As long as you prevent crucial mistakes like IO on the main thread you should be fine.
change it. prefixes, different name colors based on ranks, suffixes
ok the shade thing is working now, it wasn't including the jars, but I set the Google JSON dependency scope to provided, and now it's working. I got the correct structure from here: https://stackoverflow.com/questions/21021485/how-to-configure-maven-shade-plugin-in-a-multi-module-project
u prob shouldnt make ur code based on modern ultra fast nasa 999999999$ cpus tho
yeah use setplayerlistname
Note that this name will not be displayed in game, only in chat and places defined by plugins.
you probably could make that bottom if, and else statement of the top
I sent two
3*
so
if (!(sender instanceof Player)){
sender.sendMessage("Only players can use this command");
return true;
}else
(command.getName().equalsIgnoreCase("ci")){
SelectionScreen gui = new SelectionScreen();
p.openInventory(gui.getInventory());
p.sendMessage(ChatColor.AQUA + "please make a selection");
}
like this?
tbf im happy i can be in coding servers, since without them my ego would skyrocket
since in my country i'm basically a genius
having a source to lower ur ego is pretty useful
being in a country that isnt 3rd world and is outside of africa is way more useful tho
oops this should be in general
if (command.getName().equalsIgnoreCase("ci")){
SelectionScreen gui = new SelectionScreen();
p.openInventory(gui.getInventory());
p.sendMessage(ChatColor.AQUA + "please make a selection");
}
return true;
}
why do i need to do getcommand.get name?
wont the main class do that?
String pString = "players." + p.getUniqueId().toString();
FileConfiguration conf = EmeraldsPlugin.data.getConfig();
if(!conf.contains(pString)){
conf.set(pString + ".balance", 0);
EmeraldsPlugin.data.saveConfig();
}
int bal = conf.getInt(pString + ".balance");
p.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "Your Balance: " + ChatColor.RESET + ChatColor.GREEN + bal + " Coins");
Why when I run my command, it just says /balance and nothing else?
Is my code here wrong?
static abuser!
package me.emerald.emeraldsplugin.data;
import me.emerald.emeraldsplugin.EmeraldsPlugin;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.logging.Level;
public class UserData {
private EmeraldsPlugin plugin;
private FileConfiguration dataConfig = null;
private File configFile = null;
public UserData(EmeraldsPlugin plugin){
this.plugin = plugin;
saveDefaultConfig();
}
public void reloadConfig(){
if(this.configFile == null)
this.configFile = new File(this.plugin.getDataFolder(), "data.yml");
this.dataConfig = YamlConfiguration.loadConfiguration(this.configFile);
InputStream defaultStream = this.plugin.getResource("data.yml");
if(defaultStream != null){
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream));
this.dataConfig.setDefaults(defaultConfig);
}
}
public FileConfiguration getConfig() {
if(this.dataConfig == null)
reloadConfig();
return this.dataConfig;
}
public void saveConfig(){
if(this.dataConfig == null || this.configFile == null)
return;
try {
this.getConfig().save(this.configFile);
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Could not save config to " + this.configFile, e);
}
}
public void saveDefaultConfig() {
if(this.configFile == null)
this.configFile = new File(this.plugin.getDataFolder(), "data.yml");
if(!this.configFile.exists()){
this.plugin.saveResource("data.yml", false);
}
}
}
Conf code
its a nice function dont even
java isnt a scripting langauge lol
well not a function
forgor
yeah static is rly cool but ur abusing it
thats not how to use it
in this script i havent used static lol
*in this code
DAMN
no statics are used
script
dont abuse it
FileConfiguration conf = EmeraldsPlugin.data.getConfig();
but anyways, is something wrong?
so?
ok
data = new UserData(this);
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
is ur emerald plugin ur main
yep
wh why
Canât make an instance of your main class
IllegalArgumentException: Plugin Already Initialized!
t he only one allowed to make an instance of ur main is bukkit
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
and ?learnjava
don't do return and else statement
pls
You killed the bot
and never do public static
I find the cause it was because i was using"mongodb://", instead of "mongo+srv://"
I get tired of told him that
not even u learnt java when they told u to tho so ig
(i assumed)
java.lang.IllegalArgumentException: The embedded resource 'data.yml' cannot be found in plugins/EmeraldsPlugin-1.0.0.jar
found the error
Its literally said the error
Please learn java
Its really annoying to be all time asking and asking
i had to scroll thru console
If you atleast know java you wont be asking for that type of error
what did I generate the file incorrectly?
this.configFile = new File(this.plugin.getDataFolder(), "data.yml");
That literally say what happening
You got data.yml in resource folder /generated right?
it for some reason didnt generate no
maybe im missing smth
PlayerBucketEmptyEvent
Because its not placing a Block. This can be detected with other events.
Well then update to a supported version
you need to call the create file method
all you are doing with that is creating a new File() object
not necessarily creating the file itself
It should though
PlayerInteractEvent
Search in old forum posts. You might find something. But 1.8 is an ancient version and support
was dropped years ago. Just update. Only a minority still plays that version anyways.
Ahhh there are always people who just need to support 1.8 if the server supports the old combat I don't mind. And it's not like the old combat is objectively better anyways ahaha
Yeah I was pretty sure about that
So I'm using luckperms as my permissions plugin, and I want to check that a player isn't assigned to any group. When looking at the luckperms developer api, it looks like they just use the player.hasPermission("group.<group>") to find someone's group. how can i do the opposite, and see if a player isn't in any group?
.isEmpty for what?
the list of groups lol
User user = luckPerms.getUserManager().loadUser(who);
Collection<Group> inheritedGroups = user.getInheritedGroups(user.getQueryOptions()).isEmpty()
or something
idkj Im just copy pasting the wiki
Hello !
I have a little question java side:
The methiod Bukkit#getOnlinePlayers return a "Collection<? extends Player>"
How can a class (?) extends Player even tho Player is an interface, and not an object ?
To me, it should be "Collection<? implements Player>" but it's not x)
I dont think implements is a java keyword in that context
extends means the same thing
^
I literally went through a library today and found this gem:
love it
Lol
moss is dead, can somebody please help me figure out gradle? i just need to know how to import local dependency
RIP Moss, he was a good one
official support discord for a lot of plugins lol including essx and grifprevention
essx switched to fudging gradle and now i can't build it
and i really need to because i run a custom one
Where would I put this?
Why is moss dead
no devs in their support channel

what issue with gradle are you having specifically
Probably just another person that declares a channel dead after 10 seconds of being there
In Java Naming Conventions
is mavenLocal() a repo
đ
Ur class name lol
if so should just be able to add it like a maven depend/
several at this point, but the one i haven't figured out yet is how to import a local dependency, eg. a local .jar file
otherwise idk, gradle sucks
thank you i'm glad somebody of your stature agrees
that is actually easy
like a maven system depend?
Conclure comin in hot
In principle that method there means
that a Collection<CraftPlayer> or any other class/type that extends Player can be used when returning a collection instance in the method.
in maven sure, gradle idk... pls tell me how
compileOnly files("dep.jar")
do i stick that in dependencies section?
in maven it is very hard to do it correctly
nope:
Build file 'C:\Users\Leo\Desktop\Plugin Edits\3. Currents Edited\Essentials-2.x\build.gradle' line: 17
* What went wrong:
A problem occurred evaluating root project 'EssentialsXParent'.
> Could not find method compileOnly() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.```
Which is why I always use gradle if I have to depend on local jars
Chat goin hot
groovy or kotlin?
Nvm, it's groovy
it's essentialsx project clones from github, afaik just java
Yeah, I understand that
But my question was about the "extends" because a class cannot extends an interface, it implements an interface
maven install:file đ
that complicates it by a bit for the average developer
No the gradle file
An interface can
Then show me your dependency block
Is it .gradle.kts or just .gradle
it's build.gradle
compileOnly files('./PlayerTracking.jar')
}```
And you can pass in an implementation of that interface
Oh I think I have heard about this issue
Anyways there is no ? implements so we usin ? extends
Thatâs the groovy version
please tell me there's a way to import a jar file
it does, it's in the same folder as build.gradle, same folder i'm running the gradle command from
god damn it essentialsx
so i managed to make my custom config file with a tutorial, and now i have another question: how can i use this custom config file for my "bot"? i wanna make it so i can just input an input and an output + custom expressions, for example:
input:
[can you say] "%message%" [for] %player%
output: send message %message% for %player%
even the case is correct and everything?
repositories {
flatDir {
dir '.'
}
}
dependencies {
compileOnly name: 'File.jar'
}```
This is the way I used to do it (groovy dsl)
i copypasted the file name since i was paranoid
aye lemme try this syntax
What happens if you remove the ./?
Try implementation instead of compileOnly
I know that this works as I used it in one of my projects: https://github.com/Starloader-project/Starloader-API/blob/master/build.gradle#L37
no dont
now it changed to this error instead:
A problem occurred evaluating root project 'EssentialsXParent'.
> Build was configured to prefer settings repositories over project repositories but repository 'flatDir' was added by build file 'build.gradle'```
isn't implementation removed?
implementation assumes runtime classpath dependence
Show us your entire build.gradle
which is probably not what you want
id("essentials.parent-build-logic")
}
group = "net.essentialsx"
version = "2.19.4-SNAPSHOT"
project.ext {
GIT_COMMIT = !indraGit.isPresent() ? "unknown" : indraGit.commit().abbreviate(7).name()
GIT_DEPTH = GitUtil.commitsSinceLastTag(project)
GIT_BRANCH = GitUtil.headBranchName(project)
FULL_VERSION = "${version}".replace("-SNAPSHOT", "-dev+${GIT_DEPTH}-${GIT_COMMIT}")
}
repositories {
flatDir {
dir '.'
}
}
dependencies {
compileOnly name: 'PlayerTracking.jar'
}```
what is the settings.gradle file?
wait how is the project setup?
you might wanna add the repo and dep to your subprojects rather
essentialsx source from github, i only modified a couple .java files and build.gradle
how come?
can you link?
it's just a jar file, there's no project for it except for eclipse project file
Yeah
this is unorthodox
You need to edit this file: https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/build.gradle
both groovy and kotlin dsl
đś đŤ
AH let's try this one
It is basically the root maven pom
In maven speak
It however depends on what you are actually trying to do
that's where i had it in the maven version of this lol the root one
yeah adding the flatfile jar to the subproject is much more reasonable
Wouldnât want to exclude
A problem occurred evaluating project ':EssentialsX'.
> Build was configured to prefer settings repositories over project repositories but repository 'flatDir' was added by build file 'Essentials\build.gradle'```
what the hell
Use my approach
for fuck's sake is there something like a gradle2maven converter somewhere
For conclure's approach you'd need to edit https://github.com/EssentialsX/Essentials/blob/2.x/settings.gradle.kts
Partially that is
^
i did, i added the dependency and the flatdir to Essentials/build.gradle
yeah
wait what do i put in the blob
flatDir {
dir(".")
}
(settings.gradle.kts)
anyone?
there's not even a blob folder there
Just add the compileOnly files("file.jar") in Essentials/build.gradle
without anything else
That should work
public void updatePlayerTablist(Player player) {
UUID uuid = player.getUniqueId();
PlayerData data = Main.getPlayerControl().getInstance(uuid);
User user = Main.luckPerms.getPlayerAdapter(Player.class).getUser(player);
String name = !user.getInheritedGroups(user.getQueryOptions()).isEmpty() ? utility.f("&f" + player.getName()) : utility.f("&7" + player.getName());
String prefix = Main.luckPerms.getUserManager().getUser(uuid).getCachedData().getMetaData().getPrefix();
String guild = !data.guild.equals("") ? utility.f("&8[&7" + data.guild + "&8]") : utility.f("&7");
String bounty = data.bounty != 0 ? utility.f("&6&l$" + data.bounty) : utility.f("&7");
player.setPlayerListName(prefix + name + " " + guild + " " + bounty);
}```
that file doesnt exist; there's no such thing as a blob folder or file in this file structure
you can't have components in tab, also ew plexpvp
youch
how do i respond to a command in the console?
Can we detect if an inventory is not a default inventory in spigot ? (so an inventory created on the client side with packets or else)
that is because the blob folder does not exist
how do i color stuff in tab then
§
so how do i edit a file in it?
just do my compileOnly files("file.jar") approach
Or edit the root settings.gradle.kts
try ChatColor.translateAlternateColorCodes
A problem occurred evaluating root project 'EssentialsXParent'.
> Could not find method compileOnly() for arguments [{name=PlayerTracking.jar}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.```
k then
is that in the dependencies block?
how do this - someone help pls
ok i still had the flat thing on it lol, i removed it and it seemed to make some progress, but it failed again with this:
Execution failed for task ':EssentialsX:compileJava'.
> Could not resolve all files for configuration ':EssentialsX:compileClasspath'.
> Could not find :./PlayerTracking.jar:.
Required by:
project :EssentialsX```
Remove .jar
how to i respond to the console?
and yes it's in dependencies block
try ../PlayerTracking.jar
Execution failed for task ':EssentialsX:compileJava'.
> Could not resolve all files for configuration ':EssentialsX:compileClasspath'.
> Could not find :./PlayerTracking:.
Required by:
project :EssentialsX```
oh my god
Execution failed for task ':EssentialsX:compileJava'.
> Could not resolve all files for configuration ':EssentialsX:compileClasspath'.
> Could not find :C:/Users/Leo/Desktop/Plugin Edits/3. Currents Edited/Essentials-2.x/PlayerTracking.jar:.
Required by:
project :EssentialsX
not even full fucking path works
what the fuck
why can't it find it
it's literally right there
Windows moment
yes
gahh why can't i post images
god damn it
are you using the chat component api
Gotta verify
PLEASE DONT GO ANYWHERE GUYS i have to upload this to imgur real quick
please stay
Lol
at that point you can use adventure
no
I and geol will be here, like I also wanna know how to do this and why it doesnât work lol
"clickEvent=null"
It is probably EssX own build logic that interferres here
grrrrrrrrr
You could edit https://github.com/EssentialsX/Essentials/blob/2.x/build-logic/src/main/kotlin/essentials.base-conventions.gradle.kts I guess, but that is kotlin gradle
this is what i hate about both maven and gradle they're both too fucking complicated
flatDir{
dir(rootProject.dir)
}
perhaps?
ughhh where? the root one or essentials?
the repository would need to be declared in the settings.gradle.kts file
around line 3
this good?
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://jitpack.io") {
content { includeGroup("com.github.milkbowl") }
}
maven("https://repo.codemc.org/repository/maven-public") {
content { includeGroup("org.bstats") }
}
maven("https://m2.dv8tion.net/releases/") {
content { includeGroup("net.dv8tion") }
}
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") {
content { includeGroup("me.clip") }
}
maven("https://libraries.minecraft.net/") {
content { includeGroup("com.mojang") }
}
mavenCentral {
content { includeGroup("net.kyori") }
content { includeGroup("org.apache.logging.log4j") }
}
flatDir {
dir '.'
}
}```
However it is likely that it uses different syntax
Yes
.
i haven't wanted to shoot myself in the head this much in a long time... this wasn't supposed to take all fucking saturday
ahh, let's try this
to be honest the guys over at EssX are using a very enterprise-y structure
You need repository
It always takes a while to figure out what to do with these projects
how i can make max homes?
they can get off their damn high horse then it's a minecraft plugin
Hi everyone, I've got a question for yall.
So I've been trying to make custom islands that have their own world, but I ran into the issue of not enough memory.
My question now is, is there a way to limit as to how many chunks a world has/can load just like what hypixel does, and with limiting the world data size.
I searched the whole #WorldCreator but nothing that can help me there.
If anyone is able to help me, that'd be great.
Settings file 'C:\Users\Leo\Desktop\Plugin Edits\3. Currents Edited\Essentials-2.x\settings.gradle.kts' line: 25
* What went wrong:
Script compilation errors:
Line 25: dir(rootProject.dir)
^ Function invocation 'dir(...)' expected
Line 25: dir(rootProject.dir)
^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public inline fun SourceSetOutput.dir(dir: Any, vararg options: Pair<String, Any?>): Unit defined in org.gradle.kotlin.dsl```
dirs(rootProject.dir) maybe
same error
so how exactly does creating an NPC work? in other words an entity that looks like a player but isn't
Ah itâs such a mess, ainât even home kinda potato
maybe you can toFile() it
Or sth x)
toFile() it?
trying to search for any information just keeps pulling up Citizens lmao
nah
that's cuz that's the easiest way lol citizens+sentinels
citizens is bloated garbage
ok but where do i stick it
that's the problem
We are talking about how to do something in kotlin gradle
ah nvm
I don't know shit about Kotlin, my bad
gradle I can use but kotlin...
neither do i... maven used xml which is like older than my grandma
everyone knows fucking xml
The alternative is that you manually upload it to mavenLocal and use that
gradle decided it was going to make its own fucking syntax
you can take 2 days at a high school html web design class and already understand god damn xml
you'd need to declare mavenLocal manually however
XML's not even a real standard
it's just
but it should just be a mavenLocal()
"Put this shit in brackets"
where do i stick this?
XML is pretty standardised afaik
you can parse any old angle bracket markup language with an XML parser because that's the point of xml
eXtensible Markup Language
i like it though
it doesn't even need an official standard; it's literally just html tags without the rest of html
^
first you gotta upload your file to maven local. But then you can add it to the settings.gradle.kts file like the other repo we tried to declare earlier
up
oh my god what?
ok how do i do that?
i do have maven installed
inventory owner?
okay, copy upload was the wrong word
not sure what you're trying to accomplish
anyideas?
@lost matrix So how do we install a file again?
usually it helps to describe what you're trying to do in a general sense rather than asking about a very specific thing
and I say this because more often than not, I'll see a question in here that has me kind of confused because there's no reason for the person asking to be doing what they're trying to do
@quiet ice thanks for your help but i'm gonna move on to updating the next plugin now, hopefully it won't be such a fucking nightmare
i can live with old essentials
mind if I ask what you're doing? out of curiosity
i run a custom build of essentialsx... it just has a few lines of code in the function that handles the /sethome command
i knew how to edit the code back when they used maven
but now i'm just shit outta luck
If it is simple work you might also be able to use Recaf ... that should certainly work just could be gruesome if you are no familiar with it
i mean if it's a gradle plugin then i can only build it with gradle... i've tried making an intellij project from scratch with the .jar files (it took fucking hours to import everything into the correct folder structure) but that just didn't work
Plus you'd need to reapply the step over and over again every time you want to update EssX as there is not patch format for java bytecode
Recaf is a dedicated bytecode editing IDE
i mean...
Yes, overkill
I am almost home, so can test it soon otherwise in case you still havenât fiddled it out
oh thank the good lord jesus christ thank you
No, it's not really that, I want to know how spigot handles inventories that are not listed in spigot (the GUIs added with the client)
Also if it is really simple work you might just be able to use reflection or method handles and this stuff
Would save you from depending on an external jar directly
i don't know any of that... i'm only a basic java dev
.
i don't even use maven/gradle for my plugins, just intellij and file folders
how would i do this?
ping me if you need help with this
because like
that's the thing i'm good at
lmao
ah, alright. i'm actually not sure how that one works tbh
i've never dug too deep into packets/etc. as far as Spigot is concerned
you may be interested in ProtocolLib though, that's one of the few times I'd firmly recommend using a library
it depends on what you want to do. For example calling a static method is:
try {
Method method = MyClass.class.getMethod("name", Parameter1Class.class, Parameter2Class.class);
method.invoke(null, parameter1, parameter2);
} catch (Throwable t) {
}
Adding the repository didnt work :(
?paste I guess you could paste the entire pom.xml
https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-sync/4.5.0 it's on maven central anyways so that is strange...
also the repository you added is superflous
After reloading it worked
Java IDE moment
Thanks
i have a map in a config file but it is just empty when i try to get anything from it
code
config.getMapList("classEmojis")
config
classEmojis:
warriorEmoji: âď¸
archerEmoji: đš
tankEmoji: đĄď¸ď¸
wizardEmoji: đŞ
Wouldn't it be getMap?
Thanks, but that's not the problem, I already have my own packet system though, you can't quite tell where a packet is coming from as far as I understand unless you have other ideas?
there isnt a get map
Cannot resolve method 'getMap' in 'FileConfiguration'
actually yes, you are right
You can still get the keys via .getKeys however
it is named strangely, but it should be what you are searching for
aye thanks lol
lemme get u the changed files
Settings.java: https://pastebin.com/PBgXRub3
Essentials.java: https://pastebin.com/yyNbzETT
(both in .\Essentials\src\main\java\com\earth2me\essentials)
no other file is changed
btw there's a chance for syntax errors since i just copypasted code from an older version of the same files, but i can deal with that after i get it to at least see the dependency
man i'm so glad i don't use spigot's configuration api anymore
and shit like this is why
or part of it, anyway
the other part being how verbose config reads are
spigots config API is at least miles better than snakeyaml
that's true, but it's still kinda shit compared to jackson
snakeyaml is basically a fossil at this point
the one thing i do like about spigot's config api is that it's really damn easy to use
and pathing through a config file is simple
I prefer org.json:json but noone is going to use a json-based config so I do not use it in minecraft space
i just wrote a library that reads yml/xml/json into a format-neutral config tree
Night config is nice, been using it with Forge
made my life 10x easier
đ¤ đ¤ đ¤ on conclure figuring it out
combines the ease of spigot config with the not having to hardcode aspect of jackson
I've used sponge's configurate once, it is kinda nice though complicated to get started
@ivory sleet by the way you're gonna have to run gradle like this: gradle build -x checkStyleMain
for some reason they think it's okay to treat styling choices as syntax errors without that option
oo
like spaces vs. tabs what the actual fudge
certainly not in java
i should be able to fit an entire method in 1 line with no spacing at all if i wanted to lol and still can idk why it tries to styleblock me by default though that's just flat out rude
Certainly yes. Readability concerns are worth noting
up
And it should be noted that not all IDE installs are going to show 1 tab as 4 spaces for example. Some may opt in for 1 tab = 2 spaces and the extra exotic variant is 1 tab = 3 spaces. Some are like 2020 me and have it set at 1 tab = 16 spaces so they will instantly notice when there is a rouge tab.
Nowadays I just have the "show whitespace characters" option on however
not sure why
fortunately decent IDE's lets you configure how many spaces for a tab lol. Also you forgot also the other exotic variant and that is 5
There are too many variants to count with people being able to set them as they please
I have my IDE set to convert tabs to spaces, and just like you have it show whitespace characters on all the time
its more handy when I work on some other project as opposed to my own projects for the white spacing characters
However though there is no standard for how many spaces for a tab
and this has to do with history and mechanical type writers where a tab was just a physical stop for the carriage return
I mean that is kinda what makes tab so great
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
@ivory sleet any luck at all?
đ thank you lord, the other plugin i wanted to update is still on maven
thank you thank you thank you thank you
thanks
okay
I wish you can pin messages for later.
Oh well
đą you found it
let's try
this in build.gradle or the .kts file?
new File("src/main/resources/data.yml");
Any reason why it isnt able to make the file VIA a plugin?
settings
It is likely that you are trying to do new File(getDataFolder(), "data.yml") - in that case, use that instead
Yes, but when I do that, it doesnt work either
hey everyone
So I was hoping a direct path would help
Or if you are trying to use getResource("data.yml") use that instead
can someone tell me how to import this ?
import com.mojang.authlib.GameProfile;
looks like its imported already
I am using that in this yea
But, im trying to create the resouce first
Alternatively, saveResource
Do you want to create an empty file in the plugin's directory or what?
ok i think i did it right, now i'm getting more code-oriented messages... it's looking like it finally detected the jar but i'm not 100% sure yet
Basically, im trying to make a balance system, where players can have a balance in my server
String pString = "players." + p.getUniqueId().toString();
FileConfiguration conf = EmeraldsPlugin.data.getConfig();
if(!conf.contains(pString)){
conf.set(pString + ".balance", 0);
EmeraldsPlugin.data.saveConfig();
}
int bal = conf.getInt(pString + ".balance");
p.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "Your Balance: " + ChatColor.RESET + ChatColor.GREEN + bal + " Coins");
Part of my balance command
public static UserData data;
data = new UserData(this);
ah then you only need an empty file
ahh yes lol they seem to have restructured their class... guess i'll have to do some coding after all
thank you @ivory sleet
So.. should I just make a blank resource file?
Named "data.yml"
File f = new File(getDataFolder(), "data.yml");
f.getParentFile().mkdirs();
f.createNewFile();
something like this
nvm i found how to fix (need to use the server jar as dependency aswell)
@ivory sleet wait never mind it's still not working... actually i removed all of my changes and it still won't build
what does it say
nevermind... i just ran it a second time on a cleared screen and it built fine
now let's try with my edits
ahh ok yes lol it's just my code that's wrong @ivory sleet
nice
yes lol very đ thanks
how do i craft hearts????
how do i summon a horizontal firework that crossbows shoot?
Hi, I have a problem. I use the variable ${project.name} in the plugin.yml but there is an error Schema validation: String violates the pattern: '^[A-Za-z0-9_\.-]+$
Is creating a players data when joining for the first time efficient?
public void PlayerJoined(PlayerJoinEvent event){
Player p = event.getPlayer();
String pString = "players." + p.getUniqueId().toString();
FileConfiguration conf = EmeraldsPlugin.data.getConfig();
if(!conf.contains(pString))
EmeraldsPlugin.data.createUserData(p);
}
Like so
I don't see why not. Pretty common to do that. If you're loading data from file or something though, be sure to do it asynchronously
https://paste.md-5.net/zaxatomile.cs what just happened
Not sure. You're on Purpur, a very far derivative of Spigot
Doing some weird fuckery in the damage event handling. I would forward that error to them instead
Preferably on their JIRA/GitHub issues/however they track bugs
?whereami
@ivory sleet @quiet ice @prime reef i have successfully built my essentials jar 𼳠if it weren't for you guys i'd still be in anxiety hell right now so thank you all very very much â¤ď¸
I made it like a couple months ago
Is there a way to copy a world with all the exact blocks that it contains?
Help please
It violates the pattern, you canât use {}
How do I retrieve the variable then?
Yep
you have to set <filtering>true</filtering> in the build section of your pom so those entries get replaced with their real values before they are put in the jar
You can just literally copy the world folder
String value = item.getItemMeta().getPersistentDataContainer().get(new NamespacedKey(EmeraldsPlugin.jp, "coin"), PersistentDataType.STRING);
if(value == "iron"){
FileConfiguration conf = EmeraldsPlugin.data.getConfig();
String pString = "players." + p.getUniqueId().toString();
conf.set(pString + ".balance", conf.getInt(pString + ".balance") + 1);
EmeraldsPlugin.data.saveConfig();
PluginFuncs.consumeItem(p, 1, item);
p.sendMessage(ChatColor.GREEN + "Added 1 coin to your balance.");
}|
My code litterally crashed my server
Any idea why?
forgot .equals
any other reasons why it may crash?
can the artifactID have capitals?
it should not
What does the crash log say
thanks
?paste
Lol
@brave sparrow https://paste.md-5.net/ewimecibez.apache
How would I change this so that instead of a string I had an integer?
What is properties
show properties class
Maybe the error was caused by different means.
I dont have a property class
Can you look at the mappings and tell me what ItemStack#N is
I only have the official Mojang repo on my phone
Its probably java.util.Properties. Which is basically just a HashTable<Object, Object>.
The question is: why
Items ironCoin = Items.newItem("ironCoin", null);
ItemStack itemD = new ItemStack(Material.IRON_NUGGET, 1);
ItemMeta metaD = itemD.getItemMeta();
metaD.setDisplayName(ChatColor.GRAY + "Iron Coin");
NamespacedKey keyD = new NamespacedKey(EmeraldsPlugin.jp,"coin");
metaD.getPersistentDataContainer().set(keyD, PersistentDataType.STRING, "iron");
ArrayList<String> loreD = new ArrayList<>();
loreD.add(ChatColor.GOLD + "An iron coin. Right click to gain 1 coin.");
metaD.setLore(loreD);
itemD.setItemMeta(metaD);
ShapedRecipe recipeD = new ShapedRecipe(NamespacedKey.minecraft("ironcoin"), itemD);
recipeD.shape(" I ","IBI"," I ");
recipeD.setIngredient('I',Material.IRON_INGOT);
recipeD.setIngredient('B',Material.IRON_BLOCK);
ironCoin.setItem(itemD);
ironCoin.setRecipe(recipeD);
Here is the item in question
I donât want your code
I want net.minecraft.world.item.ItemStack
Thatâs the method where the server crashes
I need to know what N is
ItemStack item = event.getItem();
yep, i caught on :D
Here possibly?
they are most likely removing an item incorrectly somewhere
Why did you decide to use the Properties class instead of just using spigots FileConfiguration?
Thats the only ItemStack#N I can see
I need you to look at the Mojang mappings
And tell me what the obfuscated method N is
are you removing an item in an event? going to guess you are doing so in the interact event
For net.minecraft.world.item.ItemStack
Yep
Cant find method N
In some cases you should do it one tick later. Really depends on the context.
anywhere
let me guess you are reducing the number in the itemstack?
Yep
You need to get the mapping file from the minecraft launcher
public static void consumeItem(Player player, int count, ItemStack item) {
Map<Integer, ? extends ItemStack> ammo = player.getInventory().all(item);
int found = 0;
for (ItemStack stack : ammo.values())
found += stack.getAmount();
if (count > found)
return;
for (Integer index : ammo.keySet()) {
ItemStack stack = ammo.get(index);
int removed = Math.min(count, stack.getAmount());
count -= removed;
if (stack.getAmount() == removed)
player.getInventory().setItem(index, null);
else
stack.setAmount(stack.getAmount() - removed);
if (count <= 0)
break;
}
player.updateInventory();
}
you need to check if the itemstack only has 1 item, if they do, you need to set the item to air
instead of reducing it to 0
May I ask why
Uhm... there is a method for this in spigot...
why would that crash a server lol
declaration: package: org.bukkit.inventory, interface: Inventory
setting it to 0 is the same as setting it to null. This doesn't work because itemstacks are asserted to not be null
hence the assert error being TRAP
now everyone else learned what it means for assert to be TRAP đ
Example:
/**
* Removes 10 apples and returns an int that defines how
* many apples couldnt be removed.
*/
public int removeTenApples(Player player) {
return player.getInventory().removeItem(new ItemStack(Material.APPLE, 10)).size();
}
I haven't found anything about it, can't find anything on google.
Would you mind helping me with that ?
Copy pasting a folder?
Just google: java copy Folder
Correct.
@wet breach I need to satisfy my curiosity now, would you be a doll and tell me what the actual name for the obfuscated method net.minecraft.world.item.ItemStack#N is
I canât find a mapping on my phone
"would you be a doll"
I cant imagine that this is an actual saying...
It is
it is, just an old one
Its more common to hear in southern states
I believe i spider
Wot
Would you be a dear is usually what you hear
Same general idea
I don't have the obfuscated code at the moment, but if I had to guess it refers to the material?
This is more familiar
I hear it all the time in the hickier parts of North Carolina
Darn, I canât find a mapping on mobile
No lol
Itâs ok, you donât understand what Iâm asking for
Did you see the method i just posted which should replace your utility method?
does removeItem have a customizable amount
you can remove
Yes
Let me see if I can find a mapping somewhere in the git repo
either use what 7smile7 said or use this
if (item.getAmount() == 1) {
player.getInventory().setItemInMainHand(null);
} else {
item.setAmount(item.getAmount() - 1);
}
better to use the API though like 7smile7 showed đ
Isnt this obsolete in newer versions?
Pretty sure setting the amount to 0 is now allowed and will remove the ItemStack
Is anyone on PC and able to download the mapping?
Yes
setting the amount to 0 is exactly the reason they got the assert TRAP error
well I guess it depends which API method they were using
Can you tell me what N is
Nope. I would have to download the mappings for that...
