#help-development
1 messages · Page 1665 of 1
and getting confused why it isnt working
cuz he doesnt know that his package thingy is broken
package e.owo.lol.datemepls
when i finish dis ill go continue java dos
docs
becuz this thing is 100% not enough
Hi does anyone know how i can update the version of my plugin and upload a new jar
give up and move to brazil
hey, how could i convert from InetSocketAddress to String ? I've been trying String.valueOf() but it shows me things i dont want to see, i just need to see the standard IP adress format like X.X.X.X
hello
because rn it gives me X-X-X-X.domain.domain.net/X.X.X.X:XXXXX
if(kelepce.equals(player.getInventory().getItemInMainHand()))
why this method is not running
what the f is kelepce
kk
and its a custom item
is it in PlayerInteractEntityEvent
and did you put an Event Handler
and have you registered it in your Javaplugin extends class?
yes
yes
yes
try sysout'ing some parts of your code so you can see what is fired and what's not
System.out.println("Test1");
this part of code is not working
if(kelepce.equals(player.getInventory().getItemInMainHand()))
try isSimilar to ignore item amounts
not working
i did this at first but didnt work
and i made it .equals
and it is not working either
show where you create kelepce item
public void onClamp(final PlayerInteractAtEntityEvent e) {
Player player = e.getPlayer();
final Entity clickedEntity = e.getRightClicked();
if (clickedEntity instanceof Player) {
ItemStack kelepce = new ItemStack(Material.TRIPWIRE);
ItemMeta meta_kelepce = kelepce.getItemMeta();
meta_kelepce.setDisplayName(ChatColor.GRAY + "Kelepçeler");
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.DARK_BLUE + "Polislere Özgüdür");
lore.add(ChatColor.DARK_BLUE + "Kişileri Kelepçeleyip Soymaya Yarayabilir.");
meta_kelepce.setLore(lore);
meta_kelepce.addEnchant(Enchantment.PROTECTION_FALL, 1, true);
kelepce.setItemMeta(meta_kelepce);
if(kelepce.equals(player.getInventory().getItemInMainHand())) {
player.sendMessage("blabalbla");
}
}
}```
show the item in your hand
what
^^^
Hey, sorry but I'm back with my map problem, actually it works fine but it loads only around the 0:0, even if I select an another region 🤔
https://paste.md-5.net/icayigenac.java
if anyone can help me about it, it would be awesome thnx
How do I differenciate between normal golden apple and enchanted golden apple
like what would for example Material egoldenapple = Material.etc be
putting Material.GOLDEN_APPLE, 1, (short)1; just puts an error
Material.ENCHANTED_GOLDEN_APPLE @dim bluff
you could simply look at Material list to find it
it doesnt seem to make the difference
- my set of wanted materials doesnt even register ENCHANTED_GOLDEN_APPLE as a material. And in game the gapple and enchanted gapple do the same thing
(same cooldown)
what is your version ?
1.8.8
how do I make the difference, everywhere is telling me to change durability but none of the codes work
well
Material.GOLDEN_APPLE, 1, (short)1; idk how to do this
in itemstack constructor
do I just change all my materials to itemStacks
welcom to 1.8
it depends to
😢
u can keep using materials if yk the items doesnt have data
I need the enchanted golden apple
thats it
so I guess everything needs to change for 1item
lit
what are you trying to achieve ?
could also use XMaterial maybe https://github.com/CryptoMorin/XSeries/blob/master/src/main/java/com/cryptomorin/xseries/XMaterial.java
I'm just adding cooldowns to eating food
or wlib
everything is done and perfect
just the notch apple 🙂
might just add an if statement
XMaterial adds these material in the enum and will automatically parse it to the correct item with durability
but you'll need to change your Materials to XMaterials
wlib is a copy
can i make a command to verify someone's debit card credentials
lmao
LOL
no i forgor what i was gonna ask
im at a restraunt so i cba
something about entity visibility w/o packets
i'll ask later when im more available
if you dont want that huge fucking utility class look at my enum
https://github.com/ImajinDevon/GalaxyShop/blob/master/src/main/java/me/imaginedev/galaxyshop/version/VersionedMaterial.java
change the values to enchanted golden apple and any other
Not really help, but why does Spigot still use Gson 2.8.0 when 2.8.8 is the latest?
i at least know that it deprecated jsonparser objects and replaces them with static methods
would that decrease or increase performance
neither
Moshi (D
Why is playerConnection not a thing?
im on 1.17.1 but not mojmaps
Then it's obfuscated
You'll have to manually look through the mappings to find what it's called.
Use the remapped-mojang spigot server for that.
Or do that.
I know that it is b.
Well there you go 
you are welcome
Yeah all the Spigot stuff got obfuscated in 1.17 so if you want normal names you have to use Mojmaps and then remap at compile with SpecialSource
Facts
i would rather learn the obfuscated stuff
ogey
It's definitely a pain to initially setup mojmaps but once you get it 
i think that they can change between updates though
I wouldn't be surprised if they did
Hey, so I'm trying to deserialize ItemStacks from a json file. Serializing them seems to work fine, but for some reason deserializing throws and EOFException. I'm not sure why I'm getting an EOFException because my methods seem to be the same as other methods people wrote for similar uses.
Here is my serialization method:
@Nullable
public static String itemStackToBase64(ItemStack item) {
try {
ByteArrayOutputStream io = new ByteArrayOutputStream();
BukkitObjectOutputStream os = new BukkitObjectOutputStream(io);
os.writeObject(item);
os.close();
byte[] serializedObject = io.toByteArray();
return Base64.getEncoder().encodeToString(serializedObject);
} catch (final IOException ex) {
Bukkit.getLogger().severe("Unable to serialize item: " + item);
ex.printStackTrace();
return null;
}
}
And here is my deserialization method:
@Nullable
public static ItemStack base64ToItemStack(String base64) {
try {
byte[] serializedObject = Base64.getDecoder().decode(base64);
ByteArrayInputStream in = new ByteArrayInputStream(serializedObject);
BukkitObjectInputStream is = new BukkitObjectInputStream(in);
ItemStack item = (ItemStack) is.readObject();
is.close();
return item;
} catch (final IOException | ClassNotFoundException ex) {
Bukkit.getLogger().severe("Unable to deserialize item from string: " + base64);
ex.printStackTrace();
return null;
}
}
After adding some print statements, I narrowed it down the the exception being thrown by this line: BukkitObjectInputStream is = new BukkitObjectInputStream(in);
Imagine not going open source
ye it is called licensing it under the GPL and releasing it as free software
Choose MIT
but either way it is inconsequential as no one gives a shit anyway and it’s not like I am going to take action against someone violating my license
How can I push a minecart at a set speed?
(depending on where the rails are pointing to)
I've been trying by altering the velocity but that just bugs things out due to the different directions
I haven't seen a single case of someone coming after an open source plugin for not being GPL
It's driving me up the wall
Yeah I don't have money for a lawyer lmao
That's why I go MIT
Even if someone did violate the license
The worst that really means is they didn't credit me or didn't redistribute the license with the source
Of which neither are a big deal
And in general I just don't really care what people do with it as long as it's not harming me and I like them to credit me, but if they don't that's not a big deal either
likewise
i am a broke uni student, i have other things to be doing rather than caring about how people use plugins i wrote as a way to practice programming
Mhm
doesn’t stop you
that is a monumentally stupid decision
so.. why are you doing it?
in most cases it is malicious
why are you hard coding your own discord webhook into software other people use
You can make paid plugins open source
PlotSquared did that
And they still have buttloads of paid downloads
or.. have people hop into your discord server instead and just tell you
how are you going to clarify suggestions if they’re ambiguous
Yeah that's genuinely a really terrible idea
Even with obfuscation the string is still in there
You could very easily use wireshark to get the url
Why are you guys having a full on conversation
And send a bunch of shit to the webhook
you guys are having a 2v1. He asked a question...
Just don't do it
because discord channels are designed to allow people to have conversations
Yeah we're telling him not to do it because it is a monumentally stupid idea
Take suggestions in your discord
Without a webhook
and he has a serious security risk with his program design
The only way is to set up a backend server that the plugin would communicate with
why would players be suggesting things for your plugin?
But even if you do that there's no way to easily filter out junk or spam
All I'm saying is, you guys sound like you're pressuring him into posting his code as open source when he clearly doesn't want to do that. Not my business/problem tho
We promoted open source but we're beyond that
We're focusing much more on this as a security hole now
then you have not read the whole conversation, I have said like 3 lines to him suggesting open source?
just have a gigantic banner on your plugin page linking to your discord server
Just have /suggest show the link to a forum where they can make a request
Not here to argue 😄
Or a link to your discord
Just curios as to how I can solve my problem
I don't know enough about what you're trying to do to help
Yeah no worries, appreciate it regardless 😅
if you want to piss off every user of your plugin, go for it
+1
OH NO
you realize thats 20 times a second for every player moving etc?
and much much more
oh ok
just have a big title and subtitle
and play sounds
particles
maybe tp them into an advertising world
what about making it mandatory for them to join ur discord and link their mc account?
before they can join
just cancel the PrePlayerLoginEvent
^^
and obfuscate your code
lol
?kick @silver shuttle unfunny sexism
Done. That felt good.
Nope
Wow
Anybody know what the obfuscated version of ADD_PLAYER is? (Wrong image)
How can I push a minecart at a set speed?
(depending on where the rails are pointing to)
I've been trying by altering the velocity but that just bugs things out due to the different directions
set the velocity to the direction the rails are facing then
right but as I said, it bugs out when it hits a curve or anything like that because the minecart's direction switches up
click through, your ide can decompile it
velocities are set a one time thing, not as a constant, so when the direction changes then apply a new velocity respecting the new direction
figured it out. its a
A what 
the thing is that it can't be a one time thing since I want the minecart to move like a payload in overwatch (when players are around)
The obfuscated version is a
why is (Bukkit.getServer()).getServer()
what is that
what
💀
inception
@quaint mantleIt was a wrong image
ok but what is
why are you doing that
(Bukkit.getServer()).getServer()
i just don't really know what that is
or why?
inception
how do i make projectiles pass through certain players
make all your players watch the matrix
You'd probably have to create your own Arrow entity
You could try adding the arrow entity as a collidable exemption to the player. No idea if it will work, but worth a try.
im trying to listen to entity damage event
and teleport arrow forwards
how do i teleport an arrow forwards
in the direction it is going
Just try player.getCollidableExemptions().add(arrow.getUniqueId())
does this work on 1.8 lmfao
sorry for using it
how do i tp an arrow forwards
its an entity so entity.teleport
how do i make it teleport forwards
proj.teleport(proj.getLocation().multiply(0.1));
prob wrong lol
I don't think those collidable methods work with projectiles tbh
I think projectile collision is some deep nms shit
entity.teleport(entity.getLocation().add(entity.getLocation().getDirection().multiply(2)));
how many blocks will that teleport forwards
2, but depend on the speed of the arrow
if the arrow is traveling faster than 1 block per second
actually nm, it shoudl tp it 2 blocks
so if i do
remove teh multiply to move it one bloc, or multiply by 1
multiply 1
as getDirection() returns a unit vector it will be fine
@EventHandler(priority = EventPriority.HIGH)
public void onProjectileHitEvent(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Projectile && e.getEntity() instanceof Player) {
Player damaged = ((Player) e.getEntity());
Projectile proj = (Projectile) e.getEntity();
SkyWarsGame m = (SkyWarsGame) MinigameManager.getMinigameManager().getCurrentMinigame();
if (m.getMinigamePlayer(damaged).isGhost()) {
e.setCancelled(true);
proj.teleport(proj.getLocation().add(proj.getLocation().getDirection().multiply(2)));
}
}
}```
it works
cuz it passes through player
but the person it hits after it passes through (a non-ghost)
doesnt take damage
also pearls dont work with this either
Perhaps the server ignores it because it thinks it’s already hit someone
You could spawn a new one with the same data I guess
try doing it in the ProjectileHitEvent
there is no way to see what it hit tho
Might not exist in 1.8
tuff then
this doesnt work either
@EventHandler(priority = EventPriority.HIGH)
public void onProjectileHitEvent(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Projectile && e.getEntity() instanceof Player) {
Player damaged = ((Player) e.getEntity());
Projectile proj = (Projectile) e.getEntity();
SkyWarsGame m = (SkyWarsGame) MinigameManager.getMinigameManager().getCurrentMinigame();
if (m.getMinigamePlayer(damaged).isGhost()) {
e.setCancelled(true);
proj.teleport(proj.getLocation().add(proj.getLocation().getDirection().multiply(2)));
Projectile p = (Projectile) e.getEntity().getWorld().spawnEntity(proj.getLocation(), proj.getType());
p.setVelocity(proj.getVelocity());
p.setShooter(proj.getShooter());
proj.remove();
}
}
}```
i have a main/bungee server and a node/spigot server
can i using a spigot plugin on the spigot/paper server run bungee comands? i want to send a player back to lobby, using /send player lobby or whatever
If you have a bungeecord proxy then yes
okay, any code example/ressource?
/send is a default bungee command. If you have 2 servers and a bungee server you can do /send <player> <server>
how would i do that inside bukkit?
i assume if i run /send on a bukkit server it wont work
https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/
found this, no idea if this even works... and let's hope i dont break the bungee... i really hope 5 gigs is enough mem
Bungee takes like
thanks !
1GB per hundreds of players
oh then im f-ed
One of the errors in my IDE is ',' or ')' expected:36. I have no idea where to put it xD
p.setVelocity(new Vector(0,64,0)p.getLocation().getDirection());
time to buy better vps i guess... welll once i scale
How many freakin players do you have
Is there an event for when Bungeecord shuts down?
currently, none as i didnt deploy yet, but i wanna have a system pretty safe upto 10k
my nodes can scale infinetly, like, actually no limit, just not sure about bungee 🙄
since bungee is the glue
java.lang.ClassCastException: class com.thechemicalworkshop.com.disasterscontrol.MyEvents cannot be cast to class org.bukkit.plugin.Plugin (com.thechemicalworkshop.com.disasterscontrol.MyEvents is in unnamed module of loader 'DisastersControl-1.0-SNAPSHOT.jar' @5b07a470; org.bukkit.plugin.Plugin is in unnamed module of loader 'app')
at com.thechemicalworkshop.com.disasterscontrol.MyEvents.lambda$onPlayerDeath$1(MyEvents.java:75) ~[DisastersControl-1.0-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Paper-202]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[patched_1.17.1.jar:git-Paper-202]
else if ( number_of_players_left <= 1) {
System.out.println("game ended !");
Bukkit.broadcastMessage(ChatColor.RED + "" + ChatColor.BOLD + "" + "GAME ENDED - RETURNING TO BUNGEE");
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("connect");
out.writeUTF("survival");
// If you don't care about the player
// Player player = Iterables.getFirst(Bukkit.getOnlinePlayers(), null);
// Else, specify them
// Player player = Bukkit.getPlayerExact("Example");
player.sendPluginMessage((Plugin) this, "BungeeCord", out.toByteArray());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "stop");
}, 100);
}
}, delay);```
failed at the `Bukkit.getScheduler`
part... not sure what tho
dont tell me it's the capital C
okay it's not, same error
okay i gotta sleep, please @ me
?paste
That's your reason
can't access
will use another one like when i wake up.... unless someone can instant solve it @quaint mantle
will type tomorrow
no idea what that means tbh
i dont like java errors
And also instead of bukkit.dispatch command ... "Stop", use Bukkit.shutdown();
well that's another error 😂
tbh i want smth else than /stop as it's too slow
but yeah, the bungee stuff? any idea?
Not for me
is there a way to INSTANTLY close the server?
like end the process?
idc about saving, at all
I mean
Runtime.getRuntime.halt if you really wanted to
You could also interface with an external explosive charge connected via USB
System.exit(0)
This is a better idea though lol
hi, how to set food level more than 20?
I dont think you can. I dont think it works like health
(
@rough jay you can
it is very hacky though
use PDCs to handle a namespacedkey "ExtraHunger"
get what im sayin?
🤠
lemme know if you have any questions it can be quite confusing
public class ExtraHungerManager implements Listener {
public void setExtraHunger(Player p) { ... }
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent e) {
//...
}
}
except saturation heals you
anyways how do i evaluate a linked list
mathematical evaluation
class Node:
def __init__(self, root, previous=None, next=None):
self.root = root
self.previous = previous
self.next = next
class LinkedList:
def __init__(self):
self.front = None
self.tail = None
def add(self, token) -> None:
node = Node(root=token, previous=self.tail)
if self.front == None:
self.front = node
if self.tail != None:
self.tail.next = node
self.tail = node
gonna try
Hi anyone knows why it cant catch the connect pluginmessage?
public static void sendPlayerToServer(Player player, String server) {
try {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
out.writeUTF("Connect");
out.writeUTF(server);
player.sendPluginMessage(getInstance(), "BungeeCord", b.toByteArray());
b.close();
out.close();
Gui.msg(player, "§7Enviando a: " + "[§4" + server + "§7]");
} catch (Exception e) {
player.sendMessage(ChatColor.RED + "Error when trying to connect to " + server);
}
//player.sendPluginMessage(Handler.getInstance(), "BungeeCord", b.toByteArray());
}
I don't get the catch when the server is offline
Because it wont throw an exception If it is offline
Can somone tell me whats wron with this line? It just throws an NoSuchElementException
Property property = profile.getProperties().get("textures").iterator().next();
for those interrested the whole class
Hey, how would I spawn a mob for a later Minecraft Version. E.g. an axolotl to 1.17 clients on a 1.16.5 Server running ViaVersion?
that sounds tricky, because i dont think the 1.15 client would understand the axolotl entity
not sure thi#
tho
For 1.17 client?
you cannot spawn newer mobs for older clients
they would shit the bed or default to a single mob type
I didnt mention an older client
Spawn an axolotl to 1.17 clients on a 1.16.5 Server running ViaVersion.
no there is no way to spawn a mob that doesn’t exist as far as i know
Not with 1.17 NMS or is it all server dependent?
the fact that you are on a 1.16.5 server is the issue
it has no idea what an axolotl
with a custom client maybe
idk what the spawn entity fields are
gimme a sec
you could probably fake it tbh
you just need to fill in all those fields
Ah ok thanks.
But would the 1.16.5 server recognise it as a valid entity. Not in displaying it for a 1.16.5 client but that it exists and can be removed.
you will probably have to work that out urself
Alr thanks
bump
Have you read this? https://www.javatpoint.com/nosuchelementexception-in-java
someone here to give me an idea?
@quasi flint what're you trying to do
Changing my NPC's skin
i hate nms sori
You should check if the iterator contains anything
Also, why use the iterator?
Just do .get(0) to get at the first index.
You'll need to check that get() doesn't return empty though.
Hello i'm still learning so sorry if thats an obvious question but here is my problem , i'm trying to get the team of a player to display it in a side scoreboard but the scoreboard always display "null" here is the code Score team = objective.getScore(ChatColor.GOLD + "Vous êtes dans l'équipe :" + player.getScoreboard().getEntryTeam(getName()));
This is extremely messy
and you're naming stuff horribly
yeaah ik lol
oh god
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
The last one is also just outdated and bad :p
It is outdated, okay? It's only up to date for Java 8.
And:
- It's confusing for beginners.
- Hard to read due to the styling of the page.
- Designed for enterprise developers.
- And kinda hard to navigate?
Idk what you're on about bud.
Noones problem that beginners cant read it
they are beginners
It's literally a tutorial.
If someone trying to learn the language can't read the tutorial.
It has missed the point of being a tutorial.
You need to learn to read a java to be able to understand it
It's not supposed to be a tutorial
It is literally the official source. Before other guides were made, how would someone learn how to read Java?
It's pretty obv that docs aren't a tutorial
Doesn't mean you dont learn alot of them
And it is a tutorial. All signs point to it being designed as one.
The URL says tutorial, the The Java Tutorials have been written for JDK 8., etc.
And it literally fucking says
The Java:tm: Tutorials
at the start i was just asking how to replace this player.getScoreboard().getEntryTeam(getName()) because it don't work x)
at the top
But you know, it's a horrible idea to teach someone OOP concepts before teaching them the basics of your language.
You should teach them OOP concepts when they have the ability to process OOP concepts.
I've known multiple Java beginners who struggle with OOP because they're pushed into it too early.
first learn java
then make a util for scoreboards / use an existing one
m8 idk why you're still arguing that java docs are useless
They're not useless.
They're just badly designed.
It makes them harder to be used.
no
And ftr, calling them "Java docs" is incredibly misleading as "Javadocs" exist.
you just need to know how to read them
I literally just went over this point, Zoi.
You are terrible at debating.
can someone explain Encapsulation, Abstraction, Inheritance, and Polymorphism better? google makes it weird
https://www.javatpoint.com/encapsulation
https://www.w3schools.com/java/java_abstract.asp
https://www.w3schools.com/java/java_inheritance.asp
https://www.w3schools.com/java/java_polymorphism.asp
Encapsulation in java with example, advantages and fully encapsulated class.
But my point is that the Java tutorials were advertised as tutorials (judging by them being literally called "The Java Tutorials" and being referred to as "The Java Tutorials"), therefore they should be judged as tutorials instead of docs (the JLS is more documentative anyways), and having to learn how to read the tutorials in the first place is just counterproductive as it steers people away from said tutorials and makes those trying to use them struggle more with using them. They're poorly designed due to their outdated nature, bad structure, and unwelcoming visuals (which is part of them being outdated, as they haven't been updated to match modern style standards). If you need to learn how to read Java before you can even understand the concepts in Java, how are they a good set of tutorials? In order to read Java in the first place, you need a tutorial to teach you how to read Java, and considering Oracle made this tutorial, it's the official first source of information, very likely the first source someone may see unless they find Codecademy or other sources first, which means they can't just "learn Java before they can learn Java." You see how illogical that statement is?
My man really just wrote the bible lmfao
And with this sentence, I truly know what kind of person you are. Good day/afternoon/night, I'm done arguing with you.
@lavish hemlock > Zoibox here
Guys just stop ffs
Encapsulation is the concept of only showing the most important, front-facing parts of your program to users, AKA for example, hiding the internal parts so that it's easier to understand which parts are part of a library.
I dont care
o
like making private variables then making getters for them?
Yeah, that's a form of encapsulation as you're encapsulating the fields, making it easier to make changes to the code in the future in case that field changes.
so the class that has actual functionality uses getters instead of direct access?
Oh I see
@grim ice
I don't get polymorphism well though
Abstraction is then for splitting your code into multiple "abstractions," such as how Java's standard library has List, AbstractList, and then ArrayList. It allows for reducing the amount of code reuse.
You assumed I haven't read those, lol
For example, List defines what lists should do.
AbstractList implements a lot of common behaviour for those lists.
And then ArrayList implements specific behaviour.
oh so like
the relationship between an engine and a car
a car would be an abstract class
and the engine would extend maybe a Part class
that extends a car class
right
Well, you wouldn't want your car parts to extend the car.
You'd want your car to contain the car parts.
Oh I'm sorry actually I gave you bad definitions
Okay so Encapsulation is bundling things into single pieces.
And Abstraction is hiding the unimportant details.
How so? for abstraction
In the way I explained with my previous, wrong definition of Encapsulation.
Meanwhile, that Abstraction definition is much closer to Inheritance
For Inheritance I think I'll provide a code example
public class Car implements Vehicle {
...
}
In this situation, Car inherits the properties of Vehicle.
Therefore, a Car is a Vehicle.
This also means Car must "implement" what Vehicle has "defined."
Defining is like creating how something should be interacted with
And Implementing is creating what happens when that something is interacted with
It's an interface, so it's abstract by default, yes.
And Polymorphism plays off of Inheritance
For example, say you want to give your Person a Vehicle.
lemme just write a code example
public class Person {
public void giveVehicle(Vehicle vehicle) {
// implementation logic isn't important here ...
}
}
Since Car implements Vehicle (it is a subclass of Vehicle), you can pass a Car to the parameters of giveVehicle
myPerson.giveVehicle(new Car()); for example
and imagine we have a Boat that also implements Vehicle, well, myPerson.giveVehicle(new Boat()); works too
oh so polymorphism lets a method work for different uses? like a murder method happening with different tools,
like public void murderSomeone(Tool tool){
guy.murder(tool);
Is it possible to have a custom X marks the spot location on a map without using nms or should I make a custom map image?
Since you don't know what tool was passed unless you check (like with instanceof), you'd probably just want to use what methods are already on Tool.
a more involved example would be
guys i hav a question
i cant use World#getKey() in 1.16.5 spigot and dunno why
public void murder(Tool tool) {
// 'tool' can only be used to access what Tool has.
// Let's check and see if the Tool is a knife.
if (tool instanceof Knife) {
Knife knife = (Knife) tool; // Here we cast our 'tool' to a Knife, since we now know it's a Knife.
// Now 'knife' can access both what Tool has and what Knife has.
// ... go on to murder some poor fellow if you want ...
}
}
You're welcome
OOP is pretty weird overall but it does help to know it if you're learning Java since it makes understanding code and library development easier.
Is there a way to detect when player tries to teleport with a passenger? Now teleport event isn't being called at all because somehow it's cancelled on the client, idk how to explain it properly.
what are passengers
Feel free to message me if you have more questions @grim ice
o sure
basically an entity that rides the player
guys i'm coding a plugin that when a player run a command all compasses in that world will point toward a player's location but i cant get all compasses in that world to point toward that player can someone help me (sorry for my bad english skill)
You making a Manhunt plugin or something?
I probably can't offer advice but I'm just curious.
yeah but i dont want to pay 20 bucks
That's fair.
There are several approaches to this problem.
Also your English is fine, you just need to fix your capitalization and run-on sentences lol.
;D
The problem is that you cant get all compasses in a world. But what you can get are all compasses in the world
any player is currently holding.
yeah that's all I need
Can you somehow detect everytime Player#teleport method is being used?
@lost matrix do you think liskov thingy is really necessary
its confusing on how to follow
@summer scroll im pretty sure EntityTeleportEvent will be fired
but im not completely sure
Ok for that you need to:
- Get all players in this world.
- Iterate over them and get the inventory of each
- Iterate over each item in their inventory
- Check if its not null and of type COMPASS
- Get the ItemMeta of that ItemStack
- Cast it to CompassMeta
- Set the lodestone of that compass to a Location
- Put the CompassMeta back on the ItemStack
You mean the liskov substitution principle?
yes
how can i get all players it that world
I'm not sure about that one either, but what entity do you think will fired that event? passenger or the player?
I mean... you dont need to understand it in detail. Its something that will evolve logically if you
just program for a bit.
Probably by accessing the world and then accessing a list of players?
o
World#getPlayers()
^
maybe both actualy
ok ill try
And you can get the World from the server, but you probably knew that already.
im pretty sure the event will fire for any entity that teleports >8 blocks at once
Doesn't make sense because PlayerTeleportEvent isn't being called at all.
Better get the World from the Player that executed the command
Banner banner = (Banner) block.getState();
List<Pattern> patterns = new ArrayList<>();
patterns.add(new Pattern(DyeColor.BLACK, PatternType.FLOWER));
patterns.add(new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE));
banner.setPatterns(patterns);
``` anyone know why this does nothing?
https://www.educative.io/edpresso/what-are-the-solid-principles-in-java
in the Interface segregation principle section (4.) What would be a fix for their problem they showed?
Huh, aight.
just so you guys know, we have threads available.
So ya know, use them lol
Might have to update
Call BlockState#update(true)
I Thought of making multiple abstract interfaces and implement each of the ones they need
okee
and leave the other ones
Just noticed
but it looks like a dumb idea
more people need to notice lol.
So many people complained and it's not even being used 😂
But Optic, aren't threads "useless" according to everyone I've ever known? 😢
thanks
The general rule of interface segregation is to destruct big ones into smaller ones
Mainly because of code reusability
better than the current mess that is this channel don't you think? 😛
wait nvm asbtract interfaces cant provide code
Actttuaaaalllyyy
They can have concrete implementations
o
Btw tell md to open admissions for the discord helper role pls <3. I would be glad to apply.
default abstract interface?
I don't think we need more helpers atm, he'll most likely re-open them if needed though
default states that a method in an interface has an implementation but can still be overridden.
static is just static, you get it.
I strongly urge anyone here who needs help with their issue to open a thread, now when it’s actually available. With that being said I suggest naming your thread the question you’re asking.
Lemme give an example
public interface MyInterface {
default void concreteMethod() {
// This method has an implementation on an interface.
// This means you can still implement it on subclasses but that it's not strictly necessary.
}
static void staticMethod() {
// This method has a static implementation on an interface.
// This means you access it via the class instead of an instance of the class (which you'd get from a subclass).
// For example: MyInterface.staticMethod()
}
}
staticMethod also can't be overridden by a class that implements MyInterface, like all static methods.
and you can't access staticMethod from a MyInterface subclass.
meaning MySubclass implements MyInterface doesn't permit MySubclass.staticMethod()
really? I thought that was something they strictly avoided bc it was "too confusing"
maybe that was just the overriding of a static method via abstract static or smthn
gimme a sec
Can you somehow detect when specific method is used?
Depends. Does the method belong to your class or someone else's?
From the spigot api, I want to detect everytime Player#teleport method used
If it belongs to your class, then it's just an easily method call to say "hey, this method was used."
If it belongs to someone else, they'd have to give you an API for that.
I cannot think a better way to handle teleportation issues when trying to teleport with passenger.
How to make a random dungeon generator?
Also, teleport event doesn't get called, that's why it's so tricky.
Fun fact though:
I'm pretty sure you can still call it as fuck() WITHIN the class, you just can't specify the class beforehand.
Yeah
Since you're allowed to do that with fields.
Which I only know because people implement ASM's Opcodes interface
Spoiler: Don't do that.
Just statically import all the fields from Opcodes as it's legitimately faster and has the same result.
o
How to teleport entity with passengers?
Looking for a friend
Anyway, I'm planning on writing a Java guide someday, already got the basic integration down to generate pages from some Markdown so it shouldn't take too long to get to doing.
You can reference threads? That's fuckin' cool.
no
ZoiBox stop creating these ones
I need practice
?kick @crude charm
Done. That felt good.
WHY
LMAO
hello my little friends, how do i add nbtags to entities?
smh, conclure
tried this but didnt worked
Does anyone know what mean the args for this function ?
see the method behavior
ok but I'm still missing one arg
byte b0 it is the map scale
but how can I know wich byte is right ?
it is the ItemWorldMap class
javadocs™️
if you know where I can find the doc for net.minecraft.server package it would be nice
I only know the spigot one
Ah yes, NMS docs.
it have
it is called: try and see
unless someone who is really bored out of their mind has created unofficial documentation and told nobody
in fact i 'm trying to prerender a map to give it to the player, I have actually a code that should work but the map load only around 0:0
see
Yeah explosive charge i would do if it was hosted locally haha
Yeah i'll try this... i was thinking to recompile paper but idk how much time will i save?
Does protocollib have the PacketPlayInFlying packet?
If so does anyone have a clue what it's called?
Hello, I just wanted to ask if it is possible to calculate the equal amount of Level from a value of the .getTotalExperience() method, for use with the .setLevel() method
Ill send you a util class for that
i dont unserstand sorry
Okay
oh ok ;V being dumb
Thank you
this is starting to annoy me and I swear there must be a way to fix it on gradle, how do you avoid conflicts like this?
shouldn't shading it in work?
or smth
Hi, I got a small problem.
If i use ItemStack[] content = ((List<ItemStack>) Main.getInstance().getKluizenConfig().get("Kluizen." + Locatie + ".items")).toArray(new ItemStack[0]); inv.setContents(content); this, It will open once, But if i try to reopen it i will get the error [Lorg.bukkit.inventory.ItemStack; cannot be cast to java.util.List
If you want to apply something to one exact player and make it hard coded then sure. But why? Use config instead.
You probably save an ItemStack into that config path when the inventory closes.
codedreds tutorial xd
is there an event for when a block gets powered?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockRedstoneEvent.html as close as it gets
declaration: package: org.bukkit.event.block, class: BlockRedstoneEvent
seemingly
tbf these kind of events can quickly lead to big performance issues
MobMoveEvent
I don't, it would take .1 seconds for half the plugins in spigot to suddenly take tps down to 7
you're better off scanning the actual thing you want to do directly
then you can add your own events upon detection like I did
I wonder if there would be interest in submitting a PR for an enter combat and leave combat event for mobs
EntityMoveEvent damn, sound so expensive xd.
yes
You can actually write one your own by using a packet listener XD
but there is like a million times i have need it
yesa
thats the best way tbh
dont work if noones online doe
/near it
You just need to be careful because the move packet gets sent to several players at once
Yeah.
What about checking entity location every x second
now for a god unknown reason it says it cant reach the session server
cant a 1.15 thing pull from the api server anymore or my code completly brocken
is there a way to force java to update the value of a variable every time it gets called?
what?
create a method to get the value maybe
hmm yea
Yes. With a proxy accessor.
Example:
private final MutableInt number = new MutableInt(0);
public int getNumberValue() {
int value = number.intValue();
number.increment();
return value;
}
But this heavily violates several clean code principles. You dont want to have
side effects on a method.
A method should do exactly one thing.
how does one go about adding to spigot, do i have to fork bukkit & craftbukkit and then clone them. then commit to them and push them back? then some hacking on the jira to open a pr?
lmao
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
why
are you
naming variables like thaat
number_of_players_left ?
call it playersLeft
@gaunt saffron in java its camelCase
@narrow furnace btw i finished the rest of mooc
i suck at naming things, better don't open a large python or js project of mine
guy that was like a day
thats a 14 week course yk
yes i know almost everything
u did all the exercises?
no?
wym u didnt do the exercises
actual fuck?
how
its not a book
u dont just read it
the reading is just a short description
of the exercise
breh
honestly just use code academy
very good user interface
interactive, and you can learn with other people
choose something and learn it
dont give up in the middle
if u read the homework questions and didnt write the answers, u get a 0% no?
Pulse r u joining the code jam?
wish there were courses that know you already have a lot of experience
what is it?
wats dat
Yea
So if you do I’d like to be your mate if you’re not taken already
Oo epic
(:
@grim ice did u do any of the course
👀 code jam
what did u do
i read the stuff and i already know it
oh good so u wont be asking in here for stuff?
the stuff there arent what i ask these days i guess
cause i know a lot of the things you ask are for sure in that course
except generics
that i didnt even profit from the website
they dont even tell u what that means and this means
i had to go google it
alright lets test your knowledge then
you did 0% of the exercises
on the important stuff
ok
sure
you shouldnt have to take this long
Lmao
its a method that runs when u instantiate its in
please?
idk how to write instantite
horrible explanation
yea
lol but i still know how to use it
You're using this in a lambada. This is refering to the lambada and not your main class
2Hex, what is static? And why should you use it sometimes, but sometimes not
that might be a bit too complicated but idk
its to make something get instanitaized once
cause it has some design involved
lmao
bruh what
oh god running buildtools is miserable with this internet speed
thats what i heard though
bump
lol u didnt do it
ye 1.17
how long did the 14 week course take you
static is a modifier to allow access without an instance, it should be used for utilities, constants, or singleton design patterns
You will have to use the Position packet then
^
idk lmao i did it 2 years ago
how do u know its there then bro
@paper viper yes
because i know what static is
if you find it ill redo the whole thing from zero
redo?
im looking at the code and examples and docs, can you tell me at least which line you mean?
u cant redo if u didnt do in the first place
Yeah. and also the keyword means directly "attaining to the class", or "part of the class" (but not instances) you get the idea
yes, with the exercices
Pretty sure that position sends the position of the player every 20 ticks right?
Wanted to use the other packet to detect lag, do u know if there is any other packet that is being send every tick?
that's beautiful
and if you say otherwise
you're just wrong
plugin.yml
@Plugin(name = "HPWP", version = "VERSION")
@ApiVersion(ApiVersion.Target.v1_13)
@LogPrefix("HPWP")
@Author("Heretere")
@Website("heretere.com")
@LoadOrder(PluginLoadOrder.STARTUP)
@Permission(name = "hpwp.events", desc = "Allows /pwp events", defaultValue = PermissionDefault.OP)
@Permission(name = "hpwp.gui", desc = "Allows use of /pwp gui", defaultValue = PermissionDefault.OP)
@Permission(name = "hpwp.notify", desc = "Receive update notifications", defaultValue = PermissionDefault.OP)
@Permission(
name = "hpwp.bypass.chat",
desc = "Send and see all chat tunnels",
defaultValue = PermissionDefault.FALSE
)
@Permission(
name = "hpwp.bypass.commands",
desc = "Execute all commands even for disabled plugins",
defaultValue = PermissionDefault.FALSE
)
@Permission(
name = "hpwp.*",
desc = "Wildcard hpwp permission",
defaultValue = PermissionDefault.OP,
children = {
@ChildPermission(name = "hpwp.events"),
@ChildPermission(name = "hpwp.gui"),
@ChildPermission(name = "hpwp.notify") }
)
@Permission(
name = "hpwp.bypass.*",
desc = "Wildcard hpwp bypass permission",
defaultValue = PermissionDefault.FALSE,
children = {
@ChildPermission(name = "hpwp.bypass.commands"),
@ChildPermission(name = "hpwp.bypass.chat")
}
)
lmao
Movement packets will be send more than every tick regardless of what you do
like 20 lines of pure annotation
from the course website
what part
So I could use it to detect lag?
Helsingin yliopiston kaikille avoin ja ilmainen ohjelmoinnin perusteet opettava verkkokurssi. Kurssilla perehdytään nykyaikaisen ohjelmoinnin perusideoihin sekä ohjelmoinnissa käytettävien työvälineiden lisäksi algoritmien laatimiseen. Kurssille osallistuminen ei vaadi ennakkotietoja ohjelmoinnista.
Wdym?
i did
it seemed like math bro
Why are you detecting lag?
class Node:
def __init__(self, root, previous=None, next=None):
self.root = root
self.previous = previous
self.next = next
class LinkedList:
def __init__(self):
self.front = None
self.tail = None
def add(self, token) -> None:
node = Node(root=token, previous=self.tail)
if self.front == None:
self.front = node
if self.tail != None:
self.tail.next = node
self.tail = node
how do I sort and evaluate this list
google merge sort
Cuz I want to detect client side/connection lag, I googled for a bit and found that the PacketPlayInFlying gets send every tick and because of that you can use it to detect the player lagging
i mean by operator precedence
i could give you a java lesson better than codecamp
Aight. Just be aware that spoofing that is easy
Am aware
codecademy really just teaches a languages syntax
right
ive done their javascript course but im hardly a web dev rn lol
and?
Could I use the position packet to do the same tho? (detect lag)
does it get send every tick?
yea i only suggested it cause its interactive
and forces them to do it step by step
@paper viper ok give me another question if u dont mind
Position in Protocollib is 3 different things bundled. Try the ground packet
Alright, tysm
to be honest
i cant even blame myself. their whole thing is not organized, they throw important shit inside of useless and common stuff
its painful to even read it
so many examples and its order is ded
you are clearly only a beginner
ok
you have the resources and tools to learn
dont complain
ok just another question
we've all been through this too
Maybe you'll find it more fun to make up your own projects
that's what I did
Make em up and research till it's done
I first learned Processing, and created my own games
then I learned java, and coded my first Java project for a friend
it was shit, but i learned a lot
Then I found out about plugins, and decided to try them
pulsebeat
answer what question
if u want questions
pls another questin
you did a 14 week course in a day did you not? surely you can handle this
i mean at least their stuff are organized
you mean at least it holds your hand and gives you hints..
[14:18:09 INFO]: Stopping main thread (Ignore any thread death message you see! - DO NOT REPORT THREAD DEATH TO PAPER)
[14:18:09 ERROR]: Main thread terminated by WatchDog due to hard crash
java.lang.ThreadDeath: null
at java.lang.Thread.stop(Unknown Source) [?:?]
at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:947) ~[patched_1.17.1.jar:git-Paper-85]
at net.minecraft.server.dedicated.DedicatedServer.stopServer(DedicatedServer.java:806) ~[patched_1.17.1.jar:git-Paper-85]
at net.minecraft.server.MinecraftServer.close(MinecraftServer.java:919) ~[patched_1.17.1.jar:git-Paper-85]
at org.bukkit.craftbukkit.v1_17_R1.util.ServerShutdownThread.run(ServerShutdownThread.java:28) ~[patched_1.17.1.jar:git-Paper-85]
[14:18:09 INFO]: Stopping server
[14:18:09 INFO]: Unregistering com.sk89q.worldedit.bukkit.BukkitServerInterface from WorldEdit
[14:18:09 INFO]: Saving players
[14:18:09 INFO]: DeadlyChemist lost connection: Server closed
[14:18:09 INFO]: DeadlyChemist left the game
[14:18:09 INFO]: Saving worlds
[14:18:09 INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[14:18:10 INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[14:18:10 INFO]: ThreadedAnvilChunkStorage: All dimensions are saved
[14:18:10 INFO]: Flushing Chunk IO
[14:18:10 INFO]: Closing Thread Pool
[14:18:10 INFO]: Closing Server
container@pterodactyl~ Server marked as offline...
i tried System.exit(0);
i assume i have todo bukkit.shutdown...
is there a way to stop the server EVEN FASTER?
i don't care about keeping the data, it all all corrupt, just stop asap
Press the power button on the machine 🙂
You gotta be kidding me with System.exit
lemme call orcale
you're joking right
no? why?
He said he doesn't care
Lmfao
1s saved is goood
why do you want to corrupt your server
less than idc really
tf
but wtf
class Conditionals {
public static void main(String[] args) {
boolean breakfastTime = false;
boolean lunchTime = false;
boolean dinnerTime = true;
if (breakfastTime) {
System.out.println("Let's have waffles!");
} else if (lunchTime) {
System.out.println("Let's have sandwiches!");
} else if (dinnerTime) {
System.out.println("Let's have pizza!");
} else {
System.out.println("It's not time to eat!");
}
}
}```
i can try
why so many else ifs
You can use the ProccessHandle from Java9+ and kill Java
is that good or bad
ugh, example?
That seems fine
i want it dead asap
my start comnmand is rm -rf
destroyForcibly()?
Use allProcesses() and filter it and find your java instance then use destroyForcibly()
lemme try
looks like you could try using current()
oh, current would work?
In that case ig you could do that