mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-12-24 01:48:02 +01:00
Add new version cmd, lots of cleanup
This commit is contained in:
parent
f09bcac644
commit
9eff255f47
@ -71,7 +71,7 @@ public class MVEntityListener extends EntityListener {
|
||||
Player pattacker = (Player) attacker;
|
||||
|
||||
|
||||
if (!world.getPvp() && this.plugin.configMV.getBoolean("fakepvp", false)) {
|
||||
if (!world.getPvp() && this.plugin.getConfig().getBoolean("fakepvp", false)) {
|
||||
pattacker.sendMessage(ChatColor.RED + "PVP is disabled in this World.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -86,7 +86,7 @@ public class MVEntityListener extends EntityListener {
|
||||
return;
|
||||
}
|
||||
RegainReason reason = event.getRegainReason();
|
||||
if (reason == RegainReason.REGEN && this.plugin.configMV.getBoolean("disableautoheal", false)) {
|
||||
if (reason == RegainReason.REGEN && this.plugin.getConfig().getBoolean("disableautoheal", false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -75,7 +74,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
boolean opFallback = this.plugin.configMV.getBoolean("opfallback", true);
|
||||
boolean opFallback = this.plugin.getConfig().getBoolean("opfallback", true);
|
||||
if (this.permissions != null && this.permissions.has(player, node)) {
|
||||
// If Permissions is enabled we check against them.
|
||||
return true;
|
||||
|
@ -3,12 +3,9 @@ package com.onarandombox.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
@ -38,7 +35,7 @@ public class MVPlayerListener extends PlayerListener {
|
||||
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)) {
|
||||
if (this.plugin.getConfig().getBoolean("worldnameprefix", true)) {
|
||||
String world = event.getPlayer().getWorld().getName();
|
||||
String prefix = "";
|
||||
// If we're not a MV world, don't do anything
|
||||
|
@ -2,34 +2,28 @@ package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.onarandombox.utils.BlockSafety;
|
||||
|
||||
public class MVPlayerSession {
|
||||
|
||||
private Player player; // Player holder, may be unnecessary.
|
||||
private BlockSafety bs = new BlockSafety();
|
||||
|
||||
private Long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
|
||||
private Long messageLast = 0L; // Timestamp for the Players last Alert Message.
|
||||
|
||||
private Location bedSpawn;
|
||||
|
||||
// Beds are 2 blocks, thus we need to store both places
|
||||
private Location bedA;
|
||||
private Location bedB;
|
||||
// private Location bedSpawn;
|
||||
//
|
||||
// // Beds are 2 blocks, thus we need to store both places
|
||||
// private Location bedA;
|
||||
// private Location bedB;
|
||||
|
||||
private Configuration config; // Configuration file to find out Cooldown Timers.
|
||||
|
||||
public MVPlayerSession(Player player, Configuration config, MultiverseCore multiVerseCore) {
|
||||
this.player = player;
|
||||
this.config = config;
|
||||
this.bedSpawn = null;
|
||||
// this.bedSpawn = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +35,7 @@ public class MVPlayerSession {
|
||||
|
||||
/**
|
||||
* Grab whether the cooldown on Portal use has expired or not.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean getTeleportable() {
|
||||
@ -55,7 +49,7 @@ public class MVPlayerSession {
|
||||
|
||||
/**
|
||||
* Send a Message to the Player as long as enough time has passed since the last message.
|
||||
*
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void message(String msg) {
|
||||
@ -65,35 +59,38 @@ public class MVPlayerSession {
|
||||
this.messageLast = time;
|
||||
}
|
||||
}
|
||||
|
||||
// Commented out bed code, i'll get rid of it soon.
|
||||
// --FF
|
||||
|
||||
// public void setRespawnLocation(Location location) {
|
||||
// this.bedSpawn = location;
|
||||
// }
|
||||
|
||||
public void setRespawnLocation(Location location) {
|
||||
this.bedSpawn = location;
|
||||
}
|
||||
|
||||
// // This one simply spawns the player closer to the bed.
|
||||
// public Location getBedRespawnLocation() {
|
||||
// // There is a bedrespawn set
|
||||
// if (this.bedSpawn != null) {
|
||||
// if (!this.bs.playerCanSpawnHereSafely(this.bedSpawn) || !bedStillExists(this.bedSpawn)) {
|
||||
// this.bedSpawn = null;
|
||||
// return this.bedSpawn;
|
||||
// }
|
||||
// Location actualRespawn = this.bedSpawn;
|
||||
// Location bedRespawn = new Location(actualRespawn.getWorld(), actualRespawn.getX(), actualRespawn.getY(), actualRespawn.getZ());
|
||||
// bedRespawn.setY(bedRespawn.getY() - .25);
|
||||
// return bedRespawn;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private boolean bedStillExists(Location bedSpawn) {
|
||||
// //System.out.print("Dangers:");
|
||||
// //this.bs.showDangers(bedSpawn);
|
||||
// Location locationDown = new Location(bedSpawn.getWorld(), bedSpawn.getX(), bedSpawn.getY(), bedSpawn.getZ());
|
||||
// locationDown.setY(locationDown.getY() - 1);
|
||||
// if (locationDown.getBlock().getType() != Material.BED_BLOCK) {
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// // This one simply spawns the player closer to the bed.
|
||||
// public Location getBedRespawnLocation() {
|
||||
// // There is a bedrespawn set
|
||||
// if (this.bedSpawn != null) {
|
||||
// if (!this.bs.playerCanSpawnHereSafely(this.bedSpawn) || !bedStillExists(this.bedSpawn)) {
|
||||
// this.bedSpawn = null;
|
||||
// return this.bedSpawn;
|
||||
// }
|
||||
// Location actualRespawn = this.bedSpawn;
|
||||
// Location bedRespawn = new Location(actualRespawn.getWorld(), actualRespawn.getX(), actualRespawn.getY(), actualRespawn.getZ());
|
||||
// bedRespawn.setY(bedRespawn.getY() - .25);
|
||||
// return bedRespawn;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private boolean bedStillExists(Location bedSpawn) {
|
||||
// //System.out.print("Dangers:");
|
||||
// //this.bs.showDangers(bedSpawn);
|
||||
// Location locationDown = new Location(bedSpawn.getWorld(), bedSpawn.getX(), bedSpawn.getY(), bedSpawn.getZ());
|
||||
// locationDown.setY(locationDown.getY() - 1);
|
||||
// if (locationDown.getBlock().getType() != Material.BED_BLOCK) {
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ public class MVWorld {
|
||||
}
|
||||
|
||||
public void setPvp(Boolean pvp) {
|
||||
this.fakepvp = this.plugin.configMV.getBoolean("fakepvp", false);
|
||||
this.fakepvp = this.plugin.getConfig().getBoolean("fakepvp", false);
|
||||
if (this.fakepvp) {
|
||||
this.world.setPVP(true);
|
||||
} else {
|
||||
|
@ -50,8 +50,8 @@ public class MultiverseCore extends JavaPlugin {
|
||||
public MVPermissions ph;
|
||||
|
||||
// Configurations
|
||||
public Configuration configMV = null;
|
||||
public Configuration configWorlds = null;
|
||||
private Configuration configMV = null;
|
||||
private Configuration configWorlds = null;
|
||||
|
||||
// Setup the block/player/entity listener.
|
||||
private MVPlayerListener playerListener = new MVPlayerListener(this);;
|
||||
@ -71,6 +71,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
public AllPay banker = new AllPay(this, "[Multiverse-Core] ");
|
||||
public static boolean defaultConfigsCreated = false;
|
||||
protected MVConfigMigrator migrator = new MVConfigMigrator(this);
|
||||
protected int pluginCount;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
@ -80,6 +81,10 @@ public class MultiverseCore extends JavaPlugin {
|
||||
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
|
||||
|
||||
}
|
||||
|
||||
public Configuration getConfig() {
|
||||
return this.configMV;
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
// Output a little snippet to show it's enabled.
|
||||
@ -173,6 +178,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
*/
|
||||
private void registerCommands() {
|
||||
// Intro Commands
|
||||
this.commandHandler.registerCommand(new VersionCommand(this));
|
||||
this.commandHandler.registerCommand(new ListCommand(this));
|
||||
this.commandHandler.registerCommand(new InfoCommand(this));
|
||||
this.commandHandler.registerCommand(new CreateCommand(this));
|
||||
@ -587,8 +593,31 @@ public class MultiverseCore extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void removePlayerSession(Player player) {
|
||||
if(this.playerSessions.containsKey(player.getName())) {
|
||||
if (this.playerSessions.containsKey(player.getName())) {
|
||||
this.playerSessions.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of plugins that have specifically hooked into core.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getPluginCount() {
|
||||
return this.pluginCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the number of plugins that have specifically hooked into core.
|
||||
*/
|
||||
public void incrementPluginCount() {
|
||||
this.pluginCount += 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the number of plugins that have specifically hooked into core.
|
||||
*/
|
||||
public void decrementPluginCount() {
|
||||
this.pluginCount -= 1;
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class InfoCommand extends MultiverseCommand {
|
||||
return page;
|
||||
}
|
||||
|
||||
private ChatColor getChatColor(boolean positive) {
|
||||
protected ChatColor getChatColor(boolean positive) {
|
||||
return positive ? ChatColor.GREEN : ChatColor.RED;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVPlayerSession;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class SleepCommand extends MultiverseCommand {
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class VersionCommand extends MultiverseCommand {
|
||||
|
||||
public VersionCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Multiverse Version");
|
||||
this.setCommandUsage("/mv version");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mv version");
|
||||
this.addKey("mvv");
|
||||
this.addKey("mvversion");
|
||||
this.setPermission("multiverse.core.version", "What version of Multiverse-Core are you on!.", PermissionDefault.TRUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// Check if the command was sent from a Player.
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage("Version info dumped to console. Please check your server logs.");
|
||||
}
|
||||
this.plugin.log(Level.INFO, "Multiverse-Core Version: " + this.plugin.getDescription().getVersion());
|
||||
this.plugin.log(Level.INFO, "Loaded Worlds: " + this.plugin.getMVWorlds().size());
|
||||
this.plugin.log(Level.INFO, "Multiverse Plugins Loaded: " + this.plugin.getPluginCount());
|
||||
this.plugin.log(Level.INFO, "Dumping Config Values: (version " + this.plugin.getConfig().getString("version", "NOT SET") + ")");
|
||||
this.plugin.log(Level.INFO, "messagecooldown: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET"));
|
||||
this.plugin.log(Level.INFO, "teleportcooldown: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET"));
|
||||
this.plugin.log(Level.INFO, "worldnameprefix: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET"));
|
||||
this.plugin.log(Level.INFO, "opfallback: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET"));
|
||||
this.plugin.log(Level.INFO, "disableautoheal: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET"));
|
||||
this.plugin.log(Level.INFO, "fakepvp: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET"));
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class Destination {
|
||||
|
@ -2,14 +2,12 @@ package com.onarandombox.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
|
||||
import com.earth2me.essentials.Mob.Enemies;
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
|
@ -1,10 +1,14 @@
|
||||
# !!!This only applies to worlds being handled by Multiverse!!!
|
||||
# If you don't see it using /mvlist this setting WILL HAVE NO EFFECT
|
||||
|
||||
# How long to leave in between sending a message to the player.
|
||||
# How long to leave in between sending a message to the player. (NOT YET IMPLEMENTED)
|
||||
# In Milliseconds - Default is '5000' which is 5 Seconds.
|
||||
messagecooldown: 5000
|
||||
|
||||
# How fast are people allowed to use /MVTP (NOT YET IMPLEMENTED)
|
||||
# In Milliseconds - Default is '5000' which is 5 Seconds.
|
||||
teleportcooldown: 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
|
||||
@ -26,10 +30,6 @@ disableautoheal: false
|
||||
# Players will be notified when they punch/shoot and it's not allowed.
|
||||
fakepvp: false
|
||||
|
||||
# When this is enabled, users will spawn at their last bed slept at. If the bed is destroyed or obstructed,
|
||||
# they will spawn according to how you have 'notchrespawnstyle' set.
|
||||
bedrespawn: true
|
||||
|
||||
# This just signifies the version number so we can see what version of config you have.
|
||||
# NEVER TOUCH THIS VALUE
|
||||
version: 2.0
|
||||
version: 2.1
|
@ -155,3 +155,11 @@ commands:
|
||||
description: Tells the user all possible world types.
|
||||
usage: |
|
||||
/<command>
|
||||
mvv:
|
||||
description: Prints out version invo.
|
||||
usage: |
|
||||
/<command>
|
||||
mvversion:
|
||||
description: Prints out version invo.
|
||||
usage: |
|
||||
/<command>
|
Loading…
Reference in New Issue
Block a user