#help-development
1 messages · Page 840 of 1
....
net.minecraft.server.v1_8_R3.ExceptionWorldConflict: The save for world located at ./party is being accessed from another location, aborting```
new error
it looks like i need to remove the players first
@river oracle
You fucked my ass so hard in the benchmarks
I just translated your words into Russian out of habit
.....
proof?
Benchmark still running, but the avg time of the first test, for both. The difference is about 3 microseconds
register("test_argument", TestFunctionArgument.class, new EmptyArgumentSerializer(TestFunctionArgument::testFunctionArgument));
register("test_class", TestClassNameArgument.class, new EmptyArgumentSerializer(TestClassNameArgument::testClassName));
}```
how sure are we that we can't register custom argument types in brigadier?
well you have to remember
that becaues MiniMessage and adventure is more abstracted its bound to be slower
that comes with being platform agnostic
not much faster
yes
Also I made syntax sacrifices for speed
ban them all
kekw\
for example replacements are just <$key>
also for ! we do bold:! instead of <!bold> which the latter is defintely more syntactically pleasing
as long as its under a half a milli per parse for a very detailed
Works fine! Thanks
yeah that was my original goal
the new parser only takes around 200 nanoseconds off the top which is negligable
however the new parser is also much more maintainable
what is the way to save the contents the custom inventory that the player will fill
?
just save a custom inventoryP?
how?
so if i have a cache map with the weakKeys, if i leave the game will it automatically be removed from memory by the GC?
just for testing purposes ofc
uuid no.
So i should replace it with player?
suppose I have a custom inventory created, I want that before playing a mini-game, the inventory opens in front of the player and you can put things down and it will not close until all things are folded and after the player leaves the game, open the inventory again, which will not close until all things are taken how do I save these are the inventories
Spigot from what md5 says ensures players will always be singular
that's what i heard at least
the weak key stops the mem leak
so having that as weakkeys on spigot is fine.
does anyone know how to implement this?
is it possible to move an armorstands head really smooth? (i tested a few things and i didnt turn out super smooth)
How does a pointer to something nonexistant cause a memory leak anyways
oh cowoconluwube is here, he can explaion
Well its not exactly a pointer, but well, weak keys basically wraps the key objects around in a WeakReference
and WeakReference is a specially treated jvm class where the weak ref is not preventing its referent object from being gc’d eventually unlike normal strong references (such as instance variables and local variables when in scope)
Here its not necessary at all to have weakKeys, instead just make it expire on access/write and maybe invalidate an entry if the corresponding player to that uuid key happens to log off
maximum size may also be dangerous in the case of that you wanna track all online players quests (since u might discard unsaved data unknowingly), tho ultimately depends on how u handle caching etc
if you do use maximum size its best to have removalListeners
that way you can ensure tossed data actually is saved
Hello, I am trying to check to see if a player has a certain score on a scoreboard objective. The scoreboard won't be visible to the player. The scoreboard is being made via a datapack, so all the plugin has to do is read from it to get the player's score. Here's what I have, which isn't working:
Score score = e.getPlayer().getScoreboard().getObjective("ph_questingstatus").getScore(e.getPlayer().getName());
e.getPlayer().sendMessage("" + score.getScore());
if(score.getScore() == 1) {
e.getPlayer().sendMessage("The Nether is unavailable in Quest Mode!");
e.setCancelled(true);
}
score.getScore() is printing out 0, while it is actually 1.
no.
Mods
just do the actions on both of them.
Just based on assumptions, but I assume you have your own sub coordinates that you simply offset in the world to get the absolute positioning, no? Maybe having a Bukkit task running that keeps track of the position of your vehicle to which you then offset your seat's relative location? (If we're talking about positioning)
the itemStack is not hashed in the map when it is created In minecraft?
no ItemStack's are not hashed when you invoke their constructor
they are hashed when you insert them into maps
how do i rebuild a plugin that i made for 1.19 to 1.20?
change out the dependency and see if there is any errors, if there is no errors I don't think you have to do anything as it should work 🙂
in plugin.yml?
pom.xml
and what if i dont have pom.xml? this is an old project
are you using gradle or maven
then just toss it on an updated server and see if it works
can't really call it an old project if you don't have the sources anymore
and its not that old if its 1.19
i have the sources but i didnt know much about making plugins when i was programming it
.
where can i advertise myself :DDD
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
how do i check that? i know that i use maven on my newer plugins but im not sure about that one
check ur pom.xml
i have no pom.xml lol
lmao
do you have a build.gradle?
is it even possible to not have it
but its jjust working fine on new version so i guess we good
yes
I remember there was some plugin that had a big break between 1.5.2 and 1.13 or something like that and neither would run on 1.8 so I just recompiled it with api version 1.8 and it worked pff
Is there any event called when I'm removing item from creative inv?
ok so then is there any better way of checking if an player has item in inv then using taskrunner that loops player inv every X ticks?
you can listen to the InventoryCreativeEvent
Won’t be called for the trash slot
wasn't the question.
then is there any better way of checking if an player has item in inv
the InventoryCreativeEvent is called whenever an item is created in the creative inventory which is every time an item is put into a slot
can you be more specific? The creative mode inventory can create any item with any nbt at will, there are 0 restrictions on the kind of item that can be put into the creative inventory (other than experimentally disabled items probably)
well I think I can check player items when inventory get closed, so then I can see if anything was destroyed
I still can't reference new 1.20 biomes/items in paper/spigot 1.20.4 does anyone else have this issue
No
wdym reference? there are Material enum (ew) entries for them
And biome enum entries
IntelliJ autocomplete does not recognize Material.(any cherry stuff) or Biome.(cherry blossom biome) etc
Thus it's not found from the added library in project structure even while it builds and runs on 1.20.4
Is the added library 1.20.4
Yeah I deleted the older ones too from project structure just to be sure
Is there an event that is called when players are splashed with a splash potion?
anyone know how to get custom textures on my scoreboard?
Try EntityPotionEffectEvent
Or PotionSplashEvent
hey, I created a custom armor trim and trim color/material with a datapack and a resourcepack, Can I access somehow to these in a plugin?
I know I can do new ArmorTrim(TrimMaterial.something, TrimPattern.something) but idk if this can be used with custom datapack trims
Optional<LivingEntity> opLV = event.getAffectedEntities().stream().filter(livingEn -> livingEn instanceof Player).findFirst();
if (!opLV.isPresent()) return;
Player p = (Player) opLV.get();
or Player p = (Player) opLV.orElse(null);
This will give u player that splashed the potion
You could also just get the shooter…
that, that would be too easy
@young knoll wanna move CreativeCategory enum to an interface 😉
thanks in advance

