diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index d6adafb..ed87a6d 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 195019a..27b6a1f 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,124 +1,134 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.10.0b +version: 3.10.1 commands: money: description: Tells the player the amount of money they are holding. usage: /money - permission: AutoPluginUpdate.money + permission: TwosideKeeper.money permission-message: You don't have permission to check your balance! enchant_advanced: description: Enchants items with more properties. usage: /enchant_advanced - permission: AutoPluginUpdate.enchant + permission: TwosideKeeper.enchant permission-message: No permissions! harden_armor: description: Hardens a piece of armor. usage: /harden_armor - permission: AutoPluginUpdate.harden + permission: TwosideKeeper.harden permission-message: No permissions! item_cube: description: Sets this item as an item cube. usage: /item_cube - permission: AutoPluginUpdate.item_cube + permission: TwosideKeeper.item_cube permission-message: No permissions! artifact: description: Gives the player an artifact. usage: /artifact [amt] - permission: AutoPluginUpdate.artifact + permission: TwosideKeeper.artifact permission-message: No permissions! recyclingcenter: description: Defines a new container for a Recycling Center. usage: /recyclingcenter - permission: AutoPluginUpdate.recyclingcenter + permission: TwosideKeeper.recyclingcenter permission-message: No permissions! glowingitem: description: Creates a new glowing item. usage: /glowingitem - permission: AutoPluginUpdate.glowingitem + permission: TwosideKeeper.glowingitem permission-message: No permissions! sound: description: Toggle sound message notifications. usage: /sound - permission: AutoPluginUpdate.sound + permission: TwosideKeeper.sound permission-message: No permissions! log: - description: Adjusts the debugging log level for AutoPluginUpdate in the console. + description: Adjusts the debugging log level for TwosideKeeper in the console. usage: /log - permission: AutoPluginUpdate.log + permission: TwosideKeeper.log permission-message: No permissions! servertype: description: Sets the server type to another type. usage: /servertype - permission: AutoPluginUpdate.servertype + permission: TwosideKeeper.servertype permission-message: No permissions! ess: description: Generates a Mysterious Essence report. usage: /ess - permission: AutoPluginUpdate.report + permission: TwosideKeeper.report permission-message: No permissions! bow: description: Generates a Bow report. usage: /bow - permission: AutoPluginUpdate.report + permission: TwosideKeeper.report permission-message: No permissions! loot: description: Generates a Loot report. usage: /loot - permission: AutoPluginUpdate.report + permission: TwosideKeeper.report permission-message: No permissions! mega: description: Generates a Mega Piece. usage: /mega - permission: AutoPluginUpdate.mega + permission: TwosideKeeper.mega permission-message: No permissions! fix: description: Does many things depending on what item is being held. Typically if it's broken, typing this will help. usage: /fix - permission: AutoPluginUpdate.fix + permission: TwosideKeeper.fix permission-message: No permissions! tp_world: description: Teleports to a location in a specified world. usage: /tp_world - permission: AutoPluginUpdate.tp_world + permission: TwosideKeeper.tp_world permission-message: No permissions! stats: description: Display statistics for damage and defense. usage: /stats [username] - permission: AutoPluginUpdate.money + permission: TwosideKeeper.money permission-message: No permissions! awakenedartifact: description: Used for upgrading awakened artifacts. usage: /awakenedartifact - permission: AutoPluginUpdate.money + permission: TwosideKeeper.money permission-message: No permissions! awakenedartifact_ability: description: Apply an awakened artifact ability to an item. usage: /awakenedartifact_ability - permission: AutoPluginUpdate.artifact + permission: TwosideKeeper.artifact permission-message: No permissions! mode: description: Displays information about a mode. usage: /mode - permission: AutoPluginUpdate.money + permission: TwosideKeeper.money permission-message: No permissions! dps: description: DPS Logger. usage: /dps - permission: AutoPluginUpdate.money + permission: TwosideKeeper.money permission-message: No permissions! muchlogsmuchwow: description: D00d. usage: /muchlogsmuchwow - permission: AutoPluginUpdate.muchlogsmuchwow + permission: TwosideKeeper.muchlogsmuchwow permission-message: No permissions! make_set_item: description: Turns an item into a set. usage: /make_set_item - permission: AutoPluginUpdate.makesetitem + permission: TwosideKeeper.makesetitem permission-message: No permissions! craft: description: Displays the crafting recipe for a custom item. Press Tab after typing /craft to see options. usage: /craft ITEM - permission: AutoPluginUpdate.money + permission: TwosideKeeper.money + permission-message: No permissions! + weather: + description: Toggles the sending of a weather warning message to the player. + usage: /weather + permission: TwosideKeeper.money + permission-message: No permissions! + ready: + description: Ready up for the tree climbing race. + usage: /ready + permission: TwosideKeeper.money permission-message: No permissions! \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/DropDeathItems.java b/src/sig/plugin/TwosideKeeper/DropDeathItems.java index 8987d0e..028e46a 100644 --- a/src/sig/plugin/TwosideKeeper/DropDeathItems.java +++ b/src/sig/plugin/TwosideKeeper/DropDeathItems.java @@ -1,10 +1,12 @@ package sig.plugin.TwosideKeeper; +import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -23,7 +25,7 @@ public class DropDeathItems implements Runnable{ this.p=p; this.deathloc=deathloc; this.contents=contents; - this.inv_contents = Bukkit.createInventory(p, 36); + this.inv_contents = Bukkit.createInventory(p, 63); for (ItemStack it : contents) { if (it!=null) { inv_contents.addItem(it); @@ -34,7 +36,14 @@ public class DropDeathItems implements Runnable{ @Override public void run() { if (!AttemptToDropItems(p,deathloc)) { - Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin,new DropDeathItems(p,contents,deathloc),1); //Keep trying until the chunk is loaded!!! + TwosideKeeper.log("Re-running...",0); + List tempcontents = new ArrayList(); + for (ItemStack it : inv_contents.getContents()) { + if (it!=null && it.getType()!=Material.AIR) { + tempcontents.add(it); + } + } + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin,new DropDeathItems(p,tempcontents,deathloc),1); //Keep trying until the chunk is loaded!!! TwosideKeeper.temporary_chunks.clear(); } } @@ -47,13 +56,16 @@ public class DropDeathItems implements Runnable{ while (!InventoryUtils.hasEmptyInventory(inv_contents)) { if (deathloc.getChunk().isLoaded()) { Item it = deathloc.getWorld().dropItemNaturally(deathloc, InventoryUtils.getFirstItemThatIsNotEmpty(inv_contents)); - if (it!=null) { + it.setInvulnerable(true); + if (it!=null && it.isValid()) { inv_contents.removeItem(it.getItemStack()); TwosideKeeper.log("Dropping "+it.getItemStack().toString()+" at Death location "+deathloc,2); } else { + TwosideKeeper.log("Item did not spawn! Will try again.",0); return false; } } else { + TwosideKeeper.log("Chunk is not loaded! Will try again.",0); return false; } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 95c8735..715076b 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -1376,6 +1376,9 @@ public class GenericFunctions { } } } + case MYCEL:{ + return "Mycelium"; + } case HARD_CLAY:{ return "Hardened Clay"; } @@ -3206,9 +3209,19 @@ public class GenericFunctions { UpdateHuntersCompass(item); UpdateUpgradeShard(item); UpdateOldQuivers(item); + UpdateItemCubeContentsList(item); return item; } + //TODO Item Cube Contents list. + private static void UpdateItemCubeContentsList(ItemStack item) { + /*if (ItemUtils.isValidLoreItem(item) && + item.getItemMeta().getLore().size()>=4 && + ) { + + }*/ + } + private static void UpdateOldQuivers(ItemStack item) { if (item!=null && item.getType()==Material.TIPPED_ARROW && diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java index 67122bf..294694a 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java @@ -28,7 +28,7 @@ public enum RecipeLinker { eic(RecipeCategory.CONTAINERS,ChatColor.YELLOW,"Ender Item Cube",new ItemStack[]{ CustomItem.EnderItemCube(), new ItemStack(Material.OBSIDIAN),new ItemStack(Material.OBSIDIAN),new ItemStack(Material.OBSIDIAN), - new ItemStack(Material.EMERALD),new ItemStack(Material.CHEST),new ItemStack(Material.EMERALD), + new ItemStack(Material.EMERALD),new ItemStack(Material.ENDER_CHEST),new ItemStack(Material.EMERALD), new ItemStack(Material.OBSIDIAN),new ItemStack(Material.OBSIDIAN),new ItemStack(Material.OBSIDIAN), }), vacuumcube(RecipeCategory.CONTAINERS,ChatColor.YELLOW,"Vacuum Cube",new ItemStack[]{ diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/BiomeUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/BiomeUtils.java new file mode 100644 index 0000000..f52801e --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/BiomeUtils.java @@ -0,0 +1,18 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Utils; + +import org.bukkit.block.Biome; + +public class BiomeUtils { + + public static boolean isColdBiome(Biome biome) { + return (biome==Biome.ICE_FLATS || + biome==Biome.ICE_MOUNTAINS || + biome==Biome.MUTATED_ICE_FLATS || + biome==Biome.TAIGA_COLD || + biome==Biome.TAIGA_COLD_HILLS || + biome==Biome.FROZEN_RIVER || + biome==Biome.COLD_BEACH || + biome==Biome.FROZEN_OCEAN); + } + +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/DirtBlockReply.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/DirtBlockReply.java new file mode 100644 index 0000000..ea410ae --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/DirtBlockReply.java @@ -0,0 +1,8 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Utils; + +public enum DirtBlockReply { + HOLDING5DIRT, + NOTENOUGHDIRT, + TOOMUCHDIRT, + NOTEMPTYINVENTORY +} \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java index 7c5cc19..7eed2e6 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java @@ -15,6 +15,7 @@ import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.HelperStructures.CubeType; import sig.plugin.TwosideKeeper.HelperStructures.CustomItem; import sig.plugin.TwosideKeeper.HelperStructures.ItemCube; +import sig.plugin.TwosideKeeper.HolidayEvents.Christmas; public class InventoryUtils { public static boolean isCarryingVacuumCube(Player p) { @@ -130,4 +131,28 @@ public class InventoryUtils { } return null; } + public static DirtBlockReply onlyHoldingFiveDirtBlocks(Player p) { + Inventory inv = p.getInventory(); + int dirtblockcount=0; + for (ItemStack i : inv.getContents()) { + if (i!=null) { + if (i.getType()==Material.DIRT) { + dirtblockcount+=i.getAmount(); + } else { + if (!Christmas.isCookieItem(i)) { + return DirtBlockReply.NOTEMPTYINVENTORY; + } + } + } + } + if (dirtblockcount==5) { + return DirtBlockReply.HOLDING5DIRT; + } else + if (dirtblockcount<5) { + return DirtBlockReply.NOTENOUGHDIRT; + } else + { + return DirtBlockReply.TOOMUCHDIRT; + } + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemCubeUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemCubeUtils.java index fbf32ef..cf7a405 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemCubeUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemCubeUtils.java @@ -81,4 +81,14 @@ public class ItemCubeUtils { } return false; } + public static boolean isItemCubeMaterial(Material mat) { + if (mat==Material.CHEST || + mat==Material.ENDER_CHEST || + mat==Material.HOPPER_MINECART || + mat==Material.STORAGE_MINECART) { + return true; + } else { + return false; + } + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/TextUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/TextUtils.java new file mode 100644 index 0000000..3512d7b --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/TextUtils.java @@ -0,0 +1,21 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Utils; + +import org.bukkit.ChatColor; + +public class TextUtils { + + public static ChatColor RandomColor() { + ChatColor[] colors = {ChatColor.AQUA, + ChatColor.BLACK, + ChatColor.BLUE,ChatColor.DARK_AQUA, + ChatColor.DARK_BLUE,ChatColor.DARK_GRAY, + ChatColor.DARK_GREEN,ChatColor.DARK_PURPLE, + ChatColor.DARK_RED,ChatColor.GOLD, + ChatColor.GRAY,ChatColor.GREEN, + ChatColor.LIGHT_PURPLE,ChatColor.RED, + ChatColor.WHITE,ChatColor.YELLOW}; + + return colors[((int)(Math.random()*colors.length))]; + } + +} diff --git a/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java b/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java new file mode 100644 index 0000000..009571d --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java @@ -0,0 +1,238 @@ +package sig.plugin.TwosideKeeper.HolidayEvents; + +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Chest; +import org.bukkit.block.Sign; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowman; +import org.bukkit.event.Event.Result; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import aPlugin.API.Chests; +import aPlugin.DropItem; +import aPlugin.DropMaterial; +import sig.plugin.TwosideKeeper.TwosideKeeper; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.BiomeUtils; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.TextUtils; + +public class Christmas { + public final static String CHRISTMAS_TAG = ChatColor.BLUE+"Christmas Event Item"+ChatColor.RESET; + + public static void insertChristmasTag(ItemStack item) { + ItemUtils.addLore(item, CHRISTMAS_TAG); + } + + public static ItemStack getRocketBoosterItem() { + ItemStack item = new ItemStack(Material.FIREWORK); + ItemUtils.setDisplayName(item, ChatColor.DARK_AQUA+"Rocket Booster"); + insertChristmasTag(item); + ItemUtils.addLore(item, "A Launcher that shoots you"); + ItemUtils.addLore(item, "extremely fast in your facing"); + ItemUtils.addLore(item, "direction. Slowly recharges"); + ItemUtils.addLore(item, "over time if kept on the hotbar."); + item.addUnsafeEnchantment(Enchantment.LUCK, 0); + ItemUtils.hideEnchantments(item); + return item.clone(); + } + + public static boolean isRocketBoosterItem(ItemStack item) { + return ItemUtils.isValidLoreItem(item) && item.getType()==Material.FIREWORK && ItemUtils.LoreContains(item, CHRISTMAS_TAG); + } + + public static ItemStack getCookieItem() { + ItemStack item = new ItemStack(Material.COOKIE); + ItemUtils.setDisplayName(item, ChatColor.AQUA+"Holiday Cookie"); + ItemUtils.addLore(item, ChatColor.WHITE+"Heals"+ChatColor.YELLOW+" 256 "+ChatColor.RESET+"health."); + ItemUtils.addLore(item, ChatColor.GRAY+"- Strength II (15:00)"); + ItemUtils.addLore(item, ChatColor.GRAY+"- Resistance II (15:00)"); + ItemUtils.addLore(item, ChatColor.GRAY+"- Regeneration III (15:00)"); + ItemUtils.addLore(item, ChatColor.GRAY+"- Saturation (5:00)"); + ItemUtils.addLore(item, ""); + insertChristmasTag(item); + ItemUtils.addLore(item, "A sweet and delicious cookie"); + ItemUtils.addLore(item, "that provides wonderful buffs."); + return item.clone(); + } + + public static boolean isCookieItem(ItemStack item) { + return ItemUtils.isValidLoreItem(item) && item.getType()==Material.COOKIE && ItemUtils.LoreContains(item, CHRISTMAS_TAG); + } + + public static ItemStack getChristmasEventToken() { + ItemStack item = new ItemStack(Material.COMMAND_REPEATING); + ItemUtils.setDisplayName(item, ChatColor.AQUA+"Christmas Token"); + insertChristmasTag(item); + ItemUtils.addLore(item, "A token used to obtain special"); + ItemUtils.addLore(item, "treats and goodies for the Christmas"); + ItemUtils.addLore(item, "event. Turn in tokens to the "); + ItemUtils.addLore(item, "Twoside Bank Tree."); + ItemUtils.addLore(item, ""); + return item.clone(); + } + + public static boolean isChristmasEventToken(ItemStack item) { + return ItemUtils.isValidLoreItem(item) && item.getType()==Material.COMMAND_REPEATING && ItemUtils.LoreContains(item, CHRISTMAS_TAG); + } + + public static ItemStack getChristmasTreeSchematic() { + ItemStack item = new ItemStack(Material.PAPER); + ItemUtils.setDisplayName(item, ChatColor.AQUA+"Christmas Tree Schematic"); + insertChristmasTag(item); + ItemUtils.addLore(item, "A blueprint for the creation of an"); + ItemUtils.addLore(item, "excellent Christmas Tree. Must be"); + ItemUtils.addLore(item, "placed on a proper Tree plot to"); + ItemUtils.addLore(item, "grow."); + return item.clone(); + } + + public static boolean isChristmasTreeSchematic(ItemStack item) { + return ItemUtils.isValidLoreItem(item) && item.getType()==Material.PAPER && ItemUtils.LoreContains(item, CHRISTMAS_TAG); + } + + public static void InitializeChristmasBox() { + Chests c = aPlugin.API.Chests.LOOT_CUSTOM_2; + c.addDrop(new DropMaterial(Material.COAL,1,4,10)); + c.addDrop(new DropMaterial(Material.IRON_INGOT,1,4,10)); + c.addDrop(new DropMaterial(Material.GOLD_INGOT,1,4,10)); + c.addDrop(new DropMaterial(Material.REDSTONE,1,4,10)); + c.addDrop(new DropMaterial(Material.GLOWSTONE_DUST,1,4,10)); + c.addDrop(new DropMaterial(Material.QUARTZ,1,4,10)); + c.addDrop(new DropMaterial(Material.INK_SACK,1,4,10,(short)4)); + c.addDrop(new DropMaterial(Material.DIAMOND,1,4,10)); + c.addDrop(new DropMaterial(Material.EMERALD,1,4,10)); + c.addDrop(new DropMaterial(Material.COAL_BLOCK,1,4,5)); + c.addDrop(new DropMaterial(Material.IRON_BLOCK,1,4,5)); + c.addDrop(new DropMaterial(Material.GOLD_BLOCK,1,4,5)); + c.addDrop(new DropMaterial(Material.REDSTONE_BLOCK,1,4,5)); + c.addDrop(new DropMaterial(Material.GLOWSTONE,1,4,5)); + c.addDrop(new DropMaterial(Material.QUARTZ_BLOCK,1,4,5)); + c.addDrop(new DropMaterial(Material.LAPIS_BLOCK,1,4,5)); + c.addDrop(new DropMaterial(Material.DIAMOND_BLOCK,1,4,5)); + c.addDrop(new DropMaterial(Material.EMERALD_BLOCK,1,4,5)); + c.addDrop(new DropItem(getCookieItem(),1,3,5)); + c.addDrop(new DropItem(getChristmasEventToken(),10)); + //aPlugin.API.getChestItem(c); + } + + public static boolean RunPlayerInteractEvent(PlayerInteractEvent ev) { + if (TwosideKeeper.CHRISTMASEVENT_ACTIVATED) { + Player p = ev.getPlayer(); + if (ev.getAction()==Action.RIGHT_CLICK_BLOCK) { + Block b = ev.getClickedBlock(); + if (b.getType()==Material.SMOOTH_BRICK && isChristmasTreeSchematic(p.getEquipment().getItemInMainHand())) { + //Remove the item from the player. + p.getEquipment().setItemInMainHand(new ItemStack(Material.AIR)); + //Plant a tree. + TreeBuilder.BuildNewTree(b.getLocation().add(15,1,15), 12, 13, 0); + p.sendMessage(ChatColor.AQUA+"You place the schematic down..."); + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{p.sendMessage(ChatColor.GREEN+" Magic seems to activate inside the ground.");},5); + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{b.setType(Material.HOPPER);},2); + Block babove = b.getRelative(0, 1, 0); + Block bbelow = b.getRelative(0, -1, 0); + bbelow.setType(Material.CHEST); + babove.setType(Material.SIGN_POST); + Sign s = (Sign)babove.getState(); + s.setLine(1, RandomDarkColor()+p.getName()+"'s"); + s.setLine(2, "Tree"); + s.setRawData((byte)4); + s.update(); + ev.setUseInteractedBlock(Result.DENY); + ev.setCancelled(true); + return false; + } + } + } + return true; + } + + private static ChatColor RandomDarkColor() { + ChatColor[] choices = new ChatColor[]{ChatColor.DARK_AQUA,ChatColor.DARK_BLUE,ChatColor.DARK_GRAY,ChatColor.DARK_GREEN,ChatColor.DARK_PURPLE,ChatColor.DARK_RED,ChatColor.GOLD}; + return choices[(int)(Math.random()*choices.length)]; + } + + public static void ChristmasHeartbeat() { + int range = 8; + for (Player p : Bukkit.getOnlinePlayers()) { + //Check a random block around the player. + int blockx = (int)(Math.random()*(range*2))-range; + int blockz = (int)(Math.random()*(range*2))-range; + Block b = p.getWorld().getHighestBlockAt(p.getLocation().getBlockX()+blockx, p.getLocation().getBlockZ()+blockz); + Block bbelow = b.getRelative(0, -1, 0); + if (TwosideKeeper.CHRISTMASEVENT_ACTIVATED) { + if (b.getType()==Material.AIR && bbelow.getType().isSolid() && !bbelow.getType().name().contains("STEP") && b.getTemperature()<=0.95) { + b.setType(Material.SNOW); + b.setData((byte)0); + if (TwosideKeeper.last_snow_golem+TwosideKeeper.SNOW_GOLEM_COOLDOWN nearbyents = p.getNearbyEntities(32, 24, 32); + boolean snowmannearby=false; + for (Entity ent : nearbyents) { + if (ent instanceof Snowman) { + snowmannearby=true; + break; + } + } + if (!snowmannearby) { + //Spawn one on the snow. + Snowman snowy = (Snowman)p.getWorld().spawnEntity(b.getLocation().add(0,2,0), EntityType.SNOWMAN); + snowy.setCustomName(RandomSnowmanName()); + snowy.setMaxHealth(Math.random()*100+20); + snowy.setHealth(snowy.getMaxHealth()); + snowy.setAI(true); + } + } + } else + if (b.getType()==Material.SNOW && b.getData()<7) { + b.setData((byte)(b.getData()+1)); + } + }/* else { //Unnecessary. Snow will automatically melt. + if (b.getType()==Material.SNOW && b.getTemperature()>0.15) { + b.setType(Material.AIR); + } + }*/ + } + } + + private static String RandomSnowmanName() { + String[] name1 = {"Jingle","Merry","Bells", + "Tinkle","Angel","Twinkle", + "Rosie","Holly","Berry", + "Festive","Candy","Magic", + "Sparkle","Sugarplum","Joy", + "Tinsel","Robin","Cookie", + "Hope","Sweetie","Teddy", + "Jolly","Cosy","Sherry", + "Eve","Pinky"}; + String[] name2 = {"McSnowy","McSlushy","McChilly", + "McGlisten","McSparkle","McFrosty", + "McFreeze","McSnowballs","McIcicles", + "McBlizzard","McSparkles","McSnowflake"}; + + ChatColor col = TextUtils.RandomColor(); + + return col+name1[(int)(Math.random()*name1.length)]+" "+name2[(int)(Math.random()*name2.length)]; + } + + public static boolean ChristmasDamageEvent(EntityDamageEvent ev) { + if (TwosideKeeper.CHRISTMASEVENT_ACTIVATED) { + if (ev.getCause()==DamageCause.MELTING && (ev.getEntity() instanceof Snowman)) { + ev.setCancelled(true); + return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/HolidayEvents/TreeBuilder.java b/src/sig/plugin/TwosideKeeper/HolidayEvents/TreeBuilder.java new file mode 100644 index 0000000..51be463 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HolidayEvents/TreeBuilder.java @@ -0,0 +1,163 @@ +package sig.plugin.TwosideKeeper.HolidayEvents; + +import java.util.Random; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; + +import sig.plugin.TwosideKeeper.TwosideKeeper; +import sig.plugin.TwosideKeeper.HelperStructures.Common.BlockModifyQueue; + +public class TreeBuilder{ + int height = 8; + double radius = 10; + double initialradius = 10; + int branches = 10; + int spacing = 3; + int baserad = 0; + Location loc; + + public static TreeBuilder BuildNewTree(Location loc, int height, double radius, int baseradius) { + TreeBuilder builder = new TreeBuilder(loc,height,radius,baseradius); + builder.BuildTree(); + return builder; + } + + public TreeBuilder(Location loc, int height, double radius, int baseradius) { + this.height=height; + this.radius=radius; + this.initialradius=radius; + this.branches=height+2; + this.loc=loc.clone(); + this.baserad=baseradius; + this.spacing=height/6+1; + } + + public void BuildTree() { + //BuildTreeBase(loc,baserad,height*spacing); + for (int y=0;y0;split--) { + double randminoroffsetdir = (java.util.concurrent.ThreadLocalRandom.current().nextDouble()*(360/(double)branches))/4; + TreeBranch branch = new TreeBranch(loc,(360/(double)branches)*(double)split+randoffsetdir+randminoroffsetdir,radius); + branch.build(); + } + radius-=(initialradius/(double)height); + branches--; + } + } + + private void BuildTreeBase(Location loc, int width, int height) { + Location currentloc = loc.clone().add(-1,0,-1); + for (int i=0;i modifiers = attribute.getModifiers(); for (AttributeModifier modifier : modifiers) { diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index df18eda..a54bd34 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -122,6 +122,8 @@ public class PlayerStructure { public long lastvendettastack=0; public long lastlavaplume=0; public long usetimer=0; + public boolean weatherwatch=false; + public String weatherwatch_user=""; public long iframetime = 0; @@ -294,6 +296,8 @@ public class PlayerStructure { workable.set("weaponcharges", weaponcharges); workable.set("damagepool", damagepool); workable.set("vendetta_amt", vendetta_amt); + workable.set("weatherwatch", weatherwatch); + workable.set("weatherwatch_user", weatherwatch_user); //ConfigurationSection deathlootlist = workable.createSection("deathloot"); if (DeathManager.deathStructureExists(Bukkit.getPlayer(name))) { DeathStructure ds = DeathManager.getDeathStructure(Bukkit.getPlayer(name)); @@ -342,6 +346,8 @@ public class PlayerStructure { workable.addDefault("weaponcharges", weaponcharges); workable.addDefault("lifestealstacks", lifestealstacks); workable.addDefault("vendetta_amt", vendetta_amt); + workable.addDefault("weatherwatch", weatherwatch); + workable.addDefault("weatherwatch_user", weatherwatch_user); workable.options().copyDefaults(); @@ -369,6 +375,8 @@ public class PlayerStructure { this.weaponcharges = workable.getInt("weaponcharges"); this.lastattacked = TwosideKeeper.getServerTickTime(); this.lastcombat = TwosideKeeper.getServerTickTime(); + this.weatherwatch = workable.getBoolean("weatherwatch"); + this.weatherwatch_user = workable.getString("weatherwatch_user"); if (this.hasDied) { List deathlootlist = new ArrayList(); diff --git a/src/sig/plugin/TwosideKeeper/RecyclingCenter.java b/src/sig/plugin/TwosideKeeper/RecyclingCenter.java index f477dda..a7303e5 100644 --- a/src/sig/plugin/TwosideKeeper/RecyclingCenter.java +++ b/src/sig/plugin/TwosideKeeper/RecyclingCenter.java @@ -16,6 +16,7 @@ import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; @@ -175,24 +176,23 @@ public class RecyclingCenter { b.getType()==Material.TRAPPED_CHEST) { if (b.getState()!=null) { Chest c = (Chest) b.getState(); - for (int j=0;j<27;j++) { - if (c.getBlockInventory().getItem(j)!=null && c.getBlockInventory().getItem(j).getType()==i.getType()) { - } - } - int itemslot = (int)Math.floor(Math.random()*27); - ItemStack oldItem = c.getBlockInventory().getItem(itemslot); + int itemslot = RandomlyChooseEmptySpot(c.getBlockInventory()); + //ItemStack oldItem = c.getBlockInventory().getItem(itemslot); //There is also a chance to move this item to another random spot. if (!isCommon(i.getType()) || mustBeRecycled(i)) { - if (oldItem!=null && (Math.random()*100<=TwosideKeeper.RECYCLECHANCE || mustBeRecycled(i))) { + /*if (oldItem!=null && (Math.random()*100<=TwosideKeeper.RECYCLECHANCE || mustBeRecycled(i))) { int itemslot2 = (int)Math.floor(Math.random()*27); c.getBlockInventory().setItem(itemslot2, oldItem); - } + }*/ c.getBlockInventory().setItem(itemslot, i); populateItemList(i); - if (TwosideKeeper.LOGGING_LEVEL>=3) { - TwosideKeeper.log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i)+((i.getAmount()>1)?ChatColor.YELLOW+" x"+i.getAmount():"")+ChatColor.RESET+" to Recycling Center Node "+rand_node.toString(),2); + if (TwosideKeeper.LOGGING_LEVEL>=2) { + TwosideKeeper.log("Sent "+ChatColor.AQUA+i.toString()+ChatColor.RESET+" to Recycling Center Node "+rand_node.toString(),2); + } else { + if (TwosideKeeper.LOGGING_LEVEL>=1) { + TwosideKeeper.log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i)+((i.getAmount()>1)?ChatColor.YELLOW+" x"+i.getAmount():"")+ChatColor.RESET+" to Recycling Center Node "+rand_node.toString(),1); } else { - TwosideKeeper.log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i)+((i.getAmount()>1)?ChatColor.YELLOW+" x"+i.getAmount():"")+ChatColor.RESET+" to Recycling Center.",2); + TwosideKeeper.log("Sent "+ChatColor.AQUA+GenericFunctions.UserFriendlyMaterialName(i)+((i.getAmount()>1)?ChatColor.YELLOW+" x"+i.getAmount():"")+ChatColor.RESET+" to Recycling Center.",0); } } } @@ -200,9 +200,24 @@ public class RecyclingCenter { } else { TwosideKeeper.log("No Recycling Center Nodes set! All dropped items will continue to be discarded. Use /recyclingcenter to define them.",1); } - } + } + } + } + + private int RandomlyChooseEmptySpot(Inventory blockInventory) { + int i=54; + while (i>0) { + int randomslot = (int)Math.floor(Math.random()*27); + ItemStack item = blockInventory.getItem(randomslot); + if (item==null || item.getType()==Material.AIR) { + //This is empty. + return randomslot; + } + i--; + } + return (int)Math.floor(Math.random()*27); } - + public static boolean mustBeRecycled(ItemStack it) { if (GenericFunctions.isArtifactEquip(it) || ItemUtils.isArtifactDust(it)) { return true; diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 15ff8b6..fa86d11 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -202,11 +202,14 @@ import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume; import sig.plugin.TwosideKeeper.HelperStructures.Effects.TemporaryLava; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArrayUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.BlockUtils; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.DirtBlockReply; import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemCubeUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.TimeUtils; +import sig.plugin.TwosideKeeper.HolidayEvents.Christmas; +import sig.plugin.TwosideKeeper.HolidayEvents.TreeBuilder; import sig.plugin.TwosideKeeper.Logging.BowModeLogger; import sig.plugin.TwosideKeeper.Logging.LootLogger; import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger; @@ -376,6 +379,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static final int SPAWN_DEBUG_LEVEL=5; public static final int LAVA_PLUME_COOLDOWN=60; + public static final int SNOW_GOLEM_COOLDOWN=60; + public static final int DODGE_COOLDOWN=100; public static final int DEATHMARK_COOLDOWN=240; public static final int EARTHWAVE_COOLDOWN=100; @@ -399,6 +404,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static double worldShopPriceMult = 2.0; //How much higher the price increases for every increment of worlsShopDistanceSquared. public static String lastActionBarMessage=""; + public static long last_snow_golem = 0; public static File filesave; public static HashMap playerdata; @@ -428,11 +434,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Bank timers and users. public static HashMap banksessions; public static Habitation habitat_data; + public static boolean last_announced_storm = false; //Whether or not the last announcement was about a storm. + + public static List weather_watch_users = new ArrayList(); public static Plugin plugin; public int sleepingPlayers=0; public static List validsetitems = new ArrayList(); + public final static boolean CHRISTMASEVENT_ACTIVATED=true; + boolean reloadedchunk=false; int[] lampblocks = {1626,71,-255, //List of all lamp blocks in the city to be lit. @@ -1049,6 +1060,67 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } }break; + case "SPAWN":{ + Location loc = new Location(Bukkit.getWorld(args[1]),Double.parseDouble(args[2]),Double.parseDouble(args[3]),Double.parseDouble(args[4])); + + Item it = p.getWorld().dropItemNaturally(loc, new ItemStack(Material.DIAMOND)); + if (it.isValid()) { + log("Spawned a "+it.getItemStack(),0); + } else { + log("Failed to spawn "+it.getItemStack(),0); + } + }break; + case "RECYCLE":{ + Item it = p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(p.getEquipment().getItemInMainHand())); + it.setPickupDelay(100); + it.setTicksLived(28000); + }break; + case "STORM":{ + TwosideKeeper.log("Storm: "+p.getWorld().hasStorm()+". Thunder: "+p.getWorld().isThundering(), 1); + }break; + case "SETRAIN":{ + p.getWorld().setStorm(true); + //TwosideKeeper.log("Storm: "+p.getWorld().hasStorm()+". Thunder: "+p.getWorld().isThundering(), 1); + }break; + case "SETTHUNDER":{ + p.getWorld().setThundering(true); + //TwosideKeeper.log("Storm: "+p.getWorld().hasStorm()+". Thunder: "+p.getWorld().isThundering(), 1); + }break; + case "BUILDTREE":{ + if (args.length==4) { + TreeBuilder builder = new TreeBuilder(p.getLocation(),Integer.parseInt(args[1]),Integer.parseInt(args[2]),Integer.parseInt(args[3])); + builder.BuildTree(); + } else { + p.sendMessage("/fix BUILDTREE "); + } + }break; + case "GIVESCHEMATIC":{ + if (args.length==1) { + GenericFunctions.giveItem(p, Christmas.getChristmasTreeSchematic()); + } else + if (args.length==2) { + ItemStack schematic = Christmas.getChristmasTreeSchematic(); + schematic.setAmount(Integer.parseInt(args[1])); + GenericFunctions.giveItem(p, schematic); + } else { + p.sendMessage("/fix GIVESCHEMATIC [amount]"); + } + }break; + case "FORCEBLOCKQUEUE":{ + BlockModifyQueue.Cleanup(blockqueue); + }break; + case "COOKIE":{ + if (args.length==1) { + GenericFunctions.giveItem(p, Christmas.getCookieItem()); + } else + if (args.length==2) { + ItemStack schematic = Christmas.getCookieItem(); + schematic.setAmount(Integer.parseInt(args[1])); + GenericFunctions.giveItem(p, schematic); + } else { + p.sendMessage("/fix COOKIE [amount]"); + } + }break; } } //LivingEntity m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE); @@ -1171,7 +1243,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { return true; } else if (cmd.getName().equalsIgnoreCase("money")) { - sender.sendMessage("You are currently holding "+ChatColor.GREEN+"$"+df.format(getPlayerMoney(Bukkit.getPlayer(sender.getName())))); + Player p = (Player)sender; + sender.sendMessage("You are currently holding "+ChatColor.GREEN+"$"+df.format(getPlayerMoney(p))); return true; } else if (cmd.getName().equalsIgnoreCase("enchant_advanced")) { @@ -1405,14 +1478,69 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } return true; - } + } else + if (cmd.getName().equalsIgnoreCase("weather")) { + Player p = (Player)sender; + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (args.length==0) { + if (!pd.weatherwatch_user.isEmpty() && !pd.weatherwatch) { + p.sendMessage("Turned "+ChatColor.GREEN+"ON"+ChatColor.RESET+" weather warning for Discord user "+pd.weatherwatch_user+"."); + p.sendMessage(ChatColor.ITALIC+" To disable them, type /weather"); + pd.weatherwatch=true; + AddUserToWeatherWatch(p); + } else { + p.sendMessage("Weather warnings are turned "+ChatColor.RED+"OFF"+ChatColor.RESET+"."); + p.sendMessage(ChatColor.ITALIC+" To enable them, type /weather "); + p.sendMessage(ChatColor.ITALIC+" and replace with your name."); + pd.weatherwatch=false; + RemoveUserFromWeatherWatch(p); + } + } else { + p.sendMessage("Turned "+ChatColor.GREEN+"ON"+ChatColor.RESET+" weather warning for Discord user "+args[0]+"."); + p.sendMessage(ChatColor.ITALIC+" To disable them, type /weather"); + pd.weatherwatch_user = args[0]; + pd.weatherwatch=true; + AddUserToWeatherWatch(p); + } + return true; + } else + if (cmd.getName().equalsIgnoreCase("ready")) { + Player p = (Player)sender; + switch (InventoryUtils.onlyHoldingFiveDirtBlocks(p)) { + case HOLDING5DIRT:{ + Bukkit.broadcastMessage(p.getName()+" is "+ChatColor.GREEN+"READY"+"."); + }break; + case NOTEMPTYINVENTORY: + Bukkit.broadcastMessage(p.getName()+" is "+ChatColor.RED+"NOT READY"+"."); + p.sendMessage(" You need to get rid of "+ChatColor.RED+"ALL ITEMS"+ChatColor.RESET+" to play."); + break; + case NOTENOUGHDIRT: + Bukkit.broadcastMessage(p.getName()+" is "+ChatColor.RED+"NOT READY"+"."); + p.sendMessage(" You need to have exactly "+ChatColor.YELLOW+"5 DIRT BLOCKS"+ChatColor.RESET+" to play."); + break; + case TOOMUCHDIRT: + Bukkit.broadcastMessage(p.getName()+" is "+ChatColor.RED+"NOT READY"+"."); + p.sendMessage(" You need to have exactly "+ChatColor.YELLOW+"5 DIRT BLOCKS"+ChatColor.RESET+" to play."); + break; + } + return true; + } } else { //Implement console/admin version later (Let's you check any name's money.) } return false; } - private void DisplayCraftingRecipe(Player p, String string) { + private void RemoveUserFromWeatherWatch(Player p) { + weather_watch_users.remove(p.getName()); + } + private void AddUserToWeatherWatch(Player p) { + if (!weather_watch_users.contains(p.getName())) { + weather_watch_users.add(p.getName()); + } + } + + private void DisplayCraftingRecipe(Player p, String string) { RecipeLinker l = RecipeLinker.valueOf(string); ItemStack[] newarray = Arrays.copyOfRange(l.getRec(), 1, l.getRec().length); if (p.hasPermission("createViaCraftMenu") && (getServerType()==ServerType.TEST || getServerType()==ServerType.QUIET)) { @@ -2161,6 +2289,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { setPlayerMaxHealth(p); } },1); + + if (!Christmas.RunPlayerInteractEvent(ev)) {return;} + if (ev.getClickedBlock()!=null && ev.getClickedBlock().getType()==Material.CHEST && TwosideRecyclingCenter.isChoosingRecyclingCenter() && ev.getPlayer().hasPermission("TwosideKeeper.recyclingcenter")) { @@ -2515,7 +2646,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getClickedBlock().getType().toString().contains("RAIL") && ev.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasLore() && - ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().size()==4 && + ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().size()>=4 && ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { ev.setCancelled(true); //Do not place minecarts on rails -.- ev.getPlayer().updateInventory(); @@ -2524,7 +2655,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ev.getAction()==Action.RIGHT_CLICK_AIR || (ev.getPlayer().isSneaking() && ev.getAction()==Action.RIGHT_CLICK_AIR) || (ev.getPlayer().isSneaking() && ev.getAction()==Action.RIGHT_CLICK_BLOCK && !GenericFunctions.isDumpableContainer(ev.getClickedBlock().getType()))) { if (ev.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasLore() && - ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().size()==4 && + ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().size()>=4 && ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { //This is an item cube. log("In we are",5); @@ -2561,7 +2692,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //This is an attempt to insert an item cube into a container. See what item cube we're holding. if (ev.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasLore() && - ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().size()==4 && + ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().size()>=4 && ev.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { ev.setCancelled(true); @@ -3085,7 +3216,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ev.getItemInHand().hasItemMeta() && ev.getItemInHand().getItemMeta().hasLore() && - ev.getItemInHand().getItemMeta().getLore().size()==4 && + ev.getItemInHand().getItemMeta().getLore().size()>=4 && ev.getItemInHand().getItemMeta().getLore().get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { //This is an item cube. ev.setCancelled(true); @@ -3135,7 +3266,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { DecimalFormat df = new DecimalFormat("0.00"); if (p!=null) { p.sendMessage(ChatColor.GRAY+"Due to death, you lost "+DEATHPENALTY+"% of your holding money. "); - givePlayerMoney(p,-Math.round(getPlayerMoney(p)/2)); + givePlayerMoney(p,-(getPlayerMoney(p)/2)); p.sendMessage(" Now Holding: "+ChatColor.GREEN+"$"+df.format(getPlayerMoney(p))); } @@ -3238,7 +3369,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void onSignChange(SignChangeEvent ev) { - Player p = ev.getPlayer(); + Player p = ev.getPlayer(); String line1 = ev.getLine(0); String line2 = ev.getLine(2); //-- BANK -- @@ -3246,13 +3377,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Make sure we're Op, otherwise we're not allowed to do this. if (line1.equalsIgnoreCase("-- bank --") && line2.equalsIgnoreCase("Check Balance")) { - //Turn it into a bank sign. + //Turn it into a bank sign. ev.setLine(0, ChatColor.AQUA+"-- BANK --"); ev.setLine(1, ChatColor.GREEN+"CHECK BALANCE"); ev.setLine(2, "Right-Click"); ev.setLine(3, "to use"); p.sendMessage("Successfully created a Balance Bank Sign."); - } else + } else if (line1.equalsIgnoreCase("-- bank --") && line2.equalsIgnoreCase("Withdraw")) { //Turn it into a bank sign. @@ -3459,7 +3590,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ev.getItemDrop().getItemStack().hasItemMeta()) { if (ev.getItemDrop().getItemStack().getItemMeta().hasLore()) { - if (ev.getItemDrop().getItemStack().getItemMeta().getLore().size()==4) { + if (ev.getItemDrop().getItemStack().getItemMeta().getLore().size()>=4) { if (ev.getItemDrop().getItemStack().getItemMeta().getLore().get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { //We have an item cube. int itemcube_id=Integer.parseInt(ev.getItemDrop().getItemStack().getItemMeta().getLore().get(3).split("#")[1]); @@ -3615,7 +3746,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { amounttotake = diff; givePlayerBankMoney(p,-amounttotake); } - DropDeathInventoryContents(p, deathloc, 1); + DropDeathInventoryContents(p, deathloc, 0); } PlayerStructure pd = (PlayerStructure) playerdata.get(p.getUniqueId()); @@ -3679,9 +3810,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { do { deathloc.getWorld().loadChunk(deathloc.getChunk()); it=deathloc.getWorld().dropItemNaturally(deathloc, list.get(0)); + it.setInvulnerable(true); TwosideKeeper.temporary_chunks.add(deathloc.getChunk()); } while (it==null || !it.isValid()); - it.setInvulnerable(true); TwosideKeeper.log("Dropping "+list.get(0).toString()+" at Death location "+deathloc,2); list.remove(0); } else { @@ -3721,20 +3852,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { return list; } - public void AttemptToDropItems(Player p, Location deathloc) { - deathloc.getWorld().loadChunk(deathloc.getChunk()); - if (deathloc.getChunk().isLoaded()) { - for (int i=0;i item_meta_lore = item_meta.getLore(); - if (item_meta_lore.size()==4 && item_meta_lore.get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { + if (item_meta_lore.size()>=4 && item_meta_lore.get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { int itemcubeid = -1; if (((PlayerStructure)playerdata.get(ev.getWhoClicked().getUniqueId())).isViewingItemCube && ev.getWhoClicked().getOpenInventory().getTitle().contains("Item Cube #")) { @@ -4067,7 +4184,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ItemMeta item_meta = ev.getCurrentItem().getItemMeta(); if (item_meta.hasLore()) { List item_meta_lore = item_meta.getLore(); - if (item_meta_lore.size()==4 && item_meta_lore.get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { + if (item_meta_lore.size()>=4 && item_meta_lore.get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { int idnumb = Integer.parseInt(item_meta_lore.get(3).split("#")[1]); int itemcubeid = -1; //This is the ID of the window we are looking at, if one exists. CubeType cubetype = CubeType.NORMAL; @@ -4215,7 +4332,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ItemMeta item_meta = ev.getCurrentItem().getItemMeta(); if (item_meta.hasLore()) { List item_meta_lore = item_meta.getLore(); - if (item_meta_lore.size()==4 && item_meta_lore.get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { + if (item_meta_lore.size()>=4 && item_meta_lore.get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { int idnumb = Integer.parseInt(item_meta_lore.get(3).split("#")[1]); int itemcubeid = -1; if (((PlayerStructure)playerdata.get(ev.getWhoClicked().getUniqueId())).isViewingItemCube && @@ -4489,6 +4606,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } else { log("Reason for spawn: "+ev.getSpawnReason().toString(),4); } + if (ev.getSpawnReason().equals(SpawnReason.SPAWNER)) { + if (MonsterController.isZombieLeader(ev.getEntity())) { + MonsterController.removeZombieLeaderAttribute(ev.getEntity()); + } + } if (ev.getLocation().getWorld().getName().equalsIgnoreCase("world") && ev.getEntityType()==EntityType.HORSE) { Horse h = (Horse)ev.getEntity(); @@ -4570,6 +4692,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void updateHealthbarDamageEvent(EntityDamageEvent ev) { if (ev.getEntity().isDead()) {ev.setCancelled(true); return;} + if (!Christmas.ChristmasDamageEvent(ev)) {return;} if (ev.getCause()!=DamageCause.ENTITY_ATTACK && ev.getCause()!=DamageCause.PROJECTILE && ev.getCause()!=DamageCause.ENTITY_EXPLOSION && @@ -4931,8 +5054,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void announcePluginUpdateEvent(AnnounceUpdateEvent ev) { - aPlugin.API.discordSendRaw(ev.getAnnouncementMessage()); - } + aPlugin.API.discordSendRawItalicized(ev.getAnnouncementMessage()); + } @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void expEvent(PlayerExpChangeEvent ev) { @@ -6507,7 +6630,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Item cube should be in slot 4. if (ev.getInventory().getItem(5)!=null) { ItemMeta inventory_itemMeta=ev.getInventory().getItem(5).getItemMeta(); - if (inventory_itemMeta.hasLore() && inventory_itemMeta.getLore().size()==4) { + if (inventory_itemMeta.hasLore() && inventory_itemMeta.getLore().size()>=4) { log("4 Elements detected.",5); String loreitem = inventory_itemMeta.getLore().get(3); log("Lore data is: "+loreitem,5); @@ -6951,6 +7074,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { getConfig().set("SERVER_TYPE", SERVER_TYPE.GetValue()); getConfig().set("LAST_ELITE_SPAWN", LAST_ELITE_SPAWN); getConfig().set("LAST_DEAL", LAST_DEAL); + getConfig().set("WEATHER_WATCH_USERS", weather_watch_users); if (ELITE_LOCATION!=null) { getConfig().set("ELITE_LOCATION_X", ELITE_LOCATION.getBlockX()); getConfig().set("ELITE_LOCATION_Z", ELITE_LOCATION.getBlockZ()); @@ -7014,6 +7138,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { getConfig().addDefault("WORLD_SHOP_DIST", worldShopDistanceSquared); getConfig().addDefault("WORLD_SHOP_MULT", worldShopPriceMult); getConfig().addDefault("LAST_DEAL", TimeUtils.GetCurrentDayOfWeek()); + getConfig().addDefault("WEATHER_WATCH_USERS", weather_watch_users); getConfig().options().copyDefaults(true); saveConfig(); SERVERTICK = getConfig().getLong("SERVERTICK"); @@ -7050,6 +7175,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { worldShopDistanceSquared = getConfig().getDouble("WORLD_SHOP_DIST"); worldShopPriceMult = getConfig().getDouble("WORLD_SHOP_MULT"); LAST_DEAL = getConfig().getInt("LAST_DEAL"); + weather_watch_users = getConfig().getStringList("WEATHER_WATCH_USERS"); if (getConfig().contains("ELITE_LOCATION_X")) { int x = getConfig().getInt("ELITE_LOCATION_X"); int z = getConfig().getInt("ELITE_LOCATION_Z"); @@ -7762,10 +7888,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Only warning messages appear in level 1. Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW+"[WARNING]"+ChatColor.RESET+logmessage); }break; - case 2: { + case 2: { //Regular Gameplay information can appear here. Bukkit.getConsoleSender().sendMessage(logmessage); - }break; + }break; case 3: { //Debug messages that generalize the events happening in the world. Bukkit.getConsoleSender().sendMessage(logmessage); @@ -7963,6 +8089,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static void announcePluginVersions() { if (SERVER_TYPE!=ServerType.QUIET) { aPlugin.API.discordSendRawItalicized(SERVER_TYPE.GetServerName()+"Server has been restarted.\nRunning v."+Bukkit.getPluginManager().getPlugin("TwosideKeeper").getDescription().getVersion()+" of TwosideKeeper\nRunning v"+Bukkit.getPluginManager().getPlugin("aPlugin").getDescription().getVersion()+" of Jobs."); + if (CHRISTMASEVENT_ACTIVATED) { + aPlugin.API.discordSendRaw("___________________"); + aPlugin.API.discordSendRaw("**Christmas Holiday Event** is currently active! Please visit <> for full details."); + } } } diff --git a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java index b90fa71..5711679 100644 --- a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java +++ b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java @@ -1,5 +1,6 @@ package sig.plugin.TwosideKeeper; +import java.io.File; import java.text.DecimalFormat; import java.util.Calendar; import java.util.Collection; @@ -16,6 +17,8 @@ import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.attribute.Attribute; import org.bukkit.block.Block; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Entity; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Item; @@ -41,6 +44,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume; import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.MessageUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; +import sig.plugin.TwosideKeeper.HolidayEvents.Christmas; final class runServerHeartbeat implements Runnable { /** @@ -347,6 +351,10 @@ final class runServerHeartbeat implements Runnable { //TwosideKeeper.outputArmorDurability(p,">"); } + CheckAndAnnounceWeather(); + + Christmas.ChristmasHeartbeat(); + MaintainMonsterData(); PartyManager.SetupParties(); @@ -355,6 +363,27 @@ final class runServerHeartbeat implements Runnable { } + private void CheckAndAnnounceWeather() { + if (Bukkit.getWorld("world").hasStorm()) { + if (!TwosideKeeper.last_announced_storm) { + TwosideKeeper.last_announced_storm=true; + for (String user : TwosideKeeper.weather_watch_users) { + if (Bukkit.getPlayer(user)!=null) { + Player p = Bukkit.getPlayer(user); + p.sendMessage(ChatColor.ITALIC+""+ChatColor.GRAY+"A storm"+((Bukkit.getWorld("world").isThundering())?" (With Thunder)":"")+" is now occuring on the server. (Day "+(int)(TwosideKeeper.getServerTickTime()/48000)+")"); + } + File config; + config = new File(TwosideKeeper.filesave,"users/"+user+".data"); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + aPlugin.DiscordMessageSender.sendPM("A storm"+((Bukkit.getWorld("world").isThundering())?" (With Thunder)":"")+" is now occuring on the server. (Day "+(int)(TwosideKeeper.getServerTickTime()/48000)+")", workable.getString("weatherwatch_user")); + } + } + } + else { + TwosideKeeper.last_announced_storm=false; + } + } + public static void runFilterCubeCollection(Player p) { if (InventoryUtils.hasFullInventory(p) && InventoryUtils.isCarryingFilterCube(p)) { List ents = p.getNearbyEntities(0.25, 0.25, 0.25); @@ -512,7 +541,7 @@ final class runServerHeartbeat implements Runnable { TwosideKeeper.log("Size: "+TwosideKeeper.livingentitydata.size(), 5); for (UUID id : data) { LivingEntityStructure ms = TwosideKeeper.livingentitydata.get(id); - if (!ms.m.isValid()) { + if (!ms.m.isValid() || ms.m instanceof Player) { //TwosideKeeper.monsterdata.remove(data); TwosideKeeper.ScheduleRemoval(TwosideKeeper.livingentitydata, ms); TwosideKeeper.ScheduleRemoval(data, id);