Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.spazzinq.flightcontrol.command.*;
import org.spazzinq.flightcontrol.listener.BlockBreakFlyDisableListener;
import org.spazzinq.flightcontrol.manager.*;
import org.spazzinq.flightcontrol.multiversion.Particle;
import org.spazzinq.flightcontrol.multiversion.current.Particle13;
Expand Down Expand Up @@ -67,7 +68,7 @@ public void onEnable() {
updateManager.checkForUpdate();
}
}.runTaskAsynchronously(this);

getServer().getPluginManager().registerEvents(new BlockBreakFlyDisableListener(this), this);
// Start bStats
new MetricsLite(this, 4704); // 4704 = plugin ID
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.spazzinq.flightcontrol.listener;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.spazzinq.flightcontrol.FlightControl;

public class BlockBreakFlyDisableListener implements Listener {
private final FlightControl pl;

public BlockBreakFlyDisableListener(FlightControl pl) {
this.pl = pl;
}

@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Material blockType = event.getBlock().getType();

if (pl.getConfManager().getBlockBreakDisableList().contains(blockType.name())) {
if (player.isFlying()) {
player.setAllowFlight(false);
player.setFlying(false);

String message = org.bukkit.ChatColor.translateAlternateColorCodes('&',
pl.getLangManager().getBlockBreakDisable().replace("%block%", blockType.name().toLowerCase()));
player.sendMessage(message);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;

public class ConfManager extends StorageManager {
@Getter @Setter private boolean autoEnable;
Expand All @@ -40,6 +41,8 @@ public class ConfManager extends StorageManager {

@Getter @Setter private String flyCommandName;
@Getter @Setter private String aeEnchantName;
@Getter @Setter private List<String> blockBreakDisableList;


public ConfManager() {
super("config.yml");
Expand Down Expand Up @@ -76,6 +79,9 @@ public ConfManager() {
flyCommandName = conf.getString("settings.fly_command_name", "fly");
aeEnchantName = conf.getString("settings.ae_enchant_name");

// Lists
blockBreakDisableList = conf.getStringList("block_break_disable_list");

// Load other stuff that have separate methods
loadSounds();
loadTrail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public class LangManager extends StorageManager {
@Getter private String tempFlyDisabled;
@Getter private String tempFlyCheck;
@Getter private String tempFlyUsage = "";
@Getter private String blockBreakDisable;


public LangManager() {
super("lang.yml");
Expand Down Expand Up @@ -147,6 +149,7 @@ public LangManager() {
tempFlyDisable = lang.getString("admin.tempfly.disable");
tempFlyDisabled = lang.getString("admin.tempfly.disabled");
tempFlyCheck = lang.getString("admin.tempfly.check");
blockBreakDisable = lang.getString("player.flight.block_break_disable");
}

@Override protected void updateFormatting() {
Expand Down
7 changes: 7 additions & 0 deletions FlightControl/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ trail:
# Color picker (RBG): https://www.google.com/search?q=color+picker
rgb: "0,0,0"

block_break_disable_list:
- BARRIER
- CARROTS
- POTATOES
# - SUGAR_CANE
# Add more blocks

sounds:
# Plays the sounds on EVERY double tap of the space bar
every_enable: false
Expand Down
1 change: 1 addition & 0 deletions FlightControl/src/main/resources/lang_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ player:
can_enable: '&bYou can use /fly now.'
cannot_enable: '&cYou cannot fly right now.'
height_denied: '&cYou cannot fly this high!'
block_break_disable: "&cFlight disabled when breaking %block%!"
trail:
enabled: '&aYou enabled the flight trail!'
disabled: '&cYou disabled the flight trail!'
Expand Down
1 change: 1 addition & 0 deletions FlightControl/src/main/resources/lang_pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ player:
can_enable: '&bVocê pode usar o /fly agora.'
cannot_enable: '&cVocê não pode voar agora.'
height_denied: '&cVocê não pode voar tão alto!'
block_break_disable: "&cVoo desativado ao quebrar %block%!"
trail:
enabled: '&aVocê ativou o rastro ao voar!'
disabled: '&cVocê desativou o rastro ao voar!'
Expand Down