Compare commits
87
Commits
update-5.0.0
..
1.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
464eb8510a | ||
|
|
81145fb96a | ||
|
|
7a64f0613b | ||
|
|
02e4833b1a | ||
|
|
78b32d3e53 | ||
|
|
ec9a13aa45 | ||
|
|
8610063307 | ||
|
|
464209f972 | ||
|
|
f33bd16d44 | ||
|
|
d21569e376 | ||
|
|
8ed67c5fb1 | ||
|
|
e5d7f33512 | ||
|
|
a690516474 | ||
|
|
1790bb0f77 | ||
|
|
8f68d7fbcf | ||
|
|
d974ac15bb | ||
|
|
bd1caf4c09 | ||
|
|
4d4a9c101f | ||
|
|
3c1c54ae3d | ||
|
|
24c47ab3d5 | ||
|
|
4eda237b1b | ||
|
|
6aac64254c | ||
|
|
806b6e92ea | ||
|
|
d34649a93e | ||
|
|
7b63c0a2b5 | ||
|
|
2e78b744f8 | ||
|
|
8e3d942863 | ||
|
|
34e1d9b911 | ||
|
|
d5df299969 | ||
|
|
bec76364aa | ||
|
|
a7ba33fb3e | ||
|
|
fa3b99b5a3 | ||
|
|
f20db72dfd | ||
|
|
41be717b2c | ||
|
|
82457e5b79 | ||
|
|
b341a6dd3a | ||
|
|
8b241f15dc | ||
|
|
ab9783047f | ||
|
|
fb3fe9c235 | ||
|
|
4fa3a34752 | ||
|
|
5f1a13f6c4 | ||
|
|
459c37b77c | ||
|
|
1cca9580b8 | ||
|
|
77df9488ed | ||
|
|
e97c4fb238 | ||
|
|
5ba41d50d8 | ||
|
|
478960945f | ||
|
|
4023b42938 | ||
|
|
4a7244b544 | ||
|
|
b09460502a | ||
|
|
65e0fe237d | ||
|
|
e3e548faec | ||
|
|
fdee9c7e9a | ||
|
|
2792001453 | ||
|
|
537ddff634 | ||
|
|
3882164074 | ||
|
|
e79a49f7de | ||
|
|
1105aa12c8 | ||
|
|
51f582c3b5 | ||
|
|
67a104193a | ||
|
|
d512e82a13 | ||
|
|
058ce5b29c | ||
|
|
07e831f458 | ||
|
|
900af0e497 | ||
|
|
727a064a3b | ||
|
|
43309dc841 | ||
|
|
ff1448fb5f | ||
|
|
3116fe3c21 | ||
|
|
92b6a9a6fc | ||
|
|
04e71d4377 | ||
|
|
7bbd9348c2 | ||
|
|
c5185c58be | ||
|
|
c553062c14 | ||
|
|
38c650c19a | ||
|
|
1be9974982 | ||
|
|
478da03d48 | ||
|
|
c85c68f816 | ||
|
|
f8c2221fcd | ||
|
|
3e58995fc8 | ||
|
|
233fe409ec | ||
|
|
fa34bbfc61 | ||
|
|
174fcdb1f7 | ||
|
|
58a489191d | ||
|
|
7cfb90759e | ||
|
|
5905b3132d | ||
|
|
0992584943 | ||
|
|
0eac36a65e |
No files matched your search
@@ -1,5 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 💬 Multiverse Discord Server
|
||||
url: https://discord.gg/NZtfKky
|
||||
about: Need help with using Multiverse-Core or just want to chat with the devs? Join the Multiverse Discord Server for help!
|
||||
@@ -1,56 +0,0 @@
|
||||
---
|
||||
name: ❓ Help!
|
||||
about: Encountered a problem with Multiverse-Core? Not sure how to fix it?
|
||||
title: ''
|
||||
labels: 'Type: Assistance'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Multiverse-Core help guide
|
||||
|
||||
Don't write inside the arrows as they will be hidden when you post your issue.
|
||||
|
||||
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
|
||||
|
||||
If you need help other submodules of Multiverse, go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
|
||||
|
||||
Or come join our Discord server to get help sooner: https://discord.gg/NZtfKky
|
||||
|
||||
If you're happy to wait (or you were sent here from Discord), read on:
|
||||
|
||||
1. Check the Usage and FAQ pages to see if it answers your queries:
|
||||
https://github.com/Multiverse/Multiverse-Core/wiki/Basics
|
||||
https://github.com/Multiverse/Multiverse-Core/wiki/FAQ
|
||||
|
||||
2. Fill out the template.
|
||||
This will help us understand what problem you've encountered and help us
|
||||
find a solution.
|
||||
|
||||
3. When linking files, do not attach them to the post!
|
||||
Copy and paste any logs into https://gist.github.com/ or other similar service.
|
||||
|
||||
4. Delete this line and all above lines before posting your issue! -->
|
||||
|
||||
### Information
|
||||
|
||||
* **Server version:** <!-- Insert output of `/version` command -->
|
||||
|
||||
* **Full output of `/mv version -p`:** <!-- Replace this with the command output's https://paste.gg/ link -->
|
||||
|
||||
* **Server log:** <!-- Upload `logs/latest.log` to https://gist.github.com/ -->
|
||||
|
||||
### Help request
|
||||
|
||||
**Problem**
|
||||
<!-- What problem did you encounter? -->
|
||||
|
||||
**What I have tried**
|
||||
<!-- What have you tried so far? -->
|
||||
|
||||
**Screenshots**
|
||||
<!-- If relevant, include any screenshots here. -->
|
||||
@@ -1,59 +0,0 @@
|
||||
---
|
||||
name: 🐛 Report a Bug
|
||||
about: Report a Multiverse-Core bug. Only use this if you're 100% sure it's something wrong with Multiverse-Core - otherwise, try "Help!".
|
||||
title: ''
|
||||
labels: 'Bug: Unconfirmed'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Multiverse-Core bug reporting guide
|
||||
|
||||
Don't put anything inside this block, as it won't be included in the issue.
|
||||
|
||||
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
|
||||
|
||||
If you are having issues with other submodules of Multiverse, go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
|
||||
|
||||
If you are reporting a bug, please follow the following steps:
|
||||
|
||||
1. Fill out the template in full.
|
||||
Run the commands in the console. Don't just put "latest" as a version,
|
||||
or we will ignore it.
|
||||
|
||||
2. When linking files, do not attach them to the post!
|
||||
Copy and paste any logs into https://gist.github.com/, then paste a
|
||||
link to them in the relevant parts of the template.
|
||||
**DO NOT drag files into this box!**
|
||||
|
||||
3. Make sure not to write between the arrows, as anything there will be
|
||||
hidden.
|
||||
|
||||
4. Delete this line and all above lines before posting your issue! -->
|
||||
|
||||
### Information
|
||||
|
||||
* **Server version:** <!-- Insert output of `/version` command -->
|
||||
|
||||
* **Full output of `/mv version -p`:** <!-- Replace this with the command output's https://paste.gg/ link -->
|
||||
|
||||
* **Server log:** <!-- Upload `logs/latest.log` to https://gist.github.com/ -->
|
||||
|
||||
### Details
|
||||
I was **`<able / not able>`** to reproduce my issue on a freshly setup and up-to-date server with the latest version of Multiverse plugins with no other plugins and with no kinds of other server or client mods.
|
||||
|
||||
**Description**
|
||||
<!-- Replace this with a brief summary of the bug. -->
|
||||
|
||||
**Steps to reproduce**
|
||||
<!-- Replace this with exactly what you did to cause the bug. -->
|
||||
|
||||
**Expected behavior**
|
||||
<!-- Replace this with what you expected to happen. -->
|
||||
|
||||
**Screenshots**
|
||||
<!-- Replace this with screenshots, if necessary. -->
|
||||
@@ -1,54 +0,0 @@
|
||||
---
|
||||
name: 💡 Request a Feature
|
||||
about: Suggest a feature you want to see in Multiverse-Core!
|
||||
title: ''
|
||||
labels: 'Type: Idea'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Multiverse-Core feature request guide
|
||||
|
||||
Fill out the template. Don't write inside the arrows as they will be hidden
|
||||
when you post your issue.
|
||||
|
||||
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
|
||||
|
||||
If you are look for other submodules of Multiverse, go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
|
||||
|
||||
Not sure if your feature fits in Multiverse-Core? Feel free to ask on our Discord
|
||||
server: https://discord.gg/NZtfKky
|
||||
|
||||
If you have a feature suggestion for Multiverse-Core, read the following tips:
|
||||
|
||||
1. Fill out the template.
|
||||
This will help us understand what you're requesting and why you want us
|
||||
to add it.
|
||||
|
||||
2. Keep it simple.
|
||||
Make sure it's easy to understand what you're requesting. A good way is
|
||||
to keep it to one request per GitHub issue, as we can then easily track
|
||||
feature requests.
|
||||
|
||||
3. Check whether it has already been asked or added.
|
||||
You can search the issue tracker to see if your feature has already been
|
||||
requested at https://github.com/Multiverse/Multiverse-Core/issues.
|
||||
|
||||
4. Ask yourself: "Does this belong in Multiverse-Core?"
|
||||
There are lots of features that we reject because most servers won't
|
||||
need or use them. If your feature is very specific or already exists in
|
||||
another plugin, it might not be a good fit for Multiverse-Core.
|
||||
|
||||
5. Delete this line and all above lines before posting your issue! -->
|
||||
|
||||
### Feature request
|
||||
|
||||
**Feature description**
|
||||
<!-- What feature are you suggesting? -->
|
||||
|
||||
**How the feature is useful**
|
||||
<!-- How is the feature useful to players, server owners and/or developers? -->
|
||||
+2
-1
@@ -3,4 +3,5 @@ jdk:
|
||||
- oraclejdk8
|
||||
notifications:
|
||||
email: false
|
||||
dist: trusty
|
||||
before_install:
|
||||
- sed -i.bak -e 's|https://nexus.codehaus.org/snapshots/|https://oss.sonatype.org/content/repositories/codehaus-snapshots/|g' ~/.m2/settings.xml
|
||||
@@ -13,4 +13,4 @@ Copyright (c) 2011, The Multiverse Team All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the The Multiverse Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
machine:
|
||||
java:
|
||||
version: oraclejdk8
|
||||
@@ -3,13 +3,12 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
<artifactId>Multiverse-Core</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<version>4.1.1-1.8.8-SNAPSHOT</version>
|
||||
<name>Multiverse-Core</name>
|
||||
<description>World Management Plugin</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.build.number>UNKNOWN</project.build.number>
|
||||
<project.bitly-access-token>bitly-access-token</project.bitly-access-token>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
@@ -22,6 +21,10 @@
|
||||
<id>onarandombox</id>
|
||||
<url>http://repo.onarandombox.com/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
@@ -30,9 +33,10 @@
|
||||
<id>minebench-repo</id>
|
||||
<url>https://repo.minebench.de/</url>
|
||||
</repository>
|
||||
<!-- Has a copy of metrics R8-SNAPSHOT !-->
|
||||
<repository>
|
||||
<id>CodeMC</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
<id>elmakers-repo</id>
|
||||
<url>http://maven.elmakers.com/repository/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
@@ -66,17 +70,6 @@
|
||||
<project.build.number>${env.BUILD_NUMBER}</project.build.number>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>bitly</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env.BITLY_ACCESS_TOKEN</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<project.bitly-access-token>${env.BITLY_ACCESS_TOKEN}</project.bitly-access-token>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
@@ -98,44 +91,21 @@
|
||||
<version>1.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>replace-bitly-access-token</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<basedir>${project.build.sourceDirectory}</basedir>
|
||||
<includes>
|
||||
<include>com/onarandombox/MultiverseCore/utils/webpaste/BitlyURLShortener.java</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>bitly-access-token</token>
|
||||
<value>${project.bitly-access-token}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>replace-maven-version-number</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<basedir>${project.build.directory}/classes</basedir>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}-b${project.build.number}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<file>target/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}-b${project.build.number}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Jar Plugin -->
|
||||
<plugin>
|
||||
@@ -233,8 +203,8 @@
|
||||
<shadedPattern>com.onarandombox.buscript</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>com.onarandombox.bstats</shadedPattern>
|
||||
<pattern>org.mcstats</pattern>
|
||||
<shadedPattern>com.onarandombox.mcstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.dumptruckman.minecraft.util.Logging</pattern>
|
||||
@@ -275,10 +245,10 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- SerializationConfig Dependency -->
|
||||
<dependency>
|
||||
@@ -297,7 +267,7 @@
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<version>1.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- End of Economy Dependency -->
|
||||
@@ -307,21 +277,15 @@
|
||||
<artifactId>CommandHandler</artifactId>
|
||||
<version>11</version>
|
||||
</dependency>
|
||||
<!-- End of CommandHandler Dependency -->
|
||||
<dependency>
|
||||
<groupId>net.minidev</groupId>
|
||||
<artifactId>json-smart</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>buscript</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.8</version>
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
<version>R6</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
import me.main__.util.SerializationConfig.ChangeDeniedException;
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.VirtualProperty;
|
||||
import net.minidev.json.JSONObject;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -29,17 +28,20 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The implementation of a Multiverse handled world.
|
||||
@@ -212,7 +214,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
public Double validateChange(String property, Double newValue, Double oldValue,
|
||||
MVWorld object) throws ChangeDeniedException {
|
||||
if (newValue <= 0) {
|
||||
Logging.fine("Someone tried to set a scale <= 0, aborting!");
|
||||
plugin.log(Level.FINE, "Someone tried to set a scale <= 0, aborting!");
|
||||
throw new ChangeDeniedException();
|
||||
}
|
||||
return super.validateChange(property, newValue, oldValue, object);
|
||||
@@ -295,7 +297,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
public GameMode validateChange(String property, GameMode newValue, GameMode oldValue,
|
||||
MVWorld object) throws ChangeDeniedException {
|
||||
for (Player p : plugin.getServer().getWorld(getName()).getPlayers()) {
|
||||
Logging.finer(String.format("Setting %s's GameMode to %s",
|
||||
plugin.log(Level.FINER, String.format("Setting %s's GameMode to %s",
|
||||
p.getName(), newValue.toString()));
|
||||
plugin.getPlayerListener().handleGameModeAndFlight(p, MVWorld.this);
|
||||
}
|
||||
@@ -317,16 +319,16 @@ public class MVWorld implements MultiverseWorld {
|
||||
// verify that the location is safe
|
||||
if (!bs.playerCanSpawnHereSafely(newValue)) {
|
||||
// it's not ==> find a better one!
|
||||
Logging.warning(String.format("Somebody tried to set the spawn location for '%s' to an unsafe value! Adjusting...", getAlias()));
|
||||
Logging.warning("Old Location: " + plugin.getLocationManipulation().strCoordsRaw(oldValue));
|
||||
Logging.warning("New (unsafe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue));
|
||||
plugin.log(Level.WARNING, String.format("Somebody tried to set the spawn location for '%s' to an unsafe value! Adjusting...", getAlias()));
|
||||
plugin.log(Level.WARNING, "Old Location: " + plugin.getLocationManipulation().strCoordsRaw(oldValue));
|
||||
plugin.log(Level.WARNING, "New (unsafe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue));
|
||||
SafeTTeleporter teleporter = plugin.getSafeTTeleporter();
|
||||
newValue = teleporter.getSafeLocation(newValue, SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS);
|
||||
if (newValue == null) {
|
||||
Logging.warning("Couldn't fix the location. I have to abort the spawn location-change :/");
|
||||
plugin.log(Level.WARNING, "Couldn't fix the location. I have to abort the spawn location-change :/");
|
||||
throw new ChangeDeniedException();
|
||||
}
|
||||
Logging.warning("New (safe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue));
|
||||
plugin.log(Level.WARNING, "New (safe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue));
|
||||
}
|
||||
}
|
||||
return super.validateChange(property, newValue, oldValue, object);
|
||||
@@ -409,7 +411,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
// Add limit bypass to it's parent
|
||||
this.limitbypassperm.addParent("mv.bypass.playerlimit.*", true);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Logging.finer("Permissions nodes were already added for " + this.name);
|
||||
this.plugin.log(Level.FINER, "Permissions nodes were already added for " + this.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,16 +422,16 @@ public class MVWorld implements MultiverseWorld {
|
||||
// Verify that location was safe
|
||||
if (!bs.playerCanSpawnHereSafely(location)) {
|
||||
if (!this.getAdjustSpawn()) {
|
||||
Logging.fine("Spawn location from world.dat file was unsafe!!");
|
||||
Logging.fine("NOT adjusting spawn for '" + this.getAlias() + "' because you told me not to.");
|
||||
Logging.fine("To turn on spawn adjustment for this world simply type:");
|
||||
Logging.fine("/mvm set adjustspawn true " + this.getAlias());
|
||||
this.plugin.log(Level.FINE, "Spawn location from world.dat file was unsafe!!");
|
||||
this.plugin.log(Level.FINE, "NOT adjusting spawn for '" + this.getAlias() + "' because you told me not to.");
|
||||
this.plugin.log(Level.FINE, "To turn on spawn adjustment for this world simply type:");
|
||||
this.plugin.log(Level.FINE, "/mvm set adjustspawn true " + this.getAlias());
|
||||
return location;
|
||||
}
|
||||
// If it's not, find a better one.
|
||||
SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter();
|
||||
Logging.warning("Spawn location from world.dat file was unsafe. Adjusting...");
|
||||
Logging.warning("Original Location: " + plugin.getLocationManipulation().strCoordsRaw(location));
|
||||
this.plugin.log(Level.WARNING, "Spawn location from world.dat file was unsafe. Adjusting...");
|
||||
this.plugin.log(Level.WARNING, "Original Location: " + plugin.getLocationManipulation().strCoordsRaw(location));
|
||||
Location newSpawn = teleporter.getSafeLocation(location,
|
||||
SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS);
|
||||
// I think we could also do this, as I think this is what Notch does.
|
||||
@@ -448,7 +450,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
this.getName(), plugin.getLocationManipulation().locationToString(newerSpawn));
|
||||
return newerSpawn;
|
||||
} else {
|
||||
Logging.severe("Safe spawn NOT found!!!");
|
||||
this.plugin.log(Level.SEVERE, "Safe spawn NOT found!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,11 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import buscript.Buscript;
|
||||
@@ -32,6 +34,7 @@ import com.onarandombox.MultiverseCore.api.MVPlugin;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.commands.AnchorCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CheckCommand;
|
||||
@@ -93,8 +96,6 @@ import com.onarandombox.MultiverseCore.utils.MVMessaging;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
|
||||
import com.onarandombox.MultiverseCore.utils.MaterialConverter;
|
||||
import com.onarandombox.MultiverseCore.utils.TestingMode;
|
||||
import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||
@@ -108,6 +109,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
@@ -120,6 +122,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
import org.mcstats.Metrics;
|
||||
|
||||
/**
|
||||
* The implementation of the Multiverse-{@link Core}.
|
||||
@@ -306,7 +309,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.worldManager.loadDefaultWorlds();
|
||||
this.worldManager.loadWorlds(true);
|
||||
} else {
|
||||
Logging.severe("Your configs were not loaded. Very little will function in Multiverse.");
|
||||
this.log(Level.SEVERE, "Your configs were not loaded. Very little will function in Multiverse.");
|
||||
}
|
||||
this.anchorManager.loadAnchors();
|
||||
|
||||
@@ -337,29 +340,107 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Output a little snippet to show it's enabled.
|
||||
Logging.config("Version %s (API v%s) Enabled - By %s", this.getDescription().getVersion(), PROTOCOL, getAuthors());
|
||||
|
||||
if (getMVConfig().isShowingDonateMessage()) {
|
||||
getLogger().config("Help dumptruckman keep this project alive. Become a patron! https://www.patreon.com/dumptruckman");
|
||||
getLogger().config("One time donations are also appreciated: https://www.paypal.me/dumptruckman");
|
||||
}
|
||||
}
|
||||
|
||||
private void setupMetrics() {
|
||||
if (TestingMode.isDisabled()) {
|
||||
MetricsConfigurator.configureMetrics(this);
|
||||
}
|
||||
getLogger().info("Help dumptruckman keep this project alive. Become a patron! https://www.patreon.com/dumptruckman");
|
||||
getLogger().info("One time donations are also appreciated: https://www.paypal.me/dumptruckman");
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the buscript javascript library.
|
||||
*/
|
||||
private void initializeBuscript() {
|
||||
buscript = new Buscript(this);
|
||||
// Add global variable "multiverse" to javascript environment
|
||||
buscript.setScriptVariable("multiverse", this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plotter for Environment-Values.
|
||||
*/
|
||||
private static final class EnvironmentPlotter extends Metrics.Plotter {
|
||||
private MultiverseCore core;
|
||||
private final Environment env;
|
||||
|
||||
public EnvironmentPlotter(MultiverseCore core, Environment env) {
|
||||
super(envToString(env));
|
||||
this.core = core;
|
||||
this.env = env;
|
||||
}
|
||||
|
||||
private static String envToString(Environment env) {
|
||||
return new StringBuilder().append(env.name().toUpperCase().charAt(0))
|
||||
.append(env.name().toLowerCase().substring(1)).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
int count = 0;
|
||||
for (MultiverseWorld w : core.getMVWorldManager().getMVWorlds())
|
||||
if (w.getEnvironment() == env)
|
||||
count++;
|
||||
core.log(Level.FINE, String.format("Tracking %d worlds of type %s", count, env));
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plotter for Generator-Values.
|
||||
*/
|
||||
private static final class GeneratorPlotter extends Metrics.Plotter {
|
||||
private MultiverseCore core;
|
||||
private final String gen;
|
||||
|
||||
public GeneratorPlotter(MultiverseCore core, String gen) {
|
||||
super(gen);
|
||||
this.core = core;
|
||||
this.gen = gen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
int count = 0;
|
||||
for (MultiverseWorld w : core.getMVWorldManager().getMVWorlds())
|
||||
if (gen.equals(w.getGenerator()))
|
||||
count++;
|
||||
core.log(Level.FINE, String.format("Tracking %d worlds of type %s", count, gen));
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
private void setupMetrics() {
|
||||
try {
|
||||
buscript = new Buscript(this);
|
||||
// Add global variable "multiverse" to javascript environment
|
||||
buscript.setScriptVariable("multiverse", this);
|
||||
} catch (NullPointerException e) {
|
||||
buscript = null;
|
||||
Logging.warning("Buscript failed to load! The script command will be disabled!");
|
||||
Metrics m = new Metrics(this);
|
||||
|
||||
Metrics.Graph envGraph = m.createGraph("worlds_by_env");
|
||||
for (Environment env : Environment.values())
|
||||
envGraph.addPlotter(new EnvironmentPlotter(this, env));
|
||||
|
||||
m.addCustomData(new Metrics.Plotter("Loaded worlds") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return getMVWorldManager().getMVWorlds().size();
|
||||
}
|
||||
});
|
||||
m.addCustomData(new Metrics.Plotter("Total number of worlds") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return getMVWorldManager().getMVWorlds().size()
|
||||
+ getMVWorldManager().getUnloadedWorlds().size();
|
||||
}
|
||||
});
|
||||
|
||||
Set<String> gens = new HashSet<String>();
|
||||
for (MultiverseWorld w : this.getMVWorldManager().getMVWorlds())
|
||||
gens.add(w.getGenerator());
|
||||
gens.remove(null);
|
||||
gens.remove("null");
|
||||
Metrics.Graph genGraph = m.createGraph("custom_gens");
|
||||
for (String gen : gens)
|
||||
genGraph.addPlotter(new GeneratorPlotter(this, gen));
|
||||
|
||||
m.start();
|
||||
log(Level.FINE, "Metrics have run!");
|
||||
} catch (IOException e) {
|
||||
log(Level.WARNING, "There was an issue while enabling metrics: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +464,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
pm.registerEvents(this.entityListener, this);
|
||||
pm.registerEvents(this.weatherListener, this);
|
||||
pm.registerEvents(this.portalListener, this);
|
||||
Logging.info(ChatColor.GREEN + "We are aware of the warning about the deprecated event. There is no alternative that allows us to do what we need to do and performance impact is negligible. It is safe to ignore.");
|
||||
pm.registerEvents(this.worldListener, this);
|
||||
pm.registerEvents(new MVMapListener(this), this);
|
||||
}
|
||||
@@ -502,13 +582,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
try {
|
||||
wconf.load(worldsFile);
|
||||
} catch (IOException e) {
|
||||
Logging.warning("Cannot load worlds.yml");
|
||||
log(Level.WARNING, "Cannot load worlds.yml");
|
||||
} catch (InvalidConfigurationException e) {
|
||||
Logging.warning("Your worlds.yml is invalid!");
|
||||
log(Level.WARNING, "Your worlds.yml is invalid!");
|
||||
}
|
||||
|
||||
if (!wconf.isConfigurationSection("worlds")) { // empty config
|
||||
Logging.fine("No worlds to migrate!");
|
||||
this.log(Level.FINE, "No worlds to migrate!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -521,7 +601,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// fine
|
||||
newValues.put(entry.getKey(), entry.getValue());
|
||||
} else if (entry.getValue() instanceof ConfigurationSection) {
|
||||
Logging.fine("Migrating: " + entry.getKey());
|
||||
this.log(Level.FINE, "Migrating: " + entry.getKey());
|
||||
// we have to migrate this
|
||||
WorldProperties world = new WorldProperties(Collections.EMPTY_MAP);
|
||||
ConfigurationSection section = (ConfigurationSection) entry.getValue();
|
||||
@@ -687,8 +767,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
try {
|
||||
difficulty = Difficulty.valueOf(section.getString("difficulty").toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
Logging.warning("Could not parse difficulty: " + section.getString("difficulty"));
|
||||
Logging.warning("Setting world " + entry.getKey() + " difficulty to NORMAL");
|
||||
this.log(Level.WARNING, "Could not parse difficulty: " + section.getString("difficulty"));
|
||||
this.log(Level.WARNING, "Setting world " + entry.getKey() + " difficulty to NORMAL");
|
||||
difficulty = Difficulty.NORMAL;
|
||||
}
|
||||
if (difficulty != null) {
|
||||
@@ -705,7 +785,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
wasChanged = true;
|
||||
} else {
|
||||
// huh?
|
||||
Logging.warning("Removing unknown entry in the config: " + entry);
|
||||
this.log(Level.WARNING, "Removing unknown entry in the config: " + entry);
|
||||
// just don't add to newValues
|
||||
wasChanged = true;
|
||||
}
|
||||
@@ -839,12 +919,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @deprecated This is now deprecated, nobody needs it any longer.
|
||||
* All logging is now done with {@link Logging}.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void log(Level level, String msg) {
|
||||
Logging.log(level, msg);
|
||||
}
|
||||
@@ -1063,7 +1139,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Logging.severe("Could not save Multiverse config.yml config. Please check your file permissions.");
|
||||
this.log(Level.SEVERE, "Could not save Multiverse config.yml config. Please check your file permissions.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import com.dumptruckman.minecraft.util.*;
|
||||
import com.onarandombox.MultiverseCore.api.*;
|
||||
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import me.main__.util.SerializationConfig.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Our configuration.
|
||||
*/
|
||||
@@ -73,8 +71,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
private volatile int portalsearchradius;
|
||||
@Property
|
||||
private volatile boolean autopurge;
|
||||
@Property
|
||||
private volatile boolean idonotwanttodonate;
|
||||
|
||||
public MultiverseCoreConfiguration() {
|
||||
super();
|
||||
@@ -107,7 +103,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
defaultportalsearch = false;
|
||||
portalsearchradius = 128;
|
||||
autopurge = true;
|
||||
idonotwanttodonate = false;
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
@@ -353,14 +348,4 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
public void setAutoPurgeEnabled(boolean autopurge) {
|
||||
this.autopurge = autopurge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowingDonateMessage() {
|
||||
return !idonotwanttodonate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowDonateMessage(boolean showDonateMessage) {
|
||||
this.idonotwanttodonate = !showDonateMessage;
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,11 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* A simple API to require plugins to have a log method.
|
||||
*
|
||||
* @deprecated Replaced by {@link Logging}.
|
||||
* */
|
||||
@Deprecated
|
||||
/** A simple API to require plugins to have a log method. */
|
||||
public interface LoggablePlugin {
|
||||
/**
|
||||
* Logs a message at the specified level.
|
||||
|
||||
@@ -213,18 +213,4 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||
* @param autopurge True if automatic purge should be enabled.
|
||||
*/
|
||||
void setAutoPurgeEnabled(boolean autopurge);
|
||||
|
||||
/**
|
||||
* Gets whether or not the donation/patreon messages are shown.
|
||||
*
|
||||
* @return True if donation/patreon messages should be shown.
|
||||
*/
|
||||
boolean isShowingDonateMessage();
|
||||
|
||||
/**
|
||||
* Sets whether or not the donation/patreon messages are shown.
|
||||
*
|
||||
* @param idonotwanttodonate True if donation/patreon messages should be shown.
|
||||
*/
|
||||
void setShowDonateMessage(boolean idonotwanttodonate);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class CheckCommand extends MultiverseCommand {
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Player p = this.plugin.getServer().getPlayerExact(args.get(0));
|
||||
Player p = this.plugin.getServer().getPlayer(args.get(0));
|
||||
if (p == null) {
|
||||
sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0));
|
||||
sender.sendMessage("Are they online?");
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -61,7 +60,7 @@ public class DebugCommand extends MultiverseCommand {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||
} else {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel);
|
||||
Logging.fine("Multiverse Debug ENABLED");
|
||||
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -56,61 +55,21 @@ public class GameruleCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final GameRule gameRule = GameRule.getByName(args.get(0));
|
||||
final String gameRule = args.get(0);
|
||||
final String value = args.get(1);
|
||||
final World world;
|
||||
if (args.size() == 2) {
|
||||
world = p.getWorld();
|
||||
} else {
|
||||
world = Bukkit.getWorld(args.get(2));
|
||||
if (world == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Failure!" + ChatColor.WHITE + " World " + ChatColor.AQUA + args.get(2)
|
||||
+ ChatColor.WHITE + " does not exist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (gameRule == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Failure! " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE
|
||||
+ " is not a valid gamerule.");
|
||||
if (world.setGameRuleValue(gameRule, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Gamerule " + ChatColor.AQUA + gameRule
|
||||
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
||||
} else {
|
||||
if (gameRule.getType() == Boolean.class) {
|
||||
boolean booleanValue;
|
||||
if (value.equalsIgnoreCase("true")) {
|
||||
booleanValue = true;
|
||||
} else if (value.equalsIgnoreCase("false")) {
|
||||
booleanValue = false;
|
||||
} else {
|
||||
sender.sendMessage(getErrorMessage(gameRule.getName(), value) + "it can only be set to true or false.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!world.setGameRule(gameRule, booleanValue)) {
|
||||
sender.sendMessage(getErrorMessage(gameRule.getName(), value) + "something went wrong.");
|
||||
return;
|
||||
}
|
||||
} else if (gameRule.getType() == Integer.class) {
|
||||
try {
|
||||
if (!world.setGameRule(gameRule, Integer.parseInt(value))) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(getErrorMessage(gameRule.getName(), value) + "it can only be set to a positive integer.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Failure!" + ChatColor.WHITE + " Gamerule " + ChatColor.AQUA + gameRule.getName()
|
||||
+ ChatColor.WHITE + " isn't supported yet, please let us know about it.");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Gamerule " + ChatColor.AQUA + gameRule.getName()
|
||||
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value + ChatColor.WHITE + ".");
|
||||
sender.sendMessage(ChatColor.RED + "Failure!" + ChatColor.WHITE + " Gamerule " + ChatColor.AQUA + gameRule
|
||||
+ ChatColor.WHITE + " cannot be set to " + ChatColor.RED + value);
|
||||
}
|
||||
}
|
||||
|
||||
private String getErrorMessage(String gameRule, String value) {
|
||||
return ChatColor.RED + "Failure!" + ChatColor.WHITE + " Gamerule " + ChatColor.AQUA + gameRule
|
||||
+ ChatColor.WHITE + " could not be set to " + ChatColor.RED + value + ChatColor.WHITE + ", ";
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -61,11 +60,6 @@ public class GamerulesCommand extends MultiverseCommand {
|
||||
world = p.getWorld();
|
||||
} else {
|
||||
world = Bukkit.getWorld(args.get(0));
|
||||
if (world == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Failure!" + ChatColor.WHITE + " World " + ChatColor.AQUA + args.get(0)
|
||||
+ ChatColor.WHITE + " does not exist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder gameRules = new StringBuilder();
|
||||
@@ -74,7 +68,7 @@ public class GamerulesCommand extends MultiverseCommand {
|
||||
gameRules.append(ChatColor.WHITE).append(", ");
|
||||
}
|
||||
gameRules.append(ChatColor.AQUA).append(gameRule).append(ChatColor.WHITE).append(": ");
|
||||
gameRules.append(ChatColor.GREEN).append(world.getGameRuleValue(GameRule.getByName(gameRule)));
|
||||
gameRules.append(ChatColor.GREEN).append(world.getGameRuleValue(gameRule));
|
||||
}
|
||||
sender.sendMessage("=== Gamerules for " + ChatColor.AQUA + world.getName() + ChatColor.WHITE + " ===");
|
||||
sender.sendMessage(gameRules.toString());
|
||||
|
||||
@@ -115,7 +115,6 @@ public class InfoCommand extends MultiverseCommand {
|
||||
FancyColorScheme colors = new FancyColorScheme(ChatColor.AQUA, ChatColor.AQUA, ChatColor.GOLD, ChatColor.WHITE);
|
||||
message.add(new FancyHeader("General Info", colors));
|
||||
message.add(new FancyMessage("World Name: ", world.getName(), colors));
|
||||
message.add(new FancyMessage("World UID: ", world.getCBWorld().getUID().toString(), colors));
|
||||
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
|
||||
message.add(new FancyMessage("Game Mode: ", world.getGameMode().toString(), colors));
|
||||
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
|
||||
@@ -152,7 +151,6 @@ public class InfoCommand extends MultiverseCommand {
|
||||
message = new ArrayList<FancyText>();
|
||||
message.add(new FancyHeader("More World Settings", colors));
|
||||
message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
|
||||
message.add(new FancyMessage("Generator: ", world.getGenerator(), colors));
|
||||
message.add(new FancyMessage("Structures: ", world.getCBWorld().canGenerateStructures() + "", colors));
|
||||
message.add(new FancyMessage("Weather: ", world.isWeatherEnabled() + "", colors));
|
||||
message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors));
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
||||
public ListCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("World Listing");
|
||||
this.setCommandUsage("/mv list [page]");
|
||||
this.setCommandUsage("/mv list");
|
||||
this.setArgRange(0, 2);
|
||||
this.addKey("mvlist");
|
||||
this.addKey("mvl");
|
||||
|
||||
@@ -27,7 +27,6 @@ public class ReloadCommand extends MultiverseCommand {
|
||||
this.setCommandUsage("/mv reload");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mvreload");
|
||||
this.addKey("mvr");
|
||||
this.addKey("mv reload");
|
||||
this.addCommandExample("/mv reload");
|
||||
this.setPermission("multiverse.core.reload", "Reloads worlds.yml and config.yml.", PermissionDefault.OP);
|
||||
|
||||
@@ -35,10 +35,6 @@ public class ScriptCommand extends MultiverseCommand {
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (plugin.getScriptAPI() == null) {
|
||||
sender.sendMessage("Buscript failed to load while the server was starting. Scripts cannot be run.");
|
||||
return;
|
||||
}
|
||||
File file = new File(plugin.getScriptAPI().getScriptFolder(), args.get(0));
|
||||
if (!file.exists()) {
|
||||
sender.sendMessage("That script file does not exist in the Multiverse-Core scripts directory!");
|
||||
|
||||
@@ -30,7 +30,6 @@ public class SetSpawnCommand extends MultiverseCommand {
|
||||
this.setCommandUsage("/mv setspawn");
|
||||
this.setArgRange(0, 6);
|
||||
this.addKey("mvsetspawn");
|
||||
this.addKey("mvsets");
|
||||
this.addKey("mvss");
|
||||
this.addKey("mv set spawn");
|
||||
this.addKey("mv setspawn");
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SpawnCommand extends MultiverseCommand {
|
||||
sender.sendMessage("You don't have permission to teleport another player to spawn. (multiverse.core.spawn.other)");
|
||||
return;
|
||||
}
|
||||
Player target = this.plugin.getServer().getPlayerExact(args.get(0));
|
||||
Player target = this.plugin.getServer().getPlayer(args.get(0));
|
||||
if (target != null) {
|
||||
target.sendMessage("Teleporting to this world's spawn...");
|
||||
spawnAccurately(target);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.Teleporter;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
@@ -41,7 +40,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
Permission menu = new Permission("multiverse.teleport.*", "Allows you to display the teleport menu.", PermissionDefault.OP);
|
||||
|
||||
this.setName("Teleport");
|
||||
this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {DESTINATION}");
|
||||
this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}");
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mvtp");
|
||||
this.addKey("mv tp");
|
||||
@@ -59,7 +58,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
String destinationName;
|
||||
|
||||
if (args.size() == 2) {
|
||||
teleportee = this.plugin.getServer().getPlayerExact(args.get(0));
|
||||
teleportee = this.plugin.getServer().getPlayer(args.get(0));
|
||||
if (teleportee == null) {
|
||||
this.messaging.sendMessage(sender, String.format("Sorry, I couldn't find player: %s%s",
|
||||
ChatColor.GOLD, args.get(0)), false);
|
||||
@@ -95,7 +94,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true);
|
||||
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
|
||||
if (teleportEvent.isCancelled()) {
|
||||
Logging.fine("Someone else cancelled the MVTeleport Event!!!");
|
||||
this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -163,9 +162,9 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
((CustomTeleporterDestination)d).getTeleporter() : this.playerTeleporter;
|
||||
TeleportResult result = teleportObject.teleport(teleporter, teleportee, d);
|
||||
if (result == TeleportResult.FAIL_UNSAFE) {
|
||||
Logging.fine("Could not teleport " + teleportee.getName()
|
||||
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName()
|
||||
+ " to " + plugin.getLocationManipulation().strCoordsRaw(d.getLocation(teleportee)));
|
||||
Logging.fine("Queueing Command");
|
||||
this.plugin.log(Level.FINE, "Queueing Command");
|
||||
Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class };
|
||||
List<Object> items = new ArrayList<Object>();
|
||||
items.add(teleporter);
|
||||
|
||||
@@ -10,13 +10,12 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.BitlyURLShortener;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteFailedException;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteService;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceFactory;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.URLShortener;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.URLShortenerFactory;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.URLShortenerType;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -25,8 +24,10 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -34,91 +35,110 @@ import java.util.Map;
|
||||
* Dumps version info to the console.
|
||||
*/
|
||||
public class VersionCommand extends MultiverseCommand {
|
||||
private static final URLShortener SHORTENER = URLShortenerFactory.getService(URLShortenerType.BITLY);
|
||||
private static final URLShortener SHORTENER = new BitlyURLShortener();
|
||||
|
||||
public VersionCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Multiverse Version");
|
||||
this.setCommandUsage("/mv version " + ChatColor.GOLD + "[-b|-h|-p] [--include-plugin-list]");
|
||||
this.setCommandUsage("/mv version " + ChatColor.GOLD + "-[bh] [--include-plugin-list]");
|
||||
this.setArgRange(0, 2);
|
||||
this.addKey("mv version");
|
||||
this.addKey("mvver");
|
||||
this.addKey("mvv");
|
||||
this.addKey("mvversion");
|
||||
this.setPermission("multiverse.core.version",
|
||||
"Dumps version info to the console, optionally to pastebin.com with -b, to hastebin.com using -h, or to paste.gg with -p.", PermissionDefault.TRUE);
|
||||
"Dumps version info to the console, optionally to pastie.org with -p or pastebin.com with a -b.", PermissionDefault.TRUE);
|
||||
}
|
||||
|
||||
private String getLegacyString() {
|
||||
return "[Multiverse-Core] Multiverse-Core Version: " + this.plugin.getDescription().getVersion() + '\n'
|
||||
+ "[Multiverse-Core] Bukkit Version: " + this.plugin.getServer().getVersion() + '\n'
|
||||
+ "[Multiverse-Core] Loaded Worlds: " + this.plugin.getMVWorldManager().getMVWorlds() + '\n'
|
||||
+ "[Multiverse-Core] Multiverse Plugins Loaded: " + this.plugin.getPluginCount() + '\n'
|
||||
+"[Multiverse-Core] Economy being used: " + plugin.getEconomist().getEconomyName() + '\n'
|
||||
+ "[Multiverse-Core] Permissions Plugin: " + this.plugin.getMVPerms().getType() + '\n'
|
||||
+ "[Multiverse-Core] Dumping Config Values: (version " + this.plugin.getMVConfig().getVersion() + ")" + '\n'
|
||||
+ "[Multiverse-Core] enforceaccess: " + plugin.getMVConfig().getEnforceAccess() + '\n'
|
||||
+ "[Multiverse-Core] prefixchat: " + plugin.getMVConfig().getPrefixChat() + '\n'
|
||||
+ "[Multiverse-Core] prefixchatformat: " + plugin.getMVConfig().getPrefixChatFormat() + '\n'
|
||||
+ "[Multiverse-Core] useasyncchat: " + plugin.getMVConfig().getUseAsyncChat() + '\n'
|
||||
+ "[Multiverse-Core] teleportintercept: " + plugin.getMVConfig().getTeleportIntercept() + '\n'
|
||||
+ "[Multiverse-Core] firstspawnoverride: " + plugin.getMVConfig().getFirstSpawnOverride() + '\n'
|
||||
+ "[Multiverse-Core] displaypermerrors: " + plugin.getMVConfig().getDisplayPermErrors() + '\n'
|
||||
+ "[Multiverse-Core] globaldebug: " + plugin.getMVConfig().getGlobalDebug() + '\n'
|
||||
+ "[Multiverse-Core] silentstart: " + plugin.getMVConfig().getSilentStart() + '\n'
|
||||
+ "[Multiverse-Core] messagecooldown: " + plugin.getMessaging().getCooldown() + '\n'
|
||||
+ "[Multiverse-Core] version: " + plugin.getMVConfig().getVersion() + '\n'
|
||||
+ "[Multiverse-Core] firstspawnworld: " + plugin.getMVConfig().getFirstSpawnWorld() + '\n'
|
||||
+ "[Multiverse-Core] teleportcooldown: " + plugin.getMVConfig().getTeleportCooldown() + '\n'
|
||||
+ "[Multiverse-Core] defaultportalsearch: " + plugin.getMVConfig().isUsingDefaultPortalSearch() + '\n'
|
||||
+ "[Multiverse-Core] portalsearchradius: " + plugin.getMVConfig().getPortalSearchRadius() + '\n'
|
||||
+ "[Multiverse-Core] autopurge: " + plugin.getMVConfig().isAutoPurgeEnabled() + '\n'
|
||||
+ "[Multiverse-Core] Special Code: FRN002" + '\n';
|
||||
StringBuilder legacyFile = new StringBuilder();
|
||||
legacyFile.append("[Multiverse-Core] Multiverse-Core Version: ").append(this.plugin.getDescription().getVersion()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] Bukkit Version: ").append(this.plugin.getServer().getVersion()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] Loaded Worlds: ").append(this.plugin.getMVWorldManager().getMVWorlds()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] Multiverse Plugins Loaded: ").append(this.plugin.getPluginCount()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] Economy being used: ").append(plugin.getEconomist().getEconomyName()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] Permissions Plugin: ").append(this.plugin.getMVPerms().getType()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] Dumping Config Values: (version ")
|
||||
.append(this.plugin.getMVConfig().getVersion()).append(")").append('\n');
|
||||
legacyFile.append("[Multiverse-Core] messagecooldown: ").append(plugin.getMessaging().getCooldown()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] teleportcooldown: ").append(plugin.getMVConfig().getTeleportCooldown()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] worldnameprefix: ").append(plugin.getMVConfig().getPrefixChat()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] worldnameprefixFormat: ").append(plugin.getMVConfig().getPrefixChatFormat()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] enforceaccess: ").append(plugin.getMVConfig().getEnforceAccess()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] displaypermerrors: ").append(plugin.getMVConfig().getDisplayPermErrors()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] teleportintercept: ").append(plugin.getMVConfig().getTeleportIntercept()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] firstspawnoverride: ").append(plugin.getMVConfig().getFirstSpawnOverride()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] firstspawnworld: ").append(plugin.getMVConfig().getFirstSpawnWorld()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] debug: ").append(plugin.getMVConfig().getGlobalDebug()).append('\n');
|
||||
legacyFile.append("[Multiverse-Core] Special Code: FRN002").append('\n');
|
||||
return legacyFile.toString();
|
||||
}
|
||||
|
||||
private String getMarkdownString() {
|
||||
return "# Multiverse-Core" + '\n'
|
||||
+ "## Overview" + '\n'
|
||||
+ "| Name | Value |" + '\n'
|
||||
+ "| --- | --- |" + '\n'
|
||||
+ "| Multiverse-Core Version | `" + this.plugin.getDescription().getVersion() + "` |" + '\n'
|
||||
+ "| Bukkit Version | `" + this.plugin.getServer().getVersion() + "` |" + '\n'
|
||||
+ "| Loaded Worlds | `" + this.plugin.getMVWorldManager().getMVWorlds() + "` |" + '\n'
|
||||
+ "| Multiverse Plugins Loaded | `" + this.plugin.getPluginCount() + "` |" + '\n'
|
||||
+ "| Economy being used | `" + plugin.getEconomist().getEconomyName() + "` |" + '\n'
|
||||
+ "| Permissions Plugin | `" + this.plugin.getMVPerms().getType() + "` |" + '\n'
|
||||
+ "## Parsed Config" + '\n'
|
||||
+ "These are what Multiverse thought the in-memory values of the config were." + "\n\n"
|
||||
+ "| Config Key | Value |" + '\n'
|
||||
+ "| --- | --- |" + '\n'
|
||||
+ "| version | `" + this.plugin.getMVConfig().getVersion() + "` |" + '\n'
|
||||
+ "| messagecooldown | `" + plugin.getMessaging().getCooldown() + "` |" + '\n'
|
||||
+ "| teleportcooldown | `" + plugin.getMVConfig().getTeleportCooldown() + "` |" + '\n'
|
||||
+ "| worldnameprefix | `" + plugin.getMVConfig().getPrefixChat() + "` |" + '\n'
|
||||
+ "| worldnameprefixFormat | `" + plugin.getMVConfig().getPrefixChatFormat() + "` |" + '\n'
|
||||
+ "| enforceaccess | `" + plugin.getMVConfig().getEnforceAccess() + "` |" + '\n'
|
||||
+ "| displaypermerrors | `" + plugin.getMVConfig().getDisplayPermErrors() + "` |" + '\n'
|
||||
+ "| teleportintercept | `" + plugin.getMVConfig().getTeleportIntercept() + "` |" + '\n'
|
||||
+ "| firstspawnoverride | `" + plugin.getMVConfig().getFirstSpawnOverride() + "` |" + '\n'
|
||||
+ "| firstspawnworld | `" + plugin.getMVConfig().getFirstSpawnWorld() + "` |" + '\n'
|
||||
+ "| debug | `" + plugin.getMVConfig().getGlobalDebug() + "` |" + '\n';
|
||||
StringBuilder markdownString = new StringBuilder();
|
||||
markdownString.append("# Multiverse-Core\n");
|
||||
markdownString.append("## Overview\n");
|
||||
markdownString.append("| Name | Value |\n");
|
||||
markdownString.append("| --- | --- |\n");
|
||||
markdownString.append("| Multiverse-Core Version | `").append(this.plugin.getDescription().getVersion()).append("` |\n");
|
||||
markdownString.append("| Bukkit Version | `").append(this.plugin.getServer().getVersion()).append("` |\n");
|
||||
//markdownString.append("| Loaded Worlds | `").append(this.plugin.getMVWorldManager().getMVWorlds()).append("` |\n");
|
||||
markdownString.append("| Multiverse Plugins Loaded | `").append(this.plugin.getPluginCount()).append("` |\n");
|
||||
markdownString.append("| Economy being used | `").append(plugin.getEconomist().getEconomyName()).append("` |\n");
|
||||
markdownString.append("| Permissions Plugin | `").append(this.plugin.getMVPerms().getType()).append("` |\n");
|
||||
markdownString.append("## Parsed Config\n");
|
||||
markdownString.append("These are what Multiverse thought the in-memory values of the config were.\n\n");
|
||||
markdownString.append("| Config Key | Value |\n");
|
||||
markdownString.append("| --- | --- |\n");
|
||||
markdownString.append("| version | `").append(this.plugin.getMVConfig().getVersion()).append("` |\n");
|
||||
markdownString.append("| messagecooldown | `").append(plugin.getMessaging().getCooldown()).append("` |\n");
|
||||
markdownString.append("| teleportcooldown | `").append(plugin.getMVConfig().getTeleportCooldown()).append("` |\n");
|
||||
markdownString.append("| worldnameprefix | `").append(plugin.getMVConfig().getPrefixChat()).append("` |\n");
|
||||
markdownString.append("| worldnameprefixFormat | `").append(plugin.getMVConfig().getPrefixChatFormat()).append("` |\n");
|
||||
markdownString.append("| enforceaccess | `").append(plugin.getMVConfig().getEnforceAccess()).append("` |\n");
|
||||
markdownString.append("| displaypermerrors | `").append(plugin.getMVConfig().getDisplayPermErrors()).append("` |\n");
|
||||
markdownString.append("| teleportintercept | `").append(plugin.getMVConfig().getTeleportIntercept()).append("` |\n");
|
||||
markdownString.append("| firstspawnoverride | `").append(plugin.getMVConfig().getFirstSpawnOverride()).append("` |\n");
|
||||
markdownString.append("| firstspawnworld | `").append(plugin.getMVConfig().getFirstSpawnWorld()).append("` |\n");
|
||||
markdownString.append("| debug | `").append(plugin.getMVConfig().getGlobalDebug()).append("` |\n");
|
||||
return markdownString.toString();
|
||||
}
|
||||
|
||||
private void addVersionInfoToEvent(MVVersionEvent event) {
|
||||
// add the legacy version info
|
||||
event.appendVersionInfo(this.getLegacyString());
|
||||
private String readFile(final String filename) {
|
||||
String result;
|
||||
try {
|
||||
FileReader reader = new FileReader(filename);
|
||||
BufferedReader bufferedReader = new BufferedReader(reader);
|
||||
String line;
|
||||
result = "";
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result += line + '\n';
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
Logging.severe("Unable to find %s. Here's the traceback: %s", filename, e.getMessage());
|
||||
e.printStackTrace();
|
||||
result = String.format("ERROR: Could not load: %s", filename);
|
||||
} catch (IOException e) {
|
||||
Logging.severe("Something bad happend when reading %s. Here's the traceback: %s", filename, e.getMessage());
|
||||
e.printStackTrace();
|
||||
result = String.format("ERROR: Could not load: %s", filename);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// add the legacy file, but as markdown so it's readable
|
||||
// TODO Readd this in 5.0.0
|
||||
// event.putDetailedVersionInfo("version.md", this.getMarkdownString());
|
||||
private Map<String, String> getVersionFiles() {
|
||||
Map<String, String> files = new HashMap<String, String>();
|
||||
|
||||
// add config.yml
|
||||
// Add the legacy file, but as markdown so it's readable
|
||||
files.put("version.md", this.getMarkdownString());
|
||||
|
||||
// Add the config.yml
|
||||
File configFile = new File(this.plugin.getDataFolder(), "config.yml");
|
||||
event.putDetailedVersionInfo("multiverse-core/config.yml", configFile);
|
||||
files.put(configFile.getName(), this.readFile(configFile.getAbsolutePath()));
|
||||
|
||||
// add worlds.yml
|
||||
File worldsFile = new File(this.plugin.getDataFolder(), "worlds.yml");
|
||||
event.putDetailedVersionInfo("multiverse-core/worlds.yml", worldsFile);
|
||||
// Add the config.yml
|
||||
File worldConfig = new File(this.plugin.getDataFolder(), "worlds.yml");
|
||||
files.put(worldConfig.getName(), this.readFile(worldConfig.getAbsolutePath()));
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,26 +148,23 @@ public class VersionCommand extends MultiverseCommand {
|
||||
sender.sendMessage("Version info dumped to console. Please check your server logs.");
|
||||
}
|
||||
|
||||
MVVersionEvent versionEvent = new MVVersionEvent();
|
||||
|
||||
this.addVersionInfoToEvent(versionEvent);
|
||||
MVVersionEvent versionEvent = new MVVersionEvent(this.getLegacyString(), this.getVersionFiles());
|
||||
final Map<String, String> files = this.getVersionFiles();
|
||||
this.plugin.getServer().getPluginManager().callEvent(versionEvent);
|
||||
|
||||
String versionInfo = versionEvent.getVersionInfo();
|
||||
|
||||
if (CommandHandler.hasFlag("--include-plugin-list", args)) {
|
||||
versionEvent.appendVersionInfo('\n' + "Plugins: " + getPluginList());
|
||||
versionEvent.putDetailedVersionInfo("plugins.txt", "Plugins: " + getPluginList());
|
||||
versionInfo = versionInfo + "\nPlugins: " + getPluginList();
|
||||
}
|
||||
|
||||
final String versionInfo = versionEvent.getVersionInfo();
|
||||
versionEvent.putDetailedVersionInfo("version.txt", versionInfo);
|
||||
|
||||
final Map<String, String> files = versionEvent.getDetailedVersionInfo();
|
||||
final String data = versionInfo;
|
||||
|
||||
// log to console
|
||||
String[] lines = versionInfo.split("\\r?\\n");
|
||||
String[] lines = data.split("\n");
|
||||
for (String line : lines) {
|
||||
if (!line.isEmpty()) {
|
||||
this.plugin.getServer().getLogger().info(line);
|
||||
Logging.info(line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,16 +175,10 @@ public class VersionCommand extends MultiverseCommand {
|
||||
String pasteUrl;
|
||||
if (CommandHandler.hasFlag("-b", args)) {
|
||||
// private post to pastebin
|
||||
pasteUrl = postToService(PasteServiceType.PASTEBIN, true, versionInfo, files);
|
||||
} else if (CommandHandler.hasFlag("-g", args)) {
|
||||
// private post to github
|
||||
pasteUrl = postToService(PasteServiceType.GITHUB, true, versionInfo, files);
|
||||
pasteUrl = postToService(PasteServiceType.PASTEBIN, true, data, files);
|
||||
} else if (CommandHandler.hasFlag("-h", args)) {
|
||||
// private post to hastebin
|
||||
pasteUrl = postToService(PasteServiceType.HASTEBIN, true, versionInfo, files);
|
||||
} else if (CommandHandler.hasFlag("-p", args)) {
|
||||
// private post to paste.gg
|
||||
pasteUrl = postToService(PasteServiceType.PASTEGG, true, versionInfo, files);
|
||||
// private post to pastebin
|
||||
pasteUrl = postToService(PasteServiceType.HASTEBIN, true, data, files);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -193,25 +204,20 @@ public class VersionCommand extends MultiverseCommand {
|
||||
* @param pasteFiles Map of filenames/contents of debug info.
|
||||
* @return URL of visible paste
|
||||
*/
|
||||
private static String postToService(PasteServiceType type, boolean isPrivate, String pasteData, Map<String, String> pasteFiles) {
|
||||
private static String postToService(PasteServiceType type, boolean isPrivate, String pasteData,
|
||||
Map<String, String> pasteFiles) {
|
||||
PasteService ps = PasteServiceFactory.getService(type, isPrivate);
|
||||
|
||||
try {
|
||||
String result;
|
||||
if (ps.supportsMultiFile()) {
|
||||
result = ps.postData(pasteFiles);
|
||||
result = ps.postData(ps.encodeData(pasteFiles), ps.getPostURL());
|
||||
} else {
|
||||
result = ps.postData(pasteData);
|
||||
result = ps.postData(ps.encodeData(pasteData), ps.getPostURL());
|
||||
}
|
||||
|
||||
if (SHORTENER != null) return SHORTENER.shorten(result);
|
||||
return result;
|
||||
return SHORTENER.shorten(result);
|
||||
} catch (PasteFailedException e) {
|
||||
e.printStackTrace();
|
||||
return "Error posting to service.";
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return "That service isn't supported yet.";
|
||||
System.out.print(e);
|
||||
return "Error posting to service";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.bukkit.util.Vector;
|
||||
* A bed-{@link MVDestination}.
|
||||
*/
|
||||
public class BedDestination implements MVDestination {
|
||||
public static final String OWN_BED_STRING = "playerbed";
|
||||
public static final String OLD_BED_STRING = "b:playerbed";
|
||||
private String playername = "";
|
||||
private boolean isValid;
|
||||
private Location knownBedLoc;
|
||||
@@ -46,11 +46,11 @@ public class BedDestination implements MVDestination {
|
||||
boolean validFormat = split.length >= 1 && split.length <= 2 && split[0].equals(this.getIdentifier());
|
||||
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(split[1]);
|
||||
boolean validPlayer = p.getName() != null && !p.getName().equals(OWN_BED_STRING);
|
||||
boolean validPlayer = (p != null);
|
||||
|
||||
if (validFormat && validPlayer) this.playername = p.getName();
|
||||
|
||||
this.isValid = destination.equals("b:" + OWN_BED_STRING) || (validFormat && validPlayer);
|
||||
this.isValid = destination.equals(OLD_BED_STRING) || (validFormat && validPlayer);
|
||||
|
||||
return this.isValid;
|
||||
}
|
||||
@@ -136,6 +136,6 @@ public class BedDestination implements MVDestination {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "b:" + (playername.isEmpty() ? OWN_BED_STRING : playername);
|
||||
return playername.isEmpty() ? OLD_BED_STRING : ("b:" + playername);
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class PlayerDestination implements MVDestination {
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation(Entity e) {
|
||||
Player p = plugin.getServer().getPlayerExact(this.player);
|
||||
Player p = plugin.getServer().getPlayer(this.player);
|
||||
Player plLoc = null;
|
||||
if (e instanceof Player) {
|
||||
plLoc = (Player) e;
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -21,9 +13,9 @@ public class MVVersionEvent extends Event {
|
||||
private final StringBuilder versionInfoBuilder;
|
||||
private final Map<String, String> detailedVersionInfo;
|
||||
|
||||
public MVVersionEvent() {
|
||||
versionInfoBuilder = new StringBuilder();
|
||||
detailedVersionInfo = new HashMap<>();
|
||||
public MVVersionEvent(String legacyVersionInfo, Map<String, String> files) {
|
||||
this.versionInfoBuilder = new StringBuilder(legacyVersionInfo);
|
||||
this.detailedVersionInfo = files;
|
||||
}
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
@@ -57,14 +49,14 @@ public class MVVersionEvent extends Event {
|
||||
*
|
||||
* This information is used for advanced paste services that would prefer
|
||||
* to get the information as several files. Examples include config.yml or
|
||||
* portals.yml. Note that the map returned is immutable.
|
||||
* portals.yml.
|
||||
*
|
||||
* The keys are filenames, the values are the contents of the files.
|
||||
*
|
||||
* @return The immutable key value mapping of files and the contents of those files.
|
||||
* @return The key value mapping of files and the contents of those files.
|
||||
*/
|
||||
public Map<String, String> getDetailedVersionInfo() {
|
||||
return Collections.unmodifiableMap(this.detailedVersionInfo);
|
||||
return this.detailedVersionInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,46 +66,4 @@ public class MVVersionEvent extends Event {
|
||||
public void appendVersionInfo(String moreVersionInfo) {
|
||||
this.versionInfoBuilder.append(moreVersionInfo);
|
||||
}
|
||||
|
||||
private String readFile(final String filename) {
|
||||
StringBuilder result;
|
||||
|
||||
try {
|
||||
FileReader reader = new FileReader(filename);
|
||||
BufferedReader bufferedReader = new BufferedReader(reader);
|
||||
String line;
|
||||
result = new StringBuilder();
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line).append("\n");
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
Logging.severe("Unable to find %s. Here's the traceback: %s", filename, e.getMessage());
|
||||
e.printStackTrace();
|
||||
result = new StringBuilder(String.format("ERROR: Could not load: %s", filename));
|
||||
} catch (IOException e) {
|
||||
Logging.severe("Something bad happend when reading %s. Here's the traceback: %s", filename, e.getMessage());
|
||||
e.printStackTrace();
|
||||
result = new StringBuilder(String.format("ERROR: Could not load: %s", filename));
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a file to to the detailed version-info currently saved in this event.
|
||||
* @param fileName The name of the file.
|
||||
* @param contents The contents of the file.
|
||||
*/
|
||||
public void putDetailedVersionInfo(String fileName, String contents) {
|
||||
this.detailedVersionInfo.put(fileName, contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a file to to the detailed version-info currently saved in this event.
|
||||
* @param filename The name of the file.
|
||||
* @param file The file.
|
||||
*/
|
||||
public void putDetailedVersionInfo(String filename, File file) {
|
||||
this.putDetailedVersionInfo(filename, readFile(file.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -9,7 +9,6 @@ package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
@@ -21,7 +20,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
public class MVAsyncPlayerChatListener extends MVChatListener {
|
||||
public MVAsyncPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
|
||||
super(plugin, playerListener);
|
||||
Logging.fine("Created AsyncPlayerChatEvent listener.");
|
||||
plugin.log(Level.FINE, "Created AsyncPlayerChatEvent listener.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
@@ -99,7 +98,7 @@ public class MVEntityListener implements Listener {
|
||||
* Handle people with non-standard animals: ie a patched craftbukkit.
|
||||
*/
|
||||
if (type == null || type.getName() == null) {
|
||||
Logging.finer("Found a null typed creature.");
|
||||
this.plugin.log(Level.FINER, "Found a null typed creature.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class MVMapListener implements Listener {
|
||||
public void mapInitialize(final MapInitializeEvent event) {
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
if ((player.getItemInHand().getType() == Material.MAP
|
||||
|| player.getItemInHand().getType() == Material.FILLED_MAP)
|
||||
|| player.getItemInHand().getType() == Material.EMPTY_MAP)
|
||||
&& player.getItemInHand().getDurability() == event.getMap().getId()) {
|
||||
final Location playerLoc = player.getLocation();
|
||||
final MapView map = event.getMap();
|
||||
|
||||
@@ -9,7 +9,6 @@ package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
@@ -22,7 +21,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
public class MVPlayerChatListener extends MVChatListener {
|
||||
public MVPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
|
||||
super(plugin, playerListener);
|
||||
Logging.fine("Registered PlayerChatEvent listener.");
|
||||
plugin.log(Level.FINE, "Registered PlayerChatEvent listener.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,7 +71,7 @@ public class MVPlayerListener implements Listener {
|
||||
|
||||
|
||||
if (mvWorld.getBedRespawn() && event.isBedSpawn()) {
|
||||
Logging.fine("Spawning " + event.getPlayer().getName() + " at their bed");
|
||||
this.plugin.log(Level.FINE, "Spawning " + event.getPlayer().getName() + " at their bed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,15 +110,15 @@ public class MVPlayerListener implements Listener {
|
||||
public void playerJoin(PlayerJoinEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
if (!p.hasPlayedBefore()) {
|
||||
Logging.finer("Player joined for the FIRST time!");
|
||||
this.plugin.log(Level.FINER, "Player joined for the FIRST time!");
|
||||
if (plugin.getMVConfig().getFirstSpawnOverride()) {
|
||||
Logging.fine("Moving NEW player to(firstspawnoverride): "
|
||||
this.plugin.log(Level.FINE, "Moving NEW player to(firstspawnoverride): "
|
||||
+ worldManager.getFirstSpawnWorld().getSpawnLocation());
|
||||
this.sendPlayerToDefaultWorld(p);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
Logging.finer("Player joined AGAIN!");
|
||||
this.plugin.log(Level.FINER, "Player joined AGAIN!");
|
||||
if (this.plugin.getMVConfig().getEnforceAccess() // check this only if we're enforcing access!
|
||||
&& !this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + p.getWorld().getName(), false)) {
|
||||
p.sendMessage("[MV] - Sorry you can't be in this world anymore!");
|
||||
@@ -156,7 +156,7 @@ public class MVPlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void playerTeleport(PlayerTeleportEvent event) {
|
||||
Logging.finer("Got teleport event for player '"
|
||||
this.plugin.log(Level.FINER, "Got teleport event for player '"
|
||||
+ event.getPlayer().getName() + "' with cause '" + event.getCause() + "'");
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@@ -166,25 +166,25 @@ public class MVPlayerListener implements Listener {
|
||||
String teleporterName = MultiverseCore.getPlayerTeleporter(teleportee.getName());
|
||||
if (teleporterName != null) {
|
||||
if (teleporterName.equals("CONSOLE")) {
|
||||
Logging.finer("We know the teleporter is the console! Magical!");
|
||||
this.plugin.log(Level.FINER, "We know the teleporter is the console! Magical!");
|
||||
teleporter = this.plugin.getServer().getConsoleSender();
|
||||
} else {
|
||||
teleporter = this.plugin.getServer().getPlayerExact(teleporterName);
|
||||
teleporter = this.plugin.getServer().getPlayer(teleporterName);
|
||||
}
|
||||
}
|
||||
Logging.finer("Inferred sender '" + teleporter + "' from name '"
|
||||
this.plugin.log(Level.FINER, "Inferred sender '" + teleporter + "' from name '"
|
||||
+ teleporterName + "', fetched from name '" + teleportee.getName() + "'");
|
||||
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
|
||||
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
|
||||
if (toWorld == null) {
|
||||
Logging.fine("Player '" + teleportee.getName() + "' is teleporting to world '"
|
||||
this.plugin.log(Level.FINE, "Player '" + teleportee.getName() + "' is teleporting to world '"
|
||||
+ event.getTo().getWorld().getName() + "' which is not managed by Multiverse-Core. No further "
|
||||
+ "actions will be taken by Multiverse-Core.");
|
||||
return;
|
||||
}
|
||||
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
|
||||
// The player is Teleporting to the same world.
|
||||
Logging.finer("Player '" + teleportee.getName() + "' is teleporting to the same world.");
|
||||
this.plugin.log(Level.FINER, "Player '" + teleportee.getName() + "' is teleporting to the same world.");
|
||||
this.stateSuccess(teleportee.getName(), toWorld.getAlias());
|
||||
return;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public class MVPlayerListener implements Listener {
|
||||
// Charge the teleporter
|
||||
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, teleporter, teleportee, true));
|
||||
if (event.isCancelled() && teleporter != null) {
|
||||
Logging.fine("Player '" + teleportee.getName()
|
||||
this.plugin.log(Level.FINE, "Player '" + teleportee.getName()
|
||||
+ "' was DENIED ACCESS to '" + toWorld.getAlias()
|
||||
+ "' because '" + teleporter.getName()
|
||||
+ "' don't have the FUNDS required to enter it.");
|
||||
@@ -203,14 +203,14 @@ public class MVPlayerListener implements Listener {
|
||||
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee));
|
||||
if (event.isCancelled() && teleporter != null) {
|
||||
Logging.fine("Player '" + teleportee.getName()
|
||||
this.plugin.log(Level.FINE, "Player '" + teleportee.getName()
|
||||
+ "' was DENIED ACCESS to '" + toWorld.getAlias()
|
||||
+ "' because '" + teleporter.getName()
|
||||
+ "' don't have: multiverse.access." + event.getTo().getWorld().getName());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Logging.fine("Player '" + teleportee.getName()
|
||||
this.plugin.log(Level.FINE, "Player '" + teleportee.getName()
|
||||
+ "' was allowed to go to '" + toWorld.getAlias() + "' because enforceaccess is off.");
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public class MVPlayerListener implements Listener {
|
||||
if (toWorld.getCBWorld().getPlayers().size() >= toWorld.getPlayerLimit()) {
|
||||
// Ouch the world is full, lets see if the player can bypass that limitation
|
||||
if (!pt.playerCanBypassPlayerLimit(toWorld, teleporter, teleportee)) {
|
||||
Logging.fine("Player '" + teleportee.getName()
|
||||
this.plugin.log(Level.FINE, "Player '" + teleportee.getName()
|
||||
+ "' was DENIED ACCESS to '" + toWorld.getAlias()
|
||||
+ "' because the world is full and '" + teleporter.getName()
|
||||
+ "' doesn't have: mv.bypass.playerlimit." + event.getTo().getWorld().getName());
|
||||
@@ -235,7 +235,7 @@ public class MVPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
private void stateSuccess(String playerName, String worldName) {
|
||||
Logging.fine("MV-Core is allowing Player '" + playerName
|
||||
this.plugin.log(Level.FINE, "MV-Core is allowing Player '" + playerName
|
||||
+ "' to go to '" + worldName + "'.");
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ public class MVPlayerListener implements Listener {
|
||||
|
||||
// REMEMBER! getTo MAY be NULL HERE!!!
|
||||
// If the player was actually outside of the portal, adjust the from location
|
||||
if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.NETHER_PORTAL) {
|
||||
if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.PORTAL) {
|
||||
Location newloc = this.plugin.getSafeTTeleporter().findPortalBlockNextTo(event.getFrom());
|
||||
// TODO: Fix this. Currently, we only check for PORTAL blocks. I'll have to figure out what
|
||||
// TODO: we want to do here.
|
||||
@@ -282,12 +282,12 @@ public class MVPlayerListener implements Listener {
|
||||
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
|
||||
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
|
||||
// The player is Portaling to the same world.
|
||||
Logging.finer("Player '" + event.getPlayer().getName() + "' is portaling to the same world.");
|
||||
this.plugin.log(Level.FINER, "Player '" + event.getPlayer().getName() + "' is portaling to the same world.");
|
||||
return;
|
||||
}
|
||||
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, event.getPlayer(), event.getPlayer(), true));
|
||||
if (event.isCancelled()) {
|
||||
Logging.fine("Player '" + event.getPlayer().getName()
|
||||
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName()
|
||||
+ "' was DENIED ACCESS to '" + event.getTo().getWorld().getName()
|
||||
+ "' because they don't have the FUNDS required to enter.");
|
||||
return;
|
||||
@@ -295,17 +295,25 @@ public class MVPlayerListener implements Listener {
|
||||
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer()));
|
||||
if (event.isCancelled()) {
|
||||
Logging.fine("Player '" + event.getPlayer().getName()
|
||||
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName()
|
||||
+ "' was DENIED ACCESS to '" + event.getTo().getWorld().getName()
|
||||
+ "' because they don't have: multiverse.access." + event.getTo().getWorld().getName());
|
||||
}
|
||||
} else {
|
||||
Logging.fine("Player '" + event.getPlayer().getName()
|
||||
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName()
|
||||
+ "' was allowed to go to '" + event.getTo().getWorld().getName()
|
||||
+ "' because enforceaccess is off.");
|
||||
}
|
||||
if (!plugin.getMVConfig().isUsingDefaultPortalSearch()) {
|
||||
event.setSearchRadius(this.plugin.getMVConfig().getPortalSearchRadius());
|
||||
try {
|
||||
Class.forName("org.bukkit.TravelAgent");
|
||||
if (event.getPortalTravelAgent() != null) {
|
||||
event.getPortalTravelAgent().setSearchRadius(plugin.getMVConfig().getPortalSearchRadius());
|
||||
}
|
||||
} catch (ClassNotFoundException ignore) {
|
||||
plugin.log(Level.FINE, "TravelAgent not available for PlayerPortalEvent for " + event.getPlayer().getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,7 +335,7 @@ public class MVPlayerListener implements Listener {
|
||||
if (mvWorld != null) {
|
||||
this.handleGameModeAndFlight(player, mvWorld);
|
||||
} else {
|
||||
Logging.finer("Not handling gamemode and flight for world '" + world.getName()
|
||||
this.plugin.log(Level.FINER, "Not handling gamemode and flight for world '" + world.getName()
|
||||
+ "' not managed by Multiverse.");
|
||||
}
|
||||
}
|
||||
@@ -368,7 +376,7 @@ public class MVPlayerListener implements Listener {
|
||||
player.getName(), player.getWorld().getName(), world.getName());
|
||||
}
|
||||
} else {
|
||||
Logging.fine("Player: " + player.getName() + " is IMMUNE to gamemode changes!");
|
||||
MVPlayerListener.this.plugin.log(Level.FINE, "Player: " + player.getName() + " is IMMUNE to gamemode changes!");
|
||||
}
|
||||
}
|
||||
}, 1L);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.Material;
|
||||
@@ -57,7 +56,7 @@ public class MVPortalListener implements Listener {
|
||||
public void portalForm(PortalCreateEvent event) {
|
||||
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld());
|
||||
if (world != null && !world.getAllowedPortals().isPortalAllowed(PortalType.NETHER)) {
|
||||
Logging.fine("Cancelling creation of nether portal because portalForm disallows.");
|
||||
plugin.log(Level.FINE, "Cancelling creation of nether portal because portalForm disallows.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -72,15 +71,15 @@ public class MVPortalListener implements Listener {
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
if (event.getClickedBlock().getType() != Material.END_PORTAL_FRAME) {
|
||||
if (event.getClickedBlock().getType() != Material.ENDER_PORTAL_FRAME) {
|
||||
return;
|
||||
}
|
||||
if (event.getItem() == null || event.getItem().getType() != Material.ENDER_EYE) {
|
||||
if (event.getItem() == null || event.getItem().getType() != Material.EYE_OF_ENDER) {
|
||||
return;
|
||||
}
|
||||
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getPlayer().getWorld());
|
||||
if (world != null && !world.getAllowedPortals().isPortalAllowed(PortalType.ENDER)) {
|
||||
Logging.fine("Cancelling creation of ender portal because portalForm disallows.");
|
||||
plugin.log(Level.FINE, "Cancelling creation of ender portal because portalForm disallows.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class AnchorManager {
|
||||
this.anchorConfig.save(new File(this.plugin.getDataFolder(), "anchors.yml"));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Logging.severe("Failed to save anchors.yml. Please check your file permissions.");
|
||||
this.plugin.log(Level.SEVERE, "Failed to save anchors.yml. Please check your file permissions.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.destination.CannonDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TravelAgent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
|
||||
public class BukkitTravelAgent implements TravelAgent {
|
||||
private final MVTravelAgent agent;
|
||||
|
||||
public BukkitTravelAgent(MVTravelAgent agent) {
|
||||
this.agent = agent;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public BukkitTravelAgent setSearchRadius(int radius) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getSearchRadius() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public BukkitTravelAgent setCreationRadius(int radius) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getCreationRadius() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean getCanCreatePortal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setCanCreatePortal(boolean create) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location findOrCreate(Location location) {
|
||||
return this.getSafeLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location findPortal(Location location) {
|
||||
return this.getSafeLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean createPortal(Location location) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private Location getSafeLocation() {
|
||||
// At this time, these can never use the velocity.
|
||||
if (agent.destination instanceof CannonDestination) {
|
||||
agent.core.log(Level.FINE, "Using Stock TP method. This cannon will have 0 velocity");
|
||||
}
|
||||
SafeTTeleporter teleporter = agent.core.getSafeTTeleporter();
|
||||
Location newLoc = agent.destination.getLocation(agent.player);
|
||||
if (agent.destination.useSafeTeleporter()) {
|
||||
newLoc = teleporter.getSafeLocation(agent.player, agent.destination);
|
||||
}
|
||||
if (newLoc == null) {
|
||||
return agent.player.getLocation();
|
||||
}
|
||||
return newLoc;
|
||||
|
||||
}
|
||||
|
||||
public void setPortalEventTravelAgent(PlayerPortalEvent event) {
|
||||
event.setPortalTravelAgent(this);
|
||||
event.useTravelAgent(true);
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Stream;
|
||||
@@ -72,30 +70,19 @@ public class FileUtils {
|
||||
* Helper method to copy the world-folder.
|
||||
* @param source Source-File
|
||||
* @param target Target-File
|
||||
* @param log A logger that logs the operation
|
||||
*
|
||||
* @return true if it had success
|
||||
* @return if it had success
|
||||
*/
|
||||
public static boolean copyFolder(File source, File target) {
|
||||
return copyFolder(source, target, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to copy the world-folder.
|
||||
* @param source Source-File
|
||||
* @param target Target-File
|
||||
* @param excludeFiles files to ignore and not copy over to Target-File
|
||||
*
|
||||
* @return true if it had success
|
||||
*/
|
||||
public static boolean copyFolder(File source, File target, List<String> excludeFiles) {
|
||||
public static boolean copyFolder(File source, File target, Logger log) {
|
||||
Path sourceDir = source.toPath();
|
||||
Path targetDir = target.toPath();
|
||||
|
||||
try {
|
||||
Files.walkFileTree(sourceDir, new CopyDirFileVisitor(sourceDir, targetDir, excludeFiles));
|
||||
Files.walkFileTree(sourceDir, new CopyDirFileVisitor(sourceDir, targetDir));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Logging.warning("Unable to copy directory", e);
|
||||
log.log(Level.WARNING, "Unable to copy directory", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -104,12 +91,10 @@ public class FileUtils {
|
||||
|
||||
private final Path sourceDir;
|
||||
private final Path targetDir;
|
||||
private final List<String> excludeFiles;
|
||||
|
||||
private CopyDirFileVisitor(Path sourceDir, Path targetDir, List<String> excludeFiles) {
|
||||
private CopyDirFileVisitor(Path sourceDir, Path targetDir) {
|
||||
this.sourceDir = sourceDir;
|
||||
this.targetDir = targetDir;
|
||||
this.excludeFiles = excludeFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,13 +108,9 @@ public class FileUtils {
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
// Pass files that are set to ignore
|
||||
if (excludeFiles != null && excludeFiles.contains(file.getFileName().toString()))
|
||||
return FileVisitResult.CONTINUE;
|
||||
// Copy the files
|
||||
Path targetFile = targetDir.resolve(sourceDir.relativize(file));
|
||||
Files.copy(file, targetFile, COPY_ATTRIBUTES);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
@@ -101,7 +100,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
||||
// If we're not enforcing access, anyone can enter.
|
||||
if (!plugin.getMVConfig().getEnforceAccess()) {
|
||||
Logging.finest("EnforceAccess is OFF. Player was allowed in " + w.getAlias());
|
||||
this.plugin.log(Level.FINEST, "EnforceAccess is OFF. Player was allowed in " + w.getAlias());
|
||||
return true;
|
||||
}
|
||||
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
||||
@@ -258,14 +257,14 @@ public class MVPermissions implements PermissionsInterface {
|
||||
|
||||
boolean hasPermission = sender.hasPermission(node);
|
||||
if (!sender.isPermissionSet(node)) {
|
||||
Logging.finer(String.format("The node [%s%s%s] was %sNOT%s set for [%s%s%s].",
|
||||
this.plugin.log(Level.FINER, String.format("The node [%s%s%s] was %sNOT%s set for [%s%s%s].",
|
||||
ChatColor.RED, node, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE, ChatColor.AQUA,
|
||||
player.getDisplayName(), ChatColor.WHITE));
|
||||
}
|
||||
if (hasPermission) {
|
||||
Logging.finer("Checking to see if player [" + player.getName() + "] has permission [" + node + "]... YES");
|
||||
this.plugin.log(Level.FINER, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]... YES");
|
||||
} else {
|
||||
Logging.finer("Checking to see if player [" + player.getName() + "] has permission [" + node + "]... NO");
|
||||
this.plugin.log(Level.FINER, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]... NO");
|
||||
}
|
||||
return hasPermission;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* The Multiverse TravelAgent.
|
||||
*/
|
||||
public class MVTravelAgent {
|
||||
protected MVDestination destination;
|
||||
protected MultiverseCore core;
|
||||
protected Player player;
|
||||
|
||||
public MVTravelAgent(MultiverseCore multiverseCore, MVDestination d, Player p) {
|
||||
this.destination = d;
|
||||
this.core = multiverseCore;
|
||||
this.player = p;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.Material;
|
||||
@@ -196,7 +195,7 @@ public class PermissionTools {
|
||||
* @return True if they can't go to the world, False if they can.
|
||||
*/
|
||||
public boolean playerCanGoFromTo(MultiverseWorld fromWorld, MultiverseWorld toWorld, CommandSender teleporter, Player teleportee) {
|
||||
Logging.finest("Checking '" + teleporter + "' can send '" + teleportee + "' somewhere");
|
||||
this.plugin.log(Level.FINEST, "Checking '" + teleporter + "' can send '" + teleportee + "' somewhere");
|
||||
|
||||
Player teleporterPlayer;
|
||||
if (plugin.getMVConfig().getTeleportIntercept()) {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
|
||||
@@ -87,7 +86,7 @@ public class PurgeWorlds {
|
||||
}
|
||||
int entitiesKilled = 0;
|
||||
for (Entity e : world.getEntities()) {
|
||||
Logging.finest("Entity list (aval for purge) from WORLD < " + mvworld.getName() + " >: " + e.toString());
|
||||
this.plugin.log(Level.FINEST, "Entity list (aval for purge) from WORLD < " + mvworld.getName() + " >: " + e.toString());
|
||||
|
||||
// Check against Monsters
|
||||
if (killMonster(mvworld, e, thingsToKill, negateMonsters)) {
|
||||
@@ -134,16 +133,16 @@ public class PurgeWorlds {
|
||||
entityName = e.toString().replaceAll("Craft", "").toUpperCase();
|
||||
}
|
||||
if (e instanceof Slime || e instanceof Monster || e instanceof Ghast || e instanceof EnderDragon) {
|
||||
Logging.finest("Looking at a monster: " + e);
|
||||
this.plugin.log(Level.FINEST, "Looking at a monster: " + e);
|
||||
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("MONSTERS")) {
|
||||
if (!negate) {
|
||||
Logging.finest("Removing a monster: " + e);
|
||||
this.plugin.log(Level.FINEST, "Removing a monster: " + e);
|
||||
e.remove();
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (negate) {
|
||||
Logging.finest("Removing a monster: " + e);
|
||||
this.plugin.log(Level.FINEST, "Removing a monster: " + e);
|
||||
e.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,9 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Bed;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.material.Bed;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
@@ -152,13 +151,12 @@ public class SimpleBlockSafety implements BlockSafety {
|
||||
* @return The location of the other bed piece, or null if it was a jacked up bed.
|
||||
*/
|
||||
private Location findOtherBedPiece(Location checkLoc) {
|
||||
BlockData data = checkLoc.getBlock().getBlockData();
|
||||
if (!(data instanceof Bed)) {
|
||||
if (checkLoc.getBlock().getType() != Material.BED_BLOCK) {
|
||||
return null;
|
||||
}
|
||||
Bed b = (Bed) data;
|
||||
|
||||
if (b.getPart() == Bed.Part.HEAD) {
|
||||
// Construct a bed object at this location
|
||||
final Bed b = new Bed(Material.BED_BLOCK, checkLoc.getBlock().getData());
|
||||
if (b.isHeadOfBed()) {
|
||||
return checkLoc.getBlock().getRelative(b.getFacing().getOppositeFace()).getLocation();
|
||||
}
|
||||
// We shouldn't ever be looking at the foot, but here's the code for it.
|
||||
@@ -211,10 +209,7 @@ public class SimpleBlockSafety implements BlockSafety {
|
||||
@Override
|
||||
public boolean isEntitiyOnTrack(Location l) {
|
||||
Material currentBlock = l.getBlock().getType();
|
||||
return (currentBlock == Material.POWERED_RAIL
|
||||
|| currentBlock == Material.DETECTOR_RAIL
|
||||
|| currentBlock == Material.RAIL
|
||||
|| currentBlock == Material.ACTIVATOR_RAIL);
|
||||
return (currentBlock == Material.POWERED_RAIL || currentBlock == Material.DETECTOR_RAIL || currentBlock == Material.RAILS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -53,7 +52,7 @@ public class SimpleLocationManipulation implements LocationManipulation {
|
||||
if (location == null) {
|
||||
return "";
|
||||
}
|
||||
return String.format(Locale.ENGLISH, "%s:%.2f,%.2f,%.2f:%.2f:%.2f", location.getWorld().getName(),
|
||||
return String.format("%s:%.2f,%.2f,%.2f:%.2f:%.2f", location.getWorld().getName(),
|
||||
location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
@@ -59,9 +58,9 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
||||
if (safe != null) {
|
||||
safe.setX(safe.getBlockX() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
safe.setZ(safe.getBlockZ() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
Logging.fine("Hey! I found one: " + plugin.getLocationManipulation().strCoordsRaw(safe));
|
||||
this.plugin.log(Level.FINE, "Hey! I found one: " + plugin.getLocationManipulation().strCoordsRaw(safe));
|
||||
} else {
|
||||
Logging.fine("Uh oh! No safe place found!");
|
||||
this.plugin.log(Level.FINE, "Uh oh! No safe place found!");
|
||||
}
|
||||
return safe;
|
||||
}
|
||||
@@ -73,8 +72,8 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
||||
}
|
||||
// We want half of it, so we can go up and down
|
||||
tolerance /= 2;
|
||||
Logging.finer("Given Location of: " + plugin.getLocationManipulation().strCoordsRaw(l));
|
||||
Logging.finer("Checking +-" + tolerance + " with a radius of " + radius);
|
||||
this.plugin.log(Level.FINER, "Given Location of: " + plugin.getLocationManipulation().strCoordsRaw(l));
|
||||
this.plugin.log(Level.FINER, "Checking +-" + tolerance + " with a radius of " + radius);
|
||||
|
||||
// For now this will just do a straight up block.
|
||||
Location locToCheck = l.clone();
|
||||
@@ -192,7 +191,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
||||
@Override
|
||||
public TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d) {
|
||||
if (d instanceof InvalidDestination) {
|
||||
Logging.finer("Entity tried to teleport to an invalid destination");
|
||||
this.plugin.log(Level.FINER, "Entity tried to teleport to an invalid destination");
|
||||
return TeleportResult.FAIL_INVALID;
|
||||
}
|
||||
Player teleporteePlayer = null;
|
||||
@@ -249,7 +248,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
||||
public Location getSafeLocation(Entity e, MVDestination d) {
|
||||
Location l = d.getLocation(e);
|
||||
if (plugin.getBlockSafety().playerCanSpawnHereSafely(l)) {
|
||||
Logging.fine("The first location you gave me was safe.");
|
||||
plugin.log(Level.FINE, "The first location you gave me was safe.");
|
||||
return l;
|
||||
}
|
||||
if (e instanceof Minecart) {
|
||||
@@ -268,21 +267,21 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
||||
// Add offset to account for a vehicle on dry land!
|
||||
if (e instanceof Minecart && !plugin.getBlockSafety().isEntitiyOnTrack(safeLocation)) {
|
||||
safeLocation.setY(safeLocation.getBlockY() + .5);
|
||||
Logging.finer("Player was inside a minecart. Offsetting Y location.");
|
||||
this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location.");
|
||||
}
|
||||
Logging.finer("Had to look for a bit, but I found a safe place for ya!");
|
||||
this.plugin.log(Level.FINE, "Had to look for a bit, but I found a safe place for ya!");
|
||||
return safeLocation;
|
||||
}
|
||||
if (e instanceof Player) {
|
||||
Player p = (Player) e;
|
||||
this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false);
|
||||
Logging.finer("No safe location found for " + p.getName());
|
||||
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
|
||||
} else if (e.getPassenger() instanceof Player) {
|
||||
Player p = (Player) e.getPassenger();
|
||||
this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false);
|
||||
Logging.finer("No safe location found for " + p.getName());
|
||||
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
|
||||
}
|
||||
Logging.fine("Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
|
||||
this.plugin.log(Level.FINE, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -293,19 +292,19 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
||||
public Location findPortalBlockNextTo(Location l) {
|
||||
Block b = l.getWorld().getBlockAt(l);
|
||||
Location foundLocation = null;
|
||||
if (b.getType() == Material.NETHER_PORTAL) {
|
||||
if (b.getType() == Material.PORTAL) {
|
||||
return l;
|
||||
}
|
||||
if (b.getRelative(BlockFace.NORTH).getType() == Material.NETHER_PORTAL) {
|
||||
if (b.getRelative(BlockFace.NORTH).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.NORTH).getLocation(), foundLocation);
|
||||
}
|
||||
if (b.getRelative(BlockFace.SOUTH).getType() == Material.NETHER_PORTAL) {
|
||||
if (b.getRelative(BlockFace.SOUTH).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.SOUTH).getLocation(), foundLocation);
|
||||
}
|
||||
if (b.getRelative(BlockFace.EAST).getType() == Material.NETHER_PORTAL) {
|
||||
if (b.getRelative(BlockFace.EAST).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.EAST).getLocation(), foundLocation);
|
||||
}
|
||||
if (b.getRelative(BlockFace.WEST).getType() == Material.NETHER_PORTAL) {
|
||||
if (b.getRelative(BlockFace.WEST).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.WEST).getLocation(), foundLocation);
|
||||
}
|
||||
return foundLocation;
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Golem;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Phantom;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Squid;
|
||||
@@ -149,7 +148,7 @@ public class SimpleWorldPurger implements WorldPurger {
|
||||
if (specifiedAnimals)
|
||||
specified = true;
|
||||
negate = negateAnimals;
|
||||
} else if (e instanceof Monster || e instanceof Ghast || e instanceof Slime || e instanceof Phantom) {
|
||||
} else if (e instanceof Monster || e instanceof Ghast || e instanceof Slime) {
|
||||
// it's a monster
|
||||
if (specifiedMonsters && !negateMonsters) {
|
||||
Logging.finest("Removing an entity because I was told to remove all monsters in world %s: %s", e.getWorld().getName(), e);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
/**
|
||||
* A utility class that enables automated tests to flag Multiverse for testing. This allows Multiverse to not perform
|
||||
* certain behaviors such as enabled stats uploads.
|
||||
*/
|
||||
public class TestingMode {
|
||||
|
||||
private static boolean enabled = false;
|
||||
|
||||
public static void enable() {
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
public static boolean isDisabled() {
|
||||
return !enabled;
|
||||
}
|
||||
}
|
||||
@@ -43,19 +43,15 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Public facing API to add/remove Multiverse worlds.
|
||||
*/
|
||||
public class WorldManager implements MVWorldManager {
|
||||
private final MultiverseCore plugin;
|
||||
private final Pattern worldNamePattern = Pattern.compile("[a-zA-Z0-9/._-]+");
|
||||
private final WorldPurger worldPurger;
|
||||
private final Map<String, MultiverseWorld> worlds;
|
||||
private Map<String, WorldProperties> worldsFromTheConfig;
|
||||
@@ -91,7 +87,7 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Logging.warning("Could not read 'bukkit.yml'. Any Default worldgenerators will not be loaded!");
|
||||
this.plugin.log(Level.WARNING, "Could not read 'bukkit.yml'. Any Default worldgenerators will not be loaded!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,18 +125,12 @@ public class WorldManager implements MVWorldManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for valid world name
|
||||
if (!(isValidWorldName(oldName) && isValidWorldName(newName))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final File oldWorldFile = new File(this.plugin.getServer().getWorldContainer(), oldName);
|
||||
final File newWorldFile = new File(this.plugin.getServer().getWorldContainer(), newName);
|
||||
final List<String> ignoreFiles = new ArrayList<>(Arrays.asList("session.lock", "uid.dat"));
|
||||
|
||||
// Make sure the new world doesn't exist outside of multiverse.
|
||||
if (newWorldFile.exists()) {
|
||||
Logging.warning("Folder for new world '%s' already exists", newName);
|
||||
Logging.warning("File for new world '%s' already exists", newName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -162,8 +152,14 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
|
||||
// Grab a bit of metadata from the old world.
|
||||
MultiverseWorld oldWorld = getMVWorld(oldName);
|
||||
|
||||
MVWorld oldWorld = (MVWorld) getMVWorld(oldName);
|
||||
Environment environment = oldWorld.getEnvironment();
|
||||
String seedString = oldWorld.getSeed() + "";
|
||||
WorldType worldType = oldWorld.getWorldType();
|
||||
Boolean generateStructures = oldWorld.getCBWorld().canGenerateStructures();
|
||||
String generator = oldWorld.getGenerator();
|
||||
boolean useSpawnAdjust = oldWorld.getAdjustSpawn();
|
||||
|
||||
// Don't need the loaded world anymore.
|
||||
if (wasJustLoaded) {
|
||||
this.unloadWorld(oldName, true);
|
||||
@@ -181,40 +177,32 @@ public class WorldManager implements MVWorldManager {
|
||||
oldWorld.getCBWorld().save();
|
||||
}
|
||||
Logging.config("Copying files for world '%s'", oldName);
|
||||
if (!FileUtils.copyFolder(oldWorldFile, newWorldFile, ignoreFiles)) {
|
||||
if (!FileUtils.copyFolder(oldWorldFile, newWorldFile, Logging.getLogger())) {
|
||||
Logging.warning("Failed to copy files for world '%s', see the log info", newName);
|
||||
return false;
|
||||
}
|
||||
if (oldWorld != null && wasAutoSave) {
|
||||
oldWorld.getCBWorld().setAutoSave(true);
|
||||
}
|
||||
|
||||
if (newWorldFile.exists()) {
|
||||
Logging.fine("Succeeded at copying files");
|
||||
|
||||
// initialize new properties with old ones
|
||||
WorldProperties newProps = new WorldProperties();
|
||||
newProps.copyValues(this.worldsFromTheConfig.get(oldName));
|
||||
// don't keep the alias the same -- that would be useless
|
||||
newProps.setAlias("");
|
||||
// store the new properties in worlds config map
|
||||
this.worldsFromTheConfig.put(newName, newProps);
|
||||
|
||||
// save the worlds config to disk (worlds.yml)
|
||||
if (!saveWorldsConfig()) {
|
||||
Logging.severe("Failed to save worlds.yml");
|
||||
return false;
|
||||
}
|
||||
|
||||
// actually load the world
|
||||
if (doLoad(newName)) {
|
||||
Logging.fine("Succeeded at loading cloned world '" + newName + "'");
|
||||
return true;
|
||||
}
|
||||
Logging.severe("Failed to load the cloned world '" + newName + "'");
|
||||
File uidFile = new File(newWorldFile, "uid.dat");
|
||||
if (uidFile.exists() && !uidFile.delete()) {
|
||||
Logging.warning("Failed to delete unique ID file for world '%s'", newName);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newWorldFile.exists()) {
|
||||
Logging.fine("Succeeded at copying files");
|
||||
if (this.addWorld(newName, environment, seedString, worldType, generateStructures, generator, useSpawnAdjust)) {
|
||||
// getMVWorld() doesn't actually return an MVWorld
|
||||
Logging.fine("Succeeded at importing world");
|
||||
MVWorld newWorld = (MVWorld) this.getMVWorld(newName);
|
||||
newWorld.copyValues(this.worldsFromTheConfig.get(oldName));
|
||||
// don't keep the alias the same -- that would be useless
|
||||
newWorld.setAlias(null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Logging.warning("Failed to copy files for world '%s', see the log info", newName);
|
||||
return false;
|
||||
}
|
||||
@@ -237,11 +225,6 @@ public class WorldManager implements MVWorldManager {
|
||||
if (name.equalsIgnoreCase("plugins") || name.equalsIgnoreCase("logs")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isValidWorldName(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Long seed = null;
|
||||
WorldCreator c = new WorldCreator(name);
|
||||
if (seedString != null && seedString.length() > 0) {
|
||||
@@ -284,7 +267,7 @@ public class WorldManager implements MVWorldManager {
|
||||
Logging.info(builder.toString());
|
||||
|
||||
if (!doLoad(c, true)) {
|
||||
Logging.severe("Failed to Create/Load the world '" + name + "'");
|
||||
this.plugin.log(Level.SEVERE, "Failed to Create/Load the world '" + name + "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -357,7 +340,7 @@ public class WorldManager implements MVWorldManager {
|
||||
MultiverseWorld world = this.getMVWorld(this.firstSpawn);
|
||||
if (world == null) {
|
||||
// If the spawn world was unloaded, get the default world
|
||||
Logging.warning("The world specified as the spawn world (" + this.firstSpawn + ") did not exist!!");
|
||||
this.plugin.log(Level.WARNING, "The world specified as the spawn world (" + this.firstSpawn + ") did not exist!!");
|
||||
try {
|
||||
return this.getMVWorld(this.plugin.getServer().getWorlds().get(0));
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
@@ -424,31 +407,16 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the world name is allowed
|
||||
*
|
||||
* @param name Name of the world
|
||||
* @return True if the world world name is valid based on regex
|
||||
*/
|
||||
private boolean isValidWorldName(String name) {
|
||||
if (!worldNamePattern.matcher(name).matches()) {
|
||||
Logging.warning("Invalid world name '" + name + "'");
|
||||
Logging.warning("World name should not contain spaces or special characters!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void brokenWorld(String name) {
|
||||
Logging.severe("The world '" + name + "' could NOT be loaded because it contains errors and is probably corrupt!");
|
||||
Logging.severe("Try using Minecraft Region Fixer to repair your world! '" + name + "'");
|
||||
Logging.severe("https://github.com/Fenixin/Minecraft-Region-Fixer");
|
||||
this.plugin.log(Level.SEVERE, "The world '" + name + "' could NOT be loaded because it contains errors and is probably corrupt!");
|
||||
this.plugin.log(Level.SEVERE, "Try using Minecraft Region Fixer to repair your world! '" + name + "'");
|
||||
this.plugin.log(Level.SEVERE, "https://github.com/Fenixin/Minecraft-Region-Fixer");
|
||||
}
|
||||
|
||||
private void nullWorld(String name) {
|
||||
Logging.severe("The world '" + name + "' could NOT be loaded because the server didn't like it!");
|
||||
Logging.severe("We don't really know why this is. Contact the developer of your server software!");
|
||||
Logging.severe("Server version info: " + Bukkit.getServer().getVersion());
|
||||
this.plugin.log(Level.SEVERE, "The world '" + name + "' could NOT be loaded because the server didn't like it!");
|
||||
this.plugin.log(Level.SEVERE, "We don't really know why this is. Contact the developer of your server software!");
|
||||
this.plugin.log(Level.SEVERE, "Server version info: " + Bukkit.getServer().getVersion());
|
||||
}
|
||||
|
||||
private boolean doLoad(String name) {
|
||||
@@ -488,8 +456,8 @@ public class WorldManager implements MVWorldManager {
|
||||
throw new IllegalArgumentException("That world is already loaded!");
|
||||
|
||||
if (!ignoreExists && !new File(this.plugin.getServer().getWorldContainer(), worldName).exists() && !new File(this.plugin.getServer().getWorldContainer().getParent(), worldName).exists()) {
|
||||
Logging.warning("WorldManager: Can't load this world because the folder was deleted/moved: " + worldName);
|
||||
Logging.warning("Use '/mv remove' to remove it from the config!");
|
||||
this.plugin.log(Level.WARNING, "WorldManager: Can't load this world because the folder was deleted/moved: " + worldName);
|
||||
this.plugin.log(Level.WARNING, "Use '/mv remove' to remove it from the config!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -519,13 +487,6 @@ public class WorldManager implements MVWorldManager {
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder) {
|
||||
if (this.hasUnloadedWorld(name, false)) {
|
||||
// Attempt to load if unloaded so we can actually delete the world
|
||||
if (!this.doLoad(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
World world = this.plugin.getServer().getWorld(name);
|
||||
if (world == null) {
|
||||
// We can only delete loaded worlds
|
||||
@@ -536,7 +497,7 @@ public class WorldManager implements MVWorldManager {
|
||||
MVWorldDeleteEvent mvwde = new MVWorldDeleteEvent(getMVWorld(name), removeFromConfig);
|
||||
this.plugin.getServer().getPluginManager().callEvent(mvwde);
|
||||
if (mvwde.isCancelled()) {
|
||||
Logging.fine("Tried to delete a world, but the event was cancelled!");
|
||||
this.plugin.log(Level.FINE, "Tried to delete a world, but the event was cancelled!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -552,7 +513,7 @@ public class WorldManager implements MVWorldManager {
|
||||
|
||||
try {
|
||||
File worldFile = world.getWorldFolder();
|
||||
Logging.finer("deleteWorld(): worldFile: " + worldFile.getAbsolutePath());
|
||||
plugin.log(Level.FINER, "deleteWorld(): worldFile: " + worldFile.getAbsolutePath());
|
||||
if (deleteWorldFolder ? FileUtils.deleteFolder(worldFile) : FileUtils.deleteFolderContents(worldFile)) {
|
||||
Logging.info("World '%s' was DELETED.", name);
|
||||
return true;
|
||||
@@ -866,7 +827,7 @@ public class WorldManager implements MVWorldManager {
|
||||
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Logging.severe("Could not save worlds.yml. Please check your settings.");
|
||||
this.plugin.log(Level.SEVERE, "Could not save worlds.yml. Please check your settings.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -938,9 +899,6 @@ public class WorldManager implements MVWorldManager {
|
||||
return this.configWorlds;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasUnloadedWorld(String name, boolean includeLoaded) {
|
||||
if (getMVWorld(name) != null) {
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.utils.metrics;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class MetricsConfigurator {
|
||||
|
||||
private static final int PLUGIN_ID = 7765;
|
||||
private static final String NO_GENERATOR_NAME = "N/A";
|
||||
|
||||
public static void configureMetrics(MultiverseCore plugin) {
|
||||
MetricsConfigurator configurator = new MetricsConfigurator(plugin);
|
||||
configurator.initMetrics();
|
||||
}
|
||||
|
||||
private final MultiverseCore plugin;
|
||||
private final Metrics metrics;
|
||||
|
||||
private MetricsConfigurator(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.metrics = new Metrics(plugin, PLUGIN_ID);
|
||||
}
|
||||
|
||||
private MVWorldManager getWorldManager() {
|
||||
return plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
private Collection<MultiverseWorld> getMVWorlds() {
|
||||
return getWorldManager().getMVWorlds();
|
||||
}
|
||||
|
||||
private void initMetrics() {
|
||||
try {
|
||||
addCustomGeneratorsMetric();
|
||||
addEnvironmentsMetric();
|
||||
addWorldCountMetric();
|
||||
|
||||
Logging.fine("Metrics enabled.");
|
||||
} catch (Exception e) {
|
||||
Logging.warning("There was an issue while enabling metrics:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void addCustomGeneratorsMetric() {
|
||||
addAdvancedPieMetric("custom_generators", map -> {
|
||||
for (MultiverseWorld w : getMVWorlds()) {
|
||||
MetricsHelper.incrementCount(map, getGeneratorName(w));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getGeneratorName(MultiverseWorld world) {
|
||||
String gen = world.getGenerator();
|
||||
return (gen != null && !gen.equalsIgnoreCase("null")) ? gen.split(":")[0] : NO_GENERATOR_NAME;
|
||||
}
|
||||
|
||||
private void addEnvironmentsMetric() {
|
||||
addAdvancedPieMetric("environments", map -> {
|
||||
for (MultiverseWorld w : getMVWorlds()) {
|
||||
MetricsHelper.incrementCount(map, titleCaseEnv(w.getEnvironment()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String titleCaseEnv(World.Environment env) {
|
||||
String envName = env.name().replaceAll("_+", " ");
|
||||
return WordUtils.capitalizeFully(envName);
|
||||
}
|
||||
|
||||
private void addWorldCountMetric() {
|
||||
addMultiLineMetric("world_count", map -> {
|
||||
int loadedWorldsCount = getMVWorlds().size();
|
||||
map.put("Loaded worlds", loadedWorldsCount);
|
||||
map.put("Total number of worlds", loadedWorldsCount + getWorldManager().getUnloadedWorlds().size());
|
||||
});
|
||||
}
|
||||
|
||||
private void addAdvancedPieMetric(String chartId, Consumer<Map<String, Integer>> metricsFunc) {
|
||||
metrics.addCustomChart(MetricsHelper.createAdvancedPieChart(chartId, metricsFunc));
|
||||
}
|
||||
|
||||
private void addMultiLineMetric(String chartId, Consumer<Map<String, Integer>> metricsFunc) {
|
||||
metrics.addCustomChart(MetricsHelper.createMultiLineChart(chartId, metricsFunc));
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.utils.metrics;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
|
||||
enum MetricsHelper {
|
||||
;
|
||||
|
||||
/**
|
||||
* Adds one to the value in the given map with the given key. If the key does not exist in the map, it will be added with a value of 1.
|
||||
*/
|
||||
static void incrementCount(Map<String, Integer> map, String key) {
|
||||
Integer count = map.getOrDefault(key, 0);
|
||||
map.put(key, count + 1);
|
||||
}
|
||||
|
||||
static Metrics.AdvancedPie createAdvancedPieChart(String chartId, Consumer<Map<String, Integer>> metricsFunc) {
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
metricsFunc.accept(map);
|
||||
return new Metrics.AdvancedPie(chartId, () -> map);
|
||||
}
|
||||
|
||||
static Metrics.MultiLineChart createMultiLineChart(String chartId, Consumer<Map<String, Integer>> metricsFunc) {
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
metricsFunc.accept(map);
|
||||
return new Metrics.MultiLineChart(chartId, () -> map);
|
||||
}
|
||||
|
||||
}
|
||||
+14
-36
@@ -1,43 +1,19 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import net.minidev.json.JSONObject;
|
||||
import net.minidev.json.parser.JSONParser;
|
||||
import net.minidev.json.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A {@link URLShortener} using {@code bit.ly}. Requires an access token.
|
||||
* An {@link URLShortener} using {@code bit.ly}.
|
||||
*/
|
||||
class BitlyURLShortener extends URLShortener {
|
||||
private static final String ACCESS_TOKEN = "Bearer bitly-access-token";
|
||||
private static final String BITLY_POST_REQUEST = "https://api-ssl.bitly.com/v4/shorten";
|
||||
public class BitlyURLShortener extends HttpAPIClient implements URLShortener {
|
||||
private static final String GENERIC_BITLY_REQUEST_FORMAT = "https://api-ssl.bitly.com/v3/shorten?format=txt&apiKey=%s&login=%s&longUrl=%s";
|
||||
|
||||
BitlyURLShortener() {
|
||||
super(BITLY_POST_REQUEST, ACCESS_TOKEN);
|
||||
if (ACCESS_TOKEN.endsWith("access-token")) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
// I think it's no problem that these are public
|
||||
private static final String USERNAME = "multiverse2";
|
||||
private static final String API_KEY = "R_9dbff4862a3bc0c4218a7d78cc10d0e0";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String encodeData(String data) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("domain", "j.mp");
|
||||
json.put("long_url", data);
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String encodeData(Map<String, String> data) {
|
||||
throw new UnsupportedOperationException();
|
||||
public BitlyURLShortener() {
|
||||
super(String.format(GENERIC_BITLY_REQUEST_FORMAT, API_KEY, USERNAME, "%s"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,11 +22,13 @@ class BitlyURLShortener extends URLShortener {
|
||||
@Override
|
||||
public String shorten(String longUrl) {
|
||||
try {
|
||||
String stringJSON = this.exec(encodeData(longUrl), ContentType.JSON);
|
||||
return (String) ((JSONObject) new JSONParser().parse(stringJSON)).get("link");
|
||||
} catch (IOException | ParseException e) {
|
||||
String result = this.exec(longUrl);
|
||||
if (!result.startsWith("http://j.mp/")) // ... then it's failed :/
|
||||
throw new IOException(result);
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return longUrl;
|
||||
return longUrl; // sorry ...
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import net.minidev.json.JSONObject;
|
||||
import net.minidev.json.parser.JSONParser;
|
||||
import net.minidev.json.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Pastes to {@code gist.github.com}. Requires an access token with the {@code gist} scope.
|
||||
*/
|
||||
class GitHubPasteService extends PasteService {
|
||||
private final boolean isPrivate;
|
||||
// this access token must have the "gist" scope
|
||||
private static final String ACCESS_TOKEN = "token github-access-token";
|
||||
private static final String GITHUB_POST_REQUEST = "https://api.github.com/gists";
|
||||
|
||||
GitHubPasteService(boolean isPrivate) {
|
||||
super(GITHUB_POST_REQUEST, ACCESS_TOKEN);
|
||||
this.isPrivate = isPrivate;
|
||||
if (ACCESS_TOKEN.endsWith("access-token")) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String encodeData(String data) {
|
||||
Map<String, String> mapData = new HashMap<String, String>();
|
||||
mapData.put("multiverse.txt", data);
|
||||
return this.encodeData(mapData);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String encodeData(Map<String, String> files) {
|
||||
JSONObject root = new JSONObject();
|
||||
root.put("description", "Multiverse-Core Debug Info");
|
||||
root.put("public", !this.isPrivate);
|
||||
JSONObject fileList = new JSONObject();
|
||||
for (Map.Entry<String, String> entry : files.entrySet()) {
|
||||
JSONObject fileObject = new JSONObject();
|
||||
fileObject.put("content", entry.getValue());
|
||||
fileList.put(entry.getKey(), fileObject);
|
||||
}
|
||||
|
||||
root.put("files", fileList);
|
||||
return root.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String postData(String data) throws PasteFailedException {
|
||||
try {
|
||||
String stringJSON = this.exec(encodeData(data), ContentType.JSON);
|
||||
return (String) ((JSONObject) new JSONParser().parse(stringJSON)).get("html_url");
|
||||
} catch (IOException | ParseException e) {
|
||||
throw new PasteFailedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String postData(Map<String, String> data) throws PasteFailedException {
|
||||
try {
|
||||
String stringJSON = this.exec(encodeData(data), ContentType.JSON);
|
||||
return (String) ((JSONObject) new JSONParser().parse(stringJSON)).get("html_url");
|
||||
} catch (IOException | ParseException e) {
|
||||
throw new PasteFailedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsMultiFile() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GithubPasteService implements PasteService {
|
||||
|
||||
private final boolean isPrivate;
|
||||
|
||||
public GithubPasteService(boolean isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeData(String data) {
|
||||
Map<String, String> mapData = new HashMap<String, String>();
|
||||
mapData.put("multiverse.txt", data);
|
||||
return this.encodeData(mapData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeData(Map<String, String> files) {
|
||||
JsonObject root = new JsonObject();
|
||||
root.add("description", new JsonPrimitive("Multiverse-Core Debug Info"));
|
||||
root.add("public", new JsonPrimitive(!this.isPrivate));
|
||||
JsonObject fileList = new JsonObject();
|
||||
for (Map.Entry<String, String> entry : files.entrySet())
|
||||
{
|
||||
JsonObject fileObject = new JsonObject();
|
||||
fileObject.add("content", new JsonPrimitive(entry.getValue()));
|
||||
fileList.add(entry.getKey(), fileObject);
|
||||
}
|
||||
root.add("files", fileList);
|
||||
return root.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getPostURL() {
|
||||
try {
|
||||
return new URL("https://api.github.com/gists");
|
||||
//return new URL("http://jsonplaceholder.typicode.com/posts");
|
||||
} catch (MalformedURLException e) {
|
||||
return null; // should never hit here
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String postData(String encodedData, URL url) throws PasteFailedException {
|
||||
OutputStreamWriter wr = null;
|
||||
BufferedReader rd = null;
|
||||
try {
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setDoOutput(true);
|
||||
wr = new OutputStreamWriter(conn.getOutputStream());
|
||||
wr.write(encodedData);
|
||||
wr.flush();
|
||||
|
||||
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
String pastieUrl = "";
|
||||
//Pattern pastiePattern = this.getURLMatchingPattern();
|
||||
StringBuilder responseString = new StringBuilder();
|
||||
|
||||
while ((line = rd.readLine()) != null) {
|
||||
responseString.append(line);
|
||||
}
|
||||
return new JsonParser().parse(responseString.toString()).getAsJsonObject().get("html_url").getAsString();
|
||||
} catch (Exception e) {
|
||||
throw new PasteFailedException(e);
|
||||
} finally {
|
||||
if (wr != null) {
|
||||
try {
|
||||
wr.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
if (rd != null) {
|
||||
try {
|
||||
rd.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsMultiFile() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+47
-36
@@ -1,68 +1,79 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import net.minidev.json.JSONObject;
|
||||
import net.minidev.json.parser.JSONParser;
|
||||
import net.minidev.json.parser.ParseException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Pastes to {@code hastebin.com}.
|
||||
*/
|
||||
class HastebinPasteService extends PasteService {
|
||||
private static final String HASTEBIN_POST_REQUEST = "https://hastebin.com/documents";
|
||||
public class HastebinPasteService implements PasteService {
|
||||
|
||||
HastebinPasteService() {
|
||||
super(HASTEBIN_POST_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String encodeData(String data) {
|
||||
public String encodeData(String data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String encodeData(Map<String, String> data) {
|
||||
public String encodeData(Map<String, String> data) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String postData(String data) throws PasteFailedException {
|
||||
public URL getPostURL() {
|
||||
try {
|
||||
String stringJSON = this.exec(encodeData(data), ContentType.PLAINTEXT);
|
||||
return "https://hastebin.com/" + ((JSONObject) new JSONParser().parse(stringJSON)).get("key");
|
||||
} catch (IOException | ParseException e) {
|
||||
throw new PasteFailedException(e);
|
||||
return new URL("https://hastebin.com/documents");
|
||||
} catch (MalformedURLException e) {
|
||||
return null; // should never hit here
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String postData(Map<String, String> data) throws PasteFailedException {
|
||||
public String postData(String encodedData, URL url) throws PasteFailedException {
|
||||
OutputStreamWriter wr = null;
|
||||
BufferedReader rd = null;
|
||||
try {
|
||||
String stringJSON = this.exec(encodeData(data), ContentType.PLAINTEXT);
|
||||
return "https://hastebin.com/" + ((JSONObject) new JSONParser().parse(stringJSON)).get("key");
|
||||
} catch (IOException | ParseException e) {
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setDoOutput(true);
|
||||
|
||||
wr = new OutputStreamWriter(conn.getOutputStream());
|
||||
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
|
||||
wr.write(encodedData);
|
||||
wr.flush();
|
||||
|
||||
String line;
|
||||
StringBuilder responseString = new StringBuilder();
|
||||
while ((line = rd.readLine()) != null) {
|
||||
responseString.append(line);
|
||||
}
|
||||
String key = new JsonParser().parse(responseString.toString()).getAsJsonObject().get("key").getAsString();
|
||||
|
||||
return "https://hastebin.com/" + key;
|
||||
} catch (Exception e) {
|
||||
throw new PasteFailedException(e);
|
||||
} finally {
|
||||
if (wr != null) {
|
||||
try {
|
||||
wr.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
if (rd != null) {
|
||||
try {
|
||||
rd.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsMultiFile() {
|
||||
return false;
|
||||
|
||||
@@ -1,129 +1,50 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
* HTTP API-client.
|
||||
*/
|
||||
abstract class HttpAPIClient {
|
||||
public abstract class HttpAPIClient {
|
||||
/**
|
||||
* The URL for this API-request, and if necessary, the access token.
|
||||
* If an access token is not necessary, it should be set to null.
|
||||
* The URL for this API-request.
|
||||
*/
|
||||
private final String url;
|
||||
private final String accessToken;
|
||||
protected final String urlFormat;
|
||||
|
||||
/**
|
||||
* Types of data that can be sent.
|
||||
*/
|
||||
enum ContentType {
|
||||
JSON,
|
||||
PLAINTEXT,
|
||||
URLENCODED
|
||||
public HttpAPIClient(String urlFormat) {
|
||||
this.urlFormat = urlFormat;
|
||||
}
|
||||
|
||||
HttpAPIClient(String url) {
|
||||
this(url, null);
|
||||
}
|
||||
|
||||
HttpAPIClient(String url, String accessToken) {
|
||||
this.url = url;
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP Content-Type header that corresponds with each ContentType.
|
||||
* @param type The type of data.
|
||||
* @return The HTTP Content-Type header that corresponds with the type of data.
|
||||
*/
|
||||
private String getContentHeader(ContentType type) {
|
||||
switch (type) {
|
||||
case JSON:
|
||||
return "application/json; charset=utf-8";
|
||||
case PLAINTEXT:
|
||||
return "text/plain; charset=utf-8";
|
||||
case URLENCODED:
|
||||
return "application/x-www-form-urlencoded; charset=utf-8";
|
||||
default:
|
||||
throw new IllegalArgumentException("Unexpected value: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the given String data into a format suitable for transmission in an HTTP request.
|
||||
*
|
||||
* @param data The raw data to encode.
|
||||
* @return A URL-encoded string.
|
||||
*/
|
||||
abstract String encodeData(String data);
|
||||
|
||||
/**
|
||||
* Encode the given Map data into a format suitable for transmission in an HTTP request.
|
||||
*
|
||||
* @param data The raw data to encode.
|
||||
* @return A URL-encoded string.
|
||||
*/
|
||||
abstract String encodeData(Map<String, String> data);
|
||||
|
||||
/**
|
||||
* Executes this API-Request.
|
||||
* @param payload The data that will be sent.
|
||||
* @param type The type of data that will be sent.
|
||||
* @param args Format-args.
|
||||
* @return The result (as text).
|
||||
* @throws IOException When the I/O-operation failed.
|
||||
*/
|
||||
final String exec(String payload, ContentType type) throws IOException {
|
||||
BufferedReader rd = null;
|
||||
OutputStreamWriter wr = null;
|
||||
protected final String exec(Object... args) throws IOException {
|
||||
|
||||
URLConnection conn = new URL(String.format(this.urlFormat, args)).openConnection();
|
||||
conn.connect();
|
||||
StringBuilder ret = new StringBuilder();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
HttpsURLConnection conn = (HttpsURLConnection) new URL(this.url).openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
while (!reader.ready()); // wait until reader is ready, may not be necessary, SUPPRESS CHECKSTYLE: EmptyStatement
|
||||
|
||||
// we can receive anything!
|
||||
conn.addRequestProperty("Accept", "*/*");
|
||||
// set a dummy User-Agent
|
||||
conn.addRequestProperty("User-Agent", "placeholder");
|
||||
// this isn't required, but is technically correct
|
||||
conn.addRequestProperty("Content-Type", getContentHeader(type));
|
||||
// only some API requests require an access token
|
||||
if (this.accessToken != null) {
|
||||
conn.addRequestProperty("Authorization", this.accessToken);
|
||||
while (reader.ready()) {
|
||||
ret.append(reader.readLine()).append('\n');
|
||||
}
|
||||
|
||||
wr = new OutputStreamWriter(conn.getOutputStream(), StandardCharsets.UTF_8.newEncoder());
|
||||
wr.write(payload);
|
||||
wr.flush();
|
||||
|
||||
String line;
|
||||
StringBuilder responseString = new StringBuilder();
|
||||
// this has to be initialized AFTER the data has been flushed!
|
||||
rd = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
|
||||
|
||||
while ((line = rd.readLine()) != null) {
|
||||
responseString.append(line);
|
||||
}
|
||||
|
||||
return responseString.toString();
|
||||
} finally {
|
||||
if (wr != null) {
|
||||
if (reader != null) {
|
||||
try {
|
||||
wr.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
if (rd != null) {
|
||||
try {
|
||||
rd.close();
|
||||
reader.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
/**
|
||||
* Thrown when pasting fails.
|
||||
* Thrown when pasting failed.
|
||||
*/
|
||||
public class PasteFailedException extends Exception {
|
||||
public PasteFailedException() {
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import net.minidev.json.JSONArray;
|
||||
import net.minidev.json.JSONObject;
|
||||
import net.minidev.json.parser.JSONParser;
|
||||
import net.minidev.json.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Pastes to {@code paste.gg}.
|
||||
*/
|
||||
class PasteGGPasteService extends PasteService {
|
||||
private final boolean isPrivate;
|
||||
private static final String PASTEGG_POST_REQUEST = "https://api.paste.gg/v1/pastes";
|
||||
|
||||
PasteGGPasteService(boolean isPrivate) {
|
||||
super(PASTEGG_POST_REQUEST);
|
||||
this.isPrivate = isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String encodeData(String data) {
|
||||
Map<String, String> mapData = new HashMap<String, String>();
|
||||
mapData.put("multiverse.txt", data);
|
||||
return this.encodeData(mapData);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String encodeData(Map<String, String> files) {
|
||||
JSONObject root = new JSONObject();
|
||||
root.put("name", "Multiverse-Core Debug Info");
|
||||
root.put("visibility", this.isPrivate ? "unlisted" : "public");
|
||||
JSONArray fileList = new JSONArray();
|
||||
for (Map.Entry<String, String> entry : files.entrySet()) {
|
||||
JSONObject fileObject = new JSONObject();
|
||||
JSONObject contentObject = new JSONObject();
|
||||
fileObject.put("name", entry.getKey());
|
||||
fileObject.put("content", contentObject);
|
||||
contentObject.put("format", "text");
|
||||
contentObject.put("value", entry.getValue());
|
||||
fileList.add(fileObject);
|
||||
}
|
||||
|
||||
root.put("files", fileList);
|
||||
return root.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String postData(String data) throws PasteFailedException {
|
||||
try {
|
||||
String stringJSON = this.exec(encodeData(data), ContentType.JSON);
|
||||
return (String) ((JSONObject) ((JSONObject) new JSONParser().parse(stringJSON)).get("result")).get("id");
|
||||
} catch (IOException | ParseException e) {
|
||||
throw new PasteFailedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String postData(Map<String, String> data) throws PasteFailedException {
|
||||
try {
|
||||
String stringJSON = this.exec(encodeData(data), ContentType.JSON);
|
||||
return "https://paste.gg/" + ((JSONObject) ((JSONObject) new JSONParser().parse(stringJSON)).get("result")).get("id");
|
||||
} catch (IOException | ParseException e) {
|
||||
throw new PasteFailedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsMultiFile() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +1,63 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An interface to a web-based text-pasting service. Classes extending this
|
||||
* should implement its methods to send data to an online text-sharing service,
|
||||
* such as pastebin.com. Given some PasteService instance ps, a paste is accomplished by:
|
||||
* An interface to a web-based text-pasting service. Classes implementing this
|
||||
* interface should implement its methods to send data to an online text-sharing
|
||||
* service, such as pastebin.com. Conventionally, a paste is accomplished by (given
|
||||
* some PasteService instance ps):
|
||||
*
|
||||
* {@code ps.postData(someString);}
|
||||
* {@code ps.postData(ps.encodeData(someString), ps.getPostURL());}
|
||||
*
|
||||
* Services that provide a distinction between "public" and "private" pastes
|
||||
* should implement a constructor that specifies which kind the PasteService
|
||||
* should implement a custom constructor that specifies which kind the PasteService
|
||||
* instance is submitting; an example of this is the PastebinPasteService class.
|
||||
*/
|
||||
public abstract class PasteService extends HttpAPIClient {
|
||||
PasteService(String url) {
|
||||
super(url);
|
||||
}
|
||||
|
||||
PasteService(String url, String accessToken) {
|
||||
super(url, accessToken);
|
||||
}
|
||||
public interface PasteService {
|
||||
|
||||
/**
|
||||
* Post data to the Web.
|
||||
* Encode the given String data into a format suitable for transmission in an HTTP request.
|
||||
*
|
||||
* @param data A String to post to the web.
|
||||
* @param data The raw data to encode.
|
||||
* @return A URL-encoded string.
|
||||
*/
|
||||
String encodeData(String data);
|
||||
|
||||
/**
|
||||
* Encode the given Map data into a format suitable for transmission in an HTTP request.
|
||||
*
|
||||
* @param data The raw data to encode.
|
||||
* @return A URL-encoded string.
|
||||
*/
|
||||
String encodeData(Map<String, String> data);
|
||||
|
||||
/**
|
||||
* Get the URL to which this paste service sends new pastes.
|
||||
*
|
||||
* @return The URL that will be accessed to complete the paste.
|
||||
*/
|
||||
URL getPostURL();
|
||||
|
||||
/**
|
||||
* Post encoded data to the Web.
|
||||
*
|
||||
* @param encodedData A URL-encoded String containing the full request to post to
|
||||
* the given URL. Can be the result of calling #encodeData().
|
||||
* @param url The URL to which to paste. Can be the result of calling #getPostURL().
|
||||
* @throws PasteFailedException When pasting/posting the data failed.
|
||||
* @return The URL at which the new paste is visible.
|
||||
*/
|
||||
public abstract String postData(String data) throws PasteFailedException;
|
||||
|
||||
/**
|
||||
* Post data to the Web.
|
||||
*
|
||||
* @param data A Map to post to the web.
|
||||
* @throws PasteFailedException When pasting/posting the data failed.
|
||||
* @return The URL at which the new paste is visible.
|
||||
*/
|
||||
public abstract String postData(Map<String, String> data) throws PasteFailedException;
|
||||
String postData(String encodedData, URL url) throws PasteFailedException;
|
||||
|
||||
/**
|
||||
* Does this service support uploading multiple files.
|
||||
*
|
||||
* Newer services like GitHub's Gist support multi-file pastes,
|
||||
* which allows us to upload configs in addition to the standard logs.
|
||||
* Newer services like gist support multi-file which allows us to upload configs
|
||||
* in addition to the standard logs.
|
||||
*
|
||||
* @return True if this service supports multiple file upload.
|
||||
*/
|
||||
public abstract boolean supportsMultiFile();
|
||||
boolean supportsMultiFile();
|
||||
}
|
||||
+1
-3
@@ -14,14 +14,12 @@ public class PasteServiceFactory {
|
||||
*/
|
||||
public static PasteService getService(PasteServiceType type, boolean isPrivate) {
|
||||
switch(type) {
|
||||
case PASTEGG:
|
||||
return new PasteGGPasteService(isPrivate);
|
||||
case PASTEBIN:
|
||||
return new PastebinPasteService(isPrivate);
|
||||
case HASTEBIN:
|
||||
return new HastebinPasteService();
|
||||
case GITHUB:
|
||||
return new GitHubPasteService(isPrivate);
|
||||
return new GithubPasteService(isPrivate);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,10 +7,6 @@ package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
* @see PasteServiceFactory
|
||||
*/
|
||||
public enum PasteServiceType {
|
||||
/**
|
||||
* @see PasteGGPasteService
|
||||
*/
|
||||
PASTEGG,
|
||||
/**
|
||||
* @see PastebinPasteService
|
||||
*/
|
||||
@@ -20,7 +16,7 @@ public enum PasteServiceType {
|
||||
*/
|
||||
HASTEBIN,
|
||||
/**
|
||||
* @see GitHubPasteService
|
||||
* @see GithubPasteService
|
||||
*/
|
||||
GITHUB
|
||||
}
|
||||
+59
-35
@@ -1,19 +1,24 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Pastes to {@code pastebin.com}.
|
||||
*/
|
||||
class PastebinPasteService extends PasteService {
|
||||
private final boolean isPrivate;
|
||||
private static final String PASTEBIN_POST_REQUEST = "https://pastebin.com/api/api_post.php";
|
||||
public class PastebinPasteService implements PasteService {
|
||||
|
||||
PastebinPasteService(boolean isPrivate) {
|
||||
super(PASTEBIN_POST_REQUEST);
|
||||
private boolean isPrivate;
|
||||
|
||||
public PastebinPasteService(boolean isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
}
|
||||
|
||||
@@ -21,54 +26,73 @@ class PastebinPasteService extends PasteService {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String encodeData(String data) {
|
||||
public URL getPostURL() {
|
||||
try {
|
||||
return URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("d61d68d31e8e0392b59b50b277411c71", "UTF-8") +
|
||||
"&" + URLEncoder.encode("api_option", "UTF-8") + "=" + URLEncoder.encode("paste", "UTF-8") +
|
||||
"&" + URLEncoder.encode("api_paste_code", "UTF-8") + "=" + URLEncoder.encode(data, "UTF-8") +
|
||||
"&" + URLEncoder.encode("api_paste_private", "UTF-8") + "=" + URLEncoder.encode(this.isPrivate ? "1" : "0", "UTF-8") +
|
||||
"&" + URLEncoder.encode("api_paste_format", "UTF-8") + "=" + URLEncoder.encode("yaml", "UTF-8") +
|
||||
"&" + URLEncoder.encode("api_paste_name", "UTF-8") + "=" + URLEncoder.encode("Multiverse-Core Debug Info", "UTF-8");
|
||||
return new URL("http://pastebin.com/api/api_post.php");
|
||||
} catch (MalformedURLException e) {
|
||||
return null; // should never hit here
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String encodeData(String data) {
|
||||
try {
|
||||
String encData = URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("d61d68d31e8e0392b59b50b277411c71", "UTF-8");
|
||||
encData += "&" + URLEncoder.encode("api_option", "UTF-8") + "=" + URLEncoder.encode("paste", "UTF-8");
|
||||
encData += "&" + URLEncoder.encode("api_paste_code", "UTF-8") + "=" + URLEncoder.encode(data, "UTF-8");
|
||||
encData += "&" + URLEncoder.encode("api_paste_private", "UTF-8") + "=" + URLEncoder.encode(this.isPrivate ? "1" : "0", "UTF-8");
|
||||
encData += "&" + URLEncoder.encode("api_paste_format", "UTF-8") + "=" + URLEncoder.encode("yaml", "UTF-8");
|
||||
return encData;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return ""; // should never hit here
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String encodeData(Map<String, String> data) {
|
||||
throw new UnsupportedOperationException();
|
||||
public String encodeData(Map<String, String> data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String postData(String data) throws PasteFailedException {
|
||||
public String postData(String encodedData, URL url) throws PasteFailedException {
|
||||
OutputStreamWriter wr = null;
|
||||
BufferedReader rd = null;
|
||||
try {
|
||||
return this.exec(encodeData(data), ContentType.URLENCODED);
|
||||
} catch (IOException e) {
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setDoOutput(true);
|
||||
wr = new OutputStreamWriter(conn.getOutputStream());
|
||||
wr.write(encodedData);
|
||||
wr.flush();
|
||||
|
||||
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
String pastebinUrl = "";
|
||||
while ((line = rd.readLine()) != null) {
|
||||
pastebinUrl = line;
|
||||
}
|
||||
return pastebinUrl;
|
||||
} catch (Exception e) {
|
||||
throw new PasteFailedException(e);
|
||||
} finally {
|
||||
if (wr != null) {
|
||||
try {
|
||||
wr.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
if (rd != null) {
|
||||
try {
|
||||
rd.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String postData(Map<String, String> data) throws PasteFailedException {
|
||||
try {
|
||||
return this.exec(encodeData(data), ContentType.URLENCODED);
|
||||
} catch (IOException e) {
|
||||
throw new PasteFailedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsMultiFile() {
|
||||
return false;
|
||||
|
||||
@@ -1,27 +1,13 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
/**
|
||||
* An interface to a web-based URL Shortener. Classes extending this should
|
||||
* implement its methods to shorten links using the service. Given some
|
||||
* URLShortener instance us, a URL is shortened by:
|
||||
*
|
||||
* {@code us.shorten(longUrl);}
|
||||
*
|
||||
* An example of this, is the BitlyURLShortener.
|
||||
* URL-Shortener.
|
||||
*/
|
||||
public abstract class URLShortener extends HttpAPIClient {
|
||||
URLShortener(String url) {
|
||||
super(url);
|
||||
}
|
||||
|
||||
URLShortener(String url, String accessToken) {
|
||||
super(url, accessToken);
|
||||
}
|
||||
|
||||
public interface URLShortener {
|
||||
/**
|
||||
* Shorten a URL.
|
||||
* Shorten an URL.
|
||||
* @param longUrl The long form.
|
||||
* @return The shortened URL.
|
||||
*/
|
||||
public abstract String shorten(String longUrl);
|
||||
String shorten(String longUrl);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
/**
|
||||
* Used to construct {@link URLShortener}s.
|
||||
*/
|
||||
public class URLShortenerFactory {
|
||||
private URLShortenerFactory() { }
|
||||
|
||||
/**
|
||||
* Constructs a new {@link URLShortener}.
|
||||
* @param type The {@link URLShortenerType}.
|
||||
* @return The newly created {@link URLShortener}.
|
||||
*/
|
||||
public static URLShortener getService(URLShortenerType type) {
|
||||
if (type == URLShortenerType.BITLY) {
|
||||
try {
|
||||
return new BitlyURLShortener();
|
||||
} catch (UnsupportedOperationException ignored) {}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
/**
|
||||
* An enum containing all known {@link URLShortener}s.
|
||||
*
|
||||
* @see URLShortener
|
||||
* @see URLShortenerFactory
|
||||
*/
|
||||
public enum URLShortenerType {
|
||||
/**
|
||||
* @see BitlyURLShortener
|
||||
*/
|
||||
BITLY
|
||||
}
|
||||
+113
-65
@@ -1,9 +1,7 @@
|
||||
name: Multiverse-Core
|
||||
main: com.onarandombox.MultiverseCore.MultiverseCore
|
||||
authors: ['dumptruckman', 'Rigby', 'fernferret', 'lithium3141', 'main--']
|
||||
authors: ['Rigby', 'fernferret', 'lithium3141', 'main--', 'dumptruckman']
|
||||
website: 'https://dev.bukkit.org/projects/multiverse-core'
|
||||
softdepend: ['Vault']
|
||||
api-version: 1.13
|
||||
version: maven-version-number
|
||||
commands:
|
||||
mv:
|
||||
@@ -11,24 +9,34 @@ commands:
|
||||
usage: /<command>
|
||||
mvcreate:
|
||||
description: World create command
|
||||
aliases: [mvc]
|
||||
usage: |
|
||||
/<command> <world> <environment>
|
||||
/<command> creative normal -- Creates a world called 'creative' with a NORMAL environment.
|
||||
/<command> hellworld nether -- Creates a world called 'hellworld' with a NETHER environment.
|
||||
mvc:
|
||||
description: World create command
|
||||
usage: |
|
||||
/<command> <world> <environment>
|
||||
/<command> creative normal -- Creates a world called 'creative' with a NORMAL environment.
|
||||
/<command> hellworld nether -- Creates a world called 'hellworld' with a NETHER environment.
|
||||
mvimport:
|
||||
description: World import command
|
||||
aliases: [mvim]
|
||||
usage: |
|
||||
/<command> <world> <environment> [-g generator[:id]] [-n]
|
||||
/<command> creative normal -- Imports an existing world called 'creative' with a NORMAL environment.
|
||||
/<command> hellworld nether -- Imports an existing world called 'hellworld' with a NETHER environment.
|
||||
/<command> <world> <environment>
|
||||
/<command> creative normal -- Imports an existing world called 'creative' with a NORMAL environment.
|
||||
/<command> hellworld nether -- Imports an existing world called 'hellworld' with a NETHER environment.
|
||||
mvim:
|
||||
description: World import command
|
||||
usage: |
|
||||
/<command> <world> <environment>
|
||||
/<command> creative normal -- Imports an existing world called 'creative' with a NORMAL environment.
|
||||
/<command> hellworld nether -- Imports an existing world called 'hellworld' with a NETHER environment.
|
||||
mvremove:
|
||||
description: Remove world from multiverse command
|
||||
description: World remove command
|
||||
usage: |
|
||||
/<command> <world>
|
||||
mvdelete:
|
||||
description: Delete world from server folders command
|
||||
description: World delete command
|
||||
usage: |
|
||||
/<command> <world>
|
||||
mvunload:
|
||||
@@ -37,75 +45,103 @@ commands:
|
||||
/<command> <world>
|
||||
mvmodify:
|
||||
description: Modify the settings of an existing world
|
||||
aliases: [mvm]
|
||||
usage: |
|
||||
/<command> <set|add|remove|clear> <value> <property> [world]
|
||||
/<command> set pvp false creative -- Turns off PVP in the 'creative' world.
|
||||
/<command> <world> <option>:<value>
|
||||
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
|
||||
mvmset:
|
||||
description: Modify the settings of an existing world
|
||||
usage: |
|
||||
/<command> <value> <property> [world]
|
||||
/<command> pvp false creative -- Turns off PVP in the 'creative' world.
|
||||
/<command> <world> <option>:<value>
|
||||
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
|
||||
mvmadd:
|
||||
description: Modify the settings of an existing world
|
||||
usage: |
|
||||
/<command> <value> <property> [world]
|
||||
/<command> sheep animals world_nether -- Add sheep to animal list for 'world_nether' world.
|
||||
/<command> <world> <option>:<value>
|
||||
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
|
||||
mvmremove:
|
||||
description: Modify the settings of an existing world
|
||||
aliases: [mvmdelete]
|
||||
usage: |
|
||||
/<command> <value> <property> [world]
|
||||
/<command> sheep animals world_nether -- remove sheep from animal list for 'world_nether' world.
|
||||
/<command> <world> <option>:<value>
|
||||
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
|
||||
mvmclear:
|
||||
description: Modify the settings of an existing world
|
||||
usage: |
|
||||
/<command> <property> [world]
|
||||
/<command> animals world_nether -- Empties animal list for 'world_nether' world.
|
||||
/<command> <world> <option>:<value>
|
||||
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
|
||||
mvm:
|
||||
description: Modify the settings of an existing world
|
||||
usage: |
|
||||
/<command> <world> <option>:<value>
|
||||
/<command> creative pvp:false -- Turns off PVP in the 'creative' world.
|
||||
mvtp:
|
||||
description: Command to teleport between Worlds
|
||||
usage: |
|
||||
/<command> [player] <destination>
|
||||
/<command> <world>[:spawn]
|
||||
Example: /<command> creative - Teleports you to the relevant location in the 'creative' world.
|
||||
Example: /<command> creative:spawn - Teleports you to the spawn of the 'creative' world.
|
||||
mvlist:
|
||||
description: Print list of loaded Worlds
|
||||
aliases: [mvl]
|
||||
usage: |
|
||||
/<command> [page]
|
||||
/<command> [environment]
|
||||
Example: /<command> NETHER - Shows all NETHER Worlds.
|
||||
Example: /<command> NORMAL - Shows all NORMAL Worlds.
|
||||
mvl:
|
||||
description: Print list of loaded Worlds
|
||||
usage: |
|
||||
/<command> [environment]
|
||||
Example: /<command> NETHER - Shows all NETHER Worlds.
|
||||
Example: /<command> NORMAL - Shows all NORMAL Worlds.
|
||||
mvsetspawn:
|
||||
description: Set the spawn area for a particular world
|
||||
aliases: [mvsets, mvss]
|
||||
usage: /<command> -- Sets the spawn area of the current world to your location.
|
||||
mvset:
|
||||
description: Set the spawn area for a particular world
|
||||
usage: /<command> -- Sets the spawn area of the current world to your location.
|
||||
mvss:
|
||||
description: Set the spawn area for a particular world
|
||||
usage: /<command> -- Sets the spawn area of the current world to your location.
|
||||
mvspawn:
|
||||
description: Teleport to the spawn area
|
||||
aliases: [mvs]
|
||||
usage: /<command> [player] -- Teleports you to the spawn area of your current world.
|
||||
usage: /<command> -- Teleports you to the spawn area of your current world.
|
||||
mvs:
|
||||
description: Teleport to the spawn area
|
||||
usage: /<command> -- Teleports you to the spawn area of your current world.
|
||||
mvcoord:
|
||||
description: Display World, Coordinates, Direction & Compression for a world.
|
||||
aliases: [mvco]
|
||||
usage: |
|
||||
/<command> [world]
|
||||
/<command> -- Shows the relevant coordinates in your current world.
|
||||
/<command> creative -- Shows the relevant coordinates if you were in the 'creative' world.
|
||||
mvc:
|
||||
description: Display World, Coordinates, Direction & Compression for a world.
|
||||
usage: |
|
||||
/<command> [world]
|
||||
/<command> -- Shows the relevant coordinates in your current world.
|
||||
/<command> creative -- Shows the relevant coordinates if you were in the 'creative' world.
|
||||
mvwho:
|
||||
description: Display online users per world.
|
||||
aliases: [mvw]
|
||||
usage: |
|
||||
/<command> [world|--all]
|
||||
/<command> [world]
|
||||
/<command> -- Shows who is online in each world.
|
||||
/<command> creative -- Shows who is online in the 'creative' world.
|
||||
mvw:
|
||||
description: Display online users per world.
|
||||
usage: |
|
||||
/<command> [world]
|
||||
/<command> -- Shows who is online in each world.
|
||||
/<command> creative -- Shows who is online in the 'creative' world.
|
||||
mvreload:
|
||||
description: Reload Configuration files.
|
||||
aliases: [mvr]
|
||||
usage: /<command>
|
||||
mvr:
|
||||
description: Reload Configuration files.
|
||||
usage: /<command>
|
||||
mvpurge:
|
||||
description: Purge the targetted world of creatures.
|
||||
usage: |
|
||||
/<command> [WORLD|all] [all|animals|monsters|MOBNAME]
|
||||
/<command> [world] [creatures]
|
||||
/<command> -- Purges the players world of all creatures.
|
||||
/<command> creative all -- Purges the creative world of all Creatures.
|
||||
/<command> creative * -- Purges the creative world of all Creatures.
|
||||
/<command> creative creeper -- Purges the creative world of all CREEPERS.
|
||||
mvconfirm:
|
||||
description: Confirms sensitive decisions like deleting a world.
|
||||
@@ -113,75 +149,87 @@ commands:
|
||||
/<command>
|
||||
mvinfo:
|
||||
description: Gets world info.
|
||||
aliases: [mvi]
|
||||
usage: |
|
||||
/<command> [world] [page]
|
||||
/<command> [world]
|
||||
mvi:
|
||||
description: Gets world info.
|
||||
usage: |
|
||||
/<command> [world]
|
||||
mvenv:
|
||||
description: Tells the user all possible environment types.
|
||||
usage: |
|
||||
/<command>
|
||||
mvv:
|
||||
description: Prints out version info.
|
||||
usage: |
|
||||
/<command>
|
||||
mvversion:
|
||||
description: Prints out version info.
|
||||
aliases: [mvv, mvver]
|
||||
usage: |
|
||||
/<command> [-b|-h|-p] [--include-plugin-list]
|
||||
/<command>
|
||||
mvco:
|
||||
description: Displays the player's coordinates.
|
||||
usage: |
|
||||
/<command>
|
||||
mvh:
|
||||
description: Displays the Multiverse Help.
|
||||
usage: |
|
||||
/<command>
|
||||
mvsearch:
|
||||
description: Displays the Multiverse Help.
|
||||
usage: |
|
||||
/<command>
|
||||
mvhelp:
|
||||
description: Displays the Multiverse Help.
|
||||
aliases: [mvsearch, mvh]
|
||||
usage: |
|
||||
/<command> [filter] [page #]
|
||||
/<command>
|
||||
mvdebug:
|
||||
description: Turns on debugging.
|
||||
usage: |
|
||||
/<command> [1|2|3|off|silent]
|
||||
/<command>
|
||||
mvgenerators:
|
||||
description: Displays all found world generators.
|
||||
aliases: [mvgens]
|
||||
usage: |
|
||||
/<command>
|
||||
mvgens:
|
||||
description: Displays all found world generators.
|
||||
usage: |
|
||||
/<command>
|
||||
mvload:
|
||||
description: Loads a world into Multiverse.
|
||||
usage: |
|
||||
/<command> <world>
|
||||
/<command> {WORLD}
|
||||
mvregen:
|
||||
description: Regenerates a world Multiverse already knows about.
|
||||
usage: |
|
||||
/<command> <world> [-s seed]
|
||||
/<command> {WORLD}
|
||||
mvscript:
|
||||
description: Runs a script from the Multiverse scripts directory.
|
||||
usage: |
|
||||
/<command> <script> [target]
|
||||
/<command> {script} [target]
|
||||
mvclone:
|
||||
description: World clone command
|
||||
aliases: [mvcl]
|
||||
usage: |
|
||||
/<command> <world> <environment> [-g generator[:id]]
|
||||
/<command> <world> <environment>
|
||||
/<command> creative grieftastic -- Creates a world called 'grieftastic' exactly identical to the world 'creative'.
|
||||
mvsilent:
|
||||
description: Reduces startup messages
|
||||
usage: |
|
||||
/<command> [true|false]
|
||||
|
||||
mvgamerule:
|
||||
description: Sets a gamerule.
|
||||
aliases: [mvrule]
|
||||
usage: |
|
||||
/<command> <rule> <value> [world]
|
||||
/<command> {RULE} {VALUE} [WORLD]
|
||||
mvrule:
|
||||
description: Sets a gamerule.
|
||||
usage: |
|
||||
/<command> {RULE} {VALUE} [WORLD]
|
||||
mvgamerules:
|
||||
description: Lists the gamerules
|
||||
aliases: [mvrules]
|
||||
description: Lists the gamerules.
|
||||
usage: |
|
||||
/<command> [world]
|
||||
mvanchors:
|
||||
description: Creating and removing Anchors command
|
||||
aliases: [mvanchor]
|
||||
/<command> [WORLD]
|
||||
mvrules:
|
||||
description: Lists the gamerules.
|
||||
usage: |
|
||||
/<command> <name> [-d]
|
||||
mvcheck:
|
||||
description: Validate your multiverse settings command
|
||||
usage: |
|
||||
/<command> <name> <destination>
|
||||
mvconfig:
|
||||
description: Configuration command
|
||||
aliases: [mvconf]
|
||||
usage: |
|
||||
/<command> <property> <value>
|
||||
/<command> [WORLD]
|
||||
@@ -6,9 +6,6 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import org.junit.After;
|
||||
@@ -81,7 +78,7 @@ public class FileUtilsTest {
|
||||
assertFalse(Files.isDirectory(targetChildDir));
|
||||
assertFalse(Files.isRegularFile(targetChildDirFile));
|
||||
|
||||
assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile()));
|
||||
assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile(), Logging.getLogger()));
|
||||
|
||||
assertTrue(Files.isDirectory(targetDir));
|
||||
assertTrue(Files.isRegularFile(targetFile));
|
||||
@@ -89,34 +86,6 @@ public class FileUtilsTest {
|
||||
assertTrue(Files.isRegularFile(targetChildDirFile));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void copyFolder_excludingSomeFiles() throws Exception {
|
||||
Path targetDir = tempDir.resolve("target");
|
||||
Path targetFile = targetDir.resolve("parentDirFile.txt");
|
||||
Path targetIgnoreFile = targetDir.resolve("parentIgnoreFile.txt");
|
||||
Path targetChildDir = targetDir.resolve("childDir");
|
||||
Path targetChildDirFile = targetChildDir.resolve("childDirFile.txt");
|
||||
Path targetChildIgnoreFile = targetChildDir.resolve("childIgnoreFile.txt");
|
||||
|
||||
List<String> excludeFiles = new ArrayList<>(Arrays.asList("parentIgnoreFile.txt", "childIgnoreFile.txt"));
|
||||
|
||||
assertFalse(Files.isDirectory(targetDir));
|
||||
assertFalse(Files.isRegularFile(targetFile));
|
||||
assertFalse(Files.isRegularFile(targetIgnoreFile));
|
||||
assertFalse(Files.isDirectory(targetChildDir));
|
||||
assertFalse(Files.isRegularFile(targetChildDirFile));
|
||||
assertFalse(Files.isRegularFile(targetChildIgnoreFile));
|
||||
|
||||
assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile(), excludeFiles));
|
||||
|
||||
assertTrue(Files.isDirectory(targetDir));
|
||||
assertTrue(Files.isRegularFile(targetFile));
|
||||
assertFalse(Files.isRegularFile(targetIgnoreFile));
|
||||
assertTrue(Files.isDirectory(targetChildDir));
|
||||
assertTrue(Files.exists(targetChildDirFile));
|
||||
assertFalse(Files.isRegularFile(targetChildIgnoreFile));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void copyFolder_intoExistingFolder() throws Exception {
|
||||
Path targetDir = Files.createDirectory(tempDir.resolve("target"));
|
||||
@@ -129,7 +98,7 @@ public class FileUtilsTest {
|
||||
assertFalse(Files.isDirectory(targetChildDir));
|
||||
assertFalse(Files.isRegularFile(targetChildDirFile));
|
||||
|
||||
assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile()));
|
||||
assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile(), Logging.getLogger()));
|
||||
|
||||
assertTrue(Files.isDirectory(targetDir));
|
||||
assertTrue(Files.isRegularFile(targetFile));
|
||||
@@ -145,6 +114,6 @@ public class FileUtilsTest {
|
||||
assertTrue(Files.isDirectory(targetDir));
|
||||
assertTrue(Files.isRegularFile(targetFile));
|
||||
|
||||
assertFalse(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile()));
|
||||
assertFalse(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile(), Logging.getLogger()));
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,6 @@ public class TestInstanceCreator {
|
||||
public static final File worldsDirectory = new File("bin/test/server");
|
||||
|
||||
public boolean setUp() {
|
||||
TestingMode.enable();
|
||||
try {
|
||||
pluginDirectory.mkdirs();
|
||||
assertTrue(pluginDirectory.exists());
|
||||
|
||||
Reference in new issue
Block a user