mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-18 00:20:44 +00:00
Changed a lot. Forgot to keep track of most of them. However I've
fixed the bug causing the default Bukkit commands to be overridden.
This commit is contained in:
@@ -2,6 +2,6 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Jos/Minecraft/Plugins/API's/bukkit-1.1-R6.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Jos/Minecraft/Plugins/API's/bukkit-1.2.4-R0.1-20120323.055539-8.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
23
plugins/randomspawn-paper/Random Spawn/Random Spawn.jardesc
Normal file
23
plugins/randomspawn-paper/Random Spawn/Random Spawn.jardesc
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="E:/Coconut Juice/plugins/RandomSpawn-1.8.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/Random Spawn/Random Spawn.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||
<selectedProjects/>
|
||||
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
|
||||
<sealing sealJar="false">
|
||||
<packagesToSeal/>
|
||||
<packagesToUnSeal/>
|
||||
</sealing>
|
||||
</manifest>
|
||||
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
|
||||
<file path="/Random Spawn/.classpath"/>
|
||||
<file path="/Random Spawn/spawnLocations.yml"/>
|
||||
<file path="/Random Spawn/config.yml"/>
|
||||
<file path="/Random Spawn/.gitignore"/>
|
||||
<file path="/Random Spawn/worlds.yml"/>
|
||||
<file path="/Random Spawn/plugin.yml"/>
|
||||
<javaElement handleIdentifier="=Random Spawn/src"/>
|
||||
<file path="/Random Spawn/.project"/>
|
||||
</selectedElements>
|
||||
</jardesc>
|
||||
@@ -5,76 +5,62 @@ author: Josvth
|
||||
commands:
|
||||
randomspawn:
|
||||
description: The main command.
|
||||
usage: Incorrect usage! Try /rs help
|
||||
usage: Command not found! Try /rs help
|
||||
aliases: rs
|
||||
help:
|
||||
rs help:
|
||||
description: Shows a list with all the commands.
|
||||
usage: /rs help [1/2/3]
|
||||
permission: RandomSpawn.help
|
||||
prefix: randomspawn
|
||||
reload:
|
||||
rs reload:
|
||||
description: Reloads the Random Spawn config files.
|
||||
usage: /rs reload [config/worlds/spawnlocations]
|
||||
permission: RandomSpawn.reload
|
||||
prefix: randomspawn
|
||||
info:
|
||||
rs info:
|
||||
description: Shows the Random Spawn settings for this world.
|
||||
usage: /rs info
|
||||
permission: RandomSpawn.info
|
||||
prefix: randomspawn
|
||||
enable:
|
||||
rs enable:
|
||||
description: Enables Random Spawn in this world.
|
||||
usage: /rs enable
|
||||
permission: RandomSpawn.configure
|
||||
prefix: randomspawn
|
||||
disable:
|
||||
rs disable:
|
||||
description: Disables Random Spawn in this world.
|
||||
usage: /rs disable
|
||||
permission: RandomSpawn.configure
|
||||
prefix: randomspawn
|
||||
|
||||
setarea:
|
||||
rs setarea:
|
||||
description: Sets the Random Spawn area.
|
||||
usage: /rs setarea [square/circle] <radius> or /rs setarea <xrange> <zrange> or /rs setarea <xmin> <xmax> <zmin> <zmax>
|
||||
permission: RandomSpawn.configure
|
||||
prefix: randomspawn
|
||||
usebeds:
|
||||
rs usebeds:
|
||||
description: Toggles using beds.
|
||||
usage: /rs usebeds [true/false]
|
||||
permission: RandomSpawn.configure
|
||||
prefix: randomspawn
|
||||
keepfirstspawns:
|
||||
rs keepfirstspawns:
|
||||
description: Toggles spawn saving.
|
||||
usage: /rs keepfirstspawns [true/false]
|
||||
aliases: kfs
|
||||
permission: RandomSpawn.configure
|
||||
prefix: randomspawn
|
||||
firstjoin:
|
||||
rs firstjoin:
|
||||
description: Toggles randomspawning on first join.
|
||||
usage: /rs firstjoin [true/false]
|
||||
aliases: fj
|
||||
permission: RandomSpawn.configure
|
||||
prefix: randomspawn
|
||||
|
||||
setfirstspawn:
|
||||
rs setfirstspawn:
|
||||
description: Sets the first spawn location for this world.
|
||||
usage: /rs setfirstspawn
|
||||
aliases: sfs
|
||||
permission: RandomSpawn.setfirstspawn
|
||||
prefix: randomspawn
|
||||
tpfirstspawn:
|
||||
rs tpfirstspawn:
|
||||
description: Teleports you to the first spawn location of this world.
|
||||
usage: /rs tpfirstspawn
|
||||
aliases: tfs
|
||||
permission: RandomSpawn.tpfirstspawn
|
||||
prefix: randomspawn
|
||||
unsetfirstspawn:
|
||||
rs unsetfirstspawn:
|
||||
description: Unsets the first spawn location for this world.
|
||||
usage: /rs unsetfirstspawn
|
||||
aliases: unsfs
|
||||
permission: RandomSpawn.setfirstspawn
|
||||
prefix: randomspawn
|
||||
|
||||
|
||||
permissions:
|
||||
RandomSpawn.*:
|
||||
description: Gives access to all Random Spawn commands.
|
||||
|
||||
@@ -6,23 +6,21 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
public class RandomSpawnDeathListener implements Listener {
|
||||
|
||||
RandomSpawn plugin;
|
||||
|
||||
public RandomSpawnDeathListener(RandomSpawn instance){
|
||||
|
||||
public class RandomSpawnDebugListener implements Listener {
|
||||
private RandomSpawn plugin;
|
||||
|
||||
public RandomSpawnDebugListener(RandomSpawn instance) {
|
||||
plugin = instance;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, this.plugin);
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(EntityDeathEvent event){
|
||||
if(event.getEntity() instanceof Player){
|
||||
Player player = (Player) event.getEntity();
|
||||
Player player = (Player)event.getEntity();
|
||||
plugin.logDebug(player.getName() + " died from " + player.getLastDamageCause().getCause().name());
|
||||
plugin.logDebug(player.getName() + " Falldistance: " + player.getFallDistance() + " Velocity: " + player.getVelocity() + " No damage tickes: " + player.getNoDamageTicks() + " Location: " + player.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class RandomSpawnJoinListener implements Listener {
|
||||
World world = player.getWorld();
|
||||
String worldName = world.getName();
|
||||
|
||||
File file = new File(world.getWorldFolder() + "/players/" + player.getName() + ".dat");
|
||||
File file = new File(world.getWorldFolder() + File.separator + "players" + File.separator + player.getName() + ".dat");
|
||||
|
||||
if(file.exists()){ return; } // checks if its not the first join of a player
|
||||
|
||||
|
||||
@@ -14,12 +14,13 @@ public class RandomSpawnRespawnListener implements Listener {
|
||||
private RandomSpawn plugin;
|
||||
|
||||
public RandomSpawnRespawnListener(RandomSpawn instance){
|
||||
this.plugin = instance;
|
||||
this.plugin.getServer().getPluginManager().registerEvents(this, this.plugin);
|
||||
plugin = instance;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event){
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String playerName = player.getName();
|
||||
|
||||
@@ -28,17 +29,17 @@ public class RandomSpawnRespawnListener implements Listener {
|
||||
|
||||
Location deathLocation = player.getLocation();
|
||||
|
||||
if (player.hasPermission("RandomSpawn.exclude")){ // checks if player should be excluded
|
||||
if (player.hasPermission("RandomSpawn.exclude")){ // checks if player should be excluded
|
||||
this.plugin.logDebug(playerName + " is excluded from Random Spawning.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.isBedSpawn() && this.plugin.getYamlHandler().worlds.getBoolean(worldName + ".usebeds", true)){
|
||||
if (event.isBedSpawn() && this.plugin.getYamlHandler().worlds.getBoolean(worldName + ".usebeds", true)){ // checks if player should be spawned at his bed
|
||||
this.plugin.logDebug(playerName + " is spawned at his bed!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.plugin.getYamlHandler().worlds.getBoolean(worldName + ".keeprandomspawns", false)){ // checks if player should be spawned at a saved spawn
|
||||
if (this.plugin.getYamlHandler().worlds.getBoolean(worldName + ".keeprandomspawns", false)){ // checks if player should be spawned at a saved spawn
|
||||
Location savedSpawn = getPlayerSpawn(player, world);
|
||||
if (savedSpawn != null){
|
||||
event.setRespawnLocation(savedSpawn);
|
||||
@@ -54,6 +55,7 @@ public class RandomSpawnRespawnListener implements Listener {
|
||||
this.plugin.logDebug(playerName + " is teleported somewhere in the sky.");
|
||||
|
||||
plugin.randomSpawnPlayer(player, world);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
package me.Josvth.RandomSpawn;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import me.Josvth.RandomSpawn.Listeners.*;
|
||||
|
||||
public class RandomSpawn extends JavaPlugin{
|
||||
|
||||
protected RandomSpawnLogger logger;
|
||||
RandomSpawnYamlHandler yamlHandler;
|
||||
|
||||
Logger logger;
|
||||
|
||||
private RandomSpawnYamlHandler yamlHandler;
|
||||
RandomSpawnCommandHandler commandHandler;
|
||||
|
||||
RandomSpawnRespawnListener respawnListener;
|
||||
RandomSpawnJoinListener joinListener;
|
||||
RandomSpawnDeathListener deathListener;
|
||||
RandomSpawnSignListener signListener;
|
||||
RandomSpawnDebugListener debugListener;
|
||||
|
||||
public HashMap<Player,RandomSpawnSpawner> tasks = new HashMap<Player,RandomSpawnSpawner>();
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
for(RandomSpawnSpawner spawner : tasks.values()){
|
||||
@@ -32,47 +35,48 @@ public class RandomSpawn extends JavaPlugin{
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
//setup handlers
|
||||
this.logger = new RandomSpawnLogger(this);
|
||||
logger = Logger.getLogger("Minecraft");
|
||||
|
||||
this.yamlHandler = new RandomSpawnYamlHandler(this);
|
||||
//setup handlers
|
||||
yamlHandler = new RandomSpawnYamlHandler(this);
|
||||
logDebug("Yamls loaded!");
|
||||
|
||||
this.commandHandler = new RandomSpawnCommandHandler(this);
|
||||
commandHandler = new RandomSpawnCommandHandler(this);
|
||||
logDebug("Commands registered!");
|
||||
|
||||
//setup listeners
|
||||
this.respawnListener = new RandomSpawnRespawnListener(this);
|
||||
this.joinListener = new RandomSpawnJoinListener(this);
|
||||
this.deathListener = new RandomSpawnDeathListener(this);
|
||||
this.signListener = new RandomSpawnSignListener(this);
|
||||
respawnListener = new RandomSpawnRespawnListener(this);
|
||||
joinListener = new RandomSpawnJoinListener(this);
|
||||
signListener = new RandomSpawnSignListener(this);
|
||||
|
||||
if(getYamlHandler().config.getBoolean("debug",false)){
|
||||
debugListener = new RandomSpawnDebugListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void playerInfo(Player player, String message){
|
||||
this.logger.playerInfo(player, message);
|
||||
}
|
||||
|
||||
|
||||
public void logInfo(String message){
|
||||
this.logger.info(message);
|
||||
logger.info("[Random Spawn] " + message);
|
||||
}
|
||||
|
||||
public void logDebug(String message){
|
||||
if (yamlHandler.config.getBoolean("debug",false)) {
|
||||
this.logger.debug(message);
|
||||
}
|
||||
if (yamlHandler.config.getBoolean("debug",false)) { logger.info("[Random Spawn] (DEBUG) " + message); }
|
||||
}
|
||||
|
||||
public void logWarning(String message){
|
||||
this.logger.warn(message);
|
||||
public void playerInfo(Player player, String message){
|
||||
player.sendMessage(ChatColor.AQUA + "[RandomSpawn] " + ChatColor.RESET + message);
|
||||
}
|
||||
|
||||
|
||||
public RandomSpawnYamlHandler getYamlHandler(){
|
||||
return yamlHandler;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasValidEnviroment(World world){
|
||||
return world.getEnvironment() != Environment.NETHER;
|
||||
}
|
||||
|
||||
public void randomSpawnPlayer(Player player, World spawnWorld) {
|
||||
RandomSpawnSpawner spawner = new RandomSpawnSpawner(this, player, spawnWorld);
|
||||
spawner.setTaskId(this.getServer().getScheduler().scheduleSyncRepeatingTask(this, spawner, 0, this.yamlHandler.config.getInt("generator.interval",4)));
|
||||
spawner.setTaskId(getServer().getScheduler().scheduleSyncRepeatingTask(this, spawner, 0, yamlHandler.config.getInt("generator.interval",4)));
|
||||
player.setMaximumNoDamageTicks(12000);
|
||||
player.setNoDamageTicks(12000);
|
||||
player.sendMessage(yamlHandler.config.getString("messages.pleasewait", "Please wait while your spawn is being loaded."));
|
||||
|
||||
@@ -4,25 +4,29 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public abstract class RandomSpawnCommandExecutor {
|
||||
|
||||
protected RandomSpawn plugin;
|
||||
protected String name;
|
||||
|
||||
public void setPlugin(RandomSpawn instance) {
|
||||
this.plugin = instance;
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
public abstract boolean onCommand(CommandSender sender, List<String> args);
|
||||
|
||||
public boolean onConsoleCommand(CommandSender sender, List<String> args){
|
||||
return onCommand(sender,args);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
try {
|
||||
return plugin.getCommand(name).getDescription();
|
||||
return plugin.getCommand("rs " + name).getDescription();
|
||||
} catch (NullPointerException e){
|
||||
return null;
|
||||
}
|
||||
@@ -30,15 +34,23 @@ public abstract class RandomSpawnCommandExecutor {
|
||||
|
||||
public String getUsage() {
|
||||
try {
|
||||
return plugin.getCommand(name).getUsage();
|
||||
return plugin.getCommand("rs " + name).getUsage();
|
||||
} catch (NullPointerException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getPermission() {
|
||||
try {
|
||||
return plugin.getCommand("rs " + name).getPermission();
|
||||
} catch (NullPointerException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
try {
|
||||
return plugin.getCommand(name).getAliases();
|
||||
return plugin.getCommand("rs " + name).getAliases();
|
||||
} catch (NullPointerException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ public class RandomSpawnCommandHandler implements CommandExecutor{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,7 +51,11 @@ public class RandomSpawnCommandHandler implements CommandExecutor{
|
||||
sender.sendMessage("This command can only be used in game!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!sender.hasPermission(commandExecutor.getPermission())){
|
||||
sender.sendMessage("You don't have the permission to use this command!");
|
||||
}
|
||||
|
||||
if (commandExecutor.onCommand(sender, Arrays.asList(args).subList(1, args.length)) == false){
|
||||
sender.sendMessage(commandExecutor.getUsage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user