#help-development
1 messages Β· Page 2245 of 1
It has the same problem and no pretty printing
You don;t want pretty printing yet. solve yoru encoding issue
I mean yeah if you're writing data, you won't want to pretty print ;p
Whitespace is additional unnecessary data
however you shoudl not be getting a stack trace from toString(). getAsString() should also be fine on a single JsonObject
Better than mine on a good day π
ah
for (GuildPlayerObject guildPlayer:Main.getPlayerCache().values()){
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("name" , guildPlayer.getName());
jsonObject.addProperty("uuid",guildPlayer.getUniqueId().toString());
compressedData.write((jsonObject.toString() + ",\n").getBytes(StandardCharsets.UTF_8));
}```This shoudl not error
a simple toString()
@manic furnace Does that work ^
How would you do a fill menu system?
So for example if the menus has 3 rows it fill all around leaving the middle row with nothing
if it does you can java JSONSerializer json = new JSONSerializer(); json.prettyPrint(true); compressedData.write((json.deepSerialize(jsonObject) + ",\n").getBytes(StandardCharsets.UTF_8));
or something close
If you need a cleaner implementation with yrou Gson https://howtodoinjava.com/gson/custom-serialization-deserialization/
yeah ik but for mods watchin glmao
// load package C
final String pkgCloc = "./C-1.0.jar";
try {
final URL pkgCUrl = new File(pkgCloc).toURL();
ClassLoader loader = new URLClassLoader(
new URL[] { pkgCUrl }, Object.class.getClassLoader()
);
loader.loadClass("c.pkg.PackageC")
.getMethod("loadPackage")
.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
``` any idea why this code may be crashing with a `ClassNotFoundException` (https://paste.md-5.net/bukafepeqa.md)
Classloader hell?
LoaderPlugin:23 is
loader.loadClass("c.pkg.PackageC")
Make sure youβre using the same classloader which defined the class to load the class
or should i try Class.forName("name", loader)
Launch players? In the air?
im trying to parent it to the system classloader
ill try this.getClass().getClassLoader()
Change their Y velocity
still doesnt work
For launching players you can modify his velocity
You can multiply it for example
use System#getClassLoader() if want a system class loader
k thanks
Try that maybe works
When i use SystemClassloader for loading i scan the jar using a JarEntry object and them i load each class if matches to x name/package
nevermind then
loop x+ y
loop x y+
loop x+w y+
loop x+ y+h
where w is widht of inventory
and h height
then use int idx = y * w + x to get the thing
yeah
just switch hardcode sizes
for (a = 0; a < menu.getRows(), a++) {
}```
dont think theres a way to only fill borders if u dont know widht & height
@glossy venture you sorted ur problem?
nah
try { String filePath = config.getConfig().getString("jarfile"); String mainClass = config.getConfig().getString("class"); if (filePath == null || mainClass == null) { PluginLogger.getInstance().severe("Your file path or main class is not specified in prices.yml"); Bukkit.getPluginManager().disablePlugin(plugin); return; } File file = new File(plugin.getDataFolder(), filePath); if (!file.exists()) { PluginLogger.getInstance().severe("The jarfile specified in prices.yml does not exist"); Bukkit.getPluginManager().disablePlugin(plugin); return; } URLClassLoader classLoader = new URLClassLoader(new URL[]{file.toURI().toURL()}, getClass().getClassLoader()); Class<?> clazz = Class.forName(mainClass, true, classLoader); if (!PriceProvider.class.isAssignableFrom(clazz)) { PluginLogger.getInstance().severe(mainClass + " does not extend PriceProvider"); Bukkit.getPluginManager().disablePlugin(plugin); classLoader.close(); return; } this.priceProvider = (PriceProvider) clazz.getConstructor().newInstance(); } catch (Exception e) { e.printStackTrace(); PluginLogger.getInstance().severe("There was a problem loading your price provider"); Bukkit.getPluginManager().disablePlugin(plugin); }
Let start again on my menu api i keep the amount of rows from the menu. And them a Map<Integer, ItemStack>
what the fuck
u can calculate width = size / rows
and then use my mehtod
this is exactly what im doing
this
public void drawItem(int x, int y, ItemStack stack) {
inventory.setItem(y * width + x, stack);
}
public void drawRect(int x, int y, int x2, int y2, ItemStack stack) {
for (int xi = x; xi < x2; xi++)
drawItem(xi, y, stack);
for (int xi = x; xi < x2; xi++)
drawItem(xi, y2, stack);
y++;
y2--;
for (int yi = y; yi < y2; yi++)
drawItem(x, yi, stack);
for (int yi = y; yi < y2; yi++)
drawItem(x2, yi, stack);
}
i was doing gui too
idk if it works
but thats how i owuld do it
I dont have InventoryDisplay thing
now just pass x = 0, y = 0, x2 = w - 1, y2 = h - 1
π½
drawItem just gets an item from a function and draws it at x y
no wait
public class Menu {
@Getter private final String name;
@Getter private final int rows;
private final Map<Integer, MenuButton> buttons = Maps.newHashMap();
@Getter private Inventory inventory;
public Menu(String name, int rows) {
this.name = name;
this.rows = rows;
}
public Menu setButton(int slot, MenuButton button) {
this.buttons.put(slot, button);
return this;
}
public Menu unsetButton(int slot) {
this.buttons.remove(slot);
return this;
}
public Menu build() {
this.inventory = Bukkit.createInventory(null, this.rows * 9, Chat.style(this.name));
this.buttons.forEach((slot, button) -> this.inventory.setItem(slot, button.getItem()));
return this;
}
public void update() {
this.inventory.clear();
this.buttons.forEach((slot, button) -> this.inventory.setItem(slot, button.getItem()));
}
public void open(Player player) { player.openInventory(this.inventory); }
public void close(Player player) { player.closeInventory(); }
public MenuButton getButton(int slot) { return this.buttons.get(slot); }
}
That my menu thing
i added everything u need
how do i get the bukkit LivingEntity from an NMS LivingEntity
public void drawItem(int x, int y, ItemStack stack) {
inventory.setItem(y * width + x, stack);
}
public void drawRect(int x, int y, int x2, int y2, ItemStack stack) {
for (int xi = x; xi < x2; xi++)
drawItem(xi, y, stack);
for (int xi = x; xi < x2; xi++)
drawItem(xi, y2, stack);
y++;
y2--;
for (int yi = y; yi < y2; yi++)
drawItem(x, yi, stack);
for (int yi = y; yi < y2; yi++)
drawItem(x2, yi, stack);
}
bet theres a .getBukkitEntity()
or .bukkitEntity
@sterile token
Anybody know off the top of their head if the BlockDispenseEvent is called even if the dispenser is blocked?
where came witdh from?
?paste
https://paste.md-5.net/eviganayep.cs does anyone know if this would work?
π€
?tryandsee
Oh lmao the command used to display a gift
And it doesn't work?
well that was helpful thanks!
well thats exactly what im doing
still doesnt work
i created a very normal program for very normal things once and it worked fine
and then later i load a class and invoke a method
am i just bad at minecraft or was breeding horses removed-
wait i think my plugin is messing with something
Okay?
i found the answer immediately nvm
hat happen orby?
he probs put it in the wrong place
hello!
can i ask plugin questions here?
if so,
i tried to create a plugin in intellij and build it but i got the following error:
symbol: class JavaPlugin
location: package org.bukkit.plugin.java```
Did you include spigot as a dependency?
It's strongly recommended to compute data with database Asynchronously, not on the main server thread
Well there are bunch of tuts about that. I advise you to check about CompletableFuture at some points.
What's your database ?
Mongo?
ye
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>```
is this not that?
i used the minecraft development plugin in intellij
That spigot-api
did you re-sync maven
i believe so
alright
join the gradle gang
You can either use CompletableFuture or Bukkit async tasks
give me a minute to switch to gradle
Honestly Gradle has given me more problems than maven
me too
Also gradle doesnt allow to program/code your own repo system
@summer sapphireyou shuld use the minecraft dev plugin to create projects though
I found a thread related to mongo and async: https://www.spigotmc.org/threads/mongodb-async.48837/ Have a look to find some first doors of exploration
Everything Maven can do Gradle can
despair
the -> horror
It's just about preference in the end
I already answer you what to use...
You can either use CompletableFuture or Bukkit async tasks
what the nameof explosion event
i cannot find on jd
Async isn't simple ^^ But CompletableFuture makes it kind of cool
inst ht i aid?
Can you please translate in english a french can understand ? π
Async is very simple lol
Disclaimer: Once you'll get these, you will always use them π
thats what i did and i got an invalid maven project it seems
Just the 'non simple' part of it, is hitting async catchers or using stuff that cant be used async
gradle built
BUT
im trying to make it into kotlin lmao
Exactly, it seams easy, but can lead to SO MANY FUCKING ISSUES (speaking in knowledge)
I've watched so many videos on lambdas and shit but i never seem to get it
guess the best time to learn is now
if you really only use async for the bare minimum that its needed, it wont be an issue
can anyone here help me set up the project with kotlin?
How can I detect every time armour is put onto an user with all the edge cases like right-clicking it on etc?
check javadocs for events i guess
or maybe like right-click event player inventory slot
so PlayerInteractEvent + InventoryClickEvent
@agile anvil should I use the synchronous driver and CompletableFuture
or get the async mongodb driver
Oh yeah I forgot mongo was strange with it's driver
i successfully built my kotlin plugin on gradle!
thank you very much for your assistance!
I never heard about the async driver, hence I do not really use mongo
for mongo I only run pulling stuff out and putting stuff into the db
would you recommend using a different db for Minecraft plugin
*run async
I want to have a projectile be fired with a set delay between shots and I was wondering what the best way to do that would be.
I thought of scheduling all the tasks for firing the projectiles in a for loop, but didnt wanna have all those tasks flying around.
The other solution ive thought of is to make a task timer and cancel it after a certain amount of runs, I am unsure of how to properly cancel it tho.
the second option for sure is the preferred one
Well choice of dbs depends on so many factors. But at a scale of a minecraft server it doesn't really matters
Take the db you prefer
if i spawn a ender dragon in the overworld using spigot, does it have ai or no?
Hey Guys! I wanna make custom gui. I know how Can I do that But How can I do that with a number that is not a multiple of 9.
https://github.com/MiguelX413/first-plugin/tree/142428cfc09a8bc7ee16b78501ffdd0f068a8228
https://gitlab.com/MiguelX413/first-plugin/-/tree/142428cfc09a8bc7ee16b78501ffdd0f068a8228/
can i get some feedback, like if theres any beginner's mistakes which i should avoid?
it would be much appreciated
I've encountered too many things like this on some servers
They're probably using custom resource packs
as a base project, whether there any setup problems etc

lol
null safety appeals to me tbh
if you like kotlin I'd suggest at least also using the kotlin gradle DSL
Isn't that like a dispenser inv?
how would i do that
im very new to JVM languages
thx
Yeah Its like but How Can I use that on my code?
declaration: package: org.bukkit, class: Bukkit
it seems that the plugin.yml doesnt get bundled into my jars
if i do it manually the jar built just fine though
devs whats the neatest and nicest way to do the following: you have two inputs, location, int offset, and the function creates a new location but being randomly offset in each direction based on the offset inputed
so you have a location and an offset and want to pick a random location on the circle with radius offset around that location ?
gradle isnt including https://github.com/MiguelX413/first-plugin/blob/142428cfc09a8bc7ee16b78501ffdd0f068a8228/src/main/resources/plugin.yml in the jar it outputs
Just use the location and add a random offset...
Thats like 1 + 1 = 2 type of complexity
public Location withOffset(Location location, int offset) {
Random random = ThreadLocalRandom.current();
Location result = location.clone();
result.add(random.nextInt(-offset, offset), random.nextInt(-offset, offset), random.nextInt(-offset, offset));
return result;
}
?jd-bc
Thats basically what i had written π₯΄, nvm my question i just always envision something out of bounds of possibilities
Although this migh be a bit risky because it also has a random y offset
What is the purpose of the first method
I have no fucking idea
Its action have no correlation to its name
ok so
i want to create a document with playername on my db
when a playerjoins
its counting documents to check if the document with the playername already exists
so it doesnt create two files for the same person
Thats not how you do any of this
XD
Also the mongo collection should not be in the same class as your listener
You need a separate class that only handles your mongodb playe stuff
Let me write you an example
Dont use this pls.
Hey guys ! I'm looking to know where to find out the names of the player's statistics on a server :
} else if (statValue == 2) {
if (statType != null) {
if (statType.name().equalsIgnoreCase("SHEEP")) {
p.sendMessage("sheep test");
}
}
}```
Here, when the player kills 2 sheeps, it sends the message.
Now I'm trying to get when the player die, tried deaths, death etc... but it won't work, is there a website where I can find that ? Didn't find any, and the values on the world -> stats -> uuid file doesn't work as well π€
(I'm listening to the event PlayerStatisticIncrementEvent)
Yea don't worry about it lmaoo, forgot to remove this line when testing
Your data class
@Data
public class PlayerData {
public static PlayerData fromDocument(Document document) {
PlayerData playerData = new PlayerData();
playerData.setLastSeenName(document.getString("lastSeenName"));
return playerData;
}
private String lastSeenName;
public Document toDocument() {
Document document = new Document();
document.put("lastSeenName", lastSeenName);
return document;
}
}
The MongoDB class for this data class:
public class PlayerMongoPersistence {
// TODO: Init this collection in your constructor
private MongoCollection<Document> playerCollection;
public void savePlayerData(UUID playerId, PlayerData playerData) {
Document document = playerData.toDocument();
UpdateOptions options = new UpdateOptions().upsert(true);
playerCollection.updateOne(Filters.eq(playerId), document, options);
}
public CompletableFuture<Void> savePlayerDataAsync(UUID playerId, PlayerData playerData) {
return CompletableFuture.runAsync(() -> this.savePlayerData(playerId, playerData));
}
public PlayerData loadPlayerData(UUID playerId) {
Document document = playerCollection.find(Filters.eq(playerId)).first();
if(document == null) {
return new PlayerData();
} else {
return PlayerData.fromDocument(document);
}
}
public CompletableFuture<PlayerData> loadPlayerDataAsync(UUID playerId) {
return CompletableFuture.supplyAsync(() -> this.loadPlayerData(playerId));
}
}
monkaS
FileHandler.getConfigurationSection(java.lang.String)" is null
MNS
Its the same
π‘
I'm glad you wrote that up for me
i cant think of a reason why it wouldnt
but i have no idea what any of it does
Can someone point me in the right direction. How do you clear the inventory of a Container when it is in the form of an ItemStack? I tried (Conainer)ItemStack.getInventory().clear(); which didn't work.
Sysout your keys
7smile7
You mean a shulker box for example?
Allr
Yes.
I'm attempting to create a hollow cube of some material, but when using the following code the walls for the x don't appear. I tried copying the code for z, but it didn't change anything.
https://sourceb.in/C8nt3IT5on
Hey, keep getting a Could not pass event PlayerInteractEvent to ChromePlugin v1.0-SNAPSHOT org.bukkit.event.EventException: null with this listener (kotlin):
class InteractListener : Listener {
@EventHandler
fun onPlayerInteract(event : PlayerInteractEvent) {
val block : Block = event.clickedBlock ?: return
if(event.action != Action.RIGHT_CLICK_BLOCK) return
if(block.type == Material.STONE_PRESSURE_PLATE) {
if(block.location.block == Location(block.world, 0.0, 100.0, 0.0).block) {
Bukkit.getServer().broadcastMessage("test")
}
}
}
}```
I'm just trying to send a message if a player right clicks a specific pressure plate in the world.
kotlin spigot π
ok yeah, default spigot plugins with the minecraft-dev plugin in intellij seem to not include the plugin.yml in the output jar
they do for me
the unmodified template i just built did not
I have a Database interface with methods to get stuff from database. However, I don't want people to access the database since database data may be outdated. I have a datafinder interface with methods to getdata from database if not loaded or to get it from the cache. Should the implementation of datafinder store cached data?
The Inventory is store in the ItemMeta. Specifically the BlockStateMeta
It represents a whole BlockState. In your case the BlockState is ShulkerBox or more abstract BlockInventoryHolder
try removing everything after the "def javaVersion = 17"
Or should there be a datacache of sorts
Thanks, i will look at that.
that did not do the trick
the build made with the plugin
(quick up if it rings any bell for anyone)
already includes the plugin.yml
like when you go in a server
and you can type your command
it's there
it wont work with https://github.com/MiguelX413/first-plugin/blob/142428cfc09a8bc7ee16b78501ffdd0f068a8228/build.gradle or the default
the problem is that it does not
i manually added the plugin.yml into the resulting jar then it ran fine though
so everything else seems to be building fine
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.7.0'
}
group = 'me.miguelcr'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
def targetJavaVersion = 17
@summer sapphire try this
I'm including lombok in my maven dependency and it is also installed as a plugin. I'm using intellij idea. For some reason when I try to import it, it won't resolve.
avoid maven like fire
both https://paste.md-5.net/aboyojemed.rb and https://paste.md-5.net/ugipoyalav.rb had the same issue
gradle is life
thx ill give it a try
bro
what are you even doing
anyway
@lost matrix how do I understand any of this
I'm lost
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
it still didnt
so i just found this.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/ComplexEntityPart.html
Are you telling me i can make parts of the ender dragon invisible, considering it extends entity, or is it not possible since its just an interface?
bruh why cant i send pictures or literally anything
!verify
Im not 100% sure what you are saying but caching should be done independently from database access.
Usage: !verify <forums username>
java: package lombok does not exist
when trying to build the project.
on it
try to remove the imports then reimport them with ALT + enter
Remove imports? You mean remove the dependency and add it back?
no remove the imports where you imported them
then try to reimport them with ALT + ENTER
Do you really need MongoDB?
Did you work with Files before? You should be
very familiar with saving data into Files before you tinker with databases.
It imports this "import jdk.nashorn.internal.objects.annotations.Getter;"
it cannot find the lombok
as if i never even added it as the dependency
it didnt include the plugin.yml still
Where is the "reload option"
Reload button or whatever
I pressed on the maven thingy in the right
I only have lifecycles etc
I don't really think thats the case tho, I think something is fcked in my settings.
Or idk.
possibly
It's weird, never had this problem b4.
I mean what could be possibly fcked
how tf i can add a dependency and not import it
what the fuck
okay remove the lombok dependency
then click on one of your @Getter annotation usages
like wherever you've used it
then ALT+ENTER
and there should be "add lombok to classpath"
try that
File -> Invalidate Caches could also help when intellij is weird
worked
Thanks bro
Not getting any compile errors at least
havent tried to build yet.
Gotchu, it's most likely cuz I'm editing a src of another old plugin
And its on my desktop
The src folder
project folder*
Do you want me to add comments?
And i didnt copy paste the .idea folder
I kept it.
So the original plugin had a different one
just remembered.
security vulnerabilities be like
hmmmmmmmmmmmmm
I think i'm getting the gist of it slowly
wait
oh yeah
if i have a method like the saveplayerdata for example
i just create completablefuture of its type with the same params and return runAsync
to make it async
honestly that looks easier than i thought
what i dont understand is
how do i get PlayerData
from the event
Yeah. You just create a method
public T doSomethingSync() {
}
And to "make it" async you just wrap it
public CompletableFuture<T> doSomethingAsync() {
CompletableFuture.supplyAsync(() -> doSomethingSync());
}
public void onPlayerJoin(PlayerJoinEvent event) {
String playerName = event.getPlayer().getName();
event.setJoinMessage(ChatColor.GREEN + playerName + " has joined the server!");
PlayerMongoPersistence playerMongoPersistence = new PlayerMongoPersistence(collection);
playerMongoPersistence.savePlayerData(event.getPlayer().getUniqueId(), );
}```
so i have this
but there i dont know how to get the PlayerData
what is strategy?
let me show u the interfaces i have thus far
public interface AltDatabase {
void connect();
void close();
void initialize();
AltPlayer getAltPlayerFromUUID(UUID uuid);
AltPlayer getOrCreateAltPlayer(UUID uuid, String name);
AltPlayer getAltPlayerFromName(String name);
Set<AltPlayer> getPlayersFromIP(String ip);
void insertIPData(PlayerIP playerIP);
}
public interface AltFinder {
/**
* Gets the alts of a player.
*
* @param ip The IP of the player.
* @return A future of a set of alts on a thread suitable based on SingleThreadExecutor.
*/
CompletableFuture<Set<AltPlayer>> getAlts(String ip);
/**
*
* @param altPlayer The alt player to get alts for.
* @return A future of a set of alts on a thread suitable based on SingleThreadExecutor.
*/
CompletableFuture<Set<AltPlayer>> getAlts(AltPlayer altPlayer);
/**
* Gets the alts of a player.
*
* @param name The name of the player.
* @return A future of an alt on a thread suitable based on SingleThreadExecutor.
*/
CompletableFuture<AltPlayer> getAltPlayer(String name);
/**
* Gets the alt player of a player.
*
* @param uuid The UUID of the player.
* @return A future of an alt on a thread suitable based on SingleThreadExecutor.
*/
CompletableFuture<AltPlayer> getAltPlayer(UUID uuid);
}
can someone else try to build my project too?
You would not use the PlayerMongoPersistence class like that.
You still need a class to store you player data in while the Player is online.
The data has a scope.
Player joins -> load data from mongodb into map
Player quits -> save data from map into mongodb
@RequiredArgsConstructor
public class PlayerDataManager {
private final Map<UUID, PlayerData> playerDataMap = new ConcurrentHashMap<>();
private final PlayerPersistenceHandler playerPersistenceHandler;
public void loadPlayerData(UUID playerId) {
PlayerData loadedData = playerPersistenceHandler.loadDataAsync(playerId).join();
playerDataMap.put(playerId, loadedData);
}
public void unloadPlayerData(UUID playerId) {
PlayerData liveData = playerDataMap.remove(playerId);
if (liveData == null) {
return;
}
playerPersistenceHandler.saveDataAsync(playerId, liveData);
}
public PlayerData getPlayerData(UUID playerId) {
return playerDataMap.get(playerId);
}
}
despair
should an implementation of this cache data or should i have a seprate class for cached data and the AltFinder class just figures whether stuff should be gotten from cache / db etc?
so what I was trying to do is just simple when a player joins for the first time
Yeah, cache outside of that
oki ty
add his name into a file on db
Eh, no, you can cache in the AltFinder. My bad
Yeah that's fine. I misread your code
this is getting too complex for my brain
altfinder uses altdatabase since i dont want altdatabase to be accesible hence the use of another class
Try mastering files before you go for DBs.
Yeah, no that makes sense. You can cache in the AltFinder implementation
cool ty π
i deleted it and cloned it and it didnt help
you know what
i might just be building this wrong
ok i think its working rn
./gradlew jar``` did something good
I only wanted to write player name to db on join
anyway i guess tomorrow I'll pull it together somehow
ty for the files though
I'll understand it eventually when i read it over and over
and with clear mind
java.lang.LinkageError: loading constraint violation when resolving method "com/mongodb/MongoClient.getDefaultCodecRegistry()Lorg/bson/codecs/configuration/CodecRegistry;" : loader "org/bukkit/plugin/java/PluginClassLoader@f1d354c5" of class "dev/nasgar/net/manager/StorageManager" and loader "java/net/URLClassLoader@4a177471" of class "com/mongodb/MongoClient" have different types for the method signature
its caused because im using spigot library loader?
hi im new to spigot and i got a question regarding the event "event.GetAction". I want to code something that is similar to an Ignition of a lightsaber. If you hold shift and rightclick then it should ignite. I was trying to find something online and i found the event "event.GetAction" but it wont work, does anyone know why?
for some reason my horses can't go into love mode when being fed breeding items
only when my plugin is loaded
I've tried disabling every PlayerInteractEntity listener
still the same issue
in fact i just disabled all listeners
relocate your driver
Uhh aren't ur horses custom?
yeah but i havent overriden any breeding features
What did you change about them
So you have changed breeding 
how they figure out who to Fuck id reckon

What'd you change in that class
the right clicking to enter love mode never worked in the first place
well right now its just a direct copy of the default breeding goal
its still a work in progress
If you replace yours with the default one and change Horse.class to AbstractHorse.class does it work?

Do you even get the hearts/does it consume the food
If it doesn't even consume the food then I imagine there's some event cancelling it
it consumes the food, but no hearts
ive already tried removing all listeners
Maybe your horses are aromantic then
Asexual horses π³
Do any other mobs work for breeding
yes
the event definitely isn't being cancelled...
@EventHandler(priority = EventPriority.MONITOR)
public void eee(PlayerInteractEntityEvent event) {
System.out.println(event.isCancelled());
}
false
false
false
false
bruh
it turns out one of my listeners is causing issues
idk what it is yet
but i did not know that you can't breed untamed horses
https://github.com/MiguelX413/first-plugin/commit/0cbbe2a4baa026c03a14b74e56c09e39b57fe00e
can i have a rundown of what the stuff below def targetJavaVersion = 17 did ?
Can someone help me transfer a Player variable from one class to another. I've tried so much but nothing seems to work!
Uh oh. I feel the urge to execute a certain, infamous command...
Show us what you got so far
^

// Your code goes here
that is tiny
hold on
private PunishGuiListener guiListener = new PunishGuiListener();
guiListener.recieveTarget(target);
``` Other class
Player target2 = null;
public void recieveTarget(Player target) {
target2 = target;
}
``` Class2
if what I did makes no sense don't bully me
The naming alone...
Thats not enough code
alright
well
i can't really show more because i deleted it last night
if you want I can explain what i'm trying to do
@lost matrix do you think weak references would be a preferable option over storing UUIDs in classes, like shown here (storing player)
I have a /punish command with an argument for the player you want to punish. I'm trying to get that player into a gui click listener in another class
and idk how to
public boolean isRelevant() {
return this.playerRef.get() != null;
}
Im not a huge fan of weak references. They are pretty cool but also have a lot of implications that are not
instantly apparent when reading the code.
i dont think it would make a huge difference, maybe just a small amount of unneeded complexity
Create a data manager class. It holds player data and you can pass an instance of it to your commands and listeners
Its def. viable.
okay...
but the player data is being created when the command is run, so how would I put that into a data manager
The data manager is created once when the server starts. And after that no other instance of that class is created.
This makes the class a singleton.
i may have accidently made two male horses breed

Tha fk are all those colors?
I'm not really sure what to do here
If you found a Block then you need to return SUCCESS
yeah but like- i can't really find where the algorithm finds the block
What are you doing StepResult π³
if (desiredBlock.test(block)) {
found.add(block); // <- Here
}
π€¦ββοΈ
oh
and I'm assuming found contains all the blocks that are navigable to?
The whole algorithm is still a bit clunky. Ill change some stuff tomorrow.
Yes. But you only want the nearest so all of this needs to be trimmed down.
Hi there, I am running the following code:
Object handle = player.getClass().getMethod("getHandle").invoke(player);
Object connection = handle.getClass().getDeclaredField("playerConnection").get(handle);
But I am getting a NoSuchFieldException for the second line. After researching, I found out that the field name "playerConnection" is in reality the de-obfuscated one, and I need to find the obfuscated one. How do I do this?
I figure both of these may be of interest to you
why the tests?
Should ask what it is you're trying to do with packets first before shoving you on your way. There may be API for what you're doing
but I can't find the "playerConnection" in the NMS. it's coming from the Spigot libraries, not NMS
you can search for it using different formats
oh check the Craft version of whatever your doing
and don't use reflection for that lol
just import the Craft classes
what [is it] you're trying to do with packets?
must dodge question must continue the grind that is the sigma mindset
There are a lot of things people try to do with packets that have had API for like... ever. And there are newer API additions that people just don't know about. Like the client-sided world borders I mentioned earlier today that were added in 1.18.2
I am trying to open a sign GUI
The world border thing is amazing
dayummmmm who woulda guessed
but i dont want the sign to be placed
It must be a pain in the ass to maintain an API this big with mojang changing their code constantly
this might sound stupid but i cant find the CraftBukkit classes
its packaged with teh server code from the remapped jar
What packet do you usually send to open a sign window? (I could look myself but I can't be bothered atm lol)
CraftBukkit can be found here btw https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/
your just using the hacky reflection work around for running build tools remapped and importing it via maven / gradle
look I am sorry but I don't get it
I don't know why I can't access the craftbukkit classes
I imported spigot from gradle
did you run buildtools?
i haven't used gradle but in maven, you need to change spigot-api to spigot
i'm not sure how it works with gradle
in either case you need to run buildtools
Hello. According to Aikar Timings this part of my plugin is generating a lot of lag, does grabbing this enum use a lot of performance? https://gyazo.com/7af4b974543f76c2404391c3a2f2c101
?paste
https://paste.md-5.net/obuzexiyiv.java here are some of the methods used
can i see getStatCluster?
i'll just ask
how does ur plugin store data?
one sec
categories is an enum, which just specifies the category for the cluter
since its a map, this should be the fastest way to grab it right?
String[] lines = new String[] { "What's your name?", null, "^^^^^^^", null };
player.openSign(lines, result -> {
player.sendMessage(result[1] + " is a cool name.");
});```
This make sense?
so I'm creating a custom persistent data type
where the primitive is PersistentDataContainer
Ideally I'd use a CompletableFuture instead, but I'm not sure that's an option because I need to return a boolean for whether or not it succeeded
Can u paste the timings?
PersistentDataContainer is an interface
Plugin name is custom crafting!
?
Does your server store data?
Plugin sore data*
Not in a map
I mean in files or a db
Etc
the player profiles are cached from mongo and stored in a map
no config
each individual challenge however is stored in an enum, with each requirement and other info
U should see how long the code u think is causing lag takes to run using system.currenttimeinmillis
If u can, try to run it 1000times
Then divide by 1000 to get the avg runtime for a method
Idk what the trylevelupmethod does
bump
Is there a way to see if a mob is spawned by a specific plugin?
no
Anyone know what sound this is?
Possibly through the plugins api
But other than that I don't think so
BLOCK_NOTE_BLOCK_PLING
I'm online all the time I'm just usually busy during the day lol
what would be the best way to create a jetpack's functionality?
Playerinteractevent, check if the player is interacting with a jetpack
add to the player's Y velocity
or keep it stable
bump
You don;t create a new PersistentDataContainer
PersistentDataContainer persistentDataContainer = context.newPersistentDataContainer();
Are you sure? Sounds way deeper when I tried it. What pitch?
it sounds like at least 2 notes at once
Probably much lower than default
could just be my ears
But it's just pling afaict
change the pitch
I know but I'm using chatcontrolred thats why I asked in #help-server for further help xD
It doesn't seem to change when I change it
if I wanted to create a custom persistent data type generic for enums, would this be proper?
public class PersistentDataType_ENUM implements PersistentDataType<String, Enum<?>> {
@Override
public Class<String> getPrimitiveType() {
return String.class;
}
@Override
@SuppressWarnings("unchecked")
public Class<Enum<?>> getComplexType() {
return (Class<Enum<?>>) new TypeToken<Enum<?>>(){}.getRawType();
}
for example I want to use it by doing new PersistentDataType_ENUM<Trait>() where Trait is an enum
I'm trying to convert a Forge ItemStack to a Spigot one. As in, serialize a Forge ItemStack, and deserialize in Spigot. Anyone know how to bridge the gap?
Which version?
1.19
Suppose it depends on the format. https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/ItemFactory.html#createItemStack(java.lang.String) lets you parse it in the format of a give command but I know item serialization doesn't result in that same format
Else you may have to resort to some server internals
I was thinking of trying something like that. Fantastic that there's already a perfect method for it. Thank you. :)
If that doesn't work, server internal method you may want is net.minecraft.world.item.ItemStack.of(NBTTagCompound)
Then wrapping that in CraftItemStack.asCraftMirror()
π
what the hell is this? https://spigotnc.org
One of those fun leaking websites with zero relevance
this just got me for a second before I realised it's not the original site
can i get a code review on my enum persistent data type
I'm not sure what I'm doing for getComplexType()
Yeah, would avoid putting any credentials into that website at all costs
hell yea
Should be able to just return enumClass; there, okay
u cant
the player object is always given to you
u never call the constructor
the server creates a craft player object
which is casted to player and thats given to you
im such a noob
good morning everyone π
hopes that choco is still online
Can someone explain to me how to setup the pom and module structure so that I can use the maven-assembly-plugin to create a combined .jar out of my multi module project?
I already have a working multi module setup that uses a dist module that has all my other modules as dependency but I feel like that's not the best solution and that the assembly plugin is what I'm actually looking for
how to add a dependency in pom.xml by a jar file?
You mean you want to add a local jar file to your project as a maven dependency?
yes
but I don't know their group id, artifac id etc.
is one downloaded from spigotmc.org
Well it's just a glorified zip file you can open it
TL;DR: You install it to your local repo and you can make up a group id, artifact id, etc. just check the link I just sent
or you can look at it's juicy contents and add it that way 
Does anyone know a good script parsing lib that can evaluate conditions within a string?
nashorn
Anyone knows why I'm getting this ultimateAdvancementAPI.exceptions.APINotInstantiatedException: null
Doing anything as suggested here https://github.com/frengor/UltimateAdvancementAPI/wiki/Shadeable-Version
was that the name? I think it was
yeah nashorn is basically a javascript engine for java https://docs.oracle.com/javase/10/nashorn/introduction.htm#JSNUG136
you probably shaded that plugin into yours
?paste your pom.xml
oh wait, they want you to shade it? that's very... uncommon
π
show your main class' code pls
thanks you
ok please also send the full stacktrace you get
what's Main line 92?
This got removed in Java 14 afaik
huh very weird. then I guess you gotta open an issue on their github. It seems very weird anyway that you have to create a new "AdvancementMain". What even is this?
I have no idea
yeah you have to just shade it yourself
did you also put the plugin version on your server by chance?
My guess is you are using the wrong UltimateAdvancementAPI
If you shade it AND have the plugin you will have two of this
turns out its not including some necessary things
are you using maven? what "necessary" things doesnt it include?
gradle, and kotlin stuff
then I can't help lol
do you mean that it doesnt include the kotlin lib?
yes
gradle is pretty stupid and cannot "shade" stuff on its own. IIRC you need the shadow plugin
i see!
there however is no official one, everyone seems to be using a shadow plugin by some random github dude
or use java and not kotlin
alternatively, there are plugins on spigot that do nothing except to provide the kotlin stdlib
for example this https://www.spigotmc.org/resources/kotlin-stdlib.80808/
lmfao
programming moment
https://stackoverflow.com/questions/56434280/how-to-use-kotlin-with-a-bukkit-spigot-plugin-and-gradle
something like this?
yeah well in maven it's way easier, you can just use the official maven-shade-plugin there π
yep, exactly
you could probably add kotlin to the libraries section of your plugin.yml
that'd work too, but of course only in 1.16.5+
im wokring with 1.18!
oh yeah then you can add the following to your plugin.yml:
libraries:
- org.jetbrains.kotlin:kotlin-stdlib:<kotlinVersion>
but no idea if that actually works lol
is checking player PDC a 'lightweight' check?
yes, it's in memory anyway
Depends what you mean by lightweight? In the grand scheme of things yes.
'PlayerMoveEvent - only use lightweight checks here'
Just incase
btw
A dude had the same problem and posted his gradle file
It's more what you do with the data then checking the PDC
it means, early exit from the event as soon as possible if you really don;t need it
the PDC of a loaded entity is just a Map<String,Tag>
well yes. The PDC's supposed to contain a boolean if it needs to run
./gradlew jar``` does not do the trick
so if not PDC.get(BOOLEAN) return
ie, if you are checking for when a player enters a certain area, you only need to test when they actually change the Block location, so you text x,y,z for a full block change and exit if not
that's no problem at all
What are you intending to do in the PlayerMoveEvent?
you could although of course just cache the boolean yourself. e.g. on join, add the PDC's boolean to a Map<UUID, Boolean>. then the PDC data doesn't have to be unwrapped every time
for shadow use ./gradlew shadowJar
i mean in general
like
a normal spigot java plugin
from the minecraft-dev plugin in intellij
move visual stuff
release version 17 is not supported 
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> error: release version 17 not supported
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 359ms
1 actionable task: 1 executed
as in?
java 17?
As in release version 17 is not supported
java 17?
yes
odd
Have you tried googling it?
what version of the shadow plugin are you using?
gnoogling*
No just my own plugin with it shaded into it
none, this is literally the template, no modifications
you need to use gradle 7.1
Is there a new search engine for me out there that's better than bing?
go to your /gradle/wrapper/gradle-wrapper.properties
its in java
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7.3.3?
its all being weird tbh
try changing it to 7.1
always works for me
well we want java 17
You shouldn't need to downgrade to get things to work
How does 7.1 support it but 7.3 doesn't
maybe 7.3 is for 18 idfk
yeah either 7.3 supports it too, or gradle is very stupid
It should be backwards compat
or thats not the error at all
my IDE is being stupid and using the system java version instead of what the project settings JDK version??????????????
ah
I once had an issue that was fixed by setting the java version gradle uses to 17
that is supposed to happen if you just enter "java" in the "execute anything" tool window
i see
makes sense
your project settings only apply to e.g. when you use intellij to invoke gradle
you should have a gradle tab on the upper right. if you click on "compileJava" there, then it should use your defined jdk π
super easy
it would be funny if github wouldn't be pronounced "git-hub" but rather "gi-thub" like with the "th" as in "thanks" lol
iβm doing that from now on
yup
ok
so
im back where i started
just gotta add shadowing
i think
man
i miss cargo
ya lol
gradle is so much more complicated than maven while adding so little benefits
Oh no here we go again 
i <3 cargo
[dependencies]
ivm-common = { path = "../ivm-common" }
constant_pool_macro = { git = "https://github.com/Redempt/constant_pool" }
ive spent
so muchtime
just
setting up
the build system
ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
kick one of your friends and say "mb it was a misclick" as the reason
lmao
reminds me of this one the office episode
"i didnt get both of your messages"
t
u
'remove(); - mark the entity for removal'
How fast does that remove stuff?
Probably next tick
is there a non nms way to find out which dragon part a ComplexEntityPart is? GetType returns UNKNOWN, getName returns EnderDragon, and getCustomName returns null, for every part in the set
Seems like a no from looking at the javadocs
janky workaround it is
i grab the bounding box of each part on spawn tick, and make a list of parts and spawn locations. comparing the bounding box with the spawn location should give me the parts
no proper variable names i have to use a hash map
but thats a small price to pay for not using nms
Create an enum and map it to the numbers
oh that might just work
i know what you mean but i dont know how
my experience with enums consist of getType==Material.TYPE
Call it EnderDragonPartType
And let it have an int in tje constructor
Which is the partid
and store a map of parts to part type ofc
Instead of mapping part to int
i've found a different way, but it just gives me more questions
mainly
how the fuck does boundingbox calculate volume
LBW
x*y*z
Length x breadth x height
welllllll no
Wdym?
yes because 1x1x1 is 1
Well yeah
so apparantly i never realized how big the dragon is lol
π
in that case...
head:27
body:75
wings:32
tailsegment:8```
need to figure out how to separate the wings but other than that
wait
non initialized variables arent null?
why?
Ohhh
Just initialize as null
That haooens sometimes and I'm not smart enf to know why
Or just replace second winga woth nl
Null
canI set player head skin to higher resolution than 16x16?
okay it gets more confusing. wingB says it has to be initialized, too? Why? The first action i take with it is initializing it
no
default is all you get
unless you use resource packs
uuuuuuuuuuuuurgh
so
APPARANTLY
a ? b : c is not the same goddamm thing as if(a){b;}else{c;}
can ANYONE tell me why
eeeh it should be same ?
huh
its not
how did u test it?
btw does anyone have texture editor that allows editing higher resolution skulls?
that's not how it works
try using ( before and after conditions
you can't replace your if with the ? thing
the three element operator was made specifically for this kind of stuff, for quickly writing checks for which of two values to assign to a variable, or am i completely wrong here
what error does intellij provide u?
yes you're wrong
int myVar = something ? 1 : 2;
// is the same as
int myVar;
if(something) {
myVar = 1;
} else {
myVar = 2;
}
notice that in both cases, it's myVar that is assigned, and not two different vars
ah that makes sense
unexpected type
another common use case is for example sth like this
player.sendMessage("Something has been " + (isEnabled ? "enabled" : "disabled"));
ah i see
different topic why do i need to initialize a variable to null check it
isnt stuff null by default
I guess it depends the type
local variables do not have any default value, unlike fields. Why this is the case, I have no idea lol
weird
