#help-development
1 messages Ā· Page 1764 of 1
i found this AutoPlug | Automatic Plugin/Server/Java/Self Updater 5.2
sometimes hosting providers limit upload and download speeds on sftp
and you can bypass this via plugins
although some plugins download files in the main thread
which is bad
because it crashes the server
so would I create another folder under src/main/java or where would I do that? or is there a tutorial online that shows you how to do that?
I know what you mean by create a new class for spigot
yes
you can keep it in another package just
or if you use maven/gradle then you got the possibility to isolate bungee from spigot if wanted
which I usually do to avoid runtime-less classes being available at compile time
i love how java has IdentityHashMaps
while it doesnt have implementation of IndentityHashSet
and I need to use this instead Collections.newSetFromMap(new IdentityHashMap<>())
Doesn't have String.isNumeric either
hashmap = hashset
HashSet could at any point of time rely on something else but a HashMap tho but yeah
How to set direction a player is facing without changing their whole location
idk why I can't remember im being stupid
declaration: package: org.bukkit.entity, interface: Entity
Anyone knows how to create per player scoreboard by teams? ; v ;, im trying to make a rank score updates every 10 secs, but i need per player sb teams...
soo, if you can help plz hlp mah ; v ;
im not sure if this is helpful but there's a scoreboard API in bukkit which allows you to create scoreboard and add players to teams
second option would be to send packet to the player
i want to create it with spigotAPI
I will literally use IdentityHashmap everywhere I can right now
im actually new to java so i dont know anything abt hashmapsl ol
declaration: package: org.bukkit.scoreboard, interface: Scoreboard
all of the methods for the scoreboard
didnt work š¦
okie
i'll check it out
just be careful if you're using scoreboard plugins
it can override your plugins scoreboard
because client only supports one scoreboard at a time
So I made a HashMap :
public final HashMap<String, Area> areaMap = new HashMap<>();
I managed to make a new Area (and add it to the HashMap) but how do I remove an Area?
Here's the code to make a new Area:
public void addNewArea(Location upCorner, Location downCorner, String name, Player owner, List<Player> coOwners) {
if (!doesAreaExist(name))
areaMap.put(name, new Area(upCorner, downCorner, name, owner, coOwners));
}
just remove it from the hashmap?
there's no method to do so...
which class?
in that case teleport the player to his eyeLocation
HashMap
last resort
ill try that
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
even tutorials mentions it
np
that just lags the player out now
how often are you doing it?
Hello
Hello
oh hey
I need some help here! I'm trying to prevent a Item Frame of having its item being taking out
cache every single value possibility in java
I've tried some events, but none of them worked
every tick
that would eat up ram. Trie data structure i think is the thing you're mentioning
for strings this is useful
Would y'all mind taking a look at this? The function of the plugin is for a player to die as soon as they step onto the nether roof, and then a custom death message will be sent. The issue is that the custom death message isn't firing, and the even my "debug" output is not firing, so obviously the player's UUID isn't being added to the list.
package com.music4lity.NoNetherRoof.events;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.ChatColor;
public class Listeners implements Listener {
public List<UUID> victimList = new ArrayList<UUID>();
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (player.getWorld().getName().endsWith("_nether")) {
int y = player.getLocation().getBlockY();
if (y >= 128) {
player.setHealth(0);
victimList.add(player.getUniqueId());
}
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent death) {
Player player = death.getEntity();
UUID playerUUID = player.getUniqueId();
if (victimList.contains(playerUUID)) {
death.setDeathMessage(ChatColor.DARK_RED + player.getName() + ChatColor.DARK_AQUA + " tried to walk on the Nether roof");
victimList.remove(playerUUID);
System.out.println("debug");
}
}
}
@steady warren try this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityDamageByEntityEvent.html
declaration: package: org.bukkit.event.entity, class: EntityDamageByEntityEvent
if event.getEntity instanceof ItemFrame
It seems to work
THank you
No errors in console
use a hashset instead of list here
private final Set<UUID> victimList = new HashSet<>();
Still not getting a death message
that wasnt a fix
way too often
am I stupid or how do I remove a specific string index from a String[]?
strings[i] = null
ty
you try first add the user to the Set and later kill the player?
is it registered?
did you look at the code
If the array is an @NotNull, does that still work?
I'll try switching that up
yes because the array cannot be null, not the arguments in it
alr ty
how often should i do this
Thanks for pointing that out. Adding to the set and then killing worked.
Im such a dumbass
i think (?
_ _
Hey guys so if I have a hashmap to record some information if I wanted 2 values under a key that stood for different things I could just use a list and call 0 and 1 from the list for what I want but is there a more efficient way to do something like this or will this work well
have an object represent whatever you're trying to represent
^
using a list will have much more overhead compared to a single object
mm yeah that the good shit šš
personally I like creating a Pair class if I have a lot of areas where two values must be stored
ye I'll surely use either of those in a Minecraft modding/plugin dev setting thanks guys
JSR-223 abuse go brrrrrrr
Anyone know how to define a single diamond block instead of every diamond block that gets crafted
per example, breaking a single block at a certain location.
why isnt armorstand.getLocation().setYaw((float) rotat); setting the yaw of my armorstand? ive broadcasted the variable rotat and it is a float but it doesnt rotate the armor stand
I am getting these errors trying to send a message through the "Bungeecord" messaging channel. https://paste.helpch.at/yudiqiteni.sql
You know when you are on a wrong version of minecraft, and for example using Paper on the part where usually amount of players is eg 20/100 it says Paper 1.9.4 in red, how could I change that?
This thing
and what u wanna do with that?
wym
my_tuple = (1, 2, 3) # immutable
Change it to just say like 1.8-1.9
Oh I mean like a way to build it with something equivalent of ImmutableList.Builder or smtng
why
@quaint mantle Is this possible?
class TupleBuilder:
def __init__(self) -> None:
self.vals = []
def append(self, val) -> 'TupleBuilder':
self.vals.append(val)
return self
def build(self) -> None:
return (*self.vals)
Ah
idk what event this is... i know the ServerListPingEvent but dunno if that is the same event to hover over it or something
build = TupleBuilder()\
.append(5)\
.append(10)\
.build()
Smart
I also just need it to show that when the player is on the old or new version
nothing on google related to my issue
I am trying to use the BungeeCord channel
I would recommend chunk pdc
?pdc
anyone?
Thanks
My IDE gives me a warning when I register my commands, saying that setExecutor might throw a NullPointerException here. Obviously, I'm only using it on commands that exist so, so there will never be such an exception. Is there a way to get rid of the warning without doing an unnecessary null check?
getCommand("collect").setExecutor(new CollectCommand());
Is there a way to check what version a player joins the server on?
@SuppressWarnings("ConstantConditions") above the method
Getting all servers on a BungeeCord Network
Are you using ViaVersion or ProtocolSupport?
Thank you. That does indeed seem to remove the warnings! Would using this be considered good practice tho?
yes its fine
Im having this issue whenever I try to add a player to an array list, they arraylist size doesnt change,
QueueManager ```java
public static ArrayList <Player> queue = new ArrayList<Player>();
public void addPlayer(Player player) {
queue.add(player);
}
public void removePlayer(Player player) {
queue.remove(player);
}```
Npc rightclick.java
@EventHandler
public void onNpcClick(NPCLeftClickEvent event) {
if (event.getNPC().getId() == 1) {
Player p = event.getClicker();
qm.addPlayer(p);
p.sendMessage("You have been added to the queue");
}
}```
what do you mean teh size doesn;t change?
clouds
That list is static
well i have a cmd to check the size
QueueManager qm = new QueueManager();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
if (args[0].equalsIgnoreCase("size")) {
p.sendMessage(qm.queue.size() + "");
} else if (args[0].equalsIgnoreCase("inqueue")) {
if (qm.queue.contains(p)) {
p.sendMessage("You are in the queue.");
} else {
p.sendMessage("You are not in the queue.");
}
}```
You should be referencing it statically, or it should just not be static
i tried it not being static to no avail
so i was in the process of converting all to static
and what's the issue?
the arraylist size isnt increasing whenver i add my player to the arraylist
from what you have shown (other than the non static access of a static list, there is no reaosn for it to not grow
:/
what other can I show
could you perhaps be creating a new manager each time?
QueueManager qm = new QueueManager();
i may or may not being exetremly dumb, but i think i am
as you show yrou code disjointed theres no way for us to tell
package net.ntdi.sumocombo.listeners.logic;
import net.ntdi.sumocombo.commands.staff.CloneDuel;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.ArrayList;
public class QueueManager {
public static ArrayList <Player> queue = new ArrayList<Player>();
public static void addPlayer(Player player) {
queue.add(player);
}
public static void removePlayer(Player player) {
queue.remove(player);
}
public static void removeAll() {
queue.clear();
}
public static int getSize() {
return queue.size();
}
public static Player getPlayer(int index) {
return queue.get(index);
}
public static Player getNextPlayer() {
return queue.get(0);
}
public static void group(Player p) {
if (getSize() >= 2) {
Player player1 = queue.get(0);
Player player2 = queue.get(1);
DuelManager.copyWorld(Bukkit.getWorld("Airena"), "duel_" + player1.getName() + "_" + player2.getName());
queue.remove(player1);
queue.remove(player2);
player1.sendMessage(ChatColor.GREEN + "Your queued duel with " + player2.getName() + " has been started!");
player2.sendMessage(ChatColor.GREEN + "Your queued duel with " + player1.getName() + " has been started!");
player1.sendMessage(ChatColor.GRAY + "Teleporting to the duel arena...");
player2.sendMessage(ChatColor.GRAY + "Teleporting to the duel arena...");
player1.teleport(new Location(Bukkit.getWorld("duel_" + player1.getName() + "_" + player2.getName()), -3.5, 52, 4.5, -135, 1));
player2.teleport(new Location(Bukkit.getWorld("duel_" + player1.getName() + "_" + player2.getName()), 4.5, 52, -3.5, 45, 1));
} else {
p.sendMessage(ChatColor.RED + "Waiting for 2+ players to join the queue");
}
}
}
``` QUEUEMANAGER.java
package net.ntdi.sumocombo.commands.staff;
import net.ntdi.sumocombo.listeners.logic.QueueManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class QueueCheckCommand implements CommandExecutor {
QueueManager qm = new QueueManager();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
if (args[0].equalsIgnoreCase("size")) {
p.sendMessage(qm.queue.size() + "");
} else if (args[0].equalsIgnoreCase("inqueue")) {
if (qm.queue.contains(p)) {
p.sendMessage("You are in the queue.");
} else {
p.sendMessage("You are not in the queue.");
}
}
return true;
}
}
``` QueueCheckCommand.java
if that's static why not access it doing QueueManager.queue?
^
your queueCheckCommand is using its own queue manager
Coll you look like a static
only IF his queue is really static. If it is his IDE would be screaming at him about non static access
True, but it would still compile
oh he made all methods static
yea
Unless doing instance.<something static> somehow doesn't point to the same thing as Class.<something static>
Yep, I see no reason for your queue to not grow if you add more than one player
are you ever calling group?
thats my queueing function
so not yet, i wanna get the queue to actually work for adding and removing
that ill add that into play
are you adding two actual players to test?
yes
also it works now, had to rename to static for everything
thanks for the assitance
š
i need help with custom enchants
- how do i make it only work on picks?
- how do i make it conflict with certain enchants?
ok i think ik how to make it conflict but idk how to make it only work with picks
How are you applying the enchantment
Adding it to items
oh i didnt do that yet
Well, you would check for the right item then
but i think ima make it from enchanting table, book, etc. like the normal mc enchants
do they work with those
custom enchants
Not automatically
lol
VillagerAcquireTradeEvent
hey could anyone look at my thread? #907772462077452328
Define show up in the enchanting table
like in the enchantments list when a pickaxe is put it
You can modify the suggestions in the PrepareItemEnchantEvent
But I don't think it works with custom enchantments because the client has no translation key
Inventory not matching on InventoryClickEvent
cant seem to find the packet play out class
are you talking about the wiki or nms?
?jd-bc
huh?
Hey me again, I need to make a countdown but its in a static function and I need to use static variables but the variable stays after the countdown is done, not getting reset. What can i do?
SumoCombo.getInstance().getServer().getScheduler().scheduleAsyncRepeatingTask(SumoCombo.getInstance(), new Runnable() {
@Override
public void run() {
if (nume != -1) {
if (nume != 0){
player1.sendMessage(ChatColor.YELLOW + "" + nume + "s");
player1.sendMessage(ChatColor.YELLOW + "" + nume + "s");
nume--;
} else {
player1.sendMessage(ChatColor.YELLOW + "GO!");
player2.sendMessage(ChatColor.YELLOW + "GO!");
nume--;
canMove.remove(player1);
canMove.remove(player2);
canMove.put(player1, true);
canMove.put(player2, true);
}
}
}
}, 0L, 20L);```
my code
why do you need to make a static function
because
because?
becuase I call a static arraylist
...
You shouldnāt make any of it static
Static will make your code a global mess
im 99% sure you can grab static data in public methods
i do it for my static maps
You can
hmph ig ill remove and see what happens
But again, you should avoid static
well
Using static makes your code not unit testable which sucks
My plugins have a few static final constants and thatās about it
static is ok for data vars that get used across classes right?
no
then what do you do for hashmap and such
i use Queue q = new Queue();
Create a repository/registry/manager class
Create methods to access it
cause hashmaps return null values when accessing them across classes
wouldnt that be bad if the thing werent static..
And encapsulate the damn data structure
No they donāt?
then i must be doing something terribly wrong
Yes
oh you know what it probably is
im creating the instance for the class that grabs the hashmap in the constructor so the values dont exist yet
Only solace static provides is the fact that itās faster than other stuff in Java, though at the cost of zero object orientation
Sounds like a micro optimization
I have my bStats and plugin IDs static
ok can someone hold my hand through this packet method lmao this is the first time ive done nms https://wiki.vg/Protocol#Spawn_Entity
And some util methods, and a few enum sets of materials, thatās about it
For true constants, pure methods, helper methods, singletons static, inner classes, identity keys, sometimes immutable objects, static is fine imo
The singleton topic is still a hot debate
Like my managers and registries could all be singletons, but I donāt have them like that
Itās just that most spigot devs are obsessed with it
singletons?
yes
Classes that will only ever have 1 instance basically
getInstance,
somethingInstance
oh yikes
Your plugin class is a singleton
are they just used for like startup and shutdown?
An enforced one at that
Theyāre used for resource intensive objects that may not even be used during runtime
and they can be used for configurations or something
ah
And technically managers and registries and the like
With that being said, having an upper interface to make it mockable is highly recommended
Mockable?
Speaking of static singleton, an unjustifiable imprecise use case is if you only need one instance of something
When you start setting up unit tests youāll realize how you often will be creating tons of instances of that very class
Ah
Iāve not done much with unit tests, only a bit in college
I mostly work with other games, so it isnāt really an easy option
Oo yeah ah
yeah so uh i started java over the summer
so im understanding a good 20% of what you're saying
lmfao
Anyways mocking is a technique when we control an object in a certain way to make our tests pass
Often it requires us to extend the already existing class of the object
And override logic
Thatās why interfaces are nice for precisely that
Ah
I should probably do more unit testing stuff
Iām sure one day itāll be very useful
Yeah, tdd is supposed to be fun, which probably would be the case if I didnāt get my tests to fail all the time
I think mini posted a minecraft unit testing project the other day
Itās fine, but ask away if there is anything of course, no google questions tho lol
uhm
Oh that was integration tests
ok so im doing nms rn
But yeah almost the same
its also very mean
how much of the params do i need to use to get the bare minimum to work
mocking people for things out of their control š
Can we mock Mojang for some of the weird stuff that goes on inside minecraft
Lol
like squid ai
How can I store a short string in the nbt of an itemstack?
Iām convinced some of the code is basically an SCP
?pdc
Looks like all of it
But I donāt work with packets that much
hm ;\
also the wiki says things like entity id and uuid
im not sure how i get the uuid if the entity doesnt exist yet
and i dont know what an entity id is
Doesnāt the packet constructor just take an entity
so just make a EntityChicken and then shove it through the PacketPlayOut method?
contains entity type, coords, velocities, etc.
The constructor does?
public PacketPlayOutSpawnEntity(int var0, UUID var1, double var2, double var4, double var6, float var8, float var9, EntityTypes<?> var10, int var11, Vec3D var12) {
this.c = var0;
this.d = var1;
this.e = var2;
this.f = var4;
this.g = var6;
this.k = MathHelper.d(var8 * 256.0F / 360.0F);
this.l = MathHelper.d(var9 * 256.0F / 360.0F);
this.m = var10;
this.n = var11;
this.h = (int)(MathHelper.a(var12.b, -3.9D, 3.9D) * 8000.0D);
this.i = (int)(MathHelper.a(var12.c, -3.9D, 3.9D) * 8000.0D);
this.j = (int)(MathHelper.a(var12.d, -3.9D, 3.9D) * 8000.0D);
}```
it's just this right?
or is it the stuff right after the class gets created
Yeah thatās it, I just figured it would be simpler
mhm
Huh
kinda sucks this server doesnt support pictures
i guess they dont have enough moderation for that
ah
Looks like itās mostly x y z and velocity
mhm
i just get tripped up with the entity type and data and stuff
since im guessing it's not the typical EntityType.CHICKEN
int but itās called fishing float, interesting Mojang, very Interesting
that's mojang?
i thought this was all spigot or bukkit's interp. of the source code
Oh that not mojang oops lol
Hmm depends but usually a class which encapsulates an instance of itself
The game used to refer to the fishing bobber as āunknownā iirc
class B {
void doStuff();
}
class C {
B b;
C(B b) {this.b=b}
void doStuff() {b.doStuff();}
}
Iād call C a wrapper for B
But generally wrapper is a very vague name
As there are different types of wrappers
(Which has official names)
Yeah
when you get into libraries and want to combine libraries to achieve your goal, wrapping is necessary
suppose you have logic from library A, and logic from library B
and you dont want your users to shade both libraries
you can have a wrapper class for library A and library B
dont know what shading is
and have methods which call from them
basically just including dependencies
oh well making a class that calls from multiple classes seems a lot more useful than calling one single class
not necessarily
Anyways if youāre truly interested in wrappers look up
Proxy
Bridge
Adapter
Decorator
Composite
^
Theyāre all different kind of structural design patterns regarding wrapping in one or another way
There are some behavioral ones as well but skip that lol
another good example, NMS
ProtocalLib is a good wrapper with NMS so it translates the raw packet classes into usable API
So you don't have to write code using NMS and you can use just ProtocolLib because the library wraps the NMS classes
Yeah splendid example
protocollib seemed interesting
but doesnt have what i need for my current project so i had to skip out
@EventHandler
public void chickenPacket(PlayerInteractEntityEvent event) {
WorldServer world = ((CraftWorld) event.getRightClicked().getWorld()).getHandle();
EntityChicken chicken = new EntityChicken(world);
// 'EntityChicken(net.minecraft.world.entity.EntityTypes<? extends net.minecraft.world.entity.animal.EntityChicken>, net.minecraft.world.level.World)' in 'net.minecraft.world.entity.animal.EntityChicken' cannot be applied to '(net.minecraft.server.level.WorldServer)'
Location loc = event.getRightClicked().getLocation();
chicken.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
EntityPlayer player = (EntityPlayer) event.getPlayer();
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(chicken);
((CraftPlayer)event.getPlayer()).getHandle().b.sendPacket(packet);
}}```
alright so im getting that error in intellij
but if protocollib broke then everything will break, it is a big project ngl
It did break a bit at the start of 1.17
so i think this is breaking cuz i put worldserver and in the method, it wants some other type of world
@NotNull net.minecraft.world.level.World world)```
but setting WorldServer to World doesnt change anything
WorldServer extends world
ye i assumed it would
not sure why giving it exactly what it asked for is bringing up a problem
would i need to also insert that first param
yeah i think i just need to add the entity type
oh wow
just took a look at the entity type class
feel stupid
wait no that was bukkit entities
is there a reason as to why all these parameters need to be this.a, this.b, this.c
seems like laziness to me
its deobfusticated
well obviously not very well if the DE obfuscation has param names that still seem obfuscated lmfao
cannot access net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity
im getting this error when compiling
You canāt magically get names back without mappings
The decompiler canāt get the original names of the methods back
@patent horizon what is your problem
cant access the original methods from nms when compiling my plugin
which are the errors
.
did you added the spigot to the pom/build.gradle?
for this you need craftbukkit if im not wrong.
hmm
my kody simpson tutorial said otherwise lol
do you know the pom stuff?
or where to find it
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
would i replace spigot or just add another one?
try add... i not use nms so many then i forget xd
Could not find artifact org.bukkit:craftbukkit:pom:1.17.1-R0.1-SNAPSHOT in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
Use spigot build tools
you'd need to run it as well, simply downloading it is pointless
Okay, use the spigot dep and then remove the -api part
that's it
yes, you can access nms, packets
that wouldnt explain why i cant access the functions
show full pom
this is craftbukkit, not spigot
yeah the other dude told me to get a craftbukkit dependency
run the version that you want to use
javaĀ -jarĀ BuildTools.jarĀ --revĀ 1.17
or this one
javaĀ -jarĀ BuildTools.jarĀ --revĀ 1.17.1
oh in the gitbash?
ive already did that step
i have all the spigot, bukkit, craftbukkit, etc. folders
i dont have any errors in the pom
it cant access PacketPlayOutSpawnEntityLiving but it can access EntityTypes and EntityChicken
Try invaliding caches and restarting your ide
nopers
package me.wally.cybercade4.Lobby;
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.animal.EntityChicken;
import net.minecraft.world.level.World;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class ChickenPacket implements CommandExecutor {
public void chickenPacket(Player player, Location loc) {
World world = ((CraftWorld) player.getWorld()).getHandle();
EntityChicken chicken = new EntityChicken(EntityTypes.l, world);
chicken.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(chicken);
((CraftPlayer)player).getHandle().b.sendPacket(packet);
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (s.equalsIgnoreCase("chickenPacket")) chickenPacket((Player) commandSender, (((Player) commandSender).getLocation()));
return false;
}
}
am i missing something?
wow ghost pinging š
are you using java 16 for that project?
1.8 correto or whatever
1.17 require java 16
oh right
outdated compatibility only works with spigot api
lol
is there an easy way to change jdk versions without making a whole new project?
so uhh
the language of java didnt astronomically change when going from 8 > 16 right?
yeah, nothing breaks
awesome
wait so if i leave the server while an entity packet still exists does it automatically get destroyed?
yes it will
ah ok groovy
if i make a player think they're riding an entity created from a packet, can they just walk around normally?
thats to open the project structure
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>```
the ${java.version}
you replace with 16
or 17 if you want
or you can do
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>```
this it will convert the whole project and promise it will always in java 16
while the project structure only change the language to java 16, but not save it to maven...
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>```
can i just change that to 1.16?
yessir
so it will have that thing
if normal then you have to set the properties like what i do, or just configuration it
change 1.8 to 16
...
reload maven then it will auto change to language 16
and leave out the 1.
p.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, Integer.MAX_VALUE, 1, true, Color.WHITE));
Anyone know how to fix this issue??
I just found out that PlayerInteractEvent fires when you drop an item, is there any way around this?
Hover over it and it will tell you
yeah ik that
i did that and it says the "Color" aspect isn't a thing
when it is
see
then remove the colour :/
event.getAction();
yeah but i dont want to bc i want colors to be a part of this glow effect.
That is not how the glow effect works, im pretty sure you have to be in a team with a coloured display name
it counts dropping an item out of the inventory as Action.LEFT_CLICK_AIR
i did my research and it says you can apply colors to a glow effect.
even the java docs even states you can
send a link
declaration: package: org.bukkit.potion, class: PotionEffect
"Creates a potion effect with no defined color."
Im 100% sure its not referring to the colour of the glow
you do know potion particles are coloured
yes ik that
I told you, they have to be in a team with a coloured name
did you create the team through the plugin
No bc i did it manually via mc commands before hand./
okay i officially am so confused with mc
now when i do the cmds in-game it works and yet before it didnt im so confused.
/team modify <team> color <teamColor> that will do it, if not then you will have to do player.setGlowing(true);
ok well that works
What did you mean by anyway around
np š
i meant is there a way to ignore it if its dropped out of the inventory, rather than an actual left click
but why do you need to ignore it, like why are you using the event
so EntityPickupItemEvent is deprectated? what should i use instead, i want to check when an item enters a player's inventory whether by picking up an item or grabbing something out of a container, what should i use?
Edit: my bad just saw PlayerPickupItemEvent is deprectated but not EntityPickupItemEvent haha
Also, is there a way built into spigot to make a player have the glowing effect visible to select players without using packets or protocollib?
this question
no
Hey is the BukkitScheduler persistent? Like does it takes on restart.
why so
To end a weekly contest.
Ig you'd have to reschedule a task everytime
Or, maybe, run a task every minute and check if current timestamp equals or more than timestamp you set
I was thinking of using a external scheduler like JobRunr which has built in persistence
Plus we are using redis, so it will be easy to setup with that
I was just asking if bukkit did, because if so I would just use that
any misplaced {s or }s here?
learn java
"any" 
put your return true inside the last bracket and give your if some
also strings dont work like this
if (command.getName().equalsIgnoreCase(anotherString: "appeal")){
any ideas on missing )s here?
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.
did you just copy that line from your IDE verbatim
because anotherString: is the intellij hint
whats that unknown variable
ah
ouch
You probably want to use the system date for something like that
The p variable doesnāt exist, and sendMessage is lowerCamelCase
Like all java methods should be
wait i really thought he was trolling
oh LOL he really didnt even know how java works?
...
see what calenderevents does
an Item is an entity, an ItemStack is an item in inventory
you have to drop it, theyre two different things
Why it is not working?
if (vaultHook != null) {
format = format.replace("\\{prefix\\}",
vaultHook.getChat().getPlayerPrefix(player));
format = format.replace("\\{suffix\\}",
vaultHook.getChat().getPlayerSuffix(player));
}else {
format = format.replace("\\{prefix\\}", "");
format = format.replace("\\{suffix\\}", "");
}
format = format.replace("\\{player\\}", player.getName());
format = format.replace("\\{message\\}", message);
return format;
It should replace {player} to player name and etc.
I dont think those \ is needed for replace, only replaceAll
and what happens instead?
What Exception is thrown when it's not possible to parse it to a List? Or even better, how do I lookup Exceptions through Google when it's not stated in the docs? Do I just have to catch a generic Exception here?
(List) drop.get("commands")
ClassCastException
But ideally you could just check the type (with instanceof) and then cast
You need at least 5 years of java experience to understand that š¤
This would be my code now:
List<String> dropCommandsList;
try {
dropCommandsList = drop.get("commands") instanceof String ? List.of(drop.get("commands").toString()) : (List) drop.get("commands");
} catch (ClassCastException e) {
dropCommandsList = null;
}
So you would rather first check if (x instanceof String) then else if(x instanceof List) and then in the else block set it to null?
why dont you simply...? just use list.of in the first place?
Does List.of(x) accept a list as argument?
That gives me a warning:
Because at that point it's not know what kind of content the list has. The list comes fresh from a yaml file
wow...?
you already have that toString
and that warning isnt an error right?
i guess i will leave it normal there.
My bad, it's indeed an error, not a warning, I can't compile it without using toString() .
I might have a logic flaw in there, not 100% sure it even fires.
hey
why dont you just use a if check
if you use java 16
you will have pattern
it is the best thing java ever give to me lol
wait
oh no
sorry im dumb lel
Well, the good news is, my code seems to work. I just gotta find out if the instanceof String ever is true, because I'm not so sure anymore š
List<String> commandsList;
try {
commandsList = dropsMob.get("commands") instanceof String ?
List.of(dropsMob.get("commands").toString()) :
(List<String>) dropsMob.get("commands");
} catch (ClassCastException e) {
LoggingUtils.warn("Incorrectly formatted commands for entity " + dropsEntityTypeString + "");
commandsList = null;
}
Thank you!
does anyone here actually bother doing TDD for their minecraft plugins?
What is tdd?
test driven development
buzz words
I mean... it's a real thing
it is
it's also widely used, but whether it should be used for games is controversial
Ah, unit tests and stuff?
yep
game development usually progressess too fast for TDD
unit tests come once you have teh framework mostly complete
I know devs that do tests
but, personally, im not. Just doing static void main and testing stuff which doesnt depend on running server
yes some devs implement unit tests but its not TDD. Its teh actual reverse
TDD is driven by the unit test you design.
afaik tdd always puts the tests first no matter where you're at with writing the code
What is drop?
Yeah well youāll be missing out on decoupling stuff if you just write your tests after lol
So probably end up with the test fragility problem
another important question, what do you do when you are trying to develop but can't even type properly because you're sore from the gym
please send a reply for this one real quickly, it's killing me
what event is fired when player changes a item location in its own inventory?
So.. I'm looking for some code (that will not be published on the spigotmc website as it violates it's TOS) where if the license of my plugin is invalid, the plugin will corrupt itself. Anyone has any clue how to achieve this? I already have code for checking licenses, so basically just need a function to self-destruct the plugin
either delete itself (which I know you cannot do when it's in use) or just break itself.
I'm writing code for a client that is known to well, not pay at all and just take your plugin.. I'd like to protect myself š
Simple, get payment up front
The net.minecraft.world.entity.EntityTypes mapping was removed?
Yeah... but still.. it would be nice to have some protection.. It would be a subscription based plugin as I provide the API for it on my server.
(1.16.5) EntityTypes.COW -> (1.17.1) EntityTypes.n
make 2 jars
in PlayerInventory#setHelmet() how do u give player empty value? like to set his helmet to air?
Null?
O
wasd?!?!?1
its from paper discord
oh ok...
but i think he can set it to air too...
or inject in a plugin, code for self destruction
a random plugin
and when injecting, send the plugin name to you
would it be a cool idea if i break all the spigot things like remove and change things around to make it my own jar š
Then sell it for 1000$ on mcm
that would just be your mentioned second jar
Yeah but, they wouldn't know which one
but can't you as a user just remove the code which injects the jar and recompile the jar?
"not malicious" - want to inject a random plugin to destroy another
Well, it's a protection measure
i mean creating a second jar is probably the way to go, but we still are in java. you can just remove the self destruction
obfuscation doesnt stop them, it just slows them down
the jar is loaded, you would have to externally unload it and delete it then. not sure if thats possible while leaving the server on
I mean, intave has a wierd licensing system
they need you to be able to have a folder .intave
where there are some files with wierd names
And their license it's per machine, you don't need to enter some sort of key
https://stackoverflow.com/questions/47017755/how-can-a-jar-file-delete-itself doesnt seem too bad
you mean you actually have to purchase a license for every server you run?
so 1 license = 3 servers?
the rest are 5⬠per machine per month (don't remember exactly)

So you buy the plugin once

And you can use it on 3 machines no extra charge
define machine. machine = server?
if you want to add it to more than 3 machines, there is a monthly payment if i remember right
idk if it was monthly or a one time payment
ah
How do u get a players minecraft version in 1.17? I checked this https://www.spigotmc.org/threads/getting-a-players-version.203346/ But theres no "CraftPlayer" class anymore
But i think they can see if two machines are on 1 ip
that would be the smart thing to do
easy money
they removed the mapping
so CraftPlayer now is b or g or whatever
no clue of nms
CraftPlayer is Bukkit. It shoudl exist just fine
but not the way to it, right? still have to go over a method or not
CraftPlayer is fine, but beyond getHandle you have to know the mappings ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion()
getHandle returns the nms object, so thats where you need to find teh mapping
yeah good at least i was not totally wrong
im sure the spigot API has a method for this.. or maybe im confuse with paper..
huh?
how can i get my plugins instance if no dependency injection is possible?
i was thinking about a getInstance method in the main class, but should that return this or getPlugin(getClass())?
why is di not possible?
its not really logic to construct and user that you need a plugin instance
also for my enum i need a better way
enums shouldnt depend on plugin any way
its to access the lang file
its logical if you actually need a plugin lol
you shoudl probably consider seperating yoru enum and your translation/language
^
keep your enum as a straight enum, then pass it to a translation method
hmm
can someone tell me the method of changing the whitelist msg
public class maintainence implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
sender.sendMessage("The Server is in now maintainence mode");
Bukkit.getServer().setWhitelist(true);
return false;
}
}
not very difficult
ok
What would be the difference between the following two lines and which one is preferred?
I'm getting the map from a config file so I do not yet know what kind of data it contains.
Map reward = (Map) configReward;
Map<?,?> reward = (Map<?,?>) configReward;
So they will behave exactly the same? I'm actually just trying to get rid of the warnings my IDE is giving me š
is a stringlist path also a configurationsection?
what
or a configurationsection is
root:
child1
child2
and a stringlist is with - blabla?
think
@SuppressWarnings("unchecked") :kekw:
raw use of parameterized classes is not cool
No, it's not a configuration section.
be a giga chad and dont suppress any
# Configuration Section
root:
# Keys
child1:
child2:
lovely-child1:
i-hate-that-child1:
# Configuration "Section" - Path, so more a like Key.
raw:
# Stringlist
- "Child"
- "Another Child"
- "Hah, guess what? A dog"
- "Child2.0"
yeet the child
imagine calling your children child1 and child2
thanks
hell yeah 10 sonarlint issues down, 824 to go
am i wrong or is there a #removeIf(predicate) method in a map?
could be in a set or something too
aha
be a terra chad and dont cause any
how do i get the gamerprofile thingie, and also what is it
i googled to see how to get the repository and dependency but someone said it's illegal?
its from java.auth
you can use minecraft libraries repo
or i think spigot artifact already has it
iirc yes
ok, thanks
btw do you have any tips for not doing spaghetti code? rn i'm just adding comments for like every line and the code itself is just a big mess
i require help
comments arent necessary if your code is written well
written well 
thanks
yw
but if you have big chunks of code :kekw:
Some events cannot be cancelled. There's backend logic behind every single event when it gets "cancelled". If an event doesn't have that, it won't implement cancelled.
is a permission case sensitive?
no i'm making my own
ah shit
and iirc permission objects are stored somewhere after server shutdown
not sure if i can delete the wrong ones
no
As expected from a Map with string keys ?
𤦠meant to check value not key xD Thx
cant you declare variables in a .forEach(e ->)?
you can
well it says this
You need curly brackets for your if statement?
yeah more then 1 line ^^^^
aah first line
does anyone have a good tutorial on coding multiblock structures? I found one singular tutorial and it doesn't work for my use case
i have a method that sets an ItemStack field to an item, that method is run on onEnable in the main class.
however, when i try to get it on an event in another class, it returns null. does anyone know why this happens?
lmk if you need the code
uh yeah show the code
what is the Enderpearl damage cause
(I want to use it in EntityDamageEvent)
Fall I think
fall damage
ah thats bad btw thanks
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent, enum: DamageCause
list of all damage causes ^
for future reference
guys i am trying to translate a class but everytime i try i always get this error
[19:54:08] [Server thread/ERROR]: [PlaceholderAPI] failed to load class files of expansions
java.util.concurrent.CompletionException: java.lang.ClassFormatError: Unknown constant tag 117 in class file net/alex9849/advancedregionmarket/placeholders/implementations/RegionCountPlaceholder
at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) ~[?:1.8.0_281]
at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) ~[?:1.8.0_281]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) ~[?:1.8.0_281]
at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source) ~[?:1.8.0_281]
at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) ~[?:1.8.0_281]
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) ~[?:1.8.0_281]
at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) ~[?:1.8.0_281]
at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) ~[?:1.8.0_281]
Caused by: java.lang.ClassFormatError: Unknown constant tag 117 in class file net/alex9849/advancedregionmarket/placeholders/implementations/RegionCountPlaceholder
at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_281]
at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.8.0_281]
at java.security.SecureClassLoader.defineClass(Unknown Source) ~[?:1.8.0_281]
at java.net.URLClassLoader.defineClass(Unknown Source) ~[?:1.8.0_281]
at java.net.URLClassLoader.access$100(Unknown Source) ~[?:1.8.0_281]
at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_281]
at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_281]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_281]
at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_281]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_281]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_281]
at me.clip.placeholderapi.util.FileUtil.findClass(FileUtil.java:62) ~[?:?]
at me.clip.placeholderapi.expansion.manager.LocalExpansionManager.lambda$findExpansionInFile$6(LocalExpansionManager.java:359) ~[?:?]
... 6 more
how can i fix it
gotta show us your code :)
its not my code wait
translate a class?
what exactly are you trying to do? if this isn't your code lol
placeholderapi
there is a placeholder if a plot sold its writes sold but i dont want to see like sold i want this on my language
so what did you change to try and do that? if you're just configuring a file you can change that in their lang config. this is more of a #help-server question btw
when i change the api is breaking down
smh why did someone told me to store help messages
what i cant understand you
are you using the papi api?
yes
uhm are we looking at bytecode?
what means bytecode xd i dont know like this terms
papi
thats a compiled java file
i think you are trying to edit the code instead of just configuring the plugin
yes
yeah you don't want to do that
you can change the word to match your language without recoding the plugin, there is probably a configuration option for that
i just trying to translate this words but there is no config yml because its a papi api its in the placeholders api file and its jar
what plugin is using papi to say "sold"
Even if you did want to modify PAPI itself, you should fork it on Github and change the source directly, not the bytecode š
cause thats where the config would be, not in papi
what are you even trying to do?
i dont know what means bytecode guys i am not a developer
addvancedregionmarket-placeholders-1.0.2.jar
you want to go into advancedregionmarket folder in your plugins folder
there should be some sort of config there to change the words
you want to rename a message from that advancedregionmarket plugin?
no coding involved
^^
yeah he just wants to change a message/lang file lol
Open the JAR in Notepad ez
xy moment?
probably more of a language barrier issue id imagine
dont you code nowadays in notepad anyways?
Like 99% of the time yes
notepad++ gang
The other 1% is spent drawing out code in Paint
there is nothing about sold
i checked now but i cant do anything
is there a file named "lang" or "messages"
anything like that
oh yeah and the paper devs on paper
then you might be considering to use another plugin :kekw:
TacoSpigot on tacos š®
messages.yml
messages.yml
messages.yml
i checked all ymls but its not here
send messages.yml
actually whats the issue
He's just trying to change a message that a plugin is sending
while everyone is here maybe consider helping me out haha
It's a configuration issue
^
Wdym multiblock structures Livvy
so he does wanna change it by itself or via code?
Like just pasting in many blocks at once?
i found sold but there is nothing for free placeholder
store the location
clicking on block x only does something if a specific structure is built in specific area next to it
just replace the word sold with what you want it to say
doesnt need anything about placeholder
doesnt the worldedit api has something for that?
everything ive seen with the worldedit api has been for pasting a schematic
verifying structures
hmm
it may have a verifying structures ability but i wouldnt know it
Does WorldEdit maybe return how many blocks were changed? If you attempt to paste the structure, and 0 blocks were changed, that would mean it's valid
that should do t
do you actually have a custom structure generator or do you f.e. want to do smth near a specific tree?
%arm_regionplaceholder_lunaroda-17_owner%
daily reminder that if you're not coding but editing configs for plugins you're not making, that's a #help-server topic
well i have a specific build that i did that i want players to have to build to create an object

like the mario party game rebuild?
or like extend it?
some forge mods have multiblock structures if that helps lol. you build out of blocks a specific build and that registers with the code that it is all one specific structure and you can interact with it
An example of this would be Enchanting Table and it's books, right?
think like the blast furnace from railcraft
ehhh sorta
except it would only work if the books were there
for example
thank you livvy
either you check for a pattern or if you know what it would be you store the location
yeah check for a pattern
thats what im trying to figure out lol
because i can check for a pattern but only in a circular symetrical way
Guess you could store a map of block types with relative locations
like i can check that all blocks around a center item match
but detecting it because of cardinal directions changing x and z values is making it weird to do a non-symmetrical structure
like brewery has those big barrels and slimefun has the machines
if that helps anyone understand what im looking for lmao
the only idea i have would be to check your area for those blocks and if it contains multiple of them and they are even side by side, true it
that was what i was gonna try at first, but i need to edit player location based on the location of the blocks, so i wasnt able to do that (cause it sends the player to the wrong place) :((
im gonna look into worldedit api but ive never used it so thats a lil worrisome
Yeah, if WorldEdit can return the blocks changed before actually pasting the blocks you should definitely just use that.
@quaint mantle
How can i fix VotingPlugin keeps failing to load votesites.yml
how dafaq can i disable moving items in a specific gui only?
ik its InventoryClickEvent
but how do i get the inventory's name
a better way is to let your class class extend InventoryHolder and when creating the inv, use Bukkit.createInv(this, name i guess, slots etc) and in the listener check for the event.getInv.getHolder instanceof ... -> cancel
No, bad


