[solved]How to code 3 stages of warp (del, set, warp)

Hi so i see a bit of how people are going about coding warps and teleportations…but can i just ask for someone to show me how to setup the command executors for these three types of commands :slight_smile: thank you

This should help

https://docs.spongepowered.org/en-GB/plugin/commands/index.html

not quite…i already know how to use command executors…i mean the methods for setting a warp deleting a warp and creating a warp…what kind of methods are used examples etc :slight_smile: but thank you anyway

I’m not sure if something like warp exists in sponge, since it doesn’t exist in vanilla.

ahhh except they do :smile:

because they have location vectors and teleport helper… i just don’t know how to use these…yet :slight_smile:

Ok. Sry I thought you meant a warp object/class.

1 Like

:slight_smile: it’s ok I understand I’ve messed up worse… like forgeting to add a @listener to an event before and then freaking out :sweat: and when i found out…lol let’s just say i couldn’t program for a while as I was upset with my self :slight_smile: so trust me i’m not bothered by your suggestions :slight_smile: infact your suggestions clarify and allow others a more in depth knowledge of what i’m asking for :slight_smile: so thank you @TypicalDarkness :slight_smile:

I’d first of all create a class to define warps:
Something like this:

public class Warp {
    private Location<World> location;
    public void setLocation(Location<World> l) {location = l; }
    public Location<World> getLocation() {return location; }

    public void teleport(Player p) {
        p.setLocation(getLocation());
    }
    public Warp(Location<World> l) {
        setLocation(l);
    }
}

Storing the warps in a Set would make it quite easy to add and delete (remove) warps.

1 Like

hmmm ok

that’s a start i believe…what do you think @simon816?

Ok i should also problably state that this isn’t really a warp i’m trying to create…just a single teleportation with a single string (name) that’s changed all the time

…ok soooo here’s an issue
[01:17:52] [Server thread/FATAL] [FML/]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_66]
at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_66]
at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:715) [FMLCommonHandler.class:?]
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:656) [MinecraftServer.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:364) [po.class:?]
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:598) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:478) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_66]
Caused by: java.lang.NullPointerException
at net.minecraft.command.ServerCommandManager.func_71556_a(SourceFile:81) ~[cl.class:?]
at net.minecraft.network.NetHandlerPlayServer.func_147361_d(NetHandlerPlayServer.java:812) ~[rj.class:?]
at net.minecraft.network.NetHandlerPlayServer.func_147354_a(NetHandlerPlayServer.java:791) ~[rj.class:?]
at net.minecraft.network.play.client.C01PacketChatMessage.func_180757_a(SourceFile:37) ~[lu.class:?]
at net.minecraft.network.play.client.C01PacketChatMessage.func_148833_a(SourceFile:9) ~[lu.class:?]
at net.minecraft.network.PacketThreadUtil$1.onProcessPacket(SourceFile:85) ~[ih.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) ~[ih.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_66]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_66]
at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) ~[FMLCommonHandler.class:?]
… 5 more

So i get this after i’ve written my codeing for a warp system…however i got this from trying to set the warp location…help?

Why dont you learn java first?

Why don’t you learn manners first?

2 Likes

It would be a lot more helpful if you posted code.

This looks like you passed in null somewhere, but it’s impossible to tell where from that error.

1 Like

Can i see all your code?

btw i thought you were struggling with the command bit not the warp part. Sorry

and just to get my way of doing it. I would have just have a global MAP

Map<String, Location<? extends Extent>> WARPS = new HashMap<String, Location<? extends Extent>>();

Oh and do you mean that the name changes all the time? or the location changes? by

Ok i should also problably state that this isn’t really a warp i’m trying to create…just a single teleportation with a single string (name) that’s changed all the time

2 Likes

code is MainClass || setPortal || portalManager || portalLocation || Portal || deletePortal || configurationManager

Thank you :slight_smile: I think it has something to do with the location value…possibly…lol like i said this is the first time i’ve tried warps… the rest of the coding still works but when i try to run the commands for warp with a name that’s when the errors hit :slight_smile: thank you

its ok.

just got a few questions.

  1. How come your using a custom version for what is essentually a Vector with double values. What I mean by that is your PortalLocations is identical to loc.getPosition(); (returns a Vector3d) only vector3d is used a lot more in Sponge then your PortalLocations. Its used in the same way. Sorry if that sounded rude, didnt mean to

  2. on your main class, you have a lot of listeners and a lot of code. This code repeats itself for the different entity types

       if (event.getTargetEntity().getType().equals(EntityTypes.CHICKEN)){
         player.sendMessage(Texts.of("You Killed a Chicken & earned some Money"));
         this.economy.getPlayerAPI().addCurrency(player2, ConfigurationManager.getInstance().getConfig().getNode(new Object[] { "Pay_4_Kills", "Chicken" }).getInt());
       }
    

how come you dont just do this instead of repeating the code

EntityType entityType = event.getTargetEntity().getType();
player.sendMessage(Texts.of("You killed a " + entityType.getName() + " & earned some money"));
this.economy.getPlayerAPI().addCurrency(player2, ConfigurationManager.getInstence().getConfig().getNode(new Object[] { "Pay_4_Kills", entityType.getName() }).getInt());)

as for your issue, i would try and make your code more effienct by removing as much unnessery code as possible then trying again

ok well i can definetly do that…but that doesn’t help me with why the commands for warping are not working :frowning:

If you remove code and still get the issue it means that the issue is easier to find.

1 Like