#help-development
1 messages Β· Page 2239 of 1
it doesnt explain much
i made typo, it should actually be deserialize since it turns Map into T
and how would that MapSerializer instance know which constructor to call?
it should of course work with all classes, not only those that I registered somewhere. But anyway, there is other way than what I'm currently doing unless Constructors could be declared in interfaces or abstract classes, which at least they can't as of java 17
public class Question extends MapSerializable {
@Getter private final String question;
@Getter private final Answer answer;
public Question(String question, Answer answer) {
this.question = question;
this.answer = answer;
}
public Question(Map<String,Object> map) {
this.question = YamlUtils.getString(map, "question");
this.answer = new Answer(YamlUtils.getStringList(map, "answers"));
}
@Override
public Map<String, Object> serialize() {
return new MapSerializable.Builder().put("question",question).put("answers",answer.getCorrectAnswers()).serialize();
}
}
For example this. If I remove the Map constructor, it still compiles fine, but then throws an exception when trying to deserialize it. And that's what I want to avoid
public class QuestionDeserializer implements MapDeserializer<Question> {
public Question deserialize(Map<String, Object> map) {
return new Question(map.get("question").toString(), new Answer(YamlUtils.getStringList(map, "answers")));
}
}
Spigot does this via reflections
This needs a runtime type context to work
wdym?
I know, me too
If you have a centralised registry for (de)serialisation then it needs to know the type it is deserializing in order to know which MapDeserializer to use.
Anyways i didnt read through the whole convo. Do you guys want to implement marshalling?
I simply want this to work without reflection. I want to declare that every MapSerializable has a constructor that takes a Map
https://paste.md-5.net/wemonitiji.java
They do
yep, of course, it's impossible to deserialize a yaml/json or anything else without knowing the type of the object you are trying to deserialize
at least not displaying
are you setting back the itemmeta to the itemstack?
sec lemme give u the code
its a debug mess but its working
public static void breakMobSpawner(BlockBreakEvent event)
{
Block block = event.getBlock();
Player player = event.getPlayer();
if (block != null && player != null)
{
if (block.getType() == Material.SPAWNER && player.getGameMode() != GameMode.SURVIVAL)
{
Bukkit.broadcastMessage("TEST");
ItemWrapper wrapper = new ItemWrapper(new ItemStack(Material.SPAWNER, 1), null);
wrapper.setItemString("test", "LEMAO");
ItemMeta meta = wrapper.getItemStack().getItemMeta();
meta.setDisplayName("LUL");
wrapper.getItemStack().setItemMeta(meta);
//wrapper.setItemBytes("block_data", NonReflectables.serializeBukkitObjectToByteArray(block.getBlockData().getAsString()));
block.getWorld().dropItemNaturally(block.getLocation(), wrapper.getItemStack());
}
}
}
result is 1 NBT flag
the name
setItemString is a wrapper method to set PDC values
its working in alot of my other methods
Well then your wrapper doesnt work
it does in alot of other methods
just not here?
sec
public boolean setItemString(String key, String value)
{
if (this.is != null)
{
if (this.is.hasItemMeta())
{
ItemMeta meta = this.is.getItemMeta();
meta.getPersistentDataContainer().set(new NamespacedKey(main.getPlugin(main.class), key), PersistentDataType.STRING, value);
this.is.setItemMeta(meta);
return true;
}
}
return false;
}
public String getItemString(String key)
{
if (this.is != null)
{
if (this.is.hasItemMeta())
{
PersistentDataContainer pdc = this.is.getItemMeta().getPersistentDataContainer();
NamespacedKey nKey = new NamespacedKey(main.getPlugin(main.class), key);
if (pdc.has(nKey, PersistentDataType.STRING))
{
return pdc.get(nKey, PersistentDataType.STRING);
}
}
}
return "";
}
If you wrap something, make sure to add all the methods you need so you dont have garbage like this where you have to constantly unwrap the wrapped object
^ code is there
if (this.is.hasItemMeta())
This might be the problem
but a newly instantiated is usually has itemmeta
well
ill test it for its return value sec
boolean b = wrapper.setItemString("test", "LEMAO");
Bukkit.broadcastMessage(((b) ? "TRUE" : "FALSE"));
the code
[12:13:05] [Server thread/INFO]: FALSE
```well rip
how can that even happen
so my fallback condition is the issue, question stands how can an IS even NOT have itemmeta
How to check if a player is looking at a door?
i am not sure, but looking at type ItemStack's constructor
Preconditions.checkArgument(type != null, "Material cannot be null");
this.type = type;
this.amount = amount;
if (damage != 0) {
setDurability(damage);
}
if (data != null) {
createData(data);
}
i would assume that ItemMeta is null at the start, and when u call getitemMeta first time
return this.meta == null ? Bukkit.getItemFactory().getItemMeta(this.type) : this.meta.clone();
it creates new via Bukkit.getItemFactory()
yea ive just browsed trough the docs
seems if its null getItemMeta instantiates a new container
as such i should only check if the itemstack itself is null
as getItemMeta cant throw null errors
you should probably also check if getItemMeta() is null since getItemFactory().getItemMeta() is nullable
so change hasItemMeta to
like this
if (is != null && is.getItemMeta() != null)
yea
right ty so ive just used the implementation incorrectly xD
can you make a case insensitive query on mongo?
it does work now tho
ive changed my implementation to check for getItemMeta being null
hasItemMeta returns false
getItemMeta returns an itemmeta
oh i see
i read it wrong, item meta checks if the this.meta is not null
public boolean setItemString(String key, String value)
{
if (this.is != null)
{
if (this.is.getItemMeta() != null)
{
ItemMeta meta = this.is.getItemMeta();
meta.getPersistentDataContainer().set(new NamespacedKey(main.getPlugin(main.class), key), PersistentDataType.STRING, value);
this.is.setItemMeta(meta);
return true;
}
}
return false;
}
public String getItemString(String key)
{
if (this.is != null)
{
if (this.is.getItemMeta() != null)
{
PersistentDataContainer pdc = this.is.getItemMeta().getPersistentDataContainer();
NamespacedKey nKey = new NamespacedKey(main.getPlugin(main.class), key);
if (pdc.has(nKey, PersistentDataType.STRING))
{
return pdc.get(nKey, PersistentDataType.STRING);
}
}
}
return "";
}
this
yeah this is correct
and works now
teye
π
but it does make sense that i didnt notice it before because the plugins main purpose is to create new custom items and add flags to it. so the item meta was never null before
I have tried things like
SELECT (SELECT *, FIND_IN_SET(rating, (SELECT GROUP_CONCAT(DISTINCT rating ORDER BY rating DESC) FROM {table} WHERE ranked = 1)) FROM {table} WHERE ranked = 1) AS r
(SELECT *, FIND_IN_SET(previous_season_rating, (SELECT GROUP_CONCAT(DISTINCT previous_season_rating ORDER BY previous_season_rating DESC) FROM {table} WHERE previous_season_ranked = 1)) FROM {table} WHERE previous_season_ranked = 1) AS previous_season_rank
But that gives an syntax error
the mob spawner thing is just a minor subroutine im adding in because the framework already exists
umm... can i question?
What is the api in the red frame in this picture?
i search "spigot screen api",but i coudlne find it.
Those are mods
spigot has nothing to do with the frontend
oh reallyπ
that's blc
can you make a case insensitive query on mongo?
that's 12 years old and not by using the java driver
Hey, i'm trying to send packets with sendPacketNearby but this function doesn't exist and I don't know how to access to this, i'm using protocolLib in 1.18.1
maybe this could help https://www.mongodb.com/community/forums/t/case-insensitive-query-with-java-driver/1297?
are you not able to use ProtocolLib?
no i have protocolLib
and(eq("familyId", item.familyId), eq("userName", item.userName)) i don't really understand how this is supposed to be java code
thanks for your answer. i found it
https://client.badlion.net/
??
afaik there is no such method
there's just the normal sendpacket method under PlayerConnection
is the protocollib javadoc broken? it says "js is disabled in your browser" but its enabled and it says it in all browsers https://ci.dmulloy2.net/job/ProtocolLib/javadoc/
class tree
It's not. That looks like Scala (which like Kotlin runs on the JVM)
looks fine to me
it opens for me
Broken for me
oh ok
yes it is
i get the same message on my ungoogled-chromium browser
but everything works apart of search
Im trying to make a pickaxe enchant which creates an explosion. This can break a hole which is the same size and can destroy obsidian. How would I do this? I have the base enchant sorted just need to make the effects
does the explosion have to be a sphere?
you can iterate all the blocks in an area and then check the distance between the central block and the iterated block and if it is bigger than a certain number, don't break the block
do i have to do anything extra to remove an enchant from all items in a chest?
right now im going through the chest inventory and removing mending from all items in the chest but the mending isn't actually removing
im updating the tilestate of the chest afterwards, is this why?
nevermind, it is cause the tilestate
Do I have to follow a specific file structure for my plugin to work? Does bukkit, or paper read a plugin in a specific way?
Hey, how can I raycast?
declaration: package: org.bukkit, interface: World
ok, ill do that. Thanks!
this could be helpful
public static List<Block> getBlocksWithin(Location start, Location end) {
List<Block> blocks = new ArrayList<>();
int startX = Math.min(start.getBlockX(), end.getBlockX());
int startY = Math.min(start.getBlockY(), end.getBlockY());
int startZ = Math.min(start.getBlockZ(), end.getBlockZ());
int endX = Math.max(start.getBlockX(), end.getBlockX());
int endY = Math.max(start.getBlockY(), end.getBlockY());
int endZ = Math.max(start.getBlockZ(), end.getBlockZ());
for (int x = startX; x <= endX; x++) {
for (int y = startY; y <= endY; y++) {
for (int z = startZ; z <= endZ; z++) {
Location loc = new Location(start.getWorld(), x, y, z);
blocks.add(loc.getBlock());
}
}
}
return blocks;
}
does anyone by any chance know what exactly is happening if the server logs are full of this
com.mojang.authlib.GameProfile@5c7f092d[id=<null>,name=lLD_Mftz*****,properties={},legacy=false] (/200.2.***.**:58251): Took too long to log in
like its a crash attempt but im not sure about how to migitate it
maybe killing the login if the id is null at some point?
took too long to login sounds like a network issue
i've seen often null ids so im not sure if that's a problem
i dont think so
its some sort of attack
theres 40k of those invalid login attempts
and it crashed at some point
from different accounts?
i dont get why it crashes, shouldnt all the login stuff be on the netty threads?
how long was the span of time where it happened
sync stuff happens too, i'm not an expert of minecraft internals
usernames are random strings
Collection<ServerboundPacketListener<Packet<ServerGamePacketListener>>>
sounds like an attack
yes i figured that much
he he
funni
if the system should exit caused by a crash, should i use System.exit(0) or -1?
not in the context of a plugin anyways
0 is when the code ran successfully
there are different exit codes based on what happened
ah wait i meant 1 then
it gets much worse when you have ? extends x
i had a pretty big generic somewhere
that was pretty much unreadable
yes positive integer numbers as error codes are the best since not all JVM implementations theoretically can support negative numbers
IN THEORY ONLY
oh lol
Map<Map<? extends Map<?>, ? extends Map<?>>, Map<? extends Map<?>, ?>>
arent we?
@Supresswarnings("unchecked") smh
i managed to achieve type safety somehow
generics confuse me at times
i have made a /pay command that lets you steal money from others if you insert negative amounts
nice
always fun
imagine you're in baltop and a guy comes over and robs the shit out of you
/pay kill05 -100000 coins
how tf
how do you store cash
player profiles that are then saved in a database
adding a negative is subtracting
yea that's what happens basically
no shit sherlock
it subtracts a negative amount so it sums
hm
lol
im out
I didn't know they had blobemotes here, pog


Do I have to follow a specific file structure for my plugin to work? Does bukkit, or paper read a plugin in a specific way?
does this look like a good beginning??
you need to have a resources folder if you're wanting to include a config file or smth
and just put your code in your package
very simple
Ight thank you
Quick question, atleast I hope so, is there a way to easily serialize this: {id:"minecraft:cobblestone",Count:1b,Damage:0s} into an Itemstack?
got smth π
i'm looking at kotlin code to get ideas for java code.. i mean...
is it json?
json would be "Count": true
Thing is... it's kinda mojankjson, since it doesnt work correctly
^^
it prints 18 how do i make it print 19?
looks like the right bound of #between is exclusive
So you want it to round up?
it would make sense to print 19 seconds if the cooldown was 20s and only one second passed no?
I would assume something took slightly longer and it's like 18.99 seconds
actually, lets print the millis
18995
i guess thats why
just adding 15 milliseconds now smh π
how do i make a config file
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
A custom one?
just follow the guide
The embedded resource 'config.yml' cannot be found in plugins\resourcepacker-1.0-SNAPSHOT.jar
mhm
ah
saveDefaultConfig() in your onEnable
When using this player.getInventory().getItemInMainHand().getType().name() to get name of item in MainHand it returns the right names whit most of the block. But by the new blocks and items like Amethyst Shard it returns AIR. How can I fix that?
Of my server?
Yes
Maybe not the right versions of the plugin?
Show code
Fair, but just wanted to be sure that I wasnt doing weird things with the code
I'm codin 1.12 What version should be vault?
?paste
oh Actually I didnt add on plugin.yml
yeah
make a JsonItem class with the fields id count and damage
then use gson to turn the json into the class
then have it implement ItemForm interface which has a static method
ItemStack toItem(ItemForm itemForm)
It's mojangson not json
that sets the fields from json to an item stack
There is a difference
idk whats mojangson
I depend on my pom.xml its enough?
but im doing what i would do in a normal java project i assume
dunno about these mojang quirks
No. soft-depend in the plugin.yml
I didnt how can I
Json but a little more accepting
softdepend: [Vault]
Guys I solved it was about economy plugin when I download EssentialsX its worked
You also need softdepend: [Vault]
So ur plugin always enables before vault
After **
Anyone know why sometimes I get a "CraftBlockState cannot be cast to Container" here:
Block block = ((Location)serializedMap.get("container")).getBlock();
Container container = (Container)block.getState();
because it's not a container
Check if it is first
this is in a deserialize method, what would I do if it isn't a container? Can I return null in that method?
Mqke sure you specify the api-version in plugin.yml
I'd assume so
what do you need the container for anyway? in the code you sent, you only cast it to container and then not do anything with it
It depends on what you want to happen if it's not a container
sorry, here is the whole method for context:
public static LockedContainer deserialize(Map<String, Object> serializedMap) {
String ownerUUID = (String)serializedMap.get("owner");
OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(ownerUUID));
Block block = ((Location)serializedMap.get("container")).getBlock();
Container container = (Container)block.getState();
UUID uuid = UUID.fromString((String)serializedMap.get("uuid"));
LockedContainer deserialized = new LockedContainer(container, owner, uuid);
return deserialized;
}
well you have to know for yourself whether you're fine with this returning null or not
it is YamlConfiguration.loadConfiguration which runs all the deserialize methods, I just don't know if would be happy with null being returned. I can test it ig
It is
ok cool
Can I make a player say a message with a tooltip?
Using chat components
Hmm (sorry for ping)
Surely there must be a way to abort a deserialization or something?
stupid question
but how does Method#invoke work?
since I have shoot()
and Im getting the method and just doing method.invoke(null)
But it returns null
Chest or barrel
Is shoot static and void?
itβs first argument is the instance
Well maybe you just wanna store the location in lockedcontainer
Or null in case the method is static
its void
and its Overriding from SuperClass
therefore class?
so like
lol.doStuff();
would be getMethod("doStuff").invoke(lol)
Oh well you need to pass what you're invoking the method on
So if u wanna invoke it on a player, you do method.invoke(player)
Which is the same as player.shoot()
Itβs only if the method is static that you pass null to invoke like .invoke(null)
Same goes for Field::get
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
You passed an instance of wrong type
Class<? extends RangedWeapon> wep = getWeaponClass(p.getItemInHand());
public static Class<? extends RangedWeapon> getWeaponClass(ItemStack item){
if(item.getItemMeta()==null)
return null;
ItemMeta meta = item.getItemMeta();
PersistentDataContainer pdc = meta.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(Pirates.plugin,"rangedWeapon");
switch (pdc.get(key,PersistentDataType.STRING)){
case ("SNIPER"):
return Sniper.class;
default: return null;
}
Wait are you using reflection internally of your own plugin
yep π
Why...
Did you not properly expose classes need so your compensating via reflection
its just gonna make ur code more complicated and slower π€¨
Why don't u just cast to rangedweapon and call shoot normally?
I have Super class RangedWeapon and my Weapons are extending it
Yet I have no other idea how to execute method when the class is extending RangedWeapon
Using reflection in your own code makes almost 0% sense a good 90% of the time
If obj instanceof RangedWeapon
Yeah cuz ur providing a class
forgot to cast
U can't cast thwt
Bro what are you on
sleep deprecation
This is a simple instance of call no classes needed
Just regoster each rangedweapon with an instance
Register*
Have a manager class for weapon so u can call weaponManager.register(Weapon)
That class can also give you the weapon for a given itemstack
Bump
Conclure can you maybe have a look? ^^
Interface
I said thag already
public WeaponManager(Pirates plugin) {
this.plugin = plugin;
this.KEY_WEAPON = new NamespacedKey(plugin, "weapon");
}
final Pirates plugin;
public final NamespacedKey KEY_WEAPON;
final HashMap<String, RangedWeapon> weapons = new HashMap<>();
public RangedWeapon getWeapon(ItemStack stack) {
if (!stack.hasItemMeta())
return null;
PersistentDataContainer pdc = meta.getPersistentDataContainer();
return weapons.get(KEY_WEAPON, PersistentDataType.STRING);
}
Bruh tryna steal my suggestion
π I didn't see that
I don't care I'm livid now fuxk yoh Olivo
I'm bouta pull up get ready to square up pal
Bruh I've already had it recently I'm immune we are good to go
You can get it more than once
Ik it's not been long since I've had it thougj
Also how do you know it's the same variant
I don't and I don't care
Hello !
I've created a fly command, and I'm trying to remove fall damages only after the command /fly (when fly is disabled)...
How can I do this ?
I tried 3 things:
- Create a list, then put the player in this list when he does /fly. When he get fall damages, cancel and remove the player from the list.
Problem: The player is still in the list if he wasn't falling, and he will be safe for his next fall. - Remove the player from the list when he hits the ground
Problem: He hits the ground before getting damages, so he will get damages - Use the method Player#setFallDistance() after using the command, but it doesn't work (idk why).
What fall distance did you input ?
java.lang.IllegalStateException: AsyncPlayerChatEvent may only be triggered synchronously.
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:657) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.adventure.ChatProcessor.post(ChatProcessor.java:194) ~[paper-1.18.2.jar:git-Paper-347]
at io.papermc.paper.adventure.ChatProcessor.process(ChatProcessor.java:66) ~[paper-1.18.2.jar:git-Paper-347]
at net.minecraft.server.network.ServerGamePacketListenerImpl.chat(ServerGamePacketListenerImpl.java:2223) ~[?:?] at org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer.chat(CraftPlayer.java:673) ~[paper-1.18.2.jar:git-Paper-347]
at me.wihy.nextdc.MCcmds.item.onChat(item.java:18) ~[NextDC-1.0.0-SNAPSHOT.jar:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor1.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:git-Paper-347]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:669) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.adventure.ChatProcessor.post(ChatProcessor.java:194) ~[paper-1.18.2.jar:git-Paper-347]
at io.papermc.paper.adventure.ChatProcessor.process(ChatProcessor.java:66) ~[paper-1.18.2.jar:git-Paper-347]
at net.minecraft.server.network.ServerGamePacketListenerImpl.chat(ServerGamePacketListenerImpl.java:2223) ~[?:?] at
``` what does this mean
It tells you :)
Try to input a negative value
AsyncPlayerChatEvent may only be triggered sync
It even tells you item.java line 18
(Basically call that chat method sync)
just look at their source code on github π
I tried with -10.0F and not working
Same with -5000.0F and not working :']
Gonna take a look
Well, that's the same thing :']
the decompiled code shows weird stuff sometimes
event.getPlayer().chat(message); what's the problem with this
nvm
^ its gonna go off thread anyway
create a BukkitScheduler with runTaskLater(), once the player hits the ground you remove it from the list
Gonna try
Guys I have a custom ItemStack. I wanna make event with When ItemStack Placed on the ground but I cant cast my custom Item to Block How Can I Do That
falling damage
uh ye
What's wrong ?
im not understanding this
I've created a fly command, and I'm trying to remove fall damages only after the command /fly (when fly is disabled)...
Hey, I have a weird error happening today with Maven and I can't seem to find any fix for it.
Basically, I'm building an API for changing player skins. I've already done this API in the past, but I'm currently rewriting it.
This is the project structure:
The API contains the PacketProvider<T> class for sending the correct packets for the given Bukkit version: https://github.com/itspinger/DisguiseAPI/blob/master/API/src/main/java/net/pinger/disguise/packet/PacketProvider.java
Each module has a class which implements the PacketProvider<Packet> class (1.16.4 for example):
https://github.com/itspinger/DisguiseAPI/blob/master/v1.16.4/src/main/java/net/pinger/disguise/packet/v1_16_4/PacketProviderImpl.java
The plugin module is the module where all modules are combined within the PacketContext implementation
https://github.com/itspinger/DisguiseAPI/blob/master/Plugin/src/main/java/net/pinger/disguise/packet/PacketContextImpl.java
But what happens when I actually try to compile is I get the cannot access net.minecraft.server.v1_14_R1.Packet error when I do a mvn clean install
wow
remove embeds pls
wtf
Well, you do /fly, you can fly you're happy
Then you do /fly while flying and you're falling. I want this fall to deal no damage, and only this one
<link> will remove embeds fyi itspinger
okay
something in my head is saying that whenever you fall when just having set Player#setFlying to false, that you dont get fall damage but that cant be true
Ah, gonna try and tell you
theyre trying to cancel fall damage for only the fall that happens after fly is turned off
i understand ye
Have you actually ran buildtools for all those versions
or just set the fall distance?
No I don't use buildtools
But they build fine in own modules respectively
Like only the Plugin module fails with that message
But you need to run BuildTools to have the nms dependency π
1.8.8, 1.9.4 build fine
Not working ^^'
I'm using a repository π
Oh no
what parameter did yu give it?
It's already built on my machine either way
Well the plugin module lists all those versions up to 14 as a dependency
@Override
public void disableFly(FileConfiguration fileConfiguration, boolean forced) {
Player player = this.getPlayer();
if (player == null) return;
if (!player.getAllowFlight()) return;
player.setFallDistance(-500f);
player.setFlying(false);
player.setAllowFlight(false);
String flyDisabled;
if (forced) flyDisabled = fileConfiguration.getString(Message.FLY_DISABLED.getKey());
else flyDisabled = fileConfiguration.getString(Message.FLY_OFF.getKey());
player.sendMessage(MessageUtils.setColorsMessage(flyDisabled));
}
Yeah
Depending on an illegal distribution of Mojang code is not good
Because someone asked me to put a negative value
Gonna try with 0
maybe put setfalldistance after you disable its flight
Yeah, so you don't have the nms dependency available in your build path
Either whatever repo you're using doesn't serve it, or you don't have any of them locally
both are not working (0 as a value and put setfalldistance after disable its flight)
Found !
I've put a huge negative value in setFallDistance and it's working xd
lol
IDE points me to the line where I add them to the providers set
Like I said, the Plugin module is the one that fails building, the other modules build just fine
public PacketContextImpl() {
// Add default providers here
// this.registeredProviders.add(PacketProviderImpl.class);
}
If I comment out the line and then try to build, it builds fine
So Idk why that happens
Haven't work with maven for a while, but maybe it's because the specific versions have the nms dependency with the provided scope? Maybe that's why the plugin module doesn't have the nms dependencies as transitive dependencies
Without NMS or mixins, is there any reliable direct way to cleanly redirect an end exit portal to a specific destination in the overworld?
We have an indirect workaround, but its 100+ lines, requires a bunch of vector calculations, and is a slight pain to maintain.
No that shouldn't be the problem
Provided means that the compiler shouldn't inject it into the jar
It should already be loaded within the JVM
I've tried googling but it doesn't get me anywhere
If I did use <compile> tag on all of them the .jar file would be huge aswell
More than 70mb probably
Only if you shade it
You can try with the compile tag and see if it works
But looking at the documentation, it says that provided dependencies aren't offered as transitive ones
Yeah but that shouldn't stop it from compiling
I'm not actually using any of the nms classes inside the Plugin module
The <provided> tag should be what they need though.
I'm using wrapper classes
Do you mean the PacketProviderImpl classes? Because they import net.minecraft
I don't get the difference between Location#getY and Location#getBlockY π€
IntelliJ says they can be null, but why ?
(Using it in EntityDamageEvent, to prevent fall damages)
can i get radius from one location to new location?
Radius ? Do you mean distance ?
yes sorry
EndGateway#setExitLocation()
something like Location#distance
That only works for end gateways; not end portals.
thanks
Location#getY() returns the exact Y value. (52.57182)
Location#getBlockY() returns the floored (rounded down) Y value. (52)
how to get the thing where you fall over and turn red and shit the carpet?
There's no more difference so ?
in spigot
??
I mean, that's the difference. Depending on what you need, one returns an int, the other returns a double. So, use that as you need.
Ah, idk sry
Alright thank you π
Yes they import them but I'm not instantiating them anywhere
I'm using .class only to store the classes
Like I'm not directly importing the net.minecraft inside the Plugin module
Then why not remove the dependency in the pom then?
If it's not used anywhere in the actual module, then it can be removed.
Well it's not included in the Plugin module
But it is in the version modules
Because I need it there
Could anyone clone the repo and try to build it
Incase it's only on my machine lol
Btw, what was the rationale for making end portals so aggressive?
How long do PRs take with spigot? Would an end portal fix be within the purview of what one might be able to get merged?
The fact that it takes a load of vector calculations to redirect an end portal seems like an api limitation worth addressing
Can't find whatever net.pinger.disguise:PacketHandler is
Wait let me push the latest
Okay done
How would one check if a block is a tileentity?
check if its state is a TileState
Will do, thx
I mean, you could just cancel the PortalEnterEvent, check the block location, then teleport the player to the new location based on the portal block they entered.
EntityPortalEnterEvent can not be cancelled
What about the EntityPortalEvent?
Not called
Hello I have a listener for the BlockBreakEvent and I cancel the event when the player tries to break a specific block, but the block still breaks anyway, anyone know why?
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if (!manager.isLockedContainer(block)) return;
event.setCancelled(true);
logger.info("cancelled");
...
}
(the log message is sent)
PlayerRespawnEvent is what gets called, and it also can not be cancelled
Weird, because that should get called.
Called when a non-player entity is about to teleport because it is in contact with a portal
Oh
wait
lmao
End exit portals are a special case
there is no cancellable event that gets called, and thus, if the player touches the block, it is impossible to cancel the teleportation.
Sorry, what about the PlayerPortalEvent?
Got the same error as you, it seems like .class ends up initialising the class? Because when I remove the scope for the 1.16 module it compiles successfully
Yeah it does compile but the whole jar gets shaded inside
neither called nor applicable for entities.
And I don't really want that
But it makes no sense why that would happen aswell
Like
I've never had this problem
Hmm, what are you wanting to happen then? Cause there are workarounds that don't involve using vector math. It can be as simple as block detection and teleportation. It just depends on what you want specifically.
nope
PlayerRespawnEvent and EntityPortalEnterEvent trigger before PlayerMoveEvent
You need to catch the blocks surrounding the portal and make them the teleport triggers, which makes it seem unnatural
Our workaround involves using a bunch of normalised vectors to predict the motion of the player or entity.
Using those checks, we determine whether it is likely they will hit a portal.
We then use some more expansive checks to expand the portal block's hitbox by 0.1 blocks, and teleport the player before they can touch it.
If the player is going too fast, we let them touch it, then hijack the respawn event to force them to respawn at a specific location in the overworld.
I'm telling you, there are other/better workarounds.
Have you tried PlayerTeleportEvent#setTo()
Doesn't work for entities, doesn't get called in the first place
End exit portals do not technically teleport the player; they force the player to respawn
not only do they force the player to respawn, they do so the moment the player touches a portal, and before the player technically moves there with PlayerMoveEvent
So I can't quite explain why, but it seems like removing extends PacketProvider<?> from line 14 (so that it's just private final Set<Class<?>> registeredProviders = new HashSet<>();) allows it to compile?
The only way around that is to cancel the respawn event (or the EntityPortalEnterEvent) with nms.
Or, to implement your own detection algorithm slightly out from the block.
Such algorithms are flawed though at maximum velocities though, so hijacking the portal event is required
Can you explain what you are trying to achieve? From what I gather, you are making a teleportation system that uses end portals that works for all entities.
Welp, I should have been more precise... I'm in 1.12.2, TileState doesn't exist yet.
what
I cannot check for TileState
Well, rip
Basically, we have a recursive teleporter able to teleport literally any combination of players and/or entities.
This can be triggered by any "traversable" block set by the player; one such block is an end portal.
Thus, we want to be able to teleport any combination of players and/or entities that hit an end portal.
This is our current workaround; it feels a bit much for what should be a simple task.
https://github.com/stargate-rewritten/Stargate-Bukkit/blob/4fa09c15c20cdebf6dd9e26a56a690be07ff8f75/src/main/java/net/TheDgtl/Stargate/listener/MoveEventListener.java#L92-L202
Basically trying to determine if there is an existing direct solution, or if this is a PR-worthy issue.
The easiest solution would just be if PlayerRespawnEvent or EntityPortalEnterEvent had setCancellable
help please
Hence the prospect of a PR
I don't think those would be accepted though. Player respawning is important for many things. Being able to cancel that event in a plugin could cause the game to break. However, I think this is one of those cases where you would have to listen to multiple events if you wanted this to work as expected. Due to the Teleporation logic for players and entites being split into their respective events. (PlayerTeleportEvent & EntityTeleportEvent)
Players have the TeleportCause enum that you could leverage, but regular entities don't. (Entity teleportation is pretty easy though.)
The problem here though is that it isn't teleportation
When you enter an end exit portal, you do not teleport
therefore, none of the teleportation events get triggered
Hey, I'm trying to follow this https://www.spigotmc.org/threads/1-8-1-13-custom-block-breaking-change-block-hardness.362586/ for a custom block breaking system but this tutorial is outdated (i'm in 1.18.2), I still have follow this tutorial and the system doesn't work properly. Is there a updated tutorial or someone that can help me about that? The principal problems are:
- PlayerAnimationEvent is not called sometimes when it should
- The author of this tutorial forgot to calculate time that should take to broke the block depending on the tool used
- The author of this tutorial forgot to set hardness depending on the block
Neither PlayerTeleportEvent nor EntityTeleportEvent is called.
The actual "Teleportation" is playerRespawnEvent
That's odd. I wonder if the other events get fired later or are tied to other specific use cases. Because they wouldn't exist otherwise.
Let me setup a test server and try some of this stuff out.
cant you just set the goal of playerrespawnevent to where the player currently is instead of cancelling it
PlayerMoveEvent is called after EntityPortalEnterEvent, which itself results in PlayerRespawnEvent.
By allowing EntityPortalEnterEvent to be cancelled, it would fix this whole mess.
As for those other events, the TeleportEvents and PortalEvents occur for all other portals, and thus, exist.
Its just end exit portals that are a special case.
The problem is, it will still result in an uncancellable teleportation to the overworld.
We can hijack where they end up in the overworld, but we can not control their order.
This makes reconstructing complex entities difficult
Also makes it less than seamless if the destination is in a dimension other than the overworld.
For example, try to teleport an experience bottle riding a bat leashed to a boat riding a furnace minecart riding a donkey riding a player to the nether from an end exit portal.
It can be done by hijacking various respawn events and reconstructing everything.
It's just far more complicated than doing it directly, and is very noticeable for the player.
The easier solution is just to prevent the respawn events and do it yourself.
That involves a load of vectors and whatnot, with respawn hijacking as a fallback for high velocity entities.
why not save all passengers into someting, teleport the player, then set the passengers of the player back to whatever that stack was
Ok, just did some testing and the PlayerPortalEvent & EntityPortalEvent are both cancellable.
When I try to enter a normal end portal. The event is cancelled.
When I place a mob in the portal, the event is also cancelled.
iirc theres some special rules for passengers and teleports
please can someone take a look at this and explain what is going wrong
You return before you cancel the event. Instead of returning just cancel the event if the block is locked.
It does in fact solve the issue
But I'm wondering whether I should leave it at that
hmm? that is intended, it should only cancel if it is a locked container
Even doing Class<? extends PacketProvider> works
But I get the raw use of parameter type warning
Yes, but you use the return keyword before you set the event as cancelled.
return stops code execution.
its part of the if claus
Because we can't stop everything from being teleported to the overworld, and can't control the order of the teleportation.
If they are going to the nether, this becomes very messy; it also becomes very noticeable to players, and thus, clunky.
yes, but that return is only ran if the block ISNT a locked container
plus I have already confirmed the code gets past that point
the problem is that even though the event is being cancelled the block still breaks
Then your check isn't doing what it needs to.
If it's getting past a guard clause, then you need to reevaluate what you are checking for.
π€¨
Think about it.
@kind hatch he is saying the block breaks even if he sets the event to cancelled, also, im fairly certain that check does what it's supposed to
I'm not sure it does. Otherwise the event would be cancelled.
Unless you have another plugin on the server that is interfering with yours, then it comes down to that one check.
Did you see my testing with the events?
Sorry, three conversations at once.
Missed that; one min
Just making sure, this is an end exit portal?
No, that is a normal end portal.
i.e. a portal in the end going to the overworld?
Radically different
Portals in the overworld going to the end are easy enough to deal with
Either way, it gets called for every portal I make and try to use.
Have you tried going from the end to the overworld?
That's going to the end though
what about going from the end to the overworld?
i.e. exiting the end
Nether portals != end exit portal.
End portal != end exit portal.
End gateway != end exit portal.
whats the difference between PlayerInteractAtEntityEvent and PlayerInteractEntityEvent?
End gateway != end portal?
Why is end gateway firing if its an end portal?
end gateways are these things
nvm, cant upload screenshots
either way, not something I care about
end exit portals are the things that spawn when you kill the dragon
End Gateway
^ Don't care about those
You mean this?
yes
indeed
I want to redirect one of those
And that's why I need a 100+ line vector workaround
Ok, that helps clear things up. Let me see if I can't find anything about it.
As far as I am concerned, there are six solutions
Ok, already have an idea.
The end has a special property.
Every end portal in The End acts as the end dragon portal.
- Crazy vector workaround (we are doing this) with respawn hijackcing as a fallback for high velocity entities.
- Brick the end exit portal with NMS.
- Brick the end exit portal by screwing with world loading.
- Replace the end exit portal with falling end portal blocks.
- Get a PR to make EntityPortalEnterEvent cancellable
- force a bunch of bounding boxes and detect colisions
Correct; this solution needs to apply for specific end exit portals, i.e. any arbitrary portal placed in the end.
private void dropItem(Location location, int amount) {
for (int temp = amount; temp > 0; temp--) {
ItemStack itemStack = new ItemStack(ore);
if (!stack) {
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName("custom" + dropID++);
itemStack.setItemMeta(itemMeta);
}
Item item = location.getWorld().dropItem(location, itemStack);
item.setVelocity(new Vector(0, 0, 0));
}
}
Can someone explain briefly what this code does
dropItem
with little more detail than that ;-;
@kind hatch I have removed all other plugins, the problem still happens, though may I point out it is only handled incorrectly if the person breaking the block is not the owner of the locked container (as far as I can tell)
Here is the repo, maybe you can take a further look with more context https://github.com/Synthetic-Dev/LockedContainers/blob/main/src/main/java/me/syntheticdev/lockedcontainers/events/BlockListener.java#L47
from what i can tell if you drop an item it drops every item of it separately and possibly renames them depending on if a flag is set
why not use the dropItem method that takes a consumer?
It spawns a number of βoreβs at the provided location in the provided amount and adds a special metadata to prevent stacking, if itβs not meant to stack
oh hey alex... do you know if i can override nms without having to rebuild the server?
Can someone help me?
beyond mixins not much
u mean me?
wdym with override?
i want to change the inner workings of the server to use my method instead of the provided one
it was something in LivingEntity
dont know the exact name atm
This is a piece of code from an open source plugin that someone was calling out bad. I don't understand it myself. But, I was just looking for what would be a good code xD
I hope to understand this as I get more proficient with spigot development
(Or anyone else who can help, you'll have to scroll up to understand the conversation though)
As Lynx said you can load Mixins and make changes. However that might not be ideal if you plan on releasing it as a public plugin
ah that was it. I wanted to override LivingEntity#isDamageSourceBlocked
how do I get players respawn location?
player.getBedSpawnLocation
if that's null?
when do you need the respawn location?
Then they will spawn at a random location near world spawn
I'm teleporting player so it can't be null
to be precise i want to skip line 1434
for safety reasons
why not?
Because you would need to make a custom jar that launches instead of the server jar
There isn't really much you can do apart from not teleport them since they don't have a respawn location
Your jar then needs to launch the server
Basically you need the Mixins to load quite early
@atomic niche I guess I'm getting different results.
Is that going from the end to the overworld?
Yes
It also looks like the EntityPortalEnterEvent gets called first according to the output.
Yes, but EntityPortalEnterEvent can not be cancelled
But it can be leveraged.
You could use it to store information about a player or entity. Then in whatever event you want to use, use that information you stored to make comparisions.
but how does one go about preventing the applicable respawn events?
PlayerMoveEvent's getTo is too late
Neither EntityPortalEnterEvent nor PlayerRespawnEvent can be cancelled
We have all the information we need for the teleport;
The missing information is when to preform the teleport.
To make it as seamless as possible, we want to teleport the player a fraction of a second before they would trigger the respawn events
I think you would actually want to use the RespawnEvent and just set the respawn location using PlayerRespawnEvent#setRespawnLocation()
That way it is seamless.
Probably not
How so?
The thing is,
a: that forces overworld.
b: it's a pain to resync entities when hijacking the respawn
If they check for the proper criteria, it should be fine.
How does it force overworld? That method takes a Location object. In which you can set the world.
ah
nvm, I guess I misremembered something
Anyways, still a pain to resync. For example, several parts of the entity recursion can enter the portal at the same time.
When rebuilding the entity, it needs to be done in a very specific order with very finicky timings, or stuff breaks.
If you have an experience bottle riding a bat leashed to a boat riding a furnace minecart riding a donkey riding a player.
And if the teleportation is not handled with very specific timings, everything will fall apart.
It can be rebuilt, but it gets really confusing and messy
Handling the teleport ourselves, unless absolutely necessary, makes life easier
Why do you need to rebuild the entity? Just use the methods from the events.
EntityPortalEvent#setTo()
Or, Entity#teleport()
Because none of the existing spigot teleport events are able to deal with complex entity stacks
they invariably split apart after one or two deep recursion
and they fail to handle leads
Wdym entity stacks?
again why not stuff all passengers except the main entity into something and the restore it once the main entity teleported
unless a player is a passenger
you should be fine
Because of how MC handles remounting and entity presence.
It's very finicky and requires precise timings.
Reassembling something is a pain, especially with circular components
I don't think even vanilla supports stacked entities going through portals?
how the fuck do you stack entities in a loop
You mean passengers? No
Passengers are not complex entities
It supports players riding entities, but that's it.
Why isnt possible to know the slot on InventoryDragEvent
It had broken my menu api
π‘
Because you are dragging an item. You could be dragging multiple items across multiple slots.
.
1οΈβ£
β¬οΈβ¬οΈ
2οΈβ£β¬
οΈ3οΈβ£
This is circular leashing ^
Because i keep items as Map<Integer, MenuButton>
why not just cancel inventorydragevent if its in your menu
check if it does something weird to items but you shouold be fine otherwise
Thanks matter
Well, you will probably still have to do some things when it comes to entity teleportation, but simplifying the teleportation logic is the first step.
Shadow are you able to take a look at my problem again?
Here is repo and line: https://github.com/Synthetic-Dev/LockedContainers/blob/main/src/main/java/me/syntheticdev/lockedcontainers/events/BlockListener.java#L47
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
If you have an issue just send the issue and the code
Dont ask someone for specific help!
We were already having a convo but I can send the problem again
can i have multiple items in a ItemStack
yea
long story short
but for different items needs a new item stack
itemStack = 1 slot
yeah
and a shulker is a single item just with some extra data that is its contents
Yeah because a banana is no the same as an apple. They are 2 fruits but are totally diff
π
Reading this is a little confusing due to how you name your methods.
Also, your double chest logic in the #isLockedContainer() method might be causing some issues.
What is wrong with that logic? I've tested it and it seems to work
Yeah his methods name are really extrange
You have three methods for checking the same criteria. Named slightly differently or overloaded. Then in your #isLockedContainer() method you have a boolean called is It would help if it was named isLocked That coupled with the boolean using different checks makes this a little more confusing.
Anyways, that method first checks it see if the container is a proper type of container. You then use a different named method to get the same result. Which is then used to check for double chests.
I'm not sure if it is causing your issue, but it is definitely not easy to read.
hey! does someone have any tutorial about using mounts? such as mounting ender pearls, i haven't found anything in google. Thanks π
https://www.spigotmc.org/resources/rideableenderpearl.72042/ This plugin has a GitHub page for it.
okay, thanks!
whats the best way to turn a string from config into a itemstack
Material#valueOf()
what about an array so
NETHERITE_INGOT,
ENCHANTED_GOLDEN_APPLE
]```
and drop both them items
Iterate over your list.
is a string hard coded noticeably less efficient than having a separate text file containing the string if its around 1-2k words?
Not really. Strings are already the worst thing in terms of memory, but if you are grabbing it from a file, it would be the same as hard coding.
The only real difference would be the overhead for the file object. Once that gets gc'ed you are left with the same string.
ah well i was just wondering if pasting strings or eventually json is better done as hardcoded string or as file in src/resources
long strings i mean
i dont make an extra file for a regex string
I mean, if it's a file that's part of your plugin, you will have that file overhead unless you are streaming it.
i would be streaming it to read it in i think
Entity#addPassenger is very finicky for complex entities and requires very specific timings to avoid breaking apart.
Preventing leashes from breaking is also very difficult and requires carefully managing all stages of the teleportation.
Restoring momentum and dealing with legacy entities is also a challenge that requires careful execution.
Ensuring the above occurs seamlessly without desync or other visual problems is a challenge.
It involves a carefully considered DFS algorithm, a load of timing and motion calculations, etc.
It would be extraordinarily difficult to get that algorithm to work within the constrains of respawn events.
We originally tried simply hijacking respawns, but for particularly complex entities, it causes visual problems.
It works, but not in a way that is seamless for players; as such, its our fall-back method and not our solution.
By handling teleportation ourselves without respawn events, we can offer a much better player experience.
Anyways, thank you for help π
i dont exactly recall how i normally do it
getting multiple errors after setting a folder as package
How can you register an event to just call a method?
It's not going to be always the same Classes so I can not use Event Handler annotation
private void update() {
// Some stuff
}
public void updateWith(Class<? extends Event> event) {
// Call update when the event triggers
}
// on enable
public void onEnable() {
// An example
MyClass.updateWith(PlayerDeathEvent.class)
MyClass.updateWith(PlayerLeaveEvent.class)
}
I don't find it too hard to read, also, there is no method that gives the same result?
actually you can. Its possible to register other classes to the plugin as event handlers
JavaPlugin#getResource ??
grabs a file with the path having its origin in the same folder your plugin.yml is
you should always use the event handler annotation and you should always implement Listener.
I can't create event handler for all the possible events that might be passed to the plugin
actually you can
you know you can create multiple events right
I just want to trigger the update...
getting multiple errors after setting a folder as package any help?
Well, do you know which part is giving you issue? What are you expecting to happen and what is actually happening?
whats a way to do a 50/50 chance
what is "the update"
It must be the folder the class is in
random.double > .5
like random number between 0 1 and if its 1 then do something?
Just updates some data in the plugin
Is this okay or will make tps going down?
me.WHAT YOU HIDE.skywars π€¦ββοΈ
yes
Unless players are being constantly damaged, you shouldn't see a TPS drop.
The issue is that event.setCancelled(true); is called in the onBlockBreak method, ok. And then, I have custom handling for breaking the block, line 60 if (lockedContainer == null || !cancelled) { only passes if the person who breaks the block is the owner (I have logged it), but if someone tries to break the block who isn't the owner the block is still broken (it uses the default breaking logic). Which means that the event.setCancelled(true) is not stopping them from breaking the block.
That's the package not skywars π€¦ββοΈ π€¦ββοΈ
Allright i ask because someone told that doing .contains() many times on event can cause tps issue. Thanks
Ehhh, it depends on the context.
so what am I supposed to do
Player damage isn't that taxing.
Your contains lookup may be depending on how big the list is.
2 Words LEARN JAVA π΅βπ«
ok then
.contains() on a list is an O(N) operation
if you want to speed it up you can trade space complexity for time complexity by using a hashset or hashmap
because those use underlying hash tables, .contains() on those are near O(1)
i thought they were O(1)
Ok, even more confusion here. Your method name is #destroyLockedContainer() Implying that if it was true, you would allow the container to be destroyed. Your very first check in that method returns true if the player isn't the owner of that container.
contains on a hash table?
yes
what do you want from me?? π’
well i guess it'd be more accurate to say its O(1) average case
which is bound to happen as soon as your V instances scale up
Clarification :3
ill fix the returns then, hold on. the destroyLockedContainer method use to be used to determine whether to cancel the event or not but then I realised I needed custom block break handling
also i havent touched plugins in a while and im trying to make a basic one rn, what am i supposed to name the groupid and artifact id?
im following the guide from apache maven and i got something in this format:
GroupID:
com.username.plugin-name
ArtifactID:plugin-name
Main Class Name:com.username.pluginname.pluginname.PluginName
this seems horrible, i have to be doing it wrong right
group id is just the reverse of a domain (preferably one you own)
i dont own any domain
Thats the standard
dont u have github or sth
gotcha
If you didn't have one of those, then the format would be me.my-name.my-plugin-name
why using own domains ?
thanks Conclure
you don't put the plugin name in the gorup id tho
I always use: dev.alex.net and i never buy it
tho with that being said
artifact id throws me off sometimes also
some people put their project name + module, for instance spigot-base-api whilst some have just api where the group id is supposed to clarify the project
Is correct this
When i have multiple multi module project i use for parent=dev.alex.net.<project> and for modules=dev.alex.net.<project>.<module-name>
so in ur second example the groupid would be like io.github.username.spigot-base and the artifactid would be api?
Does it solve the issue though?
https://www.spigotmc.org/resources/tnt-tag-minigame-bungeecord-recoding.43672/
I have this plugin. It is requiring NMS 1.18 which isn't included in the src. I tried to take a look at the src to see if I could add it but everything is obfusucated. Anyone know if there are any fixes?
That just means that it needs to be run on a 1.18 server.
Or use PTC lib?
PTC lib? What's that?
PTC lib = prtocol lib
yes well for instance
as far as I understood it
either
com.google.gson:gson
or
com.google:google-gson
gotcha
which is annoying, cause afaik there's no rule which one is wrong
I don't think ProtocolLib is the issue here, otherwise it would be a simple fix.
aight thanks
that or now i recently started doing com.github.retrooper.
Poorgrammer
miment
hi
No no i mean that if you want to create multi platform plugin the best way of doing it is protocol lib?
im using mongodb as my database and im unsure on how to stop the spam after opening the server in the console. any idea how to stop it?
Just... decrease the log level like usual
it's amazing how github copilot is actually useful, and not completely useless as for example tabnine or all those other similar things
Try this
Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
mongoLogger.setLevel(Level.SEVERE);
lul. Maybe i should give it a try
how to cancel a command send event?
listen to the event and cancel it
you should! I tried tabnine and code4me and both were just totally useless. but github copilot is actually amazing
just like you'd cancel any other cancellable event
the event is PlayerCommandSendEvent and event.setCancelled(true) doesn't exists
PreProcess
?jd-s
what do you want to cancel? a player running a command, or the list of available commands being sent to the player?
player running a command
declaration: package: org.bukkit.event.player, class: PlayerCommandPreprocessEvent
I didn't use copilot for a long time so it signed me out and lost all the saved cache of my coding style :/ now it barely works for me
then use the event 7smile mentioned
thx vm
RIP. i only registered a few days ago and it immediately suggested extremely useful things for me
why does this happen?
I store the world like this:
World world = Bukkit.getWorld(player.getWorld().getName());
you cannot store a world in a yaml
you must store the world's name or the world's UUID
but not the actual world instance
didnt it just go paid
i had preview access
idk. maybe it's included in github pro?
nah its not
String world = player.getWorld().getName();
something like this would work?
NOT paying*
oh its free trial
ah yeah then it's free for me because I got unlimited university email addresses
how to sign up now then lol
no idea lol
i think I just installed it in intellij and then it asked me to authorize it in the browser
and then it immediately worked like a charm
ill try it in pycharm in a sec
for real, it's amazing what this thing can do
hmm yeah seems to work again weird
yeah its great
but sometimes it shits the bed alex
i was spectical at first because all the other similar plugins were just utter bullshit
sceptical*
i can't write today
I see you found the perfect balance of rainbow and non rainbow
lmao that's roughly what tabnine and code4me presented me
yes lol
this is what code4me suggested to me ALL THE TIME, no matter what I entered
lul
Hi, A little question, How do I can switch on/off a redstone lamp with an Interact Event ? Thanks u
i imagine it is in the block state
i'm not sure if that works because once the physics get calculated again, it'll be turned off again i think
there's AnaloguePowered or sth similar for redstone
mfnalex, so the way to store a world is with a string? in a yaml file i mean
use the name or uid
yeah either store the world's name or the world's UID
okay, thanks
is this a meme
lol
it's a lie
it accepts any integer
what's the problem?
have you tried to read the error message that intellij probably shows you?
Yes, Inventory doesn't have any getTitle() method. You can get the title from the InventoryView instead
it's a bad idea though to check your inventories by their title
you should rather keep all your created inventories in a collection and check if it contains the clicked inventory instead
get the InventoryView from the event, and then get the title from that
declaration: package: org.bukkit.event.inventory, class: InventoryEvent
only with the normal pie charts
?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 you get a list of every single permission on the server? getServer().getPluginManager().getPermissions() doesnt give them all
Some permissions arent registered by some plugins.
What permissions are missing?
just the standard minecraft ones
like the perms for /weather clear etc
all im getting is https://hastebin.de/agenolehux.css
JDA question: does anyone know why TextChannel#sendTyping().queue() isn't showing the "XYZ is typing..." to me? No errors, it just doesn't show the "... is typing..." thing
why would a permission not get registered? If it only exists virtually?
Some people just check permissions like this:
player.hasPermission("some.plugin.permission")
And spigot has no way of knowing that this string exists.
yea thought so
but i meant more along the lines
does a permission get registered if it is in plugin yml as a command permission, but not an explicit permission in the permissions section
yes
that makes things easier at least
its also not giving ones like op
Hey! how can i do this so i don't get an error?
I'm storing a world as a string in a file but then, when i try to create this: Location loc = new Location((World) plugin.spawnLocationFile.getcFile().get("Spawn.world")... etc
it says that a string cannot be casted to a World, how can i solve that?
Guys I wanna give chest to player and When player place it I will set something on chest What Should I set varible ItemStack or Chest?
op is not a permission
Since a String isn't a world you can't cast it. Use Bukkit#getWorld instead
but i get another error since i cannot store a world in a file
Store the name
Store only the name of the world in a fle
World world = Bukkit.getWorld(player.getWorld().getName());
if i do this, i get an error
minecraft.command.op on the bukkit wiki lol
lol this makes no sense
this makes no sense
That's the command.
you want to get the world by its name which you get from the world you get from the palyer?
the permission for the command, yes
thats the perm for the /op command
YES!!!
thats what im talking about
the list getServer().getPluginManager().getPermissions() dont contain all permissions, including that one
so how do I get every permission on the server?!??
Do you just want to store a location in a file?
yea
help!
java.lang.IllegalArgumentException: Invalid UUID string: 0/60
at java.util.UUID.fromString1(UUID.java:280) ~[?:?]
at java.util.UUID.fromString(UUID.java:258) ~[?:?]
public static void displayCooldown(Player player, int cooldown) {
final int[] counter = {0};
Bukkit.getServer().getScheduler().runTaskTimer(plugin, new Runnable() {
@Override
public void run() {
String message = counter + "/" + cooldown;
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, UUID.fromString(message));
counter[0] += 1;
}
}, 0, 20);
}
Location is ConfigurationSerializable. You can just store it on a FileConfiguration
but i need the world
Your message isn't a valid UUID
"0/60" is not a valid UUID
So?
what is invalid about it
Its not a UUID
1c58dbdc-88ec-496e-b9c5-dd21f78c4884
This is a UUID
then why does it want a uuid if it should send a string
new UUID(counter,cooldown) 
UUID.fromString(message) this method here doesn't create a UUID
Because you are calling UUID.fromString(message)?
Huh?
public void sendMessage(@NotNull ChatMessageType position, @NotNull BaseComponent... component)
But its not needed
no luck as of far
https://www.spigotmc.org/wiki/the-chat-component-api/
Read this and use it together with what smile sent
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
im having a problem where Bukkit.getWorld() doesnt get a world with a custom name... anyone know about this?
does this mention actionbar
Its probably not loaded
they say that they are in that world with their character
then the names dont match
isnt there a way to display items on hover?
they do. at this point I think they are in a differently named world
of a chat component
That would be the ChatPosition in the method smile sent
no no
i already have that
but is there a way to make it already go into the sever area
Call your code somewhere and use getDataFolder for your plugin folder
Sure. Java is turing complete. You can do whatever you want (as long as the executing user has the permissions)
SHOW_ITEM action when you're making a HoverEvent for a TextComponent iirc
getDataFolder.getParent
ah
I shall delay the getting of the worlds a few seconds, that should do it
the first part is red and doesnt have an import class varible
You need to call it on your plugin instance
wdym