测试版2.0

This commit is contained in:
yaohunya 2024-10-21 11:01:23 +08:00
parent dd95bcb686
commit dafbc09075
6 changed files with 53 additions and 14 deletions

View File

@ -107,7 +107,20 @@ public class Game {
}
}.runTaskTimer(MinerWar.inst(),0L,10L);
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(){
villagerShop.remove();
for (Player player1 : Bukkit.getOnlinePlayers()){
@ -126,6 +139,8 @@ public class Game {
bossBar1.addPlayer(player);
bossBar2.addPlayer(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){

View File

@ -22,6 +22,8 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
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.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
@ -76,7 +78,19 @@ public class GamePotect implements Listener {
@EventHandler
public void onClick(InventoryClickEvent e){
int rawSlot = e.getRawSlot();
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 // 禁止丢弃任何物品
@ -86,7 +100,16 @@ public class GamePotect implements Listener {
e.setCancelled(true);
/*if(e.getItemDrop().getItemStack().getType().equals(Material.RAW_GOLD)) {
e.setCancelled(true);
}*/
}*/
}
@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);
}
}

View File

@ -82,9 +82,12 @@ public class KeepEntitiesOnDeath implements Listener {
scale = 0.2;
}
int rawGoldAmount = game.getExcavateAmount(player); // 获取玩家有多少粗金
int dropRawGold = (int) (rawGoldAmount * scale);// 获取本次死亡会掉落多少粗金
if(dropRawGold >= 1) {
player.sendMessage("§c[消息] §a丢失了§e"+dropRawGold+"块§a黄金");
if(rawGoldAmount >= 1) {
int dropRawGold = (int) (rawGoldAmount * scale);// 获取本次死亡会掉落多少粗金
if (dropRawGold <= 1) {
dropRawGold = 1;
}
player.sendMessage("§c[消息] §a丢失了§e" + dropRawGold + "块§a黄金");
setBackpackThickGoldTime(player, rawGoldAmount - dropRawGold);
game.effect_RefreshExcavateAmount(player);
}

View File

@ -26,8 +26,8 @@ public class PlayerListener implements Listener {
Player p = e.getPlayer();
if (game.isStarted()) {
if (p.isSneaking()) {
p.setFoodLevel(4);
p.setHealth(6);
// p.setFoodLevel(4);
// p.setHealth(6);
RepairGiftGui.OpenGui(p);
}
}

View File

@ -10,6 +10,8 @@ import com.yutian.minerwar.listener.KeepEntitiesOnDeath;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import tools.CDTimeAPI;
import tools.GameUtil;
@ -22,14 +24,8 @@ public class GiftEventHandler {
userName = GameUtil.hideName(userName);
if (eventName.equalsIgnoreCase("螺旋升天")) {
} else if (eventName.contains("瞬间加血")) {
int heal = 1;
int stringHeal = Integer.parseInt(eventName.replace("瞬间加血",""));
if(stringHeal >= 1){
heal = stringHeal;
}
int newHeal = (int) Math.min(zhubo.getHealth() + heal, 20);
zhubo.setHealth(newHeal);
} else if (eventName.equalsIgnoreCase("瞬间加血")) {
zhubo.addPotionEffect(new PotionEffect(PotionEffectType.HEAL,3,0));
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);
} else if (eventName.equalsIgnoreCase("天使庇护")) {

View File

@ -17,6 +17,7 @@ public class StackUtil {
ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addEnchant(Enchantment.DAMAGE_ALL,4,true);
meta.setUnbreakable(true);
item.setItemMeta(meta);
return item;
@ -25,6 +26,7 @@ public class StackUtil {
ItemStack item = new ItemStack(Material.IRON_PICKAXE);
ItemMeta meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addEnchant(Enchantment.DIG_SPEED,3,true);
meta.setUnbreakable(true);
item.setItemMeta(meta);
return item;