SteamWar/BauSystem
Archiviert
13
0

Fix script book in 1.12

Dieser Commit ist enthalten in:
Lixfel 2020-12-11 12:47:32 +01:00
Ursprung da3e49b54b
Commit 4b1a03e5fb
3 geänderte Dateien mit 73 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,31 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
class ScriptListener_12 {
private ScriptListener_12(){}
static boolean isNoBook(ItemStack item){
return item.getType() != Material.BOOK_AND_QUILL && item.getType() != Material.WRITTEN_BOOK;
}
}

Datei anzeigen

@ -0,0 +1,31 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
class ScriptListener_15 {
private ScriptListener_15(){}
static boolean isNoBook(ItemStack item){
return item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK;
}
}

Datei anzeigen

@ -19,8 +19,8 @@
package de.steamwar.bausystem.world;
import de.steamwar.core.Core;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -39,7 +39,7 @@ public class ScriptListener implements Listener {
return;
ItemStack item = event.getItem();
if(item == null || (item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK) || item.getItemMeta() == null)
if(item == null || isNoBook(item) || item.getItemMeta() == null)
return;
event.setCancelled(true);
@ -53,4 +53,13 @@ public class ScriptListener implements Listener {
}
}
private boolean isNoBook(ItemStack item){
switch(Core.getVersion()){
case 12:
return ScriptListener_12.isNoBook(item);
case 15:
default:
return ScriptListener_15.isNoBook(item);
}
}
}