Update2.0 #22
@ -48,9 +48,11 @@ public class Config {
|
|||||||
public static final int ShieldFlyTime;
|
public static final int ShieldFlyTime;
|
||||||
public static final int EndTime;
|
public static final int EndTime;
|
||||||
|
|
||||||
static{
|
public static final double MissileChance;
|
||||||
|
|
||||||
|
static {
|
||||||
File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
|
File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
|
||||||
if(!configfile.exists()){
|
if (!configfile.exists()) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Config fehlt!");
|
Bukkit.getLogger().log(Level.SEVERE, "Config fehlt!");
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
@ -62,6 +64,8 @@ public class Config {
|
|||||||
ShieldFlyTime = config.getInt("ShieldFlyTime");
|
ShieldFlyTime = config.getInt("ShieldFlyTime");
|
||||||
EndTime = config.getInt("EndTime");
|
EndTime = config.getInt("EndTime");
|
||||||
|
|
||||||
|
MissileChance = config.getDouble("MissileChance");
|
||||||
|
|
||||||
ConfigurationSection arena = config.getConfigurationSection("Arena");
|
ConfigurationSection arena = config.getConfigurationSection("Arena");
|
||||||
assert arena != null;
|
assert arena != null;
|
||||||
ArenaMinX = arena.getInt("MinX");
|
ArenaMinX = arena.getInt("MinX");
|
||||||
|
@ -148,6 +148,11 @@ public class Missile extends SpecialItem {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMissile() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
File missileFolder = new File(MissileWars.getPlugin().getDataFolder(), "missiles");
|
File missileFolder = new File(MissileWars.getPlugin().getDataFolder(), "missiles");
|
||||||
if (!missileFolder.exists() || !missileFolder.canRead() || !missileFolder.isDirectory()) {
|
if (!missileFolder.exists() || !missileFolder.canRead() || !missileFolder.isDirectory()) {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.misslewars.items;
|
package de.steamwar.misslewars.items;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.Config;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
@ -33,14 +34,22 @@ public abstract class SpecialItem {
|
|||||||
|
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
|
|
||||||
private static List<SpecialItem> items = new ArrayList<>();
|
private static List<SpecialItem> supportItems = new ArrayList<>();
|
||||||
|
private static List<SpecialItem> missileItems = new ArrayList<>();
|
||||||
|
|
||||||
SpecialItem(){
|
SpecialItem() {
|
||||||
items.add(this);
|
if (this.isMissile()) {
|
||||||
|
missileItems.add(this);
|
||||||
|
} else {
|
||||||
|
supportItems.add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract ItemStack getItem();
|
public abstract ItemStack getItem();
|
||||||
public abstract boolean handleUse(Player p);
|
public abstract boolean handleUse(Player p);
|
||||||
|
public boolean isMissile() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemStack createItem(Material material, String name, int amount) {
|
public ItemStack createItem(Material material, String name, int amount) {
|
||||||
return createItem(material, name, amount, new ArrayList<>());
|
return createItem(material, name, amount, new ArrayList<>());
|
||||||
@ -57,16 +66,23 @@ public abstract class SpecialItem {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleUse(ItemStack item, Player player){
|
public static boolean handleUse(ItemStack item, Player player) {
|
||||||
for(SpecialItem specialItem : items){
|
return handleUse(item, player, missileItems) || handleUse(item, player, supportItems);
|
||||||
if(item.isSimilar(specialItem.getItem())){
|
}
|
||||||
return specialItem.handleUse(player);
|
|
||||||
}
|
private static boolean handleUse(ItemStack item, Player player, List<SpecialItem> items) {
|
||||||
|
for (SpecialItem specialItem : items) {
|
||||||
|
if (item.isSimilar(specialItem.getItem())) return specialItem.handleUse(player);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getRandomItem(){
|
public static ItemStack getRandomItem() {
|
||||||
return items.get(random.nextInt(items.size())).getItem();
|
if (random.nextDouble() > Config.MissileChance) {
|
||||||
|
return supportItems.get(random.nextInt(supportItems.size())).getItem();
|
||||||
|
} else {
|
||||||
|
return missileItems.get(random.nextInt(missileItems.size())).getItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Sollte auch /configs liegen
Siehe Oben nein. War schon immer so. Und Außerdem ist auch dort liegen auch die Shield Schem und so. Deswegen sollte das wohl einfach so bleiben!
Das wird wenn versymlinkt (sobald mehrere Configs gleich sind). Da kann man auch mal umbauen, aber das Plugin sollte nix mit /configs zu tun haben.