is there even a reason to do that
Well it is registry based
Registry back?!?
aren't CreativeCategories jank as fuck anyways on the server
I'm just curious how its useful since I'm pretty sure those aren't synced
not yet ™️
Lynx are you still a wizard
neither are cat types
or at one point they stopped being synced
I mean, more than just synced regs have been converted
and I don't see how creative mode categories are not a potential synced one down the line
so would be nice
not saying its a bad idea just thought they were jank as hell
Oh lynx you have to tell the cat about inventory pr
they all know about my great achievement
whether it'll be merged or stuck in PR hell forever is another question
lynx returned to paper hq
It will probably be a major version merge
probs
wow family so lame imagine
My entire family is sick and our extended family is elderly as hell so we can't do shit
🥲
Lynx get kenny to give you 2k to give to choco to improve downstream relations and totally not bribe choco to make some ors
Prs
Even husky day care?
thanks
Honestly that sounds so fun I'd even do it myself
Do you not know about husky singing
gradle is suspiciously fast compared to maven
maven takes like 10 seconds gradle does it in less than a second
It's the power of caching
Creative categories are fully client side now

This is what I was talking about
I couldn't put my finger on it
The types and registries are in the shared code
You're shared code
Ik for sure client sided mods can

Or just synced block registries
If that ever happened just wait for the 10000 silver plugins just like mods
Yeah but I want tiny blocks with the new scale stuff
Imagine being a tiny man in a tiny house
I already do this irl
No need for a plugin 💪
Seems like a skill issue get smaller
is there a way to easily create subcommands like this:
commands:
group:
add:
description: ...
usage: /<command>
leave:
description: ...
usage: /<command>
where it would later create /group add arg1 arg2 and /group leave
without the need to handle all that in one CommandExecutor but instead split that command into multiple subcommands
lol no
Use a command framework
can you recommend smth?
I’m like 5’6 how small do I need to be
Shorter
Cloud, acf
ok ty :D
guys how do you access import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;?
the shooter wont return the Player
#getShooter = "Retrieve the shooter of this projectile.'
Import the spigot.jar. For 1.18+ run ?nms on this server
Yes it returns a ProjectileSource iirc
You know what implements ProjectileSource?
Yes, i mean their u go that is anothere way to do it, but not as effcient when ur trying to retrieevee statisitics on potions (accuracy, haerts wasted, and missed)
Exccuse my shitty sticky keys
Im taller than you
Imm talleer than both off u
doubt
I am 5'9
6'2
Im also 5'9 and ztill growing
I am an absolute unit
Yo btw fixed everything, you guys are amazing around heree, Shout oout you and @vocal cloud
W's in the Chat
W
damn I just got a massive urge to make 1k$ by the end of the year
Why not $5k?
bet
I am 5'5''
Told you I'd do it lol
Details? (Prompt)?
Just curious what ur working on
I wanted to get minigame infrastructure going but got bored
For MC?
yea
3.5k is wild!
it's nothing
Wynncraft2
Lol.
my boss lady thing is getting me on a 50k project :)
might actually be my new top project
gotta do math
“Boss lady thing”
Is this the lady from the media thing
maybe once all the deals go through I'll be able to afford food
no clue who you're referring to
Oh short memory
Holy shit, 50k is amazing! Imm going to make 60k
because like
we did have a media issue but I never talked to you ab it
p sure I didn't
I dont remember if we did but we are referring to two different things i believe. Coincidence i suppose
prolly
you aren't talking about the time bosslady paid 15k for marketing and the guy dipped and is declaring for bankrupcy are you
I swear we haven't spoken for like a month
Maybe. I just know you had an offer from some media thing
Short time ago
oH
that one
at the conference yeah
we exchanged contacts but never went anywhere
so not that lady either
it was also a solid 5 weeks ago
Sad, at the very least they could have given you more contacts
I swear we haven't spoken for a while because I have been distant for a while
I can still message them on the app p sure
after the conference ended I got like 15 emails from companies whose booths I attended
Well i suppose that is good
and I think I can still rewatch most talks n stuff
Which is where I'm drawing all the conference's value from rn
still have to pay my last parcel on the house and my severance pay is like a week late at this point
Always keep in some kind of contact. Even if you dont work for them they can always give you more contacts or refer you to others
So that's fun
Contacts are good yeah
But still the main thing I'm getting out of the conference is just new ideas
Like if I wanted to build an official business around minecraft I could very well do it with the knowledge I learned there
Make a full website and pitch it to people type deal
is there no pdc for blocks?
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
is there an api function to randomly enchant an item in a way similar to an enchantment table?
?jd-s
Why that one deprecated
holy mother of convenience thank god theres a lib for this

Could those perhaps be not our docs
no no no
paper docs probably
neveerrr
also why did paper deprecate that
I think we had that already
Skill issue
Truely 😭
💀 no love for my PR nah I get it
Should have PRed upstream

hmm
reminds me
time to fix the issues on the PDC list thing
I am so good at upstream relations

🔥 you are
Tbf he’s probably the best out of em all
Paper docs spotted
Hmm, maybe yea 😅
My ide tries to auto format it like that
same
oh paper implemented enchantWithLevels()
Well the method existed prior and paper generally prefers its own methods over spigots
so
yea, even tho they do the "same" thing
Yours smell tho
is there an actual reason its deprecated outside of that
beacuse I'd prefer to receive Feedback if API is actually broken or non-ideal
I think it initially had a problem with something something
but iirc fixed
with how it handled itemstack vs CraftItemStack
dunno
Remember when paper deprecated one of their events in favour of ours
how would i create a block with a pdc, like i want to create a block which when placed still has that pdc with the lib u guys provided earlier
Good times
im lost
Put pdc on the item and then copy it with the place event
ItemStacks 😨
sometimes I wake up at night in a cold sweat
Yeaaaa
thinking about them
ItemStack vs CraftItemStack is a pain
the bytecode rewrite to move itemstack to an interface is gonna be wild
ASM ftw 🔥

