Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
File renamed without changes.
24 changes: 24 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SonarPet is a fork of [EchoPet](https://github.com/DSH105/EchoPet) and inherits its licensing.

EchoPet is [GPLv3 Licensed](./GPL.txt). Any uses of this project
must comply with the terms of the GPL.
The original code from DSH105 is under that license
and we must comply with it.

By default, all contributions are licensed
under the (restrictive) GPLv3 license.

The GPL is somewhat restrictive and prevents inclusion
in proprietary software.


I (Techcable) have chosen to release all
my changes under the [MIT License](./MIT.txt). This is retroactive - it includes all
of my changes that I ever contributed to this repository.

Contributors may also choose to release their changes under
the (permissive) MIT license by adding their names to the following
list:
````
Techcable <[email protected]>, <[email protected]>
````
21 changes: 21 additions & 0 deletions MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Nicholas Schlabach

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
45 changes: 38 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,62 @@
SonarPet [![Build Status](https://travis-ci.org/TechzoneMC/SonarPet.svg?branch=master)](https://travis-ci.org/TechzoneMC/SonarPet)
========
A fork of [EchoPet](https://github.com/DSH105/EchoPet) updated to 1.11
A fork of [EchoPet](https://github.com/DSH105/EchoPet) updated to modern versions

## **NOTE**: Unmaintained
I'm no longer willing to be the primary maintainer of SonarPet,
contact me on IRC if you're willing to take over this job.
## **NOTE**: Inactive
In spite of recent activity, SonarPet is still officially unmaintained.
This is still "officially" unsupported unless I decide to
Contact me on IRC if you're willing to help with maintenance and support.

### Supported Versions/Servers
SonarPet is undergoing some internal changes:
1. Support for "multiple versions" is being dropped.
- Due to rapid changes to mi
- Supporting 10 versions at once is incredibly draining!!!!
2. This plugin officially requires [Paper](https://papermc.io/)!!
- Spigot and CraftBukkit are unsupported - they will no longer work in the future.
- In the future, I plan to use official Paper APIs to replace most of our NMS code
- Ideally we would have zero-NMS dependencies
3. SonarPet will be completely free, and I will no longer offer paid support.
- SonarPet was previously released as a paid resource on Spigot
(with a portion of all revenue going to the old authors)
- I apologize for dropping support for a paid plugin. I should have realized
full-time development was incompatible with my school schedule. It was misleading,
and I won't do it again.
- Don't give me too hard a time: My code was still better than
99.9% of all other paid plugins

## Features
- All mobs can be pets (even enderdragons)
- An awesome donator perk that is _EULA compliant_
- Pets are greatly customisable, through the extensive Command Base and PetMenu
- A Custom AI makes all Pets focused on specific goals, handled closely by the core of the Plugin
- Make your pets attack your enemies
- Supports minecraft 1.6.4-1.11

## Changes
I've made some changes to EchoPet in SonarPet, which are listed below.
- I've renamed references from 'EchoPet' to 'SonarPet'
- Permissions and class names remain, to retain backwards compatibility and to avoid the need to change permissions
- I've added 1.9-1.11 support
- Note: Multiple version support will be dropped in the future!!!!

## Requirements
- Java 8
- Modern Minecraft
- Don't use old versions!
- Eventually I'll drop multi-version support.....
- [Paper](https://papermc.io/)
- Paper is strictly better than Spigot. Use it!

## Credits
- Dsh105 - Creating EchoPet
- CaptainBern - Helping out with EchoPet
- Techcable - 1.9-1.11 update and maintinaing SonarPet
- Techcable - 1.9+ updates and maintaining SonarPet
- NOTE: I'm officially inactive/dead. Please do not conduct a seance.

## License
EchoPet was originally licensed under the GPLv3.
This essentially requires us to be an open source project.

As

Please respect the contributions of the original authors and maintainers
by releasing your contributions to the public. It's the least you can do :)
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public void setDefaults() {
int friendlySlot = icon.getSlot() + 1;
set("petSelector.menu.slot-" + friendlySlot + ".command", icon.getCommand());
set("petSelector.menu.slot-" + friendlySlot + ".petType", icon.getPetType() == null ? "" : icon.getPetType().toString());
set("petSelector.menu.slot-" + friendlySlot + ".materialId", icon.getType().getId());
set("petSelector.menu.slot-" + friendlySlot + ".materialData", icon.getMaterialData().getData());
// NOTE: Temporarily upgraded from old system
set("petSelector.menu.slot-" + friendlySlot + ".material", MaterialSystem.getInstance().serializeData(icon.getItemData()));
set("petSelector.menu.slot-" + friendlySlot + ".name", (icon.getName() == null ? "" : icon.getName()).replace(ChatColor.COLOR_CHAR, '&'));
ArrayList<String> lore = new ArrayList<String>();
for (String s : icon.getLore()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ public int getSlot() {
}

public Material getType() {
return getMaterialData().getItemType();
}

public MaterialData getMaterialData() {
return itemData.getMaterialData();
return itemData.getType();
}

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,13 @@ public String getCommand() {
}

public Material getType() {
return getMaterialData().getItemType();
return getItemData().getType();
}

public int getAmount() {
return amount;
}

public MaterialData getMaterialData() {
return getItemData().getMaterialData();
}

public String getName() {
return getItemData().getDisplayName().get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import com.dsh105.echopet.compat.api.config.ConfigOptions;
import com.dsh105.echopet.compat.api.config.PetItem;
import com.dsh105.echopet.compat.api.entity.PetType;
import com.google.common.collect.ImmutableList;

import net.techcable.sonarpet.item.ItemData;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.HandlerList;
Expand All @@ -35,8 +34,6 @@
import java.util.List;
import java.util.Optional;

import net.techcable.sonarpet.item.ItemData;

public class SelectorLayout {

private static ArrayList<SelectorIcon> selectorLayout = new ArrayList<SelectorIcon>();
Expand Down Expand Up @@ -83,6 +80,14 @@ public static void loadLayout() {
if (petType != null && GeneralUtil.isEnumType(PetType.class, petType.toUpperCase())) {
pt = PetType.valueOf(petType.toUpperCase());
}
String serializedData = config.getInt();
if (serializedData != null) {
/*
* Always prefer using the new system of serialization.
* It will gracefully ends our dependence on material ids
* once we update to 1.13
*/
}
int id = config.getInt(s + ".slot-" + i + ".materialId");
int data = config.getInt(s + ".slot-" + i + ".materialData");
String name = config.getString(s + ".slot-" + i + ".name");
Expand All @@ -99,8 +104,7 @@ public static void loadLayout() {
loreList.add(ChatColor.translateAlternateColorCodes('&', part));
}
}
Material type = Material.getMaterial(id);
selectorLayout.add(new SelectorIcon(i - 1, cmd, pt, ItemData.create(type, data).withDisplayName(name.trim().isEmpty() ? Optional.empty() : Optional.of(name)).withLore(loreList)));
selectorLayout.add(new SelectorIcon(i - 1, cmd, pt, basicData.withDisplayName(name.trim().isEmpty() ? Optional.empty() : Optional.of(name)).withLore(loreList)));
}

selectorMenu = new SelectorMenu();
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/net/techcable/sonarpet/SafeSound.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

/**
* A version independent enumeration of sounds.
*
* @deprecated Legacy 1.8.8 compat
*/
@Deprecated
public enum SafeSound {
BLAZE_AMBIENT("ENTITY_BLAZE_AMBIENT", "BLAZE_BREATH"),
BLAZE_DEATH("ENTITY_BLAZE_DEATH", "BLAZE_DEATH"),
Expand Down
36 changes: 36 additions & 0 deletions api/src/main/java/net/techcable/sonarpet/block/BlockData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.techcable.sonarpet.block;

import org.bukkit.Material;

/**
* A facade around the modern `BlockData` interface,
* in order to ensure backwards compatibility.
*/
public interface BlockData {
Material getMaterial();
String getAsString();
static BlockData createBlockData(Material m) {
return BlockDataFactory.getInstance().createBlockData(m);
}
static BlockData parseBlockData(String s) {
return BlockDataFactory.getInstance().parseBlockData(s);
}

/**
* Parse the sepcified block data 'leniently',
* making a decent attempt to convert from legacy data.
*
* @param s the data to parse
* @throws IllegalArgumentException if the data is invalid
* @return the resulting block data
*/
static BlockData parseLeniently(String s) {
return BlockDataFactory.getInstance().parseLeniently(s);
}
static BlockData fromLegacyData(String materialName, byte data) {
return BlockDataFactory.getInstance().fromLegacyData(materialName, data);
}
static BlockData fromLegacyData(Material m, byte data) {
return BlockDataFactory.getInstance().fromLegacyData(m, data);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.techcable.sonarpet.block;

import net.techcable.sonarpet.utils.NmsVersion;
import org.bukkit.Material;
import org.bukkit.block.BlockState;

public interface BlockDataFactory {
BlockData createBlockData(Material m);
BlockData createBlockData(Material m, String data);
BlockData parseBlockData(String s);

static BlockDataFactory getInstance() {
if (NmsVersion.current().isAtLeast(NmsVersion.v1_13_R2)) {
return new ModernBlockDataFactory();
} else {
return new LegacyBlockDataFactory();
}
}
BlockData parseLeniently(String s);
BlockData fromLegacyData(int id, byte data);
BlockData fromLegacyData(String materialName, byte data);
BlockData fromLegacyData(Material m, byte data);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.techcable.sonarpet.block;

import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import org.bukkit.Material;
import org.bukkit.material.MaterialData;

@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public class LegacyBlockData implements BlockData {
private final MaterialData materialData;

@Override
public Material getMaterial() {
return materialData.getItemType();
}

@Override
public String getAsString() {
return "legacy[" + materialData.getItemType().name() + ":" + materialData.getData() + "]";
}
}
Loading