minecraft-server 0.0.1.pre.44 → 0.0.1.pre.45
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/minecraft/server/config.rb +20 -2
- data/lib/minecraft/server/logger.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjUzOGMxNGQ3NjU4NjNhN2ZhNWUzN2E0MTQwN2RhZTMzOGY1N2E3YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmNjOTUyYWE3ZGU1NDBmMjcwNjcxNmY3ZTBhYWRjOTU2ZjUzOWQ0Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2JiMmMxMDY2MWJlMmFjZWZkZGRkYjY0NjgzMTY3Yzg4ZTY2MmIwY2E3Yjk0
|
10
|
+
NDg5N2I2NDk2Njg4YzlmOGNlZTViMzBjNjk4YWJiMWU0ZjE2ZTk3NzY0NjAz
|
11
|
+
YWMyMGEyZDRiYTM3YWU3ZGY0OTFkNmEwZGE1MWZmMmUwNTE1MDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmRiYjQxM2E5MzI5N2UzYzRlZmU3M2RiMWIwYWE2NzBlYzc2YWNkZGFjMDli
|
14
|
+
ODg4ODU5NzQzZWU1Yjc5Y2Q2MWFlYTZjMTk1MzNhYmZjOTBmMGY0MDZkOWUy
|
15
|
+
Y2UzMDMzZDg4MWJlMGZlNWRlMzc5YjY1M2JjNmE4NjMyOWEzZGI=
|
@@ -1,8 +1,18 @@
|
|
1
1
|
module Minecraft
|
2
2
|
class Server
|
3
|
+
# DSL with methods defining how the {Minecraft::Server} should run.
|
4
|
+
# Contains methods for APIs and network setting the {Minecraft::Server} should implement.
|
3
5
|
class Config
|
6
|
+
# @!attribute [r] config
|
7
|
+
# The current hash containing the configuration attributes this class is currently working with.
|
8
|
+
# @return [Hash] The configuration attributes
|
4
9
|
attr_reader :config
|
5
10
|
|
11
|
+
# Creates this instance so that the file in question will load against the DSL and load values into the config
|
12
|
+
# hash.
|
13
|
+
# As well, runs each method before the file is fun so that if an attribute is not defined that default value can
|
14
|
+
# loaded into the config hash.
|
15
|
+
# @param file [String, File] the file conforming to the DSL in this class
|
6
16
|
def initialize(file)
|
7
17
|
@config = {}
|
8
18
|
|
@@ -17,7 +27,7 @@ module Minecraft
|
|
17
27
|
self.instance_eval(File.read(file), file)
|
18
28
|
end
|
19
29
|
|
20
|
-
|
30
|
+
# @!group APIs being Implemented by the Server
|
21
31
|
|
22
32
|
# Representation of whether or not this instance of {Minecraft::Server} is compatible with the {Bukkit} API.
|
23
33
|
# @return [Boolean] Whether or not this instance of {Minecraft::Server} is using the {Bukkit} API.
|
@@ -44,7 +54,9 @@ module Minecraft
|
|
44
54
|
@config[:sponge] = boolean
|
45
55
|
end
|
46
56
|
|
47
|
-
|
57
|
+
# @!endgroup
|
58
|
+
|
59
|
+
# @!group Network Settings
|
48
60
|
|
49
61
|
# Representation of the port used for network communication.
|
50
62
|
# @return [Integer] The port used for network communication
|
@@ -56,9 +68,13 @@ module Minecraft
|
|
56
68
|
@config[:max_players] = players
|
57
69
|
end
|
58
70
|
alias_method :player_limit, :max_players
|
71
|
+
|
72
|
+
# #!endgroup
|
59
73
|
end
|
60
74
|
|
75
|
+
# Creates a valid default config file with recommended defaults.
|
61
76
|
class ConfigFile
|
77
|
+
# The default configuration file, each array entry is a separate line of the file.
|
62
78
|
DEFAULT_FILE = [
|
63
79
|
'## APIs being Implemented By Server',
|
64
80
|
'',
|
@@ -73,6 +89,8 @@ module Minecraft
|
|
73
89
|
'max_players 20'
|
74
90
|
]
|
75
91
|
|
92
|
+
# Creates a default configuration file.
|
93
|
+
# @param file [String] the location of the file you wish to file
|
76
94
|
def initialize(file)
|
77
95
|
File.open(file, 'w+') do |f|
|
78
96
|
f.puts DEFAULT_FILE
|
@@ -2,7 +2,17 @@ require 'log4r'
|
|
2
2
|
|
3
3
|
module Minecraft
|
4
4
|
class Server
|
5
|
+
# Instance of Log4R's Logger which sets up a proper logging setup at initialization.
|
6
|
+
# Set's the Logger to log to the Shell session the {Minecraft::Server} is running in.
|
7
|
+
# As well creates and logs to two log files in the `logs` directory, under the current directory the server is running
|
8
|
+
# from.
|
9
|
+
# One log is created simply under the name `latest.log` and is cleared and relogged to at each server start.
|
10
|
+
# Another log file is created with a name based from the date and time the server was started, under the format
|
11
|
+
# `(Year)-(Month)-(Date)--(Hour)-(Minute)-(Second).log`.
|
5
12
|
class Logger < Log4r::Logger
|
13
|
+
# Create an instance of Log4R's Logger which logs to the Shell Session, Latest Log File, and Timed Log File.
|
14
|
+
# @param title [String] Name to be applied to the instance of log, different instance can, and should, have
|
15
|
+
# different names.
|
6
16
|
def initialize(title = 'Minecraft Server')
|
7
17
|
super title
|
8
18
|
self.outputters << Log4r::Outputter.stdout
|