#help-development
1 messages · Page 1609 of 1
mannn
will explode unless you add a max depth condition or heuristics
i cant find why my thing isnt working
yeh
hmm ok
for heuristics, sort the list of a node's neighbors based on the estimated distance to the destination
so that the closest node is put on the stack last
So you can't help me?
and is therefore popped out first
borat do you have an idea
your code is illegible
use more newlines
group blocks of code together
uses sysouts or whatever to figure out what is stopping it from working
you could also use a binary heap in place of the stack I suppose, with a comparator comparing the estimated distance to target
that may be better or faster or slightly slower than sorting the neighbors
the standard java impl for a binary heap is the PriorityQueue
would using a json file for punishments be better than using a sql database
define punishment
ban, warn, kick etc
db would be more robust, but not necessary
not at a scale
preload a player's warning data to memory on asyncprelogin
borat it actually works now - it returns the target node ....
the downside of json is that it's not easily shared across servers, and every time you need to retrieve something from it, you need to read through the entire file
alright ill use sql
or keep the whole file in memory at all times to avoid having to read it
yeah I don't think json would help in the long run at all
im thinking of having an entire thread dedicated to handling async queries and loading player punishment data to a map when they login
probably not necessary
should i just load everything into a map at the startup?
you should load things to a cache during async player prelogin
and optionally block the event until the data is retrieved
that second one might cause issues
only if your data retrieval takes longer than 30 seconds
at which point you have bigger problems
yep
whats wrong with loading everything to memory then sending it back to db on disable, like a map
that's not scalable
you'll end up with 60 thousand players' worth of shit you're probably not going to read in memory
loading arbitrary amounts of data on startup straight into memory is a fun way of finding out how many people have thousands or millions of entries
granted, some plugins like towny do do it
but that's more because there is no feasible alternative or because the changes involved in doing it differently would be infeasible
Is there a way to get the class that called a method?
public class Test {
Methods.runMethod();
}
public class Methods {
public static void runMethod() {
// System.out.println("Class that called this method");
}
}
or because of bad initial implementation and not having the patience to fix it
use StackWalker on java 1.9+ or whatever that class was called
or dump the thread's stack and look at the immediately preceding frame on java 1.8
there's also a reflective method to get the calling frame on java 1.8 but I remember that being haram for some reason
make the method require itself as a param
Object or Class<?>
maybe reflections
I saw something using reflection getCallerClass or something like that. But that method doesn't work exactly how I wanted.
no lol
Need... no... I want that info so I can display as debug
its most likely a bad design pattern
well
use stackwalker
you can always throw an exception
and get the stack trace
So if a class outside of my plugin is doing something I can display which class is calling the method
that is very slow but if it isn't a super hot loop and only for debug, it's probably fine
the advantage of the stackwalker is that it doesn't need to shit out the entire stack trace every time
but it does have a little bit of a learning curve iirc
Funny enough I just saw StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass() lol
Got me thinking if sponge which is entirely switching to a key based system
https://www.youtube.com/watch?v=FIACGmzibAM&t=1383s&ab_channel=KodySimpson The thing you are talking about is called "Reflections" but i don't think you need to use it for display logs
In this episode, I show you the basics of reflection in Java. Reflection put in simple terms is the process of deconstructing classes and data structures using code itself, dynamically at runtime. #Java #Reflection #JavaTutorial
Code: Coming Soon
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite ...
he knows what reflection is
Yeah also reflections != reflection for anyone who’s mixing the together
^^^ imaginedev's msg
Also... reflection is for getting classes when you have their name lol. Not for getting which class is calling the method you're running.
well
Reflection is for scanning at runtime I’d say
technically reflection is all actions that pertain to code looking at itself, that is, reflecting upon itself
Well yes we can invoke stuff
so getting the calling class of your method is sort of reflection
But that’s probably more performant with method handles now
technically then lol
well, for example by @fresh templetHandler attribute spigot register unknown methods to then invoke them
Non-static method 'setCooldown(java.util.UUID, int)' cannot be referenced from a static context is becuz ineed an object right
Myes partly
It’s not like instance methods can’t be invoked in static context
You just can’t reference a non static method in a static context
non-static methods exist on objects
if you don't have an object, you don't have a method
because the method is part of the object
and hence you can't call the method, which you don't have
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
has some mistakes
i mean its easy to fix them yourself
most spigot resources do
yeah ig
I should update that
Where exactly ;o
Non-static method 'setCooldown(java.util.UUID, int)' cannot be referenced from a static context
is one for example
Guys do you know how to get LecternInventory object?
wtf ur intelliJ so fancy
tell me the ways
just google it
sorry for irrelevance
"how to set background image in Intelji"
Idk if you just can magically create one
Especially api wise
what are you doing
even when i get inventory from OnInventoryOpen event, i can;t cast it to LecternInventory
what's stopping you
should i consider it as a spigot bug?
LecternInventory extends Inventory
yea
you can cast it, just make sure to instanceof
as not every Inventory is a LecternInventory
actually looking at the screenshot, it doesn't make sense for that to happen, but I'm not sure how bukkit handles inventories internally
Thread.currentThread().getStackTrace()[2].getClassName() actually works...
digging into it a bit, I don't see why that'd return a craftinventory
the call is forwarded to CraftServer which forwards it to CraftInventoryCreator
which, if it doesn't have an inventory holder, will forward it to CraftTileInventoryConverter.Lectern
which creates a new TileEntityLectern
and returns its inventory
which is a LecternInventory
are you passing it an inventoryholder?
Yeah he did
Well look at that
That might have caused it
yeah if it has a holder the inventory is created by CraftCustomInventoryConverter
but that shouldn't return a CraftInventory like the exception says, but rather a CraftCustomInventory
i would love to somehow set the InventoryHolder but as you can see i have no access to LecternInventory
but how to get LecurnInventory object this is the case
i cant cast it from event.getInvenotry()
to prove i open the right inventory here is the book
Oh yeah you could just have a Set<LecturnInventory> then?
how to fill this set? Look when i try to get LecturnInventory error is thorn up
Of course you’d have to ensure no memory leaks are happening
Try pass null instead of player
ok
Quick one: if I build 1.7, how far will it reach compatibly?
1.8
F
Or might as well say, how do I make my plugins are version flexible as I can
Cuz that’s what I’m trying to do
use nms, proxies
Hmmm
https://github.com/ImajinDevon/GalaxyShop/tree/master/src/main/java/me/imaginedev/galaxyshop/version
take a look here
it shows how you can handle multiple versions
Where you encounter incompatibilities, some abstraction could be a solution
Yeah makes sense
same story ;<
private Instant getInstant(String[] args) {
if (args.length == 4) {
try {
DateTime dt = DateTime.of(args[3]);
if (dt == null) return null;
int type = dt.duration;
return Instant.now().plusSeconds((long) Integer.parseInt(args[2]) * type);
} catch (NumberFormatException e) {
return null;
}
}
return null;
}
better way of doing this?
looks really clunky
Separating things that change across versions, I see
How often are you calling it?
per command
@RequiredArgsConstructor
private enum DateTime {
MIN(60),
DAY(86400),
MONTH(2592000);
private final int duration;
public static DateTime of(String msg) {
String upperCase = msg.toUpperCase();
for (DateTime time : values()) {
String name = time.name();
if (name.equals(upperCase) || (name + 's').equals(upperCase)) {
return time;
}
}
return null;
}
}
its a custom enum
@gleaming grove you might actually have to pass a Lectern
Oh then it’s fine btw
Commands aren’t spammed frequently
aight
you mean to create virtual Lectern and get LecternInventory sounds interesting
Yeah would be one solution, or use nms straight on
yea good idea i create Lecturn at the player position and then send information that he actually stand on AIR
maybe with this approach i can do without NMS
Oo ye
hey is there a good way to get a random block? everything i've seen has relied on MaterialData, which is depreciated
@ivory sleet This is fuck up XD i cant cast block to Lecturn
just pick a random value from the enum
could work ^^
i thought all the blocks were seperate classes with the interface BlockData now?
(Lectern) block.getBlockData()
^
oh i thought you meant material
You don’t cast from the Block directly
random block type or in the world?
yea i made mistake it should be block.getState()
i want to spawn a fallingblock entity with a random block so in the world ig
make sure you import the right thing, there's two different lectern classes for state and blockdata
use blockdata
right i see, thanks for help
Hey, i made a code where a player gets in spectator, when he uses the spectator teleport menu he can't teleport, but i've put a bypass using hashset.
However, players still cannot teleport (they cant use spec menu but the plugin cant teleport them automatically where i want)
here's my code
😩
the only solution or repentance is death
this.bypassedPlayers.remove(player.getUniqueId());
You remove the bypassed player after the first teleport that happens.
This is solvable by writing a new method.
you should delete the old method while you're at it
This should be used each time you want to teleport a player with a bypass.
public void teleportBypassed(Player player, Location location) {
this.bypassedPlayers.add(player.getUniqueId());
player.teleport(location);
}
😬
indeed
haven't we all done that
when i realised that i could not use Thread#sleep() i nearly cried
"wdym i have to use a scheduler???!!!?!??!?!"
idk man, i'm pretty new to java
exactly
so it'd be like that ? doesn't work tho
@Override
public void run() {
public void teleportBypassed(Player player, Location location) {
this.bypassedPlayers.add(player.getUniqueId());
player.teleport(one);
}
player.sendMessage(StringUtils.repeat(" \n", 100));
player.sendMessage(" §a§lIci, c'est la Banque de Comodo Island!\n \n §aIci, vous pourrez retirer de l'argent ou en déposer\n §aen toute sécurité.\n \n §b§lLes taux de conversions sont:\n §8§l- §f§a§l5$ §7pour §a§l1 émeraude \n ");```
i recommend a java beginner tutorial
of the "you can't declare a method inside a method" variety
indeed
quick q:
class a{
void x(){}
void y(){x();}
}
class b extends a{
@Override
void x(){super.x(); ...}
@Override
void y(){super.y(); ...}
}
if i call b.y(); it does a.y() which does ... b.x() or a.x()? It should be b.x() right?
Yes magma
it's pseudocode
b.y() calls a.y()
thanks conclure
(:
a.x
^
wait what?
which calls x()
which forwards to a.x
yes
okay almost fixed it
Ofc not
When you call super you are moving up the inheritance so you are then in a not b
Coloring output stream is slightly more than trivial
shouldn't it be public static void ? since i have an error when calling this method that i cant make reference to non-static method.
how can i add colors to it?
or is that not an option?
Hmm frankly I haven’t done it myself but why not just use Bukkit.getConsoleSender().sendMessage(...);
i think paper supports colors in the standard logger
at least I've never had to fuck around with the console sender to get colors working
well til I learned it takes 8-12 hours to brew black tea in cold water
can i add color to this?
like Chatcolor RED + "something"
Ye
it'd probably go faster if you made the tea in an ultrasound washer
what I've done in the past is put it in boiling water then add ice cubes
that's how it's supposed to be done yes
stuff doesn't want to dissolve at low temperatures
oh no the cold tea police is going to put me down
more like dying of old age because it takes so long
1.5 hours more and I am done
do you even get paid
I'm not staying awake to work, I'm staying awake because I have to attend a social event in 1.5 hours
take a power nap
that's a myth
the only power it would give me is the power to sleep through an alarm
if you drink something heavily caffeinated before going to sleep it works pretty nicely
yall need to stop trying to bait me into going to bed
I'm already falling asleep at my desk as is
you dont have to be in your bed to take a nap
it's one of those things you learn when you're a truck driver and need to drive around despite sleep deprivation
I'm trying to maintain a delicate balance here because I want to be able to go to sleep right after this and not mess up my sleep debt too much
are you being facetious or do you just not know the concept
it's what bears accumulate during the summer
that's why they hibernate throughout winter
facetious... I dont event know what that means.
Im not a native english speaker so i was just wondering if sleep dept is actually a thing.
it is
Ah i see
basically, your body expects you to sleep roughly 30% of your time alive
if you stay awake for 72 hours and then go sleep you're not going to sleep 8 hours
if you sleep less than that, you are more likely to sleep more later, to 'catch up'
or at least you won't feel rested after 8 hours
or 'pay a debt'
Ah now it makes sense
mostly because of dehydration
yep
and only mostly at that
last time I made sure I was hydrated and it still hit me like a truck
you could always just wake up for a quick shit and a snack every 12 hours
not moving for 30 hours isn't good for you
well it's not like you're sleeping on the toilet next to the fridge
How does it feel knowing you slept thru a day tho
I dont even know how to stay awake on order to have to sleep >12 hours at a time.
Last time i was awake for more than 2 days was ~4y ago. And even then i only slept like 12 or 13 hours
longest day I've had was 72h
yeah it's pretty abnormal to go past the 18h mark in my experience
70
only happens when your circadian rythm and your body is crippled
hospital
i sleep at 2 and wake up at 10
I have no circadian rythm lmao
perfect 8 hours
yeah well maybe you should consider a red theme
to not fuck with it
I just can't live in a 24h format
you probably look like borat
i'm not from a third world country
you still can look like em
I never did well with 24h, days should be closer to 30h long for my sleep schedule not to slip
Mine naturally shifts to the night. When i have semester breaks i always tend to stay up longer and sleep into the mid day.
that's racist
but also I keep working with people in japan and the US on a daily basis who are only available at specific times so there goes my sleep schedule
having a tendency towards a 24h+ day cycle implies that you don't know how to relax yourself properly at night
so you need to force your body to be able to sleep by tiring it
an unhealthy and common problem in this modern world
please I don't need you to go into detail about how you "relax yourself properly at night" borat
too much shit going on and too much shit to worry about
consider reading a book, for example
I always read before bed
maybe you read too hard
ah I see
public enum PunishmentType {
KICK,
BAN,
IP_BAN,
MUTE,
WARNING
}
am i missing any punishments
I'm too good at relaxing
no, you suck at it
if I sucked at it how can I be excessively good at relaxing activities
make it a registry so you don't need to worry about missing any
1v1 me at reading
reading a book isn't inherently relaxing
I feel like you might break open closed principle
Depending if you add new punishment types as the time comes
?
oh i get it
in english, you need to modify the source code of your enum in order to add new types of punishments
tbh I also have no interest in changing how I currently do my sleep pattern, I will have to in the future and I already miss doing it this way
And assuming you have a lot switch statements, switching on punishment type then it might be tedious to implement the punishment type, so a sign of rigidity.
i could use some sort of int id for the punishments
but, idk if its even worth it tbh
int ids have their own issues, the only solid and futureproof id is a namespaced key
who doesn't love magic values
Or just have an interface and then a registry with entires and each one derive that interface
i think ill just stay with the enum for now until i understand what the hell yall are talking about 

I think enum is alright
it's 'fine'
temp ban, temp mute
built in
temp ip ban
built in\
blacklist
temp warning
and invent temp kick
rangeban
where after a while it forces the client back in
@quaint mantle
tempshadowban
I have those
https://youtu.be/7EmboKQH8lM 1:16:13 @hardy swan if you don’t mind watch that subcategory of the video. It explains why it might be bad.
tempshadowmute
I need to order that better lol
shadowban is probably kind of difficult to implement
tempshadowipban
I know what you mean by open-close principle
public BanPunishment(BanList.Type type, @Nullable Instant expires, String enforcer) {
super(enforcer, expires);
this.type = type;
this.expires = expires;
this.enforcer = enforcer;
}
public class IPBanPunishment extends BanPunishment {
public IPBanPunishment(Instant expires, String enforcer) {
super(BanList.Type.IP, expires, enforcer);
}
@Override
public PunishmentType getType() {
return PunishmentType.IP_BAN;
}
}
this is how the whole system works
@RequiredArgsConstructor
public abstract class Punishment {
public abstract PunishmentType getType();
private @Getter final String enforcer;
/**
* Apply a punishment to the player with the provided reason.
*
* @param player the player
* @param reason the reason
*/
public void applyPunishment(Player player, @Nullable String reason) {}
}
public abstract class TemporaryPunishment extends Punishment {
private final Instant date;
public TemporaryPunishment(String enforcer, Instant until) {
super(enforcer);
this.date = until;
}
public boolean isActive() {
return date == null || Instant.now().isBefore(date);
}
}
spam 😱
but yeah its super simple
Ye more about enums but alright nice
i want to make a player get teleported every second in a certain condition
and i want the scheduler to stop
that isn't what a condition means
you don't do things in a condition
a condition is a condition
while (!condition) {
runnable.run()
}
listening to it right now
it can be evaluated, and its result can either be true or false
@quaint mantle using while crashed the whole server
I want to teleport players into an if statement
in the runnable
😐
hmm can u give me an example if u dont mind
2hex just out of curiosity have you published any plugins on spigot so far
i think he did
dear god
Yikes
it's pretty rich to start with bettersprint when you crash your server half the time you upload anything
they are legit shit
then take them down
yeah i was thinking about that
don't let your dreams be dreams
well that isnt the topic
Do you know how broken that is?
can you please help my case instead of checking over shit plugins i've made
perfectly balanced
:/
i'll decompile the flossing plugin
too late
you are the second person I ever bring up the source code for on here
uh and?
the first one ended up its own spigot post (the story of bob)
BukkitRunnable runnable = () -> {
while (!condition) {
player.teleport(someLocation);
}
}.runTaskTimer(plugin, 20, 0);
@grim ice something like this, i havent used runnables in a while
lmao
that reminds me of something slimefun related for some reason?
thanks for being a decent human being
np
yeah I was the dude who originally shared the source code with spigot way back when
declaration: package: org.bukkit.inventory, interface: Inventory
on irc
for slimefun? lmao
yeah
god I fucking hate that thing
people flooded it with pull requests about diamond operators and such
it fills me with indescribable hatred
@tardy delta
/**
* Get if the item can fit in the provided inventory.
*
* @param item the item
* @param inventory the inventory
*
* @return if the item can fit in the inventory
*/
public static boolean canFit(@NotNull ItemStack item, @NotNull Inventory inventory) {
int amount = item.getAmount();
int stackSize = item.getMaxStackSize();
for (ItemStack i : inventory.getStorageContents()) {
if (i == null || i.getType() == Material.AIR) {
amount -= stackSize;
}
else if (i.isSimilar(item)) {
amount -= stackSize - i.getAmount();
}
if (amount <= 0) return true;
}
return false;
}
he wants empty slots
k
i want to check how many free slots the player has
to give him the items from a trade
yeah use this
Iterate over all slots and count those which are null or of type air
oki just a for loop
Ah. You can also give him all the items and drop those which cant fit in his inventory
Spigot hat a method for that
o
does getstoragecontents checks for the inventory without the gear slots?
yeah
public void giveOrDropFor(final Player player, final ItemStack... items) {
final World world = player.getWorld();
final Location playerLoc = player.getLocation();
Inventory playerInv = player.getInventory();
playerInv.addItem(items).values().forEach(overFlownItem -> world.dropItemNaturally(playerLoc, overFlownItem));
}
yo, I want to send to the player the close window packet
but I'm wondering if its important to send the correct id with it, for example 0 is for the players private inventory
but I'm wondering how I can get the correct id as there are a lot of kinds of inventories in the game that could be open
does it just drops the item when the inventory is full?
CodedRed made a video about MySQL, he explains really well how to use SQL
isnt he the one who promotes static, bad code structure and bad class naming conventions
he explains pretty well, ill check it out
jfc a 20 minute tutorial
Hey is anyone familiar with quality armory vehicules ?
?
I bought the plugin
and it's spamming console
Yes
i legit bought it
I am familiar with it yes
it is total trash
get a refund
How
get a refund
can I get a refund
it sucks in every way imaginable
I need a vehicule plugin anyways
the models are alright I suppose
Is there an alternative ?
i don't know
if you're willing to pay for it, yeah there are alternatives
just make sure you can get a refund in case they suck too
Yeah I got money
Yeah
because they probably suck too
I want my quality armory money back
I really need vehicules tho
grab some torches and pitchforks and proceed to the review section
wait
i dont think that's correct
is it
I have an error : x is not finite
why is this suspicious?
with quality armory
I've sent an issue on github
yeah that is caused by them trying to normalize a zero velocity
which shits out nans
no response for 5 days
Yes it only drops the items that dont fit
oki
the fix itself was trivial
but it didn't actually solve the issue
now it doesn't blow up, but none of the flying vehicles fly
The key types might not match up
oh
That's my only problem
oh i was trying to remove a consolesender instead of a player
the version I fixed a while ago had an issue with flying vehicles
hello, what is the plugin, when you right click on a specific item, it puts all the mini games in an inventory you can choice and you can access the mini game of your choice
There are tons of plugins.
Also -> #help-server
okay
Anyone doesnt mind helping? I want a player to get teleported every second if smth is true (i have it setup) and if it stopped being true itll stop tping the player
@quaint mantle Do you think you can check my issue
i'm not going to contribute to that shitshow
sad
some servers do use it tho
2 ways.
- Have a runnable that runs every 20 ticks no matter what and checks the boolean.
- Start/Stop a runnable when the condition changes.
I think the first one is more comfortable.
they've probably fixed it on their own
Is there a discord support
for qa vehicules ?
i don't know
How do I get a refund for qav
Bukkit.getScheduler().runTaskTimer(plugin, () -> { if(Objects.equals("handcuffed", e.getRightClicked().getPersistentDataContainer().get(key, PersistentDataType.STRING))) { e.getRightClicked().teleport(target); } }, 20L, 20L);
u mean like that
itll prob consume so much ram and stuff though
wont it
o
dumb question, how am i supposed to access the event player
from there
you don't
you iterate over all players
so hum
How does one get a spigot plugin refund
how
all of the mods seem to have conveniently disappeared
can u show me or an example or something
for (Player player : Bukkit.getOnlinePlayers())
event.getPlayer()
This would be an autarc class for your task:
public class TeleportRunnable implements Runnable {
@Getter
@Setter
private static boolean teleporting = false;
private static TeleportRunnable teleportRunnable;
public static void start(final JavaPlugin plugin, final Location location) {
Preconditions.checkState(teleportRunnable == null);
teleportRunnable = new TeleportRunnable(location);
Bukkit.getScheduler().runTaskTimer(plugin, teleportRunnable, 20, 20);
}
private final Location location;
private TeleportRunnable(final Location location) {
this.location = location;
}
private void tpPlayer(final Player player) {
player.teleport(this.location);
}
@Override
public void run() {
if (teleporting) {
Bukkit.getOnlinePlayers().forEach(this::tpPlayer);
}
}
}
but
where will this teleport the player to
Then you can just use
TeleportRunnable.start(plugin, location);
To start it and
TeleportRunnable.setTeleporting(true/false);
To enable/disable the teleporting
oh so
assuming each player is teleported to a different location, you need a Map for Player -> Location
location is the target location
otherwise everybody gets teleported to the same location
o
Yes its one single location you specify when you start the runnable. Or do you want per player locations?
yeah..
its when a player right clicks a player the right clicked person keeps getting tped
Then you should scrap the static stuff and make this a Singleton
until the other play right clicks again
is there no way to make this easier
i feel like smth this simple should have an easier solution
there is legit nothing on google bruh
Anyone knows what is exactly this error?
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project AGMRanks: Fatal error compiling: error: invalid target release: 1.16
I have java 16 installed and ready to use
I hope this doesnt clutter the chat:
what?
public class TeleportRunnable implements Runnable {
private static TeleportRunnable teleportRunnable;
public static TeleportRunnable getInstance() {
if (teleportRunnable == null) {
teleportRunnable = new TeleportRunnable();
Bukkit.getScheduler().runTaskTimer(JavaPlugin.getPlugin(YourPlugin.class), teleportRunnable, 20, 20);
}
return teleportRunnable;
}
private final Map<UUID, Location> teleportLocations;
private TeleportRunnable() {
this.teleportLocations = new HashMap<>();
}
public void addPlayer(final UUID playerID, final Location location) {
this.teleportLocations.put(playerID, location);
}
public void removePlayer(final UUID playerID) {
this.teleportLocations.remove(playerID);
}
@Override
public void run() {
final Set<UUID> offlinePlayers = new HashSet<>();
for (final Entry<UUID, Location> entry : this.teleportLocations.entrySet()) {
final Player player = Bukkit.getPlayer(entry.getKey());
if (player == null) {
offlinePlayers.add(entry.getKey());
continue;
}
player.teleport(entry.getValue());
}
this.teleportLocations.keySet().removeAll(offlinePlayers);
}
}
🥄
WAIT
new BukkitRunnable() { @Override public void run() { //Your code here! if(!Objects.equals("handcuffed", e.getRightClicked().getPersistentDataContainer().get(key, PersistentDataType.STRING))) cancel(); //Cancels it if condition is met, can be whatever. } }.runTaskTimer(plugin, 20, 20);
wont that be better
wtf
Letting a player tp every second:
TeleportRunnable.getInstance().addPlayer(playerID, location);
Stopping it again:
TeleportRunnable.getInstance().removePlayer(playerID);
wait
And it automatically removes offline players
me
will it work, might be old cuz i found it in a post,
?
"wtf"
that means what the fuck
use Player as key for the map
i know
iterate over the entry set with removeIf
thats how i feel
!
@lost matrix i have a question tho
and return !entry.getKey().isOnline()
borat made bad suggestion?
use UUID
using players as keys is fine as long as you're sanitizing them
which is what we're doing
I mean... having a reference to game bound objects is discouraged
new BukkitRunnable() {
@Override
public void run() {
if(!Objects.equals("handcuffed", e.getRightClicked().getPersistentDataContainer().get(key, PersistentDataType.STRING))) cancel();
}
}.runTaskTimer(plugin, 20, 20);```
this will not work, will it
who the hell told you to use Objects.equals
so long as the player object is checked for validity before doing anything with it, it's fine
someone, and i seem to misuse it?
But having UUIDs is more robust.
If a player logs out and in again within a second the tp runnable will still get the Player object and tp him. But if you use a Player object then its a new one after rejoining.
Player objects are invalidated and abandoned when the player logs out
an abandoned player object will always return false for isOnline
because it no longer represents that player
new BukkitRunnable() {
@Override
public void run() {
e.getRightClicked().teleport(target);
if(!Objects.equals("handcuffed", e.getRightClicked().getPersistentDataContainer().get(key, PersistentDataType.STRING))) cancel();
}
}.runTaskTimer(plugin, 20, 20);```
@lost matrix will this work alternatively
if anything, the alternative is less robust, because the player being retained for one second is arbitrary
But if you use Bukkit.getOnlinePlayer() on the UUID then it will return the proper Player object so he is not removed from the map.
can one of you please answer me if you know?
the retention of the player should be handled separately
i think the thing i just sent will work fine? won't it
This looks weird. Whole method pls
Ah nvm. No this will not work.
regardless
my actual point which was forgotten because the noooo muh player objecterino debacle
The event does not exist by the time your task runs
was that you should iterate it with removeIf
instead of building a hashset of elements to remove
Sounds cleaner to me.
or at the very least use a linkedlist for the removal collection
Your event will teleport the player once. At best.
why
Depending on the rest of your code it might even keep teleporting the player without you being able to ever cancel it again.
what
The time complexity of a collections iterator remove method is the same as the one that applies at the removeIf method. I havent used Iterators in a while
yes, but time complexity isn't all in all
what you are doing right now is allocating a new 16 element array to back the hashset every time
which goes entirely wasted
furthermore, with every insertion, you are computing the hashcode and equals of the inserted element
further, the iteration time complexity of a set is slower than that of a list
it is in every way inefficient
the only saving grace is that it's done only every second
Yes i know it clutters the GC. I would normally also do this with a linked data structure because removeIf is O(1) then. It was just a quick mock up.
Dont use lambdas for this. Try properly implementing a new class for your task. The scopes are defined more clear then.
so
https://0bin.net/paste/XUFRngue#9J3G7XwdxvdRnzcxJGV2ben2UufpOT7Zr08wl2uBqWC
I made it so only command blocks can use this command but one of a reason it doesnt broadcast the message when used in a command block. There are also no errors in logs.
0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.
do i use ur solution
is ur solution the best or?
It works. So if you want to you can use it.
No.
This is the changed version to also satisfy borat:
public class TeleportRunnable implements Runnable {
private static TeleportRunnable teleportRunnable;
public static TeleportRunnable getInstance() {
if (teleportRunnable == null) {
teleportRunnable = new TeleportRunnable();
Bukkit.getScheduler().runTaskTimer(JavaPlugin.getPlugin(YourPlugin.class), teleportRunnable, 20, 20);
}
return teleportRunnable;
}
private final Map<Player, Location> teleportLocations;
private TeleportRunnable() {
this.teleportLocations = new LinkedHashMap<>();
}
public void addPlayer(final Player player, final Location location) {
this.teleportLocations.put(player, location);
}
public void removePlayer(final Player player) {
this.teleportLocations.remove(player);
}
@Override
public void run() {
this.teleportLocations.keySet().removeIf(player -> {
player.teleport(this.teleportLocations.get(player));
return !player.isOnline();
});
}
}
o
But its quite a bit harder to understand
but it's satisfying
*for a beginner
i'm trying to set an entity's AI, right? but its for LivingEntity, so im kinda crossed on what to do here
@lost matrix quick question
the YourPlugin
Hm. Im not sure if i should call removeIf on the keySet or the entrySet there...
and obviously i'm gonna make the name system prettier
if you don't need values, use keyset
if you need values, use entryset
both are cached and both are live views of the map so it doesn't really matter beyond the presence of the values
Nope this is just one self-sufficent class you can copy and use.
I just wasnt 100% sure on the implication of removeIf on the entrySet
By "setting an entity's AI", what do you mean by that?
LivingEntity#setAI(boolean AI);
how can i use an itemstack from one java class in another as a material?
Entity != LivingEntity
@lost matrix and to use it TeleportRunnable.getInstance().addPlayer((Player) e.getRightClicked(), target);
will be fine, right?
Cast to Mob for that
But make sure the right clicked entity is actually a player
what
wdym
personally instead of a singleton I'd store the runnable instance in the main class or somewhere else that is per plugin instance, and access it from there
Don't think LivingEntity has the AI method
but it doesn't really matter and is more a question of preference
Since LivingEntity includes players which don't have AI
but the Mob object does have that method
actually i just found a way
you probably want to use setAware instead of setAI anyway
Anyone understands this error?
I don't get it at all 😞
awareness controls the actual AI of the entity
setAI controls gravity, taking damage, and everything else
https://0bin.net/paste/XUFRngue#9J3G7XwdxvdRnzcxJGV2ben2UufpOT7Zr08wl2uBqWC
I made it so only command blocks can use this command but one of a reason it doesnt broadcast the message when used in a command block. There are also no errors in logs.
0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.
and the entity's AI
i.e; walking, etc.
it's a vegetable with setAI(false)
it's more like a statue
which is the point of spawnNpc
as in you can't damage it, you can't move it, it isn't even affected by gravity
you probably want at least gravity
Show the code that evolves around AMGRanks line 66
so it just floats in the air incorporeally
at the location where it spawns
it won't go up or down
unless it has like, levitation
levitation won't do anything either
all movement is disabled when ai is set to false
63 vault = new Vault();
64 rankManager = new RankManager();
65 userManager = new UserManager();
66 GUI = new GUI(this);
67 rankManager.loadRanks();
I suspect some static init bullshittery
Scope pls
static initializers are haram
ok so yeah
perfect
just waht iwant lol
What does your GUI class look like?
Hm. Are you trying to load another spigot plugin while your current one is being enabled?
do we have a stack trace or something
im trying to give the player an item when they click on something in the GUI
what would the "item" be?
The repo is not on the version that matches the stack trace 😦
The class is from another plugin I have
do you have your depends set up correctly
p.getWorld().dropItem()
And pls dont use single character variables lile e or p
spigot doesn't let you load classes from random plugins anymore
and It was working before the java update
Location currentLocation = e.getPlayer().getLocation(); Vector Direction = e.getPlayer().getLocation().getDirection(); Location target = currentLocation.add(Direction);
in this case, target means the player location but 1 block ahead, right
So how can I use the API in the plugin?
Try it with one tick delay...
ok, I made an item with Item Stack how can i give the player that item via the dropItem()
Hmm yeah performance wise probably although I would say a primitive while loop is lower level than that higher order function removeIf and potentially reads better.
The removeIf that is
using a linkedlist as the imtermediate collection makes it acceptable
Player#getInventory() returns the player inventory.
Then Inventory#addItem(ItemStack...) lets you add ItemStacks to an Inventory
it's still not as good as it could be but it's significantly better
Indeed
Didn't work, The same error just 1 tick later
er i want to get the item i made in another class and use it as a mat in my new Gui class:?
Thats simple Java. Spigot is not an ideal environment for learning the basics.
Create an instance of your ItemStack and make it accessible through dependency injection or a singleton pattern.
honestly
he doesnt need that
he can do it in a simpler way
thats kinda dumb but it still works
method: copy paste the item stack
If i hear static im hunting you 
ik a way
that i can easy;y do it
so if i make an item stack in the same class how can i drop that item?
That violates the DRY principle:
Dont
Repeat
Yourself
One of the first principles you should really take to heart when programming.
so see here i make an item
yeah
and iwanna use it here
@lost matrix Which class is the source of problem? GUI, SpigotPlugin, or AGMRanks?
and how exactly do u want him to do that instead @lost matrix
if theres a way i want to use it too
DI?
Im going out with someone now. Hf 
o
how do players obtain end crystals
oh okay
eye of ender, glass pane and a ghast tear
game be like: bruh
isn't that ridiculously cheap
yeah
aren't they supposed to be like endgame items
but it isnt rly useful
or something
yes but theyre not rly useful
Ghast tears are kinda hard to get arguably
i suppose
i legit can get one in under 10 minutes in a complete new world
I mean it’s not really close combat plus the drops could fall down into a lava pit
Would some one clarify this error for me?
java.lang.LinkageError: loader constraint violation: when resolving method 'void me.ashenguard.api.Configuration.<init>(me.ashenguard.api.spigot.SpigotPlugin, java.lang.String, java.lang.String, java.util.function.Function)' the class loader org.bukkit.plugin.java.PluginClassLoader @4734270 of the current class, me/ashenguard/agmranks/ranks/Rank, and the class loader org.bukkit.plugin.java.PluginClassLoader @10e9d5dd for the method's defining class, me/ashenguard/api/Configuration, have different Class objects for the type me/ashenguard/api/spigot/SpigotPlugin used in the signature (me.ashenguard.agmranks.ranks.Rank is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @4734270, parent loader 'app'; me.ashenguard.api.Configuration is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @10e9d5dd, parent loader 'app')
its luck
unless you have a ghast grinder yeah I'd say it's pretty difficult to get lots of them
ye
they don't spawn that often and their AI is shit so they just float over lava most of the time
lmao yup
thats why u should use my plugin to get ghost spawners!
poggers!!!
anyways
back to my extreme stupid questions
my server actually does have ghast spawners
Location currentLocation = e.getPlayer().getLocation();
Vector Direction = e.getPlayer().getLocation().getDirection();
Location target = currentLocation.add(Direction); target means 1 block ahead of the player, right?
where is it
here
is it in a other class
what...
oh
an easy solution is to write the itemstack in the class
when u make it inside a method itll only be accessible there
if u dont use other stuff
tyy
i think it works
honestly
an easier solution
nvm
but do u have in mind that the player might not have an empty slot
https://0bin.net/paste/pO3mhuoz#FviCEN0izmIchK3tNfrGhASY245-xyHsMYwxgL33Yaz
Can someone look at my code?
It can only be used on command blocks but when used on a command block it doesnt output any message neither does it give a error
0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.
how rare are hearts of the sea
not rare if you have a treasure map
surely one treasure map doesn't get you that many of them
although I guess you can repeatedly buy them from a villager
Can you
Huh
I think they are fairly rare tbh
But if you need something rare use a nether star
i would but the wither spawners kind of make it not rare
You're guaranteed exactly 1 Heart of the Sea in each Treasure Chest I'm pretty sure
And Treasure Maps aren't really all that rare
how far do you need to travel to find the treasure usually
it ought to take at least a few minutes, right
Yeah it takes a few mins, usually it's finding the stupid chest and not actually getting to the x
rare enough for me ig
Is there some function to refresh tab? I made a command that removes and adds the NPCs that were spawned with my plugin and it adds them to the tab list every time.
Or some way to exclude NPCs from tab?
packets?
sometime when I press tab on hypickle
i see the NPCs in the tablist for a split second
and then they disappear
Yeah but @quaint mantle don’t give out the seed
You can find treasure with the seed
how do i make it so a player needs a permition to run a command?
this is the command i wanna add it 2
if(sender.hasPermission("urpermhere")){
// code
}
player.hasPermission("")
https://0bin.net/paste/3kHHZH0A#B3f6xlpm5UCYwElxYtXDBTLLtra8TbOT2fXmJzt7UTs
Can someone look at my code?
Im litteraly pulling my hair since its supposed to work.
The command can only be used in command blocks but when using it it doesnt give any output neither does it give a error. I dont think its a big issue since its a easy code.
0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.
Any idea what packet that is?
so would i need to make a new @overide
Jesus, my tab needs help
what
What...?
or is there a way to implement it to what i allraedy have?
wtf ru talking about
uh if u dont know those umm
hes asking if its possible to add that line to code inside his code.
How would one have a multiline description in the plugin.yml file?
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Bukkit.getServer().getPluginManager().callEvent(new GuiEvent((Player) sender));
return true;
}else {
Bukkit.getLogger().info("You must be a player to run this command");
}```
maybe learn basics before gui
this
yea
That shouldn't be confusing...
ikr
It's just another if
https://0bin.net/paste/3kHHZH0A#B3f6xlpm5UCYwElxYtXDBTLLtra8TbOT2fXmJzt7UTs
Can someone look at my code?
Im litteraly pulling my hair since its supposed to work.
The command can only be used in command blocks but when using it it doesnt give any output neither does it give a error. I dont think its a big issue since its a easy code.
0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.
How would one have a multiline description in the plugin.yml file?
maybe add another description line?
like:
plugin
description: line1
description: line2?
Unsure if multiple lines is even supported
description:
- "line1"
- "line2"
and then use getConfig().getStringList("description")
Wait plugin.yml
lmao
why would you need that
its /f or smth idek
Why you need that on plugin.yml, its only a plugin description ' -'
im kinda confused at how i can add a perm to this
ive tryed but it didn't work lol
https://0bin.net/paste/3kHHZH0A#B3f6xlpm5UCYwElxYtXDBTLLtra8TbOT2fXmJzt7UTs
Can someone look at my code?
Im litteraly pulling my hair since its supposed to work.
The command can only be used in command blocks but when using it it doesnt give any output neither does it give a error. I dont think its a big issue since its a easy code.
0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.
Add the permission to your plugin.yml or do a permission check on the sender
i wanna do a perm check on the sender
Any know why when build a custom branch of craftbukkit with buildtools the branch change to master?
Then use hasPermission
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
pls read it
where in there tho?
"A short description of what the command does."
On the sender .-.
ik like a med amout of java
I never talked about java
Do you know how to use Javadocs?
You can check with Player.hasPermission
https://0bin.net/paste/3kHHZH0A#B3f6xlpm5UCYwElxYtXDBTLLtra8TbOT2fXmJzt7UTs
Can someone look at my code?
Im litteraly pulling my hair since its supposed to work.
The command can only be used in command blocks but when using it it doesnt give any output neither does it give a error. I dont think its a big issue since its a easy code.
0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.
Are you registering the command
yes. Its in both my main.java and plugin.yml if thats what you mean
Why you dont send the error.
Since there is no error
Add some print statements, see where it's getting stuck.
is world.getHighestBlockYAt async safe?
neither does it give a error.
it never says a multi line description is not supported, in fact for the plugin description it self it says it is supported
omg
the plugin
not the command desc
You mean Bukkit.getLogger().info("1") right?
why would u have multiple lines for a command
Yeah sure that works, just make the messages different
just make a command that's like /<urcommand> help
Shouldn't cause too much of a problem if you're only reading. Generally though nothing in the bukkit api is
if u have args or smth
yea i just ask cuz the world isnt undergoing any writing at all
You can do a paged help command...
(at the time of using it)
it shouldn't blow up, but you're not guaranteed to get correct information
Just make sure chunk is loaded before checking
and there might be an async catcher explicitly put on it to make it blow up
mm ok
Hi, got a infinit problem ! I wanna damage all player of a team by 50% when a mate is hit but i have a exponential problem. I use EntityDamageEvent when the mate is hit and then apply a damage to all mates of the team, but this trigger again EntityDamageEvent and etc : infinit loop
someone know a solution ?
Create a list
When a player is damaged, if it is in the list, it will not trigger, if it isnt in the list, you add it on the list, hit it, and remove it of the list
smart thx
do you know a place i can learn from
either it was java or spigot stuff that i seem to lack info on
?learnjava does not help me btw
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.
W3Schools is good
