Skip to content

Commit

Permalink
1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wode490390 committed Jan 22, 2020
1 parent 4b40fff commit a47dd87
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 83 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
version: 2

jobs:
build:
docker:
- image: circleci/openjdk:8-jdk-stretch

steps:
- checkout

- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}

- run:
command: |
mvn dependency:go-offline
Expand All @@ -18,10 +22,6 @@ jobs:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}

- store_artifacts:
path: artifact
workflows:
version: 2
build:
jobs:
- build
22 changes: 22 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
name: Java CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn clean package

- name: Copy artifacts
run: |
mkdir artifact
cp target/*.jar artifact
- name: Archive artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifact
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,3 @@ __MACOSX/*

# Java
*.MF

# Jrebel
rebel.xml
rebel-remote.xml
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
language: java

jdk:
- openjdk8

install:
- mvn clean package

cache:
directories:
- '$HOME/.m2/repository'
91 changes: 84 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,32 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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>cn.wode490390.nukkit</groupId>
<artifactId>antixray</artifactId>
<version>1.1.1</version>
<packaging>jar</packaging>
<version>1.1.2</version>
<name>AntiXray</name>
<description>Anti X-Ray cheat plugin for Nukkit</description>
<inceptionYear>2018</inceptionYear>
<url>http://wode490390.cn/</url>
<packaging>jar</packaging>
<inceptionYear>2018</inceptionYear>

<licenses>
<license>
<name>GNU General Public License, Version 3.0</name>
<url>http://www.gnu.org/licenses/gpl.html</url>
<distribution>repo</distribution>
</license>
</licenses>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/wode490390/AntiXray/issues</url>
</issueManagement>

<ciManagement>
<system>CircleCI</system>
<url>https://circleci.com/gh/wode490390/AntiXray</url>
</ciManagement>

<scm>
<connection>scm:git:https://github.com/wode490390/AntiXray.git</connection>
<developerConnection>scm:git:git@github.com:wode490390/AntiXray.git</developerConnection>
<url>https://github.com/wode490390/AntiXray</url>
</scm>

<distributionManagement>
<repository>
<id>github</id>
<name>github-releases</name>
<url>https://maven.pkg.github.com/wode490390/AntiXray</url>
</repository>
</distributionManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>nukkitx</id>
<id>nukkitx-repo</id>
<url>http://repo.nukkitx.com/main/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>cn.nukkit</groupId>
Expand All @@ -37,10 +68,11 @@
<dependency>
<groupId>net.openhft</groupId>
<artifactId>zero-allocation-hashing</artifactId>
<version>0.9</version>
<version>0.10.1</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<defaultGoal>clean package</defaultGoal>
<finalName>wodeAntiXray-${project.version}</finalName>
Expand Down Expand Up @@ -76,6 +108,51 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<prefix>git</prefix>
<dateFormat>yyyy.MM.dd '@' HH:mm:ss z</dateFormat>
<dateFormatTimeZone>${user.timezone}</dateFormatTimeZone>
<verbose>true</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<format>properties</format>
<skipPoms>true</skipPoms>
<injectAllReactorProjects>false</injectAllReactorProjects>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
<skip>false</skip>
<runOnlyOnce>true</runOnlyOnce>
<excludeProperties>
<excludeProperty>git.user.*</excludeProperty>
</excludeProperties>
<includeOnlyProperties />
<useNativeGit>false</useNativeGit>
<abbrevLength>7</abbrevLength>
<commitIdGenerationMode>flat</commitIdGenerationMode>
<gitDescribe>
<skip>false</skip>
<always>false</always>
<abbrev>7</abbrev>
<dirty>-dirty</dirty>
<match>*</match>
<tags>false</tags>
<forceLongFormat>false</forceLongFormat>
</gitDescribe>
</configuration>
</plugin>
</plugins>
</build>
</project>
51 changes: 25 additions & 26 deletions src/main/java/cn/wode490390/nukkit/antixray/AntiXray.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
import cn.nukkit.plugin.PluginBase;
import cn.nukkit.scheduler.AsyncTask;
import cn.nukkit.utils.Config;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
Expand All @@ -47,10 +53,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand All @@ -74,11 +76,11 @@ public class AntiXray extends PluginBase implements Listener {
boolean localCache;
int fake_o;
int fake_n;
List<Integer> ores;
List<Integer> filters;
IntList ores;
IntList filters;
private List<String> worlds;

private final Map<Level, WorldHandler> handlers = new HashMap<>();
private final Map<Level, WorldHandler> handlers = Maps.newHashMap();

@Override
public void onEnable() {
Expand Down Expand Up @@ -150,25 +152,24 @@ public void onEnable() {
try {
this.worlds = config.getStringList(node);
} catch (Exception e) {
this.worlds = new ArrayList<>();
this.logLoadException(node, e);
}
node = "ores";
try {
this.ores = config.getIntegerList(node);
this.ores = new IntArrayList(new IntOpenHashSet(config.getIntegerList(node)));
} catch (Exception e) {
this.ores = new ArrayList<>();
this.logLoadException(node, e);
}
node = "filters";
try {
this.filters = config.getIntegerList(node);
} catch (Exception e) {
this.filters = new ArrayList<>();
this.logLoadException(node, e);
}

if (!this.worlds.isEmpty() && !this.ores.isEmpty()) {
if (this.worlds != null && this.ores != null && !this.worlds.isEmpty() && !this.ores.isEmpty()) {
node = "filters";
try {
this.filters = new IntArrayList(new IntOpenHashSet(config.getIntegerList(node)));
} catch (Exception e) {
this.filters = new IntArrayList(0);
this.logLoadException(node, e);
}

if (this.localCache) {
CACHE_DIR = new File(this.getDataFolder(), "cache");
if (!CACHE_DIR.exists()) {
Expand Down Expand Up @@ -208,11 +209,12 @@ public void onPlayerChunkRequest(PlayerChunkRequestEvent event) {
}

@EventHandler
//TODO: Use BlockBreakEvent instead of BlockUpdateEvent
public void onBlockUpdate(BlockUpdateEvent event) {
Position position = event.getBlock();
Level level = position.getLevel();
if (this.worlds.contains(level.getName())) {
List<UpdateBlockPacket> packets = new ArrayList<>();
List<UpdateBlockPacket> packets = new ObjectArrayList<>();
for (Vector3 vector : new Vector3[]{
position.add(1),
position.add(-1),
Expand Down Expand Up @@ -244,11 +246,12 @@ public void onBlockUpdate(BlockUpdateEvent event) {
packets.add(packet);
}
if (packets.size() > 0) {
Set<Player> players = Collections.synchronizedSet(new HashSet<>());
level.getChunkPlayers(position.getChunkX(), position.getChunkZ()).values().parallelStream()
/*Set<Player> players = Sets.newHashSet();
level.getChunkPlayers(position.getChunkX(), position.getChunkZ()).values().stream()
.filter(player -> !player.hasPermission(PERMISSION_WHITELIST))
.forEach(player -> players.add(player));
this.getServer().batchPackets(players.toArray(new Player[0]), packets.toArray(new UpdateBlockPacket[0]));
this.getServer().batchPackets(players.toArray(new Player[0]), packets.toArray(new UpdateBlockPacket[0]));*/
this.getServer().batchPackets(level.getChunkPlayers(position.getChunkX(), position.getChunkZ()).values().toArray(new Player[0]), packets.toArray(new UpdateBlockPacket[0]));
}
}
}
Expand Down Expand Up @@ -316,10 +319,6 @@ private static boolean deleteFolder(File file) {

public class CleanerListener implements Listener {

private CleanerListener() {

}

@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
WorldHandler handler = AntiXray.this.handlers.get(event.getLevel());
Expand Down
Loading

0 comments on commit a47dd87

Please sign in to comment.