Add toggle double jump command/item
This commit is contained in:
@@ -42,6 +42,7 @@ public class Features implements Listener {
|
||||
|
||||
private final HashMap<Player, ArrayList<Feature>> playerFeatures = new HashMap<>();
|
||||
private final HashMap<Player, Boolean> canDoubleJump = new HashMap<>();
|
||||
private final HashMap<Player, HashMap<Feature, Boolean>> featureEnabled = new HashMap<>();
|
||||
|
||||
public void updateFeatures(Player P)
|
||||
{
|
||||
@@ -50,11 +51,13 @@ public class Features implements Listener {
|
||||
ResultSet rs = API.getMySql().querySelect("SELECT featureId FROM coreFeatures WHERE playerId = (SELECT id FROM players WHERE uuid = '"+P.getUniqueId().toString()+"')");
|
||||
resetPlayerFeatures(P);
|
||||
playerFeatures.put(P, new ArrayList<Feature>());
|
||||
featureEnabled.put(P, new HashMap<Feature, Boolean>());
|
||||
while(rs.next())
|
||||
{
|
||||
if(Feature.getById(rs.getInt("featureId")) != null)
|
||||
{
|
||||
this.addFeature(P, Feature.getById(rs.getInt("featureId")));
|
||||
featureEnabled.get(P).put(Feature.DOUBLE_JUMP, true);
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
@@ -78,6 +81,36 @@ public class Features implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void disableFeature(Player P, Feature f) {
|
||||
if(!mainLobby()) return;
|
||||
if (f == Feature.DOUBLE_JUMP) {
|
||||
if (!hasFeature(P, f)) {
|
||||
API.statusMsg(P, "dont_have_dbl_jump", false);
|
||||
return;
|
||||
}
|
||||
featureEnabled.get(P).put(f, false);
|
||||
canDoubleJump.put(P, false);
|
||||
API.statusMsg(P, "dbl_jump_off", true);
|
||||
if (P.getGameMode() != GameMode.CREATIVE) {
|
||||
P.setAllowFlight(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enableFeature(Player P, Feature f) {
|
||||
if(!mainLobby()) return;
|
||||
if (f == Feature.DOUBLE_JUMP) {
|
||||
if (!hasFeature(P, f)) {
|
||||
API.statusMsg(P, "dont_have_dbl_jump", false);
|
||||
return;
|
||||
}
|
||||
featureEnabled.get(P).put(f, true);
|
||||
P.setAllowFlight(true);
|
||||
canDoubleJump.put(P, true);
|
||||
API.statusMsg(P, "dbl_jump_on", true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasFeature(Player P, Feature f)
|
||||
{
|
||||
if(!mainLobby()) return false;
|
||||
|
||||
Reference in New Issue
Block a user