forked from kaboomserver/extras
Don't hardcode join titles
This commit is contained in:
parent
ddd6fa76f4
commit
3a3b450921
6 changed files with 62 additions and 26 deletions
|
@ -650,6 +650,8 @@ public class Main extends JavaPlugin {
|
|||
this.nonSolidBlockList.addAll(nonSolidDoubleBlockList);
|
||||
this.nonSolidBlockList.addAll(nonSolidSingularBlockList);
|
||||
this.nonSolidBlockList.addAll(nonSolidWallMountedBlockList);
|
||||
|
||||
saveResource("config.yml", false);
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package pw.kaboom.extras;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -7,6 +9,9 @@ import org.bukkit.command.CommandExecutor;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -17,18 +22,24 @@ class CommandPrefix implements CommandExecutor {
|
|||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
final Player player = (Player) sender;
|
||||
final JavaPlugin plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <prefix|off>");
|
||||
} else if (args[0].equalsIgnoreCase("off")) {
|
||||
plugin.getConfig().set(player.getUniqueId().toString(), null);
|
||||
plugin.saveConfig();
|
||||
player.sendMessage("You no longer have a tag");
|
||||
} else {
|
||||
plugin.getConfig().set(player.getUniqueId().toString(), String.join(" ", args));
|
||||
plugin.saveConfig();
|
||||
player.sendMessage("You now have the tag: " + ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
|
||||
final File configFile = new File(JavaPlugin.getPlugin(Main.class).getDataFolder(), "prefixes.yml");
|
||||
final FileConfiguration prefixConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
try {
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <prefix|off>");
|
||||
} else if (args[0].equalsIgnoreCase("off")) {
|
||||
prefixConfig.set(player.getUniqueId().toString(), null);
|
||||
prefixConfig.save(configFile);
|
||||
player.sendMessage("You no longer have a tag");
|
||||
} else {
|
||||
prefixConfig.set(player.getUniqueId().toString(), String.join(" ", args));
|
||||
prefixConfig.save(configFile);
|
||||
player.sendMessage("You now have the tag: " + ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
player.sendMessage("Something went wrong while saving the prefix. Please check console.");
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -5,12 +5,13 @@ import java.util.ArrayList;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Nameable;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
|
||||
import org.bukkit.block.data.Levelled;
|
||||
|
||||
|
@ -73,13 +74,21 @@ class BlockPhysics implements Listener {
|
|||
@EventHandler
|
||||
void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
final Material material = event.getChangedType();
|
||||
final BlockState blockState = event.getSourceBlock().getState();
|
||||
final BlockState blockStateSource = event.getSourceBlock().getState();
|
||||
|
||||
/*if (event.getSourceBlock().getBlockData().getAsString().length() > 3019) {
|
||||
event.getSourceBlock().setType(Material.AIR);
|
||||
} else if (event.getBlock().getBlockData().getAsString().length() > 3019) {
|
||||
event.getBlock().setType(Material.AIR);
|
||||
}*/
|
||||
|
||||
if (material == Material.FARMLAND) {
|
||||
event.setCancelled(true);
|
||||
} else if (event.getSourceBlock().getState() instanceof CommandBlock) {
|
||||
event.getSourceBlock().getState().update();
|
||||
} else if (event.getBlock().getState() instanceof CommandBlock) {
|
||||
event.getBlock().getState().update();
|
||||
} else if (blockState instanceof CommandBlock) {
|
||||
blockState.update();
|
||||
} else if (blockStateSource instanceof CommandBlock) {
|
||||
blockStateSource.update();
|
||||
} else if (event.getBlock().isLiquid()) {
|
||||
final Block block = event.getBlock();
|
||||
final World world = block.getWorld();
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package pw.kaboom.extras;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -32,11 +36,14 @@ class PlayerChat implements Listener {
|
|||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final File configFile = new File(JavaPlugin.getPlugin(Main.class).getDataFolder(), "prefixes.yml");
|
||||
final FileConfiguration prefixConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
if (JavaPlugin.getPlugin(Main.class).getConfig().getString(player.getUniqueId().toString()) != null) {
|
||||
if (prefixConfig.getString(player.getUniqueId().toString()) != null) {
|
||||
final String prefix = ChatColor.translateAlternateColorCodes(
|
||||
'&',
|
||||
JavaPlugin.getPlugin(Main.class).getConfig().getString(player.getUniqueId().toString())
|
||||
prefixConfig.getString(player.getUniqueId().toString())
|
||||
);
|
||||
|
||||
event.setFormat(prefix + ChatColor.RESET + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + "%2$s");
|
||||
|
|
|
@ -62,6 +62,8 @@ class PlayerConnection implements Listener {
|
|||
@EventHandler
|
||||
void onPlayerJoin(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String title = JavaPlugin.getPlugin(Main.class).getConfig().getString("playerJoinTitle");
|
||||
final String subtitle = JavaPlugin.getPlugin(Main.class).getConfig().getString("playerJoinSubtitle");
|
||||
final int fadeIn = 10;
|
||||
final int stay = 160;
|
||||
final int fadeOut = 5;
|
||||
|
@ -87,13 +89,16 @@ class PlayerConnection implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
player.sendTitle(
|
||||
ChatColor.GRAY + "Welcome to Kaboom!",
|
||||
"Free OP • Anarchy • Creative",
|
||||
fadeIn,
|
||||
stay,
|
||||
fadeOut
|
||||
);
|
||||
if (title != null ||
|
||||
subtitle != null) {
|
||||
player.sendTitle(
|
||||
title,
|
||||
subtitle,
|
||||
fadeIn,
|
||||
stay,
|
||||
fadeOut
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
2
src/main/resources/config.yml
Normal file
2
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
playerJoinTitle: "§7Welcome to Kaboom!"
|
||||
playerJoinSubtitle: "Free OP • Anarchy • Creative"
|
Loading…
Reference in a new issue