Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ClockClap authored and = committed May 24, 2021
1 parent c8c63d2 commit 949a2a2
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
2 changes: 2 additions & 0 deletions 7mi-TCT-API/src/main/java/me/clockclap/tct/api/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public static List<String> colorChars() {
public static final String TCT_CHAT_WOLVES_VICTORY = ChatColor.RED + "村人陣営は全滅し、妖狐も死亡しました";
public static final String TCT_CHAT_FOX_VICTORY_A = ChatColor.GOLD + "人狼陣営は全滅し、妖狐が生き残りました";
public static final String TCT_CHAT_FOX_VICTORY_B = ChatColor.GOLD + "村人陣営は全滅し、妖狐が生き残りました";
public static final String TCT_CHAT_FOX_VICTORY_C = ChatColor.GOLD + "全陣営が全滅し、妖狐が生き残りました";
public static final String TCT_CHAT_NO_VICTORY = ChatColor.GRAY + "運営によって強制終了されたため、引き分けになります";
public static final String TCT_CHAT_VICTORY = "%COLOR%%TEAM%が勝利しました";
//ゲーム終了
Expand Down Expand Up @@ -203,6 +204,7 @@ public static List<String> colorChars() {
public static final String TCT_TITLE_MAIN_FOX_VICTORY = ChatColor.GOLD + "妖狐陣営が勝利しました";
public static final String TCT_TITLE_SUB_FOX_VICTORY_A = ChatColor.GRAY + "人狼陣営全滅時に生き残っていた妖狐陣営の勝利";
public static final String TCT_TITLE_SUB_FOX_VICTORY_B = ChatColor.GRAY + "村人陣営全滅時に生き残っていた妖狐陣営の勝利";
public static final String TCT_TITLE_SUB_FOX_VICTORY_C = ChatColor.GRAY + "全陣営全滅時に生き残っていた妖狐陣営の勝利";
public static final String TCT_TITLE_MAIN_NO_VICTORY = ChatColor.DARK_GRAY + "引き分け";
public static final String TCT_TITLE_SUB_NO_VICTORY = ChatColor.GRAY + "ゲームが強制終了されました";
public static final String TCT_TITLE_MAIN_VICTORY = "%COLOR%%TEAM%が勝利しました";
Expand Down
2 changes: 1 addition & 1 deletion 7miTCT/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>7mi-TCT</artifactId>
<version>4.0.8</version>
<version>4.2.0</version>
<packaging>jar</packaging>

<name>7miTct</name>
Expand Down
56 changes: 52 additions & 4 deletions 7miTCT/src/main/java/me/clockclap/tct/event/DamageEvent.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.clockclap.tct.event;

import me.clockclap.tct.NanamiTct;
import me.clockclap.tct.NanamiTctApi;
import me.clockclap.tct.api.Reference;
import me.clockclap.tct.api.sql.MySQLStatus;
import me.clockclap.tct.game.GameState;
Expand All @@ -22,12 +23,14 @@
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class DamageEvent implements Listener {
Expand Down Expand Up @@ -80,7 +83,7 @@ public void onDamageByEntity(EntityDamageByEntityEvent e) {
continue;
}
if (item.hasItemMeta()) {
if(item.getType() == Material.ARROW) return;
if(item.getType() == Material.ARROW) continue;
if (item.getItemMeta().getDisplayName().equalsIgnoreCase(CustomItems.SPONGE.getItemStack().getItemMeta().getDisplayName())) {
int amt = item.getAmount() - 1;
if(amt <= 0) {
Expand All @@ -103,6 +106,7 @@ public void onDamageByEntity(EntityDamageByEntityEvent e) {
}
}

@SuppressWarnings("unchecked")
@EventHandler
public void onDeath(EntityDeathEvent e) {
if(e.getEntity() instanceof Player) {
Expand Down Expand Up @@ -155,7 +159,6 @@ public void onDeath(EntityDeathEvent e) {
return;
}
if (villagers.size() <= 0 && wolves.size() <= 0) {
p.spigot().respawn();
plugin.getGame().getTimer().cancel();
if (foxes.size() > 0) {
plugin.getGame().stop(GameTeams.FOXES);
Expand All @@ -180,7 +183,53 @@ public void onDeath(EntityDeathEvent e) {
if(opkiller != null) {
PlayerData killer = plugin.getGame().getReference().PLAYERDATA.get(opkiller.getUniqueId());
killer.addKilledPlayer(NanamiTct.utilities.resetColor(p.getName()));
data.setKilledBy(new Killer(p.getKiller(), plugin.getGame().getReference().PLAYERDATA.get(p.getKiller().getUniqueId()).getRole()));
data.setKilledBy(new Killer(opkiller, plugin.getGame().getReference().PLAYERDATA.get(p.getKiller().getUniqueId()).getRole()));
FileConfiguration config = NanamiTctApi.config.getConfig();
Firework fw = (Firework) p.getWorld().spawnEntity(p.getLocation(), EntityType.FIREWORK);
FireworkMeta meta = fw.getFireworkMeta();
FireworkEffect.Builder builder = FireworkEffect.builder();
try {
FireworkEffect.Type type = FireworkEffect.Type.valueOf(config.getString("fireworks.type", "BURST"));
builder.with(type);
} catch (Exception ex) {
builder.with(FireworkEffect.Type.BURST);
}
try {
for (String color : (List<String>) config.getList("fireworks.colors", Arrays.asList("0xff0000"))) {
int c;
if (color.startsWith("0x")) {
c = (int) Long.parseLong(color, 16);
} else {
c = (int) Long.parseLong(color, 10);
}
builder.withColor(Color.fromRGB(c));
}
} catch(Exception ex) {
builder.withColor(Color.RED);
}
try {
for (String color : (List<String>) config.getList("fireworks.fades", Arrays.asList("0xff0000"))) {
int c;
if (color.startsWith("0x")) {
c = (int) Long.parseLong(color, 16);
} else {
c = (int) Long.parseLong(color, 10);
}
builder.withFade(Color.fromRGB(c));
}
} catch(Exception ex) {
builder.withFade(Color.RED);
}
if(builder != null) {
FireworkEffect effect = builder.build();
meta.addEffect(effect);
meta.setPower(config.getInt("fireworks.power"));
} else {
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BURST).withColor(Color.RED).withFade(Color.RED).build();
meta.addEffect(effect);
meta.setPower(1);
}
fw.setFireworkMeta(meta);
if(NanamiTct.playerStats != null) {
PlayerStat killerStat = NanamiTct.playerStats.getStat(opkiller.getUniqueId());
killerStat.setCountKill(killerStat.getCountKill() + 1);
Expand All @@ -190,7 +239,6 @@ public void onDeath(EntityDeathEvent e) {
if(item.hasItemMeta() && item.getItemMeta().getDisplayName().equalsIgnoreCase(CustomItems.EMPTY_BOTTLE.getItemStack().getItemMeta().getDisplayName())) {
int tick = 200;
int level;
FileConfiguration config = NanamiTct.plugin.getTctConfig().getConfig();
try {
if (config.getString("potion-effect.slowness.duration").endsWith("t")) {
String str = config.getString("potion-effect.slowness.duration");
Expand Down
3 changes: 3 additions & 0 deletions 7miTCT/src/main/java/me/clockclap/tct/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,9 @@ public void stop(GameTeam winners) {
} else if (wol.size() > 0 && vil.size() <= 0) {
p.sendMessage(Reference.TCT_CHATPREFIX + " " + Reference.TCT_CHAT_FOX_VICTORY_B);
p.sendTitle(Reference.TCT_TITLE_MAIN_FOX_VICTORY, Reference.TCT_TITLE_SUB_FOX_VICTORY_B, 5, 40, 5);
} else if (vil.size() <= 0 && wol.size() <= 0) {
p.sendMessage(Reference.TCT_CHATPREFIX + " " + Reference.TCT_CHAT_FOX_VICTORY_C);
p.sendTitle(Reference.TCT_TITLE_MAIN_FOX_VICTORY, Reference.TCT_TITLE_SUB_FOX_VICTORY_C, 5, 40, 5);
}
}
if (winners == GameTeams.WOLVES) {
Expand Down
1 change: 1 addition & 0 deletions 7miTCT/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 7mi_TCT
version: ${version}
load: STARTUP
main: me.clockclap.tct.NanamiTct
api-version: 1.12
prefix: 7mi-TCT
Expand Down

0 comments on commit 949a2a2

Please sign in to comment.