Created
September 28, 2013 13:27
-
-
Save CeramicTitan/6742064 to your computer and use it in GitHub Desktop.
Super old mining plugin.
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 me.ceramictitan.aurimine; | |
import java.util.logging.Level; | |
import net.milkbowl.vault.economy.Economy; | |
import org.bukkit.Bukkit; | |
import org.bukkit.ChatColor; | |
import org.bukkit.Effect; | |
import org.bukkit.Material; | |
import org.bukkit.block.Block; | |
import org.bukkit.enchantments.Enchantment; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.block.BlockBreakEvent; | |
import org.bukkit.inventory.ItemStack; | |
import org.bukkit.plugin.PluginManager; | |
import org.bukkit.plugin.RegisteredServiceProvider; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class AuriMine extends JavaPlugin implements Listener { | |
public static Economy econ = null; | |
public void onDisable() { | |
} | |
public void onEnable() { | |
if (!setupEconomy()) { | |
getLogger().log(Level.SEVERE, "Vault not found disabling plugin!"); | |
getServer().getPluginManager().disablePlugin(this); | |
return; | |
} | |
PluginManager pm = getServer().getPluginManager(); | |
pm.registerEvents(this, this); | |
loadConfig(); | |
} | |
private void loadConfig() { | |
getConfig().addDefault("prices.diamond_ore", 350.00);// done | |
getConfig().addDefault("prices.iron_ore", 50.00);// done | |
getConfig().addDefault("prices.emerald_ore", 500.00);// done | |
getConfig().addDefault("prices.gold_ore", 200.00);// done | |
getConfig() | |
.addDefault( | |
"break_message", | |
"&a[&eAuriMine&a] &a$%price &8has been added to your account for breaking &d%block&8!"); | |
getConfig().options().copyDefaults(true); | |
saveConfig(); | |
} | |
private boolean setupEconomy() { | |
if (getServer().getPluginManager().getPlugin("Vault") == null) { | |
return false; | |
} | |
RegisteredServiceProvider<Economy> rsp = getServer() | |
.getServicesManager().getRegistration(Economy.class); | |
if (rsp == null) { | |
return false; | |
} | |
econ = rsp.getProvider(); | |
return econ != null; | |
} | |
@EventHandler | |
public void onBlockBreak(BlockBreakEvent event) { | |
final Player p = event.getPlayer(); | |
Block block = event.getBlock(); | |
if (block.getType() == Material.IRON_ORE | |
&& p.getItemInHand() | |
.containsEnchantment(Enchantment.SILK_TOUCH)) { | |
if (event.isCancelled() == true) { | |
return; | |
} | |
if (event.getPlayer().getItemInHand().getType() != Material.STONE_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.DIAMOND_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.IRON_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.GOLD_PICKAXE) { | |
return; | |
} | |
String message = getConfig().getString("break_message"); | |
message = ChatColor.translateAlternateColorCodes('&', message); | |
message = message.replace("%price", | |
String.valueOf(getConfig().getDouble("prices.iron_ore"))); | |
message = message.replace("%block", block.getType().toString() | |
.replace("_", " ")); | |
event.setCancelled(true); | |
block.getWorld().dropItemNaturally(block.getLocation(), | |
new ItemStack(Material.IRON_INGOT, 1)); | |
block.setType(Material.AIR); | |
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 50); | |
econ.depositPlayer(p.getName(), | |
this.getConfig().getDouble("prices.iron_ore")); | |
p.sendMessage(message); | |
Bukkit.getServer().getScheduler() | |
.scheduleSyncDelayedTask(this, new Runnable() { | |
@Override | |
public void run() { | |
p.sendMessage(ChatColor.DARK_AQUA | |
+ "You balance is now " + ChatColor.GREEN | |
+ econ.getBalance(p.getName())); | |
} | |
}, 10L); | |
} else if (block.getType() == Material.IRON_ORE) { | |
if (event.isCancelled() == true) { | |
return; | |
} | |
if (event.getPlayer().getItemInHand().getType() != Material.STONE_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.DIAMOND_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.IRON_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.GOLD_PICKAXE) { | |
return; | |
} | |
String message = getConfig().getString("break_message"); | |
message = ChatColor.translateAlternateColorCodes('&', message); | |
message = message.replace("%price", | |
String.valueOf(getConfig().getDouble("prices.iron_ore"))); | |
message = message.replace("%block", block.getType().toString() | |
.replace("_", " ")); | |
event.setCancelled(true); | |
block.getWorld().dropItemNaturally(block.getLocation(), | |
new ItemStack(Material.IRON_INGOT, 1)); | |
block.setType(Material.AIR); | |
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 50); | |
econ.depositPlayer(p.getName(), | |
this.getConfig().getDouble("prices.iron_ore")); | |
p.sendMessage(message); | |
Bukkit.getServer().getScheduler() | |
.scheduleSyncDelayedTask(this, new Runnable() { | |
@Override | |
public void run() { | |
p.sendMessage(ChatColor.DARK_AQUA | |
+ "You balance is now " + ChatColor.GREEN | |
+ econ.getBalance(p.getName())); | |
} | |
}, 10L); | |
} else if (block.getType() == Material.DIAMOND_ORE | |
&& p.getItemInHand() | |
.containsEnchantment(Enchantment.SILK_TOUCH)) { | |
if (event.isCancelled() == true) { | |
return; | |
} | |
if (event.getPlayer().getItemInHand().getType() != Material.DIAMOND_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.IRON_PICKAXE) { | |
return; | |
} | |
String message = getConfig().getString("break_message"); | |
message = ChatColor.translateAlternateColorCodes('&', message); | |
message = message | |
.replace( | |
"%price", | |
String.valueOf(getConfig().getDouble( | |
"prices.diamond_ore"))); | |
message = message.replace("%block", block.getType().toString() | |
.replace("_", " ")); | |
event.setCancelled(true); | |
block.getWorld().dropItemNaturally(block.getLocation(), | |
new ItemStack(Material.DIAMOND, 1)); | |
block.setType(Material.AIR); | |
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 50); | |
econ.depositPlayer(p.getName(), | |
this.getConfig().getDouble("prices.diamond_ore")); | |
p.sendMessage(message); | |
Bukkit.getServer().getScheduler() | |
.scheduleSyncDelayedTask(this, new Runnable() { | |
@Override | |
public void run() { | |
p.sendMessage(ChatColor.DARK_AQUA | |
+ "You balance is now " + ChatColor.GREEN | |
+ econ.getBalance(p.getName())); | |
} | |
}, 10L); | |
} else if (block.getType() == Material.DIAMOND_ORE) { | |
if (event.isCancelled() == true) { | |
return; | |
} | |
if (event.getPlayer().getItemInHand().getType() != Material.DIAMOND_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.IRON_PICKAXE) { | |
return; | |
} | |
String message = getConfig().getString("break_message"); | |
message = ChatColor.translateAlternateColorCodes('&', message); | |
message = message | |
.replace( | |
"%price", | |
String.valueOf(getConfig().getDouble( | |
"prices.diamond_ore"))); | |
message = message.replace("%block", block.getType().toString() | |
.replace("_", " ")); | |
p.sendMessage(message); | |
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 50); | |
econ.depositPlayer(p.getName(), | |
this.getConfig().getDouble("prices.diamond_ore")); | |
Bukkit.getServer().getScheduler() | |
.scheduleSyncDelayedTask(this, new Runnable() { | |
@Override | |
public void run() { | |
p.sendMessage(ChatColor.DARK_AQUA | |
+ "You balance is now " + ChatColor.GREEN | |
+ econ.getBalance(p.getName())); | |
} | |
}, 10L); | |
} else if (block.getType() == Material.EMERALD_ORE | |
&& p.getItemInHand() | |
.containsEnchantment(Enchantment.SILK_TOUCH)) { | |
if (event.isCancelled() == true) { | |
return; | |
} | |
if (event.getPlayer().getItemInHand().getType() != Material.DIAMOND_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.IRON_PICKAXE) { | |
return; | |
} | |
String message = getConfig().getString("break_message"); | |
message = ChatColor.translateAlternateColorCodes('&', message); | |
message = message | |
.replace( | |
"%price", | |
String.valueOf(getConfig().getDouble( | |
"prices.emerald_ore"))); | |
message = message.replace("%block", block.getType().toString() | |
.replace("_", " ")); | |
event.setCancelled(true); | |
block.getWorld().dropItemNaturally(block.getLocation(), | |
new ItemStack(Material.EMERALD, 1)); | |
block.setType(Material.AIR); | |
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 50); | |
econ.depositPlayer(p.getName(), | |
this.getConfig().getDouble("prices.emerald_ore")); | |
p.sendMessage(message); | |
Bukkit.getServer().getScheduler() | |
.scheduleSyncDelayedTask(this, new Runnable() { | |
@Override | |
public void run() { | |
p.sendMessage(ChatColor.DARK_AQUA | |
+ "You balance is now " + ChatColor.GREEN | |
+ econ.getBalance(p.getName())); | |
} | |
}, 10L); | |
} else if (block.getType() == Material.EMERALD_ORE) { | |
if (event.isCancelled() == true) { | |
return; | |
} | |
if (event.getPlayer().getItemInHand().getType() != Material.DIAMOND_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.IRON_PICKAXE) { | |
return; | |
} | |
String message = getConfig().getString("break_message"); | |
message = ChatColor.translateAlternateColorCodes('&', message); | |
message = message | |
.replace( | |
"%price", | |
String.valueOf(getConfig().getDouble( | |
"prices.emerald_ore"))); | |
message = message.replace("%block", block.getType().toString() | |
.replace("_", " ")); | |
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 50); | |
econ.depositPlayer(p.getName(), | |
this.getConfig().getDouble("prices.emerald_ore")); | |
p.sendMessage(message); | |
Bukkit.getServer().getScheduler() | |
.scheduleSyncDelayedTask(this, new Runnable() { | |
@Override | |
public void run() { | |
p.sendMessage(ChatColor.DARK_AQUA | |
+ "You balance is now " + ChatColor.GREEN | |
+ econ.getBalance(p.getName())); | |
} | |
}, 10L); | |
} else if (block.getType() == Material.GOLD_ORE | |
&& p.getItemInHand() | |
.containsEnchantment(Enchantment.SILK_TOUCH)) { | |
if (event.isCancelled() == true) { | |
return; | |
} | |
if (event.getPlayer().getItemInHand().getType() != Material.STONE_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.DIAMOND_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.IRON_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.GOLD_PICKAXE) { | |
return; | |
} | |
String message = getConfig().getString("break_message"); | |
message = ChatColor.translateAlternateColorCodes('&', message); | |
message = message.replace("%price", | |
String.valueOf(getConfig().getDouble("prices.gold_ore"))); | |
message = message.replace("%block", block.getType().toString() | |
.replace("_", " ")); | |
event.setCancelled(true); | |
block.getWorld().dropItemNaturally(block.getLocation(), | |
new ItemStack(Material.GOLD_INGOT, 1)); | |
block.setType(Material.AIR); | |
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 50); | |
econ.depositPlayer(p.getName(), | |
this.getConfig().getDouble("prices.gold_ore")); | |
econ.p.sendMessage(message); | |
Bukkit.getServer().getScheduler() | |
.scheduleSyncDelayedTask(this, new Runnable() { | |
@Override | |
public void run() { | |
p.sendMessage(ChatColor.DARK_AQUA | |
+ "You balance is now " + ChatColor.GREEN | |
+ econ.getBalance(p.getName())); | |
} | |
}, 10L); | |
} else if (block.getType() == Material.GOLD_ORE) { | |
if (event.isCancelled() == true) { | |
return; | |
} | |
if (event.getPlayer().getItemInHand().getType() != Material.STONE_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.DIAMOND_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.IRON_PICKAXE | |
&& event.getPlayer().getItemInHand().getType() != Material.GOLD_PICKAXE) { | |
System.out.println("Fail"); | |
return; | |
} | |
String message = getConfig().getString("break_message"); | |
message = ChatColor.translateAlternateColorCodes('&', message); | |
message = message.replace("%price", | |
String.valueOf(getConfig().getDouble("prices.gold_ore"))); | |
message = message.replace("%block", block.getType().toString() | |
.replace("_", " ")); | |
event.setCancelled(true); | |
block.getWorld().dropItemNaturally(block.getLocation(), | |
new ItemStack(Material.GOLD_INGOT, 1)); | |
block.setType(Material.AIR); | |
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 50); | |
econ.depositPlayer(p.getName(), | |
this.getConfig().getDouble("prices.gold_ore")); | |
p.sendMessage(message); | |
Bukkit.getServer().getScheduler() | |
.scheduleSyncDelayedTask(this, new Runnable() { | |
@Override | |
public void run() { | |
p.sendMessage(ChatColor.DARK_AQUA | |
+ "You balance is now " + ChatColor.GREEN | |
+ econ.getBalance(p.getName())); | |
} | |
}, 10L); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment