Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2517195
Added a plugin.yml
Diagoras Jan 7, 2013
d2d9161
Fixed error with commands
Diagoras Jan 7, 2013
c635bed
Get player count overall, not per world
Jan 17, 2013
2cf92b7
Merge https://github.com/Diagoras/DynCap
erocs Jan 18, 2013
bc50718
Fix the bug
erocs Jan 18, 2013
b806964
Added a login queue
igotyou May 21, 2013
d26ed17
small bug fix
igotyou May 21, 2013
c8eb35a
Punish people that join too fast
igotyou May 21, 2013
44232a1
Untested fix to not showing the actual player cap
shadowjay1 May 21, 2013
50ca51b
Merge pull request #1 from shadowjay1/master
igotyou May 21, 2013
27a3ac3
Added a config file, with a queue whitelist
igotyou May 21, 2013
1f3ea2f
Fixed a small bug and added a few commands.
igotyou May 21, 2013
a626b0b
Small bug fix
igotyou May 21, 2013
2d614a8
Many small changes here and there. A completetly new command: getqueu…
igotyou May 21, 2013
b574a17
Added a average join time command.
igotyou May 21, 2013
33a936d
Added the permission dyncap.debug.getqueueinfo which alows players to…
igotyou May 24, 2013
f09ff6a
forgot to add orthzar
igotyou May 24, 2013
3d24c2b
Forgot to add permissions to be off by default...
igotyou May 24, 2013
717a848
Fixed permissions, added a try catch statement to the playerJoinEvent…
igotyou May 25, 2013
0ee396b
Merge pull request #1 from igotyou/master
erocs May 26, 2013
156cf8c
maven build script
WildWeazel Jul 2, 2014
7a094f4
Merge pull request #3 from WildWeazel/patch-1
erocs Jul 2, 2014
47b33da
use bukkit repo
WildWeazel Jul 12, 2014
77cc6c4
Merge pull request #4 from WildWeazel/patch-2
erocs Jul 12, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# firstJoin is the message that gets sent to a client, if it tries to connect when the server has a login queue.
# %d is the queue position. Remember to include %d somewhere in the string, but only once, otherwise errors will occur.
#
# toFastJoin is the message that gets sent to a client, if the client joins before minimumjointime has elapsed.
# there is no %d in this strng. Only text.
#
# updateMessage is the message that gets sent to a client, when it connects after having being added to the queue.
# %d is the queue position. Remember to include %d somewhere in the string, but only once, otherwise errors will occur.
#
# BanMessage is the message that gets sent to a client if the client is on the ban list.
# there is no %d in this strng. Only text.
messages:
firstJoin: The server is full, you have been added to the login queue. Your current position is %d. Please try again in no less than 10 seconds, and no more than 60 seconds.
toFastJoin: You rejoined way to quick, you have been moved to the end of the login queue. Next time please join no less than every 10 seconds.
updateMessage: Your position in the queue is %d. Please try again in no less than 10 seconds, and no more than 60 seconds.
banMessage: You are banned. If you believe this is a mistake, message modmail at www.reddit.com/r/civcraft
# all timers are in seconds.
timers:
#
# minimumJoinTime is the amount of time that must at least elapse, before a player tries to rejoin.
# If minimumJoinTime has not elapsed before they rejoin, they get removed from the login queue.
#
minimumJoinTime: 5
#
# timeOutTime is the amount of time that can elapse, since a player last tried to join the server,
# before they are removed from the login queue.
#
timeOutTime: 60
other:
initialDynCap: 175
#
# whiteListedPlayers: a list of players that can join imediatetly, even if there is a login queue.
# Even though case is ignored in the code. Ie would recomend getting the case right.
# Because of config files being weird there needs to be something after the colon.
# However the right side of the colon is never read, so just make it something like the username again.
#
whiteListedPlayers:
ttk2: ttk2
hammond_of_texas: hammond_of_texas
ariehkovler: ariehkovler
spock_bot: spock_bot
orthzar: orthzar
Binary file added dyncap.jar
Binary file not shown.
48 changes: 48 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: DynCap
version: 1.0.1
main: com.untamedears.DynCap.DynCapPlugin
author: Exultant
commands:
setcap:
description: Sets the player cap
usage: /setcap <Max Players>
permission: dyncap.console
getcap:
description: Displays the current player cap
usage: /getcap
permission: dyncap.console
getqueuesize:
description: Displays the current player queue size
usage: /getqueuesize
aliases: gqs
reloadqueue:
description: Reload the config.yml of dyncap
usage: /reloadQueue
permission: dyncap.console
getqueueinfo:
description: Displays information about the supplied queue item.
usage: /getqueueinfo <start index or player name> optional if first paramter is a index <end index>
aliases: gqi
permission: dyncap.debug.getqueueinfo
getjoinaverage:
description: Gets the average amount of time spent in the login queue, before joining.
usage: /getjoinaverage
aliases: gja
permission: dyncap.console
resetjoinaverage:
description: Resets the average amount of time
usage: /resetjoinaverage
aliases: rja
permission: dyncap.console
permissions:
dyncap.console:
description: Console commands for DynCap
default: false
children:
dyncap.debug.getqueueinfo: true
dyncap.debug:
description: Debug commands for DynCap
default: false
dyncap.debug.getqueueinfo:
description: Get queue info command for DynCap
default: false
46 changes: 46 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.untamedears</groupId>
<artifactId>DynCap</artifactId>
<packaging>jar</packaging>
<version>1.0.1-SNAPSHOT</version>
<name>DynCap</name>
<url>https://github.com/erocs/DynCap</url>

<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

<build>
<sourceDirectory>${basedir}/src</sourceDirectory>

<resources>
<resource>
<directory>${basedir}</directory>
<includes>
<include>*.yml</include>
</includes>
</resource>
</resources>
</build>

<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.7.2-R0.3</version>
<scope>provided</scope>
</dependency>
</dependencies>

<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
</repositories>
</project>
144 changes: 141 additions & 3 deletions src/com/untamedears/DynCap/DynCapCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

public class DynCapCommands implements CommandExecutor {
Expand All @@ -19,14 +20,28 @@ public DynCapCommands(DynCapPlugin p, Logger l) {

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
//commands can only be issued from the console

if (label.equalsIgnoreCase("getQueueSize") || label.equalsIgnoreCase("gqs")) {
return getQueueSize(sender);
} else if (label.equalsIgnoreCase("getqueueinfo") || label.equalsIgnoreCase("gqi")) {
return getQueueInfo(sender, args);
}

//commands below here can only be issued from the console
if (sender instanceof Player) {
return false;
}
if (label.equalsIgnoreCase("setcap")) {

if (label.equalsIgnoreCase("setCap")) {
return setcapCmd(args);
} else if (label.equalsIgnoreCase("getcap")) {
} else if (label.equalsIgnoreCase("getCap")) {
return getcapCmd();
} else if (label.equalsIgnoreCase("reloadQueue")) {
return reloadQueueConfig();
} else if (label.equalsIgnoreCase("getjoinaverage") || label.equalsIgnoreCase("gja")) {
return getJoinAverage();
} else if (label.equalsIgnoreCase("resetjoinaverage") || label.equalsIgnoreCase("rja")) {
return resetJoinAverage();
}
return false;
}
Expand Down Expand Up @@ -54,5 +69,128 @@ private boolean getcapCmd() {
log.info(message);
return true;
}

private boolean getQueueSize(CommandSender sender)
{
Integer queueSize = plugin.getQueueSize();
return sendMessage(sender, queueSize + " players are in the queue.");
}

private boolean reloadQueueConfig()
{
plugin.reloadConfig();
plugin.initConfig();
log.info("queue config reloaded");
return true;
}

private boolean getQueueInfo(CommandSender sender, String[] args)
{
if (!sender.hasPermission("dyncap.debug.getqueueinfo"))
{
return false;
}
if (args.length < 1 || args.length > 2) { return false; }

if (args.length == 1)
{
//display info on 1 slot
if (isInteger(args[0]))
{
int startIndex = (Integer.parseInt(args[0]) - 1);
QueueItem queueItem = plugin.getQueueItem(startIndex);
if (queueItem != null)
{
return sendMessage(sender, startIndex + " " + queueItem.getName() + " " + queueItem.getSecondsSinceLastAttempt());
}
else
{
return sendMessage(sender, "Could not find information about index " + args[0]);
}
}
//search by name
else
{
String playerName = args[0];
int index = plugin.getQueuePosition(playerName);
if (index != -1)
{
QueueItem queueItem = plugin.getQueueItem(index);
return sendMessage(sender, index + " " + queueItem.getName() + " " + queueItem.getSecondsSinceLastAttempt() );
}
else
{
return sendMessage(sender, "Could not find " + playerName + " in the queue.");
}
}
}
else if (args.length == 2)
{
if (isInteger(args[0]) && isInteger(args[1]))
{
int startIndex = (Integer.parseInt(args[0]) - 1);
int endIndex = (Integer.parseInt(args[1]) - 1);
for (int x = startIndex; x <= endIndex; x++)
{
QueueItem queueItem = plugin.getQueueItem(x);
if (queueItem != null)
{
sendMessage(sender, x + " " + queueItem.getName() + " " + queueItem.getSecondsSinceLastAttempt() );
}
else
{
sendMessage(sender, "Could not find information about index " + (x + 1));
}
}
return true;
}
else
{
sendMessage(sender, "Please enter two integers above 0");
}
}
return false;
}

private static boolean isInteger(String s) {
try {
Integer.parseInt(s);
} catch(NumberFormatException e) {
return false;
}
// only got here if we didn't return false
return true;
}


private boolean resetJoinAverage()
{
plugin.resetAverageTimeToJoin();
log.info("Average join time has been reset!");
return true;
}

private boolean getJoinAverage()
{
float average = plugin.getAverageTimeToJoin();
log.info("Average join time is " + average + " seconds.");
return true;
}

private boolean sendMessage(CommandSender sender, String string)
{
if (sender instanceof Player)
{
Player player = (Player) sender;
player.sendMessage(string);
return true;
}
else if (sender instanceof ConsoleCommandSender)
{
log.info(string);
return true;
}
return false;
}

}
Loading