SteamWar/FightSystem
Archiviert
13
1

fixed some bugs; added kit to fightplayer; reworked schematic list; updated KitManager

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-04-08 19:30:23 +02:00
Ursprung 6034252d67
Commit 209f1ba88a
5 geänderte Dateien mit 109 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -109,19 +109,19 @@ public class AkCommand implements CommandExecutor {
}
}else if(args[0].equalsIgnoreCase("kit")) {
if(FightSystem.getPlugin().getFightState() != FightState.SETUP) {
player.sendMessage(FightSystem.PREFIX + "§cDu kannst dein Kit nicht mehr wechseln");
player.sendMessage(FightSystem.PREFIX + "§cDu kannst dein Kit nicht mehr wechseln!");
return false;
}
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null){
player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team");
player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!");
return false;
}
Kit kit = KitManager.getKitByName(args[1]);
if(kit == null){
player.sendMessage(FightSystem.PREFIX + "§cDieses Kit existiert nicht");
player.sendMessage(FightSystem.PREFIX + "§cDieses Kit existiert nicht!");
return false;
}
@ -130,27 +130,27 @@ public class AkCommand implements CommandExecutor {
(fightPlayer.isLeader() && !kit.isLeaderAllowed()) ||
(!fightPlayer.isLeader() && !kit.isMemberAllowed())
){
player.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden");
player.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!");
return false;
}
//TODO: Owns Kit
kit.loadToPlayer(player);
Fight.getFightPlayer(player).setKit(kit);
} else if(args[0].equalsIgnoreCase("schem")) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null) {
player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team");
player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!");
return false;
}else if(fightTeam.hasSchematic()) {
player.sendMessage(FightSystem.PREFIX + "§cDie Schematic ist bereits gewählt");
player.sendMessage(FightSystem.PREFIX + "§cDie Schematic ist bereits gewählt!");
return false;
}
Schematic schem = Schematic.getSchemFromDB(args[1], player.getUniqueId());
if(schem == null) {
player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic gibt es nicht");
player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic gibt es nicht!");
return false;
}else if(schem.getSchemType() != Config.SchematicType) {
player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic ist kein " + Config.GameName);
@ -158,6 +158,7 @@ public class AkCommand implements CommandExecutor {
}
fightTeam.setSchematic(schem);
Fight.getPlayerTeam(player).broadcast(FightSystem.PREFIX + "Schematic §6" + args[1] + " §8wird für den Kampf verwendet!");
}
}else{
sendHelp(player);

Datei anzeigen

@ -1,11 +1,13 @@
package me.yaruma.fightsystem.fight;
import me.yaruma.fightsystem.kit.Kit;
import org.bukkit.entity.Player;
public class FightPlayer {
private final Player player;
private boolean isOut;
private Kit kit;
public boolean equals(Object obj) {
if (!(obj instanceof Player))
@ -40,5 +42,11 @@ public class FightPlayer {
return Fight.getPlayerTeam(player).getLeader().getPlayer() == player;
}
public Kit getKit() {
return kit;
}
public void setKit(Kit kit) {
this.kit = kit;
}
}

Datei anzeigen

@ -96,9 +96,11 @@ public class KitManager {
}
public static void loadAllKits() {
//for(String key : instance.getKitData().getConfigurationSection("Kits").getKeys(false)) {
// loadedKits.add(loadKitFromConfig(key));
//}
if(instance.getKitData().getConfigurationSection("Kits") != null) {
for(String key : instance.getKitData().getConfigurationSection("Kits").getKeys(false)) {
loadedKits.add(loadKitFromConfig(key));
}
}
}
public static Kit getKitByName(String kitName) {

Datei anzeigen

@ -10,6 +10,10 @@ import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.world.World;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser;
import me.yaruma.fightsystem.FightSystem;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
@ -20,7 +24,9 @@ import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class WorldEdit {
@ -100,5 +106,80 @@ public class WorldEdit {
}
}
public static void sendPlayerSchematicList(int currentPage, int filesPerPage, Player player, SchematicType schematicType) {
List<Schematic> preSchematicList = Schematic.getSchemsAccessibleByUser(player.getUniqueId());
List<Schematic> schematicList = new ArrayList<>();
for(Schematic s : preSchematicList) {
if(s.getSchemType() == schematicType)
schematicList.add(s);
}
if(schematicList.isEmpty()) {
player.sendMessage(FightSystem.PREFIX + "§cDu hast noch keine Schematic(s)!");
return;
}
int pages;
double doublePages = (Double.valueOf(schematicList.size()) / Double.valueOf(filesPerPage));
int intPages = schematicList.size() / filesPerPage;
if(schematicList.size() <= filesPerPage) {
pages = 1;
} else if(doublePages > intPages) {
pages = (intPages + 1);
} else
pages = intPages;
int currPage = currentPage;
if(currPage >= pages) return;
player.sendMessage("§5======§8[§dSeite " + (currentPage + 1) + " §7/ §d" + pages + " §7| §d" + schematicList.size() + " Schematic(s)§8]§5======");
for(int i = currPage * filesPerPage; i < (currPage * filesPerPage) + filesPerPage; i++) {
if(schematicList.size() <= i) break;
Schematic schematic = schematicList.get(i);
TextComponent schematics = new TextComponent("§b" + schematic.getSchemName());
schematics.setBold(true);
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic benutzen...").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + schematic.getSchemName()));
player.spigot().sendMessage(schematics);
}
if(pages <= 1) return;
if(currPage == 0) {
TextComponent nextPage = new TextComponent("Nächste Seite >>");
nextPage.setColor(ChatColor.RED);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list 1"));
player.spigot().sendMessage(nextPage);
} else if((currPage + 1) == pages) {
TextComponent beforePage = new TextComponent("<< Vorherige Seite");
beforePage.setColor(ChatColor.RED);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (currPage - 1)));
player.spigot().sendMessage(beforePage);
} else {
TextComponent beforePage = new TextComponent("<< Seite ");
beforePage.setColor(ChatColor.RED);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (currPage - 1)));
TextComponent nextPage = new TextComponent(">>");
nextPage.setColor(ChatColor.RED);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (currPage + 1)));
beforePage.addExtra(nextPage);
player.spigot().sendMessage(beforePage);
}
}
}

Datei anzeigen

@ -1,6 +1,6 @@
name: FightSystem
version: 1.0
author: Yaruma3341
author: [Yaruma3341, Lixfel]
main: me.yaruma.fightsystem.FightSystem
depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit]