Noob asking for advice!

I’m new to the world of Java and plugin development so I don’t might a jab here or there about my lack of knowledge, as long as you help solve my issue of course. :stuck_out_tongue: Anyway, I’m trying to make a plugin that will execute a command when a player clicks (I’m not picky about left or right clicks) on a Pixelmon statue. I figure I would need to implement the Pixelmon API into my plugin (which I have no idea how to do)…well, basically, as far as I’ve gotten so far is (to my amazement) I just now finally got the plugin to register the clicking of a sign, so basically I would like a helping hand with pretty much the whole event handler after that, as in what I want clicking on a sign (will hopefully later be replaced with Pixelmon statues) to do.

I want it to:
Check for if it has been 24 hours since they last triggered the event and
If they haven’t triggered the event in the last 24 hours, set a timer variable specific to that player at the current time so that the player would have to wait 24 hours after they click the sign before they can click it again

(The sign/Pixelmon statue will be coded to teleport a player to specified-in-the-config coordinates)
Check the location where the sign/statue teleports for if a player is already at that location. If there is a player detected at the teleport-to location, it does not teleport the player clicking the sign and tells them someone is already at the location and to come back later. If there is no player at the teleport-to location, it teleports the player clicking the sign/statue to the teleport-to location and

Sends a few messages to the player (just instructions on how to do and leave the event when done) as well as spawns the Pokemon they will be fighting in the event. The plugin will have to send the console a command to execute, which would be the /pokespawn command. I also want to add a randomly chosen variable value to the command. I want to spawn a boss Pokemon with the command, but I want the type of boss Pokemon (options 1-4 in the actual command syntax) to be randomly selected, so that when the Pokemon spawns, it spawns as either a red, blue, yellow, or green boss randomly selected by the plugin.

I know it sounds like a lot, but I have a tendency to over-explain things, I have been told. Hope I’m not asking for too much. Thanks in advance!

Pixelmon was shutdown a while ago I believe. However we can still help if we want to. The problem is I dont know a thing about pixelmon. Are the ‘statues’ classed as Entity or Block?

To add the implementation of the Pixelmon API is really easy, however because it is closed source. You need a copy of a working pixelmon mod. After that you go to your projects build path and add the pixelmon mod as a external jar. (I can not be any more specific unless I know what IDE you use - the program you use to program in java).

As for getting data from a config file. this will help. Just get the world name and the 3 double values (XYZ) and build a location from there.

Checking if a player is at that location is easy too. get all players

Sponge.getServer().getOnlinePlayers();

then for each player get there location and check the distance from there current location and that config location and check that the distance is not less then 1. If it is then fail the teleport, if not teleport

Console commands are simple too. look for the sudo or sendCommand in the CommandManager

for a random number generator here is the simple code

Random random = new Random();
//random number between 1 and 4
int randomNo = random(3)+1;

IntelliJ. Sorry I didn’t specify that earlier. XD

The Pixelmon statues I would like to say are classified as blocks but I’m not 100% sure. They don’t move or make any noise and are not interact-able in any way.

To add a external jar in intelij. Open your project. Then select “File” and then select “Project Structure”. After that click “Libraries” and then select the little green plus sign. Then select “Java” and browse for the pixelmon mod. After that it will say something along the lines of “Are you sure” and click ok. After that click “apply” then ok. If you now select your Libraries folder under your project src, you will see it

As for if it is a block or a entity. You can do the following to list all blocks and all Entities. From there you can see if something matches

Set<BlockType> types = Sponge.getRegistery().AllOf(BlockType.class);
types.stream().forEach(t -> Sponge.getServer().getConsole().sendMessage(Text.of("Block: " + t)));
//entities
Set<EntityType> types = Sponge.getRegistery().AllOf(EntityType.class);
types.stream().forEach(t -> Sponge.getServer().getConsole().sendMessage(Text.of("Entity: " + t)));

Sweet, thanks. I’ll try that so see if I can find the statues. The random integer thing is given me an error, though, saying that its requiring an integer but found a double instead.

XD can you tell im tired. What i wrote was not code… At least java.

Try this.

Random random = new Random();
int value = random.nextInt(3) + 1;

I’m also having trouble with the other code, I’m afraid. :frowning:

… You really want me to spoon feed you the code?

No no, just wanted to be pointed in the right direction. I apologize if it seems that way.

I’ll just stick with normal Minecraft signs for now until I get more experience working with Java and the Sponge API. XD

Ok. Tell me if you need any other help. Just so you know the bit i got wrong was getting the console of the server and sending the message. I got this wrong because it is something that should be learnt.

this will help you learn Sponge:
https://docs.spongepowered.org/stable/en/plugin/index.html

this will help you learn Java:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html

I understand. I’m trying to rush this process. XD I’m literally trying to do this with both Java tutorials and Sponge plugin tutorials open on my other monitor. I do appreciate your time, though!

Pixelmon statues were entities I’m pretty sure. InteractEntityEvent (if it’s even thrown) will be what you want.

Awesome, thanks! I’ll give that a try!

Note:

The ‘clicking on a sign to execute the spawn command’ worked before I added the 'if (block.getLocation().equals(getBlockAt(“world”, 1082, 64, -900))) { ’ statement, so I know the problem is somewhere with this piece.

Thanks in advance!

Try doing

Block.getLocation().getBlockPosition().equals(

As location equals will attempt to match the exact location so a location of 1.1, 0, 0 trying to match 1.0, 0, 0 will fail. Getting the exact block location and matching them should match

1 Like

if (block.getLocation().getBlockPosition().equals(getBlockAt(“world”, 1082, 64, -900))) {

This gave me an error so I tried changing it to

if (block.getPosition().equals(getBlockAt(“world”, 1082, 64, -900))) {

which didn’t give me an error but still didn’t work in the plugin, or am I just stupid and was using your code incorrectly?

Using my code incorrectly. The idea of equals is for both classTypes to be the same before and after the equals.

So your getBlockAt needs to have . getBlockPosition on the end too