Skip to content

Instantly share code, notes, and snippets.

@Caellian
Last active August 29, 2015 14:24
Show Gist options
  • Save Caellian/0ce7dc90806f90fea93b to your computer and use it in GitHub Desktop.
Save Caellian/0ce7dc90806f90fea93b to your computer and use it in GitHub Desktop.
Explanation for SlotEnum
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");
}
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;
}
}
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;
}
}
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