mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-11-22 11:35:16 +01:00
Distort Sign Text
This commit is contained in:
parent
4e279fae2e
commit
71963232f3
@ -185,6 +185,7 @@ public class P extends JavaPlugin {
|
||||
Brew.colorInBrewer = config.getBoolean("colorInBrewer", false);
|
||||
Words.log = config.getBoolean("logRealChat", false);
|
||||
Words.commands = config.getStringList("distortCommands");
|
||||
Words.doSigns = config.getBoolean("distortSignText");
|
||||
|
||||
// loading recipes
|
||||
ConfigurationSection configSection = config.getConfigurationSection("recipes");
|
||||
|
@ -9,6 +9,7 @@ import java.lang.Character;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import com.dre.brewery.BPlayer;
|
||||
|
||||
@ -19,6 +20,7 @@ public class Words {
|
||||
public static ArrayList<Words> words = new ArrayList<Words>();
|
||||
public static List<String> commands;
|
||||
public static FileConfiguration config;
|
||||
public static Boolean doSigns;
|
||||
public static Boolean log;
|
||||
private static Map<String, Long> waitPlayers = new HashMap<String, Long>();
|
||||
|
||||
@ -106,6 +108,30 @@ public class Words {
|
||||
}
|
||||
}
|
||||
|
||||
// Distort players words when he uses a command
|
||||
public static void signWrite(SignChangeEvent event) {
|
||||
BPlayer bPlayer = BPlayer.get(event.getPlayer().getName());
|
||||
if (bPlayer != null) {
|
||||
if (loadWords()) {
|
||||
int index = 0;
|
||||
for (String message : event.getLines()) {
|
||||
if (message.length() > 1) {
|
||||
for (Words word : words) {
|
||||
if (word.alcohol <= bPlayer.getDrunkeness()) {
|
||||
message = word.distort(message);
|
||||
}
|
||||
}
|
||||
if (message.length() > 15) {
|
||||
message = message.substring(0, 14);
|
||||
}
|
||||
event.setLine(index, message);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Distort players words when he talks
|
||||
public static void playerChat(AsyncPlayerChatEvent event) {
|
||||
BPlayer bPlayer = BPlayer.get(event.getPlayer().getName());
|
||||
|
@ -10,6 +10,8 @@ import org.bukkit.block.Block;
|
||||
|
||||
import com.dre.brewery.BCauldron;
|
||||
import com.dre.brewery.Barrel;
|
||||
import com.dre.brewery.BPlayer;
|
||||
import com.dre.brewery.Words;
|
||||
import com.dre.brewery.P;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
@ -25,6 +27,15 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onSignChangeLow(SignChangeEvent event) {
|
||||
if (Words.doSigns) {
|
||||
if (BPlayer.players.containsKey(event.getPlayer().getName())) {
|
||||
Words.signWrite(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Block block = event.getBlock();
|
||||
|
Loading…
Reference in New Issue
Block a user