переход на groovy конфигурацию
This commit is contained in:
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
Загрузчик "ванильных" (vanilla, ["Anvil"](https://minecraft.gamepedia.com/Anvil_file_format)) карт Minecraft.
|
Загрузчик "ванильных" (vanilla, ["Anvil"](https://minecraft.gamepedia.com/Anvil_file_format)) карт Minecraft.
|
||||||
|
|
||||||
Пример настройки можно посмотреть в файле `sample-config.xml`
|
Пример настройки можно посмотреть в файле [`sample-config.groovy`](./sample-config.groovy)
|
||||||
|
|||||||
18
anvil-loader/sample-config.groovy
Normal file
18
anvil-loader/sample-config.groovy
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
beans {
|
||||||
|
xmlns([context:'http://www.springframework.org/schema/context'])
|
||||||
|
context.'annotation-config'()
|
||||||
|
|
||||||
|
spawnLocation(mc.core.EntityLocation) { bean ->
|
||||||
|
bean.constructorArgs = [ 8d/*X*/, 64d/*Y*/, 8d/*Z*/, 0f/*Yaw*/, 0f/*Pitch*/ ]
|
||||||
|
}
|
||||||
|
|
||||||
|
anvilChunkProvider(mc.world.anvil.AnvilChunkProvider) { bean ->
|
||||||
|
bean.constructorArgs = [ "path/to/minecraft/maps/New world" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
/* В качестве хранилища, используется модуль Simple world */
|
||||||
|
simpleWorld(mc.world.simple.SimpleWorld) {
|
||||||
|
spawn = spawnLocation
|
||||||
|
chunkProvider = anvilChunkProvider
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
|
|
||||||
http://www.springframework.org/schema/context
|
|
||||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
|
||||||
<context:annotation-config />
|
|
||||||
|
|
||||||
<bean id="spawnLocation" class="mc.core.EntityLocation">
|
|
||||||
<constructor-arg index="0" type="double" value="8"/>
|
|
||||||
<constructor-arg index="1" type="double" value="64"/>
|
|
||||||
<constructor-arg index="2" type="double" value="8"/>
|
|
||||||
<constructor-arg index="3" type="float" value="0"/>
|
|
||||||
<constructor-arg index="4" type="float" value="0"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- В качестве хранилища, используется модуль Simple world -->
|
|
||||||
<bean id="simpleWorld" class="mc.world.simple.SimpleWorld">
|
|
||||||
<property name="spawn" ref="spawnLocation"/>
|
|
||||||
<property name="chunkProvider">
|
|
||||||
<bean class="mc.world.anvil.AnvilChunkProvider">
|
|
||||||
<constructor-arg index="0" type="java.lang.String" value="path/to/minecraft/maps/New world"/>
|
|
||||||
</bean>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</beans>
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Ядро сервера.
|
Ядро сервера.
|
||||||
|
|
||||||
Пример настройки можно посмотреть в файле `sample-config.xml`.
|
Пример настройки можно посмотреть в файле [`sample-config.groovy`](./sample-config.groovy).
|
||||||
|
|
||||||
## Spring beans
|
## Spring beans
|
||||||
|
|
||||||
@@ -14,8 +14,10 @@
|
|||||||
|
|
||||||
**Bean example:**
|
**Bean example:**
|
||||||
|
|
||||||
```xml
|
```groovy
|
||||||
<bean class="mc.core.CoreEventListener"/>
|
beans {
|
||||||
|
coreEventListener(mc.core.CoreEventListener)
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### ConfigFromSpring
|
#### ConfigFromSpring
|
||||||
@@ -31,12 +33,14 @@
|
|||||||
|
|
||||||
**Bean example:**
|
**Bean example:**
|
||||||
|
|
||||||
```xml
|
```groovy
|
||||||
<bean id="config" class="mc.core.embedded.ConfigFromSpring">
|
beans {
|
||||||
<property name="descriptionServer" value="MC Core"/>
|
config(mc.core.embedded.ConfigFromSpring) {
|
||||||
<property name="maxPlayers" value="100"/>
|
descriptionServer = 'MC Core - LIMBO'
|
||||||
<property name="favicon" value="icon.png"/>
|
maxPlayers = 1
|
||||||
</bean>
|
favicon = 'icon.png'
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### GameLoop
|
#### GameLoop
|
||||||
@@ -47,11 +51,13 @@
|
|||||||
* `gameTimer` - бин, управляющий ходом времени
|
* `gameTimer` - бин, управляющий ходом времени
|
||||||
* `percentWarnLowTps` - порог "низкого" значения TPS, в процентах
|
* `percentWarnLowTps` - порог "низкого" значения TPS, в процентах
|
||||||
|
|
||||||
```xml
|
```groovy
|
||||||
<bean id="gameLoop" class="mc.core.GameLoop">
|
beans {
|
||||||
<property name="gameTimer" ref="timeProcessor"/>
|
gameLoop(mc.core.GameLoop) {
|
||||||
<property name="percentWarnLowTps" value="15"/>
|
gameTimer = ref('timeProcessor')
|
||||||
</bean>
|
percentWarnLowTps = 15
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### SimpleChatProcessor
|
#### SimpleChatProcessor
|
||||||
@@ -62,8 +68,10 @@
|
|||||||
|
|
||||||
**Bean example:**
|
**Bean example:**
|
||||||
|
|
||||||
```xml
|
```groovy
|
||||||
<bean id="chatProcessor" class="mc.core.chat.SimpleChatProcessor" />
|
beans {
|
||||||
|
chatProcessor(mc.core.chat.SimpleChatProcessor)
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Время
|
### Время
|
||||||
@@ -79,10 +87,12 @@
|
|||||||
|
|
||||||
**Bean example:**
|
**Bean example:**
|
||||||
|
|
||||||
```xml
|
```groovy
|
||||||
<bean id="idleTime" class="mc.core.time.IdleTime">
|
beans {
|
||||||
<property name="gameTime" value="1000"/>
|
timeProcessor(mc.core.time.IdleTime) {
|
||||||
</bean>
|
gameTime = 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### TimePerTick
|
#### TimePerTick
|
||||||
@@ -96,10 +106,12 @@
|
|||||||
|
|
||||||
**Bean example:**
|
**Bean example:**
|
||||||
|
|
||||||
```xml
|
```groovy
|
||||||
<bean id="timePerTick" class="mc.core.time.TimePerTick">
|
beans {
|
||||||
<property name="startGameTime" value="1000"/>
|
timeProcessor(mc.core.time.TimePerTick) {
|
||||||
</bean>
|
startGameTime = 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### RealTime
|
#### RealTime
|
||||||
@@ -110,6 +122,8 @@
|
|||||||
|
|
||||||
**Bean example:**
|
**Bean example:**
|
||||||
|
|
||||||
```xml
|
```groovy
|
||||||
<bean id="realTime" class="mc.core.time.RealTime"/>
|
beans {
|
||||||
|
timeProcessor(mc.core.time.RealTime)
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
version '0.2'
|
version '0.2.1'
|
||||||
|
|
||||||
apply plugin: 'maven'
|
|
||||||
apply plugin: 'application'
|
apply plugin: 'application'
|
||||||
|
|
||||||
mainClassName = "mc.core.Main"
|
mainClassName = 'mc.core.Main'
|
||||||
|
|
||||||
|
ext {
|
||||||
|
groovy_version = '2.5.6'
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
/* Spring Groovy Bean Configuration */
|
||||||
|
compile (group: 'org.codehaus.groovy', name: 'groovy', version: groovy_version)
|
||||||
|
compile (group: 'org.codehaus.groovy', name: 'groovy-xml', version: groovy_version)
|
||||||
|
|
||||||
/* Components */
|
/* Components */
|
||||||
compile (group: 'commons-io', name: 'commons-io', version: '2.6')
|
compile (group: 'commons-io', name: 'commons-io', version: '2.6')
|
||||||
compile (group: 'com.google.guava', name: 'guava', version: '26.0-jre')
|
compile (group: 'com.google.guava', name: 'guava', version: '26.0-jre')
|
||||||
/* Named Binary Tags */
|
|
||||||
|
/* NBT, Named Binary Tags */
|
||||||
compile (group: 'com.flowpowered', name: 'flow-nbt', version: '1.0.1-SNAPSHOT')
|
compile (group: 'com.flowpowered', name: 'flow-nbt', version: '1.0.1-SNAPSHOT')
|
||||||
}
|
}
|
||||||
|
|||||||
26
core/sample-config.groovy
Normal file
26
core/sample-config.groovy
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
beans {
|
||||||
|
xmlns([context:'http://www.springframework.org/schema/context'])
|
||||||
|
context.'annotation-config'()
|
||||||
|
|
||||||
|
config(mc.core.embedded.ConfigFromSpring) {
|
||||||
|
descriptionServer = 'MC Core - LIMBO'
|
||||||
|
maxPlayers = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
playerManager(mc.core.embedded.FakePlayerManager)
|
||||||
|
|
||||||
|
timer(mc.core.time.IdleTime) {
|
||||||
|
gameTime = 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
coreEventListener(mc.core.CoreEventListener)
|
||||||
|
|
||||||
|
gameLoop(mc.core.GameLoop) {
|
||||||
|
gameTimer = timer
|
||||||
|
percentWarnLowTps = 15
|
||||||
|
}
|
||||||
|
|
||||||
|
chatProcessor(mc.core.chat.SimpleChatProcessor)
|
||||||
|
|
||||||
|
server(mc.core.embedded.FakeServer)
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
|
||||||
http://www.springframework.org/schema/context
|
|
||||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
|
||||||
<context:annotation-config />
|
|
||||||
|
|
||||||
<bean id="config" class="mc.core.embedded.ConfigFromSpring">
|
|
||||||
<property name="descriptionServer" value="MC Core - LIMBO"/>
|
|
||||||
<property name="maxPlayers" value="1"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="timer" class="mc.core.time.IdleTime">
|
|
||||||
<property name="gameTime" value="1000"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean class="mc.core.CoreEventListener"/>
|
|
||||||
|
|
||||||
<bean id="gameLoop" class="mc.core.GameLoop">
|
|
||||||
<property name="gameTimer" ref="timer"/>
|
|
||||||
<property name="percentWarnLowTps" value="15"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="chatProcessor" class="mc.core.chat.SimpleChatProcessor" />
|
|
||||||
</beans>
|
|
||||||
@@ -5,7 +5,7 @@ import mc.core.network.Server;
|
|||||||
import mc.core.network.StartServerException;
|
import mc.core.network.StartServerException;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
import org.springframework.context.support.GenericGroovyApplicationContext;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -15,19 +15,20 @@ import java.nio.file.Paths;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class Main {
|
public class Main {
|
||||||
private static ApplicationContext createContext() {
|
private static ApplicationContext createContext() {
|
||||||
final String springXml = System.getProperty("springConfig", "./spring.xml");
|
final String defautlSpringConfig = "spring.groovy";
|
||||||
|
final String springConfig = System.getProperty("springConfig", "./" + defautlSpringConfig);
|
||||||
|
|
||||||
if (!Files.exists(Paths.get(springXml))) {
|
if (!Files.exists(Paths.get(springConfig))) {
|
||||||
log.info("File \"{}\" not found. Get default config.", springXml);
|
log.info("File \"{}\" not found. Get default config.", springConfig);
|
||||||
try (FileOutputStream fos = new FileOutputStream(springXml)) {
|
try (FileOutputStream fos = new FileOutputStream(springConfig)) {
|
||||||
IOUtils.copy(Main.class.getResourceAsStream("/spring.xml"), fos);
|
IOUtils.copy(Main.class.getResourceAsStream("/" + defautlSpringConfig), fos);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Get default spring config", e);
|
log.error("Get default spring config", e);
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FileSystemXmlApplicationContext(springXml);
|
return new GenericGroovyApplicationContext("file:" + springConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
14
core/src/main/resources/spring.groovy
Normal file
14
core/src/main/resources/spring.groovy
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
beans {
|
||||||
|
xmlns([context:'http://www.springframework.org/schema/context'])
|
||||||
|
context.'annotation-config'()
|
||||||
|
|
||||||
|
playerManager(mc.core.embedded.FakePlayerManager)
|
||||||
|
|
||||||
|
timer(mc.core.time.TimePerTick)
|
||||||
|
|
||||||
|
gameLoop(mc.core.GameLoop) {
|
||||||
|
gameTimer = timer
|
||||||
|
}
|
||||||
|
|
||||||
|
server(mc.core.embedded.FakeServer)
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
|
||||||
http://www.springframework.org/schema/context
|
|
||||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
|
||||||
<context:annotation-config />
|
|
||||||
|
|
||||||
<bean id="playerManager" class="mc.core.embedded.FakePlayerManager"/>
|
|
||||||
|
|
||||||
<bean id="gameLoop" class="mc.core.GameLoop">
|
|
||||||
<property name="gameTimer">
|
|
||||||
<bean class="mc.core.time.TimePerTick"/>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="server" class="mc.core.embedded.FakeServer"/>
|
|
||||||
</beans>
|
|
||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
Хранилище данных игроков на базе [H2 Database](http://www.h2database.com/).
|
Хранилище данных игроков на базе [H2 Database](http://www.h2database.com/).
|
||||||
|
|
||||||
Пример настройки можно посмотреть в файле `sample-config.xml`
|
Пример настройки можно посмотреть в файле [`sample-config.groovy`](./sample-config.groovy)
|
||||||
|
|||||||
31
h2_playermanager/sample-config.groovy
Normal file
31
h2_playermanager/sample-config.groovy
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
def hibernateProps = new Properties()
|
||||||
|
hibernateProps.put('hibernate.dialect', 'org.hibernate.dialect.H2Dialect')
|
||||||
|
hibernateProps.put('hibernate.show_sql', false)
|
||||||
|
hibernateProps.put('hibernate.hbm2ddl.auto', 'update')
|
||||||
|
|
||||||
|
beans {
|
||||||
|
xmlns([context: 'http://www.springframework.org/schema/context'])
|
||||||
|
context.'annotation-config'()
|
||||||
|
context.'component-scan'('base-package': 'mc.core.h2db')
|
||||||
|
|
||||||
|
xmlns([jpa: 'http://www.springframework.org/schema/data/jpa'])
|
||||||
|
jpa.'repositories'('base-package': 'mc.core.h2db.repository')
|
||||||
|
|
||||||
|
dataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) {
|
||||||
|
driverClassName = 'org.h2.Driver'
|
||||||
|
url = 'jdbc:h2:mem:test;DB_CLOSE_DELAY=-1'
|
||||||
|
username = 'sa'
|
||||||
|
password = 's3cReT'
|
||||||
|
}
|
||||||
|
|
||||||
|
entityManagerFactory(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) {
|
||||||
|
dataSource = ref('dataSource')
|
||||||
|
persistenceProviderClass = 'org.hibernate.jpa.HibernatePersistenceProvider'
|
||||||
|
packagesToScan = 'mc.core.h2db.entity'
|
||||||
|
jpaProperties = hibernateProps
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionManager(org.springframework.orm.jpa.JpaTransactionManager) {
|
||||||
|
entityManagerFactory = ref('entityManagerFactory')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
|
||||||
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
|
|
||||||
http://www.springframework.org/schema/context
|
|
||||||
http://www.springframework.org/schema/context/spring-context.xsd
|
|
||||||
http://www.springframework.org/schema/data/jpa
|
|
||||||
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
|
|
||||||
<context:annotation-config />
|
|
||||||
<context:component-scan base-package="mc.core.h2db"/>
|
|
||||||
<jpa:repositories base-package="mc.core.h2db.repository"/>
|
|
||||||
|
|
||||||
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
|
||||||
<property name="driverClassName" value="org.h2.Driver"/>
|
|
||||||
<property name="url" value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"/>
|
|
||||||
<property name="username" value="sa"/>
|
|
||||||
<property name="password" value="s3cReT"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
|
||||||
<property name="dataSource" ref="dataSource"/>
|
|
||||||
<property name="persistenceProviderClass" value="org.hibernate.jpa.HibernatePersistenceProvider"/>
|
|
||||||
<property name="packagesToScan" value="mc.core.h2db.entity"/>
|
|
||||||
<property name="jpaProperties">
|
|
||||||
<props>
|
|
||||||
<prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
|
|
||||||
<prop key="hibernate.show_sql">false</prop>
|
|
||||||
<prop key="hibernate.hbm2ddl.auto">update</prop>
|
|
||||||
</props>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
|
|
||||||
<property name="entityManagerFactory" ref="entityManagerFactory"/>
|
|
||||||
</bean>
|
|
||||||
</beans>
|
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
Реализация протокола на сетевом движке [Netty.IO](https://netty.io/).
|
Реализация протокола на сетевом движке [Netty.IO](https://netty.io/).
|
||||||
|
|
||||||
Пример настройки можно посмотреть в файле `sample-config.xml`
|
Пример настройки можно посмотреть в файле [`sample-config.groovy`](./sample-config.groovy)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
18
proto_1.12.2_netty/sample-config.groovy
Normal file
18
proto_1.12.2_netty/sample-config.groovy
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
beans {
|
||||||
|
xmlns([context: 'http://www.springframework.org/schema/context'])
|
||||||
|
context.'annotation-config'()
|
||||||
|
context.'component-scan'('base-package': 'mc.core.network.proto_1_12_2.netty')
|
||||||
|
|
||||||
|
/* Для логирования сетевых пакетов, можно добавить нижезакомментированный бин */
|
||||||
|
//'pipeline.log'(io.netty.handler.logging.LoggingHandler) { bean -> bean.scope = 'prototype' }
|
||||||
|
'pipeline.decoder'(mc.core.network.proto_1_12_2.netty.PacketDecoder) { bean -> bean.scope = 'prototype' }
|
||||||
|
'pipeline.postencoder'(mc.core.network.proto_1_12_2.netty.PacketPostEncoder) { bean -> bean.scope = 'prototype' }
|
||||||
|
'pipeline.encoder'(mc.core.network.proto_1_12_2.netty.PacketEncoder) { bean -> bean.scope = 'prototype' }
|
||||||
|
'pipeline.handler'(mc.core.network.proto_1_12_2.netty.PacketHandler) { bean -> bean.scope = 'prototype' }
|
||||||
|
|
||||||
|
server(mc.core.network.proto_1_12_2.netty.NettyServer) {
|
||||||
|
host = '127.0.0.1'
|
||||||
|
port = 25565
|
||||||
|
workerGroupCount = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
|
|
||||||
http://www.springframework.org/schema/context
|
|
||||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
|
||||||
<context:annotation-config />
|
|
||||||
<context:component-scan base-package="mc.core.network.proto_1_12_2.netty" />
|
|
||||||
|
|
||||||
<!-- Для логирования сетевых пакетов, можно добавить нижезакомментированный бин -->
|
|
||||||
<!-- <bean id="pipeline.log" class="io.netty.handler.logging.LoggingHandler" scope="prototype"/> -->
|
|
||||||
<bean id="pipeline.decoder" class="mc.core.network.proto_1_12_2.netty.PacketDecoder" scope="prototype"/>
|
|
||||||
<bean id="pipeline.postencoder" class="mc.core.network.proto_1_12_2.netty.PacketPostEncoder" scope="prototype"/>
|
|
||||||
<bean id="pipeline.encoder" class="mc.core.network.proto_1_12_2.netty.PacketEncoder" scope="prototype"/>
|
|
||||||
<bean id="pipeline.handler" class="mc.core.network.proto_1_12_2.netty.PacketHandler" scope="prototype"/>
|
|
||||||
|
|
||||||
<bean id="server" class="mc.core.network.proto_1_12_2.netty.NettyServer">
|
|
||||||
<property name="host" value="127.0.0.1"/>
|
|
||||||
<property name="port" value="25565"/>
|
|
||||||
<property name="workerGroupCount" value="2"/>
|
|
||||||
</bean>
|
|
||||||
</beans>
|
|
||||||
@@ -4,36 +4,32 @@
|
|||||||
|
|
||||||
## Spring bean
|
## Spring bean
|
||||||
|
|
||||||
```xml
|
```groovy
|
||||||
<bean id="simpleWorld" class="mc.world.simple.SimpleWorld">
|
def layers = new ArrayList<String>();
|
||||||
<property name="spawn">
|
layers.add('1;BEDROCK')
|
||||||
<bean class="mc.core.EntityLocation">
|
layers.add('2;DIRT')
|
||||||
<constructor-arg index="0" type="double" value="8"/>
|
layers.add('1;GRASS')
|
||||||
<constructor-arg index="1" type="double" value="6"/>
|
|
||||||
<constructor-arg index="2" type="double" value="8"/>
|
beans {
|
||||||
<constructor-arg index="3" type="float" value="0"/>
|
spawnLocation(mc.core.EntityLocation) { bean ->
|
||||||
<constructor-arg index="4" type="float" value="0"/>
|
bean.constructorArgs = [ 8d/*X*/, 6d/*Y*/, 8d/*Z*/, 0f/*Yaw*/, 0f/*Pitch*/ ]
|
||||||
<constructor-arg index="5" type="mc.core.world.World">
|
}
|
||||||
<null/>
|
|
||||||
</constructor-arg>
|
flatChunkProvider(mc.world.simple.FlatChunkProvider) {
|
||||||
</bean>
|
layersBlock = layers
|
||||||
</property>
|
}
|
||||||
<property name="layersBlock">
|
|
||||||
<list value-type="java.lang.String">
|
simpleWorld(mc.world.simple.SimpleWorld) {
|
||||||
<value>1;BEDROCK</value>
|
spawn = ref('spawnLocation')
|
||||||
<value>2;DIRT</value>
|
chunkProvider = ref('flatChunkProvider')
|
||||||
<value>1;GRASS</value>
|
}
|
||||||
</list>
|
}
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`spawn` - точка спавна.
|
`spawn` - точка спавна
|
||||||
|
`chunkProvider` - провайдер чанков
|
||||||
|
|
||||||
При указании точки спавна, указывать шестой параметр `World` не имеет смысла,
|
У `flatChunkProvider` указан только один параметр - `layersBlock`. В качестве значения указывается спиток строк,
|
||||||
т.к. `SimpleWorld` всё равно перезапишет этот параметр.
|
каждая из которых описывает слой блоков.
|
||||||
|
Формат строк следующий: `кол-во_слоёв;тип_блока`.
|
||||||
`layersBlock` - слои блоков.
|
Порядок строк следующий: сверху **нижние слои**, а снизу - **верхние**.
|
||||||
|
|
||||||
В качестве значения указывается спиток строк, каждая из которых описывает слой блоков.
|
|
||||||
Формат строк такой: `кол-во_слоёв;тип_блока`. Порядок строк такой: сверху нижние слои, а снизу - верхние.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user