Skip to content

Commit 20db0ac

Browse files
committed
Game features and fixes additions from humbug.
1 parent e4c1164 commit 20db0ac

File tree

5 files changed

+174
-24
lines changed

5 files changed

+174
-24
lines changed

src/main/java/com/programmerdan/minecraft/simpleadminhacks/configs/GameFeaturesConfig.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ public class GameFeaturesConfig extends SimpleHackConfig {
3131
private boolean enderChestUse;
3232
private boolean shulkerBoxUse;
3333
private boolean totemPowers;
34+
private boolean elytraUse;
35+
private boolean chorusFruitUse;
3436

3537
private boolean weepingAngel;
3638
private int weepingAngelEnv;
3739
private int weepingAngelPlayer;
3840

41+
private boolean blockWaterInHell;
42+
3943
public GameFeaturesConfig(SimpleAdminHacks plugin, ConfigurationSection base) {
4044
super(plugin, base);
4145
}
@@ -62,15 +66,23 @@ protected void wireup(ConfigurationSection config) {
6266

6367
this.totemPowers = config.getBoolean("totemPower", false);
6468
if (!this.totemPowers) plugin().log(" Undeath via totems is disabled");
69+
70+
this.elytraUse = config.getBoolean("elytraUse", true);
71+
if (!this.elytraUse) plugin().log(" Elytra use is disabled");
72+
73+
this.chorusFruitUse = config.getBoolean("chorusFruitTeleportation", false);
74+
if (!this.chorusFruitUse) plugin().log(" Chorus Fruit Teleportation is disabled");
6575

66-
this.weepingAngel = config.getBoolean("weepingAngel.enabled", false);
76+
this.weepingAngel = config.getBoolean("weepingAngel.enabled", false);
6777
if (this.weepingAngel) {
6878
this.weepingAngelEnv = config.getInt("weepingAngel.environment", 1);
6979
this.weepingAngelPlayer = config.getInt("weepingAngel.playerKill", 5);
7080

7181
plugin().log(" Weeping Angel is enabled. Times | Env[" + weepingAngelEnv + "] PK[" + weepingAngelPlayer + "]");
7282
}
7383

84+
this.blockWaterInHell = config.getBoolean("blockWaterInHell", true);
85+
if (this.blockWaterInHell) plugin().log(" Blocking bucket use in hell biomes");
7486

7587
/* Add additional feature config grabs here. */
7688
}
@@ -106,6 +118,14 @@ public boolean isTotemPowers() {
106118
return this.totemPowers;
107119
}
108120

121+
public boolean isElytraUse() {
122+
return this.elytraUse;
123+
}
124+
125+
public boolean isChorusFruitTeleportation() {
126+
return this.chorusFruitUse;
127+
}
128+
109129
public boolean isWeepingAngel() {
110130
return this.weepingAngel;
111131
}
@@ -118,5 +138,9 @@ public int getWeepingAngelPlayer() {
118138
return this.weepingAngelPlayer;
119139
}
120140

141+
public boolean isBlockWaterInHell() {
142+
return this.blockWaterInHell;
143+
}
144+
121145
}
122146

src/main/java/com/programmerdan/minecraft/simpleadminhacks/configs/GameFixesConfig.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.programmerdan.minecraft.simpleadminhacks.SimpleHackConfig;
99

1010
import java.util.ArrayList;
11+
import java.util.logging.Level;
1112

