#help-development
1 messages · Page 1591 of 1
You probably have to do some nms hack then, not exposed in api I’m afraid of
Bukkit Scheduler and an TaskTimer
?scheduling
and then?
I'm confused. Why is the length always 1.0?
It isn’t, only if you normalize it
thanks!
@eternal oxide btw how do u think i can get the spawn egg of 'creature'
i will have to use enums?
or what was it
Ye
What exactly are you trying to do?
so when someone breaks a spawner or something?
it drops an egg
yep
thanks, how would I set the magnitude then?
in my plugin u can craft eggs and spawners and theyre expensive so them disappearing is cruel
use the entity type.name().toUppercase().replace(" ", "_") + "_SPAWN_EGG"
oh ty
Not as easy, you have to know what direction also
Is there a scheduler thing that runs it x amount of times? Or do i need to use a normal java loop?
It’s trivial to implement a stop after x runs using a repeating task
this doesn't work... it keeps responding to the command by outputing "/feed" in the chat
then with that String you can Material.getMaterial(String) or something close
Basically, I'm trying to get the player's line of sight.
any idea why this isnt working
public void onLogin(AsyncPlayerPreLoginEvent e){
if(!isPunished(e.getUniqueId().toString())) return;
String[] punish = getPunishment(e.getUniqueId().toString());
if(punish[2].split(": ")[1] == "BAN") e.disallow(Result.KICK_OTHER, ChatColor.RED + "You are banned for the reason: " + ChatColor.GOLD + punish[3]);
}
its not disallowing the login
i've debugged aswell
Okay
all works.. just not .disallow()
Surely that line does not go to 0,0,0
ijdk why it wouldnt work lol?
You have to use .equals() to compare strings
String comparison use .equals
quick question, does setting objects to null in the onDisable prevent memory leaks on a reload? As in, FileConfiguration, HashMaps containing player data etc.
Setting object to null is a good way to release references
or vibration particle
k thanks
on that note, i dont need to do that with final objects, but what about static ones?
@Override
public Event callEventSync(Event event)
{
CompletableFuture<Event> futureEvent = new CompletableFuture<>();
if(event instanceof BukkitEvent)
{
Bukkit.getServer().getScheduler().runTask(this.bukkitPluginLoader, () ->
{
Bukkit.getServer().getPluginManager().callEvent((BukkitEvent) event);
futureEvent.complete(event);
});
}
try
{
return futureEvent.get();
}
catch(InterruptedException | ExecutionException e)
{
throw new TvheeAPIInternalException(getClass(), "callEventSync", e);
}
}
This crashes my server, idk why
because i store a copy of the plugin object in a static variable to manipulate it easier
generally you won;t need to do it on anything that is in your classes. Unless you are running your own Executor or something.
just be sure to close any file handles and dispose of maps
ah ok
The problem is on futureEvent.get();
the runTask() method does run the callback on the next tick. I think the future is not completed because of this when you call future.get()
If they’re just internally used, then no
Ok, but how to fix that?
Garbage collection is slick
.get will lock teh current thread until the Future is finished
Yes, I am never using futures
are you saying i need to call the gc manually?
Yeah as Elgar said but I would like to say that even those might get garbage collected when the class loader is unloaded or smtng and no hard references to the static field, also true constants are an exception but they’re inlined anyways.
No
But if a dependent plugin holds strong references to your objects, then it may prevent garbage collection and lead to memory leaks
However usually when a reload runs every plugin reloads right so it should fix that.
So you are saying that setting to null makes things more secure, but isn't necessary? Also, it would be helpful to see if there was a reload / load / unload, can you differentiate between them?
Also I set a getInstance method so a reload of that plugin should not cause issues with dependencies
I’m saying you don’t have to set up things to null or clear map 99% of the time. As Elgar said, if you’re running executors or do some other stuff like a db connection then handle shutdown for those properly.
you can detect if your plugin is being reloaded or loaded for the first time. In onLoad check Bukkit.getWorlds().isEmpty() If empty its a fresh server start.
Hmm getInstance() can be dangerous if it isn’t a reload but rather just plugman unloading your plugin, if another plugin depends on that getInstance they will depend on an unneeded instance. Using JavaPlugin#getPlugin is safer.
Hey there (I'm pretty new to Java, sorry if I'm a bit slow, taking a full course next week). I have a VehicleDestroyEvent and I want to give the player some items when the event occurs. However, I can only get the attacker and it is an Entity, not a Player. I have tried using the following code to cast the Entity to a Player:
Player player = (Player) entity;
however, when I try and add an item with this code:
player.getInventory(new ItemStack(Material.TNT));
it says 'getInventory()' in 'org.bukkit.entity.HumanEntity' cannot be applied to '(org.bukkit.inventory.ItemStack)'
Can anyone help?
Well if the plugin is unloaded it returns null either way
Well as it says you can't use itemstack there
I know that, but is there a different way of doing it?
If you want to add stuff use the addItem method
okay, thank you :)
True, but i am referring to the getInstance method here. Its meant to be used mainly within the plugin, and if the plugin is unloaded but cached, thats not a great issue. The problem comes with other plugins would try to change permanent values of the playerData, as the plugin I'm working on is mostly providing static data, which only changes if a player interacts with specific things, like for example a value storing the coordinates of the last crying obsidian they interacted with.
which is handled by the plugin itself
On another note, which event fires when a player attempts to join versus when a player actually manages to join? I sometimes see 'Player left the game' when they attempt to connect but fail to.
AsyncPlayerPreLoginEvent then PlayerLoginEvent, then PlayerJoinEvent
k thanks i only found the join event
?paste
hey
so
idk how this is even being set off
every string[2] is accessible
& in userSystemName
Btw moterius you could run a profiler if you wanna find out if something is leaking 😉
well i want to know how to make it right the first time lol
also
1.17 is REALLY heavy on the RAM, so I'd rather be as efficient and CPU heavy as possible
like
a server eats 2GB even without anyone online
'recommended for small modpacks' my ass
I mean yeah
Towny is a good plugin
I dunno what u laughing at it does it's job for my server
You don't even know what my server is about so your bitch ass -8 player server and you can stfu you dumb ass
and then it needs like 100mb per player
the values online are not reliable
they say a player needs half a GB
i just gave up and took 4 GB
You do realize that a GB is a fucking huge amount of data?
Sounds somewhat unrealistic but I guess could be possible
I now changed it into a void method, but the event field does not change:
@Override
public void callEventSync(Event event)
{
if(event instanceof org.bukkit.event.Event)
Bukkit.getServer().getScheduler().runTask(this.bukkitPluginLoader, () -> Bukkit.getServer().getPluginManager().callEvent((org.bukkit.event.Event) event));
}
For example, if I cancel the GameInteractEvent, this won't detect it is cancelled:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e)
{
GameInteractEvent gameInteractEvent = new GameInteractEvent(getPlayer(e.getPlayer()));
TvheeAPI.getInstance().getPluginManager().callEvent(gameInteractEvent);
System.out.println("GameInteractListener " + gameInteractEvent.isCancelled());
e.setCancelled(gameInteractEvent.isCancelled());
}
@EventHandler
public void onGameInteract(GameInteractEvent e)
{
if(!e.getPlayer().hasPermission("dogleader.interact") && !state.isRunning())
{
e.setCancelled(true);
System.out.println("DogLeaderGame " + e.isCancelled());
}
}
[12:33:54] [Server thread/INFO]: GameInteractListener false
[12:33:54] [Server thread/INFO]: DogLeaderGame true
nvm, read it wrong
i get players by uuid via Bukkit.getPlayer(uuidstring);
where uuidstring is getUniqueId().toString(), from something
That looks dumb
What would you do then?
I mean checking if Event instanceof Event or what
U can get them from just uuid?
Event is at the top of its hierarchy
yeah?
appearently not
considering op is null
Event is my own api class, that's why I check if it is a bukkit event
Thats weird...
Does anyone know how I would get the points between two 3d xyz positions?
But bukkit events won’t inherit your event api class
Bezier
No I mean, I am create bungee and bukkit events, and let them both implement my own Event interface, that's why I have to check if its a bukkit or bungee event
But do you know a solution?
damn you triggered for no reason 😂
oh jesus
lol
No tvhee I barley know what you’re doing tbf
abort! abort!
: o
...negative players
without Towny
Altho I would suggest creating your own event system
Your own event bus if it’s going to be multi platform based
A bezier curve would get you the points between the start and the end point.
I could do that, but that means lots of work
but its more like a bezier line then
can you not subtract one from the other, halve the resulting vector, and add it to the point its pointing from to the other
like
does anyone know why in my plugin commands work but listeners dont?
vector = a - b;
vector *= .5;
result = b + vector;
Technically you could just calculate the y/z difference for every x increase/decrease (via Pythagoras) and then just add every location for every x increase/decrease
well since it's static points
you dont even need that
just add the difference in x, y, and z to a point as i did
also i think there is a ray tracing function in bukkit
if(Onceuncraftable.INSTANCE.getConfig().getBoolean("mine-spawners-with-silk-touch")){ is basically checking if the config mentioned is true, right?
The asker didn't search for the point between (x1, y1, z1) and (x2, y2, z2) but rather the points (plural) between (x1, y1, z1) and (x2, y2, z2)
} else { will run if it is false right?
nah ur just a retard
yes
sorry for the spoonfeeding but is there anyway to change the default world of the server, bascially the same world in level-name in server.properties
under normal circumstances yes, but this is minecraft so it is likely that the user means BlockPos points
can you not use multiverse and copy/paste the original world
No need for the toxicity
^
would rather it to be standalone but i guess i could try that
Youre the one whos toxic tho
Quote my toxic messages please
will if(e.getPlayer().getItemInUse().containsEnchantment(Enchantment.SILK_TOUCH)) { work with BlockBreakEvent?
??
Laughing about using towny is pretty toxic tbh
Well in most cases its already done, and probably better than you would do.
@grim ice can you not use SilkSpawners? Or look in that plugin's code?
I didn't laugh at you using towny
I just laughed at the idea of using towny, I didn't realize it was even still a thing
Sure and im petri nygård
I'm not sure what that means.
u dont need to
Hey is this a thing to run syncTasks in an asyncTask ? 🤔 from what I have tested so far I do not seem to have any error but it kinda feels weird
Yes thats fine
I think the syncTasks run on the main thread while the asyncTasks do not. Speak, if it's timing you need you should use sync, I guess
I could be completely wrong though
@eternal oxide will if(e.getPlayer().getItemInUse().containsEnchantment(Enchantment.SILK_TOUCH)) { work with BlockBreakEvent?
Thanks ! 🙂
Yes that's what I tought but I was not sure c:
'getItemInHand()' is deprecated
Not before the event is fired
'getItemInHand()' is deprecated
?jd
Read why
is the player object in that case dynamic or static? I don't know myself...
(speak, if the event is fired, is the player in it cached or the actual player in the world?)
The Player object in all events is the world object, EXCEPT the death event. Then its a copy.
so handle it fast. Got it
?paste
Do i have to reregister the commands when I'm reloading the pluign?
Should be in your onEnable anyway
Not working is not a good error
there is no error.
Theres always an error, unles syou have no plugin
Reason: I'm trying to make the plugin efficient, and as such I'musing
if(!Bukkit.getWorlds().isEmpty()){
to run specific functions only when there is a reload (IE if there could be players online) but i wasnt sure if commands stay cached
annotation
I know that feeling
Note that only works in the onLoad() method. Will not be a valid test in onEnable()
so use it to set a flag field in your onLoad()
It is good to worry about reloads though. Not many plugin devs do and its the reason it breaks a lot.
static boolean reload = false;
@Override
public void onLoad(){
reload = !Bukkit.getWorlds().isEmpty();
}```
like that?
yes
does this
File read = new File(this.getDataFolder(), "playerdata.yml");```
return the file `plugins/<Pluginname>/playerdata.yml`?
yes, if it exists
you can simply do if (!read.exists()) read.mkdirs() or somethign close
createNewFile
or if you have a default of that as a resource in your jar saveResource("playerdata.yml")
is that IOException a severe or a warning, also, how do i get a ressource withotu saving it?
registered the listener?
wait
WHY
WHY
WHY
WHY
AM I SO DUMB
i hate events
i always forget stuff in them
how can i send the player to another server in bukkit
google "spigot bungeecord plugin channel"
@eternal oxide
lmao still doesnt work
loll
config.yml:
mine-spawners-with-silk-touch: false
this is default ^
anyone?
You are trying to drop a spawner and an egg?
yes
so what part does not work?
if someone with the permission does /onceuncraftable minespawners true
everything
if u do the command u stil lcant break
do you get an error?
nope
well you havn;t registered any commands
add some sysout debug messages to your event and see if or how far it gets
is PlayerQuitEvent triggered when a player is kicked?
yes
ok thanks
What do you guys use for 1.17 mappings? I used https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.17.1 but it doesn't seem to work for 1.17.1
No some NMS stuff changed in 1.17.1
things still have the potential to be remapped
Ah wait the page loaded after a few mins. I get Error while loading spigot mappings: Version not found but it loads, strange
doesjava if(commands.length!=0){ for(String s : commands){
bring any performance improvement if the list is empty over removing the length check?
the lengtgh check isnt necessary
k
how fix this?
public void loadPlayer() {
if (true) {
Statement statement = createStatement();
ResultSet result = null;
try {
result = statement.executeQuery("SELECT * FROM `wn_data` WHERE uuid = '" + player.getUniqueId() + "';");
} catch (SQLException e) {
e.printStackTrace();
Main.broadcastWarn("Eita.");
}
}
}
its SQLite
you do realise if(true) is useless
i know
can we see which line is throwing the NPE
🤔
PlayerAPI.java:30
line 30 in the PlayerAPI class
if only people were using up-to-date software
result = statement.executeQuery("SELECT * FROM `wn_data` WHERE uuid = '" + player.getUniqueId() + "';");
and would get the amazing java 15+ null pointer exceptions
well either player is null
statement is probably null
or statement
or player
I'd take a guess it is the player
why not pass Player as an arg
my mans coding for 1.8, as if proper functional method design is their biggest issue
i will check the statement
Please do this async
Thank you have a nice day
yeah, will be async
its only a prototype
thanks for the tip
no, spam it in a loop on the main thread
That is also an option
Every tick load the players data, just in case
On the main thread
How would I go about making a magma cube jump when it has no gravity/AI? Would I have to do some pathfindergoal clearing bs?
?paste
no AI = no path finding
can we see the config
probably just a formatting error
mine-spawners-with-silk-touch: false
/*
*
- turn on if you want players to be able to break spawners with silktouch and drop them
- (including the spawn egg)
*/
thats it?
yes
but for some reason
in the server
when i open config,yml
it doesnt havae a space
so its
mine-spawners-with-silk-touch:false
?paste your config.yml
they did before
.
in paste not in channel
it "looks" fine
however, delete teh line getConfig.options.copydefaults. You don;t need it
just saveDefaultConfig
now try it
alr'
oh, yaml does not use java commenting
WA
yeah just one hash
knew it
there's only really two styles of commenting stuff:
// comment
and
comment
so I'd have to do stupid stuff with pathfinder goals then, do new pathfinder goals appear at random intervals or are they always there? (so I don't have to worry about it doing its own thing)
HTML
LUA --
You would have to do all your own AI logic/movement as when the AI is disabled none of that code runs.
Why is e.getEntered() in VehicleEnterEvent an Entity but e.getExited() a living entity in VehicleExitEvent?
the issue with HTML is that they are also inline comments
so extending CraftMagmaCube or whatever its cbukkit class is?
using maven javadoc plugin, how can I link the spigot api in my docs?
also why does my javadoc have duplicates
link as in URL reference to a webpage or linking the class directly
yea url as part of links configuration
I don't know of a valid way to link from your javadoc to the official spigot url using like {@link Player}
not what I meant
e.g. if you have a function like
#doSomethingWithPlayer(org.bukkit.entity.Player player)
and you generate docs, it won't know what org.bukkit.entity.Player is.
When linked properly, clicking org.bukkit.entity.Player will redirect you to spigot docs
how can i set the server motd in bungeecord event
ProxyPingEvent
I can't for the life of me figure out why my plugin thinks I never have permissions to use a command. I have defined my command and the permission nodes in my plugin.yml https://paste.helpch.at/oqegukutuj.php and I have gave myself several combinations of these permission nodes in LuckPerms, but when I do Player.hasPermission(...), it only returns true if the player is opped. Any ideas what I'm doing wrong? Here's my code https://paste.helpch.at/obosakarak.java
that may be because you messed up with quotes here:
it doesn't do what you think it does
I think
Hm I'll try putting a backslash before those
Nope, still doesn't work
And tbf, if that was the issue, gamemode.self should have still worked, which is the one that I'm testing mostly
@austere cove oh sweet, so you answered your own question xD any difference between using link vs offlinelink ?
what link did you use for spigot
I linked paper lol
(options as StandardJavadocDocletOptions).linksOffline(
"https://papermc.io/javadocs/paper/1.17",
"https://papermc.io/javadocs/paper/1.17"
)
I used the root for both the url and package-list root
https://hub.spigotmc.org/javadocs/bukkit/ does not work cos
https://hub.spigotmc.org/javadocs/bukkit/package-list does not exist
same w https://hub.spigotmc.org/javadocs/spigot/
yeah use offline links
<configuration>
<source>8</source>
<offlineLinks>
<offlineLink>
<url>https://hub.spigotmc.org/javadocs/spigot</url>
<location>https://hub.spigotmc.org/javadocs/spigot</location>
</offlineLink>
</offlineLinks>
</configuration>
works great for me
this is what you want right ?
redirects me to spigot entity docs
[WARNING] Javadoc Warnings
[WARNING] javadoc: warning - Error fetching URL: https://hub.spigotmc.org/javadocs/spigot/
am running ```xml
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
using Apache Maven 3.8.1
#setInvisible iirc
I'm running 3.3.0
setVisible then
works perfectly fine for me using javadoc 3.3.0
?? just did a fresh clean & install and I still have the warns
I copied that snippet
welp this is wild xD
would be my entire javadoc config
but I don't think there is anything worthwhile in there
retried it w the same phase and still got a warning
Welp 😂 running javadoc 16.0.1 from adopt openjdk if that helps
Hey, im making a bedwars plugin, my team generator are working, but, how can i make it check the amount of dropped items?
I want:
Iron only stack to 96
and gold only stack to 64.
How can i do that
is there a way to get all the datapacks installed using the spigot api?
i don't think the spigot api even acknowledges the existence of datapacks
thats what I kinda figured after there being zero occurances on the jd :/
it's only been around for several years
you can't expect the api to actually reflect what's happening with the game
it'll probably take at least 5 more years
maybe your IDE just just trash xD
external emojis are only allowed for nitro booster cucks
External emojis are for boosters
because md5 needs jew shekels to keep the guild banner and shit
Still not found anything that could be causing this; I've tried making sure the gamemode is lowercase, I've tried testing for the parent nodes aswell as the child nodes, I've tried on a fresh server... nothing seems to work
what are you trying to do
Test if a player has a permission, to put it simply
Is there a way to save data on blocks?
on tile entities, yes
On normal blocks no?
not really
Chunk pdc technically
only very technically
there is no reliable way of keeping track of when blocks are destroyed and moved around
events do exist for that
the best you can do is have like 20 listeners and listen to all of the events, but that is gay and will still explode if other plugins do stuff that don't throw events
then their fault
not really
the api doesn't really provide any events for plugins to fire in such cases
ok so probably is better storing it on external file right?
so it isn't their fault that they aren't throwing any events about it
eclipse or intelliJ
Well, you have to fire the event that is the closest to what it should do
Otherwise block protection plugins will not work as intended
block protection plugins generally use player related events
and firing those without actual player interaction is kind of haram
The event system sadly does not have an intent system in place, so yes, there will be some issues
Both work just fine I do prefer Intellij though
f.e most anticheat plugins will expode if you spoof a player block break event for a block that is out of reach
heh, I don't support AC plugins anyways
Heck, I did bork Spartan by creating an EntityShootBowEvent with a null entity not so long ago
spartan is gay anyway
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
if(sender instanceof Player){
Player player = (Player) sender;
// /heal
if(cmd.getName().equalsIgnoreCase("heal")) {
double maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue();
player.setHealth(maxHealth);
player.sendMessage(ChatColor.AQUA + "You have been healed!");
return true;
}else if(cmd.getName().equalsIgnoreCase("feed")){
player.setFoodLevel(20);
player.sendMessage(ChatColor.AQUA + "Your hunger has been set to max!");
return true;
}
} else{
System.out.println("Execute this command ingame");
return true;
}
``` Anybody know why if i execute "heal" on console, it gives me "execute this command ingame", but not when i execute "feed"?
does feed even run at console?
no its not supposed to run, thats why its supposed to output "execute this command ingame", but its not giving me that
Did you register the command?
That wasn;t my question. Does the feed command "attempt" to run when issued at the console?
you probably have set a different command executor for heal and feed
i don't see any other way that'd happen
Is that an insult? ;D
It's probably them just being them
does anyone know why listeners dont work but commands do?
annotation EventHandler
I kinda want to make a calculated arrow shooter with some math. Do you guys know what arrow firing power converts to in meters per second?
1 block = 1 mtr. A projectile velocity is a vector. use getLength() to find its magnitude, which is distance traveled per tick
Oooh
what happens if you want to call Block#getType() on an unloaded block
Where can I get Spigot mappings? Spigot doesn't use Mojang's mappings right? So where can I get the mappings it uses?
@Override
public Material getType() {
return CraftMagicNumbers.getMaterial(world.getType(position).getBlock());
}
It loads the chunk I guess
holds the mappings used by spigot
the Block object itself is just a wrapper over a BlockPos and a World
any calls made to any of its methods that retrieve any data about it delegate to the underlying chunk at those coordinates, and it will be synchronously loaded to retrieve that data if it isn't loaded already
How to convert AxisAlignedBB to two vectors? NMS
Wait so I basically have to convert them two times? From spigot to obfuscated and from obfuscated to mojang?
Is there like no tool to help with this?
how do you unregister a command programmatically?
What are you even trying to do xD @smoky finch
all variables in AABB are public
you can just access them to craft the vectors you want
I am assuming [maxX,maxY,maxZ] and [minX,...] respectively
What do ppl do with mappings? NMS of course. Packets n stuff
trying to figure out how to send a spyglass packet
How are you so sure? I've seen an animation enum for it
https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/ has a tutorial on how to setup mojang mapped workspace with special source
its an animation
but that is serverbound
you are trying to send (clientbound)
well, I guess you can trick other players into seeing players holding a spyglass
while they actually aren't
but that is as far as you'll get
cannot force a client to use a spyglass
I don't think that helps if I'm going to use reflection right?
Okay but how is this specialsource maven thingy going to convert my reflection code to that I wrote based on mojang mappings back to spigot's
you don't use reflection with special source
reflection is pretty dead/hard to use in 1.17
as no tool is really capable of mapping reflection code yet
ah so by "no" you meant I can't use that tutorial
Well, you aren't supposed to use reflection with 1.17 in the first place
you depend on the "mojang-mapped" spigot dependency
and code against that
We're not supposed to use reflection at all for any other version in general, but who am I kidding, it's minecraft. I prefer to support a few versions behind the current ver
If you want to use reflection you will have to deal with the runtime names
e.g. checkout the server jar's content
it is an incredible pain tho
Sorry if I'm being annoying but this is annoying me- I can't see any reason why this isn't working >.< Anybody got any ideas?
when I try to reobf my plugin, it maps only classes and fields, but not methods, should I report it as bur or am I just doing something incorrectly?
I used the commands from forums and it didn't throw me any error
so your method calls do not get reobfuscated ? e.g. player.getName() would not get reobf to the correct runtime method name ?
oh, so now I tried to do it again and decompile it to copy the code here and it is ok
o.O
but last time I've done it, it was like
oe connection = ((CraftPlayer)player).getHandle().b.a;
pk[] var3 = packetList;
int var4 = packetList.length;
for(int var5 = 0; var5 < var4; ++var5) {
pk packet = var3[var5];
connection.send(packet);
}
and I used exactly the same command
(yep, I hnow, that I must map it back to spigot mappings, but mapping-obf whas the mapping where something went wrong and in spigot, it was just the issue from mapping-obf)
issue was the send method right ?
Well, not being able to replicate it is kinda bad xD
ik ;)
how to get enchantment name
?
enchan.getname is deprecated
closest is probably the key of its namespaced key
and that is also what javadocks are saying
Deprecated.
enchantments are badly named, use getKey().
this is the description of getName
why?
this is spigot help-development
no one reads javadocs
else this channel would be 30% as busy
btw
I tried to decompile whole custom entity class (idk why I didn't try it earlier)
and the obfuscation works only sometimes
public class Missile extends atw {
Location mountingPoint;
public Missile(Location l) {
super(atk.f, ((CraftWorld)Objects.requireNonNull(l.getWorld())).getHandle());
this.mountingPoint = l;
this.setPos(l.getX(), l.getY(), l.getZ());
this.bM = new MissileEngine(this, 10);
this.bO = new MissileHomingSystem(this, this.level);
this.setNoGravity(true);
this.noPhysics = true;
}
protected void v() {
this.bP.a(0, new PathfinderGoalFireMissile(this));
this.bP.a(1, new PathfinderGoalTrackTarget(this));
this.bP.a(2, new PathfinderGoalSelectMeteorite(this));
}
public void u_() {
if (this.lerpSteps > 0) {
double d0 = this.getX() + (this.lerpX - this.getX()) / (double)this.lerpSteps;
double d1 = this.getY() + (this.lerpY - this.getY()) / (double)this.lerpSteps;
double d2 = this.getZ() + (this.lerpZ - this.getZ()) / (double)this.lerpSteps;
double d3 = ahb.f(this.lerpYRot - (double)this.getYRot());
this.setYRot(this.getYRot() + (float)d3 / (float)this.lerpSteps);
this.setXRot(this.getXRot() + (float)(this.lerpXRot - (double)this.getXRot()) / (float)this.lerpSteps);
--this.lerpSteps;
this.setPos(d0, d1, d2);
this.setRot(this.getYRot(), this.getXRot());
}
if (this.lerpHeadSteps > 0) {
this.yHeadRot = (float)((double)this.yHeadRot + ahb.f(this.lyHeadRot - (double)this.yHeadRot) / (double)this.lerpHeadSteps);
--this.lerpHeadSteps;
}
this.level.ab().a("ai");
if (this.eB()) {
this.level.ab().a("newAi");
this.ey();
this.level.ab().c();
}
this.level.ab().c();
this.level.ab().a("travel");
this.move(aua.a, this.getDeltaMovement());
this.level.ab().c();
}
public void knockback(double d0, double d1, double d2) {
}
}
?paste
this class writes a string into the config but i cant change it in the config because it changes to the default https://paste.md-5.net/negemizayo.java
if (this.eB()) {
this.level.ab().a("newAi");
this.ey();
this.level.ab().c();
}
this.level.ab().c();
this.level.ab().a("travel");
this.move(aua.a, this.getDeltaMovement());
this.level.ab().c();```
oh god
?
is it possible to get the server minecraft version?
does anyone know why it is like this?
Bukkit.getVersion() iirc
?
No, we don't even know how your config class works
it is decompiled class that was remmaped to mapping-obf
@vale cradle i show it
I will go step by step on what I do so if you see any problem you can hope fully help me
---- My Spigot plugin ----
First I register an outgoing plugin channel in my main class :
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Then I call the function load
load(pName, "Infractions");
load(pName, "Descriptions");
My function load :
public void load(String p, String name) {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("load");
out.writeUTF(name);
} catch (IOException e) {
e.printStackTrace();
}
sendToBungeeCord(p, b);
}
In this function I call the function sendToBungeeCord.
My function sendToBungeeCord :
public void sendToBungeeCord(String p, ByteArrayOutputStream b) {
Player pla = Bukkit.getPlayer(p);
pla.sendPluginMessage(Bobbies.pl, "BungeeCord", b.toByteArray());
pla.sendMessage("" + b);
}
Here is what my sendMessage gives me :
?paste
but problem is, that something isn't remapped
bruh
---- My Bungee plugin ----
In my main class I extends Plugin and in my onEnable function I register listener :
getProxy().getPluginManager().registerListener(this, new onPlayerMessageEvent(this));
In this class I implement Listener and here is the event handler code :
@EventHandler
public void onPluginMessageEvent(PluginMessageEvent e) {
if (e.getTag().equalsIgnoreCase("BungeeCord")) {
DataInputStream in = new DataInputStream(new ByteArrayInputStream(e.getData()));
try {
String channel = in.readUTF();
System.out.println("chan " + channel);
if (channel.equals("load")) {
String name = in.readUTF();
loadConfig(getFile(name));
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Here Is what my sysout gives me
He says that the channel is Forward but never the channel load :(
So if someone can help me pls
@vale cradle https://paste.md-5.net/sudegumoro.java
?paste
holy
I've got a java question, say that I have (just pseudocode)
class A{
public A(boolean thing){...}
}
class B extends A{
public B(boolean thing){super(thing);...}
}
if I want
class B extends A{
public B(boolean thing, int blah){super(thing);...}
}
where my B class has a different constructor from class A, what is the easiest correct way of implementing this? I can think of at least a couple, but are there good ways to do this?
is it possible to get the server icon path?
What's the expected result and what do you get?
i want to just save a String in the config and get it as a String variable so i can use it
You already implemented what you wanted to, don't you?
I don't see where you are struggling at
me?
And? What do you get?
I am extending something but I want the constructor for the extended class to require more fields
I could create a static method to force it somewhat but that doesn't sound like a clean or scalable way of doing it
ideally I'd want a setup where if I extend class b it would require all the constructors from a plus all the ones from b
You want the constructor of the class A to have more fields or?
no, the one of class b
i get that but the user cant personalize the config (cant write something in the config) because everytime when the player joins the server the String resets
this returns git-Paper-111 (MC: 1.17.1) i just want 1.17.1 will i have to use string slicing or is there another method?
if you extend class A it requires you implement a class with the same constructors
wait
fuck nevermind
I'm just being dumb
brain fart
idk, maybe try regex
What do you want to do?
I'm gonna go get some more caffeine in me, clearly this isn't working out at my current levels
.#
thanks tommy
No, it doesn't
ok thankns
i already told you
and is this possible?
yeah I was conflating warnings, my bad
@vale cradle
yep
I mean, even if you explain me, I don't find many sense in the code you sent me, so show me an example: Either print the variables in the console or telling an example of the steps you're following and what you got
how do i do it?
That is what I'm saying?
there will be a error on a file operation if the file doesn't exists
nope
neither the File constructor or the exists method throw an error if the file does not exist
do i do /server-icon.png or ../server-icon.png ?
just do, server-icon.png
ok
Note: that is gonna get the server-icon at current directory.
that's a problem
say i just want to print the string in the console so i want to get the String a player writes in the config and use it as a variable (but in the config there should be a given key called "test" or something
Because the file is not located into the root lol
uh shi, im dumb
And the file is on the CWD
… use the provided methods
Why don’t you use the provided methods… lol
The getParentFile
hm
ye
so i have this code to register custom enchants but when i register the second enchantment(autoPickup in this case) it says that its already registered
what you do then?
Path
do you know how to do this i never worked with configs and dont understand it
Both have 2 different purposes imo
No they aren’t
I mean, both works good
Java even mentioned to switch
They said that you should be sketching over to Path more
*switching
I am new to spigot api, how to make a item disapear on right click on air
I added the events and also specified the custom item
Mainly cause it’s immutable too
Mhm, I'd need to look more over it
Bukkit.getConsoleSender().sendMessage(message)
Or System.out.println(msg) if you're lazy
Change the type to air
no it would always reset this is my problem
type means the event type ?
if mutabillity is the concern then I do not see the actualy concern
Show all code
No, the material
@modest fog no the type of the material
The file resets or the cached config does?
ill have to send it in a file
just the String resets to the default i have given
private final String name;
private final int maxLvl;
public EnchantmentWrapper(String namespace, String name, int lvl) {
super(NamespacedKey.minecraft(namespace));
this.name = name;
this.maxLvl = lvl;
}
@Override
public String getName() {
return null;
}
@Override
public int getMaxLevel() {
return 0;
}
@Override
public int getStartLevel() {
return 0;
}
@Override
public EnchantmentTarget getItemTarget() {
return null;
}
@Override
public boolean isTreasure() {
return false;
}
@Override
public boolean isCursed() {
return false;
}
@Override
public boolean conflictsWith(Enchantment enchantment) {
return false;
}
@Override
public boolean canEnchantItem(ItemStack itemStack) {
return false;
}
}```
Try to only use the reflection once ;p
Resets to platzhalter?
im kinda new to spigot, what does it mean?
@vale cradle ye
Why do you register twice lol
When you try to use the get the declared field or so
You are recalling the same method over and over again
It's kinda heavy method so try calling them the less as possible
Oh wait nvm
My eyes are broken
It’s not recursive, but still you are registering it twice
But, why are you complaining about it always resets? You always set that string before anything else happens
I need glasses
Just asking to set material to air All i have to do is this right
Material.AIR;
So, would be normal to always get that string ofc
how?
yes and this is my problem how can i just set it once
Yes, ItemStack.setType(Material.AIR);
k Thx
*I didnt knew i had to keep ItemStack
Will keep in mind
Idk, just set it on server start or check if the variable is already defined
What does this mean, It came when I tried to set the Item as Air
Non-static method 'setType(org.bukkit.Material)' cannot be referenced from a static context
Of course
?
Just do whatever fit to your needs dud
okay
I mean, when I said ItemStack I wasn't refering to the class itself (calling a static method) but to the ItemStack instance
instance
Ok
hey guys, I'm working with bungeecord config stuff atm, and I was wondering if it's possible to know if a boolean is set to false.
enabled: false
The thing is, if I simply get the boolean, it will return false if there is anything other than true, and I need to know specifically if the value is false. Is there any way to do this? :)
how do i do that
Note I am Very Dumb | Srry for that
So how to get ItemStack as an instance
Wish Could right plugin in js
if the result is false, check contains. If contains is true then the value is really false.
it would not, contains will tell you if there is really an entry stored for that boolean
Do you know Object Oriented Programming?
Perfect, will give that a go
JS also supports OOP
I feel dumb being here
So ye, take a class about OOP
I mean, will sound sad, but you can't do nothing so special if you don't know OOP in Java
thx for telling
really gotta go to java now
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
OOP is not a Java concept
Is a paradigm
Applies to the most of programming languages
so
like in js
me making discord bot
but using different folders
to keep different things
like one for events
one for handler
one for commands
Thats what my one brain cell mind can think of
But I think yes, u right
You will know when you already learn it lol
so ik
but i dont know
Intresting
Just had a thought, wouldn't "contains" just check if the key exists, not necessarily the value?
is there actually an easier way to check if a block can be broken by the current tool than like this:
if (player.getInventory().getItemInMainHand().getType().equals(Material.IRON_PICKAXE)){
// break block
}
smt like if(player.canBreakBlock(Block/Material))
Not really because people can basically break every block using their fist if they take long enough
Yes, if the key exists and the getBoolean returns false then it is really set to false.
If teh key does NOT exists, you will still get a false result from getBoolean
I doubt there will be any methods like you want because you're looking for a way to check if the player's item is high enough to get a loot drop; not actually break the block
yea
yeah sure, just wanted to ask if there already is a way
i'm not entirely sure tho, what this would do
What class is that under?
Block
That should work actually
So if you get a block from a material, you check the players hand itemstack with that method and if its true that tool is correct
i mean.. idk what it means by preferred tbh
well to me it sounds like for example axe and trees
where it will break just faster
Only one way to see ¯_(ツ)_/¯
well yea...
omg
I dont see any lambdas there despite what the link suggests 
ah
oh nice
Note I am Very Dumb | Srry for that
So how to get ItemStack as an instance
Will Learn OOP In a While, Really gotta make this rn
You keep saying that
learn oop first
Also read the javadocs
Ok
dont defer it anymore
everything is easy once you understand it good enough
eeeeeeeeeeeh
"How to get ItemStack as an instance" is more of a "???" question that "learn OOP"
is it just me or is the leather armor meta really odd
does minecraft actually render colors that aren't the pseudo-enums in the api?
pretty sure leather armour supports full RGB
huh really?
Yes, why else would it show you the RGB values of it?
ah that is one dangerous line of logic to follow lol
There are 12,326,391 (73.4% of sRGB) colors leather armor can be, as it is possible to put more than one dye on the crafting bench alongside the leather armor.
The logic isn't dangerous, it makes very much sense. Developers will not implement a rarely used feature just for fun
why is my plugin config not saving when i reload
it should only read from the file, not save tho?
yeah exactly
oh send ur code then Ig
the appropriate code
okay
im opeening intelliJ
public void onEnable() {
INSTANCE = this;
recipes.addRecipes();
getServer().getPluginManager().registerEvents(new onJoin(recipes), this);
getServer().getPluginManager().registerEvents(new Mineable(), this);
getCommand("mineablespawners").setExecutor(new Changeconfig());
getCommand("craftenchants").setExecutor(new Changeconfig());
saveDefaultConfig();
}```
mine-spawners-with-silk-touch: false
craft-enchants: true
# turn on first option if you want players to be able to break spawners with silktouch and drop them
# (ncluding the spawn egg)
# turn off second option if you do not want craftable enchants.
@ivory sleet sry for pinging
thats not all
omg, singleton again
yes but I cant read the code, barely
is MaterialData depricated?
mye
Construtor, setters are near to non existence for alot of people :/
how can I check if item is a bed?
thats not a singleton
are you talking about me?
yes
just an exposed static field
oh
probably final
i don't think its final
the name hints so
you can't assign value to final
yes you can
waa
aren't final supposed to be constant?
static final Object OBJECT = new Object();
assignment right there
well yea you cant re-assign
yes
oh yeah you're right
wdym
nothing hex
I didnt pay attention to the former code
is it something i should worry about
if so please tell me
probably non of your concerns as a spigot dev
just don't use unnecessary static words, use construtor, setters or some kind of dependency injection
anyways you have to call Onceuncraftable.INSTANCE.getConfig().saveConfig() or saveDefaultConfig() after setting a value
You didn't even explain what is wrong.
I did.
oh sorry, it was up
just like if you were to change the file in an editor
you guys flooded the chat
Oh!
or manually make the file
?
so for my case
if (args[0].equals("true")) {
if (Onceuncraftable.INSTANCE.getConfig().getBoolean("mine-spawners-with-silk-touch")) {
sender.sendMessage(ChatColor.GREEN + "It's already true!");
} else {
Onceuncraftable.INSTANCE.getConfig().set("mine-spawners-with-silk-touch", true);
Onceuncraftable.INSTANCE.saveConfig();
}
}```
yes
Alright, thanks il try it
I do not see any issue
Makes sense, and most importantly it works! Thanks for the advice 👍
intersting that you don't see issue,
class Test{
public final String e = "eee";
public static void main(String[] args) {
new Test().e = "eaf";
}
}
do u see the issue now?
jshell is not meant as a class parser
oh fair
I do not see why jshell would even be needed outside of a quick System.out.printf("%X", 45)
So do I
others do tho
But jshell likely does also not have autocomplete
kinda rude
rly?
I see
oh well, i wonder when copilot will support java
How many developers needs to make a new spigot.jar?
i got it for other 5 lang but still sad cuz i just use kotlin and java mainly
huh?
how can i let something happen when a mob hits a player?
EntityDamageByEntityEvent
To make a new spigot like paper, bulkier and etc
How long it will take ?
Ah, fork
thanks
Paper is spigot fork
spigot is bukkit fork
bukkit is mc fork
You mean something like Spongepowered or something like paper?
Depends on what you're doing
you don't randomly create a fork for no reason at all
first get a plan
like, just to fix dupes you won't have to create a fork of spigot when paper already has that feature
I personally have plans of creating a fork myself (with the goal of having bukkit with mixin support) - though this will take a very long time to get completed
@quiet ice I dm you, I would like to talk to you 🙂
Aren't patches kinda like mixins?
