测试版2.0
This commit is contained in:
parent
dd95bcb686
commit
dafbc09075
|
@ -107,7 +107,20 @@ public class Game {
|
||||||
}
|
}
|
||||||
}.runTaskTimer(MinerWar.inst(),0L,10L);
|
}.runTaskTimer(MinerWar.inst(),0L,10L);
|
||||||
tasks.add(task);
|
tasks.add(task);
|
||||||
|
// 启动任务,定期检查时间并切换白天和黑夜
|
||||||
|
BukkitTask worldTimeTask = new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// 获取当前世界时间
|
||||||
|
long currentTime = world.getTime();
|
||||||
|
// 每秒加快 2 ticks,使其加速一倍(10 分钟一个昼夜)
|
||||||
|
world.setTime(currentTime + 3);
|
||||||
}
|
}
|
||||||
|
}.runTaskTimer(MinerWar.inst(),0L,1L);
|
||||||
|
tasks.add(worldTimeTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void stop(){
|
public void stop(){
|
||||||
villagerShop.remove();
|
villagerShop.remove();
|
||||||
for (Player player1 : Bukkit.getOnlinePlayers()){
|
for (Player player1 : Bukkit.getOnlinePlayers()){
|
||||||
|
@ -126,6 +139,8 @@ public class Game {
|
||||||
bossBar1.addPlayer(player);
|
bossBar1.addPlayer(player);
|
||||||
bossBar2.addPlayer(player);
|
bossBar2.addPlayer(player);
|
||||||
initPlayerBackpack(player);
|
initPlayerBackpack(player);
|
||||||
|
Location location = new Location(player.getWorld(),6.5,78.0,-75.5,90,0);
|
||||||
|
player.teleport(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initPlayerBackpack(Player player){
|
public void initPlayerBackpack(Player player){
|
||||||
|
|
|
@ -22,6 +22,8 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityInteractEvent;
|
import org.bukkit.event.entity.EntityInteractEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
|
@ -76,7 +78,19 @@ public class GamePotect implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(InventoryClickEvent e){
|
public void onClick(InventoryClickEvent e){
|
||||||
|
int rawSlot = e.getRawSlot();
|
||||||
Player p = (Player) e.getWhoClicked();
|
Player p = (Player) e.getWhoClicked();
|
||||||
|
Inventory inv = e.getInventory();
|
||||||
|
if(inv.getType() == InventoryType.CRAFTING){
|
||||||
|
if(rawSlot == 36 || rawSlot == 37 || rawSlot == 38){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(inv.getType() == InventoryType.MERCHANT){
|
||||||
|
if(rawSlot == 30 || rawSlot == 31 || rawSlot == 32){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler // 禁止丢弃任何物品
|
@EventHandler // 禁止丢弃任何物品
|
||||||
|
@ -89,6 +103,15 @@ public class GamePotect implements Listener {
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onCloseInv(InventoryCloseEvent e){
|
||||||
|
Player player = (Player) e.getPlayer();
|
||||||
|
Inventory inventory = e.getInventory();
|
||||||
|
if(inventory.getType().equals(InventoryType.MERCHANT)){
|
||||||
|
MinerWar.getGame().effect_RefreshExcavateAmount(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBreakProtectedArea(BlockBreakEvent e){
|
public void onBreakProtectedArea(BlockBreakEvent e){
|
||||||
|
|
|
@ -82,9 +82,12 @@ public class KeepEntitiesOnDeath implements Listener {
|
||||||
scale = 0.2;
|
scale = 0.2;
|
||||||
}
|
}
|
||||||
int rawGoldAmount = game.getExcavateAmount(player); // 获取玩家有多少粗金
|
int rawGoldAmount = game.getExcavateAmount(player); // 获取玩家有多少粗金
|
||||||
|
if(rawGoldAmount >= 1) {
|
||||||
int dropRawGold = (int) (rawGoldAmount * scale);// 获取本次死亡会掉落多少粗金
|
int dropRawGold = (int) (rawGoldAmount * scale);// 获取本次死亡会掉落多少粗金
|
||||||
if(dropRawGold >= 1) {
|
if (dropRawGold <= 1) {
|
||||||
player.sendMessage("§c[消息] §a丢失了§e"+dropRawGold+"块§a黄金!");
|
dropRawGold = 1;
|
||||||
|
}
|
||||||
|
player.sendMessage("§c[消息] §a丢失了§e" + dropRawGold + "块§a黄金!");
|
||||||
setBackpackThickGoldTime(player, rawGoldAmount - dropRawGold);
|
setBackpackThickGoldTime(player, rawGoldAmount - dropRawGold);
|
||||||
game.effect_RefreshExcavateAmount(player);
|
game.effect_RefreshExcavateAmount(player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ public class PlayerListener implements Listener {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
if (game.isStarted()) {
|
if (game.isStarted()) {
|
||||||
if (p.isSneaking()) {
|
if (p.isSneaking()) {
|
||||||
p.setFoodLevel(4);
|
// p.setFoodLevel(4);
|
||||||
p.setHealth(6);
|
// p.setHealth(6);
|
||||||
RepairGiftGui.OpenGui(p);
|
RepairGiftGui.OpenGui(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import com.yutian.minerwar.listener.KeepEntitiesOnDeath;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import tools.CDTimeAPI;
|
import tools.CDTimeAPI;
|
||||||
import tools.GameUtil;
|
import tools.GameUtil;
|
||||||
|
|
||||||
|
@ -22,14 +24,8 @@ public class GiftEventHandler {
|
||||||
userName = GameUtil.hideName(userName);
|
userName = GameUtil.hideName(userName);
|
||||||
if (eventName.equalsIgnoreCase("螺旋升天")) {
|
if (eventName.equalsIgnoreCase("螺旋升天")) {
|
||||||
|
|
||||||
} else if (eventName.contains("瞬间加血")) {
|
} else if (eventName.equalsIgnoreCase("瞬间加血")) {
|
||||||
int heal = 1;
|
zhubo.addPotionEffect(new PotionEffect(PotionEffectType.HEAL,3,0));
|
||||||
int stringHeal = Integer.parseInt(eventName.replace("瞬间加血",""));
|
|
||||||
if(stringHeal >= 1){
|
|
||||||
heal = stringHeal;
|
|
||||||
}
|
|
||||||
int newHeal = (int) Math.min(zhubo.getHealth() + heal, 20);
|
|
||||||
zhubo.setHealth(newHeal);
|
|
||||||
zhubo.playSound(zhubo.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP,1,1);
|
zhubo.playSound(zhubo.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP,1,1);
|
||||||
zhubo.getWorld().spawnParticle(Particle.VILLAGER_HAPPY,zhubo.getLocation().add(0,1,0),20,0.1,0.1,0.1,0.3);
|
zhubo.getWorld().spawnParticle(Particle.VILLAGER_HAPPY,zhubo.getLocation().add(0,1,0),20,0.1,0.1,0.1,0.3);
|
||||||
} else if (eventName.equalsIgnoreCase("天使庇护")) {
|
} else if (eventName.equalsIgnoreCase("天使庇护")) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class StackUtil {
|
||||||
ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
|
ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||||
|
meta.addEnchant(Enchantment.DAMAGE_ALL,4,true);
|
||||||
meta.setUnbreakable(true);
|
meta.setUnbreakable(true);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
return item;
|
return item;
|
||||||
|
@ -25,6 +26,7 @@ public class StackUtil {
|
||||||
ItemStack item = new ItemStack(Material.IRON_PICKAXE);
|
ItemStack item = new ItemStack(Material.IRON_PICKAXE);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||||
|
meta.addEnchant(Enchantment.DIG_SPEED,3,true);
|
||||||
meta.setUnbreakable(true);
|
meta.setUnbreakable(true);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
return item;
|
return item;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user