SteamWar/FightSystem
Archiviert
13
1

Paste & Kitanpassungen

Dieser Commit ist enthalten in:
lixfel 2019-04-13 16:30:25 +02:00
Ursprung 1aed04917d
Commit 5ac22edc90
5 geänderte Dateien mit 28 neuen und 48 gelöschten Zeilen

Datei anzeigen

@ -235,13 +235,8 @@ public class FightSystem extends JavaPlugin {
} }
private void teleportAllToFightSpawn() { private void teleportAllToFightSpawn() {
Fight.getBlueTeam().teleportToSpawn();
for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) { Fight.getRedTeam().teleportToSpawn();
fightPlayer.getPlayer().teleport(Config.TeamBlueSpawn);
}
for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) {
fightPlayer.getPlayer().teleport(Config.TeamRedSpawn);
}
for(Player player : Bukkit.getServer().getOnlinePlayers()) { for(Player player : Bukkit.getServer().getOnlinePlayers()) {
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);

Datei anzeigen

@ -139,6 +139,7 @@ public class AkCommand implements CommandExecutor {
//TODO: Owns Kit //TODO: Owns Kit
Fight.getFightPlayer(player).setKit(kit); Fight.getFightPlayer(player).setKit(kit);
player.sendMessage(FightSystem.PREFIX + "§aDu hast nun das Kit §6" + args[1] + "§a!");
} else if(args[0].equalsIgnoreCase("schem")) { } else if(args[0].equalsIgnoreCase("schem")) {
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);

Datei anzeigen

@ -1,6 +1,8 @@
package me.yaruma.fightsystem.fight; package me.yaruma.fightsystem.fight;
import me.yaruma.fightsystem.kit.Kit; import me.yaruma.fightsystem.kit.Kit;
import me.yaruma.fightsystem.kit.KitManager;
import me.yaruma.fightsystem.utils.Config;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class FightPlayer { public class FightPlayer {
@ -24,6 +26,7 @@ public class FightPlayer {
public FightPlayer(Player player, boolean isOut) { public FightPlayer(Player player, boolean isOut) {
this.player = player; this.player = player;
this.isOut = isOut; this.isOut = isOut;
kit = KitManager.getKitByName(Config.MemberDefault);
} }
public void setOut(boolean isOut) { public void setOut(boolean isOut) {

Datei anzeigen

@ -8,6 +8,7 @@ import com.sk89q.worldedit.world.World;
import de.warking.hunjy.MySQL.Schematic; import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.WarkingUser; import de.warking.hunjy.MySQL.WarkingUser;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.kit.KitManager;
import me.yaruma.fightsystem.utils.Config; import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.ItemBuilder; import me.yaruma.fightsystem.utils.ItemBuilder;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -44,6 +45,12 @@ public class FightTeam {
rotate = Rotate; rotate = Rotate;
} }
public void teleportToSpawn(){
for(FightPlayer player : players){
player.getPlayer().teleport(spawn);
}
}
public FightPlayer getFightPlayer(Player player) { public FightPlayer getFightPlayer(Player player) {
for(FightPlayer fightPlayer : players) { for(FightPlayer fightPlayer : players) {
if(fightPlayer.getPlayer().equals(player)) if(fightPlayer.getPlayer().equals(player))
@ -99,6 +106,7 @@ public class FightTeam {
public void setLeader(FightPlayer leader) { public void setLeader(FightPlayer leader) {
this.leader = leader; this.leader = leader;
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
if(!this.players.contains(leader)){ if(!this.players.contains(leader)){
this.players.add(leader); this.players.add(leader);
} }
@ -123,12 +131,17 @@ public class FightTeam {
} }
World w = new BukkitWorld(Bukkit.getWorlds().get(0)); World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = schem.getClipboard().getDimensions(); Vector dimensions = schem.getClipboard().getDimensions();
Vector v = paste.subtract(dimensions.getX()/2, 0, dimensions.getZ()/2).subtract(schem.getClipboard().getRegion().getMinimumPoint()).add(schem.getClipboard().getOrigin()); Vector v;
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
AffineTransform aT = new AffineTransform(); AffineTransform aT = new AffineTransform();
if(rotate){ if(rotate){
aT.rotateY(180); aT = aT.rotateY(180);
v = paste.add(dimensions.getX()/2, 0, dimensions.getZ()/2).subtract(offset.multiply(-1, 1, -1));
}else{
v = paste.subtract(dimensions.getX()/2, 0, dimensions.getZ()/2).subtract(offset);
} }
schem.paste(w, v, false, true, aT).flushQueue(); schem.paste(w, v, false, true, aT).flushQueue();
teleportToSpawn();
} }
public void setSchematic(Schematic schematic){ public void setSchematic(Schematic schematic){

Datei anzeigen

@ -2,8 +2,6 @@ package me.yaruma.fightsystem.kit;
import de.warking.hunjy.CoinSystem.CoinSystem; import de.warking.hunjy.CoinSystem.CoinSystem;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,14 +19,6 @@ public class KitManager {
private static final ArrayList<Kit> loadedKits = new ArrayList<>(); private static final ArrayList<Kit> loadedKits = new ArrayList<>();
private static void loadInventoryToPlayer(String kitName, Player player) {
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(new File(kitsPath));
ItemStack[] content = ((List<ItemStack>) yamlConfiguration.get("Kits." + kitName + ".Armor")).toArray(new ItemStack[0]);
player.getInventory().setArmorContents(content);
content = ((List<ItemStack>) yamlConfiguration.get("Kits." + kitName + ".Items")).toArray(new ItemStack[0]);
player.getInventory().setContents(content);
}
public static void saveInventory(String kitName, Player player){ public static void saveInventory(String kitName, Player player){
loadedKits.add(new Kit(kitName, 0, true, true, player.getInventory().getArmorContents(), player.getInventory().getContents())); loadedKits.add(new Kit(kitName, 0, true, true, player.getInventory().getArmorContents(), player.getInventory().getContents()));
saveAllKits(); saveAllKits();
@ -49,38 +39,16 @@ public class KitManager {
return true; //wird spaeter gemacht return true; //wird spaeter gemacht
} }
public static void loadKitToPlayer(Kit kit, Player player) {
if(kit != null) {
if(ownsKit(player)) {
FightPlayer fightPlayer = Fight.getPlayerTeam(player).getFightPlayer(player);
if(fightPlayer != null) {
if(fightPlayer.isLeader() && kit.isLeaderAllowed() || !fightPlayer.isLeader() && kit.isMemberAllowed()) {
loadInventoryToPlayer(kit.getName(), player);
player.sendMessage(FightSystem.PREFIX + "§6" + kit.getName() + " §ageladen!");
} else {
player.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!");
}
} else {
player.sendMessage(FightSystem.PREFIX + "§cDu befindest dich in keinem Team!");
}
} else {
player.sendMessage(FightSystem.PREFIX + "§cDu besitzt dieses Kit nicht!");
}
}
}
public static Kit loadKitFromConfig(String name) { public static Kit loadKitFromConfig(String name) {
FileConfiguration data = instance.getKitData(); FileConfiguration data = instance.getKitData();
name = "Kits." + name; String path = "Kits." + name;
if(data.contains(name)) { if(data.contains(path)) {
List<ItemStack> armor = (List<ItemStack>) data.getList(name + ".Armor"); List<ItemStack> armor = (List<ItemStack>) data.getList(path + ".Armor");
List<ItemStack> items = (List<ItemStack>) data.getList(name + ".Items"); List<ItemStack> items = (List<ItemStack>) data.getList(path + ".Items");
int price = data.getInt(name + ".Price"); int price = data.getInt(path + ".Price");
boolean leaderAllowed = data.getBoolean(name + ".LeaderAllowed"); boolean leaderAllowed = data.getBoolean(path + ".LeaderAllowed");
boolean memberAllowed = data.getBoolean(name + ".MemberAllowed"); boolean memberAllowed = data.getBoolean(path + ".MemberAllowed");
Kit kit = new Kit(name, price, leaderAllowed, memberAllowed, armor.toArray(new ItemStack[1]), items.toArray(new ItemStack[1])); Kit kit = new Kit(name, price, leaderAllowed, memberAllowed, armor.toArray(new ItemStack[1]), items.toArray(new ItemStack[1]));
return kit; return kit;