Add Colors to chat, update default config

This commit is contained in:
Eric Stokes 2011-06-26 20:24:44 -06:00
parent 84b726b636
commit 46ed043104
4 changed files with 66 additions and 21 deletions

View File

@ -2,6 +2,7 @@ package com.onarandombox.MultiverseCore;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
@ -16,11 +17,11 @@ import org.bukkit.event.player.PlayerTeleportEvent;
public class MVPlayerListener extends PlayerListener {
private final Logger log = Logger.getLogger("Minecraft");
MultiverseCore plugin;
public MVPlayerListener(MultiverseCore plugin) {
this.plugin = plugin;
}
@Override
public void onPlayerTeleport(PlayerTeleportEvent event) {
// MultiVerseCore.debugMsg(event.getPlayer().getName() + " just tried to Teleport");
@ -34,19 +35,17 @@ public class MVPlayerListener extends PlayerListener {
log.warning("To: " + event.getTo().getWorld().getName());
log.warning("From: " + event.getFrom().getWorld().getName());
}
public void onPlayerKick(PlayerKickEvent event) {
event.setCancelled(true);
}
@Override
public void onPlayerMove(PlayerMoveEvent event) {
Player p = event.getPlayer(); // Grab Player
Location loc = p.getLocation(); // Grab Location
/**
* Check the Player has actually moved a block to prevent unneeded calculations...
* This is to prevent huge performance drops on high player count servers.
* Check the Player has actually moved a block to prevent unneeded calculations... This is to prevent huge performance drops on high player count servers.
*/
MVPlayerSession ps = this.plugin.getPlayerSession(p);
if (ps.loc.getBlockX() == loc.getBlockX() && ps.loc.getBlockY() == loc.getBlockY() && ps.loc.getBlockZ() == loc.getBlockZ()) {
@ -55,12 +54,37 @@ public class MVPlayerListener extends PlayerListener {
ps.loc = loc; // Update the Players Session to the new Location.
}
}
@Override
public void onPlayerChat(PlayerChatEvent event) {
// Not sure if this should be a seperat plugin... in here for now!!!
// FernFerret
if (event.isCancelled()) {
return;
}
/**
* Check whether the Server is set to prefix the chat with the World name. If not we do nothing, if so we need to check if the World has an Alias.
*/
if (this.plugin.configMV.getBoolean("worldnameprefix", true)) {
String world = event.getPlayer().getWorld().getName();
String prefix = "";
// If we're not a MV world, don't do anything
if (!this.plugin.isMVWorld(world)) {
return;
}
MVWorld mvworld = this.plugin.getMVWorld(world);
prefix = mvworld.getColoredWorldString();
String format = event.getFormat();
event.setFormat("[" + prefix + "]" + format);
}
}
@Override
public void onPlayerRespawn(PlayerRespawnEvent event) {
// TODO: Handle Global Respawn from config
@ -70,14 +94,14 @@ public class MVPlayerListener extends PlayerListener {
MVPlayerSession ps = this.plugin.getPlayerSession(event.getPlayer());
event.setRespawnLocation(ps.getRespawnWorld().getSpawnLocation());
}
@Override
public void onPlayerJoin(PlayerJoinEvent event) {
}
@Override
public void onPlayerQuit(PlayerQuitEvent event) {
}
}

View File

@ -95,6 +95,14 @@ public class MVWorld {
// }
}
public String getColoredWorldString() {
if (this.getAlias() != null && this.getAlias().length() > 0) {
return this.getAliasColor() + this.getAlias() + ChatColor.WHITE;
} else {
return this.world.getName();
}
}
private void getMobExceptions() {
List<String> temp;
temp = this.config.getStringList("worlds." + this.name + ".animals.exceptions", new ArrayList<String>());

View File

@ -145,6 +145,7 @@ public class MultiverseCore extends JavaPlugin {
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Priority.Normal, this); // To remove Player Sessions
pm.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Priority.Highest, this);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.Normal, this); // To Allow/Disallow PVP as well as EnableHealth.
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning.

View File

@ -1,15 +1,27 @@
#True/False - Whether MultiVerse should handle all respawns on every World including the Default.
#Disable this if you have a form of Respawn Teleportation plugin.
# True/False - Whether MultiVerse should handle all respawns on every World including the Default.
# Disable this if you have a form of Respawn Teleportation plugin.
globalrespawn: false
#True/False - Whether MultiVerse should handle all respawns on the MultiVerse Worlds.
#If 'globalrespawn:true' then this will have no effect.
# True/False - Whether MultiVerse should handle all respawns on the MultiVerse Worlds.
# If 'globalrespawn:true' then this will have no effect.
alternaterespawn: true
#How long to leave in between sending a message to the player.
#In Milliseconds - Default is '5000' which is 5 Seconds.
# How long to leave in between sending a message to the player.
# In Milliseconds - Default is '5000' which is 5 Seconds.
messagecooldown: 5000
#Portal Cooldown, only affects MultiVerse portals.
#In Milliseconds - Default is '5000' which is 5 Seconds.
portalcooldown: 5000
# Portal Cooldown, only affects MultiVerse portals.
# In Milliseconds - Default is '5000' which is 5 Seconds.
portalcooldown: 5000
# If this is set to true, we will prefix the chat with
# a colorful world alias if it's present. If not, we simply
# show the world's name in white. If this is false Multiverse
# won't touch your chat
worldnameprefix: true
# If Multiverse does not find permissions should it automattically fall back to
# people defined in ops.txt? Remember, if you use ops based permissions
# the awesome Multiverse devs get to decide which commands require op!
# (Which is why we highly recomend a permissions plugin! You shouldn't trust us this much...)
fallbacktoops: true