Core/src/main/java/eu/univento/core/api/customitems/swords/CustomSwordManager.java

40 lines
1.0 KiB
Java

/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.core.api.customitems.swords;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.inventory.ItemStack;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author joethei
* @version 1.0
*/
public class CustomSwordManager {
private static Map<CustomPlayer, CustomSword> swords = new LinkedHashMap<>();
public static CustomSword valueOf(ItemStack item) {
for(CustomSword sword : swords.values())
if(sword.getItem().equals(item)) return sword;
return null;
}
public static void add(CustomPlayer p, CustomSword sword) {
swords.put(p, sword);
}
public static void remove(CustomPlayer p, CustomSword sword) {
if(swords.get(p).equals(sword))
swords.remove(p);
}
public static boolean contains(CustomSword sword) {
return swords.containsValue(sword);
}
}