Help With Plugin

Discussion in 'Plugin Development' started by gs0543, Apr 27, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    gs0543

    Somone on the forums made my server a custom plugin Here is code

    Code:
    package its.jh.ethrowilderness;
     
    import java.io.PrintStream;
    import java.util.Random;
    import org.bukkit.*;
    import org.bukkit.block.Biome;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.FileConfigurationOptions;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class EthroWilderness extends JavaPlugin
    {
     
    public EthroWilderness()
    {
    }
     
    public void onEnable()
    {
    getConfig().options().copyDefaults(true);
    saveConfig();
    PluginManager pm = getServer().getPluginManager();
    world = getServer().getWorld(getConfig().getString("world"));
    if(world == null)
    {
    System.out.println("[EthroWilderness] Specified world not found.");
    pm.disablePlugin(this);
    }
    radius = getConfig().getInt("radius");
    random = new Random();
    System.out.println("[EhtroWilderness] ItsJerryAndHarry thank you for using EhtroWilderness!");
    }
     
    public boolean onCommand(CommandSender sender, Command cmd, String label, String args[])
    {
    if(!sender.hasPermission("randomspawn.wild"))
    {
    sender.sendMessage((new StringBuilder()).append(ChatColor.GRAY).append("[").append(ChatColor.RED).append("EthroWilderness").append(ChatColor.GRAY).append("] ").append(ChatColor.RED).append("You don't have permission to do this.").toString());
    return true;
    }
    if(!(sender instanceof Player))
    {
    sender.sendMessage((new StringBuilder()).append(ChatColor.GRAY).append("[").append(ChatColor.RED).append("EthroWilderness").append(ChatColor.GRAY).append("] ").append(ChatColor.RED).append("You have to be a player to do this.").toString());
    return true;
    }
    int x = random.nextInt(radius);
    if(random.nextInt(2) == 1)
    x *= -1;
    int z = random.nextInt(radius);
    if(random.nextInt(2) == 1)
    z *= -1;
    Block block = world.getBlockAt(x, world.getHighestBlockYAt(x, z), z);
    do
    {
    if(x < radius)
    {
    x += 100;
    z += 100;
    }
    Biome biome = block.getBiome();
    if(biome == Biome.OCEAN || biome == Biome.RIVER || biome == Biome.MUSHROOM_SHORE)
    {
    block = world.getBlockAt(x, world.getHighestBlockYAt(x, z), z);
    } else
    {
    ((Player)sender).teleport(block.getLocation());
    sender.sendMessage((new StringBuilder()).append(ChatColor.GRAY).append("[").append(ChatColor.RED).append("EthroWilderness").append(ChatColor.GRAY).append("] ").append(ChatColor.RED).append("Welcome to the wild.").toString());
    return true;
    }
    } while(true);
    }
     
    int radius;
    World world;
    Random random;
    }
    The plugin spawns you in a random location and checks if the location is ocean or not and if it is it respawns you
    Is there a way to update/Upgrade the code so it will become less lag because when the plugin checks to see if you spawn in water it makes lots of lag so if anyone can help me that great also I DID NOT CODE THIS PLUGIN NO CREDITS GO TO ME!

    BUmp...

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  2. Offline

    WaffleOnABike

    Just helping out, put your code in code brackets. Like so...

    Code:
    Code here.
    Much easier for devs on here to read it.
     
  3. Offline

    Darq

    He meant [code][/code] tags. :D
     
  4. Offline

    WaffleOnABike

    Yea, edited, and failed the first time! :p
     
  5. Offline

    gs0543

    Thanks I edited it
     
Thread Status:
Not open for further replies.

Share This Page