Disables block gravity and makes it togglable (FS-89) (#50)

* Disables block gravity by default (FS-89)

* Combine these checks as Codacy ever so kindly suggested
This commit is contained in:
Video 2021-04-19 01:34:36 -06:00 committed by GitHub
parent 20c2c4c96e
commit 2cdf1e66a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.data.AnaloguePowerable;
import org.bukkit.block.data.Powerable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -30,6 +31,7 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FireworkExplodeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
@ -212,6 +214,15 @@ public class EventBlocker extends FreedomService
}
}
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event)
{
if (!ConfigEntry.ALLOW_GRAVITY.getBoolean() && event.getEntity() instanceof FallingBlock)
{
event.setCancelled(true);
}
}
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event)
{

View File

@ -54,6 +54,7 @@ public class Command_toggle extends FreedomCommand
msg("- landmines");
msg("- mp44");
msg("- tossmob");
msg("- gravity");
return false;
}
@ -297,6 +298,12 @@ public class Command_toggle extends FreedomCommand
toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED);
break;
}
case "gravity":
{
toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY);
break;
}
}
return true;
}
@ -320,7 +327,7 @@ public class Command_toggle extends FreedomCommand
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
"respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob");
"respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob", "gravity");
}
return Collections.emptyList();
}

View File

@ -34,6 +34,7 @@ public enum ConfigEntry
ALLOW_RESPAWN_ANCHORS(Boolean.class, "allow.respawnanchors"),
AUTO_TP(Boolean.class, "allow.auto_tp"),
AUTO_CLEAR(Boolean.class, "allow.auto_clear"),
ALLOW_GRAVITY(Boolean.class, "allow.gravity"),
//
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
//

View File

@ -226,6 +226,7 @@ allow:
respawnanchors: false
auto_tp: false
auto_clear: false
gravity: false
# Blocked commands:
#