Last active
December 20, 2015 10:49
-
-
Save sahirshahryar/6119016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.icloud.dcljr.MineCloudHardMode; | |
import java.util.Arrays; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.Map; | |
import org.bukkit.Bukkit; | |
import org.bukkit.Location; | |
import org.bukkit.Material; | |
import org.bukkit.Server; | |
import org.bukkit.World; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.configuration.file.FileConfiguration; | |
import org.bukkit.entity.EntityType; | |
import org.bukkit.entity.HumanEntity; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.EventPriority; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.block.Action; | |
import org.bukkit.event.entity.EntityRegainHealthEvent; | |
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; | |
import org.bukkit.event.inventory.ClickType; | |
import org.bukkit.event.inventory.CraftItemEvent; | |
import org.bukkit.event.inventory.InventoryAction; | |
import org.bukkit.event.inventory.InventoryType.SlotType; | |
import org.bukkit.event.player.PlayerInteractEvent; | |
import org.bukkit.inventory.InventoryView; | |
import org.bukkit.inventory.ItemStack; | |
import org.bukkit.inventory.Recipe; | |
import org.bukkit.inventory.ShapedRecipe; | |
import org.bukkit.inventory.ShapelessRecipe; | |
import org.bukkit.plugin.PluginManager; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public final class MineCloudHardMode extends JavaPlugin implements Listener { | |
@Override | |
public void onEnable(){ | |
getLogger().info("Mine Cloud Hard Mode Loaded!"); | |
FileConfiguration config = this.getConfig(); | |
config.addDefault("config.Mine Cloud Hard World", "MineCloudHard" ); | |
config.addDefault("config.Glistering Melon Heal", true ); | |
config.addDefault("config.Glistering Melon Heal Amount(every 1 number is a half heart)", 2); | |
config.options().copyDefaults(true); | |
saveConfig(); | |
PluginManager pm = this.getServer().getPluginManager(); | |
pm.registerEvents(this, this); | |
ArrayList<ShapelessRecipes> shapeless = new ArrayList<ShapelessRecipe>(); | |
ArrayList<ShapedRecipe> recipes = new ArrayList<ShapedRecipe>(); | |
ShapelessRecipe gmelon = new ShapelessRecipe(new ItemStack(Material.SPECKLED_MELON, 1)); | |
gmelon.addIngredient(Material.MELON); | |
gmelon.addIngredient(Material.GOLD_BLOCK); | |
shapeless.add(gmelon); | |
ShapelessRecipe gapple = new ShapelessRecipe(new ItemStack(Material.GOLDEN_APPLE, 1)); | |
gapple.addIngredient(Material.APPLE); | |
gapple.addIngredient(Material.GOLD_BLOCK); | |
shapeless.add(gapple); | |
ShapedRecipe wsword = new ShapedRecipe(new ItemStack(Material.WOOD_SWORD, 1)); | |
wsword.shape("A", "A", "B"); | |
wsword.setIngredient('A', Material.LOG); | |
wsword.setIngredient('B', Material.WOOD); | |
recipes.add(wsword); | |
ShapedRecipe wshovel = new ShapedRecipe(new ItemStack(Material.WOOD_SPADE, 1)); | |
wshovel.shape("A", "B", "B"); | |
wshovel.setIngredient('A', Material.LOG); | |
wshovel.setIngredient('B', Material.WOOD); | |
recipes.add(wshovel); | |
ShapedRecipe whoe = new ShapedRecipe(new ItemStack(Material.WOOD_HOE, 1)); | |
whoe.shape("AA ", " B ", " B "); | |
whoe.setIngredient('A', Material.LOG); | |
whoe.setIngredient('B', Material.WOOD); | |
recipes.add(whoe); | |
ShapedRecipe wpick = new ShapedRecipe(new ItemStack(Material.WOOD_PICKAXE, 1)); | |
wpick.shape("AAA", " B ", " B "); | |
wpick.setIngredient('A', Material.LOG); | |
wpick.setIngredient('B', Material.WOOD); | |
recipes.add(wpick); | |
ShapedRecipe waxe = new ShapedRecipe(new ItemStack(Material.WOOD_AXE, 1)); | |
waxe.shape("AA ", "AB ", " B "); | |
waxe.setIngredient('A', Material.LOG); | |
waxe.setIngredient('B', Material.WOOD); | |
recipes.add(waxe); | |
ShapedRecipe ssword = new ShapedRecipe(new ItemStack(Material.STONE_SWORD, 1)); | |
ssword.shape("A", "A", "B"); | |
ssword.setIngredient('A', Material.STONE); | |
ssword.setIngredient('B', Material.WOOD); | |
recipes.add(ssword); | |
ShapedRecipe sshovel = new ShapedRecipe(new ItemStack(Material.STONE_SPADE, 1)); | |
sshovel.shape("A", "B", "B"); | |
sshovel.setIngredient('A', Material.STONE); | |
sshovel.setIngredient('B', Material.WOOD); | |
recipes.add(sshovel); | |
ShapedRecipe shoe = new ShapedRecipe(new ItemStack(Material.STONE_HOE, 1)); | |
shoe.shape("AA ", " B ", " B "); | |
shoe.setIngredient('A', Material.STONE); | |
shoe.setIngredient('B', Material.WOOD); | |
recipes.add(shoe); | |
ShapedRecipe spick = new ShapedRecipe(new ItemStack(Material.STONE_PICKAXE, 1)); | |
spick.shape("AAA", " B ", " B "); | |
spick.setIngredient('A', Material.STONE); | |
spick.setIngredient('B', Material.WOOD); | |
recipes.add(spick); | |
ShapedRecipe saxe = new ShapedRecipe(new ItemStack(Material.STONE_AXE, 1)); | |
saxe.shape("AA ", "AB ", " B "); | |
saxe.setIngredient('A', Material.STONE); | |
saxe.setIngredient('B', Material.WOOD); | |
recipes.add(saxe); | |
ShapedRecipe isword = new ShapedRecipe(new ItemStack(Material.IRON_SWORD, 1)); | |
isword.shape("A", "A", "B"); | |
isword.setIngredient('A', Material.IRON_BLOCK); | |
isword.setIngredient('B', Material.WOOD); | |
recipes.add(isword); | |
ShapedRecipe ishovel = new ShapedRecipe(new ItemStack(Material.IRON_SPADE, 1)); | |
ishovel.shape("A", "B", "B"); | |
ishovel.setIngredient('A', Material.IRON_BLOCK); | |
ishovel.setIngredient('B', Material.WOOD); | |
recipes.add(ishovel); | |
ShapedRecipe ihoe = new ShapedRecipe(new ItemStack(Material.IRON_HOE, 1)); | |
ihoe.shape("AA ", " B ", " B "); | |
ihoe.setIngredient('A', Material.IRON_BLOCK); | |
ihoe.setIngredient('B', Material.WOOD); | |
recipes.add(ihoe); | |
ShapedRecipe ipick = new ShapedRecipe(new ItemStack(Material.IRON_PICKAXE, 1)); | |
ipick.shape("AAA", " B ", " B "); | |
ipick.setIngredient('A', Material.IRON_BLOCK); | |
ipick.setIngredient('B', Material.WOOD); | |
recipes.add(ipick); | |
ShapedRecipe iaxe = new ShapedRecipe(new ItemStack(Material.IRON_AXE, 1)); | |
iaxe.shape("AA ", "AB ", " B "); | |
iaxe.setIngredient('A', Material.IRON_BLOCK); | |
iaxe.setIngredient('B', Material.WOOD); | |
recipes.add(iaxe); | |
ShapedRecipe gsword = new ShapedRecipe(new ItemStack(Material.GOLD_SWORD, 1)); | |
gsword.shape("A", "A", "B"); | |
gsword.setIngredient('A', Material.GOLD_BLOCK); | |
gsword.setIngredient('B', Material.WOOD); | |
recipes.add(gsword); | |
ShapedRecipe gshovel = new ShapedRecipe(new ItemStack(Material.GOLD_SPADE, 1)); | |
gshovel.shape("A", "B", "B"); | |
gshovel.setIngredient('A', Material.GOLD_BLOCK); | |
gshovel.setIngredient('B', Material.WOOD); | |
recipes.add(gshovel); | |
ShapedRecipe ghoe = new ShapedRecipe(new ItemStack(Material.GOLD_HOE, 1)); | |
ghoe.shape("AA ", " B ", " B "); | |
ghoe.setIngredient('A', Material.GOLD_BLOCK); | |
ghoe.setIngredient('B', Material.WOOD); | |
recipes.add(ghoe); | |
ShapedRecipe gpick = new ShapedRecipe(new ItemStack(Material.GOLD_PICKAXE, 1)); | |
gpick.shape("AAA", " B ", " B "); | |
gpick.setIngredient('A', Material.GOLD_BLOCK); | |
gpick.setIngredient('B', Material.WOOD); | |
recipes.add(gpick); | |
ShapedRecipe gaxe = new ShapedRecipe(new ItemStack(Material.GOLD_AXE, 1)); | |
gaxe.shape("AA ", "AB ", " B "); | |
gaxe.setIngredient('A', Material.GOLD_BLOCK); | |
gaxe.setIngredient('B', Material.WOOD); | |
recipes.add(gaxe); | |
ShapedRecipe dsword = new ShapedRecipe(new ItemStack(Material.DIAMOND_SWORD, 1)); | |
dsword.shape("A", "A", "B"); | |
dsword.setIngredient('A', Material.DIAMOND_BLOCK); | |
dsword.setIngredient('B', Material.WOOD); | |
recipes.add(dsword); | |
ShapedRecipe dshovel = new ShapedRecipe(new ItemStack(Material.DIAMOND_SPADE, 1)); | |
dshovel.shape("A", "B", "B"); | |
dshovel.setIngredient('A', Material.DIAMOND_BLOCK); | |
dshovel.setIngredient('B', Material.WOOD); | |
recipes.add(dshovel); | |
ShapedRecipe dhoe = new ShapedRecipe(new ItemStack(Material.DIAMOND_HOE, 1)); | |
dhoe.shape("AA ", " B ", " B "); | |
dhoe.setIngredient('A', Material.DIAMOND_BLOCK); | |
dhoe.setIngredient('B', Material.WOOD); | |
recipes.add(dhoe); | |
ShapedRecipe dpick = new ShapedRecipe(new ItemStack(Material.DIAMOND_PICKAXE, 1)); | |
dpick.shape("AAA", " B ", " B "); | |
dpick.setIngredient('A', Material.DIAMOND_BLOCK); | |
dpick.setIngredient('B', Material.WOOD); | |
recipes.add(dpick); | |
ShapedRecipe daxe = new ShapedRecipe(new ItemStack(Material.DIAMOND_AXE, 1)); | |
daxe.shape("AA ", "AB ", " B "); | |
daxe.setIngredient('A', Material.DIAMOND_BLOCK); | |
daxe.setIngredient('B', Material.WOOD); | |
recipes.add(daxe); | |
ShapedRecipe ihelm = new ShapedRecipe(new ItemStack(Material.IRON_HELMET, 1)); | |
ihelm.shape("AAA", "A A"); | |
ihelm.setIngredient('A', Material.IRON_BLOCK); | |
recipes.add(ihelm); | |
ShapedRecipe ichest = new ShapedRecipe(new ItemStack(Material.IRON_CHESTPLATE, 1)); | |
ichest.shape("A A", "AAA", "AAA"); | |
ichest.setIngredient('A', Material.IRON_BLOCK); | |
recipes.add(ichest); | |
ShapedRecipe ilegs = new ShapedRecipe(new ItemStack(Material.IRON_LEGGINGS, 1)); | |
ilegs.shape("AAA", "A A", "A A"); | |
ilegs.setIngredient('A', Material.IRON_BLOCK); | |
recipes.add(ilegs); | |
ShapedRecipe iboots = new ShapedRecipe(new ItemStack(Material.IRON_BOOTS, 1)); | |
iboots.shape("A A", "A A"); | |
iboots.setIngredient('A', Material.IRON_BLOCK); | |
recipes.add(iboots); | |
ShapedRecipe ghelm = new ShapedRecipe(new ItemStack(Material.GOLD_HELMET, 1)); | |
ghelm.shape("AAA", "A A"); | |
ghelm.setIngredient('A', Material.GOLD_BLOCK); | |
recipes.add(ghelm); | |
ShapedRecipe gchest = new ShapedRecipe(new ItemStack(Material.GOLD_CHESTPLATE, 1)); | |
gchest.shape("A A", "AAA", "AAA"); | |
gchest.setIngredient('A', Material.GOLD_BLOCK); | |
recipes.add(gchest); | |
ShapedRecipe glegs = new ShapedRecipe(new ItemStack(Material.GOLD_LEGGINGS, 1)); | |
glegs.shape("AAA", "A A", "A A"); | |
glegs.setIngredient('A', Material.GOLD_BLOCK); | |
recipes.add(glegs); | |
ShapedRecipe gboots = new ShapedRecipe(new ItemStack(Material.GOLD_BOOTS, 1)); | |
gboots.shape("A A", "A A"); | |
gboots.setIngredient('A', Material.GOLD_BLOCK); | |
recipes.add(gboots); | |
ShapedRecipe dhelm = new ShapedRecipe(new ItemStack(Material.DIAMOND_HELMET, 1)); | |
dhelm.shape("AAA", "A A"); | |
dhelm.setIngredient('A', Material.DIAMOND_BLOCK); | |
recipes.add(dhelm); | |
ShapedRecipe dchest = new ShapedRecipe(new ItemStack(Material.DIAMOND_CHESTPLATE, 1)); | |
dchest.shape("A A", "AAA", "AAA"); | |
dchest.setIngredient('A', Material.DIAMOND_BLOCK); | |
recipes.add(dchest); | |
ShapedRecipe dlegs = new ShapedRecipe(new ItemStack(Material.DIAMOND_LEGGINGS, 1)); | |
dlegs.shape("AAA", "A A", "A A"); | |
dlegs.setIngredient('A', Material.DIAMOND_BLOCK); | |
recipes.add(dlegs); | |
ShapedRecipe dboots = new ShapedRecipe(new ItemStack(Material.DIAMOND_BOOTS, 1)); | |
dboots.shape("A A", "A A"); | |
dboots.setIngredient('A', Material.DIAMOND_BLOCK); | |
recipes.add(dboots); | |
for (ShapedRecipe recipe : recipes) { | |
this.getServer().addRecipe(recipe); | |
} | |
for (ShapelessRecipe recipe : shapeless) { | |
this.getServer().addRecipe(recipe); | |
} | |
} | |
@EventHandler | |
public void RemoveRecipes(CraftItemEvent e) { | |
FileConfiguration config = this.getConfig(); | |
HumanEntity p = (HumanEntity) e.getViewers().get(0); | |
if (p instanceof Player) { | |
Player player = (Player) p; | |
switch (e.getResult()) { | |
case GOLDEN_APPLE: case SPECKLED_MELON: case WOOD_PICKAXE: case WOOD_AXE: | |
case WOOD_HOE: case WOOD_SPADE: case WOOD_SWORD: case STONE_PICKAXE: | |
case STONE_AXE: case STONE_HOE: case STONE_SPADE: case STONE_SWORD: | |
case IRON_PICKAXE: case IRON_AXE: case IRON_HOE: case IRON_SPADE: | |
case IRON_SWORD: case GOLD_PICKAXE: case GOLD_AXE: case GOLD_HOE: | |
case GOLD_SPADE: case GOLD_SWORD: case DIAMOND_PICKAXE: case DIAMOND_AXE: | |
case DIAMOND_HOE: case DIAMOND_SPADE: case DIAMOND_SWORD: case IRON_HELMET: | |
case IRON_CHESTPLATE: case IRON_LEGGINGS: case IRON_BOOTS: case GOLD_HELMET: | |
case GOLD_CHESTPLATE: case GOLD_LEGGINGS: case GOLD_BOOTS: case DIAMOND_HELMET: | |
case DIAMOND_CHESTPLATE: case DIAMOND_LEGGINGS: case DIAMOND_BOOTS: | |
e.setCancelled(p.getWorld().getName().equals(config.getString("config.Mine Cloud Hard World"))); | |
} | |
} | |
} | |
} | |
@EventHandler | |
public void PrepareItemCraftEvent(CraftItemEvent e) { int item = e.getRecipe().getResult().getTypeId(); | |
FileConfiguration config = this.getConfig(); | |
List<String> enabledWorlds = Arrays.asList(config.getString("config.Mine Cloud Hard World")); | |
HumanEntity p = (HumanEntity) e.getViewers().get(0); | |
if ((p instanceof Player)) { | |
Player player = (Player) p; | |
switch (item) { | |
case 256: case 257: case 258: case 267: case 268: | |
case 269: case 270: case 271: case 272: case 273: | |
case 274: case 275: case 276: case 277: case 278: | |
case 279: case 283: case 284: case 285: case 286: | |
case 290: case 291: case 292: case 293: case 294: | |
case 306: case 307: case 308: case 309: case 310: | |
case 311: case 312: case 313: case 314: case 315: | |
case 316: case 317: case 382: case 322: | |
e.setCancelled(!enabledWorlds.contains(player.getWorld().getName())); | |
} | |
} | |
} | |
@EventHandler | |
public void OnPlayerClickConvertWood(PlayerInteractEvent event){ | |
Player player = event.getPlayer(); | |
FileConfiguration config = this.getConfig(); | |
Location loc = new Location(Bukkit.getWorld(config.getString("config.Mine Cloud Hard World")), 100, 100, 100); | |
if((event.getAction() ==Action.LEFT_CLICK_BLOCK) && player.getItemInHand().getType() == Material.LOG){ | |
ItemStack wood = event.getPlayer().getItemInHand(); | |
ItemStack OakWood = new ItemStack(Material.LOG, 1, (short) 0); | |
if(loc == event.getClickedBlock().getLocation()) { | |
if(wood.getAmount() == 1) | |
return; | |
wood.setAmount(wood.getAmount()-1); | |
event.getPlayer().getInventory().addItem(new ItemStack(OakWood)); | |
event.getPlayer().updateInventory(); | |
} | |
} | |
} | |
@EventHandler | |
public void OnPlayerMelon(PlayerInteractEvent event){ | |
Player player = event.getPlayer(); | |
FileConfiguration config = this.getConfig(); | |
if(config.getBoolean("config.Glistering Melon Heal")) | |
if(player.getHealth() == 20){ | |
}else{ | |
List<String> enabledWorlds = Arrays.asList(config.getString("config.Mine Cloud Hard World")); | |
if(!enabledWorlds.contains(player.getWorld().getName())){ | |
return; | |
} | |
int smelon = +config.getInt("config.Glistering Melon Heal Amount(every 1 number is a half heart)"); | |
if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() ==Action.RIGHT_CLICK_BLOCK) && player.getItemInHand().getType() == Material.SPECKLED_MELON){ | |
player.setHealth(player.getHealth() + smelon > player.getMaxHealth() ? player.getMaxHealth() : player.getHealth() + smelon); | |
ItemStack melon = event.getPlayer().getItemInHand(); | |
if(melon.getAmount() > 1) | |
{ | |
melon.setAmount(melon.getAmount()-1); | |
event.getPlayer().updateInventory(); | |
} | |
else | |
{ | |
event.getPlayer().getInventory().removeItem(melon); | |
event.getPlayer().updateInventory(); | |
} | |
} | |
} | |
} | |
@Override | |
public void onDisable() { | |
getLogger().info("Mine Cloud Hard Mode UnLoaded!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment