Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
HiveGames-OSS committed Aug 11, 2024
0 parents commit a14795c
Show file tree
Hide file tree
Showing 198 changed files with 32,099 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
*.java text eol=lf
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @HiveGamesOSS/chunker
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@f97a4078d80bca790cd68e93a88da11a056ac0a3
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path

name: Publish Maven Package

on:
release:
types: [created]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
target/
/var
pom.xml.versionsBackup
test-output/
/atlassian-ide-plugin.x
.idea
.*.swp
.*.swo
leveldb-c
*~
*.swp
.idea
.idea/*
*.iml
*.ipr
*.iws
.DS_Store
.scala_dependencies
.project
.classpath
.settings
eclipse-classes
10 changes: 10 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Microsoft Open Source Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).

Resources:

- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
- Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support)
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Contributing to leveldb-mcpe-java

Thanks for your interest in contributing to this repository.

If you find a bug in Chunker or wish to request adding a feature please make a GitHub issue on the Chunker repository,
searching first to ensure it doesn't exist already.

We don't accept contributions currently for this repository though you are more than welcome to fork it and add your own
contributions, you are also welcome to create an issue on our main Chunker repository referencing your changes for
review.

This project is maintained by Hive Games.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# LevelDB MCPE in Java

This project is a fork of https://github.com/pcmind/leveldb aiming to implement the changes made
in https://github.com/Mojang/leveldb-mcpe/ where relevant to allow the library to read MCPE.

For more information see the original repository on use cases / API usage.

Building
--------

**Requirements**

- Git
- Java 11 or higher
- Maven

**Steps**

1. Clone this repository via `git clone git://github.com/HiveGamesOSS/leveldb-mcpe-java.git`.
2. Build the project via `mvn clean install`.
3. Obtain the library from `target/` folder.

Library Usage
--------

You can use the following in your maven pom.xml:

```xml

<dependency>
<groupId>com.hivemc.leveldb</groupId>
<artifactId>leveldb</artifactId>
<version>1.0.0</version>
</dependency>
```

```xml

<dependency>
<groupId>com.hivemc.leveldb</groupId>
<artifactId>leveldb-api</artifactId>
<version>1.0.0</version>
</dependency>
```

This library is aimed as a drop in replacement to the original fork https://github.com/pcmind/leveldb.

License
--------

Details of the LICENSE can be found in the license.txt, this fork maintains the original license for all code and
modifications.
37 changes: 37 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Security

Hive Games takes the security of our software products and services seriously, which includes all source code
repositories managed through our GitHub organizations.

If you believe you have found a security vulnerability in any Hive Games repository which follows the MITRE.org
definition of “a weakness in the computational logic (e.g., code) found in software and hardware components that, when
exploited, results in a negative impact to confidentiality, integrity, OR availability. Mitigation of the
vulnerabilities in this context typically involves coding changes but could also include specification changes or even
specification deprecations (e.g., removal of affected protocols or functionality in their entirety).” MITRE.org CNA
Rules 7.1, please report it to us as described below.

## Reporting Security Issues

**Please do not report security vulnerabilities through public GitHub issues.**

Instead, please send email to [secure@hivemc.com](mailto:secure@hivemc.com).

You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we
received your original message.

Please include the requested information listed below (as much as you can provide) to help us better understand the
nature and scope of the possible issue:

* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

## Preferred Languages

We prefer all communications to be in English.
10 changes: 10 additions & 0 deletions SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Support

## How to file issues and get help

This project does not allow issues / PRs, if you would like help with Chunker related issues please file an issue on our
main repository referencing this project if needed.

## Hive Games Support Policy

Support for this project is limited to the Chunker scope.
26 changes: 26 additions & 0 deletions leveldb-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.hivemc.leveldb</groupId>
<artifactId>leveldb-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>leveldb-api</artifactId>
<name>${project.artifactId}</name>
<description>High level Java API for LevelDB</description>

<properties>
<air.main.basedir>${project.parent.basedir}</air.main.basedir>
</properties>

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
57 changes: 57 additions & 0 deletions leveldb-api/src/main/java/org/iq80/leveldb/CompressionType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2011 the original author or authors.
* See the notice.md file distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.iq80.leveldb;

/**
* DB contents are stored in a set of blocks, each of which holds a
* sequence of key,value pairs. Each block may be compressed before
* being stored in a file. The following enum describes which
* compression method (if any) is used to compress a block.
*/
public enum CompressionType
{
// NOTE: do not change the values of existing entries, as these are
// part of the persistent format on disk.
NONE(0x00),
SNAPPY(0x01),
// MCPE Compression Types
ZLIB(0x02),
ZLIB_RAW(0x04);

public static CompressionType getCompressionTypeByPersistentId(int persistentId)
{
for (CompressionType compressionType : CompressionType.values()) {
if (compressionType.persistentId == persistentId) {
return compressionType;
}
}
throw new IllegalArgumentException("Unknown persistentId " + persistentId);
}

private final int persistentId;

CompressionType(int persistentId)
{
this.persistentId = persistentId;
}

public int persistentId()
{
return persistentId;
}
}
Loading

0 comments on commit a14795c

Please sign in to comment.