├── Annihilation Default Kits └── src │ └── com │ └── gmail │ └── nuclearcat1337 │ ├── base │ ├── ConfigurableKit.java │ ├── DelayUpdate.java │ ├── Delays.java │ ├── Direction.java │ ├── KitConfig.java │ ├── SpecialItemKit.java │ ├── StandardItemUpdater.java │ └── Vector3D.java │ └── kits │ ├── Acrobat.java │ ├── Archer.java │ ├── Assassin.java │ ├── Berserker.java │ ├── Defender.java │ ├── Enchanter.java │ ├── Lumberjack.java │ ├── Miner.java │ ├── Pyro.java │ ├── Scorpio.java │ ├── Scout.java │ ├── Succubus.java │ ├── Swapper.java │ ├── Thor.java │ ├── Transporter.java │ ├── Vampire.java │ └── Warrior.java ├── Annihilation Vault Extension ├── plugin.yml └── src │ └── com │ └── gmail │ └── nuclearcat1337 │ └── vaultPlugin │ ├── Listeners.java │ └── VaultHook.java ├── Annihilation World Restorer ├── plugin.yml └── src │ └── com │ └── gmail │ └── nuclearcat1337 │ └── annipro │ └── worldrestorer │ └── WorldRestorer.java ├── Annihilation XP Extension ├── plugin.yml └── src │ └── com │ └── gmail │ └── nuclearcat1337 │ └── xpSystem │ ├── database │ ├── AsyncLogQuery.java │ ├── AsyncQuery.java │ ├── Database.java │ └── MySQLDatabase.java │ ├── main │ ├── KitArgument.java │ ├── LoadKits.java │ ├── MyXPCommand.java │ ├── QueryXP.java │ ├── XPArgument.java │ ├── XPListeners.java │ ├── XPMain.java │ └── XPSystem.java │ ├── shop │ ├── KitShopMenuItem.java │ ├── KitWrapper.java │ └── Shop.java │ └── utils │ └── Acceptor.java ├── Annihilation ├── assets │ ├── BlueTeam.png │ ├── GreenTeam.png │ ├── Phase1.png │ ├── Phase2.png │ ├── Phase3.png │ ├── Phase4.png │ ├── Phase5.png │ ├── RedTeam.png │ └── YellowTeam.png ├── plugin.yml └── src │ ├── Changelog.txt │ ├── README.txt │ ├── com │ ├── bobacadodl │ │ └── imgmessage │ │ │ ├── AnimatedMessage.java │ │ │ ├── ImageChar.java │ │ │ └── ImageMessage.java │ └── gmail │ │ └── nuclearcat1337 │ │ └── anniPro │ │ ├── anniEvents │ │ ├── AnniEvent.java │ │ ├── GameEndEvent.java │ │ ├── GameStartEvent.java │ │ ├── NexusHitEvent.java │ │ ├── PlayerKilledEvent.java │ │ ├── PluginDisableEvent.java │ │ └── ResourceBreakEvent.java │ │ ├── anniGame │ │ ├── AnniPlayer.java │ │ ├── AnniTeam.java │ │ ├── ArmorStandListener.java │ │ ├── Game.java │ │ ├── GameListeners.java │ │ ├── GameVars.java │ │ ├── Nexus.java │ │ ├── StandardPhaseHandler.java │ │ └── autoRespawn │ │ │ ├── RespawnHandler.java │ │ │ ├── RespawnPacket.java │ │ │ └── versions │ │ │ ├── v1_7_R3Packet.java │ │ │ ├── v1_7_R4Packet.java │ │ │ ├── v1_8_R1Packet.java │ │ │ └── v1_8_R2Packet.java │ │ ├── anniMap │ │ ├── AnniMap.java │ │ ├── AnniSign.java │ │ ├── Area.java │ │ ├── Areas.java │ │ ├── FacingObject.java │ │ ├── GameMap.java │ │ ├── LobbyMap.java │ │ ├── RegeneratingBlock.java │ │ ├── RegeneratingBlocks.java │ │ ├── SignType.java │ │ └── Signs.java │ │ ├── announcementBar │ │ ├── AnnounceBar.java │ │ ├── Announcement.java │ │ ├── Bar.java │ │ ├── FakeBar.java │ │ ├── MessageBar.java │ │ ├── TempData.java │ │ └── versions │ │ │ ├── v1_7_R3 │ │ │ ├── Bar.java │ │ │ ├── Dragon.java │ │ │ ├── IDragon.java │ │ │ └── Util.java │ │ │ ├── v1_7_R4 │ │ │ ├── Bar.java │ │ │ ├── Dragon.java │ │ │ ├── IDragon.java │ │ │ ├── PacketPlayOutActionBar.java │ │ │ ├── ProxyHashBiMap.java │ │ │ └── Util.java │ │ │ ├── v1_8_R1 │ │ │ └── Bar.java │ │ │ └── v1_8_R2 │ │ │ └── Bar.java │ │ ├── enderFurnace │ │ ├── api │ │ │ ├── EnderFurnace.java │ │ │ ├── FurnaceCreator.java │ │ │ ├── FurnaceData.java │ │ │ ├── IFurnace.java │ │ │ └── ReflectionUtil.java │ │ └── versions │ │ │ ├── v1_7_R3 │ │ │ ├── FurnaceCreator.java │ │ │ ├── FurnaceData.java │ │ │ └── Furnace_V1_7_R3.java │ │ │ ├── v1_7_R4 │ │ │ ├── FurnaceCreator.java │ │ │ ├── FurnaceData.java │ │ │ └── Furnace_V1_7_R4.java │ │ │ ├── v1_8_R1 │ │ │ ├── FurnaceCreator.java │ │ │ ├── FurnaceData.java │ │ │ └── Furnace_V1_8_R1.java │ │ │ └── v1_8_R2 │ │ │ ├── FurnaceCreator.java │ │ │ ├── FurnaceData.java │ │ │ └── Furnace_v1_8_R2.java │ │ ├── itemMenus │ │ ├── ActionMenuItem.java │ │ ├── BackMenuItem.java │ │ ├── CloseMenuItem.java │ │ ├── ComboMenuItem.java │ │ ├── ItemClickEvent.java │ │ ├── ItemClickHandler.java │ │ ├── ItemMenu.java │ │ ├── ItemMenuHolder.java │ │ ├── ItemMenuListener.java │ │ ├── MenuItem.java │ │ ├── StaticMenuItem.java │ │ └── SubMenuItem.java │ │ ├── kits │ │ ├── AnniPlugin.java │ │ ├── CivilianKit.java │ │ ├── CustomItem.java │ │ ├── IconPackage.java │ │ ├── Kit.java │ │ ├── KitLoading.java │ │ ├── KitMenuItem.java │ │ ├── KitUtils.java │ │ └── Loadout.java │ │ ├── main │ │ ├── AnniArgument.java │ │ ├── AnniCommand.java │ │ ├── AnnihilationMain.java │ │ ├── AreaCommand.java │ │ ├── Lang.java │ │ └── TeamCommand.java │ │ ├── mapBuilder │ │ ├── FutureBlockReplace.java │ │ ├── MapBuilder.java │ │ ├── RegenBlockPrompt.java │ │ ├── SingleQuestionPrompt.java │ │ └── TeamBlock.java │ │ ├── utils │ │ ├── DamageControl.java │ │ ├── IDTools.java │ │ ├── InvisibilityListeners.java │ │ ├── Loc.java │ │ ├── MapKey.java │ │ ├── Perm.java │ │ ├── ShopMenu.java │ │ ├── ShopMenuItem.java │ │ ├── Util.java │ │ └── VersionUtils.java │ │ └── voting │ │ ├── AutoRestarter.java │ │ ├── AutoStarter.java │ │ ├── ConfigManager.java │ │ ├── ScoreboardAPI.java │ │ └── VoteMapManager.java │ └── net │ └── techcable │ └── npclib │ ├── LICENSE │ ├── api │ ├── LogoutTag.java │ ├── NMS.java │ ├── NPC.java │ ├── NPCMain.java │ └── Util.java │ ├── util │ ├── ProfileUtils.java │ └── ReflectUtil.java │ └── versions │ ├── v1_7_R3 │ ├── EntityNPCPlayer.java │ ├── NMS.java │ ├── NPCConnection.java │ ├── NPCNetworkManager.java │ ├── NullChannel.java │ └── NullSocketAddress.java │ ├── v1_7_R4 │ ├── EntityNPCPlayer.java │ ├── NMS.java │ ├── NPCConnection.java │ ├── NPCNetworkManager.java │ ├── NullChannel.java │ ├── NullSocketAddress.java │ └── ProtocolHack.java │ ├── v1_8_R1 │ ├── EntityNPCPlayer.java │ ├── NMS.java │ ├── NPCConnection.java │ ├── NPCNetworkManager.java │ ├── NullChannel.java │ └── NullSocketAddress.java │ └── v1_8_R2 │ ├── EntityNPCPlayer.java │ ├── NMS.java │ ├── NPCConnection.java │ ├── NPCNetworkManager.java │ ├── NullChannel.java │ └── NullSocketAddress.java ├── LICENSE.txt └── README.md /Annihilation Default Kits/src/com/gmail/nuclearcat1337/base/DelayUpdate.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.base; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public interface DelayUpdate 6 | { 7 | void update(Player player, int secondsLeft); 8 | } 9 | -------------------------------------------------------------------------------- /Annihilation Default Kits/src/com/gmail/nuclearcat1337/base/Delays.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.base; 2 | import java.util.ArrayList; 3 | import java.util.HashMap; 4 | import java.util.Iterator; 5 | import java.util.List; 6 | import java.util.Map; 7 | import java.util.UUID; 8 | 9 | import org.bukkit.Bukkit; 10 | import org.bukkit.entity.Player; 11 | 12 | import com.gmail.nuclearcat1337.anniPro.main.AnnihilationMain; 13 | 14 | 15 | public class Delays 16 | { 17 | private static Delays instance; 18 | public static Delays getInstance() 19 | { 20 | if(instance == null) 21 | instance = new Delays(); 22 | return instance; 23 | } 24 | 25 | private int counter = 0; 26 | private final Map delayIDs; 27 | private final Map delayHandlers; 28 | private final List delays; 29 | 30 | private Delays() 31 | { 32 | delays = new ArrayList(); 33 | delayIDs = new HashMap(); 34 | delayHandlers = new HashMap(); 35 | Bukkit.getScheduler().scheduleSyncRepeatingTask(AnnihilationMain.getInstance(), new DelayUpdater(this), 20L, 20L); 36 | } 37 | 38 | private class DelayUpdater implements Runnable 39 | { 40 | private final Delays d; 41 | public DelayUpdater(Delays d) 42 | { 43 | this.d = d; 44 | } 45 | 46 | @Override 47 | public void run() 48 | { 49 | Iterator it = d.delays.iterator(); 50 | while(it.hasNext()) 51 | { 52 | //Bukkit.getLogger().info("This"); 53 | Delay d = it.next(); 54 | if(d.update() <= 0) 55 | { 56 | /// Bukkit.getLogger().info("That"); 57 | it.remove(); 58 | } 59 | } 60 | } 61 | } 62 | 63 | public void createNewDelay(String delayName, DelayUpdate handler) 64 | { 65 | if(!delayIDs.containsKey(delayName.toLowerCase())) 66 | { 67 | delayIDs.put(delayName.toLowerCase(), counter); 68 | delayHandlers.put(counter, handler); 69 | counter++; 70 | } 71 | } 72 | 73 | public boolean hasActiveDelay(Player p, String delayType) 74 | { 75 | for(Delay d : delays) 76 | { 77 | if(d.playerID.equals(p.getUniqueId()) && d.DelayID == this.delayIDs.get(delayType.toLowerCase()) && System.currentTimeMillis() < d.endTime) 78 | return true; 79 | } 80 | return false; 81 | } 82 | 83 | public void addDelay(Player p, long endTime, String delay) 84 | { 85 | Integer id = delayIDs.get(delay.toLowerCase()); 86 | Delay d = new Delay(p.getUniqueId(),id,endTime,delayHandlers.get(id)); 87 | delays.add(d); 88 | } 89 | 90 | private class Delay 91 | { 92 | private UUID playerID; 93 | private int DelayID; 94 | private long endTime; 95 | private DelayUpdate handler; 96 | 97 | public Delay(UUID playerID, int ID, long end, DelayUpdate handler) 98 | { 99 | this.playerID = playerID; 100 | this.DelayID = ID; 101 | this.endTime = end; 102 | this.handler = handler; 103 | } 104 | 105 | public int update() 106 | { 107 | Player p = Bukkit.getPlayer(playerID); 108 | if(p != null) 109 | { 110 | int seconds = (int)((endTime-System.currentTimeMillis())/1000); 111 | handler.update(p, seconds); 112 | return seconds; 113 | } 114 | return 0; 115 | } 116 | 117 | @Override 118 | public int hashCode() 119 | { 120 | final int prime = 31; 121 | int result = 1; 122 | result = prime * result + DelayID; 123 | result = prime * result + ((playerID == null) ? 0 : playerID.hashCode()); 124 | return result; 125 | } 126 | 127 | @Override 128 | public boolean equals(Object obj) 129 | { 130 | if (this == obj) 131 | return true; 132 | if (obj == null) 133 | return false; 134 | if (getClass() != obj.getClass()) 135 | return false; 136 | Delay other = (Delay) obj; 137 | if (DelayID != other.DelayID) 138 | return false; 139 | if (playerID == null) 140 | { 141 | if (other.playerID != null) 142 | return false; 143 | } 144 | else if (!playerID.equals(other.playerID)) 145 | return false; 146 | return true; 147 | } 148 | 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /Annihilation Default Kits/src/com/gmail/nuclearcat1337/base/Direction.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.base; 2 | 3 | import org.bukkit.util.Vector; 4 | 5 | public enum Direction 6 | { 7 | North, 8 | South, 9 | East, 10 | West, 11 | NorthWest, 12 | NorthEast, 13 | SouthWest, 14 | SouthEast; 15 | 16 | public Vector getVector() 17 | { 18 | switch(this) 19 | { 20 | case North: 21 | default: 22 | return new Vector(0,0,-1); 23 | case South: 24 | return new Vector(0,0,1); 25 | case West: 26 | return new Vector(-1,0,0); 27 | case East: 28 | return new Vector(1,0,0); 29 | case NorthWest: 30 | return new Vector(-1,0,-1); 31 | case NorthEast: 32 | return new Vector(1,0,-1); 33 | case SouthWest: 34 | return new Vector(-1,0,1); 35 | case SouthEast: 36 | return new Vector(1,0,1); 37 | } 38 | } 39 | 40 | public static Direction getDirection(Vector vec) 41 | { 42 | Vector k = vec.normalize(); 43 | int x = k.getBlockX(); 44 | int z = k.getBlockZ(); 45 | if(z < 1) 46 | { 47 | if(x<0) 48 | return Direction.NorthWest; 49 | else if(x>0) 50 | return Direction.NorthEast; 51 | else 52 | return Direction.North; 53 | } 54 | else if(z > 1) 55 | { 56 | if(x<0) 57 | return Direction.SouthWest; 58 | else if(x>0) 59 | return Direction.SouthEast; 60 | else 61 | return Direction.South; 62 | } 63 | else if(x < 0) 64 | return Direction.West; 65 | else return Direction.East; 66 | } 67 | 68 | public static Direction getOpposite(Direction direc) 69 | { 70 | switch(direc) 71 | { 72 | default: 73 | return null; 74 | case North: 75 | return Direction.South; 76 | case South: 77 | return Direction.North; 78 | case East: 79 | return Direction.West; 80 | case West: 81 | return Direction.East; 82 | case NorthWest: 83 | return Direction.SouthEast; 84 | case NorthEast: 85 | return Direction.SouthWest; 86 | case SouthWest: 87 | return Direction.NorthEast; 88 | case SouthEast: 89 | return Direction.NorthWest; 90 | } 91 | } 92 | 93 | 94 | public static Direction getOpposite(Vector vec) 95 | { 96 | return Direction.getOpposite(Direction.getDirection(vec)); 97 | } 98 | 99 | // public static final BlockFace[] axis = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST }; 100 | // public static final BlockFace[] radial = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST }; 101 | // 102 | // /** 103 | // * Gets the horizontal Block Face from a given yaw angle
104 | // * This includes the NORTH_WEST faces 105 | // * 106 | // * @param yaw angle 107 | // * @return The Block Face of the angle 108 | // */ 109 | // public static BlockFace yawToFace(float yaw) { 110 | // return yawToFace(yaw, true); 111 | // } 112 | // 113 | // /** 114 | // * Gets the horizontal Block Face from a given yaw angle 115 | // * 116 | // * @param yaw angle 117 | // * @param useSubCardinalDirections setting, True to allow NORTH_WEST to be returned 118 | // * @return The Block Face of the angle 119 | // */ 120 | // public static BlockFace yawToFace(float yaw, boolean useSubCardinalDirections) { 121 | // if (useSubCardinalDirections) { 122 | // return radial[Math.round(yaw / 45f) & 0x7]; 123 | // } else { 124 | // return axis[Math.round(yaw / 90f) & 0x3]; 125 | // } 126 | // } 127 | } 128 | -------------------------------------------------------------------------------- /Annihilation Default Kits/src/com/gmail/nuclearcat1337/base/SpecialItemKit.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.base; 2 | import org.bukkit.configuration.ConfigurationSection; 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.EventPriority; 6 | import org.bukkit.event.block.Action; 7 | import org.bukkit.event.player.PlayerInteractEvent; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 11 | import com.gmail.nuclearcat1337.anniPro.voting.ConfigManager; 12 | import com.google.common.base.Function; 13 | 14 | 15 | public abstract class SpecialItemKit extends ConfigurableKit 16 | { 17 | private ItemStack specialItem; 18 | private String specialItemName; 19 | protected Delays delays; 20 | 21 | @Override 22 | protected void setUp() 23 | { 24 | delays = Delays.getInstance(); 25 | specialItem = specialItem(); 26 | if(getDelayLength() > 0 && useDefaultChecking()) 27 | { 28 | delays.createNewDelay(getInternalName(), new StandardItemUpdater(getSpecialItemName(),specialItem.getType(),new Function(){ 29 | @Override 30 | public Boolean apply(ItemStack stack) 31 | { 32 | return isSpecialItem(stack); 33 | }})); 34 | } 35 | onInitialize(); 36 | } 37 | 38 | protected abstract void onInitialize(); 39 | 40 | //getSpecialItem() has a guarantee that the special item name 41 | //has a value 42 | protected abstract ItemStack specialItem(); 43 | protected abstract String defaultSpecialItemName(); 44 | protected abstract boolean isSpecialItem(ItemStack stack); 45 | protected abstract boolean performSpecialAction(Player player, AnniPlayer p); 46 | protected abstract long getDelayLength(); 47 | protected abstract boolean useDefaultChecking(); 48 | 49 | public ItemStack getSpecialItem() 50 | { 51 | return specialItem; 52 | } 53 | 54 | //This will be called before setUp 55 | @Override 56 | protected void loadKitStuff(ConfigurationSection section) 57 | { 58 | super.loadKitStuff(section); 59 | specialItemName = section.getString("SpecialItemName"); 60 | } 61 | 62 | @Override 63 | protected int setDefaults(ConfigurationSection section) 64 | { 65 | //section.set("SpecialItemName", defaultSpecialItemName()); 66 | return ConfigManager.setDefaultIfNotSet(section, "SpecialItemName", defaultSpecialItemName()); 67 | } 68 | 69 | public String getSpecialItemName() 70 | { 71 | return specialItemName; 72 | } 73 | 74 | // public void giveSpecialItem(Player player) 75 | // { 76 | // if(player != null) 77 | // player.getInventory().addItem(specialItem.clone()); 78 | // } 79 | 80 | // public ItemStack getSpecialItem() 81 | // { 82 | // return this.specialItem.clone(); 83 | // } 84 | 85 | @EventHandler(priority = EventPriority.HIGHEST) 86 | public void specialItemActionCheck(final PlayerInteractEvent event) 87 | { 88 | if(useDefaultChecking()) 89 | { 90 | if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) 91 | { 92 | if(event.getItem() != null && event.getItem().getType() == specialItem.getType()) 93 | { 94 | AnniPlayer p = AnniPlayer.getPlayer(event.getPlayer().getUniqueId()); 95 | if(p != null && p.getKit().equals(this) && isSpecialItem(event.getItem())) 96 | { 97 | event.setCancelled(true); 98 | if(!delays.hasActiveDelay(event.getPlayer(), getInternalName())) 99 | { 100 | //Do firestorm 101 | if(performSpecialAction(event.getPlayer(),p) && getDelayLength() > 0) 102 | delays.addDelay(event.getPlayer(), System.currentTimeMillis()+getDelayLength(), getInternalName()); 103 | } 104 | } 105 | } 106 | } 107 | } 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /Annihilation Default Kits/src/com/gmail/nuclearcat1337/base/StandardItemUpdater.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.base; 2 | import java.util.Map.Entry; 3 | 4 | import org.bukkit.ChatColor; 5 | import org.bukkit.Material; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.inventory.meta.ItemMeta; 9 | 10 | import com.google.common.base.Function; 11 | 12 | 13 | public class StandardItemUpdater implements DelayUpdate 14 | { 15 | private final Function function; 16 | private final String itemName; 17 | private final Material mat; 18 | public StandardItemUpdater(String itemName, Material mat, Function isTheRightItem) 19 | { 20 | function = isTheRightItem; 21 | this.mat = mat; 22 | this.itemName = itemName; 23 | } 24 | 25 | @Override 26 | public void update(Player player, int secondsLeft) 27 | { 28 | for(Entry entry : player.getInventory().all(mat).entrySet()) 29 | { 30 | if(function.apply(entry.getValue())) 31 | { 32 | ItemMeta m = entry.getValue().getItemMeta(); 33 | if(secondsLeft <= 0) 34 | m.setDisplayName(itemName+" "+ChatColor.GREEN+"READY"); 35 | else 36 | m.setDisplayName(itemName+" "+ChatColor.RED+secondsLeft); 37 | entry.getValue().setItemMeta(m); 38 | } 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Annihilation Default Kits/src/com/gmail/nuclearcat1337/kits/Berserker.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.kits; 2 | import java.util.ArrayList; 3 | import java.util.List; 4 | 5 | import org.bukkit.Material; 6 | import org.bukkit.configuration.ConfigurationSection; 7 | import org.bukkit.entity.EntityType; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.EventPriority; 11 | import org.bukkit.event.entity.EntityDamageByEntityEvent; 12 | import org.bukkit.event.entity.PlayerDeathEvent; 13 | import org.bukkit.inventory.ItemStack; 14 | 15 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 16 | import com.gmail.nuclearcat1337.anniPro.kits.Loadout; 17 | import com.gmail.nuclearcat1337.base.ConfigurableKit; 18 | 19 | 20 | public class Berserker extends ConfigurableKit 21 | { 22 | @Override 23 | protected void setUp() 24 | { 25 | 26 | } 27 | 28 | @Override 29 | protected String getInternalName() 30 | { 31 | return "Berserker"; 32 | } 33 | 34 | @Override 35 | protected ItemStack getIcon() 36 | { 37 | return new ItemStack(Material.CHAINMAIL_CHESTPLATE); 38 | } 39 | 40 | @Override 41 | protected int setDefaults(ConfigurationSection section) 42 | { 43 | return 0; 44 | } 45 | 46 | @Override 47 | protected List getDefaultDescription() 48 | { 49 | List l = new ArrayList(); 50 | addToList(l,new String[] 51 | { 52 | aqua+"You are the power.", 53 | "", 54 | aqua+"Start each life with only", 55 | aqua+"9 hearts of health, for", 56 | aqua+"every kill you make you", 57 | aqua+"gain a heart to a maximum", 58 | aqua+"health of 13 hearts.", 59 | }); 60 | return l; 61 | } 62 | 63 | @Override 64 | public void cleanup(Player player) 65 | { 66 | if(player != null) 67 | { 68 | player.setMaxHealth(20); 69 | //player.setHealth(20); 70 | } 71 | } 72 | 73 | @Override 74 | public void onPlayerSpawn(Player player) 75 | { 76 | // KitUtils.giveTeamArmor(player); 77 | // player.getInventory().addItem(KitUtils.getStoneSword()); 78 | // player.getInventory().addItem(KitUtils.getWoodPick()); 79 | // player.getInventory().addItem(KitUtils.getWoodAxe()); 80 | // player.getInventory().addItem(KitUtils.getHealthPotion1()); 81 | // player.getInventory().addItem(KitUtils.getNavCompass()); 82 | player.setMaxHealth(18); 83 | super.onPlayerSpawn(player); 84 | } 85 | 86 | @Override 87 | protected Loadout getFinalLoadout() 88 | { 89 | return new Loadout().addStoneSword().addWoodPick().addWoodAxe().addHealthPotion1(); 90 | } 91 | 92 | //TODO---need to implement extra damage when the player has 40% of health or less 93 | // @AnnihilationEvent 94 | // public void damageListener(PlayerKilledEvent event) 95 | // { 96 | // AnniPlayer p = event.getKiller(); 97 | // if(p != null && p.getKit().equals(this)) 98 | // { 99 | // 100 | // } 101 | // } 102 | 103 | //If the berserker is below 40% health 104 | @EventHandler(priority = EventPriority.MONITOR) 105 | public void damageListener(final EntityDamageByEntityEvent event) 106 | { 107 | if(event.getEntity().getType() == EntityType.PLAYER && event.getDamager().getType() == EntityType.PLAYER) 108 | { 109 | Player one = (Player)event.getDamager(); 110 | AnniPlayer p = AnniPlayer.getPlayer(one.getUniqueId()); 111 | if(p != null && p.getKit().equals(this)) 112 | { 113 | if((one.getHealth() / one.getMaxHealth()) <= .42) 114 | event.setDamage(event.getDamage()+1); 115 | } 116 | } 117 | } 118 | 119 | 120 | //checks for player death and increments max health 121 | @EventHandler(priority = EventPriority.MONITOR) 122 | public void damageListener(final PlayerDeathEvent event) 123 | { 124 | Player killer = event.getEntity().getKiller(); 125 | if(killer != null) 126 | { 127 | AnniPlayer p = AnniPlayer.getPlayer(killer.getUniqueId()); 128 | if(p != null && p.getKit().equals(this)) 129 | { 130 | if(killer.getMaxHealth() <= 24) 131 | killer.setMaxHealth(killer.getMaxHealth()+2); 132 | } 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /Annihilation Default Kits/src/com/gmail/nuclearcat1337/kits/Defender.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.kits; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.bukkit.Material; 7 | import org.bukkit.configuration.ConfigurationSection; 8 | import org.bukkit.entity.EntityType; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.event.EventHandler; 11 | import org.bukkit.event.EventPriority; 12 | import org.bukkit.event.entity.EntityDamageEvent; 13 | import org.bukkit.inventory.ItemStack; 14 | import org.bukkit.potion.PotionEffect; 15 | import org.bukkit.potion.PotionEffectType; 16 | 17 | import com.gmail.nuclearcat1337.anniPro.anniEvents.AnnihilationEvent; 18 | import com.gmail.nuclearcat1337.anniPro.anniEvents.PlayerKilledEvent; 19 | import com.gmail.nuclearcat1337.anniPro.anniEvents.PlayerKilledEvent.KillAttribute; 20 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 21 | import com.gmail.nuclearcat1337.anniPro.kits.KitUtils; 22 | import com.gmail.nuclearcat1337.anniPro.kits.Loadout; 23 | import com.gmail.nuclearcat1337.base.ConfigurableKit; 24 | 25 | public class Defender extends ConfigurableKit 26 | { 27 | 28 | @Override 29 | protected void setUp() 30 | { 31 | 32 | } 33 | 34 | @Override 35 | protected String getInternalName() 36 | { 37 | return "Defender"; 38 | } 39 | 40 | @Override 41 | protected ItemStack getIcon() 42 | { 43 | return new ItemStack(Material.WOOD_SWORD); 44 | } 45 | 46 | @Override 47 | protected int setDefaults(ConfigurationSection section) 48 | { 49 | return 0; 50 | } 51 | 52 | // @Override 53 | // public boolean hasPermission(Player player) 54 | // { 55 | // return false; 56 | // } 57 | 58 | @Override 59 | protected List getDefaultDescription() 60 | { 61 | List l = new ArrayList(); 62 | addToList(l,new String[] 63 | { 64 | aqua+"You are the last line.", 65 | "", 66 | aqua+"While around the nexus", 67 | aqua+"you gain the regeneration", 68 | aqua+"buff and killing players", 69 | aqua+"while in the vicinity", 70 | aqua+"of the nexus rewards you", 71 | aqua+"with extra experience", 72 | aqua+"points.", 73 | }); 74 | return l; 75 | } 76 | 77 | @AnnihilationEvent(priority = EventPriority.MONITOR) 78 | public void checkXP(PlayerKilledEvent event) 79 | { 80 | if(event.getKiller().getTeam().equals(this) && event.getAttributes().contains(KillAttribute.NEXUSDEFENSE)) 81 | event.getKiller().getPlayer().giveExp(20); 82 | } 83 | 84 | @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) 85 | public void damageHandler(EntityDamageEvent event) 86 | { 87 | if(event.getEntityType() == EntityType.PLAYER) 88 | { 89 | AnniPlayer p = AnniPlayer.getPlayer(event.getEntity().getUniqueId()); 90 | if(p != null && p.getTeam() != null && !p.getTeam().isTeamDead() && p.getTeam().getNexus().getLocation() != null && p.getKit().equals(this)) 91 | { 92 | Player player = (Player)event.getEntity(); 93 | if(player.getLocation().distanceSquared(p.getTeam().getNexus().getLocation().toLocation()) <= 20*20) 94 | player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,Integer.MAX_VALUE,0)); 95 | else 96 | player.removePotionEffect(PotionEffectType.REGENERATION); 97 | } 98 | } 99 | } 100 | 101 | @Override 102 | public void cleanup(Player arg0) 103 | { 104 | 105 | } 106 | 107 | @Override 108 | protected Loadout getFinalLoadout() 109 | { 110 | return new Loadout().addWoodSword().addWoodPick().addWoodAxe().addWoodShovel().setUseDefaultArmor(true).setArmor(2,KitUtils.addSoulbound(new ItemStack(Material.CHAINMAIL_CHESTPLATE))); 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /Annihilation Default Kits/src/com/gmail/nuclearcat1337/kits/Enchanter.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.kits; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Random; 6 | 7 | import org.bukkit.Material; 8 | import org.bukkit.configuration.ConfigurationSection; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | import com.gmail.nuclearcat1337.anniPro.anniEvents.AnnihilationEvent; 13 | import com.gmail.nuclearcat1337.anniPro.anniEvents.ResourceBreakEvent; 14 | import com.gmail.nuclearcat1337.anniPro.kits.Loadout; 15 | import com.gmail.nuclearcat1337.base.ConfigurableKit; 16 | 17 | public class Enchanter extends ConfigurableKit 18 | { 19 | private Random rand; 20 | 21 | @Override 22 | protected void setUp() 23 | { 24 | rand = new Random(System.currentTimeMillis()); 25 | } 26 | 27 | @Override 28 | protected String getInternalName() 29 | { 30 | return "Enchanter"; 31 | } 32 | 33 | @Override 34 | protected ItemStack getIcon() 35 | { 36 | return new ItemStack(Material.EXP_BOTTLE); 37 | } 38 | 39 | @Override 40 | protected int setDefaults(ConfigurationSection section) 41 | { 42 | return 0; 43 | } 44 | 45 | @Override 46 | protected List getDefaultDescription() 47 | { 48 | List l = new ArrayList(); 49 | addToList(l,new String[] 50 | { 51 | aqua+"Gain extra exp when gathering", 52 | aqua+"resources which enables", 53 | aqua+"quicker level succession.", 54 | aqua+"", 55 | aqua+"There is a small chance", 56 | aqua+"to obtain experience bottles", 57 | aqua+"when mining ores and chopping", 58 | aqua+"wood.", 59 | }); 60 | return l; 61 | } 62 | 63 | 64 | @Override 65 | public void cleanup(Player arg0) 66 | { 67 | 68 | } 69 | 70 | //Increase the xp gained from mining blocks and potentially gives you an XP bottle (1% chance) 71 | @AnnihilationEvent 72 | public void onResourceBreak(ResourceBreakEvent event) 73 | { 74 | if(event.getPlayer().getKit().equals(this)) 75 | { 76 | int xp = event.getXP(); 77 | //Bukkit.getLogger().info("Inital XP: "+xp); 78 | if(xp > 0) 79 | { 80 | //I guess this needs to be verified to actuall give you more XP 81 | xp = (int)Math.ceil(xp*2); 82 | event.setXP(xp); 83 | //Bukkit.getLogger().info("New XP: "+xp); 84 | if(rand.nextInt(100) == 4) 85 | { 86 | Player pl = event.getPlayer().getPlayer(); 87 | if(pl != null) 88 | pl.getInventory().addItem(new ItemStack(Material.EXP_BOTTLE)); 89 | } 90 | } 91 | } 92 | } 93 | 94 | // @Override 95 | // public IconPackage getIconPackage() 96 | // { 97 | // return new IconPackage(new ItemStack(Material.EXP_BOTTLE), 98 | // new String[]{ 99 | // aqua+"Gain extra exp when gathering", 100 | // aqua+"resources which enables", 101 | // aqua+"quicker level succession.", 102 | // aqua+"", 103 | // aqua+"There is a small chance", 104 | // aqua+"to obtain experience bottles", 105 | // aqua+"when mining ores and chopping", 106 | // aqua+"wood.", 107 | // }); 108 | // } 109 | // 110 | // @Override 111 | // public String getName() 112 | // { 113 | // return "Enchanter"; 114 | // } 115 | 116 | // @Override 117 | // public void onPlayerSpawn(Player player) 118 | // { 119 | // KitUtils.giveTeamArmor(player); 120 | // player.getInventory().addItem(KitUtils.getGoldSword()); 121 | // player.getInventory().addItem(KitUtils.getWoodPick()); 122 | // player.getInventory().addItem(KitUtils.getWoodAxe()); 123 | // player.getInventory().addItem(KitUtils.getNavCompass()); 124 | // } 125 | 126 | @Override 127 | protected Loadout getFinalLoadout() 128 | { 129 | return new Loadout().addGoldSword().addWoodPick().addWoodAxe(); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /Annihilation Default Kits/src/com/gmail/nuclearcat1337/kits/Lumberjack.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.kits; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.bukkit.Material; 7 | import org.bukkit.configuration.ConfigurationSection; 8 | import org.bukkit.enchantments.Enchantment; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | import com.gmail.nuclearcat1337.anniPro.anniEvents.AnnihilationEvent; 13 | import com.gmail.nuclearcat1337.anniPro.anniEvents.ResourceBreakEvent; 14 | import com.gmail.nuclearcat1337.anniPro.kits.Loadout; 15 | import com.gmail.nuclearcat1337.base.ConfigurableKit; 16 | 17 | public class Lumberjack extends ConfigurableKit 18 | { 19 | @Override 20 | protected void setUp() 21 | { 22 | } 23 | 24 | @Override 25 | protected String getInternalName() 26 | { 27 | return "Lumberjack"; 28 | } 29 | 30 | @Override 31 | protected ItemStack getIcon() 32 | { 33 | return new ItemStack(Material.STONE_AXE); 34 | } 35 | 36 | @Override 37 | protected int setDefaults(ConfigurationSection section) 38 | { 39 | return 0; 40 | } 41 | 42 | @Override 43 | protected List getDefaultDescription() 44 | { 45 | List l = new ArrayList(); 46 | addToList(l,new String[] 47 | { 48 | aqua+"You are the wedge.", 49 | "", 50 | aqua+"Gather wood with an efficiency", 51 | aqua+"axe and with the chance", 52 | aqua+"of gaining double yeild,", 53 | aqua+"ensuring quick work of", 54 | aqua+"any trees in your way.", 55 | }); 56 | return l; 57 | } 58 | 59 | @Override 60 | protected Loadout getFinalLoadout() 61 | { 62 | return new Loadout().addWoodSword().addWoodPick().addSoulboundEnchantedItem(new ItemStack(Material.STONE_AXE), Enchantment.DIG_SPEED, 1); 63 | } 64 | 65 | @Override 66 | public void cleanup(Player arg0) 67 | { 68 | } 69 | 70 | //Does the double loot for logs 71 | @AnnihilationEvent 72 | public void onResourceBreak(ResourceBreakEvent event) 73 | { 74 | if(event.getPlayer().getKit().equals(this)) 75 | { 76 | if(event.getResource().Type == Material.LOG) 77 | { 78 | ItemStack[] stacks = event.getProducts(); 79 | for(int x = 0; x < stacks.length; x++) 80 | stacks[x].setAmount(stacks[x].getAmount()*2); 81 | event.setProducts(stacks); 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Annihilation Default Kits/src/com/gmail/nuclearcat1337/kits/Miner.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.kits; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Random; 6 | 7 | import org.bukkit.Material; 8 | import org.bukkit.configuration.ConfigurationSection; 9 | import org.bukkit.enchantments.Enchantment; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import com.gmail.nuclearcat1337.anniPro.anniEvents.AnnihilationEvent; 14 | import com.gmail.nuclearcat1337.anniPro.anniEvents.ResourceBreakEvent; 15 | import com.gmail.nuclearcat1337.anniPro.kits.Loadout; 16 | import com.gmail.nuclearcat1337.base.ConfigurableKit; 17 | 18 | public class Miner extends ConfigurableKit 19 | { 20 | // private final ItemStack Pick = KitUtils.addEnchant(KitUtils.getStonePick(),Enchantment.DIG_SPEED,1); 21 | // private final ItemStack Furnace = KitUtils.addSoulbound(new ItemStack(Material.FURNACE)); 22 | // private final ItemStack coal = new ItemStack(Material.COAL,4); 23 | 24 | private Random rand; 25 | 26 | @Override 27 | protected void setUp() 28 | { 29 | rand = new Random(System.currentTimeMillis()); 30 | } 31 | 32 | @Override 33 | protected String getInternalName() 34 | { 35 | return "Miner"; 36 | } 37 | 38 | @Override 39 | protected ItemStack getIcon() 40 | { 41 | return new ItemStack(Material.STONE_PICKAXE); 42 | } 43 | 44 | @Override 45 | protected int setDefaults(ConfigurationSection section) 46 | { 47 | return 0; 48 | } 49 | 50 | @Override 51 | protected List getDefaultDescription() 52 | { 53 | List l = new ArrayList(); 54 | addToList(l,new String[] 55 | { 56 | aqua+"You are the hands.", 57 | "", 58 | aqua+"Mine precious resources", 59 | aqua+"to gear up your team as", 60 | aqua+"well as yourself so you", 61 | aqua+"will strike swiftly and", 62 | aqua+"with strength on battlefield!", 63 | "", 64 | aqua+"Start with an effeciency", 65 | aqua+"pick, 4 coal, and a furnace", 66 | aqua+"to get minerals quicker.", 67 | }); 68 | return l; 69 | } 70 | 71 | @Override 72 | public void cleanup(Player arg0) 73 | { 74 | 75 | } 76 | 77 | //Does the double loot from regenerating resources 78 | @AnnihilationEvent 79 | public void onResourceBreak(ResourceBreakEvent event) 80 | { 81 | if(event.getPlayer().getKit().equals(this)) 82 | { 83 | if(event.getResource().Type != Material.LOG && event.getResource().Type != Material.MELON_BLOCK && event.getResource().Type != Material.GRAVEL) 84 | { 85 | ItemStack[] products = event.getProducts(); 86 | if(products != null) 87 | { 88 | for(int x = 0; x < products.length; x++) 89 | { 90 | boolean y = rand.nextBoolean(); 91 | if(y) 92 | products[x].setAmount(products[x].getAmount()*2); 93 | } 94 | } 95 | event.setProducts(products); 96 | } 97 | } 98 | } 99 | 100 | @Override 101 | protected Loadout getFinalLoadout() 102 | { 103 | return new Loadout().addWoodSword().addSoulboundEnchantedItem(new ItemStack(Material.STONE_PICKAXE), Enchantment.DIG_SPEED, 1).addWoodAxe().addItem(new ItemStack(Material.COAL,4)) 104 | .addSoulboundItem(new ItemStack(Material.FURNACE)); 105 | } 106 | 107 | // @Override 108 | // public void onPlayerSpawn(Player player) 109 | // { 110 | // KitUtils.giveTeamArmor(player); 111 | // player.getInventory().addItem(KitUtils.getWoodSword()); 112 | // player.getInventory().addItem(Pick); 113 | // player.getInventory().addItem(KitUtils.getWoodAxe()); 114 | // player.getInventory().addItem(coal); 115 | // player.getInventory().addItem(Furnace); 116 | // player.getInventory().addItem(KitUtils.getNavCompass()); 117 | // } 118 | } 119 | -------------------------------------------------------------------------------- /Annihilation Default Kits/src/com/gmail/nuclearcat1337/kits/Vampire.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.kits; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Random; 6 | 7 | import org.bukkit.Material; 8 | import org.bukkit.configuration.ConfigurationSection; 9 | import org.bukkit.entity.EntityType; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.event.EventHandler; 12 | import org.bukkit.event.EventPriority; 13 | import org.bukkit.event.entity.EntityDamageByEntityEvent; 14 | import org.bukkit.inventory.ItemStack; 15 | import org.bukkit.potion.Potion; 16 | import org.bukkit.potion.PotionType; 17 | 18 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 19 | import com.gmail.nuclearcat1337.anniPro.kits.Loadout; 20 | import com.gmail.nuclearcat1337.base.ConfigurableKit; 21 | 22 | public class Vampire extends ConfigurableKit 23 | { 24 | private Random rand; 25 | @Override 26 | protected void setUp() 27 | { 28 | rand = new Random(); 29 | } 30 | 31 | @Override 32 | protected String getInternalName() 33 | { 34 | return "Vampire"; 35 | } 36 | 37 | @Override 38 | protected ItemStack getIcon() 39 | { 40 | return new ItemStack(Material.REDSTONE); 41 | } 42 | 43 | @Override 44 | protected int setDefaults(ConfigurationSection section) 45 | { 46 | return 0; 47 | } 48 | 49 | @Override 50 | protected List getDefaultDescription() 51 | { 52 | List l = new ArrayList(); 53 | addToList(l,new String[] 54 | { 55 | aqua+"You are the fear.", 56 | "", 57 | aqua+"Every hit you land has", 58 | aqua+"a 30% chance to drain", 59 | aqua+"health from your victim", 60 | aqua+"and heal you.", 61 | }); 62 | return l; 63 | } 64 | 65 | @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) 66 | public void damageHandler(EntityDamageByEntityEvent event) 67 | { 68 | if(event.getDamager().getType() == EntityType.PLAYER) 69 | { 70 | Player player = (Player)event.getDamager(); 71 | AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); 72 | if(p != null && p.getKit().equals(this)) 73 | { 74 | if(rand.nextInt(3) == 1) 75 | { 76 | double health = player.getHealth()+1D; 77 | if(health > player.getMaxHealth()) 78 | health = player.getMaxHealth(); 79 | player.setHealth(health); 80 | } 81 | } 82 | } 83 | } 84 | 85 | @Override 86 | protected Loadout getFinalLoadout() 87 | { 88 | return new Loadout().addStoneSword().addWoodPick().addWoodAxe() 89 | .addItem(new Potion(PotionType.NIGHT_VISION).toItemStack(1)); 90 | } 91 | 92 | @Override 93 | public void cleanup(Player arg0) 94 | { 95 | 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /Annihilation Vault Extension/plugin.yml: -------------------------------------------------------------------------------- 1 | name: AnnihilationVault 2 | main: com.gmail.nuclearcat1337.vaultPlugin.VaultHook 3 | version: 1.1.0 4 | authors: [Mr_Little_Kitty] 5 | depend: [Vault, Annihilation] 6 | description: An Annihilation vault hook 7 | commands: 8 | permissions: -------------------------------------------------------------------------------- /Annihilation World Restorer/plugin.yml: -------------------------------------------------------------------------------- 1 | name: AnnihilationWorldRestorer 2 | main: com.gmail.nuclearcat1337.annipro.worldrestorer.WorldRestorer 3 | version: 1.0.0 4 | author: Mr_Little_Kitty 5 | authors: [Mr_Little_Kitty] 6 | description: A plugin for restoring Annihilation Worlds 7 | load: STARTUP 8 | loadbefore: [Annihilation] -------------------------------------------------------------------------------- /Annihilation XP Extension/plugin.yml: -------------------------------------------------------------------------------- 1 | name: AnnihilationXPSystem 2 | main: com.gmail.nuclearcat1337.xpSystem.main.XPMain 3 | version: 1.1.0 4 | authors: [Mr_Little_Kitty] 5 | depend: [Annihilation] 6 | description: An Annihilation XP System 7 | commands: 8 | MyXP: 9 | description: Shows the players XP 10 | Shop: 11 | description: Opens the Kit Shop 12 | permissions: -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/database/AsyncLogQuery.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.database; 2 | 3 | //import java.sql.ResultSet; 4 | 5 | public interface AsyncLogQuery 6 | { 7 | //public void setResult(ResultSet result); 8 | public String getQuery(); 9 | } 10 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/database/AsyncQuery.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.database; 2 | 3 | import java.sql.ResultSet; 4 | 5 | public interface AsyncQuery extends Runnable 6 | { 7 | public boolean isCallback(); 8 | public String getQuerey(); 9 | public void setResult(ResultSet set); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/database/MySQLDatabase.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.database; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | 7 | class MySQLDatabase extends Database 8 | { 9 | private final String user; 10 | private final String database; 11 | private final String password; 12 | private final String port; 13 | private final String hostname; 14 | 15 | public MySQLDatabase(String hostname, String port, 16 | String database, String username, String password) 17 | { 18 | this.hostname = hostname; 19 | this.port = port; 20 | this.database = database; 21 | this.user = username; 22 | this.password = password; 23 | } 24 | 25 | @Override 26 | public Connection openConnection() throws SQLException, 27 | ClassNotFoundException 28 | { 29 | if (checkConnection()) 30 | { 31 | return connection; 32 | } 33 | Class.forName("com.mysql.jdbc.Driver"); 34 | connection = DriverManager.getConnection("jdbc:mysql://" 35 | + this.hostname + ":" + this.port + "/" + this.database, 36 | this.user, this.password); 37 | return connection; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/main/KitArgument.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.main; 2 | 3 | import java.util.UUID; 4 | 5 | import org.bukkit.ChatColor; 6 | import org.bukkit.command.CommandSender; 7 | 8 | import com.gmail.nuclearcat1337.anniPro.itemMenus.MenuItem; 9 | import com.gmail.nuclearcat1337.anniPro.kits.Kit; 10 | import com.gmail.nuclearcat1337.anniPro.main.AnniArgument; 11 | import com.gmail.nuclearcat1337.anniPro.utils.IDTools; 12 | import com.google.common.base.Predicate; 13 | 14 | public class KitArgument implements AnniArgument 15 | { 16 | private XPSystem xpSystem; 17 | public KitArgument(XPSystem system) 18 | { 19 | this.xpSystem = system; 20 | } 21 | 22 | @Override 23 | public void executeCommand(final CommandSender sender, String label, final String[] args) 24 | { 25 | if(args != null && args.length > 2) 26 | { 27 | IDTools.getUUID(args[2], new Predicate(){ 28 | @Override 29 | public boolean apply(UUID id) 30 | { 31 | if(id != null) 32 | { 33 | Kit kit = Kit.getKit(args[1]); 34 | if(kit != null) 35 | { 36 | if(args[0].equalsIgnoreCase("add")) 37 | { 38 | sender.sendMessage(ChatColor.GREEN+"Kit added."); 39 | xpSystem.addKit(id, kit); 40 | sender.sendMessage("Added kit "+kit.getName()); 41 | //addKit(kit.getName(), id); 42 | } 43 | else if(args[0].equalsIgnoreCase("remove")) 44 | { 45 | sender.sendMessage(ChatColor.RED+"Kit removed."); 46 | //removeKit(kit.getName(), id); 47 | xpSystem.removeKit(id, kit); 48 | sender.sendMessage("Removed kit "+kit.getName()); 49 | } 50 | else 51 | sender.sendMessage(ChatColor.RED+"Operation "+ChatColor.GOLD+args[0]+ChatColor.RED+" is not supported."); 52 | } 53 | else 54 | sender.sendMessage(ChatColor.RED+"Could not locate the kit you specified."); 55 | } 56 | else 57 | sender.sendMessage(ChatColor.RED+"Could not locate the player you specified."); 58 | return false; 59 | }}); 60 | } 61 | } 62 | 63 | @Override 64 | public String getArgumentName() 65 | { 66 | return "Kit"; 67 | } 68 | 69 | @Override 70 | public String getHelp() 71 | { 72 | return ChatColor.LIGHT_PURPLE+"Kit [add,remove] --"+ChatColor.GREEN+"adds or removes a kit from a player."; 73 | } 74 | 75 | @Override 76 | public MenuItem getMenuItem() 77 | { 78 | return null; 79 | } 80 | 81 | @Override 82 | public String getPermission() 83 | { 84 | return null; 85 | } 86 | 87 | @Override 88 | public boolean useByPlayerOnly() 89 | { 90 | return false; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/main/LoadKits.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.main; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 9 | import com.gmail.nuclearcat1337.xpSystem.database.AsyncQuery; 10 | import com.gmail.nuclearcat1337.xpSystem.utils.Acceptor; 11 | 12 | class LoadKits implements AsyncQuery 13 | { 14 | private final AnniPlayer player; 15 | private final Acceptor postLoad; 16 | private List kits; 17 | 18 | public LoadKits(AnniPlayer p, Acceptor postLoad) 19 | { 20 | this.player = p; 21 | this.postLoad = postLoad; 22 | } 23 | 24 | @Override 25 | public void run() 26 | { 27 | player.setData("Kits", kits); 28 | if(postLoad != null) 29 | postLoad.accept(player); 30 | } 31 | 32 | @Override 33 | public String getQuerey() 34 | { 35 | return "SELECT * FROM tbl_player_kits WHERE ID='"+player.getID()+"';"; 36 | } 37 | 38 | @Override 39 | public boolean isCallback() 40 | { 41 | return true; 42 | } 43 | 44 | @Override 45 | public void setResult(ResultSet result) 46 | { 47 | kits = new ArrayList(); 48 | try 49 | { 50 | while(result.next()) 51 | { 52 | kits.add(result.getString("Kit").toLowerCase()); 53 | } 54 | } 55 | catch(SQLException e) 56 | { 57 | 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/main/MyXPCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.main; 2 | 3 | import org.bukkit.ChatColor; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.command.CommandExecutor; 8 | 9 | import com.gmail.nuclearcat1337.xpSystem.utils.Acceptor; 10 | 11 | public class MyXPCommand implements CommandExecutor 12 | { 13 | private final XPSystem xpSystem; 14 | private final String myXPMessage; 15 | 16 | public MyXPCommand(XPSystem system, String message) 17 | { 18 | this.xpSystem = system; 19 | this.myXPMessage = message; 20 | } 21 | 22 | @Override 23 | public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) 24 | { 25 | if(sender instanceof Player) 26 | { 27 | final Player player = (Player)sender; 28 | if(xpSystem.isActive()) 29 | { 30 | xpSystem.getXP(player.getUniqueId(), new Acceptor(){ 31 | @Override 32 | public void accept(Integer amount) 33 | { 34 | player.sendMessage(XPMain.formatString(myXPMessage,amount)); 35 | }}); 36 | } 37 | else sender.sendMessage(ChatColor.RED+"The XP system is not active."); 38 | } 39 | else sender.sendMessage("This command needs to be used by a player."); 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/main/QueryXP.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.main; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | import java.util.UUID; 6 | 7 | import com.gmail.nuclearcat1337.xpSystem.database.AsyncQuery; 8 | import com.gmail.nuclearcat1337.xpSystem.utils.Acceptor; 9 | 10 | class QueryXP implements AsyncQuery 11 | { 12 | private final UUID playerID; 13 | private final Acceptor acceptor; 14 | 15 | private int xp = 0; 16 | 17 | public QueryXP(UUID playerID, Acceptor acceptor) 18 | { 19 | assert playerID != null; 20 | assert acceptor != null; 21 | 22 | this.playerID = playerID; 23 | this.acceptor = acceptor; 24 | } 25 | 26 | @Override 27 | public void run() 28 | { 29 | acceptor.accept(xp); 30 | } 31 | 32 | @Override 33 | public boolean isCallback() 34 | { 35 | return true; 36 | } 37 | 38 | @Override 39 | public String getQuerey() 40 | { 41 | return "SELECT * FROM tbl_player_xp WHERE ID='"+playerID.toString()+"'"; 42 | //return "INSERT INTO tbl_player_xp (ID, XP) VALUES ('"+p.ID.toString()+"', "+XP+") ON DUPLICATE KEY UPDATE XP=XP+VALUES(XP);"; 43 | } 44 | 45 | @Override 46 | public void setResult(ResultSet set) 47 | { 48 | try 49 | { 50 | if(set.next()) 51 | { 52 | xp = set.getInt("XP"); 53 | set.close(); 54 | } 55 | } 56 | catch (SQLException e) 57 | { 58 | e.printStackTrace(); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/main/XPArgument.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.main; 2 | 3 | import java.util.UUID; 4 | 5 | import org.bukkit.ChatColor; 6 | import org.bukkit.command.CommandSender; 7 | 8 | import com.gmail.nuclearcat1337.anniPro.itemMenus.MenuItem; 9 | import com.gmail.nuclearcat1337.anniPro.main.AnniArgument; 10 | import com.gmail.nuclearcat1337.anniPro.utils.IDTools; 11 | import com.google.common.base.Predicate; 12 | 13 | public class XPArgument implements AnniArgument 14 | { 15 | private XPSystem xpSystem; 16 | public XPArgument(XPSystem system) 17 | { 18 | this.xpSystem = system; 19 | } 20 | 21 | @Override 22 | public void executeCommand(final CommandSender sender, String label, final String[] args) 23 | { 24 | if(args != null && args.length > 2) 25 | { 26 | try 27 | { 28 | if(args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("subtract")) 29 | { 30 | final int XP = Integer.parseInt(args[1]); 31 | IDTools.getUUID(args[2], new Predicate(){ 32 | @Override 33 | public boolean apply(UUID id) 34 | { 35 | if(id != null) 36 | { 37 | if(args[0].equalsIgnoreCase("add")) 38 | { 39 | xpSystem.giveXP(id, XP); 40 | sender.sendMessage("Gave "+XP+" XP"); 41 | } 42 | else 43 | { 44 | xpSystem.removeXP(id, XP); 45 | sender.sendMessage("Removed "+XP+" XP"); 46 | } 47 | } 48 | else 49 | sender.sendMessage(ChatColor.RED+"Could not locate the player you specified."); 50 | return false; 51 | }}); 52 | } 53 | else sender.sendMessage("You did not specify a valid XP operation."); 54 | } 55 | catch(NumberFormatException e) 56 | { 57 | sender.sendMessage("The XP values specified was not a number"); 58 | } 59 | } 60 | } 61 | 62 | @Override 63 | public String getArgumentName() 64 | { 65 | return "XP"; 66 | } 67 | 68 | @Override 69 | public String getHelp() 70 | { 71 | return ChatColor.LIGHT_PURPLE+"XP [add,substract] --"+ChatColor.GREEN+"adds or subtracts XP from a from player."; 72 | } 73 | 74 | @Override 75 | public MenuItem getMenuItem() 76 | { 77 | return null; 78 | } 79 | 80 | @Override 81 | public String getPermission() 82 | { 83 | return null; 84 | } 85 | 86 | @Override 87 | public boolean useByPlayerOnly() 88 | { 89 | return false; 90 | } 91 | 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/main/XPListeners.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.main; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.EventPriority; 6 | import org.bukkit.event.Listener; 7 | 8 | import com.gmail.nuclearcat1337.anniPro.anniEvents.GameEndEvent; 9 | import com.gmail.nuclearcat1337.anniPro.anniEvents.NexusHitEvent; 10 | import com.gmail.nuclearcat1337.anniPro.anniEvents.PlayerKilledEvent; 11 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 12 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniTeam; 13 | import com.gmail.nuclearcat1337.anniPro.anniGame.Game; 14 | 15 | public class XPListeners implements Listener 16 | { 17 | private final XPSystem xpSystem; 18 | private final String xpMessage; 19 | private final int killXP; 20 | private final int nexusHitXP; 21 | private final int[] teamXPs; 22 | 23 | public XPListeners(XPSystem system, String message,int killXP,int nexusXP,int[] teamXPs) 24 | { 25 | this.xpSystem = system; 26 | this.xpMessage = message; 27 | this.killXP = killXP; 28 | this.nexusHitXP = nexusXP; 29 | this.teamXPs = teamXPs; 30 | } 31 | 32 | private void sendXPMessage(AnniPlayer player, int XP) 33 | { 34 | player.sendMessage(XPMain.formatString(xpMessage, XP)); 35 | } 36 | 37 | @EventHandler(priority=EventPriority.MONITOR) 38 | public void gameEnd(GameEndEvent e) 39 | { 40 | if(e.getWinningTeam() != null && xpSystem.isActive()) 41 | { 42 | for(AnniPlayer p : e.getWinningTeam().getPlayers()) 43 | { 44 | if(p.getPlayer() != null) 45 | { 46 | int amount = XPMain.checkMultipliers(p.getPlayer(),teamXPs[0]); 47 | xpSystem.giveXP(p.getID(),amount); 48 | sendXPMessage(p,amount); 49 | } 50 | } 51 | } 52 | } 53 | 54 | @EventHandler(priority=EventPriority.MONITOR) 55 | public void xpNexusHit(NexusHitEvent e) 56 | { 57 | if(xpSystem.isActive() && Game.isGameRunning() && !e.isCancelled()) 58 | { 59 | Player player = e.getPlayer().getPlayer(); 60 | assert player != null; 61 | 62 | for(AnniPlayer pl : e.getPlayer().getTeam().getPlayers()) 63 | { 64 | int amount = XPMain.checkMultipliers(player,e.getDamage()*nexusHitXP); 65 | xpSystem.giveXP(pl.getID(),amount); 66 | sendXPMessage(pl,amount); 67 | } 68 | 69 | 70 | if(e.willKillTeam()) 71 | { 72 | AnniTeam t = e.getHitNexus().Team; 73 | int alive = 0; 74 | for(AnniTeam team : AnniTeam.Teams) 75 | { 76 | if(!team.isTeamDead() && !team.equals(t)) 77 | alive++; 78 | } 79 | for(AnniPlayer p : t.getPlayers()) 80 | { 81 | int amount = XPMain.checkMultipliers(player,teamXPs[alive]); 82 | xpSystem.giveXP(p.getID(),amount); 83 | sendXPMessage(p,amount); 84 | } 85 | } 86 | } 87 | } 88 | 89 | @EventHandler(priority=EventPriority.MONITOR) 90 | public void xpPlayerKill(PlayerKilledEvent e) 91 | { 92 | if(xpSystem.isActive() && Game.isGameRunning()) 93 | { 94 | int amount = XPMain.checkMultipliers(e.getKiller().getPlayer(),killXP); 95 | xpSystem.giveXP(e.getKiller().getID(),amount); 96 | sendXPMessage(e.getKiller(),amount); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/shop/KitShopMenuItem.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.shop; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.bukkit.ChatColor; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 13 | import com.gmail.nuclearcat1337.anniPro.itemMenus.ItemClickEvent; 14 | import com.gmail.nuclearcat1337.anniPro.itemMenus.MenuItem; 15 | import com.gmail.nuclearcat1337.anniPro.kits.Kit; 16 | import com.gmail.nuclearcat1337.xpSystem.main.XPMain; 17 | import com.gmail.nuclearcat1337.xpSystem.main.XPSystem; 18 | import com.gmail.nuclearcat1337.xpSystem.utils.Acceptor; 19 | 20 | public class KitShopMenuItem extends MenuItem 21 | { 22 | private final KitWrapper wrapper; 23 | private final XPSystem system; 24 | private final Map confirmingPlayers; 25 | 26 | public KitShopMenuItem(final KitWrapper wrapper,final XPSystem system) 27 | { 28 | super(wrapper.kit.getName(), wrapper.kit.getIconPackage().getIcon(), wrapper.kit.getIconPackage().getLore()); 29 | this.wrapper = wrapper; 30 | this.system = system; 31 | confirmingPlayers = new HashMap(); 32 | } 33 | 34 | public Kit getKit() 35 | { 36 | return wrapper.kit; 37 | } 38 | 39 | @Override 40 | public ItemStack getFinalIcon(Player player) 41 | { 42 | List str = new ArrayList(getLore()); 43 | str.add(ChatColor.GOLD+"--------------------------"); 44 | if(wrapper.kit.hasPermission(player)) 45 | str.add(Shop.purchasedMessage); 46 | //str.add(ChatColor.GREEN+"PURCHASED"); 47 | else 48 | { 49 | Long l = confirmingPlayers.get(player.getName()); 50 | if(l == null) 51 | str.add(XPMain.formatString(Shop.forsaleMessage, wrapper.price)); 52 | else 53 | { 54 | if(System.currentTimeMillis()-l.longValue() > 2000) 55 | { 56 | str.add(XPMain.formatString(Shop.forsaleMessage, wrapper.price)); 57 | confirmingPlayers.remove(player.getName()); 58 | } 59 | else 60 | str.add(XPMain.formatString(Shop.confirmMessage, wrapper.price)); 61 | } 62 | } 63 | 64 | //str.add(ChatColor.RED+"LOCKED. PURCHASE FOR "); 65 | return setNameAndLore(getIcon().clone(), getDisplayName(), str); 66 | } 67 | 68 | @Override 69 | public void onItemClick(ItemClickEvent event) 70 | { 71 | final Player player = event.getPlayer(); 72 | if(player != null && !wrapper.kit.hasPermission(player)) 73 | { 74 | event.setWillUpdate(true); 75 | final AnniPlayer anniplayer = AnniPlayer.getPlayer(player.getUniqueId()); 76 | if(anniplayer != null) 77 | { 78 | Long l = confirmingPlayers.get(player.getName()); 79 | if(l != null) 80 | { 81 | confirmingPlayers.remove(player.getName()); 82 | if(System.currentTimeMillis()-l.longValue() > 2000) 83 | player.sendMessage(Shop.confirmExpired); 84 | else 85 | { 86 | event.setWillUpdate(false); 87 | event.setWillClose(true); 88 | this.system.getXP(player.getUniqueId(), new Acceptor(){ 89 | @Override 90 | public void accept(Integer xp) 91 | { 92 | if(xp >= wrapper.price) 93 | { 94 | system.addKit(player.getUniqueId(), wrapper.kit); 95 | system.removeXP(player.getUniqueId(), wrapper.price); 96 | player.sendMessage(Shop.kitPurchased.replace("%w", wrapper.kit.getName())); 97 | } 98 | else player.sendMessage(Shop.notEnoughXP); 99 | 100 | }}); 101 | } 102 | } 103 | else confirmingPlayers.put(player.getName(), System.currentTimeMillis()); 104 | } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/shop/KitWrapper.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.shop; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.kits.Kit; 4 | 5 | public class KitWrapper 6 | { 7 | public KitWrapper(Kit k, int price) 8 | { 9 | this.kit = k; 10 | this.price = price; 11 | } 12 | public Kit kit; 13 | public int price; 14 | } 15 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/shop/Shop.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.shop; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import java.util.UUID; 7 | 8 | import org.bukkit.ChatColor; 9 | import org.bukkit.command.Command; 10 | import org.bukkit.command.CommandExecutor; 11 | import org.bukkit.command.CommandSender; 12 | import org.bukkit.configuration.ConfigurationSection; 13 | import org.bukkit.entity.Player; 14 | 15 | import com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu; 16 | import com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu.Size; 17 | import com.gmail.nuclearcat1337.anniPro.kits.Kit; 18 | import com.gmail.nuclearcat1337.anniPro.voting.ConfigManager; 19 | import com.gmail.nuclearcat1337.xpSystem.main.XPSystem; 20 | 21 | public class Shop implements CommandExecutor 22 | { 23 | //private XPSystem system; 24 | static String purchasedMessage; 25 | static String forsaleMessage; 26 | static String confirmMessage; 27 | static String confirmExpired; 28 | static String notEnoughXP; 29 | static String kitPurchased; 30 | String noKitsToPurchase; 31 | private KitShopMenuItem[] items; 32 | private final Map menus; 33 | 34 | public Shop(XPSystem system, ConfigurationSection shopSection) 35 | { 36 | menus = new HashMap(); 37 | purchasedMessage = getString(shopSection,"Already-Purchased-Kit"); 38 | forsaleMessage = getString(shopSection,"Not-Yet-Purchased-Kit"); 39 | confirmMessage = getString(shopSection,"Confirm-Purchase-Kit"); 40 | confirmExpired = getString(shopSection,"Confirmation-Expired"); 41 | notEnoughXP = getString(shopSection,"Not-Enough-XP"); 42 | kitPurchased = getString(shopSection,"Kit-Purchased"); 43 | noKitsToPurchase = getString(shopSection,"No-Kits-To-Purchase"); 44 | if(!shopSection.isConfigurationSection("Kits")) 45 | shopSection.createSection("Kits"); 46 | ConfigurationSection kitSec = shopSection.getConfigurationSection("Kits"); 47 | Collection kits = Kit.getKits(); 48 | items = new KitShopMenuItem[kits.size()]; 49 | int c =0; 50 | for(Kit k : kits) 51 | { 52 | ConfigManager.setDefaultIfNotSet(kitSec, k.getName(), 10000); 53 | KitShopMenuItem item = new KitShopMenuItem(new KitWrapper(k,kitSec.getInt(k.getName())),system); 54 | items[c] = item; 55 | c++; 56 | } 57 | } 58 | 59 | private String getString(ConfigurationSection section, String path) 60 | { 61 | return ChatColor.translateAlternateColorCodes('&', section.getString(path)); 62 | } 63 | 64 | @Override 65 | public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) 66 | { 67 | if(sender instanceof Player) 68 | { 69 | Player player = (Player)sender; 70 | ItemMenu menu = menus.get(player.getUniqueId()); 71 | if(menu == null) 72 | { 73 | menu = new ItemMenu(player.getName()+"'s Kit Shop",Size.fit(items.length)); 74 | menus.put(player.getUniqueId(), menu); 75 | } 76 | menu.clearAllItems(); 77 | int counter = 0; 78 | for(KitShopMenuItem m : items) 79 | { 80 | if(!m.getKit().hasPermission(player)) 81 | { 82 | menu.setItem(counter, m); 83 | counter++; 84 | } 85 | } 86 | if(counter == 0) 87 | sender.sendMessage(this.noKitsToPurchase); 88 | else 89 | menu.open(player); 90 | } 91 | return true; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Annihilation XP Extension/src/com/gmail/nuclearcat1337/xpSystem/utils/Acceptor.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.xpSystem.utils; 2 | 3 | public interface Acceptor 4 | { 5 | public void accept(T obj); 6 | } 7 | -------------------------------------------------------------------------------- /Annihilation/assets/BlueTeam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrLittleKitty/AnnihilationPro/38e75ac942b7f089c68e0038ff063580a9e8fe26/Annihilation/assets/BlueTeam.png -------------------------------------------------------------------------------- /Annihilation/assets/GreenTeam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrLittleKitty/AnnihilationPro/38e75ac942b7f089c68e0038ff063580a9e8fe26/Annihilation/assets/GreenTeam.png -------------------------------------------------------------------------------- /Annihilation/assets/Phase1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrLittleKitty/AnnihilationPro/38e75ac942b7f089c68e0038ff063580a9e8fe26/Annihilation/assets/Phase1.png -------------------------------------------------------------------------------- /Annihilation/assets/Phase2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrLittleKitty/AnnihilationPro/38e75ac942b7f089c68e0038ff063580a9e8fe26/Annihilation/assets/Phase2.png -------------------------------------------------------------------------------- /Annihilation/assets/Phase3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrLittleKitty/AnnihilationPro/38e75ac942b7f089c68e0038ff063580a9e8fe26/Annihilation/assets/Phase3.png -------------------------------------------------------------------------------- /Annihilation/assets/Phase4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrLittleKitty/AnnihilationPro/38e75ac942b7f089c68e0038ff063580a9e8fe26/Annihilation/assets/Phase4.png -------------------------------------------------------------------------------- /Annihilation/assets/Phase5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrLittleKitty/AnnihilationPro/38e75ac942b7f089c68e0038ff063580a9e8fe26/Annihilation/assets/Phase5.png -------------------------------------------------------------------------------- /Annihilation/assets/RedTeam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrLittleKitty/AnnihilationPro/38e75ac942b7f089c68e0038ff063580a9e8fe26/Annihilation/assets/RedTeam.png -------------------------------------------------------------------------------- /Annihilation/assets/YellowTeam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrLittleKitty/AnnihilationPro/38e75ac942b7f089c68e0038ff063580a9e8fe26/Annihilation/assets/YellowTeam.png -------------------------------------------------------------------------------- /Annihilation/plugin.yml: -------------------------------------------------------------------------------- 1 | name: Annihilation 2 | main: com.gmail.nuclearcat1337.anniPro.main.AnnihilationMain 3 | version: 1.5.5 4 | authors: [Mr_Little_Kitty] 5 | description: A plugin for playing the game of Annihilation 6 | commands: 7 | Anni: 8 | description: provides commands for the Annihilation game 9 | Team: 10 | description: Command related to annihilation team 11 | Area: 12 | description: Command for managing annihilation areas 13 | Vote: 14 | description: Allows players to vote for a map in annihilation 15 | Kit: 16 | description: Opens the kit menu for the player 17 | permissions: 18 | A.anni: 19 | description: gives permission to use the anni command 20 | default: op 21 | A.Area: 22 | description: gives permission to use the anni command 23 | default: op 24 | Anni.ChangeKit: 25 | description: allows a player to change their kit with a command 26 | default: op 27 | Anni.JoinPhase.3: 28 | default: false 29 | Anni.JoinPhase.4: 30 | default: false 31 | Anni.JoinPhase.5: 32 | default: false 33 | Anni.BypassJoin: 34 | default: false -------------------------------------------------------------------------------- /Annihilation/src/README.txt: -------------------------------------------------------------------------------- 1 | Annihilation Pro Readme (Currently in-progress) 2 | 3 | Files: 4 | 5 | "Annihilation.jar" (NOT OPTIONAL) 6 | --This goes in the "plugins" folder 7 | --This is the main plugin required to run the Annihilation game mode 8 | 9 | "AnnihilationStarterKits.jar" (OPTIONAL, but RECOMMENDED) 10 | --This goes in the "plugins/Annihilation/Kits" folder 11 | --This provides the starting kits for the Annihilation game mode 12 | --Any addition kit packs should also be placed in the "plugins/Annihilation/Kits" folder 13 | --Additional kit packs: 14 | ----StarterKitsPlus (http://www.spigotmc.org/resources/annihilation-pro-starterkitsplus.7199/) 15 | 16 | "AnnihilationVault.jar" (OPTIONAL) 17 | --This goes in the "plugins" folder 18 | --This requires that you have the plugin "Vault" and an economy plugin on your server 19 | 20 | "AnnihilationXP.jar" (OPTIONAL) 21 | --This goes in the "plugins" folder 22 | --This requires that you have a MySQL server 23 | --You must configure the MySQL server in the XPConfig file 24 | 25 | "AnnihilationWorldRestorer.jar" (OPTIONAL, but RECOMMENDED) 26 | --This goes in the "plugins" folder 27 | --This plugin restores the Annihilation worlds on the start of your server 28 | --This plugins works as follows: 29 | ----1. This plugin looks through all of the worlds in the "plugins/Annihilation/Worlds" folder 30 | ----2. If that world is already in the "plugins/Annihilation/WorldBackups" folder, the world is restored from its backup 31 | ----3. If that world is not already in the "plugins/Annihilation/WorldBackups" folder, it is backed up to the backups folder 32 | ----Example: You have a world "Cat" in the "plugins/Annihilation/Worlds" folder. When the plugin starts, the world "Cat" 33 | is copied to the "plugins/Annihilation/WorldBackups" folder. Now, every time you start your server, 34 | the world "Cat" is copied from the backups folder and put into the worlds folder. 35 | 36 | 37 | All of these have configuration files. 38 | The configuration files are all found in the "plugins/Annihilation" folder. 39 | 40 | -------------------------------------------------------------------------------- /Annihilation/src/com/bobacadodl/imgmessage/AnimatedMessage.java: -------------------------------------------------------------------------------- 1 | package com.bobacadodl.imgmessage; 2 | 3 | import javax.imageio.ImageIO; 4 | import javax.imageio.ImageReader; 5 | import javax.imageio.stream.ImageInputStream; 6 | import java.awt.image.BufferedImage; 7 | import java.io.File; 8 | import java.io.IOException; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * User: bobacadodl 14 | * Date: 1/25/14 15 | * Time: 10:41 PM 16 | */ 17 | public class AnimatedMessage { 18 | private ImageMessage[] images; 19 | private int index = 0; 20 | 21 | public AnimatedMessage(ImageMessage... images) { 22 | this.images = images; 23 | } 24 | 25 | public AnimatedMessage(File gifFile, int height, char imgChar) throws IOException { 26 | List frames = getFrames(gifFile); 27 | images = new ImageMessage[frames.size()]; 28 | for (int i = 0; i < frames.size(); i++) { 29 | images[i] = new ImageMessage(frames.get(i), height, imgChar); 30 | } 31 | } 32 | 33 | public List getFrames(File input) { 34 | List images = new ArrayList(); 35 | try { 36 | ImageReader reader = ImageIO.getImageReadersBySuffix("GIF").next(); 37 | ImageInputStream in = ImageIO.createImageInputStream(input); 38 | reader.setInput(in); 39 | for (int i = 0, count = reader.getNumImages(true); i < count; i++) { 40 | BufferedImage image = reader.read(i); // read next frame from gif 41 | images.add(image); 42 | } 43 | } catch (IOException ex) { 44 | ex.printStackTrace(); 45 | } 46 | return images; 47 | } 48 | 49 | public ImageMessage current() { 50 | return images[index]; 51 | } 52 | 53 | public ImageMessage next() { 54 | ++index; 55 | if (index >= images.length) { 56 | index = 0; 57 | return images[index]; 58 | } else { 59 | return images[index]; 60 | } 61 | } 62 | 63 | public ImageMessage previous() { 64 | --index; 65 | if (index <= 0) { 66 | index = images.length - 1; 67 | return images[index]; 68 | } else { 69 | return images[index]; 70 | } 71 | } 72 | 73 | public ImageMessage getIndex(int index) { 74 | return images[index]; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Annihilation/src/com/bobacadodl/imgmessage/ImageChar.java: -------------------------------------------------------------------------------- 1 | package com.bobacadodl.imgmessage; 2 | 3 | /** 4 | * User: bobacadodl 5 | * Date: 1/25/14 6 | * Time: 11:03 PM 7 | */ 8 | public enum ImageChar { 9 | BLOCK('\u2588'), 10 | DARK_SHADE('\u2593'), 11 | MEDIUM_SHADE('\u2592'), 12 | LIGHT_SHADE('\u2591'); 13 | private char c; 14 | 15 | ImageChar(char c) { 16 | this.c = c; 17 | } 18 | 19 | public char getChar() { 20 | return c; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniEvents/AnniEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniEvents; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.event.Event; 5 | 6 | public final class AnniEvent 7 | { 8 | public static void callEvent(Event event) 9 | { 10 | Bukkit.getPluginManager().callEvent(event); 11 | } 12 | 13 | // public static void registerListener(Listener listener) 14 | // { 15 | // Bukkit.getPluginManager().registerEvents(listener, AnnihilationMain.getInstance()); 16 | // } 17 | } 18 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniEvents/GameEndEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniEvents; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniTeam; 4 | import org.bukkit.event.Event; 5 | import org.bukkit.event.HandlerList; 6 | 7 | public final class GameEndEvent extends Event 8 | { 9 | private static final HandlerList list = new HandlerList(); 10 | 11 | private final AnniTeam winner; 12 | 13 | public GameEndEvent(AnniTeam winningTeam) 14 | { 15 | this.winner = winningTeam; 16 | } 17 | 18 | public AnniTeam getWinningTeam() 19 | { 20 | return winner; 21 | } 22 | 23 | @Override 24 | public HandlerList getHandlers() 25 | { 26 | return list; 27 | } 28 | 29 | public static HandlerList getHandlerList() 30 | { 31 | return list; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniEvents/GameStartEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniEvents; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | 6 | public final class GameStartEvent extends Event 7 | { 8 | private static final HandlerList list = new HandlerList(); 9 | @Override 10 | public HandlerList getHandlers() 11 | { 12 | return list; 13 | } 14 | 15 | public static HandlerList getHandlerList() 16 | { 17 | return list; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniEvents/NexusHitEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniEvents; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 4 | import com.gmail.nuclearcat1337.anniPro.anniGame.Nexus; 5 | import org.bukkit.event.Cancellable; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | 9 | public final class NexusHitEvent extends Event implements Cancellable 10 | { 11 | private static final HandlerList list = new HandlerList(); 12 | 13 | private AnniPlayer player; 14 | private final Nexus nexus; 15 | private int damage; 16 | private boolean cancelled; 17 | 18 | public NexusHitEvent(AnniPlayer player, Nexus hitNexus, int damage) 19 | { 20 | this.player = player; 21 | this.nexus = hitNexus; 22 | this.damage = damage; 23 | 24 | } 25 | 26 | public AnniPlayer getPlayer() 27 | { 28 | return player; 29 | } 30 | 31 | public Nexus getHitNexus() 32 | { 33 | return nexus; 34 | } 35 | 36 | public int getDamage() 37 | { 38 | return damage; 39 | } 40 | 41 | public void setDamage(int damage) 42 | { 43 | this.damage = damage; 44 | } 45 | 46 | public boolean willKillTeam() 47 | { 48 | return (nexus.Team.getHealth()-damage) <= 0; 49 | } 50 | 51 | @Override 52 | public HandlerList getHandlers() 53 | { 54 | return list; 55 | } 56 | 57 | public static HandlerList getHandlerList() 58 | { 59 | return list; 60 | } 61 | 62 | @Override 63 | public boolean isCancelled() 64 | { 65 | return cancelled; 66 | } 67 | 68 | @Override 69 | public void setCancelled(final boolean b) 70 | { 71 | cancelled = b; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniEvents/PlayerKilledEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniEvents; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import org.bukkit.Location; 8 | 9 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 10 | import org.bukkit.event.Event; 11 | import org.bukkit.event.HandlerList; 12 | 13 | public final class PlayerKilledEvent extends Event 14 | { 15 | private static final HandlerList list = new HandlerList(); 16 | @Override 17 | public HandlerList getHandlers() 18 | { 19 | return list; 20 | } 21 | 22 | public enum KillAttribute 23 | { 24 | REMEMBRANCE, 25 | NEXUSDEFENSE, 26 | NEXUSATTACK, 27 | } 28 | 29 | private AnniPlayer player; 30 | private AnniPlayer killer; 31 | private boolean dropXP; 32 | private final List attributes; 33 | 34 | public PlayerKilledEvent(AnniPlayer killer, AnniPlayer player) 35 | { 36 | this.player = player; 37 | this.killer = killer; 38 | dropXP = false; 39 | List att = new ArrayList(); 40 | if(killer.getTeam() != null) 41 | { 42 | if(killer.getTeam().isTeamDead()) 43 | att.add(KillAttribute.REMEMBRANCE); 44 | else 45 | { 46 | Location killerLoc = killer.getPlayer().getLocation(); 47 | if(killer.getTeam().getNexus().getLocation() != null && killerLoc.getWorld().getName().equalsIgnoreCase(killer.getTeam().getNexus().getLocation().getWorld())) 48 | { 49 | if(killer.getTeam().getNexus().getLocation().toLocation().distanceSquared(killerLoc) <= 20*20) 50 | att.add(KillAttribute.NEXUSDEFENSE); 51 | } 52 | } 53 | } 54 | this.attributes = Collections.unmodifiableList(att); 55 | } 56 | 57 | public AnniPlayer getPlayer() 58 | { 59 | return player; 60 | } 61 | 62 | public static HandlerList getHandlerList() 63 | { 64 | return list; 65 | } 66 | 67 | public AnniPlayer getKiller() 68 | { 69 | return killer; 70 | } 71 | 72 | public boolean shouldDropXP() 73 | { 74 | return dropXP; 75 | } 76 | 77 | public void setShouldDropXP(boolean dropXP) 78 | { 79 | this.dropXP = dropXP; 80 | } 81 | 82 | public List getAttributes() 83 | { 84 | return this.attributes; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniEvents/PluginDisableEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniEvents; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | 6 | public class PluginDisableEvent extends Event 7 | { 8 | private static final HandlerList list = new HandlerList(); 9 | 10 | public static HandlerList getHandlerList() 11 | { 12 | return list; 13 | } 14 | 15 | @Override 16 | public HandlerList getHandlers() 17 | { 18 | return list; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniEvents/ResourceBreakEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniEvents; 2 | 3 | import org.bukkit.event.Cancellable; 4 | import org.bukkit.event.Event; 5 | import org.bukkit.event.HandlerList; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 9 | import com.gmail.nuclearcat1337.anniPro.anniMap.RegeneratingBlock; 10 | 11 | public class ResourceBreakEvent extends Event implements Cancellable 12 | { 13 | private static final HandlerList list = new HandlerList(); 14 | private RegeneratingBlock resource; 15 | private int xp; 16 | private ItemStack[] endresult; 17 | private boolean cancelled; 18 | 19 | public AnniPlayer getPlayer() 20 | { 21 | return player; 22 | } 23 | 24 | private AnniPlayer player; 25 | 26 | @Override 27 | public boolean isCancelled() 28 | { 29 | return cancelled; 30 | } 31 | 32 | @Override 33 | public void setCancelled(final boolean b) 34 | { 35 | cancelled = b; 36 | } 37 | 38 | public ResourceBreakEvent(AnniPlayer player, RegeneratingBlock resource, int XP, ItemStack... endResult) 39 | { 40 | this.player = player; 41 | this.resource = resource; 42 | this.xp = XP; 43 | this.endresult = endResult; 44 | } 45 | 46 | public RegeneratingBlock getResource() 47 | { 48 | return resource; 49 | } 50 | 51 | public int getXP() 52 | { 53 | return xp; 54 | } 55 | 56 | public void setXP(int XP) 57 | { 58 | xp = XP; 59 | } 60 | 61 | public ItemStack[] getProducts() 62 | { 63 | return endresult; 64 | } 65 | 66 | public void setProducts(ItemStack[] results) 67 | { 68 | endresult = results; 69 | } 70 | 71 | @Override 72 | public HandlerList getHandlers() 73 | { 74 | return list; 75 | } 76 | 77 | public static HandlerList getHandlerList() 78 | { 79 | return list; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniGame/ArmorStandListener.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniGame; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.EntityType; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.entity.EntitySpawnEvent; 8 | import org.bukkit.plugin.Plugin; 9 | 10 | public class ArmorStandListener implements Listener 11 | { 12 | public ArmorStandListener(Plugin p) 13 | { 14 | Bukkit.getPluginManager().registerEvents(this,p); 15 | } 16 | 17 | @EventHandler 18 | public void armorStandStop(EntitySpawnEvent event) 19 | { 20 | if(event.getEntityType() == EntityType.ARMOR_STAND) 21 | event.setCancelled(true); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniGame/autoRespawn/RespawnHandler.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.main.AnnihilationMain; 4 | import com.gmail.nuclearcat1337.anniPro.utils.VersionUtils; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.EventPriority; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.entity.PlayerDeathEvent; 11 | import org.bukkit.plugin.Plugin; 12 | import org.bukkit.scheduler.BukkitRunnable; 13 | 14 | public class RespawnHandler implements Listener 15 | { 16 | private static RespawnHandler instance; 17 | public static void register(Plugin plugin) 18 | { 19 | if(instance == null) 20 | { 21 | instance = new RespawnHandler(); 22 | Bukkit.getPluginManager().registerEvents(instance,plugin); 23 | } 24 | } 25 | 26 | private RespawnPacket packet; 27 | private RespawnHandler() 28 | { 29 | try 30 | { 31 | String version = VersionUtils.getVersion(); 32 | String className = "com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn.versions."+version+"Packet"; 33 | Class cl = Class.forName(className); 34 | Class pack = cl.asSubclass(RespawnPacket.class); 35 | RespawnPacket p = pack.newInstance(); 36 | packet = p; 37 | } 38 | catch(Throwable t) 39 | { 40 | packet = new FakePacket(); 41 | } 42 | } 43 | 44 | @EventHandler(priority = EventPriority.HIGHEST) 45 | public void autoRespawn(PlayerDeathEvent event) 46 | { 47 | new AutoRespawnTask(event.getEntity()).runTaskLater(AnnihilationMain.getInstance(), 2L); 48 | } 49 | 50 | private class AutoRespawnTask extends BukkitRunnable 51 | { 52 | private Player player; 53 | public AutoRespawnTask(Player player) 54 | { 55 | this.player = player; 56 | } 57 | 58 | @Override 59 | public void run() 60 | { 61 | packet.sendToPlayer(player); 62 | player = null; 63 | } 64 | } 65 | 66 | private class FakePacket implements RespawnPacket 67 | { 68 | @Override 69 | public void sendToPlayer(final Player player) 70 | { 71 | player.sendMessage("WARNING: This server is using a version that is not supported."); 72 | } 73 | } 74 | 75 | // try 76 | // { 77 | // Object nmsPlayer = player.getClass().getMethod("getHandle").invoke(player); 78 | // Object packet = Class.forName(nmsPlayer.getClass().getPackage().getName() + ".PacketPlayInClientCommand").newInstance(); 79 | // Class enumClass = Class.forName(nmsPlayer.getClass().getPackage().getName() + ".EnumClientCommand"); 80 | // 81 | // for(Object ob : enumClass.getEnumConstants()) 82 | // { 83 | // if(ob.toString().equals("PERFORM_RESPAWN")) 84 | // { 85 | // packet = packet.getClass().getConstructor(enumClass).newInstance(ob); 86 | // } 87 | // } 88 | // 89 | // Object con = nmsPlayer.getClass().getField("playerConnection").get(nmsPlayer); 90 | // con.getClass().getMethod("a", packet.getClass()).invoke(con, packet); 91 | // return; 92 | // } 93 | // catch(Throwable t) 94 | // { 95 | // return; 96 | // } 97 | } 98 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniGame/autoRespawn/RespawnPacket.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public interface RespawnPacket 6 | { 7 | void sendToPlayer(Player player); 8 | } 9 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniGame/autoRespawn/versions/v1_7_R3Packet.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn.versions; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn.RespawnPacket; 4 | import net.minecraft.server.v1_7_R3.EnumClientCommand; 5 | import net.minecraft.server.v1_7_R3.PacketPlayInClientCommand; 6 | import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer; 7 | import org.bukkit.entity.Player; 8 | 9 | public class v1_7_R3Packet implements RespawnPacket 10 | { 11 | private final PacketPlayInClientCommand packet; 12 | public v1_7_R3Packet() 13 | { 14 | packet = new PacketPlayInClientCommand(EnumClientCommand.PERFORM_RESPAWN); 15 | } 16 | 17 | @Override 18 | public void sendToPlayer(final Player player) 19 | { 20 | CraftPlayer p = (CraftPlayer)player; 21 | p.getHandle().playerConnection.a(packet); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniGame/autoRespawn/versions/v1_7_R4Packet.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn.versions; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn.RespawnPacket; 4 | import net.minecraft.server.v1_7_R4.EnumClientCommand; 5 | import net.minecraft.server.v1_7_R4.PacketPlayInClientCommand; 6 | import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; 7 | import org.bukkit.entity.Player; 8 | 9 | public class v1_7_R4Packet implements RespawnPacket 10 | { 11 | private final PacketPlayInClientCommand packet; 12 | public v1_7_R4Packet() 13 | { 14 | packet = new PacketPlayInClientCommand(EnumClientCommand.PERFORM_RESPAWN); 15 | } 16 | 17 | @Override 18 | public void sendToPlayer(final Player player) 19 | { 20 | CraftPlayer p = (CraftPlayer)player; 21 | p.getHandle().playerConnection.a(packet); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniGame/autoRespawn/versions/v1_8_R1Packet.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn.versions; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn.RespawnPacket; 4 | import net.minecraft.server.v1_8_R1.EnumClientCommand; 5 | import net.minecraft.server.v1_8_R1.PacketPlayInClientCommand; 6 | import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; 7 | import org.bukkit.entity.Player; 8 | 9 | public class v1_8_R1Packet implements RespawnPacket 10 | { 11 | private final PacketPlayInClientCommand packet; 12 | public v1_8_R1Packet() 13 | { 14 | packet = new PacketPlayInClientCommand(EnumClientCommand.PERFORM_RESPAWN); 15 | } 16 | 17 | @Override 18 | public void sendToPlayer(final Player player) 19 | { 20 | CraftPlayer p = (CraftPlayer)player; 21 | p.getHandle().playerConnection.a(packet); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniGame/autoRespawn/versions/v1_8_R2Packet.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn.versions; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.autoRespawn.RespawnPacket; 4 | import net.minecraft.server.v1_8_R2.PacketPlayInClientCommand; 5 | import net.minecraft.server.v1_8_R2.PacketPlayInClientCommand.EnumClientCommand; 6 | import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; 7 | import org.bukkit.entity.Player; 8 | 9 | public class v1_8_R2Packet implements RespawnPacket 10 | { 11 | private final PacketPlayInClientCommand packet; 12 | public v1_8_R2Packet() 13 | { 14 | packet = new PacketPlayInClientCommand(EnumClientCommand.PERFORM_RESPAWN); 15 | } 16 | 17 | @Override 18 | public void sendToPlayer(final Player player) 19 | { 20 | CraftPlayer p = (CraftPlayer)player; 21 | p.getHandle().playerConnection.a(packet); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniMap/AnniSign.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniMap; 2 | 3 | import org.bukkit.block.BlockFace; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | 6 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniTeam; 7 | import com.gmail.nuclearcat1337.anniPro.utils.Loc; 8 | 9 | public final class AnniSign 10 | { 11 | private final FacingObject obj; 12 | private boolean signPost; 13 | private SignType type; 14 | 15 | public AnniSign(FacingObject obj, boolean signPost, SignType type) 16 | { 17 | this.obj = obj; 18 | this.signPost = signPost; 19 | this.type = type; 20 | } 21 | 22 | public AnniSign(ConfigurationSection configSection) 23 | { 24 | if(configSection == null) 25 | throw new NullPointerException(); 26 | 27 | boolean signpost = configSection.getBoolean("isSignPost"); 28 | //Location loc = ConfigManager.getLocation(configSection.getConfigurationSection("Location")); 29 | Loc loc = new Loc(configSection.getConfigurationSection("Location")); 30 | BlockFace facing = BlockFace.valueOf(configSection.getString("FacingDirection")); 31 | obj = new FacingObject(facing, loc); 32 | this.signPost = signpost; 33 | String data = configSection.getString("Data"); 34 | if(data.equalsIgnoreCase("Brewing")) 35 | type = SignType.Brewing; 36 | else if(data.equalsIgnoreCase("Weapon")) 37 | type = SignType.Weapon; 38 | else 39 | type = SignType.newTeamSign(AnniTeam.getTeamByName(data.split("-")[1])); 40 | } 41 | 42 | //public abstract void onSignClick(final Player player); 43 | 44 | public boolean isSignPost() 45 | { 46 | return this.signPost; 47 | } 48 | 49 | public Loc getLocation() 50 | { 51 | return obj.getLocation(); 52 | } 53 | 54 | public BlockFace getFacingDirection() 55 | { 56 | return obj.getFacingDirection(); 57 | } 58 | 59 | public SignType getType() 60 | { 61 | return this.type; 62 | } 63 | 64 | public void saveToConfig(ConfigurationSection configSection) 65 | { 66 | if(configSection != null) 67 | { 68 | configSection.set("isSignPost", this.isSignPost()); 69 | //ConfigManager.saveLocation(this.getLocation(), configSection.createSection("Location")); 70 | getLocation().saveToConfig(configSection.createSection("Location")); 71 | configSection.set("FacingDirection", this.getFacingDirection().name()); 72 | String data; 73 | if(this.getType().equals(SignType.Brewing)) 74 | data = "Brewing"; 75 | else if(this.getType().equals(SignType.Weapon)) 76 | data = "Weapon"; 77 | else 78 | data = "Team-"+this.getType().getTeam().getName(); 79 | configSection.set("Data", data); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniMap/FacingObject.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniMap; 2 | 3 | import org.bukkit.block.BlockFace; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | 6 | import com.gmail.nuclearcat1337.anniPro.utils.Loc; 7 | 8 | public final class FacingObject 9 | { 10 | private final BlockFace facing; 11 | private final Loc location; 12 | public FacingObject(BlockFace facingDirection, Loc location) 13 | { 14 | this.facing = facingDirection; 15 | this.location = location; 16 | } 17 | 18 | public BlockFace getFacingDirection() 19 | { 20 | return facing; 21 | } 22 | 23 | public Loc getLocation() 24 | { 25 | return location; 26 | } 27 | 28 | public void saveToConfig(ConfigurationSection configSection) 29 | { 30 | if(configSection != null) 31 | { 32 | configSection.set("FacingDirection", facing.name()); 33 | location.saveToConfig(configSection.createSection("Location")); 34 | //ConfigManager.saveLocation(location, configSection.createSection("Location")); 35 | } 36 | } 37 | 38 | public static FacingObject loadFromConfig(ConfigurationSection configSection) 39 | { 40 | if(configSection != null) 41 | { 42 | //Location loc = ConfigManager.getLocation(configSection.getConfigurationSection("Location")); 43 | Loc loc = new Loc(configSection.getConfigurationSection("Location")); 44 | BlockFace facing = BlockFace.valueOf(configSection.getString("FacingDirection")); 45 | return new FacingObject(facing,loc); 46 | } 47 | return null; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniMap/LobbyMap.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniMap; 2 | 3 | import java.io.File; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.configuration.ConfigurationSection; 7 | import org.bukkit.entity.Player; 8 | 9 | import com.gmail.nuclearcat1337.anniPro.anniGame.GameVars; 10 | import com.gmail.nuclearcat1337.anniPro.kits.CustomItem; 11 | import com.gmail.nuclearcat1337.anniPro.main.AnnihilationMain; 12 | import com.gmail.nuclearcat1337.anniPro.utils.Loc; 13 | 14 | public class LobbyMap extends AnniMap 15 | { 16 | private Location spawn; 17 | 18 | public LobbyMap(Location spawn) 19 | { 20 | super(spawn.getWorld().getName(),new File(AnnihilationMain.getInstance().getDataFolder(),"AnniLobbyConfig.yml")); 21 | this.spawn = spawn; 22 | } 23 | 24 | public LobbyMap(File configFile) 25 | { 26 | super(null,configFile); 27 | // spawn = ConfigManager.getLocation(configSection.getConfigurationSection("SpawnLocation")); 28 | } 29 | 30 | public Location getSpawn() 31 | { 32 | return spawn; 33 | } 34 | 35 | public void setSpawn(Location newSpawn) 36 | { 37 | this.spawn = newSpawn; 38 | super.setWorldName(newSpawn.getWorld().getName()); 39 | } 40 | 41 | public void sendToSpawn(final Player player) 42 | { 43 | if(spawn != null && player != null) 44 | { 45 | player.getInventory().clear(); 46 | player.getInventory().setArmorContents(null); 47 | player.setHealth(player.getMaxHealth()); 48 | player.setFoodLevel(20); 49 | player.setGameMode(GameVars.getDefaultGamemode()); 50 | player.getInventory().addItem(CustomItem.KITMAP.toItemStack()); 51 | player.getInventory().addItem(CustomItem.TEAMMAP.toItemStack()); 52 | if(GameVars.getVoting()) 53 | player.getInventory().addItem(CustomItem.VOTEMAP.toItemStack()); 54 | player.teleport(getSpawn()); 55 | } 56 | } 57 | 58 | @Override 59 | protected void loadFromConfig(ConfigurationSection section) 60 | { 61 | if(section != null && section.isConfigurationSection("SpawnLocation")) 62 | { 63 | spawn = new Loc(section.getConfigurationSection("SpawnLocation")).toLocation(); 64 | super.setWorldName(spawn.getWorld().getName()); 65 | } 66 | } 67 | 68 | @Override 69 | protected void saveToConfig(ConfigurationSection section) 70 | { 71 | if(this.getSpawn() != null && section != null) 72 | new Loc(this.getSpawn(),true).saveToConfig(section.createSection("SpawnLocation")); 73 | //super.saveConfig(); 74 | } 75 | 76 | // public void saveToConfig(ConfigurationSection configSection) 77 | // { 78 | // if(configSection != null) 79 | // { 80 | // super.saveToConfig(configSection); 81 | // //ConfigManager.saveLocation(this.getSpawn(), configSection.createSection("SpawnLocation")); 82 | // 83 | // } 84 | // } 85 | } 86 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniMap/RegeneratingBlock.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniMap; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import org.bukkit.Material; 6 | import org.bukkit.configuration.ConfigurationSection; 7 | 8 | public class RegeneratingBlock 9 | { 10 | public RegeneratingBlock(Material Type, int MaterialData, boolean Regenerate, boolean CobbleReplace, boolean NaturalBreak, int Time, 11 | TimeUnit Unit, int XP, Material Product, String Amount, int ProductData, String Effect) 12 | { 13 | this.Type = Type; 14 | this.Regenerate = Regenerate; 15 | this.CobbleReplace = CobbleReplace; 16 | this.NaturalBreak = NaturalBreak; 17 | this.Time = Time; 18 | this.Unit = Unit; 19 | this.XP = XP; 20 | this.Product = Product; 21 | this.Amount = Amount; 22 | this.MaterialData = MaterialData; 23 | this.Effect = Effect; 24 | this.ProductData = ProductData; 25 | } 26 | 27 | public final Material Type; 28 | public final int MaterialData; 29 | public final boolean Regenerate; 30 | public final boolean CobbleReplace; 31 | public final boolean NaturalBreak; 32 | public final int Time; 33 | public final TimeUnit Unit; 34 | public final int XP; 35 | public final Material Product; 36 | public final String Amount; 37 | public final int ProductData; 38 | public final String Effect; 39 | 40 | public void saveToConfig(ConfigurationSection configSection) 41 | { 42 | if(configSection != null) 43 | { 44 | configSection.set("Type", Type.name()); 45 | configSection.set("MaterialData", MaterialData); 46 | configSection.set("Regenerate", Regenerate); 47 | configSection.set("CobbleReplace", CobbleReplace); 48 | configSection.set("NaturalBreak", NaturalBreak); 49 | configSection.set("Time", Time); 50 | configSection.set("Unit", Unit != null ? Unit.name() : ""); 51 | configSection.set("XP", XP); 52 | configSection.set("Product", Product != null ? Product.name() : ""); 53 | configSection.set("Amount", Amount); 54 | configSection.set("ProductData", ProductData); 55 | configSection.set("Effect", Effect); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/anniMap/SignType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.anniMap; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniTeam; 4 | 5 | public final class SignType 6 | { 7 | public static SignType Weapon = new SignType((byte)1,null); 8 | public static SignType Brewing = new SignType((byte)2,null); 9 | public static SignType Team = new SignType((byte)3,null); 10 | 11 | public static SignType newTeamSign(AnniTeam team) 12 | { 13 | return new SignType((byte)3,team); 14 | } 15 | 16 | private byte ID; 17 | private AnniTeam team; 18 | private SignType(byte ID, AnniTeam team) 19 | { 20 | this.ID = ID; 21 | this.team = team; 22 | } 23 | 24 | public AnniTeam getTeam() 25 | { 26 | return this.team; 27 | } 28 | 29 | @Override 30 | public int hashCode() 31 | { 32 | final int prime = 31; 33 | int result = 1; 34 | result = prime * result + ID; 35 | return result; 36 | } 37 | 38 | @Override 39 | public boolean equals(Object obj) 40 | { 41 | if (this == obj) 42 | return true; 43 | if (obj == null) 44 | return false; 45 | if (getClass() != obj.getClass()) 46 | return false; 47 | SignType other = (SignType) obj; 48 | if (ID != other.ID) 49 | return false; 50 | return true; 51 | } 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/announcementBar/Announcement.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.announcementBar; 2 | 3 | public final class Announcement 4 | { 5 | private String message; 6 | private Runnable callBack; 7 | private int time; 8 | private boolean permanent; 9 | 10 | public Announcement(String message) 11 | { 12 | this.message = message; 13 | permanent = true; 14 | callBack = null; 15 | } 16 | 17 | public String getMessage() 18 | { 19 | return message; 20 | } 21 | 22 | public Announcement setMessage(String str) 23 | { 24 | this.message = str; 25 | return this; 26 | } 27 | 28 | public Announcement setTime(int time) 29 | { 30 | this.time = time; 31 | if(this.time > 0) 32 | permanent = false; 33 | return this; 34 | } 35 | 36 | public Announcement setPermanent(boolean permanent) 37 | { 38 | this.permanent = permanent; 39 | if(permanent) 40 | time = 0; 41 | return this; 42 | } 43 | 44 | public Announcement setCallback(Runnable callBack) 45 | { 46 | this.callBack = callBack; 47 | return this; 48 | } 49 | 50 | public Runnable getCallBack() 51 | { 52 | return callBack; 53 | } 54 | 55 | public boolean isPermanent() 56 | { 57 | return permanent; 58 | } 59 | 60 | public int getTime() 61 | { 62 | return time; 63 | } 64 | 65 | public void destroy() 66 | { 67 | message = null; 68 | callBack = null; 69 | } 70 | 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/announcementBar/Bar.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.announcementBar; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public interface Bar 6 | { 7 | void sendToPlayer(Player player, String message, float percentOfTotal); 8 | } 9 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/announcementBar/FakeBar.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.announcementBar; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.UUID; 8 | 9 | class FakeBar implements Bar 10 | { 11 | //This bar should tell the player that the server is using an unsuported version, but also send the phase message 12 | private Map timers; 13 | public FakeBar() 14 | { 15 | timers = new HashMap<>(); 16 | } 17 | 18 | @Override 19 | public void sendToPlayer(final Player player, final String message, final float percentOfTotal) 20 | { 21 | Long l = timers.get(player.getUniqueId()); 22 | if(l == null || System.currentTimeMillis() >= l.longValue()) 23 | { 24 | player.sendMessage("This server is using an unsupported version for the phase bar!"); 25 | player.sendMessage(message); 26 | timers.put(player.getUniqueId(),System.currentTimeMillis()+(20*1000)); //Send them the message every 20 seconds 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/announcementBar/TempData.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.announcementBar; 2 | 3 | public class TempData 4 | { 5 | public Announcement announcement; 6 | public long timeLeft; 7 | } 8 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/announcementBar/versions/v1_7_R4/PacketPlayOutActionBar.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.announcementBar.versions.v1_7_R4; 2 | 3 | import java.io.IOException; 4 | 5 | import net.minecraft.server.v1_7_R4.*; 6 | 7 | import net.md_5.bungee.api.chat.BaseComponent; 8 | import net.md_5.bungee.api.chat.TextComponent; 9 | import net.md_5.bungee.chat.ComponentSerializer; 10 | 11 | import org.bukkit.Bukkit; 12 | import org.bukkit.ChatColor; 13 | import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; 14 | import org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage; 15 | import org.bukkit.entity.Player; 16 | 17 | import java.io.IOException; 18 | 19 | class PacketPlayOutActionBar extends PacketPlayOutChat 20 | { 21 | public String json; 22 | 23 | /** 24 | * Creates an action bar message 25 | * @param message The message to display 26 | */ 27 | public PacketPlayOutActionBar(String message) 28 | { 29 | super(); 30 | this.json = "{\"text\":\""+message+"\"}"; 31 | } 32 | 33 | /** 34 | * When using md_5's chat API 35 | * @param components Components of which the chat consists of 36 | * @deprecated Doesn't support colours and formatting 37 | */ 38 | @Deprecated 39 | public PacketPlayOutActionBar(BaseComponent...components) 40 | { 41 | super(); 42 | this.json = ComponentSerializer.toString(components); 43 | } 44 | 45 | public void a(PacketDataSerializer packetdataserializer) throws IOException 46 | { 47 | this.json = ChatSerializer.a(ChatSerializer.a(packetdataserializer.c(32767))); 48 | } 49 | 50 | public void b(PacketDataSerializer packetdataserializer) throws IOException 51 | { 52 | packetdataserializer.a(this.json); 53 | packetdataserializer.writeByte(0x2); 54 | } 55 | 56 | public void a(PacketPlayOutListener packetplayoutlistener) 57 | { 58 | packetplayoutlistener.a(this); 59 | } 60 | 61 | public String b() 62 | { 63 | return String.format("actionbar='%s'", new Object[] { this.json }); 64 | } 65 | 66 | public void handle(PacketListener packetlistener) 67 | { 68 | a((PacketPlayOutListener)packetlistener); 69 | } 70 | 71 | // Added some helper methods 72 | public void send(Player player) 73 | { 74 | if(((CraftPlayer)player).getHandle().playerConnection.networkManager.getVersion() < 47) 75 | return; 76 | 77 | ((CraftPlayer)player).getHandle().playerConnection.sendPacket(this); 78 | } 79 | 80 | public void broadcast() 81 | { 82 | for(Player player : Bukkit.getOnlinePlayers()) 83 | { 84 | send(player); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/announcementBar/versions/v1_7_R4/ProxyHashBiMap.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.announcementBar.versions.v1_7_R4; 2 | 3 | import java.util.HashMap; 4 | import java.util.Set; 5 | import net.minecraft.server.v1_7_R4.PacketPlayOutChat; 6 | import net.minecraft.util.com.google.common.collect.BiMap; 7 | import net.minecraft.util.com.google.common.collect.HashBiMap; 8 | 9 | import javax.annotation.Nullable; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | import java.util.Set; 13 | 14 | class ProxyHashBiMap implements BiMap 15 | { 16 | 17 | private BiMap delegate; 18 | 19 | private ProxyHashBiMap inverse; 20 | 21 | // This will proxy 22 | protected Map proxy = new HashMap(1); 23 | 24 | public ProxyHashBiMap(BiMap map) 25 | { 26 | this.delegate = map; 27 | this.inverse = new Inverse(this, map.inverse(), map); 28 | } 29 | 30 | private ProxyHashBiMap(BiMap map, BiMap inversed) 31 | { 32 | this.delegate = map; 33 | this.inverse = null; 34 | } 35 | 36 | @Override 37 | public int size() 38 | { 39 | return this.delegate.size(); 40 | } 41 | 42 | @Override 43 | public boolean isEmpty() 44 | { 45 | return this.delegate.isEmpty(); 46 | } 47 | 48 | @Override 49 | public boolean containsKey(Object key) 50 | { 51 | return this.delegate.containsKey(key); 52 | } 53 | 54 | @Override 55 | public boolean containsValue(Object value) 56 | { 57 | return this.delegate.containsValue(value); 58 | } 59 | 60 | @Override 61 | public V get(Object key) 62 | { 63 | Object okey = null; 64 | if((okey = this.proxy.get(key)) != null) 65 | key = okey; 66 | return this.delegate.get(key); 67 | } 68 | 69 | @Override 70 | public V put(@Nullable K k, @Nullable V v) 71 | { 72 | return this.delegate.put(k, v); 73 | } 74 | 75 | @Override 76 | public V remove(Object key) 77 | { 78 | return this.delegate.remove(key); 79 | } 80 | 81 | @Override 82 | public V forcePut(@Nullable K k, @Nullable V v) 83 | { 84 | return this.delegate.forcePut(k, v); 85 | } 86 | 87 | @Override 88 | public void putAll(Map map) 89 | { 90 | this.delegate.clear(); 91 | } 92 | 93 | @Override 94 | public void clear() 95 | { 96 | this.delegate.clear(); 97 | } 98 | 99 | @Override 100 | public Set keySet() 101 | { 102 | return this.delegate.keySet(); 103 | } 104 | 105 | @Override 106 | public Set values() 107 | { 108 | return this.delegate.values(); 109 | } 110 | 111 | @Override 112 | public Set> entrySet() 113 | { 114 | return this.delegate.entrySet(); 115 | } 116 | 117 | @Override 118 | public ProxyHashBiMap inverse() 119 | { 120 | return this.inverse; 121 | } 122 | 123 | public void injectSpecial(K key, K okey) 124 | { 125 | this.proxy.put(key, okey); 126 | } 127 | 128 | public void ejectSpecial(K key) 129 | { 130 | this.proxy.remove(key); 131 | } 132 | 133 | private class Inverse extends ProxyHashBiMap 134 | { 135 | private ProxyHashBiMap original; 136 | 137 | private Inverse(ProxyHashBiMap original, BiMap forward, BiMap backward) 138 | { 139 | super(forward, backward); 140 | this.original = original; 141 | } 142 | 143 | /** 144 | * Prevent creation of more Maps, just return the original 145 | * @return the original BiMap 146 | */ 147 | @Override 148 | public ProxyHashBiMap inverse() 149 | { 150 | return this.original; 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/announcementBar/versions/v1_8_R1/Bar.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.announcementBar.versions.v1_8_R1; 2 | 3 | import net.minecraft.server.v1_8_R1.ChatSerializer; 4 | import net.minecraft.server.v1_8_R1.IChatBaseComponent; 5 | import net.minecraft.server.v1_8_R1.PacketPlayOutChat; 6 | import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; 7 | import org.bukkit.entity.Player; 8 | 9 | public class Bar implements com.gmail.nuclearcat1337.anniPro.announcementBar.Bar 10 | { 11 | @Override 12 | public void sendToPlayer(final Player player, final String message, final float percentOfTotal) 13 | { 14 | IChatBaseComponent actionComponent = ChatSerializer.a("{\"text\":\"" + cleanMessage(message) + "\"}"); 15 | PacketPlayOutChat actionPacket = new PacketPlayOutChat(actionComponent, (byte) 2); 16 | ((CraftPlayer) player).getHandle().playerConnection.sendPacket(actionPacket); 17 | } 18 | 19 | private static String cleanMessage(String message) 20 | { 21 | if (message.length() > 64) 22 | message = message.substring(0, 63); 23 | 24 | return message; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/announcementBar/versions/v1_8_R2/Bar.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.announcementBar.versions.v1_8_R2; 2 | 3 | import net.minecraft.server.v1_8_R2.IChatBaseComponent; 4 | import net.minecraft.server.v1_8_R2.IChatBaseComponent.ChatSerializer; 5 | import net.minecraft.server.v1_8_R2.PacketPlayOutChat; 6 | import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; 7 | import org.bukkit.entity.Player; 8 | 9 | public class Bar implements com.gmail.nuclearcat1337.anniPro.announcementBar.Bar 10 | { 11 | @Override 12 | public void sendToPlayer(final Player player, final String message, final float percentOfTotal) 13 | { 14 | IChatBaseComponent actionComponent = ChatSerializer.a("{\"text\":\"" + cleanMessage(message) + "\"}"); 15 | PacketPlayOutChat actionPacket = new PacketPlayOutChat(actionComponent, (byte) 2); 16 | ((CraftPlayer) player).getHandle().playerConnection.sendPacket(actionPacket); 17 | } 18 | 19 | private static String cleanMessage(String message) 20 | { 21 | if (message.length() > 64) 22 | message = message.substring(0, 63); 23 | 24 | return message; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/api/EnderFurnace.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.api; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.*; 4 | import com.gmail.nuclearcat1337.anniPro.utils.VersionUtils; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.WorldCreator; 7 | import org.bukkit.entity.Player; 8 | 9 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 10 | 11 | import java.lang.reflect.Constructor; 12 | import java.lang.reflect.InvocationTargetException; 13 | 14 | public final class EnderFurnace 15 | { 16 | private static FurnaceCreator creator; 17 | 18 | private EnderFurnace() 19 | {} 20 | 21 | 22 | public static FurnaceCreator getCreator() 23 | { 24 | if(creator == null) 25 | { 26 | String version = VersionUtils.getVersion(); 27 | String name = "com.gmail.nuclearcat1337.anniPro.enderFurnace.versions."+version+".FurnaceCreator"; 28 | //Bukkit.getLogger().info(name); 29 | Class rawClass = null; 30 | try 31 | { 32 | rawClass = Class.forName(name); 33 | Class furnaceClass = rawClass.asSubclass(FurnaceCreator.class); 34 | Constructor constructor = furnaceClass.getConstructor(); 35 | creator = constructor.newInstance(); 36 | } 37 | catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) 38 | { 39 | //Bukkit.getLogger().info("This happened :("); 40 | creator = new TempCreator(); 41 | } 42 | } 43 | return creator; 44 | } 45 | 46 | public static FurnaceData getFurnaceData(AnniPlayer player) 47 | { 48 | Object obj = player.getData("ED"); 49 | if(obj == null) 50 | return null; 51 | return (FurnaceData)obj; 52 | } 53 | 54 | private static class TempCreator implements FurnaceCreator 55 | { 56 | @Override 57 | public IFurnace createFurnace(final AnniPlayer player) 58 | { 59 | return new TempFurnace(player); 60 | } 61 | 62 | private class TempFurnace implements IFurnace 63 | { 64 | private final String version; 65 | private final AnniPlayer p; 66 | public TempFurnace(AnniPlayer p) 67 | { 68 | this.p = p; 69 | version = VersionUtils.getVersion(); 70 | } 71 | 72 | @Override 73 | public void tick() {} 74 | 75 | @Override 76 | public void open() { p.sendMessage("Sorry, this server is using an unsupported version for Ender Furnaces. Version: "+version); } 77 | 78 | @Override 79 | public FurnaceData getFurnaceData() 80 | { 81 | return null; 82 | } 83 | 84 | @Override 85 | public void load(final FurnaceData data) {} 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/api/FurnaceCreator.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.api; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 4 | 5 | public interface FurnaceCreator 6 | { 7 | IFurnace createFurnace(AnniPlayer player); 8 | } 9 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/api/IFurnace.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.api; 2 | 3 | public interface IFurnace 4 | { 5 | void tick(); 6 | 7 | void open(); 8 | 9 | FurnaceData getFurnaceData(); 10 | 11 | void load(FurnaceData data); 12 | } 13 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/api/ReflectionUtil.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.api; 2 | 3 | import java.lang.reflect.Field; 4 | 5 | public class ReflectionUtil 6 | { 7 | public static void setSuperValue(Object instance, String fieldName, 8 | Object value) throws Exception 9 | { 10 | Field field = instance.getClass().getSuperclass() 11 | .getDeclaredField(fieldName); 12 | field.setAccessible(true); 13 | field.set(instance, value); 14 | } 15 | 16 | public static void setValue(Object instance, String fieldName, Object value) 17 | throws Exception 18 | { 19 | Field field = instance.getClass().getDeclaredField(fieldName); 20 | field.setAccessible(true); 21 | field.set(instance, value); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/versions/v1_7_R3/FurnaceCreator.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.versions.v1_7_R3; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 4 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.api.EnderFurnace; 5 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.api.IFurnace; 6 | 7 | public class FurnaceCreator implements com.gmail.nuclearcat1337.anniPro.enderFurnace.api.FurnaceCreator 8 | { 9 | @Override 10 | public IFurnace createFurnace(final AnniPlayer player) 11 | { 12 | IFurnace f = new Furnace_V1_7_R3(player.getPlayer()); 13 | if(EnderFurnace.getFurnaceData(player) != null) 14 | f.load(EnderFurnace.getFurnaceData(player)); 15 | return f; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/versions/v1_7_R3/FurnaceData.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.versions.v1_7_R3; 2 | 3 | import net.minecraft.server.v1_7_R3.TileEntityFurnace; 4 | 5 | class FurnaceData extends com.gmail.nuclearcat1337.anniPro.enderFurnace.api.FurnaceData 6 | { 7 | public FurnaceData(TileEntityFurnace furnace) 8 | { 9 | super(asBukkitCopy(furnace.getContents()),furnace.burnTime,furnace.ticksForCurrentFuel,furnace.cookTime); 10 | } 11 | 12 | private static org.bukkit.inventory.ItemStack[] asBukkitCopy(net.minecraft.server.v1_7_R3.ItemStack[] stacks) 13 | { 14 | org.bukkit.inventory.ItemStack[] items = new org.bukkit.inventory.ItemStack[stacks.length]; 15 | for(int i = 0; i < items.length; i++) 16 | { 17 | items[i] = org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack.asBukkitCopy(stacks[i]); 18 | } 19 | return items; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/versions/v1_7_R4/FurnaceCreator.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.versions.v1_7_R4; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 4 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.api.EnderFurnace; 5 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.api.IFurnace; 6 | 7 | public class FurnaceCreator implements com.gmail.nuclearcat1337.anniPro.enderFurnace.api.FurnaceCreator 8 | { 9 | @Override 10 | public IFurnace createFurnace(final AnniPlayer player) 11 | { 12 | IFurnace f = new Furnace_V1_7_R4(player.getPlayer()); 13 | if(EnderFurnace.getFurnaceData(player) != null) 14 | f.load(EnderFurnace.getFurnaceData(player)); 15 | return f; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/versions/v1_7_R4/FurnaceData.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.versions.v1_7_R4; 2 | 3 | import net.minecraft.server.v1_7_R4.TileEntityFurnace; 4 | 5 | class FurnaceData extends com.gmail.nuclearcat1337.anniPro.enderFurnace.api.FurnaceData 6 | { 7 | public FurnaceData(TileEntityFurnace furnace) 8 | { 9 | super(asBukkitCopy(furnace.getContents()),furnace.burnTime,furnace.ticksForCurrentFuel,furnace.cookTime); 10 | } 11 | 12 | private static org.bukkit.inventory.ItemStack[] asBukkitCopy(net.minecraft.server.v1_7_R4.ItemStack[] stacks) 13 | { 14 | org.bukkit.inventory.ItemStack[] items = new org.bukkit.inventory.ItemStack[stacks.length]; 15 | for(int i = 0; i < items.length; i++) 16 | { 17 | items[i] = org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack.asBukkitCopy(stacks[i]); 18 | } 19 | return items; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/versions/v1_7_R4/Furnace_V1_7_R4.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.versions.v1_7_R4; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.api.IFurnace; 4 | import net.minecraft.server.v1_7_R4.Block; 5 | import net.minecraft.server.v1_7_R4.Blocks; 6 | import net.minecraft.server.v1_7_R4.EntityHuman; 7 | import net.minecraft.server.v1_7_R4.EntityPlayer; 8 | import net.minecraft.server.v1_7_R4.TileEntityFurnace; 9 | 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.InventoryHolder; 12 | import org.bukkit.inventory.ItemStack; 13 | import org.bukkit.block.Furnace; 14 | import org.bukkit.craftbukkit.v1_7_R4.block.CraftFurnace; 15 | import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; 16 | import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; 17 | 18 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.api.ReflectionUtil; 19 | 20 | class Furnace_V1_7_R4 extends TileEntityFurnace implements IFurnace 21 | { 22 | private EntityPlayer owningPlayer; 23 | 24 | public Furnace_V1_7_R4(Player p) 25 | { 26 | EntityPlayer player = ((CraftPlayer) p).getHandle(); 27 | this.owningPlayer = player; 28 | this.world = player.world; 29 | try 30 | { 31 | ReflectionUtil.setSuperValue(this, "o", "Ender Furnace"); 32 | } 33 | catch (Exception e) 34 | { 35 | e.printStackTrace(); 36 | } 37 | } 38 | 39 | @Override 40 | public boolean a(EntityHuman entityhuman) 41 | { 42 | return true; 43 | } 44 | 45 | @Override 46 | public int p() 47 | { 48 | return 0; 49 | } 50 | 51 | @Override 52 | public Block q() 53 | { 54 | return Blocks.FURNACE; 55 | } 56 | 57 | @Override 58 | public InventoryHolder getOwner() 59 | { 60 | // int x = 0; 61 | // org.bukkit.block.Block b = this.world.getWorld().getBlockAt(x, 0, 0); 62 | // while(b != null && b.getType() != Material.AIR) 63 | // b = this.world.getWorld().getBlockAt(++x,0,0); 64 | // Furnace furnace = new CraftFurnace(b); 65 | Furnace furnace = new CraftFurnace(this.world.getWorld().getBlockAt(0, 0, 0)); 66 | try 67 | { 68 | ReflectionUtil.setValue(furnace, "furnace", this); 69 | } 70 | catch (Exception e) 71 | { 72 | e.printStackTrace(); 73 | } 74 | return furnace; 75 | } 76 | 77 | @Override 78 | public void open() 79 | { 80 | //Bukkit.getLogger().info("Owning players name is "+this.owningPlayer.getName()); 81 | this.owningPlayer.openFurnace(this); 82 | } 83 | 84 | @Override 85 | public void tick() 86 | { 87 | h(); 88 | } 89 | 90 | public void setItemStack(int i, ItemStack itemstack) 91 | { 92 | setItem(i, CraftItemStack.asNMSCopy(itemstack)); 93 | } 94 | 95 | public ItemStack getItemStack(int i) 96 | { 97 | return CraftItemStack.asBukkitCopy(getItem(i)); 98 | } 99 | 100 | @Override 101 | public FurnaceData getFurnaceData() 102 | { 103 | return new FurnaceData(this); 104 | } 105 | 106 | @Override 107 | public void load(final com.gmail.nuclearcat1337.anniPro.enderFurnace.api.FurnaceData data) 108 | { 109 | ItemStack[] items = data.getItems(); 110 | for(int x = 0; x < 3; x++) 111 | this.setItem(x, org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack.asNMSCopy(items[x])); 112 | this.burnTime = data.getBurnTime(); 113 | this.ticksForCurrentFuel = data.getTicksForCurrentFuel(); 114 | this.cookTime = data.getCookTime(); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/versions/v1_8_R1/FurnaceCreator.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.versions.v1_8_R1; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 4 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.api.EnderFurnace; 5 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.api.IFurnace; 6 | 7 | public class FurnaceCreator implements com.gmail.nuclearcat1337.anniPro.enderFurnace.api.FurnaceCreator 8 | { 9 | @Override 10 | public IFurnace createFurnace(final AnniPlayer player) 11 | { 12 | IFurnace f = new Furnace_V1_8_R1(player.getPlayer()); 13 | if(EnderFurnace.getFurnaceData(player) != null) 14 | f.load(EnderFurnace.getFurnaceData(player)); 15 | return f; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/versions/v1_8_R1/FurnaceData.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.versions.v1_8_R1; 2 | 3 | import net.minecraft.server.v1_8_R1.TileEntityFurnace; 4 | 5 | class FurnaceData extends com.gmail.nuclearcat1337.anniPro.enderFurnace.api.FurnaceData 6 | { 7 | public FurnaceData(TileEntityFurnace furnace) 8 | { 9 | super(asBukkitCopy(furnace.getContents()),furnace.getProperty(0),furnace.getProperty(1),furnace.getProperty(2)); 10 | } 11 | 12 | private static org.bukkit.inventory.ItemStack[] asBukkitCopy(net.minecraft.server.v1_8_R1.ItemStack[] stacks) 13 | { 14 | org.bukkit.inventory.ItemStack[] items = new org.bukkit.inventory.ItemStack[stacks.length]; 15 | for(int i = 0; i < items.length; i++) 16 | { 17 | items[i] = org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack.asBukkitCopy(stacks[i]); 18 | } 19 | return items; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/versions/v1_8_R2/FurnaceCreator.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.versions.v1_8_R2; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 4 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.api.EnderFurnace; 5 | import com.gmail.nuclearcat1337.anniPro.enderFurnace.api.IFurnace; 6 | 7 | public class FurnaceCreator implements com.gmail.nuclearcat1337.anniPro.enderFurnace.api.FurnaceCreator 8 | { 9 | @Override 10 | public IFurnace createFurnace(final AnniPlayer player) 11 | { 12 | IFurnace f = new Furnace_v1_8_R2(player.getPlayer()); 13 | if(EnderFurnace.getFurnaceData(player) != null) 14 | f.load(EnderFurnace.getFurnaceData(player)); 15 | return f; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/enderFurnace/versions/v1_8_R2/FurnaceData.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.enderFurnace.versions.v1_8_R2; 2 | 3 | import net.minecraft.server.v1_8_R2.TileEntityFurnace; 4 | 5 | class FurnaceData extends com.gmail.nuclearcat1337.anniPro.enderFurnace.api.FurnaceData 6 | { 7 | public FurnaceData(TileEntityFurnace furnace) 8 | { 9 | super(asBukkitCopy(furnace.getContents()),furnace.getProperty(0),furnace.getProperty(1),furnace.getProperty(2)); 10 | } 11 | 12 | private static org.bukkit.inventory.ItemStack[] asBukkitCopy(net.minecraft.server.v1_8_R2.ItemStack[] stacks) 13 | { 14 | org.bukkit.inventory.ItemStack[] items = new org.bukkit.inventory.ItemStack[stacks.length]; 15 | for(int i = 0; i < items.length; i++) 16 | { 17 | items[i] = org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack.asBukkitCopy(stacks[i]); 18 | } 19 | return items; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/ActionMenuItem.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | public class ActionMenuItem extends MenuItem 6 | { 7 | private ItemClickHandler handler; 8 | 9 | public ActionMenuItem(String displayName, ItemClickHandler handler, ItemStack icon, String... lore) 10 | { 11 | super(displayName, icon, lore); 12 | this.handler = handler; 13 | } 14 | 15 | @Override 16 | public void onItemClick(ItemClickEvent event) 17 | { 18 | handler.onItemClick(event); 19 | } 20 | 21 | public ItemClickHandler getHandler() 22 | { 23 | return this.handler; 24 | } 25 | 26 | public void setHandler(ItemClickHandler handler) 27 | { 28 | this.handler = handler; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/BackMenuItem.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 2 | 3 | import org.bukkit.ChatColor; 4 | import org.bukkit.Material; 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | /** 8 | * A {@link com.gmail.nuclearcat1337.anniPro.itemMenus.StaticMenuItem} that opens the 9 | * {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu}'s parent menu if it exists. 10 | */ 11 | public class BackMenuItem extends StaticMenuItem 12 | { 13 | 14 | public BackMenuItem() 15 | { 16 | super(ChatColor.RED + "Back", new ItemStack(Material.FENCE_GATE)); 17 | } 18 | 19 | @Override 20 | public void onItemClick(ItemClickEvent event) 21 | { 22 | event.setWillGoBack(true); 23 | } 24 | } -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/CloseMenuItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AmpMenus. 3 | * 4 | * Copyright (c) 2014 5 | * 6 | * AmpMenus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AmpMenus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with AmpMenus. If not, see . 18 | */ 19 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 20 | 21 | import org.bukkit.ChatColor; 22 | import org.bukkit.Material; 23 | import org.bukkit.inventory.ItemStack; 24 | 25 | /** 26 | * A {@link com.gmail.nuclearcat1337.anniPro.itemMenus.StaticMenuItem} that closes the 27 | * {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu}. 28 | */ 29 | public class CloseMenuItem extends StaticMenuItem 30 | { 31 | 32 | public CloseMenuItem() 33 | { 34 | super(ChatColor.RED + "Close", new ItemStack(Material.RECORD_4)); 35 | } 36 | 37 | @Override 38 | public void onItemClick(ItemClickEvent event) 39 | { 40 | event.setWillClose(true); 41 | } 42 | } -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/ComboMenuItem.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | public class ComboMenuItem extends SubMenuItem 6 | { 7 | private ItemClickHandler handler; 8 | public ComboMenuItem(String displayName, ItemMenu menu, ItemClickHandler handler, ItemStack icon, String... lore) 9 | { 10 | super(displayName, menu, icon, lore); 11 | this.handler = handler; 12 | } 13 | 14 | @Override 15 | public void onItemClick(ItemClickEvent event) 16 | { 17 | if(handler != null) 18 | handler.onItemClick(event); 19 | super.onItemClick(event); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/ItemClickEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.inventory.ClickType; 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | /** 8 | * An event called when an Item in the 9 | * {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} is clicked. 10 | */ 11 | public class ItemClickEvent 12 | { 13 | private Player player; 14 | private ClickType clicktype; 15 | private boolean goBack = false; 16 | private boolean close = false; 17 | private boolean update = false; 18 | private ItemStack stack; 19 | 20 | public ItemClickEvent(Player player,ItemStack stack, ClickType type) 21 | { 22 | this.player = player; 23 | this.stack = stack; 24 | this.clicktype = type; 25 | } 26 | 27 | /** 28 | * Gets the player who clicked. 29 | * 30 | * @return The player who clicked. 31 | */ 32 | public Player getPlayer() 33 | { 34 | return player; 35 | } 36 | 37 | public ClickType getClickType() 38 | { 39 | return clicktype; 40 | } 41 | 42 | public ItemStack getClickedItem() 43 | { 44 | return stack; 45 | } 46 | 47 | /** 48 | * Checks if the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will go back 49 | * to the parent menu. 50 | * 51 | * @return True if the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will go 52 | * back to the parent menu, else false. 53 | */ 54 | public boolean willGoBack() 55 | { 56 | return goBack; 57 | } 58 | 59 | /** 60 | * Sets if the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will go back to 61 | * the parent menu. 62 | * 63 | * @param goBack 64 | * If the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will go 65 | * back to the parent menu. 66 | */ 67 | public void setWillGoBack(boolean goBack) 68 | { 69 | this.goBack = goBack; 70 | if (goBack) 71 | { 72 | close = false; 73 | update = false; 74 | } 75 | } 76 | 77 | /** 78 | * Checks if the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will close. 79 | * 80 | * @return True if the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will 81 | * close, else false. 82 | */ 83 | public boolean willClose() 84 | { 85 | return close; 86 | } 87 | 88 | /** 89 | * Sets if the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will close. 90 | * 91 | * @param close 92 | * If the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will 93 | * close. 94 | */ 95 | public void setWillClose(boolean close) 96 | { 97 | this.close = close; 98 | if (close) 99 | { 100 | goBack = false; 101 | update = false; 102 | } 103 | } 104 | 105 | /** 106 | * Checks if the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will update. 107 | * 108 | * @return True if the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will 109 | * update, else false. 110 | */ 111 | public boolean willUpdate() 112 | { 113 | return update; 114 | } 115 | 116 | /** 117 | * Sets if the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will update. 118 | * 119 | * @param update 120 | * If the {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemMenu} will 121 | * update. 122 | */ 123 | public void setWillUpdate(boolean update) 124 | { 125 | this.update = update; 126 | if (update) 127 | { 128 | goBack = false; 129 | close = false; 130 | } 131 | } 132 | } -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/ItemClickHandler.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 2 | 3 | public interface ItemClickHandler 4 | { 5 | void onItemClick(ItemClickEvent event); 6 | } 7 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/ItemMenuHolder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 2 | 3 | import org.bukkit.inventory.Inventory; 4 | import org.bukkit.inventory.InventoryHolder; 5 | 6 | /** 7 | * Allows you to set the {@link ninja.amp.ampmenus.menus.MenuItem} that created 8 | * the Inventory as the Inventory's holder. 9 | */ 10 | public class ItemMenuHolder implements InventoryHolder 11 | { 12 | private ItemMenu menu; 13 | private Inventory inventory; 14 | 15 | public ItemMenuHolder(ItemMenu menu, Inventory inventory) 16 | { 17 | this.menu = menu; 18 | this.inventory = inventory; 19 | } 20 | 21 | /** 22 | * Gets the {@link ninja.amp.ampmenus.menus.MenuItem} holding the Inventory. 23 | * 24 | * @return The {@link ninja.amp.ampmenus.menus.MenuItem} holding the 25 | * Inventory. 26 | */ 27 | public ItemMenu getMenu() 28 | { 29 | return menu; 30 | } 31 | 32 | @Override 33 | public Inventory getInventory() 34 | { 35 | return inventory; 36 | } 37 | } -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/ItemMenuListener.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.EventPriority; 7 | import org.bukkit.event.HandlerList; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.inventory.InventoryClickEvent; 10 | import org.bukkit.event.server.PluginDisableEvent; 11 | import org.bukkit.inventory.Inventory; 12 | import org.bukkit.plugin.Plugin; 13 | import org.bukkit.plugin.RegisteredListener; 14 | import org.bukkit.plugin.java.JavaPlugin; 15 | 16 | /** 17 | * Passes inventory click events to their menus for handling. 18 | */ 19 | public class ItemMenuListener implements Listener 20 | { 21 | private Plugin plugin = null; 22 | private static final ItemMenuListener INSTANCE = new ItemMenuListener(); 23 | 24 | private ItemMenuListener() 25 | { 26 | } 27 | 28 | /** 29 | * Gets the {@link ninja.amp.ampmenus.MenuListener} instance. 30 | * 31 | * @return The {@link ninja.amp.ampmenus.MenuListener} instance. 32 | */ 33 | public static ItemMenuListener getInstance() 34 | { 35 | return INSTANCE; 36 | } 37 | 38 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) 39 | public void onInventoryClick(InventoryClickEvent event) 40 | { 41 | if (event.getWhoClicked() instanceof Player && event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof ItemMenuHolder) 42 | { 43 | event.setCancelled(true); 44 | ((ItemMenuHolder) event.getInventory().getHolder()).getMenu() 45 | .onInventoryClick(event); 46 | } 47 | } 48 | 49 | /** 50 | * Registers the events of the {@link ninja.amp.ampmenus.MenuListener} to a 51 | * plugin. 52 | * 53 | * @param plugin 54 | * The plugin used to register the events. 55 | */ 56 | public void register(JavaPlugin plugin) 57 | { 58 | if (!isRegistered(plugin)) 59 | { 60 | plugin.getServer().getPluginManager() 61 | .registerEvents(INSTANCE, plugin); 62 | this.plugin = plugin; 63 | } 64 | } 65 | 66 | /** 67 | * Checks if the {@link ninja.amp.ampmenus.MenuListener} is registered to a 68 | * plugin. 69 | * 70 | * @param plugin 71 | * The plugin. 72 | * @return True if the {@link ninja.amp.ampmenus.MenuListener} is registered 73 | * to the plugin, else false. 74 | */ 75 | public boolean isRegistered(JavaPlugin plugin) 76 | { 77 | if (plugin.equals(this.plugin)) 78 | { 79 | for (RegisteredListener listener : HandlerList 80 | .getRegisteredListeners(plugin)) 81 | { 82 | if (listener.getListener().equals(INSTANCE)) 83 | { 84 | return true; 85 | } 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 92 | public void onPluginDisable(PluginDisableEvent event) 93 | { 94 | if (event.getPlugin().equals(plugin)) 95 | { 96 | closeOpenMenus(); 97 | plugin = null; 98 | } 99 | } 100 | 101 | /** 102 | * Closes all {@link ninja.amp.ampmenus.menus.ItemMenu}s currently open. 103 | */ 104 | public static void closeOpenMenus() 105 | { 106 | for (Player player : Bukkit.getOnlinePlayers()) 107 | { 108 | if (player.getOpenInventory() != null) 109 | { 110 | Inventory inventory = player.getOpenInventory() 111 | .getTopInventory(); 112 | if (inventory.getHolder() instanceof ItemMenuHolder) 113 | { 114 | player.closeInventory(); 115 | } 116 | } 117 | } 118 | } 119 | } -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/MenuItem.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.inventory.ItemStack; 5 | import org.bukkit.inventory.meta.ItemMeta; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * An Item inside an {@link com.gmail.nuclearcat1337.anniPro.itemMenus.MenuItem}. 12 | */ 13 | public class MenuItem 14 | { 15 | private String displayName; 16 | private ItemStack icon; 17 | private List lore; 18 | 19 | public MenuItem(String displayName, ItemStack icon, String... lore) 20 | { 21 | this.displayName = displayName; 22 | this.icon = icon; 23 | this.lore = new ArrayList(); 24 | for(String str : lore) 25 | this.lore.add(str); 26 | //Arrays.asList(lore); 27 | } 28 | 29 | /** 30 | * Gets the display name of the MenuItem. 31 | * 32 | * @return The display name. 33 | */ 34 | public String getDisplayName() 35 | { 36 | return displayName; 37 | } 38 | 39 | /** 40 | * Gets the icon of the MenuItem. 41 | * 42 | * @return The icon. 43 | */ 44 | public ItemStack getIcon() 45 | { 46 | return icon; 47 | } 48 | 49 | public void setIcon(ItemStack newIcon) 50 | { 51 | this.icon = newIcon; 52 | } 53 | 54 | public void setDisplayName(String name) 55 | { 56 | this.displayName = name; 57 | } 58 | 59 | /** 60 | * Gets the lore of the MenuItem. 61 | * 62 | * @return The lore. 63 | */ 64 | public List getLore() 65 | { 66 | return lore; 67 | } 68 | 69 | /** 70 | * Gets the ItemStack to be shown to the player. 71 | * 72 | * @param player 73 | * The player. 74 | * @return The final icon. 75 | */ 76 | public ItemStack getFinalIcon(Player player) 77 | { 78 | return setNameAndLore(getIcon().clone(), getDisplayName(), getLore()); 79 | } 80 | 81 | /** 82 | * Called when the MenuItem is clicked. 83 | * 84 | * @param event 85 | * The {@link com.gmail.nuclearcat1337.anniPro.itemMenus.ItemClickEvent}. 86 | */ 87 | public void onItemClick(ItemClickEvent event) 88 | { 89 | // Do nothing by default 90 | } 91 | 92 | /** 93 | * Sets the display name and lore of an ItemStack. 94 | * 95 | * @param itemStack 96 | * The ItemStack. 97 | * @param displayName 98 | * The display name. 99 | * @param lore 100 | * The lore. 101 | * @return The ItemStack. 102 | */ 103 | public static ItemStack setNameAndLore(ItemStack itemStack, 104 | String displayName, List lore) 105 | { 106 | ItemMeta meta = itemStack.getItemMeta(); 107 | meta.setDisplayName(displayName); 108 | meta.setLore(lore); 109 | itemStack.setItemMeta(meta); 110 | return itemStack; 111 | } 112 | } -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/StaticMenuItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of AmpMenus. 3 | * 4 | * Copyright (c) 2014 5 | * 6 | * AmpMenus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AmpMenus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with AmpMenus. If not, see . 18 | */ 19 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 20 | 21 | import org.bukkit.entity.Player; 22 | import org.bukkit.inventory.ItemStack; 23 | 24 | /** 25 | * A {@link ninja.amp.ampmenus.items.MenuItem} whose icon never changes. 26 | */ 27 | public class StaticMenuItem extends MenuItem 28 | { 29 | public StaticMenuItem(String displayName, ItemStack icon, String... lore) 30 | { 31 | super(displayName, icon, lore); 32 | setNameAndLore(getIcon(), getDisplayName(), getLore()); 33 | } 34 | 35 | @Override 36 | public ItemStack getFinalIcon(Player player) 37 | { 38 | return getIcon(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/itemMenus/SubMenuItem.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.itemMenus; 2 | 3 | import java.util.UUID; 4 | 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | import com.gmail.nuclearcat1337.anniPro.main.AnnihilationMain; 10 | 11 | /** 12 | * A {@link ninja.amp.ampmenus.items.MenuItem} that opens a sub 13 | * {@link ninja.amp.ampmenus.menus.ItemMenu}. 14 | */ 15 | public class SubMenuItem extends MenuItem 16 | { 17 | //private final JavaPlugin plugin; 18 | private final ItemMenu menu; 19 | 20 | public SubMenuItem(String displayName, ItemMenu menu, ItemStack icon, String... lore) 21 | { 22 | super(displayName, icon, lore); 23 | //this.plugin = plugin; 24 | this.menu = menu; 25 | } 26 | 27 | @Override 28 | public void onItemClick(ItemClickEvent event) 29 | { 30 | event.setWillClose(true); 31 | final UUID ID = event.getPlayer().getUniqueId(); 32 | Bukkit.getScheduler().scheduleSyncDelayedTask(AnnihilationMain.getInstance(), new Runnable() 33 | { 34 | public void run() 35 | { 36 | Player p = Bukkit.getPlayer(ID); 37 | if (p != null && menu != null) 38 | { 39 | menu.open(p); 40 | } 41 | } 42 | }, 3); 43 | } 44 | } -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/kits/AnniPlugin.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.kits; 2 | 3 | import org.bukkit.event.Listener; 4 | 5 | public abstract class AnniPlugin implements Listener 6 | { 7 | public abstract boolean onEnable(); 8 | } 9 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/kits/CivilianKit.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.kits; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Material; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | import com.gmail.nuclearcat1337.anniPro.anniEvents.AnniEvent; 9 | import com.gmail.nuclearcat1337.anniPro.main.AnnihilationMain; 10 | import com.gmail.nuclearcat1337.anniPro.main.Lang; 11 | 12 | public class CivilianKit extends Kit 13 | { 14 | public CivilianKit() 15 | { 16 | Bukkit.getPluginManager().registerEvents(this, AnnihilationMain.getInstance()); 17 | //AnniEvent.registerListener(this); 18 | this.Initialize(); 19 | } 20 | 21 | private Loadout loadout; 22 | 23 | @Override 24 | public boolean Initialize() 25 | { 26 | loadout = new Loadout().addWoodSword().addWoodPick().addWoodAxe().addSoulboundItem(new ItemStack(Material.WORKBENCH)).addNavCompass().finalizeLoadout(); 27 | return true; 28 | } 29 | 30 | @Override 31 | public String getDisplayName() 32 | { 33 | return Lang.CIVILIANNAME.toString(); 34 | } 35 | 36 | @Override 37 | public IconPackage getIconPackage() 38 | { 39 | return new IconPackage(new ItemStack(Material.WORKBENCH), Lang.CIVILIANLORE.toStringArray()); 40 | // return new IconPackage(new ItemStack(Material.WORKBENCH), 41 | // new String[]{ aqua+"You are the backbone.", 42 | // "", 43 | // aqua+"Fuel all facets of the", 44 | // aqua+"war machine with your", 45 | // aqua+"set of wooden tools and", 46 | // aqua+"prepare for battle!" 47 | // }); 48 | } 49 | 50 | @Override 51 | public void onPlayerSpawn(Player player) 52 | { 53 | // KitUtils.giveTeamArmor(player); 54 | // player.getInventory().addItem(Sword); 55 | // player.getInventory().addItem(Pick); 56 | // player.getInventory().addItem(Axe); 57 | // player.getInventory().addItem(CraftingTable); 58 | // player.getInventory().addItem(KitUtils.getNavCompass()); 59 | loadout.giveLoadout(player); 60 | } 61 | 62 | @Override 63 | public void cleanup(Player player) 64 | { 65 | 66 | } 67 | 68 | @Override 69 | public boolean hasPermission(Player player) 70 | { 71 | return true; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/kits/IconPackage.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.kits; 2 | 3 | import java.util.ArrayList; 4 | 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | public class IconPackage 8 | { 9 | private final ItemStack stack; 10 | private String name = null; 11 | private String[] lore = null; 12 | 13 | public IconPackage(ItemStack stack) 14 | { 15 | this.stack = stack; 16 | } 17 | 18 | public IconPackage(ItemStack stack, String name) 19 | { 20 | this(stack); 21 | this.name = name; 22 | } 23 | 24 | public IconPackage(ItemStack stack, String[] lore) 25 | { 26 | this(stack); 27 | this.lore = lore; 28 | } 29 | 30 | public IconPackage(ItemStack stack, String name, String[] lore) 31 | { 32 | this(stack); 33 | this.name = name; 34 | this.lore = lore; 35 | } 36 | 37 | 38 | public ItemStack getFinalIcon() 39 | { 40 | ItemStack s = stack.clone(); 41 | if(name != null) 42 | KitUtils.setName(s, name); 43 | if(lore != null) 44 | { 45 | ArrayList str = new ArrayList(); 46 | for(String x : lore) 47 | str.add(x); 48 | KitUtils.setLore(s,str); 49 | } 50 | return s; 51 | } 52 | 53 | public ItemStack getIcon() 54 | { 55 | return this.stack; 56 | } 57 | 58 | public String[] getLore() 59 | { 60 | return lore; 61 | } 62 | 63 | public String getName() 64 | { 65 | return name; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/kits/Kit.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.kits; 2 | 3 | import java.util.Collection; 4 | import java.util.Collections; 5 | import java.util.Map; 6 | import java.util.TreeMap; 7 | 8 | import org.bukkit.ChatColor; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.event.Listener; 11 | 12 | public abstract class Kit implements Listener, Comparable 13 | { 14 | public static final Kit CivilianInstance; 15 | private static final Map kits; 16 | static 17 | { 18 | kits = new TreeMap(); 19 | CivilianInstance = new CivilianKit(); 20 | registerKit(CivilianInstance); 21 | } 22 | 23 | static void registerKit(Kit kit) 24 | { 25 | kits.put(kit.getName().toLowerCase(), kit); 26 | } 27 | 28 | public static Collection getKits() 29 | { 30 | return Collections.unmodifiableCollection(kits.values()); 31 | } 32 | 33 | public static Kit getKit(String name) 34 | { 35 | return kits.get(ChatColor.stripColor(name).toLowerCase()); 36 | } 37 | 38 | protected final ChatColor aqua = ChatColor.AQUA; 39 | 40 | public abstract boolean Initialize(); 41 | 42 | public String getName() 43 | { 44 | return ChatColor.stripColor(getDisplayName()); 45 | } 46 | 47 | public abstract String getDisplayName(); 48 | 49 | public abstract IconPackage getIconPackage(); 50 | 51 | public abstract boolean hasPermission(Player player); 52 | 53 | public abstract void onPlayerSpawn(Player player); 54 | 55 | public abstract void cleanup(Player player); 56 | 57 | @Override 58 | public int compareTo(Kit kit) 59 | { 60 | return this.getName().compareTo(kit.getName()); 61 | } 62 | 63 | @Override 64 | public int hashCode() 65 | { 66 | final int prime = 31; 67 | int result = 1; 68 | result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); 69 | return result; 70 | } 71 | 72 | @Override 73 | public boolean equals(Object obj) 74 | { 75 | if (this == obj) 76 | return true; 77 | if (obj == null) 78 | return false; 79 | if (getClass() != obj.getClass()) 80 | return false; 81 | Kit other = (Kit) obj; 82 | if (this.getName() == null) 83 | { 84 | if (other.getName() != null) 85 | return false; 86 | } 87 | else if (!this.getName().equals(other.getName())) 88 | return false; 89 | return true; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/kits/KitMenuItem.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.kits; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.gmail.nuclearcat1337.anniPro.main.Lang; 7 | import org.bukkit.ChatColor; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 12 | import com.gmail.nuclearcat1337.anniPro.anniGame.Game; 13 | import com.gmail.nuclearcat1337.anniPro.itemMenus.ItemClickEvent; 14 | import com.gmail.nuclearcat1337.anniPro.itemMenus.MenuItem; 15 | 16 | public class KitMenuItem extends MenuItem 17 | { 18 | private final Kit kit; 19 | public KitMenuItem(final Kit kit) 20 | { 21 | super(kit.getName(), kit.getIconPackage().getIcon(), kit.getIconPackage().getLore()); 22 | this.kit = kit; 23 | } 24 | 25 | public Kit getKit() 26 | { 27 | return kit; 28 | } 29 | 30 | @Override 31 | public ItemStack getFinalIcon(Player player) 32 | { 33 | List str = new ArrayList(getLore()); 34 | str.add(ChatColor.GOLD+"--------------------------"); 35 | if(kit.hasPermission(player)) 36 | str.add(ChatColor.GREEN+"UNLOCKED"); 37 | else 38 | str.add(ChatColor.RED+"LOCKED"); 39 | return setNameAndLore(getIcon().clone(), getDisplayName(), str); 40 | } 41 | 42 | @Override 43 | public void onItemClick(ItemClickEvent event) 44 | { 45 | final Player player = event.getPlayer(); 46 | if(player != null) 47 | { 48 | event.setWillClose(true); 49 | final AnniPlayer anniplayer = AnniPlayer.getPlayer(player.getUniqueId()); 50 | if(kit != null && anniplayer != null) 51 | { 52 | if(kit.hasPermission(player)) 53 | { 54 | if(Game.isGameRunning() && anniplayer.getKit() != null) 55 | anniplayer.getKit().cleanup(player); 56 | anniplayer.setKit(kit); 57 | player.sendMessage(ChatColor.DARK_PURPLE+kit.getName()+" selected."); 58 | if(Game.isGameRunning() && anniplayer.getTeam() != null) 59 | player.setHealth(0); 60 | } 61 | else player.sendMessage(Lang.CANT_SELECT_KIT.toString()); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/kits/KitUtils.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.kits; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.ChatColor; 8 | import org.bukkit.Material; 9 | import org.bukkit.enchantments.Enchantment; 10 | import org.bukkit.inventory.ItemStack; 11 | import org.bukkit.inventory.meta.ItemMeta; 12 | 13 | 14 | public class KitUtils 15 | { 16 | public static ItemStack[] getLeatherArmor() 17 | { 18 | ItemStack[] stacks = new ItemStack[]{ new ItemStack(Material.LEATHER_BOOTS), 19 | new ItemStack(Material.LEATHER_LEGGINGS), 20 | new ItemStack(Material.LEATHER_CHESTPLATE), 21 | new ItemStack(Material.LEATHER_HELMET)}; 22 | 23 | for(int x = 0; x < stacks.length; x++) 24 | stacks[x] = KitUtils.addSoulbound(stacks[x]); 25 | return stacks; 26 | } 27 | public static boolean isSoulbound(ItemStack stack) 28 | { 29 | ItemMeta meta = stack.getItemMeta(); 30 | if(meta == null) 31 | return false; 32 | List lore = meta.getLore(); 33 | if(lore == null) 34 | return false; 35 | return lore.contains(ChatColor.GOLD+"Soulbound"); 36 | } 37 | 38 | public static ItemStack addSoulbound(ItemStack stack) 39 | { 40 | if(stack == null) 41 | return stack; 42 | ItemMeta meta = stack.getItemMeta(); 43 | if(meta == null) 44 | meta = Bukkit.getItemFactory().getItemMeta(stack.getType()); 45 | List lore = meta.getLore(); 46 | if(lore == null) 47 | lore = new ArrayList(); 48 | lore.add(ChatColor.GOLD+"Soulbound"); 49 | meta.setLore(lore); 50 | stack.setItemMeta(meta); 51 | return stack; 52 | } 53 | 54 | public static ItemStack addEnchant(ItemStack s, Enchantment m, int level) 55 | { 56 | s.addUnsafeEnchantment(m, level); 57 | return s; 58 | } 59 | 60 | public static boolean itemHasName(ItemStack stack, String name) 61 | { 62 | if(stack == null) 63 | return false; 64 | ItemMeta meta = stack.getItemMeta(); 65 | if(meta == null) 66 | return false; 67 | if(!meta.hasDisplayName()) 68 | return false; 69 | return meta.getDisplayName().equalsIgnoreCase(name); 70 | } 71 | 72 | // public static ItemStack[] coloredArmor(AnniTeam team) 73 | // { 74 | // Color c; 75 | // if(team.getColor() == ChatColor.RED) 76 | // c = Color.RED; 77 | // else if(team.getColor() == ChatColor.BLUE) 78 | // c = Color.BLUE; 79 | // else if(team.getColor() == ChatColor.GREEN) 80 | // c = Color.GREEN; 81 | // else 82 | // c = Color.YELLOW; 83 | // for(ItemStack stack : armor) 84 | // { 85 | // LeatherArmorMeta meta = (LeatherArmorMeta) stack.getItemMeta(); 86 | // meta.setColor(c); 87 | // stack.setItemMeta(meta); 88 | // } 89 | // return armor; 90 | // } 91 | // 92 | // public static void giveTeamArmor(Player player) 93 | // { 94 | // final AnniPlayer pl = AnniPlayer.getPlayer(player.getUniqueId()); 95 | // if(pl != null) 96 | // { 97 | // final AnniTeam t = pl.getTeam(); 98 | // if(t != null) 99 | // { 100 | // player.getInventory().setArmorContents(coloredArmor(t)); 101 | // } 102 | // } 103 | // } 104 | 105 | public static ItemStack setName(ItemStack itemStack, String name) 106 | { 107 | ItemMeta meta = itemStack.getItemMeta(); 108 | if(meta == null) 109 | meta = Bukkit.getItemFactory().getItemMeta(itemStack.getType()); 110 | meta.setDisplayName(name); 111 | itemStack.setItemMeta(meta); 112 | return itemStack; 113 | } 114 | 115 | public static ItemStack setLore(ItemStack itemStack, List lore) 116 | { 117 | ItemMeta meta = itemStack.getItemMeta(); 118 | if(meta == null) 119 | meta = Bukkit.getItemFactory().getItemMeta(itemStack.getType()); 120 | meta.setLore(lore); 121 | itemStack.setItemMeta(meta); 122 | return itemStack; 123 | } 124 | 125 | public static ItemStack setNameLore(ItemStack itemStack, String name, List lore) 126 | { 127 | return setLore(setName(itemStack,name),lore); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/main/AnniArgument.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.main; 2 | 3 | import org.bukkit.command.CommandSender; 4 | 5 | import com.gmail.nuclearcat1337.anniPro.itemMenus.MenuItem; 6 | 7 | public interface AnniArgument 8 | { 9 | String getHelp(); 10 | boolean useByPlayerOnly(); 11 | String getArgumentName(); 12 | void executeCommand(CommandSender sender, String label, String[] args); 13 | String getPermission(); 14 | MenuItem getMenuItem(); 15 | } 16 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/mapBuilder/FutureBlockReplace.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.mapBuilder; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Material; 5 | import org.bukkit.block.Block; 6 | import org.bukkit.block.BlockState; 7 | 8 | public class FutureBlockReplace implements Runnable 9 | { 10 | //private final Block b; 11 | private final BlockState state; 12 | 13 | public FutureBlockReplace(Block b) 14 | { 15 | this.state = b.getState(); 16 | } 17 | 18 | public FutureBlockReplace(Block b, boolean cobble) 19 | { 20 | this.state = b.getState(); 21 | b.setType(cobble? Material.COBBLESTONE:Material.AIR); 22 | } 23 | 24 | public void run() 25 | { 26 | Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("Annihilation"), new Runnable() 27 | { 28 | @Override 29 | public void run() 30 | { 31 | // Bukkit.getLogger().info("RAWR "+state.getType().toString()); 32 | state.update(true); 33 | } 34 | } 35 | ); 36 | } 37 | } -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/mapBuilder/SingleQuestionPrompt.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.mapBuilder; 2 | 3 | import org.bukkit.conversations.Conversation; 4 | import org.bukkit.conversations.ConversationContext; 5 | import org.bukkit.conversations.ConversationFactory; 6 | import org.bukkit.conversations.Prompt; 7 | import org.bukkit.conversations.ValidatingPrompt; 8 | import org.bukkit.entity.Player; 9 | 10 | import com.gmail.nuclearcat1337.anniPro.main.AnnihilationMain; 11 | 12 | public final class SingleQuestionPrompt extends ValidatingPrompt 13 | { 14 | private static ConversationFactory factory; 15 | 16 | //private final Player player; 17 | private final String question; 18 | private final AcceptAnswer listener; 19 | 20 | public static void newPrompt(final Player player, final String question, final AcceptAnswer listener) 21 | { 22 | if(factory == null) 23 | factory = new ConversationFactory(AnnihilationMain.getInstance()); 24 | if(!player.isConversing()) 25 | { 26 | Conversation conv = factory.withModality(false).withFirstPrompt(new SingleQuestionPrompt(question,listener)).withLocalEcho(true).buildConversation(player); 27 | conv.begin(); 28 | } 29 | } 30 | 31 | private SingleQuestionPrompt(final String question, final AcceptAnswer listener) 32 | { 33 | //this.player = player; 34 | this.question = question; 35 | this.listener = listener; 36 | } 37 | 38 | @Override 39 | public String getPromptText(ConversationContext context) 40 | { 41 | return question; 42 | } 43 | 44 | @Override 45 | protected Prompt acceptValidatedInput(ConversationContext context, String input) 46 | { 47 | if(input.equalsIgnoreCase("quit") || input.equalsIgnoreCase("stop") || input.equalsIgnoreCase("end")) 48 | return Prompt.END_OF_CONVERSATION; 49 | 50 | if(listener.onAnswer(input)) 51 | return Prompt.END_OF_CONVERSATION; 52 | else 53 | return this; 54 | } 55 | 56 | @Override 57 | protected boolean isInputValid(ConversationContext context, String input) 58 | { 59 | return true; 60 | } 61 | } 62 | 63 | interface AcceptAnswer 64 | { 65 | boolean onAnswer(String input); 66 | } 67 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/mapBuilder/TeamBlock.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.mapBuilder; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.Material; 8 | import org.bukkit.block.Block; 9 | import org.bukkit.block.BlockFace; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.event.block.Action; 12 | import org.bukkit.inventory.ItemStack; 13 | import org.bukkit.inventory.meta.ItemMeta; 14 | 15 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniTeam; 16 | import com.gmail.nuclearcat1337.anniPro.kits.KitUtils; 17 | 18 | public class TeamBlock 19 | { 20 | public static final TeamBlock Red = new TeamBlock(AnniTeam.Red); 21 | public static final TeamBlock Blue = new TeamBlock(AnniTeam.Blue); 22 | public static final TeamBlock Green = new TeamBlock(AnniTeam.Green); 23 | public static final TeamBlock Yellow = new TeamBlock(AnniTeam.Yellow); 24 | 25 | public static TeamBlock getByTeam(AnniTeam team) 26 | { 27 | if(team.getName().equalsIgnoreCase("red")) 28 | return Red; 29 | else if(team.getName().equalsIgnoreCase("blue")) 30 | return Blue; 31 | else if(team.getName().equalsIgnoreCase("green")) 32 | return Green; 33 | else return Yellow; 34 | } 35 | 36 | interface TeamBlockHandler 37 | { 38 | void onBlockClick(final Player player, final AnniTeam team, final Action action, final Block block, final BlockFace face); 39 | } 40 | 41 | public final AnniTeam Team; 42 | private final List lore; 43 | private final byte datavalue; 44 | 45 | private TeamBlock(final AnniTeam team) 46 | { 47 | this.Team = team; 48 | this.lore = new ArrayList(); 49 | if(team.equals(AnniTeam.Red)) 50 | datavalue = (byte)14; 51 | else if(team.equals(AnniTeam.Blue)) 52 | datavalue = (byte)11; 53 | else if(team.equals(AnniTeam.Green)) 54 | datavalue = (byte)13; 55 | else 56 | datavalue = (byte)4; 57 | } 58 | 59 | public TeamBlock addLine(Action action, ChatColor color1, String message) 60 | { 61 | String str = ""; 62 | if(action == Action.LEFT_CLICK_BLOCK || action == Action.LEFT_CLICK_AIR) 63 | str = color1+"Left click to "; 64 | else if(action == Action.RIGHT_CLICK_BLOCK || action == Action.RIGHT_CLICK_AIR) 65 | str = color1+"Right click to "; 66 | str += message; 67 | lore.add(str); 68 | return this; 69 | } 70 | 71 | public void clearLines() 72 | { 73 | this.lore.clear(); 74 | } 75 | 76 | public String getName() 77 | { 78 | return Team.getColor()+Team.getName()+" Team"; 79 | } 80 | 81 | @Override 82 | public String toString() 83 | { 84 | return this.getName(); 85 | } 86 | 87 | private ItemStack toItemStack() 88 | { 89 | @SuppressWarnings("deprecation") 90 | ItemStack stack = new ItemStack(Material.WOOL,1,(short)0,datavalue); 91 | ItemMeta meta = stack.getItemMeta(); 92 | meta.setDisplayName(getName()); 93 | if (lore != null) 94 | meta.setLore(lore); 95 | stack.setItemMeta(meta); 96 | return KitUtils.addSoulbound(stack); 97 | } 98 | 99 | public void giveToPlayer(final Player player) 100 | { 101 | ItemStack[] inv = player.getInventory().getContents(); 102 | for(int x = 0; x < inv.length; x++) 103 | { 104 | if(inv[x] != null && inv[x].getType() == Material.WOOL) 105 | { 106 | if(KitUtils.itemHasName(inv[x], this.getName())) 107 | player.getInventory().clear(x); 108 | } 109 | } 110 | player.getInventory().addItem(this.toItemStack()); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/utils/DamageControl.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.utils; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.EntityType; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.entity.EntityDamageEvent; 9 | import org.bukkit.event.entity.EntityDamageEvent.DamageCause; 10 | import org.bukkit.plugin.Plugin; 11 | 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | import java.util.UUID; 15 | 16 | public class DamageControl implements Listener 17 | { 18 | private static DamageControl instance; 19 | static boolean registered; 20 | public static void register(Plugin plugin) 21 | { 22 | if(!registered) 23 | { 24 | registered = true; 25 | instance = new DamageControl(); 26 | Bukkit.getPluginManager().registerEvents(instance,plugin); 27 | } 28 | } 29 | 30 | private final Map> controllers; 31 | 32 | private DamageControl() 33 | { 34 | controllers = new HashMap<>(); 35 | } 36 | 37 | public static void addImmunity(Player player, DamageCause source) 38 | { 39 | addImmunity(player.getUniqueId(), source); 40 | } 41 | 42 | public static void addImmunity(UUID id, DamageCause source) 43 | { 44 | instance.getImmunities(id).put(source, Long.MAX_VALUE); 45 | } 46 | 47 | public static void addTempImmunity(Player player, DamageCause source, long time) 48 | { 49 | addTempImmunity(player.getUniqueId(),source,time); 50 | } 51 | 52 | public static void addTempImmunity(UUID id, DamageCause source, long time) 53 | { 54 | instance.getImmunities(id).put(source,time); 55 | } 56 | 57 | public static void removeImmunity(Player player, DamageCause source) 58 | { 59 | removeImmunity(player.getUniqueId(),source); 60 | } 61 | 62 | public static void removeImmunity(UUID id, DamageCause source) 63 | { 64 | instance.getImmunities(id).remove(source); 65 | } 66 | 67 | @EventHandler(ignoreCancelled = true) 68 | public void immunityCheck(EntityDamageEvent event) 69 | { 70 | if(event.getEntityType() == EntityType.PLAYER) 71 | { 72 | if(hasImmunity(event.getEntity().getUniqueId(),event.getCause())) 73 | event.setCancelled(true); 74 | } 75 | } 76 | 77 | private boolean hasImmunity(UUID id, DamageCause source) 78 | { 79 | if(!controllers.containsKey(id)) 80 | return false; 81 | Map imm = controllers.get(id); 82 | if(!imm.containsKey(source)) 83 | return false; 84 | if(imm.get(source) <= System.currentTimeMillis()) 85 | { 86 | imm.remove(source); 87 | return false; 88 | } 89 | return true; 90 | } 91 | 92 | 93 | public Map getImmunities(UUID id) 94 | { 95 | Map immunities = controllers.get(id); 96 | if(immunities == null) 97 | { 98 | immunities = new HashMap<>(2); 99 | controllers.put(id,immunities); 100 | } 101 | return immunities; 102 | } 103 | 104 | // private class Control 105 | // { 106 | // private final DamageSource source; 107 | // private final long expiration; 108 | // 109 | // public Control(DamageSource source, long expiration) 110 | // { 111 | // this.source = source; 112 | // this.expiration = expiration; 113 | // } 114 | // } 115 | } 116 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/utils/InvisibilityListeners.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.utils; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniEvents.AnniEvent; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.entity.EntityType; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.EventPriority; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.block.BlockBreakEvent; 11 | import org.bukkit.event.entity.EntityDamageEvent; 12 | import org.bukkit.plugin.Plugin; 13 | import org.bukkit.potion.PotionEffectType; 14 | 15 | 16 | import com.gmail.nuclearcat1337.anniPro.anniEvents.NexusHitEvent; 17 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 18 | import com.gmail.nuclearcat1337.anniPro.main.Lang; 19 | 20 | public class InvisibilityListeners implements Listener 21 | { 22 | public InvisibilityListeners(Plugin plugin) 23 | { 24 | Bukkit.getPluginManager().registerEvents(this, plugin); 25 | // AnniEvent.registerListener(this); 26 | } 27 | 28 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 29 | public void blockBreakingChecker(final BlockBreakEvent event) 30 | { 31 | Player player = event.getPlayer(); 32 | AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); 33 | if(p != null) 34 | checkInvis(player); 35 | } 36 | 37 | @EventHandler 38 | public void nexuChecker(NexusHitEvent event) 39 | { 40 | Player p = event.getPlayer().getPlayer(); 41 | if(p != null) 42 | checkInvis(p); 43 | } 44 | 45 | // @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 46 | // public void blockPlacingChecker(final BlockPlaceEvent event) 47 | // { 48 | // Player player = event.getPlayer(); 49 | // AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); 50 | // if(p != null) 51 | // checkInvis(player); 52 | // } 53 | 54 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 55 | public void playerDamageChecker(final EntityDamageEvent event) 56 | { 57 | if(event.getEntityType() == EntityType.PLAYER) 58 | { 59 | Player player = (Player)event.getEntity(); 60 | AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); 61 | if(p != null) 62 | checkInvis(player); 63 | } 64 | } 65 | 66 | private void checkInvis(Player player) 67 | { 68 | if(player.hasPotionEffect(PotionEffectType.INVISIBILITY)) 69 | { 70 | player.removePotionEffect(PotionEffectType.INVISIBILITY); 71 | player.sendMessage(Lang.INVISREVEAL.toString()); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/utils/Loc.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.utils; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | public final class Loc 8 | { 9 | private Number x,y,z; 10 | private float pitch,yaw; 11 | private String world; 12 | 13 | public Loc(Location loc, boolean precise) 14 | { 15 | this.world = loc.getWorld().getName(); 16 | if(precise) 17 | { 18 | x = loc.getX(); 19 | y = loc.getY(); 20 | z = loc.getZ(); 21 | pitch = loc.getPitch(); 22 | yaw = loc.getYaw(); 23 | } 24 | else 25 | { 26 | x = loc.getBlockX(); 27 | y = loc.getBlockY(); 28 | z = loc.getBlockZ(); 29 | pitch = 0; 30 | yaw = 0; 31 | } 32 | } 33 | 34 | public Loc(String world, Number x, Number y, Number z) 35 | { 36 | this(world,x,y,z,0,0); 37 | } 38 | 39 | public Loc(String world, Number x, Number y, Number z, float pitch, float yaw) 40 | { 41 | this.world = world; 42 | this.x = x; 43 | this.y = y; 44 | this.z = z; 45 | this.pitch = pitch; 46 | this.yaw = yaw; 47 | } 48 | 49 | public Loc(ConfigurationSection section) 50 | { 51 | assert section != null; 52 | this.world = section.getString("World"); 53 | this.pitch = (float)section.getDouble("Pitch"); 54 | this.yaw = (float)section.getDouble("Yaw"); 55 | if(section.isDouble("X")) 56 | x = section.getDouble("X"); 57 | else x = section.getInt("X"); 58 | if(section.isDouble("Y")) 59 | y = section.getDouble("Y"); 60 | else y = section.getInt("Y"); 61 | if(section.isDouble("Z")) 62 | z = section.getDouble("Z"); 63 | else z = section.getInt("Z"); 64 | } 65 | 66 | public int getBlockX() 67 | { 68 | //return (int)x.doubleValue(); 69 | return x.intValue(); 70 | } 71 | 72 | public int getBlockY() 73 | { 74 | //return (int)y.doubleValue(); 75 | return y.intValue(); 76 | } 77 | 78 | public int getBlockZ() 79 | { 80 | //return (int)z.doubleValue(); 81 | return z.intValue(); 82 | } 83 | 84 | public String getWorld() 85 | { 86 | return world; 87 | } 88 | 89 | public Location toLocation() 90 | { 91 | return new Location(Bukkit.getWorld(world),x.doubleValue(),y.doubleValue(),z.doubleValue(),yaw,pitch); 92 | } 93 | 94 | @Override 95 | public boolean equals(Object obj) 96 | { 97 | if(obj == this) 98 | return true; 99 | if(obj instanceof Loc) 100 | { 101 | Loc l = (Loc)obj; 102 | return this.world.equals(l.world) && this.getBlockX() == l.getBlockX() && this.getBlockY() == l.getBlockY() && this.getBlockZ() == l.getBlockZ(); 103 | } 104 | else if(obj instanceof Location) 105 | { 106 | Location l = (Location)obj; 107 | return this.world.equals(l.getWorld().getName()) && this.getBlockX() == l.getBlockX() && this.getBlockY() == l.getBlockY() && this.getBlockZ() == l.getBlockZ(); 108 | } 109 | return false; 110 | } 111 | 112 | public void saveToConfig(ConfigurationSection section) 113 | { 114 | section.set("World", world); 115 | section.set("X", x); 116 | section.set("Y", y); 117 | section.set("Z", z); 118 | section.set("Pitch", (double)pitch); 119 | section.set("Yaw", (double)yaw); 120 | } 121 | } -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/utils/MapKey.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.utils; 2 | 3 | import org.bukkit.Location; 4 | 5 | public class MapKey implements Comparable 6 | { 7 | public static MapKey getKey(Location location) 8 | { 9 | return location != null ? new MapKey(location.getBlockX()+" "+location.getBlockY()+" "+location.getBlockZ()+" "+location.getWorld().getName()) : null; 10 | } 11 | 12 | public static MapKey getKey(Loc location) 13 | { 14 | return location != null ? getKey(location.toLocation()) : null; 15 | } 16 | 17 | private String key; 18 | private MapKey(String key) 19 | { 20 | this.key = key; 21 | } 22 | 23 | @Override 24 | public int hashCode() 25 | { 26 | final int prime = 31; 27 | int result = 1; 28 | result = prime * result + ((key == null) ? 0 : key.hashCode()); 29 | return result; 30 | } 31 | 32 | @Override 33 | public boolean equals(Object obj) 34 | { 35 | if (this == obj) 36 | return true; 37 | if (obj == null) 38 | return false; 39 | if (getClass() != obj.getClass()) 40 | return false; 41 | MapKey other = (MapKey) obj; 42 | if (key == null) 43 | { 44 | if (other.key != null) 45 | return false; 46 | } 47 | else if (!key.equals(other.key)) 48 | return false; 49 | return true; 50 | } 51 | 52 | @Override 53 | public int compareTo(MapKey o) 54 | { 55 | return key.compareTo(o.key); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/utils/Perm.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.utils; 2 | 3 | public class Perm implements Comparable 4 | { 5 | public final String perm; 6 | public final double multiplier; 7 | 8 | public Perm(String perm, int mult) 9 | { 10 | this.perm = perm; 11 | this.multiplier = mult; 12 | } 13 | 14 | @Override 15 | public int compareTo(Perm arg0) 16 | { 17 | return (int)Double.compare(multiplier, arg0.multiplier); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/utils/ShopMenuItem.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.utils; 2 | 3 | import java.util.ArrayList; 4 | 5 | import org.bukkit.Material; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.inventory.PlayerInventory; 9 | import org.bukkit.inventory.meta.ItemMeta; 10 | 11 | import com.gmail.nuclearcat1337.anniPro.itemMenus.ItemClickEvent; 12 | import com.gmail.nuclearcat1337.anniPro.itemMenus.MenuItem; 13 | import com.gmail.nuclearcat1337.anniPro.main.Lang; 14 | 15 | public class ShopMenuItem extends MenuItem 16 | { 17 | private final ItemStack display; 18 | private final ItemStack product; 19 | private final int cost; 20 | public ShopMenuItem(ItemStack displayStack, ItemStack productStack, int cost) 21 | { 22 | super(null, null,new String[0]); 23 | this.display = displayStack.clone(); 24 | this.product = productStack.clone(); 25 | ArrayList l = new ArrayList(); 26 | l.add(Lang.COST.toStringReplacement(cost)); 27 | l.add(Lang.QUANTITY.toStringReplacement(product.getAmount())); 28 | ItemMeta m = display.getItemMeta(); 29 | m.setLore(l); 30 | display.setItemMeta(m); 31 | this.cost = cost; 32 | } 33 | 34 | @Override 35 | public void onItemClick(ItemClickEvent event) 36 | { 37 | Player player = event.getPlayer(); 38 | PlayerInventory p = player.getInventory(); 39 | if(p.containsAtLeast(new ItemStack(Material.GOLD_INGOT), cost)) 40 | { 41 | int total = 0; 42 | for(ItemStack s : p.all(Material.GOLD_INGOT).values()) 43 | { 44 | total += s.getAmount(); 45 | } 46 | p.remove(Material.GOLD_INGOT); 47 | if(total-cost > 0) 48 | p.addItem(new ItemStack(Material.GOLD_INGOT,total-cost)); 49 | p.addItem(product); 50 | player.sendMessage(Lang.PURCHASEDITEM.toString()); 51 | } 52 | else player.sendMessage(Lang.COULDNOTPURCHASE.toString()); 53 | } 54 | 55 | @Override 56 | public ItemStack getFinalIcon(Player player) 57 | { 58 | return display; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/utils/Util.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.utils; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | public class Util 7 | { 8 | public static String shortenString(String string, int characters) 9 | { 10 | if(string.length() <= characters) 11 | return string; 12 | return string.substring(0, characters); 13 | } 14 | 15 | public static boolean tryCreateFile(File file) 16 | { 17 | if(!file.exists()) 18 | { 19 | try 20 | { 21 | file.createNewFile(); 22 | return true; 23 | } 24 | catch (IOException e) 25 | { 26 | e.printStackTrace(); 27 | } 28 | } 29 | return false; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/utils/VersionUtils.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.utils; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | public class VersionUtils 6 | { 7 | public static String getVersion() 8 | { 9 | String packageName = Bukkit.getServer().getClass().getPackage().getName(); 10 | return packageName.substring(packageName.lastIndexOf(".") + 1); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Annihilation/src/com/gmail/nuclearcat1337/anniPro/voting/AutoStarter.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nuclearcat1337.anniPro.voting; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.announcementBar.AnnounceBar; 4 | import com.gmail.nuclearcat1337.anniPro.announcementBar.Announcement; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.EventPriority; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.player.PlayerJoinEvent; 11 | import org.bukkit.plugin.Plugin; 12 | 13 | import com.gmail.nuclearcat1337.anniPro.anniGame.Game; 14 | import com.gmail.nuclearcat1337.anniPro.anniGame.GameVars; 15 | import com.gmail.nuclearcat1337.anniPro.announcementBar.MessageBar; 16 | import com.gmail.nuclearcat1337.anniPro.main.AnnihilationMain; 17 | 18 | public class AutoStarter implements Listener 19 | { 20 | private final int players; 21 | private final int countdown; 22 | private boolean canRun; 23 | 24 | public AutoStarter(Plugin p, int playersToStart, int countdown) 25 | { 26 | Bukkit.getPluginManager().registerEvents(this, p); 27 | this.players = playersToStart; 28 | this.countdown = countdown; 29 | canRun = true; 30 | } 31 | 32 | @EventHandler(priority = EventPriority.MONITOR) 33 | public void playerCheck(PlayerJoinEvent event) 34 | { 35 | check(); 36 | } 37 | 38 | private void check() 39 | { 40 | if(!Game.isGameRunning() && canRun) 41 | { 42 | int count = Bukkit.getOnlinePlayers().size(); 43 | 44 | if(count >= players) 45 | { 46 | canRun = false; 47 | Announcement ann = new Announcement(ChatColor.GREEN + "Starting in: {#}").setTime(countdown); 48 | if(GameVars.getVoting()) 49 | { 50 | ann.setCallback(new Runnable() 51 | { 52 | @Override 53 | public void run() 54 | { 55 | try 56 | { 57 | String winner = VoteMapManager.getWinningMap(); 58 | Bukkit.broadcastMessage(ChatColor.GREEN + winner + " selected. Loading map."); 59 | if (Game.loadGameMap(winner)) 60 | Game.startGame(); 61 | else 62 | { 63 | Bukkit.broadcastMessage(ChatColor.RED + "There has been an error in loading the map: " + winner); 64 | Bukkit.broadcastMessage(ChatColor.RED + "The game will not start."); 65 | } 66 | } catch (Exception e) 67 | { 68 | Bukkit.getLogger().warning("[ANNIHILATION] FATAL ERROR. VOTING IS ENABLED BUT THERE ARE NO MAPS IN THE WORLDS FOLDER!"); 69 | Bukkit.getPluginManager().disablePlugin(AnnihilationMain.getInstance()); 70 | } 71 | } 72 | }); 73 | } 74 | else 75 | { 76 | ann.setCallback(new Runnable() 77 | { 78 | @Override 79 | public void run() 80 | { 81 | if (Game.loadGameMap(GameVars.getMap())) 82 | Game.startGame(); 83 | else 84 | { 85 | Bukkit.broadcastMessage(ChatColor.RED + "There has been an error in loading the fixed map: " + GameVars.getMap().getName()); 86 | Bukkit.broadcastMessage(ChatColor.RED + "The game will not start."); 87 | } 88 | } 89 | }); 90 | } 91 | AnnounceBar.getInstance().countDown(ann); 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Techcable 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/api/LogoutTag.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.api; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.anniEvents.AnniEvent; 4 | import com.gmail.nuclearcat1337.anniPro.anniEvents.PlayerKilledEvent; 5 | import com.gmail.nuclearcat1337.anniPro.anniGame.AnniPlayer; 6 | import com.gmail.nuclearcat1337.anniPro.anniGame.GameVars; 7 | import com.gmail.nuclearcat1337.anniPro.kits.KitUtils; 8 | import com.gmail.nuclearcat1337.anniPro.main.AnnihilationMain; 9 | import org.bukkit.Location; 10 | import org.bukkit.Material; 11 | import org.bukkit.World; 12 | import org.bukkit.entity.Player; 13 | import org.bukkit.inventory.ItemStack; 14 | import org.bukkit.scheduler.BukkitRunnable; 15 | 16 | import java.util.UUID; 17 | 18 | public class LogoutTag extends BukkitRunnable 19 | { 20 | private ItemStack[] inventory; 21 | private ItemStack[] armor; 22 | 23 | private Boolean wasKilled; 24 | 25 | private NPC npc; 26 | private UUID player; 27 | 28 | private String teamName; 29 | 30 | public LogoutTag(Player player) 31 | { 32 | this.player = player.getUniqueId(); 33 | 34 | AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); 35 | assert p != null; 36 | teamName = p.getTeam().getName(); 37 | 38 | inventory = player.getInventory().getContents(); 39 | armor = player.getInventory().getArmorContents(); 40 | npc = new NPC(player,this); 41 | wasKilled = null; 42 | this.runTaskLater(AnnihilationMain.getInstance(), GameVars.getNpcTimeout()*20); //NPC timeout comes from the config 43 | } 44 | 45 | public Boolean wasKilled() 46 | { 47 | return wasKilled; 48 | } 49 | 50 | // public void equiptPlayer(Player player) 51 | // { 52 | // if(inventory != null) 53 | // player.getInventory().setContents(inventory); 54 | // if(armor != null) 55 | // player.getInventory().setArmorContents(armor); 56 | // } 57 | 58 | public boolean onKill(Player killer) //could be null if not killed by another entity 59 | { 60 | if(killer != null) 61 | { 62 | AnniPlayer pl = AnniPlayer.getPlayer(killer.getUniqueId()); 63 | assert pl != null; 64 | if (pl.getTeam().getName().equals(teamName)) 65 | return false; 66 | } 67 | 68 | wasKilled = true; 69 | Location loc = npc.getLocation(); 70 | npc.despawn(); 71 | cancel(); 72 | World world = loc.getWorld(); 73 | for(ItemStack s : inventory) 74 | if(s != null && s.getType() != Material.AIR) 75 | if(!KitUtils.isSoulbound(s)) 76 | world.dropItemNaturally(loc,s); 77 | for(ItemStack s : armor) 78 | if(s != null && s.getType() != Material.AIR) 79 | if(!KitUtils.isSoulbound(s)) 80 | world.dropItemNaturally(loc,s); 81 | inventory = null; 82 | armor = null; 83 | 84 | //This could be a very bad idea. 85 | //At this time I currently dont remember exactly what relies on this event 86 | //For all I know something that needs to actual Player object could use this event 87 | if(killer != null) 88 | { 89 | AnniPlayer k = AnniPlayer.getPlayer(killer.getUniqueId()); 90 | AnniPlayer p = AnniPlayer.getPlayer(player); 91 | if(p != null && k != null) 92 | AnniEvent.callEvent(new PlayerKilledEvent(k,p)); 93 | } 94 | 95 | return true; 96 | } 97 | 98 | public void close() 99 | { 100 | inventory = null; 101 | armor = null; 102 | npc = null; 103 | wasKilled = null; 104 | player = null; 105 | } 106 | 107 | @Override 108 | public void run() 109 | { 110 | wasKilled = false; 111 | npc.despawn(); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/api/NMS.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.api; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.Player; 5 | 6 | public interface NMS 7 | { 8 | public Player spawnPlayer(Player player, Location location, NPC npc); 9 | public void onDespawn(NPC npc); 10 | // public void notifyOfSpawn(Player[] paramArrayOfPlayer1, Player[] paramArrayOfPlayer2); 11 | // public void notifyOfDespawn(Player[] paramArrayOfPlayer1, Player[] paramArrayOfPlayer2); 12 | } 13 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/api/NPC.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.api; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.utils.Loc; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Entity; 6 | import org.bukkit.entity.Player; 7 | 8 | public class NPC 9 | { 10 | public NPC(Player player, LogoutTag tag) 11 | { 12 | //this.uuid = player.getUniqueId(); 13 | this.tag = tag; 14 | spawn(player,player.getLocation()); 15 | } 16 | 17 | private LogoutTag tag; 18 | private boolean spawned; 19 | private Entity entity; 20 | private Loc loc; 21 | //private UUID uuid; 22 | 23 | public boolean despawn() 24 | { 25 | if(!spawned) return false; 26 | this.spawned = false; 27 | //Util.getNMS().onDespawn(this); 28 | 29 | Util.getNMS().onDespawn(this); 30 | 31 | entity.remove(); 32 | entity = null; 33 | //update(); 34 | //cancel(); 35 | // getRegistry().deregister(this); 36 | 37 | tag = null; 38 | loc = null; 39 | 40 | return true; 41 | } 42 | 43 | public Location getLocation() 44 | { 45 | return loc.toLocation(); 46 | } 47 | 48 | private boolean spawn(Player player, Location toSpawn) 49 | { 50 | if (spawned) return false; 51 | Entity spawned = Util.getNMS().spawnPlayer(player,toSpawn,this); 52 | loc = new Loc(toSpawn,true); 53 | if (spawned != null) 54 | { 55 | this.spawned = true; 56 | this.entity = spawned; 57 | //update(); 58 | //tryEquipmentChangeNotify(Bukkit.getOnlinePlayers()); 59 | return true; 60 | } else return false; 61 | } 62 | 63 | // public void update() 64 | // { 65 | // update(Util.getNearbyPlayers(128, getEntity().getLocation())); 66 | // } 67 | 68 | // public void update(Player[] players) 69 | // { 70 | // if (spawned) Util.getNMS().notifyOfSpawn(players, new Player[] { (Player)getEntity() }); 71 | // else 72 | // Util.getNMS().notifyOfDespawn(players, new Player[] { (Player)getEntity() }); 73 | // } 74 | 75 | public boolean onKill(Player killer) 76 | { 77 | return tag.onKill(killer); 78 | } 79 | 80 | public Entity getEntity() 81 | { 82 | return entity; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/api/Util.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.api; 2 | 3 | import com.gmail.nuclearcat1337.anniPro.utils.VersionUtils; 4 | import com.google.common.base.Throwables; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.Location; 7 | import org.bukkit.entity.Player; 8 | 9 | import java.lang.reflect.Constructor; 10 | import java.lang.reflect.InvocationTargetException; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | //import net.techcable.npclib.NPC; 15 | //import net.techcable.npclib.nms.NMS; 16 | 17 | public class Util 18 | { 19 | private Util() {} 20 | 21 | 22 | private static NMS nms; 23 | public static NMS getNMS() { 24 | if (nms == null) { 25 | try { 26 | String version = VersionUtils.getVersion(); 27 | String name = "net.techcable.npclib.versions." + version + ".NMS"; 28 | //Bukkit.getLogger().info(name); 29 | Class rawClass = Class.forName(name); 30 | Class nmsClass = rawClass.asSubclass(NMS.class); 31 | Constructor constructor = nmsClass.getConstructor(); 32 | return constructor.newInstance(); 33 | } catch (ClassNotFoundException ex) { 34 | throw new UnsupportedOperationException("Unsupported nms version", ex); 35 | } catch (InvocationTargetException ex) { 36 | throw Throwables.propagate(ex.getTargetException()); 37 | } catch (Exception ex) { 38 | throw Throwables.propagate(ex); 39 | } 40 | } 41 | return nms; 42 | } 43 | 44 | // public static String getVersion() { 45 | // String packageName = Bukkit.getServer().getClass().getPackage().getName(); 46 | // return packageName.substring(packageName.lastIndexOf(".") + 1); 47 | // } 48 | 49 | // public static void look(Entity entity, Location toLook) { 50 | // if (!entity.getWorld().equals(toLook.getWorld())) 51 | // return; 52 | // Location fromLocation = entity.getLocation(); 53 | // double xDiff, yDiff, zDiff; 54 | // xDiff = toLook.getX() - fromLocation.getX(); 55 | // yDiff = toLook.getY() - fromLocation.getY(); 56 | // zDiff = toLook.getZ() - fromLocation.getZ(); 57 | // 58 | // double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff); 59 | // double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff); 60 | // 61 | // double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ)); 62 | // double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90; 63 | // if (zDiff < 0.0) 64 | // yaw += Math.abs(180 - yaw) * 2; 65 | // 66 | // getNMS().look(entity, (float) yaw - 90, (float) pitch); 67 | // } 68 | 69 | // public static Entity spawn(Player player) { 70 | // //if (type.equals(EntityType.PLAYER)) { 71 | // return getNMS().sp 72 | // //} else throw new UnsupportedOperationException(); 73 | // } 74 | 75 | public static Player[] getNearbyPlayers(int range, Location l) { 76 | List nearby = new ArrayList<>(12); 77 | for (Player p : Bukkit.getOnlinePlayers()) { 78 | double distance = p.getLocation().distanceSquared(l); 79 | if (distance <= range) { 80 | nearby.add(p); 81 | } 82 | } 83 | return nearby.toArray(new Player[nearby.size()]); 84 | } 85 | } -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/util/ReflectUtil.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.util; 2 | 3 | import java.lang.reflect.Field; 4 | import java.lang.reflect.InvocationTargetException; 5 | import java.lang.reflect.Method; 6 | 7 | public class ReflectUtil { 8 | 9 | private ReflectUtil() {} 10 | 11 | public static Field makeField(Class clazz, String fieldName) { 12 | try { 13 | return clazz.getDeclaredField(fieldName); 14 | } catch (NoSuchFieldException ex) { 15 | throw new RuntimeException(ex); 16 | } 17 | } 18 | 19 | public static void setField(Field field, Object objToSet, Object value) { 20 | field.setAccessible(true); 21 | try { 22 | field.set(objToSet, value); 23 | } catch (IllegalArgumentException | IllegalAccessException e) { 24 | throw new RuntimeException(e); 25 | } 26 | } 27 | 28 | public static Method makeMethod(Class clazz, String methodName, Class... paramaters) { 29 | try { 30 | return clazz.getDeclaredMethod(methodName, paramaters); 31 | } catch (NoSuchMethodException ex) { 32 | throw new RuntimeException(ex); 33 | } 34 | } 35 | 36 | public static T callMethod(Method method, Object instance, Object... paramaters) { 37 | method.setAccessible(true); 38 | try { 39 | return (T) method.invoke(instance, paramaters); 40 | } catch (IllegalArgumentException | IllegalAccessException ex) { 41 | throw new RuntimeException(ex); 42 | } catch (InvocationTargetException ex) { 43 | throw new RuntimeException(ex.getCause()); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R3/EntityNPCPlayer.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R3; 2 | 3 | import net.minecraft.server.v1_7_R3.DamageSource; 4 | import net.minecraft.server.v1_7_R3.EntityPlayer; 5 | import net.minecraft.server.v1_7_R3.EnumGamemode; 6 | import net.minecraft.server.v1_7_R3.PlayerInteractManager; 7 | import net.techcable.npclib.api.NPC; 8 | import org.bukkit.Location; 9 | import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer; 10 | import org.bukkit.entity.EntityType; 11 | import org.bukkit.entity.Player; 12 | 13 | public class EntityNPCPlayer extends EntityPlayer 14 | { 15 | private NPC npc; 16 | public EntityNPCPlayer(Player player, Location location, NPC npc) 17 | { 18 | //super(NMS.getServer(), NMS.getHandle(location.getWorld()), makeProfile(player.getName(), player.getUniqueId()), new PlayerInteractManager(NMS.getHandle(location.getWorld()))); 19 | super(NMS.getServer(), NMS.getHandle(location.getWorld()), ((CraftPlayer) player).getProfile(), new PlayerInteractManager(NMS.getHandle(location.getWorld()))); 20 | this.npc = npc; 21 | playerInteractManager.b(EnumGamemode.SURVIVAL); //MCP = initializeGameType ---- SRG=func_73077_b 22 | playerConnection = new NPCConnection(this); 23 | 24 | setPosition(location.getX(), location.getY(), location.getZ()); 25 | } 26 | 27 | @Override 28 | public boolean damageEntity(DamageSource source, float damage) { 29 | Player p = null; 30 | if(source.getEntity() != null && source.getEntity().getBukkitEntity().getType() == EntityType.PLAYER) 31 | p = (Player)source.getEntity().getBukkitEntity(); 32 | if(npc.onKill(p)) 33 | npc = null; 34 | return false; 35 | //return super.damageEntity(source,damage); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R3/NPCConnection.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R3; 2 | 3 | import net.minecraft.server.v1_7_R3.Packet; 4 | import net.minecraft.server.v1_7_R3.PlayerConnection; 5 | 6 | public class NPCConnection extends PlayerConnection { 7 | 8 | public NPCConnection(EntityNPCPlayer npc) { 9 | super(NMS.getServer(), new NPCNetworkManager(), npc); 10 | } 11 | 12 | @Override 13 | public void sendPacket(Packet packet) { 14 | //Don't send packets to an npc 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R3/NPCNetworkManager.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R3; 2 | 3 | import net.minecraft.server.v1_7_R3.NetworkManager; 4 | import net.techcable.npclib.util.ReflectUtil; 5 | 6 | import java.lang.reflect.Field; 7 | 8 | 9 | public class NPCNetworkManager extends NetworkManager { 10 | 11 | public NPCNetworkManager() { 12 | super(false); //MCP = isClientSide 13 | Field channel = ReflectUtil.makeField(NetworkManager.class, "m"); //MCP = channel 14 | Field address = ReflectUtil.makeField(NetworkManager.class, "n"); //MCP = socketAddress 15 | 16 | ReflectUtil.setField(channel, this, new NullChannel()); 17 | ReflectUtil.setField(address, this, new NullSocketAddress()); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R3/NullChannel.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R3; 2 | 3 | import net.minecraft.util.io.netty.channel.AbstractChannel; 4 | import net.minecraft.util.io.netty.channel.ChannelConfig; 5 | import net.minecraft.util.io.netty.channel.ChannelMetadata; 6 | import net.minecraft.util.io.netty.channel.ChannelOutboundBuffer; 7 | import net.minecraft.util.io.netty.channel.EventLoop; 8 | 9 | import java.net.SocketAddress; 10 | 11 | public class NullChannel extends AbstractChannel { 12 | 13 | public NullChannel() { 14 | super(null); 15 | } 16 | 17 | @Override 18 | public ChannelConfig config() { 19 | return null; 20 | } 21 | 22 | @Override 23 | public boolean isActive() { 24 | return false; 25 | } 26 | 27 | @Override 28 | public boolean isOpen() { 29 | return false; 30 | } 31 | 32 | @Override 33 | public ChannelMetadata metadata() { 34 | return null; 35 | } 36 | 37 | @Override 38 | protected void doBeginRead() throws Exception { 39 | } 40 | 41 | @Override 42 | protected void doBind(SocketAddress arg0) throws Exception { 43 | } 44 | 45 | @Override 46 | protected void doClose() throws Exception { 47 | } 48 | 49 | @Override 50 | protected void doDisconnect() throws Exception { 51 | } 52 | 53 | @Override 54 | protected void doWrite(ChannelOutboundBuffer arg0) throws Exception { 55 | } 56 | 57 | @Override 58 | protected boolean isCompatible(EventLoop arg0) { 59 | return false; 60 | } 61 | 62 | @Override 63 | protected SocketAddress localAddress0() { 64 | return null; 65 | } 66 | 67 | @Override 68 | protected AbstractUnsafe newUnsafe() { 69 | return null; 70 | } 71 | 72 | @Override 73 | protected SocketAddress remoteAddress0() { 74 | return null; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R3/NullSocketAddress.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R3; 2 | 3 | import java.net.SocketAddress; 4 | 5 | 6 | public class NullSocketAddress extends SocketAddress { 7 | private static final long serialVersionUID = 1L; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R4/EntityNPCPlayer.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R4; 2 | 3 | import net.minecraft.server.v1_7_R4.DamageSource; 4 | import net.minecraft.server.v1_7_R4.EntityPlayer; 5 | import net.minecraft.server.v1_7_R4.EnumGamemode; 6 | import net.minecraft.server.v1_7_R4.PlayerInteractManager; 7 | import net.minecraft.util.com.mojang.authlib.GameProfile; 8 | import net.minecraft.util.com.mojang.authlib.properties.Property; 9 | import net.techcable.npclib.api.NPC; 10 | import org.bukkit.Location; 11 | import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; 12 | import org.bukkit.entity.EntityType; 13 | import org.bukkit.entity.Player; 14 | 15 | import java.util.UUID; 16 | 17 | public class EntityNPCPlayer extends EntityPlayer { 18 | 19 | private NPC npc; 20 | public EntityNPCPlayer(Player player, Location location, NPC npc) 21 | { 22 | //super(NMS.getServer(), NMS.getHandle(location.getWorld()), makeProfile(player.getName(), player.getUniqueId()), new PlayerInteractManager(NMS.getHandle(location.getWorld()))); 23 | super(NMS.getServer(), NMS.getHandle(location.getWorld()), ((CraftPlayer) player).getProfile(), new PlayerInteractManager(NMS.getHandle(location.getWorld()))); 24 | this.npc = npc; 25 | playerInteractManager.b(EnumGamemode.SURVIVAL); //MCP = initializeGameType ---- SRG=func_73077_b 26 | playerConnection = new NPCConnection(this); 27 | 28 | setPosition(location.getX(), location.getY(), location.getZ()); 29 | } 30 | 31 | @Override 32 | public boolean damageEntity(DamageSource source, float damage) { 33 | Player p = null; 34 | if(source.getEntity() != null && source.getEntity().getBukkitEntity().getType() == EntityType.PLAYER) 35 | p = (Player)source.getEntity().getBukkitEntity(); 36 | if(npc.onKill(p)) 37 | npc = null; 38 | return false; 39 | //return super.damageEntity(source,damage); 40 | } 41 | 42 | public static GameProfile makeProfile(String name, UUID skinId) { 43 | GameProfile profile = new GameProfile(UUID.randomUUID(), name); 44 | if (skinId != null) { 45 | GameProfile skin = new GameProfile(skinId, null); 46 | skin = NMS.getServer().av().fillProfileProperties(skin, true); //Srg = func_147130_as 47 | if (skin.getProperties().get("textures") == null || !skin.getProperties().get("textures").isEmpty()) { 48 | Property textures = skin.getProperties().get("textures").iterator().next(); 49 | profile.getProperties().put("textures", textures); 50 | } 51 | } 52 | return profile; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R4/NPCConnection.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R4; 2 | 3 | import net.minecraft.server.v1_7_R4.Packet; 4 | import net.minecraft.server.v1_7_R4.PlayerConnection; 5 | 6 | public class NPCConnection extends PlayerConnection { 7 | 8 | public NPCConnection(EntityNPCPlayer npc) { 9 | super(NMS.getServer(), new NPCNetworkManager(), npc); 10 | } 11 | 12 | @Override 13 | public void sendPacket(Packet packet) { 14 | //Don't send packets to an npc 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R4/NPCNetworkManager.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R4; 2 | 3 | import net.minecraft.server.v1_7_R4.NetworkManager; 4 | import net.techcable.npclib.util.ReflectUtil; 5 | 6 | import java.lang.reflect.Field; 7 | 8 | public class NPCNetworkManager extends NetworkManager { 9 | 10 | public NPCNetworkManager() { 11 | super(false); //MCP = isClientSide 12 | 13 | Field channel = ReflectUtil.makeField(NetworkManager.class, "m"); //MCP = channel 14 | Field address = ReflectUtil.makeField(NetworkManager.class, "n"); //MCP = address 15 | 16 | ReflectUtil.setField(channel, this, new NullChannel()); 17 | ReflectUtil.setField(address, this, new NullSocketAddress()); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R4/NullChannel.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R4; 2 | 3 | import net.minecraft.util.io.netty.channel.AbstractChannel; 4 | import net.minecraft.util.io.netty.channel.ChannelConfig; 5 | import net.minecraft.util.io.netty.channel.ChannelMetadata; 6 | import net.minecraft.util.io.netty.channel.ChannelOutboundBuffer; 7 | import net.minecraft.util.io.netty.channel.EventLoop; 8 | 9 | import java.net.SocketAddress; 10 | 11 | public class NullChannel extends AbstractChannel { 12 | 13 | public NullChannel() { 14 | super(null); 15 | } 16 | 17 | @Override 18 | public ChannelConfig config() { 19 | return null; 20 | } 21 | 22 | @Override 23 | public boolean isActive() { 24 | return false; 25 | } 26 | 27 | @Override 28 | public boolean isOpen() { 29 | return false; 30 | } 31 | 32 | @Override 33 | public ChannelMetadata metadata() { 34 | return null; 35 | } 36 | 37 | @Override 38 | protected void doBeginRead() throws Exception { 39 | } 40 | 41 | @Override 42 | protected void doBind(SocketAddress arg0) throws Exception { 43 | } 44 | 45 | @Override 46 | protected void doClose() throws Exception { 47 | } 48 | 49 | @Override 50 | protected void doDisconnect() throws Exception { 51 | } 52 | 53 | @Override 54 | protected void doWrite(ChannelOutboundBuffer arg0) throws Exception { 55 | } 56 | 57 | @Override 58 | protected boolean isCompatible(EventLoop arg0) { 59 | return false; 60 | } 61 | 62 | @Override 63 | protected SocketAddress localAddress0() { 64 | return null; 65 | } 66 | 67 | @Override 68 | protected AbstractUnsafe newUnsafe() { 69 | return null; 70 | } 71 | 72 | @Override 73 | protected SocketAddress remoteAddress0() { 74 | return null; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R4/NullSocketAddress.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R4; 2 | 3 | import java.net.SocketAddress; 4 | 5 | public class NullSocketAddress extends SocketAddress { 6 | private static final long serialVersionUID = 1L; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_7_R4/ProtocolHack.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_7_R4; 2 | 3 | import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils.Collections; 4 | import net.minecraft.server.v1_7_R4.EntityPlayer; 5 | import net.minecraft.server.v1_7_R4.Packet; 6 | import net.techcable.npclib.util.ReflectUtil; 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; 9 | import org.bukkit.entity.Player; 10 | 11 | import java.lang.reflect.Method; 12 | import java.util.Collection; 13 | import java.util.Iterator; 14 | 15 | public class ProtocolHack { 16 | private ProtocolHack() {} 17 | 18 | private static EntityPlayer getHandle(Player bukkitPlayer) { 19 | if (!(bukkitPlayer instanceof CraftPlayer)) return null; 20 | return ((CraftPlayer)bukkitPlayer).getHandle(); 21 | } 22 | 23 | private static EntityPlayer[] getHandles(Collection bukkitPlayers) 24 | { 25 | EntityPlayer[] handles = new EntityPlayer[bukkitPlayers.size()]; 26 | Iterator itt = bukkitPlayers.iterator(); 27 | //for (int i = 0; i < bukkitPlayers.length; i++) 28 | int i = 0; 29 | while(itt.hasNext()) 30 | { 31 | handles[i] = getHandle(itt.next()); 32 | i++; 33 | } 34 | return handles; 35 | } 36 | 37 | private static EntityPlayer[] getHandles(Player[] bukkitPlayers) 38 | { 39 | EntityPlayer[] handles = new EntityPlayer[bukkitPlayers.length]; 40 | for (int i = 0; i < bukkitPlayers.length; i++) 41 | { 42 | handles[i] = getHandle(bukkitPlayers[i]); 43 | } 44 | return handles; 45 | } 46 | 47 | public static boolean isProtocolHack() { 48 | try { 49 | Class.forName("org.spigotmc.ProtocolData"); 50 | return true; 51 | } catch (ClassNotFoundException ex) { 52 | return false; 53 | } 54 | } 55 | 56 | public static void notifyOfSpawn(Collection toNotify, Player... npcs) 57 | { 58 | Method addPlayer = ReflectUtil.makeMethod(getPlayerInfoClass(), "addPlayer", EntityPlayer.class); 59 | EntityPlayer[] handles = getHandles(npcs); 60 | Packet[] packets = new Packet[handles.length]; 61 | for (int i = 0; i < handles.length; i++) 62 | { 63 | EntityPlayer handle = handles[i]; 64 | Packet packet = ReflectUtil.callMethod(addPlayer, null, handle); 65 | packets[i] = packet; 66 | } 67 | sendPacketsTo(toNotify, packets); 68 | } 69 | 70 | public static void notifyOfDespawn(Collection toNotify, Player... npcs) { 71 | Method removePlayer = ReflectUtil.makeMethod(getPlayerInfoClass(), "removePlayer", EntityPlayer.class); 72 | EntityPlayer[] handles = getHandles(npcs); 73 | Packet[] packets = new Packet[handles.length]; 74 | for (int i = 0; i < handles.length; i++) { 75 | EntityPlayer handle = handles[i]; 76 | Packet packet = ReflectUtil.callMethod(removePlayer, null, handle); 77 | packets[i] = packet; 78 | } 79 | sendPacketsTo(toNotify, packets); 80 | } 81 | 82 | public static Class getPlayerInfoClass() { 83 | try { 84 | return Class.forName("net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo"); 85 | } catch (Exception ex) { 86 | throw new RuntimeException(ex); 87 | } 88 | } 89 | 90 | public static void sendPacketsTo(Collection recipients, Packet... packets) { 91 | EntityPlayer[] nmsRecipients = getHandles(recipients); 92 | for (EntityPlayer recipient : nmsRecipients) { 93 | if (recipient == null) continue; 94 | for (Packet packet : packets) { 95 | if (packet == null) continue; 96 | recipient.playerConnection.sendPacket(packet); 97 | } 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_8_R1/EntityNPCPlayer.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_8_R1; 2 | 3 | import net.techcable.npclib.api.NPC; 4 | import org.bukkit.Location; 5 | import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; 6 | 7 | import net.minecraft.server.v1_8_R1.DamageSource; 8 | import net.minecraft.server.v1_8_R1.EntityPlayer; 9 | import net.minecraft.server.v1_8_R1.EnumGamemode; 10 | import net.minecraft.server.v1_8_R1.PlayerInteractManager; 11 | import org.bukkit.entity.EntityType; 12 | import org.bukkit.entity.Player; 13 | 14 | public class EntityNPCPlayer extends EntityPlayer { 15 | private NPC npc; 16 | public EntityNPCPlayer(Player player, Location location, NPC npc) 17 | { 18 | //super(NMS.getServer(), NMS.getHandle(location.getWorld()), makeProfile(player.getName(), player.getUniqueId()), new PlayerInteractManager(NMS.getHandle(location.getWorld()))); 19 | super(NMS.getServer(), NMS.getHandle(location.getWorld()), ((CraftPlayer)player).getProfile(), new PlayerInteractManager(NMS.getHandle(location.getWorld()))); 20 | this.npc = npc; 21 | playerInteractManager.b(EnumGamemode.SURVIVAL); //MCP = initializeGameType ---- SRG=func_73077_b 22 | playerConnection = new NPCConnection(this); 23 | setPosition(location.getX(), location.getY(), location.getZ()); 24 | } 25 | 26 | @Override 27 | public boolean damageEntity(DamageSource source, float damage) { 28 | Player p = null; 29 | if(source.getEntity() != null && source.getEntity().getBukkitEntity().getType() == EntityType.PLAYER) 30 | p = (Player)source.getEntity().getBukkitEntity(); 31 | if(npc.onKill(p)) 32 | npc = null; 33 | return false; 34 | //return super.damageEntity(source,damage); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_8_R1/NPCConnection.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_8_R1; 2 | 3 | import net.minecraft.server.v1_8_R1.EntityPlayer; 4 | import net.minecraft.server.v1_8_R1.MinecraftServer; 5 | import net.minecraft.server.v1_8_R1.NetworkManager; 6 | import net.minecraft.server.v1_8_R1.Packet; 7 | import net.minecraft.server.v1_8_R1.PlayerConnection; 8 | 9 | public class NPCConnection extends PlayerConnection { 10 | 11 | public NPCConnection(EntityNPCPlayer npc) 12 | { 13 | super(NMS.getServer(), new NPCNetworkManager(), npc); 14 | } 15 | @Override 16 | public void sendPacket(Packet packet) { 17 | //Don't send packets to an npc 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_8_R1/NPCNetworkManager.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_8_R1; 2 | 3 | import java.lang.reflect.Field; 4 | 5 | import net.minecraft.server.v1_8_R1.EnumProtocolDirection; 6 | import net.minecraft.server.v1_8_R1.NetworkManager; 7 | import net.techcable.npclib.util.ReflectUtil; 8 | 9 | public class NPCNetworkManager extends NetworkManager { 10 | 11 | public NPCNetworkManager() { 12 | super(EnumProtocolDirection.CLIENTBOUND); //MCP = isClientSide ---- SRG=field_150747_h 13 | Field channel = ReflectUtil.makeField(NetworkManager.class, "i"); //MCP = channel ---- SRG=field_150746_k 14 | Field address = ReflectUtil.makeField(NetworkManager.class, "j"); //MCP = address ---- SRG=field_77527_e 15 | 16 | ReflectUtil.setField(channel, this, new NullChannel()); 17 | ReflectUtil.setField(address, this, new NullSocketAddress()); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_8_R1/NullChannel.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_8_R1; 2 | 3 | import java.net.SocketAddress; 4 | 5 | import io.netty.channel.AbstractChannel; 6 | import io.netty.channel.Channel; 7 | import io.netty.channel.ChannelConfig; 8 | import io.netty.channel.ChannelMetadata; 9 | import io.netty.channel.ChannelOutboundBuffer; 10 | import io.netty.channel.EventLoop; 11 | 12 | public class NullChannel extends AbstractChannel { 13 | 14 | public NullChannel() { 15 | super(null); 16 | } 17 | 18 | @Override 19 | public ChannelConfig config() { 20 | return null; 21 | } 22 | 23 | @Override 24 | public boolean isActive() { 25 | return false; 26 | } 27 | 28 | @Override 29 | public boolean isOpen() { 30 | return false; 31 | } 32 | 33 | @Override 34 | public ChannelMetadata metadata() { 35 | return null; 36 | } 37 | 38 | @Override 39 | protected void doBeginRead() throws Exception { 40 | } 41 | 42 | @Override 43 | protected void doBind(SocketAddress arg0) throws Exception { 44 | } 45 | 46 | @Override 47 | protected void doClose() throws Exception { 48 | } 49 | 50 | @Override 51 | protected void doDisconnect() throws Exception { 52 | } 53 | 54 | @Override 55 | protected void doWrite(ChannelOutboundBuffer arg0) throws Exception { 56 | } 57 | 58 | @Override 59 | protected boolean isCompatible(EventLoop arg0) { 60 | return false; 61 | } 62 | 63 | @Override 64 | protected SocketAddress localAddress0() { 65 | return null; 66 | } 67 | 68 | @Override 69 | protected AbstractUnsafe newUnsafe() { 70 | return null; 71 | } 72 | 73 | @Override 74 | protected SocketAddress remoteAddress0() { 75 | return null; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_8_R1/NullSocketAddress.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_8_R1; 2 | 3 | import java.net.SocketAddress; 4 | 5 | public class NullSocketAddress extends SocketAddress { 6 | private static final long serialVersionUID = 1L; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_8_R2/EntityNPCPlayer.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_8_R2; 2 | 3 | import net.techcable.npclib.api.NPC; 4 | import com.mojang.authlib.GameProfile; 5 | import com.mojang.authlib.properties.Property; 6 | import net.minecraft.server.v1_8_R2.DamageSource; 7 | import net.minecraft.server.v1_8_R2.EntityPlayer; 8 | import net.minecraft.server.v1_8_R2.PlayerInteractManager; 9 | import net.minecraft.server.v1_8_R2.WorldSettings.EnumGamemode; 10 | import net.techcable.npclib.util.ProfileUtils; 11 | import org.bukkit.Location; 12 | import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; 13 | import org.bukkit.entity.EntityType; 14 | import org.bukkit.entity.Player; 15 | 16 | import java.util.UUID; 17 | 18 | public class EntityNPCPlayer extends EntityPlayer { 19 | 20 | private NPC npc; 21 | public EntityNPCPlayer(Player player, Location location, NPC npc) 22 | { 23 | //super(NMS.getServer(), NMS.getHandle(location.getWorld()), makeProfile(player.getName(), player.getUniqueId()), new PlayerInteractManager(NMS.getHandle(location.getWorld()))); 24 | super(NMS.getServer(), NMS.getHandle(location.getWorld()), ((CraftPlayer)player).getProfile(), new PlayerInteractManager(NMS.getHandle(location.getWorld()))); 25 | this.npc = npc; 26 | playerInteractManager.b(EnumGamemode.SURVIVAL); //MCP = initializeGameType ---- SRG=func_73077_b 27 | playerConnection = new NPCConnection(this); 28 | 29 | setPosition(location.getX(), location.getY(), location.getZ()); 30 | } 31 | 32 | @Override 33 | public boolean damageEntity(DamageSource source, float damage) { 34 | Player p = null; 35 | if(source.getEntity() != null && source.getEntity().getBukkitEntity().getType() == EntityType.PLAYER) 36 | p = (Player)source.getEntity().getBukkitEntity(); 37 | if(npc.onKill(p)) 38 | npc = null; 39 | return false; 40 | //return super.damageEntity(source,damage); 41 | } 42 | 43 | // public static GameProfile makeProfile(String name, UUID skinId) 44 | // { 45 | // GameProfile profile = new GameProfile(UUID.randomUUID(), name); 46 | // if (skinId != null) 47 | // { 48 | // GameProfile skin = new GameProfile(skinId, null); 49 | // skin = NMS.getServer().aC().fillProfileProperties(skin, true); //Srg = func_147130_as 50 | // if (skin.getProperties().get("textures") == null || !skin.getProperties().get("textures").isEmpty()) 51 | // { 52 | // Property textures = skin.getProperties().get("textures").iterator().next(); 53 | // profile.getProperties().put("textures", textures); 54 | // } 55 | // } 56 | // return profile; 57 | // } 58 | } 59 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_8_R2/NPCConnection.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_8_R2; 2 | 3 | import net.minecraft.server.v1_8_R2.Packet; 4 | import net.minecraft.server.v1_8_R2.PlayerConnection; 5 | 6 | public class NPCConnection extends PlayerConnection { 7 | 8 | public NPCConnection(EntityNPCPlayer npc) { 9 | super(NMS.getServer(), new NPCNetworkManager(), npc); 10 | } 11 | @Override 12 | public void sendPacket(Packet packet) { 13 | //Don't send packets to an npc 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_8_R2/NPCNetworkManager.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_8_R2; 2 | 3 | import net.minecraft.server.v1_8_R2.EnumProtocolDirection; 4 | import net.minecraft.server.v1_8_R2.NetworkManager; 5 | import net.techcable.npclib.util.ReflectUtil; 6 | 7 | import java.lang.reflect.Field; 8 | 9 | public class NPCNetworkManager extends NetworkManager { 10 | 11 | public NPCNetworkManager() { 12 | super(EnumProtocolDirection.CLIENTBOUND); //MCP = isClientSide ---- SRG=field_150747_h 13 | Field channel = ReflectUtil.makeField(NetworkManager.class, "k"); //MCP = channel ---- SRG=field_150746_k 14 | Field address = ReflectUtil.makeField(NetworkManager.class, "l"); //MCP = address ---- SRG=field_77527_e 15 | 16 | ReflectUtil.setField(channel, this, new NullChannel()); 17 | ReflectUtil.setField(address, this, new NullSocketAddress()); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_8_R2/NullChannel.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_8_R2; 2 | 3 | import io.netty.channel.AbstractChannel; 4 | import io.netty.channel.ChannelConfig; 5 | import io.netty.channel.ChannelMetadata; 6 | import io.netty.channel.ChannelOutboundBuffer; 7 | import io.netty.channel.EventLoop; 8 | 9 | import java.net.SocketAddress; 10 | 11 | public class NullChannel extends AbstractChannel { 12 | 13 | public NullChannel() { 14 | super(null); 15 | } 16 | 17 | @Override 18 | public ChannelConfig config() { 19 | return null; 20 | } 21 | 22 | @Override 23 | public boolean isActive() { 24 | return false; 25 | } 26 | 27 | @Override 28 | public boolean isOpen() { 29 | return false; 30 | } 31 | 32 | @Override 33 | public ChannelMetadata metadata() { 34 | return null; 35 | } 36 | 37 | @Override 38 | protected void doBeginRead() throws Exception { 39 | } 40 | 41 | @Override 42 | protected void doBind(SocketAddress arg0) throws Exception { 43 | } 44 | 45 | @Override 46 | protected void doClose() throws Exception { 47 | } 48 | 49 | @Override 50 | protected void doDisconnect() throws Exception { 51 | } 52 | 53 | @Override 54 | protected void doWrite(ChannelOutboundBuffer arg0) throws Exception { 55 | } 56 | 57 | @Override 58 | protected boolean isCompatible(EventLoop arg0) { 59 | return false; 60 | } 61 | 62 | @Override 63 | protected SocketAddress localAddress0() { 64 | return null; 65 | } 66 | 67 | @Override 68 | protected AbstractUnsafe newUnsafe() { 69 | return null; 70 | } 71 | 72 | @Override 73 | protected SocketAddress remoteAddress0() { 74 | return null; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /Annihilation/src/net/techcable/npclib/versions/v1_8_R2/NullSocketAddress.java: -------------------------------------------------------------------------------- 1 | package net.techcable.npclib.versions.v1_8_R2; 2 | 3 | import java.net.SocketAddress; 4 | 5 | public class NullSocketAddress extends SocketAddress { 6 | private static final long serialVersionUID = 1L; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) [2016] [Eric Wolfe] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AnnihilationPro 2 | The full source code for the Minecraft plugin AnnihilationPro. 3 | 4 | The last official compiled version of the plugin (1.5.5) can be found here: 5 | https://www.mediafire.com/?eeh190pm52i31r4 6 | --------------------------------------------------------------------------------