Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.yogsther.ultrahardcore;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.GameMode;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.EntityDamageByEntityEvent;
- import org.bukkit.event.player.PlayerJoinEvent;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- // TODO LIST
- // Add a /start command (Clear inventory, clear XP, clear effects, setDifficlty, setDaylycykle, toggle PVP,and other booleans)
- // FIX PREMISSIONS!!!
- //
- //
- //
- //
- //
- //
- //
- //
- public class ultrahardcore extends JavaPlugin implements Listener {
- public boolean isPVP;
- public boolean duringSetup;
- public boolean setupDone;
- public boolean duringGame;
- @EventHandler
- public void onPlayerAttack(EntityDamageByEntityEvent event) {
- if ((!isPVP) && event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
- event.setCancelled(true);
- }
- }
- public void setPVP(boolean pvp) {
- isPVP = pvp;
- }
- public boolean getPVP() {
- return isPVP;
- }
- public void onEnable() {
- PluginManager pm = this.getServer().getPluginManager();
- pm.registerEvents(this, this);
- isPVP = true;
- duringSetup = false;
- setupDone = false;
- duringGame = false;
- }
- // onPlayerJoin (To fix falldamage and hunger)
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent e) {
- Player player = e.getPlayer();
- if (duringSetup == true) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000000, 1, true));
- player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 255, true));
- player.setGameMode(GameMode.ADVENTURE);
- player.sendMessage(ChatColor.GOLD
- + "Welcome to todays Ultra Hardcore, the game has not started yet. Please just wait.");
- } else if (duringGame == false) {
- player.sendMessage(ChatColor.LIGHT_PURPLE + "Looks like nothing special is going on here..");
- } else {
- player.setGameMode(GameMode.SPECTATOR);
- player.sendMessage(ChatColor.RED
- + "OBS: A game of Ultra Hardcore is going on right now. If you wanted too join it's too late.");
- }
- }
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- // All commands
- // Start command
- if (label.equalsIgnoreCase("start") && (sender instanceof Player)) {
- if (setupDone == true) {
- if (duringGame == false) {
- if (duringSetup == true) {
- Bukkit.dispatchCommand(sender, "gamemode 0 @a");
- Bukkit.dispatchCommand(sender, "clear @a");
- Bukkit.dispatchCommand(sender, "xp -10000L @a");
- Bukkit.dispatchCommand(sender, "difficulty hard");
- Bukkit.dispatchCommand(sender, "gamerule doDaylightCycle true");
- Bukkit.dispatchCommand(sender, "time set day");
- Bukkit.dispatchCommand(sender, "worldborder set 2000");
- Bukkit.dispatchCommand(sender, "worldborder set 200 9000");
- Bukkit.dispatchCommand(sender, "spreadplayers 0 0 400 999 true @a");
- Bukkit.dispatchCommand(sender, "time set day");
- Bukkit.dispatchCommand(sender, "effect @a clear");
- Bukkit.broadcastMessage(ChatColor.GOLD + "Ultra hardcore has started, have fun!");
- Bukkit.broadcastMessage(ChatColor.RED
- + "OBS: Loading all the chunks and players will take about 10 seconds, you may experience lag. Just wait a few seconds.");
- isPVP = true;
- duringGame = true;
- duringSetup = false;
- return false;
- }
- } else {
- sender.sendMessage(ChatColor.RED
- + "A game is already in progress, please reload the server if you want to end the game!");
- return false;
- }
- } else {
- sender.sendMessage(ChatColor.RED + "Setup has not been done! Do /setup");
- return false;
- }
- }
- if (label.equalsIgnoreCase("setup") && (sender instanceof Player)) {
- if (setupDone == false) {
- Bukkit.broadcastMessage(ChatColor.BLUE + "Ultra Hardcore is setting up. This will take a few seconds.");
- long seed = Bukkit.getWorld(Bukkit.getServer().getPlayer(sender.getName()).getWorld().getName())
- .getSeed();
- sender.sendMessage(ChatColor.LIGHT_PURPLE + "The world seed is: " + seed);
- // Important setup
- Bukkit.dispatchCommand(sender, "gamerule logAdminCommands false");
- Bukkit.dispatchCommand(sender, "gamerule doDaylightCycle false");
- Bukkit.dispatchCommand(sender, "time set day");
- Bukkit.dispatchCommand(sender, "gamemode 2 @a");
- Bukkit.dispatchCommand(sender, "effect @a minecraft:jump_boost 1000000 255 true");
- Bukkit.dispatchCommand(sender, "effect @a minecraft:saturation 1000000 255 true");
- Bukkit.dispatchCommand(sender, "difficulty 0");
- Bukkit.dispatchCommand(sender, "tp @a 0 100 0");
- Bukkit.dispatchCommand(sender, "gamerule naturalRegeneration false");
- // Turn off PVP
- isPVP = false;
- // Worldborder
- Bukkit.dispatchCommand(sender, "worldborder set 20");
- Bukkit.dispatchCommand(sender, "worldborder damage amount 0");
- // Teams
- // Setting up teams
- Bukkit.dispatchCommand(sender, "scoreboard teams add blue");
- Bukkit.dispatchCommand(sender, "scoreboard teams add red");
- Bukkit.dispatchCommand(sender, "scoreboard teams add green");
- Bukkit.dispatchCommand(sender, "scoreboard teams add purple");
- Bukkit.dispatchCommand(sender, "scoreboard teams add yellow");
- Bukkit.dispatchCommand(sender, "scoreboard teams add black");
- Bukkit.dispatchCommand(sender, "scoreboard teams add green");
- Bukkit.dispatchCommand(sender, "scoreboard teams add aqua");
- Bukkit.dispatchCommand(sender, "scoreboard teams add white");
- // Setting up colors
- Bukkit.dispatchCommand(sender, "scoreboard teams option blue color blue");
- Bukkit.dispatchCommand(sender, "scoreboard teams option red color red");
- Bukkit.dispatchCommand(sender, "scoreboard teams option green color green");
- Bukkit.dispatchCommand(sender, "scoreboard teams option purple color light_purple");
- Bukkit.dispatchCommand(sender, "scoreboard teams option yellow color yellow");
- Bukkit.dispatchCommand(sender, "scoreboard teams option black color black");
- Bukkit.dispatchCommand(sender, "scoreboard teams option green color green");
- Bukkit.dispatchCommand(sender, "scoreboard teams option aqua color aqua");
- Bukkit.dispatchCommand(sender, "scoreboard teams option white color white");
- // Setting up Healthbars
- Bukkit.dispatchCommand(sender, "scoreboard objectives add Health health");
- Bukkit.dispatchCommand(sender, "scoreboard objectives setdisplay list Health");
- // Setting worldspawn
- Bukkit.dispatchCommand(sender, "setworldspawn");
- sender.sendMessage(ChatColor.GREEN
- + "Setup is done, people can now join and wait here in the lobby. To start the game type /start.");
- // Add effects to everyone
- duringSetup = true;
- setupDone = true;
- return false;
- }
- sender.sendMessage(ChatColor.RED + "Setup has already been done!");
- return false;
- } else {
- sender.sendMessage(ChatColor.RED + "You have to be a player to use this command.");
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement