Fixes + Automatic Inspection Cleanup run (potentially something broken)
Dieser Commit ist enthalten in:
Ursprung
9b9da7ff6c
Commit
140959cdbd
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1 @@
|
||||
.idea
|
||||
*.iml
|
||||
.idea
|
25
fightsystem.iml
Normale Datei
25
fightsystem.iml
Normale Datei
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.19" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:SpigotCore:1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:WorldEdit:1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:FAWE:1.0" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -37,44 +37,42 @@ public class FightSystem extends JavaPlugin {
|
||||
private FightState fightState;
|
||||
|
||||
|
||||
public Location Team1SpawnLoc = null;
|
||||
public Location Team2SpawnLoc = null;
|
||||
public Location SpecSpawnLoc = null;
|
||||
public Location Team1PasteLoc = null;
|
||||
public Location Team2PasteLoc = null;
|
||||
private Location Team1SpawnLoc = null;
|
||||
private Location Team2SpawnLoc = null;
|
||||
private Location SpecSpawnLoc = null;
|
||||
private Location Team1PasteLoc = null;
|
||||
private Location Team2PasteLoc = null;
|
||||
|
||||
public int ArenaMinX;
|
||||
public int ArenaMaxX;
|
||||
public int ArenaMinZ;
|
||||
public int ArenaMaxZ;
|
||||
|
||||
public int schemsizeX;
|
||||
public int schemsizeY;
|
||||
public int schemsizeZ;
|
||||
private int schemsizeX;
|
||||
private int schemsizeY;
|
||||
private int schemsizeZ;
|
||||
|
||||
public int team1cornerX;
|
||||
public int team1cornerY;
|
||||
public int team1cornerZ;
|
||||
private int team1cornerX;
|
||||
private int team1cornerY;
|
||||
private int team1cornerZ;
|
||||
|
||||
public int team2cornerX;
|
||||
public int team2cornerY;
|
||||
public int team2cornerZ;
|
||||
private int team2cornerX;
|
||||
private int team2cornerY;
|
||||
private int team2cornerZ;
|
||||
|
||||
public int underArenaBorder;
|
||||
|
||||
|
||||
public int fightTime = 0;
|
||||
public double damageRed = 0D;
|
||||
public double getDamageBlue = 0D;
|
||||
|
||||
|
||||
public boolean entern = false;
|
||||
|
||||
public File kits = new File("plugins/" + this.getName(), "kits.data");
|
||||
public FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits);
|
||||
private final File kits = new File("plugins/" + this.getName(), "kits.data");
|
||||
private final FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits);
|
||||
|
||||
public void saveKitData() {
|
||||
try { getKitData.save(kits); } catch (Exception ex) { }
|
||||
private void saveKitData() {
|
||||
try { getKitData.save(kits); } catch (Exception ignored) { }
|
||||
}
|
||||
|
||||
|
||||
@ -335,7 +333,7 @@ public class FightSystem extends JavaPlugin {
|
||||
countdown.startTimer(FightSystem.getPlugin());
|
||||
}
|
||||
|
||||
public int getMoneyToPay(String moneyPath) {
|
||||
private int getMoneyToPay(String moneyPath) {
|
||||
return fileManager.getIntegerFromConfig(moneyPath);
|
||||
}
|
||||
|
||||
@ -425,10 +423,12 @@ public class FightSystem extends JavaPlugin {
|
||||
}
|
||||
|
||||
public double getDamageRed() {
|
||||
double damageRed = 0D;
|
||||
return damageRed;
|
||||
}
|
||||
|
||||
public double getGetDamageBlue() {
|
||||
double getDamageBlue = 0D;
|
||||
return getDamageBlue;
|
||||
}
|
||||
|
||||
|
@ -64,12 +64,12 @@ public class AkCommand implements CommandExecutor {
|
||||
if(!Fight.getBlueTeam().hasTeamLeader()){
|
||||
FightPlayer fightPlayer = new FightPlayer(player, false);
|
||||
Fight.getBlueTeam().setLeader(fightPlayer);
|
||||
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName"));
|
||||
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getBlueTeam().getPrefix() + Fight.getBlueTeam().getName());
|
||||
|
||||
} else if(!Fight.getRedTeam().hasTeamLeader()){
|
||||
FightPlayer fightPlayer = new FightPlayer(player, false);
|
||||
Fight.getBlueTeam().setLeader(fightPlayer);
|
||||
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName"));
|
||||
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getRedTeam().getPrefix() + Fight.getRedTeam().getName());
|
||||
|
||||
} else
|
||||
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!");
|
||||
@ -107,7 +107,7 @@ public class AkCommand implements CommandExecutor {
|
||||
if(fightPlayer.isLeader() && fightTeam.isPlayerInTeam(target)){
|
||||
fightTeam.removePlayer(target);
|
||||
player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §aaus dem Team entfernt!");
|
||||
target.sendMessage(FightSystem.PREFIX + "§4Du wurdest auf deinem Team entfernt!");
|
||||
target.sendMessage(FightSystem.PREFIX + "§cDu wurdest auf deinem Team entfernt!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class Fight {
|
||||
|
||||
public static FightTeam redTeam = new FightTeam(null, FightSystem.getPlugin());
|
||||
public static FightTeam blueTeam = new FightTeam(null, FightSystem.getPlugin());
|
||||
public static final FightTeam redTeam = new FightTeam(null, FightSystem.getPlugin());
|
||||
public static final FightTeam blueTeam = new FightTeam(null, FightSystem.getPlugin());
|
||||
|
||||
|
||||
public static FightTeam getPlayerTeam(Player player) {
|
||||
|
@ -2,8 +2,9 @@ package me.yaruma.fightsystem.fight;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FightCreator {
|
||||
class FightCreator {
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
public static void invitePlayerToTeam(Player player) {
|
||||
|
||||
}
|
||||
|
@ -5,5 +5,5 @@ public enum FightState {
|
||||
SETUP,
|
||||
PRE_RUNNING,
|
||||
RUNNING,
|
||||
SPECTATE;
|
||||
SPECTATE
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ import java.util.ArrayList;
|
||||
public class FightTeam {
|
||||
|
||||
private FightPlayer leader;
|
||||
private ArrayList<FightPlayer> players;
|
||||
private final ArrayList<FightPlayer> players;
|
||||
private FightSystem plugin;
|
||||
private boolean ready;
|
||||
private ArrayList<Player> invited;
|
||||
private final ArrayList<Player> invited;
|
||||
private String name;
|
||||
private String prefix;
|
||||
|
||||
@ -115,7 +115,7 @@ public class FightTeam {
|
||||
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
|
||||
if(this.ready == true) {
|
||||
if(this.ready) {
|
||||
|
||||
fightTeam.getLeader().getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAtributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
|
||||
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
|
||||
|
@ -15,41 +15,37 @@ import java.util.List;
|
||||
|
||||
public class WaterRemover {
|
||||
|
||||
private List<AbstractMap.SimpleEntry<Location, Integer>> explodedBlocks = new ArrayList<AbstractMap.SimpleEntry<Location, Integer>>();
|
||||
private List<Block> waterList = new ArrayList<Block>();
|
||||
private List<AbstractMap.SimpleEntry<Location, Integer>> explodedBlocks = new ArrayList<>();
|
||||
private List<Block> waterList = new ArrayList<>();
|
||||
private BukkitTask task;
|
||||
|
||||
public void start() {
|
||||
this.stop();
|
||||
this.explodedBlocks = new ArrayList<AbstractMap.SimpleEntry<Location, Integer>>();
|
||||
this.waterList = new ArrayList<Block>();
|
||||
this.task = Bukkit.getScheduler().runTaskTimerAsynchronously((Plugin)FightSystem.getPlugin(), new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
WaterRemover.this.wateredCheck();
|
||||
WaterRemover.this.removeWater();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.explodedBlocks = new ArrayList<>();
|
||||
this.waterList = new ArrayList<>();
|
||||
this.task = Bukkit.getScheduler().runTaskTimerAsynchronously((Plugin)FightSystem.getPlugin(), () -> {
|
||||
try {
|
||||
WaterRemover.this.wateredCheck();
|
||||
WaterRemover.this.removeWater();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 0L, 20L);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
private void stop() {
|
||||
if (this.task != null) {
|
||||
this.task.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Location loc) {
|
||||
this.explodedBlocks.add(new AbstractMap.SimpleEntry<Location, Integer>(loc, 0));
|
||||
this.explodedBlocks.add(new AbstractMap.SimpleEntry<>(loc, 0));
|
||||
}
|
||||
|
||||
private void wateredCheck() {
|
||||
for (int i = 0; i < this.explodedBlocks.size(); ++i) {
|
||||
for (int i = this.explodedBlocks.size() - 1; i >= 0; i--) {
|
||||
if (this.explodedBlocks.get(i).getValue() >= 15) {
|
||||
Block b = this.explodedBlocks.get(i).getKey().getBlock();
|
||||
if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) {
|
||||
@ -63,12 +59,10 @@ public class WaterRemover {
|
||||
}
|
||||
|
||||
private void removeWater() {
|
||||
ArrayList<Block> blocksToRemove = new ArrayList<Block>();
|
||||
ArrayList<Block> blocksToRemove = new ArrayList<>();
|
||||
for (int i = this.waterList.size() - 1; i > -1; --i) {
|
||||
Block current = this.waterList.get(i);
|
||||
for (Block removeBlock : this.getSourceBlocksOfWater(current)) {
|
||||
blocksToRemove.add(removeBlock);
|
||||
}
|
||||
blocksToRemove.addAll(this.getSourceBlocksOfWater(current));
|
||||
if (current.getType() != Material.AIR) continue;
|
||||
this.waterList.remove(i);
|
||||
}
|
||||
@ -80,12 +74,12 @@ public class WaterRemover {
|
||||
}
|
||||
|
||||
private List<Block> getSourceBlocksOfWater(Block startBlock) {
|
||||
ArrayList<Block> water = new ArrayList<Block>();
|
||||
this.collectBlocks(startBlock, water, new ArrayList<Block>());
|
||||
ArrayList<Block> water = new ArrayList<>();
|
||||
this.collectBlocks(startBlock, water, new ArrayList<>());
|
||||
return water;
|
||||
}
|
||||
|
||||
public void collectBlocks(Block anchor, List<Block> collected, List<Block> visitedBlocks) {
|
||||
private void collectBlocks(Block anchor, List<Block> collected, List<Block> visitedBlocks) {
|
||||
if (anchor.getType() != Material.WATER && anchor.getType() != Material.STATIONARY_WATER) {
|
||||
return;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class BlockBreakListener implements Listener {
|
||||
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
|
||||
@EventHandler
|
||||
public void handleBlockBreak(BlockBreakEvent event) {
|
||||
|
@ -11,43 +11,37 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class EntityDamageByEntityListener implements Listener {
|
||||
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
|
||||
@EventHandler
|
||||
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if(instance.getFightState() != FightState.RUNNING) {
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
if(event.getEntity() instanceof Player) {
|
||||
Player player = ((Player) event.getEntity()).getPlayer();
|
||||
} else if(event.getEntity() instanceof Player) {
|
||||
Player player = ((Player) event.getEntity()).getPlayer();
|
||||
|
||||
if(event.getDamager() instanceof Player) {
|
||||
Player damager = ((Player) event.getDamager()).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);
|
||||
return;
|
||||
}
|
||||
|
||||
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) != null) {
|
||||
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);
|
||||
damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden zufügen!");
|
||||
}
|
||||
} else
|
||||
event.setCancelled(true);
|
||||
}else 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 zufügen!");
|
||||
damagerArrow.setFireTicks(0);
|
||||
player.setFireTicks(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.yaruma.fightsystem.listener;
|
||||
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.fight.FightState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -11,6 +12,7 @@ public class EntityExplodeListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handleEntityExplode(EntityExplodeEvent event) {
|
||||
if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) return;
|
||||
for(Block block : event.blockList()) {
|
||||
if(block.getType() != Material.WATER || block.getType() != Material.STATIONARY_WATER)
|
||||
FightSystem.getPlugin().getWaterRemover().add(block.getLocation());
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
public class PlayerChatListener implements Listener {
|
||||
|
||||
FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
||||
private final FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerChat(PlayerChatEvent event) {
|
||||
|
@ -3,7 +3,6 @@ package me.yaruma.fightsystem.listener;
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.fight.Fight;
|
||||
import me.yaruma.fightsystem.fight.FightTeam;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -17,7 +17,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
public class PlayerInteractListener implements Listener {
|
||||
|
||||
FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
|
@ -19,8 +19,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PlayerJoinListener implements Listener {
|
||||
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
FileManager fileManager = instance.getFileManager();
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
private final FileManager fileManager = instance.getFileManager();
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
|
@ -14,8 +14,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class PlayerMoveListener implements Listener {
|
||||
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
private final FileManager fileManager = FightSystem.getPlugin().getFileManager();
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerMove(PlayerMoveEvent event) {
|
||||
@ -56,10 +56,7 @@ public class PlayerMoveListener implements Listener {
|
||||
}
|
||||
}else if(fightTeam != null && !instance.isEntern()){
|
||||
player.teleport(from);
|
||||
if (fightTeam == Fight.blueTeam)
|
||||
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName") + " §c!");
|
||||
else
|
||||
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName") + " §c!");
|
||||
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu " + Fight.getOpposite(fightTeam).getPrefix() + Fight.getOpposite(fightTeam).getName() + "§c!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import me.yaruma.fightsystem.fight.FightState;
|
||||
import me.yaruma.fightsystem.fight.FightTeam;
|
||||
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
||||
import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline;
|
||||
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
public class PlayerRespawnListener implements Listener {
|
||||
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerRespawn(PlayerRespawnEvent event) {
|
||||
|
@ -4,16 +4,12 @@ import me.yaruma.fightsystem.FightSystem;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.FileConfigurationOptions;
|
||||
|
||||
public class FileManager
|
||||
{
|
||||
public File file;
|
||||
public FileConfiguration config;
|
||||
private final File file;
|
||||
private final FileConfiguration config;
|
||||
|
||||
public FileManager(FightSystem instance) {
|
||||
this.config = instance.getConfig();
|
||||
@ -55,7 +51,7 @@ public class FileManager
|
||||
return this.config;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
private void save() {
|
||||
try {
|
||||
this.config.save(this.file);
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class ItemBuilder {
|
||||
|
||||
private ItemStack item;
|
||||
private ItemMeta meta;
|
||||
private final ItemStack item;
|
||||
private final ItemMeta meta;
|
||||
|
||||
public ItemBuilder(Material matrial) {
|
||||
item = new ItemStack(matrial);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.yaruma.fightsystem.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Region {
|
||||
|
||||
@ -17,7 +16,7 @@ public class Region {
|
||||
return isIn2DRegion(location, minX, minZ, minX + xRange, minZ + zRange, margin);
|
||||
}
|
||||
|
||||
public static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ, int margin){
|
||||
private static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ, int margin){
|
||||
return inRange(location.getBlockX(), minX, maxX, margin) && inRange(location.getBlockZ(), minZ, maxZ, margin);
|
||||
}
|
||||
|
||||
@ -25,11 +24,11 @@ public class Region {
|
||||
return inRange(location.getBlockX(), minX, maxX) && inRange(location.getBlockZ(), minZ, maxZ);
|
||||
}
|
||||
|
||||
public static boolean inRange(double value, int min, int max, int margin){
|
||||
private static boolean inRange(double value, int min, int max, int margin){
|
||||
return inRange(value, min-margin, max+margin);
|
||||
}
|
||||
|
||||
public static boolean inRange(double value, int min, int max){
|
||||
private static boolean inRange(double value, int min, int max){
|
||||
return min <= value && value <= max;
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ import java.util.ArrayList;
|
||||
|
||||
public class Countdown {
|
||||
|
||||
private static ArrayList<Countdown> countdowns = new ArrayList<>();
|
||||
private static final ArrayList<Countdown> countdowns = new ArrayList<>();
|
||||
|
||||
private int time;
|
||||
private CountdownCallback countdownCallback;
|
||||
private final CountdownCallback countdownCallback;
|
||||
private int taskID;
|
||||
|
||||
public Countdown(int time, CountdownCallback countdownCallback) {
|
||||
@ -45,7 +45,7 @@ public class Countdown {
|
||||
}, 0, 20);
|
||||
}
|
||||
|
||||
public void cancelTimer() {
|
||||
private void cancelTimer() {
|
||||
|
||||
try {
|
||||
Bukkit.getScheduler().cancelTask(this.taskID);
|
||||
@ -68,7 +68,7 @@ public class Countdown {
|
||||
}
|
||||
}
|
||||
|
||||
public CountdownType getType() {
|
||||
private CountdownType getType() {
|
||||
return countdownCallback.getType();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.yaruma.fightsystem.utils.countdown;
|
||||
|
||||
public interface CountdownCallback {
|
||||
interface CountdownCallback {
|
||||
|
||||
String countdownCounting();
|
||||
void countdownFinished();
|
||||
|
@ -7,7 +7,7 @@ public enum CountdownType {
|
||||
PRE_RUNNING,
|
||||
SETUP_OVER,
|
||||
SPECTATE_OVER,
|
||||
TIME_OVER;
|
||||
TIME_OVER
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package me.yaruma.fightsystem.utils.countdown;
|
||||
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.manager.FileManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class FinishPreRunning implements CountdownCallback {
|
||||
|
||||
|
@ -13,33 +13,31 @@ import org.bukkit.scoreboard.ScoreboardManager;
|
||||
|
||||
public class Scoreboard {
|
||||
|
||||
private ScoreboardManager scoreboardManager;
|
||||
private org.bukkit.scoreboard.Scoreboard scoreboard;
|
||||
private Objective objective;
|
||||
private int taskID;
|
||||
private final org.bukkit.scoreboard.Scoreboard scoreboard;
|
||||
private final Objective objective;
|
||||
|
||||
public Scoreboard(FightSystem instance) {
|
||||
this.scoreboardManager = Bukkit.getScoreboardManager();
|
||||
this.scoreboard = this.scoreboardManager.getNewScoreboard();
|
||||
ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
|
||||
this.scoreboard = scoreboardManager.getNewScoreboard();
|
||||
this.objective = scoreboard.registerNewObjective("AAA", "BBB");
|
||||
}
|
||||
|
||||
public void setAutoScoreboard(int delay, Player player) {
|
||||
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), new Runnable() {
|
||||
int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), new Runnable() {
|
||||
|
||||
private int index = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
FightTeam fightTeam = getIndexDisplay(index);
|
||||
if(fightTeam != null) {
|
||||
if (fightTeam != null) {
|
||||
objective.unregister();
|
||||
scoreboard.registerNewObjective("AAA", "BBB");
|
||||
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
objective.setDisplayName(fightTeam.getPrefix() + fightTeam.getName());
|
||||
|
||||
for(FightPlayer fp : fightTeam.getPlayers()) {
|
||||
for (FightPlayer fp : fightTeam.getPlayers()) {
|
||||
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth());
|
||||
}
|
||||
|
||||
@ -52,16 +50,19 @@ public class Scoreboard {
|
||||
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
objective.setDisplayName("§6Kampf");
|
||||
if(Methods.isEnabled("WinConditions.Timeout")){
|
||||
if (Methods.isEnabled("WinConditions.Timeout")) {
|
||||
int fightTime = FightSystem.getPlugin().getFightTime();
|
||||
if(fightTime >= 60)
|
||||
objective.getScore("§7Zeit: §a" + fightTime/60 + "m " + fightTime%60 + "s" ).setScore(3);
|
||||
if (fightTime >= 60)
|
||||
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
|
||||
else
|
||||
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3);
|
||||
}
|
||||
if(Methods.isEnabled("WinConditions.Entern")) objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2);
|
||||
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1);
|
||||
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0);
|
||||
if (Methods.isEnabled("WinConditions.Entern"))
|
||||
objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2);
|
||||
if (Methods.isEnabled("WinConditions.PercentSystem"))
|
||||
objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1);
|
||||
if (Methods.isEnabled("WinConditions.PercentSystem"))
|
||||
objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0);
|
||||
index = 0;
|
||||
}
|
||||
player.setScoreboard(scoreboard);
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class WinconditionAllDead implements Listener {
|
||||
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class WinconditionCaptainDead implements Listener {
|
||||
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
FileManager fileManager = instance.getFileManager();
|
||||
|
||||
@EventHandler
|
||||
|
@ -7,8 +7,8 @@ import me.yaruma.fightsystem.utils.countdown.FinishNoneEntern;
|
||||
|
||||
public class WinconditionEntern {
|
||||
|
||||
private static FightSystem instance = FightSystem.getPlugin();
|
||||
private static FileManager fileManager = instance.getFileManager();
|
||||
private static final FightSystem instance = FightSystem.getPlugin();
|
||||
private static final FileManager fileManager = instance.getFileManager();
|
||||
|
||||
public static void entern() {
|
||||
if(!Methods.isEnabled("WinConditions.Entern")) return;
|
||||
|
@ -12,13 +12,13 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
public class WinconditionPercentSystem implements Listener {
|
||||
|
||||
public static int team1DestroyedBlocks;
|
||||
public static int team2DestroyedBlocks;
|
||||
private static int team1DestroyedBlocks;
|
||||
private static int team2DestroyedBlocks;
|
||||
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
FileManager fileManager = instance.getFileManager();
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
private final FileManager fileManager = instance.getFileManager();
|
||||
|
||||
private static int schematicSize =
|
||||
private static final int schematicSize =
|
||||
Math.abs(
|
||||
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.x") *
|
||||
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.y") *
|
||||
|
@ -7,8 +7,8 @@ import me.yaruma.fightsystem.utils.countdown.FinishTimeOver;
|
||||
|
||||
public class WinconditionTimeout {
|
||||
|
||||
private static FightSystem instance = FightSystem.getPlugin();
|
||||
private static FileManager fileManager = instance.getFileManager();
|
||||
private static final FightSystem instance = FightSystem.getPlugin();
|
||||
private static final FileManager fileManager = instance.getFileManager();
|
||||
|
||||
public static void timeout() {
|
||||
if(!Methods.isEnabled("WinConditions.Timeout")) return;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren