Skip to content

Commit

Permalink
Version 3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsLewizzz committed Jun 9, 2020
1 parent 77ad3f4 commit 3673469
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 40 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fun.lewisdev</groupId>
<artifactId>DeluxeHub</artifactId>
<version>3.2.9</version>
<version>3.3.0</version>
<packaging>jar</packaging>

<name>DeluxeHub</name>
Expand Down Expand Up @@ -40,7 +40,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public InventoryItem getIcon(final int slot) {
return icons.get(slot);
}

public Map<Integer, InventoryItem> getIcons() {
return icons;
}

public Inventory getInventory() {
if (size > 54) size = 54;
else if (size < 9) size = 9;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class InventoryItem {
public final List<ClickAction> clickActions;

public InventoryItem(final ItemStack itemStack) {
this.clickActions = new ArrayList<ClickAction>();
this.clickActions = new ArrayList<>();
this.itemStack = itemStack;
}

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/fun/lewisdev/deluxehub/module/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public void loadModules(DeluxeHub plugin) {
registerModule(new CustomCommands(plugin));
registerModule(new PlayerListener(plugin));
registerModule(new HotbarManager(plugin));
registerModule(new HologramManager(plugin));
registerModule(new WorldProtect(plugin));
registerModule(new LobbySpawn(plugin));
registerModule(new PlayerVanish(plugin));
registerModule(new HologramManager(plugin));

modules.values().forEach(module -> {
for (Module module : modules.values()) {
try {
module.setDisabledWorlds(disabledWorlds);
module.onEnable();
Expand All @@ -71,22 +71,23 @@ public void loadModules(DeluxeHub plugin) {
plugin.getLogger().severe("The plugin will now disable..");
plugin.getLogger().severe("============= DELUXEHUB MODULE LOAD ERROR =============");
plugin.getServer().getPluginManager().disablePlugin(plugin);
break;
}
});
}

plugin.getLogger().info("Loaded " + modules.size() + " plugin modules.");
}

public void unloadModules() {
modules.values().forEach(module -> {
for (Module module : modules.values()) {
try {
HandlerList.unregisterAll(module);
module.onDisable();
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().severe("There was an error unloading the " + module.getModuleType().toString() + " module.");
}
});
}
modules.clear();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class AutoBroadcast extends Module implements Runnable {
private int broadcastTask = 0;
private int count = 0;
private int size = 0;
private int requiredPlayers = 0;

private Sound sound = null;
private double volume;
Expand All @@ -47,6 +48,8 @@ public void onEnable() {
pitch = config.getDouble("announcements.sound.pitch");
}

requiredPlayers = config.getInt("announcements.required_players", 0);

size = broadcasts.size();
if (size > 0)
broadcastTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(getPlugin(), this, 60L, config.getInt("announcements.delay") * 20);
Expand All @@ -61,9 +64,9 @@ public void onDisable() {
public void run() {
if (count == size) count = 0;

if (count < size) {
if (count < size && Bukkit.getOnlinePlayers().size() >= requiredPlayers) {
for (Player player : Bukkit.getOnlinePlayers()) {
if(inDisabledWorld(player.getLocation())) continue;
if (inDisabledWorld(player.getLocation())) continue;

broadcasts.get(count).forEach(message -> {
if (message.contains("<center>") && message.contains("</center>"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import de.tr7zw.changeme.nbtapi.NBTItem;
import fun.lewisdev.deluxehub.DeluxeHub;
import fun.lewisdev.deluxehub.utility.ItemStackBuilder;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -18,6 +20,7 @@ public abstract class HotbarItem implements Listener {

private HotbarManager hotbarManager;
private ItemStack item;
private ConfigurationSection configurationSection;
private String key;
private String permission = null;
private int slot;
Expand Down Expand Up @@ -67,9 +70,23 @@ public String getPermission() {
return permission;
}

public void setConfigurationSection(ConfigurationSection configurationSection) {
this.configurationSection = configurationSection;
}

public ConfigurationSection getConfigurationSection() {
return configurationSection;
}

public void giveItem(Player player) {
if (permission != null && !player.hasPermission(permission)) return;
player.getInventory().setItem(slot, item);

ItemStack newItem = item.clone();
if (getConfigurationSection() != null && getConfigurationSection().contains("username")) {
newItem = new ItemStackBuilder(newItem).setSkullOwner(player.getName()).build();
}

player.getInventory().setItem(slot, newItem);
}

public void removeItem(Player player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void onEnable() {
customItem.setPermission(config.getString("custom_join_items.items." + entry + ".permission"));
}

customItem.setConfigurationSection(config.getConfigurationSection("custom_join_items.items." + entry));
customItem.setAllowMovement(config.getBoolean("custom_join_items.disable_inventory_movement"));
registerHotbarItem(customItem);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,12 @@ public void onPlayerQuit(PlayerQuitEvent event) {
@EventHandler(priority = EventPriority.HIGHEST)
public void onWorldChange(PlayerTeleportEvent event) {
Player player = event.getPlayer();
if (event.isCancelled() || event.getFrom().getWorld().getName().equals(event.getTo().getWorld().getName()))
return;
if (event.getFrom().getWorld().getName().equals(event.getTo().getWorld().getName())) return;

if (!inDisabledWorld(event.getTo().getWorld()) && !players.containsKey(player.getUniqueId())) {
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> createScoreboard(player), worldDelay);
} else {
if (inDisabledWorld(event.getTo().getWorld()) && players.containsKey(player.getUniqueId())) {
removeScoreboard(player);

} else if (!players.containsKey(player.getUniqueId())) {
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> createScoreboard(player), worldDelay);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class WorldProtect extends Module {
private boolean blockPlace;
private boolean blockInteract;
private boolean playerPvP;
private boolean playerDrowning;
private boolean fireDamage;

private List<Material> interactables = Arrays.asList(
XMaterial.ACACIA_DOOR.parseMaterial(),
Expand Down Expand Up @@ -115,6 +117,8 @@ public void onEnable() {
blockBurn = config.getBoolean("world_settings.disable_block_burn");
fireSpread = config.getBoolean("world_settings.disable_block_fire_spread");
leafDecay = config.getBoolean("world_settings.disable_block_leaf_decay");
playerDrowning = config.getBoolean("world_settings.disable_drowning");
fireDamage = config.getBoolean("world_settings.disable_fire_damage");
}

@Override
Expand Down Expand Up @@ -256,14 +260,23 @@ public void onBlockInteract(PlayerInteractEvent event) {

@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (!fallDamage) return;
if (!(event.getEntity() instanceof Player)) return;
if (event.getCause() == EntityDamageEvent.DamageCause.VOID) return;

Player player = (Player) event.getEntity();
if (inDisabledWorld(player.getLocation())) return;

if (event.getCause() == EntityDamageEvent.DamageCause.FALL) event.setCancelled(true);
if (fallDamage && event.getCause() == EntityDamageEvent.DamageCause.FALL) event.setCancelled(true);
else if (playerDrowning && event.getCause() == EntityDamageEvent.DamageCause.DROWNING) event.setCancelled(true);
else if (fireDamage && (event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK || event.getCause() == EntityDamageEvent.DamageCause.LAVA))
event.setCancelled(true);
else if (voidDeath && event.getCause() == EntityDamageEvent.DamageCause.VOID) {
player.setFallDistance(0.0F);

Location location = ((LobbySpawn) getPlugin().getModuleManager().getModule(ModuleType.LOBBY)).getLocation();
if (location == null) return;

Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> player.teleport(location), 3L);
event.setCancelled(true);
}
}

@EventHandler
Expand Down Expand Up @@ -358,20 +371,4 @@ public void onEntityDamage(EntityDamageByEntityEvent event) {
event.getDamager().sendMessage(Messages.EVENT_PLAYER_PVP.toString());
}
}

@EventHandler
public void onVoidDamage(EntityDamageEvent event) {
if (!voidDeath || event.getCause() != EntityDamageEvent.DamageCause.VOID) return;

Entity entity = event.getEntity();
if (!(entity instanceof Player) || inDisabledWorld(entity.getLocation())) return;

entity.setFallDistance(0.0F);

Location location = ((LobbySpawn) getPlugin().getModuleManager().getModule(ModuleType.LOBBY)).getLocation();
if (location == null) return;

Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> entity.teleport(location), 3L);
event.setCancelled(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public static ItemStackBuilder getItemStack(ConfigurationSection section, Player
builder.withAmount(section.getInt("amount"));
}

if (section.contains("username")) {
builder.setSkullOwner(section.getString("username"));
if (section.contains("username") && player != null) {
builder.setSkullOwner(section.getString("username").replace("%player%", player.getName()));
}

if (section.contains("display_name")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ public enum XMaterial {
REDSTONE_WALL_TORCH,
REDSTONE_WIRE,
RED_BANNER(1, "BANNER", "STANDING_BANNER"),
RED_BED(14, "BED_BLOCK", "BED"),
RED_BED(0, "BED_BLOCK", "BED"),
RED_CARPET(14, "CARPET"),
RED_CONCRETE(14, "CONCRETE"),
RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"),
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ announcements:
# Delay to send announcements (in seconds)
delay: 60

# How many players should be required to send announcements?
required_players: 1

sound:
enabled: true
value: BLOCK_NOTE_BLOCK_PLING
Expand Down Expand Up @@ -242,6 +245,8 @@ world_settings:
disable_fall_damage: true
disable_player_pvp: true
disable_void_death: true
disable_fire_damage: true
disable_drowning: true

# Misc
disable_weather_change: true
Expand Down

0 comments on commit 3673469

Please sign in to comment.