Last active
August 29, 2015 14:24
-
-
Save Caellian/0ce7dc90806f90fea93b to your computer and use it in GitHub Desktop.
Explanation for SlotEnum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.caellyan.core.explanation; | |
/** | |
* Created by Caellian on 3.7.2015., at 22:27. | |
*/ | |
public class Mod | |
{ | |
//You can do it this way, so if boots slot changes, you don't have to update your mod. | |
Slot bootsSlot = SlotHelper.slotMap.get(SlotEnum.BOOTS); | |
//Or you can do it this way, which is harder to maintain. | |
Slot chestplateSlot = SlotHelper.slotMap.get("body-chestplate"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.caellyan.core.explanation; | |
/** | |
* Created by Caellian on 3.7.2015., at 22:27. | |
*/ | |
public class Slot<X> | |
{ | |
private X item; | |
//Maybe even using float values in case a game uses weight or volume instead of count? | |
int slotSize; | |
public Slot(X item) | |
{ | |
this.item = item; | |
} | |
public X getItem() | |
{ | |
return item; | |
} | |
public int getSlotSize() | |
{ | |
return slotSize; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.caellyan.core.explanation; | |
/** | |
* Created by Caellian on 3.7.2015., at 22:27. | |
*/ | |
public enum SlotEnum | |
{ | |
HELMET("body-helmet"), | |
CHESTPLATE("body-chestplate"), | |
LEGGINGS("body-leggings"), | |
BOOTS("body-boots"), | |
RING("body-ring"), | |
HORSE_HELMET("horse-helmet"); | |
final String value; | |
SlotEnum(String value) | |
{ | |
this.value = value; | |
} | |
public String getValue() | |
{ | |
return value; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.caellyan.core.explanation; | |
import java.util.HashMap; | |
/** | |
* Created by Caellian on 3.7.2015., at 22:28. | |
*/ | |
public class SlotHelper | |
{ | |
public static final HashMap<String, Slot> slotMap = new HashMap<>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment