-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
272 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
...xesFolia/src/main/java/me/xginko/aef/modules/preventions/withers/DisableWitherSkulls.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
.../src/main/java/me/xginko/aef/modules/preventions/withers/RemoveAllSkullsPeriodically.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
...ia/src/main/java/me/xginko/aef/modules/preventions/withers/RemoveSkullsOnChunkunload.java
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
...olia/src/main/java/me/xginko/aef/modules/preventions/withers/WitherSkullDropsAtSpawn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package me.xginko.aef.modules.preventions.withers; | ||
|
||
import io.github.thatsmusic99.configurationmaster.api.ConfigSection; | ||
import me.xginko.aef.modules.AEFModule; | ||
import me.xginko.aef.utils.LocationUtil; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.entity.EntityExplodeEvent; | ||
import org.bukkit.util.NumberConversions; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class WitherSkullDropsAtSpawn extends AEFModule implements Listener { | ||
|
||
private final Map<String, Double> worldsAndTheirRadiuses = new HashMap<>(); | ||
|
||
public WitherSkullDropsAtSpawn() { | ||
super("preventions.withers.disable-item-drops-at-spawn"); | ||
config.addComment(configPath + ".enable", | ||
"Prevents wither skulls from dropping items when they hit a block\n" + | ||
"within a certain radius from 00. Can help with lag."); | ||
Map<String, Object> defaults = new HashMap<>(); | ||
defaults.put("world", 5000); | ||
defaults.put("world_nether", 5000); | ||
defaults.put("world_the_end", 5000); | ||
ConfigSection section = config.getConfigSection(configPath + ".worlds", defaults); | ||
for (String world : section.getKeys(false)) { | ||
try { | ||
double radiusSquared = NumberConversions.square(Integer.parseInt(section.getString(world))); | ||
this.worldsAndTheirRadiuses.put(world, radiusSquared); | ||
} catch (NumberFormatException e) { | ||
warn("Radius for world '" + world + "' is not a valid integer."); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void enable() { | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
|
||
@Override | ||
public boolean shouldEnable() { | ||
return config.getBoolean(configPath + ".enable", false); | ||
} | ||
|
||
@Override | ||
public void disable() { | ||
HandlerList.unregisterAll(this); | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
private void onEntityExplode(EntityExplodeEvent event) { | ||
if (event.getEntityType() != EntityType.WITHER_SKULL) return; | ||
if (!worldsAndTheirRadiuses.containsKey(event.getLocation().getWorld().getName())) return; | ||
|
||
if (LocationUtil.getSquaredDistance2DTo00(event.getLocation()) | ||
<= worldsAndTheirRadiuses.get(event.getLocation().getWorld().getName())) { | ||
event.setYield(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
...esLegacy/src/main/java/me/xginko/aef/modules/preventions/withers/DisableWitherSkulls.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.