#help-development
1 messages ยท Page 2238 of 1
look at the full error. it will tell you that there's an index out of bounds exception.
actually that's better way to handle this, because by using container synchronizer method, your items will still be handled by the server, and you can make invisible slot selections
There're a few actions that conflicts with the glow packet. So the problem should be fixed by re-sending the packet right after listening for these events, I guess?
I do have one private final HashMap<Player, ArrayList<Entity>> glow = new HashMap<>();
That, would have been smart haha
I am working on many different project with diffreent program langues and its getting masy ๐
show the code
yeah pretty stupid description lol but it probably makes perfect sense
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (msg instanceof Packet<?>) {
for (PacketListener<?> handler : this.handlers) {
Class<?> clazz = handler.getClazz();
if (!clazz.isInstance(msg)) continue;
if (!handler.onPacketSend(player, clazz.cast(msg))) return;
}
}
super.write(ctx, msg, promise);
}
public class PacketListener<T extends Packet<?>>
im trying to reuse my old packet listening code
do not use Packet<?> but T in your method
T is another class
then show the full class pls
if you only send parts of it, it's hard to figure out what the problem is
public class PacketListener<T extends Packet<?>> {
private final Class<T> clazz;
public PacketListener(Class<T> clazz) {
this.clazz = Objects.requireNonNull(clazz);
}
public Class<T> getClazz() {
return this.clazz;
}
public boolean onPacketSend(Player player, T packet) {
return true;
};
public boolean onPacketReceive(Player player, T packet) {
return true;
};
}
this is old code, this should use preconditions rather than requireNonNull, since i prefer those nowadays
Player target = player.getServer().getOfflinePlayer(args[0]); does not work
what would I replace it with?
I think there is just one. The metadata packet
that works just fine
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
ye cuz type erasure
you do understand what im trying to do? I want args[0] to get offlineplayer
i did was doing the exact same thing yesterday and ran into the same issue
i fixed it
anyone know how i can
set a players XP
however it automatically calculates the levels ect
i used the kind of hacky solution of just casting it to a non-generified type but it ended up working
I understand. I just don't understand what is "not working"
i removed the wildcard
for (PacketListener<Packet<?>> handler : this.handlers) {
Class<Packet<?>> clazz = handler.getClazz();
if (!clazz.isInstance(msg)) continue;
if (!handler.onPacketSend(player, clazz.cast(msg))) return;
and this has no errors anymore
don't ask me how this fixed it
well, it says it requires a Player variable instead of Offlineplayer
what requires a Player instance instead of an OfflinePlayer instance?
anyone know how i can
set a players XP
however it automatically calculates the levels ect
Player target = player.getServer().getOfflinePlayer(args[0]);
you can just do Bukkit.getOfflinePlayer(args[0]) presuming args is a string array
Still pretty confused on this
"big red line under" probably comes with a more detailled explanation
chill out
wouldnt this need custom minecraft web client in order to achieve this
Server#getOfflinePlayer definitely requires a String or UUID and not a Player.
So should I listen for the metadata packet?
I told you already, it says it needs a player variable instead of offlineplayer
works fine for me (even though it is deprecated)
getOfflinePlayer definitely doesn't require a player, and args[0] most likely is not an offlineplayer
getOfflinePlayer returns an OfflinePlayer, not a Player object
so what you say doesn't really make any sense
show a screenshot of your code or ?paste it
not just the single line
well yeah, you're getting an OfflinePlayer but you made the type a Player
not sure what you expected
oh I didnt even look at the left side of the assignment
yeah obviously an OfflinePlayer is not a Player
obviously
yeah so you know what the problem is now
yeah now I do thanks to deotime. Not you asking me the same question over and over and now realizing you havent even looked at what I sent out
Hi, does anyone know how mods work? like how to make them
Do you guys do preconditions on internal methods or classes
you need forge to use mods
im wondering if that's a waste or not
well if the only explanations you give is "well, it says it requires a Player variable instead of Offlineplayer" and "it has a big red line under" then obviously I don't spent 20 minutes to try to find out what the exact error actually is
forge or fabric
ye
ik how to use them, I want to know how to make them
there are courses that teach you how to do them
oh ok
No cause you didnt even look at the code. Lmao
just type the same question over and over
first off, do you know Java
a correct question would have been "Why can I not assign an OfflinePlayer into a variable that's declared as Player" and then we could have easily told "that's because OfflinePlayer is the super class of Player"
guys can we shade protocollib into our plugin
I asked it twice
If not, learn Java first, then try making spigot plugins or forge mods
so users dont have to download it
anyway have a nice day
I mean you can
but its not intended for that
TinyProtocol is suitable for shading and its made by ProtocolLib contributors
(like you could instantiate your own instance of its main class and invoke onEnable, onDisable etc)
oh aight thx
lemme check thay
Anyone know what I need to do to make it so I can actually take the result from the slot? (it won't let me)
~~Code: https://sourceb.in/oipzCi15V2~~
~~Context: https://gyazo.com/10f15532ef4815930d37af77d577ea5b.gif~~
Do I need to do something with the SmithItemEvent event?
Fixed it by adding a smithing recipe
Would it be possible to set skin from png file? Or i can only use skins assigned to official minecraft accounts ?
Hey, how would I get all blocks in the players perspective?
The blocks in the inventory? or around him?
he means in his FOV probs
you can get the blocks in a general area, but theres no way to know what the players fov is so you cant really
you could just use the max fov though in whatever calculation to stay safe
is there any way to condense this to one line? java getCommand("ldsync").setExecutor(new CommandManager()); getCommand("ldsync").setTabCompleter(new CommandManager());
make a new method
alright
ty
public void registerCommand(String name, CommandExecutor executor, @Nullable TabCompleter tabCompleter) {
getCommand(name).setExecutor(executor);
if(tabCompleter != null) {
getCommand(name).setTabCompleter(tabCompleter);
}
}
something along this?
cool cool
remove the newline character ๐
no I meant
for the original two lines code
if you removed the newline there, it would have been one line lol
oh
i mean
i guess
but thats bad pratice
for readability
all one line
crazy crates the plugin
for their sub commands
oh you haven't seen my death chest plugin in 5 lines
they have a long ass chain of if else checks
for each sub command
instead of like new classes and a sub command manager
the rule was: no more than 3 semicolons per line
is it on github
ik ik im joking
WHAT IS THIS
Do u know why ppl use nms to serialize itemstacks?
bro even my wide monitor cant fit it all zoomed all the way out
bc unaware mayb
It makes no sense to me since spigot preserves nbt
because there is no API way to do it in a readable format I guess
They do it to a byte array
Then to base 64
hm that's pretty useless, why not use a BukkitObjectOutputStream
One sec I'll show
Added API for this now. Though you still have to have a catalyst block in the world (at least for now). Still waiting to get merged, but should look something like this (unless it changes during the review process)
if (!(block.getState() instanceof SculkCatalyst catalyst)) {
return;
}
SculkSpreader spreader = catalyst.getSculkSpreader();
spreader.addCursor(catalyst.getLocation(), 25); // You can put this at any location within the viscinity of the catalyst though```
Related note: sculk is really, really weird to wrap your head around, but it's cool
It's a block that spreads sculk in exchange for mob experience
That's the shrieker
However you spell it
that only contributes to my confusion lmao. guess i should open the mc wiki
How could I get a list of all the usernames so i can check if there is config information of that player?
ConfigurationSection#getKeys(false)
getKeys(false)
Since the names are at the root of the path, you just do config.ketKeys(false)
Did u get ur db to work?
yaml storage supremcy >
is sqlite flat file
So your telling me I should start using something you gave up on? xD
Ye
link
Oh. Pull request if anybody has access and wants to either watch or review the code
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1080/overview
Gotta sign the CLA though
He gave up cuz he couldn't get his mysql db to connect
Im justing making the plugin for my own server with some friends so this should be fine
getKeys(false) will work fine ๐
Alright thanks
How can I paste a schematic? FAWE API doesnt import for me with maven
why can't i use getItemInMainHand here?
public void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();
Inventory playerInventory = player.getInventory();
Material configMaterial = Material.valueOf(plugin.getConfig().getString("material"));
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskLater(plugin, () -> {
ItemStack mainhandItem = playerInventory.getItemIn ???```
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Because an Inventory is not a PlayerInventory
Change your playerInventory variable to be of type PlayerInventory
I'm getting a multiple root tags error
Ah i see, thx!
Can someone help?
your whole config is fucked
bump
Ik that's why I'm trying to make it work. On line one I'm getting an error(multiple root tags)
you only need
<repositories>
// REPOS HERE
</repositories>
<dependencies>
// DEPENDENCIES HERE
</dependencies>
u have multiple of those, and repos in dependencies, vice versa
because you removed the root tag
which is called <project>
this is how a pom should look https://paste.jeff-media.com/?1a5380d87813409b#CF5wxiW7AsVpoK3kKmR7J1dBVysoHoQbfPgGUVrFhPLH
database ?
I mean, depends on the data
stuff like tags, or data that is really only useful in game
PDC works for
item identifier
etc
player data that you might need offline or gets complex ?
why ?
bump bmup mubp
PacketPlayOutAnimation iirc
depends on what swing you mean
Check if the target block is null or something
just do a raytrace
if it hits a block, it's breaking
if it hits an entity, it's attacking
does anyone know how to use 9host?
why do my items merge when i die, even though item merge radius is -1
what the
smh
what do i even do
Where the fk is MultiMap from?
I only know Multimap from gson
import the right one
bro i dont even know
i need to use it for attributes
idk why
AttributeModifier modDamage = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", item.getDamage(), AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, modDamage);
MultiMap<Attribute, AttributeModifier> modifiers = new MultiMap<>();
modifiers.put(Attribute.GENERIC_ATTACK_DAMAGE, List.of(modDamage));
meta.setAttributeModifiers(modifiers); //above error here
itemz.setItemMeta(meta);```
Wut? Thats just me standing there. Was out and some weird poses. idk
How can you even instantiate MultiMap? It should be an interface
no errors for sum reason
how do i set the attack damage and attack speed of an item
this clearly isnt the solution
What are you trying to do? Whats itemz and item
Why do you even need this:
modifiers.put(Attribute.GENERIC_ATTACK_DAMAGE, List.of(modDamage));
bc for some reason
AttributeModifier modDamage = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", item.getDamage(), AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, modDamage);
itemz.setItemMeta(meta);```
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
doesnt set the attack damage properly
What do you mean by properly?
This should be it:
ItemMeta meta = itemz.getItemMeta();
AttributeModifier modDamage = new AttributeModifier(UUID.randomUUID(), "cool.name", item.getDamage(), AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, modDamage);
itemz.setItemMeta(meta);
Use this and see if you get the attribute tag ingame (should be visible in lore)
just use a random name
any help for me?
Is this your parent pom?
yes
This is the absolute weirdest multi module setup i have ever seen
Is this the whole pom?
Is this all in one file?
yes
Because this looks completely fked. Like someone scrambled several poms and just deleted half of the important tags.
This is not xml syntax
You cant define dependencies several times
The project is not closed up. The pom is just open to the bottom end
This is just completely fked
Nothing in there should ever have worked
My suggestion: Set up a clean pom from scratch
Ok thank you
it doesnt even define a groupid, artifactid etc lol
is it possible to compile a plugin with the following files?
you should buy the plugin if you can't even compile it yourself
it just doesn't work
Dont tell me someone actually takes money for this
it looks like "Skywars X" by Wazup92 on spigotmc (13.50USD)
yes
how tf did spigot approve that
approve what
public String player _suicide;
like..
Where is the src code? This is almost as amusing as the "terrible plugin"
My friend told me that he has got the code and wants me to compile it. but it is almost impossible for some reason
I shit you not but
- Source code costs additional money!
1kk?
there's probably some library for that. if not, write it yourself?
Does it have to be performant?
meaning that it's not worth the effort to compile it ?
I don't do this at all
public static String withSuffix(long count) {
if (count < 1000) {
return String.valueOf(count);
}
int exp = (int) (Math.log(count) / Math.log(1000));
return String.format("%.1f %c", count / Math.pow(1000, exp), "kMGTPE".charAt(exp-1));
}
This is ok
where did you get the source code anyway?
0: 0
27: 27
999: 999
1000: 1.0 k
110592: 110.6 k
28991029248: 29.0 G
9223372036854775807: 9.2 E
This are the test results
what is G though?
I used this for some physics stuff. Frequencies.
So G = Giga, T = Terra, P = Peta and so on
ah ok
I didn't
Then change out the suffixes
did you draw this yourself lol
yer
haha nice
on some shitty paper
fking birb
are u tearing apart my crappy website now
ngl I started using my website to host lore for my arma 3 campaigns
just read that
I don't understand the joke
General kenobi the Negotiator ๐
I never watched star wars
General Kenobi was given the title of the Negotiator due to his ability to prevent wars/battles without the use of a weapon
Is there a way i can get the class that called a specified method?
context?
Kind of through the stack trace. But this sounds like bad design on max.
do you know the specific method to call to do that?
basically i would like to have the class that instanciated another class, for example:
sure. one sec
in the class 1 i do new Class2(); and from Class2 i want to get class1(since that's the class that instanciated class2) instanciated without having to like adding Class1 to the constructor of Class2
that would give me the Class, but not like, instanciated
idk how to explain myself, i'm italian sorry
I would strongly advise against using this for anything else than logging purposes.
StackWalker @spring minnow iirc
that's the name, not the class instanciated
might exist alternatives
then do Class.forName(...) ?
thanks, i'll try
then i should instantiate the constructor with the reflection
wait you want to get the INSTANCE of the class that called the method?
?paste
sorry
yes
sorry if i didn't explain well
learn how XML works pls
if you have an opening <project> somewhere then you also must have some closing </project>
i'll try if it can work well to me
I do have a closing.
i think it could
what you just pasted for a second ended with </dependencies>
ah
I edited it, but now I'm getting a different error. Dependency 'xxx' not found
wait
maven fixed my issue
@EventHandler
public void onShieldBlocksDamage(EntityDamageByEntityEvent event) {
if (!event.getEntityType().equals(EntityType.PLAYER)) return;
Player player = (Player)event.getEntity();
if (!player.isBlocking()) return;
PlayerInventory inventory = player.getInventory();
ItemStack mainHand = inventory.getItemInMainHand();
ItemStack offHand = inventory.getItemInOffHand();
ItemStack shield = NetheriteShield.is(mainHand) ? mainHand
: (NetheriteShield.is(offHand) ? offHand : null);
if (shield == null) return;
event.setDamage(Math.max(1d, Math.ceil(event.getDamage() * 0.3d)));
}
Trying to reduce the amount of damage that is done to my custom shield, but it isn't taking any damage. Should I be using a different event? Or should I apply the damage to the item manually?
if a player is blocking with a shield, it negates all damage even if you change it
right so I have to manually set the item damage?
the way i've gone around that is by setting the damage modifier of BLOCKING to 0
maven cannot auto download dependencies for worldedit-core
I tried manually adding it but I'm getting an error Could not find artifact com.sk89q.worldedit:worldedit-core:pom:7.3.0 in dmulloy2-repo (https://repo.dmulloy2.net/repository/public/)
damage modifier is deprecated in 1.19, so should I be using it?
im not sure if theres another way to do it
How can I paste a schematic from local file?
from what i know, it's the only way to change how much damage reduction a player recieves
this seems to have worked
Damageable meta = (Damageable)shield.getItemMeta();
meta.setDamage(meta.getDamage() + (int)Math.round(event.getDamage()));
shield.setItemMeta(meta);
unless you want to do some funky maths
oh i thought you meant change how much damage the player receives
not the shield
oh! no.
I suppose if that was the case I could do something similar by just manually damaging the player
yeah, the only problem with that is if you die the death message won't be accurate
like if you died from fall damage it'll just say "Player died"
instead of "Player fell from a high place"
hmm
maven cannot auto download dependencies for worldedit-core
I tried manually adding it but I'm getting an error Could not find artifact com.sk89q.worldedit:worldedit-core:pom:7.3.0 in dmulloy2-repo (https://repo.dmulloy2.net/repository/public/)
maven used it
I hope you have the enginehub repo in your repos as well
hey im trying to develop a "pets" plugin any idea how i can make heads float and follow the player
https://github.com/EngineHub/WorldEdit is this the one maven should use?
Probably Jitpack uses that
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I believe I haven't added the repo
you have not
am i supposed to download a file from there?
what should the id be
it worked thanks
anyway to get a wolf head?
don't think there is a MHF skull for that
so i have a line here that uses whatever material the user wishes from config.yml Material configMaterial = Material.valueOf(plugin.getConfig().getString("material"));
but i want to change it so that there could be a list of materials that the code will use (so instead of just "give effect when holding diamond", it's "give effect when holding either of these items in the list"
so how would i do that?
change to StringList
then use a for loop forEach key in the String list
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
error while trying to compile
<project> xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
do you see the issue
ye
ty
haven't used stringlist before, how would i format it? i keep getting errors when i mess around with it
list:
- one
- two
OR
list: [one, two]
getStringList("list") -> ["one", "two"]
if the list doesn't exist on the config, or is badly formatted, it returns an empty list
ah i see, thanks!
k so this matches the first element in the list of materials in my config.yml:
Material.valueOf(configMaterial.get(0)
so my list is
- DIAMOND
- DIAMOND_SWORD
- EMERALD```
and my code (using the line sent above) gives the player an effect whenever they are holding a diamond, since it gets the first element in the list
how do i make it so that if they player holds EITHER a diamond OR and diamond sword OR an emerald, they get the effect?
bump bmup pumbup bump
google wasn't that helpful, can someone at least give me some insight on how i would go about to do this?
show how you check for the effect
I gonna guess and the list size isnt always 3 right
so I think you just check if the item in hand got the same material as the given material in the string list
i've got the rest of the stuff covered, i'm just trying to be able to have the effect be applied whenever a player holds any item from the list
and yeah the list isn't always 3
currently the player can configure config.yml to whatever item they want, but it's only 1 item at a time
i want to have the player be able to add a list of items rather than just 1
I would prob. do smth like this:
if(stringList.stream().map(s -> Material.valueOf(s)).anyMatch(material -> <MATERIAL IN HAND> == material)) {
// apply effect
}
aight lemme see what i can do with that, thank you guys
just try to do it with contains
stringList.contains(material.name()) tada
Some capitalization stuff you'll have to be careful of though
I'm having an issue where my plugin doesn't think that my gui title and the string i've provided for the title is the same
show your code
1 sec
๐
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Lines 4 and 5 return the exact same thing
true
Cannot resolve method 'title' in 'InventoryView'
wait you use paper or spigot?
yea this is only for paper
looked in the wrong docs
i use paper on the server, but spigot api in the plugin
then stay with getTitle
can you show what printed
im testing again in a sec
[02:48:42 INFO]: [CieloSkyblock] ยงnCreate an island
[02:48:42 INFO]: [CieloSkyblock] &nCreate an island
ahhh i see
its not the same ;)
yup didnt realize initially lool
xD
can I cancel teleport/move event without sending teleport packet to player
cant you just cancel the event?
then it sends the player an unnecessary teleport packet
if you cancel Entity/PlayerTeleportEvent?
thats weird
https://paste.md-5.net/fojexereje.xml I have that pom.xml, but when I try to load plugin it give me an error like: No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
How are you building your plugin?
with maven
That's IJ?
IntellijIDEA
Beyond my domain. Though you should be able to edit your build somehow to insert goals. By default, no goals are specified. You want to either clean package or clean install
I just have no idea how to do that because I don't use IJ
Not as far as I'm aware
- it doesn't rubberband players back when cancelled
- doesn't fire anymore when player moves wrongly
Very possible that the server just doesn't handle it the same way anymore
then any ideas how to change behavior when player moves wrongly
Only changes related to teleporting was last month to do with two events being called when going through a portal
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/95d233dc5b5ab0bf125ce761ace782bc2f1ac78e
bump
Thanks you
i am using the IntelliJ Minecraft Development plugin and i had a question about local maven projects.
when you create a new project using the dev plugin, it also asks you to fill out your maven dependency details.
lets say you created two projects in your IDE, both with the MC Dev plugin. Both projects have their own pom and dependency details.
How would you add project 1 as a dependency to project 2 with maven?
import me.kyllian.captcha.spigot.CaptchaPlugin;
import me.kyllian.captcha.spigot.handlers.MapHandler;
import org.bukkit.Bukkit;
public class MapHandlerFactory {
private CaptchaPlugin plugin;
public MapHandlerFactory(CaptchaPlugin plugin) {
this.plugin = plugin;
}
public MapHandler getMapHandler() {
String minecraftVersion = Bukkit.getMinecraftVersion();
int mainVer = Integer.parseInt(minecraftVersion.split("\\.")[1]);
return mainVer >= 13 ? new MapHandlerNew(plugin) : new MapHandlerOld(plugin);
}
}``` why I have a` java.lang.NoSuchMethodError: 'java.lang.String org.bukkit.Bukkit.getMinecraftVersion()'` at `String minecraftVersion = Bukkit.getMinecraftVersion();`?
I will try
excuse me, but i could not find ChatMessage class in 1.19
is it removed or renamed?
public class SQLiteDatabase extends SQLDatabase {
private final File folder;
private final String fileName;
public SQLiteDatabase(File folder, String fileName) {
this.folder = folder;
this.fileName = fileName;
if (!this.folder.isDirectory())
this.folder.mkdirs();
File file = new File(this.folder, this.fileName);
try {
if (!file.exists())
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
setupDataSource();
}
public void setupDataSource() {
dataSource.setJdbcUrl("jdbc:sqlite:" + folder.toPath().toAbsolutePath().resolve(fileName));
dataSource.setDriverClassName("org.sqlite.JDBC");
dataSource.setConnectionTestQuery("SELECT 1");
}
@Override
public String getType() {
return "SQLite";
}
}
i think i sent it for mysql
As a Rust user myself,
It pains me to see File getting stored in an object ๐ญ
it should really be called path tbh
in rust?
public abstract class SQLDatabase extends Database<Connection> {
protected final HikariDataSource dataSource;
public SQLDatabase() {
this.dataSource = new HikariDataSource();
}
public Connection getConnection() {
try {
return this.dataSource.getConnection();
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
public boolean isConnected() {
try (Connection connection = this.getConnection()) {
return connection.isValid(2);
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
public void close() {
if (!dataSource.isClosed())
this.dataSource.close();
}
}
no in java
it is..
File is called path in java?
yeah but i find it weird that File just represents the path to a file
and not a file itself
well you cant really own a file
in every language its like that
either you store what the file was, or keep a reference to it
because files arent stored inside the language
hm that's true
its dependent on the OS
oh btw can you help me out with reactive streams?
^
i'm reading here but i dont understand it
that is not working tho, when reloading dependencies it says it cannot be found
show the pom
The first one is me trying to add it to a different project, the second one is the pom.xml of the project iteself
did you do mvn install
where do i do that? and what is it's significance
it builds it and installs it to the local repository
but dont you need to upload the maven project anywhere?
huh
just do maven install on whatever you need to be accessible
it handles the rest
can I change the behavior when player moves wrongly (such as >10 blocks in one tick, through blocks, too fast)
I mean if I for example use spigot api as dependency. Doesnt maven download it from the internet
yeah
any args or just mvn install?
mvn install
thats it
you can press the maven button on the side of your intellij also
and how could I upload my own project to maven so others can just add it to the dependency? never got told
doenst that build your JARs tho? im confused
just do it
add it to github
then use https://jitpack.io/
that just resulted in an error saying the dependency couldnt be found
oh am i supposed to remove it first?
which one
the main project it seems
im confused
not the one i am trying to add
where did you install
yeah wrong one
Could not resolve dependencies for project dev.shreyasayyengar:rpdnd-core:jar:1.0-SNAPSHOT: dev.shreyasayyengar:purchaseclaim:jar:1.0-SNAPSHOT was not found in https://repo.papermc.io/repository/maven-public/ during a previous attempt.
rpdnd-core is my main project, purchaseclaim is the dependency i am tryuing to add
which is still showing as red
do install on purchaseclaim
yup
oh lol ayt it worked now, it's no longer red
๐ญ can you explain what just happened
xD
install builds the project then puts it on your local repository
maven just weird
nah its simple
Ah, so that it can be found via other dependencies correct?
yup
it first looks into local projects, adn then tries to search globally i assume?
now if you want other people to be able to access it, you should use this
nope install puts it into its own folder
into a folder in your user folder
i mean, when i reload the dependecies in my main project
actually not that hard, but no one ever explained how to use maven
you don't have to do install anymore i dont think
it reloads dynamically
for intellij i think
public interface AltPlayer {
Set<PlayerIP> getIPs();
PlayerIP getIP(String ip);
boolean hasJoinedWith(String ip);
boolean hasJoinedWith(PlayerIP playerIP);
PlayerIP getLastIP();
String getName();
UUID getUUID();
long getLastLogin();
void addLogin(String ip);
}
I have this interface with an implementation and I'd like changes to be pushed to the db no matter where addLogin(String) is called from. Other than passing my database class which can put the player data back in the table, what other solutions are there?
right right, but what i am asking is that, once the install has been ran on my sub-project, when i add that depo in my main project, i assume it first tries to find that dependency locally, and then searches the web?
or am i completely wrong
right
it only searches in the repositories you specify*
not the entire web
its not that stupid
anyways
ye, i guess only the repos that have been added?
C:\Users\YOUR_USER\.m2\repository
I was trying to use java reactive streams but i dont think that those are an ideal solution
Dependency inversion
An AltPlayer should only be a record
Any mutations can happen through a manager class
Alternatively, inject mutation callbacks into the object
That way the object doesn't need to actually know about the db
^ hes trying to say, make a manager class
But it can still carry out what you need
That's the first option I gave
^ but make sure altplayer only knows what it needs to
The second is to inject callbacks
Or just one in this case I guess
Consumer<AltPlayer> onUpdate
so addLogin(String) should be just part of the impl?
That would probably make sense
No data leaking!!! - yes
Updating the db is an implementation detail though
hold on i gotta google these terms
Your implementation of the interface should have a constructor that takes any dependencies it needs
You don't want it to have a dependency on the actual database
i just say data leaking, i dont really know the term for it
anti encapsulation
that
So you should pass in callbacks that perform the db update and are called when the field is mutated
on the main thread!!!! /s
The callbacks could add a task to a queue
Arc<Mutex<Vec>>
Ignore him
Ignore the guy above me
ok so just to clarify, it's ok to remove addLogin from the interface and put it in the implementation only where i can call addLogin(Consumer<AltPlayer> onUpdate)?
the onUpdate
ok that makes even more sense
And when addLogin is called, you call it
yep gotcha
That way the database isn't a hard dependency for AltPlayer
ok ty
suckup
lmao
I just like answering design questions 100x more than npe #8553368801
hi
no
?nohello when
what would that do
can someone help please i got this error : The method registerPlaceholderHook(String, PlaceholderHook) from the type PlaceholderAPI is deprecated when using placeholder api
say "Saying hello is disallowed in this server."
look at the docs for it
try CTRL + Q
i might have a different keybind
Look up nohello
Or just https://nohello.net/en/
i am using
PlaceholderAPI.registerPlaceholderHook("nve", new PlaceholderHook() {
@Override
public String onRequest(OfflinePlayer p, String params) {
if (p!=null && p.isOnline()) {
return onPlaceholderRequest(p.getPlayer(), params);
}
return null;
}
@Override
public String onPlaceholderRequest(Player p, String params) {
return params;
}
});}
}```
Use PlaceholderExpansion
?nohello
And you just call .register() on it
hello
oh ok
๐
Hello imajin
๐
another question,
public record PlayerIP(UUID getUUID, String getIP, int getNumLogins, long getLastLogin){}
This is the PlayerIP record and these are how instances are stored in AltPlayerImpl
private Map<String, PlayerIP> ipMap = new HashMap<>();
When i want to modify a PlayerIP, to change last login or whatver, should i just create a new one and replace it in the map or should i switch from a record to class with getters and setters for PlayerIP?
i'll fix it later
I always do
i always do those when i'm done coding
^ shit google intern
๐
target/
.idea/
Cargo.lock
*.iml
Redempt
?
using a Consumer<PlayerIP> onUpdate since the only thing that can really be updated in AltPlayer is the playerip
i guess i can change to a consumer<AltPlayer> if that changes
You may want to create a separate record class that indicates what changed if that happens
Otherwise you'll need to update every row in the db because you don't necessarily know what changed
i wont need to if i use the PlayerIP consumer
since that corresponds to a single row
A manager class is a bit less elegant but it does reduce the boilerplate
Yeah
Keep it to just PlayerIP if you can then
i am very mad at java for not naming the method in Consumer "eat"
fuck java
should be consume
no because consume usually means get rid of itself, return a value
i think eat would be perfect
Eat<FuckingClass>
another design choice question
planning my plugin rn hence all the questions
public abstract class AltDatabase {
public abstract AltPlayer getAltPlayerFromUUID(UUID uuid);
public abstract AltPlayer getAltPlayerFromName(String name);
public abstract Set<AltPlayer> getPlayersFromIP(String ip);
public abstract void insertIPData(PlayerIP playerIP);
}
why leave this as an abstract?
@Override
public AltPlayer getAltPlayerFromUUID(UUID uuid) {
//get stuff and then
return new AltPlayerImpl("name", UUID.randomUUID(), 5, new HashSet<>(), this::insertIPData);
}
ope
the AltDatabase?
yea why are you using an abstract class just curious
to support multiple types of databases
putting data in mongo is not the same as inserting into sql
considering you have 0 implementation at this level an interface is just a better option
that was just an example i typed out
and yes you'd want to abstract your database layer.
You'd also want something like connect and along those lines
that's already done
looks good to me, but I'm not an expert
Can i store in persistentdatastorage my custom class instance?
Asynchronous command dispatch! what is that?
my code line is Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "kick "+player.getName()+" Ai gresit captca-ul");
and if i want to replace it with player.kickPlayer(reason) it send me Asynchronous player kick!
could it possibly be that ๐คทโโ๏ธ its being run asynchronously
considering I have no clue of the implementation my gut is telling me your using AsyncPlayerChatEvent
and running this
you can make your own type
yep
can i solve it?
not that I'm aware of api warns of restricted uses
The constructor provides a boolean to indicate if the event was fired synchronously or asynchronously. When asynchronous, this event can be called from any thread, sans the main thread, and has limited access to the API. ```
smth I did a few months ago:
public class PartyDataType implements PersistentDataType<byte[], Party> {
@Override
public Class<byte[]> getPrimitiveType() {
return byte[].class;
}
@Override
public Class<Party> getComplexType() {
return Party.class;
}
@Override
public byte[] toPrimitive(Party complex, PersistentDataAdapterContext context) {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos)) {
out.writeObject(complex);
return bos.toByteArray();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
public Party fromPrimitive(byte[] primitive, PersistentDataAdapterContext context) {
try {
InputStream is = new ByteArrayInputStream(primitive);
ObjectInputStream o = new ObjectInputStream(is);
return (Party) o.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
}
Okay
Ibstead of party should be that my class right?
yes
in namespaced key, first argument, can just do new Pluginname()?
isnt first argument the name?
then how do i access it?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
like
with static variable
di is better
im gonna stay with static variable
yes
that works but its good practice to use dependency injection
also instead of making it public make a static getter
yea
ok
and make it private
cool thanks
Learn DI though. It will serve you well in many instances
Elgar
yep
are you a fan of rust
Never used it
are you a fan of it tho
I've never even looked at it to know
// Include a function that's defined by the VM.
// These have to be included manually, (as seen below), because we don't want the VM to cloud the namespace.
include vm_stdout_write;
// This function is ran when the VM starts.
_start:
// Push the message to the stack.
push "Hello, world!\n";
// Write to stdout.
call vm_stdout_write;
// After the call to vm_stdout_write, the stack should have a new value, an i32.
// Since the _start function should also return an i32 as the exit code, we'll just return.
ret
thoughts on the frontend of my vm?
inspired by assembly
I can see the similarity
one of those comments is wrong
Too early in the morning for me to read faint grey on black comments.
ill help with that
much better
are you in europe?
UK
can someone help please
?ASK
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
just ask
L
i got this error using placeholder
U keep an odd schedule
lmao
Failed to load expansion class PlaceHolder - One of its properties is null which is not allowed!
Fuck he got me
I feel thats extemely self explanatory
java.lang.NullPointerException: Cannot invoke "String.replace(char, char)" because "name" is null
self explanatory once again
um, why would stdout leave an i32 on the stack. seems wrong
are you programming java without the knowledge of what null means
you better quit while your at it
error code
Having never seen Rust but I know ASM I'm going to assume an i32 is a call reference used to return to the calling function
it uses teh stack for errors? odd
errors in asm are sinple binary checks
the stack is not used
stack is for data (push/pop) and calls
well and for swopping register values
pardon my slow typing and thinking
no
maybe
decent
maybe something like this
_start@success:
ret i32:0;
_start@error:
ret i32:1;
_start:
push "Hello, world!\n";
uni i32 var; // unset variable
mov var, vm_stdout_write; // mov Destination, Data
cmp var, i32:0 // comparison of `var` and 0 (success)
uni i32 code; // haha
mov cat _start@success, _start@error // continue at: If True, If False
ret code;
@eternal oxide
u dance like this when u code yea
btw why isnt assembly assembly rather than asm
looks very close to standard asm with a few tweeks
i read like 10 pages of assembly documentation
omw to continue that project and be its maintainer
.
ill remake it
want the syntax?
yea
booleans gonna be "booba"
true and false is "a/t"
errors are gonna be "RuntimeDickhead" rather than "RunTimeException"
the syntax isnt that advanced
my asm days were from before there were GUI compilers. we wrote mnemonics and then straight to hex.
its called stackL for a reason
y
uhm imajin
help me out
i m usin python rn
return "dingus", req.json()
what will this return
an array of two elements?
a tuple
explain in java terms ๐ซ
python supports multiple return types
(&str, JsonObject)
yea sadly
explain in fortnite terms
for example
(str, Json)
var1, var2 = function();
[] but final and unwritable
yea and Json thing is a dict
oh aight
let (var1, var2) = function();
stack String messages_to_print;
cpt print_messages:
copy messages_to_print -> stdout_buf;
run stdout_flush
cpt main:
push "Hello, world!" -> messages_to_print;
run print_messages;
@golden kelp have a blast
what is this ancient text
Rust
i bet rust devs got a load of crabbitches
And here I was thinking rust syntax was super fucking weird from glancing at it in the past
xd
that seems semi normal
what language will get u more bishes
1๏ธโฃ - rust
2๏ธโฃ - c
3๏ธโฃ - js
4๏ธโฃ - brainfuck
people who use code in JS hate themselves too much to find someone else
holy shit that hurts
They are busy on debating whether they should go on to actually think about getting a gf
their minds are busy on "Is life really worth it"
JS sucks
xd
If i were to ever touch web dev I'd use WASM if I can't only purely use wasm I'll use Type Script to soften the pain
gross web development is too oversaturated for me to care about anyways
It seems like everyone and their brother wants to be a web developer
thats so true
especialy on twitter
with that #100devs thing
I rather work back end or on system administration than Web Develop
everyone is either a "10+ year experience web3 solana smart contract developer" or a "expert in html developer"
Web Development Sucks why I sitll haven't gotten around to my website
I need to learn wasm first
but before I learn wasm I need to learn rust
eh I'll make that my project next week
@quaint mantle your answering all my rust questions next week
don't worry though I'm quite acquainted with the search engine named Google
rust makes me cry myself to sleep
get good
no
thats so fucking smart, whoever thought of that has like 69696969696iq
yes
Hi guys, I need some info about server management. Could I remove the fallback server and re-add it? What will happen when I remove the fallback server?
I mean using ProxyServer.getServers().remove() method.
sometimes I wonder how they justify the price of 499โฌ for this when it does shit like this
for 1 year per person
I though like 120+ or smth xD
oh wait i just see, if you go to "for personal usage" then it's 150 per year
also why can't i define a constructor signature in interfaces
or at least declare an abstract constructor in an abstract class
or force a class implementing an interface or extending an abstract class that they have to "override" a certain static method
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "TcfbYӨfbob60fbuਉfb'f73fbvƍdfce Ⴟfcuc91fcsȹbfcefa4fcd EaefcyIb8fcocc2fcuVccfdr Zd6fdk	adffdi&#a3e9fdt&#adf3fd!")); how could I use gradients?
what would be the point tho?
telling classes that implement / extend MapSerializable to provide a static deserialize method
or to have a constructor that takes a Map
well you can do that through documentation?
and if you really want you can check whether they do so with reflection, and if not, throw an exception
still this requires me to use reflection to call the respective method then
and this could be avoided by allowing interfaces or abstract classes to declare static methods or constructors
I'm not asking for a workaround but why it's not possible in the first place ๐
reflection ๐
well, since static methods are part of the class, you should be calling them with ClassName.method() and therefore, if you want to accept Class<? extends YourInterface> as parameter you'll have to use reflection to call the method, and if you are calling the static method on the instance of the class like new ClassName().staticMethod() you can just not make it static.
yeah I know. but if I have a method that takes a Class<T extends MyInterface> then the compiler should know that T.somethingFromMyInterface() is a thing
unfortunately it isn't and so my question was: why not?
it should at least allow to declare a constructor signature
but it doesn't and that's why I'm sad
Abstract constructors (especially in interfaces) are nonsense
using adventure?
Iโm very, very new to javaโฆ could you give me an example/docs?
https://docs.adventure.kyori.net/
Audience audience = Plugin.getInstance().adventure().player(player);
audience.sendMessage(MiniMessage.miniMessage().deserialize("<rainbow>Hello world</rainbow>")); // Adventure may be included in spigot, so you can use player.sendMessage if it
Thank you! Iโll try it out :)
well according to OOP definition of interface
In Object Oriented Programming, an Interface is a description of all functions that an object must have in order to be an "X".
interface defines a description of functions for the object and since static methods are not members of objects, but rather classes, then it won't make sense to allow interfaces to enforce static methods. What you are suggesting is a compile-time checks for the presence of methods access with reflection
in the specific case of serialization, in my opinion, it would make more sense to create a separate Serializer(s) and Deserializer(s) and register them for their corresponding types, like, for example in GSON
although i never worked with, i would assume that compile-time reflection checks would be possible with java compiler plugin
So what about the constructor? That's basically also just a method so it should be "declarable" in an interface
but it isn't
I mean, sure, I can and am using workarounds like getting the constructor with reflection. But it feels so stupid since java could just allow to declare a constructor in an interface to avoid this
Here's what I'm currently doing but I just don't like having to do this https://paste.md-5.net/wemonitiji.java
constructors are special methods, and i'd rather say they are static methods
Line from JLS
Constructor declarations are not members. They are never inherited and therefore are not subject to hiding or overriding.
but they aren't static methods. It first creates a new object and then calls the respective <init> method. So in bytecode they are just regular methods
yeah, they aren't, and they arent member methods either, but in my opinion they are more similar to static factory methods
anyway, I know that I cannot declare constructors or static methods in interfaces. I just say, it would be nice if it would be possible
You could use an abstract class depending on what the goal is
LOOOL
LMFAO
wtf
we have some kind of idiom here that goes like:
"climb the tree and get the dates. come back here who told you to climb??"
Have you add the repository?
constructors cannot be declared abstract
but like, static methods are supposed to not need a constructed object, and only objects can have inheritance
so it make sense
SELECT *, FIND_IN_SET(rating, (SELECT GROUP_CONCAT(DISTINCT rating ORDER BY rating DESC) FROM {table} WHERE ranked = 1)) AS r FROM {table} WHERE ranked = 1;
SELECT *, FIND_IN_SET(previous_season_rating, (SELECT GROUP_CONCAT(DISTINCT previous_season_rating ORDER BY previous_season_rating DESC) FROM {table} WHERE previous_season_ranked = 1)) AS previous_rank FROM {table} WHERE previous_season_ranked = 1;
Anyone knows how I can combine these 2 queries into one? So I get 2 extra columns at my ResultSet (AS rank and AS previous_season_rank)
Note: {table} is replaced with the name of the table
for static methods to not be able to be overriden
for solo use its not that expensive tho https://gyazo.com/f213bab7c729bb32dcdb11d480c17e21
;/
Ouch I thought you could. Never really used them
and there are some design patterns to go around that problems
yeah :< I currently do it like this, which works fine but I think it's dirty https://paste.md-5.net/wemonitiji.java
i cant see how thats needed
look at the code I just sent
I need it to call the constructor of my serializable classes without reflection
Anyone?
https://stackoverflow.com/questions/260666/can-an-abstract-class-have-a-constructor
Can't you just create a normal constructor?
I need to call the Constructor that takes a Map from the MapSerializable class. All I have there is a Class<? extends MapSerializable>
and since I cannot declare that every MapSerializable has a Constructor that takes a Map, I can't do that without reflection
I basically wanna do what bukkit's ConfigurationSerializable does, and that one has the same problems that I currently have lol
it also needs to call the static deserialize or the map-constructor with reflection
I'm pretty sure that if md5 hasn't found a better way, then I won't find any better way either lol
if you don't want to be dirty, i'd suggest you something like this
public interface MapSerializer<T> {
T serialize(Map<String, Object>);
}
Instead of having an additional constructor in the class, you put the serialization in a separate class like MyClassMapSerializer implements MapSerializer<MyClass> or even lambda expression map -> ..., and store those serializers instead of constructors, like Map<Class<?>, MapSerializer<?>>. with a method <T> void add(Class<T>, MapSerializer<T>) which will guarantee that class will match with correct map serializer
the serialize method is no problem. It's the deserialize method
So you want to call a constructor of an abstract class after your constructor was already called and give it arguments
isnt that just a design problem
no, I want to call the constructor of the given class that extends my abstract class