本文整理汇总了Java中tv.mineinthebox.manco.interfaces.Crate类的典型用法代码示例。如果您正苦于以下问题:Java Crate类的具体用法?Java Crate怎么用?Java Crate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Crate类属于tv.mineinthebox.manco.interfaces包,在下文中一共展示了Crate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCrates
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
/**
* @author xize
* @param loads all the crates once!
*/
private void loadCrates() {
ManCo.log(LogType.INFO, "registering crates...");
int num = 0;
if(!crates.isEmpty()) {
crates.clear();
}
for(String name : con.getConfigurationSection("crates.crate").getKeys(false)) {
Crate crate = null;
if(con.getBoolean("crates.crate."+name+".isRare")) {
crate = new RareCrate(name, pl);
} else {
crate = new NormalCrate(name, pl);
}
if(!crates.containsKey(crate.getCrateName())) {
crates.put(crate.getCrateName(), crate);
} else {
crates.get(crate.getCrateName());
}
num++;
}
ManCo.log(LogType.INFO, "in total " + num + " crates have been registered.");
}
示例2: spawnCrate
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public Crate spawnCrate(CratePlayer p, Crate crate, Location loc) {
if(p.hasCrate()) {
return crate;
}
if(canFall(loc)) {
if(getConfiguration().isCrateMessagesEnabled()) {
if(crate.getType() == CrateType.RARE) {
Bukkit.broadcastMessage(getConfiguration().getRareCrateDropMessage().replaceAll("%p", p.getPlayer().getName()).replaceAll("%crate", crate.getCrateName()));
} else if(crate.getType() == CrateType.NORMAL) {
Bukkit.broadcastMessage(getConfiguration().getNormalCrateDropMessage().replaceAll("%p", p.getPlayer().getName()).replaceAll("%crate", crate.getCrateName()));
}
}
FallingBlock fall = p.getPlayer().getWorld().spawnFallingBlock(loc.add(0, 1, 0), Material.CHEST, (byte)0);
fall.setMetadata("crate_serie", new FixedMetadataValue(this, crate.getCrateName()));
fall.setMetadata("crate_owner", new FixedMetadataValue(this, p.getPlayer().getName()));
getCrateOwners().add(p.getPlayer().getName());
}
return crate;
}
示例3: addCrateSerie
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
@Override
public Crate addCrateSerie(String serie, CrateType type, ItemStack[] items) {
File f = new File(getDataFolder() + File.separator + "config.yml");
YamlConfiguration con = YamlConfiguration.loadConfiguration(f);
con.set("crates.crate."+serie.toLowerCase()+".isEnabled", true);
con.set("crates.crate."+serie.toLowerCase()+".isRare", (type == CrateType.RARE));
con.set("crates.crate."+serie.toLowerCase()+".rareEffects", false);
con.set("crates.crate."+serie.toLowerCase()+".keyEnable", false);
con.set("crates.crate."+serie.toLowerCase()+".keyItem", Material.BLAZE_ROD.name());
con.set("crates.crate."+serie.toLowerCase()+".keyPrice", 0.0);
con.set("crates.crate."+serie.toLowerCase()+".miniumSlotsFilled", 10);
con.set("crates.crate."+serie.toLowerCase()+".items", getCleanItems(items));
try {
con.save(f);
} catch (IOException e) {
e.printStackTrace();
}
getConfiguration().reload();
return getCrateSerie(serie);
}
示例4: getCrateList
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
/**
* returns the crate list
*
* @author xize
* @return EnumMap<CrateType, HashMap<String, Crate>>()
*/
public Crate[] getCrateList(CrateType type) {
Collection<Crate> allcrates = getCrateList().values();
Iterator<Crate> it = allcrates.iterator();
List<Crate> crates = new ArrayList<Crate>();
for(Crate crate = (it.hasNext() ? it.next() : null); it.hasNext(); crate = it.next()) {
crates.add(crate);
}
return crates.toArray(new Crate[crates.size()]);
}
示例5: onEdit
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
@EventHandler
public void onEdit(InventoryCloseEvent e) {
if(e.getInventory().getTitle().startsWith("me:")) {
String name = e.getInventory().getTitle().substring("me:".length());
Crate crate = pl.getCrate(name);
crate.setRandomItems(e.getInventory().getContents());
}
}
示例6: onPrepare
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
@EventHandler
public void onPrepare(PrepareItemCraftEvent e) {
CraftingInventory inv = e.getInventory();
if(inv.getRecipe().getResult().hasItemMeta()) {
if(inv.getRecipe().getResult().getItemMeta().hasDisplayName()) {
if(inv.getRecipe().getResult().getItemMeta().getDisplayName().equalsIgnoreCase("crate")) {
if(inv.getItem(5) != null) {
if(inv.getItem(5).hasItemMeta()) {
if(inv.getItem(5).getItemMeta().hasDisplayName()) {
if(pl.isCrate(inv.getItem(5).getItemMeta().getDisplayName())) {
Crate crate = pl.getCrate(inv.getItem(5).getItemMeta().getDisplayName());
if(crate.needsKey()) {
if(inv.getItem(5).getType() == (crate.getType() == CrateType.NORMAL ? Material.GOLD_INGOT : Material.DIAMOND)) {
inv.setResult(crate.getKeyItem());
} else {
inv.setResult(null);
}
} else {
inv.setResult(null);
}
} else {
inv.setResult(null);
}
} else {
inv.setResult(null);
}
} else {
inv.setResult(null);
}
}
}
}
}
}
示例7: spawnRandomCrate
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
/**
* @author xize
* @param returns the random crate
* @return NormalCrate
*/
public Crate spawnRandomCrate(String player) {
if(pl.getManagers().getPlayerManager().isOnline(player)) {
Random rand = new Random();
XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(player);
CratePlayer cratePlayer = api.getCratePlayer(player);
Crate crate = api.getCrates()[rand.nextInt(api.getCrates().length)];
return api.spawnCrate(cratePlayer, crate, xp.getBukkitPlayer().getLocation());
}
return null;
}
示例8: onVote
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onVote(VotifierEvent e) {
Vote vote = e.getVote();
if(pl.getManagers().getPlayerManager().isEssentialsPlayer(vote.getUsername())) {
Player p = Bukkit.getPlayer(vote.getUsername());
Crate crate = pl.getManagers().getManCoManager().spawnRandomCrate(vote.getUsername());
if(p.isOnline()) {
sendMessage(p, pl.getConfiguration().getVoteConfig().getVotePersonalMessage().replaceAll("%player%", p.getName()).replaceAll("%reward%", (crate.getType() == CrateType.RARE ? ChatColor.DARK_PURPLE + crate.getCrateName() : crate.getCrateName())));
broadcast(pl.getConfiguration().getVoteConfig().getVoteBroadcastMessage().replaceAll("%player%", vote.getUsername()).replaceAll("%reward%", (crate.getType() == CrateType.RARE ? ChatColor.DARK_PURPLE + crate.getCrateName() : crate.getCrateName())));
}
}
}
示例9: CrateEvent
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
public CrateEvent(Crate crate) {
this.crate = crate;
}
示例10: CrateFallEvent
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
public CrateFallEvent(CratePlayer p, Chest chest, Crate crate) {
super(crate);
this.chest = chest;
this.p = p;
}
示例11: getCrate
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
public Crate getCrate() {
if(hasCrate()) {
return pl.getCrate(getCrateChest().getMetadata("crate_serie").get(0).asString());
}
return null;
}
示例12: onCall
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onCall(EntityChangeBlockEvent e) {
if(e.getEntity() instanceof FallingBlock) {
FallingBlock fall = (FallingBlock) e.getEntity();
if(fall.hasMetadata("crate_serie") && fall.hasMetadata("crate_owner")) {
String player = (String)((FixedMetadataValue)fall.getMetadata("crate_owner").get(0)).asString();
String serie = (String)((FixedMetadataValue)fall.getMetadata("crate_serie").get(0)).asString();
if(!pl.canFall(fall.getLocation())) {
fall.removeMetadata("crate_owner", pl);
fall.removeMetadata("crate_serie", pl);
e.setCancelled(true);
return;
}
Player p = Bukkit.getPlayer(player);
if(p instanceof Player) {
Block block = fall.getLocation().getBlock();
block.setType(Material.CHEST);
Chest chest = (Chest) block.getState();
chest.setMetadata("crate_owner", new FixedMetadataValue(pl, player));
chest.setMetadata("crate_serie", new FixedMetadataValue(pl, serie));
Crate ncrate = pl.getCrateSerie(serie);
List<ItemStack> items = new ArrayList<ItemStack>();
Iterator<ItemStack> it = ncrate.getRandomItems().iterator();
while(it.hasNext()) {
items.add(it.next());
}
for(int i = 0; i < ncrate.getMiniumSlots(); i++) {
Collections.shuffle(items);
chest.getInventory().addItem(items.get(0));
}
p.setMetadata("crate", new FixedMetadataValue(pl, chest));
Bukkit.getPluginManager().callEvent(new CrateFallEvent(pl.getApi().getCratePlayer(player), chest, ncrate));
fall.removeMetadata("crate_owner", pl);
fall.removeMetadata("crate_serie", pl);
e.setCancelled(true);
} else {
fall.removeMetadata("crate_owner", pl);
fall.removeMetadata("crate_serie", pl);
e.setCancelled(true);
}
}
}
}
示例13: getCrate
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
public Crate getCrate(String name) {
if(getConfiguration().getCrateList().containsKey(name)) {
return getConfiguration().getCrateList().get(name);
}
throw new NullPointerException("crate does not exist");
}
示例14: getCrateSerie
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
@Override
public Crate getCrateSerie(String name) throws NullPointerException {
return getCrate(name);
}
示例15: removeCrateSerie
import tv.mineinthebox.manco.interfaces.Crate; //导入依赖的package包/类
@Override
public void removeCrateSerie(String name) throws NullPointerException {
Crate crate = getCrateSerie(name);
crate.remove();
}