cause enchantItem is broken and doesn't work
wow machine
I think it has like, one edge case right ?
something something enchanted books
oh yeah that sounds about right
I should have gone to bed after the PRmarathon
well that is the broken part, the other part is its very badly implemented. Like it only sometimes mutates the input stack? super weird logic
welp suppose I should draft up a patch for that then time to go bug finding
Yea I thikn that is the ItemStack vs CraftItemStack stuff
probably 
if either of you two have comments
tldr being instead of
PersistentDataType.LIST.strings()
it would be
PersistentDataType.STRING.listType()
what would the latter do to the implementation of PersistentDataTypes
nothing
its a default method
advantage being that a) PDT could override that
and b) get rid of some API types
then I have no real preference probably the latter to relieve the implementation detail if custom types are implement
Lynx is crying now
Clearly we need X_LIST
well from an implementation perspective, If you put it in the curernt types I feel like that is probably better for devs wanting to implement custom types
Yea
I mean that is the one plus point
for the other, I think PersistentDataType.LIST.strings() is just cleaner
syntax wise
Wait does this automatically work with custom types
it would still be true the other way
I mean, the current PR also has a method to convert a PDTt to a ListType
with that PTD
you would just create them differently
yea
youd just do PersistentDataType.LIST.create(customPDTinstance)
the only benefit of the default method is the potential for custom pdt to override that method to do whatever
and idk how much of a benefit that is
Yea, which like, that is the upside, the downside being imo it looks worse as a method chain
I like the LIST.strings() more than the other way around
Hmm
yea of might be nice
but not as a static method
I hate those fucking the static imports
MM can correct me but I think we had that discussion on an owen PR not too long ago ?
with some sus stew stuff ?
its weird because if all static constructors just name their shit "of" it explodes on static imports
Static imports are clearly sin
yeah, I'd like ListType#listType instead of ListType#of
Yea
But I think a static method on that might be nice ?
hmm
More static linking of instances 🙃
tbf, you cannot static import instance methods
so like PersistentDataType.LIST.of wouild work
and you'd shorten it to LIST.of()
which is ugly
fuck
tomorrow lynx job 😂 time to sleep at 3 am
Alright fuck it time to rewrite the api in a new language
who is gonna code a rust server with me
what exactly does this want me to do?
if your package is like com.thunderins2 you'd want to replace YOUR.PACKAGE.NAMEwith that
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.thunderin</groupId>
<artifactId>nebula</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Nebula</name>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<outputFile>C:\Users\Acer\Desktop\Nebula dEv\plugins\${project.artifactId}-${project.version}.jar</outputFile>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>com.jeff_media.customblockdata</pattern>
<shadedPattern>me.thunderin.customblockdata</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.44.1.0</version>
</dependency>
<dependency>
<groupId>com.jeff-media</groupId>
<artifactId>custom-block-data</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
when I build now that ive added the stuff for cbd, i get Unsupported class file major version 61
am I forced to use static methods for acf commands? they always use it for subcommands in their examples
my problem now is I have a dependency, I could either:
- use static methods +
@Dependencyfield and add the instance to the CommandManager
or if it works - use normal methods + constructor dependency
what should I prefer?
where do i call a void for it to be always executed? im looking for something like Update() void in unity
constructor dependency
Make a runnable with a 1 tick interval
That sounds painful
Soon™ (maybe)
Omg best pr ever
seems to be caused by my shade not being 3.5.0 but maven says that dont exist?
https://maven.apache.org/plugins/maven-shade-plugin/download.cgi latest seems to be 3.5.1
Is it good practice to always have the latest version of Maven plugins?
What’s cbd in this case?
customblockdata, its a lib which allows for pdc to be used on blocks
do i need to do more than just changing the version or something? maven still doesnt believe me ahaha

Plugin 'org.apache.maven.plugins:maven-shade-plugin:3.5.1' not found

maven doesnt believe me
intellij error or mvn package error
The oil does not help with java programming
I can confirm
what do you reckon i do then? jus restart my ide?
Well check if mvn package fails
in some terminal
otherwise, IJ has a repair ide option
how do i make a runnable with a 40tick interval?
runTaskTimer
Runnables use ticks by default. Just set the interval to 40.
but how do i make a runnable?
?scheduling
@eternal night surprisingly not hard fix too bad this wasn't reported to us sooner I must've missed something silly in my initial tests
I think we barely got it too
I mean, issue being you wanna always return the stack
do you have a PR ? xD
not yet
gotta do a little bit of cleanup quick

CraftItemStack is a mess I still don't fully understands I always havfe to flick back and forth between its impl
Yea CIS is annoying af
one future day
we shall be rid of it
Well, not really rid of it, more like, rid of ItemStack class
probably should work out ItemMeta first though prey sure MD really wants a re-impl of that
He do
Yea I mean, its gonna be fucked
in a perfect world we have a non clone
but like, every plugin and their mother depends on that
What's wrong with ItemMeta?
looses data, changes data, doesn't support vanilla stuff, a ton of things
like item meta parses all of the vanilla nbt tag into some sort of spigot representation
makes me want to cry when trying to add a ByteSerialization API
MD said it should just interact with the NBT directly
it should yea
sponge style would be great
while also keeping ItemMeta interface
for easy usage
I thank god every day Inventories were not that horrible to deal with
CraftItemStack and ItemStack bring me to tears sometimes
we all need joint therapy sessions
@eternal night
private static ItemStack enchantItem(RandomSource source, ItemStack itemStack, int level, boolean allowTreasures) {
Preconditions.checkArgument(itemStack != null, "ItemStack must not be null");
Preconditions.checkArgument(!itemStack.getType().isAir(), "ItemStack must not be air");
itemStack = CraftItemStack.asCraftCopy(itemStack);
CraftItemStack craft = (CraftItemStack) itemStack;
return CraftItemStack.asCraftMirror(EnchantmentManager.enchantItem(source, craft.handle, level, allowTreasures));
}```
the amount of copying here hurts the soul, but not really sure what else to do for the desired contract
Have you tried an exorcism
cant I use acf with java 21?
these lines give me Unsupported class file major version 65
tasks.shadowJar {
relocate("co.aikar.commands", "me.squidxtv.groupingsystem.acf")
relocate("co.aikar.locales", "me.squidxtv.groupingsystem.locales")
}
for some reason when i set a mob to have a new piece of armor, the enchants never appear
mobEquipment.setItem(slot, newArmor);
the actual armor piece does show up, and the item slot does seem to have the enchantment info but it just never appears in-game
cant I use acf with java 21?
nope. latest shadow plugin only goes up to java 19
working with shadwJar works fine until I use relocate
lucky that it works at all in those cases, I'd say
the release notes state jdk 18 is the highest supported in release 8.0.0
ah ok
using a fork which already supports java 20/21:
https://github.com/johnrengelman/shadow/pull/876#issuecomment-1783983216
Why isn't this relocated? Script provided no exceptions.
It does not work because project written on kotlin?
import com.sumeru.party.SumeruParty;
import com.sumeru.party.utils.PartyUtils;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
public class PartyGUI implements Listener, InventoryHolder {
public static final String name = "Party Inventory!";
private final Inventory inventory;
public PartyGUI() {
inventory = SumeruParty.plugin.getServer().createInventory(this, 36, name);
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (!(event.getInventory().getHolder() instanceof PartyGUI)) {
return;
}
if (PartyUtils.isInventoryEmpty(player)) {
SumeruParty.playerInventories.put(player, event.getInventory());
player.closeInventory();
event.setCancelled(true);
}
}
@Override
public Inventory getInventory() {
return this.inventory;
}
}``` ``` public static HashMap<Player, Inventory> playerInventories = new HashMap<>();``` gameStart ```if (!PartyUtils.isInventoryEmpty(player)) {
PartyGUI inventory = new PartyGUI();
player.openInventory(inventory.getInventory());
}``` gameEnd ```if (player.isOnline() && (SumeruParty.playerInventories.containsKey(player))) {
Inventory inventory = SumeruParty.playerInventories.get(player).getHolder().getInventory();
player.openInventory(inventory);
}```please help me, I can't put such an item as a bush in the inventory, it throws it away.
I want that before playing a mini-game, the inventory opens in front of the player and you can put things down and after the player leaves the game, open the inventory again.
how i fix this error?
make sure you are setting the meta before passing in the item
Pretty simple
You shouldn't need to implement InventoryHolder or Listener in your PartyGUI class , you should handle listening to events in a seperate class in my opinion
PartyGUI should store playerUUID, and create an inventory for each player.
Create a PartyGUIManager class that manages PartyGUI's for players.
Create a new Map<UUID, PartyGUI> storedParties
And manage each PartyGUI for the player within your PartyGUIManager class, you will create methods inside of their to help you achieve the functionality you are looking for.
In your case its simple once game starts, save all those items in the inventory to your list
in your PartyGUI class you'll have a List<ItemStack> im assuming, or Map<Integer, ItemStack> if you care about slots.
And then retrieve those stored items back once game ends, simple!!
I can code this for you, I find it easier to do rather than explain. Its a fairly simple concept
If anyone needs a simple CooldownManagerAPI for their code, ping me.
Works with XP bars to display how many seconds in cooldown is left,
uses an Enum of CooldownTypes
CooldownManager.class:
Methods: (start, forceStop, isOnCooldown, hasCooldown, removeCooldown, clearCooldowns, getTimeRemaining, getTimeRemainingFormatted, setTimeRemaining)
Super easy to use
everything worked for me, but it seems there is a better way to do it.
If it aint broke dont fix it.
But yes what i suggested is a better practice IMO
Someone else said this yesterday:
DON'T use inventory holders. Save the inventory instance and check if its the instance
now i have ```public class PartyGUI {
public void openInventory(Player player) {
if (!PartyUtils.isInventoryEmpty(player)) {
if (SumeruParty.playerInventories.containsKey(player.getUniqueId())) {
player.openInventory(SumeruParty.playerInventories.get(player.getUniqueId()));
} else {
Inventory inventory = SumeruParty.plugin.getServer().createInventory(player, 36, "Party Inventory!");
SumeruParty.playerInventories.put(player.getUniqueId(), inventory);
player.openInventory(inventory);
}
}
}
public void storeInventory(Player player) {
if (SumeruParty.playerInventories.containsKey(player.getUniqueId())) {
SumeruParty.playerInventories.put(player.getUniqueId(), player.getInventory());
}
}
public static void restoreInventory(Player player) {
if (SumeruParty.playerInventories.containsKey(player.getUniqueId())) {
player.getInventory().clear(); // Clear player inventory before restoring
player.getInventory().setContents(SumeruParty.playerInventories.get(player.getUniqueId()).getContents());
}
}
}```
You are abusin static, theirs no reason for those methods to be static. Use a manager, and use UUIDs dont use Player object imo bad practice. Player object is for quick ease access, UID’s are accurate and unique to a specific player obviously so its better to store UUIDS
public static final HashMap<UUID, Inventory> playerInventories = new HashMap<>();
i use UUID now
Ew why is it static tho?
no need for static
You should really watch Coding with John on youtube for a basic understanding of Java
He makes great vids that are fun to watch
Very educational
i think he knows when to use static or not
I assumed he didnt because those methods are static inside PartyGUI, when u can use a manager instead which is a lot more efficient
well in terms of efficiency statics are faster. However the use of statics causes issues such as expecting an object instance to be different when it really isn't, or you believe the object should be different when its not. There are other disadvantages such as anything static never gets GC'ed either
It is actually easy for someone new to Java to get hooked on static usage since functional programming is easier to learn and work with at times lol
would using pdc of an item be a good way to store other items in the item to act a backpack?
Yes
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
import com.sumeru.party.utils.PartyUtils;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.UUID;
public class PartyGUI {
private final JavaPlugin plugin;
private final InventoryManager inventoryManager;
public PartyGUI(JavaPlugin plugin) {
this.plugin = plugin;
this.inventoryManager = new InventoryManager();
}
public void storeInventory(Player player) {
inventoryManager.storeInventory(player, player.getInventory());
}
public void restoreInventory(Player player) {
if (inventoryManager.containsInventory(player)) {
player.getInventory().clear();
player.getInventory().setContents(inventoryManager.getInventory(player).getContents());
}
}
private class InventoryManager {
private final HashMap<UUID, Inventory> playerInventories = new HashMap<>();
public boolean containsInventory(Player player) {
return playerInventories.containsKey(player.getUniqueId());
}
public Inventory getInventory(Player player) {
return playerInventories.get(player.getUniqueId());
}
public void storeInventory(Player player, Inventory inventory) {
playerInventories.put(player.getUniqueId(), inventory);
}
}
}```
PartyGUI gui = new PartyGUI(SumeruParty.plugin);
gui.storeInventory(player);
}```
This is closer to what I need?
and if (player.isOnline()) { PartyGUI gui = new PartyGUI(SumeruParty.plugin); gui.restoreInventory(player); }
In programming, it's undesirable to overcomplicate code, but I was wondering if it's a good idea to make one good system. I'm making a plugin for artifacts, and I'd like to abstract away their detailed interactions in certain contexts because I have a lot of Enum classes to create ways to interact with players. (This could lead to a lot of nested if constructs. And would like to make a class for example Artifact.workProcessStart();
That's fine
Yeah that works. If u were going to store PartyGUI in map just make sure to instantiate your InventoryManager only once in your main class
why is my server recommending player names in tab completion instead of the things it should recommed?
The command hasn't coded tab completion
no
it does have tab completion
it just recommends player names
im running bungeecord with a bunch of servers
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Is it true that a decompiled jar will always not be identical to the source code?
Mostly’ish
bruh I keep accidentally uploading github repositories to NedHuman/PluginName instead of Server/PluginName, after I delete them it still says "This folder is already a respository" and I cannot add it again anymore, anyone know how I could fix this? (im using github desktop btw)
Location spawn = DB.sheepfrenzy;
World world = spawn.getWorld();
Random random = new Random();
int x = random.nextInt(60) - 30;
int z = random.nextInt(60) - 30;
x += (int) spawn.getX();
z += (int) spawn.getZ();
return new Location(world, x, spawn.getY(), z);
}
@org.bukkit.event.EventHandler
public void onRespawn(PlayerRespawnEvent event) {
new BukkitRunnable() {
@Override
public void run() {
if (SumeruParty.players.contains(event.getPlayer().getName()) && (SumeruParty.current_minigame == 1)) {
Location spawnpos = getRespawnCoords();
Block block = spawnpos.getWorld().getHighestBlockAt((int) spawnpos.getX(), (int) spawnpos.getZ());
if (block.getType() != Material.AIR) {
event.setRespawnLocation(spawnpos);
this.cancel();
}
}
}
}.runTaskTimer(SumeruParty.plugin, 20, 20);
}``` sorry that I have a habit of throwing code at people, but in this context DB.sheepFreenzy is the main spawn position on the mini-game map. the problem is that there are also tnt that destroy the map and there is a glowstone under the map and if you step on it you will die, and if you leave the main spawn point it can be destroyed by primed tnt and you will endlessly fall on glowstone also without a death screen. I want to use the main spawn point to select a random position on the entire map for which there is a block and not a void and spawn the player there at death
but instead respawnLocation is not set at all
to check if there is a block under the player, I have not found a better way than to create a repetitive task that checks this
if (SumeruParty.players.contains(event.getPlayer().getName()) && (SumeruParty.current_minigame == 1)) { I am also convinced that this condition is executed
You can’t use a tasktimer there
what should i do?
Remove ur scheduler
and?
how then to check block under player for air material
can you explain please
can i use something like this? ```private boolean isValidRespawnLocation(Location location) {
World world = location.getWorld();
int x = (int) location.getX();
int z = (int) location.getZ();
return world.getHighestBlockAt(x, z).getType() != Material.AIR;
}```
but then the player will need to press the respawn button again
Is there a way to get a Material from an ID like minecraft:dirt?
public void onDeath(PlayerDeathEvent e)
{
final Player p = e.getEntity();
if (SumeruParty.gameStarted && (SumeruParty.players.contains(p.getName()))) {
e.setDeathMessage(null);
e.setKeepInventory(true);
Bukkit.getScheduler().scheduleSyncDelayedTask(SumeruParty.plugin, () -> p.spigot().respawn(), 2);
Bukkit.getScheduler().scheduleAsyncRepeatingTask(SumeruParty.plugin, () -> {
Location spawnpos = getRespawnCoords();
if (isValidRespawnLocation(spawnpos)) {
p.teleport(spawnpos);
SumeruParty.logger.info("fff");
}
}, 0L, 20L);
}
}``` I deleted the onrespawn event and put the code in ondeath but it still doesn't work
it looks like something is wrong with the getRespawnCoords method can someone help me track down the error
Can I ask a question... Why does your EventHandler annotation contain the whole package name
because my class is also called EventHandler
why
There is no need for ur scheduler
that's how I want to name the classes, it shouldn't affect anything, I think
and then what should I do?
Remove it and try again
It shouldn't, but it's still goofy to name classes like that. Sinve your class implements Listener why not call it EventListener and then you can annotate methods with just "EventHandler"
but the problem is that if the block under player is going to be air, then plugin need to generate the correct coordinates again
Then use while loop, your scheduler will not work as u intended
The scheduler call is really goofy
while (!isValidRespawnLocation(spawnpos)) {
spawnpos = getRespawnCoords();
if (isValidRespawnLocation(spawnpos)) {
p.teleport(spawnpos);
SumeruParty.logger.info("fff");
}
}```
?
Sigh
That looks wrong
I'm sorry to make you sigh, but could you please explain what's wrong?
while (!isValidRespawnLocation(spawnpos)) { spawnPos = getRespawnCoords();}
p.teleport(spawnpos);
```
What does getRespawnCoords do tho
i remember in an old joke version, u could make custom portals to nearly infinite worlds, and those portals had different colors, is it possible to change portals color in recent versions? 1.20.1
nothing is happening I was kicked with exceeded timeout it looks like this while loop is running indefinitely
^ he sent it here
I am gonna sleep
I want to use the main spawn point to select a random position on the entire map for which there is a block and not a void and spawn the player there at death
that is, getRespawnCoords takes a random position on the map based on the main point and checks the block highest in x and z using isValidRespawnLocation
is this block equal to the air so that the player does not fall during respawn so this block has been blown during the game
Do you understand what I want to do?
and everything is clear
get a chunksnapshot of the coord
then you can do your processing of it in another thread
or in an async task
this way you don't cause the main thread to hault
once you found what you want, bring it back to the main thread to then teleport I suppose
well i don't believe finding valid cords will block that much that server crash
what is chunksnapshot and what does it do
I can't even go in.
on server
you probably should learn more java if you don't understand about not stopping the main game loop
it is a while loop, so yes it will halt the main thread until it is done
i know, but it should do at most 10 iterations, not infinity loop, it should be anomaly to find unvalid spawn location, not valid one
.
as well as what you deem as valid
yeah ig this matters
do {
spawnpos = getRespawnCoords();
} while (!isValidRespawnLocation(spawnpos));
ChunkSnapshot chunkSnapshot = spawnpos.getChunk().getChunkSnapshot();
p.teleport(spawnpos);``` how do I use chunkscnapshot in this context
there is a flaw with that code that makes it go infinitely
just fyi
frostalf can you please explain?
so there is a problem
indeed, and easy to make mistake as well
they are getting the block coord
the block coord isn't ground level
rather level with all the rest of the ground
so they need to go 1 up on the y
if they don't do that, no matter where they traverse on the x and z the spawn location would be invalid as its in the ground 🙂
Are you trying to make instant respawn?
@sterile flicker ^ there, frostalf explained
well I do suppose at some point a valid location would be found
but it would take a long while
without death screen yes
Easy. Set players health to 20 boom done. You must do this on PlayerDeathEvent
I think first, they should focus on fixing their respawn location thing
so its not killing the main thread 🙂
If you want to have a death animation still, you must make a method #fakeKillPlayer that calls correct Packets, i can send you my method for it, its rlly cool and id be happy to share it with you
the while loop is screaming PROBLEM to me. Idk why op has that in his code
me personally i avoid while loops, too much room for error
?
Hey there, is there any event called on "/clear" at all?
no, except for the normal PlayerCommandPreprocessEvent ofc
alright thank you
is there a way to use packets without having to guess what does what like just that the methods names are not encrpyted
you don't know how to read java code?
sorry that I dont know what xyz.a(b) does
its what an IDE is for
use mojang maps
then the methods have proper names
a proper IDE will let you follow code with ease regardless of how many classes it goes through
not all of them
a good bit of them though
all methods have a mapped name
no
example?
spigot doesn't make use of all classes and mojang doesn't release mappings for everything either
and I can't just whip you up an example of this at a moments notice either
I have never encountered a single method that's not mapped
the methods name are encrpyted thats my problem I know how to read it but if its like player rendering an I need to spawn the player again I should know the name for it and not need to guess if its the sub method a b or c
of course not because the common stuff that is needed is mapped
as I said, use mojang maps
?nms
its not hard to know what is or is not for rendering if you walked the method back, don't really need to guess
my IDE can tell me where any given method is used in a project
I can even rename it at will and in all places at once if it makes it easier to track. You can go with mojang mappings too, but just pointing out a decent IDE makes it unnecessary
I could back track it but why work hard if there would be an easier way
I guess its difficult for some
is there an event for attempting to use a nether portal even if teleportation wont happen?
Unresolved plugin: 'net.md-5:specialsource-maven-plugin:1.2.2' do I need to specify something with Buildtools for that too?
declaration: package: org.bukkit.event.entity, class: EntityPortalEnterEvent
did you click the maven reload button?
yup
try to run mvn package anyway, it should download it
whats a good kotlin sql ORM?
thanks. works fine. solution is ```public Location getRespawnCoords() {
Location spawn = Data.sheepfrenzy;
World world = spawn.getWorld();
Random random = new Random();
int x = random.nextInt(60) - 30;
int z = random.nextInt(60) - 30;
return new Location(world, x + spawn.getX(), world.getHighestBlockYAt((int) (x + spawn.getX()), (int) (z+spawn.getZ())) - 1, z + spawn.getZ());
}
private boolean isValidRespawnLocation(Location location) {
return location.getBlock().getType() != Material.AIR;
}``` and ```Bukkit.getScheduler().scheduleSyncDelayedTask(SumeruParty.plugin, () -> {
p.spigot().respawn();
Location spawnpos;
do {
spawnpos = getRespawnCoords();
} while (!isValidRespawnLocation(spawnpos));
spawnpos.setY(spawnpos.getY() + 2);
p.teleport(spawnpos);
}, 2);```
ktorm i would say
Unfortunately it doesn't work
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.util.HashMap;
import java.util.UUID;
public class PartyGUI {
public PartyGUI() {
}
public void storeInventory(Player player) {
InventoryManager.getInstance().storeInventory(player, player.getInventory());
}
public void restoreInventory(Player player) {
if (InventoryManager.getInstance().containsInventory(player)) {
player.getInventory().clear();
player.getInventory().setContents(InventoryManager.getInstance().getInventory(player).getContents());
}
}
private static class InventoryManager {
private final HashMap<UUID, Inventory> playerInventories = new HashMap<>();
private static final InventoryManager instance = new InventoryManager();
private InventoryManager() {
}
public static InventoryManager getInstance() {
return instance;
}
public boolean containsInventory(Player player) {
return playerInventories.containsKey(player.getUniqueId());
}
public Inventory getInventory(Player player) {
return playerInventories.get(player.getUniqueId());
}
public void storeInventory(Player player, Inventory inventory) {
playerInventories.put(player.getUniqueId(), inventory);
}
}
}```
I added getinstance to make sure I instantiate my InventoryManager only once
but it's just at the onrestore stage clearing my inventory.
Hi, I'm trying to modify a plugin's source code to my needs but its bukkit, how could I change it? (IntelliJ)
Change what
To Spigot
spigot "includes" bukkit
bukkit plugins run fine on spigot
however if you wanna switch to spigot-api just replace the dependency in pom.xml from org.bukkit bukkit-api to org.spigotmc spigot-api
Yes but I cant use spigot's advanced methods/api
There aren't many of those
Honestly alt detector is a pretty good exercise and not too complicated.
You should write this from the ground up. We can give you the general idea on how it works if you want.
nah I dont wanna modify it a lot
Currently it broadcasts all alts, im gonna make it so it only broadcasts if the alts are banned
I wanna hear it how it works
My first thought is IP
yes it stores IPs in a database
Without doing any research: Mapping a single IP to multiple accounts
My thought as well 😉
but IPs are unrealiable as they're mostly dynamic
Sadly that falls apart fairly quickly
yes
I can just do .isBanned()
Spigot has very limited extended api
If I did a research, I'd find better ways to do it?
Probably not. There is not a lot of information to be gathered from the minecraft client.
You could try some really complicated approaches like heuristic analysis of player behavior
or tracking the internet provider associated with this IP, together with some geo information.
I guess IP is my only option then, I'd also have to check if player isn't connected via tunnel or vpn?
while true, the reverse ip is not
the reverse ip's are unique to specific isp's
What even is a reverse ip supposed to be...
yeah what is reverse IP
you mean a hostname of an IP?
ip -> hostname?
Reverse IP lookup, also known as reverse DNS lookup, is the process of querying the Domain Name System (DNS) to determine the domain name associated with an Internet Protocol (IP) address
all ip's have a reverse
Could work
No, this "reverse" refers to the lookup process.
many ip's can map to the same reverse
but hostnames are often different
even for the same ISP
<a>.<b>.<c>.<isp>.com
kind of
how are you supposed to parse that and detect it
I think my best bet is an ip
Please help)
ip's can't reverse to more then one hostname
yes but each one is different
no
hostname per IP right?
no
When you control a block of IP's they map to a singular location
this is why blocks have to be cut down
its just a dns lookup
Why do you create a new InventoryManager for every single PartyGUI?
the record you are looking for in the dns is a ptr
so like how you would look up a domain's ip in dns, you do the same but for a ptr with the ip
so how do you do a dns query in java
so I first need to get the IPv4 and then use it to query it
I was told that I don't need static in my class. How do I improve my class?
that can be retrieved on player join I think? its a function
The IP packet contains the target address. Thats as far as you will get.
tnx
you want to this before they join
login contains everything you need
and is the ideal place because you can suspend the process for a logger period of time unlike the join
where they may just DC also if they are not supposed to connect it makes little sense to waste more resources and let them get to the join
Create only a single instance of InventoryManager and dont create a new one for every GUI.
*And dont make the manager an inner class. That makes no sense.
also note, ipv6 exists too
unless you strictly only accept ipv4 connections
then you need to ensure your server only accepts ipv4 connections
otherwise you have a major flaw in your design
I think the easiest way would be to just use the ip they connect with, either ipv4 or v6 and run a lookup in the database for a match
and enforce system like 5users / IP
well just know that ipv4 ptr records are slightly different then ipv6
ipv6 is in 4 bit sections where as ipv4 is in 8 bit sections
Yeah. And NAT is useless with it but for some reason still used...
NAT is not useless
NAT has a natural security to its design
IPV6 was designed to allow any machine assigned an ipv6 to connect to the outside world
but this is bad if the machine isn't needed to be contacted directly from the outside or you don't want people to just arbitrarily talk to it
this is where IPV6 NAT comes in
also, since IPV6 NAT exists, this basically makes the infinite ipv6 space more infinite then it was before
ipv6 was created because ipv4 was starting to run out of new ip adresses
ipv6 was created before that even started to happen 🙂
and that is what its primary purpose was for
however, some things were incorporated that ipv4 lacked
however NAT came after ipv6 was started and was initially for a stop gap
but, it proved effective in not only in the stop gap measure but also being a natural defense in shielding machines from the outside
any machine that has a private IP from the private ip space can not be reached directly
ipv6 without nat removes this
and exposes all machines regardless if internal or not to the outside world
hello, what do you guys think is the best way to construct an Object with Code that the Object will run once a certain condition happens? Do I just give it a Runnable? Or BukkitRunnable?
it sounded good but back then DDoS and other malicious things were not prevalent
Runnable is a general purpose function, whereas BukkitRunnable are used to create schedulers
what makes you say that?
Yep, Java actually has all kind of functions, in case you didn't know that https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html
Very useful
still not working ```package com.sumeru.party.gui;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.util.HashMap;
import java.util.UUID;
package com.sumeru.party.gui;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.util.HashMap;
import java.util.UUID;
public class InventoryManager {
private final HashMap<UUID, Inventory> playerInventories = new HashMap<>();
private static final InventoryManager instance = new InventoryManager();
private InventoryManager() {
}
public static InventoryManager getInstance() {
return instance;
}
public boolean containsInventory(Player player) {
return playerInventories.containsKey(player.getUniqueId());
}
public Inventory getInventory(Player player) {
return playerInventories.get(player.getUniqueId());
}
public void storeInventory(Player player, Inventory inventory) {
playerInventories.put(player.getUniqueId(), inventory);
}
} package com.sumeru.party.gui;
import org.bukkit.entity.Player;
public class PartyGUI {
public void storeInventory(Player player) {
InventoryManager.getInstance().storeInventory(player, player.getInventory());
}
public void restoreInventory(Player player) {
if (InventoryManager.getInstance().containsInventory(player)) {
player.getInventory().clear();
player.getInventory().setContents(InventoryManager.getInstance().getInventory(player).getContents());
}
}
} player join if (!PartyUtils.isInventoryEmpty(player)) {
PartyGUI gui = new PartyGUI();
gui.storeInventory(player);
}player leaveif (player.isOnline()) {
PartyGUI gui = new PartyGUI();
gui.restoreInventory(player);
}```
jesus use a pastebin
jesus christ jesus
nothing XD
Jesus Christ, Jesus Christ, Your arms open and close.
so does anyone know how to solve this problem?
and if I want to always give it an ArrayList for example, do I use consumers?
Depending on the direction, yes you'd either use Consumer or Supplier
alright then
Explain your problem again pls.
my problem right now is that instead of giving items after exiting/ends the game, it just cleans up the inventory.
I want to save the player's inventory before joining the game and give it out when exiting the game
You need to save the contents, not the inventory!
The inventory is the same instance that you clear on onrestore
Well you dont copy the items anywhere.
You just throw the players Inventory in a map, and then proceed to clear the same inventory.
The inventories of your player and the one in your map are identitcal.
this
Make an array copy of the contents
how do I organize everything to keep the contents of the inventory?
No clue what you mean with this
so private final Map<UUID, ItemStack[]> playerInventories = new HashMap<>(); playerInventories.put(player.getUniqueId(), inventory.getContents()); instead of playerInventories.put(player.getUniqueId(), inventory); and public ItemStack[] getInventory(Player player) { instead of public Inventory getInventory
I mean yeah, but make a copy of the array beforehand
getContents() creates a new array each time. I dont think a copy is needed here.
That's what I thought but wasn't too sure if that's the case
Since it's not documented 😵💫
Yeah it should include infos like transitivity of changes and stuff
Gotta love the docs from spigot
Feel free to PR and impove Spigot 🙂
Already did last year
so is there anything else besides these changes needed?
seemed fairly obvious
I mean yes that's what I would do, but it's not specified in the documentation and spigot uses mutability basically everywhere
Vector, location even ItemStack
So it's not far fetched to think that they're not returning an arraycopy
is there a way to legally extend the intelij idea trial?
only illegally
expires in 4days..
use the community edition
XD
for free)
yes
yes
I don't see how you wouldn't in this case
Memory complexity
Imagine getting the contents and shallow copying 27 slots every time, since inventory is mutable itself it would make sense to not copy the array, even tho it is the better option
no it wouldn't make sense at all
if it were mutable that means you could change the inventory from that method
which makes no sense to do or even allow
given its purpose it is to give you all the contents in the inventory
and you have a method that compliments called setContents()
which takes the same array
well same kind anyways
I mean like I said it's the most logical option, but it's an implementation detail that should be specified in the documentation to force underlying implementations to implement it that way, imo
You can buy a student edu email from ebay
... or just use community edition
I don't think most people need the features of the enterprise edition
I guess, yeah
it still doesn't work for me. can I call storeInventory and restoreInventory statically?
I think you can also export the settings and reimport them on another device
what event fires when firework is used to boost elytra?
PlayerInteractEvent?
That'd be manual labor (ew)
Yes, and then simply check Action, whether the player is flying, wearing an elytra and is holding a rocket
Alternatively there is PlayerElytraBoostEvent with paper
actually you can boost without an elytra
You can?
yes but game will cancel gliding after a tick
so you gotta cancel the cancelation of gliding
Hello, I followed mfnalex's nms tutorial (https://blog.jeff-media.com/nms-use-mojang-mappings-for-your-spigot-plugins/)
But when I add org.spigotmc.spigot, I get errors.
I used BuildTools with mojang mappings, javadoc generation and source generation for the 1.15.2 version.
Here is my pom.xml: https://paste.md-5.net/ugipimiwaf.xml
If you need to access NMS classes from inside your Spigot plugin, it is a very good idea to use the so called Mojang mappings. Disclaimer: This post is obviously written for 1.18.2. If you use another version, you of course have to replace every occurance of “1.18.2” with the version you actually use. What...
Mojang mappings are not available for 1.15.2
they're 1.17.1+
hummm
they exist for 1.14+ but spigot doesnt not support them till 1.17.1
^^
Could you resend your code
Or better: create a thread
thats difference beetwen spawn.getWorld().spawn(spawnpos, Sheep.class); spawn.getWorld().spawnEntity(spawnpos, EntityType.SHEEP);?
import org.bukkit.entity.Player;
public class PartyGUI {
public static void storeInventory(Player player) {
InventoryManager.getInstance().storeInventory(player, player.getInventory());
}
public static void restoreInventory(Player player) {
if (InventoryManager.getInstance().containsInventory(player)) {
player.getInventory().clear();
player.getInventory().setContents(InventoryManager.getInstance().getInventory(player));
}
}
}``` and ```package com.sumeru.party.gui;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class InventoryManager {
private final Map<UUID, ItemStack[]> playerInventories = new HashMap<>();
private static final InventoryManager instance = new InventoryManager();
private InventoryManager() {
}
public static InventoryManager getInstance() {
return instance;
}
public boolean containsInventory(Player player) {
return playerInventories.containsKey(player.getUniqueId());
}
public ItemStack[] getInventory(Player player) {
return playerInventories.get(player.getUniqueId());
}
public void storeInventory(Player player, Inventory inventory) {
playerInventories.put(player.getUniqueId(), inventory.getContents());
}
}```
PartyGUI.storeInventory(player);
}``` or ```if (!PartyUtils.isInventoryEmpty(player)) {
PartyGUI gui = new PartyGUI();
gui.storeInventory(player);
}```
I'm waiting for someone to say "jesus, use pastebin"
jesus, use pastebin
And what about the problem itself?
Is it the same issue?
No. I changed it to static and haven't tried it yet
did I do the right thing by changing to static?
You can or you utilize the singleton pattern
But please try it first before asking for help if your problem is resolved
fun fact, if you can guarantee your map to not have null inserted using get() can be more efficient
What is the point in singletons
to guarantee a singular instance of an object
in otherwords no matter where the instance is obtained, there should ever be only a single instance that exists
this is what singleton does/is
But what is the point
Be more specific
its more handy with manager classes or the easiest place to implement
Why do I want a single instance of the object, why prevent others
where you only want a single manager object to ever exist or can exist
Because there are systems where having more than one instance of an object would ruin its functionality.
In that case, why don't I static everything
Is that a general question or are you referring to my answer with this question.
not always they can be made static
if something instantiates an instance of the singleton, its guaranteed there is only one of it
emily enters the chat
Because your code would probably suck then, given that overuse of static does cause quite the maintenance issue long term
static or not I don't give a shit, I'm still breaking whatever it is 😂
Wait, are you asking why you would create a singleton instead of making all methods and fields of a class static in the first place?
Yes
the main factor which I stated is that a singleton doesn't need to always exist. If it isn't needed down the road it can be GC'ed
statics can't be GC'ed
Testability and, if you deal with multithreading then having a bunch of static fields is a nightmare, esp if they’re mutable
Hmm
public static, my beloved ❤️
reminds me of C all over again

Man I started a war with bringing out the singleton pattern
if the singleton manager depends on some instance of something else, it'd need to be passed to the constructor, so you couldn't make everything static in that case, unless you make all the static methods also take that instance which, ew
nah I'm just here to slack off lmao
Wasn't my intention bois I'm sorry
Lmao
My biggest reason would be lazy initialization.
Having the field initialized eagerly will eventually lead to horrific dependency problems, causing the classloader to break
resulting in very hard to discover bugs.
I should be upgrading my chat filter yet I'm just here reading about ya'll talk about singletons
no you didn't, it is good that people learn about concepts they are not familiar with
yeah I know bruv was ironic
I like how many messages I could cause by saying like 15 words
Sorry if the joke didn't land
i find it quite interesting how singleton is usually associated with static access
it not only didn't land, it missed orbit entirely and went straight for the Andromeda galaxy
I mean the canonical singleton pattern does imply the pattern to have a global access point which ppl usually associate static with
That, on the other hand, made me smile
Another reason would be instance behavior i guess.
Imagine having an abstract structure for your manager classes, with each manager ensuring certain behavior.
You cant inherit or ensure anything with static methods.
So thanks a lot
np
Hmm, that definitely makes sense
Now you make me smile I need to reduce processing time from 1.8ms down to at least 0.6ms to get an acceptable time but like, I can't be fu-
-cking arsed?
I never care about time
kinda
Well it would bring down the time from 30 minutes PER TEST to around 10 minutes
Oh what
I am dealing with a lot of data aight?
is it a plugin?
somehow my pom.xml is gone, how do I regenerate it?
Hello, how can I convert net.minecraft.world.entity.EntityType to Bukkit EntityType?
if the naming convention is the same you can convert to string and then to entitytype ig
otherwise you might have to map them
Idk how to get the name