SteamWar/FightSystem
Archiviert
13
1

Not stable version

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-23 20:22:29 +01:00
Ursprung d2d126f02f
Commit c06a6803cc
8 geänderte Dateien mit 75 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -75,7 +75,7 @@ public class FightSystem extends JavaPlugin {
Fight.getRedTeam().setName(fileManager.getStringFromConfig("Output.TeamRedName"));
Fight.getRedTeam().setPrefix(fileManager.getStringFromConfig("Output.TeamRedColor"));
Fight.getBlueTeam().setPrefix(fileManager.getStringFromConfig("Output.TeamBlueName"));
Fight.getBlueTeam().setName(fileManager.getStringFromConfig("Output.TeamBlueName"));
Fight.getBlueTeam().setPrefix(fileManager.getStringFromConfig("Output.TeamBlueColor"));
//Load config
@ -175,6 +175,7 @@ public class FightSystem extends JavaPlugin {
pm.registerEvents(new BlockPlaceListener(), plugin);
pm.registerEvents(new BlockBreakListener(), plugin);
pm.registerEvents(new PlayerMoveListener(), plugin);
pm.registerEvents(new EntityDamageByEntityListener(), plugin);
//WinConditions
if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin);

Datei anzeigen

@ -10,6 +10,8 @@ import org.bukkit.event.block.BlockBreakEvent;
public class BlockBreakListener implements Listener {
FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handleBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
@ -18,7 +20,7 @@ public class BlockBreakListener implements Listener {
event.setCancelled(true);
else if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) {
event.setCancelled(true);
if(FightSystem.getPlugin().getFightState() == FightState.PRE_RUNNING) {
if(instance.getFightState() == FightState.SETUP || instance.getFightState() == FightState.PRE_RUNNING) {
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke abbauen!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr abbauen!");

Datei anzeigen

@ -0,0 +1,59 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class EntityDamageByEntityListener implements Listener {
FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(instance.getFightState() != FightState.RUNNING) {
if(event.getEntity() instanceof Player) {
event.setCancelled(true);
}
} else {
if(event.getEntity() instanceof Player) {
Player player = ((Player) event.getEntity()).getPlayer();
if(event.getDamager() instanceof Player) {
Player damager = ((Player) event.getDamager()).getPlayer();
if(Fight.getPlayerTeam(player) != null) {
if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) {
event.setCancelled(true);
damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden machen!");
}
} else
event.setCancelled(true);
}
if(event.getDamager() instanceof Arrow) {
Arrow damagerArrow = (Arrow) event.getDamager();
if(!(damagerArrow.getShooter() instanceof Player)) {
return;
}
Player damager = (Player) damagerArrow.getShooter();
if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) {
event.setCancelled(true);
damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden machen!");
damagerArrow.setFireTicks(0);
player.setFireTicks(0);
}
}
}
}
}
}

Datei anzeigen

@ -23,10 +23,10 @@ public class PlayerChatListener implements Listener {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null){
if(fightTeam != null) {
String prefixColorCode = fightTeam.getPrefix();
String teamName = fightTeam.getName();
if(message.startsWith(teamChatDetection)){
if(message.startsWith(teamChatDetection)) {
fightTeam.broadcast(prefixColorCode + player.getName() + "» " + prefixColorCode + message);
} else {
Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + " §8» §7" + message);

Datei anzeigen

@ -48,7 +48,11 @@ public class PlayerInteractListener implements Listener {
break;
case "§4Abbrechen":
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team von §a" + fightTeam.getLeader().getPlayer().getName() + " §6hat den Kampf abgebrochen! \n Server stoppt in 30 Sekunden...");
Countdown countdown = new Countdown(20*30, new FinishNoPlayersOnline());
player.getInventory().clear();
if(Fight.getOpposite(fightTeam).getLeader().getPlayer() != null) Fight.getOpposite(fightTeam).getLeader().getPlayer().getInventory().clear();
Countdown.cancelAllTimers(instance);
Countdown countdown = new Countdown(30, new FinishNoPlayersOnline());
countdown.startTimer(instance);
break;
default:

Datei anzeigen

@ -53,7 +53,7 @@ public class Countdown {
Bukkit.getScheduler().cancelTask(taskID);
}
public void cancelAllTimers(FightSystem plugin) {
public static void cancelAllTimers(FightSystem plugin) {
Bukkit.getScheduler().cancelTasks(plugin);
}
}

Datei anzeigen

@ -11,7 +11,7 @@ public class SetupItems {
public static void giveSetupItems(Player player) {
Inventory inventory = player.getInventory();
inventory.setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
inventory.setItem(3, new ItemBuilder(Material.INK_SACK, (short) 1).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§4Abbrechen").build());
inventory.setItem(5, new ItemBuilder(Material.INK_SACK, (short) 1).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§4Abbrechen").build());
}

Datei anzeigen

@ -48,8 +48,8 @@ public class Scoreboard {
objective.setDisplayName("§6Fight Info");
objective.getScore("§7Zeit: §a" + FightSystem.getPlugin().getFightTime()).setScore(0);
if(Methods.isEnabled("Fight.Entern")) objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(1);
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden ROT: " + FightSystem.getPlugin().getDamageRed()).setScore(2);
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: " + FightSystem.getPlugin().getGetDamageBlue()).setScore(3);
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(2);
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(3);
}
player.setScoreboard(scoreboard);
index++;