1213
public class GameFixesConfig extends SimpleHackConfig {
1314

@@ -17,7 +18,8 @@ public class GameFixesConfig extends SimpleHackConfig {
1718
private boolean stopHopperDupe;
1819
private boolean stopRailDupe;
1920
private boolean stopEndPortalDeletion;
20-
21+
private boolean stopBedBombing;
22+
2123
private ArrayList<BlockFace> bfArray;
2224
private ArrayList<Material> railArray;
2325
private ArrayList<Material> pistonArray;
@@ -30,14 +32,22 @@ public GameFixesConfig(SimpleAdminHacks plugin, ConfigurationSection base) {
3032
protected void wireup(ConfigurationSection config) {
3133
blockElytraBreakBug = config.getBoolean("blockElytraBreakBug", true);
3234
damageOnElytraBreakBug = config.getDouble("damageOnElytraBreakBug", 0.0d);
35+
if (blockElytraBreakBug) plugin().log(Level.INFO, " Block Elytra 1height break bug is enabled, doing {} damage to violators", damageOnElytraBreakBug);
36+
3337
canStorageTeleport = config.getBoolean("canStorageTeleport");
38+
if (!canStorageTeleport) plugin().log(" Storage holder teleportation is disabled.");
39+
3440
stopHopperDupe = config.getBoolean("stopHopperDupe");
41+
if (stopHopperDupe) plugin().log(" Stop Hopper self-feeding Dupe is enabled.");
3542

3643
stopRailDupe = config.getBoolean("stopRailDupe", true);
37-
if (stopRailDupe) plugin().log("Stop Rail Dupe is enabled.");
44+
if (stopRailDupe) plugin().log(" Stop Rail Dupe is enabled.");
3845

3946
stopEndPortalDeletion = config.getBoolean("stopEndPortalDeletion", true);
40-
if (stopEndPortalDeletion) plugin().log("Stop End Portal Deletion is enabled.");
47+
if (stopEndPortalDeletion) plugin().log(" Stop End Portal Deletion is enabled.");
48+
49+
stopBedBombing = config.getBoolean("stopBedBombingInHellBiomes", true);
50+
if (stopBedBombing) plugin().log(" Stop Bed Bombing In Hell Biomes is enabled.");
4151
}
4252

4353
private void wireUpArrays() {
@@ -99,4 +109,8 @@ public ArrayList<Material> getRailArray() {
99109
public ArrayList<Material> getPistonArray() {
100110
return pistonArray;
101111
}
112+
113+
public boolean stopBedBombing() {
114+
return this.stopBedBombing;
115+
}
102116
}

src/main/java/com/programmerdan/minecraft/simpleadminhacks/hacks/GameFeatures.java

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
import org.apache.commons.lang.time.DateUtils;
88
import org.bukkit.BanList;
99
import org.bukkit.Bukkit;
10+
import org.bukkit.block.Biome;
1011
import org.bukkit.block.CreatureSpawner;
1112
import org.bukkit.entity.*;
1213
import org.bukkit.event.Listener;
1314
import org.bukkit.event.EventHandler;
1415
import org.bukkit.event.EventPriority;
1516
import org.bukkit.event.block.Action;
17+
import org.bukkit.event.block.BlockDispenseEvent;
1618
import org.bukkit.event.block.BlockPlaceEvent;
1719
import org.bukkit.event.entity.CreatureSpawnEvent;
1820
import org.bukkit.event.entity.EntityDamageByEntityEvent;
1921
import org.bukkit.event.entity.EntityResurrectEvent;
22+
import org.bukkit.event.entity.EntityToggleGlideEvent;
2023
import org.bukkit.event.entity.PlayerDeathEvent;
2124
import org.bukkit.event.inventory.FurnaceExtractEvent;
2225
import org.bukkit.event.inventory.InventoryMoveItemEvent;
@@ -32,10 +35,19 @@
3235
import com.programmerdan.minecraft.simpleadminhacks.SimpleAdminHacks;
3336
import com.programmerdan.minecraft.simpleadminhacks.SimpleHack;
3437
import com.programmerdan.minecraft.simpleadminhacks.configs.GameFeaturesConfig;
38+
import com.untamedears.humbug.annotations.BahHumbug;
39+
import com.untamedears.humbug.annotations.BahHumbugs;
40+
41+
import org.bukkit.event.player.PlayerBucketEmptyEvent;
3542
import org.bukkit.event.player.PlayerInteractEntityEvent;
3643
import org.bukkit.event.player.PlayerInteractEvent;
3744
import org.bukkit.event.player.PlayerItemDamageEvent;
45+
import org.bukkit.event.player.PlayerTeleportEvent;
46+
import org.bukkit.inventory.ItemStack;
47+
import org.bukkit.material.Dispenser;
3848
import org.bukkit.material.Hopper;
49+
import org.bukkit.potion.PotionEffect;
50+
import org.bukkit.potion.PotionEffectType;
3951

4052
/**
4153
* This is a grab-bag class to hold any _features_ related configurations that impact the
@@ -141,12 +153,33 @@ public String status() {
141153
genStatus.append("disabled\n");
142154
}
143155

156+
genStatus.append(" Elytra use is ");
157+
if (config.isElytraUse()) {
158+
genStatus.append("enabled\n");
159+
} else {
160+
genStatus.append("disabled\n");
161+
}
162+
163+
genStatus.append(" Chorus Fruit teleportation is ");
164+
if (config.isChorusFruitTeleportation()) {
165+
genStatus.append("enabled\n");
166+
} else {
167+
genStatus.append("disabled\n");
168+
}
169+
144170
genStatus.append(" WeepAngel is ");
145171
if (config.isWeepingAngel()) {
146172
genStatus.append("enabled\n");
147173
} else {
148174
genStatus.append("disabled\n");
149175
}
176+
177+
genStatus.append(" Block water in HELL biomes is ");
178+
if (config.isBlockWaterInHell()) {
179+
genStatus.append("enabled\n");
180+
} else {
181+
genStatus.append("disabled\n");
182+
}
150183

151184
// more?
152185
} else {
@@ -248,12 +281,29 @@ public void disabledShulkerBoxHoppering(InventoryMoveItemEvent event) {
248281

249282
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
250283
public void disableTotemPowers(EntityResurrectEvent event) {
251-
if (!config.isEnabled()) return;
284+
if (!config.isEnabled() || config.isTotemPowers()) return;
285+
252286
if (EntityType.PLAYER.equals(event.getEntityType())) {
253287
event.setCancelled(true);
254288
}
255289
}
256290

291+
@EventHandler(priority = EventPriority.HIGHEST)
292+
public void disableChorusFruitTeleportation(PlayerTeleportEvent event) {
293+
if (!config.isEnabled() || config.isChorusFruitTeleportation()) return;
294+
295+
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT)) {
296+
event.setCancelled(true);
297+
}
298+
}
299+
300+
@EventHandler(priority = EventPriority.HIGHEST)
301+
public void disableElytraUse(EntityToggleGlideEvent event) {
302+
if (!config.isEnabled() || config.isElytraUse()) return;
303+
304+
event.setCancelled(true);
305+
}
306+
257307
@EventHandler(priority = EventPriority.HIGH)
258308
public void weepingAngelListener(PlayerDeathEvent event) {
259309
if (!config.isEnabled()) return;
@@ -303,4 +353,29 @@ public void run() {
303353
}, 2L);
304354
}
305355

356+
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
357+
public void onPlayerBucketEmptyEvent(PlayerBucketEmptyEvent e) {
358+
if (config.isEnabled() && config.isBlockWaterInHell()) {
359+
if ((e.getBlockClicked().getBiome() == Biome.HELL) && (e.getBucket() == Material.WATER_BUCKET)) {
360+
e.setCancelled(true);
361+
e.getItemStack().setType(Material.BUCKET);
362+
}
363+
}
364+
}
365+
366+
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
367+
public void onDispenseEvent(BlockDispenseEvent event) {
368+
if (config.isEnabled() && config.isBlockWaterInHell()) {
369+
if (event.getBlock().getType() == Material.DISPENSER) {
370+
Dispenser disp = (Dispenser) event.getBlock().getState().getData();
371+
Biome biome = event.getBlock().getRelative(disp.getFacing()).getBiome();
372+
373+
if (Biome.HELL.equals(biome) && event.getItem() != null && event.getItem().getType().equals(Material.WATER_BUCKET)) {
374+
event.setItem(new ItemStack(Material.BUCKET, event.getItem().getAmount()));
375+
event.setCancelled(true);
376+
}
377+
378+
}
379+
}
380+
}
306381
}

src/main/java/com/programmerdan/minecraft/simpleadminhacks/hacks/GameFixes.java

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.programmerdan.minecraft.simpleadminhacks.hacks;
22

33
import org.bukkit.Material;
4+
import org.bukkit.World.Environment;
45
import org.bukkit.ChatColor;
6+
import org.bukkit.block.Biome;
57
import org.bukkit.block.Block;
68
import org.bukkit.block.BlockFace;
79
import org.bukkit.configuration.ConfigurationSection;
@@ -70,27 +72,42 @@ public String status() {
7072
genStatus.append("GameFixes is ");
7173
if (config != null && config.isEnabled()) {
7274
genStatus.append(ChatColor.GREEN).append("active\n").append(ChatColor.RESET);
75+
genStatus.append(" Block elytra break bug is ");
7376
if (config.isBlockElytraBreakBug()) {
74-
genStatus.append(" Block elytra break bug is ").append(ChatColor.GREEN).append("enabled\n")
75-
.append(ChatColor.RESET);
77+
genStatus.append(ChatColor.GREEN).append("enabled\n").append(ChatColor.RESET);
7678
genStatus.append(" Will deal " + config.getDamageOnElytraBreakBug() + " damage to players\n");
7779
} else {
78-
genStatus.append(" Block elytra break bug is ").append(ChatColor.RED).append("disabled\n")
79-
.append(ChatColor.RESET);
80+
genStatus.append(ChatColor.RED).append("disabled\n").append(ChatColor.RESET);
8081
}
82+
genStatus.append(" Block storage entities from teleporting to prevents exploits ");
8183
if (!config.canStorageTeleport()) {
82-
genStatus.append(" Block storage entities from teleporting to prevents exploits ")
83-
.append(ChatColor.GREEN).append("enabled\n").append(ChatColor.RESET);
84+
genStatus.append(ChatColor.GREEN).append("enabled\n").append(ChatColor.RESET);
8485
} else {
85-
genStatus.append(" Block storage entities from teleporting to prevents exploits ")
86-
.append(ChatColor.RED).append("disabled\n").append(ChatColor.RESET);
86+
genStatus.append(ChatColor.RED).append("disabled\n").append(ChatColor.RESET);
8787
}
88+
genStatus.append(" Hopper self-feed duplication exploit fix ");
8889
if (config.isStopHopperDupe()) {
89-
genStatus.append(" Hopper self-feed duplication exploit fix ")
90-
.append(ChatColor.GREEN).append("enabled\n").append(ChatColor.RESET);
90+
genStatus.append(ChatColor.GREEN).append("enabled\n").append(ChatColor.RESET);
9191
} else {
92-
genStatus.append(" Hopper self-feed duplication exploit fix ")
93-
.append(ChatColor.RED).append("disabled\n").append(ChatColor.RESET);
92+
genStatus.append(ChatColor.RED).append("disabled\n").append(ChatColor.RESET);
93+
}
94+
genStatus.append(" Duplications using rails exploit fix ");
95+
if (config.isStopRailDupe()) {
96+
genStatus.append(ChatColor.GREEN).append("enabled\n").append(ChatColor.RESET);
97+
} else {
98+
genStatus.append(ChatColor.RED).append("disabled\n").append(ChatColor.RESET);
99+
}
100+
genStatus.append(" End Portal removal exploit fix ");
101+
if (config.isStopEndPortalDeletion()) {
102+
genStatus.append(ChatColor.GREEN).append("enabled\n").append(ChatColor.RESET);
103+
} else {
104+
genStatus.append(ChatColor.RED).append("disabled\n").append(ChatColor.RESET);
105+
}
106+
genStatus.append(" Bed Bombing in Nether / Hell Biomes fix ");
107+
if (config.stopBedBombing()) {
108+
genStatus.append(ChatColor.GREEN).append("enabled\n").append(ChatColor.RESET);
109+
} else {
110+
genStatus.append(ChatColor.RED).append("disabled\n").append(ChatColor.RESET);
94111
}
95112
} else {
96113
genStatus.append(ChatColor.RED).append("inactive").append(ChatColor.RESET);
@@ -147,7 +164,7 @@ public void onInventoryMoveItem(InventoryMoveItemEvent event) {
147164

148165
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
149166
public void onPistonPushRail(BlockPistonExtendEvent event) {
150-
if (config.isStopRailDupe()) {
167+
if (config.isEnabled() && config.isStopRailDupe()) {
151168
for (Block block : event.getBlocks()) {
152169
Material type = block.getType();
153170

@@ -161,7 +178,7 @@ public void onPistonPushRail(BlockPistonExtendEvent event) {
161178

162179
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
163180
public void onRailPlace(BlockPlaceEvent event) {
164-
if (config.isStopRailDupe()) {
181+
if (config.isEnabled() && config.isStopRailDupe()) {
165182
Block block = event.getBlock();
166183
Material type = block.getType();
167184

@@ -181,7 +198,7 @@ public void onRailPlace(BlockPlaceEvent event) {
181198
//Trying to stop players from deleting end portals
182199
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
183200
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
184-
if (config.isStopEndPortalDeletion()) {
201+
if (config.isEnabled() && config.isStopEndPortalDeletion()) {
185202
Block block = event.getBlockClicked().getRelative(event.getBlockFace());
186203

187204
if (block.getType() == Material.ENDER_PORTAL) {
@@ -192,7 +209,7 @@ public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
192209

193210
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
194211
public void onDispenseEvent(BlockDispenseEvent event) {
195-
if (config.isStopEndPortalDeletion()) {
212+
if (config.isEnabled() && config.isStopEndPortalDeletion()) {
196213
if (event.getBlock().getType() == Material.DISPENSER) {
197214
Dispenser disp = (Dispenser) event.getBlock().getState().getData();
198215
Material type = event.getBlock().getRelative(disp.getFacing()).getType();
@@ -204,6 +221,21 @@ public void onDispenseEvent(BlockDispenseEvent event) {
204221
}
205222
}
206223
}
224+
225+
@EventHandler(priority = EventPriority.HIGHEST)
226+
public void onPlayerEnterBed(BlockPlaceEvent event) {
227+
if (!config.isEnabled() || !config.stopBedBombing()) return;
228+
229+
Block b = event.getBlock();
230+
if (!(b.getType() == Material.BED || b.getType() == Material.BED_BLOCK))
231+
return;
232+
233+
Environment env = b.getLocation().getWorld().getEnvironment();
234+
Biome biome = b.getLocation().getBlock().getBiome();
235+
if (env == Environment.NETHER || env == Environment.THE_END || Biome.HELL == biome || Biome.SKY == biome) {
236+
event.setCancelled(true);
237+
}
238+
}
207239

208240
public static GameFixesConfig generate(SimpleAdminHacks plugin, ConfigurationSection config) {
209241
return new GameFixesConfig(plugin, config);

0 commit comments

Comments
 (0)