Results 1 to 4 of 4
  1. #1
    ohtraitor is offline Member
    Join Date
    May 2014
    Posts
    2
    Rep Power
    0

    Default Help on my minecraft plugin!!

    So, im making a minecraft plugin for my server. And im having a bit of trouble, I want it so that when you do the command (map1) it will create a new world/Just copy the map so its the same always through multiverse and then teleport you to it. But ive only made it so it teleports you to coordinates. Any help? :/


    package me.simmmatt;


    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Maps extends JavaPlugin {

    @Override
    public void onEnable() {

    }

    @Override
    public void onDisable() {

    }

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if (cmd.getName().equalsIgnoreCase("map1") && sender instanceof Player) {

    Player player = (Player) sender;





    Location teleportLocation = null;

    int x = 0;
    int y = 150;
    int z = 0;

    boolean isOnLand = false;

    while (isOnLand == false) {

    teleportLocation = new Location(player.getWorld(), x, y, z);

    if (teleportLocation.getBlock().getType() != Material.AIR) {
    isOnLand = true;
    } else y--;

    }

    player.teleport(new Location(player.getWorld(), teleportLocation.getX(), teleportLocation.getY() + 1, teleportLocation.getZ()));

    player.sendMessage(ChatColor.GREEN + "You have been teleported to map 1!");

    return true;



    } else if
    (cmd.getName().equalsIgnoreCase("map2") && sender instanceof Player) {

    Player player = (Player) sender;





    Location teleportLocation = null;

    int x = 100;
    int y = 150;
    int z = 100;

    boolean isOnLand = false;

    while (isOnLand == false) {

    teleportLocation = new Location(player.getWorld(), x, y, z);

    if (teleportLocation.getBlock().getType() != Material.AIR) {
    isOnLand = true;
    } else y--;

    }

    player.teleport(new Location(player.getWorld(), teleportLocation.getX(), teleportLocation.getY() + 1, teleportLocation.getZ()));

    player.sendMessage(ChatColor.GREEN + "You have been teleported to map 2!");

    return true;

    } else if
    (cmd.getName().equalsIgnoreCase("map3") && sender instanceof Player) {

    Player player = (Player) sender;





    Location teleportLocation = null;

    int x = 300;
    int y = 150;
    int z = 300;

    boolean isOnLand = false;

    while (isOnLand == false) {

    teleportLocation = new Location(player.getWorld(), x, y, z);

    if (teleportLocation.getBlock().getType() != Material.AIR) {
    isOnLand = true;
    } else y--;

    }

    player.teleport(new Location(player.getWorld(), teleportLocation.getX(), teleportLocation.getY() + 1, teleportLocation.getZ()));

    player.sendMessage(ChatColor.GREEN + "You have been teleported to map 3!");

    return true;

    }
    return false;
    }
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Help on my minecraft plugin!!

    Please edit your post and wrap your code with code tags:
    [code]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Shadow48402 is offline Member
    Join Date
    May 2014
    Posts
    2
    Rep Power
    0

    Default Re: Help on my minecraft plugin!!

    So if I understand, you want to copy a world?

    In that case you can use this util, it's on the bukkit forums (Link)
    Java Code:
    public void copyWorld(File source, File target){
        try {
            ArrayList<String> ignore = new ArrayList<String>(Arrays.asList("uid.dat", "session.dat"));
            if(!ignore.contains(source.getName())) {
                if(source.isDirectory()) {
                    if(!target.exists())
                    target.mkdirs();
                    String files[] = source.list();
                    for (String file : files) {
                        File srcFile = new File(source, file);
                        File destFile = new File(target, file);
                        copyWorld(srcFile, destFile);
                    }
                } else {
                    InputStream in = new FileInputStream(source);
                    OutputStream out = new FileOutputStream(target);
                    byte[] buffer = new byte[1024];
                    int length;
                    while ((length = in.read(buffer)) > 0)
                        out.write(buffer, 0, length);
                    in.close();
                    out.close();
                }
            }
        } catch (IOException e) {
     
        }
    }

  4. #4
    ohtraitor is offline Member
    Join Date
    May 2014
    Posts
    2
    Rep Power
    0

    Default Re: Help on my minecraft plugin!!

    I dont know how to edit the thread to do so.

    And thanks for the help with that. Is it possible to have it copy and rename it through like a certain amount of names if not used?

Similar Threads

  1. Minecraft Plugin Help
    By dckillerman123 in forum New To Java
    Replies: 8
    Last Post: 09-19-2013, 04:07 PM
  2. Minecraft dev needed, will pay $$
    By nate252 in forum Jobs Offered
    Replies: 0
    Last Post: 09-04-2012, 02:45 AM
  3. Java - Plugin for Minecraft
    By Modz in forum New To Java
    Replies: 1
    Last Post: 08-19-2012, 03:33 PM
  4. Replies: 0
    Last Post: 12-16-2010, 11:14 AM
  5. AnyEdit Plugin For Eclipse Plugin
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-18-2007, 01:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •