Goal: set given world's gamerule from a gamerule string (e.g. "doInsomnia")
Problem: return type of GameRule#getByName()
World#setGameRule() requires GameRule<T> as its rule parameter, but GameRule#getByName() provides GameRule<?>
the following code works, but the compiler complains:
I can't use GameRule.DO_INSOMNIA because I'm getting the gamerule from a config file.
World#setGameRuleValue would in theory work since it takes String as both parameters, but it has be deprecated.
Any help would be appreciated
Problem: return type of GameRule#getByName()
World#setGameRule() requires GameRule<T> as its rule parameter, but GameRule#getByName() provides GameRule<?>
the following code works, but the compiler complains:
Java:
String myGameRule = "doInsomnia";
boolean newValue = false;
GameRule gr = GameRule.getByName(myGameRule);
boolean success = getWorld().setGameRule(gr, newValue);
I can't use GameRule.DO_INSOMNIA because I'm getting the gamerule from a config file.
World#setGameRuleValue would in theory work since it takes String as both parameters, but it has be deprecated.
Any help would be appreciated
Last edited: