Added KittyCannon for the minigame
This commit is contained in:
parent
a321a8444d
commit
77bc93d674
13 changed files with 114 additions and 9 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -11,7 +11,5 @@ commands:
|
||||||
ooc:
|
ooc:
|
||||||
description: Send message in Out-of-Character
|
description: Send message in Out-of-Character
|
||||||
usage: "&cUsage: /ooc <message>&r"
|
usage: "&cUsage: /ooc <message>&r"
|
||||||
skype:
|
|
||||||
description: Get the Skype conversation link
|
|
||||||
author: NorbiPeti
|
author: NorbiPeti
|
||||||
depend: [Essentials, Towny, TownyChat, Minigames]
|
depend: [Essentials, Towny, TownyChat, Minigames]
|
||||||
|
|
|
@ -2,17 +2,31 @@ package tk.sznp.thebuttonautoflair;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.BlockCommandSender;
|
import org.bukkit.command.BlockCommandSender;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Ocelot;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Mob;
|
||||||
|
import com.earth2me.essentials.Mob.MobException;
|
||||||
|
|
||||||
|
import au.com.mineauz.minigames.MinigamePlayer;
|
||||||
|
import au.com.mineauz.minigames.Minigames;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class Commands implements CommandExecutor {
|
public class Commands implements CommandExecutor {
|
||||||
|
|
||||||
|
@ -137,6 +151,9 @@ public class Commands implements CommandExecutor {
|
||||||
case "quiz":
|
case "quiz":
|
||||||
DoQuiz(player, args, null);
|
DoQuiz(player, args, null);
|
||||||
break;
|
break;
|
||||||
|
case "kittycannon":
|
||||||
|
DoKittyCannon(player, args);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -155,9 +172,6 @@ public class Commands implements CommandExecutor {
|
||||||
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = true;
|
MaybeOfflinePlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "skype":
|
|
||||||
// "skype:?chat&blob=Y_5Ob1BEcw0ZlstdUHyf0ENS5n1Xz2Huhx-5b-pB2JyMSRO5QMEALkJuTSuUaAb3-XfWXwCndwhGex_UpXDbyQ";
|
|
||||||
return true;
|
|
||||||
default:
|
default:
|
||||||
player.sendMessage("Unknown command: " + cmd.getName());
|
player.sendMessage("Unknown command: " + cmd.getName());
|
||||||
break;
|
break;
|
||||||
|
@ -580,4 +594,60 @@ public class Commands implements CommandExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
|
public static String KittyCannonMinigame = "KittyCannon";
|
||||||
|
|
||||||
|
private static void DoKittyCannon(Player player, String[] args) {
|
||||||
|
if (player == null) {
|
||||||
|
SendMessage(player,
|
||||||
|
"§cThis command can only be used by a player.§r");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MinigamePlayer mp = Minigames.plugin.pdata.getMinigamePlayer(player);
|
||||||
|
if (!player.isOp()
|
||||||
|
&& (!mp.isInMinigame() || mp.getMinigame().getName(false)
|
||||||
|
.equalsIgnoreCase(KittyCannonMinigame))) {
|
||||||
|
SendMessage(player,
|
||||||
|
"§You can only use KittyCannon in it's minigame!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final Mob cat = Mob.OCELOT;
|
||||||
|
final Ocelot ocelot = (Ocelot) cat.spawn(player.getWorld(),
|
||||||
|
player.getServer(), player.getEyeLocation());
|
||||||
|
if (ocelot == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final ArrayList<String> lore = new ArrayList<>();
|
||||||
|
lore.add(player.getName());
|
||||||
|
final int i = random.nextInt(Ocelot.Type.values().length);
|
||||||
|
ocelot.setCatType(Ocelot.Type.values()[i]);
|
||||||
|
ocelot.setTamed(true);
|
||||||
|
ocelot.setBaby();
|
||||||
|
ocelot.addPotionEffect(new PotionEffect(
|
||||||
|
PotionEffectType.DAMAGE_RESISTANCE, 5, 5));
|
||||||
|
ocelot.setVelocity(player.getEyeLocation().getDirection()
|
||||||
|
.multiply(2));
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(PluginMain.Instance,
|
||||||
|
new Runnable() {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final Location loc = ocelot.getLocation();
|
||||||
|
ocelot.remove();
|
||||||
|
loc.getWorld().createExplosion(loc, 0F);
|
||||||
|
final ItemStack head = new ItemStack(
|
||||||
|
Material.SKULL_ITEM, 1, (short) 3, (byte) 3);
|
||||||
|
SkullMeta im = (SkullMeta) head.getItemMeta();
|
||||||
|
im.setDisplayName("§rOcelot Head");
|
||||||
|
im.setOwner("MHF_Ocelot");
|
||||||
|
im.setLore(lore);
|
||||||
|
head.setItemMeta(im);
|
||||||
|
loc.getWorld().dropItem(loc, head);
|
||||||
|
}
|
||||||
|
}, 20);
|
||||||
|
} catch (MobException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package tk.sznp.thebuttonautoflair;
|
package tk.sznp.thebuttonautoflair;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
@ -11,8 +12,12 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
|
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
|
import au.com.mineauz.minigames.MinigamePlayer;
|
||||||
import au.com.mineauz.minigames.Minigames;
|
import au.com.mineauz.minigames.Minigames;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -91,9 +96,6 @@ public class PlayerListener implements Listener { // 2015.07.16.
|
||||||
}
|
}
|
||||||
|
|
||||||
mp.RPMode = true; // 2015.08.25.
|
mp.RPMode = true; // 2015.08.25.
|
||||||
|
|
||||||
if (p.getName().equals("FigyTuna") && Commands.PluginUpdated)
|
|
||||||
p.sendMessage("§bThe The Button MC plugin got updated. Please restart the server. :P§r");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -325,4 +327,40 @@ public class PlayerListener implements Listener { // 2015.07.16.
|
||||||
Ftimer.schedule(tt, 15 * 1000);
|
Ftimer.schedule(tt, 15 * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerItemPickup(PlayerPickupItemEvent e) {
|
||||||
|
// System.out.println("A");
|
||||||
|
MinigamePlayer mp = Minigames.plugin.pdata.getMinigamePlayer(e
|
||||||
|
.getPlayer());
|
||||||
|
// System.out.println("B");
|
||||||
|
if (!e.getPlayer().isOp()
|
||||||
|
&& (!mp.isInMinigame() || mp.getMinigame().getName(false)
|
||||||
|
.equalsIgnoreCase(Commands.KittyCannonMinigame)))
|
||||||
|
return;
|
||||||
|
// System.out.println("C");
|
||||||
|
ItemStack item = e.getItem().getItemStack();
|
||||||
|
if (!item.getType().equals(Material.SKULL_ITEM)
|
||||||
|
&& !item.getType().equals(Material.SKULL))
|
||||||
|
return;
|
||||||
|
// System.out.println("D");
|
||||||
|
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||||
|
if (!meta.getDisplayName().equals("§rOcelot Head")
|
||||||
|
|| !meta.getOwner().equals("MHF_Ocelot"))
|
||||||
|
return;
|
||||||
|
// System.out.println("E");
|
||||||
|
if (meta.getLore() == null || meta.getLore().size() == 0)
|
||||||
|
return;
|
||||||
|
// System.out.println("F");
|
||||||
|
ItemStack hat = e.getPlayer().getInventory().getHelmet();
|
||||||
|
if (!(hat != null
|
||||||
|
&& (hat.getType().equals(Material.SKULL) || hat.getType()
|
||||||
|
.equals(Material.SKULL_ITEM)) && ((SkullMeta) hat
|
||||||
|
.getItemMeta()).getDisplayName().equals("§rWolf Head")))
|
||||||
|
e.getPlayer().damage(1f, Bukkit.getPlayer(meta.getLore().get(0)));
|
||||||
|
e.getItem().remove();
|
||||||
|
// System.out.println("G");
|
||||||
|
e.setCancelled(true);
|
||||||
|
// System.out.println("H");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
this.getCommand("ooc").setExecutor(comm);
|
this.getCommand("ooc").setExecutor(comm);
|
||||||
this.getCommand("ooc").setUsage(
|
this.getCommand("ooc").setUsage(
|
||||||
this.getCommand("ooc").getUsage().replace('&', '§'));
|
this.getCommand("ooc").getUsage().replace('&', '§'));
|
||||||
this.getCommand("skype").setExecutor(comm);
|
|
||||||
Instance = this; // 2015.08.08.
|
Instance = this; // 2015.08.08.
|
||||||
Console = this.getServer().getConsoleSender(); // 2015.08.12.
|
Console = this.getServer().getConsoleSender(); // 2015.08.12.
|
||||||
LoadFiles(false); // 2015.08.09.
|
LoadFiles(false); // 2015.08.09.
|
||||||
|
|
Loading…
Reference in a new issue