Skip to content

Instantly share code, notes, and snippets.

@EricZeiberg
Created January 13, 2014 23:09
Show Gist options
  • Save EricZeiberg/8409898 to your computer and use it in GitHub Desktop.
Save EricZeiberg/8409898 to your computer and use it in GitHub Desktop.
Crazy Bukkit
package me.masterejay.pizzaspleef.commands;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
import me.masterejay.pizzaspleef.PizzaSpleef;
import me.masterejay.pizzaspleef.utils.Cuboid;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* This command is unused atm
* @author MasterEjay
*/
public class RegenerateCommand {
static HashMap<Location, Block> hash = new HashMap<Location, Block>();
@Command(aliases = {"regen", "regenerate"}, desc = "Regenerates the world", usage = "")
public static void regen(CommandContext cmd, CommandSender sender) throws CommandException {
for (Location l : hash.keySet()){
if (l.getBlock().getType() == Material.AIR){
for (Block b : hash.values()){
l.getBlock().setType(b.getType());
}
}
}
}
@Command(aliases = {"save", "s"}, desc = "Saves the world", usage = "")
public static void save(CommandContext cmd, CommandSender sender) throws CommandException {
if (sender instanceof ConsoleCommandSender){
throw new CommandException("Consoles can't use this command");
}
Player p = (Player) sender;
Location loc1 = new Location(p.getWorld(), -42, 66, -48);
Location loc2 = new Location(p.getWorld(), 9, 55, 0);
Cuboid c = new Cuboid(loc1, loc2);
int i = 0;
for (Block b: c){
i++;
if (b.getType() == Material.OBSIDIAN || b.getType() == Material.GOLD_BLOCK
|| b.getType() == Material.WOOD || b.getType() == Material.WOOL || b.getType() == Material.REDSTONE_BLOCK || b.getType() == Material.SOUL_SAND
|| b.getType() == Material.STAINED_CLAY || b.getType() == Material.IRON_BLOCK || b.getType() == Material.WEB ){
hash.put(b.getLocation(), b);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment