Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.frederikbontved.reallife;
- import java.io.IOException;
- import java.util.HashMap;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Effect;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.Minecart;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerQuitEvent;
- import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
- import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
- import org.bukkit.event.vehicle.VehicleUpdateEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.util.Vector;
- public class Reallifecars extends JavaPlugin implements Listener {
- Logger logger = Logger.getLogger("Minecraft");
- public static Reallifecars plugin;
- public HashMap<String, Boolean> railways = new HashMap<String, Boolean>();
- public HashMap<String, Location> railways_spawn = new HashMap<String, Location>();
- public HashMap<String, Location> railways_spawn_2 = new HashMap<String, Location>();
- public HashMap<String, Location> railways_spawn_3 = new HashMap<String, Location>();
- public HashMap<String, Location> railways_spawn_4 = new HashMap<String, Location>();
- public HashMap<String, Location> railways_spawn_5 = new HashMap<String, Location>();
- public HashMap<String, Location> railways_spawn_6 = new HashMap<String, Location>();
- public HashMap<String, Integer> railways_spawn_count = new HashMap<String, Integer>();
- public HashMap<String, Location> railways_stop = new HashMap<String, Location>();
- public HashMap<Location, String> railways_locations = new HashMap<Location, String>();
- public HashMap<String, String> railways_reward = new HashMap<String, String>();
- public HashMap<String, String> railways_players = new HashMap<String, String>();
- public HashMap<String, String> railways_players_2 = new HashMap<String, String>();
- public HashMap<String, Location> railways_finish = new HashMap<String, Location>();
- public HashMap<String, String> shop = new HashMap<String, String>();
- public HashMap<String, String> boost = new HashMap<String, String>();
- @Override
- public void onEnable() {
- readData();
- this.logger.info("Cars has been enabled!");
- this.getServer().getPluginManager().registerEvents(this, this);
- this.getConfig().options().copyDefaults(true);
- saveConfig();
- }
- @Override
- public void onDisable() {
- this.logger.info("Cars has been disabled!");
- saveData();
- }
- private void readData() {
- try {
- HashMapSaver hs = new HashMapSaver(this);
- railways = hs.get_railways();
- railways_spawn = hs.get_railways_spawn();
- railways_spawn_2 = hs.get_railways_spawn_2();
- railways_spawn_3 = hs.get_railways_spawn_3();
- railways_spawn_4 = hs.get_railways_spawn_4();
- railways_spawn_5 = hs.get_railways_spawn_5();
- railways_spawn_6 = hs.get_railways_spawn_6();
- railways_spawn_count = hs.get_railways_spawn_count();
- railways_stop = hs.get_railways_stop();
- railways_locations = hs.get_railways_locations();
- railways_reward = hs.get_railways_reward();
- railways_players = hs.get_railways_players();
- railways_players_2 = hs.get_railways_players_2();
- railways_finish = hs.get_railways_finish();
- shop = hs.get_shop();
- boost = hs.get_boost();
- } catch (IOException e) {
- railways = new HashMap<>();
- railways_spawn = new HashMap<>();
- railways_spawn_2 = new HashMap<>();
- railways_spawn_3 = new HashMap<>();
- railways_spawn_4 = new HashMap<>();
- railways_spawn_5 = new HashMap<>();
- railways_spawn_6 = new HashMap<>();
- railways_spawn_count = new HashMap<>();
- railways_stop = new HashMap<>();
- railways_locations = new HashMap<>();
- railways_reward = new HashMap<>();
- railways_players = new HashMap<>();
- railways_players_2 = new HashMap<>();
- railways_finish = new HashMap<>();
- shop = new HashMap<>();
- boost = new HashMap<>();
- this.logger.info("Could not find save data. Starts with empty values");
- } catch (ClassNotFoundException e) {
- this.logger.severe(e.toString());
- }
- }
- private void saveData() {
- try {
- HashMapSaver hs = new HashMapSaver(this);
- hs.save_railways(railways);
- hs.save_railways_spawn(railways_spawn);
- hs.save_railways_spawn_2(railways_spawn_2);
- hs.save_railways_spawn_3(railways_spawn_3);
- hs.save_railways_spawn_4(railways_spawn_4);
- hs.save_railways_spawn_5(railways_spawn_5);
- hs.save_railways_spawn_6(railways_spawn_6);
- hs.save_railways_spawn_count(railways_spawn_count);
- hs.save_railways_stop(railways_stop);
- hs.save_railways_locations(railways_locations);
- hs.save_railways_reward(railways_reward);
- hs.save_railways_players(railways_players);
- hs.save_railways_players_2(railways_players_2);
- hs.save_railways_finish(railways_finish);
- hs.save_shop(shop);
- hs.save_boost(boost);
- } catch (IOException e) {
- this.logger.severe(e.toString());
- }
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- Player player = (Player) sender;
- if (cmd.getName().equalsIgnoreCase("c")) {
- if (args[0].equalsIgnoreCase("help")) {
- player.sendMessage(this.getConfig().getString("translation_1"));
- }
- if (args[0].equalsIgnoreCase("create")) {
- if (player.hasPermission("rlc.create")) {
- if (args.length == 2) {
- if (!(railways.containsKey(args[1]))) {
- railways.put(args[1], false);
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_2").replace("&n", args[1]));
- player.sendMessage(ChatColor.GOLD + this.getConfig().getString("translation_3"));
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_4").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_5"));
- }
- }
- }
- if (args[0].equalsIgnoreCase("spawn")) {
- if (player.hasPermission("rlc.spawn")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- if (!(railways_spawn.containsKey(args[1]))) {
- railways_spawn.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_6").replace("&n", args[1]));
- player.sendMessage(ChatColor.GOLD + this.getConfig().getString("translation_7"));
- }
- else {
- railways_spawn.remove(args[1]);
- railways_spawn.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_8").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_9").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_10"));
- }
- }
- }
- if (args[0].equalsIgnoreCase("spawn2")) {
- if (player.hasPermission("rlc.spawn")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- if (!(railways_spawn_2.containsKey(args[1]))) {
- railways_spawn_2.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_6").replace("&n", args[1]));
- player.sendMessage(ChatColor.GOLD + this.getConfig().getString("translation_7"));
- }
- else {
- railways_spawn_2.remove(args[1]);
- railways_spawn_2.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_8").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_9").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_10"));
- }
- }
- }
- if (args[0].equalsIgnoreCase("spawn3")) {
- if (player.hasPermission("rlc.spawn")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- if (!(railways_spawn_3.containsKey(args[1]))) {
- railways_spawn_3.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_6").replace("&n", args[1]));
- player.sendMessage(ChatColor.GOLD + this.getConfig().getString("translation_7"));
- }
- else {
- railways_spawn_3.remove(args[1]);
- railways_spawn_3.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_8").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_9").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_10"));
- }
- }
- }
- if (args[0].equalsIgnoreCase("spawn4")) {
- if (player.hasPermission("rlc.spawn")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- if (!(railways_spawn_4.containsKey(args[1]))) {
- railways_spawn_4.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_6").replace("&n", args[1]));
- player.sendMessage(ChatColor.GOLD + this.getConfig().getString("translation_7"));
- }
- else {
- railways_spawn_4.remove(args[1]);
- railways_spawn_4.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_8").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_9").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_10"));
- }
- }
- }
- if (args[0].equalsIgnoreCase("spawn5")) {
- if (player.hasPermission("rlc.spawn")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- if (!(railways_spawn_5.containsKey(args[1]))) {
- railways_spawn_5.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_6").replace("&n", args[1]));
- player.sendMessage(ChatColor.GOLD + this.getConfig().getString("translation_7"));
- }
- else {
- railways_spawn_5.remove(args[1]);
- railways_spawn_5.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_8").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_9").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_10"));
- }
- }
- }
- if (args[0].equalsIgnoreCase("spawn6")) {
- if (player.hasPermission("rlc.spawn")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- if (!(railways_spawn_6.containsKey(args[1]))) {
- railways_spawn_6.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_6").replace("&n", args[1]));
- player.sendMessage(ChatColor.GOLD + this.getConfig().getString("translation_7"));
- }
- else {
- railways_spawn_6.remove(args[1]);
- railways_spawn_6.put(args[1], player.getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_8").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_9").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_10"));
- }
- }
- }
- if (args[0].equalsIgnoreCase("stop")) {
- if (player.hasPermission("rlc.stop")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- if (!(railways_stop.containsKey(args[1]))) {
- railways_stop.put(args[1], player.getLocation().getBlock().getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_11").replace("&n", args[1]));
- player.sendMessage(ChatColor.GOLD + this.getConfig().getString("translation_12"));
- }
- else {
- railways_stop.remove(args[1]);
- railways_stop.put(args[1], player.getLocation().getBlock().getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_13").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_14").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_15"));
- }
- }
- }
- if (args[0].equalsIgnoreCase("location")) {
- if (player.hasPermission("rlc.location")) {
- if (args.length == 2) {
- if (railways.containsValue(args[1])) {
- railways_locations.put(player.getLocation().getBlock().getLocation(), args[1]);
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_48").replace("&n", args[1]));
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_14").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_15"));
- }
- }
- }
- if (args[0].equalsIgnoreCase("finish")) {
- if (player.hasPermission("rlc.finish")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- if (!(railways_finish.containsKey(args[1]))) {
- railways_finish.put(args[1], player.getLocation().getBlock().getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_16").replace("&n", args[1]));
- player.sendMessage(ChatColor.GOLD + this.getConfig().getString("translation_17"));
- }
- else {
- railways_finish.remove(args[1]);
- railways_finish.put(args[1], player.getLocation().getBlock().getLocation());
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_18").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_19").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_20"));
- }
- }
- }
- else if (args[0].equalsIgnoreCase("reward")) {
- if (player.hasPermission("rlc.reward")) {
- if (args.length == 3) {
- if (railways.containsKey(args[1])) {
- if (!(railways_reward.containsKey(args[1]))) {
- railways_reward.put(args[1], args[2]);
- player.sendMessage(this.getConfig().getString("translation_21").replace("&n", args[1]));
- player.sendMessage(ChatColor.GOLD + this.getConfig().getString("translation_22"));
- }
- else {
- railways_reward.remove(args[1]);
- railways_reward.put(args[1], args[2]);
- player.sendMessage(this.getConfig().getString("translation_23").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_24").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_25"));
- }
- }
- }
- else if (args[0].equalsIgnoreCase("remove")) {
- if (player.hasPermission("rlc.remove")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- railways.remove(args[1]);
- railways_spawn.remove(args[1]);
- railways_spawn_2.remove(args[1]);
- railways_spawn_3.remove(args[1]);
- railways_spawn_4.remove(args[1]);
- railways_spawn_5.remove(args[1]);
- railways_spawn_6.remove(args[1]);
- railways_spawn_count.remove(args[1]);
- railways_stop.remove(args[1]);
- railways_reward.remove(args[1]);
- railways_players_2.remove(args[1]);
- railways_finish.remove(args[1]);
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_45").replace("&n", args[1]));
- }
- else {
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_24").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_25"));
- }
- }
- }
- else if (args[0].equalsIgnoreCase("close")) {
- if (player.hasPermission("rlc.close")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- railways.remove(args[1]);
- railways.put(args[1], false);
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_46").replace("&n", args[1]));
- }
- else {
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_24").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_25"));
- }
- }
- }
- else if (args[0].equalsIgnoreCase("join")) {
- if (player.hasPermission("rlc.join")) {
- if (args.length == 2) {
- if (railways.containsKey(args[1])) {
- if (!(railways.get(args[1]) == true)) {
- Location joinLoc = railways_spawn.get(args[1]);
- if (railways_spawn.containsKey(args[1])) {
- railways_spawn_count.put(args[1], 1);
- }
- else {
- player.sendMessage(this.getConfig().getString("translation_44"));
- }
- if (railways_spawn_2.containsKey(args[1])) {
- Location changeLoc2 = railways_spawn_2.get(args[1]);
- joinLoc.setX(changeLoc2.getX());
- joinLoc.setY(changeLoc2.getY());
- joinLoc.setZ(changeLoc2.getZ());
- railways_spawn_count.put(args[1], 2);
- }
- else {
- player.sendMessage(this.getConfig().getString("translation_44"));
- }
- if (railways_spawn_3.containsKey(args[1])) {
- Location changeLoc3 = railways_spawn_3.get(args[1]);
- joinLoc.setX(changeLoc3.getX());
- joinLoc.setY(changeLoc3.getY());
- joinLoc.setZ(changeLoc3.getZ());
- railways_spawn_count.put(args[1], 3);
- }
- if (railways_spawn_4.containsKey(args[1])) {
- Location changeLoc4 = railways_spawn_4.get(args[1]);
- joinLoc.setX(changeLoc4.getX());
- joinLoc.setY(changeLoc4.getY());
- joinLoc.setZ(changeLoc4.getZ());
- railways_spawn_count.put(args[1], 4);
- }
- else {
- player.sendMessage(this.getConfig().getString("translation_44"));
- }
- if (railways_spawn_5.containsKey(args[1])) {
- Location changeLoc5 = railways_spawn_5.get(args[1]);
- joinLoc.setX(changeLoc5.getX());
- joinLoc.setY(changeLoc5.getY());
- joinLoc.setZ(changeLoc5.getZ());
- railways_spawn_count.put(args[1], 5);
- }
- else {
- player.sendMessage(this.getConfig().getString("translation_44"));
- }
- if (railways_spawn_6.containsKey(args[1])) {
- Location changeLoc6 = railways_spawn_6.get(args[1]);
- joinLoc.setX(changeLoc6.getX());
- joinLoc.setY(changeLoc6.getY());
- joinLoc.setZ(changeLoc6.getZ());
- railways_spawn_count.put(args[1], 6);
- }
- else {
- player.sendMessage(this.getConfig().getString("translation_44"));
- }
- player.getWorld().spawn(joinLoc, Minecart.class);
- player.teleport(joinLoc);
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_26").replace("&n", args[1]));
- player.sendMessage("I ALT: " + railways_spawn_count.get(args[1]) + " -NICE IKK'?!");
- railways_players.put(player.getName(), args[1]);
- int countdown = 15;
- while (countdown != 0) {
- player.sendMessage(ChatColor.DARK_AQUA + this.getConfig().getString("translation_27") + ChatColor.RED + countdown);
- countdown--;
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- if (countdown == 0) {
- player.sendMessage(ChatColor.YELLOW + this.getConfig().getString("translation_28"));
- railways.remove(args[1]);
- railways.put(args[1], true);
- }
- }
- }
- else {
- player.sendMessage(this.getConfig().getString("translation_29"));
- }
- }
- else {
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_30").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_31"));
- }
- }
- }
- else if (args[0].equalsIgnoreCase("list")) {
- if (player.hasPermission("rlc.list")) {
- if (args.length == 1) {
- if (!(railways.isEmpty())) {
- player.sendMessage("" + railways.size());
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_47"));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_33"));
- }
- }
- }
- else if (args[0].equalsIgnoreCase("shop")) {
- if (player.hasPermission("rlc.shop")) {
- if (args.length == 1) {
- player.sendMessage(ChatColor.AQUA + this.getConfig().getString("translation_32"));
- player.sendMessage(ChatColor.GRAY + "- Skriv '/c buy nitro' for at få din bil hurtigere!");
- player.sendMessage(ChatColor.GRAY + "- //ANDRE TING.. :O");
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_33"));
- }
- }
- }
- else if (args[0].equalsIgnoreCase("buy")) {
- if (player.hasPermission("rlc.buy")) {
- if (args.length == 2) {
- if (shop.containsKey(args[1])) {
- if (!(boost.containsKey(player.getName()))) {
- //DER SKAL ABEJDES PÅ AT TRÆKKE PENGE FRA KONTO
- boost.put(player.getName(), args[1]);
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_34").replace("&n", args[1]));
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_35"));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_36").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_37"));
- }
- }
- }
- else if (args[0].equalsIgnoreCase("add")) {
- if (player.hasPermission("rlc.add")) {
- if (args.length == 3) {
- if (!(shop.containsKey(args[1]))) {
- shop.put(args[1], args[2]);
- player.sendMessage(ChatColor.GREEN + this.getConfig().getString("translation_38").replace("&n", args[1]));
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_39").replace("&n", args[1]));
- }
- }
- else {
- player.sendMessage(ChatColor.RED + this.getConfig().getString("translation_40"));
- }
- }
- }
- }
- return false;
- }
- @EventHandler
- public void onPlayerInteract(PlayerInteractEvent event) {
- Player player = event.getPlayer();
- if (player.getItemInHand().getTypeId() == 328 && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
- if (player.hasPermission("rlc.create")) {
- Location loc = event.getClickedBlock().getLocation();
- loc.add(0, 1, 0);
- player.getWorld().spawn(loc, Minecart.class);
- }
- }
- }
- @EventHandler
- public void onVehicleUpdate(VehicleUpdateEvent event) {
- Entity passenger = event.getVehicle().getPassenger();
- if(!(passenger instanceof Player)) {
- return;
- }
- //FÅR BILEN TIL AT KØRER
- Player player = (Player) event.getVehicle().getPassenger();
- int Speed = 5;
- if (boost.containsKey(player.getName())) {
- if (boost.get(player.getName()) == "nitro") {
- //COMMING SOON!
- }
- }
- if(event.getVehicle() instanceof Minecart) {
- if(player.isInsideVehicle()) {
- Location newLoc = event.getVehicle().getLocation();
- Vector velocity = event.getVehicle().getPassenger().getVelocity();
- velocity.multiply(Speed);
- newLoc.add(new Vector(velocity.getX() * (double)Speed, 0.0D, velocity.getZ() * (double)Speed));
- event.getVehicle().teleport(newLoc);
- player.getWorld().playEffect(player.getLocation(), Effect.SMOKE, 0);
- }
- //DESTOERER BILEN HVIS DEN KØRER I VAND, ELLER LAVA!
- if(event.getVehicle().getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().isLiquid()) {
- event.getVehicle().eject();
- event.getVehicle().remove();
- //LUKKER BANEN
- railways_players.remove(player.getName());
- player.playEffect(player.getLocation(), Effect.EXTINGUISH, 0);
- player.sendMessage(this.getConfig().getString("translation_41"));
- }
- Location loc = event.getVehicle().getLocation().getBlock().getLocation();
- //TJEKKER OM PLAYEREN ER PÅ EN WINNERLOC!
- if (railways_stop.containsValue(loc)) {
- if (railways_players.containsKey(player.getName())) {
- String railways_name = railways_players.get(player.getName());
- if (railways.get(railways_name) == true) {
- railways.remove(railways_name);
- railways.put(railways_name, false);
- Bukkit.broadcastMessage(ChatColor.AQUA + this.getConfig().getString("translation_42").replace("&rn", railways_name));
- player.sendMessage(ChatColor.DARK_GREEN + this.getConfig().getString("translation_43"));
- event.getVehicle().eject();
- event.getVehicle().remove();
- player.teleport(railways_finish.get(railways_name));
- }
- }
- }
- //'BUG' FIXES..
- Location bugLoc = event.getVehicle().getLocation();
- if (!(bugLoc.getBlock().getType() == Material.AIR)) {
- bugLoc.add(0, 1, 0);
- if (bugLoc.getBlock().getType() == Material.AIR) {
- Location fixloc = event.getVehicle().getLocation();
- fixloc.add(0, 1, 0);
- event.getVehicle().teleport(fixloc);
- }
- }
- }
- }
- @EventHandler
- public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) {
- if (event.getVehicle() instanceof Minecart) {
- event.setCancelled(true);
- }
- }
- @EventHandler
- public void onVehicleBlockCollision(VehicleBlockCollisionEvent event) {
- if (event.getVehicle() instanceof Minecart) {
- Bukkit.broadcastMessage("Test..");
- event.getVehicle().setVelocity(new Vector(-1,-1,-1));
- }
- }
- @EventHandler
- public void onPlayerQuit(PlayerQuitEvent event) {
- railways_players.remove(event.getPlayer().getName());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement