Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/unchama/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Sep 5, 2017
2 parents b971bd7 + 06a8134 commit a0ec8ab
Show file tree
Hide file tree
Showing 27 changed files with 563 additions and 57 deletions.
7 changes: 6 additions & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ commands:
description: This is Lastquit command.
usage: /<command> <player>
default: op
permission: gigantic.lastquit
permission: gigantic.lastquit
halfguard:
description: This is HalfGuard command.
usage: /<command>
default: op
permission: gigantic.halfguard
15 changes: 2 additions & 13 deletions src/com/github/unchama/command/CommandType.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
package com.github.unchama.command;

import com.github.unchama.command.commands.*;
import org.bukkit.command.TabExecutor;

import com.github.unchama.command.commands.AchieveCommand;
import com.github.unchama.command.commands.DebugCommand;
import com.github.unchama.command.commands.EnchantmentCommand;
import com.github.unchama.command.commands.FlyCommand;
import com.github.unchama.command.commands.GachaCommand;
import com.github.unchama.command.commands.GrowthCommand;
import com.github.unchama.command.commands.HomeCommand;
import com.github.unchama.command.commands.LastquitCommand;
import com.github.unchama.command.commands.ListenCommand;
import com.github.unchama.command.commands.MineBoostCommand;
import com.github.unchama.command.commands.PresentBoxCommand;
import com.github.unchama.command.commands.StickCommand;
import com.github.unchama.command.commands.TakeoverCommand;
/**
* @author tar0ss
*
Expand All @@ -33,6 +21,7 @@ public enum CommandType {
TAKEOVER(new TakeoverCommand()),
LASTQUIT(new LastquitCommand()),
ACHIEVE(new AchieveCommand()),
HALFGUARD(new HalfBlockProtectCommand()),
;


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.github.unchama.command.commands;


import com.github.unchama.gigantic.PlayerManager;
import com.github.unchama.player.GiganticPlayer;
import com.github.unchama.player.protect.HalfBlockProtectData;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;

import java.util.List;

/**
* Y5ハーフブロック破壊可能フラグ変更コマンド
* 権限を有する人のみ使用可能
*
* @author karayuu
*/
public class HalfBlockProtectCommand implements TabExecutor {

@Override
public List<String> onTabComplete(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
return null;
}

@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
//プレイヤーからの送信ではない時終了
if(!(commandSender instanceof Player)){
commandSender.sendMessage(ChatColor.RED + "このコマンドはゲーム内から実行してください.");
return false;
}

if (strings.length == 0) {
// /halfguard 実行時
GiganticPlayer gp = PlayerManager.getGiganticPlayer((Player) commandSender);
if (gp == null) {
throw new NullPointerException("/HalfGuardコマンドData取得処理でnull.開発者に報告してください.");
}
HalfBlockProtectData data= gp.getManager(HalfBlockProtectData.class);

data.toggleHalfBreakFlag();
commandSender.sendMessage("現在ハーフブロックは" + getStats(data.canBreakHalfBlock()) + ChatColor.RESET + "です.");
return true;
}
return false;
}

private String getStats (Boolean canBreak) {
if (canBreak) {
return ChatColor.GREEN + "破壊可能";
} else {
return ChatColor.RED + "破壊不可能";
}
}
}
14 changes: 14 additions & 0 deletions src/com/github/unchama/enchantment/EnchantmentEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
public enum EnchantmentEnum {

//コメントアウトは保留案件

//II
CHOBA("跳馬", new ChobaEnchantment(), MaterialUtil.getHelmets()),
TOSSHIN("突進", new TosshinEnchantment(), MaterialUtil.getHelmets()),
FUROFUSHI("不老不死", new FuroFushiEnchantment(), MaterialUtil.getLeggings()),
KOTUEI("骨影", new KotueiEnchantment(), MaterialUtil.getPickaxes()),
YUWAKU("誘惑", new YuwakuEnchantment(), MaterialUtil.getSwords()),
HANGEKI("反撃", new HangekiEnchantment(), Material.BOW),
ITAZURA("悪戯", new ItazuraEnchantment(), MaterialUtil.getAxes()),
//NIDANJUMP("二段ジャンプ", new NidanJumpEnchantment(), MaterialUtil.getBoots()),
SYUNPO("瞬歩", new SyunpoEnchantment(), MaterialUtil.getShovels()),
ANTIKNOWKBACK("ノックバック耐性", new AntiKnockbackEnchantment(), MaterialUtil.getBoots()),

//III
HAHUU("覇風", new HahuuEnchantment(), MaterialUtil.getPickaxes(), 1),
//DENSEN("伝染", new DensenEnchantment(), MaterialUtil.getAxes()),
HYOKA("氷華", new HyokaEnchantment(), MaterialUtil.getShovels(), 1),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.unchama.enchantment.enchantments;

import com.github.unchama.enchantment.GiganticEnchantment;
import com.github.unchama.event.PlayerDamageWithArmorEvent;
import com.github.unchama.gigantic.Gigantic;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;

/**
* @author Mon_chi
*/
public class AntiKnockbackEnchantment implements GiganticEnchantment {

@Override
public boolean onEvent(Event event, Player player, ItemStack item, int level) {
if (event instanceof PlayerDamageWithArmorEvent) {
System.out.println(player.getName());
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_PLACE, 3, 3);
Bukkit.getScheduler().runTaskLater(Gigantic.plugin, () -> player.setVelocity(new Vector(0, 0, 0)), 1L);
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.github.unchama.enchantment.enchantments;

import com.github.unchama.enchantment.GiganticEnchantment;
import com.github.unchama.event.PlayerDamageWithArmorEvent;
import com.github.unchama.event.SecondEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

/**
* @author Mon_chi
*/
public class ChobaEnchantment implements GiganticEnchantment {

private int countFlag;

public ChobaEnchantment() {
this.countFlag = 0;
}

@Override
public boolean onEvent(Event event, Player player, ItemStack item, int level) {
if (event instanceof SecondEvent) {
if (countFlag < 2) {
this.countFlag += 1;
}
else {
this.countFlag = 0;
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20 * 5, 2));
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20 * 5, 2));
}
}
else if (event instanceof PlayerDamageWithArmorEvent) {
EntityDamageEvent e = ((PlayerDamageWithArmorEvent) event).getOriginEvent();
if (e.getCause() == EntityDamageEvent.DamageCause.FALL) {
e.setDamage(e.getDamage() * 0.5);
}
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.github.unchama.enchantment.enchantments;

import com.github.unchama.enchantment.GiganticEnchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.inventory.ItemStack;

/**
* @author Mon_chi
*/
public class FuroFushiEnchantment implements GiganticEnchantment {

@Override
public boolean onEvent(Event event, Player player, ItemStack item, int level) {
if (event instanceof FoodLevelChangeEvent) {
if (((FoodLevelChangeEvent) event).getFoodLevel() < 7) {
((FoodLevelChangeEvent) event).setFoodLevel(7);
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.unchama.enchantment.GiganticEnchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
Expand All @@ -21,10 +22,10 @@ public boolean onEvent(Event event, Player player, ItemStack item, int level) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = ((LivingEntity) entity);
livingEntity.damage(6, player);
if (!livingEntity.isDead()) {
if (livingEntity.getType() != EntityType.PLAYER && !livingEntity.isDead()) {
Vector direction = entity.getLocation().getDirection().normalize().multiply(3);
direction.setX(-direction.getX()).setY(-direction.getY()).setZ(-direction.getZ());
entity.setVelocity(direction);
entity.setVelocity(direction.add(entity.getVelocity()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.unchama.enchantment.enchantments;

import com.github.unchama.enchantment.GiganticEnchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;

/**
* @author Mon_chi
*/
public class HangekiEnchantment implements GiganticEnchantment {

@Override
public boolean onEvent(Event event, Player player, ItemStack item, int level) {
if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
if (e.getEntity() == player && e.getDamager() != player) {
Vector direction = e.getDamager().getLocation().getDirection().normalize().multiply(10);
direction.setX(-direction.getX()).setY(-direction.getY()).setZ(-direction.getZ());
e.getDamager().setVelocity(direction.add(e.getDamager().getVelocity()));
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public boolean onEvent(Event event, Player player, ItemStack item, int level) {
LivingEntity livingEntity = (LivingEntity) entity;
livingEntity.damage(6, player);
if (!livingEntity.isDead())
livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * 10, 1));
livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 10, 255));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.github.unchama.enchantment.enchantments;

import com.github.unchama.enchantment.GiganticEnchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;

/**
* @author Mon_chi
*/
public class ItazuraEnchantment implements GiganticEnchantment {

@Override
public boolean onEvent(Event event, Player player, ItemStack item, int level) {
if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
if (e.getDamager() == player && e.getEntity() instanceof LivingEntity && e.getEntityType() != EntityType.CHICKEN) {
e.getEntity().remove();
e.getEntity().getWorld().spawnEntity(e.getEntity().getLocation(), EntityType.CHICKEN);
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.github.unchama.enchantment.enchantments;

import com.github.unchama.enchantment.GiganticEnchantment;
import com.github.unchama.util.Util;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

/**
* @author Mon_chi
*/
public class KotueiEnchantment implements GiganticEnchantment {
@Override
public boolean onEvent(Event event, Player player, ItemStack item, int level) {
if (event instanceof BlockBreakEvent) {
for (Entity entity : player.getNearbyEntities(20, 20, 20)) {
if (entity.getType() == EntityType.SKELETON && !entity.isDead()) {
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 50, 4));
}
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
Expand All @@ -19,21 +20,23 @@ public class RaiteiEnchantment implements GiganticEnchantment {
@Override
public boolean onEvent(Event event, Player player, ItemStack item, int level) {
if (event instanceof PlayerDamageWithArmorEvent) {
PlayerDamageWithArmorEvent e = (PlayerDamageWithArmorEvent) event;
if (e.getOriginEvent().getDamager() instanceof LivingEntity) {
LivingEntity damager = (LivingEntity) e.getOriginEvent().getDamager();
damager.damage(12, player);
List<Entity> entitiesAroundDamager = damager.getNearbyEntities(10, 10, 10);
List<Integer> damagedEntities = new ArrayList<>();
for (Entity entity : entitiesAroundDamager) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
livingEntity.damage(8, player);
damagedEntities.add(livingEntity.getEntityId());
for (Entity nestedEntity: livingEntity.getNearbyEntities(10, 10, 10)) {
if (!entitiesAroundDamager.contains(nestedEntity) && !damagedEntities.contains(nestedEntity.getEntityId())) {
livingEntity.damage(4, player);
damagedEntities.add(nestedEntity.getEntityId());
if (((PlayerDamageWithArmorEvent) event).getOriginEvent() instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) ((PlayerDamageWithArmorEvent) event).getOriginEvent();
if (e.getDamager() instanceof LivingEntity) {
LivingEntity damager = (LivingEntity) e.getDamager();
damager.damage(12, player);
List<Entity> entitiesAroundDamager = damager.getNearbyEntities(10, 10, 10);
List<Integer> damagedEntities = new ArrayList<>();
for (Entity entity : entitiesAroundDamager) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
livingEntity.damage(8, player);
damagedEntities.add(livingEntity.getEntityId());
for (Entity nestedEntity : livingEntity.getNearbyEntities(10, 10, 10)) {
if (!entitiesAroundDamager.contains(nestedEntity) && !damagedEntities.contains(nestedEntity.getEntityId())) {
livingEntity.damage(4, player);
damagedEntities.add(nestedEntity.getEntityId());
}
}
}
}
Expand Down
Loading

0 comments on commit a0ec8ab

Please sign in to comment.