mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-27 10:31:42 +01:00
Remove some uses of PlanPlugin#getDataFolder (deprecated)
This commit is contained in:
parent
d639bd643c
commit
7dce52245f
@ -25,6 +25,7 @@ import net.md_5.bungee.api.plugin.PluginDescription;
|
||||
import net.md_5.bungee.api.plugin.PluginManager;
|
||||
import org.mockito.Mockito;
|
||||
import utilities.TestConstants;
|
||||
import utilities.TestResources;
|
||||
import utilities.mocks.objects.TestLogger;
|
||||
|
||||
import java.io.File;
|
||||
@ -38,9 +39,10 @@ import static org.mockito.Mockito.when;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class PlanBungeeMocker extends Mocker {
|
||||
public class PlanBungeeMocker {
|
||||
|
||||
private PlanBungee planMock;
|
||||
private File tempFolder;
|
||||
|
||||
private PlanBungeeMocker() {
|
||||
}
|
||||
@ -51,7 +53,6 @@ public class PlanBungeeMocker extends Mocker {
|
||||
|
||||
private PlanBungeeMocker mockPlugin() {
|
||||
planMock = Mockito.mock(PlanBungee.class);
|
||||
super.planMock = planMock;
|
||||
|
||||
doReturn(new ColorScheme("§1", "§2", "§3")).when(planMock).getColorScheme();
|
||||
|
||||
@ -63,7 +64,8 @@ public class PlanBungeeMocker extends Mocker {
|
||||
}
|
||||
|
||||
PlanBungeeMocker withDataFolder(File tempFolder) {
|
||||
when(planMock.getDataFolder()).thenReturn(tempFolder);
|
||||
this.tempFolder = tempFolder;
|
||||
when(planMock.getDataFolder()).thenReturn(this.tempFolder);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -91,7 +93,8 @@ public class PlanBungeeMocker extends Mocker {
|
||||
}
|
||||
|
||||
PlanBungeeMocker withPluginDescription() {
|
||||
File pluginYml = getFile("/bungee.yml");
|
||||
File pluginYml = tempFolder.toPath().resolve("jar").resolve("bungee.yml").toFile();
|
||||
TestResources.copyResourceIntoFile(pluginYml, "/bungee.yml");
|
||||
HashSet<String> empty = new HashSet<>();
|
||||
PluginDescription pluginDescription = new PluginDescription("Plan", "", "9.9.9", "AuroraLS3", empty, empty, pluginYml, "");
|
||||
when(planMock.getDescription()).thenReturn(pluginDescription);
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.commands.use.ColorScheme;
|
||||
import com.djrapitops.plan.commands.use.Subcommand;
|
||||
import net.playeranalytics.plugin.PluginInformation;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
@ -45,7 +46,10 @@ public interface PlanPlugin {
|
||||
|
||||
void onDisable();
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* @deprecated Use {@code @Named("dataFolder") File}, or {@link PluginInformation#getDataFolder()}
|
||||
*/
|
||||
@Deprecated(since = "2021-03-09")
|
||||
File getDataFolder();
|
||||
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package utilities.mocks;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import utilities.TestResources;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Abstract Mocker for methods that can be used for both Bungee and Bukkit.
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
abstract class Mocker {
|
||||
|
||||
PlanPlugin planMock;
|
||||
|
||||
File getFile(String fileName) {
|
||||
// Read the resource from jar to a temporary file
|
||||
File file = new File(new File(planMock.getDataFolder(), "jar"), fileName);
|
||||
TestResources.copyResourceIntoFile(file, fileName);
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
@ -29,7 +29,7 @@ import static org.mockito.Mockito.doReturn;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class PlanPluginMocker extends Mocker {
|
||||
public class PlanPluginMocker {
|
||||
|
||||
private PlanPlugin planMock;
|
||||
|
||||
@ -42,7 +42,6 @@ public class PlanPluginMocker extends Mocker {
|
||||
|
||||
private PlanPluginMocker mockPlugin() {
|
||||
planMock = Mockito.mock(PlanPlugin.class);
|
||||
super.planMock = planMock;
|
||||
|
||||
doReturn(new ColorScheme("§1", "§2", "§3")).when(planMock).getColorScheme();
|
||||
|
||||
|
@ -30,7 +30,7 @@ import static org.mockito.Mockito.doReturn;
|
||||
* @author AuroraLS3
|
||||
* @author Kopo942
|
||||
*/
|
||||
public class PlanFabricMocker extends Mocker {
|
||||
public class PlanFabricMocker {
|
||||
|
||||
private PlanFabric planMock;
|
||||
|
||||
@ -43,7 +43,6 @@ public class PlanFabricMocker extends Mocker {
|
||||
|
||||
private PlanFabricMocker mockPlugin() {
|
||||
planMock = Mockito.mock(PlanFabric.class);
|
||||
super.planMock = planMock;
|
||||
|
||||
doReturn(new ColorScheme("§1", "§2", "§3")).when(planMock).getColorScheme();
|
||||
|
||||
|
@ -34,7 +34,7 @@ import static org.mockito.Mockito.doReturn;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class PlanNukkitMocker extends Mocker {
|
||||
public class PlanNukkitMocker {
|
||||
|
||||
private PlanNukkit planMock;
|
||||
|
||||
@ -47,7 +47,6 @@ public class PlanNukkitMocker extends Mocker {
|
||||
|
||||
private PlanNukkitMocker mockPlugin() {
|
||||
planMock = Mockito.mock(PlanNukkit.class);
|
||||
super.planMock = planMock;
|
||||
|
||||
doReturn(new ColorScheme("§1", "§2", "§3")).when(planMock).getColorScheme();
|
||||
|
||||
|
@ -32,7 +32,7 @@ import static org.mockito.Mockito.doReturn;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class PlanVelocityMocker extends Mocker {
|
||||
public class PlanVelocityMocker {
|
||||
|
||||
private PlanVelocity planMock;
|
||||
|
||||
@ -45,7 +45,6 @@ public class PlanVelocityMocker extends Mocker {
|
||||
|
||||
private PlanVelocityMocker mockPlugin() {
|
||||
planMock = Mockito.mock(PlanVelocity.class);
|
||||
super.planMock = planMock;
|
||||
|
||||
doReturn(new ColorScheme("§1", "§2", "§3")).when(planMock).getColorScheme();
|
||||
|
||||
@ -53,7 +52,6 @@ public class PlanVelocityMocker extends Mocker {
|
||||
}
|
||||
|
||||
public PlanVelocityMocker withDataFolder(File tempFolder) {
|
||||
doReturn(tempFolder).when(planMock).getDataFolder();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user