Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.fatal;
- import java.io.File;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Set;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- import net.md_5.bungee.api.ChatColor;
- public class JumpPad extends JavaPlugin {
- public File file = new File(getDataFolder() + "/padlocations.yml");
- public static List<Location> blockLocs = new ArrayList<Location>();
- public static Location Location;
- String createPerm = "jumppad.create";
- String removePerm = "jumppad.remove";
- String noPerms = (ChatColor.RED + "You do not have access to this command.");
- public JumpPad() {
- }
- @Override
- public void onEnable() {
- registerConfig();
- PluginManager pm = getServer().getPluginManager();
- ListenerClass list = new ListenerClass(this);
- JumpPadManager jpm = new JumpPadManager();
- pm.registerEvents(list, this);
- World world = (World)getConfig().get("world");
- Location locc = new Location(world, getConfig().getDouble(".x"), getConfig().getDouble(".y"), getConfig().getDouble(".y"));
- blockLocs.add(locc);
- Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
- public void run() {
- //Bukkit.broadcastMessage("" + locc);
- blockLocs.add(locc);
- }
- }, 20, 1);
- }
- @Override
- public void onDisable() {
- }
- private void registerConfig(){
- getConfig().options().copyDefaults(true);
- saveConfig();
- }
- public boolean onCommand(CommandSender pl, Command cmd, String label, String[] args) {
- Player p = (Player) pl;
- @SuppressWarnings("deprecation")
- Block block = p.getTargetBlock((Set<Material>) null, 5);
- Location bLoc = block.getLocation();
- if (cmd.getName().equalsIgnoreCase("jumppad")) {
- if (p instanceof Player) {
- if (args.length == 0) {
- pl.sendMessage(ChatColor.RED + "Usage : /jumppad <Create/Remove> <Multiplier(Number)> <BlockName>");
- pl.sendMessage(ChatColor.RED+ "[WARNING] :" + ChatColor.GREEN + " Keep this number under 100, otherwise the sever might crash!");
- } else if (args.length >= 1) {
- if (args[0].equalsIgnoreCase("create")) {
- if (args.length == 3) {
- if (pl.hasPermission(createPerm)) {
- if (!block.getType().isSolid()) {
- p.sendMessage(ChatColor.RED + "You must be looking at a block, 5 blocks away or closer.");
- return false;
- } else {
- if (isFloat(args[1])) {
- //Location = bLoc;
- JumpPadManager.CreatePad(bLoc, p, Float.parseFloat(args[1]));
- String name = args[2].toString();
- getConfig().set("block." + name + ".location", bLoc);
- saveConfig();
- //blockLocs.add((bLoc));
- } else if (args[1] == null || !isFloat(args[1])){
- p.sendMessage(ChatColor.RED + "You must specify a multiplier to the jumppad");
- p.sendMessage(ChatColor.RED+ "[WARNING] :" + ChatColor.GREEN + " Keep this number under 100, otherwise the sever might crash!");
- }
- }
- }
- } else {
- pl.sendMessage(ChatColor.RED + "Usage : /jumppad <Create/Remove> <Multiplier(Number)> <BlockName>");
- pl.sendMessage(ChatColor.RED+ "[WARNING] :" + ChatColor.GREEN + " Keep this number under 100, otherwise the sever might crash!");
- }
- } else if (args[0].equalsIgnoreCase("remove")) {
- if (pl.hasPermission(removePerm)) {
- if (!block.getType().isSolid()) {
- pl.sendMessage(ChatColor.RED + "You must be looking at a block, 5 blocks away or closer.");
- return false;
- } else {
- // String location = bLoc.getWorld().getName() + "," + bLoc.getX() + "," + bLoc.getY() + "," + bLoc.getZ() + "," + bLoc.getYaw() + "," + bLoc.getPitch();
- // List<String> locations = this.getConfig().getStringList("locations");
- // locations.remove(location);
- // this.getConfig().set("locations", null);
- // this.saveConfig();
- JumpPadManager.RemovePad(bLoc, p);
- }
- }
- } else if (args[0].equalsIgnoreCase("list")) {
- p.sendMessage(blockLocs + " <");
- }
- }
- } else {
- pl.sendMessage(ChatColor.RED + "You must be in game to access this command!");
- return false;
- }
- return false;
- }
- return false;
- }
- private boolean isFloat(String text) {
- try {
- Float.parseFloat(text);
- return true;
- } catch (Exception e) {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement