mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-25 16:51:50 +01:00
bug fixes
This commit is contained in:
parent
27e2a6c8c9
commit
c2de3bfcfa
Binary file not shown.
@ -57,8 +57,7 @@ public class Citizens extends JavaPlugin {
|
||||
private CommandManager cmdManager;
|
||||
private Settings config;
|
||||
private Storage saves;
|
||||
private final boolean compatible = ((CraftServer) getServer()).getServer().getVersion()
|
||||
.startsWith(COMPATIBLE_MC_VERSION);
|
||||
private boolean compatible;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String cmdName, String[] args) {
|
||||
@ -133,6 +132,7 @@ public class Citizens extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Disable if the server is not using the compatible Minecraft version
|
||||
compatible = ((CraftServer) getServer()).getServer().getVersion().startsWith(COMPATIBLE_MC_VERSION);
|
||||
String mcVersion = ((CraftServer) getServer()).getServer().getVersion();
|
||||
if (!compatible) {
|
||||
Messaging.log(Level.SEVERE, "v" + getDescription().getVersion() + " is not compatible with Minecraft v"
|
||||
@ -146,11 +146,10 @@ public class Citizens extends JavaPlugin {
|
||||
config.load();
|
||||
|
||||
// NPC storage
|
||||
if (Setting.USE_DATABASE.asBoolean()) {
|
||||
if (Setting.USE_DATABASE.asBoolean())
|
||||
saves = new DatabaseStorage();
|
||||
} else {
|
||||
else
|
||||
saves = new YamlStorage(getDataFolder() + File.separator + "saves.yml");
|
||||
}
|
||||
|
||||
// Register API managers
|
||||
npcManager = new CitizensNPCManager(saves);
|
||||
@ -206,7 +205,7 @@ public class Citizens extends JavaPlugin {
|
||||
if (npc.isSpawned())
|
||||
++spawned;
|
||||
}
|
||||
Messaging.log("Loaded " + created + " NPCs (" + spawned + " spawned)");
|
||||
Messaging.log("Loaded " + created + " NPCs (" + spawned + " spawned).");
|
||||
}
|
||||
|
||||
private void registerPermissions() {
|
||||
|
@ -19,9 +19,8 @@ public class Settings {
|
||||
if (!root.keyExists(setting.path)) {
|
||||
Messaging.log("Writing default setting: '" + setting.path + "'");
|
||||
root.setRaw(setting.path, setting.get());
|
||||
} else {
|
||||
} else
|
||||
setting.set(root.getRaw(setting.path));
|
||||
}
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ public class NPCCommands {
|
||||
max = 1)
|
||||
@Permission("npc.despawn")
|
||||
public void despawnNPC(CommandContext args, Player player, NPC npc) {
|
||||
npc.getTrait(Spawned.class).setSpawned(false);
|
||||
npc.despawn();
|
||||
Messaging.send(player, ChatColor.GREEN + "You despawned " + StringHelper.wrap(npc.getName()) + ".");
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ public class CitizensNPC extends AbstractNPC {
|
||||
|
||||
manager.despawn(this);
|
||||
mcEntity = null;
|
||||
getTrait(Spawned.class).setSpawned(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -82,17 +81,16 @@ public class CitizensNPC extends AbstractNPC {
|
||||
// Set the location
|
||||
// TODO: do this automatically (default traits?)
|
||||
// TODO: is spawned as a trait needed? Takes up memory
|
||||
if (!hasTrait(SpawnLocation.class)) {
|
||||
if (!hasTrait(SpawnLocation.class))
|
||||
addTrait(new SpawnLocation(loc));
|
||||
} else {
|
||||
else
|
||||
getTrait(SpawnLocation.class).setLocation(loc);
|
||||
}
|
||||
|
||||
if (!hasTrait(Spawned.class)) {
|
||||
if (!hasTrait(Spawned.class))
|
||||
addTrait(new Spawned(true));
|
||||
} else {
|
||||
else
|
||||
getTrait(Spawned.class).setSpawned(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -12,12 +12,11 @@ import net.citizensnpcs.api.npc.trait.trait.SpawnLocation;
|
||||
import net.citizensnpcs.resource.lib.CraftNPC;
|
||||
import net.citizensnpcs.storage.Storage;
|
||||
import net.citizensnpcs.util.ByIdArray;
|
||||
import net.citizensnpcs.util.Messaging;
|
||||
|
||||
import net.minecraft.server.ItemInWorldManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.WorldServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
@ -75,7 +74,6 @@ public class CitizensNPCManager implements NPCManager {
|
||||
|
||||
@Override
|
||||
public NPC getNPC(Entity entity) {
|
||||
Messaging.log("Version: " + getMinecraftServer(Bukkit.getServer()).getVersion());
|
||||
for (NPC npc : npcs)
|
||||
if (npc.isSpawned() && npc.getBukkitEntity().getEntityId() == entity.getEntityId())
|
||||
return npc;
|
||||
|
@ -27,9 +27,8 @@ public class Messaging {
|
||||
public static void send(Player player, Object msg) {
|
||||
String send = msg.toString();
|
||||
|
||||
for (ChatColor color : ChatColor.values()) {
|
||||
for (ChatColor color : ChatColor.values())
|
||||
send = send.replace("<" + color.getChar() + ">", color.toString());
|
||||
}
|
||||
|
||||
player.sendMessage(send);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user